Magellan Linux

Contents of /alx-src/branches/alxconf-060/bin/alx-hwdetection.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3375 - (show annotations) (download) (as text)
Wed Mar 28 09:56:36 2012 UTC (12 years, 1 month ago) by niro
File MIME type: application/x-sh
File size: 3708 byte(s)
-added detection for a quirk required by some intel framebuffer devices
1 #!/bin/bash
2
3 # hwinfo wrapper to use hwinfo with sudo if requested
4 hwinfo()
5 {
6 local use_sudo=""
7 case ${SUDO} in
8 yes|y|true|1) use_sudo=sudo ;;
9 esac
10
11 ${use_sudo} /usr/sbin/hwinfo $@
12 }
13
14 # get_hwinfo $hw_item
15 get_hwinfo()
16 {
17 local enable_desc="0"
18
19 if [[ $1 = --with-description ]] || [[ $1 = -d ]]
20 then
21 enable_desc=1
22 shift
23 fi
24
25 local item="$1"
26 local all
27 local i
28
29 # handle special items
30 case ${item} in
31 memory) get_hwinfo_memory; return ;;
32 smp) get_hwinfo_smp; return ;;
33 esac
34
35 all=$(hwinfo --short --"${item}")
36
37 declare -i i=0
38 while read device description
39 do
40 # skip the first line
41 (( i++ ))
42 [ ${i} -eq 1 ] && continue
43
44 if [[ ${enable_desc} = 1 ]]
45 then
46 echo "${device};${description}"
47 else
48 echo "${device}"
49 fi
50 done <<< "${all}"
51 }
52
53 # remove_duplicates $list
54 remove_duplicates()
55 {
56 local list="$@"
57 local fixed_list=":"
58 local i
59
60 for i in ${list}
61 do
62 if [[ -z $(echo "${fixed_list}" | fgrep ":${i}:") ]]
63 then
64 fixed_list="${fixed_list}${i}:"
65 fi
66 done
67
68 unset list
69
70 # remove all ':' and show the cleaned list
71 # this way fixes double spaces also
72 local counter
73 declare -i counter=0
74 for i in $(echo ${fixed_list} | sed "s|:| |g")
75 do
76 (( counter++ ))
77 if [[ ${counter} -eq 1 ]]
78 then
79 list="${i}"
80 else
81 list+=" ${i}"
82 fi
83 done
84
85 echo "${list}"
86 }
87
88 get_x11_driver_modules()
89 {
90 local modules
91 modules="$(hwinfo --gfxcard | grep 'XFree86 v4 Server Module:' | sed 's/.*Module:\ \(.*\)/\1/')"
92
93 # use vesa if nothing was found
94 [[ -z ${modules} ]] && modules="vesa"
95
96 # remove duplicates from list and show it
97 remove_duplicates "${modules}"
98 }
99
100 get_drm_driver_modules()
101 {
102 local modules
103 modules="$(hwinfo --gfxcard | grep 'Driver:' | sed 's/.*: \"\(.*\)\"/\1/;q')"
104
105 # use vesa if nothing was found
106 [[ -z ${modules} ]] && modules="uvesafb"
107
108 # remove duplicates from list and show it
109 remove_duplicates "${modules}"
110 }
111
112 get_wlan_driver_modules()
113 {
114 local device="$1"
115 local modules
116
117 if [[ -z ${device} ]]
118 then
119 echo "Error: get_netcard_driver_module(): no device given"
120 return 1
121 fi
122
123 modules=$(hwinfo --wlan | grep -B1 "Device File: ${device}" | sed 's/.*Modules: \"\(.*\)\"/\1/;q')
124 remove_duplicates "${modules}"
125 }
126
127 get_netcard_driver_modules()
128 {
129 local device="$1"
130 local modules
131
132 if [[ -z ${device} ]]
133 then
134 echo "Error: get_netcard_driver_module(): no device given"
135 return 1
136 fi
137
138 modules=$(hwinfo --netcard | grep -B1 "Device File: ${device}" | sed 's/.*Modules: \"\(.*\)\"/\1/;q')
139 remove_duplicates "${modules}"
140 }
141
142 get_system_type()
143 {
144 local hwinfo
145 local systemtype
146
147 hwinfo="$(hwinfo --bios --storage)"
148
149 if [[ ! -z $(echo "${hwinfo}" | grep -i zotac) ]]
150 then
151 systemtype="zotac"
152 elif [[ ! -z $(echo "${hwinfo}" | grep -i CLE266) ]]
153 then
154 systemtype="rangee"
155 elif [[ ! -z $(echo "${hwinfo}" | grep -i i810) ]]
156 then
157 systemtype="maxdata"
158 elif [[ ! -z $(echo "${hwinfo}" | grep -i i815) ]]
159 then
160 systemtype="maxdata"
161 else
162 systemtype="standard"
163 fi
164
165 echo "${systemtype}"
166 }
167
168 intel_framebuffer_quirk_required()
169 {
170 local retval=0
171 local fbdev
172
173 if [[ -e /proc/fb ]]
174 then
175 if [[ ! -z $(grep 'inteldrmfb' /proc/fb) ]]
176 then
177 fbdev=$(grep 'inteldrmfb' /proc/fb | sed 's:\([0-9]\).*:\1:')
178 if [[ ${fbdev} != 0 ]]
179 then
180 retval="${fbdev}"
181 fi
182 fi
183 fi
184
185 echo "${retval}"
186 }
187
188 # debug
189 #echo "LAN: $(get_netcard_driver_modules eth0)"
190 #echo "WLAN: $(get_wlan_driver_modules wlan0)"
191 #echo "X11: $(get_x11_driver_modules)"
192 #echo "KMS/FB: $(get_drm_driver_modules)"
193
194 case $1 in
195 wlan) get_wlan_driver_modules wlan0 ;;
196 lan) get_netcard_driver_modules eth0 ;;
197 vga) get_x11_driver_modules ;;
198 console) get_drm_driver_modules ;;
199 system) get_system_type ;;
200 intel-fb-quirk) intel_framebuffer_quirk_required ;;
201 esac