Team LiB
Previous Section Next Section

Hack 96. Control Your Power with ACPI

Extend the life of your laptop battery by limiting your computer's appetite for power.

The Advanced Configuration and Power Interface (ACPI) is an open industry specification that allows for power management on laptops, desktops, and servers. Compaq/Hewlett-Packard, Intel, Microsoft, Phoenix, and Toshiba first released it in 1996. These developers aimed to replace Advanced Power Management (APM), the previous industry standard for power management.

You can configure ACPI and control it from within the operating system. This is a step forward from APM, which was affected only by system idle time and could be configured only from within the BIOS screens during startup. ACPI can be used by most new laptops, although some brands have specific configuration issues. Be sure to do a web search for your specific machine to see what limitations your system has.

ACPI has several different software components:

  • A subsystem, which monitors and affects hardware, including thermal control, motherboard configuration, and power states

  • A policy manager, which allows the user to modify system states

  • Drivers to control and monitor devices, such as laptop batteries, SMBus (communications/transmission path), and EC (embedded controller)

11.6.1. Installing ACPI

A number of things must be in place to use ACPI successfully. Your kernel must have the correct configuration, you must have the relevant modules loaded, and you should be running an application to monitor the status of your system.

To confirm that the kernel is properly configured, launch a kernel configuration tool and go to the General Setup section. Inside this section, confirm that Power Management Support is enabled. Also, make sure APM is disabled. Select all options to do with ACPI that are relevant to your hardware. You can choose either M for modules or * to compile directly into the kernel. Save the new configuration and exit. Then compile your kernel and modules, as discussed in [Hack #88] .

ACPI is always under revision. It is available in later versions of the 2.4.x series kernel (2.4.22 and higher) and all 2.6.x series kernels. You should always use the latest stable version of the kernel that your system can support. Even the most recent kernel can have minor bug fixes available as a patch, so be sure to check for one at http://acpi.sourceforge.net. If your distribution has already patched your kernel, you might have difficulty applying a second patch for ACPI. Read /usr/src/kernel-source-<version>/README to see if your kernel has already been patched.

If you are already running a kernel with ACPI support, you can check the ACPI revision date with the following command:

foo@bar:~$ cat /proc/acpi/info

This might give you detailed list or only a version number. You are looking for the line that starts with version:.

11.6.2. Load Related Modules

The next step is to check to see that each ACPI module is loaded after your machine boots. You can do this with the lsmod command. You are looking for the following options: button, battery, fan, ac, thermal, and processor. If you chose Y instead of M (modules) when you compiled your kernel, you will not see this list, because the components were compiled into the kernel itself. Otherwise, the output should look similar to this:

    Module                  Size  Used by
    button                  2420   0 (unused)
    battery                 5960   0 (unused)
    ac                      1832   0 (unused)
    fan                     1608   0 (unused)
    thermal                 6664   0 (unused)
    processor               8664   0 [thermal]

If you compiled ACPI support as modules and you do not see the ACPI modules listed, you need to load the modules by hand. The modules should be in /lib/modules/<kernel-version>/kernel/drivers/acpi/.

To prevent having to load the modules each time you reboot, you can do one of two things: compile them directly into the kernel (a bit late for that, though, eh?) or add them to your /etc/modules file. If you do not already have a copy of the file, just create a new one and add each module name (remember, no .o) on a separate line. You can also try running update-modules which should automatically update your /etc/modules.conf configuration file.

11.6.3. Use ACPI

You can install a few different applications/daemons on your system: acpid (the daemon that controls your hardware states), and a monitoring program. Be sure to remove the APM daemon (apmd) if you are running ACPI. In addition to using an application to monitor your system, you can also check the ACPI files individually. Look in the /proc/acpi directory for various things of importance. For example, if you want to look at your battery status you need to read the battery state file:

foo@bar:~$ cat /proc/acpi/battery/BAT0/state
present:                 yes
capacity state:          ok
charging state:          charging
present rate:            37 mW
remaining capacity:      44400 mWh
present voltage:         12456 mV

More information on ACPI in Linux, including information on power management (sleep and suspend), is available at http://acpi.sourceforge.net.

Emma Jane Hogbin

    Team LiB
    Previous Section Next Section