OSDN Git Service

0-auto-detect: change uvesafb default option (ywrap -> redraw)
[android-x86/bootable-newinstaller.git] / initrd / scripts / 0-auto-detect
1 #
2 # By Chih-Wei Huang <cwhuang@linux.org.tw>
3 # Last updated 2009/12/10
4 #
5 # License: GNU Public License
6 # We explicitely grant the right to use the scripts
7 # with Android-x86 project.
8 #
9
10 error()
11 {
12         echo $*
13         return 1
14 }
15
16 # An auto detect function provided by kinneko
17 auto_detect()
18 {
19         tmp=/tmp/dev2mod
20         echo 'dev2mod() { while read dev; do case $dev in' > $tmp
21         sort -r /lib/modules/`uname -r`/modules.alias | \
22                 sed -n 's/^alias  *\([^ ]*\)  *\(.*\)/\1)modprobe \2;;/p' >> $tmp
23         echo 'esac; done; }' >> $tmp
24         source $tmp
25         cat /sys/bus/*/devices/*/modalias | dev2mod
26 }
27
28 find_network_dev_name()
29 {
30         wififound=0
31         rmline=`grep -n "#REMOVE FROM HERE" init.rc|cut -d':' -f1`
32         rmline=`expr $rmline + 1`
33         sed -i -e "$rmline,\$d" init.rc
34         for netdev in `ls /sys/class/net`; do
35                 if [ $netdev = "lo" -o $netdev = "wmaster0" ]; then
36                         continue
37                 fi              
38                 w=/sys/class/net/$netdev
39                 if [ -d $w/wireless -o -d $w/phy80211 ]; then
40                         if [ $wififound -eq 0 ]; then
41                                 sed -i "s|\(^ *service wpa_supplicant .*\)\(-i.*\)\( -c.*$\)|\1-i $netdev\3|g" init.rc
42                                 wififound=1
43                         fi
44                 fi
45                 echo "service dhcpcd$netdev /system/bin/dhcpcd $netdev" >> init.rc
46                 echo "   group system dhcp" >> init.rc
47                 echo "   disabled" >>init.rc
48                 echo "   oneshot" >> init.rc
49         done
50 }
51
52 load_modules()
53 {
54         if [ -n "$FOUND" ]; then
55                 BTDEV="bnep rfcomm sco btusb"
56                 for m in $PREDEV $EXTMOD $BTDEV; do
57                         modprobe $m
58                 done
59                 [ -n "$FB0DEV" -a -z "$UVESA_MODE" ] && modprobe $FB0DEV
60                 [ -n "$LANDEV" ] && modprobe $LANDEV
61                 [ -n "$WIFDEV" ] && modprobe $WIFDEV
62                 [ -n "$SNDDEV" ] && modprobe $SNDDEV
63                 [ -n "$CAMDEV" ] && modprobe $CAMDEV
64         else
65                 auto_detect
66         fi
67
68         mdev -s
69         [ -c /dev/video0 ] || modprobe vivi
70         [ -d /proc/asound/card0 ] || modprobe snd-dummy
71         [ -c /dev/fb0 ] || modprobe uvesafb mode_option=${UVESA_MODE:-800x600}-16 ${UVESA_OPTION:-mtrr=3 scroll=redraw}
72         find_network_dev_name
73 #       find_wifi_dev_name
74 }