summaryrefslogtreecommitdiffstats
path: root/initramfs/initrd-stuff/bin/xconfig
blob: dce2a68fea33fce79290c070709fe3fd6805be14 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
#!/bin/ash
iscrt () {
local dim=$1
local year=$2
local crt="CRT Generic"
# sub 17" displays
if [ $dim -lt 750 ] ; then
  # modern crt should have a size of 17"+
  if [ $year -gt 1998 ] ; then crt="TFT 4:3 <17inch" ; fi
# 17" crt displays, little bit smaller than tfts
elif [ $dim -lt 900 ] ; then
  crt="CRT 17inch"
  echo "1280x1024\n1152x864" > /tmp/res
# 19" crt / sub 19" tft
elif [ $dim -lt 1000 ] ; then
  if [ $year -lt 2001 ] ; then
    crt="CRT 19inch"
    echo "1400x1050\n1280x1024\n1152x864" > /tmp/res
  else
    crt="TFT 4:3 17inch"
  fi
# 18/19" tft displays (available after 2001)
elif [ $dim -lt 1200 ] ; then  
  if [ $year -ge 2002 ] ; then
    crt="TFT 4:3 18+inch"
  else
    crt="CRT 20inch"
    echo "1400x1050\n1280x1024\n1152x864" > /tmp/res
  fi
# sub 22" displays are crts if older than 2004 :)
elif [ $dim -lt 1300 ] ; then
  if [ $year -ge 2004 ] ; then
    crt="TFT 4:3 19+inch"
  else
    crt="CRT 20+inch"
    echo "1600x1200\n1400x1050\n1280x1024\n1152x864" > /tmp/res
  fi
# any bigger display is most probably a tft
elif [ $year -ge 2004 ] ; then
  crt="TFT 4:3 22+inch"
fi
echo "$crt"
}
xfc=xorg
echo -e '
Section "Files"
EndSection
Section "Module"
  Load         "i2c"
  Load         "bitmap"
  Load         "ddc"
  Load         "extmod"
  Load         "freetype"
  Load         "int10"
  Load         "vbe"
EndSection
Section "InputDevice"
  Identifier "Generic Keyboard"
  Driver       "kbd"
  Option       "CoreKeyboard"
  Option       "XkbRules"          "xorg"
  Option       "XkbModel"          "pc105"
  Option       "XkbLayout"         "de"
  Option       "XkbVariant"        "nodeadkeys"
EndSection
Section "InputDevice"
  Identifier   "Generic Mouse"
  Driver       "mouse"
  Option       "CorePointer"
  Option       "Device"            "/dev/input/mice"
  Option       "Protocol"          "ImPS/2"
  Option       "ZAxisMapping"      "4 5"
  Option       "Emulate3Buttons"   "true"
EndSection
Section "InputDevice"
  Driver       "wacom"
  Identifier   "stylus"
  Option       "Device"            "/dev/input/wacom"
  Option       "Type"              "stylus"
  Option       "ForceDevice"       "ISDV4"         # Tablet PC ONLY
EndSection
Section "InputDevice"
  Driver       "wacom"
  Identifier   "eraser"
  Option       "Device"            "/dev/input/wacom"
  Option       "Type"              "eraser"
  Option       "ForceDevice"       "ISDV4"         # Tablet PC ONLY
EndSection
Section "InputDevice"
  Driver       "wacom"
  Identifier   "cursor"
  Option       "Device"            "/dev/input/wacom"
  Option       "Type"              "cursor"
  Option       "ForceDevice"       "ISDV4"         # Tablet PC ONLY
EndSection
Section "Device"
  Identifier   "Generic Video Card"
  Driver       "vesa"
EndSection
Section "Monitor"
  Identifier   "Generic Display"
  Option       "DPMS"
EndSection
Section "Screen"
  Identifier   "Default Screen"
  Device       "Generic Video Card"
  Monitor      "Generic Display"
  DefaultDepth 24
  SubSection "Display"
    Depth        24
    Modes        "1024x768" "800x600"
  EndSubSection
EndSection
Section "ServerLayout"
  Identifier   "Default Layout"
  Screen       "Default Screen"
  InputDevice  "Generic Keyboard"
  InputDevice  "Configured Mouse"
  InputDevice  "stylus"            "SendCoreEvents"
  InputDevice  "cursor"            "SendCoreEvents"
  InputDevice  "eraser"            "SendCoreEvents"
EndSection
Section "DRI"
  Mode    0666
EndSection
'> /tmp/$xfc

rm /tmp/res
cat $1|sed "/mode: /d"|while read line ; do 
	case $line in
	  ctiming*|dtiming*)
            Res=$(echo $line|sed "s/.*:\ //;s/@.*//")
            Width=${Res%%x*}
            Height=${Res##*x}
	    # we need exact resolutions for tft displays only
            [ "${IsCrt%% *}" = "TFT" -a $((${Width}00 / ${Height})) -ge 125 ] &&  echo $Res >> /tmp/res
            [ "x${VendorName}" = "x" ] && VendorName="No vendor string detected" 
            grep ModelName /tmp/$xfc 2>&1 >/dev/null || \
              sed -e "/Section \"Monitor\"/a\ \ ModelName    \"Display - ${IsCrt}\"" \
                  -e "/Section \"Device\"/a\ \ VendorName   \"${VendorName}\"" \
                  -i /tmp/$xfc	  
          ;;
	  monitorname*|monitorid*)
            [ "x${line##monitor*:}" = "x" ] || sed "s/Display - /${line##monitor*: } - /" -i /tmp/$xfc
	  ;;
          product*)
            [ "$line" != "product:" ] && \
              sed "/Section \"Device\"/a\ \ BoardName    \"${line##product: }\"" \
                -i /tmp/$xfc
          ;;
	  oem*|vendor*)
            [ "x${line##?e*:}" = "x" ] || VendorName="${line##?e*: }"
          ;;
	  manufacture*)
	    Year=${line##* }
	  ;;
	  screensize*)
	    Dim=${line##screensize: }
            Width=${Dim%% *}
            Height=${Dim##* }
            Dim=$(($Width * $Height))
	    # check for geometry - no crt if no 4:3 ratio
	    if [ $((${Width}00 / $((${Height} + 1 )))) -lt 140 ] ; then
 	      IsCrt="$(iscrt $Dim $Year)"
 	    else
 	      IsCrt="TFT WideScreen"
 	    fi
          ;;
	esac
done
for line in `sort -run /tmp/res` ; do Modes="$Modes \"$line\""; done
sed "s/Modes        \"/Modes       ${Modes} \"/" -i /tmp/$xfc