Jump-start your project by learning from devs who
write Windows drivers and file systems every day.
Take an OSR seminar!

OSR is Hiring! Click here to find out more.

Upcoming OSR Seminars:
Writing WDF Drivers for Windows Lab, Palo Alto, CA 28 April-2 May, 2014
Advanced WDF Driver Lab, Palo Alto, CA 5-8 May, 2014
Developing File Systems for Windows, Boston/Waltham, MA 13-16 May, 2014
Windows Internals & Software Drivers Lab, Dulles/Sterling, VA, CA 23-27 June, 2014


Go Back   OSR Online Lists > ntdev
Welcome, Guest
You must login to post to this list
  Message 1 of 11  
30 Jul 10 14:28
Kevin Dalpatadu
xxxxxx@gmail.com
Join Date: 10 Feb 2009
Posts To This List: 104
SET_INTERFACE.

Hi, I am trying to emulate the ms usb hub driver. I do this by creating usb devices on my bus and receiving urbs from them. The problem occurs after a set config with a printer I am testing. It appears that the printer does not set intf 0 alt 0 as other devices do by default. A filter driver that I attached below the device captures a set config sent to the ms hub and then captures nothing after that. But I see a set interface being issued to the printer (via a usb analyzer). This is a long shot, but does anyone know if the ms hub driver itself issues the set interface. Thanks, Kevin.
  Message 2 of 11  
30 Jul 10 14:48
Tim Roberts
xxxxxx@probo.com
Join Date: 28 Jan 2005
Posts To This List: 8994
Re: SET_INTERFACE.

xxxxx@gmail.com wrote: > I am trying to emulate the ms usb hub driver. I do this by creating usb devices on my bus and receiving urbs from them. > > The problem occurs after a set config with a printer I am testing. It appears that the printer does not set intf 0 alt 0 as other devices do by default. A filter driver that I attached below the device captures a set config sent to the ms hub and then captures nothing after that. But I see a set interface being issued to the printer (via a usb analyzer). > > This is a long shot, but does anyone know if the ms hub driver itself issues the set interface. SET_CONFIGURATION automatically does a SET_INTERFACE for interface 0. When there is only one interface with no alternate settings, it's quite common to omit the SET_INTERFACE URB. -- Tim Roberts, xxxxx@probo.com Providenza & Boekelheide, Inc.
  Message 3 of 11  
02 Aug 10 16:17
Kevin Dalpatadu
xxxxxx@gmail.com
Join Date: 10 Feb 2009
Posts To This List: 104
RE: SET_INTERFACE.

Hi, This works fine. However, when I plugin an Epson USB adapter, I see that the hub sets intf 0 alt 1. Any thoughts?
  Message 4 of 11  
02 Aug 10 16:23
Tim Roberts
xxxxxx@probo.com
Join Date: 28 Jan 2005
Posts To This List: 8994
Re: SET_INTERFACE.

xxxxx@gmail.com wrote: > However, when I plugin an Epson USB adapter, I see that the hub sets intf 0 alt 1. > > Any thoughts? Any thoughts about what? The hub doesn't select interfaces on its own. It only does so in response to a driver request. -- Tim Roberts, xxxxx@probo.com Providenza & Boekelheide, Inc.
  Message 5 of 11  
02 Aug 10 16:28
Kevin Dalpatadu
xxxxxx@gmail.com
Join Date: 10 Feb 2009
Posts To This List: 104
RE: SET_INTERFACE.

I have attached a filter driver below the device pdo, and I don't see any set interface requests being sent to the hub driver. But I do see set interface requests being sent down to the device. So I assumed that the hub driver does this. And as you said: -- SET_CONFIGURATION automatically does a SET_INTERFACE for interface 0. When there is only one -- interface with no alternate settings, it's quite common to omit the SET_INTERFACE URB. So who does the set interface?
  Message 6 of 11  
