diff options
author | Victor Lowther <victor.lowther@gmail.com> | 2008-05-26 06:49:32 -0500 |
---|---|---|
committer | Victor Lowther <victor.lowther@gmail.com> | 2008-05-26 06:49:32 -0500 |
commit | f94d93e8d4d988e7aa1bdc36bbbf0fadea724083 (patch) | |
tree | 35ca914d68aa8fe9ac12d0e7d7611141242161f4 | |
parent | ab2deff4eae5954e02bed2f01fbf81d2300b82fb (diff) | |
parent | a95fac932e9f9a921690860bd01f4e5b88b619c2 (diff) |
Merge branch 'vlowther-binary-video-quirks'
-rw-r--r-- | pm/functions.in | 33 | ||||
-rw-r--r-- | pm/pm-functions.in | 50 | ||||
-rwxr-xr-x | pm/sleep.d/98smart-kernel-video | 33 | ||||
-rwxr-xr-x | pm/sleep.d/99video | 10 | ||||
-rw-r--r-- | pm/sleep.d/Makefile.am | 1 |
5 files changed, 95 insertions, 32 deletions
diff --git a/pm/functions.in b/pm/functions.in index 055d0dd..e4dd63f 100644 --- a/pm/functions.in +++ b/pm/functions.in @@ -188,3 +188,36 @@ restorestate() # $1 = name of state state_exists "$1" && cat "${STORAGEDIR}/state:$1" } + +# If we were told by the user to ignore some parameters from HAL. +# remove them from our list. This implementation is rather stupid. +remove_parameters() { + local x y + if [ "$1" = "all" ]; then + for p in "${STORAGEDIR}/parm:"*; do + [ -O "$p" ] && rm -f "$p"; + done + else + for p in "$@"; do + [ -O "${STORAGEDIR}/parm:$p" ] && \ + rm "${STORAGEDIR}/parm:$p" + done + fi + touch "${STORAGEDIR}/new-parm" +} + +# Add a parameter to our commandline parameters. +add_parameters() { + for x in "$@"; do + touch "${STORAGEDIR}/parm:${x}" + done + # update for next hook. + touch "${STORAGEDIR}/new-parm" +} + +# Remove a parameter from our commandline parameters. +get_parameters() { + for x in "${STORAGEDIR}/parm:"*; do + [ -O "$x" ] && echo "${x##*:}" + done +} diff --git a/pm/pm-functions.in b/pm/pm-functions.in index 3c11667..8a543ff 100644 --- a/pm/pm-functions.in +++ b/pm/pm-functions.in @@ -17,7 +17,6 @@ set -a PM_UTILS_LIBDIR="@PM-UTILS-LIBDIR@" PM_UTILS_ETCDIR="@PM-UTILS-SYSCONFDIR@" PM_UTILS_RUNDIR="/var/run/pm-utils" -PM_CMDLINE="$*" PATH=/sbin:/usr/sbin:/bin:/usr/bin:"${PM_UTILS_LIBDIR}"/bin INHIBIT="${PM_UTILS_RUNDIR}/inhibit" @@ -48,6 +47,11 @@ DROP_PARAMETERS="" set +a +# save our parameter list. Second stupidest way of doing this. +for x in "$@"; do + touch "${STORAGEDIR}/parm:${x}" +done + for cfg in "${PM_UTILS_ETCDIR}"/config.d/*[!~] ; do [ -f "$cfg" ] || continue # Ugly, I know. The goal here is to allow multiple files in @@ -79,6 +83,15 @@ log() printf "$fmt" "$*" } +# update PM_CMDLINE iff someone changed our parameters +update_parameters() +{ + [ -f "${STORAGEDIR}/new-parm" ] || return + export PM_CMDLINE="$(get_parameters)" + rm "${STORAGEDIR}/new-parm" +} + + # if the user asked us to blacklist any hooks, do it. load_hook_blacklist() { @@ -90,34 +103,11 @@ load_hook_blacklist() done } -# If we were told by the user to ignore some parameters from HAL. -# remove them from our list. This implementation is rather stupid. -remove_parameters() { - local x y - for p in "$@"; do - y="" - for x in $PM_CMDLINE; do - # 'all' removes all parameters. - [ "$x" = "$p" -o "$p" = 'all' ] && { - log "Removing parameter $x." - continue - } - y="$y $x" - done - PM_CMDLINE="$y" - done -} - -# -add_parameters() { - log "Adding parameters $@" - PM_CMDLINE="$PM_CMDLINE $@" -} - load_hook_parameters() { [ "$DROP_PARAMETERS" ] && remove_parameters $DROP_PARAMETERS [ "$ADD_PARAMETERS" ] && add_parameters $ADD_PARAMETERS + update_parameters } take_suspend_lock() @@ -155,7 +145,7 @@ hook_ok() return 0 } -# Run all applicalbe hooks, logging success and failure as we go. +# Run all applicable hooks, logging success and failure as we go. run_hooks() { # $1 = type of hook to find. # $2 = paramaters to pass to hooks. @@ -176,17 +166,17 @@ run_hooks() { for base in $(IFS="${oifs}"; for f in "$syshooks/"*[!~] "$phooks/"*[!~]; do [ -O "$f" ] && echo ${f##*/} ; done | $sort | uniq) ; do + IFS="${oifs}" if [ -f "$syshooks/$base" ]; then hook="$syshooks/$base" elif [ -f "$phooks/$base" ]; then hook="$phooks/$base" fi log -n "${hook} $2: " - hook_ok "$hook" && ( - IFS="${oifs}" - "${hook}" $2 - ) + hook_ok "$hook" && "${hook}" $2 hook_exit_status $? + update_parameters + IFS="${nifs}" done IFS="${oifs}" } diff --git a/pm/sleep.d/98smart-kernel-video b/pm/sleep.d/98smart-kernel-video new file mode 100755 index 0000000..651abcb --- /dev/null +++ b/pm/sleep.d/98smart-kernel-video @@ -0,0 +1,33 @@ +#!/bin/sh +# +# Copyright 2008 Victor Lowther <victor.lowther@gmail.com +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of version 2 of the GNU General Public License as +# published by the Free Software Foundation. + + +. "${PM_FUNCTIONS}" + + +# Test to see if the kernel has a video driver that is smart enough to +# handle quirks without external assistance. If it is, disable 99video. +smart_kernel_video() +{ + # If we are using an ATI or nVidia binary driver, no quirks required. + [ -d /sys/module/nvidia -o -d /sys/module/fglrx ] && return 0; + + local kernel_rev="$(uname -r |awk -F '[_-]' '{print $1}')" + # Intel at or after kernel 2.6.26 is also quirk-free. + # FIXME: a more accurate way of testing this? + [ -d /sys/module/i915 ] && \ + [ "$kernel_rev" > "2.6.26" -o "$kernel_rev" = "2.6.26" ] && \ + return 0; + return 1 +} + +case $1 in + suspend|hibernate) + smart_kernel_video && add_parameters "--quirk-none" ;; + *) exit 0 ;; +esac diff --git a/pm/sleep.d/99video b/pm/sleep.d/99video index c8efd12..b927a1b 100755 --- a/pm/sleep.d/99video +++ b/pm/sleep.d/99video @@ -31,7 +31,6 @@ for opt in $PM_CMDLINE; do esac done - reset_brightness() { for bl in /sys/class/backlight/* ; do @@ -93,7 +92,14 @@ vbe_restoremode() } # post the video card -vbe_post() { vbe post; sleep 0.1; } +vbe_post() +{ + local rom="/var/run/video.rom" + # if we do not have a romfile, do not post with it. + [ -f "$rom" ] || unset rom + vbe post $rom + sleep 0.1 +} # turn critical bits of radeon cards off/on radeon_off() { radeon dac off; radeon light off; } diff --git a/pm/sleep.d/Makefile.am b/pm/sleep.d/Makefile.am index 4555fe6..5a9693c 100644 --- a/pm/sleep.d/Makefile.am +++ b/pm/sleep.d/Makefile.am @@ -12,6 +12,7 @@ sleep_SCRIPTS = \ 90clock \ 94cpufreq \ 95led \ + 98smart-kernel-video \ 99video EXTRA_DIST=$(sleep_SCRIPTS) |