[Pm-utils] [PATCH 1/1] Handle kernel modesetting correctly.

Victor Lowther victor.lowther at gmail.com
Mon Mar 23 19:42:55 PDT 2009


Now that KMS is finally going to be included in mainstream, we need to handle
it. This patch does so by folding 90chvt into 99video, checking to see if we
are using a KMS capable framebuffer, and if so removing all HAL-passed video
quirks and adding a quirk that allows 99video to skip changing to vt63.

My testing with the nvidia driver indicates that it does something vaguely
approximating the Right Thing with vt handling, so it gets to ignore
chvt handling in 99video too.

Comments?

---
 pm/module.d/uswsusp             |    3 +--
 pm/sleep.d/90chvt               |   20 --------------------
 pm/sleep.d/98smart-kernel-video |   23 +++++++++++++++++++++--
 pm/sleep.d/99video              |   19 ++++++++++++++++---
 pm/sleep.d/Makefile.am          |    1 -
 5 files changed, 38 insertions(+), 28 deletions(-)

diff --git a/pm/module.d/uswsusp b/pm/module.d/uswsusp
index b9778af..30462eb 100755
--- a/pm/module.d/uswsusp
+++ b/pm/module.d/uswsusp
@@ -4,8 +4,7 @@
 # s2ram and s2disk handle all this stuff internally.
 uswsusp_hooks()
 {
-	disablehook 90chvt "disabled by uswsusp"
-	disablehook 99video "disabled by uswsusp"
+       	disablehook 99video "disabled by uswsusp"
 }
 
 # Since we disabled 99video, we need to take responsibility for proper
diff --git a/pm/sleep.d/90chvt b/pm/sleep.d/90chvt
deleted file mode 100755
index 47a2c85..0000000
--- a/pm/sleep.d/90chvt
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/bin/sh
-# Ensure we eare in text mode by switching to an unused vt.
-# Also avoids lots of ghastly suspend/resume errors due to trying
-# to suspend/resume while running in X.
-
-. "${PM_FUNCTIONS}"
-
-case "$1" in
-	hibernate|suspend)
-		fgconsole |savestate console
-		chvt 63
-		;;
-	thaw|resume) 
-		state_exists console || exit 1
-		chvt $(restorestate console) 
-		deallocvt 63
-		;;
-	*)
-		;;
-esac
diff --git a/pm/sleep.d/98smart-kernel-video b/pm/sleep.d/98smart-kernel-video
index 1043e94..997dc3e 100755
--- a/pm/sleep.d/98smart-kernel-video
+++ b/pm/sleep.d/98smart-kernel-video
@@ -31,6 +31,7 @@ smart_kernel_nvidia()
 	--quirk-radeon-off \
 	--quirk-no-fb \
 	--quirk-pci-save
+    add_parameters --quirk-no-chvt
 }
 
 smart_kernel_fglrx()
@@ -74,10 +75,28 @@ smart_kernel_intel()
 	--quirk-pci-save
 }
 
+smart_kernel_modesetting() { 
+    [ -d /sys/class/drm/card0/device/graphics/fb0 ] || return 1
+    remove_parameters --quirk-dpms-on \
+    	--quirk-dpms-suspend \
+	--quirk-s3-mode \
+    	--quirk-s3-bios \
+	--quirk-vbe-post \
+	--quirk-vbe-post \
+	--quirk-vga-mode3 \
+	--quirk-vbemode-restore \
+	--quirk-vbestate-restore \
+	--quirk-reset-brightness \
+	--quirk-radeon-off \
+	--quirk-no-fb \
+	--quirk-pci-save
+    add_parameters --quirk-no-chvt
+}
+    
 smart_kernel_video() 
 {
-        smart_kernel_nvidia || smart_kernel_fglrx || smart_kernel_intel || \
-	return $NA
+        smart_kernel_modesetting || smart_kernel_nvidia || \
+	    smart_kernel_fglrx || smart_kernel_intel || return $NA
 }
 
 case $1 in
diff --git a/pm/sleep.d/99video b/pm/sleep.d/99video
index 1fe54c2..01da7c7 100755
--- a/pm/sleep.d/99video
+++ b/pm/sleep.d/99video
@@ -28,6 +28,7 @@ for opt in $PM_CMDLINE; do
 		vga-mode3) 	   QUIRK_VGA_MODE_3="true" ;;
 		no-fb) 		   QUIRK_NOFB="true" ;;
 		pci-save) 	   QUIRK_PCI_SAVE="true" ;;
+	        no-chvt)           QUIRK_NO_CHVT="true" ;;
 		none) 		   QUIRK_NONE="true" ;;
 		*) continue ;;
 	esac
@@ -63,6 +64,17 @@ die_if_framebuffer()
 	exit 1
 }
 
+maybe_to_vt63() { 
+    [ "$QUIRK_NO_CHVT" = "true" ] && return
+    fgconsole |savestate console
+    chvt 63
+}
+
+maybe_from_vt63() {
+    state_exists console || return
+    chvt $(restorestate console)
+    deallocvt 63
+}
 
 save_fbcon()
 {
@@ -187,17 +199,18 @@ help() {
 }
 
 case "$1" in
-	suspend) suspend_video ;;
-	hibernate)
+	suspend) maybe_to_vt63; suspend_video ;;
+	hibernate) maybe_to_vt63
 		if [ "$HIBERNATE_RESUME_POST_VIDEO" = "yes" ]; then
 			suspend_video
 		fi
 		;;
-	resume) resume_video ;;
+	resume) resume_video; maybe_from_vt63;;
 	thaw)
 		if [ "${HIBERNATE_RESUME_POST_VIDEO}" = "yes" ]; then
 			resume_video
 		fi
+		maybe_from_vt63
 		;;
 	help) help ;;
 esac
diff --git a/pm/sleep.d/Makefile.am b/pm/sleep.d/Makefile.am
index 226b66c..b367a17 100644
--- a/pm/sleep.d/Makefile.am
+++ b/pm/sleep.d/Makefile.am
@@ -8,7 +8,6 @@ sleep_SCRIPTS =			\
 	49bluetooth		\
 	55NetworkManager	\
 	75modules		\
-	90chvt			\
 	90clock			\
 	94cpufreq		\
 	95led			\
-- 
1.6.0.4



More information about the Pm-utils mailing list