1From 338c2cab495d3d3d62cb7094b7dad78aea7f53eb Mon Sep 17 00:00:00 2001 2From: Yu YongZhen <yuyz@rock-chips.com> 3Date: Wed, 25 Apr 2018 09:25:18 +0800 4Subject: [PATCH] pm:sleep.d: remove unused sleep hooks 5 6--- 7 pm/sleep.d/00powersave | 13 -- 8 pm/sleep.d/01grub | 34 --- 9 pm/sleep.d/49bluetooth | 35 --- 10 pm/sleep.d/55NetworkManager | 42 ---- 11 pm/sleep.d/75modules | 31 --- 12 pm/sleep.d/90clock | 27 --- 13 pm/sleep.d/94cpufreq | 46 ---- 14 pm/sleep.d/95led | 16 -- 15 pm/sleep.d/98video-quirk-db-handler | 450 ------------------------------------ 16 pm/sleep.d/99video | 219 ------------------ 17 pm/sleep.d/Makefile.am | 12 +- 18 pm/sleep.d/Makefile.in | 12 +- 19 12 files changed, 2 insertions(+), 935 deletions(-) 20 delete mode 100644 pm/sleep.d/00powersave 21 delete mode 100644 pm/sleep.d/01grub 22 delete mode 100755 pm/sleep.d/49bluetooth 23 delete mode 100755 pm/sleep.d/55NetworkManager 24 delete mode 100755 pm/sleep.d/75modules 25 delete mode 100755 pm/sleep.d/90clock 26 delete mode 100755 pm/sleep.d/94cpufreq 27 delete mode 100755 pm/sleep.d/95led 28 delete mode 100755 pm/sleep.d/98video-quirk-db-handler 29 delete mode 100755 pm/sleep.d/99video 30 31diff --git a/pm/sleep.d/00powersave b/pm/sleep.d/00powersave 32deleted file mode 100644 33index bf0f98b..0000000 34--- a/pm/sleep.d/00powersave 35+++ /dev/null 36@@ -1,13 +0,0 @@ 37-#!/bin/sh 38- 39-. "${PM_FUNCTIONS}" 40- 41-command_exists pm-powersave || exit $NA 42- 43-case $1 in 44- suspend|hibernate) pm-powersave false ;; 45- resume|thaw) pm-powersave ;; 46- *) exit $NA ;; 47-esac 48-exit 0 49- 50\ No newline at end of file 51diff --git a/pm/sleep.d/01grub b/pm/sleep.d/01grub 52deleted file mode 100644 53index db1d53b..0000000 54--- a/pm/sleep.d/01grub 55+++ /dev/null 56@@ -1,34 +0,0 @@ 57-#!/bin/sh 58-# Ensure grub will load the correct kernel on resume from hibernate, 59-# TODO: This is rather redhat specific, and very grub specific. 60- 61-default_resume_kernel() 62-{ 63- [ "$1" = "suspend" ] && return $NA 64- case $(uname -m) in 65- i?86|x86_64|athlon) 66- ;; 67- *) # this is only valid for x86 and x86_64 68- return $NA 69- ;; 70- esac 71- 72- [ -x /sbin/grubby -a -x /sbin/grub ] || return $NA 73- [ -e "/boot/vmlinuz-$(uname -r)" ] || return 1 74- out=$(/sbin/grubby --info /boot/vmlinuz-$(uname -r) |grep index) 75- [ -n "${out}" ] || return 1 76- current=${out#index=} 77- echo "savedefault --default=${current} --once" | \ 78- /sbin/grub --device-map=/boot/grub/device.map \ 79- --batch --no-floppy --no-curses >/dev/null 80- 81- return 0 82-} 83- 84-case "$1" in 85- hibernate|suspend) 86- default_resume_kernel $2 87- ;; 88- *) exit $NA 89- ;; 90-esac 91diff --git a/pm/sleep.d/49bluetooth b/pm/sleep.d/49bluetooth 92deleted file mode 100755 93index d46ba49..0000000 94--- a/pm/sleep.d/49bluetooth 95+++ /dev/null 96@@ -1,35 +0,0 @@ 97-#!/bin/sh 98-# IBM specific hack to disable/enable bluetooth. 99-# TODO: Doesn't the working USB suspend/resume functionality 100-# make this code more or less obsolete? 101- 102-. "${PM_FUNCTIONS}" 103- 104-[ -f /proc/acpi/ibm/bluetooth ] || exit $NA 105- 106-suspend_bluetooth() 107-{ 108- if grep -q enabled /proc/acpi/ibm/bluetooth; then 109- savestate ibm_bluetooth enable 110- echo disable > /proc/acpi/ibm/bluetooth 111- else 112- savestate ibm_bluetooth disable 113- fi 114-} 115- 116-resume_bluetooth() 117-{ 118- state_exists ibm_bluetooth || return 119- restorestate ibm_bluetooth > /proc/acpi/ibm/bluetooth 120-} 121- 122-case "$1" in 123- hibernate|suspend) 124- suspend_bluetooth 125- ;; 126- thaw|resume) 127- resume_bluetooth 128- ;; 129- *) exit $NA 130- ;; 131-esac 132diff --git a/pm/sleep.d/55NetworkManager b/pm/sleep.d/55NetworkManager 133deleted file mode 100755 134index f3c6df5..0000000 135--- a/pm/sleep.d/55NetworkManager 136+++ /dev/null 137@@ -1,42 +0,0 @@ 138-#!/bin/sh 139-# If we are running NetworkManager, tell it we are going to sleep. 140-# TODO: Make NetworkManager smarter about how to handle sleep/resume 141-# If we are asleep for less time than it takes for TCP to reset a 142-# connection, and we are assigned the same IP on resume, we should 143-# not break established connections. Apple can do this, and it is 144-# rather nifty. 145- 146-. "${PM_FUNCTIONS}" 147- 148-suspend_nm() 149-{ 150- # Tell NetworkManager to shut down networking 151- printf "Having NetworkManager put all interaces to sleep..." 152- dbus_send --system \ 153- --dest=org.freedesktop.NetworkManager \ 154- /org/freedesktop/NetworkManager \ 155- org.freedesktop.NetworkManager.sleep && \ 156- echo Done. || echo Failed. 157-} 158- 159-resume_nm() 160-{ 161- # Wake up NetworkManager and make it do a new connection 162- printf "Having NetworkManager wake interfaces back up..." 163- dbus_send --system \ 164- --dest=org.freedesktop.NetworkManager \ 165- /org/freedesktop/NetworkManager \ 166- org.freedesktop.NetworkManager.wake && \ 167- echo Done. || echo Failed. 168-} 169- 170-case "$1" in 171- hibernate|suspend) 172- suspend_nm 173- ;; 174- thaw|resume) 175- resume_nm 176- ;; 177- *) exit $NA 178- ;; 179-esac 180diff --git a/pm/sleep.d/75modules b/pm/sleep.d/75modules 181deleted file mode 100755 182index 261e70d..0000000 183--- a/pm/sleep.d/75modules 184+++ /dev/null 185@@ -1,31 +0,0 @@ 186-#!/bin/sh 187-# Unload requested modules. 188- 189-. "${PM_FUNCTIONS}" 190- 191-suspend_modules() 192-{ 193- [ -z "$SUSPEND_MODULES" ] && return $NA 194- for x in $SUSPEND_MODULES ; do 195- printf "Unloading kernel module %s..." "$x" 196- modunload $x && echo Done. || echo Failed. 197- done 198- return 0 199-} 200- 201-resume_modules() 202-{ 203- modreload 204- echo "Reloaded unloaded modules." 205-} 206- 207-case "$1" in 208- hibernate|suspend) 209- suspend_modules 210- ;; 211- thaw|resume) 212- resume_modules 213- ;; 214- *) exit $NA 215- ;; 216-esac 217diff --git a/pm/sleep.d/90clock b/pm/sleep.d/90clock 218deleted file mode 100755 219index d81e2a6..0000000 220--- a/pm/sleep.d/90clock 221+++ /dev/null 222@@ -1,27 +0,0 @@ 223-#!/bin/sh 224-# Synchronize system time with hardware time. 225-# Modern kernels handle this correctly so we skip this hook by default. 226- 227-. "${PM_FUNCTIONS}" 228- 229-suspend_clock() 230-{ 231- printf "Saving system time to hardware clock..." 232- /sbin/hwclock --systohc >/dev/null 2>&1 0<&1 && echo Done. || \ 233- echo Failed. 234-} 235- 236-resume_clock() 237-{ 238- printf "Loading system time from hardware clock..." 239- /sbin/hwclock --hctosys >/dev/null 2>&1 0<&1 && echo Done. || \ 240- echo Failed. 241-} 242- 243-is_set "$NEED_CLOCK_SYNC" || exit $NA 244- 245-case "$1" in 246- hibernate|suspend) suspend_clock ;; 247- thaw|resume) resume_clock ;; 248- *) exit $NA ;; 249-esac 250diff --git a/pm/sleep.d/94cpufreq b/pm/sleep.d/94cpufreq 251deleted file mode 100755 252index 6807681..0000000 253--- a/pm/sleep.d/94cpufreq 254+++ /dev/null 255@@ -1,46 +0,0 @@ 256-#!/bin/sh 257-# Ensure cpu governor is set to something sane. 258-# TODO: Which of the cpu governors is still insane? File bugs against 259-# those that are. 260- 261-. "${PM_FUNCTIONS}" 262- 263-[ -d /sys/devices/system/cpu/ ] || exit $NA 264- 265-hibernate_cpufreq() 266-{ 267- ( cd /sys/devices/system/cpu/ 268- for x in cpu[0-9]*; do 269- # if cpufreq is a symlink, it is handled by another cpu. Skip. 270- [ -L "$x/cpufreq" ] && continue 271- gov="$x/cpufreq/scaling_governor" 272- # if we do not have a scaling_governor file, skip. 273- [ -f "$gov" ] || continue 274- # if our temporary governor is not available, skip. 275- grep -q "$TEMPORARY_CPUFREQ_GOVERNOR" \ 276- "$x/cpufreq/scaling_available_governors" || continue 277- savestate "${x}_governor" < "$gov" 278- echo "$TEMPORARY_CPUFREQ_GOVERNOR" > "$gov" 279- done ) 280-} 281- 282-thaw_cpufreq() 283-{ 284- ( cd /sys/devices/system/cpu/ 285- for x in cpu[0-9]*/cpufreq/scaling_governor ; do 286- [ -f "$x" ] || continue 287- state_exists "${x%%/*}_governor" || continue 288- restorestate "${x%%/*}_governor" > "$x" 289- done ) 290-} 291- 292-case "$1" in 293- suspend|hibernate) 294- hibernate_cpufreq 295- ;; 296- resume|thaw) 297- thaw_cpufreq 298- ;; 299- *) exit $NA 300- ;; 301-esac 302diff --git a/pm/sleep.d/95led b/pm/sleep.d/95led 303deleted file mode 100755 304index b4bb970..0000000 305--- a/pm/sleep.d/95led 306+++ /dev/null 307@@ -1,16 +0,0 @@ 308-#!/bin/sh 309-# On an IBM system. make the suspend LED blink. 310-# TODO: Merge with 95led? Should be trivial. 311- 312-[ -f /proc/acpi/ibm/led ] || exit $NA 313- 314-case "$1" in 315- hibernate|suspend) 316- echo "7 blink" >/proc/acpi/ibm/led 317- ;; 318- thaw|resume) 319- echo "7 off" >/proc/acpi/ibm/led 320- ;; 321- *) exit $NA 322- ;; 323-esac 324diff --git a/pm/sleep.d/98video-quirk-db-handler b/pm/sleep.d/98video-quirk-db-handler 325deleted file mode 100755 326index e9ea3ca..0000000 327--- a/pm/sleep.d/98video-quirk-db-handler 328+++ /dev/null 329@@ -1,450 +0,0 @@ 330-#!/bin/bash 331-# Prototype video quirk database handler that does not rely on HAL. 332- 333-shopt -s extglob 334- 335-. "${PM_FUNCTIONS}" 336- 337-[[ $PM_DEBUG ]] && { 338- export PS4='${BASH_SOURCE}@${LINENO}(${FUNCNAME[0]}): '; 339- set -x 340-} 341- 342-possible_video_quirks=" --quirk-dpms-on 343- --quirk-dpms-suspend 344- --quirk-s3-mode 345- --quirk-s3-bios 346- --quirk-vbe-post 347- --quirk-vbe-post 348- --quirk-vga-mode-3 349- --quirk-vbemode-restore 350- --quirk-vbestate-restore 351- --quirk-reset-brightness 352- --quirk-radeon-off 353- --quirk-no-fb 354- --quirk-save-pci" 355- 356-possible_system_properties="system.firmware.version 357- system.firmware.vendor 358- system.firmware.release_date 359- system.hardware.vendor 360- system.hardware.product 361- system.hardware.version 362- system.board.product 363- system.board.version 364- system.board.vendor 365- system.hardware.primary_video.vendor 366- system.hardware.primary_video.product 367- system.hardware.primary_video.driver 368- system.hardware.primary_video.using_kms 369- system.kernel.version" 370- 371-has_video_parameters() { 372- local p params=$(get_parameters) 373- [[ $params ]] || return 1 374- for p in $params; do 375- [[ $possible_video_quirks = *$p* ]] && return 376- done 377- return 1 378-} 379- 380-# video specific helper functions. 381- 382-# Are we using the nVidia binary driver? 383-using_nvidia() { [[ -d /sys/module/nvidia ]]; } 384- 385-# How about the ATI one? 386-using_fglrx() { [[ -d /sys/module/fglrx ]]; } 387- 388-# OK, what about a driver that is using kernel modesetting? 389-using_kms() { grep -q -E '(nouveau|drm)fb' /proc/fb; } 390- 391-# Get some video related values when HAL has not gotten them for us, or 392-# HAL is not available. 393-videoget() { 394- local dev pci 395- pci="/sys/bus/pci/devices" 396- for dev in "$pci"/*; do 397- [[ -f "${dev}/class" ]] || continue 398- [[ "$(cat "${dev}/class")" = "0x030000" ]] || continue 399- case $1 in 400- vendor) RES="$(cat "${dev}/vendor")" ;; 401- device) RES="$(cat "${dev}/device")" ;; 402- driver) 403- if [[ -L ${dev}/driver ]]; then 404- RES="$(readlink "${dev}/driver")" 405- RES="${RES##*/}" 406- elif using_nvidia; then 407- RES=nvidia 408- elif using_fglrx; then 409- RES=fglrx 410- fi 411- ;; 412- using_kms) 413- if using_kms; then 414- RES=true 415- else 416- RES=false 417- fi 418- ;; 419- esac 420- break 421- done 422-} 423- 424-# Get some important information about this system. 425- 426-# If we have /sys/class/dmi/id, life is easy, and we do not need to 427-# depend on HAL or dmidecode. 428-_dmisysget() { 429- [[ -r /sys/class/dmi/id/$1 ]] || RES="" 430- read RES < "/sys/class/dmi/id/$1" 431-} 432- 433-dmisysget() { 434- case $1 in 435- system.firmware.vendor) _dmisysget bios_vendor ;; 436- system.firmware.version) _dmisysget bios_version ;; 437- system.firmware.release_date) _dmisysget bios_date ;; 438- system.hardware.vendor) _dmisysget sys_vendor ;; 439- system.hardware.product) _dmisysget product_name ;; 440- system.hardware.version) _dmisysget product_version ;; 441- system.board.product) _dmisysget board_name ;; 442- system.board.version) _dmisysget board_version ;; 443- system.board.vendor) _dmisysget board_vendor ;; 444- system.hardware.primary_video.vendor) videoget vendor ;; 445- system.hardware.primary_video.product) videoget device ;; 446- system.hardware.primary_video.driver) videoget driver ;; 447- system.hardware.primary_video.using_kms) videoget using_kms ;; 448- system.kernel.version) RES=$(uname -r) ;; 449- *) return 1 450- esac 451-} 452- 453-# Get system information using dmidecode. Slow and ugly, but 454-# should be supported just about everywhere. 455-_dmidecodeget() { 456- RES=$(dmidecode -s $1) 457-} 458- 459-dmidecodeget() { 460- case $1 in 461- system.firmware.vendor) _dmidecodeget bios-vendor ;; 462- system.firmware.version) _dmidecodeget bios-version ;; 463- system.firmware.release_date) _dmidecodeget bios-release-date;; 464- system.hardware.vendor) _dmidecodeget system-manufacturer;; 465- system.hardware.product) _dmidecodeget system-product-name;; 466- system.hardware.version) _dmidecodeget system-version;; 467- system.board.product) _dmidecodeget baseboard-product-name;; 468- system.board.version) _dmidecodeget baseboard-version;; 469- system.board.vendor) _dmidecodeget baseboard-manufacturer;; 470- *) return 1 471- esac 472-} 473- 474-# If we have HAL, it has already done most of the work for us. 475-halget() { 476- local hgp="hal-get-property --udi /org/freedesktop/Hal/devices/computer --key" 477- case $1 in 478- system.firmware.version) RES=$($hgp "$1") ;; 479- system.firmware.vendor) RES=$($hgp "$1") ;; 480- system.firmware.release_date) RES=$($hgp "$1") ;; 481- system.hardware.vendor) RES=$($hgp "$1") ;; 482- system.hardware.product) RES=$($hgp "$1") ;; 483- system.hardware.version) RES=$($hgp "$1") ;; 484- system.board.product) RES=$($hgp "$1") ;; 485- system.board.version) RES=$($hgp "$1") ;; 486- system.board.vendor) RES=$($hgp "$1") ;; 487- *) return 1 488- esac 489-} 490- 491-canonicalize_dmivar() { 492- [[ $1 =~ ^[a-z._-]+$ && $possible_system_properties = *$1* ]] || return 1 493- echo "${1//[-.]/_}" 494-} 495- 496-# Precache the DMI and other information we will need as shell variables. 497-# This will make things easier when we start running for real. 498-precache_dmivars() { 499- local p q f 500- for q in $possible_system_properties; do 501- p=$(canonicalize_dmivar $q) || return 1 502- RES="" 503- for f in dmisysget halget dmidecodeget; do 504- "$f" "$q" && break || continue 2 505- done 506- RES="${RES##+( )}" 507- RES="${RES%%+( )}" 508- read "$p" <<<$RES 509- done 510- RES="" 511-} 512- 513-# Use bash variable indirection to set RES to the actual parameter 514-# we are looking for. Sanity check the variable we were passed to 515-# keep things sane. 516-getprop() { 517- RES="" 518- local p 519- if ! p=$(canonicalize_dmivar $1); then 520- echo "Unable to obtain DMI information for $1" >&2 521- exit 1 522- fi 523- RES="${!p}" 524-} 525- 526-# test to see if the parameter passed is a decimal or hexidecimal number 527-# Note the complete lack of floating point support. 528-isnum() { 529- [[ $1 =~ ^[0-9]+\$ || $1 =~ ^0[xX][0-9a-fA-F]+\$ ]] 530-} 531- 532-# for all the matching functions, 533-# $2 = the given constant (or regular expression), 534-# $1 = the raw data grabbed from HAL or dmidecode or wherever 535- 536-regex() { [[ $1 =~ ${2//;/|} ]]; } 537- 538-regex_ncase() { 539- local r 540- shopt -s nocasematch 541- regex "$1" "$2" 542- r=$? 543- shopt -u nocasematch 544- return $r 545-} 546- 547-regex_inverse() { ! regex "$1" "$2"; } 548-compare_eq() { [[ $1 = $2 ]]; } 549-compare_ne() { [[ $1 != $2 ]]; } 550-compare_gt() { [[ $1 > $2 ]]; } 551-compare_ge() { compare_eq "$@" || compare_gt "$@"; } 552-compare_lt() { [[ $1 < $2 ]]; } 553-compare_le() { compare_eq "$@" || compare_lt "$@"; } 554-numeric_compare_eq() { (( $1 == $2 )); } 555-numeric_compare_ne() { (( $1 != $2 )); } 556-numeric_compare_gt() { (( $1 > $2 )); } 557-numeric_compare_ge() { (( $1 >= $2 )); } 558-numeric_compare_lt() { (( $1 < $2 )); } 559-numeric_compare_le() { (( $1 <= $2 )); } 560-numeric_compare_eq_list() { 561- local key val 562- # $1 = key val to compare 563- # $2 = list to compare to 564- key=$1 565- val="${2//;/ }" 566- for x in $val; do 567- (( $key == $x )) && return 0 568- done 569- return 1 570-} 571- 572-# Helper function for nVidia g80 gpus. They require extra special handling 573-# when not using the nVidia binary driver. 574-have_nvidia_g80() { 575- numeric_compare_eq $system_hardware_primary_video_vendor 0x10de || return 576- numeric_compare_eq_list $system_hardware_primary_video_product \ 577- '0x190;0x191;0x192;0x193;0x194;0x195;0x196;0x197;0x198;0x199;0x19a;0x19b;0x19c;0x19d;0x19e;0x19f;0x400;0x401;0x402;0x403;0x404;0x405;0x406;0x407;0x408;0x409;0x40a;0x40b;0x40c;0x40d;0x40e;0x40f;0x420;0x421;0x422;0x423;0x424;0x425;0x426;0x427;0x428;0x429;0x42a;0x42b;0x42c;0x42d;0x42e;0x42f' || return 578-} 579- 580-# Helper function for recent Intel framebuffer drivers. 581-have_smart_intel() { 582- local kernel_rev=$system_kernel_revision 583- local driver=$system_hardware_primary_video_driver 584- # currently, intel kernel modesetting is not quite smart enough 585- # we still need acpi s3 kernel modesetting hooks, so don't remove those 586- # options if they were passed. 587- [[ $driver = i915 && ( $kernel_rev > 2.6.26 || $kernel_rev = 2.6.26 ) ]] 588-} 589- 590-# find the appropriate quirks for this system using the native-format 591-# quirks database. Since the database is tree-ish, we use some stupid 592-# recursion tricks. 593- 594-# $1 = whether to ignore what we are reading 595-_find_native() { 596- local action key matcher regex 597- while read action key matcher regex; do 598- [[ $action && ${action:0:1} != '#' ]] || continue 599- case $action in 600- match) 601- if [[ $1 = ignore ]]; then 602- _find_native $1 603- else 604- getprop "$key" 605- [[ $matcher && $regex ]] || find_native ignore 606- # if this matcher matches, look at nodes farther out. 607- if $matcher "$RES" "$regex"; then 608- _find_native work 609- else 610- _find_native ignore 611- fi 612- fi 613- ;; 614- endmatch) 615- [[ $found ]] && return 0 || return 1 ;; 616- addquirk) [[ $1 = ignore ]] && continue 617- found=true 618- add_parameters "$key" 619- ;; 620- delquirk) [[ $1 = ignore ]]&& continue 621- found=true 622- remove_parameters "$key" 623- ;; 624- esac 625- done 626-} 627- 628-find_native() ( 629- [[ -f $1 ]] || return 1 630- exec <"$1" 631- _find_native work 632- res=$? 633- get_parameters 634- return $res 635-) 636- 637-# If we resumed, write out the quirks we used as our last known 638-# working ones for this hardware, kernel, driver, and KMS setting. 639-write_last_known_working() ( 640- local matcher quirk 641- precache_dmivars 642- exec >"$PM_LKW_QUIRKS" 643- for prop in system.firmware.version system.firmware.vendor \ 644- system.firmware.release_date system.hardware.vendor \ 645- system.hardware.product system.hardware.version \ 646- system.board.product system.board.version system.board.vendor \ 647- system.hardware.primary_video.vendor \ 648- system.hardware.primary_video.product \ 649- system.hardware.primary_video.driver \ 650- system.hardware.primary_video.using_kms \ 651- system.kernel.version; do 652- getprop "$prop" 653- if isnum "$RES"; then 654- matcher=numeric_compare_eq 655- else 656- matcher=compare_eq 657- fi 658- echo "match $prop $matcher ${RES}" 659- done 660- if [[ $QUIRKS ]]; then 661- for quirk in $QUIRKS; do 662- echo "addquirk $quirk" 663- done 664- else 665- echo "addquirk --quirk-none" 666- fi 667- for ((x=1; x<14; x++)); do 668- echo endmatch 669- done 670-) 671- 672-case $1 in 673- suspend|hibernate) 674- # Aaand.... GO 675- # cache all the properties we will need. 676- precache_dmivars 677- 678- # This logic can also be expressed using entries in the quirkdb, 679- # but I am too lazy to do that until a final quirk database is 680- # formalized. 681- if has_parameter --quirk-test && has_video_parameters; then 682- # The user is explicitly testing video parameters. 683- # Use them without the usual filtering. This may cause the system 684- # to blow up, but they explicitly asked for it. 685- remove_parameters --quirk-test 686- echo "Quirk testing mode enabled." 687- elif using_kms; then 688- # Using kernel modesetting? No quirks, and do not change vts. 689- remove_parameters $possible_video_quirks 690- add_parameters --quirk-no-chvt 691- echo "Kernel modesetting video driver detected, not using quirks." 692- elif using_nvidia; then 693- # Ditto for nVidia binary drivers 694- remove_parameters $possible_video_quirks 695- echo "nVidia binary video drive detected, not using quirks." 696- elif using_fglrx; then 697- # fglrx may or may not have to change vts, reports one 698- # way or the other welcome. 699- remove_parameters $possible_video_quirks 700- add_parameters --quirk-none 701- echo "ATI Catalyst driver detected, not using quirks." 702- elif have_nvidia_g80; then 703- # nVidia G80 GPUs require special handling when not using nvidia 704- # binary drivers. I do not know if noveau requires help or not. 705- remove_parameters $possible_video_quirks 706- add_parameters --quirk-vbe-post 707- echo "nVidia g80 series card detected." 708- else 709- # Go ahead and get our quirks. 710- if has_video_parameters; then 711- # Parameters from the command line take precedence 712- # over the database, so do not query it. 713- echo "Using quirks passed as parameters." 714- elif [[ $PM_QUIRKS ]]; then 715- # If we have $PM_QUIRKS. use it instead of the quirk database 716- add_parameters $PM_QUIRKS 717- echo "Using PM_QUIRKS environment variable for quirks." 718- # If we were not passed any quirks on the command line, 719- # get them from the database. 720- elif QUIRKS=$(find_native "$PM_LKW_QUIRKS"); then 721- # Known working quirks from our last run are still valid. 722- # Use them. 723- add_parameters $QUIRKS 724- echo "Using last known working set of quirks." 725- else 726- # Our known working quirks from the last run are either 727- # nonexistent or invalid. Either way, start over. 728- rm "$PM_LKW_QUIRKS" >/dev/null 2>&1 729- for f in "$PM_QUIRKDB"/*.quirkdb 730- do 731- QUIRKS=$(find_native "$f") && break 732- done 733- # some default quirks if we did not get any. 734- if [[ -z $QUIRKS ]]; then 735- QUIRKS="--quirk-vbe-post --quirk-dpms-on 736- --quirk-dpms-suspend --quirk-vbestate-restore 737- --quirk-vbemode-restore --quirk-vga-mode-3" 738- echo "No quirk database entry for this system, using default." 739- else 740- echo "Using quirks for this system from quirk database." 741- fi 742- add_parameters $QUIRKS 743- savestate video_quirks "$QUIRKS" 744- fi 745- if have_smart_intel; then 746- # Intel without KMS does not require most quirks, no matter 747- # what anything else says. The only ones that seem to 748- # matter are the --quirk-s3 ones, so remove everything else. 749- remove_parameters --quirk-dpms-on \ 750- --quirk-dpms-suspend \ 751- --quirk-vbe-post \ 752- --quirk-vbe-post \ 753- --quirk-vga-mode-3 \ 754- --quirk-vbemode-restore \ 755- --quirk-vbestate-restore \ 756- --quirk-reset-brightness \ 757- --quirk-radeon-off \ 758- --quirk-no-fb \ 759- --quirk-save-pci 760- echo "Cleaning up quirks not needed by Intel video cards." 761- fi 762- fi 763- ;; 764- thaw|resume) 765- if state_exists video_quirks; then 766- QUIRKS=$(restorestate video_quirks); 767- write_last_known_working 768- echo "Saving last known working quirks: $QUIRKS" 769- elif has_parameter --store-quirks-as-lkw; then 770- for x in $(get_parameters); do 771- for y in $possible_video_quirks; do 772- [[ $x = $y ]] && QUIRKS=" $QUIRKS $x" 773- done 774- done 775- write_last_known_working 776- echo "Saving last known working quirks: $QUIRKS" 777- fi 778- ;; 779-esac 780diff --git a/pm/sleep.d/99video b/pm/sleep.d/99video 781deleted file mode 100755 782index 452a88a..0000000 783--- a/pm/sleep.d/99video 784+++ /dev/null 785@@ -1,219 +0,0 @@ 786-#!/bin/sh 787-# 788-# Copyright 2006-2007 Richard Hughes <richard@hughsie.com> 789-# Copyright 2007 Peter Jones <pjones@redhat.com> 790-# 791-# This program is free software; you can redistribute it and/or modify 792-# it under the terms of version 2 of the GNU General Public License as 793-# published by the Free Software Foundation. 794- 795-# Handle video quirks. If you are having suspend/resume issues, 796-# troubleshooting using this hook is probably the best place to start. 797-# If it weren't for video card quirks, suspend/resume on Linux would be 798-# a whole lot more stable. 799- 800-. "${PM_FUNCTIONS}" 801- 802-for opt in $PM_CMDLINE; do 803- case "${opt##--quirk-}" in # just quirks, please 804- dpms-on) QUIRK_DPMS_ON="true" ;; 805- dpms-suspend) QUIRK_DPMS_SUSPEND="true" ;; 806- radeon-off) QUIRK_RADEON_OFF="true" ;; 807- reset-brightness) QUIRK_RESET_BRIGHTNESS="true" ;; 808- s3-bios) QUIRK_S3_BIOS="true" ;; 809- s3-mode) QUIRK_S3_MODE="true" ;; 810- vbe-post) QUIRK_VBE_POST="true" ;; 811- vbemode-restore) QUIRK_VBEMODE_RESTORE="true" ;; 812- vbestate-restore) QUIRK_VBESTATE_RESTORE="true" ;; 813- vga-mode-3) QUIRK_VGA_MODE_3="true" ;; 814- no-fb) QUIRK_NOFB="true" ;; 815- save-pci) QUIRK_SAVE_PCI="true" ;; 816- no-chvt) QUIRK_NO_CHVT="true" ;; 817- none) QUIRK_NONE="true" ;; 818- *) continue ;; 819- esac 820-done 821- 822-reset_brightness() 823-{ 824- for bl in /sys/class/backlight/* ; do 825- [ -f "$bl/brightness" ] || continue 826- BR="$(cat $bl/brightness)" 827- echo 0 > "$bl/brightness" 828- echo "$BR" > "$bl/brightness" 829- done 830-} 831- 832-if command_exists vbetool; then 833- vbe() { vbetool "$@"; } 834-else 835- vbe() { echo "vbetool not installed!" 1>&2; return 1; } 836-fi 837- 838-if command_exists radeontool; then 839- radeon() { radeontool "$@"; } 840-else 841- radeon() { echo "radeontool not found" 1>&2; return 1; } 842-fi 843- 844-die_if_framebuffer() 845-{ 846- [ -d "/sys/class/graphics/fb0" ] || return 847- echo "--quirk-no-fb passed, but system is using a framebuffer." 848- echo "Aborting." 849- exit 1 850-} 851- 852- 853-save_fbcon() 854-{ 855- local con 856- for con in /sys/class/graphics/*/state; do 857- [ -f $con ] || continue 858- echo 1 >"${con}" 859- done 860-} 861- 862-resume_fbcon() 863-{ 864- local con 865- for con in /sys/class/graphics/*/state; do 866- [ -f $con ] || continue 867- echo 0 >"${con}" 868- done 869-} 870- 871-maybe_chvt() 872-{ 873- is_set "$QUIRK_NO_CHVT" && return 874- fgconsole |savestate console 875- chvt 63 876-} 877- 878-maybe_deallocvt() 879-{ 880- state_exists console || return 0 881- chvt $(restorestate console) 882- deallocvt 63 883-} 884- 885-# Some tiny helper functions for quirk handling 886-quirk() { is_set "$1" && [ -z $QUIRK_NONE ]; } 887- 888-# save/restore vbe state 889-vbe_savestate() { vbe vbestate save |savestate vbestate; } 890-vbe_restorestate() { restorestate vbestate |vbe vbestate restore; } 891- 892-# save/restore the vbe mode 893-vbe_savemode() { vbe vbemode get |savestate vbemode; } 894-vbe_restoremode() 895-{ 896- # this is a little mode complicated to handle special-casing mode 3. 897- local vbemode=$(restorestate vbemode) 898- if [ "$vbemode" = "3" ]; then 899- vbe vgamode set $vbemode 900- else 901- vbe vbemode set $vbemode 902- fi 903-} 904- 905-# post the video card 906-vbe_post() 907-{ 908- local rom="/var/run/video.rom" 909- # if we do not have a romfile, do not post with it. 910- [ -f "$rom" ] || unset rom 911- vbe post $rom 912- sleep 0.1 913-} 914- 915-# turn critical bits of radeon cards off/on 916-radeon_off() { radeon dac off; radeon light off; } 917-radeon_on() { radeon dac on; radeon light on; } 918- 919-# save and restore video card PCI config state 920-save_pci() 921-{ 922- local pci="/sys/bus/pci/devices" 923- for dev in "${pci}"/*; do 924- [ -f "${dev}/class" ] || continue 925- [ $(cat "${dev}/class") = "0x030000" ] || continue 926- [ -f "${dev}/config" ] || continue 927- # it is a video card, it has a configuration. Save it. 928- savestate "pci_video_${dev##*/}" <${dev}/config 929- done 930-} 931- 932-restore_pci() 933-{ 934- local pci="/sys/bus/pci/devices" 935- for dev in "${pci}"/*; do 936- state_exists "pci_video_${dev##*/}" || continue 937- restorestate "pci_video_${dev##*/}" > "${dev}/config" 938- done 939-} 940- 941-suspend_video() 942-{ 943- # 0=nothing, 1=s3_bios, 2=s3_mode, 3=both 944- local acpi_flag=0 945- quirk "${QUIRK_S3_BIOS}" && acpi_flag=$(($acpi_flag + 1)) 946- quirk "${QUIRK_S3_MODE}" && acpi_flag=$(($acpi_flag + 2)) 947- sysctl -w kernel.acpi_video_flags=$acpi_flag 948- 949- quirk "${QUIRK_NOFB}" && die_if_framebuffer 950- quirk "${QUIRK_VBESTATE_RESTORE}" && vbe_savestate 951- quirk "${QUIRK_VBEMODE_RESTORE}" && vbe_savemode 952- quirk "${QUIRK_RADEON_OFF}" && radeon_off 953- quirk "${QUIRK_SAVE_PCI}" && save_pci 954- quirk "${QUIRK_VGA_MODE_3}" && vbe vbemode set 3 955- quirk "${QUIRK_DPMS_SUSPEND}" && vbe dpms suspend 956- save_fbcon 957-} 958-resume_video() 959-{ 960- # We might need to do one or many of these quirks 961- quirk "${QUIRK_SAVE_PCI}" && restore_pci 962- quirk "${QUIRK_VBE_POST}" && vbe_post 963- quirk "${QUIRK_VBESTATE_RESTORE}" && vbe_restorestate 964- quirk "${QUIRK_VBEMODE_RESTORE}" && vbe_restoremode 965- resume_fbcon # also should be handled by a quirk. 966- quirk "${QUIRK_RADEON_OFF}" && radeon_on 967- quirk "${QUIRK_DPMS_ON}" && vbe dpms on 968- quirk "${QUIRK_RESET_BRIGHTNESS}" && reset_brightness 969- return 0 # avoid spurious hook exit failure message. 970-} 971- 972-help() { 973- echo # first echo makes it look nicer. 974- echo "Video quirk handler options:" 975- echo 976- echo " --quirk-dpms-on" 977- echo " --quirk-dpms-suspend" 978- echo " --quirk-radeon-off" 979- echo " --quirk-reset-brightness" 980- echo " --quirk-s3-bios" 981- echo " --quirk-s3-mode" 982- echo " --quirk-vbe-post" 983- echo " --quirk-vbemode-restore" 984- echo " --quirk-vbestate-restore" 985- echo " --quirk-vga-mode-3" 986- echo " --quirk-none" 987-} 988- 989-case "$1" in 990- suspend) maybe_chvt; suspend_video ;; 991- hibernate) maybe_chvt 992- if is_set "$HIBERNATE_RESUME_POST_VIDEO"; then 993- suspend_video 994- fi 995- ;; 996- resume) resume_video; maybe_deallocvt;; 997- thaw) 998- if is_set "${HIBERNATE_RESUME_POST_VIDEO}"; then 999- resume_video 1000- fi 1001- maybe_deallocvt 1002- ;; 1003- help) help ;; 1004-esac 1005diff --git a/pm/sleep.d/Makefile.am b/pm/sleep.d/Makefile.am 1006index 2350825..1d7e0fa 100644 1007--- a/pm/sleep.d/Makefile.am 1008+++ b/pm/sleep.d/Makefile.am 1009@@ -1,17 +1,7 @@ 1010 sleepdir = $(libdir)/pm-utils/sleep.d 1011 1012 sleep_SCRIPTS = \ 1013- 00logging \ 1014- 00powersave \ 1015- 01grub \ 1016- 49bluetooth \ 1017- 55NetworkManager \ 1018- 75modules \ 1019- 90clock \ 1020- 94cpufreq \ 1021- 95led \ 1022- 98video-quirk-db-handler \ 1023- 99video 1024+ 00logging 1025 1026 EXTRA_DIST=$(sleep_SCRIPTS) 1027 1028diff --git a/pm/sleep.d/Makefile.in b/pm/sleep.d/Makefile.in 1029index d5a9243..c929d17 100644 1030--- a/pm/sleep.d/Makefile.in 1031+++ b/pm/sleep.d/Makefile.in 1032@@ -155,17 +155,7 @@ top_builddir = @top_builddir@ 1033 top_srcdir = @top_srcdir@ 1034 sleepdir = $(libdir)/pm-utils/sleep.d 1035 sleep_SCRIPTS = \ 1036- 00logging \ 1037- 00powersave \ 1038- 01grub \ 1039- 49bluetooth \ 1040- 55NetworkManager \ 1041- 75modules \ 1042- 90clock \ 1043- 94cpufreq \ 1044- 95led \ 1045- 98video-quirk-db-handler \ 1046- 99video 1047+ 00logging 1048 1049 EXTRA_DIST = $(sleep_SCRIPTS) 1050 all: all-am 1051-- 10521.9.1 1053 1054