Implementing IAdapterPowerManagement

When implementing the IAdapterPowerManagement interface for your driver, refer to the implementation of the CAdapterCommon class in the sample audio drivers in the Microsoft Windows Driver Kit (WDK). This class handles device interrupts and performs other functions that are common to all audio adapter drivers. Your adapter's CAdapterCommon class should inherit from the IAdapterPowerManagement interface and support this interface in its NonDelegatingQueryInterface method. (For details on nondelegating interfaces, see the description of the INonDelegatingUnknown interface in the MSDN library.)

You can use the IMP_IAdapterPowerManagement definition from header file Portcls.h to add the function declarations for the IAdapterPowerManagement::PowerChangeState, IAdapterPowerManagement::QueryPowerChangeState, and IAdapterPowerManagement::QueryDeviceCapabilities methods to your driver's CAdapterCommon class definition.

During the PortCls system driver's call to an adapter's device-startup routine (see Starting a Device), the adapter should register its IAdapterPowerManagement interface with PortCls by calling PcRegisterAdapterPowerManagement. For a code example, see the StartDevice function in the Sb16 sample adapter driver in the WDK. The PcRegisterAdapterPowerManagement function's first parameter is an IUnknown pointer to the adapter driver's CAdapterCommon object. PortCls queries this object for its IAdapterPowerManagement interface.

When PortCls calls the adapter driver's IAdapterPowerManagement::PowerChangeState method to change the device's power state, the adapter driver should cache the device's new power state in the adapter's CAdapterCommon object. During the CAdapterCommon::Init call (see the implementation in the WDK's sample adapter drivers), the driver should set the initial power state to PowerDeviceD0 (described in DeviceState) before returning from a successful initialization. The driver should write to the hardware only if it is known to be in an appropriate power state. In the Sb16 sample driver in the WDK, for example, the driver writes to the hardware only in the PowerDeviceD0 state.

Before powering down in response to a PowerChangeState call, the adapter driver should place the audio outputs in a state that prevents speaker noise from occurring when the power switches off. For example, the shutdown process might include ramping the DAC outputs to zero, turning off the DACs, and muting the MIDI lines.

Send comments about this topic to Microsoft