WdfDeviceInitSetPowerPolicyOwnership()'s WDM equivalent

Hi there,
To the best of my knowledge, by callingWdfDeviceInitSetPowerPolicyOwnership()in KMDF (or in UMDF2) one can notify the framework that the device object owns power policy for the device.
I’m wondering whether there’s an equivalent WDM function as well.
Thanks in advance!
Best,
Szilard Szaloki

Well, the WDM equivalent is that you pass through IRP_MJ_POWER requests with acting on them. Power handling is a complicated state machine in KMDF, and that API essentially disables it.

Hi Tim, Thanks for the quick response! What if there’s more than one driver in the device stack willing to do the same?

It is up to each driver in the stack to negotiate or define the power policy owner. Each device stack (or device install class) defines the mechanics of who owns power policy and how to (potentially) claim it. The WDF api doesn’t participate in this, it is merely a way to declare your device’s power policy ownership role (to override the default PPO role based on device type (PDO, FDO, or filter).

Hi Doron,
Thanks for your answer!
Actually, I would like to put the device into a low-power state without my driver being the PPO in the given device stack.
Would that be possible?

It depends on how tolerant the PPO is to outside entities trying to control power state. A WDF based PPO will assert if anyone outside of the PPO tries to change power state. Best option is to use a PPO supported way to runtime idle the device if it supports such an interface.

Actually, I would like to put the device into a low-power state without my driver being the PPO in the given device stack.

Surely you can understand why this won’t work. The main driver knows in what state it left the device. He believes he is in control of that state. If he needs to communicate with the device, he’s going to assume it is in the state he left, up and running. If it’s not, disaster will surely ensue.

Hmmmm… I suppose you could fake an S-State transition for the devnode, and get the PPO to generate some corresponding D-State transition.

Would that be sufficient?

Peter

S state transitions are sent with the pnp stage change lock held, there are many pnp/power implementations that rely on this implementation. You could probably get away with it. Until you don’t. Szilard, what stack/device are you trying to idle and power down?

A monitor’s device stack.

S state transitions are sent with the pnp stage change lock held

It’s a sleazy method, for sure.

Because you’re presumably an upper filter in the devnode, you should be able to fake it.

monitor’s device stack.

Eh? Like VIDEO? Time to ask the time honored question: What are you trying to accomplish. There are certainly simple methods to power-down a video display.

Peter