OSDN Git Service

* add uvesafb support
[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
29 get_asus_info()
30 {
31         # common for all Eee PC models
32         [ -c /dev/fb0 ] || FB0DEV=i915
33         PREDEV=snd-hda-codec-realtek
34         SNDDEV=snd-hda-intel
35         CAMDEV=uvcvideo
36
37         board=`cat /sys/class/dmi/id/product_name`
38         # assume Eee PC models
39         case "$board" in
40                 700|701|900)
41                         LANDEV=atl2
42                         WIFDEV=ath5k
43                         ;;
44                 701SD|900SD)
45                         LANDEV=atl1e
46                         WIFDEV=rtl8187se
47                         ;;
48                 900A|904HD|1000HD)
49                         LANDEV=atl1e
50                         WIFDEV=ath5k
51                         ;;
52                 901|1000|1000H)
53                         LANDEV=atl1e
54                         WIFDEV=rt2860sta
55                         ;;
56                 ET1602*)
57                         FB0DEV=
58                         UVESA_MODE=${UVESA_MODE:-1366x768}
59                         LANDEV=r8169
60                         WIFDEV=rt2860sta
61                         ;;
62                 T91)
63                         FB0DEV=
64                         UVESA_MODE=${UVESA_MODE:-1024x600}
65                         LANDEV=atl1e
66                         WIFDEV=ath9k
67                         ;;
68                 *)
69                         LANDEV=atl1e
70                         WIFDEV=ath9k
71                         ;;
72         esac
73 }
74
75 get_vbox_info()
76 {
77         LANDEV=pcnet32
78         SNDDEV="snd-sb16 isapnp=0 irq=5"
79 }
80
81 get_qemu_info()
82 {
83         LANDEV=8139cp
84         SNDDEV=snd-ens1370
85 }
86
87 get_vmware_info()
88 {
89         LANDEV=pcnet32
90         SNDDEV=snd-ens1371
91 }
92
93 check_product()
94 {
95         grep -q "$1" /sys/class/dmi/id/uevent
96 }
97
98 detect_hardware()
99 {
100         check_product ASUSTeK && get_asus_info && return 0
101         check_product Acer.*AO && get_ao_info && return 0
102         check_product VirtualBox && get_vbox_info && return 0
103         check_product QEMU && get_qemu_info && return 0
104         check_product VMware && get_vmware_info && return 0
105 }
106
107 load_modules()
108 {
109         detect_hardware
110         if [ $? -eq 0 ]; then
111                 for m in $PREDEV; do
112                         modprobe $m
113                 done
114                 [ -n "$FB0DEV" -a -z "$UVESA_MODE" ] && modprobe $FB0DEV
115                 [ -n "$LANDEV" ] && modprobe $LANDEV
116                 [ -n "$WIFDEV" ] && modprobe $WIFDEV
117                 [ -n "$SNDDEV" ] && modprobe $SNDDEV
118                 [ -n "$CAMDEV" ] && modprobe $CAMDEV
119         else
120                 auto_detect
121         fi
122
123         mdev -s
124         [ -d /proc/asound/card0 ] || modprobe snd-dummy
125         [ -c /dev/fb0 ] || modprobe uvesafb mode_option=${UVESA_MODE:-800x600}-16 ${UVESA_OPTION:-mtrr=3 scroll=ywrap}
126 }