summaryrefslogtreecommitdiff
path: root/sys-power/pm-utils
diff options
context:
space:
mode:
authorRobin H. Johnson <robbat2@gentoo.org>2015-08-08 13:49:04 -0700
committerRobin H. Johnson <robbat2@gentoo.org>2015-08-08 17:38:18 -0700
commit56bd759df1d0c750a065b8c845e93d5dfa6b549d (patch)
tree3f91093cdb475e565ae857f1c5a7fd339e2d781e /sys-power/pm-utils
downloadgentoo-56bd759df1d0c750a065b8c845e93d5dfa6b549d.tar.gz
gentoo-56bd759df1d0c750a065b8c845e93d5dfa6b549d.tar.xz
proj/gentoo: Initial commit
This commit represents a new era for Gentoo: Storing the gentoo-x86 tree in Git, as converted from CVS. This commit is the start of the NEW history. Any historical data is intended to be grafted onto this point. Creation process: 1. Take final CVS checkout snapshot 2. Remove ALL ChangeLog* files 3. Transform all Manifests to thin 4. Remove empty Manifests 5. Convert all stale $Header$/$Id$ CVS keywords to non-expanded Git $Id$ 5.1. Do not touch files with -kb/-ko keyword flags. Signed-off-by: Robin H. Johnson <robbat2@gentoo.org> X-Thanks: Alec Warner <antarus@gentoo.org> - did the GSoC 2006 migration tests X-Thanks: Robin H. Johnson <robbat2@gentoo.org> - infra guy, herding this project X-Thanks: Nguyen Thai Ngoc Duy <pclouds@gentoo.org> - Former Gentoo developer, wrote Git features for the migration X-Thanks: Brian Harring <ferringb@gentoo.org> - wrote much python to improve cvs2svn X-Thanks: Rich Freeman <rich0@gentoo.org> - validation scripts X-Thanks: Patrick Lauer <patrick@gentoo.org> - Gentoo dev, running new 2014 work in migration X-Thanks: Michał Górny <mgorny@gentoo.org> - scripts, QA, nagging X-Thanks: All of other Gentoo developers - many ideas and lots of paint on the bikeshed
Diffstat (limited to 'sys-power/pm-utils')
-rw-r--r--sys-power/pm-utils/Manifest1
-rw-r--r--sys-power/pm-utils/files/1.4.1-bluetooth-sync.patch43
-rw-r--r--sys-power/pm-utils/files/1.4.1-disable-sata-alpm.patch24
-rw-r--r--sys-power/pm-utils/files/1.4.1-echo-n.patch51
-rw-r--r--sys-power/pm-utils/files/1.4.1-fix-alpm-typo.patch29
-rw-r--r--sys-power/pm-utils/files/1.4.1-fix-intel-audio-powersave-hook.patch40
-rw-r--r--sys-power/pm-utils/files/1.4.1-ignore-led-failure.patch14
-rw-r--r--sys-power/pm-utils/files/1.4.1-inhibit-on-right-status.patch20
-rw-r--r--sys-power/pm-utils/files/1.4.1-logging-append.patch17
-rw-r--r--sys-power/pm-utils/files/1.4.1-run-hook-logging.patch17
-rw-r--r--sys-power/pm-utils/files/1.4.1-suspend-hybrid.patch36
-rw-r--r--sys-power/pm-utils/files/1.4.1-uswsusp-hibernate-mode.patch19
-rw-r--r--sys-power/pm-utils/files/1.4.1-xfs_buffer_arguments.patch31
-rw-r--r--sys-power/pm-utils/files/pm-utils.logrotate8
-rw-r--r--sys-power/pm-utils/files/power.d/pci_devices61
-rw-r--r--sys-power/pm-utils/files/power.d/usb_bluetooth45
-rw-r--r--sys-power/pm-utils/files/sleep.d/50unload_alx18
-rw-r--r--sys-power/pm-utils/metadata.xml11
-rw-r--r--sys-power/pm-utils/pm-utils-1.4.1-r6.ebuild94
-rw-r--r--sys-power/pm-utils/pm-utils-1.4.1-r7.ebuild95
20 files changed, 674 insertions, 0 deletions
diff --git a/sys-power/pm-utils/Manifest b/sys-power/pm-utils/Manifest
new file mode 100644
index 00000000000..b0f96eb8f57
--- /dev/null
+++ b/sys-power/pm-utils/Manifest
@@ -0,0 +1 @@
+DIST pm-utils-1.4.1.tar.gz 208687 SHA256 8ed899032866d88b2933a1d34cc75e8ae42dcde20e1cc21836baaae3d4370c0b SHA512 5bc9479fe75f120aee136befeb24c8d7d85f61410b551177ed61fd1b4ea9cce7989796b067e357ea93b44b4ae9f66311687066f188236c5efdfd3750695a8017 WHIRLPOOL 7bf4752d96af776c90eb2d0319d615be157c8289551c72edb0c7fed05aeebbdc729f405d5ff04de401f4c12bfb8801e8b80242c3ba28e7b973442e51bf2374a3
diff --git a/sys-power/pm-utils/files/1.4.1-bluetooth-sync.patch b/sys-power/pm-utils/files/1.4.1-bluetooth-sync.patch
new file mode 100644
index 00000000000..b41f32cf916
--- /dev/null
+++ b/sys-power/pm-utils/files/1.4.1-bluetooth-sync.patch
@@ -0,0 +1,43 @@
+From 640b53438c20818b3e344343b58b1f1765606a85 Mon Sep 17 00:00:00 2001
+From: Martin Pitt <martin.pitt@ubuntu.com>
+Date: Mon, 31 Jan 2011 15:30:01 +0100
+Subject: [PATCH] 49bluetooth: Wait for btusb module to get unused
+
+The 49bluetooth hook disables /proc/acpi/ibm/bluetooth but this isn't
+synchronous, i. e. it doesn't wait until the module usage count actually drops
+to 0. Due to that, it's impossible to add btusb to SUSPEND_MODULES (on some
+models/older kernels you need to do that to fix suspend problems), as at that
+point the module is still in use.
+
+On my system (ThinkPad X201) the module takes between 0.3 and 0.5 seconds to
+unload, so use 100 ms wait steps with a timeout of 2 seconds.
+
+Bug: https://bugs.freedesktop.org//show_bug.cgi?id=33759
+Bug-Ubuntu: https://launchpad.net/bugs/698331
+---
+ pm/sleep.d/49bluetooth | 9 +++++++++
+ 1 files changed, 9 insertions(+), 0 deletions(-)
+
+diff --git a/pm/sleep.d/49bluetooth b/pm/sleep.d/49bluetooth
+index d46ba49..0dc1909 100755
+--- a/pm/sleep.d/49bluetooth
++++ b/pm/sleep.d/49bluetooth
+@@ -12,6 +12,15 @@ suspend_bluetooth()
+ if grep -q enabled /proc/acpi/ibm/bluetooth; then
+ savestate ibm_bluetooth enable
+ echo disable > /proc/acpi/ibm/bluetooth
++
++ # wait for up to 2 seconds for the module to actually get
++ # unused
++ TIMEOUT=20
++ while [ $TIMEOUT -ge 0 ]; do
++ [ `cat /sys/module/btusb/refcnt` = 0 ] && break
++ TIMEOUT=$((TIMEOUT-1))
++ sleep 0.1
++ done
+ else
+ savestate ibm_bluetooth disable
+ fi
+--
+1.7.2.3
+
diff --git a/sys-power/pm-utils/files/1.4.1-disable-sata-alpm.patch b/sys-power/pm-utils/files/1.4.1-disable-sata-alpm.patch
new file mode 100644
index 00000000000..e3e3819b82e
--- /dev/null
+++ b/sys-power/pm-utils/files/1.4.1-disable-sata-alpm.patch
@@ -0,0 +1,24 @@
+Description: Disable SATA link power management by default, as it still causes disk errors and corruptions on many hardware.
+Author: Martin Pitt <martin.pitt@ubuntu.com>
+Bug-Ubuntu: https://launchpad.net/bugs/539467
+
+--- pm/power.d/sata_alpm
++++ pm/power.d/sata_alpm
+@@ -2,7 +2,7 @@
+
+ . "${PM_FUNCTIONS}"
+
+-SATA_ALPM_ENABLE=${SATA_ALPM_ENABLE:-true}
++SATA_ALPM_ENABLE=${SATA_ALPM_ENABLE:-false}
+
+ help() {
+ cat <<EOF
+@@ -16,7 +16,7 @@
+
+ This hook has 1 parameter:
+ SATA_ALPM_ENABLE = whether to use SATA ALPM on battery.
+-Defaults to "true".
++Defaults to "false".
+
+ EOF
+ }
diff --git a/sys-power/pm-utils/files/1.4.1-echo-n.patch b/sys-power/pm-utils/files/1.4.1-echo-n.patch
new file mode 100644
index 00000000000..354ccb6a7e6
--- /dev/null
+++ b/sys-power/pm-utils/files/1.4.1-echo-n.patch
@@ -0,0 +1,51 @@
+From ffce4bc35a34b6b543e2ae2828a3096a19ebb1ae Mon Sep 17 00:00:00 2001
+From: Alexandre Rostovtsev <tetromino@gentoo.org>
+Date: Tue, 28 Jul 2015 22:24:56 -0400
+Subject: [PATCH] Avoid -n in "echo -n foo > /sys/bar"
+
+It's not portable and not needed.
+
+https://bugs.freedesktop.org/show_bug.cgi?id=91497
+
+[ Rebased on top of Gentoo's -r6 patchset. ]
+---
+ pm/pm-functions.in | 8 +++++-----
+ 1 file changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/pm/pm-functions.in b/pm/pm-functions.in
+index c82be30..a68f955 100644
+--- a/pm/pm-functions.in
++++ b/pm/pm-functions.in
+@@ -296,13 +296,13 @@
+ if [ -z "$SUSPEND_MODULE" ]; then
+ if grep -q mem /sys/power/state; then
+ SUSPEND_MODULE="kernel"
+- do_suspend() { echo -n "mem" >/sys/power/state; }
++ do_suspend() { echo "mem" >/sys/power/state; }
+ elif [ -c /dev/pmu ] && pm-pmu --check; then
+ SUSPEND_MODULE="kernel"
+ do_suspend() { pm-pmu --suspend; }
+ elif grep -q standby /sys/power/state; then
+ SUSPEND_MODULE="kernel"
+- do_suspend() { echo -n "standby" >/sys/power/state; }
++ do_suspend() { echo "standby" >/sys/power/state; }
+ fi
+ fi
+
+@@ -317,10 +317,10 @@
+ HIBERNATE_MODE_SAVE=$(cat /sys/power/disk) && \
+ HIBERNATE_MODE_SAVE="${HIBERNATE_MODE_SAVE##*[}" && \
+ HIBERNATE_MODE_SAVE="${HIBERNATE_MODE_SAVE%%]*}" && \
+- echo -n "${HIBERNATE_MODE}" > /sys/power/disk
+- echo -n "disk" > /sys/power/state
++ echo "${HIBERNATE_MODE}" > /sys/power/disk
++ echo "disk" > /sys/power/state
+ RET=$?
+- echo -n "$HIBERNATE_MODE_SAVE" > /sys/power/disk
++ echo "$HIBERNATE_MODE_SAVE" > /sys/power/disk
+ return "$RET"
+ }
+ fi
+--
+2.4.6
+
diff --git a/sys-power/pm-utils/files/1.4.1-fix-alpm-typo.patch b/sys-power/pm-utils/files/1.4.1-fix-alpm-typo.patch
new file mode 100644
index 00000000000..799369159ff
--- /dev/null
+++ b/sys-power/pm-utils/files/1.4.1-fix-alpm-typo.patch
@@ -0,0 +1,29 @@
+From 93d46b88f415c1931b017856e3162c192bfba07c Mon Sep 17 00:00:00 2001
+From: Martin Pitt <martin.pitt@ubuntu.com>
+Date: Wed, 11 Jan 2012 15:39:53 +0100
+Subject: [PATCH 3/3] Fix typo in sata_alpm
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+ALPM → APLM
+
+Bug: https://bugs.freedesktop.org/show_bug.cgi?id=44676
+Bug-Ubuntu: https://launchpad.net/bugs/900930
+---
+ pm/power.d/sata_alpm | 4 ++--
+ 1 files changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/pm/power.d/sata_alpm b/pm/power.d/sata_alpm
+index 5ede307..400e1e7 100644
+--- a/pm/power.d/sata_alpm
++++ b/pm/power.d/sata_alpm
+@@ -28,7 +28,7 @@ set_sata_alpm() {
+ [ "${kv%-*}" \< "2.6.33" ] && exit $NA # avoid fs corruption
+ for f in /sys/class/scsi_host/host*; do
+ [ -w "$f/link_power_management_policy" ] || continue
+- printf "Setting SATA APLM on %s to %s..." "${f##*/}" "$1"
++ printf "Setting SATA ALPM on %s to %s..." "${f##*/}" "$1"
+ echo "$1" > "$f/link_power_management_policy" && echo Done. || \
+ echo Failed.
+ done
diff --git a/sys-power/pm-utils/files/1.4.1-fix-intel-audio-powersave-hook.patch b/sys-power/pm-utils/files/1.4.1-fix-intel-audio-powersave-hook.patch
new file mode 100644
index 00000000000..2d884da1e7b
--- /dev/null
+++ b/sys-power/pm-utils/files/1.4.1-fix-intel-audio-powersave-hook.patch
@@ -0,0 +1,40 @@
+From: Florian Kriener <florian@kriener.org>
+To: submit@bugs.debian.org
+Subject: [pm-utils] wrong path in intel-audio-powersave (and a small bug)
+Date: Sat, 25 Sep 2010 11:27:30 +0200
+
+In the script intel-audio-powersave is this loop
+
+for dev in /sys/module/snd_*/parameters/power_save; do
+ [ -w "$dev/parameters/power_save" ] || continue
+ printf "Setting power savings for $s to %d..." "$dev##*/" "$1"
+ echo $1 > "$dev/parameters/power_save" && echo Done. || echo Failed.
+done
+
+I think it should be
+
+for dev in /sys/module/snd_*; do
+ [ -w "$dev/parameters/power_save" ] || continue
+ printf "Setting power savings for %s to %d..." "${dev##*/}" "$1"
+ echo $1 > "$dev/parameters/power_save" && echo Done. || echo Failed.
+done
+
+
+This fixes the two bugs.
+
+diff --git a/pm/power.d/intel-audio-powersave b/pm/power.d/intel-audio-powersave
+index 36675a8..da63e40 100644
+--- a/pm/power.d/intel-audio-powersave
++++ b/pm/power.d/intel-audio-powersave
+@@ -20,9 +20,9 @@ EOF
+
+ audio_powersave() {
+ [ "$INTEL_AUDIO_POWERSAVE" = "true" ] || exit $NA
+- for dev in /sys/module/snd_*/parameters/power_save; do
++ for dev in /sys/module/snd_*; do
+ [ -w "$dev/parameters/power_save" ] || continue
+- printf "Setting power savings for $s to %d..." "$dev##*/" "$1"
++ printf "Setting power savings for %s to %d..." "${dev##*/}" "$1"
+ echo $1 > "$dev/parameters/power_save" && echo Done. || echo Failed.
+ done
+ }
diff --git a/sys-power/pm-utils/files/1.4.1-ignore-led-failure.patch b/sys-power/pm-utils/files/1.4.1-ignore-led-failure.patch
new file mode 100644
index 00000000000..7b8e4f2da1d
--- /dev/null
+++ b/sys-power/pm-utils/files/1.4.1-ignore-led-failure.patch
@@ -0,0 +1,14 @@
+Description: LED operation should not block S3/S4
+Author: Adam Lee <adam8157@gmail.com>
+
+Some Lenovo Thinkpad models don't have a suspend LED, this should not
+block S3/S4.
+
+--- pm/sleep.d/95led
++++ pm/sleep.d/95led
+@@ -14,3 +14,5 @@
+ *) exit $NA
+ ;;
+ esac
++
++exit 0
diff --git a/sys-power/pm-utils/files/1.4.1-inhibit-on-right-status.patch b/sys-power/pm-utils/files/1.4.1-inhibit-on-right-status.patch
new file mode 100644
index 00000000000..250ae0872fb
--- /dev/null
+++ b/sys-power/pm-utils/files/1.4.1-inhibit-on-right-status.patch
@@ -0,0 +1,20 @@
+Description: Do not use the exit status of log rather the exit status of the hook.
+
+http://bugs.freedesktop.org/show_bug.cgi?id=32210
+http://bugs.gentoo.org/360673
+
+--- pm/pm-functions.in
++++ pm/pm-functions.in
+@@ -197,9 +197,11 @@
+ # rest of args passed to hook unchanged.
+ log "Running hook $*:"
+ hook_ok "$1" && "$@"
++ # log() changes the return value, so save it for later
++ local status=$?
+ log ""
+ log -n "$*: "
+- hook_exit_status $? && LAST_HOOK="${1##*/}" || inhibit
++ hook_exit_status $status && LAST_HOOK="${1##*/}" || inhibit
+ }
+
+ if profiling; then
diff --git a/sys-power/pm-utils/files/1.4.1-logging-append.patch b/sys-power/pm-utils/files/1.4.1-logging-append.patch
new file mode 100644
index 00000000000..7a5d682b122
--- /dev/null
+++ b/sys-power/pm-utils/files/1.4.1-logging-append.patch
@@ -0,0 +1,17 @@
+Author: James Westby <james.westby@ubuntu.com>
+Description: Do not clear the log file on each operation, but instead append to it.
+ This makes debugging of several suspends much easier.
+Bug: https://bugs.freedesktop.org/show_bug.cgi?id=25255
+Bug-Ubuntu: https://launchpad.net/bugs/410352
+
+--- pm/pm-functions.in
++++ pm/pm-functions.in
+@@ -271,7 +271,7 @@
+ return 1
+ fi
+ export LOGGING=true
+- exec > "$1" 2>&1
++ exec >> "$1" 2>&1
+ }
+
+ check_suspend() { [ -n "$SUSPEND_MODULE" ]; }
diff --git a/sys-power/pm-utils/files/1.4.1-run-hook-logging.patch b/sys-power/pm-utils/files/1.4.1-run-hook-logging.patch
new file mode 100644
index 00000000000..19ac4064d79
--- /dev/null
+++ b/sys-power/pm-utils/files/1.4.1-run-hook-logging.patch
@@ -0,0 +1,17 @@
+Description: In suspend log, put empty line after running the hook, not in between.
+Author: Dominique Brazziel <dbrazziel@snet.net>
+Bug-Debian: http://bugs.debian.org/661168
+
+--- pm/pm-functions.in
++++ pm/pm-functions.in
+@@ -199,9 +199,9 @@
+ hook_ok "$1" && "$@"
+ # log() changes the return value, so save it for later
+ local status=$?
+- log ""
+ log -n "$*: "
+ hook_exit_status $status && LAST_HOOK="${1##*/}" || inhibit
++ log ""
+ }
+
+ if profiling; then
diff --git a/sys-power/pm-utils/files/1.4.1-suspend-hybrid.patch b/sys-power/pm-utils/files/1.4.1-suspend-hybrid.patch
new file mode 100644
index 00000000000..8d92002733f
--- /dev/null
+++ b/sys-power/pm-utils/files/1.4.1-suspend-hybrid.patch
@@ -0,0 +1,36 @@
+Description: Add support for in-kernel suspend to both
+Author: Bojan Smojver <bojan@rexursive.com>
+Author: Jaroslav Škarvada <jskarvad@redhat.com>
+Bug: https://bugs.freedesktop.org/show_bug.cgi?id=52572
+Bug-Ubuntu: https://launchpad.net/bugs/1172692
+
+--- pm/pm-functions.in
++++ pm/pm-functions.in
+@@ -336,8 +336,28 @@
+ {
+ [ -n "${HIBERNATE_MODE}" ] && \
+ grep -qw "${HIBERNATE_MODE}" /sys/power/disk && \
++ HIBERNATE_MODE_SAVE=$(cat /sys/power/disk) && \
++ HIBERNATE_MODE_SAVE="${HIBERNATE_MODE_SAVE##*[}" && \
++ HIBERNATE_MODE_SAVE="${HIBERNATE_MODE_SAVE%%]*}" && \
+ echo -n "${HIBERNATE_MODE}" > /sys/power/disk
+ echo -n "disk" > /sys/power/state
++ RET=$?
++ echo -n "$HIBERNATE_MODE_SAVE" > /sys/power/disk
++ return "$RET"
++ }
++fi
++
++# for kernels that support suspend to both (i.e. hybrid suspend)
++# since kernel 3.6
++if [ -z "$SUSPEND_HYBRID_MODULE" ] && \
++ [ -f /sys/power/disk ] && \
++ grep -q disk /sys/power/state && \
++ grep -q suspend /sys/power/disk; then
++ SUSPEND_HYBRID_MODULE="kernel"
++ do_suspend_hybrid()
++ {
++ HIBERNATE_MODE="suspend"
++ do_hibernate
+ }
+ fi
diff --git a/sys-power/pm-utils/files/1.4.1-uswsusp-hibernate-mode.patch b/sys-power/pm-utils/files/1.4.1-uswsusp-hibernate-mode.patch
new file mode 100644
index 00000000000..8c970698d5b
--- /dev/null
+++ b/sys-power/pm-utils/files/1.4.1-uswsusp-hibernate-mode.patch
@@ -0,0 +1,19 @@
+Description: Check HIBERNATE_MODE in uswsusp module
+Author: Vadim Solomin <vadic052@gmail.com>
+Bug-Debian: http://bugs.debian.org/589553
+
+--- pm/module.d/uswsusp
++++ pm/module.d/uswsusp
+@@ -87,7 +87,11 @@
+ HIBERNATE_MODULE="uswsusp"
+ do_hibernate()
+ {
+- s2disk
++ if [ -n "$HIBERNATE_MODE" ]; then
++ s2disk -P "shutdown method=$HIBERNATE_MODE"
++ else
++ s2disk
++ fi
+ }
+ fi
+
diff --git a/sys-power/pm-utils/files/1.4.1-xfs_buffer_arguments.patch b/sys-power/pm-utils/files/1.4.1-xfs_buffer_arguments.patch
new file mode 100644
index 00000000000..3eee91166f8
--- /dev/null
+++ b/sys-power/pm-utils/files/1.4.1-xfs_buffer_arguments.patch
@@ -0,0 +1,31 @@
+From fdc626dadfd985e823f4e828f2a542c945aea219 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Andr=C3=A9=20Draszik?= <andre.draszik@st.com>
+Date: Tue, 10 Jan 2012 11:21:02 +0100
+Subject: [PATCH 2/2] pm/power.d/xfs_buffer: Fix wrong argument ordering
+
+Write the values in the correct order.
+
+Bug: https://bugs.freedesktop.org/show_bug.cgi?id=44620
+Bug-Ubuntu: https://launchpad.net/bugs/645974
+
+Signed-off-by: Martin Pitt <martin.pitt@ubuntu.com>
+---
+ pm/power.d/xfs_buffer | 2 +-
+ 1 files changed, 1 insertions(+), 1 deletions(-)
+
+diff --git a/pm/power.d/xfs_buffer b/pm/power.d/xfs_buffer
+index d21e845..9f06f6e 100644
+--- a/pm/power.d/xfs_buffer
++++ b/pm/power.d/xfs_buffer
+@@ -59,7 +59,7 @@ xfs_ac() {
+ xfs_battery() {
+ state_exists xfs_buffer_default || \
+ read_values |savestate xfs_buffer_default
+- write_values "$XFS_AGE_BUFFER" "$XFS_BUFD" "$XFS_SYNCD"
++ write_values "$XFS_AGE_BUFFER" "$XFS_SYNCD" "$XFS_BUFD"
+ }
+
+ case $1 in
+--
+1.7.7.3
+
diff --git a/sys-power/pm-utils/files/pm-utils.logrotate b/sys-power/pm-utils/files/pm-utils.logrotate
new file mode 100644
index 00000000000..85de4003509
--- /dev/null
+++ b/sys-power/pm-utils/files/pm-utils.logrotate
@@ -0,0 +1,8 @@
+/var/log/pm-suspend.log /var/log/pm-powersave.log {
+ monthly
+ rotate 4
+ delaycompress
+ compress
+ notifempty
+ missingok
+}
diff --git a/sys-power/pm-utils/files/power.d/pci_devices b/sys-power/pm-utils/files/power.d/pci_devices
new file mode 100644
index 00000000000..c06b706d82a
--- /dev/null
+++ b/sys-power/pm-utils/files/power.d/pci_devices
@@ -0,0 +1,61 @@
+#!/bin/sh
+
+#
+# This script adjusts the power control of a set of PCI devices that
+# prove beneficial to enable power savings
+#
+
+PCI_DEVICES_PM_ENABLE="${PCI_DEVICES_PM_ENABLE:-true}"
+
+set_pci_device()
+{
+ for dev in /sys/bus/pci/devices/* ; do
+ if [ -e $dev/class -a -e $dev/power/control ]; then
+ id=`basename $dev`
+ case `cat $dev/class` in
+ 0x020000) # ethernet
+ echo "Setting Ethernet device $id to $1"
+ echo $1 > $dev/power/control
+ ;;
+ 0x028000) # wireless
+ echo "Setting Wireless device $id to $1"
+ echo $1 > $dev/power/control
+ ;;
+ 0x040300) # audio
+ echo "Setting Audio device $id to $1"
+ echo $1 > $dev/power/control
+ ;;
+ 0x060000) # host bridge
+ echo "Setting Host Bridge $id to $1"
+ echo $1 > $dev/power/control
+ ;;
+ 0x080500) # SD card reader
+ echo "Setting SD card reader device $id to $1"
+ echo $1 > $dev/power/control
+ ;;
+ 0x088000|0x088001) # card reader
+ echo "Setting card reader device $id to $1"
+ echo $1 > $dev/power/control
+ ;;
+ 0x0c0000|0x0c0010) # firewire
+ echo "Setting FireWire device $id to $1"
+ echo $1 > $dev/power/control
+ ;;
+ esac
+ fi
+ done
+}
+
+case "$1" in
+ true) # powersaving on
+ [ "$PCI_DEVICES_PM_ENABLE" = true ] && set_pci_device "auto"
+ ;;
+ false) # powersaving off
+ [ "$PCI_DEVICES_PM_ENABLE" = true ] && set_pci_device "on"
+ ;;
+ *)
+ exit 254
+ ;;
+esac
+
+exit 0
diff --git a/sys-power/pm-utils/files/power.d/usb_bluetooth b/sys-power/pm-utils/files/power.d/usb_bluetooth
new file mode 100644
index 00000000000..615d19e9563
--- /dev/null
+++ b/sys-power/pm-utils/files/power.d/usb_bluetooth
@@ -0,0 +1,45 @@
+#!/bin/sh
+
+#
+# This script adjusts the USB bluetooth device settings via the USB
+# power control. This simply sets this to "auto" for power saving and to "on"
+# for non-power saving. This has been shown to save about 1W on some
+# systems.
+#
+# According to http://www.usb.org/developers/defined_class
+# USB wireless bluetooth devices have baseclass 0xe0, subclass 0x01,
+# protocol 0x01
+#
+
+USB_BLUETOOTH_PM_ENABLE="${USB_BLUETOOTH_PM_ENABLE:-true}"
+
+set_usb_bluetooth()
+{
+ for dev in /sys/bus/usb/devices/* ; do
+ if [ -e $dev/bDeviceClass -a \
+ -e $dev/bDeviceSubClass -a \
+ -e $dev/bDeviceProtocol -a \
+ -e $dev/power/control ]; then
+ if [ x`cat $dev/bDeviceClass` = xe0 -a \
+ x`cat $dev/bDeviceSubClass` = x01 -a \
+ x`cat $dev/bDeviceProtocol` = x01 ]; then
+ echo Setting $dev to $1
+ echo $1 > $dev/power/control
+ fi
+ fi
+ done
+}
+
+case "$1" in
+ true) # powersaving on
+ [ "$USB_BLUETOOTH_PM_ENABLE" = true ] && set_usb_bluetooth "auto"
+ ;;
+ false) # powersaving off
+ [ "$USB_BLUETOOTH_PM_ENABLE" = true ] && set_usb_bluetooth "on"
+ ;;
+ *)
+ exit 254
+ ;;
+esac
+
+exit 0
diff --git a/sys-power/pm-utils/files/sleep.d/50unload_alx b/sys-power/pm-utils/files/sleep.d/50unload_alx
new file mode 100644
index 00000000000..6d352c50f7c
--- /dev/null
+++ b/sys-power/pm-utils/files/sleep.d/50unload_alx
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+# 50unload_alx: unload the alx module during suspend (LP #1173952)
+
+[ -d /sys/module/alx ] || exit 0
+
+. "${PM_FUNCTIONS}"
+
+case "$1" in
+ suspend)
+ echo "Unloading alx kernel module ..."
+ modunload alx && echo Done. || echo Failed.
+ ;;
+ resume)
+ echo "Reloading alx kernel module ..."
+ ;;
+esac
+exit 0
diff --git a/sys-power/pm-utils/metadata.xml b/sys-power/pm-utils/metadata.xml
new file mode 100644
index 00000000000..e1f7c983143
--- /dev/null
+++ b/sys-power/pm-utils/metadata.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+ <herd>freedesktop</herd>
+ <maintainer>
+ <email>freedesktop-bugs@gentoo.org</email>
+ </maintainer>
+ <use>
+ <flag name="ntp">Install support for <pkg>net-misc/ntp</pkg></flag>
+ </use>
+</pkgmetadata>
diff --git a/sys-power/pm-utils/pm-utils-1.4.1-r6.ebuild b/sys-power/pm-utils/pm-utils-1.4.1-r6.ebuild
new file mode 100644
index 00000000000..ceb279a51d1
--- /dev/null
+++ b/sys-power/pm-utils/pm-utils-1.4.1-r6.ebuild
@@ -0,0 +1,94 @@
+# Copyright 1999-2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+EAPI=5
+inherit eutils multilib
+
+DESCRIPTION="Suspend and hibernation utilities"
+HOMEPAGE="http://pm-utils.freedesktop.org/"
+SRC_URI="http://pm-utils.freedesktop.org/releases/${P}.tar.gz"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="alpha amd64 arm ia64 ~mips ppc ppc64 sparc x86"
+IUSE="alsa debug ntp video_cards_intel video_cards_radeon"
+
+vbetool="!video_cards_intel? ( sys-apps/vbetool )"
+RDEPEND="!<app-laptop/laptop-mode-tools-1.55-r1
+ !sys-power/powermgmt-base[-pm-utils(+)]
+ sys-apps/dbus
+ >=sys-apps/util-linux-2.13
+ sys-power/pm-quirks
+ alsa? ( media-sound/alsa-utils )
+ ntp? ( || ( net-misc/ntp net-misc/openntpd ) )
+ amd64? ( ${vbetool} )
+ x86? ( ${vbetool} )
+ video_cards_radeon? ( app-laptop/radeontool )"
+DEPEND="${RDEPEND}"
+
+DOCS="AUTHORS ChangeLog NEWS pm/HOWTO* README* TODO"
+
+src_prepare() {
+ local ignore="01grub"
+ use ntp || ignore+=" 90clock"
+
+ use debug && echo 'PM_DEBUG="true"' > "${T}"/gentoo
+ echo "HOOK_BLACKLIST=\"${ignore}\"" >> "${T}"/gentoo
+
+ epatch \
+ "${FILESDIR}"/${PV}-bluetooth-sync.patch \
+ "${FILESDIR}"/${PV}-disable-sata-alpm.patch \
+ "${FILESDIR}"/${PV}-fix-intel-audio-powersave-hook.patch \
+ "${FILESDIR}"/${PV}-logging-append.patch \
+ "${FILESDIR}"/${PV}-fix-alpm-typo.patch \
+ "${FILESDIR}"/${PV}-inhibit-on-right-status.patch \
+ "${FILESDIR}"/${PV}-ignore-led-failure.patch \
+ "${FILESDIR}"/${PV}-run-hook-logging.patch \
+ "${FILESDIR}"/${PV}-suspend-hybrid.patch \
+ "${FILESDIR}"/${PV}-uswsusp-hibernate-mode.patch \
+ "${FILESDIR}"/${PV}-xfs_buffer_arguments.patch
+}
+
+src_configure() {
+ econf --disable-doc
+}
+
+src_install() {
+ default
+ doman man/*.{1,8}
+
+ # Remove duplicate documentation install
+ rm -r "${ED}"/usr/share/doc/${PN}
+
+ insinto /etc/pm/config.d
+ doins "${T}"/gentoo
+
+ insinto /etc/logrotate.d
+ newins "${FILESDIR}"/${PN}.logrotate ${PN} #408091
+
+ exeinto /usr/$(get_libdir)/${PN}/sleep.d
+ doexe "${FILESDIR}"/sleep.d/50unload_alx
+
+ exeinto /usr/$(get_libdir)/${PN}/power.d
+ doexe "${FILESDIR}"/power.d/{pci_devices,usb_bluetooth}
+
+ # No longer required with current networkmanager (rm -f from debian/rules)
+ rm -f "${ED}"/usr/$(get_libdir)/${PN}/sleep.d/55NetworkManager
+
+ # No longer required with current kernels (rm -f from debian/rules)
+ rm -f "${ED}"/usr/$(get_libdir)/${PN}/sleep.d/49bluetooth
+
+ # Punt HAL related file wrt #401257 (rm -f from debian/rules)
+ rm -f "${ED}"/usr/$(get_libdir)/${PN}/power.d/hal-cd-polling
+
+ # Punt hooks which have shown to not reduce, or even increase power usage
+ # (rm -f from debian rules)
+ rm -f "${ED}"/usr/$(get_libdir)/${PN}/power.d/{journal-commit,readahead}
+
+ # Remove hooks which are not stable enough yet (rm -f from debian/rules)
+ rm -f "${ED}"/usr/$(get_libdir)/${PN}/power.d/harddrive
+
+ # Change to executable (chmod +x from debian/rules)
+ fperms +x /usr/$(get_libdir)/${PN}/defaults
+}
diff --git a/sys-power/pm-utils/pm-utils-1.4.1-r7.ebuild b/sys-power/pm-utils/pm-utils-1.4.1-r7.ebuild
new file mode 100644
index 00000000000..a7b19e41fe4
--- /dev/null
+++ b/sys-power/pm-utils/pm-utils-1.4.1-r7.ebuild
@@ -0,0 +1,95 @@
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+EAPI=5
+inherit eutils multilib
+
+DESCRIPTION="Suspend and hibernation utilities"
+HOMEPAGE="http://pm-utils.freedesktop.org/"
+SRC_URI="http://pm-utils.freedesktop.org/releases/${P}.tar.gz"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~arm ~ia64 ~mips ~ppc ~ppc64 ~sparc ~x86"
+IUSE="alsa debug ntp video_cards_intel video_cards_radeon"
+
+vbetool="!video_cards_intel? ( sys-apps/vbetool )"
+RDEPEND="!<app-laptop/laptop-mode-tools-1.55-r1
+ !sys-power/powermgmt-base[-pm-utils(+)]
+ sys-apps/dbus
+ >=sys-apps/util-linux-2.13
+ sys-power/pm-quirks
+ alsa? ( media-sound/alsa-utils )
+ ntp? ( || ( net-misc/ntp net-misc/openntpd ) )
+ amd64? ( ${vbetool} )
+ x86? ( ${vbetool} )
+ video_cards_radeon? ( app-laptop/radeontool )"
+DEPEND="${RDEPEND}"
+
+DOCS="AUTHORS ChangeLog NEWS pm/HOWTO* README* TODO"
+
+src_prepare() {
+ local ignore="01grub"
+ use ntp || ignore+=" 90clock"
+
+ use debug && echo 'PM_DEBUG="true"' > "${T}"/gentoo
+ echo "HOOK_BLACKLIST=\"${ignore}\"" >> "${T}"/gentoo
+
+ epatch \
+ "${FILESDIR}"/${PV}-bluetooth-sync.patch \
+ "${FILESDIR}"/${PV}-disable-sata-alpm.patch \
+ "${FILESDIR}"/${PV}-fix-intel-audio-powersave-hook.patch \
+ "${FILESDIR}"/${PV}-logging-append.patch \
+ "${FILESDIR}"/${PV}-fix-alpm-typo.patch \
+ "${FILESDIR}"/${PV}-inhibit-on-right-status.patch \
+ "${FILESDIR}"/${PV}-ignore-led-failure.patch \
+ "${FILESDIR}"/${PV}-run-hook-logging.patch \
+ "${FILESDIR}"/${PV}-suspend-hybrid.patch \
+ "${FILESDIR}"/${PV}-uswsusp-hibernate-mode.patch \
+ "${FILESDIR}"/${PV}-xfs_buffer_arguments.patch \
+ "${FILESDIR}"/${PV}-echo-n.patch
+}
+
+src_configure() {
+ econf --disable-doc
+}
+
+src_install() {
+ default
+ doman man/*.{1,8}
+
+ # Remove duplicate documentation install
+ rm -r "${ED}"/usr/share/doc/${PN}
+
+ insinto /etc/pm/config.d
+ doins "${T}"/gentoo
+
+ insinto /etc/logrotate.d
+ newins "${FILESDIR}"/${PN}.logrotate ${PN} #408091
+
+ exeinto /usr/$(get_libdir)/${PN}/sleep.d
+ doexe "${FILESDIR}"/sleep.d/50unload_alx
+
+ exeinto /usr/$(get_libdir)/${PN}/power.d
+ doexe "${FILESDIR}"/power.d/{pci_devices,usb_bluetooth}
+
+ # No longer required with current networkmanager (rm -f from debian/rules)
+ rm -f "${ED}"/usr/$(get_libdir)/${PN}/sleep.d/55NetworkManager
+
+ # No longer required with current kernels (rm -f from debian/rules)
+ rm -f "${ED}"/usr/$(get_libdir)/${PN}/sleep.d/49bluetooth
+
+ # Punt HAL related file wrt #401257 (rm -f from debian/rules)
+ rm -f "${ED}"/usr/$(get_libdir)/${PN}/power.d/hal-cd-polling
+
+ # Punt hooks which have shown to not reduce, or even increase power usage
+ # (rm -f from debian rules)
+ rm -f "${ED}"/usr/$(get_libdir)/${PN}/power.d/{journal-commit,readahead}
+
+ # Remove hooks which are not stable enough yet (rm -f from debian/rules)
+ rm -f "${ED}"/usr/$(get_libdir)/${PN}/power.d/harddrive
+
+ # Change to executable (chmod +x from debian/rules)
+ fperms +x /usr/$(get_libdir)/${PN}/defaults
+}