On Fri, Sep 08, 2006 at 08:09:15AM +0200, Sven Luther wrote:
On Fri, Sep 08, 2006 at 01:05:57AM +0200, maximilian attems wrote:
On Thu, 07 Sep 2006, David Härdeman wrote:

> Package: initramfs-tools
> Version: 0.78
> Severity: minor
> Tags: patch
> > The attached patch adds support for the "video" kernel parameter to the > framebuffer script. This allows for the use of non-vesa/vga framebuffer > drivers and at the same time simplifies the logic a bit.

looks good, need to merge anyway the improvement by mjg59
in ubuntu to add fb unconditionaly, although i don't know
yet the reason of his change.
nitpicking below.

Notice that on some arches, like powerpc, many of those fbdev drivers are
builtin.

I've attached a new version of the script (which I haven't had time to test yet). It should work properly with builtin or modular fb drivers and also support the extra options which can be passed to fb modules via the kernel command line.

--
David Härdeman
#!/bin/sh

PREREQ=""
prereqs()
{
        echo "$PREREQ"
}
case $1 in
# get pre-requisites
prereqs)
        prereqs
        exit 0
        ;;
esac

parse_kernel_opts()
{
        local OPTS="$1"
        local IFS=","

        # Must be a line like video=<fbdriver>:<opt1>,[opt2]...
        if [ "$OPTS" = "${OPTS%%:*}" ]; then
                return
        fi
        OPTS="${OPTS#*:}"

        # The options part of the kernel "video=" argument (i.e. everyting
        # after "video=<fbdriver>:") has very inconsistent rules.
        #
        # Generally the following applies:
        # 1) options are comma-separated
        # 2) options can be in either of these three forms:
        #       <arg>=<value>
        #       <arg>:<value>
        #       <boolean-arg>
        # 3) the "mode" option has the form 
<xres>x<yres>[M][R][-<bpp>][@<refresh>][i][m]
        #    and may or may not start with "mode="
        #
        # When the options are used with modules, they need to be 
space-separated
        # and the following conversions are needed:
        #       <arg>:<value> -> <arg>=<value>
        #       <boolean-arg> -> <boolean-arg>=1
        #       <modevalue>   -> mode=<modevalue>

        for opt in $OPTS; do
                if [ "$opt" != "${opt#*=}" ]; then
                        # Already in the "<arg>=<value>" form
                        echo -n "$opt "
                elif [ "$opt" != "${opt#[[:digit:]]*x[[:digit:]]}"; then
                        # Sadly no regexps are available
                        # but presumably a modevalue without the "mode=" prefix
                        echo -n "mode=$opt "
                else
                        # Presumably a boolean
                        echo -n "$opt=1 "
                fi
        done
}

FB=""
OPTS=""

for x in $(cat /proc/cmdline); do
        case $x in
        splash*)
                # Let the other options take precedent
                if [ -z "$FB" ]; then
                        FB="vga16fb"
                        OPTS=""
                fi
                ;;
        vga=*)
                FB="vesafb"
                OPTS=""
                ;;
        video=*)
                TMP=${x#*=}
                FB="${TMP%%:*}"
                OPTS="$(parse_kernel_opts "$TMP")"
                ;;
        esac
done

if [ -n "$FB" ]; then
        modprobe -q $FB $OPTS
fi

if [ -e /proc/fb ]; then
        while read fbno desc; do
                mknod /dev/fb$fbno 29 $fbno
        done < /proc/fb

        for i in 0 1 2 3 4 5 6 7 8; do
                mknod /dev/tty$i c 4 $i
        done
fi

Reply via email to