Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5585 - (hide annotations) (download) (as text)
Wed Apr 23 13:18:35 2014 UTC (10 years ago) by niro
File MIME type: application/x-sh
File size: 3967 byte(s)
added a hotfix for i845 devices to fix graphic issues by using the x11 vesa driver
1 niro 2622 #!/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 niro 4912 # use openchrome module on dell optiplex fx130
97     if [[ ! -z $(hwinfo --bios | grep -i -A1 dell | grep -i fx130) ]]
98     then
99     modules="${modules//unichrome/openchrome}"
100     fi
101    
102 niro 2622 # remove duplicates from list and show it
103     remove_duplicates "${modules}"
104     }
105    
106     get_drm_driver_modules()
107     {
108     local modules
109     modules="$(hwinfo --gfxcard | grep 'Driver:' | sed 's/.*: \"\(.*\)\"/\1/;q')"
110    
111     # use vesa if nothing was found
112     [[ -z ${modules} ]] && modules="uvesafb"
113    
114     # remove duplicates from list and show it
115     remove_duplicates "${modules}"
116     }
117    
118     get_wlan_driver_modules()
119     {
120     local device="$1"
121     local modules
122    
123     if [[ -z ${device} ]]
124     then
125     echo "Error: get_netcard_driver_module(): no device given"
126     return 1
127     fi
128    
129     modules=$(hwinfo --wlan | grep -B1 "Device File: ${device}" | sed 's/.*Modules: \"\(.*\)\"/\1/;q')
130     remove_duplicates "${modules}"
131     }
132    
133     get_netcard_driver_modules()
134     {
135     local device="$1"
136     local modules
137    
138     if [[ -z ${device} ]]
139     then
140     echo "Error: get_netcard_driver_module(): no device given"
141     return 1
142     fi
143    
144     modules=$(hwinfo --netcard | grep -B1 "Device File: ${device}" | sed 's/.*Modules: \"\(.*\)\"/\1/;q')
145     remove_duplicates "${modules}"
146     }
147    
148 niro 3201 get_system_type()
149     {
150     local hwinfo
151     local systemtype
152    
153 niro 5585 hwinfo="$(hwinfo --bios --storage --gfxcard)"
154 niro 3201
155     if [[ ! -z $(echo "${hwinfo}" | grep -i zotac) ]]
156     then
157     systemtype="zotac"
158     elif [[ ! -z $(echo "${hwinfo}" | grep -i CLE266) ]]
159     then
160     systemtype="rangee"
161 niro 3259 elif [[ ! -z $(echo "${hwinfo}" | grep -i i810) ]]
162     then
163     systemtype="maxdata"
164     elif [[ ! -z $(echo "${hwinfo}" | grep -i i815) ]]
165     then
166     systemtype="maxdata"
167 niro 5585 elif [[ ! -z $(echo "${hwinfo}" | grep -i i845) ]]
168     then
169     systemtype="i845"
170 niro 3201 else
171     systemtype="standard"
172     fi
173    
174     echo "${systemtype}"
175     }
176    
177 niro 3375 intel_framebuffer_quirk_required()
178     {
179     local retval=0
180     local fbdev
181    
182     if [[ -e /proc/fb ]]
183     then
184     if [[ ! -z $(grep 'inteldrmfb' /proc/fb) ]]
185     then
186     fbdev=$(grep 'inteldrmfb' /proc/fb | sed 's:\([0-9]\).*:\1:')
187     if [[ ${fbdev} != 0 ]]
188     then
189     retval="${fbdev}"
190     fi
191     fi
192     fi
193    
194     echo "${retval}"
195     }
196    
197 niro 2622 # debug
198     #echo "LAN: $(get_netcard_driver_modules eth0)"
199     #echo "WLAN: $(get_wlan_driver_modules wlan0)"
200     #echo "X11: $(get_x11_driver_modules)"
201     #echo "KMS/FB: $(get_drm_driver_modules)"
202    
203     case $1 in
204     wlan) get_wlan_driver_modules wlan0 ;;
205     lan) get_netcard_driver_modules eth0 ;;
206     vga) get_x11_driver_modules ;;
207     console) get_drm_driver_modules ;;
208 niro 3201 system) get_system_type ;;
209 niro 3375 intel-fb-quirk) intel_framebuffer_quirk_required ;;
210 niro 2622 esac