OSDN Git Service

remove the code to collect module path
[android-x86/bootable-newinstaller.git] / initrd / scripts / 0-auto-detect
1 #
2 # By Chih-Wei Huang <cwhuang@linux.org.tw>
3 # Last updated 2009/07/18
4 #
5 # License: GNU Public License
6 # We explicitely grant the right to use the scripts
7 # with Android-x86 project.
8 #
9
10 # An auto detect function provided by kinneko
11 auto_detect()
12 {
13         tmp=/tmp/dev2mod
14         echo 'dev2mod() { while read dev; do case $dev in' > $tmp
15         sort -r /lib/modules/`uname -r`/modules.alias | \
16                 sed -n 's/^alias  *\([^ ]*\)  *\(.*\)/\1)modprobe \2;;/p' >> $tmp
17         echo 'esac; done; }' >> $tmp
18         source $tmp
19         cat /sys/bus/*/devices/*/modalias | dev2mod
20 }
21
22 # FB0DEV: framebuffer driver
23 # LANDEV: lan driver
24 # WIFDEV: wifi driver
25 # SNDDEV: sound driver
26 # CAMDEV: camera driver
27 # PREDEV: any module the drivers depend on but can't be loaded automatically
28 # EXTMOD: any other module
29
30 get_asus_info()
31 {
32         # common for all Eee PC models
33         [ -c /dev/fb0 ] || FB0DEV=i915
34         EXTMOD=eeepc-laptop
35         PREDEV=snd-hda-codec-realtek
36         SNDDEV=snd-hda-intel
37         CAMDEV=uvcvideo
38
39         board=`cat /sys/class/dmi/id/product_name`
40         # assume Eee PC models
41         case "$board" in
42                 700|701|900)
43                         LANDEV=atl2
44                         WIFDEV=ath5k
45                         ;;
46                 701SD|900SD)
47                         LANDEV=atl1e
48                         WIFDEV=rtl8187se
49                         ;;
50                 900A|904HD|1000HD)
51                         LANDEV=atl1e
52                         WIFDEV=ath5k
53                         ;;
54                 901|1000|1000H)
55                         LANDEV=atl1e
56                         WIFDEV=rt2860sta
57                         ;;
58                 ET1602*)
59                         FB0DEV=
60                         UVESA_MODE=${UVESA_MODE:-1366x768}
61                         LANDEV=r8169
62                         WIFDEV=rt2860sta
63                         ;;
64                 T91)
65                         FB0DEV=
66                         UVESA_MODE=${UVESA_MODE:-1024x600}
67                         LANDEV=atl1e
68                         WIFDEV=ath9k
69                         ;;
70                 A6VM*)
71                         EXTMOD=asus-laptop
72                         LANDEV=skge
73                         WIFDEV=ipw2200
74                         ;;
75                 *)
76                         LANDEV=atl1e
77                         WIFDEV=ath9k
78                         ;;
79         esac
80 }
81
82 get_vbox_info()
83 {
84         LANDEV=pcnet32
85         SNDDEV="snd-sb16 isapnp=0 irq=5"
86 }
87
88 get_qemu_info()
89 {
90         LANDEV=8139cp
91         SNDDEV=snd-ens1370
92 }
93
94 get_vmware_info()
95 {
96         LANDEV=pcnet32
97         SNDDEV=snd-ens1371
98 }
99
100 check_product()
101 {
102         grep -q "$1" /sys/class/dmi/id/uevent
103 }
104
105 detect_hardware()
106 {
107         check_product ASUSTeK && get_asus_info && return 0
108         check_product Acer.*AO && get_ao_info && return 0
109         check_product VirtualBox && get_vbox_info && return 0
110         check_product QEMU && get_qemu_info && return 0
111         check_product VMware && get_vmware_info && return 0
112 }
113
114 find_wifi_dev_name()
115 {
116         for wifi in `ls /sys/class/net`; do
117                 w=/sys/class/net/$wifi
118                 if [ -d $w/wireless ] || [ -d $w/phy80211 ]; then
119                         sed -i "s|\(^ *service wpa_supplicant .*\)\(-i.*\)\( -c.*$\)|\1-i $wifi\3|g; \
120                                 s|\(^ *service dhcpcd /system/bin/dhcpcd \)\(.*\)$|\1$wifi|g" init.rc
121                         break
122                 fi
123         done
124 }
125
126 load_modules()
127 {
128         [ -z "$AUTO" ] && detect_hardware
129         if [ $? -eq 0 ]; then
130                 for m in $PREDEV $EXTMOD; do
131                         modprobe $m
132                 done
133                 [ -n "$FB0DEV" -a -z "$UVESA_MODE" ] && modprobe $FB0DEV
134                 [ -n "$LANDEV" ] && modprobe $LANDEV
135                 [ -n "$WIFDEV" ] && modprobe $WIFDEV
136                 [ -n "$SNDDEV" ] && modprobe $SNDDEV
137                 [ -n "$CAMDEV" ] && modprobe $CAMDEV
138         else
139                 auto_detect
140         fi
141
142         mdev -s
143         [ -d /proc/asound/card0 ] || modprobe snd-dummy
144         [ -c /dev/fb0 ] || modprobe uvesafb mode_option=${UVESA_MODE:-800x600}-16 ${UVESA_OPTION:-mtrr=3 scroll=ywrap}
145
146         find_wifi_dev_name
147 }