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"
21 setprop ro.product.manufacturer "$(cat $DMIPATH/sys_vendor)"
22 setprop ro.product.model "$PRODUCT"
24 # a hack for USB modem
25 lsusb | grep 1a8d:1000 && eject
27 # in case no cpu governor driver autoloads
28 [ -d /sys/devices/system/cpu/cpu0/cpufreq ] || modprobe acpi-cpufreq
30 # enable sdcardfs if /data is not mounted on tmpfs or 9p
31 mount | grep /data\ | grep -qE 'tmpfs|9p'
32 [ $? -ne 0 ] && modprobe sdcardfs
35 function init_hal_audio()
39 [ -d /proc/asound/card0 ] || modprobe snd-sb16 isapnp=0 irq=5
42 set_prop_if_empty hal.audio.out pcmC0D2p
47 function init_hal_bluetooth()
49 for r in /sys/class/rfkill/*; do
51 [ "$type" = "wlan" -o "$type" = "bluetooth" ] && echo 1 > $r/state
56 set_property bluetooth.interface hci1
58 T10*TA|M80TA|HP*Omni*)
59 BTUART_PORT=/dev/ttyS1
60 set_property hal.bluetooth.uart.proto bcm
68 # Fix MacBook 2013-2015 (Air6/7&Pro11/12) BCM4360 ssb&wl conflict.
69 MacBookPro11* | MacBookPro12* | MacBookAir6* | MacBookAir7*)
78 for bt in $(busybox lsusb -v | awk ' /Class:.E0/ { print $9 } '); do
79 chown 1002.1002 $bt && chmod 660 $bt
84 if [ -n "$BTUART_PORT" ]; then
85 set_property hal.bluetooth.uart $BTUART_PORT
86 chown bluetooth.bluetooth $BTUART_PORT
91 if dmesg -t | grep -qE '8723bs.*BT'; then
92 TTYSTRING=`dmesg -t | grep -E 'tty.*MMIO' | awk '{print $2}' | head -1`
93 if [ -n "$TTYSTRING" ]; then
94 echo "RTL8723BS BT uses $TTYSTRING for Bluetooth."
95 ln -sf $TTYSTRING /dev/rtk_h5
101 function init_hal_camera()
106 function init_hal_gps()
112 function set_drm_mode()
119 [ -n "$video" ] && drm_mode=$video
123 [ -n "$drm_mode" ] && set_property debug.drm.mode.force $drm_mode
126 function init_uvesafb()
128 UVESA_MODE=${UVESA_MODE:-${video%@*}}
132 UVESA_MODE=${UVESA_MODE:-1600x900}
138 modprobe uvesafb mode_option=${UVESA_MODE:-1024x768}-32 ${UVESA_OPTION:-mtrr=3 scroll=redraw}
141 function init_hal_gralloc()
143 case "$(cat /proc/fb | head -1)" in
145 if [ "$HWACCEL" != "0" ]; then
146 set_property ro.hardware.hwcomposer drm
147 set_property ro.hardware.gralloc gbm
148 set_property debug.drm.mode.force ${video:-1280x800}
151 0*inteldrmfb|0*radeondrmfb|0*nouveaufb|0*svgadrmfb|0*amdgpudrmfb)
152 if [ "$HWACCEL" != "0" ]; then
153 set_property ro.hardware.gralloc drm
164 [ -n "$DEBUG" ] && set_property debug.egl.trace error
167 function init_hal_hwcomposer()
173 function init_hal_vulkan()
175 case "$(cat /proc/fb | head -1)" in
177 set_property ro.hardware.vulkan android-x86
180 set_property ro.hardware.vulkan radv
187 function init_hal_lights()
189 chown 1000.1000 /sys/class/backlight/*/brightness
192 function init_hal_power()
194 for p in /sys/class/rtc/*; do
195 echo disabled > $p/device/power/wakeup
200 HP*Omni*|OEMB|Standard*PC*|Surface*3|T10*TA)
201 set_prop_if_empty sleep.state none
208 function init_hal_sensors()
210 # if we have sensor module for our hardware, use it
211 ro_hardware=$(getprop ro.hardware)
212 [ -f /system/lib/hw/sensors.${ro_hardware}.so ] && return 0
214 local hal_sensors=kbd
215 local has_sensors=true
216 case "$(cat $DMIPATH/uevent)" in
218 set_property ro.ignore_atkbd 1
230 set_property ro.ignore_atkbd 1
231 set_property hal.sensors.kbd.type 2
233 *TEGA*|*2010:svnIntel:*)
234 set_property ro.ignore_atkbd 1
235 set_property hal.sensors.kbd.type 1
240 set_property ro.ignore_atkbd 1
241 set_property hal.sensors.kbd.type 1
254 set_property hal.sensors.kbd.type 6
255 set_property poweroff.doubleclick 0
256 set_property qemu.hw.mainkeys 1
259 set_property ro.ignore_atkbd 1
260 set_property poweroff.doubleclick 0
266 modprobe lis3lv02d_i2c
267 echo -n "enabled" > /sys/class/thermal/thermal_zone0/mode
274 set_property ro.iio.accel.x.opt_scale -1
277 set_property ro.iio.accel.order 102
278 set_property ro.iio.accel.x.opt_scale -1
279 set_property ro.iio.accel.y.opt_scale -1
282 set_property ro.iio.accel.order 102
285 set_property ro.iio.accel.y.opt_scale -1
292 # has iio sensor-hub?
293 if [ -n "`ls /sys/bus/iio/devices/iio:device* 2> /dev/null`" ]; then
294 busybox chown -R 1000.1000 /sys/bus/iio/devices/iio:device*/
295 [ -n "`ls /sys/bus/iio/devices/iio:device*/in_accel_x_raw 2> /dev/null`" ] && has_sensors=true
297 elif lsmod | grep -q lis3lv02d_i2c; then
300 elif [ "$hal_sensors" != "kbd" ]; then
304 set_property ro.hardware.sensors $hal_sensors
305 set_property config.override_forced_orient ${HAS_SENSORS:-$has_sensors}
308 function create_pointercal()
310 if [ ! -e /data/misc/tscal/pointercal ]; then
311 mkdir -p /data/misc/tscal
312 touch /data/misc/tscal/pointercal
313 chown 1000.1000 /data/misc/tscal /data/misc/tscal/*
314 chmod 775 /data/misc/tscal
315 chmod 664 /data/misc/tscal/pointercal
319 function init_tscal()
323 modprobe gslx680_ts_acpi
325 T91|T101|ET2002|74499FU|945GSE-ITE8712|CF-19[CDYFGKLP]*)
333 for usbts in $(lsusb | awk '{ print $6 }'); do
347 case "$(cat $DMIPATH/uevent)" in
348 *TEGA*|*2010:svnIntel:*|*Lucid-MWE*)
349 set_property rild.libpath /system/lib/libhuaweigeneric-ril.so
350 set_property rild.libargs "-d /dev/ttyUSB2 -v /dev/ttyUSB1"
351 set_property ro.radio.noril no
354 set_property ro.radio.noril yes
359 function init_cpu_governor()
361 governor=$(getprop cpu.governor)
364 for cpu in $(ls -d /sys/devices/system/cpu/cpu?); do
365 echo $governor > $cpu/cpufreq/scaling_governor || return 1
388 function do_netconsole()
390 modprobe netconsole netconsole="@/,@$(getprop dhcp.eth0.gateway)/"
393 function do_bootcomplete()
395 hciconfig | grep -q hci || pm disable com.android.bluetooth
399 [ -z "$(getprop persist.sys.root_access)" ] && setprop persist.sys.root_access 3
401 lsmod | grep -Ehq "brcmfmac|rtl8723be" && setprop wlan.no-unload-driver 1
404 1866???|1867???|1869???) # ThinkPad X41 Tablet
415 6363???|6364???|6366???) # ThinkPad X60 Tablet
417 7762???|7763???|7767???) # ThinkPad X61 Tablet
428 7448???|7449???|7450???|7453???) # ThinkPad X200 Tablet
431 setkeycodes 0xe012 158
436 echo on > /sys/devices/pci0000:00/0000:00:15.1/i2c_designware.1/power/control
439 pm disable com.android.bluetooth
445 # [ -d /proc/asound/card0 ] || modprobe snd-dummy
446 for c in $(grep '\[.*\]' /proc/asound/cards | awk '{print $1}'); do
447 f=/system/etc/alsa/$(cat /proc/asound/card$c/id).state
449 alsa_ctl -f $f restore $c
452 alsa_amixer -c $c set Master on
453 alsa_amixer -c $c set Master 100%
454 alsa_amixer -c $c set Headphone on
455 alsa_amixer -c $c set Headphone 100%
456 alsa_amixer -c $c set Speaker 100%
457 alsa_amixer -c $c set Capture 80%
458 alsa_amixer -c $c set Capture cap
459 alsa_amixer -c $c set PCM 100 unmute
460 alsa_amixer -c $c set SPO unmute
461 alsa_amixer -c $c set IEC958 on
462 alsa_amixer -c $c set 'Mic Boost' 1
463 alsa_amixer -c $c set 'Internal Mic Boost' 1
470 PATH=/sbin:/system/bin:/system/xbin
472 DMIPATH=/sys/class/dmi/id
473 BOARD=$(cat $DMIPATH/board_name)
474 PRODUCT=$(cat $DMIPATH/product_name)
476 # import cmdline variables
477 for c in `cat /proc/cmdline`; do
479 BOOT_IMAGE=*|iso-scan/*|*.*=*)
486 [ -n "$DEBUG" ] && set_property debug.logcat 1
494 [ -n "$DEBUG" ] && set -x || exec &> /dev/null
496 # import the vendor specific script
497 hw_sh=/vendor/etc/init.sh
498 [ -e $hw_sh ] && source $hw_sh
502 [ -n "$DEBUG" ] && do_netconsole