-
-
Save dl8bb/236028271959eb503da6176c8a49cc15 to your computer and use it in GitHub Desktop.
Allwinner A20 CEC control script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Nasty script to poke the CEC control memory locations in Allwinner A20 | |
# Find the STANDBY_VALUE we want | |
case $1 in | |
on) | |
STANDBY_VALUE=0 | |
;; | |
off) | |
STANDBY_VALUE=1 | |
;; | |
*) | |
echo Usage: $0 "[on|off]" | |
exit 1 | |
;; | |
esac | |
# Find the offset of cec_count | |
CEC_COUNT_OFFSET=$((16#`grep cec_count /proc/kallsyms | cut -d ' ' -f 1`)) | |
[ $CEC_COUNT_OFFSET == 0 ] && { | |
echo Cannot find cec_count kernel symbol | |
exit 2 | |
} | |
# Find the offset of cec_standby | |
CEC_STANDBY_OFFSET=$((16#`grep cec_standby /proc/kallsyms | cut -d ' ' -f 1`)) | |
[ $CEC_STANDBY_OFFSET == 0 ] && { | |
echo Cannot find cec_standby kernel symbol | |
exit 3 | |
} | |
write_cec_count() { | |
echo -ne "\x$1" | dd of=/dev/kmem seek=$CEC_COUNT_OFFSET count=1 bs=1 2>/dev/null | |
} | |
write_cec_standby() { | |
echo -ne "\x$1" | dd of=/dev/kmem seek=$CEC_STANDBY_OFFSET count=1 bs=1 2>/dev/null | |
} | |
read_cec_count() { | |
dd if=/dev/kmem skip=$CEC_COUNT_OFFSET bs=1 count=1 2>/dev/null | hexdump -e '1/1 "%d"' | |
} | |
# Write the standby value and a count of 30 | |
write_cec_standby $STANDBY_VALUE | |
write_cec_count 1e | |
echo -n Setting... | |
# Wait for the driver to decrement cec_count to 1 | |
CEC_COUNT=30 | |
while [ $CEC_COUNT -gt 1 ]; do | |
CEC_COUNT=`read_cec_count` | |
sleep 1 | |
done | |
echo Done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment