1#!/vendor/bin/sh 2 3set -e 4 5do_id() 6{ 7 cat /sys/class/leds/vibrator/device/modalias | sed 's/^i2c://g' 8} 9 10do_ping() 11{ 12 test "$(do_id)" == "cs40l25a" 13} 14 15do_enable() 16{ 17 /system/bin/idlcli vibrator on "${@}" 18} 19 20do_disable() 21{ 22 /system/bin/idlcli vibrator off 23} 24 25do_state() 26{ 27 local state="$(cat /sys/class/leds/vibrator/device/vibe_state)" 28 if [[ "${state}" == "0" ]] 29 then 30 echo "stopped" 31 else 32 echo "running" 33 fi 34} 35 36do_dump() 37{ 38 local loc="$(basename /sys/class/leds/vibrator/device/driver/*-0043)" 39 cat /sys/kernel/debug/regmap/${loc}/registers 40} 41 42do_help() 43{ 44 local name="$(basename "${0}")" 45 echo "Usage:" 46 echo " ${name} id - Prints controller ID" 47 echo " ${name} ping - Verifies probe succedded" 48 echo " ${name} enable <ms> - Enables vibrator for <ms> milliseconds" 49 echo " ${name} disable - Disables vibrator." 50 echo " ${name} state - Returns 'stopped' or 'running' state." 51 echo " ${name} dump - Dumps memory mapped registers." 52} 53 54if [[ "${#}" -gt "0" ]] 55then 56 cmd="do_${1}" && shift 57fi 58 59if ! typeset -f "${cmd}" >/dev/null 60then 61 cmd="do_help" 62fi 63 64exec "${cmd}" "${@}" 65