Hi,
I have written a WDF device driver for the OSR USB-FX2 learning kit.
Eveything works fine, except that i have a question about power management.
The device is configured to go to sleep after 10 s idle time, and to resume
if the wake-up button on the kit is pressed. This works fine.
I have also configured the device power state in system sleep to only drop
to D2 instead of D3, and enabled wakeup.
However, when the system goes in standby, the USB device is completely
powered off, and as a result, i cannot wake the system with the wake-up
pushbutton.
The debugging output shows that the device power state is dropped to D3,
even though I configured it not to do that.
Am i doing something wrong here? Is it even possible to wake the system out
of standby that way?
This is my power configuration code, which is called in the
EvtDevicePrepareHardware function.
NTSTATUS
InitPowerManagement(IN WDFDEVICE Device,
IN PDEVICE_CONTEXT Context)
{
NTSTATUS status = STATUS_SUCCESS;
WDF_USB_DEVICE_INFORMATION usbInfo;
KdPrint((__DRIVER_NAME “Device init power management\n”));
status = WdfUsbTargetDeviceRetrieveInformation(
Context->UsbDevice,
&usbInfo);
if(!NT_SUCCESS(status))
{
KdPrint((__DRIVER_NAME
“WdfUsbTargetDeviceRetrieveInformation failed with status 0x%08x\n”,
status));
return status;
}
KdPrint((__DRIVER_NAME “Device self powered: %d”,
usbInfo.Traits & WDF_USB_DEVICE_TRAIT_SELF_POWERED ? 1 : 0));
KdPrint((__DRIVER_NAME “Device remote wake capable: %d”,
usbInfo.Traits & WDF_USB_DEVICE_TRAIT_REMOTE_WAKE_CAPABLE ? 1 : 0));
KdPrint((__DRIVER_NAME “Device high speed: %d”,
usbInfo.Traits & WDF_USB_DEVICE_TRAIT_AT_HIGH_SPEED ? 1 : 0));
if(usbInfo.Traits & WDF_USB_DEVICE_TRAIT_REMOTE_WAKE_CAPABLE)
{
WDF_DEVICE_POWER_POLICY_IDLE_SETTINGS idleSettings;
WDF_DEVICE_POWER_POLICY_WAKE_SETTINGS wakeSettings;
WDF_DEVICE_POWER_POLICY_IDLE_SETTINGS_INIT(&idleSettings,
IdleUsbSelectiveSuspend);
idleSettings.IdleTimeout = 10000;
status = WdfDeviceAssignS0IdleSettings(Device, &idleSettings);
if(!NT_SUCCESS(status))
{
KdPrint((__DRIVER_NAME
“WdfDeviceAssignS0IdleSettings failed with status 0x%08x\n”,
status));
return status;
}
WDF_DEVICE_POWER_POLICY_WAKE_SETTINGS_INIT(&wakeSettings);
wakeSettings.DxState = PowerDeviceD2;
wakeSettings.Enabled = WdfTrue;
status = WdfDeviceAssignSxWakeSettings(Device, &wakeSettings);
if(!NT_SUCCESS(status))
{
KdPrint((__DRIVER_NAME
“WdfDeviceAssignSxWakeSettings failed with status 0x%08x\n”,
status));
return status;
}
}
return status;
}
kind regards,
Bruno.