summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Lowther <victor.lowther@gmail.com>2008-09-13 04:16:38 -0500
committerVictor Lowther <victor.lowther@gmail.com>2008-09-13 04:16:38 -0500
commitf30564ba387d06df3428a16d5bd8664e35d16dae (patch)
treeae7bb58120e0a90c0106a83c107b6a06b6965399
parentdd430a021b2d413a1b6ffc8e9fbe104b2f72f35f (diff)
parentc6a445deed2ad7321d6707a328eba0cd67639104 (diff)
Merge branch 'handle-pci-save'
-rwxr-xr-xpm/sleep.d/98smart-kernel-video12
-rwxr-xr-xpm/sleep.d/99video38
2 files changed, 46 insertions, 4 deletions
diff --git a/pm/sleep.d/98smart-kernel-video b/pm/sleep.d/98smart-kernel-video
index 058149a..1043e94 100755
--- a/pm/sleep.d/98smart-kernel-video
+++ b/pm/sleep.d/98smart-kernel-video
@@ -28,7 +28,9 @@ smart_kernel_nvidia()
--quirk-vbemode-restore \
--quirk-vbestate-restore \
--quirk-reset-brightness \
- --quirk-radeon-off
+ --quirk-radeon-off \
+ --quirk-no-fb \
+ --quirk-pci-save
}
smart_kernel_fglrx()
@@ -45,7 +47,9 @@ smart_kernel_fglrx()
--quirk-vbemode-restore \
--quirk-vbestate-restore \
--quirk-reset-brightness \
- --quirk-radeon-off
+ --quirk-radeon-off \
+ --quirk-no-fb \
+ --quirk-pci-save
}
smart_kernel_intel()
@@ -65,7 +69,9 @@ smart_kernel_intel()
--quirk-vbemode-restore \
--quirk-vbestate-restore \
--quirk-reset-brightness \
- --quirk-radeon-off
+ --quirk-radeon-off \
+ --quirk-no-fb \
+ --quirk-pci-save
}
smart_kernel_video()
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