(OK) [android-x86-6.0-rc1] /system/etc/init.sh

来源:互联网 发布:ti2总决赛 知乎 编辑:程序博客网 时间:2024/05/16 05:40


## Copyright (C) 2013-2015 The Android-x86 Open Source Project## License: GNU Public License v2 or later#function set_property(){setprop "$1" "$2"[ -n "$DEBUG" ] && echo "$1"="$2" >> /dev/x86.prop}function init_misc(){# device informationsetprop ro.product.manufacturer "$(cat $DMIPATH/sys_vendor)"setprop ro.product.model "$PRODUCT"# a hack for USB modemlsusb | grep 1a8d:1000 && eject# in case no cpu governor driver autoloads[ -d /sys/devices/system/cpu/cpu0/cpufreq ] || modprobe acpi-cpufreq}function init_hal_audio(){case "$PRODUCT" inVirtualBox*|Bochs*)[ -d /proc/asound/card0 ] || modprobe snd-sb16 isapnp=0 irq=5;;*);;esac}function init_hal_bluetooth(){for r in /sys/class/rfkill/*; dotype=$(cat $r/type)[ "$type" = "wlan" -o "$type" = "bluetooth" ] && echo 1 > $r/statedonecase "$PRODUCT" inT10*TA|HP*Omni*)BTUART_PORT=/dev/ttyS1;;MacBookPro8*)rmmod b43modprobe b43 btcoex=0modprobe btusb;;# FIXME# Fix MacBook 2013-2015 (Air6/7&Pro11/12) BCM4360 ssb&wl conflict.MacBookPro11* | MacBookPro12* | MacBookAir6* | MacBookAir7*)rmmod b43rmmod ssbrmmod bcmarmmod wlmodprobe wlmodprobe btusb;;*)for bt in $(lsusb -v | awk ' /Class:.E0/ { print $9 } '); dochown 1002.1002 $bt && chmod 660 $btdonemodprobe btusb;;esacif [ -n "$BTUART_PORT" ]; thenset_property hal.bluetooth.uart $BTUART_PORTchown bluetooth.bluetooth $BTUART_PORTstart btattach:-B$BTUART_PORTlog -t hciconfig -p i "`hciconfig`"fi}function init_hal_camera(){return}function init_hal_gps(){# TODOreturn}function set_drm_mode(){case "$PRODUCT" inET1602*)drm_mode=1366x768;;*);;esac[ -n "$drm_mode" ] && set_property debug.drm.mode.force $drm_mode}function init_uvesafb(){case "$PRODUCT" in*Q550)UVESA_MODE=${UVESA_MODE:-1280x800};;ET2002*)UVESA_MODE=${UVESA_MODE:-1600x900};;T91*)UVESA_MODE=${UVESA_MODE:-1024x600};;VirtualBox*|Bochs*)UVESA_MODE=${UVESA_MODE:-1024x768};;*);;esac[ "$HWACCEL" = "0" ] && bpp=16 || bpp=32modprobe uvesafb mode_option=${UVESA_MODE:-800x600}-$bpp ${UVESA_OPTION:-mtrr=3 scroll=redraw}}function init_hal_gralloc(){case "$(cat /proc/fb | head -1)" in*virtiodrmfb)#set_property ro.hardware.hwcomposer drm;&0*inteldrmfb|0*radeondrmfb|0*nouveaufb|0*svgadrmfb)set_property ro.hardware.gralloc drmset_drm_mode;;"")init_uvesafb;&0*)# FIXME: software rendering failed to pass the SetupWizardset_property ro.setupwizard.mode DISABLED;;esac[ -n "$DEBUG" ] && set_property debug.egl.trace error}function init_hal_hwcomposer(){# TODOreturn}function init_hal_lights(){chown 1000.1000 /sys/class/backlight/*/brightness}function init_hal_power(){for p in /sys/class/rtc/*; doecho disabled > $p/device/power/wakeupdone# TODOcase "$PRODUCT" in*);;esac}function init_hal_sensors(){local hal_sensors=kbdcase "$(cat $DMIPATH/uevent)" in*Lucid-MWE*)set_property ro.ignore_atkbd 1hal_sensors=hdaps;;*ICONIA*W5*)hal_sensors=w500;;*S10-3t*)hal_sensors=s103t;;*Inagua*)#setkeycodes 0x62 29#setkeycodes 0x74 56set_property ro.ignore_atkbd 1set_property hal.sensors.kbd.type 2;;*TEGA*|*2010:svnIntel:*)set_property ro.ignore_atkbd 1set_property hal.sensors.kbd.type 1io_switch 0x0 0x1setkeycodes 0x6d 125;;*DLI*)set_property ro.ignore_atkbd 1set_property hal.sensors.kbd.type 1setkeycodes 0x64 1setkeycodes 0x65 172setkeycodes 0x66 120setkeycodes 0x67 116setkeycodes 0x68 114setkeycodes 0x69 115setkeycodes 0x6c 114setkeycodes 0x6d 115;;*tx2*)setkeycodes 0xb1 138setkeycodes 0x8a 152set_property hal.sensors.kbd.type 6set_property poweroff.doubleclick 0set_property qemu.hw.mainkeys 1;;*MS-N0E1*)set_property ro.ignore_atkbd 1set_property poweroff.doubleclick 0setkeycodes 0xa5 125setkeycodes 0xa7 1setkeycodes 0xe3 142;;*Aspire1*25*)modprobe lis3lv02d_i2chal_sensors=hdapsecho -n "enabled" > /sys/class/thermal/thermal_zone0/mode;;*ThinkPad*Tablet*)modprobe hdapshal_sensors=hdaps;;*HPPaviliong*)hal_sensors=hdaps;;*i7Stylus*)set_property hal.sensors.iio.accel.matrix 1,0,0,0,-1,0,0,0,-1;;*);;esac# has iio sensor-hub?if [ -n "`ls /sys/bus/iio/devices/iio:device* 2> /dev/null`" ]; thenbusybox chown -R 1000.1000 /sys/bus/iio/devices/iio:device*/lsmod | grep -q hid_sensor_accel_3d && hal_sensors=hsb || hal_sensors=iiofiset_property ro.hardware.sensors $hal_sensors}function create_pointercal(){if [ ! -e /data/misc/tscal/pointercal ]; thenmkdir -p /data/misc/tscaltouch /data/misc/tscal/pointercalchown 1000.1000 /data/misc/tscal /data/misc/tscal/*chmod 775 /data/misc/tscalchmod 664 /data/misc/tscal/pointercalfi}function init_tscal(){case "$PRODUCT" inST70416-6*)modprobe gslx680_ts_acpi;&T91|T101|ET2002|74499FU|945GSE-ITE8712|CF-19[CDYFGKLP]*)create_pointercalreturn;;*);;esacfor usbts in $(lsusb | awk '{ print $6 }'); docase "$usbts" in0596:0001|0eef:0001)create_pointercalreturn;;*);;esacdone}function init_ril(){case "$(cat $DMIPATH/uevent)" in*TEGA*|*2010:svnIntel:*|*Lucid-MWE*)set_property rild.libpath /system/lib/libhuaweigeneric-ril.soset_property rild.libargs "-d /dev/ttyUSB2 -v /dev/ttyUSB1";;*);;esac}function init_cpu_governor(){governor=$(getprop cpu.governor)[ $governor ] && {for cpu in $(ls -d /sys/devices/system/cpu/cpu?); doecho $governor > $cpu/cpufreq/scaling_governor || return 1done}}function do_init(){init_miscinit_hal_audioinit_hal_bluetoothinit_hal_camerainit_hal_gpsinit_hal_grallocinit_hal_hwcomposerinit_hal_lightsinit_hal_powerinit_hal_sensorsinit_tscalinit_rilpost_init}function do_netconsole(){modprobe netconsole netconsole="@/,@$(getprop dhcp.eth0.gateway)/"}function do_bootcomplete(){init_cpu_governor[ -z "$(getprop persist.sys.root_access)" ] && setprop persist.sys.root_access 3# FIXME: autosleep works better on i965?[ "$(getprop debug.mesa.driver)" = "i965" ] && setprop debug.autosleep 1lsmod | grep -e brcmfmac && setprop wlan.no-unload-driver 1case "$PRODUCT" in1866???|1867???|1869???) # ThinkPad X41 Tabletstart tablet-modestart wacom-inputsetkeycodes 0x6d 115setkeycodes 0x6e 114setkeycodes 0x69 28setkeycodes 0x6b 158setkeycodes 0x68 172setkeycodes 0x6c 127setkeycodes 0x67 217;;6363???|6364???|6366???) # ThinkPad X60 Tablet;&7762???|7763???|7767???) # ThinkPad X61 Tabletstart tablet-modestart wacom-inputsetkeycodes 0x6d 115setkeycodes 0x6e 114setkeycodes 0x69 28setkeycodes 0x6b 158setkeycodes 0x68 172setkeycodes 0x6c 127setkeycodes 0x67 217;;7448???|7449???|7450???|7453???) # ThinkPad X200 Tabletstart tablet-modestart wacom-inputsetkeycodes 0xe012 158setkeycodes 0x66 172setkeycodes 0x6b 127;;*);;esac#[ -d /proc/asound/card0 ] || modprobe snd-dummyfor c in $(grep '\[.*\]' /proc/asound/cards | awk '{print $1}'); dof=/system/etc/alsa/$(cat /proc/asound/card$c/id).stateif [ -e $f ]; thenalsa_ctl -f $f restore $celsealsa_ctl init $calsa_amixer -c $c set Master onalsa_amixer -c $c set Master 100%alsa_amixer -c $c set Headphone onalsa_amixer -c $c set Headphone 100%alsa_amixer -c $c set Speaker 100%alsa_amixer -c $c set Capture 100%alsa_amixer -c $c set Capture capalsa_amixer -c $c set PCM 100 unmutealsa_amixer -c $c set SPO unmutealsa_amixer -c $c set 'Mic Boost' 3alsa_amixer -c $c set 'Internal Mic Boost' 3fidone}function do_hci(){local hci=`hciconfig | grep ^hci | cut -d: -f1`local btd="`getprop init.svc.bluetoothd`"log -t bluetoothd -p i "$btd ($hci)"if [ -n "`getprop hal.bluetooth.uart`" ]; then[ "`getprop init.svc.bluetoothd`" = "running" ] && hciconfig $hci upfi}PATH=/sbin:/system/bin:/system/xbinDMIPATH=/sys/class/dmi/idBOARD=$(cat $DMIPATH/board_name)PRODUCT=$(cat $DMIPATH/product_name)# import cmdline variablesfor c in `cat /proc/cmdline`; docase $c in*.*=*);;*=*)eval $cif [ -z "$1" ]; thencase $c inHWACCEL=*)set_property debug.egl.hw $HWACCEL;;DEBUG=*)[ -n "$DEBUG" ] && set_property debug.logcat 1;;esacfi;;esacdone[ -n "$DEBUG" ] && set -x || exec &> /dev/null# import the vendor specific scripthw_sh=/vendor/etc/init.sh[ -e $hw_sh ] && source $hw_sh# Note: /system/etc/init.sh will be called 4 times: [init, bootcomplete, hci, hci]case "$1" innetconsole)[ -n "$DEBUG" ] && do_netconsole;;bootcomplete)do_bootcomplete# seem_init.sh is called for the second time/system/xbin/quagga/sbin/seem_init.sh#if [ ! -f /opt/init.txt ]; then#echo "init.txt not exist, bootcomplete, in /system/etc/init.sh" >> /data/inittmp.txt#else#echo "init.txt exist, bootcomplete, in /system/etc/init.sh" >> /data/inittmp.txt#fi;;hci)do_hci# comment hci in device/generic/common/init.x86.rc, line 126# do_hci is called for the second time#if [ -f /data/test.txt ]; then#/system/xbin/quagga/sbin/seem_init.sh#fi# do_hci is called for the first time#touch /data/test.txt;;init|"")# seem_init.sh is called for the first time/system/xbin/quagga/sbin/seem_init.sh#if [ ! -f /opt/init.txt ]; then#echo "init.txt not exist, init, in /system/etc/init.sh" >> /data/inittmp.txt#else#echo "init.txt exist, init, in /system/etc/init.sh" >> /data/inittmp.txt#fido_init;;esacreturn 0


0 0