4 source /sbin/functions.sh
6 # First, get the command line
7 CMDLINE="$(</proc/cmdline)"
9 # Most of this if for MIPS, except for the last one, which is for everything
10 # else to select a default resolution. Since the MIPS configs are ready to be
11 # used by default, we exit after calling a MIPS config.
16 # Newport for now, IP22 Impact later
17 if [ ! -z "$(grep 'SGI Indigo2' /proc/cpuinfo)" ]
19 sed -e '/^#@@@/s:\(^#@@@\|@@@$\)::g' \
20 /etc/X11/xorg.conf.newport > /etc/X11/xorg.conf
25 # This might support Newport too, but I2 Newport boards are rare.
26 cp -f /etc/X11/xorg.conf.impact /etc/X11/xorg.conf
31 # Figure out if we're Impact, or VPro (Odyssey)
32 if [ -e "/proc/fb" ]; then
33 ip30_impact="$(grep -i 'impact' /proc/fb)"
34 ip30_odyssey="$(grep -i 'odyssey' /proc/fb)"
35 if [ -n "${ip30_impact}" ]
37 cp -f /etc/X11/xorg.conf.impact /etc/X11/xorg.conf
38 elif [ -n "${ip30_odyssey}" ]
40 # Do nothing for now -- maybe one day we'll get an X driver
41 # cp -f /etc/X11/xorg.conf.odyssey /etc/X11/xorg.conf
42 ewarn "Currently, there is no X driver for Odyssey"
48 # We use fbdev for now -- maybe one day we'll get a gbefb X driver
49 cp -f /etc/X11/xorg.conf.o2-fbdev /etc/X11/xorg.conf
53 # We got a resolution on the command line, use it.
54 NEWMODE=$(echo ${x} | cut -d= -f2)
55 RAWMODES="\"${NEWMODE}\""
59 TMPFILE="/tmp/mkxf86config-$$"
60 MONITORTMP="${TMPFILE}-monitor"
62 rm -f "${TMPFILE}" "${MONITORTMP}"
64 # Read in what hwsetup has found for X
65 [ -f /etc/sysconfig/xserver ] && . /etc/sysconfig/xserver
67 WHEEL='s|"PS/2"|"auto"\
68 Option "ZAxisMapping" "4 5"|g;'
71 [ -f /etc/sysconfig/gentoo ] && . /etc/sysconfig/gentoo
73 # Read default keyboard from config file.
74 # There seems to be no reliable autoprobe possible.
75 [ -f /etc/sysconfig/keyboard ] && . /etc/sysconfig/keyboard
77 # Create mouse link and insert a mouse default type into xorg.conf
78 # if not already done by hwsetup
79 [ -f /etc/sysconfig/mouse ] && . /etc/sysconfig/mouse
80 # We create this link since hwsetup cannot properly detect serial mice
81 [ -e /dev/mouse ] || ln -sf /dev/ttyS0 /dev/mouse
83 PROTO="${XMOUSETYPE:-Microsoft}"
85 [ "${XEMU3}" = "no" ] && NOEMU='s|^.*Emulate3|# No 2 -> 3 Button emulation|g'
88 [ "${XKEYBOARD}" = "de" ] || DEADKEYS='s|^.*nodeadkeys.*$||g;'
90 if [ -n "${XMODULE}" ]
92 # Check for Framebuffer X-Modules and initialize framebuffer module
95 modprobe "${XMODULE}" >/dev/null 2>&1
101 # We used to use ddcxinfo-knoppix for monitor information, now we will just let
102 # X choose for itself. This will probably break older machines.
103 # You can uncomment the following to re-enable dccxinfo-knoppix, but this only
105 #MONITOR="$(ddcxinfo-knoppix -monitor)"
106 # Here we are setting a default set of HorizSync and VertRefresh. These are
107 # "safe" values. I am hoping to remove this completely in the future once more
108 # testing has been done on alternate architectures.
109 MONITOR='Section "Monitor"
110 Identifier "Monitor0"
111 HorizSync 28.0 - 96.0
112 VertRefresh 50.0 - 75.0
115 COMPLETE="$(awk '/EndSection/{print}' <<EOF
120 # Extract values for display
121 MODEL="$(awk '/^[ ]*ModelName/{print;exit}'<<EOF
129 HREFRESH="$(awk '/^[ ]*HorizSync/{print $2 $3 $4; exit}'<<EOF
134 VREFRESH="$(awk '/^[ ]*VertRefresh/{print $2 $3 $4; exit}'<<EOF
139 # Build line of allowed modes
140 # This is created from the Modelines created by ddcxinfo-knoppix and is not
141 # always accurate for your monitor. This is currently set statically to give
142 # working support for alpha/amd64/ppc/x86 for the 2007.0 Gentoo release. If
143 # anyone has more reliable, cross-platform methods, I'm all ears.
144 #RAWMODES=$(ddcxinfo-knoppix -monitor | grep ModeLine | sed -r "s/.*\"([0-9]+x[0-9]+)\".*/\1/g"| sort -rg | uniq | xargs echo | sed -r "s/([0-9]+x[0-9]+)/\"\1\"/g")
145 [ -z "${RAWMODES}" ] && RAWMODES="\"1024x768\" \"800x600\" \"640x480\""
146 MODES="Modes ${RAWMODES}"
148 # We need to check this because serial mice have long timeouts
149 SERIALMOUSE="$(ls -l1 /dev/mouse* 2>/dev/null | awk '/ttyS/{print $NF ; exit 0}')"
150 if [ -n "${SERIALMOUSE}" ]
152 SERIALMOUSE="s|/dev/ttyS0|${SERIALMOUSE}|g;"
154 SERIALMOUSE='s|^.*InputDevice.*"Serial Mouse".*$|# Serial Mouse not detected|g;'
157 # PS/2 bug: Some keyboards are incorrectly used as mice in XFree. :-(
158 PSMOUSE="$(ls -l1 /dev/mouse* 2>/dev/null | awk '/input/{print $NF ; exit 0}')"
159 if [ -n "${PSMOUSE}" ]
163 PSMOUSE='s|^.*InputDevice.*"PS/2 Mouse".*$|# PS/2 Mouse not detected|g;'
166 case "$(cat /proc/modules)" in
167 *usbmouse*|*mousedev*|*hid\ *)
171 USBMOUSE='s|^.*InputDevice.*"USB Mouse".*$|# USB Mouse not detected|g;'
175 # Kernel 2.6 reports psaux via /dev/input/mice like USB
176 case "$(uname -r)" in
178 if [ -n "${PSMOUSE}" ]
180 PSMOUSE='s|^.*InputDevice.*"PS/2 Mouse".*$|# PS/2 Mouse using /dev/input/mice in Kernel 2.6|g;'
186 if [ -a /proc/bus/input/devices ]
188 CHECK=$(cat /proc/bus/input/devices | grep -i synaptics | wc -l)
189 if [ ${CHECK} -gt 0 ]
192 SYNDEV=/dev/input/$(cat /proc/bus/input/devices | egrep -i -A 5 "^N: .*synaptics.*" | grep Handlers | sed -r "s/.*(event[0-9]+).*/\1/g")
195 SYNMOUSE='s|^.*InputDevice.*"Synaptics".*$|#No Synaptics touchpad found|g;'
199 # Write Monitor data now
200 rm -f "${MONITORTMP}"
201 echo "${MONITOR}" > "${MONITORTMP}"
203 # Intel drivers have been renamed
204 if [ "${XMODULE}" = 'i810' ]
209 # VMWare special handling
212 if [ "${XMODULE}" = "vmware" ]
214 VMWARE='s|^.*BusID.*PCI.*$|BusID "PCI:0:15:0"|g;'
215 DEPTH='s|DefaultColorDepth |# DefaultColorDepth |g;'
216 if [ -e /usr/lib/xorg/modules/input/vmmouse_drv.so ] || \
217 [ -e /usr/lib/modules/input/vmmouse_drv.so ]
219 MOUSEDRIVER='s|^.*Driver.*"mouse".*$|\tDriver\t"vmmouse"|g;'
223 #VirtualPC special handline
225 if [ "${XMODULE}" = "s3" ]
227 VPC='s|^.*BusID.*PCI.*$|BusID "PCI:0:8:0"|g;'
228 DEPTH='s|DefaultColorDepth 24|DefaultColorDepth 16|g;'
231 # If we don't have a XMODULE set, use fbdev as fall-back
233 #[ -z "${XMODULE}" [ -z "${XMODULE}" ] ] && XMODULE="fbdev"] && XMODULE="fbdev" XMODULE="vesa"
234 [ -z "${XMODULE}" ] && XMODULE="vesa"
236 # Do NOT use a default colordepth setting if we are using the "fbdev" module
237 if [ "${XMODULE}" = "fbdev" ]
239 DEPTH='s|DefaultColorDepth |# DefaultColorDepth |g;'
242 # These drivers need the sw_cursor option
247 SWCURSOR='s|^.*#Option.*"sw_cursor".*$|Option "sw_cursor"|g;'
250 SWCURSOR='s|^.*#Option.*"sw_cursor".*$|Option "sw_cursor"|g;'
251 MONITORLAYOUT='s|^.*#Option.*"MonitorLayout".*$|Option "MonitorLayout"|g;'
255 # We must use NoPM, because some machines freeze if Power management is beingi
260 #checkbootparam noapm && NOPM='Option "NoPM" "true"' || DPMS='Option "DPMS" "true"'
262 sed -e 's|@@PROTOCOL@@|'"${PROTO}"'|g;'"${NOEMU}" \
263 -e '/@@MONITOR@@/r '"${MONITORTMP}" \
264 -e 's|@@MONITOR@@||g' \
265 -e 's|@@NOPM@@|'"${NOPM}"'|g' \
266 -e 's|@@XMODULE@@|'"${XMODULE}"'|g;'"${VMWARE}""${VPC}""${SERIALMOUSE}""${USBMOUSE}""${PSMOUSE}""${SWCURSOR}""${MONITORLAYOUT}""${WHEEL}""${SYNMOUSE}""${MOUSEDRIVER}" \
267 -e 's|@@SYNDEV@@|'"${SYNDEV}"'|g' \
268 -e 's|@@MODES@@|'"${MODES}"'|g;'"${DEPTH}" \
269 -e 's|"XkbLayout" *"[^"]*"|"XkbLayout" "'"${XKEYBOARD}"'"|g;'"${DEADKEYS}" \
270 /etc/X11/xorg.conf.in >/etc/X11/xorg.conf
274 if [ -f /etc/X11/xorg.conf ]
276 sed -e 's|Identifier[ ]*"Monitor0"|Identifier "Monitor0"\
277 '"${DPMS}"'|g' /etc/X11/xorg.conf >/etc/X11/xorg.conf.new
278 mv -f /etc/X11/xorg.conf.new /etc/X11/xorg.conf
282 rm -f "${TMPFILE}" "${MONITORTMP}" 2>/dev/null
284 # Print info about selected X-Server
285 [ -n "${XDESC}" ] || XDESC="(yet) unknown card"
286 echo -n " ${GOOD}Video is"
288 [ -n "${XDESC}" ] && echo -n " ${HILITE}${XDESC}${NORMAL},"
289 echo -n " using ${GOOD}${XSERVER:-generic VESA}"
290 [ -n "${XMODULE}" ] && echo -n "(${HILITE}${XMODULE}${NORMAL})"
291 echo " Server${NORMAL}"
293 echo -n " ${GOOD}Monitor is ${HILITE}${MODEL:-Generic Monitor}${NORMAL}"
294 [ -n "${HREFRESH}" -a -n "${VREFRESH}" ] && echo "${GOOD}, ${GOOD}H:${HILITE}${HREFRESH}kHz${GOOD}, V:${HILITE}${VREFRESH}Hz${NORMAL}" || echo ""
295 [ -n "${XVREFRESH}" ] && echo " ${GOOD}Trying specified vrefresh rate of ${HILITE}${XVREFRESH}Hz.${NORMAL}"
297 [ -n "${MODES}" ] && echo " ${GOOD}Using Modes ${HILITE}${MODES##Modes }${NORMAL}"