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 [ "$HWACCEL" = "0" ] && bpp=16 || bpp=32
113 modprobe uvesafb mode_option=${UVESA_MODE:-800x600}-$bpp ${UVESA_OPTION:-mtrr=3 scroll=redraw}
116 function init_hal_gralloc()
118 case "$(cat /proc/fb | head -1)" in
120 set_property ro.hardware.hwcomposer drm
122 0*inteldrmfb|0*radeondrmfb|0*nouveaufb|0*svgadrmfb)
123 set_property ro.hardware.gralloc drm
133 [ -n "$DEBUG" ] && set_property debug.egl.trace error
136 function init_hal_hwcomposer()
142 function init_hal_lights()
144 chown 1000.1000 /sys/class/backlight/*/brightness
147 function init_hal_power()
149 for p in /sys/class/rtc/*; do
150 echo disabled > $p/device/power/wakeup
160 function init_hal_sensors()
162 local hal_sensors=kbd
163 case "$(cat $DMIPATH/uevent)" in
165 set_property ro.ignore_atkbd 1
177 set_property ro.ignore_atkbd 1
178 set_property hal.sensors.kbd.type 2
180 *TEGA*|*2010:svnIntel:*)
181 set_property ro.ignore_atkbd 1
182 set_property hal.sensors.kbd.type 1
187 set_property ro.ignore_atkbd 1
188 set_property hal.sensors.kbd.type 1
201 set_property hal.sensors.kbd.type 6
202 set_property poweroff.doubleclick 0
203 set_property qemu.hw.mainkeys 1
206 set_property ro.ignore_atkbd 1
207 set_property poweroff.doubleclick 0
213 modprobe lis3lv02d_i2c
215 echo -n "enabled" > /sys/class/thermal/thermal_zone0/mode
225 # has iio sensor-hub?
226 if [ -n "`ls /sys/bus/iio/devices/iio:device* 2> /dev/null`" ]; then
227 busybox chown -R 1000.1000 /sys/bus/iio/devices/iio:device*/
228 lsmod | grep -q hid_sensor_accel_3d && hal_sensors=hsb || hal_sensors=iio
231 set_property ro.hardware.sensors $hal_sensors
234 function create_pointercal()
236 if [ ! -e /data/misc/tscal/pointercal ]; then
237 mkdir -p /data/misc/tscal
238 touch /data/misc/tscal/pointercal
239 chown 1000.1000 /data/misc/tscal /data/misc/tscal/*
240 chmod 775 /data/misc/tscal
241 chmod 664 /data/misc/tscal/pointercal
245 function init_tscal()
249 modprobe gslx680_ts_acpi
251 T91|T101|ET2002|74499FU|945GSE-ITE8712|CF-19[CDYFGKLP]*)
259 for usbts in $(lsusb | awk '{ print $6 }'); do
273 case "$(cat $DMIPATH/uevent)" in
274 *TEGA*|*2010:svnIntel:*|*Lucid-MWE*)
275 set_property rild.libpath /system/lib/libhuaweigeneric-ril.so
276 set_property rild.libargs "-d /dev/ttyUSB2 -v /dev/ttyUSB1"
283 function init_cpu_governor()
285 governor=$(getprop cpu.governor)
288 for cpu in $(ls -d /sys/devices/system/cpu/cpu?); do
289 echo $governor > $cpu/cpufreq/scaling_governor || return 1
312 function do_netconsole()
314 modprobe netconsole netconsole="@/,@$(getprop dhcp.eth0.gateway)/"
317 function do_bootcomplete()
321 [ -z "$(getprop persist.sys.root_access)" ] && setprop persist.sys.root_access 3
323 # FIXME: autosleep works better on i965?
324 [ "$(getprop debug.mesa.driver)" = "i965" ] && setprop debug.autosleep 1
326 lsmod | grep -e brcmfmac && setprop wlan.no-unload-driver 1
329 1866???|1867???|1869???) # ThinkPad X41 Tablet
340 6363???|6364???|6366???) # ThinkPad X60 Tablet
342 7762???|7763???|7767???) # ThinkPad X61 Tablet
353 7448???|7449???|7450???|7453???) # ThinkPad X200 Tablet
356 setkeycodes 0xe012 158
364 # [ -d /proc/asound/card0 ] || modprobe snd-dummy
365 for c in $(grep '\[.*\]' /proc/asound/cards | awk '{print $1}'); do
366 f=/system/etc/alsa/$(cat /proc/asound/card$c/id).state
368 alsa_ctl -f $f restore $c
371 alsa_amixer -c $c set Master on
372 alsa_amixer -c $c set Master 100%
373 alsa_amixer -c $c set Headphone on
374 alsa_amixer -c $c set Headphone 100%
375 alsa_amixer -c $c set Speaker 100%
376 alsa_amixer -c $c set Capture 100%
377 alsa_amixer -c $c set Capture cap
378 alsa_amixer -c $c set PCM 100 unmute
379 alsa_amixer -c $c set SPO unmute
380 alsa_amixer -c $c set 'Mic Boost' 3
381 alsa_amixer -c $c set 'Internal Mic Boost' 3
388 local hci=`hciconfig | grep ^hci | cut -d: -f1`
389 local btd="`getprop init.svc.bluetoothd`"
390 log -t bluetoothd -p i "$btd ($hci)"
391 if [ -n "`getprop hal.bluetooth.uart`" ]; then
392 [ "`getprop init.svc.bluetoothd`" = "running" ] && hciconfig $hci up
396 PATH=/sbin:/system/bin:/system/xbin
398 DMIPATH=/sys/class/dmi/id
399 BOARD=$(cat $DMIPATH/board_name)
400 PRODUCT=$(cat $DMIPATH/product_name)
402 # import cmdline variables
403 for c in `cat /proc/cmdline`; do
405 androidboot.hardware=*)
411 set_property debug.egl.hw $HWACCEL
414 set_property debug.logcat 1
421 [ -n "$DEBUG" ] && set -x || exec &> /dev/null
423 # import the vendor specific script
424 hw_sh=/vendor/etc/init.sh
425 [ -e $hw_sh ] && source $hw_sh
429 [ -n "$DEBUG" ] && do_netconsole