2 # Copyright (C) 2013-2018 The Android-x86 Open Source Project
4 # License: GNU Public License v2 or later
7 function set_property()
10 [ -n "$DEBUG" ] && echo "$1"="$2" >> /dev/x86.prop
13 function set_prop_if_empty()
15 [ -z "$(getprop $1)" ] && set_property "$1" "$2"
18 function rmmod_if_exist()
21 [ -d /sys/module/$m ] && rmmod $m
28 setprop ro.product.manufacturer "$(cat $DMIPATH/sys_vendor)"
29 setprop ro.product.model "$PRODUCT"
31 # a hack for USB modem
32 lsusb | grep 1a8d:1000 && eject
34 # in case no cpu governor driver autoloads
35 [ -d /sys/devices/system/cpu/cpu0/cpufreq ] || modprobe acpi-cpufreq
37 # enable sdcardfs if /data is not mounted on tmpfs or 9p
38 mount | grep /data\ | grep -qE 'tmpfs|9p'
39 [ $? -ne 0 ] && modprobe sdcardfs
41 # remove wl if it's not used
43 if [ -d /sys/class/net/wlan0 ]; then
44 wifi=$(basename `readlink /sys/class/net/wlan0/device/driver`)
45 [ "$wifi" != "wl" ] && rmmod_if_exist wl
48 # enable virt_wifi if needed
49 local eth=`getprop net.virt_wifi eth0`
50 if [ -d /sys/class/net/$eth -a "$VIRT_WIFI" != "0" ]; then
51 if [ -n "$wifi" -a "$VIRT_WIFI" = "1" ]; then
52 rmmod_if_exist iwlmvm $wifi
54 if [ ! -d /sys/class/net/wlan0 ]; then
56 ip link set $eth name wifi_eth
58 ip link add link wifi_eth name wlan0 type virt_wifi
63 function init_hal_audio()
67 [ -d /proc/asound/card0 ] || modprobe snd-sb16 isapnp=0 irq=5
70 set_prop_if_empty hal.audio.out pcmC0D2p
75 function init_hal_bluetooth()
77 for r in /sys/class/rfkill/*; do
79 [ "$type" = "wlan" -o "$type" = "bluetooth" ] && echo 1 > $r/state
84 set_property bluetooth.interface hci1
86 T10*TA|M80TA|HP*Omni*)
87 BTUART_PORT=/dev/ttyS1
88 set_property hal.bluetooth.uart.proto bcm
96 # Fix MacBook 2013-2015 (Air6/7&Pro11/12) BCM4360 ssb&wl conflict.
97 MacBookPro11* | MacBookPro12* | MacBookAir6* | MacBookAir7*)
106 for bt in $(busybox lsusb -v | awk ' /Class:.E0/ { print $9 } '); do
107 chown 1002.1002 $bt && chmod 660 $bt
112 if [ -n "$BTUART_PORT" ]; then
113 set_property hal.bluetooth.uart $BTUART_PORT
114 chown bluetooth.bluetooth $BTUART_PORT
118 # rtl8723bs bluetooth
119 if dmesg -t | grep -qE '8723bs.*BT'; then
120 TTYSTRING=`dmesg -t | grep -E 'tty.*MMIO' | awk '{print $2}' | head -1`
121 if [ -n "$TTYSTRING" ]; then
122 echo "RTL8723BS BT uses $TTYSTRING for Bluetooth."
123 ln -sf $TTYSTRING /dev/rtk_h5
129 function init_hal_camera()
133 set_prop_if_empty hal.camera.0 0,270
134 set_prop_if_empty hal.camera.2 1,90
141 function init_hal_gps()
147 function set_drm_mode()
154 [ -n "$video" ] && drm_mode=$video
158 [ -n "$drm_mode" ] && set_property debug.drm.mode.force $drm_mode
161 function init_uvesafb()
163 UVESA_MODE=${UVESA_MODE:-${video%@*}}
167 UVESA_MODE=${UVESA_MODE:-1600x900}
173 modprobe uvesafb mode_option=${UVESA_MODE:-1024x768}-32 ${UVESA_OPTION:-mtrr=3 scroll=redraw}
176 function init_hal_gralloc()
178 [ "$VULKAN" = "1" ] && GRALLOC=gbm
180 case "$(cat /proc/fb | head -1)" in
181 *virtiodrmfb|*DRM*emulated)
182 if [ "$HWACCEL" != "0" ]; then
183 set_property ro.hardware.hwcomposer ${HWC:-drm}
184 set_property ro.hardware.gralloc ${GRALLOC:-gbm}
185 set_property debug.drm.mode.force ${video:-1280x800}
188 0*i915drmfb|0*inteldrmfb|0*radeondrmfb|0*nouveau*|0*svgadrmfb|0*amdgpudrmfb)
189 if [ "$HWACCEL" != "0" ]; then
190 set_property ro.hardware.gralloc ${GRALLOC:-drm}
201 [ -n "$DEBUG" ] && set_property debug.egl.trace error
204 function init_hal_hwcomposer()
210 function init_hal_vulkan()
212 case "$(cat /proc/fb | head -1)" in
213 0*i915drmfb|0*inteldrmfb)
214 set_property ro.hardware.vulkan android-x86
217 set_property ro.hardware.vulkan radv
224 function init_hal_lights()
226 chown 1000.1000 /sys/class/backlight/*/brightness
229 function init_hal_power()
231 for p in /sys/class/rtc/*; do
232 echo disabled > $p/device/power/wakeup
237 HP*Omni*|OEMB|Standard*PC*|Surface*3|T10*TA|VMware*)
238 set_prop_if_empty sleep.state none
241 set_prop_if_empty sleep.state force
248 function init_hal_sensors()
250 # if we have sensor module for our hardware, use it
251 ro_hardware=$(getprop ro.hardware)
252 [ -f /system/lib/hw/sensors.${ro_hardware}.so ] && return 0
254 local hal_sensors=kbd
255 local has_sensors=true
256 case "$(cat $DMIPATH/uevent)" in
258 set_property ro.ignore_atkbd 1
270 set_property ro.ignore_atkbd 1
271 set_property hal.sensors.kbd.type 2
273 *TEGA*|*2010:svnIntel:*)
274 set_property ro.ignore_atkbd 1
275 set_property hal.sensors.kbd.type 1
280 set_property ro.ignore_atkbd 1
281 set_property hal.sensors.kbd.type 1
294 set_property hal.sensors.kbd.type 6
295 set_property poweroff.doubleclick 0
296 set_property qemu.hw.mainkeys 1
299 set_property ro.ignore_atkbd 1
300 set_property poweroff.doubleclick 0
306 modprobe lis3lv02d_i2c
307 echo -n "enabled" > /sys/class/thermal/thermal_zone0/mode
314 set_property ro.iio.accel.x.opt_scale -1
315 set_property ro.iio.accel.z.opt_scale -1
318 set_property ro.iio.accel.quirks no-trig
321 set_property ro.iio.accel.x.opt_scale -1
323 *LenovoMIIX320*|*ONDATablet*)
324 set_property ro.iio.accel.order 102
325 set_property ro.iio.accel.x.opt_scale -1
326 set_property ro.iio.accel.y.opt_scale -1
329 set_property ro.iio.accel.quirks no-trig
332 set_property ro.iio.accel.order 102
334 *e-tabPro*|*pnEZpad*)
335 set_property ro.iio.accel.quirks no-trig
338 set_property ro.iio.accel.y.opt_scale -1
345 # has iio sensor-hub?
346 if [ -n "`ls /sys/bus/iio/devices/iio:device* 2> /dev/null`" ]; then
347 busybox chown -R 1000.1000 /sys/bus/iio/devices/iio:device*/
348 [ -n "`ls /sys/bus/iio/devices/iio:device*/in_accel_x_raw 2> /dev/null`" ] && has_sensors=true
350 elif lsmod | grep -q lis3lv02d_i2c; then
353 elif [ "$hal_sensors" != "kbd" ]; then
357 set_property ro.hardware.sensors $hal_sensors
358 set_property config.override_forced_orient ${HAS_SENSORS:-$has_sensors}
361 function create_pointercal()
363 if [ ! -e /data/misc/tscal/pointercal ]; then
364 mkdir -p /data/misc/tscal
365 touch /data/misc/tscal/pointercal
366 chown 1000.1000 /data/misc/tscal /data/misc/tscal/*
367 chmod 775 /data/misc/tscal
368 chmod 664 /data/misc/tscal/pointercal
372 function init_tscal()
376 modprobe gslx680_ts_acpi
378 T91|T101|ET2002|74499FU|945GSE-ITE8712|CF-19[CDYFGKLP]*)
386 for usbts in $(lsusb | awk '{ print $6 }'); do
400 case "$(cat $DMIPATH/uevent)" in
401 *TEGA*|*2010:svnIntel:*|*Lucid-MWE*)
402 set_property rild.libpath /system/lib/libhuaweigeneric-ril.so
403 set_property rild.libargs "-d /dev/ttyUSB2 -v /dev/ttyUSB1"
404 set_property ro.radio.noril no
407 set_property ro.radio.noril yes
412 function init_cpu_governor()
414 governor=$(getprop cpu.governor)
417 for cpu in $(ls -d /sys/devices/system/cpu/cpu?); do
418 echo $governor > $cpu/cpufreq/scaling_governor || return 1
441 function do_netconsole()
443 modprobe netconsole netconsole="@/,@$(getprop dhcp.eth0.gateway)/"
446 function do_bootcomplete()
448 hciconfig | grep -q hci || pm disable com.android.bluetooth
452 [ -z "$(getprop persist.sys.root_access)" ] && setprop persist.sys.root_access 3
454 lsmod | grep -Ehq "brcmfmac|rtl8723be" && setprop wlan.no-unload-driver 1
457 1866???|1867???|1869???) # ThinkPad X41 Tablet
468 6363???|6364???|6366???) # ThinkPad X60 Tablet
470 7762???|7763???|7767???) # ThinkPad X61 Tablet
481 7448???|7449???|7450???|7453???) # ThinkPad X200 Tablet
484 setkeycodes 0xe012 158
489 echo on > /sys/devices/pci0000:00/0000:00:15.1/i2c_designware.1/power/control
492 pm disable com.android.bluetooth
495 set_property power.nonboot-cpu-off 1
501 # [ -d /proc/asound/card0 ] || modprobe snd-dummy
502 for c in $(grep '\[.*\]' /proc/asound/cards | awk '{print $1}'); do
503 f=/system/etc/alsa/$(cat /proc/asound/card$c/id).state
505 alsa_ctl -f $f restore $c
508 alsa_amixer -c $c set Master on
509 alsa_amixer -c $c set Master 100%
510 alsa_amixer -c $c set Headphone on
511 alsa_amixer -c $c set Headphone 100%
512 alsa_amixer -c $c set Speaker 100%
513 alsa_amixer -c $c set Capture 80%
514 alsa_amixer -c $c set Capture cap
515 alsa_amixer -c $c set PCM 100 unmute
516 alsa_amixer -c $c set SPO unmute
517 alsa_amixer -c $c set IEC958 on
518 alsa_amixer -c $c set 'Mic Boost' 1
519 alsa_amixer -c $c set 'Internal Mic Boost' 1
526 PATH=/sbin:/system/bin:/system/xbin
528 DMIPATH=/sys/class/dmi/id
529 BOARD=$(cat $DMIPATH/board_name)
530 PRODUCT=$(cat $DMIPATH/product_name)
532 # import cmdline variables
533 for c in `cat /proc/cmdline`; do
535 BOOT_IMAGE=*|iso-scan/*|*.*=*)
542 [ -n "$DEBUG" ] && set_property debug.logcat 1
550 [ -n "$DEBUG" ] && set -x || exec &> /dev/null
552 # import the vendor specific script
553 hw_sh=/vendor/etc/init.sh
554 [ -e $hw_sh ] && source $hw_sh
558 [ -n "$DEBUG" ] && do_netconsole