[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#386441: initramfs-tools: Support custom framebuffer modules



On Mon, 11 Sep 2006, David Härdeman wrote:

> 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.

ok thanks!
 
> -- 
> David Härdeman

> #!/bin/sh
> 
> PREREQ=""
> prereqs()
> {
> 	echo "$PREREQ"
> }
> case $1 in
> # get pre-requisites
> prereqs)
> 	prereqs
> 	exit 0
> 	;;
> esac
> 
> parse_kernel_opts()
i'll make that
parse_video_opts()
as it's specific to that, rootnfs opts are very different for example.
> {
> 	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 "
you can use printf as regex replacement,
it's both in dash as in ash, see load_modules()
from scripts/functions
> 		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

i'll test it out for the 0.80 release, seems very valuable indeed.

-- 
maks



Reply to: