none
question about device power capabilty RRS feed

  • Question

  • hi, I am learning WDK usb sample - osrusbfx2.

    In the function - "OsrFxEvtDeviceAdd", I don't see codes to set the device power capability, I know driver should call WdfDeviceSetPowerCapabilities to set this but don't see this in the codes. I checked MSDN and I think the usb bus driver should have set device's power capability for us and that's why osrusbfx2 can ignore this, right? But from MSDN, it says generally a function driver should take the owership of a power policy, so why it's not osrusbfx2, but lower layer driver take this? 

    And another question comes, if it's really the lower layer driver took the power policy ownership, how it know the value it should set for the osrfx2? Are these value the common for all usb devices? I also find on differnt PC, some of the capability values are not the same. For example, for “DeviceState” array, I checked the "power state mappings" from the device manager on the osrusbfx2, the mapping table is different, looks like the setting depends on the system.

    The last quesiton, does WDF provide an API to get the power capability? I only see WdfDeviceSetPowerCapabilities, but no WdfDeviceGetPowerCapabilities for example, or can I get the device power capabilities from the registry?


    unicornx

    Monday, April 8, 2013 3:16 AM

Answers

  • you are confusing two concepts.

    1) the raw power capabilities of the device. the bus driver typically sets these since these are discoverable in a bus generic mapping

    2) the power policy of the device. this is really "when do I turn my device off and how do I do that". the power policy owner is typically FDO of the stack (osrusbfx2)

    power policy is based on the raw power capabilities of the device. you cannot do more in policy than the capabilities report. for instance, you cannot enable a power policy that idles out the device with wake if the device is not reported as wake capable.

    there is no get power capabilities API.  99% of the time you don't need it.  you can always get the power capabilities by building IRP_MJ_PNP/IRP_MN_QUERY_CAPABILITIES yourself.  When you set power capabilities you can not add more capabilities than were reported by the PDO, ie saying you can wake when the PDO says you cannot doesn't work.


    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Monday, April 8, 2013 4:17 AM

All replies

  • you are confusing two concepts.

    1) the raw power capabilities of the device. the bus driver typically sets these since these are discoverable in a bus generic mapping

    2) the power policy of the device. this is really "when do I turn my device off and how do I do that". the power policy owner is typically FDO of the stack (osrusbfx2)

    power policy is based on the raw power capabilities of the device. you cannot do more in policy than the capabilities report. for instance, you cannot enable a power policy that idles out the device with wake if the device is not reported as wake capable.

    there is no get power capabilities API.  99% of the time you don't need it.  you can always get the power capabilities by building IRP_MJ_PNP/IRP_MN_QUERY_CAPABILITIES yourself.  When you set power capabilities you can not add more capabilities than were reported by the PDO, ie saying you can wake when the PDO says you cannot doesn't work.


    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Monday, April 8, 2013 4:17 AM
  • I find I can get some power capability info from the device manager. Right click the properties of one device, on the popup property pages, select "Details", select "Power Capabilities" or "Power State Mappings", I can get part of the mem values of structure - WDF_DEVICE_POWER_CAPABILITIES。

    But I find a problem, if I try to use "Current Powe State" from the device manager, I find it can not provide correct info. When OSRFX2 board enters low-power state, driver log shows it is moving to D2, but the device manager still tell me it is D0. Is it an issue? I am still testing on XP ;)



    unicornx

    Monday, April 8, 2013 7:38 AM