2 # Copyright (C) 2013-2015 The Android-x86 Open Source Project
4 # License: GNU Public License v2 or later
7 function set_property()
9 # this must be run before post-fs stage
10 echo $1=$2 >> /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
37 function init_hal_bluetooth()
39 for r in /sys/class/rfkill/*; do
41 [ "$type" = "wlan" -o "$type" = "bluetooth" ] && echo 1 > $r/state
46 BTUART_PORT=/dev/ttyS1
54 for bt in $(lsusb -v | awk ' /Class:.E0/ { print $9 } '); do
55 chown 1002.1002 $bt && chmod 660 $bt
61 if [ -n "$BTUART_PORT" ]; then
62 set_property hal.bluetooth.uart $BTUART_PORT
63 chown bluetooth.bluetooth $BTUART_PORT
64 btattach -P bcm -B $BTUART_PORT &
65 log -t hciconfig -p i "`hciconfig`"
69 function init_hal_camera()
71 [ -c /dev/video0 ] || modprobe vivi
74 function init_hal_gps()
80 function set_drm_mode()
90 [ -n "$drm_mode" ] && set_property debug.drm.mode.force $drm_mode
93 function init_uvesafb()
97 UVESA_MODE=${UVESA_MODE:-1280x800}
100 UVESA_MODE=${UVESA_MODE:-1600x900}
103 UVESA_MODE=${UVESA_MODE:-1024x600}
106 UVESA_MODE=${UVESA_MODE:-1024x768}
112 modprobe uvesafb mode_option=${UVESA_MODE:-800x600}-32 ${UVESA_OPTION:-mtrr=3 scroll=redraw}
115 function init_hal_gralloc()
117 case "$(cat /proc/fb | head -1)" in
119 set_property ro.hardware.hwcomposer drm
121 0*inteldrmfb|0*radeondrmfb|0*nouveaufb|0*svgadrmfb)
122 set_property ro.hardware.gralloc drm
132 [ -n "$DEBUG" ] && set_property debug.egl.trace error
135 function init_hal_hwcomposer()
141 function init_hal_lights()
143 chown 1000.1000 /sys/class/backlight/*/brightness
146 function init_hal_power()
148 for p in /sys/class/rtc/*; do
149 echo disabled > $p/device/power/wakeup
159 function init_hal_sensors()
161 local hal_sensors=kbd
162 case "$(cat $DMIPATH/uevent)" in
164 set_property ro.ignore_atkbd 1
176 set_property ro.ignore_atkbd 1
177 set_property hal.sensors.kbd.type 2
179 *TEGA*|*2010:svnIntel:*)
180 set_property ro.ignore_atkbd 1
181 set_property hal.sensors.kbd.type 1
186 set_property ro.ignore_atkbd 1
187 set_property hal.sensors.kbd.type 1
200 set_property hal.sensors.kbd.type 6
201 set_property poweroff.doubleclick 0
202 set_property qemu.hw.mainkeys 1
205 set_property ro.ignore_atkbd 1
206 set_property poweroff.doubleclick 0
212 modprobe lis3lv02d_i2c
214 echo -n "enabled" > /sys/class/thermal/thermal_zone0/mode
224 # has iio sensor-hub?
225 if [ -n "`ls /sys/bus/iio/devices/iio:device* 2> /dev/null`" ]; then
226 busybox chown -R 1000.1000 /sys/bus/iio/devices/iio:device*/
227 lsmod | grep -q hid_sensor_accel_3d && hal_sensors=hsb || hal_sensors=iio
230 set_property ro.hardware.sensors $hal_sensors
233 function create_pointercal()
235 if [ ! -e /data/misc/tscal/pointercal ]; then
236 mkdir -p /data/misc/tscal
237 touch /data/misc/tscal/pointercal
238 chown 1000.1000 /data/misc/tscal /data/misc/tscal/*
239 chmod 775 /data/misc/tscal
240 chmod 664 /data/misc/tscal/pointercal
244 function init_tscal()
248 modprobe gslx680_ts_acpi
250 T91|T101|ET2002|74499FU|945GSE-ITE8712|CF-19[CDYFGKLP]*)
258 for usbts in $(lsusb | awk '{ print $6 }'); do
272 case "$(cat $DMIPATH/uevent)" in
273 *TEGA*|*2010:svnIntel:*|*Lucid-MWE*)
274 set_property rild.libpath /system/lib/libhuaweigeneric-ril.so
275 set_property rild.libargs "-d /dev/ttyUSB2 -v /dev/ttyUSB1"
282 function init_cpu_governor()
284 governor=$(getprop cpu.governor)
287 for cpu in $(ls -d /sys/devices/system/cpu/cpu?); do
288 echo $governor > $cpu/cpufreq/scaling_governor || return 1
311 function do_netconsole()
313 modprobe netconsole netconsole="@/,@$(getprop dhcp.eth0.gateway)/"
316 function do_bootcomplete()
320 [ -z "$(getprop persist.sys.root_access)" ] && setprop persist.sys.root_access 3
322 # FIXME: autosleep works better on i965?
323 [ "$(getprop debug.mesa.driver)" = "i965" ] && setprop debug.autosleep 1
325 lsmod | grep -e brcmfmac && setprop wlan.no-unload-driver 1
328 1866???|1867???|1869???) # ThinkPad X41 Tablet
339 6363???|6364???|6366???) # ThinkPad X60 Tablet
341 7762???|7763???|7767???) # ThinkPad X61 Tablet
352 7448???|7449???|7450???|7453???) # ThinkPad X200 Tablet
355 setkeycodes 0xe012 158
363 # [ -d /proc/asound/card0 ] || modprobe snd-dummy
364 for c in $(grep '\[.*\]' /proc/asound/cards | awk '{print $1}'); do
365 f=/system/etc/alsa/$(cat /proc/asound/card$c/id).state
367 alsa_ctl -f $f restore $c
370 alsa_amixer -c $c set Master on
371 alsa_amixer -c $c set Master 100%
372 alsa_amixer -c $c set Headphone on
373 alsa_amixer -c $c set Headphone 100%
374 alsa_amixer -c $c set Speaker 100%
375 alsa_amixer -c $c set Capture 100%
376 alsa_amixer -c $c set Capture cap
377 alsa_amixer -c $c set PCM 100 unmute
378 alsa_amixer -c $c set SPO unmute
379 alsa_amixer -c $c set 'Mic Boost' 3
380 alsa_amixer -c $c set 'Internal Mic Boost' 3
387 local hci=`hciconfig | grep ^hci | cut -d: -f1`
388 local btd="`getprop init.svc.bluetoothd`"
389 log -t bluetoothd -p i "$btd ($hci)"
390 if [ -n "`getprop hal.bluetooth.uart`" ]; then
391 [ "`getprop init.svc.bluetoothd`" = "running" ] && hciconfig $hci up
395 PATH=/sbin:/system/bin:/system/xbin
397 DMIPATH=/sys/class/dmi/id
398 BOARD=$(cat $DMIPATH/board_name)
399 PRODUCT=$(cat $DMIPATH/product_name)
401 # import cmdline variables
402 for c in `cat /proc/cmdline`; do
404 androidboot.hardware=*)
410 set_property debug.egl.hw $HWACCEL
413 set_property debug.logcat 1
420 [ -n "$DEBUG" ] && set -x || exec &> /dev/null
422 # import the vendor specific script
423 hw_sh=/vendor/etc/init.sh
424 [ -e $hw_sh ] && source $hw_sh
428 [ -n "$DEBUG" ] && do_netconsole