On Tue, 2007-02-20 at 13:37 +0100, Tim Dijkstra wrote:
> On Tue, 20 Feb 2007 11:59:53 +0000
> Richard Hughes <[EMAIL PROTECTED]> 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.
> >
>
>
> Any reason you didn't change the --quirk-* named as stefan and I would like
> for s2ram compatibility?
Yes. Having dashes *and* underscores in the option seemed wrong to me.
> Tim wrote:
> > Can we have them a bit differently? Like
> >
> > --quirk-vbe_save: save VBE state before suspending and restore after
> > resume.
> > --quirk-vbe_post: VBE POST the graphics card after resume
> > --quirk-vbe_mode: get VBE mode before suspend and set it after resume
> >
> > And maybe we can also support these in hal?
> >
> > --quirk-pci_save: save the PCI config space for the VGA card.
> > --quirk_radeontool: turn off the backlight on radeons before suspending.
Sure, but I think --pci-save is more sane than --pci_save IMO.
Also, let me get these patches in, and then we can add more options -
patches on patches are never a good idea.
> > That way they equal the command-line options of s2ram (except for the
> > --quirk of course)
> >
> > Finally, maybe we can add s3_mode and s3_bios (bios=1, mode=2, both=1+2),
> > that
> > is the way the go into /proc/sys/kernel/acpi_video_flags. That can also
> > be done in pm-tools.
>
> stefan wrote :
>
> > Ok for me. I also like Tim's suggestion of different names (i'd probably
> > drop the "--quirk"-prefix and just call them "--s3_bios", "--s3_mode" etc),
> > but i do not really care about that since we can always fix that in
> > pm-utils.
> > Short options would be nice ;-)
I'll drop the quirk prefix, new patches are attached.
Richard.
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 --s3-bios"
+[ "$HAL_PROP_POWER_MANAGEMENT_QUIRK_S3_MODE" == "true" ] && QUIRKS="$QUIRKS --s3-mode"
+[ "$HAL_PROP_POWER_MANAGEMENT_QUIRK_DPMS_SUSPEND" == "true" ] && QUIRKS="$QUIRKS --dpms-suspend"
+[ "$HAL_PROP_POWER_MANAGEMENT_QUIRK_DPMS_ON" == "true" ] && QUIRKS="$QUIRKS --dpms-on"
+[ "$HAL_PROP_POWER_MANAGEMENT_QUIRK_VBESTATE_RESTORE" == "true" ] && QUIRKS="$QUIRKS --vbestate-restore"
+[ "$HAL_PROP_POWER_MANAGEMENT_QUIRK_VBEMODE_RESTORE" == "true" ] && QUIRKS="$QUIRKS --vbemode-restore"
+[ "$HAL_PROP_POWER_MANAGEMENT_QUIRK_VGA_MODE_3" == "true" ] && QUIRKS="$QUIRKS --vga-mode3"
+[ "$HAL_PROP_POWER_MANAGEMENT_QUIRK_VBE_POST" == "true" ] && QUIRKS="$QUIRKS --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 --s3-bios"
+[ "$HAL_PROP_POWER_MANAGEMENT_QUIRK_S3_MODE" == "true" ] && QUIRKS="$QUIRKS --s3-mode"
+[ "$HAL_PROP_POWER_MANAGEMENT_QUIRK_DPMS_SUSPEND" == "true" ] && QUIRKS="$QUIRKS --dpms-suspend"
+[ "$HAL_PROP_POWER_MANAGEMENT_QUIRK_DPMS_ON" == "true" ] && QUIRKS="$QUIRKS --dpms-on"
+[ "$HAL_PROP_POWER_MANAGEMENT_QUIRK_VBESTATE_RESTORE" == "true" ] && QUIRKS="$QUIRKS --vbestate"
+[ "$HAL_PROP_POWER_MANAGEMENT_QUIRK_VBEMODE_RESTORE" == "true" ] && QUIRKS="$QUIRKS --vbemode"
+[ "$HAL_PROP_POWER_MANAGEMENT_QUIRK_VGA_MODE_3" == "true" ] && QUIRKS="$QUIRKS --vga-mode3"
+[ "$HAL_PROP_POWER_MANAGEMENT_QUIRK_VBE_POST" == "true" ] && QUIRKS="$QUIRKS --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 " --s3-bios"
+ echo " --s3-mode"
+ echo " --dpms-suspend"
+ echo " --dpms-on"
+ echo " --vbestate-restore"
+ echo " --vbemode-restore"
+ echo " --vga-mode3"
+ echo " --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
+ --s3-bios)
+ export DISPLAY_QUIRK_S3_BIOS="true";;
+ --s3-mode)
+ export DISPLAY_QUIRK_S3_MODE="true";;
+ --dpms-suspend)
+ export DISPLAY_QUIRK_DPMS_SUSPEND="true";;
+ --dpms-on)
+ export DISPLAY_QUIRK_DPMS_ON="true";;
+ --vbestate-restore)
+ export DISPLAY_QUIRK_VBESTATE_RESTORE="true";;
+ --vbemode-restore)
+ export DISPLAY_QUIRK_VBEMODE_RESTORE="true";;
+ --vga-mode3)
+ export DISPLAY_QUIRK_VGA_MODE_3="true";;
+ --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