Integrating Drivers and Applications with Windows Power Management Pat Stemen patste @ microsoft.com...

35
Integrating Drivers and Integrating Drivers and Applications with Applications with Windows Power Management Windows Power Management Pat Stemen Pat Stemen patste @ microsoft.com patste @ microsoft.com Program Manager Program Manager Microsoft Corporation Microsoft Corporation

Transcript of Integrating Drivers and Applications with Windows Power Management Pat Stemen patste @ microsoft.com...

Integrating Drivers and Integrating Drivers and Applications with Applications with Windows Power Windows Power ManagementManagement

Pat StemenPat Stemenpatste @ microsoft.compatste @ microsoft.comProgram ManagerProgram ManagerMicrosoft CorporationMicrosoft Corporation

AgendaAgenda

Vista Power Management GoalsVista Power Management GoalsRealizing Maximum Energy SavingsRealizing Maximum Energy SavingsNew Power Management Usage ModelsNew Power Management Usage ModelsChanges for Applications and DriversChanges for Applications and DriversIntegrating Devices or Applications with Integrating Devices or Applications with Windows Power ManagerWindows Power ManagerHandling Common Power EventsHandling Common Power EventsSummary / Next StepsSummary / Next Steps

Vista Power Management GoalsVista Power Management Goals

Simplify the user experienceSimplify the user experienceEnhance and extend power management Enhance and extend power management usage modelsusage modelsImprove the reliability of sleep transitionsImprove the reliability of sleep transitions

Predictable behaviorPredictable behaviorVisibility into power management actionsVisibility into power management actionsExtensive diagnostic tracingExtensive diagnostic tracing

Enable maximum energy savingsEnable maximum energy savingsMobile PC battery lifeMobile PC battery lifeDesktop power consumptionDesktop power consumption

Enabling Maximum PC Energy Enabling Maximum PC Energy SavingsSavings

Vista will, by default, enable energy saving Vista will, by default, enable energy saving features on desktop PCsfeatures on desktop PCs

Monitor display blankingMonitor display blankingIdle system sleep timeoutIdle system sleep timeout

Vista will default to aggressive power policy Vista will default to aggressive power policy defaults for mobile PCs on battery powerdefaults for mobile PCs on battery powerVista addresses the principle power management Vista addresses the principle power management adoption blockersadoption blockers

Offers easy power policy configurationOffers easy power policy configurationRemoves need to be Administrator to change policy Removes need to be Administrator to change policy settingssettingsSupports Group Policy control of power settingsSupports Group Policy control of power settingsProvides a rich power policy command-line toolProvides a rich power policy command-line toolFeatures reliable and deterministic sleep transitionsFeatures reliable and deterministic sleep transitions

Simplifying Power Policy Simplifying Power Policy SettingsSettings

Vista provides three default power schemesVista provides three default power schemesMaximum Energy SavingsMaximum Energy SavingsAutomaticAutomaticMaximum PerformanceMaximum Performance

The default power schemes are the personalities The default power schemes are the personalities for all power schemesfor all power schemes

Personality indicates the power saving behavior of the Personality indicates the power saving behavior of the schemeschemeActive power scheme personality can be broadcast to Active power scheme personality can be broadcast to interested componentsinterested componentsAllows applications and devices to understand and Allows applications and devices to understand and respond to user’s power intentrespond to user’s power intent

Power schemes can be easily discovered and Power schemes can be easily discovered and changed by userschanged by users

Via enhanced battery meterVia enhanced battery meterProvides a simple, 1Provides a simple, 1stst tier interface to power schemes tier interface to power schemesLinks to Power Options for advanced settingsLinks to Power Options for advanced settings

Simplifying Power Policy Simplifying Power Policy SettingsSettings

New Power Management Usage New Power Management Usage ModelsModels

Hybrid SleepHybrid SleepAddresses user confusion between Standby and Addresses user confusion between Standby and HibernateHibernate

Users do not always know when standby or hibernate Users do not always know when standby or hibernate is appropriateis appropriateEnables single “Off” choice for usersEnables single “Off” choice for users

Saves Hibernate file, then enters StandbySaves Hibernate file, then enters StandbyNormally, resume is from memory image Normally, resume is from memory image

Typically 2-3 secondsTypically 2-3 seconds

