OSDN Git Service

0-auto-detect: enable bluetooth for other platforms
[android-x86/bootable-newinstaller.git] / initrd / scripts / 0-auto-detect
index e421ea8..e8fe138 100644 (file)
@@ -1,6 +1,6 @@
 #
 # By Chih-Wei Huang <cwhuang@linux.org.tw>
-# Last updated 2009/07/18
+# Last updated 2009/08/14
 #
 # License: GNU Public License
 # We explicitely grant the right to use the scripts
@@ -27,7 +27,7 @@ auto_detect()
 # PREDEV: any module the drivers depend on but can't be loaded automatically
 # EXTMOD: any other module
 
-get_asus_info()
+asus_info()
 {
        # common for all Eee PC models
        [ -c /dev/fb0 ] || FB0DEV=i915
@@ -39,7 +39,7 @@ get_asus_info()
        board=`cat /sys/class/dmi/id/product_name`
        # assume Eee PC models
        case "$board" in
-               700|701|900)
+               700|701|702|900)
                        LANDEV=atl2
                        WIFDEV=ath5k
                        ;;
@@ -79,55 +79,79 @@ get_asus_info()
        esac
 }
 
-get_vbox_info()
+vbox_info()
 {
        LANDEV=pcnet32
        SNDDEV="snd-sb16 isapnp=0 irq=5"
+       VESA=1
 }
 
-get_qemu_info()
+qemu_info()
 {
        LANDEV=8139cp
        SNDDEV=snd-ens1370
 }
 
-get_vmware_info()
+vmware_info()
 {
        LANDEV=pcnet32
        SNDDEV=snd-ens1371
 }
 
-check_product()
-{
-       grep -q "$1" /sys/class/dmi/id/uevent
-}
-
 detect_hardware()
 {
-       check_product ASUSTeK && get_asus_info && return 0
-       check_product Acer.*AO && get_ao_info && return 0
-       check_product VirtualBox && get_vbox_info && return 0
-       check_product QEMU && get_qemu_info && return 0
-       check_product VMware && get_vmware_info && return 0
+       [ "$AUTO" = "1" ] && return
+       case "`cat /sys/class/dmi/id/uevent`" in
+               *ASUSTeK*)
+                       get_info=asus_info
+                       ;;
+               *Acer*AO*)
+                       get_info=ao_info
+                       ;;
+               *VirtualBox*)
+                       get_info=vbox_info
+                       ;;
+               *QEMU*)
+                       get_info=qemu_info
+                       ;;
+               *VMware*)
+                       get_info=vmware_info
+                       ;;
+               *)
+                       ;;
+       esac
+       [ -n "$get_info" ] && $get_info && FOUND=1
 }
 
-find_wifi_dev_name()
+find_network_dev_name()
 {
-       for wifi in `ls /sys/class/net`; do
-               w=/sys/class/net/$wifi
+       wififound=0
+       rmline=`grep -n "#REMOVE FROM HERE" init.rc|cut -d':' -f1`
+       rmline=`expr $rmline + 1`
+       sed -i -e "$rmline,\$d" init.rc
+       for netdev in `ls /sys/class/net`; do
+               if [ $netdev = "lo" -o $netdev = "wmaster0" ]; then
+                       continue
+               fi              
+               w=/sys/class/net/$netdev
                if [ -d $w/wireless -o -d $w/phy80211 ]; then
-                       sed -i "s|\(^ *service wpa_supplicant .*\)\(-i.*\)\( -c.*$\)|\1-i $wifi\3|g; \
-                               s|\(^ *service dhcpcd /system/bin/dhcpcd \)\(.*\)$|\1$wifi|g" init.rc
-                       break
+                       if [ $wififound -eq 0 ]; then
+                               sed -i "s|\(^ *service wpa_supplicant .*\)\(-i.*\)\( -c.*$\)|\1-i $netdev\3|g" init.rc
+                               wififound=1
+                       fi
                fi
+               echo "service dhcpcd$netdev /system/bin/dhcpcd $netdev" >> init.rc
+               echo "   group system dhcp" >> init.rc
+               echo "   disabled" >>init.rc
+               echo "   oneshot" >> init.rc
        done
 }
 
 load_modules()
 {
-       [ -z "$AUTO" ] && detect_hardware
-       if [ $? -eq 0 ]; then
-               for m in $PREDEV $EXTMOD; do
+       if [ -n "$FOUND" ]; then
+               BTDEV="bnep rfcomm sco btusb"
+               for m in $BTDEV $PREDEV $EXTMOD; do
                        modprobe $m
                done
                [ -n "$FB0DEV" -a -z "$UVESA_MODE" ] && modprobe $FB0DEV
@@ -140,8 +164,9 @@ load_modules()
        fi
 
        mdev -s
+       [ -c /dev/video0 ] || modprobe vivi
        [ -d /proc/asound/card0 ] || modprobe snd-dummy
        [ -c /dev/fb0 ] || modprobe uvesafb mode_option=${UVESA_MODE:-800x600}-16 ${UVESA_OPTION:-mtrr=3 scroll=ywrap}
-
-       find_wifi_dev_name
+       find_network_dev_name
+#      find_wifi_dev_name
 }