How to enable USB selective suspend and system wake in the UMDF driver for a USB device

How to enable USB selective suspend and system wake in the UMDF driver for a USB device 
 http://blogs.msdn.com/peterwie/archive/2007/03/28/how-to-enable-usb-selective-suspend-and-system-wake-in-the-umdf-driver-for-a-usb-device.aspx

Today's guest blogger is Abhishek Ram.  Abhishek owns the PNP and Power Management code for UMDF now, and has been working on getting idle detection and wait-wake support into UMDF for a future release.  In the interim he spent some time looking at how to enable selective suspend and system wakeup in the current UMDF Fx2 sample.

  

If you’re writing as UMDF driver for a USB device, you’ve probably installed the WinUSB driver as a lower filter driver for your device (like the UMDF OSR USB Fx2 driver sample in the WDK) and you’re probably using the WinUSB driver to read from, write to and control the device. In this post, I’ll talk about how you can use the WinUSB driver to enable USB selective suspend and system wake for your device.

 

Power policy ownership

The WinUSB driver should be the power policy owner in your driver stack. Meaning, it is the WinUSB driver that makes the decisions on what power state the device should be in. Note that WinUSB assumes power policy ownership of the driver stack by default – you don’t need to do anything special to enable this. You do need to make sure that your driver does not try to claim power policy ownership for the device stack. (UMDF drivers can claim power policy ownership by calling IWDFDeviceInitialize::SetPowerPolicyOwnership(). Make sure you’re not doing this in this case).

 

I/O Queues

You need to make sure that you do not use power-managed queues if you decide that you want to enable USB selective suspend through WinUSB. If you are interested in enabling only system wake and not USB selective suspend, you may use power-managed queues. You can specify whether or not a queue is power-managed during queue creation – it is a parameter to the IWDFDevice::CreateIoQueue() method.

Here’s the reason why you should not use a power-managed queue if you’ve enabled USB selective suspend through WinUSB. By definition, the framework (UMDF) will not deliver to the driver a request that arrives on a power-managed queue, unless the device is in a powered-up state. Now let’s say you’ve enabled USB selective suspend and your device idles out because it has been inactive for a while. Now, if you receive a request on a power-managed queue after the device has idled out, the framework will not deliver the request to your driver because the device is not currently powered up. And since you’re not the power policy owner for the stack, the framework will not be able to power-up the device either, as only the power policy owner of the stack can make decisions about the power state of the device. Hence the request will remain stuck in your power-managed queue.

On the other hand, if you were to use a non-power-managed queue, then if a request arrives when the device has idled out the framework would still deliver the request to your driver. Your driver would then forward it to the WinUSB driver (assuming it cannot complete it by itself). Upon receiving the request, the WinUSB driver can make the decision on whether the device needs to be powered-up. If it does need to be powered up, WinUSB can take the necessary steps to do so, as it is the power policy owner for the device stack.

 

Setting values in the device’s hardware key via the INF

In order to enable USB selective suspend and system wake using the WinUSB driver, it is necessary to set some values in the device’s hardware key via the INF. Refer to the topic “INF AddReg directive” on MSDN for details on how to do this.

 

USB selective suspend

A UMDF driver must do the following in order to enable USB selective suspend through WinUSB

1.       Through its INF file, the driver must set a value named “DeviceIdleEnabled” in the device’s hardware key to 1. This value will tell the WinUSB driver that the device is capable of supporting USB selective suspend.

HKR,,"DeviceIdleEnabled",0x00010001,1

Setting this value is a prerequisite. In the absence of this value, WinUSB will ignore requests to enable device selective suspend. However, the presence of this value alone is not enough to enable selective suspend. You’ll need to follow the next step as well.

2.       The driver must instruct WinUSB to enable selective suspend. The driver can do this either programmatically or through its INF file.

a.       Programmatic method – The IWDFUsbTargetDevice::SetPowerPolicy() method allows you to tell the WinUSB driver to enable selective suspend by setting the AUTO_SUSPEND policy. You can also configure the idle timeout by setting the SUSPEND_DELAY policy.

b.      INF method – The driver must set a value named “DefaultIdleState” in the device’s hardware key to 1. This will tell WinUSB that by default, selective suspend should be enabled. The driver can also specify the default idle timeout by setting a value named “DefaultIdleTimeout” in the device’s hardware key to the desired timeout value in milliseconds.

HKR,,"DefaultIdleState",0x00010001,1

HKR,,"DefaultIdleTimeout",0x00010001,5000

Note that the INF method allows you to specify the defaults at the time of device install and these defaults can be overridden at run-time using the programmatic method.

