summaryrefslogtreecommitdiff
path: root/pm/sleep.d/98smart-kernel-video
blob: 04f80f604f56e75a6d2cd3dc54b4430d7b910c9c (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
#!/bin/sh
#
# Copyright 2008 Victor Lowther <victor.lowther@gmail.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}"


# Test to see if the kernel has a video driver that is smart enough to 
# handle quirks without external assistance. If it is, disable 99video.
smart_kernel_video() 
{
        # If we are using an ATI or nVidia binary driver, no quirks required.
	[ -d /sys/module/nvidia -o -d /sys/module/fglrx ] && return 0;

	local kernel_rev="$(uname -r |awk -F '[_-]' '{print $1}')"
        # Intel at or after kernel 2.6.26 is also quirk-free.
	# FIXME: a more accurate way of testing this?
	[ -d /sys/module/i915 ] && \
	    [ "$kernel_rev" \> "2.6.26" -o "$kernel_rev" = "2.6.26" ] && \
	    return 0;
	return $NA
}

case $1 in
     suspend|hibernate)
	smart_kernel_video && add_parameters "--quirk-none" ;;
     *) exit 0 ;;
esac