meta-digi-dey: Add acpid support for power key suspend/poweroff.
The acpid applet will run at startup and will listen for power input events. On arrival, it will timestamp the press event, wait for the release event and decide whether to suspend or poweroff based on the time elapsed. https://jira.digi.com/browse/DEL-34 Signed-off-by: Alex Gonzalez <alex.gonzalez@digi.com>
This commit is contained in:
parent
0907a087c1
commit
cfd04a953b
|
|
@ -0,0 +1,2 @@
|
|||
EV_KEY 0x01 KEY_POWER 116 1 pswitch-press
|
||||
EV_KEY 0x01 KEY_POWER 116 0 pswitch-release
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
#!/bin/sh
|
||||
DAEMON=/sbin/acpid
|
||||
NAME=acpid
|
||||
DESC="Busybox ACPI daemon."
|
||||
ARGS="-M /etc/acpi/acpid.map"
|
||||
|
||||
test -f $DAEMON || exit 0
|
||||
|
||||
set -e
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
echo -n "starting $DESC: $NAME... "
|
||||
start-stop-daemon -S -b -n $NAME -a $DAEMON -- $ARGS
|
||||
echo "done."
|
||||
;;
|
||||
stop)
|
||||
echo -n "stopping $DESC: $NAME... "
|
||||
start-stop-daemon -K -n $NAME
|
||||
echo "done."
|
||||
;;
|
||||
restart)
|
||||
echo -n "restarting $DESC: $NAME... "
|
||||
$0 stop
|
||||
$0 start
|
||||
echo "done."
|
||||
;;
|
||||
reload)
|
||||
echo -n "reloading $DESC: $NAME... "
|
||||
killall -HUP $(basename ${DAEMON})
|
||||
echo "done."
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|restart|reload}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
#!/bin/sh
|
||||
|
||||
if [ -f /tmp/pswitch_press ]; then
|
||||
logger -t acpid "Bogus press event, removing."
|
||||
rm -f /tmp/pswitch_press
|
||||
fi
|
||||
|
||||
echo `date +%s` > /tmp/pswitch_press
|
||||
exit 0
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
#!/bin/sh
|
||||
|
||||
POWEROFF_DELAY=2
|
||||
|
||||
if [ ! -f /tmp/pswitch_press ]; then
|
||||
logger -t acpid "No press event."
|
||||
exit -1
|
||||
fi
|
||||
|
||||
while read line
|
||||
do
|
||||
TSTAMP=$line
|
||||
done < /tmp/pswitch_press
|
||||
|
||||
rm -f /tmp/pswitch_press
|
||||
|
||||
TDIFF=$((`date +%s`- $TSTAMP))
|
||||
if [ $TDIFF -lt $POWEROFF_DELAY ]; then
|
||||
logger -t acpid "Power key suspend request."
|
||||
exec /bin/suspend
|
||||
else
|
||||
logger -t acpid "Power key poweroff request."
|
||||
exec /sbin/poweroff
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
|
@ -19,6 +19,10 @@ SRC_URI += "file://0001-del-baudrates.patch \
|
|||
file://busybox-ntpd \
|
||||
file://index.html \
|
||||
file://digi.gif \
|
||||
file://busybox-acpid \
|
||||
file://acpid.map \
|
||||
file://pswitch-press \
|
||||
file://pswitch-release \
|
||||
"
|
||||
|
||||
# Add device handlers to 'mdev' package
|
||||
|
|
@ -42,6 +46,16 @@ FILES_${PN}-ntpd = "${sysconfdir}/init.d/busybox-ntpd"
|
|||
INITSCRIPT_PACKAGES =+ "${PN}-ntpd"
|
||||
INITSCRIPT_NAME_${PN}-ntpd = "busybox-ntpd"
|
||||
|
||||
# ACPID package
|
||||
PACKAGES =+ "${PN}-acpid"
|
||||
FILES_${PN}-acpid = " ${sysconfdir}/init.d/busybox-acpid \
|
||||
${sysconfdir}/acpi/acpid.map \
|
||||
${sysconfdir}/acpi/pswitch-press \
|
||||
${sysconfdir}/acpi/pswitch-release \
|
||||
"
|
||||
INITSCRIPT_PACKAGES =+ "${PN}-acpid"
|
||||
INITSCRIPT_NAME_${PN}-acpid = "busybox-acpid"
|
||||
|
||||
do_install_append() {
|
||||
if grep "CONFIG_MDEV=y" ${WORKDIR}/defconfig; then
|
||||
if grep "CONFIG_FEATURE_MDEV_CONF=y" ${WORKDIR}/defconfig; then
|
||||
|
|
@ -65,4 +79,11 @@ do_install_append() {
|
|||
fi
|
||||
# Install 'suspend' script
|
||||
install -m 0755 ${WORKDIR}/suspend ${D}${base_bindir}
|
||||
if grep "CONFIG_ACPID=y" ${WORKDIR}/defconfig; then
|
||||
install -m 0755 ${WORKDIR}/busybox-acpid ${D}${sysconfdir}/init.d/
|
||||
install -d ${D}${sysconfdir}/acpi/
|
||||
install -m 0755 ${WORKDIR}/acpid.map ${D}${sysconfdir}/acpi/
|
||||
install -m 0755 ${WORKDIR}/pswitch-press ${D}${sysconfdir}/acpi/
|
||||
install -m 0755 ${WORKDIR}/pswitch-release ${D}${sysconfdir}/acpi/
|
||||
fi
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ RDEPENDS_${PN} = "\
|
|||
ubootenv \
|
||||
update-flash \
|
||||
usbutils \
|
||||
busybox-acpid \
|
||||
${MACHINE_ESSENTIAL_EXTRA_RDEPENDS}"
|
||||
|
||||
RRECOMMENDS_${PN} = "\
|
||||
|
|
|
|||
Loading…
Reference in New Issue