diff options
author | Victor Lowther <victor.lowther@gmail.com> | 2009-12-05 11:10:50 -0600 |
---|---|---|
committer | Victor Lowther <victor.lowther@gmail.com> | 2009-12-05 11:10:50 -0600 |
commit | 71c88ca37b0be0ad35555c53e4e059f014592eff (patch) | |
tree | d424fa852179d0353391cc207f448e60464696e7 | |
parent | c6b37b9a0d5f12b7067bf24627af19fed6bcde5a (diff) | |
parent | f3886cadd361f9f1659c2f555e5a0e74ed9422b6 (diff) |
Merge branch 'master' into native-quirk-db
-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 36f9e34..3beb529 100644 --- a/pm/pm-functions.in +++ b/pm/pm-functions.in @@ -52,6 +52,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 @@ -271,3 +275,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 |