If power is lost, system resumes from hibernate If power is lost, system resumes from hibernate image on disk image on disk

Typically 5-10 secondsTypically 5-10 seconds

New Power Management Usage New Power Management Usage ModelsModels

Hybrid Sleep Benefits:Hybrid Sleep Benefits:Allows for a simple shutdown metaphorAllows for a simple shutdown metaphor

Users do not need to understand or choose Users do not need to understand or choose between Standby and Hibernate; just “Off”between Standby and Hibernate; just “Off”

Provides increased reliabilityProvides increased reliabilityData and system state are always backed by Data and system state are always backed by non-volatile storagenon-volatile storage

Enables Quick Doze to hibernateEnables Quick Doze to hibernateEliminates S0 transition on S3->S4 doze Eliminates S0 transition on S3->S4 doze timeouttimeout

System can simply be turned offSystem can simply be turned off

New Power Management Usage New Power Management Usage ModelsModels

Media PCs may benefit from a Media PCs may benefit from a Consumer Electronics (CE) On / Off Consumer Electronics (CE) On / Off modelmodelRequires fast response to user On / Requires fast response to user On / Off requestsOff requests

Similar to TV remote controlSimilar to TV remote control

PC may need to continue to operate PC may need to continue to operate even though the user is done with iteven though the user is done with it

Recording or buffering live TVRecording or buffering live TVActing as a media server to other Acting as a media server to other devicesdevices

New Power Management Usage New Power Management Usage ModelsModels

Away Mode addresses this scenarioAway Mode addresses this scenario

Away Mode is not a power policy or Away Mode is not a power policy or new power statenew power state

User is not interacting with the machineUser is not interacting with the machine

PC looks and sounds off, but work may PC looks and sounds off, but work may continue in the backgroundcontinue in the background

Goes dark and quiet immediately on Goes dark and quiet immediately on user requestuser request

New Power Management Usage New Power Management Usage ModelsModels

Away Mode DetailsAway Mode DetailsRegistry-based configurationRegistry-based configuration

OEMs can enable Away Mode during pre-installationOEMs can enable Away Mode during pre-installation

When enabled, any Standby request maps to When enabled, any Standby request maps to Away ModeAway Mode

AttributesAttributesVideo is blankedVideo is blanked

Audio is mutedAudio is muted

Keyboard / mouse input is filteredKeyboard / mouse input is filtered

System remains in S0 (working state)System remains in S0 (working state)

May still idle to Sleep, based on power policy, usageMay still idle to Sleep, based on power policy, usage

New Power Management Usage New Power Management Usage ModelsModels

Vista power management goals require Vista power management goals require extensive use of sleep and resumeextensive use of sleep and resume

Maximizing PC energy savings requires reliable Maximizing PC energy savings requires reliable sleep transitionssleep transitions

But, failed transitions are the primary sleep But, failed transitions are the primary sleep adoption blockeradoption blocker

Component vetoes are the primary causeComponent vetoes are the primary causeRoughly 1/3 of all sleep failuresRoughly 1/3 of all sleep failuresDrivers may veto sleep requestsDrivers may veto sleep requestsServices may silently fail sleepServices may silently fail sleepSome applications display warnings, some do notSome applications display warnings, some do notSome may display warnings – with the laptop lid Some may display warnings – with the laptop lid closed!closed!

New Power Management Usage New Power Management Usage ModelsModels

Component vetoes lead to great user Component vetoes lead to great user frustration and distrust of power frustration and distrust of power managementmanagement

System did not do what the user askedSystem did not do what the user asked

Worst case scenario: Worst case scenario: Laptop in a bag fails to sleep, or wakes Laptop in a bag fails to sleep, or wakes and fails to return to sleepand fails to return to sleepBattery drains, system overheats, laptop Battery drains, system overheats, laptop is unusable when needed, possible data is unusable when needed, possible data losslossUsers turn off sleep and use shutdownUsers turn off sleep and use shutdown

New Power Management Usage New Power Management Usage ModelsModels

Investigations show that applications Investigations show that applications and services abuse the ability to vetoand services abuse the ability to veto

Veto instead of develop and test for Veto instead of develop and test for power managementpower management

Veto to prevent Veto to prevent potentialpotential network network connectivity lossconnectivity loss

