[Pm-utils] [PATCH] Add optional default quirks

Matthew Garrett mjg59 at srcf.ucam.org
Fri May 16 08:04:56 PDT 2008


The number of machines that will resume without any quirks is smaller 
than the number of machines that will not resume without quirks. This 
patch adds an optional mode which will attempt a default set of quirks 
on machines where no specific quirks have been set. If any quirks 
(including quirk-video-none) are passed, they will be used rather than 
the defaults. By default this mode is disabled.

diff --git a/pm/defaults b/pm/defaults
index c0063c5..eb25de1 100644
--- a/pm/defaults
+++ b/pm/defaults
@@ -19,6 +19,12 @@
 # Valid values are "no" and "yes"
 # HIBERNATE_RESUME_POST_VIDEO="no"
 
+# Should pm-utils use a default set of quirks if none are passed to it?
+# 
+# Valid values are "no" and "yes". The system defaults to "no" if this is
+# commented out.
+# DEFAULT_VIDEO_QUIRKS="no"
+
 # The default sleep/wake system to use.  Valid values are:
 #   kernel    The built-in kernel suspend/resume support.
 #             Use this if nothing else is supported on your system.
diff --git a/pm/sleep.d/99video b/pm/sleep.d/99video
index 75b53dc..c3b2fb2 100755
--- a/pm/sleep.d/99video
+++ b/pm/sleep.d/99video
@@ -16,22 +16,49 @@
 
 for opt in $PM_CMDLINE; do
 	case "${opt##--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" ;;
+		dpms-on) 	   QUIRK_DPMS_ON="true"
+				   QUIRK_SET="true" ;;
+		dpms-suspend) 	   QUIRK_DPMS_SUSPEND="true"
+				   QUIRK_SET="true" ;;
+		radeon-off) 	   QUIRK_RADEON_OFF="true"
+				   QUIRK_SET="true" ;;
+		reset-brightness)  QUIRK_RESET_BRIGHTNESS="true"
+				   QUIRK_SET="true" ;;
+		s3-bios) 	   QUIRK_S3_BIOS="true"
+				   QUIRK_SET="true" ;;
+		s3-mode) 	   QUIRK_S3_MODE="true"
+				   QUIRK_SET="true" ;;
+		vbe-post) 	   QUIRK_VBE_POST="true"
+				   QUIRK_SET="true" ;;
+		vbemode-restore)   QUIRK_VBEMODE_RESTORE="true"
+				   QUIRK_SET="true" ;;
+		vbestate-restore)  QUIRK_VBESTATE_RESTORE="true"
+				   QUIRK_SET="true" ;;
+		vga-mode3) 	   QUIRK_VGA_MODE_3="true"
+				   QUIRK_SET="true" ;;
+		none) 		   QUIRK_NONE="true"
+				   QUIRK_SET="true" ;;
 		*) continue ;;
 	esac
 done
 
+set_default_quirks()
+{
+	if [ "x$DEFAULT_VIDEO_QUIRKS" != "xyes" ]; then
+		return;
+	fi
+
+	# If any quirks have been set, don't change them
+	quirk "${QUIRK_SET}" && return
 
+	QUIRK_DPMS_ON="true"
+	QUIRK_RESET_BRIGHTNESS="true"
+	QUIRK_VBE_POST="true"
+	QUIRK_VBEMODE_RESTORE="true"
+	QUIRK_VBESTATE_RESTORE="true"
+	QUIRK_VGA_MODE_3="true"
+}
+	
 reset_brightness()
 {
 	for bl in /sys/class/backlight/* ; do
@@ -145,7 +172,9 @@ help() {
 }
 
 case "$1" in
-	suspend) suspend_video ;;
+	suspend)
+		set_default_quirks
+		suspend_video ;;
 	hibernate)
 		if [ "$HIBERNATE_RESUME_POST_VIDEO" = "yes" ]; then
 			suspend_video
@@ -168,7 +197,8 @@ case "$1" in
 			return 0;
 		fi
 
-		resume_video 
+		set_default_quirks
+		resume_video
 		;;
 	thaw)
 		if [ "${HIBERNATE_RESUME_POST_VIDEO}" = "yes" ]; then

-- 
Matthew Garrett | mjg59 at srcf.ucam.org


More information about the Pm-utils mailing list