First, ignore powertop's recommendation. After searching around the web, that message about how to enable autosuspend is very out of date.
This thread discusses the history of the powertop suggestion, and discusses using the driver or udev to autosuspend an eeepc webcam. It also includes this nugget:
Quote:
In the mean time - the thread I linked to includes a helpful note from
Xandros. They measured that enabling the camera on the 901 model cost
~3% of overall power.
|
So autosuspending the camera won't extend your battery life that much, but every little bit helps.
This page describes the user interface for dynamic power management in a device's sysfs directory. This caveat and another note from that page should be considered:
Quote:
214 For this reason, by default the kernel disables autosuspend (the
215 power/level attribute is initialized to "on") for all devices other
216 than hubs. Hubs, at least, appear to be reasonably well-behaved in
217 this regard.
232 If a driver knows that its device has proper suspend/resume support,
233 it can enable autosuspend all by itself. For example, the video
234 driver for a laptop's webcam might do this, since these devices are
235 rarely used and so should normally be autosuspended.
|
Apparently, webcam drivers rarely enable autosuspend. A udev rule can enable autosuspend when the driver doesn't. From what I've read and the results on my three year old Toshiba laptop, this should work on most recent laptops and kernels.
First, run this command:
Quote:
[gene@Mobile-PC ~]$ sudo powertop -d -t0
PowerTOP 1.11 (C) 2007, 2008 Intel Corporation
...
Recent USB suspend statistics
Active Device name
100.0% USB device 4-1 : USB RECEIVER (Logitech)
100.0% USB device 1-6 : Chicony USB 2.0 Camera (Chicony Electronics Co., Ltd.)
0.0% USB device usb5 : UHCI Host Controller (Linux 2.6.34-20.fc14.x86_64 uhci_hcd)
100.0% USB device usb4 : UHCI Host Controller (Linux 2.6.34-20.fc14.x86_64 uhci_hcd)
0.0% USB device usb3 : UHCI Host Controller (Linux 2.6.34-20.fc14.x86_64 uhci_hcd)
0.0% USB device usb2 : UHCI Host Controller (Linux 2.6.34-20.fc14.x86_64 uhci_hcd)
100.0% USB device usb1 : EHCI Host Controller (Linux 2.6.34-20.fc14.x86_64 ehci_hcd)
|
Notice that the Chicony USB 2.0 Camera is active 100% of the time, even though the LED is off, and no software is accessing it. The other useful information is the device for the built in camera, USB device 1-6. As described in the above linked kernel PM Docs, change to the /sys/bus/usb/devices/1-6 directory and do some poking around.
NOTE: Since the /sys directory tree is world readable, but only writeable by root, it's a good idea to be a normal user while poking around in it. Also, substitute the USB device number powertop returned for
your camera where ever you see 1-6 in the following:
Quote:
[gene@Mobile-PC ~]$ cd /sys/bus/usb/devices/1-6
[gene@Mobile-PC 1-6]$ cat manufacturer product idVendor idProduct
Chicony Electronics Co., Ltd.
Chicony USB 2.0 Camera
04f2
b008
[gene@Mobile-PC 1-6]$ cat power/level power/autosuspend
on
2
|
The contents of the manufacturer and product files should match the output of the powertop command shown earlier. If they don't, you need to do some research. The contents of the idVendor and idProduct files will be used to write the udev rule. The power/level value of "on" forces the device to the on state, or never autosuspend. The power/autosuspend value is the delay in seconds before autosuspending, when it's enabled. If something is amiss, use the following command and examine the first portion of the output:
Quote:
$ [gene@Mobile-PC 1-6]$ udevadm info --path=/sys/bus/usb/devices/1-6 --attribute-walk
Udevadm info starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.
looking at device '/devices/pci0000:00/0000:00:1d.7/usb1/1-6':
...
SUBSYSTEM=="usb"
...
ATTR{idVendor}=="04f2"
ATTR{idProduct}=="b008"
...
ATTR{manufacturer}=="Chicony Electronics Co., Ltd."
ATTR{product}=="Chicony USB 2.0 Camera"
...
|
The above quote includes only the portions of the output needed for writing this autosuspend rule and for verifying against the previous powertop output. Don't let the path shown in the udevadm output throw you. The /sys tree is so full of sym links it's easy to get lost. Udevadm is showing the real directory that the user interface directory is linked to. Older guides for writing udev rules suggest using a file named 10-local.rules, but udev used to use the first rule it encountered. Now, udev uses the last rule it encounters, so newer guides recommend using a file named 99-local.rules.
As root, create and edit the file /etc/udev/rules.d/99-local.rules and add the line shown below.
NOTE: In the following, == is a test for equality, = is an assignment operator. Don't confuse them.
NOTE: Be sure to replace 04f2 and, b008 with the corresponding attributes for your camera.
Quote:
|
SUBSYSTEM=="usb", ATTR{idVendor}=="04f2", ATTR{idProduct}=="b008", ATTR{power/level}="auto"
|
The rule just sets the contents of the device directory's "power/level" file to "auto" when the device specified by ATTRibutes is detected. The command "udevadm control --reload-rules" doesn't affect existing devices, so you won't see any change until you reboot. After rebooting, check /var/log/boot.log for any udev errors related to the new rule. After the boot, you should see this:
Quote:
[gene@Mobile-PC ~]$ sudo powertop -d -t0
PowerTOP 1.11 (C) 2007, 2008 Intel Corporation
...
Recent USB suspend statistics
Active Device name
100.0% USB device 4-1 : USB RECEIVER (Logitech)
0.0% USB device 1-6 : Chicony USB 2.0 Camera (Chicony Electronics Co., Ltd.)
0.0% USB device usb5 : UHCI Host Controller (Linux 2.6.34-20.fc14.x86_64 uhci_hcd)
100.0% USB device usb4 : UHCI Host Controller (Linux 2.6.34-20.fc14.x86_64 uhci_hcd)
0.0% USB device usb3 : UHCI Host Controller (Linux 2.6.34-20.fc14.x86_64 uhci_hcd)
0.0% USB device usb2 : UHCI Host Controller (Linux 2.6.34-20.fc14.x86_64 uhci_hcd)
0.0% USB device usb1 : EHCI Host Controller (Linux 2.6.34-20.fc14.x86_64 ehci_hcd)
|
Lastly, start a webcam application and make sure everything works. Disaster recovery is simple. Delete the local rule file or the new rule from it, whichever is appropriate, and reboot.
dd_wizard