[Pm-utils] Userspace suspend support for pm-utils

Tim Dijkstra newsuser at famdijkstra.org
Fri Jun 8 02:04:28 PDT 2007


On Tue, 5 Jun 2007 23:55:04 +0200
Stefan Seyfried <seife at suse.de> wrote:

> (at least the debian package uses pretty much the same patch).

At the moment we're using the following. When s2ram is installed, it
uses the quirks coming from hal. If hal didn't supply any it will use
s2ram's. It it isn't there either we currently try it anyway (which I'm
not to happy about...)

One problem is that hal doesn't distinguish between 'not known' and 'do
not need quirks'. It ought too IMHO. Then we can really determine if it
is save to suspend or not.

grts Tim


Index: src/pm-action
===================================================================
--- src/pm-action	(Revision 3228)
+++ src/pm-action	(Arbeitskopie)
@@ -52,6 +52,9 @@
 
 export LC_COLLATE=C
 
+unset S2RAM_OPTS
+unset ACPI_SLEEP
+
 # Get the command line options
 while [ $# -gt 0 ]
 do
@@ -61,19 +64,28 @@
 		--quirk-dpms-suspend)
 			export DISPLAY_QUIRK_DPMS_SUSPEND="true" ;;
 		--quirk-radeon-off)
+			S2RAM_OPTS="$S2RAM_OPTS --radeontool";
 			export DISPLAY_QUIRK_RADEON_OFF="true" ;;
 		--quirk-s3-bios)
+			ACPI_SLEEP+=$((ACPI_SLEEP+1))
 			export DISPLAY_QUIRK_S3_BIOS="true" ;;
 		--quirk-s3-mode)
+			ACPI_SLEEP+=$((ACPI_SLEEP+2))
 			export DISPLAY_QUIRK_S3_MODE="true" ;;
 		--quirk-vbe-post)
+			S2RAM_OPTS="$S2RAM_OPTS --vbe_post";
 			export DISPLAY_QUIRK_VBE_POST="true" ;;
 		--quirk-vbemode-restore)
+			S2RAM_OPTS="$S2RAM_OPTS --vbe_mode";
 			export DISPLAY_QUIRK_VBEMODE_RESTORE="true" ;;
 		--quirk-vbestate-restore)
+			S2RAM_OPTS="$S2RAM_OPTS --vbe_save";
 			export DISPLAY_QUIRK_VBESTATE_RESTORE="true" ;;
 		--quirk-vga-mode3)
 			export DISPLAY_QUIRK_VGA_MODE_3="true" ;;
+		--quirk-save-pci)
+			S2RAM_OPTS="$S2RAM_OPTS --pci_save";
+			export DISPLAY_QUIRK_PCI_SAVE="true" ;;
 		--help)
 			help_options
 			exit 0 ;;
@@ -83,6 +95,16 @@
 	shift
 done
 
+if [ -n "$ACPI_SLEEP" ]; then
+	S2RAM_OPTS=" --acpi_sleep $ACPI_SLEEP"
+fi
+
+if [ -n "$S2RAM_OPTS" ]; then
+	S2RAM_OPTS="--force $S2RAM_OPTS"
+fi
+
+export S2RAM_OPTS
+
 . /usr/lib/pm-utils/functions
 
 [ -f /sys/power/state ] || exit 1
Index: pm/hooks/99video
===================================================================
--- pm/hooks/99video	(Revision 3228)
+++ pm/hooks/99video	(Arbeitskopie)
@@ -9,6 +9,10 @@
 
 . /usr/lib/pm-utils/functions
 
+if [ -x /usr/sbin/s2ram ] || [ -x /usr/sbin/s2both ]; then
+	exit 0;
+fi
+
 vbetool=$(type -p vbetool)
 vbe() {
 	if [ -z "$vbetool" ]; then
Index: pm/hooks/20video
===================================================================
--- pm/hooks/20video	(Revision 3228)
+++ pm/hooks/20video	(Arbeitskopie)
@@ -9,6 +9,10 @@
 
 . /usr/lib/pm-utils/functions
 
+if [ -x /usr/sbin/s2ram ] || [ -x /usr/sbin/s2both ]; then
+	exit 0;
+fi
+
 vbetool=$(type -p vbetool)
 vbe() {
 	if [ -z "$vbetool" ]; then
Index: pm/functions
===================================================================
--- pm/functions	(Revision 3228)
+++ pm/functions	(Arbeitskopie)
@@ -7,11 +7,15 @@
 #
 # PM_CMDLINE
 # RESUME_MODULES
+# S2RAM_OPTS
 #
 HIBERNATE_RESUME_POST_VIDEO=no
 INHIBIT=/var/run/pm-utils.inhibit
 PM_LOGFILE=${PM_LOGFILE:=/var/log/pm-suspend.log}
 SUSPEND_MODULES=""
+HIBERNATE_METHOD=""
+S2DISK_BIN=/usr/sbin/s2disk
+S2DISK_CONF=/etc/uswsusp.conf
 
 [ -f /usr/lib/pm-utils/defaults ] && . /usr/lib/pm-utils/defaults
 
@@ -134,13 +142,40 @@
 
 do_suspend()
 {
-	pm-pmu --suspend || echo -n "mem" > /sys/power/state
+	if [ -x /usr/sbin/s2ram ]; then
+		if [ -n "$S2RAM_OPTS" ]; then
+			# Trust HAL or the user to pass the correct options
+			/usr/sbin/s2ram $S2RAM_OPTS
+		elif /usr/sbin/s2ram --test > /dev/null ; then
+			# Trust s2ram's internal whitelist
+			/usr/sbin/s2ram
+		else
+			# Good luck
+			/usr/sbin/s2ram --force
+		fi
+	else
+		pm-pmu --suspend || echo -n "mem" > /sys/power/state
+	fi
 }
 
 do_hibernate()
 {
-	echo -n "platform" > /sys/power/disk
-	echo -n "disk" > /sys/power/state
+	if [ -z "$HIBERNATE_METHOD" ]; then
+		if [ -x $S2DISK_BIN -a -c /dev/snapshot ]; then
+			HIBERNATE_METHOD="userspace"
+		else
+			HIBERNATE_METHOD="kernel"
+		fi
+	fi
+	case $HIBERNATE_METHOD in
+		userspace)
+			$S2DISK_BIN -f $S2DISK_CONF
+			;;
+		kernel)
+			echo -n "platform" > /sys/power/disk
+			echo -n "disk" > /sys/power/state
+			;;
+	esac
 }
 
 do_suspend_hybrid()
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/pm-utils/attachments/20070608/aa180882/attachment.pgp 


More information about the Pm-utils mailing list