diff options
author | Victor Lowther <victor.lowther@gmail.com> | 2009-12-01 12:35:04 -0600 |
---|---|---|
committer | Victor Lowther <victor.lowther@gmail.com> | 2009-12-01 12:35:04 -0600 |
commit | f3886cadd361f9f1659c2f555e5a0e74ed9422b6 (patch) | |
tree | d7a444b9ecec10a3a398e015d51484bfdf275538 | |
parent | f323e2cf2eddd683721be4eadbdc82f0454e7190 (diff) |
Add support for hibernate after suspend.
Do this by adding a default suspend_hybrid sleep method. With the
default settings, we schedule an alarm for 15 minutes from now, suspend,
and hibernate if we wake up in 15 minutes.
-rw-r--r-- | pm/pm-functions.in | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/pm/pm-functions.in b/pm/pm-functions.in index 4be0f28..47b9483 100644 --- a/pm/pm-functions.in +++ b/pm/pm-functions.in @@ -50,6 +50,10 @@ SUSPEND_MODULE="" HIBERNATE_MODULE="" SUSPEND_HYBRID_MODULE="" +# variables to handle hibernate after suspend support +PM_HIBERNATE_DELAY=900 # 15 minutes +PM_RTC=/sys/class/rtc/rtc0 + # when loading configuration files, allow stash-specific ones # to override the pm-utils global ones. [ -f "${PM_UTILS_LIBDIR}"/defaults ] && . "${PM_UTILS_LIBDIR}"/defaults @@ -269,3 +273,27 @@ if [ -z "$HIBERNATE_MODULE" ] && \ echo -n "disk" > /sys/power/state } fi + +# since the kernel does not directly support hybrid sleep, we do +# something else -- suspend and schedule an alarm to go into +# hibernate if we have slept long enough. +# Only do this if we do not need to do any special video hackery on resume +# from hibernate, though. +if [ -z "$SUSPEND_HYBRID_MODULE" -a -w "$PM_RTC/wakealarm" ] && \ + check_suspend && check_hibernate && ! is_set $HIBERNATE_RESUME_POST_VIDEO; \ + then + SUSPEND_HYBRID_MODULE="kernel" + do_suspend_hybrid() { + WAKETIME=$(( $(cat "$PM_RTC/since_epoch") + PM_HIBERNATE_DELAY)) + echo >"$PM_RTC/wakealarm" + echo $WAKETIME > "$PM_RTC/wakealarm" + do_suspend + NOW=$(cat "$PM_RTC/since_epoch") + if [ "$NOW" -ge "$WAKETIME" -a "$NOW" -lt $((WAKETIME + 30)) ]; then + log "Woken by RTC alarm, hibernating." + do_hibernate + else + echo > "$PM_RTC/wakealarm" + fi + } +fi |