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.
Lightly tested by me.
Richard.
p.s. Throw the stapler now.
diff --git a/tools/linux/hal-system-power-hibernate-linux b/tools/linux/hal-system-power-hibernate-linux
index 632acb6..3e462e6 100755
--- a/tools/linux/hal-system-power-hibernate-linux
+++ b/tools/linux/hal-system-power-hibernate-linux
@@ -10,6 +10,19 @@ unsupported() {
exit 1
}
+# Make a suitable command line argument so that the tools can do the correct
+# quirks for video resume.
+# Passing the quirks to the tool allows the tool to not depend on HAL for data.
+QUIRKS=""
+[ "$HAL_PROP_POWER_MANAGEMENT_QUIRK_S3_BIOS" == "true" ] && QUIRKS="$QUIRKS --quirk-s3-bios"
+[ "$HAL_PROP_POWER_MANAGEMENT_QUIRK_S3_MODE" == "true" ] && QUIRKS="$QUIRKS --quirk-s3-mode"
+[ "$HAL_PROP_POWER_MANAGEMENT_QUIRK_DPMS_SUSPEND" == "true" ] && QUIRKS="$QUIRKS --quirk-dpms-suspend"
+[ "$HAL_PROP_POWER_MANAGEMENT_QUIRK_DPMS_ON" == "true" ] && QUIRKS="$QUIRKS --quirk-dpms-on"
+[ "$HAL_PROP_POWER_MANAGEMENT_QUIRK_VBESTATE_RESTORE" == "true" ] && QUIRKS="$QUIRKS --quirk-vbestate-restore"
+[ "$HAL_PROP_POWER_MANAGEMENT_QUIRK_VBEMODE_RESTORE" == "true" ] && QUIRKS="$QUIRKS --quirk-vbemode-restore"
+[ "$HAL_PROP_POWER_MANAGEMENT_QUIRK_VGA_MODE_3" == "true" ] && QUIRKS="$QUIRKS --quirk-vga-mode3"
+[ "$HAL_PROP_POWER_MANAGEMENT_QUIRK_VBE_POST" == "true" ] && QUIRKS="$QUIRKS --quirk-vbe-post"
+
#ALTLinux only supports powersave
if [ -f /etc/altlinux-release ] ; then
if [ -x /usr/bin/powersave ] ; then
@@ -32,7 +45,7 @@ elif [ -f /etc/mandriva-release ] ; then
elif [ -f /etc/redhat-release ] || [ -f /etc/fedora-release ] \
|| [ -f "/etc/SuSE-release" ] ; then
if [ -x /usr/sbin/pm-hibernate ] ; then
- /usr/sbin/pm-hibernate
+ /usr/sbin/pm-hibernate $QUIRKS
RET=$?
else
unsupported
@@ -47,7 +60,7 @@ else
/usr/sbin/pmi action hibernate force
RET=$?
elif [ -x "/usr/sbin/pm-hibernate" ] ; then
- /usr/sbin/pm-hibernate
+ /usr/sbin/pm-hibernate $QUIRKS
RET=$?
elif [ -x "/usr/sbin/hibernate" ] ; then
# Suspend2 tools installed
diff --git a/tools/linux/hal-system-power-suspend-linux b/tools/linux/hal-system-power-suspend-linux
index 180d4a1..d16ea7d 100755
--- a/tools/linux/hal-system-power-suspend-linux
+++ b/tools/linux/hal-system-power-suspend-linux
@@ -18,6 +18,19 @@ unsupported() {
read seconds_to_sleep
+# Make a suitable command line argument so that the tools can do the correct
+# quirks for video resume.
+# Passing the quirks to the tool allows the tool to not depend on HAL for data.
+QUIRKS=""
+[ "$HAL_PROP_POWER_MANAGEMENT_QUIRK_S3_BIOS" == "true" ] && QUIRKS="$QUIRKS --quirk-s3-bios"
+[ "$HAL_PROP_POWER_MANAGEMENT_QUIRK_S3_MODE" == "true" ] && QUIRKS="$QUIRKS --quirk-s3-mode"
+[ "$HAL_PROP_POWER_MANAGEMENT_QUIRK_DPMS_SUSPEND" == "true" ] && QUIRKS="$QUIRKS --quirk-dpms-suspend"
+[ "$HAL_PROP_POWER_MANAGEMENT_QUIRK_DPMS_ON" == "true" ] && QUIRKS="$QUIRKS --quirk-dpms-on"
+[ "$HAL_PROP_POWER_MANAGEMENT_QUIRK_VBESTATE_RESTORE" == "true" ] && QUIRKS="$QUIRKS --quirk-vbestate"
+[ "$HAL_PROP_POWER_MANAGEMENT_QUIRK_VBEMODE_RESTORE" == "true" ] && QUIRKS="$QUIRKS --quirk-vbemode"
+[ "$HAL_PROP_POWER_MANAGEMENT_QUIRK_VGA_MODE_3" == "true" ] && QUIRKS="$QUIRKS --quirk-vga-mode3"
+[ "$HAL_PROP_POWER_MANAGEMENT_QUIRK_VBE_POST" == "true" ] && QUIRKS="$QUIRKS --quirk-vbepost"
+
#PMU systems cannot use /sys/power/state yet, so use a helper to issue an ioctl
if [ "$HAL_PROP_LAPTOP_PANEL_ACCESS_METHOD" == "pmu" ]; then
hal-system-power-pmu sleep
@@ -63,7 +76,7 @@ elif [ -f "/etc/redhat-release" ] || [ -f "/etc/fedora-release" ] \
# TODO: fixup pm-suspend to define erroc code (see alarm above) and throw
# the appropriate exception
if [ -x "/usr/sbin/pm-suspend" ] ; then
- /usr/sbin/pm-suspend
+ /usr/sbin/pm-suspend $QUIRKS
RET=$?
else
# TODO: add support
@@ -88,7 +101,7 @@ else
/usr/sbin/pmi action suspend force
RET=$?
elif [ -x "/usr/sbin/pm-suspend" ] ; then
- /usr/sbin/pm-suspend
+ /usr/sbin/pm-suspend $QUIRKS
RET=$?
elif [ -w "/sys/power/state" ] ; then
# Use the raw kernel sysfs interface
Index: pm/hooks/20video
===================================================================
RCS file: /cvs/pm-utils/pm-utils/pm/hooks/20video,v
retrieving revision 1.7
diff -u -r1.7 20video
--- pm/hooks/20video 27 Apr 2006 08:05:43 -0000 1.7
+++ pm/hooks/20video 20 Feb 2007 11:59:09 -0000
@@ -1,27 +1,70 @@
#!/bin/bash
+#
+# Copyright (C) 2006-2007 Richard Hughes <[EMAIL PROTECTED]>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
. /etc/pm/functions
+checkvbetool() {
+ if ! [ -x "/usr/sbin/vbetool" ]; then
+ echo "vbetool not found" >&2
+ exit 1
+ fi
+}
+
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
+ # 1=s3_bios, 2=s3_mode, 3=both
+ if [ ${DISPLAY_QUIRK_S3_BIOS} == "true" ] && [ ${DISPLAY_QUIRK_S3_MODE} == "true" ]; then
+ echo -n 3 > /proc/sys/kernel/acpi_video_flags
+ elif [ ${DISPLAY_QUIRK_S3_BIOS} == "true" ]; then
+ echo -n 1 > /proc/sys/kernel/acpi_video_flags
+ elif [ ${DISPLAY_QUIRK_S3_MODE} == "true" ]; then
+ echo -n 2 > /proc/sys/kernel/acpi_video_flags
+ fi
+
+ # We might need to do one or many of these quirks
+ if [ ${DISPLAY_QUIRK_DPMS_SUSPEND} == "true" ]; then
+ checkvbetool
+ /usr/sbin/vbetool dpms suspend
+ fi
+ if [ ${DISPLAY_QUIRK_VBESTATE_RESTORE} == "true" ]; then
+ checkvbetool
+ /usr/sbin/vbetool vbestate save > /var/run/vbestate
+ fi
+ if [ ${DISPLAY_QUIRK_VBEMODE_RESTORE} == "true" ]; then
+ checkvbetool
+ /usr/sbin/vbetool vbemode get > /var/run/vbemode
+ fi
+ if [ ${DISPLAY_QUIRK_VGA_MODE_3} == "true" ]; then
+ # TODO: we need to set mode3
+ echo "mode3 unimplemented"
+ 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
+ # We might need to do one or many of these quirks
+ if [ ${DISPLAY_QUIRK_VBE_POST} == "true" ]; then
+ checkvbetool
+ /usr/sbin/vbetool post
+ fi
+ if [ ${DISPLAY_QUIRK_VBESTATE_RESTORE} == "true" ]; then
+ checkvbetool
+ /usr/sbin/vbetool vbestate restore < /var/run/vbestate
+ fi
+ if [ ${DISPLAY_QUIRK_VBEMODE_RESTORE} == "true" ]; then
+ checkvbetool
+ /usr/sbin/vbetool vbemode set `cat /var/run/vbemode`
+ fi
+ if [ ${DISPLAY_QUIRK_DPMS_ON} == "true" ]; then
+ checkvbetool
+ /usr/sbin/vbetool dpms on > /dev/null 2>&1
+ fi
}
case "$1" in
Index: src/pm-action
===================================================================
RCS file: /cvs/pm-utils/pm-utils/src/pm-action,v
retrieving revision 1.7
diff -u -r1.7 pm-action
--- src/pm-action 6 Nov 2006 16:35:42 -0000 1.7
+++ src/pm-action 20 Feb 2007 11:59:09 -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
@@ -23,6 +24,25 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
+help_options() {
+ echo "pm-action [options]"
+ echo
+ echo "Options can change how the supend or hibernate is done."
+ echo "Usually options are set automatically if using HAL."
+ echo
+ echo "Possible actions are:"
+ echo
+ echo " --quirk-s3-bios"
+ echo " --quirk-s3-mode"
+ echo " --quirk-dpms-suspend"
+ echo " --quirk-dpms-on"
+ echo " --quirk-vbestate-restore"
+ echo " --quirk-vbemode-restore"
+ echo " --quirk-vga-mode3"
+ echo " --quirk-vbe-post"
+ echo
+}
+
# The rule here? Simplicity.
if [ -n "$EUID" -a "$EUID" != "0" ]; then
@@ -32,6 +52,35 @@
export LC_COLLATE=C
+# Get the command line options
+while [ $# -gt 0 ]
+do
+ case "$1" in
+ --quirk-s3-bios)
+ export DISPLAY_QUIRK_S3_BIOS="true";;
+ --quirk-s3-mode)
+ export DISPLAY_QUIRK_S3_MODE="true";;
+ --quirk-dpms-suspend)
+ export DISPLAY_QUIRK_DPMS_SUSPEND="true";;
+ --quirk-dpms-on)
+ export DISPLAY_QUIRK_DPMS_ON="true";;
+ --quirk-vbestate-restore)
+ export DISPLAY_QUIRK_VBESTATE_RESTORE="true";;
+ --quirk-vbemode-restore)
+ export DISPLAY_QUIRK_VBEMODE_RESTORE="true";;
+ --quirk-vga-mode3)
+ export DISPLAY_QUIRK_VGA_MODE_3="true";;
+ --quirk-vbe-post)
+ export DISPLAY_QUIRK_VBE_POST="true";;
+ --help)
+ help_options
+ exit 1;;
+ *)
+ break;; # terminate while loop
+ esac
+ shift
+done
+
. /etc/pm/functions
[ -f /sys/power/state ] || exit 1
_______________________________________________
Pm-utils mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/pm-utils