summaryrefslogtreecommitdiff
path: root/pm/sleep.d/99video
diff options
context:
space:
mode:
Diffstat (limited to 'pm/sleep.d/99video')
-rwxr-xr-xpm/sleep.d/99video110
1 files changed, 83 insertions, 27 deletions
diff --git a/pm/sleep.d/99video b/pm/sleep.d/99video
index cdf2bc8..1dc88bd 100755
--- a/pm/sleep.d/99video
+++ b/pm/sleep.d/99video
@@ -9,6 +9,26 @@
. "${PM_FUNCTIONS}"
+for opt in $PM_CMDLINE; do
+ [ "${opt#--quirk-}" = "$opt" ] && continue # not one we care about.
+ case "${1##--quirk-}" in # just quirks, please
+ dpms-on) QUIRK_DPMS_ON="true" ;;
+ dpms-suspend) QUIRK_DPMS_SUSPEND="true" ;;
+ radeon-off) QUIRK_RADEON_OFF="true" ;;
+ reset-brightness) QUIRK_RESET_BRIGHTNESS="true" ;;
+ s3-bios) QUIRK_S3_BIOS="true" ;;
+ s3-mode) QUIRK_S3_MODE="true" ;;
+ vbe-post) QUIRK_VBE_POST="true" ;;
+ vbemode-restore) QUIRK_VBEMODE_RESTORE="true" ;;
+ vbestate-restore) QUIRK_VBESTATE_RESTORE="true" ;;
+ vga-mode3) QUIRK_VGA_MODE_3="true" ;;
+ none) QUIRK_NONE="true" ;;
+ *) continue ;;
+ esac
+ shift
+done
+
+
reset_brightness()
{
for bl in /sys/class/backlight/* ; do
@@ -49,44 +69,80 @@ 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
+
+ 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
}
+help() {
+ echo # first echo makes it look nicer.
+ echo "Video quirk handler options:"
+ echo
+ echo " --quirk-dpms-on"
+ echo " --quirk-dpms-suspend"
+ echo " --quirk-radeon-off"
+ echo " --quirk-reset-brightness"
+ echo " --quirk-s3-bios"
+ echo " --quirk-s3-mode"
+ echo " --quirk-vbe-post"
+ echo " --quirk-vbemode-restore"
+ echo " --quirk-vbestate-restore"
+ echo " --quirk-vga-mode3"
+ echo " --quirk-none"
+}
case "$1" in
- suspend*)
- save_fbcon
- ;;
- resume)
- resume_video
+ suspend*) suspend_video ;;
+ hibernate)
+ if [ "$HIBERNATE_RESUME_POST_VIDEO" = "yes" ]; then
+ suspend_video
+ fi
;;
+ resume) resume_video ;;
thaw)
if [ "${HIBERNATE_RESUME_POST_VIDEO}" = "yes" ]; then
resume_video
fi
;;
+ help) help ;;
esac