How to detect USB speed operating at in client driver?

Hi everybody,

Marry Xmas for you.
Does anyone know how to detect whether device is operating at Hi-speed or not in client driver? Usually I get judgement from ‘bcdUSB’ field in device descriptor, but now I find it is trustless.

Usbview sample illustrate how to differ low speed and full speed through enumeration, but it is prolix and not valid to Hi-speed.

Best regards,

bcdUsb will only tell you if the HC is high speed, and even then, not reliably. It will not tell you if your device is high speed. To do that, query for the USB_BUS_INTERFACE_USBDI_V1 interface (using IRP_MJ_PNP/IRP_MN_QUERY_INTERFACE) and then call USB_BUS_INTERFACE_USBDI_V1::IsDeviceHighSpeed, see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/buses_d/hh/Buses_d/usbinterkr_baeecc46-78ee-409a-9017-b6e74b3340e0.xml.asp.

BTW, KMDF does this for you and is exposed as a trait (WDF_USB_DEVICE_TRAIT_AT_HIGH_SPEED) on the WDFUSBDEVICE

d

Thanks Doron, I see USB_BUS_INTERFACE_USBDI_V1 is only supported by WinXP and later. How about Win2K and Win98se?

Best regards,

well, the evidence is empirical. microsoft never supported usb2.0 on win9x, so lack of support for the interface means you are running on a 1.1 controller for win9x in all cases, unless you are using a 3rd party stack. if you are, you have to ask them.

as for win2k, win2k gold through sp4 did not natively support usb 2.0 either, so wether the device is high speed or not, is, again, a moot point. BUT, if you installed the microsoft usb 2.0 stack on win2k (it is available for download), this interface is supported.

d

Okey, I know it now. Thanks for your advice. Maybe I need firmware support to get this information on all OS.

Best regards,

Doron Holan wrote:

as for win2k, win2k gold through sp4 did not natively support
usb 2.0 either, […]

I was thinking about this. What exactly does this mean? I have Win2k SP4 on my home machine, and I certainly have USB 2.0 support (Device Manager says (“VIA Enhanced USB Host Controller”, usbehci.sys, 5.0.2195.xxxx). And I am almost positive I never explicitly downloaded a 2.0 USB stack.

But after searching around a little bit I read some article saying that XP was “built” for compatibility with 2.0, but didn’t ship with it (due to lack of hardware), but that Win2000 had a totally separate stack made for it in order to support 2.0.

Windows Update probably automatically downloaded the drivers or VIA redistributed our stack on the CD that came with the machine/host controller. The XP and Win2k stacks are the same, we took the XP stack and packaged it up and shipped it downlevel.

d