#
# By Chih-Wei Huang <cwhuang@linux.org.tw>
-# Last updated 2009/07/18
+# Last updated 2017/01/17
#
# License: GNU Public License
# We explicitely grant the right to use the scripts
# with Android-x86 project.
#
-# TODO: implement a more generic auto detection by scanning /sys
-# For now we just look up the machine name.
-
-# FB0DEV: framebuffer driver
-# LANDEV: lan driver
-# WIFDEV: wifi driver
-# SNDDEV: sound driver
-# CAMDEV: camera driver
-# PREDEV: any module the drivers depend on but can't be loaded automatically
-
-get_asus_info()
-{
- board=`cat /sys/class/dmi/id/board_name`
- # assume Eee PC models
- case "$board" in
- 700|701|900)
- LANDEV=atl2
- WIFDEV=ath5k
- ;;
- 701SD|900SD)
- LANDEV=atl1e
- WIFDEV=rtl8187se
- ;;
- 900A|904HD|1000HD)
- LANDEV=atl1e
- WIFDEV=ath5k
- ;;
- 901)
- LANDEV=atl1e
- WIFDEV=rt2860sta
- *)
- LANDEV=atl1e
- WIFDEV=ath9k
-# WIFDEV=rt2860sta
- ;;
- esac
-
- # common for all Eee PC models
- FB0DEV=i915
- SNDDEV=snd-hda-intel
- CAMDEV=uvcvideo
- PREDEV=snd-hda-codec-realtek
-}
-
-get_vbox_info()
-{
- LANDEV=pcnet32
- SNDDEV="snd-sb16 isapnp=0 irq=5"
-}
-
-get_qemu_info()
-{
- LANDEV=8139cp
- SNDDEV=snd-ens1370
-}
-
-get_vmware_info()
-{
- LANDEV=pcnet32
- SNDDEV=snd-ens1371
-}
-
-check_product()
+# An auto detect function provided by kinneko
+auto_detect()
{
- grep -q "$1" /sys/class/dmi/id/uevent
-}
-
-detect_hardware()
-{
- check_product ASUSTeK && get_asus_info
- check_product VirtualBox && get_vbox_info
- check_product QEMU && get_qemu_info
- check_product VMware && get_vmware_info
+ tmp=/tmp/dev2mod
+ echo 'dev2mod() { while read dev; do case $dev in' > $tmp
+ sort -r /lib/modules/`uname -r`/modules.alias | \
+ sed -n 's/^alias *\([^ ]*\) *\(.*\)/\1)busybox modprobe \2;;/p' >> $tmp
+ echo 'esac; done; }' >> $tmp
+ for f in $(grep -Eh "drm_kms|sound.core" /lib/modules/`uname -r`/modules.dep | cut -d. -f1); do
+ sed -i "/$(basename $f | sed 's/-/_/g')/d" $tmp
+ done
+ source $tmp
+ cat /sys/bus/*/devices/*/uevent | grep MODALIAS | sed 's/^MODALIAS=//' | awk '!seen[$0]++' | dev2mod
+ cat /sys/devices/virtual/wmi/*/modalias | dev2mod
}
load_modules()
{
- detect_hardware
- for m in $PREDEV; do
- modprobe $m
+ if [ "$AUTO_LOAD" = "old" ]; then
+ auto_detect
+ fi
+
+ # 3G modules
+ for m in $EXTMOD; do
+ busybox modprobe $m
done
- [ -n "$FB0DEV" ] && modprobe $FB0DEV
- [ -n "$LANDEV" ] && modprobe $LANDEV
- [ -n "$WIFDEV" ] && modprobe $WIFDEV
- [ -n "$SNDDEV" ] && modprobe $SNDDEV
- [ -n "$CAMDEV" ] && modprobe $CAMDEV
}