[Pm-utils] [PATCH 1/2] Added support for the nofb and pci_save HAL quirks.

Victor Lowther victor.lowther at gmail.com
Tue Sep 9 13:32:53 PDT 2008


Patch against pm-utils master (should apply cleanly to pm-utils 1.2.0 as well).

Hal specifies that we need to handle these quirks, but we apparently never have.

Anyways, we now handle pci_save and no_fb quirks.  Anyone got a system that needs the pci_save
quirk they are willing to test this patch on?

Assuming there are no objections, this patch series will be applied to master and backported to
the pm-utils 1.1 branch as well.
---
 pm/sleep.d/99video |   38 +++++++++++++++++++++++++++++++++++++-
 1 files changed, 37 insertions(+), 1 deletions(-)

diff --git a/pm/sleep.d/99video b/pm/sleep.d/99video
index b927a1b..dc8590a 100755
--- a/pm/sleep.d/99video
+++ b/pm/sleep.d/99video
@@ -26,6 +26,8 @@ for opt in $PM_CMDLINE; do
 		vbemode-restore)   QUIRK_VBEMODE_RESTORE="true" ;;
 		vbestate-restore)  QUIRK_VBESTATE_RESTORE="true" ;;
 		vga-mode3) 	   QUIRK_VGA_MODE_3="true" ;;
+		no-fb) 		   QUIRK_NOFB="true" ;;
+		pci-save) 	   QUIRK_PCI_SAVE="true" ;;
 		none) 		   QUIRK_NONE="true" ;;
 		*) continue ;;
 	esac
@@ -53,6 +55,15 @@ else
 	radeon() { echo "radeontool not found" 1>&2; return 1; }
 fi
 
+die_if_framebuffer() 
+{ 
+	[ -d "/sys/class/graphics/fb0" ] || return
+	echo "--quirk-no-fb passed, but system is using a framebuffer."
+	echo "Aborting."
+	exit 1
+}
+
+
 save_fbcon()
 {
 	local con
@@ -105,6 +116,28 @@ vbe_post()
 radeon_off() { radeon dac off; radeon light off; }
 radeon_on() { radeon dac on; radeon light on; }
 
+# save and restore video card PCI config state
+save_pci() 
+{
+	local pci="/sys/bus/pci/devices"
+	for dev in "${pci}"/*; do
+		[ -f "${dev}/class" ] || continue
+		[ $(cat "${dev}/class") = "0x030000" ] || continue
+		[ -f "${dev}/config" ] || continue
+		# it is a video card, it has a configuration.  Save it.
+		savestate "pci_video_${dev##*/}" <${dev}/config
+	done
+}
+
+restore_pci() 
+{
+	local pci="/sys/bus/pci/devices"
+	for dev in "${pci}"/*; do
+		state_exists "pci_video_${dev##*/}" || continue
+		restorestate "pci_video_${dev##*/}" > "${dev}/config"
+	done
+}
+
 suspend_video()
 {
 	# 0=nothing, 1=s3_bios, 2=s3_mode, 3=both
@@ -113,16 +146,19 @@ suspend_video()
 	quirk "${QUIRK_S3_MODE}" && 		acpi_flag=$(($acpi_flag + 2))
 	[ 0 -ne $acpi_flag ] && sysctl -w kernel.acpi_video_flags=$acpi_flag
 	
+	quirk "${QUIRK_NOFB}" && 		die_if_framebuffer
 	quirk "${QUIRK_VBESTATE_RESTORE}" && 	vbe_savestate
 	quirk "${QUIRK_VBEMODE_RESTORE}" && 	vbe_savemode
 	quirk "${QUIRK_RADEON_OFF}" && 		radeon_off
+	quirk "${QUIRK_PCI_SAVE}" && 		pci_save
 	quirk "${QUIRK_VGA_MODE_3}" && 		vbe vbemode set 3
 	quirk "${QUIRK_DPMS_SUSPEND}" && 	vbe dpms suspend
-	save_fbcon # there should be a quirk, but HAL does not pass it.
+	save_fbcon
 }
 resume_video()
 {
 	# We might need to do one or many of these quirks
+	quirk "${QUIRK_PCI_SAVE}" && 		pci_restore
 	quirk "${QUIRK_VBE_POST}" && 		vbe_post
 	quirk "${QUIRK_VBESTATE_RESTORE}" && 	vbe_restorestate
 	quirk "${QUIRK_VBEMODE_RESTORE}" && 	vbe_restoremode
-- 
1.5.6.5



More information about the Pm-utils mailing list