02 Aug 10 17:26
Tim Roberts
xxxxxx@probo.com
Join Date: 28 Jan 2005
Posts To This List: 8994
Re: SET_INTERFACE.

xxxxx@gmail.com wrote: > I have attached a filter driver below the device pdo, and I don't see any set interface requests being sent to the hub driver. But I do see set interface requests being sent down to the device. So I assumed that the hub driver does this. > > And as you said: > > -- SET_CONFIGURATION automatically does a SET_INTERFACE for interface 0. When there is only one -- interface with no alternate settings, it's quite common to omit the SET_INTERFACE URB. > > So who does the set interface? Have you ever written a USB client driver? If you have, you should have encountered this. If you haven't, I don't see how you can ever hope to write a USB filter driver. The URB_SELECT_INTERFACE structure includes a configuration handle (as input), and a USBD_INTERFACE_INFORMATION structure that specifies which interface and alternate setting to choose. The URB_SELECT_CONFIGURATION structure includes a configuration descriptor, a configuration handle (as output), and a list of USBD_INTERFACE_INFORMATION structures that specify which interface(s) and alternate setting(s) to choose. In response to URB_SELECT_CONFIGURATION, the host controller driver will issue a SET_CONFIGURATION packet, and one or more SET_INTERFACE packets. -- Tim Roberts, xxxxx@probo.com Providenza & Boekelheide, Inc.
  Message 7 of 11  
02 Aug 10 18:03
Kevin Dalpatadu
xxxxxx@gmail.com
Join Date: 10 Feb 2009
Posts To This List: 104
RE: SET_INTERFACE.

I know that URB_SELECT_CONFIGURATION has a config and one or more USBD_INTERFACE_INFORMATION structures. Do you mean to say that in a URB_SELECT_CONFIGURATION, if 3 alt settings come down in 3 USBD_INTERFACE_INFORMATION elements that the host controller driver will send a SET_CONFIGURATION packet followed by 3 SET_INTERFACE packets down to the device? I see 3 alts coming down, and see the host controller driver sending a SET_CONFIGURATION and only one SET_INTERFACE down to the device. Also, one device gets alt 0 and another gets alt 1. How does the host controller driver know which alt to select? The fact of the matter is, that I am trying to write a driver that emulates what the host controller driver is doing.
  Message 8 of 11  
02 Aug 10 18:29
Tim Roberts
xxxxxx@probo.com
Join Date: 28 Jan 2005
Posts To This List: 8994
Re: SET_INTERFACE.

