OSDN Git Service

The new installer. Supported filesystems are
[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_wifi_dev_name()
127 {
128         for wifi in `ls /sys/class/net`; do
129                 w=/sys/class/net/$wifi
130                 if [ -d $w/wireless -o -d $w/phy80211 ]; then
131                         sed -i "s|\(^ *service wpa_supplicant .*\)\(-i.*\)\( -c.*$\)|\1-i $wifi\3|g; \
132                                 s|\(^ *service dhcpcd /system/bin/dhcpcd \)\(.*\)$|\1$wifi|g" init.rc
133                         break
134                 fi
135         done
136 }
137
138 load_modules()
139 {
140         if [ -n "$FOUND" ]; then
141                 for m in $PREDEV $EXTMOD; do
142                         modprobe $m
143                 done
144                 [ -n "$FB0DEV" -a -z "$UVESA_MODE" ] && modprobe $FB0DEV
145                 [ -n "$LANDEV" ] && modprobe $LANDEV
146                 [ -n "$WIFDEV" ] && modprobe $WIFDEV
147                 [ -n "$SNDDEV" ] && modprobe $SNDDEV
148                 [ -n "$CAMDEV" ] && modprobe $CAMDEV
149         else
150                 auto_detect
151         fi
152
153         mdev -s
154         [ -c /dev/video0 ] || modprobe vivi
155         [ -d /proc/asound/card0 ] || modprobe snd-dummy
156         [ -c /dev/fb0 ] || modprobe uvesafb mode_option=${UVESA_MODE:-800x600}-16 ${UVESA_OPTION:-mtrr=3 scroll=ywrap}
157
158         find_wifi_dev_name
159 }