On Tue, 2007-02-20 at 11:59 +0000, Richard Hughes wrote:
> On Tue, 2007-02-20 at 00:59 -0500, David Zeuthen wrote:
> >  1. Need a pm-utils release and the associated glue for HAL. Richard,
> >     can you drive this one (I can throw staplers at Peter if needed)?
> >     Thanks! This is a release blocker.
> 
> Attached patches (to pm-utils and HAL) propagate the quirk information
> onto the tools via the command line.

OK, so below is what I'm actually merging, barring complaints ;)

It's basically your patch, but with the following changes:

1) license text without the "or any later version" (we haven't
   been using that text elsewhere)
2) vbetool called in a wrapper, rather than calling 'checkvbetool'
   over and over right before calling vbetool.
3) we expect to find vbetool in the path set in pm/functions
4) set acpi_video_flags to 0 (I could be talked out of this)
   if none of the quirks are set.
5) added --quirk-radeon-off and appropriate radeontool stuff
6) alphabetized the help strings and option parsing

... I think that's it.  Anyway, it's below.

> p.s. Throw the stapler now.

ow.

Index: src/pm-action
===================================================================
RCS file: /cvs/pm-utils/pm-utils/src/pm-action,v
retrieving revision 1.7
diff -u -p -r1.7 pm-action
--- src/pm-action       6 Nov 2006 16:35:42 -0000       1.7
+++ src/pm-action       20 Feb 2007 18:00:36 -0000
@@ -8,6 +8,7 @@
 #    Bill Nottingham <[EMAIL PROTECTED]>
 #    Peter Jones <[EMAIL PROTECTED]>
 #    David Zeuthen <[EMAIL PROTECTED]>
+#    Richard Hughes <[EMAIL PROTECTED]>
 #
 # 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
@@ -25,6 +26,25 @@
 
 # The rule here? Simplicity.
 
+help_options() {
+       echo "pm-action [options]"
+       echo
+       echo "Options can change how the supend or hibernate is done."
+       echo
+       echo "Possible actions are:"
+       echo
+       echo "  --quirk-dpms-on"
+       echo "  --quirk-dpms-suspend"
+       echo "  --quirk-radeon-off"
+       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
+}
+
 if [ -n "$EUID" -a "$EUID" != "0" ]; then
        echo This utility may only be run by the root user. 1>&2
        exit 1
@@ -32,6 +52,37 @@ fi
 
 export LC_COLLATE=C
 
+# Get the command line options
+while [ $# -gt 0 ]
+do
+       case "$1" in
+               --quirk-dpms-on)
+                       export DISPLAY_QUIRK_DPMS_ON="true" ;;
+               --quirk-dpms-suspend)
+                       export DISPLAY_QUIRK_DPMS_SUSPEND="true" ;;
+               --quirk-radeon-off)
+                       export DISPLAY_QUIRK_RADEON_OFF="true" ;;
+               --quirk-s3-bios)
+                       export DISPLAY_QUIRK_S3_BIOS="true" ;;
+               --quirk-s3-mode)
+                       export DISPLAY_QUIRK_S3_MODE="true" ;;
+               --quirk-vbe-post)
+                       export DISPLAY_QUIRK_VBE_POST="true" ;;
+               --quirk-vbemode-restore)
+                       export DISPLAY_QUIRK_VBEMODE_RESTORE="true" ;;
+               --quirk-vbestate-restore)
+                       export DISPLAY_QUIRK_VBESTATE_RESTORE="true" ;;
+               --quirk-vga-mode3)
+                       export DISPLAY_QUIRK_VGA_MODE_3="true" ;;
+               --help)
+                       help_options
+                       exit 0 ;;
+               *)
+                       break ;; # terminate while loop
+       esac
+       shift
+done
+
 . /etc/pm/functions
 
 [ -f /sys/power/state ] || exit 1
Index: pm/hooks/20video
===================================================================
RCS file: /cvs/pm-utils/pm-utils/pm/hooks/20video,v
retrieving revision 1.7
diff -u -p -r1.7 20video
--- pm/hooks/20video    27 Apr 2006 08:05:43 -0000      1.7
+++ pm/hooks/20video    20 Feb 2007 18:00:36 -0000
@@ -1,27 +1,81 @@
 #!/bin/bash
+#
+# Copyright 2006-2007 Richard Hughes <[EMAIL PROTECTED]>
+# Copyright 2007 Peter Jones <[EMAIL PROTECTED]>
+#
+# 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.
 
 . /etc/pm/functions
 
+vbetool=$(type -p vbetool)
+vbe() {
+       if [ -z "$vbetool" ]; then
+               echo "vbetool not found" 1>&2
+               return 1
+       fi
+       $vbetool "$@"
+}
+
+radeontool=$(type -p radeontool)
+radeon() {
+       if [ -z "$radeontool" ]; then
+               echo "radeontool not found" 1>&2
+               return 1
+       fi
+       $radeontool "$@"
+}
+
 suspend_video()
 {
-       # Suspend all video devices using the HAL dbus methods
-       devices=`hal-find-by-capability --capability video_adapter_pm`
-       for device in $devices
-       do
-               dbus-send --system --print-reply --dest=org.freedesktop.Hal \
-                         $device 
org.freedesktop.Hal.Device.VideoAdapterPM.SuspendVideo
-       done
+       # 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_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
 }
 
 resume_video()
 {
-       # Resume all video devices using the HAL dbus methods
-       devices=`hal-find-by-capability --capability video_adapter_pm`
-       for device in $devices
-       do
-               dbus-send --system --print-reply --dest=org.freedesktop.Hal \
-                         $device 
org.freedesktop.Hal.Device.VideoAdapterPM.ResumeVideo
-       done
+       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 </dev/tty0
+               usleep 100000
+       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
+       if [ ${DISPLAY_QUIRK_DPMS_ON} == "true" ]; then
+               vbe dpms on
+       fi
 }
 
 case "$1" in
@@ -41,8 +95,6 @@ case "$1" in
                        resume_video
                fi
                ;;
-       *)
-               ;;
 esac
 
 exit $?


-- 
  Peter

_______________________________________________
Pm-utils mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/pm-utils

Reply via email to