2
0
mirror of https://github.com/koreader/koreader synced 2024-10-31 21:20:20 +00:00

Merge pull request #2200 from NiLuJe/master

Some more Kobo scripts tweaks
This commit is contained in:
Qingping Hou 2016-07-31 13:37:40 -07:00 committed by GitHub
commit 5aae4c6b73
3 changed files with 46 additions and 7 deletions

View File

@ -268,6 +268,7 @@ function Kobo:suspend()
end
function Kobo:resume()
-- Unflag subsystems for suspend
os.execute("echo 0 > /sys/power/state-extended")
-- HACK: wait a bit for the kernel to catch up
os.execute("sleep 0.1")

View File

@ -80,6 +80,12 @@ else
/usr/local/Kobo/nickel -platform kobo -skipFontLoad > /dev/null 2>&1 &
fi
# Ahoy, annoying sickel!
if [ -x /usr/local/Kobo/sickel ] ; then
/usr/local/Kobo/sickel -platform kobo:noscreen > /dev/null 2>&1 &
fi
# Rotation weirdness, part II
echo "${cur_rotate}" > "/sys/class/graphics/fb0/rotate"
cat "/sys/class/graphics/fb0/rotate" > "/sys/class/graphics/fb0/rotate"

View File

@ -1,7 +1,9 @@
#!/bin/sh
export PATH="${PATH}:/sbin:/usr/sbin"
echo "[$(date +'%x @ %X')] Kobo Suspend: BEGIN!"
echo "[$(date +'%x @ %X')] Kobo Suspend: Going to sleep . . ."
# NOTE: Sleep as little as possible here, sleeping has a tendency to make everything mysteriously hang...
# Disable wifi
if lsmod | grep -q sdio_wifi_pwr ; then
wlarm_le -i eth0 down
@ -11,9 +13,23 @@ if lsmod | grep -q sdio_wifi_pwr ; then
echo "[$(date +'%x @ %X')] Kobo Suspend: Killed WiFi"
fi
# Depending on device/FW version, some kernels do not support wakeup_count, account for that
if [ -e "/sys/power/wakeup_count" ] ; then
#HAS_WAKEUP_COUNT="true"
# NOTE: ... and of course, it appears to be broken, which probably explains why nickel doesn't use this facility...
# (By broken, I mean that the system wakes up right away).
# So, unless that changes, unconditionally disable it.
HAS_WAKEUP_COUNT="false"
fi
# Clear the kernel ring buffer... (we're missing a proper -C flag...)
#dmesg -c >/dev/null
# Go to sleep
current_wakeup_count="$(cat /sys/power/wakeup_count)"
echo "[$(date +'%x @ %X')] Kobo Suspend: Current WakeUp count: ${current_wakeup_count}"
if [ "${HAS_WAKEUP_COUNT}" == "true" ] ; then
current_wakeup_count="$(cat /sys/power/wakeup_count)"
echo "[$(date +'%x @ %X')] Kobo Suspend: Current WakeUp count: ${current_wakeup_count}"
fi
echo 1 > /sys/power/state-extended
# NOTE: Sets gSleep_Mode_Suspend to 1. Used as a flag throughout the kernel to suspend/resume various subsystems
# cf. kernel/power/main.c @ L#207
@ -22,10 +38,14 @@ sleep 2
echo "[$(date +'%x @ %X')] Kobo Suspend: Waited for 2s because of reasons..."
sync
echo "[$(date +'%x @ %X')] Kobo Suspend: Synced FS"
echo ${current_wakeup_count} > /sys/power/wakeup_count
echo "[$(date +'%x @ %X')] Kobo Suspend: Wrote WakeUp count: ${current_wakeup_count} ($?)"
if [ "${HAS_WAKEUP_COUNT}" == "true" ] ; then
echo ${current_wakeup_count} > /sys/power/wakeup_count
echo "[$(date +'%x @ %X')] Kobo Suspend: Wrote WakeUp count: ${current_wakeup_count} ($?)"
fi
echo "[$(date +'%x @ %X')] Kobo Suspend: Asking for a suspend to RAM . . ."
echo mem > /sys/power/state
echo "[$(date +'%x @ %X')] Kobo Suspend: Asked to suspend to RAM... ZzZ ZzZ ZzZ? ($?)"
# NOTE: At this point, we *should* be in suspend to RAM, as such, execution should only resume on wakeup...
echo "[$(date +'%x @ %X')] Kobo Suspend: ZzZ ZzZ ZzZ? ($?)"
## NOTE: Ideally, we'd need a way to warn the user that suspending gloriously failed at this point...
## We can safely assume that just from a non-zero return code, without looking at the detailed stderr message
## (most of the failures we'll see are -EBUSY anyway)
@ -33,4 +53,16 @@ echo "[$(date +'%x @ %X')] Kobo Suspend: Asked to suspend to RAM... ZzZ ZzZ ZzZ?
## which is where the non-sensical 1 -> mem -> 0 loop idea comes from...
## cf. nickel_suspend_strace.txt for more details.
echo "[$(date +'%x @ %X')] Kobo Suspend: END! (WakeUp count: $(cat /sys/power/wakeup_count))"
if [ "${HAS_WAKEUP_COUNT}" == "true" ] ; then
echo "[$(date +'%x @ %X')] Kobo Suspend: Woke up! (WakeUp count: $(cat /sys/power/wakeup_count))"
else
echo "[$(date +'%x @ %X')] Kobo Suspend: Woke up!"
fi
# Print tke kernel log since our attempt to sleep...
#dmesg -c
# Now that we're up, unflag subsystems for suspend...
# NOTE: We do that in Kobo:resume() to keep things tidy and easier to follow
#echo 0 > /sys/power/state-extended
#echo "[$(date +'%x @ %X')] Kobo Suspend: Unflagged kernel subsystems for suspend"