diff options
Diffstat (limited to 'sys-power/pm-utils/files/power.d/usb_bluetooth')
-rw-r--r-- | sys-power/pm-utils/files/power.d/usb_bluetooth | 45 |
1 files changed, 45 insertions, 0 deletions
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 000000000000..615d19e95631 --- /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 |