Same component many handle network Same component many handle network connectivity well outside of sleep / resumeconnectivity well outside of sleep / resume

Microsoft testing shows most Microsoft testing shows most components do not need sleep querycomponents do not need sleep query

New Power Management Usage New Power Management Usage ModelsModels

Reducing component vetoesReducing component vetoesVista will not query user mode Vista will not query user mode components when entering sleepcomponents when entering sleep

User-mode query (PBT_APMQUERYSUSPEND) User-mode query (PBT_APMQUERYSUSPEND) event will event will notnot be sent be sent

Regardless of how the sleep transition startsRegardless of how the sleep transition starts

Hardware button press, lid switch, UI, system idle Hardware button press, lid switch, UI, system idle timertimer

User-mode notification (PBT_APMSUSPEND) User-mode notification (PBT_APMSUSPEND) event will continue to be sentevent will continue to be sent

Timeout to process event has been reduced from Timeout to process event has been reduced from 20 seconds to 2 seconds20 seconds to 2 seconds

Changes for Applications and Changes for Applications and DriversDrivers

Applications and ServicesApplications and ServicesDo not depend on blocking a sleep state Do not depend on blocking a sleep state transitiontransition

Use the PBT_APMSUSPEND event to do any limited Use the PBT_APMSUSPEND event to do any limited cleanup before suspendcleanup before suspend

Cleanup must be completed within 2 secondsCleanup must be completed within 2 seconds

A message will always be sent when the A message will always be sent when the system resumessystem resumes

PBT_APMRESUME, PBT_APMRESUMECRITICAL, PBT_APMRESUME, PBT_APMRESUMECRITICAL, PBT_APMRESUMEAUTOMATICPBT_APMRESUMEAUTOMATIC

Use this message to automatically restart a task that Use this message to automatically restart a task that did not complete because of a sleep state transitiondid not complete because of a sleep state transition

Changes for Applications and Changes for Applications and DriversDrivers

Applications and ServicesApplications and ServicesApplications may temporarily disable sleep idle Applications may temporarily disable sleep idle timers when needed to ensure system timers when needed to ensure system availabilityavailability

e.g., Burning a CD, recording a TV showe.g., Burning a CD, recording a TV show

SetThreadExecutionStateSetThreadExecutionStateTemporarily disables the sleep idle timerTemporarily disables the sleep idle timerDoes not prevent user-initiated sleep transitionsDoes not prevent user-initiated sleep transitions

Usage:Usage:Call Call SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED)SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED)

Disables the sleep idle timerDisables the sleep idle timer

Process the taskProcess the taskWhen complete, call When complete, call SetThreadExecutionState(ES_CONTINUOUS)SetThreadExecutionState(ES_CONTINUOUS)

Re-enables the sleep idle timerRe-enables the sleep idle timer

Changes for Applications and Changes for Applications and DriversDrivers

Applications and ServicesApplications and ServicesHandling Away Mode notificationsHandling Away Mode notifications

Media or other applications should register Media or other applications should register for Away Mode notificationfor Away Mode notification

When the user directs the system into Away When the user directs the system into Away Mode..Mode..

Screen and Audio are offScreen and Audio are off

Don’t render graphics, audio to local devices Don’t render graphics, audio to local devices

Conserves system resources and powerConserves system resources and power

Don’t rely on prompting the user for inputDon’t rely on prompting the user for input

Changes for Applications and Changes for Applications and DriversDrivers

DriversDriversHybrid SleepHybrid Sleep

Most drivers will not need to be modified for Most drivers will not need to be modified for hybrid sleephybrid sleepDrivers are told the platform is entering the Drivers are told the platform is entering the S4 stateS4 state

IRP_MN_SET_POWER Parameters.Power.State == IRP_MN_SET_POWER Parameters.Power.State == PowerSystemHibernatePowerSystemHibernate

Drivers should save appropriate context for Drivers should save appropriate context for S4S4, , not S3not S3

Assume the system may resume from the S4 stateAssume the system may resume from the S4 state

Test your device and driver with Vista to Test your device and driver with Vista to ensure compatibilityensure compatibility

Changes for Applications and Changes for Applications and DriversDrivers

DriversDriversHybrid SleepHybrid Sleep

