350 likes | 468 Views
Integrating Drivers and Applications with Windows Power Management. Pat Stemen patste @ microsoft.com Program Manager Microsoft Corporation. Agenda. Vista Power Management Goals Realizing Maximum Energy Savings New Power Management Usage Models Changes for Applications and Drivers
E N D
Integrating Drivers and Applications with Windows Power Management Pat Stemen patste @ microsoft.com Program Manager Microsoft Corporation
Agenda • Vista Power Management Goals • Realizing Maximum Energy Savings • New Power Management Usage Models • Changes for Applications and Drivers • Integrating Devices or Applications with Windows Power Manager • Handling Common Power Events • Summary / Next Steps
Vista Power Management Goals • Simplify the user experience • Enhance and extend power management usage models • Improve the reliability of sleep transitions • Predictable behavior • Visibility into power management actions • Extensive diagnostic tracing • Enable maximum energy savings • Mobile PC battery life • Desktop power consumption
Enabling Maximum PC Energy Savings • Vista will, by default, enable energy saving features on desktop PCs • Monitor display blanking • Idle system sleep timeout • Vista will default to aggressive power policy defaults for mobile PCs on battery power • Vista addresses the principle power management adoption blockers • Offers easy power policy configuration • Removes need to be Administrator to change policy settings • Supports Group Policy control of power settings • Provides a rich power policy command-line tool • Features reliable and deterministic sleep transitions
Simplifying Power Policy Settings • Vista provides three default power schemes • Maximum Energy Savings • Automatic • Maximum Performance • The default power schemes are the personalities for all power schemes • Personality indicates the power saving behavior of the scheme • Active power scheme personality can be broadcast to interested components • Allows applications and devices to understand and respond to user’s power intent • Power schemes can be easily discovered and changed by users • Via enhanced battery meter • Provides a simple, 1st tier interface to power schemes • Links to Power Options for advanced settings
New Power Management Usage Models • Hybrid Sleep • Addresses user confusion between Standby and Hibernate • Users do not always know when standby or hibernate is appropriate • Enables single “Off” choice for users • Saves Hibernate file, then enters Standby • Normally, resume is from memory image • Typically 2-3 seconds • If power is lost, system resumes from hibernate image on disk • Typically 5-10 seconds
New Power Management Usage Models • Hybrid Sleep Benefits: • Allows for a simple shutdown metaphor • Users do not need to understand or choose between Standby and Hibernate; just “Off” • Provides increased reliability • Data and system state are always backed by non-volatile storage • Enables Quick Doze to hibernate • Eliminates S0 transition on S3->S4 doze timeout • System can simply be turned off
New Power Management Usage Models • Media PCs may benefit from a Consumer Electronics (CE) On / Off model • Requires fast response to user On / Off requests • Similar to TV remote control • PC may need to continue to operate even though the user is done with it • Recording or buffering live TV • Acting as a media server to other devices
New Power Management Usage Models • Away Mode addresses this scenario • Away Mode is not a power policy or new power state • User is not interacting with the machine • PC looks and sounds off, but work may continue in the background • Goes dark and quiet immediately on user request
New Power Management Usage Models • Away Mode Details • Registry-based configuration • OEMs can enable Away Mode during pre-installation • When enabled, any Standby request maps to Away Mode • Attributes • Video is blanked • Audio is muted • Keyboard / mouse input is filtered • System remains in S0 (working state) • May still idle to Sleep, based on power policy, usage
New Power Management Usage Models • Vista power management goals require extensive use of sleep and resume • Maximizing PC energy savings requires reliable sleep transitions • But, failed transitions are the primary sleep adoption blocker • Component vetoes are the primary cause • Roughly 1/3 of all sleep failures • Drivers may veto sleep requests • Services may silently fail sleep • Some applications display warnings, some do not • Some may display warnings – with the laptop lid closed!
New Power Management Usage Models • Component vetoes lead to great user frustration and distrust of power management • System did not do what the user asked • Worst case scenario: • Laptop in a bag fails to sleep, or wakes and fails to return to sleep • Battery drains, system overheats, laptop is unusable when needed, possible data loss • Users turn off sleep and use shutdown
New Power Management Usage Models • Investigations show that applications and services abuse the ability to veto • Veto instead of develop and test for power management • Veto to prevent potential network connectivity loss • Same component many handle network connectivity well outside of sleep / resume • Microsoft testing shows most components do not need sleep query
New Power Management Usage Models • Reducing component vetoes • Vista will not query user mode components when entering sleep • User-mode query (PBT_APMQUERYSUSPEND) event will not be sent • Regardless of how the sleep transition starts • Hardware button press, lid switch, UI, system idle timer • User-mode notification (PBT_APMSUSPEND) event will continue to be sent • Timeout to process event has been reduced from 20 seconds to 2 seconds
Changes for Applications and Drivers • Applications and Services • Do not depend on blocking a sleep state transition • Use the PBT_APMSUSPEND event to do any limited cleanup before suspend • Cleanup must be completed within 2 seconds • A message will always be sent when the system resumes • PBT_APMRESUME, PBT_APMRESUMECRITICAL, PBT_APMRESUMEAUTOMATIC • Use this message to automatically restart a task that did not complete because of a sleep state transition
Changes for Applications and Drivers • Applications and Services • Applications may temporarily disable sleep idle timers when needed to ensure system availability • e.g., Burning a CD, recording a TV show • SetThreadExecutionState • Temporarily disables the sleep idle timer • Does not prevent user-initiated sleep transitions • Usage: • Call SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED) • Disables the sleep idle timer • Process the task • When complete, call SetThreadExecutionState(ES_CONTINUOUS) • Re-enables the sleep idle timer
Changes for Applications and Drivers • Applications and Services • Handling Away Mode notifications • Media or other applications should register for Away Mode notification • When the user directs the system into Away Mode.. • Screen and Audio are off • Don’t render graphics, audio to local devices • Conserves system resources and power • Don’t rely on prompting the user for input
Changes for Applications and Drivers • Drivers • Hybrid Sleep • Most drivers will not need to be modified for hybrid sleep • Drivers are told the platform is entering the S4 state • IRP_MN_SET_POWER Parameters.Power.State == PowerSystemHibernate • Drivers should save appropriate context for S4, not S3 • Assume the system may resume from the S4 state • Test your device and driver with Vista to ensure compatibility
Changes for Applications and Drivers • Drivers • Hybrid Sleep • Wake-enabled devices must support wake from S4 • Sleep can not be “lightened” for hybrid sleep transitions • “Lightened” sleep occurs when system enters S1 instead of S3 due to wake-enabled devices
Integrating with Windows Power Policy • Vista enables all components to integrate with system-wide power policy, including device drivers and software applications • Enables rich device power management • Beyond run time idle detection • Extends current policy preference to components • Provides mechanisms for definition and installation of custom power settings • Exposes a broad set of power event notifications
Integrating with Windows Power Policy • To integrate any component with system power policy: • Define a new power setting • Install the new power setting • Register for change notification on the new power setting • Respond to change notifications
Integrating with Windows Power Policy • Define a new power setting • New power setting controls the component’s power saving behavior or performance state • Specify new power setting attributes • Unique GUID • Textual description, friendly name • Setting values for AC, DC • Range of values • List of discrete values • Specify default values for each default power scheme • Specifying the correct defaults for each of the power schemes is critical • Users might not go to the Power Control Panel to configure the new setting
Integrating with Windows Power Policy • Install the new power setting • INF or API-based installation • INF method is the preferred (and easiest) method • New INF directives to support power setting installation • Use in device installation INF or separate INF executed during application installation
Integrating with Windows Power Policy • Register for change notifications on the new power setting • Registration APIs available for USER and kernel modes • Register within device or application initialization code • Register for notification with unique GUID • Deregister when your device is stopped or application is closed • Kernel-mode registration function includes context parameter • Most drivers will pass device extension in context • Enables drivers to handle registration for multiple devices
Integrating with Windows Power Policy • Respond to the power setting change notification • Callback is notification to change device performance state or application behavior • Callback includes current / new power setting value • Actual time of behavior state transition (immediate / delayed) is defined by the driver or application • Callback will be executed when the power setting value changes • Active power scheme change • AC / DC transition • User changes setting value
Integrating with Windows Power Policy • Additional notes • Windows power control panel offers single place for power configuration • Includes configuration of custom power settings for components integrated with system power policy • Look for white paper detailing APIs and power setting installation on the WHDC Web site • http://go.microsoft.com/fwlink/?LinkId=51286
Handling Common Power Events • Applications may wish to handle common power management events • AC / DC power state change • Power scheme personality change • Monitor on / off • User presence (away mode) • Historically, applications need to poll for status change • Eg, GetSystemPowerStatus API for battery capacity, AC line status • Vista features asynchronous notification of common power events • Same API used for power setting change registration • User mode • RegisterPowerSettingNotification() • Kernel mode • PoRegisterPowerSettingNotification()
Handling Common Power Events • AC / DC power state change • Register with GUID_ACDC_POWER_SOURCE • Callback value is • AC (utility power) • DC (battery power) • Short-term DC (UPS device) • Useful for knowing when the system transitions to UPS power
Handling Common Power Events • Power scheme personality change • Register with GUID_POWER_SCHEME_PERSONALITY • Callback value is GUID indicating scheme personality • Maximum Energy Savings • Automatic • Maximum Performance • Can be used to implement simple power saving behavior • Application, driver can change power behavior according to current power scheme personality • Does not allow for power behavior configuration in the power control panel
Handling Common Power Events • Monitor on / off • Register with GUID_MONITOR_POWER_ON • Notification value indicates if the primary video device is on or off • Useful for media applications • Applications may stop rendering video or other content when the display is off to save power
Handling Common Power Events • Away Mode • Register with GUID_SYSTEM_AWAYMODE • Value indicates if the user is present or not • Notification that the system is entering or exiting Away Mode
Summary • Vista power management goal is to make power management simple for users • Vista enables power saving settings by default on all PCs • Changes to Windows power management and new usage models will impact your application and driver development • Vista enables all components to easily integrate with system power policy • Vista makes it easy to register and respond to common power management events
Next Steps • Test your application or driver! • Register for Vista beta program, provide feedback • Test tools available in Windows Driver Kit (WDK) • Take advantage of power saving features and opportunities to differentiate your products • Integrate your application or driver with system power policy • Look for white paper on WHDC • http://go.microsoft.com/fwlink/?LinkId=51286 • Leverage notifications for common power management events in your application or driver
© 2006 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.