summaryrefslogtreecommitdiff
path: root/pm/sleep.d/99video
blob: 2797a06591890782d6f8bf1d2f8ea46b867fd0e2 (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
#!/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
}

resume_video()
{
	if [ "${DISPLAY_QUIRK_RADEON_OFF}" = "true" ]; then
		radeon dac on
		radeon light on
	fi
	# We might need to do one or many of these quirks
	if [ "${DISPLAY_QUIRK_VBE_POST}" = "true" ]; then
		vbe post
		sleep 0.1
	fi
	if [ "${DISPLAY_QUIRK_VBESTATE_RESTORE}" = "true" ]; then
		vbe vbestate restore < /var/run/vbestate
	fi
	if [ "${DISPLAY_QUIRK_VBEMODE_RESTORE}" = "true" ]; then
		vbe vbemode set "$(cat /var/run/vbemode)"
	fi
	# based on data from s2ram
	resume_fbcon
	if [ "${DISPLAY_QUIRK_DPMS_ON}" = "true" ]; then
		vbe dpms on
	fi
	if [ "${DISPLAY_QUIRK_RESET_BRIGHTNESS}" = "true" ]; then
		reset_brightness
	fi
}


case "$1" in
	suspend)
		save_fbcon
		;;
	resume)
		resume_video
		;;
	thaw)
		if [ "${HIBERNATE_RESUME_POST_VIDEO}" = "yes" ]; then
			resume_video
		fi
		;;
esac