| 1 |
#!/bin/sh |
| 2 |
|
| 3 |
PREREQ="" |
| 4 |
prereqs() |
| 5 |
{ |
| 6 |
echo "$PREREQ" |
| 7 |
} |
| 8 |
case $1 in |
| 9 |
# get pre-requisites |
| 10 |
prereqs) |
| 11 |
prereqs |
| 12 |
exit 0 |
| 13 |
;; |
| 14 |
esac |
| 15 |
|
| 16 |
|
| 17 |
# The options part of the kernel "video=" argument (i.e. everyting |
| 18 |
# after "video=<fbdriver>:") has very inconsistent rules. |
| 19 |
# |
| 20 |
# Generally the following applies: |
| 21 |
# 1) options are comma-separated |
| 22 |
# 2) options can be in either of these three forms: |
| 23 |
# <arg>=<value>, <arg>:<value>, <boolean-arg>. |
| 24 |
# 3) the "mode" or "mode_option" option (name depends on the framebuffer driver) |
| 25 |
# has the form <xres>x<yres>[M][R][-<bpp>][@<refresh>][i][m] |
| 26 |
# and may or may not start with "mode=" or "mode_option=" |
| 27 |
# -> please adjust as necessary in the parse_video_opts() function |
| 28 |
# |
| 29 |
# When the options are used with modules, they need to be space-separated |
| 30 |
# and the following conversions are needed: |
| 31 |
# <arg>:<value> -> <arg>=<value> |
| 32 |
# <boolean-arg> -> <boolean-arg>=1 |
| 33 |
# <modevalue> -> mode=<modevalue> or mode_option=<modevalue> |
| 34 |
parse_video_opts() |
| 35 |
{ |
| 36 |
local OPTS="$1" |
| 37 |
local IFS="," |
| 38 |
|
| 39 |
# Must be a line like video=<fbdriver>:<opt1>,[opt2]... |
| 40 |
if [ "${OPTS}" = "${OPTS%%:*}" ]; then |
| 41 |
return |
| 42 |
fi |
| 43 |
OPTS="${OPTS#*:}" |
| 44 |
for opt in ${OPTS}; do |
| 45 |
# Already in the "<arg>=<value>" form |
| 46 |
if [ "${opt}" != "${opt#*=}" ]; then |
| 47 |
printf "%s" "$opt " |
| 48 |
# In the "<arg>:<value>" form |
| 49 |
elif [ "${opt}" != "${opt#*:}" ]; then |
| 50 |
printf "%s" "${opt%:*}=${opt#*:} " |
| 51 |
# Presumably a modevalue without the "mode=" prefix |
| 52 |
elif [ "${opt}" != "${opt#[0-9]*x[0-9]}" ]; then |
| 53 |
# Adjust: mode= option? |
| 54 |
printf "%s" "mode=$opt " |
| 55 |
# ... or mode_option= option? |
| 56 |
# printf "%s" "mode_option=$opt " |
| 57 |
# Presumably a boolean |
| 58 |
else |
| 59 |
printf "%s" "${opt}=1 " |
| 60 |
fi |
| 61 |
done |
| 62 |
} |
| 63 |
|
| 64 |
FB="" |
| 65 |
OPTS="" |
| 66 |
|
| 67 |
# shellcheck disable=SC2013 |
| 68 |
for x in $(cat /proc/cmdline); do |
| 69 |
case ${x} in |
| 70 |
vga=*) |
| 71 |
FB="vesafb"; |
| 72 |
OPTS=""; |
| 73 |
;; |
| 74 |
video=*) |
| 75 |
FB=${x#*=} |
| 76 |
FB="${FB%%:*}" |
| 77 |
OPTS="$(parse_video_opts "${x}")" |
| 78 |
esac |
| 79 |
done |
| 80 |
|
| 81 |
# Module-specific workarounds |
| 82 |
case ${FB} in |
| 83 |
matroxfb) |
| 84 |
# Map command line name to module name |
| 85 |
FB=matroxfb_base |
| 86 |
;; |
| 87 |
intelfb|i810fb|i915) |
| 88 |
# Needs AGP driver loaded |
| 89 |
/sbin/modprobe intel-agp |
| 90 |
;; |
| 91 |
uvesafb) |
| 92 |
# v86d requires /dev/zero and dev/mem, but udev haven't been started yet |
| 93 |
[ -e /dev/zero ] || mknod -m 0666 /dev/zero c 1 5 |
| 94 |
[ -e /dev/mem ] || mknod -m 0640 /dev/mem c 1 1 |
| 95 |
;; |
| 96 |
*) |
| 97 |
;; |
| 98 |
esac |
| 99 |
|
| 100 |
if [ -n "${FB}" ]; then |
| 101 |
unset MODPROBE_OPTIONS |
| 102 |
/sbin/modprobe -q fbcon |
| 103 |
# shellcheck disable=SC2086 |
| 104 |
/sbin/modprobe -q ${FB} ${OPTS} |
| 105 |
fi |
| 106 |
|
| 107 |
if [ -e /proc/fb ]; then |
| 108 |
# shellcheck disable=SC2034 |
| 109 |
while read -r fbno desc; do |
| 110 |
if [ $((fbno < 32)) ]; then |
| 111 |
mknod -m 0640 "/dev/fb${fbno}" c 29 "${fbno}" |
| 112 |
fi |
| 113 |
done < /proc/fb |
| 114 |
else |
| 115 |
mknod -m 0640 /dev/fb0 c 29 0 |
| 116 |
fi |