Wake-enabled devices must support wake Wake-enabled devices must support wake from from S4S4

Sleep can not be “lightened” for hybrid sleep Sleep can not be “lightened” for hybrid sleep transitionstransitions

““Lightened” sleep occurs when system enters S1 Lightened” sleep occurs when system enters S1 instead of S3 due to wake-enabled devicesinstead of S3 due to wake-enabled devices

Integrating with Windows Power Integrating with Windows Power PolicyPolicy

Vista enables all components to integrate Vista enables all components to integrate with system-wide power policy, including with system-wide power policy, including device drivers and software applicationsdevice drivers and software applications

Enables rich device power managementEnables rich device power managementBeyond run time idle detectionBeyond run time idle detection

Extends current policy preference to Extends current policy preference to componentscomponents

Provides mechanisms for definition and installation of Provides mechanisms for definition and installation of custom power settingscustom power settings

Exposes a broad set of power event Exposes a broad set of power event notificationsnotifications

Integrating with Windows Power Integrating with Windows Power PolicyPolicy

To integrate any component with To integrate any component with system power policy:system power policy:1.1.Define a new power settingDefine a new power setting

2.2.Install the new power settingInstall the new power setting

3.3.Register for change notification on the Register for change notification on the new power setting new power setting

4.4.Respond to change notificationsRespond to change notifications

Integrating with Windows Power Integrating with Windows Power PolicyPolicy

Define a new power settingDefine a new power settingNew power setting controls the component’s New power setting controls the component’s power saving behavior or performance statepower saving behavior or performance stateSpecify new power setting attributesSpecify new power setting attributes

Unique GUIDUnique GUIDTextual description, friendly nameTextual description, friendly nameSetting values for AC, DCSetting values for AC, DC

Range of valuesRange of valuesList of discrete valuesList of discrete values

Specify default values for each default power Specify default values for each default power schemescheme

Specifying the correct defaults for each of the power Specifying the correct defaults for each of the power schemes is criticalschemes is criticalUsers might not go to the Power Control Panel to Users might not go to the Power Control Panel to configure the new settingconfigure the new setting

Integrating with Windows Power Integrating with Windows Power PolicyPolicy

Install the new power settingInstall the new power settingINF or API-based installationINF or API-based installation

INF method is the preferred (and easiest) INF method is the preferred (and easiest) methodmethod

New INF directives to support power New INF directives to support power setting installationsetting installation

Use in device installation INF or separate Use in device installation INF or separate INF executed during application installationINF executed during application installation

Integrating with Windows Power Integrating with Windows Power PolicyPolicy

Register for change notifications on the Register for change notifications on the new power settingnew power setting

Registration APIs available for USER and kernel Registration APIs available for USER and kernel modesmodesRegister within device or application Register within device or application initialization codeinitialization code

Register for notification with unique GUIDRegister for notification with unique GUID

Deregister when your device is stopped or Deregister when your device is stopped or application is closedapplication is closedKernel-mode registration function includes Kernel-mode registration function includes context parameter context parameter

Most drivers will pass device extension in contextMost drivers will pass device extension in contextEnables drivers to handle registration for multiple Enables drivers to handle registration for multiple devicesdevices

Integrating with Windows Power Integrating with Windows Power PolicyPolicy

Respond to the power setting change Respond to the power setting change notificationnotification

Callback is notification to change device Callback is notification to change device performance state or application behaviorperformance state or application behavior

Callback includes current / new power setting valueCallback includes current / new power setting value

Actual time of behavior state transition (immediate / Actual time of behavior state transition (immediate / delayed) is defined by the driver or applicationdelayed) is defined by the driver or application

Callback will be executed when the power Callback will be executed when the power setting value changessetting value changes

Active power scheme changeActive power scheme change

AC / DC transitionAC / DC transition

User changes setting valueUser changes setting value

Integrating with Windows Power Integrating with Windows Power PolicyPolicy

Additional notesAdditional notesWindows power control panel Windows power control panel offers single place for power offers single place for power configurationconfiguration

Includes configuration of custom Includes configuration of custom power settings for components power settings for components integrated with system power policyintegrated with system power policy

Look for white paper detailing Look for white paper detailing APIs and power setting APIs and power setting installation on the WHDC Web installation on the WHDC Web sitesite