xxxxx@gmail.com wrote: > I know that URB_SELECT_CONFIGURATION has a config and one or more USBD_INTERFACE_INFORMATION structures. > > Do you mean to say that in a URB_SELECT_CONFIGURATION, if 3 alt settings come down in 3 USBD_INTERFACE_INFORMATION elements that the host controller driver will send a SET_CONFIGURATION packet followed by 3 SET_INTERFACE packets down to the device? Exactly. The URB_SELECT_CONFIGURATION request should contain one entry for each interface in the configuration, with the desired alternate setting selected in each one. Most drivers do not deal with multiple interfaces, so typically the request only contains one interface. > I see 3 alts coming down, and see the host controller driver sending a SET_CONFIGURATION and only one SET_INTERFACE down to the device. Also, one device gets alt 0 and another gets alt 1. How does the host controller driver know which alt to select? Not sure what you mean by "I see 3 alts coming down". If a device has one interface with 3 alternate settings, the URB_SELECT_CONFIGURATION request will only have one interface entry. Is this a composite device? That throws a wrinkle into things. The composite driver (usbccgp.sys) lies to the devices above it, so that each one thinks it is talking to a single interface device. It then has to translate what it gets into the proper form for a multi-interface device. If the first subdevice happens to pick alternate setting 1, usbccgp needs to send a URB_SELECT_CONFIGURATION request that has alt setting 1 for that interface, but 0 for the others (which haven't reported yet). Is this an audio or video class device, where one interface is fake and the other interface does all the work? > The fact of the matter is, that I am trying to write a driver that emulates what the host controller driver is doing. That is a nearly hopeless task. Much of the interaction between the host controller and the hub drivers is not documented. -- Tim Roberts, xxxxx@probo.com Providenza & Boekelheide, Inc.
  Message 9 of 11  
02 Aug 10 18:39
Kevin Dalpatadu
xxxxxx@gmail.com
Join Date: 10 Feb 2009
Posts To This List: 104
RE: SET_INTERFACE.

> I see 3 alts coming down, and see the host controller driver sending a SET_CONFIGURATION and only one SET_INTERFACE down to the device. Also, one device gets alt 0 and another gets alt 1. How does the host controller driver know which alt to select? Not sure what you mean by "I see 3 alts coming down". -- When I get the URB_SELECT_CONFIGURATION it has 3 USBD_INTERFACE_INFORMATION structures each filled with intf 0 and alt 0, 1 or 2. If a device has one interface with 3 alternate settings, the URB_SELECT_CONFIGURATION request will only have one interface entry. -- This is not the case. And can't be, because the host controller driver must fill in the PipeHandle information for each endpoint, so that he device driver can use it when making bulk calls etc.
  Message 10 of 11  
02 Aug 10 18:54
Tim Roberts
xxxxxx@probo.com
Join Date: 28 Jan 2005
Posts To This List: 8994
Re: SET_INTERFACE.

xxxxx@gmail.com wrote: >> I see 3 alts coming down, and see the host controller driver sending a SET_CONFIGURATION and only one SET_INTERFACE down to the device. Also, one device gets alt 0 and another gets alt 1. How does the host controller driver know which alt to select? > Not sure what you mean by "I see 3 alts coming down". > > -- When I get the URB_SELECT_CONFIGURATION it has 3 USBD_INTERFACE_INFORMATION structures each filled with intf 0 and alt 0, 1 or 2. That is a bug on the part of the client driver. It doesn't make sense. I don't know what the host controller will do with that, and I'm not convinced that it's important. > If a device has one interface with 3 alternate settings, the URB_SELECT_CONFIGURATION request will only have one interface entry. > > -- This is not the case. And can't be, because the host controller driver must fill in the PipeHandle information for each endpoint, so that he device driver can use it when making bulk calls etc. No, you are wrong. Exactly one alternate setting is active at any given time for each interface. Usually, all of the alternate settings for a single interface have the same pipes. But if they do not (which is legal), the pipes that are not present in the active alternate setting cannot be used. To use a pipe that's part of a different alternate setting, the client driver must make another URB_SELECT_INTERFACE call, and that will return new pipe handles. -- Tim Roberts, xxxxx@probo.com Providenza & Boekelheide, Inc.
  Message 11 of 11  
03 Aug 10 15:54
Kevin Dalpatadu
xxxxxx@gmail.com
Join Date: 10 Feb 2009
Posts To This List: 104
RE: SET_INTERFACE.

You are correct, thanks. From the MSDN: An URB_FUNCTION_SELECT_CONFIGURATION URB consists of a _URB_SELECT_CONFIGURATION structure followed by a sequence of variable-length USB_INTERFACE_INFORMATION structures, one USB_INTERFACE_INFORMATION structure for each unique interface number in the configuration. Client drivers must allocate enough memory to contain one USBD_PIPE_INFORMATION structure for each endpoint in the selected interfaces. I seem to get a USB_INTERFACE_INFORMATION for each alt. I will plug-in different devices and see what happens.
Posting Rules  
You may not post new threads
You may not post replies
You may not post attachments
You must login to OSR Online AND be a member of the ntdev list to be able to post.

All times are GMT -5. The time now is 14:38.


Copyright ©2014, OSR Open Systems Resources, Inc.
Based on vBulletin Copyright ©2000 - 2005, Jelsoft Enterprises Ltd.
Modified under license