2 # Copyright (C) 2013 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
15 # a hack for USB modem
16 lsusb | grep 1a8d:1000 && eject
18 # in case no cpu governor driver autoloads
19 [ -d /sys/devices/system/cpu/cpu0/cpufreq ] || modprobe acpi-cpufreq
30 function init_hal_audio()
34 [ -d /proc/asound/card0 ] || modprobe snd-sb16 isapnp=0 irq=5
41 function init_hal_bluetooth()
43 for r in /sys/class/rfkill/*; do
45 [ "$type" = "wlan" -o "$type" = "bluetooth" ] && echo 1 > $r/state
48 # these modules are incompatible with bluedroid
52 set_property ro.rfkilldisabled 1
55 function init_hal_camera()
57 [ -c /dev/video0 ] || modprobe vivi
60 function init_hal_gps()
66 function set_drm_mode()
76 [ -n "$drm_mode" ] && set_property debug.drm.mode.force $drm_mode
79 function init_uvesafb()
83 UVESA_MODE=${UVESA_MODE:-1280x800}
86 UVESA_MODE=${UVESA_MODE:-1600x900}
89 UVESA_MODE=${UVESA_MODE:-1024x600}
92 UVESA_MODE=${UVESA_MODE:-1024x768}
98 modprobe uvesafb mode_option=${UVESA_MODE:-800x600}-16 ${UVESA_OPTION:-mtrr=3 scroll=redraw}
101 function init_hal_gralloc()
103 case "$(cat /proc/fb | head -1)" in
104 0*inteldrmfb|0*radeondrmfb)
105 set_property ro.hardware.gralloc drm
114 [ "$HWACCEL" = "1" ] || set_property debug.egl.hw 0
119 function init_hal_hwcomposer()
125 function init_hal_lights()
127 chown 1000.1000 /sys/class/backlight/*/brightness
130 function init_hal_power()
132 for p in /sys/class/rtc/*; do
133 echo disabled > $p/device/power/wakeup
143 function init_hal_sensors()
145 local hal_sensors=kbd
146 case "$(cat $DMIPATH/uevent)" in
148 set_property ro.ignore_atkbd 1
160 set_property ro.ignore_atkbd 1
161 set_property hal.sensors.kbd.type 2
163 *TEGA*|*2010:svnIntel:*)
164 set_property ro.ignore_atkbd 1
165 set_property hal.sensors.kbd.type 1
170 set_property ro.ignore_atkbd 1
171 set_property hal.sensors.kbd.type 1
184 set_property hal.sensors.kbd.type 6
185 set_property poweroff.doubleclick 0
186 set_property qemu.hw.mainkeys 1
189 set_property ro.ignore_atkbd 1
190 set_property poweroff.doubleclick 0
196 modprobe lis3lv02d_i2c
198 echo -n "enabled" > /sys/class/thermal/thermal_zone0/mode
209 for i in /sys/bus/iio/devices/iio:device?; do
210 busybox chown -R 1000.1000 /sys/bus/iio/devices/iio:device?/
211 lsmod | grep -q hid_sensor_accel_3d && hal_sensors=hsb || hal_sensors=iio
215 set_property ro.hardware.sensors $hal_sensors
218 function create_pointercal()
220 if [ ! -e /data/misc/tscal/pointercal ]; then
221 mkdir -p /data/misc/tscal
222 touch /data/misc/tscal/pointercal
223 chown 1000.1000 /data/misc/tscal /data/misc/tscal/*
224 chmod 775 /data/misc/tscal
225 chmod 664 /data/misc/tscal/pointercal
229 function init_tscal()
232 T91|T101|ET2002|74499FU|945GSE-ITE8712|CF-19[CDYFGKLP]*)
240 for usbts in $(lsusb | awk '{ print $6 }'); do
254 case "$(cat $DMIPATH/uevent)" in
255 *TEGA*|*2010:svnIntel:*|*Lucid-MWE*)
256 set_property rild.libpath /system/lib/libhuaweigeneric-ril.so
257 set_property rild.libargs "-d /dev/ttyUSB2 -v /dev/ttyUSB1"
260 set_property rild.libpath /system/lib/libreference-ril.so
261 set_property rild.libargs "-d /dev/ttyUSB2"
266 function init_cpu_governor()
268 governor=$(getprop cpu.governor)
271 for cpu in $(ls -d /sys/devices/system/cpu/cpu?); do
272 echo $governor > $cpu/cpufreq/scaling_governor || return 1
295 function do_netconsole()
297 modprobe netconsole netconsole="@/,@$(getprop dhcp.eth0.gateway)/"
300 function do_bootcomplete()
304 [ -z "$(getprop persist.sys.root_access)" ] && setprop persist.sys.root_access 3
306 # FIXME: autosleep works better on i965?
307 [ "$(getprop debug.mesa.driver)" = "i965" ] && setprop debug.autosleep 1
309 lsmod | grep -e brcmfmac && setprop wlan.no-unload-driver 1
311 for bt in $(lsusb -v | awk ' /Class:.E0/ { print $9 } '); do
312 chown 1002.1002 $bt && chmod 660 $bt
316 1866???|1867???|1869???) # ThinkPad X41 Tablet
327 6363???|6364???|6366???) # ThinkPad X60 Tablet
329 7762???|7763???|7767???) # ThinkPad X61 Tablet
340 7448???|7449???|7450???|7453???) # ThinkPad X200 Tablet
343 setkeycodes 0xe012 158
351 # [ -d /proc/asound/card0 ] || modprobe snd-dummy
352 for c in $(grep '\[.*\]' /proc/asound/cards | awk '{print $1}'); do
353 f=/system/etc/alsa/$(cat /proc/asound/card$c/id).state
355 alsa_ctl -f $f restore $c
358 alsa_amixer -c $c set Master on
359 alsa_amixer -c $c set Master 100%
360 alsa_amixer -c $c set Headphone on
361 alsa_amixer -c $c set Headphone 100%
362 alsa_amixer -c $c set Speaker 100%
363 alsa_amixer -c $c set Capture 100%
364 alsa_amixer -c $c set Capture cap
365 alsa_amixer -c $c set PCM 100 unmute
366 alsa_amixer -c $c set 'Mic Boost' 3
367 alsa_amixer -c $c set 'Internal Mic Boost' 3
372 PATH=/system/bin:/system/xbin
374 DMIPATH=/sys/class/dmi/id
375 BOARD=$(cat $DMIPATH/board_name)
376 PRODUCT=$(cat $DMIPATH/product_name)
378 # import cmdline variables
379 for c in `cat /proc/cmdline`; do
381 androidboot.hardware=*)
389 [ -n "$DEBUG" ] && set -x || exec &> /dev/null
391 # import the vendor specific script
392 hw_sh=/vendor/etc/init.sh
393 [ -e $hw_sh ] && source $hw_sh
397 [ -n "$DEBUG" ] && do_netconsole