2 # Copyright (C) 2013-2015 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
16 setprop ro.product.manufacturer "$(cat $DMIPATH/sys_vendor)"
17 setprop ro.product.model "$PRODUCT"
19 # a hack for USB modem
20 lsusb | grep 1a8d:1000 && eject
22 # in case no cpu governor driver autoloads
23 [ -d /sys/devices/system/cpu/cpu0/cpufreq ] || modprobe acpi-cpufreq
26 function init_hal_audio()
30 [ -d /proc/asound/card0 ] || modprobe snd-sb16 isapnp=0 irq=5
36 if [ "`cat /proc/asound/card0/id`" = "IntelHDMI" ]; then
37 [ -d /proc/asound/card1 ] || set_property ro.hardware.audio.primary hdmi
41 function init_hal_bluetooth()
43 for r in /sys/class/rfkill/*; do
45 [ "$type" = "wlan" -o "$type" = "bluetooth" ] && echo 1 > $r/state
50 BTUART_PORT=/dev/ttyS1
58 # Fix MacBook 2013-2015 (Air6/7&Pro11/12) BCM4360 ssb&wl conflict.
59 MacBookPro11* | MacBookPro12* | MacBookAir6* | MacBookAir7*)
68 for bt in $(lsusb -v | awk ' /Class:.E0/ { print $9 } '); do
69 chown 1002.1002 $bt && chmod 660 $bt
75 if [ -n "$BTUART_PORT" ]; then
76 set_property hal.bluetooth.uart $BTUART_PORT
77 chown bluetooth.bluetooth $BTUART_PORT
78 start btattach:-B$BTUART_PORT
79 log -t hciconfig -p i "`hciconfig`"
83 function init_hal_camera()
88 function init_hal_gps()
94 function set_drm_mode()
104 [ -n "$drm_mode" ] && set_property debug.drm.mode.force $drm_mode
107 function init_uvesafb()
111 UVESA_MODE=${UVESA_MODE:-1600x900}
117 [ "$HWACCEL" = "0" ] && bpp=16 || bpp=32
118 modprobe uvesafb mode_option=${UVESA_MODE:-1024x768}-$bpp ${UVESA_OPTION:-mtrr=3 scroll=redraw}
121 function init_hal_gralloc()
123 case "$(cat /proc/fb | head -1)" in
125 # set_property ro.hardware.hwcomposer drm
127 0*inteldrmfb|0*radeondrmfb|0*nouveaufb|0*svgadrmfb)
128 set_property ro.hardware.gralloc drm
138 [ -n "$DEBUG" ] && set_property debug.egl.trace error
141 function init_hal_hwcomposer()
147 function init_hal_lights()
149 chown 1000.1000 /sys/class/backlight/*/brightness
152 function init_hal_power()
154 for p in /sys/class/rtc/*; do
155 echo disabled > $p/device/power/wakeup
165 function init_hal_sensors()
167 # if we have sensor module for our hardware, use it
168 ro_hardware=$(getprop ro.hardware)
169 [ -f /system/lib/hw/sensors.${ro_hardware}.so ] && return 0
171 local hal_sensors=kbd
172 case "$(cat $DMIPATH/uevent)" in
174 set_property ro.ignore_atkbd 1
186 set_property ro.ignore_atkbd 1
187 set_property hal.sensors.kbd.type 2
189 *TEGA*|*2010:svnIntel:*)
190 set_property ro.ignore_atkbd 1
191 set_property hal.sensors.kbd.type 1
196 set_property ro.ignore_atkbd 1
197 set_property hal.sensors.kbd.type 1
210 set_property hal.sensors.kbd.type 6
211 set_property poweroff.doubleclick 0
212 set_property qemu.hw.mainkeys 1
215 set_property ro.ignore_atkbd 1
216 set_property poweroff.doubleclick 0
222 modprobe lis3lv02d_i2c
223 echo -n "enabled" > /sys/class/thermal/thermal_zone0/mode
230 set_property hal.sensors.iio.accel.matrix 1,0,0,0,-1,0,0,0,-1
236 # has iio sensor-hub?
237 if [ -n "`ls /sys/bus/iio/devices/iio:device* 2> /dev/null`" ]; then
238 busybox chown -R 1000.1000 /sys/bus/iio/devices/iio:device*/
239 lsmod | grep -q hid_sensor_accel_3d && hal_sensors=hsb || hal_sensors=iio
240 elif lsmod | grep -q lis3lv02d_i2c; then
244 set_property ro.hardware.sensors $hal_sensors
247 function create_pointercal()
249 if [ ! -e /data/misc/tscal/pointercal ]; then
250 mkdir -p /data/misc/tscal
251 touch /data/misc/tscal/pointercal
252 chown 1000.1000 /data/misc/tscal /data/misc/tscal/*
253 chmod 775 /data/misc/tscal
254 chmod 664 /data/misc/tscal/pointercal
258 function init_tscal()
262 modprobe gslx680_ts_acpi
264 T91|T101|ET2002|74499FU|945GSE-ITE8712|CF-19[CDYFGKLP]*)
272 for usbts in $(lsusb | awk '{ print $6 }'); do
286 case "$(cat $DMIPATH/uevent)" in
287 *TEGA*|*2010:svnIntel:*|*Lucid-MWE*)
288 set_property rild.libpath /system/lib/libhuaweigeneric-ril.so
289 set_property rild.libargs "-d /dev/ttyUSB2 -v /dev/ttyUSB1"
290 set_property ro.radio.noril no
293 set_property ro.radio.noril yes
298 function init_cpu_governor()
300 governor=$(getprop cpu.governor)
303 for cpu in $(ls -d /sys/devices/system/cpu/cpu?); do
304 echo $governor > $cpu/cpufreq/scaling_governor || return 1
326 function do_netconsole()
328 modprobe netconsole netconsole="@/,@$(getprop dhcp.eth0.gateway)/"
331 function do_bootcomplete()
335 [ -z "$(getprop persist.sys.root_access)" ] && setprop persist.sys.root_access 3
337 # FIXME: autosleep works better on i965?
338 [ "$(getprop debug.mesa.driver)" = "i965" ] && setprop debug.autosleep 1
340 lsmod | grep -e brcmfmac && setprop wlan.no-unload-driver 1
343 1866???|1867???|1869???) # ThinkPad X41 Tablet
354 6363???|6364???|6366???) # ThinkPad X60 Tablet
356 7762???|7763???|7767???) # ThinkPad X61 Tablet
367 7448???|7449???|7450???|7453???) # ThinkPad X200 Tablet
370 setkeycodes 0xe012 158
378 # [ -d /proc/asound/card0 ] || modprobe snd-dummy
379 for c in $(grep '\[.*\]' /proc/asound/cards | awk '{print $1}'); do
380 f=/system/etc/alsa/$(cat /proc/asound/card$c/id).state
382 alsa_ctl -f $f restore $c
385 alsa_amixer -c $c set Master on
386 alsa_amixer -c $c set Master 100%
387 alsa_amixer -c $c set Headphone on
388 alsa_amixer -c $c set Headphone 100%
389 alsa_amixer -c $c set Speaker 100%
390 alsa_amixer -c $c set Capture 100%
391 alsa_amixer -c $c set Capture cap
392 alsa_amixer -c $c set PCM 100 unmute
393 alsa_amixer -c $c set SPO unmute
394 alsa_amixer -c $c set 'Mic Boost' 3
395 alsa_amixer -c $c set 'Internal Mic Boost' 3
404 local hci=`hciconfig | grep ^hci | cut -d: -f1`
405 local btd="`getprop init.svc.bluetoothd`"
406 log -t bluetoothd -p i "$btd ($hci)"
407 if [ -n "`getprop hal.bluetooth.uart`" ]; then
408 [ "`getprop init.svc.bluetoothd`" = "running" ] && hciconfig $hci up
412 PATH=/sbin:/system/bin:/system/xbin
414 DMIPATH=/sys/class/dmi/id
415 BOARD=$(cat $DMIPATH/board_name)
416 PRODUCT=$(cat $DMIPATH/product_name)
418 # import cmdline variables
419 for c in `cat /proc/cmdline`; do
421 BOOT_IMAGE=*|iso-scan/*|*.*=*)
428 set_property debug.egl.hw $HWACCEL
431 [ -n "$DEBUG" ] && set_property debug.logcat 1
439 [ -n "$DEBUG" ] && set -x || exec &> /dev/null
441 # import the vendor specific script
442 hw_sh=/vendor/etc/init.sh
443 [ -e $hw_sh ] && source $hw_sh
447 [ -n "$DEBUG" ] && do_netconsole