Thursday, April 10, 2008

Power Management under Windows CE [part 1/3]

Embedded devices are usually powered by batteries and the power have to be correctly managed to improve the device autonomy and by the way the user experience. Windows Embedded CE is provided with a Power Manager that will interact with the different drivers of the system to reduce power consumption when required.

System Power States
The OS have 4 different power states that will be the four states of the internal power manager state machine. The state transition will be linked to system conditions : user activities, system activities, application requests and timers.
The four states are :
  • On : in this state the device is full active and user can use all the different peripherals, and by consequence the current consumption is maximum
  • User Idle : this state is reach when user is not using the device after a time out, the power consumption can be reduced by, for example, decreasing the display backlight intensity and disabling peripherals.
  • System Idle : after application inactivity, the power manager switch to this state.
  • Suspend : in this state the device is consuming the less power as possible, but the device cannot be used, the processor clock is decreased (or turned in a suspend state if supported), the peripherals are usually turned off and the SDRAM is still refreshed.
The transition from On to User Idle and User Idle to Suspend is done after timers expirations, those timers value can be setup through the registry to customize your device. You can managed timers when device is powered by a battery and/or by AC, to optimize your device current consumption depending on the power source.
[HKLM\SYSTEM\CurrentControlSet\Control\Power\Timeouts]
"ACUserIdle"=dword:5 ; in seconds

This will set a timeout of 5 seconds to enter the User Idle state when the device is powered by AC. The status of the power source is not identified by the Power Manager, itself, it will require the development of a battery driver. The battery driver will provide power source transition notifications to the power manager.

Drivers Power States
On the system drivers can support 5 different levels of power according to the peripheral capabilities:
  • D0 : Full on, the peripheral is fully functional
  • D1 : Low On, fully functional the device consumption is reduce comparing to D0 state
  • D2 : Standby, device is partially powered, and able to wake up on request
  • D3 : Sleep, the device is consuming as less power as possible and can be used to wake up the system
  • D4 : Off, the device is off an do no consume any power
Each state is optional and a driver can support only few of them. The power manager will request to the driver the different supported power state at initialization.

System Power States vs Drivers Power States
The Power Manager is fully configurable through the registry, so default configuration is provided to at least manage power by its own without any pre-requisite. Each power state of the drivers will be associated to a system power state as follow :
  • On -> D0
  • User Idle -> D1
  • System Idle -> D2
  • Suspend -> D3
The Power Manager will request device driver to change their power state at system power state transitions, according to this list. As explained before, those values can be overridden using the registry by creating new entries like this :
[HKLM\SYSTEM\CurrentControlSet\Control\Power\State\UserIdle]
"bkl1:"=dword:4 ; backlight off

[
HKLM\SYSTEM\CurrentControlSet\Control\Power\State\SystemIdle]
"bkl1:"=dword:4 ; backlight off

[
HKLM\SYSTEM\CurrentControlSet\Control\Power\State\Suspend]
"bkl1:"=dword:4 ; backlight off

In this example, the driver named bkl1: will be turned off when the system power state will switch to User Idle, System Idle and Suspend states. You can either define power state for drivers individually in the registry or group them into IClass definition. When defining a driver in the registry you can specify which class of driver this driver is associated to.
[HKLM\SYSTEM\CurrentControlSet\Control\Power\State\SystemIdle\{ A32942B7-920C-486b-B0E6-92A702A99B35 }]
"Default"=dword:4 ; D4

This configuration will turn off all the device from the Iclass (A32942B7-920C-486b-B0E6-92A702A99B35). This IClass value is the GUID used by the power manageable devices.

That’s all for today, but two additional articles are following in the next few days. I will talk about the device driver interface requirements, and application interface used to communicate with the Power Manager and receive notification from him.

[Updated] : Access to part 2/3

- Nicolas

2 comments:

Ralph said...

I recently came across your blog and have been reading along. I thought I would leave my first comment. I don't know what to say except that I have enjoyed reading. Nice blog. I will keep visiting this blog very often.


Ruth

http://systemmemory.info

Steve said...

This is a very good article. Thanks.