* update cleaner doxygen.*dot related .cache
[t2sde.git] / package / xorg / xorg-server / xcfgt2.sh
blob15eb4a2adc74f05d18cb1948b5bc6add296c0771
1 #!/bin/bash
2 # --- T2-COPYRIGHT-NOTE-BEGIN ---
3 # T2 SDE: package/*/xorg-server/xcfgt2.sh
4 # Copyright (C) 2005 - 2024 The T2 SDE Project
5 # Copyright (C) 2005 - 2022 Rene Rebe - ExactCODE
6 #
7 # This Copyright note is generated by scripts/Create-CopyPatch,
8 # more information can be found in the files COPYING and README.
9 #
10 # This program is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License version 2.
12 # --- T2-COPYRIGHT-NOTE-END ---
14 # Quick T2 SDE live X driver matching ...
16 var_append() {
17 local x="${3// /}"
18 eval "[ \"\$$1\" ] && $1=\"\${$1}$2\"" || true
19 eval "$1=\"\${$1}\$x\""
22 tmp=`mktemp`
24 echo "XcfgT2 (C) 2005 - 2023 Rene Rebe, ExactCODE"
26 sysid=
27 if [ -d /sys/devices/virtual/dmi/id ]; then
28 for i in sys_vendor product_name chassi_vendor board_name product_serial board_serial; do
29 var_append sysid ':' "$(cat /sys/devices/virtual/dmi/id/$i 2>/dev/null)"
30 done
33 # Apple Inc.:MacBookPro3,1:Apple Inc.:Mac-F4238BC8::
34 # PhoenixAward:945GM:PhoenixAward:945GM:0123456789:
35 # ::IntelCorporation:D945GCLF2::
36 # ASUSTeK Computer INC.:900:ASUSTeK Computer INC.:900:EeePC-1234567890:EeePC
37 echo "SystemID: $sysid"
39 card="`lspci | sed -n 's/.*[^-]VGA[^:]*: //p'`" # not Non-VGA
40 [ "$card" ] || card="`cat /sys/class/graphics/fb0/name 2>/dev/null`"
42 echo "Video card: $card"
44 # defaults
45 depth= # safe default for even older cards
46 # fallback to either vesa or fbdev ...
47 case `uname -m` in
48 i*86*|x86*64) xdrv=vesa ;;
49 *) xdrv=fbdev ;;
50 esac
52 case "${card,,}" in
53 *radeon*) xdrv=radeon ;;
54 *geforce*) xdrv=nouveau ;;
55 *cirrus*) xdrv=cirrus ;;
56 *savage*) xdrv=savage ;;
57 *virge*) xdrv=s3virge ;;
58 ps3*fb) xdrv=fbdev ;;
59 *intel*8*|*intel*9*|*intel*mobile*) xdrv=intel ;;
60 *intel*7*) xdrv=i740 ;;
62 *trident*) xdrv=trident depth=16 ;;
63 *rendition*) xdrv=rendition ;;
64 *neo*) xdrv=neomagic ;;
65 *tseng*) xdrv=tseng ;;
67 *parhelia*) xdrv=mtx ;;
68 *matrox*) xdrv=mga ;;
70 *cyrix*) xdrv=cyrix ;;
71 *silicon\ motion*) xdrv=siliconmotion ;;
72 *chips*) xdrv=chips ;;
74 *3dfx*) xdrv="tdfx" ;;
75 *permedia*|*glint*) xdrv="glint" ;;
77 *vmware*) xdrv="vmware" ;;
78 *qxl*) xdrv="qxl" ;;
80 *ark\ logic*) xdrv="ark" ;;
81 *dec*tga*) xdrv="tga" ;;
83 *national\ semi*|*amd*) xdrv=nsc ;;
85 *ati\ *) xdrv=ati ;;
86 *sis*|*xgi*) xdrv=sis depth=16 ;;
88 *chrome*|*castlerock*) xdrv=openchrome ;;
89 *s3*) xdrv=s3 ;;
91 creator\ 3d|elite\ 3d) xdrv=sunffb ;;
92 bwtwo) xdrv=sunbw2 depth=1 ;;
93 cgthree) xdrv=suncg3 depth=8 ;;
94 gx*|tgx*) xdrv=suncg6 depth=8 ;;
95 cgfourteen) xdrv=suncg6 depth=32 ;;
96 tcx8) xdrv=suntcx depth=8 ;;
97 tcx24) xdrv=suntcx depth=32 ;;
98 *leo) xdrv=sunsun depth=32 ;;
100 # must be last so *nv* does not match one of the above
101 *nv*) xdrv=nv
102 esac
104 # maybe binary nvidia driver?
105 [ "$xdrv" = nv -a -f /usr/X11/lib/xorg/modules/drivers/nvidia_drv.so ] &&
106 xdrv=nvidia
108 cmdline="$(< /proc/cmdline)"
110 # manual override
111 xdriver="xdriver= $cmdline" xdriver=${xdriver##*xdriver=} xdriver=${xdriver%% *}
112 [ "$xdriver" ] && xdrv="$xdriver"
114 case "$xdrv" in
115 fbdev|nv|nvidia|sunffb) depth=24 ;;
116 vmware) depth= ;;
117 esac
119 # manual override
120 xdepth="xdepth= $cmdline" xdepth=${xdepth##*xdepth=} xdepth=${xdepth%% *}
121 [ "$xdepth" ] && depth="$xdepth"
124 # use the nvidia binary only driver - if available ...
125 if [ "$xdrv" = "nvidia" ]; then
126 echo "Installing nvidia GL libraries and headers ..."
127 rm -rf /usr/X11/lib/libGL.*
128 cp -arv /usr/src/nvidia/lib/* /usr/X11/lib/
129 cp -arv /usr/src/nvidia/X11R6/lib/* /usr/X11/lib/
130 cp -arv /usr/src/nvidia/include/* /usr/X11/lib/GL/
131 ln -sf /usr/X11/lib/xorg/modules/extensions/{libglx.so.1.0.*,libglx.so}
133 echo "Updating dynamic library database ..."
134 ldconfig /usr/X11/lib
137 horiz_sync=
138 vert_refresh=
139 modes=
140 ddc=1
142 # manual, boot command line overrides
143 xmodes="xmodes= $cmdline" xmodes=${xmodes##*xmodes=}; xmodes=${xmodes%% *}
144 xddc="xddc= $cmdline" xddc=${xddc##*xddc=}; xddc=${xddc%% *}
146 [ "$xmodes" ] && modes="$(echo $xmodes | sed 's/,/ /g; s/[^ ]\+/"&"/g')"
147 [ "$xddc" ] && ddc="$xddc"
150 # if ddcprobe available, ddc not disabled and no manual modes
151 if type -p ddcprobe > /dev/null && [ "$ddc" = 1 ] && [ -z "$modes" ]; then
152 echo "Probing for DDC information ..."
153 ddcprobe > $tmp
155 if grep -q failed $tmp; then
156 echo "DDC read failed"
157 else
158 defx=`grep "Horizontal blank time" $tmp | cut -d : -f 2 |
159 sort -nu | tail -n 1`
160 defy=`grep "Vertical blank time" $tmp | cut -d : -f 2 |
161 sort -nu | tail -n 1`
163 defx=${defx:-0}
164 defy=${defy:-0}
166 while read m; do
167 x=${m/x*/}
168 y=${m/*x/}
169 if [ $defx -eq 0 -o $x -le $defx ] &&
170 [ $defy -eq 0 -o $y -le $defy ]; then
171 echo "mode $x $y ok"
172 modes="$modes \"${x}x${y}\""
173 else
174 echo "mode $x $y skipped"
176 done < <( grep -A 1000 '^Established' $tmp |
177 grep -B 1000 '^Standard\|^Detailed' |
178 sed -e 's/[\t ]*\([^ ]*\).*/\1/' -e '/^[A-Z]/d' |
179 sort -rn | uniq )
183 # if still no mode try to determine from FB (mostly for
184 # non PC workstations / embedded devices with system FB)
185 if [ -z "$modes" ]; then
186 for mode in `sed -n 's/.:\([[:digit:]]\+x[[:digit:]]\+\)[[:alpha:]]*-[[:digit:]]\+/\1/p' \
187 /sys/class/graphics/fb0/modes 2>/dev/null | sort -r -n -u`; do
188 modes="$modes \"$mode\""
189 done
190 modes="${modes# *}"
193 # still no modes, use backward / safe compatible defaults
194 if [ -z "$modes" ]; then
195 echo "No modes from DDC or FB detection, using defaults!"
196 modes='"1024x768" "800x600" "640x480"'
197 horiz_sync="HorizSync 24.0 - 65.0"
198 vert_refresh="VertRefresh 50 - 75"
202 echo "X Driver: $xdrv"
203 echo "Using modes: $modes"
204 echo " @ depth: $depth"
205 [ "$hoiz_sync" -o "$vert_refresh" ] &&
206 echo " horiz: $horiz_sync" &&
207 echo " vert: $vert_refresh"
209 [ -f /etc/X11/xorg.conf ] && cp /etc/X11/xorg.conf /etc/X11/xorg.conf.bak
211 sed -e "s/\$xdrv/$xdrv/g" -e "s/\$modes/$modes/g" -e "s/\$depth/$depth/g" \
212 -e "s/\$horiz_sync/$horiz_sync/g" \
213 -e "s/\$vert_refresh/$vert_refresh/g" \
214 /etc/X11/xorg.conf.template > /etc/X11/xorg.conf
216 if [ -z "$depth" ]; then
217 sed -i '/DefaultDepth/d' /etc/X11/xorg.conf
220 if [ "$ddc" = 0 ]; then
221 echo "Adding NoDDC option"
222 sed -i 's/.*Ident.*Card.*/&\n Option\t"NoDDC"\n/' /etc/X11/xorg.conf
225 rm $tmp