diff options
author | Victor Lowther <victor.lowther@gmail.com> | 2008-03-06 19:08:22 -0600 |
---|---|---|
committer | Victor Lowther <victor.lowther@gmail.com> | 2008-03-06 19:08:22 -0600 |
commit | 5da6cdfef068db2fac484e45732f50a572074343 (patch) | |
tree | 98228c3c7f3fd2796781bec386a62e5183f0637c /pm/sleep.d | |
parent | 04f05c28427de4c1e96cb3b343834c22f7dcad7d (diff) | |
parent | 02c4338048175769ca81ee75d25b1dda8706c039 (diff) |
Merge branch 'vlowther-video-merge'
Diffstat (limited to 'pm/sleep.d')
-rwxr-xr-x | pm/sleep.d/20video | 67 | ||||
-rwxr-xr-x | pm/sleep.d/99video | 69 | ||||
-rw-r--r-- | pm/sleep.d/Makefile.am | 1 |
3 files changed, 46 insertions, 91 deletions
diff --git a/pm/sleep.d/20video b/pm/sleep.d/20video deleted file mode 100755 index 668b519..0000000 --- a/pm/sleep.d/20video +++ /dev/null @@ -1,67 +0,0 @@ -#!/bin/sh -# -# Copyright 2006-2007 Richard Hughes <richard@hughsie.com> -# Copyright 2007 Peter Jones <pjones@redhat.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}" - -if command_exists vbetool; then - vbe() { vbetool "$@"; } -else - vbe() { echo "vbetool not found" 1>&2; return 1; } -fi - -if command_exists radeontool; then - radeon() { radeontool "$@"; } -else - radeon() { echo "radeontool not found" 1>&2; return 1; } -fi - -suspend_video() -{ - # 0=nothing, 1=s3_bios, 2=s3_mode, 3=both - if [ "${DISPLAY_QUIRK_S3_BIOS}" = "true" -a \ - "${DISPLAY_QUIRK_S3_MODE}" = "true" ]; then - sysctl -w kernel.acpi_video_flags=3 - elif [ "${DISPLAY_QUIRK_S3_BIOS}" = "true" ]; then - sysctl -w kernel.acpi_video_flags=1 - elif [ "${DISPLAY_QUIRK_S3_MODE}" = "true" ]; then - sysctl -w kernel.acpi_video_flags=2 - else - sysctl -w kernel.acpi_video_flags=0 - fi - - # We might need to do one or many of these quirks - if [ "${DISPLAY_QUIRK_RADEON_OFF}" = "true" ]; then - radeon dac off - radeon light off - fi - if [ "${DISPLAY_QUIRK_VBESTATE_RESTORE}" = "true" ]; then - vbe vbestate save > /var/run/vbestate - fi - if [ "${DISPLAY_QUIRK_VBEMODE_RESTORE}" = "true" ]; then - vbe vbemode get > /var/run/vbemode - fi - if [ "${DISPLAY_QUIRK_VGA_MODE_3}" = "true" ]; then - vbe vbemode set 3 - fi - if [ "${DISPLAY_QUIRK_DPMS_SUSPEND}" = "true" ]; then - vbe dpms suspend - fi -} - - -case "$1" in - suspend*) - suspend_video - ;; - hibernate) - if [ "$HIBERNATE_RESUME_POST_VIDEO" = "yes" ]; then - suspend_video - fi - ;; -esac diff --git a/pm/sleep.d/99video b/pm/sleep.d/99video index cdf2bc8..8d26ba5 100755 --- a/pm/sleep.d/99video +++ b/pm/sleep.d/99video @@ -49,37 +49,60 @@ resume_fbcon() done } +# Some tiny helper functions for quirk handling +quirk() { [ "$1" = "true" ] && [ -z $QUIRK_NONE ]; } + +# save/restore vbe state +vbe_savestate() { vbe vbestate save |savestate vbestate; } +vbe_restorestate() { restorestate vbestate |vbe vbestate restore; } + +# save/restore the vbe mode +vbe_savemode() { vbe vbemode get |savestate vbemode; } +vbe_restoremode() { vbe vbemode get |savestate vbemode; } + +# post the video card +vbe_post() { vbe post; sleep 0.1; } + +# turn critical bits of radeon cards off/on +radeon_off() { radeon dac off; radeon light off; } +radeon_on() { radeon dac on; radeon light on; } + +suspend_video() +{ + # 0=nothing, 1=s3_bios, 2=s3_mode, 3=both + local acpi_flag=0 + [ "${QUIRK_S3_BIOS}" = "true" ] && acpi_flag=$(($acpi_flag + 1)) + [ "${QUIRK_S3_MODE}" = "true" ] && acpi_flag=$(($acpi_flag + 2)) + sysctl -w kernel.acpi_video_flags=$acpi_flag 2>&1 >/dev/null + + quirk "${QUIRK_VBESTATE_RESTORE}" && vbe_savestate + quirk "${QUIRK_VBEMODE_RESTORE}" && vbe_savemode + quirk "${QUIRK_RADEON_OFF}" && radeon_off + quirk "${QUIRK_VGA_MODE_3}" && vbe vbemode set 3 + quirk "${QUIRK_DPMS_SUSPEND}" && vbe dpms suspend + save_fbcon # there should be a quirk, but HAL does not pass it. +} resume_video() { - if [ "${DISPLAY_QUIRK_RADEON_OFF}" = "true" ]; then - radeon dac on - radeon light on - fi # We might need to do one or many of these quirks - if [ "${DISPLAY_QUIRK_VBE_POST}" = "true" ]; then - vbe post - sleep 0.1 - fi - if [ "${DISPLAY_QUIRK_VBESTATE_RESTORE}" = "true" ]; then - vbe vbestate restore < /var/run/vbestate - fi - if [ "${DISPLAY_QUIRK_VBEMODE_RESTORE}" = "true" ]; then - vbe vbemode set "$(cat /var/run/vbemode)" - fi - # based on data from s2ram - resume_fbcon - if [ "${DISPLAY_QUIRK_DPMS_ON}" = "true" ]; then - vbe dpms on - fi - if [ "${DISPLAY_QUIRK_RESET_BRIGHTNESS}" = "true" ]; then - reset_brightness - fi + quirk "${QUIRK_VBE_POST}" && vbe_post + quirk "${QUIRK_VBESTATE_RESTORE}" && vbe_restorestate + quirk "${QUIRK_VBEMODE_RESTORE}" && vbe_restoremode + resume_fbcon # also should be handled by a quirk. + quirk "${QUIRK_RADEON_OFF}" && radeon_on + quirk "${QUIRK_DPMS_ON}" && vbe dpms on + quirk "${QUIRK_RESET_BRIGHTNESS}" && reset_brightness } case "$1" in suspend*) - save_fbcon + suspend_video + ;; + hibernate) + if [ "$HIBERNATE_RESUME_POST_VIDEO" = "yes" ]; then + suspend_video + fi ;; resume) resume_video diff --git a/pm/sleep.d/Makefile.am b/pm/sleep.d/Makefile.am index 256ee0b..7efbc81 100644 --- a/pm/sleep.d/Makefile.am +++ b/pm/sleep.d/Makefile.am @@ -5,7 +5,6 @@ sleep_SCRIPTS = \ 01grub \ 05led \ 10NetworkManager \ - 20video \ 49bluetooth \ 50modules \ 55battery \ |