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
48 BTUART_PORT=/dev/ttyS1
49 brcm_patchram_plus -d --no2bytes --enable_hci --patchram /system/lib/firmware/brcm/bcm43241b4.hcd $BTUART_PORT
57 for bt in $(lsusb -v | awk ' /Class:.E0/ { print $9 } '); do
58 chown 1002.1002 $bt && chmod 660 $bt
64 if [ -n "$BTUART_PORT" ]; then
65 set_property hal.bluetooth.uart $BTUART_PORT
66 chown bluetooth.bluetooth $BTUART_PORT
67 log -t hciconfig -p i "`hciconfig`"
71 function init_hal_camera()
73 [ -c /dev/video0 ] || modprobe vivi
76 function init_hal_gps()
82 function set_drm_mode()
92 [ -n "$drm_mode" ] && set_property debug.drm.mode.force $drm_mode
95 function init_uvesafb()
99 UVESA_MODE=${UVESA_MODE:-1280x800}
102 UVESA_MODE=${UVESA_MODE:-1600x900}
105 UVESA_MODE=${UVESA_MODE:-1024x600}
108 UVESA_MODE=${UVESA_MODE:-1024x768}
114 modprobe uvesafb mode_option=${UVESA_MODE:-800x600}-16 ${UVESA_OPTION:-mtrr=3 scroll=redraw}
117 function init_hal_gralloc()
119 case "$(cat /proc/fb | head -1)" in
121 set_property ro.hardware.hwcomposer drm
123 0*inteldrmfb|0*radeondrmfb|0*nouveaufb|0*svgadrmfb)
124 set_property ro.hardware.gralloc drm
126 [ -n "$DEBUG" ] && set_property debug.egl.trace error
132 [ "$HWACCEL" = "1" ] || set_property debug.egl.hw 0
137 function init_hal_hwcomposer()
143 function init_hal_lights()
145 chown 1000.1000 /sys/class/backlight/*/brightness
148 function init_hal_power()
150 for p in /sys/class/rtc/*; do
151 echo disabled > $p/device/power/wakeup
161 function init_hal_sensors()
163 local hal_sensors=kbd
164 case "$(cat $DMIPATH/uevent)" in
166 set_property ro.ignore_atkbd 1
178 set_property ro.ignore_atkbd 1
179 set_property hal.sensors.kbd.type 2
181 *TEGA*|*2010:svnIntel:*)
182 set_property ro.ignore_atkbd 1
183 set_property hal.sensors.kbd.type 1
188 set_property ro.ignore_atkbd 1
189 set_property hal.sensors.kbd.type 1
202 set_property hal.sensors.kbd.type 6
203 set_property poweroff.doubleclick 0
204 set_property qemu.hw.mainkeys 1
207 set_property ro.ignore_atkbd 1
208 set_property poweroff.doubleclick 0
214 modprobe lis3lv02d_i2c
216 echo -n "enabled" > /sys/class/thermal/thermal_zone0/mode
226 # has iio sensor-hub?
227 if [ -n "`ls /sys/bus/iio/devices/iio:device* 2> /dev/null`" ]; then
228 busybox chown -R 1000.1000 /sys/bus/iio/devices/iio:device*/
229 lsmod | grep -q hid_sensor_accel_3d && hal_sensors=hsb || hal_sensors=iio
232 set_property ro.hardware.sensors $hal_sensors
235 function create_pointercal()
237 if [ ! -e /data/misc/tscal/pointercal ]; then
238 mkdir -p /data/misc/tscal
239 touch /data/misc/tscal/pointercal
240 chown 1000.1000 /data/misc/tscal /data/misc/tscal/*
241 chmod 775 /data/misc/tscal
242 chmod 664 /data/misc/tscal/pointercal
246 function init_tscal()
250 modprobe gslx680_ts_acpi
252 T91|T101|ET2002|74499FU|945GSE-ITE8712|CF-19[CDYFGKLP]*)
260 for usbts in $(lsusb | awk '{ print $6 }'); do
274 case "$(cat $DMIPATH/uevent)" in
275 *TEGA*|*2010:svnIntel:*|*Lucid-MWE*)
276 set_property rild.libpath /system/lib/libhuaweigeneric-ril.so
277 set_property rild.libargs "-d /dev/ttyUSB2 -v /dev/ttyUSB1"
284 function init_cpu_governor()
286 governor=$(getprop cpu.governor)
289 for cpu in $(ls -d /sys/devices/system/cpu/cpu?); do
290 echo $governor > $cpu/cpufreq/scaling_governor || return 1
313 function do_netconsole()
315 modprobe netconsole netconsole="@/,@$(getprop dhcp.eth0.gateway)/"
318 function do_bootcomplete()
322 [ -z "$(getprop persist.sys.root_access)" ] && setprop persist.sys.root_access 3
324 # FIXME: autosleep works better on i965?
325 [ "$(getprop debug.mesa.driver)" = "i965" ] && setprop debug.autosleep 1
327 lsmod | grep -e brcmfmac && setprop wlan.no-unload-driver 1
330 1866???|1867???|1869???) # ThinkPad X41 Tablet
341 6363???|6364???|6366???) # ThinkPad X60 Tablet
343 7762???|7763???|7767???) # ThinkPad X61 Tablet
354 7448???|7449???|7450???|7453???) # ThinkPad X200 Tablet
357 setkeycodes 0xe012 158
365 # [ -d /proc/asound/card0 ] || modprobe snd-dummy
366 for c in $(grep '\[.*\]' /proc/asound/cards | awk '{print $1}'); do
367 f=/system/etc/alsa/$(cat /proc/asound/card$c/id).state
369 alsa_ctl -f $f restore $c
372 alsa_amixer -c $c set Master on
373 alsa_amixer -c $c set Master 100%
374 alsa_amixer -c $c set Headphone on
375 alsa_amixer -c $c set Headphone 100%
376 alsa_amixer -c $c set Speaker 100%
377 alsa_amixer -c $c set Capture 100%
378 alsa_amixer -c $c set Capture cap
379 alsa_amixer -c $c set PCM 100 unmute
380 alsa_amixer -c $c set SPO unmute
381 alsa_amixer -c $c set 'Mic Boost' 3
382 alsa_amixer -c $c set 'Internal Mic Boost' 3
389 local hci=`hciconfig | grep ^hci | cut -d: -f1`
390 local btd="`getprop init.svc.bluetoothd`"
391 log -t bluetoothd -p i "$btd ($hci)"
392 if [ -n "`getprop hal.bluetooth.uart`" ]; then
393 [ "`getprop init.svc.bluetoothd`" = "running" ] && hciconfig $hci up
397 PATH=/sbin:/system/bin:/system/xbin
399 DMIPATH=/sys/class/dmi/id
400 BOARD=$(cat $DMIPATH/board_name)
401 PRODUCT=$(cat $DMIPATH/product_name)
403 # import cmdline variables
404 for c in `cat /proc/cmdline`; do
406 androidboot.hardware=*)
412 set_property debug.egl.hw $HWACCEL
415 set_property debug.logcat 1
422 [ -n "$DEBUG" ] && set -x || exec &> /dev/null
424 # import the vendor specific script
425 hw_sh=/vendor/etc/init.sh
426 [ -e $hw_sh ] && source $hw_sh
430 [ -n "$DEBUG" ] && do_netconsole