~ubuntu-branches/ubuntu/trusty/pm-utils/trusty

« back to all changes in this revision

Viewing changes to debian/power.d/usb_bluetooth

  • Committer: Package Import Robot
  • Author(s): Martin Pitt
  • Date: 2012-01-11 15:26:02 UTC
  • Revision ID: package-import@ubuntu.com-20120111152602-zpohz0e26h65vbv8
Tags: 1.4.1-8+git1
Upload current Debian packaging GIT head (patches still need to be discussed
with Debian/upstream before doing a Debian upload).

* Add 26-inhibit-on-right-status.patch: Do not use the exit status of log
  rather the exit status of the hook thereby allowing inhibit to work.
  Thanks to Ariel Cornejo for the patch! (LP: #665651)
* Add 01_xfs_buffer_arguments.patch: pm/power.d/xfs_buffer: Fix wrong
  argument ordering. Thanks to Andre Draszik for the patch!
  (LP: #645974)
* debian/rules: Remove the journal-commit and readahead scripts. Recent
  measurements have shown that they do not save any power in different
  workloads on rotary disks, and in fact increase power usage on SSD.
  (fd.o #44627, LP: #900923)
* Add debian/power.d/{pci_devices,usb_bluetooth}: Set USB bluetooth to
  autosuspend and a safe subclass of PCI devices to low-power mode during
  powersafe mode. (fd.o #44672, LP: #911325)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
 
 
3
#
 
4
# This script adjusts the USB bluetooth device settings via the USB
 
5
# power control.  This simply sets this to "auto" for power saving and to "on"
 
6
# for non-power saving.   This has been shown to save about 1W on some
 
7
# systems.
 
8
#
 
9
# According to http://www.usb.org/developers/defined_class
 
10
#   USB wireless bluetooth devices have baseclass 0xe0, subclass 0x01,
 
11
#   protocol 0x01
 
12
#
 
13
 
 
14
USB_BLUETOOTH_PM_ENABLE="${USB_BLUETOOTH_PM_ENABLE:-true}"
 
15
 
 
16
set_usb_bluetooth()
 
17
{
 
18
        for dev in /sys/bus/usb/devices/* ; do
 
19
                if [ -e $dev/bDeviceClass -a \
 
20
                     -e $dev/bDeviceSubClass -a \
 
21
                     -e $dev/bDeviceProtocol -a \
 
22
                     -e $dev/power/control ]; then
 
23
                        if [ x`cat $dev/bDeviceClass` = xe0 -a \
 
24
                        x`cat $dev/bDeviceSubClass` = x01 -a \
 
25
                        x`cat $dev/bDeviceProtocol` = x01 ]; then
 
26
                                echo Setting $dev to $1
 
27
                                echo $1 > $dev/power/control
 
28
                        fi
 
29
                fi
 
30
        done
 
31
}
 
32
 
 
33
case "$1" in
 
34
        true) # powersaving on
 
35
                [ "$USB_BLUETOOTH_PM_ENABLE" = true ] && set_usb_bluetooth "auto"
 
36
                ;;
 
37
        false) # powersaving off
 
38
                [ "$USB_BLUETOOTH_PM_ENABLE" = true ] && set_usb_bluetooth "on"
 
39
                ;;
 
40
        *)
 
41
                exit 254
 
42
                ;;
 
43
esac
 
44
 
 
45
exit 0