blob: 8d26ba5e365240ff17edf9f2ec3279ac28248fb5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
#!/bin/sh
#
# Copyright 2006-2007 Richard Hughes <richard@hughsie.com>
# Copyright 2007 Peter Jones <pjones@redhat.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of version 2 of the GNU General Public License as
# published by the Free Software Foundation.
. "${PM_FUNCTIONS}"
reset_brightness()
{
for bl in /sys/class/backlight/* ; do
[ -f "$bl/brightness" ] || continue
BR="$(cat $bl/brightness)"
echo 0 > "$bl/brightness"
echo "$BR" > "$bl/brightness"
done
}
if command_exists vbetool; then
vbe() { vbetool "$@"; }
else
vbe() { echo "vbetool not installed!" 1>&2; return 1; }
fi
if command_exists radeontool; then
radeon() { radeontool "$@"; }
else
radeon() { echo "radeontool not found" 1>&2; return 1; }
fi
save_fbcon()
{
local con
for con in /sys/class/graphics/*/state; do
[ -f $con ] || continue
echo 1 >"${con}"
done
}
resume_fbcon()
{
local con
for con in /sys/class/graphics/*/state; do
[ -f $con ] || continue
echo 0 >"${con}"
done
}
# Some tiny helper functions for quirk handling
quirk() { [ "$1" = "true" ] && [ -z $QUIRK_NONE ]; }
# save/restore vbe state
vbe_savestate() { vbe vbestate save |savestate vbestate; }
vbe_restorestate() { restorestate vbestate |vbe vbestate restore; }
# save/restore the vbe mode
vbe_savemode() { vbe vbemode get |savestate vbemode; }
vbe_restoremode() { vbe vbemode get |savestate vbemode; }
# post the video card
vbe_post() { vbe post; sleep 0.1; }
# turn critical bits of radeon cards off/on
radeon_off() { radeon dac off; radeon light off; }
radeon_on() { radeon dac on; radeon light on; }
suspend_video()
{
# 0=nothing, 1=s3_bios, 2=s3_mode, 3=both
local acpi_flag=0
[ "${QUIRK_S3_BIOS}" = "true" ] && acpi_flag=$(($acpi_flag + 1))
[ "${QUIRK_S3_MODE}" = "true" ] && acpi_flag=$(($acpi_flag + 2))
sysctl -w kernel.acpi_video_flags=$acpi_flag 2>&1 >/dev/null
quirk "${QUIRK_VBESTATE_RESTORE}" && vbe_savestate
quirk "${QUIRK_VBEMODE_RESTORE}" && vbe_savemode
quirk "${QUIRK_RADEON_OFF}" && radeon_off
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.
}
resume_video()
{
# We might need to do one or many of these quirks
quirk "${QUIRK_VBE_POST}" && vbe_post
quirk "${QUIRK_VBESTATE_RESTORE}" && vbe_restorestate
quirk "${QUIRK_VBEMODE_RESTORE}" && vbe_restoremode
resume_fbcon # also should be handled by a quirk.
quirk "${QUIRK_RADEON_OFF}" && radeon_on
quirk "${QUIRK_DPMS_ON}" && vbe dpms on
quirk "${QUIRK_RESET_BRIGHTNESS}" && reset_brightness
}
case "$1" in
suspend*)
suspend_video
;;
hibernate)
if [ "$HIBERNATE_RESUME_POST_VIDEO" = "yes" ]; then
suspend_video
fi
;;
resume)
resume_video
;;
thaw)
if [ "${HIBERNATE_RESUME_POST_VIDEO}" = "yes" ]; then
resume_video
fi
;;
esac
|