A UMDF driver can also decide whether or not the user can enable or disable USB selective suspend for the device. If the driver wants to allow the user to enable or disable USB selective suspend, it must set a value named “UserSetDeviceIdleEnabled” in the device’s hardware key to 1.

HKR,,"UserSetDeviceIdleEnabled",0x00010001,1

Doing so will cause a check box to show up in the power management settings property page for the device in the Device Manager UI. The user can check or uncheck the box to enable or disable USB selective suspend.

 

System wake

System wake refers to the ability to a device to wake a system when the system is in a lower-power state. In order to enable system wake through WinUSB, a UMDF driver must set a registry value named “SystemWakeEnabled” in the device’s hardware key to 1.

HKR,,"SystemWakeEnabled",0x00010001,1

Setting this value also allows the user to control the ability of the device to wake the system from a low-power state. A check box shows up in the power management settings property page for the device in the Device Manager UI and the user can or uncheck the box to enable or disable system wake.

 

Troubleshooting tip

There are some known hardware and operating system issues due to which some devices are unable to wake from the idle state even if USB selective suspend is enabled for them. If you hit this issue, one thing to try would be to ensure that the USB hub that the device is connected to is enabled for idle. This is not guaranteed to work, but it has proved to be a useful technique to work around some USB device wake problems. Details on how to apply this workaround –

-          In the Device Manager UI, choose “View” from the menu and then choose “Devices by connection” from the drop-down list. The Device Manager UI should refresh and display the devices by connection.

-          Find your device and locate the parent USB hub device that it is connected to. Right click on the parent USB hub and select “Properties” to view its properties

-          Go to the “Power Management” tab and check the box titled “Allow the computer to turn off this device to save power”.

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: Selective Suspend Idle Timeout是一种电源管理策略,旨在减少系统对电池或电源的消耗。在SER设置中,它可以用来控制USB设备的电源管理,以使设备在闲置时自动进入低功耗模式,从而延长电池寿命或节省能源。这种策略允许系统选择性地暂停某些设备的USB总线,以使它们进入低功耗状态。当设备再次使用时,系统会自动恢复USB总线以重新激活设备。在SER设置中,我们可以设置Idle Timeout,或设备在闲置多长时间后进入低功耗模式。这样的设置可以根据用户的需求进行调整,以确保设备在需要时始终可用,同时节省电源和延长电池寿命。总之,通过Selective Suspend Idle Timeout,我们可以有效地管理USB设备的电源消耗,同时提高设备的使用效率。 ### 回答2: Selective suspend idle timeout是一种电源管理技术,可用于延长Windows电脑的电池寿命。在Selective suspend idle timeout (Ser)中设置特定的时间,当计算机不活动超过该时间时,就会将设备置于“挂起”(suspend)状态,以降低设备的能耗,从而延长电池寿命。 Ser功能通常用于笔记本电脑和移动设备上,它可以禁用或启用USB、PCI和其他设备接口以降低功耗。这些设备通常不需要在空闲时保持开启状态,因此通过使用Ser,可以使它们持续运行更长时间。 Ser对于依赖于移动设备的用户非常有用。用户可以选择在电脑不活动时设置Ser以延长电池使用时间。通过将计算机置于suspend状态,Ser可以关闭正在运行的应用程序和其他无用的设备,从而降低系统的能耗。当设备被唤醒时,计算机可以立即返回活动状态。 总之,Selective suspend idle timeout是一项非常实用的技术,可以通过将设备置于挂起状态,使用户延长计算机的电池使用寿命,降低系统能耗并提高电池续航能力。 ### 回答3: Selective suspend idle timeout是Windows系统中的一个电源管理选项,它的功能是限制USB设备在空闲一段时间后进入睡眠状态,以节省电量。在系统设置中,这个选项被称为Selective suspend idle timeout in ser。 SER是一个串口(Serial Port)设备,它是一种广泛应用于电子设备中的通信接口,可用于传输数据或声音信号。在Windows系统中,SER通常定义为COM端口。 通过选择SER设备,在系统设置中可以配置Selective suspend idle timeout的时间,例如,设定设备在空闲5分钟后进入睡眠状态。这意味着在设备连续5分钟都没有进行数据传输或信号传输时,系统将对该设备进行休眠以降低能耗。 当该设备进入休眠状态后,系统需要与该设备重新建立通信连接才能继续使用。这个过程可能需要几秒钟的时间,可能会影响系统的响应速度。如果需要使用该设备又不想等待重新建立通信连接,可以通过取消设备的休眠状态来恢复。 总之,Selective suspend idle timeout in ser是一个能够帮助用户节省电量的功能,但需要注意的是其可能会对系统的响应速度产生影响,用户需要根据自己的需要进行设置。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值