mirror of
https://github.com/FunKey-Project/FunKey-OS.git
synced 2026-03-19 18:32:45 +01:00
rename start_audio_amp to audio_amp
Signed-off-by: Michel-FK <michel.stempin@funkey-project.com>
This commit is contained in:
52
FunKey/board/funkey/rootfs-overlay/usr/local/sbin/audio_amp
Executable file
52
FunKey/board/funkey/rootfs-overlay/usr/local/sbin/audio_amp
Executable file
@@ -0,0 +1,52 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Uncomment the following line to get debug info
|
||||
#set -x
|
||||
|
||||
SELF="$(basename ${0})"
|
||||
SYSTEM_GPIO="/sys/class/gpio"
|
||||
|
||||
# Power Audio Amplifier enable GPIO (('F' - 'A') * 32 + 6 = 166)
|
||||
GPIO_PF6=166
|
||||
|
||||
usage() {
|
||||
>2& echo "Usage: ${SELF} [1|on|ON|On for ON, 0|off|OFF|Off for OFF]"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Check number of arguments
|
||||
if [ ${#} -ne 1 ]; then
|
||||
usage
|
||||
fi
|
||||
|
||||
case "${1}" in
|
||||
1|on|ON|On)
|
||||
|
||||
# Turn ON only if volume is not null
|
||||
if [ "$(volume get)" -ne "0" ]; then
|
||||
echo "Turning audio amplifier ON"
|
||||
else
|
||||
exit 0
|
||||
fi
|
||||
enable=1
|
||||
;;
|
||||
|
||||
0|off|OFF|Off)
|
||||
echo "Turning audio amplifier OFF"
|
||||
enable=0
|
||||
;;
|
||||
|
||||
*)
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
|
||||
# Export the GPIO if necessary
|
||||
if [ ! -d "${SYSTEM_GPIO}/gpio${GPIO_PF6}" ]; then
|
||||
echo ${GPIO_PF6} > "${SYSTEM_GPIO}/export"
|
||||
fi
|
||||
|
||||
# Enable/disable the pwoer audio amplifier
|
||||
echo "out" > "${SYSTEM_GPIO}/gpio${GPIO_PF6}/direction"
|
||||
echo ${enable} > "${SYSTEM_GPIO}/gpio${GPIO_PF6}/value"
|
||||
exit 0
|
||||
@@ -11,7 +11,7 @@ REBOOTING_FILE="/run/rebooting"
|
||||
touch $REBOOTING_FILE
|
||||
|
||||
# Shutdown amp
|
||||
start_audio_amp 0 >/dev/null 2>&1
|
||||
audio_amp off >/dev/null 2>&1
|
||||
|
||||
# Force Read Only
|
||||
ro
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
SELF="$(basename ${0})"
|
||||
SYSTEM_GPIO="/sys/class/gpio"
|
||||
|
||||
# Power Audio Amplifier enable GPIO
|
||||
GPIO_PF6=166
|
||||
|
||||
usage() {
|
||||
>2& echo "Usage: ${SELF} [1 for on, 0 for off]"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Check number of args
|
||||
if [ ${#} -ne 1 ]; then
|
||||
usage
|
||||
fi
|
||||
|
||||
# Check enable arg
|
||||
enable=${1}
|
||||
if [ "${enable}" -eq 1 -o "${enable}" = "on" ]; then
|
||||
|
||||
# Turn ON only if volume is not null
|
||||
if [ "$(volume get)" -ne "0" ]; then
|
||||
echo "Turning audio amplifier ON"
|
||||
else
|
||||
exit 0
|
||||
fi
|
||||
enable=1
|
||||
elif [ "${enable}" -eq 0 -o "${enable}" = "off" ]; then
|
||||
echo "Turning audio amplifier OFF"
|
||||
enable=0
|
||||
else
|
||||
usage
|
||||
fi
|
||||
|
||||
# Export the GPIO if necessary
|
||||
if [ ! -d "${SYSTEM_GPIO}/gpio${GPIO_PF6}" ]; then
|
||||
echo ${GPIO_PF6} > "${SYSTEM_GPIO}/export"
|
||||
fi
|
||||
|
||||
# Enable/disable the pwoer audio amplifier
|
||||
echo "out" > "${SYSTEM_GPIO}/gpio${GPIO_PF6}/direction"
|
||||
echo ${enable} > "${SYSTEM_GPIO}/gpio${GPIO_PF6}/value"
|
||||
exit 0
|
||||
@@ -82,9 +82,9 @@ set_volume() {
|
||||
|
||||
# Turn on/off audio amplifier if necessary
|
||||
if [ ${current_volume} -eq 0 -a ${new_volume} -ne 0 ]; then
|
||||
start_audio_amp 1
|
||||
audio_amp on
|
||||
elif [ ${current_volume} -ne 0 -a ${new_volume} -eq 0 ]; then
|
||||
start_audio_amp 0
|
||||
audio_amp off
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user