OSDN Git Service

avoid to use pseudo device node with dhcpcd
[android-x86/bootable-newinstaller.git] / initrd / scripts / 0-auto-detect
1 #
2 # By Chih-Wei Huang <cwhuang@linux.org.tw>
3 # Last updated 2009/08/14
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 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 vbox_info()
83 {
84         LANDEV=pcnet32
85         SNDDEV="snd-sb16 isapnp=0 irq=5"
86         VESA=1
87 }
88
89 qemu_info()
90 {
91         LANDEV=8139cp
92         SNDDEV=snd-ens1370
93 }
94
95 vmware_info()
96 {
97         LANDEV=pcnet32
98         SNDDEV=snd-ens1371
99 }
100
101 detect_hardware()
102 {
103         [ "$AUTO" = "1" ] && return
104         case "`cat /sys/class/dmi/id/uevent`" in
105                 *ASUSTeK*)
106                         get_info=asus_info
107                         ;;
108                 *Acer*AO*)
109                         get_info=ao_info
110                         ;;
111                 *VirtualBox*)
112                         get_info=vbox_info
113                         ;;
114                 *QEMU*)
115                         get_info=qemu_info
116                         ;;
117                 *VMware*)
118                         get_info=vmware_info
119                         ;;
120                 *)
121                         ;;
122         esac
123         [ -n "$get_info" ] && $get_info && FOUND=1
124 }
125
126 find_network_dev_name()
127 {
128         wififound=0
129         rmline=`grep -n "#REMOVE FROM HERE" init.rc|cut -d':' -f1`
130         rmline=`expr $rmline + 1`
131         sed -i -e "$rmline,\$d" init.rc
132         for netdev in `ls /sys/class/net`; do
133                 if [ $netdev = "lo" -o $netdev = "wmaster0" ]; then
134                         continue
135                 fi              
136                 w=/sys/class/net/$netdev
137                 if [ -d $w/wireless -o -d $w/phy80211 ]; then
138                         if [ $wififound -eq 0 ]; then
139                                 sed -i "s|\(^ *service wpa_supplicant .*\)\(-i.*\)\( -c.*$\)|\1-i $netdev\3|g" init.rc
140                                 wififound=1
141                         fi
142                 fi
143                 echo "service dhcpcd$netdev /system/bin/dhcpcd $netdev" >> init.rc
144                 echo "   group system dhcp" >> init.rc
145                 echo "   disabled" >>init.rc
146                 echo "   oneshot" >> init.rc
147         done
148 }
149
150 load_modules()
151 {
152         if [ -n "$FOUND" ]; then
153                 for m in $PREDEV $EXTMOD; do
154                         modprobe $m
155                 done
156                 [ -n "$FB0DEV" -a -z "$UVESA_MODE" ] && modprobe $FB0DEV
157                 [ -n "$LANDEV" ] && modprobe $LANDEV
158                 [ -n "$WIFDEV" ] && modprobe $WIFDEV
159                 [ -n "$SNDDEV" ] && modprobe $SNDDEV
160                 [ -n "$CAMDEV" ] && modprobe $CAMDEV
161         else
162                 auto_detect
163         fi
164
165         mdev -s
166         [ -c /dev/video0 ] || modprobe vivi
167         [ -d /proc/asound/card0 ] || modprobe snd-dummy
168         [ -c /dev/fb0 ] || modprobe uvesafb mode_option=${UVESA_MODE:-800x600}-16 ${UVESA_OPTION:-mtrr=3 scroll=ywrap}
169         find_network_dev_name
170 #       find_wifi_dev_name
171 }