http://http://go.microsoft.com/fwlink/?LinkIdgo.microsoft.com/fwlink/?LinkId=51286=51286

Handling Common Power Handling Common Power EventsEvents

Applications may wish to handle common power Applications may wish to handle common power management eventsmanagement events

AC / DC power state changeAC / DC power state changePower scheme personality changePower scheme personality changeMonitor on / offMonitor on / offUser presence (away mode)User presence (away mode)

Historically, applications need to poll for status changeHistorically, applications need to poll for status changeEg, GetSystemPowerStatus API for battery capacity, AC line Eg, GetSystemPowerStatus API for battery capacity, AC line statusstatus

Vista features asynchronous notification of common power Vista features asynchronous notification of common power eventsevents

Same API used for power setting change registrationSame API used for power setting change registrationUser modeUser mode

RegisterPowerSettingNotification()RegisterPowerSettingNotification()

Kernel modeKernel modePoRegisterPowerSettingNotification()PoRegisterPowerSettingNotification()

Handling Common Power Handling Common Power EventsEvents

AC / DC power state changeAC / DC power state changeRegister with Register with GUID_ACDC_POWER_SOURCEGUID_ACDC_POWER_SOURCE

Callback value isCallback value isAC (utility power)AC (utility power)

DC (battery power)DC (battery power)

Short-term DC (UPS device)Short-term DC (UPS device)Useful for knowing when the system Useful for knowing when the system transitions to UPS powertransitions to UPS power

Handling Common Power Handling Common Power EventsEvents

Power scheme personality changePower scheme personality changeRegister with Register with GUID_POWER_SCHEME_PERSONALITYGUID_POWER_SCHEME_PERSONALITY

Callback value is GUID indicating Callback value is GUID indicating scheme personalityscheme personality

Maximum Energy SavingsMaximum Energy SavingsAutomaticAutomaticMaximum PerformanceMaximum Performance

Can be used to implement simple Can be used to implement simple power saving behavior power saving behavior

Application, driver can change power Application, driver can change power behavior according to current power behavior according to current power scheme personalityscheme personalityDoes not allow for power behavior Does not allow for power behavior configuration in the power control panelconfiguration in the power control panel

Handling Common Power Handling Common Power EventsEvents

Monitor on / offMonitor on / offRegister with Register with GUID_MONITOR_POWER_ONGUID_MONITOR_POWER_ON

Notification value indicates if the Notification value indicates if the primary video device is on or offprimary video device is on or off

Useful for media applicationsUseful for media applicationsApplications may stop rendering Applications may stop rendering video or other content when the video or other content when the display is off to save powerdisplay is off to save power

Handling Common Power Handling Common Power EventsEvents

Away ModeAway ModeRegister with Register with GUID_SYSTEM_AWAYMODEGUID_SYSTEM_AWAYMODE

Value indicates if the user is present or notValue indicates if the user is present or not

Notification that the system is entering Notification that the system is entering or exiting Away Modeor exiting Away Mode

SummarySummary

Vista power management goal is to make Vista power management goal is to make power management simple for userspower management simple for usersVista enables power saving settings by Vista enables power saving settings by default on all PCsdefault on all PCsChanges to Windows power management Changes to Windows power management and new usage models will impact your and new usage models will impact your application and driver developmentapplication and driver developmentVista enables all components to easily Vista enables all components to easily integrate with system power policyintegrate with system power policyVista makes it easy to register and respond Vista makes it easy to register and respond to common power management events to common power management events

Next StepsNext Steps

TestTest your application or driver! your application or driver!Register for Vista beta program, provide Register for Vista beta program, provide feedbackfeedbackTest tools available in Windows Driver Kit Test tools available in Windows Driver Kit (WDK)(WDK)

Take advantage of power saving features Take advantage of power saving features and opportunities to differentiate your and opportunities to differentiate your productsproductsIntegrate your application or driver with Integrate your application or driver with system power policysystem power policy

Look for white paper on WHDCLook for white paper on WHDChttp://http://go.microsoft.com/fwlink/?LinkIdgo.microsoft.com/fwlink/?LinkId=51286=51286

Leverage notifications for common power Leverage notifications for common power management events in your application or management events in your application or driverdriver

© 2006 Microsoft Corporation. All rights reserved.This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.