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

. /usr/lib/pm-utils/functions


reset_brightness() {
	for bl in /sys/class/backlight/* ; do
		[ -d $bl ] || continue
		[ -f $bl/brightness ] || continue
		BR=$(cat $bl/brightness)
		echo 0 > $bl/brightness
		echo $BR > $bl/brightness
	done
}

vbetool=$(type -p vbetool)
vbe() {
	if [ -z "$vbetool" ]; then
		echo "vbetool not found" 1>&2
		return 1
	fi
	$vbetool "$@"
}

radeontool=$(type -p radeontool)
radeon() {
	if [ -z "$radeontool" ]; then
		echo "radeontool not found" 1>&2
		return 1
	fi
	$radeontool "$@"
}

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
		usleep 100000
	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
	if [ "${DISPLAY_QUIRK_DPMS_ON}" == "true" ]; then
		vbe dpms on
	fi
	if [ "${DISPLAY_QUIRK_RESET_BRIGHTNESS}" == "true" ]; then
		reset_brightness
	fi
}


case "$1" in
	resume)
		resume_video
		;;
	thaw)
		if [ "x$HIBERNATE_RESUME_POST_VIDEO" == "xyes" ]; then
			resume_video
		fi
		;;
esac

exit $?