How do you select a configuration using WdfUsbTargetDeviceSelectConfig()

I’m trying to select another USB configuration using
WdfUsbTargetDeviceSelectConfig. I’ve been successful at selecting the
first configuration and managed to get the 2nd configuration but my
solution doesn’t seem right.

Here is what I did to select a configuration. I used
WDF_USB_DEVICE_SELECT_CONFIG_PARAMS_INIT_INTERFACES_DESCRIPTORS() to
build a WDF_USB_DEVICE_SELECT_CONFIG_PARAMS object and then I call
WdfUsbTargetDeviceSelectConfig() to select the configuration.

The trouble I had was that my first couple of implementations at doing
this failed. On my first attempt I created USB_CONFIGURATION_DESCRIPTOR
and USB_INTERFACE_DESCRIPTOR objects on the stack and then used those
objects to create the WDF_USB_DEVICE_SELECT_CONFIG_PARAMS object by
calling
WDF_USB_DEVICE_SELECT_CONFIG_PARAMS_INIT_INTERFACES_DESCRIPTORS(). I
found that if I set wTotalLength of the configuration descriptor to 39
(the size of my configuration, interface and 3 endpoints) then the call
to WdfUsbTargetDeviceSelectConfig() failed with a status of 0xC0000001
(STATUS_UNSUCCESSFUL). I then tried changing wTotalLength to 18 and
this worked but when I called WdfUsbInterfaceGetNumConfiguredPipes() it
returned 0 which was not correct.
I then changed my code so that the structures were allocated from the
PagedPool and I allocated enough space for the 3 endpoints in addition
to the configuration and interface descriptors. This worked and
WdfUsbInterfaceGetNumConfiguredPipes() returned 3 as expected. However
when I called WdfUsbInterfaceGetConfiguredPipe() the pipe information
returned was clearly wrong. Finally I initialized the 3
USB_ENDPOINT_DESCRIPTORS after the USB_INTERFACE_DESCRIPTORS and this
seems to work. The function prototype and documentation for
WDF_USB_DEVICE_SELECT_CONFIG_PARAMS_INIT_INTERFACES_DESCRIPTORS()
doesn’t make any mention that the interface descriptor need to have
correctly initialized endpoint descriptors allocated after them but
without doing this I was unable to select the endpoints.

My questions are:

  1. Is this the correct way to select a different USB configuration or am
    I missing something?
  2. If this is the correct method then when is it safe to free the memory
    that I allocated to create the descriptors? Do I have to hold this
    memory until the device is removed or another configuration is selected?

Thanks,

  • Steve -

Windows only supports devices which have *one* configuration. That
configuration can have multiple *interfaces* though. To select among
different interfaces, you perform the initial select config (which
defaults to Setting 0 unless you override) and then a
WdfUsbInterfaceSelectSetting on the WDFUSBINTERFACEs that you want to
change.

Yes, the end point descriptors must come after the interface descriptor.
Your descriptor set must be well formed, although during a select
config, KMDF uses the config descriptor reported by the device.

D

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Whitman, Steve
Sent: Monday, February 20, 2006 6:35 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] How do you select a configuration using
WdfUsbTargetDeviceSelectConfig()

I’m trying to select another USB configuration using
WdfUsbTargetDeviceSelectConfig. I’ve been successful at selecting the
first configuration and managed to get the 2nd configuration but my
solution doesn’t seem right.

Here is what I did to select a configuration. I used
WDF_USB_DEVICE_SELECT_CONFIG_PARAMS_INIT_INTERFACES_DESCRIPTORS() to
build a WDF_USB_DEVICE_SELECT_CONFIG_PARAMS object and then I call
WdfUsbTargetDeviceSelectConfig() to select the configuration.

The trouble I had was that my first couple of implementations at doing
this failed. On my first attempt I created USB_CONFIGURATION_DESCRIPTOR
and USB_INTERFACE_DESCRIPTOR objects on the stack and then used those
objects to create the WDF_USB_DEVICE_SELECT_CONFIG_PARAMS object by
calling
WDF_USB_DEVICE_SELECT_CONFIG_PARAMS_INIT_INTERFACES_DESCRIPTORS(). I
found that if I set wTotalLength of the configuration descriptor to 39
(the size of my configuration, interface and 3 endpoints) then the call
to WdfUsbTargetDeviceSelectConfig() failed with a status of 0xC0000001
(STATUS_UNSUCCESSFUL). I then tried changing wTotalLength to 18 and
this worked but when I called WdfUsbInterfaceGetNumConfiguredPipes() it
returned 0 which was not correct.
I then changed my code so that the structures were allocated from the
PagedPool and I allocated enough space for the 3 endpoints in addition
to the configuration and interface descriptors. This worked and
WdfUsbInterfaceGetNumConfiguredPipes() returned 3 as expected. However
when I called WdfUsbInterfaceGetConfiguredPipe() the pipe information
returned was clearly wrong. Finally I initialized the 3
USB_ENDPOINT_DESCRIPTORS after the USB_INTERFACE_DESCRIPTORS and this
seems to work. The function prototype and documentation for
WDF_USB_DEVICE_SELECT_CONFIG_PARAMS_INIT_INTERFACES_DESCRIPTORS()
doesn’t make any mention that the interface descriptor need to have
correctly initialized endpoint descriptors allocated after them but
without doing this I was unable to select the endpoints.

My questions are:

  1. Is this the correct way to select a different USB configuration or am
    I missing something?
  2. If this is the correct method then when is it safe to free the memory
    that I allocated to create the descriptors? Do I have to hold this
    memory until the device is removed or another configuration is selected?

Thanks,

  • Steve -

Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag argument:
‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

Doron Holan wrote:

Windows only supports devices which have *one* configuration.

Maybe I don’t get out enough, but that’s the first time I’ve ever seen
that in writing. So, the URB_FUNCTION_SELECT_CONFIGURATION function
only works for configuration 0? It isn’t possible to select a different
configuration?


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

If Windows only supports devices with one configuration then how have I
been using a device that has two configurations for the past two years?
The devices’ first configuration only has a control endpoint and the
second configuration has two bulk endpoints and an interrupt endpoint.
Here is the Device Descriptor and the second Configuration Descriptor
which I retrieved from a USB analyzer trace using an existing driver.
bLength 0x12
bDescriptorType 0x01
bcdUSB 0x0110
bDeviceClass 0xff
bDeviceSubClass 0x00
bDeviceProtocol 0x00
bMaxPacketSize0 0x08
idVendor 0xXXXX
idProduct 0xXXXX
iManufacturer 0x01
iProduct 0x02
iSerialNumber 0x03
bNumConfigurations 0x02

The second configuration is:
bLength 0x09
bDescriptorType 0x02
wTotalLength 0x0027
bNumInterfaces 0x01
bConfigurationValue 0x02
iConfiguration 0x00
bmAttributes 0xc0
bMaxPower 0x00

Also the documentation for WdfUsbTargetDeviceSelectConfig() states:
Your driver can select a device configuration by using a
WDF_USB_DEVICE_SELECT_CONFIG_PARAMS structure to specify USB
descriptors,
a URB, or handles to framework USB interface objects.
To me this certainly implies that I can select configurations other can
the first.

  • Steve -

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:bounce-240566-
xxxxx@lists.osr.com] On Behalf Of Doron Holan
Sent: Monday, February 20, 2006 11:37 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] How do you select a configuration using
WdfUsbTargetDeviceSelectConfig()

Windows only supports devices which have *one* configuration. That
configuration can have multiple *interfaces* though. To select among
different interfaces, you perform the initial select config (which
defaults to Setting 0 unless you override) and then a
WdfUsbInterfaceSelectSetting on the WDFUSBINTERFACEs that you want to
change.

Yes, the end point descriptors must come after the interface
descriptor.
Your descriptor set must be well formed, although during a select
config, KMDF uses the config descriptor reported by the device.

D

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Whitman, Steve
Sent: Monday, February 20, 2006 6:35 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] How do you select a configuration using
WdfUsbTargetDeviceSelectConfig()

I’m trying to select another USB configuration using
WdfUsbTargetDeviceSelectConfig. I’ve been successful at selecting the
first configuration and managed to get the 2nd configuration but my
solution doesn’t seem right.

Here is what I did to select a configuration. I used
WDF_USB_DEVICE_SELECT_CONFIG_PARAMS_INIT_INTERFACES_DESCRIPTORS() to
build a WDF_USB_DEVICE_SELECT_CONFIG_PARAMS object and then I call
WdfUsbTargetDeviceSelectConfig() to select the configuration.

The trouble I had was that my first couple of implementations at doing
this failed. On my first attempt I created
USB_CONFIGURATION_DESCRIPTOR
and USB_INTERFACE_DESCRIPTOR objects on the stack and then used those
objects to create the WDF_USB_DEVICE_SELECT_CONFIG_PARAMS object by
calling
WDF_USB_DEVICE_SELECT_CONFIG_PARAMS_INIT_INTERFACES_DESCRIPTORS(). I
found that if I set wTotalLength of the configuration descriptor to 39
(the size of my configuration, interface and 3 endpoints) then the
call
to WdfUsbTargetDeviceSelectConfig() failed with a status of 0xC0000001
(STATUS_UNSUCCESSFUL). I then tried changing wTotalLength to 18 and
this worked but when I called WdfUsbInterfaceGetNumConfiguredPipes()
it
returned 0 which was not correct.
I then changed my code so that the structures were allocated from the
PagedPool and I allocated enough space for the 3 endpoints in addition
to the configuration and interface descriptors. This worked and
WdfUsbInterfaceGetNumConfiguredPipes() returned 3 as expected. However
when I called WdfUsbInterfaceGetConfiguredPipe() the pipe information
returned was clearly wrong. Finally I initialized the 3
USB_ENDPOINT_DESCRIPTORS after the USB_INTERFACE_DESCRIPTORS and this
seems to work. The function prototype and documentation for
WDF_USB_DEVICE_SELECT_CONFIG_PARAMS_INIT_INTERFACES_DESCRIPTORS()
doesn’t make any mention that the interface descriptor need to have
correctly initialized endpoint descriptors allocated after them but
without doing this I was unable to select the endpoints.

My questions are:

  1. Is this the correct way to select a different USB configuration or
    am
    I missing something?
  2. If this is the correct method then when is it safe to free the
    memory
    that I allocated to create the descriptors? Do I have to hold this
    memory until the device is removed or another configuration is
    selected?

Thanks,

  • Steve -

Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag
argument:
‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag
argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

Let me clarify…the USB core supports multiple configurations.
Windows inbox client drivers support one configuration.

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Tim Roberts
Sent: Monday, February 20, 2006 9:22 AM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] How do you select a configuration using
WdfUsbTargetDeviceSelectConfig()

Doron Holan wrote:

Windows only supports devices which have *one* configuration.

Maybe I don’t get out enough, but that’s the first time I’ve ever seen
that in writing. So, the URB_FUNCTION_SELECT_CONFIGURATION function
only works for configuration 0? It isn’t possible to select a different
configuration?


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@microsoft.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

Windows inbox client drivers support one config, the core doesn’t really
care and you can do multiple configs in your own driver. I personally
don’t understand why you would need multiple configurations (outside of
differing power requirements, but you can detect that in the single
configuration and adjust appropriately) in the first place, you can do
the same thing with multiple interface settings on the same config.

KMDF only supports a single configuration. When the docs talk about
specifying descriptors or a URB, it is assumed that they are from the
first config. Internally when you create a WDFUSBDEVICE, KMDF will
create a WDFUSBINTERFACE for each interface on the (first) config.

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Whitman, Steve
Sent: Monday, February 20, 2006 9:31 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] How do you select a configuration using
WdfUsbTargetDeviceSelectConfig()

If Windows only supports devices with one configuration then how have I
been using a device that has two configurations for the past two years?
The devices’ first configuration only has a control endpoint and the
second configuration has two bulk endpoints and an interrupt endpoint.
Here is the Device Descriptor and the second Configuration Descriptor
which I retrieved from a USB analyzer trace using an existing driver.
bLength 0x12
bDescriptorType 0x01
bcdUSB 0x0110
bDeviceClass 0xff
bDeviceSubClass 0x00
bDeviceProtocol 0x00
bMaxPacketSize0 0x08
idVendor 0xXXXX
idProduct 0xXXXX
iManufacturer 0x01
iProduct 0x02
iSerialNumber 0x03
bNumConfigurations 0x02

The second configuration is:
bLength 0x09
bDescriptorType 0x02
wTotalLength 0x0027
bNumInterfaces 0x01
bConfigurationValue 0x02
iConfiguration 0x00
bmAttributes 0xc0
bMaxPower 0x00

Also the documentation for WdfUsbTargetDeviceSelectConfig() states:
Your driver can select a device configuration by using a
WDF_USB_DEVICE_SELECT_CONFIG_PARAMS structure to specify USB
descriptors,
a URB, or handles to framework USB interface objects.
To me this certainly implies that I can select configurations other can
the first.

  • Steve -

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:bounce-240566-
xxxxx@lists.osr.com] On Behalf Of Doron Holan
Sent: Monday, February 20, 2006 11:37 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] How do you select a configuration using
WdfUsbTargetDeviceSelectConfig()

Windows only supports devices which have *one* configuration. That
configuration can have multiple *interfaces* though. To select among
different interfaces, you perform the initial select config (which
defaults to Setting 0 unless you override) and then a
WdfUsbInterfaceSelectSetting on the WDFUSBINTERFACEs that you want to
change.

Yes, the end point descriptors must come after the interface
descriptor.
Your descriptor set must be well formed, although during a select
config, KMDF uses the config descriptor reported by the device.

D

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Whitman, Steve
Sent: Monday, February 20, 2006 6:35 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] How do you select a configuration using
WdfUsbTargetDeviceSelectConfig()

I’m trying to select another USB configuration using
WdfUsbTargetDeviceSelectConfig. I’ve been successful at selecting the
first configuration and managed to get the 2nd configuration but my
solution doesn’t seem right.

Here is what I did to select a configuration. I used
WDF_USB_DEVICE_SELECT_CONFIG_PARAMS_INIT_INTERFACES_DESCRIPTORS() to
build a WDF_USB_DEVICE_SELECT_CONFIG_PARAMS object and then I call
WdfUsbTargetDeviceSelectConfig() to select the configuration.

The trouble I had was that my first couple of implementations at doing
this failed. On my first attempt I created
USB_CONFIGURATION_DESCRIPTOR
and USB_INTERFACE_DESCRIPTOR objects on the stack and then used those
objects to create the WDF_USB_DEVICE_SELECT_CONFIG_PARAMS object by
calling
WDF_USB_DEVICE_SELECT_CONFIG_PARAMS_INIT_INTERFACES_DESCRIPTORS(). I
found that if I set wTotalLength of the configuration descriptor to 39
(the size of my configuration, interface and 3 endpoints) then the
call
to WdfUsbTargetDeviceSelectConfig() failed with a status of 0xC0000001
(STATUS_UNSUCCESSFUL). I then tried changing wTotalLength to 18 and
this worked but when I called WdfUsbInterfaceGetNumConfiguredPipes()
it
returned 0 which was not correct.
I then changed my code so that the structures were allocated from the
PagedPool and I allocated enough space for the 3 endpoints in addition
to the configuration and interface descriptors. This worked and
WdfUsbInterfaceGetNumConfiguredPipes() returned 3 as expected. However
when I called WdfUsbInterfaceGetConfiguredPipe() the pipe information
returned was clearly wrong. Finally I initialized the 3
USB_ENDPOINT_DESCRIPTORS after the USB_INTERFACE_DESCRIPTORS and this
seems to work. The function prototype and documentation for
WDF_USB_DEVICE_SELECT_CONFIG_PARAMS_INIT_INTERFACES_DESCRIPTORS()
doesn’t make any mention that the interface descriptor need to have
correctly initialized endpoint descriptors allocated after them but
without doing this I was unable to select the endpoints.

My questions are:

  1. Is this the correct way to select a different USB configuration or
    am
    I missing something?
  2. If this is the correct method then when is it safe to free the
    memory
    that I allocated to create the descriptors? Do I have to hold this
    memory until the device is removed or another configuration is
    selected?

Thanks,

  • Steve -

Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag
argument:
‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag
argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag argument:
‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

Unfortunately the device that I’m using has multiple configurations. I
can’t use the first configuration because that is used by the device to
perform certain functions that I don’t require. I also can’t change the
firmware of the device.

If KMDF only supports a single configuration then it sounds like I won’t
be able to use it for this device.

Can you explain why if KMDF doesn’t support multiple configurations why
there is a WdfUsbTargetDeviceSelectConfig() function in the first place?
Is this for future support of multiple configurations?
Also the documentation should be clarified on this matter. There are
many locations in the documentation where statements are made that imply
that other configurations can be used. For example the documentation
for WDF_USB_DEVICE_SELECT_CONFIG_PARAMS states:
Types.Descriptor.ConfigurationDescriptor
If the driver sets the Type member to
WdfUsbTargetDeviceSelectConfigTypeInterfacesDescriptor, this
member
contains a driver-supplied pointer to a
USB_CONFIGURATION_DESCRIPTOR
structure that specifies a configuration descriptor. If this
pointer
is NULL, the framework uses the device’s first configuration.
This implies that if the pointer is not NULL then another configuration
can be used.
In the “Working with USB Devices” chapter there is a subsection titled
“Selecting a Device Configuration” which also implies that I can select
a different configuration when the EvtDevicePrepareHardware callback is
made.

Just to be clear, you are saying that if I need to use a different
configuration other than the first configuration then I can’t use a KMDF
based driver.

Regards,

  • Steve -

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:bounce-240574-
xxxxx@lists.osr.com] On Behalf Of Doron Holan
Sent: Monday, February 20, 2006 12:43 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] How do you select a configuration using
WdfUsbTargetDeviceSelectConfig()

Windows inbox client drivers support one config, the core doesn’t
really
care and you can do multiple configs in your own driver. I personally
don’t understand why you would need multiple configurations (outside
of
differing power requirements, but you can detect that in the single
configuration and adjust appropriately) in the first place, you can do
the same thing with multiple interface settings on the same config.

KMDF only supports a single configuration. When the docs talk about
specifying descriptors or a URB, it is assumed that they are from the
first config. Internally when you create a WDFUSBDEVICE, KMDF will
create a WDFUSBINTERFACE for each interface on the (first) config.

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Whitman, Steve
Sent: Monday, February 20, 2006 9:31 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] How do you select a configuration using
WdfUsbTargetDeviceSelectConfig()

If Windows only supports devices with one configuration then how have
I
been using a device that has two configurations for the past two
years?
The devices’ first configuration only has a control endpoint and the
second configuration has two bulk endpoints and an interrupt endpoint.
Here is the Device Descriptor and the second Configuration Descriptor
which I retrieved from a USB analyzer trace using an existing driver.
bLength 0x12
bDescriptorType 0x01
bcdUSB 0x0110
bDeviceClass 0xff
bDeviceSubClass 0x00
bDeviceProtocol 0x00
bMaxPacketSize0 0x08
idVendor 0xXXXX
idProduct 0xXXXX
iManufacturer 0x01
iProduct 0x02
iSerialNumber 0x03
bNumConfigurations 0x02

The second configuration is:
bLength 0x09
bDescriptorType 0x02
wTotalLength 0x0027
bNumInterfaces 0x01
bConfigurationValue 0x02
iConfiguration 0x00
bmAttributes 0xc0
bMaxPower 0x00

Also the documentation for WdfUsbTargetDeviceSelectConfig() states:
Your driver can select a device configuration by using a
WDF_USB_DEVICE_SELECT_CONFIG_PARAMS structure to specify USB
descriptors,
a URB, or handles to framework USB interface objects.
To me this certainly implies that I can select configurations other
can
the first.

  • Steve -

> -----Original Message-----
> From: xxxxx@lists.osr.com [mailto:bounce-240566-
> xxxxx@lists.osr.com] On Behalf Of Doron Holan
> Sent: Monday, February 20, 2006 11:37 AM
> To: Windows System Software Devs Interest List
> Subject: RE: [ntdev] How do you select a configuration using
> WdfUsbTargetDeviceSelectConfig()
>
>
> Windows only supports devices which have *one* configuration. That
> configuration can have multiple *interfaces* though. To select
among
> different interfaces, you perform the initial select config (which
> defaults to Setting 0 unless you override) and then a
> WdfUsbInterfaceSelectSetting on the WDFUSBINTERFACEs that you want
to
> change.
>
> Yes, the end point descriptors must come after the interface
descriptor.
> Your descriptor set must be well formed, although during a select
> config, KMDF uses the config descriptor reported by the device.
>
> D
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of Whitman,
Steve
> Sent: Monday, February 20, 2006 6:35 AM
> To: Windows System Software Devs Interest List
> Subject: [ntdev] How do you select a configuration using
> WdfUsbTargetDeviceSelectConfig()
>
> I’m trying to select another USB configuration using
> WdfUsbTargetDeviceSelectConfig. I’ve been successful at selecting
the
> first configuration and managed to get the 2nd configuration but my
> solution doesn’t seem right.
>
> Here is what I did to select a configuration. I used
> WDF_USB_DEVICE_SELECT_CONFIG_PARAMS_INIT_INTERFACES_DESCRIPTORS() to
> build a WDF_USB_DEVICE_SELECT_CONFIG_PARAMS object and then I call
> WdfUsbTargetDeviceSelectConfig() to select the configuration.
>
> The trouble I had was that my first couple of implementations at
doing
> this failed. On my first attempt I created
USB_CONFIGURATION_DESCRIPTOR
> and USB_INTERFACE_DESCRIPTOR objects on the stack and then used
those
> objects to create the WDF_USB_DEVICE_SELECT_CONFIG_PARAMS object by
> calling
> WDF_USB_DEVICE_SELECT_CONFIG_PARAMS_INIT_INTERFACES_DESCRIPTORS().
I
> found that if I set wTotalLength of the configuration descriptor to
39
> (the size of my configuration, interface and 3 endpoints) then the
call
> to WdfUsbTargetDeviceSelectConfig() failed with a status of
0xC0000001
> (STATUS_UNSUCCESSFUL). I then tried changing wTotalLength to 18 and
> this worked but when I called WdfUsbInterfaceGetNumConfiguredPipes()
it
> returned 0 which was not correct.
> I then changed my code so that the structures were allocated from
the
> PagedPool and I allocated enough space for the 3 endpoints in
addition
> to the configuration and interface descriptors. This worked and
> WdfUsbInterfaceGetNumConfiguredPipes() returned 3 as expected.
However
> when I called WdfUsbInterfaceGetConfiguredPipe() the pipe
information
> returned was clearly wrong. Finally I initialized the 3
> USB_ENDPOINT_DESCRIPTORS after the USB_INTERFACE_DESCRIPTORS and
this
> seems to work. The function prototype and documentation for
> WDF_USB_DEVICE_SELECT_CONFIG_PARAMS_INIT_INTERFACES_DESCRIPTORS()
> doesn’t make any mention that the interface descriptor need to have
> correctly initialized endpoint descriptors allocated after them but
> without doing this I was unable to select the endpoints.
>
> My questions are:
> 1. Is this the correct way to select a different USB configuration
or
am
> I missing something?
> 2. If this is the correct method then when is it safe to free the
memory
> that I allocated to create the descriptors? Do I have to hold this
> memory until the device is removed or another configuration is
selected?
>
> Thanks,
> - Steve -
>
>
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: unknown lmsubst tag
argument:
> ‘’
> To unsubscribe send a blank email to
xxxxx@lists.osr.com
>
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: unknown lmsubst tag
argument: ‘’
> To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag
argument:
‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag
argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

WdfUsbTargetDeviceSelectConfig exists b/c you have to select *a* config
in a USB driver. SelectConfig will by default select Setting #0 on each
interface. You can customize this default behavior and specify
different Alt Settings on each interface if you like.

I will fwd the feedback on the docs to our doc writer.

You can still write a KMDF based driver and roll your own USB I/O. This
way you still can take advantage of pnp, power, and power policy
(including selective suspend). The burden on you is to now track all
sent i/o and coordinate its cancellation/wait for completion during
power transitions. In fact you can still use KMDF for that. Just
create & open a generic WDFIOTARGET for each USB pipe you have, allocate
your own PURB and then format the WDFREQUEST with
WdfIoTargetFormatRequestForInternalIoctlOthers(). Essentially you lose
the automatic WDFUSBPIPE creation/deletion on select config/interface
and the ability to call USB specific formatting functions, but you can
still leverage KMDF for all the hard stuff.

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Whitman, Steve
Sent: Monday, February 20, 2006 10:19 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] How do you select a configuration using
WdfUsbTargetDeviceSelectConfig()

Unfortunately the device that I’m using has multiple configurations. I
can’t use the first configuration because that is used by the device to
perform certain functions that I don’t require. I also can’t change the
firmware of the device.

If KMDF only supports a single configuration then it sounds like I won’t
be able to use it for this device.

Can you explain why if KMDF doesn’t support multiple configurations why
there is a WdfUsbTargetDeviceSelectConfig() function in the first place?
Is this for future support of multiple configurations?
Also the documentation should be clarified on this matter. There are
many locations in the documentation where statements are made that imply
that other configurations can be used. For example the documentation
for WDF_USB_DEVICE_SELECT_CONFIG_PARAMS states:
Types.Descriptor.ConfigurationDescriptor
If the driver sets the Type member to
WdfUsbTargetDeviceSelectConfigTypeInterfacesDescriptor, this
member
contains a driver-supplied pointer to a
USB_CONFIGURATION_DESCRIPTOR
structure that specifies a configuration descriptor. If this
pointer
is NULL, the framework uses the device’s first configuration.
This implies that if the pointer is not NULL then another configuration
can be used.
In the “Working with USB Devices” chapter there is a subsection titled
“Selecting a Device Configuration” which also implies that I can select
a different configuration when the EvtDevicePrepareHardware callback is
made.

Just to be clear, you are saying that if I need to use a different
configuration other than the first configuration then I can’t use a KMDF
based driver.

Regards,

  • Steve -

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:bounce-240574-
xxxxx@lists.osr.com] On Behalf Of Doron Holan
Sent: Monday, February 20, 2006 12:43 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] How do you select a configuration using
WdfUsbTargetDeviceSelectConfig()

Windows inbox client drivers support one config, the core doesn’t
really
care and you can do multiple configs in your own driver. I personally
don’t understand why you would need multiple configurations (outside
of
differing power requirements, but you can detect that in the single
configuration and adjust appropriately) in the first place, you can do
the same thing with multiple interface settings on the same config.

KMDF only supports a single configuration. When the docs talk about
specifying descriptors or a URB, it is assumed that they are from the
first config. Internally when you create a WDFUSBDEVICE, KMDF will
create a WDFUSBINTERFACE for each interface on the (first) config.

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Whitman, Steve
Sent: Monday, February 20, 2006 9:31 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] How do you select a configuration using
WdfUsbTargetDeviceSelectConfig()

If Windows only supports devices with one configuration then how have
I
been using a device that has two configurations for the past two
years?
The devices’ first configuration only has a control endpoint and the
second configuration has two bulk endpoints and an interrupt endpoint.
Here is the Device Descriptor and the second Configuration Descriptor
which I retrieved from a USB analyzer trace using an existing driver.
bLength 0x12
bDescriptorType 0x01
bcdUSB 0x0110
bDeviceClass 0xff
bDeviceSubClass 0x00
bDeviceProtocol 0x00
bMaxPacketSize0 0x08
idVendor 0xXXXX
idProduct 0xXXXX
iManufacturer 0x01
iProduct 0x02
iSerialNumber 0x03
bNumConfigurations 0x02

The second configuration is:
bLength 0x09
bDescriptorType 0x02
wTotalLength 0x0027
bNumInterfaces 0x01
bConfigurationValue 0x02
iConfiguration 0x00
bmAttributes 0xc0
bMaxPower 0x00

Also the documentation for WdfUsbTargetDeviceSelectConfig() states:
Your driver can select a device configuration by using a
WDF_USB_DEVICE_SELECT_CONFIG_PARAMS structure to specify USB
descriptors,
a URB, or handles to framework USB interface objects.
To me this certainly implies that I can select configurations other
can
the first.

  • Steve -

> -----Original Message-----
> From: xxxxx@lists.osr.com [mailto:bounce-240566-
> xxxxx@lists.osr.com] On Behalf Of Doron Holan
> Sent: Monday, February 20, 2006 11:37 AM
> To: Windows System Software Devs Interest List
> Subject: RE: [ntdev] How do you select a configuration using
> WdfUsbTargetDeviceSelectConfig()
>
>
> Windows only supports devices which have *one* configuration. That
> configuration can have multiple *interfaces* though. To select
among
> different interfaces, you perform the initial select config (which
> defaults to Setting 0 unless you override) and then a
> WdfUsbInterfaceSelectSetting on the WDFUSBINTERFACEs that you want
to
> change.
>
> Yes, the end point descriptors must come after the interface
descriptor.
> Your descriptor set must be well formed, although during a select
> config, KMDF uses the config descriptor reported by the device.
>
> D
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of Whitman,
Steve
> Sent: Monday, February 20, 2006 6:35 AM
> To: Windows System Software Devs Interest List
> Subject: [ntdev] How do you select a configuration using
> WdfUsbTargetDeviceSelectConfig()
>
> I’m trying to select another USB configuration using
> WdfUsbTargetDeviceSelectConfig. I’ve been successful at selecting
the
> first configuration and managed to get the 2nd configuration but my
> solution doesn’t seem right.
>
> Here is what I did to select a configuration. I used
> WDF_USB_DEVICE_SELECT_CONFIG_PARAMS_INIT_INTERFACES_DESCRIPTORS() to
> build a WDF_USB_DEVICE_SELECT_CONFIG_PARAMS object and then I call
> WdfUsbTargetDeviceSelectConfig() to select the configuration.
>
> The trouble I had was that my first couple of implementations at
doing
> this failed. On my first attempt I created
USB_CONFIGURATION_DESCRIPTOR
> and USB_INTERFACE_DESCRIPTOR objects on the stack and then used
those
> objects to create the WDF_USB_DEVICE_SELECT_CONFIG_PARAMS object by
> calling
> WDF_USB_DEVICE_SELECT_CONFIG_PARAMS_INIT_INTERFACES_DESCRIPTORS().
I
> found that if I set wTotalLength of the configuration descriptor to
39
> (the size of my configuration, interface and 3 endpoints) then the
call
> to WdfUsbTargetDeviceSelectConfig() failed with a status of
0xC0000001
> (STATUS_UNSUCCESSFUL). I then tried changing wTotalLength to 18 and
> this worked but when I called WdfUsbInterfaceGetNumConfiguredPipes()
it
> returned 0 which was not correct.
> I then changed my code so that the structures were allocated from
the
> PagedPool and I allocated enough space for the 3 endpoints in
addition
> to the configuration and interface descriptors. This worked and
> WdfUsbInterfaceGetNumConfiguredPipes() returned 3 as expected.
However
> when I called WdfUsbInterfaceGetConfiguredPipe() the pipe
information
> returned was clearly wrong. Finally I initialized the 3
> USB_ENDPOINT_DESCRIPTORS after the USB_INTERFACE_DESCRIPTORS and
this
> seems to work. The function prototype and documentation for
> WDF_USB_DEVICE_SELECT_CONFIG_PARAMS_INIT_INTERFACES_DESCRIPTORS()
> doesn’t make any mention that the interface descriptor need to have
> correctly initialized endpoint descriptors allocated after them but
> without doing this I was unable to select the endpoints.
>
> My questions are:
> 1. Is this the correct way to select a different USB configuration
or
am
> I missing something?
> 2. If this is the correct method then when is it safe to free the
memory
> that I allocated to create the descriptors? Do I have to hold this
> memory until the device is removed or another configuration is
selected?
>
> Thanks,
> - Steve -
>
>
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: unknown lmsubst tag
argument:
> ‘’
> To unsubscribe send a blank email to
xxxxx@lists.osr.com
>
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: unknown lmsubst tag
argument: ‘’
> To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag
argument:
‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag
argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag argument:
‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

> WdfUsbTargetDeviceSelectConfig exists b/c you have to select *a*
config

in a USB driver. SelectConfig will by default select Setting #0 on
each
interface. You can customize this default behavior and specify
different Alt Settings on each interface if you like.

It seems to me that this function is poorly named since I use it to
select an Interface and not a Configuration.

You can still write a KMDF based driver and roll your own USB I/O.
This
way you still can take advantage of pnp, power, and power policy
(including selective suspend). The burden on you is to now track all
sent i/o and coordinate its cancellation/wait for completion during
power transitions. In fact you can still use KMDF for that. Just
create & open a generic WDFIOTARGET for each USB pipe you have,
allocate
your own PURB and then format the WDFREQUEST with
WdfIoTargetFormatRequestForInternalIoctlOthers(). Essentially you lose
the automatic WDFUSBPIPE creation/deletion on select config/interface
and the ability to call USB specific formatting functions, but you can
still leverage KMDF for all the hard stuff.

We will be developing a new USB device where I will be able to specify
the firmware for the device (since I’m writing it) so for that device I
will be able to use KMDF to implement the driver. Actually the sample
driver is very close to what I need. For the device that I’m currently
using (while I wait for our new hardware) I thought it might I would
investigate the possibility of replacing the existing driver but I’ll
probably hold off on that for now.

What I find interesting is that when I use the procedure I documented in
my original email then it appears that I’m able to use the USB
functionality as expected. Looking at the a USB trace shows that after
I call WdfUsbTargetDeviceSelectConfig() using the second Configuration
the host issued a SetConfiguration(2) to my device. I was then able to
call WdfIoTargetStart(WdfUsbTargetPipeGetIoTarget(pDC->InterruptPipe))
and process interrupts from the device. I haven’t done much testing and
I haven’t done anything with the other pipes yet but so far things
appear to work as I expect them to.

Thanks for you help,

  • Steve -

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Whitman, Steve
Sent: Monday, February 20, 2006 10:19 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] How do you select a configuration using
WdfUsbTargetDeviceSelectConfig()

Unfortunately the device that I’m using has multiple configurations. I
can’t use the first configuration because that is used by the device
to
perform certain functions that I don’t require. I also can’t change
the
firmware of the device.

If KMDF only supports a single configuration then it sounds like I
won’t
be able to use it for this device.

Can you explain why if KMDF doesn’t support multiple configurations
why
there is a WdfUsbTargetDeviceSelectConfig() function in the first
place?
Is this for future support of multiple configurations?
Also the documentation should be clarified on this matter. There are
many locations in the documentation where statements are made that
imply
that other configurations can be used. For example the documentation
for WDF_USB_DEVICE_SELECT_CONFIG_PARAMS states:
Types.Descriptor.ConfigurationDescriptor
If the driver sets the Type member to
WdfUsbTargetDeviceSelectConfigTypeInterfacesDescriptor, this
member
contains a driver-supplied pointer to a
USB_CONFIGURATION_DESCRIPTOR
structure that specifies a configuration descriptor. If this
pointer
is NULL, the framework uses the device’s first configuration.
This implies that if the pointer is not NULL then another
configuration
can be used.
In the “Working with USB Devices” chapter there is a subsection titled
“Selecting a Device Configuration” which also implies that I can
select
a different configuration when the EvtDevicePrepareHardware callback
is
made.

Just to be clear, you are saying that if I need to use a different
configuration other than the first configuration then I can’t use a
KMDF
based driver.

Regards,

  • Steve -

> -----Original Message-----
> From: xxxxx@lists.osr.com [mailto:bounce-240574-
> xxxxx@lists.osr.com] On Behalf Of Doron Holan
> Sent: Monday, February 20, 2006 12:43 PM
> To: Windows System Software Devs Interest List
> Subject: RE: [ntdev] How do you select a configuration using
> WdfUsbTargetDeviceSelectConfig()
>
> Windows inbox client drivers support one config, the core doesn’t
really
> care and you can do multiple configs in your own driver. I
personally
> don’t understand why you would need multiple configurations (outside
of
> differing power requirements, but you can detect that in the single
> configuration and adjust appropriately) in the first place, you can
do
> the same thing with multiple interface settings on the same config.
>
> KMDF only supports a single configuration. When the docs talk about
> specifying descriptors or a URB, it is assumed that they are from
the
> first config. Internally when you create a WDFUSBDEVICE, KMDF will
> create a WDFUSBINTERFACE for each interface on the (first) config.
>
> d
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of Whitman,
Steve
> Sent: Monday, February 20, 2006 9:31 AM
> To: Windows System Software Devs Interest List
> Subject: RE: [ntdev] How do you select a configuration using
> WdfUsbTargetDeviceSelectConfig()
>
> If Windows only supports devices with one configuration then how
have
I
> been using a device that has two configurations for the past two
years?
> The devices’ first configuration only has a control endpoint and the
> second configuration has two bulk endpoints and an interrupt
endpoint.
> Here is the Device Descriptor and the second Configuration
Descriptor
> which I retrieved from a USB analyzer trace using an existing
driver.
> bLength 0x12
> bDescriptorType 0x01
> bcdUSB 0x0110
> bDeviceClass 0xff
> bDeviceSubClass 0x00
> bDeviceProtocol 0x00
> bMaxPacketSize0 0x08
> idVendor 0xXXXX
> idProduct 0xXXXX
> iManufacturer 0x01
> iProduct 0x02
> iSerialNumber 0x03
> bNumConfigurations 0x02
>
> The second configuration is:
> bLength 0x09
> bDescriptorType 0x02
> wTotalLength 0x0027
> bNumInterfaces 0x01
> bConfigurationValue 0x02
> iConfiguration 0x00
> bmAttributes 0xc0
> bMaxPower 0x00
>
> Also the documentation for WdfUsbTargetDeviceSelectConfig() states:
> Your driver can select a device configuration by using a
> WDF_USB_DEVICE_SELECT_CONFIG_PARAMS structure to specify USB
> descriptors,
> a URB, or handles to framework USB interface objects.
> To me this certainly implies that I can select configurations other
can
> the first.
>
> - Steve -
>
> > -----Original Message-----
> > From: xxxxx@lists.osr.com [mailto:bounce-240566-
> > xxxxx@lists.osr.com] On Behalf Of Doron Holan
> > Sent: Monday, February 20, 2006 11:37 AM
> > To: Windows System Software Devs Interest List
> > Subject: RE: [ntdev] How do you select a configuration using
> > WdfUsbTargetDeviceSelectConfig()
> >
> >
> > Windows only supports devices which have *one* configuration.
That
> > configuration can have multiple *interfaces* though. To select
among
> > different interfaces, you perform the initial select config (which
> > defaults to Setting 0 unless you override) and then a
> > WdfUsbInterfaceSelectSetting on the WDFUSBINTERFACEs that you want
to
> > change.
> >
> > Yes, the end point descriptors must come after the interface
> descriptor.
> > Your descriptor set must be well formed, although during a select
> > config, KMDF uses the config descriptor reported by the device.
> >
> > D
> >
> > -----Original Message-----
> > From: xxxxx@lists.osr.com
> > [mailto:xxxxx@lists.osr.com] On Behalf Of Whitman,
Steve
> > Sent: Monday, February 20, 2006 6:35 AM
> > To: Windows System Software Devs Interest List
> > Subject: [ntdev] How do you select a configuration using
> > WdfUsbTargetDeviceSelectConfig()
> >
> > I’m trying to select another USB configuration using
> > WdfUsbTargetDeviceSelectConfig. I’ve been successful at selecting
the
> > first configuration and managed to get the 2nd configuration but
my
> > solution doesn’t seem right.
> >
> > Here is what I did to select a configuration. I used
> > WDF_USB_DEVICE_SELECT_CONFIG_PARAMS_INIT_INTERFACES_DESCRIPTORS()
to
> > build a WDF_USB_DEVICE_SELECT_CONFIG_PARAMS object and then I call
> > WdfUsbTargetDeviceSelectConfig() to select the configuration.
> >
> > The trouble I had was that my first couple of implementations at
doing
> > this failed. On my first attempt I created
> USB_CONFIGURATION_DESCRIPTOR
> > and USB_INTERFACE_DESCRIPTOR objects on the stack and then used
those
> > objects to create the WDF_USB_DEVICE_SELECT_CONFIG_PARAMS object
by
> > calling
> > WDF_USB_DEVICE_SELECT_CONFIG_PARAMS_INIT_INTERFACES_DESCRIPTORS().
I
> > found that if I set wTotalLength of the configuration descriptor
to
39
> > (the size of my configuration, interface and 3 endpoints) then the
> call
> > to WdfUsbTargetDeviceSelectConfig() failed with a status of
0xC0000001
> > (STATUS_UNSUCCESSFUL). I then tried changing wTotalLength to 18
and
> > this worked but when I called
WdfUsbInterfaceGetNumConfiguredPipes()
> it
> > returned 0 which was not correct.
> > I then changed my code so that the structures were allocated from
the
> > PagedPool and I allocated enough space for the 3 endpoints in
addition
> > to the configuration and interface descriptors. This worked and
> > WdfUsbInterfaceGetNumConfiguredPipes() returned 3 as expected.
However
> > when I called WdfUsbInterfaceGetConfiguredPipe() the pipe
information
> > returned was clearly wrong. Finally I initialized the 3
> > USB_ENDPOINT_DESCRIPTORS after the USB_INTERFACE_DESCRIPTORS and
this
> > seems to work. The function prototype and documentation for
> > WDF_USB_DEVICE_SELECT_CONFIG_PARAMS_INIT_INTERFACES_DESCRIPTORS()
> > doesn’t make any mention that the interface descriptor need to
have
> > correctly initialized endpoint descriptors allocated after them
but
> > without doing this I was unable to select the endpoints.
> >
> > My questions are:
> > 1. Is this the correct way to select a different USB configuration
or
> am
> > I missing something?
> > 2. If this is the correct method then when is it safe to free the
> memory
> > that I allocated to create the descriptors? Do I have to hold
this
> > memory until the device is removed or another configuration is
> selected?
> >
> > Thanks,
> > - Steve -
> >
> >
> >
> > —
> > Questions? First check the Kernel Driver FAQ at
> > http://www.osronline.com/article.cfm?id=256
> >
> > You are currently subscribed to ntdev as: unknown lmsubst tag
> argument:
> > ‘’
> > To unsubscribe send a blank email to
xxxxx@lists.osr.com
> >
> >
> > —
> > Questions? First check the Kernel Driver FAQ at
> > http://www.osronline.com/article.cfm?id=256
> >
> > You are currently subscribed to ntdev as: unknown lmsubst tag
> argument: ‘’
> > To unsubscribe send a blank email to
xxxxx@lists.osr.com
>
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: unknown lmsubst tag
argument:
> ‘’
> To unsubscribe send a blank email to
xxxxx@lists.osr.com
>
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: unknown lmsubst tag
argument: ‘’
> To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag
argument:
‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag
argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

> It seems to me that this function is poorly named since I use it to

select an Interface and not a Configuration.
Then you are really having an issue with the WDM naming b/c even for a
WDM driver, you need to do a select config before you use your device.
This is just a 1:1 mapping.

call WdfIoTargetStart(WdfUsbTargetPipeGetIoTarget(pDC->InterruptPipe))
and process interrupts from the device.

The pipes are created in the started state, although if you have generic
stop/start code in power down/up, then moving from the started->started
state for the first power up sequence is no big deal. Also, you should
investigate the usb pipe continuous reader support. It will handle the
problem of always having a transfer pending, all you do is provide a
callback which will be invoked with the data. This works great for
devices which stream data to the host that is not part of a transfer
from the host to the device (like a NIC would do for incoming data or an
interrupt pipe which has device status on it).

D

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Whitman, Steve
Sent: Monday, February 20, 2006 11:45 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] How do you select a configuration using
WdfUsbTargetDeviceSelectConfig()

WdfUsbTargetDeviceSelectConfig exists b/c you have to select *a*
config
in a USB driver. SelectConfig will by default select Setting #0 on
each
interface. You can customize this default behavior and specify
different Alt Settings on each interface if you like.

It seems to me that this function is poorly named since I use it to
select an Interface and not a Configuration.

You can still write a KMDF based driver and roll your own USB I/O.
This
way you still can take advantage of pnp, power, and power policy
(including selective suspend). The burden on you is to now track all
sent i/o and coordinate its cancellation/wait for completion during
power transitions. In fact you can still use KMDF for that. Just
create & open a generic WDFIOTARGET for each USB pipe you have,
allocate
your own PURB and then format the WDFREQUEST with
WdfIoTargetFormatRequestForInternalIoctlOthers(). Essentially you lose
the automatic WDFUSBPIPE creation/deletion on select config/interface
and the ability to call USB specific formatting functions, but you can
still leverage KMDF for all the hard stuff.

We will be developing a new USB device where I will be able to specify
the firmware for the device (since I’m writing it) so for that device I
will be able to use KMDF to implement the driver. Actually the sample
driver is very close to what I need. For the device that I’m currently
using (while I wait for our new hardware) I thought it might I would
investigate the possibility of replacing the existing driver but I’ll
probably hold off on that for now.

What I find interesting is that when I use the procedure I documented in
my original email then it appears that I’m able to use the USB
functionality as expected. Looking at the a USB trace shows that after
I call WdfUsbTargetDeviceSelectConfig() using the second Configuration
the host issued a SetConfiguration(2) to my device. I was then able to
call WdfIoTargetStart(WdfUsbTargetPipeGetIoTarget(pDC->InterruptPipe))
and process interrupts from the device. I haven’t done much testing and
I haven’t done anything with the other pipes yet but so far things
appear to work as I expect them to.

Thanks for you help,

  • Steve -

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Whitman, Steve
Sent: Monday, February 20, 2006 10:19 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] How do you select a configuration using
WdfUsbTargetDeviceSelectConfig()

Unfortunately the device that I’m using has multiple configurations. I
can’t use the first configuration because that is used by the device
to
perform certain functions that I don’t require. I also can’t change
the
firmware of the device.

If KMDF only supports a single configuration then it sounds like I
won’t
be able to use it for this device.

Can you explain why if KMDF doesn’t support multiple configurations
why
there is a WdfUsbTargetDeviceSelectConfig() function in the first
place?
Is this for future support of multiple configurations?
Also the documentation should be clarified on this matter. There are
many locations in the documentation where statements are made that
imply
that other configurations can be used. For example the documentation
for WDF_USB_DEVICE_SELECT_CONFIG_PARAMS states:
Types.Descriptor.ConfigurationDescriptor
If the driver sets the Type member to
WdfUsbTargetDeviceSelectConfigTypeInterfacesDescriptor, this
member
contains a driver-supplied pointer to a
USB_CONFIGURATION_DESCRIPTOR
structure that specifies a configuration descriptor. If this
pointer
is NULL, the framework uses the device’s first configuration.
This implies that if the pointer is not NULL then another
configuration
can be used.
In the “Working with USB Devices” chapter there is a subsection titled
“Selecting a Device Configuration” which also implies that I can
select
a different configuration when the EvtDevicePrepareHardware callback
is
made.

Just to be clear, you are saying that if I need to use a different
configuration other than the first configuration then I can’t use a
KMDF
based driver.

Regards,

  • Steve -

> -----Original Message-----
> From: xxxxx@lists.osr.com [mailto:bounce-240574-
> xxxxx@lists.osr.com] On Behalf Of Doron Holan
> Sent: Monday, February 20, 2006 12:43 PM
> To: Windows System Software Devs Interest List
> Subject: RE: [ntdev] How do you select a configuration using
> WdfUsbTargetDeviceSelectConfig()
>
> Windows inbox client drivers support one config, the core doesn’t
really
> care and you can do multiple configs in your own driver. I
personally
> don’t understand why you would need multiple configurations (outside
of
> differing power requirements, but you can detect that in the single
> configuration and adjust appropriately) in the first place, you can
do
> the same thing with multiple interface settings on the same config.
>
> KMDF only supports a single configuration. When the docs talk about
> specifying descriptors or a URB, it is assumed that they are from
the
> first config. Internally when you create a WDFUSBDEVICE, KMDF will
> create a WDFUSBINTERFACE for each interface on the (first) config.
>
> d
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of Whitman,
Steve
> Sent: Monday, February 20, 2006 9:31 AM
> To: Windows System Software Devs Interest List
> Subject: RE: [ntdev] How do you select a configuration using
> WdfUsbTargetDeviceSelectConfig()
>
> If Windows only supports devices with one configuration then how
have
I
> been using a device that has two configurations for the past two
years?
> The devices’ first configuration only has a control endpoint and the
> second configuration has two bulk endpoints and an interrupt
endpoint.
> Here is the Device Descriptor and the second Configuration
Descriptor
> which I retrieved from a USB analyzer trace using an existing
driver.
> bLength 0x12
> bDescriptorType 0x01
> bcdUSB 0x0110
> bDeviceClass 0xff
> bDeviceSubClass 0x00
> bDeviceProtocol 0x00
> bMaxPacketSize0 0x08
> idVendor 0xXXXX
> idProduct 0xXXXX
> iManufacturer 0x01
> iProduct 0x02
> iSerialNumber 0x03
> bNumConfigurations 0x02
>
> The second configuration is:
> bLength 0x09
> bDescriptorType 0x02
> wTotalLength 0x0027
> bNumInterfaces 0x01
> bConfigurationValue 0x02
> iConfiguration 0x00
> bmAttributes 0xc0
> bMaxPower 0x00
>
> Also the documentation for WdfUsbTargetDeviceSelectConfig() states:
> Your driver can select a device configuration by using a
> WDF_USB_DEVICE_SELECT_CONFIG_PARAMS structure to specify USB
> descriptors,
> a URB, or handles to framework USB interface objects.
> To me this certainly implies that I can select configurations other
can
> the first.
>
> - Steve -
>
> > -----Original Message-----
> > From: xxxxx@lists.osr.com [mailto:bounce-240566-
> > xxxxx@lists.osr.com] On Behalf Of Doron Holan
> > Sent: Monday, February 20, 2006 11:37 AM
> > To: Windows System Software Devs Interest List
> > Subject: RE: [ntdev] How do you select a configuration using
> > WdfUsbTargetDeviceSelectConfig()
> >
> >
> > Windows only supports devices which have *one* configuration.
That
> > configuration can have multiple *interfaces* though. To select
among
> > different interfaces, you perform the initial select config (which
> > defaults to Setting 0 unless you override) and then a
> > WdfUsbInterfaceSelectSetting on the WDFUSBINTERFACEs that you want
to
> > change.
> >
> > Yes, the end point descriptors must come after the interface
> descriptor.
> > Your descriptor set must be well formed, although during a select
> > config, KMDF uses the config descriptor reported by the device.
> >
> > D
> >
> > -----Original Message-----
> > From: xxxxx@lists.osr.com
> > [mailto:xxxxx@lists.osr.com] On Behalf Of Whitman,
Steve
> > Sent: Monday, February 20, 2006 6:35 AM
> > To: Windows System Software Devs Interest List
> > Subject: [ntdev] How do you select a configuration using
> > WdfUsbTargetDeviceSelectConfig()
> >
> > I’m trying to select another USB configuration using
> > WdfUsbTargetDeviceSelectConfig. I’ve been successful at selecting
the
> > first configuration and managed to get the 2nd configuration but
my
> > solution doesn’t seem right.
> >
> > Here is what I did to select a configuration. I used
> > WDF_USB_DEVICE_SELECT_CONFIG_PARAMS_INIT_INTERFACES_DESCRIPTORS()
to
> > build a WDF_USB_DEVICE_SELECT_CONFIG_PARAMS object and then I call
> > WdfUsbTargetDeviceSelectConfig() to select the configuration.
> >
> > The trouble I had was that my first couple of implementations at
doing
> > this failed. On my first attempt I created
> USB_CONFIGURATION_DESCRIPTOR
> > and USB_INTERFACE_DESCRIPTOR objects on the stack and then used
those
> > objects to create the WDF_USB_DEVICE_SELECT_CONFIG_PARAMS object
by
> > calling
> > WDF_USB_DEVICE_SELECT_CONFIG_PARAMS_INIT_INTERFACES_DESCRIPTORS().
I
> > found that if I set wTotalLength of the configuration descriptor
to
39
> > (the size of my configuration, interface and 3 endpoints) then the
> call
> > to WdfUsbTargetDeviceSelectConfig() failed with a status of
0xC0000001
> > (STATUS_UNSUCCESSFUL). I then tried changing wTotalLength to 18
and
> > this worked but when I called
WdfUsbInterfaceGetNumConfiguredPipes()
> it
> > returned 0 which was not correct.
> > I then changed my code so that the structures were allocated from
the
> > PagedPool and I allocated enough space for the 3 endpoints in
addition
> > to the configuration and interface descriptors. This worked and
> > WdfUsbInterfaceGetNumConfiguredPipes() returned 3 as expected.
However
> > when I called WdfUsbInterfaceGetConfiguredPipe() the pipe
information
> > returned was clearly wrong. Finally I initialized the 3
> > USB_ENDPOINT_DESCRIPTORS after the USB_INTERFACE_DESCRIPTORS and
this
> > seems to work. The function prototype and documentation for
> > WDF_USB_DEVICE_SELECT_CONFIG_PARAMS_INIT_INTERFACES_DESCRIPTORS()
> > doesn’t make any mention that the interface descriptor need to
have
> > correctly initialized endpoint descriptors allocated after them
but
> > without doing this I was unable to select the endpoints.
> >
> > My questions are:
> > 1. Is this the correct way to select a different USB configuration
or
> am
> > I missing something?
> > 2. If this is the correct method then when is it safe to free the
> memory
> > that I allocated to create the descriptors? Do I have to hold
this
> > memory until the device is removed or another configuration is
> selected?
> >
> > Thanks,
> > - Steve -
> >
> >
> >
> > —
> > Questions? First check the Kernel Driver FAQ at
> > http://www.osronline.com/article.cfm?id=256
> >
> > You are currently subscribed to ntdev as: unknown lmsubst tag
> argument:
> > ‘’
> > To unsubscribe send a blank email to
xxxxx@lists.osr.com
> >
> >
> > —
> > Questions? First check the Kernel Driver FAQ at
> > http://www.osronline.com/article.cfm?id=256
> >
> > You are currently subscribed to ntdev as: unknown lmsubst tag
> argument: ‘’
> > To unsubscribe send a blank email to
xxxxx@lists.osr.com
>
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: unknown lmsubst tag
argument:
> ‘’
> To unsubscribe send a blank email to
xxxxx@lists.osr.com
>
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: unknown lmsubst tag
argument: ‘’
> To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag
argument:
‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag
argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag argument:
‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

>

> It seems to me that this function is poorly named since I use it to
> select an Interface and not a Configuration.
Then you are really having an issue with the WDM naming b/c even for a
WDM driver, you need to do a select config before you use your device.
This is just a 1:1 mapping.

Actually I don’t think that’s true. The WDM driver allows me to select
a configuration using UsbBuildGetDescriptorRequest() and
UsbBuildSelectConfigurationRequest() allows me to select a
configuration. Since the KMDF doesn’t allow me to select a
configuration then it is not a 1:1 mapping.

  • Steve -

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Whitman, Steve
Sent: Monday, February 20, 2006 11:45 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] How do you select a configuration using
WdfUsbTargetDeviceSelectConfig()

> WdfUsbTargetDeviceSelectConfig exists b/c you have to select *a*
config
> in a USB driver. SelectConfig will by default select Setting #0 on
each
> interface. You can customize this default behavior and specify
> different Alt Settings on each interface if you like.

It seems to me that this function is poorly named since I use it to
select an Interface and not a Configuration.

> You can still write a KMDF based driver and roll your own USB I/O.
This
> way you still can take advantage of pnp, power, and power policy
> (including selective suspend). The burden on you is to now track
all
> sent i/o and coordinate its cancellation/wait for completion during
> power transitions. In fact you can still use KMDF for that. Just
> create & open a generic WDFIOTARGET for each USB pipe you have,
allocate
> your own PURB and then format the WDFREQUEST with
> WdfIoTargetFormatRequestForInternalIoctlOthers(). Essentially you
lose
> the automatic WDFUSBPIPE creation/deletion on select
config/interface
> and the ability to call USB specific formatting functions, but you
can
> still leverage KMDF for all the hard stuff.

We will be developing a new USB device where I will be able to specify
the firmware for the device (since I’m writing it) so for that device
I
will be able to use KMDF to implement the driver. Actually the sample
driver is very close to what I need. For the device that I’m
currently
using (while I wait for our new hardware) I thought it might I would
investigate the possibility of replacing the existing driver but I’ll
probably hold off on that for now.

What I find interesting is that when I use the procedure I documented
in
my original email then it appears that I’m able to use the USB
functionality as expected. Looking at the a USB trace shows that
after
I call WdfUsbTargetDeviceSelectConfig() using the second Configuration
the host issued a SetConfiguration(2) to my device. I was then able
to
call WdfIoTargetStart(WdfUsbTargetPipeGetIoTarget(pDC->InterruptPipe))
and process interrupts from the device. I haven’t done much testing
and
I haven’t done anything with the other pipes yet but so far things
appear to work as I expect them to.

Thanks for you help,

  • Steve -

>
> d
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of Whitman,
Steve
> Sent: Monday, February 20, 2006 10:19 AM
> To: Windows System Software Devs Interest List
> Subject: RE: [ntdev] How do you select a configuration using
> WdfUsbTargetDeviceSelectConfig()
>
> Unfortunately the device that I’m using has multiple configurations.
I
> can’t use the first configuration because that is used by the device
to
> perform certain functions that I don’t require. I also can’t change
the
> firmware of the device.
>
> If KMDF only supports a single configuration then it sounds like I
won’t
> be able to use it for this device.
>
> Can you explain why if KMDF doesn’t support multiple configurations
why
> there is a WdfUsbTargetDeviceSelectConfig() function in the first
place?
> Is this for future support of multiple configurations?
> Also the documentation should be clarified on this matter. There
are
> many locations in the documentation where statements are made that
imply
> that other configurations can be used. For example the
documentation
> for WDF_USB_DEVICE_SELECT_CONFIG_PARAMS states:
> Types.Descriptor.ConfigurationDescriptor
> If the driver sets the Type member to
> WdfUsbTargetDeviceSelectConfigTypeInterfacesDescriptor, this
> member
> contains a driver-supplied pointer to a
> USB_CONFIGURATION_DESCRIPTOR
> structure that specifies a configuration descriptor. If this
> pointer
> is NULL, the framework uses the device’s first configuration.
> This implies that if the pointer is not NULL then another
configuration
> can be used.
> In the “Working with USB Devices” chapter there is a subsection
titled
> “Selecting a Device Configuration” which also implies that I can
select
> a different configuration when the EvtDevicePrepareHardware callback
is
> made.
>
> Just to be clear, you are saying that if I need to use a different
> configuration other than the first configuration then I can’t use a
KMDF
> based driver.
>
> Regards,
> - Steve -
>
>
> > -----Original Message-----
> > From: xxxxx@lists.osr.com [mailto:bounce-240574-
> > xxxxx@lists.osr.com] On Behalf Of Doron Holan
> > Sent: Monday, February 20, 2006 12:43 PM
> > To: Windows System Software Devs Interest List
> > Subject: RE: [ntdev] How do you select a configuration using
> > WdfUsbTargetDeviceSelectConfig()
> >
> > Windows inbox client drivers support one config, the core doesn’t
> really
> > care and you can do multiple configs in your own driver. I
personally
> > don’t understand why you would need multiple configurations
(outside
> of
> > differing power requirements, but you can detect that in the
single
> > configuration and adjust appropriately) in the first place, you
can
do
> > the same thing with multiple interface settings on the same
config.
> >
> > KMDF only supports a single configuration. When the docs talk
about
> > specifying descriptors or a URB, it is assumed that they are from
the
> > first config. Internally when you create a WDFUSBDEVICE, KMDF
will
> > create a WDFUSBINTERFACE for each interface on the (first) config.
> >
> > d
> >
> > -----Original Message-----
> > From: xxxxx@lists.osr.com
> > [mailto:xxxxx@lists.osr.com] On Behalf Of Whitman,
Steve
> > Sent: Monday, February 20, 2006 9:31 AM
> > To: Windows System Software Devs Interest List
> > Subject: RE: [ntdev] How do you select a configuration using
> > WdfUsbTargetDeviceSelectConfig()
> >
> > If Windows only supports devices with one configuration then how
have
> I
> > been using a device that has two configurations for the past two
> years?
> > The devices’ first configuration only has a control endpoint and
the
> > second configuration has two bulk endpoints and an interrupt
endpoint.
> > Here is the Device Descriptor and the second Configuration
Descriptor
> > which I retrieved from a USB analyzer trace using an existing
driver.
> > bLength 0x12
> > bDescriptorType 0x01
> > bcdUSB 0x0110
> > bDeviceClass 0xff
> > bDeviceSubClass 0x00
> > bDeviceProtocol 0x00
> > bMaxPacketSize0 0x08
> > idVendor 0xXXXX
> > idProduct 0xXXXX
> > iManufacturer 0x01
> > iProduct 0x02
> > iSerialNumber 0x03
> > bNumConfigurations 0x02
> >
> > The second configuration is:
> > bLength 0x09
> > bDescriptorType 0x02
> > wTotalLength 0x0027
> > bNumInterfaces 0x01
> > bConfigurationValue 0x02
> > iConfiguration 0x00
> > bmAttributes 0xc0
> > bMaxPower 0x00
> >
> > Also the documentation for WdfUsbTargetDeviceSelectConfig()
states:
> > Your driver can select a device configuration by using a
> > WDF_USB_DEVICE_SELECT_CONFIG_PARAMS structure to specify USB
> > descriptors,
> > a URB, or handles to framework USB interface objects.
> > To me this certainly implies that I can select configurations
other
> can
> > the first.
> >
> > - Steve -
> >
> > > -----Original Message-----
> > > From: xxxxx@lists.osr.com [mailto:bounce-240566-
> > > xxxxx@lists.osr.com] On Behalf Of Doron Holan
> > > Sent: Monday, February 20, 2006 11:37 AM
> > > To: Windows System Software Devs Interest List
> > > Subject: RE: [ntdev] How do you select a configuration using
> > > WdfUsbTargetDeviceSelectConfig()
> > >
> > >
> > > Windows only supports devices which have *one* configuration.
That
> > > configuration can have multiple *interfaces* though. To select
> among
> > > different interfaces, you perform the initial select config
(which
> > > defaults to Setting 0 unless you override) and then a
> > > WdfUsbInterfaceSelectSetting on the WDFUSBINTERFACEs that you
want
> to
> > > change.
> > >
> > > Yes, the end point descriptors must come after the interface
> > descriptor.
> > > Your descriptor set must be well formed, although during a
select
> > > config, KMDF uses the config descriptor reported by the device.
> > >
> > > D
> > >
> > > -----Original Message-----
> > > From: xxxxx@lists.osr.com
> > > [mailto:xxxxx@lists.osr.com] On Behalf Of Whitman,
> Steve
> > > Sent: Monday, February 20, 2006 6:35 AM
> > > To: Windows System Software Devs Interest List
> > > Subject: [ntdev] How do you select a configuration using
> > > WdfUsbTargetDeviceSelectConfig()
> > >
> > > I’m trying to select another USB configuration using
> > > WdfUsbTargetDeviceSelectConfig. I’ve been successful at
selecting
> the
> > > first configuration and managed to get the 2nd configuration but
my
> > > solution doesn’t seem right.
> > >
> > > Here is what I did to select a configuration. I used
> > >
WDF_USB_DEVICE_SELECT_CONFIG_PARAMS_INIT_INTERFACES_DESCRIPTORS()
to
> > > build a WDF_USB_DEVICE_SELECT_CONFIG_PARAMS object and then I
call
> > > WdfUsbTargetDeviceSelectConfig() to select the configuration.
> > >
> > > The trouble I had was that my first couple of implementations at
> doing
> > > this failed. On my first attempt I created
> > USB_CONFIGURATION_DESCRIPTOR
> > > and USB_INTERFACE_DESCRIPTOR objects on the stack and then used
> those
> > > objects to create the WDF_USB_DEVICE_SELECT_CONFIG_PARAMS object
by
> > > calling
> > >
WDF_USB_DEVICE_SELECT_CONFIG_PARAMS_INIT_INTERFACES_DESCRIPTORS().
> I
> > > found that if I set wTotalLength of the configuration descriptor
to
> 39
> > > (the size of my configuration, interface and 3 endpoints) then
the
> > call
> > > to WdfUsbTargetDeviceSelectConfig() failed with a status of
> 0xC0000001
> > > (STATUS_UNSUCCESSFUL). I then tried changing wTotalLength to 18
and
> > > this worked but when I called
WdfUsbInterfaceGetNumConfiguredPipes()
> > it
> > > returned 0 which was not correct.
> > > I then changed my code so that the structures were allocated
from
> the
> > > PagedPool and I allocated enough space for the 3 endpoints in
> addition
> > > to the configuration and interface descriptors. This worked and
> > > WdfUsbInterfaceGetNumConfiguredPipes() returned 3 as expected.
> However
> > > when I called WdfUsbInterfaceGetConfiguredPipe() the pipe
> information
> > > returned was clearly wrong. Finally I initialized the 3
> > > USB_ENDPOINT_DESCRIPTORS after the USB_INTERFACE_DESCRIPTORS and
> this
> > > seems to work. The function prototype and documentation for
> > >
WDF_USB_DEVICE_SELECT_CONFIG_PARAMS_INIT_INTERFACES_DESCRIPTORS()
> > > doesn’t make any mention that the interface descriptor need to
have
> > > correctly initialized endpoint descriptors allocated after them
but
> > > without doing this I was unable to select the endpoints.
> > >
> > > My questions are:
> > > 1. Is this the correct way to select a different USB
configuration
> or
> > am
> > > I missing something?
> > > 2. If this is the correct method then when is it safe to free
the
> > memory
> > > that I allocated to create the descriptors? Do I have to hold
this
> > > memory until the device is removed or another configuration is
> > selected?
> > >
> > > Thanks,
> > > - Steve -
> > >
> > >
> > >
> > > —
> > > Questions? First check the Kernel Driver FAQ at
> > > http://www.osronline.com/article.cfm?id=256
> > >
> > > You are currently subscribed to ntdev as: unknown lmsubst tag
> > argument:
> > > ‘’
> > > To unsubscribe send a blank email to
> xxxxx@lists.osr.com
> > >
> > >
> > > —
> > > Questions? First check the Kernel Driver FAQ at
> > > http://www.osronline.com/article.cfm?id=256
> > >
> > > You are currently subscribed to ntdev as: unknown lmsubst tag
> > argument: ‘’
> > > To unsubscribe send a blank email to
xxxxx@lists.osr.com
> >
> >
> > —
> > Questions? First check the Kernel Driver FAQ at
> > http://www.osronline.com/article.cfm?id=256
> >
> > You are currently subscribed to ntdev as: unknown lmsubst tag
> argument:
> > ‘’
> > To unsubscribe send a blank email to
xxxxx@lists.osr.com
> >
> >
> > —
> > Questions? First check the Kernel Driver FAQ at
> > http://www.osronline.com/article.cfm?id=256
> >
> > You are currently subscribed to ntdev as: unknown lmsubst tag
> argument: ‘’
> > To unsubscribe send a blank email to
xxxxx@lists.osr.com
>
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: unknown lmsubst tag
argument:
> ‘’
> To unsubscribe send a blank email to
xxxxx@lists.osr.com
>
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: unknown lmsubst tag
argument: ‘’
> To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag
argument:
‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag
argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

There is a bit of a disconnect here. I am talking about the select
config command being sent to the device, not the src descriptor which is
used to create that command. You are referring to selecting the src for
the config request.

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Whitman, Steve
Sent: Monday, February 20, 2006 1:06 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] How do you select a configuration using
WdfUsbTargetDeviceSelectConfig()

> It seems to me that this function is poorly named since I use it to
> select an Interface and not a Configuration.
Then you are really having an issue with the WDM naming b/c even for a
WDM driver, you need to do a select config before you use your device.
This is just a 1:1 mapping.

Actually I don’t think that’s true. The WDM driver allows me to select
a configuration using UsbBuildGetDescriptorRequest() and
UsbBuildSelectConfigurationRequest() allows me to select a
configuration. Since the KMDF doesn’t allow me to select a
configuration then it is not a 1:1 mapping.

  • Steve -

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Whitman, Steve
Sent: Monday, February 20, 2006 11:45 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] How do you select a configuration using
WdfUsbTargetDeviceSelectConfig()

> WdfUsbTargetDeviceSelectConfig exists b/c you have to select *a*
config
> in a USB driver. SelectConfig will by default select Setting #0 on
each
> interface. You can customize this default behavior and specify
> different Alt Settings on each interface if you like.

It seems to me that this function is poorly named since I use it to
select an Interface and not a Configuration.

> You can still write a KMDF based driver and roll your own USB I/O.
This
> way you still can take advantage of pnp, power, and power policy
> (including selective suspend). The burden on you is to now track
all
> sent i/o and coordinate its cancellation/wait for completion during
> power transitions. In fact you can still use KMDF for that. Just
> create & open a generic WDFIOTARGET for each USB pipe you have,
allocate
> your own PURB and then format the WDFREQUEST with
> WdfIoTargetFormatRequestForInternalIoctlOthers(). Essentially you
lose
> the automatic WDFUSBPIPE creation/deletion on select
config/interface
> and the ability to call USB specific formatting functions, but you
can
> still leverage KMDF for all the hard stuff.

We will be developing a new USB device where I will be able to specify
the firmware for the device (since I’m writing it) so for that device
I
will be able to use KMDF to implement the driver. Actually the sample
driver is very close to what I need. For the device that I’m
currently
using (while I wait for our new hardware) I thought it might I would
investigate the possibility of replacing the existing driver but I’ll
probably hold off on that for now.

What I find interesting is that when I use the procedure I documented
in
my original email then it appears that I’m able to use the USB
functionality as expected. Looking at the a USB trace shows that
after
I call WdfUsbTargetDeviceSelectConfig() using the second Configuration
the host issued a SetConfiguration(2) to my device. I was then able
to
call WdfIoTargetStart(WdfUsbTargetPipeGetIoTarget(pDC->InterruptPipe))
and process interrupts from the device. I haven’t done much testing
and
I haven’t done anything with the other pipes yet but so far things
appear to work as I expect them to.

Thanks for you help,

  • Steve -

>
> d
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of Whitman,
Steve
> Sent: Monday, February 20, 2006 10:19 AM
> To: Windows System Software Devs Interest List
> Subject: RE: [ntdev] How do you select a configuration using
> WdfUsbTargetDeviceSelectConfig()
>
> Unfortunately the device that I’m using has multiple configurations.
I
> can’t use the first configuration because that is used by the device
to
> perform certain functions that I don’t require. I also can’t change
the
> firmware of the device.
>
> If KMDF only supports a single configuration then it sounds like I
won’t
> be able to use it for this device.
>
> Can you explain why if KMDF doesn’t support multiple configurations
why
> there is a WdfUsbTargetDeviceSelectConfig() function in the first
place?
> Is this for future support of multiple configurations?
> Also the documentation should be clarified on this matter. There
are
> many locations in the documentation where statements are made that
imply
> that other configurations can be used. For example the
documentation
> for WDF_USB_DEVICE_SELECT_CONFIG_PARAMS states:
> Types.Descriptor.ConfigurationDescriptor
> If the driver sets the Type member to
> WdfUsbTargetDeviceSelectConfigTypeInterfacesDescriptor, this
> member
> contains a driver-supplied pointer to a
> USB_CONFIGURATION_DESCRIPTOR
> structure that specifies a configuration descriptor. If this
> pointer
> is NULL, the framework uses the device’s first configuration.
> This implies that if the pointer is not NULL then another
configuration
> can be used.
> In the “Working with USB Devices” chapter there is a subsection
titled
> “Selecting a Device Configuration” which also implies that I can
select
> a different configuration when the EvtDevicePrepareHardware callback
is
> made.
>
> Just to be clear, you are saying that if I need to use a different
> configuration other than the first configuration then I can’t use a
KMDF
> based driver.
>
> Regards,
> - Steve -
>
>
> > -----Original Message-----
> > From: xxxxx@lists.osr.com [mailto:bounce-240574-
> > xxxxx@lists.osr.com] On Behalf Of Doron Holan
> > Sent: Monday, February 20, 2006 12:43 PM
> > To: Windows System Software Devs Interest List
> > Subject: RE: [ntdev] How do you select a configuration using
> > WdfUsbTargetDeviceSelectConfig()
> >
> > Windows inbox client drivers support one config, the core doesn’t
> really
> > care and you can do multiple configs in your own driver. I
personally
> > don’t understand why you would need multiple configurations
(outside
> of
> > differing power requirements, but you can detect that in the
single
> > configuration and adjust appropriately) in the first place, you
can
do
> > the same thing with multiple interface settings on the same
config.
> >
> > KMDF only supports a single configuration. When the docs talk
about
> > specifying descriptors or a URB, it is assumed that they are from
the
> > first config. Internally when you create a WDFUSBDEVICE, KMDF
will
> > create a WDFUSBINTERFACE for each interface on the (first) config.
> >
> > d
> >
> > -----Original Message-----
> > From: xxxxx@lists.osr.com
> > [mailto:xxxxx@lists.osr.com] On Behalf Of Whitman,
Steve
> > Sent: Monday, February 20, 2006 9:31 AM
> > To: Windows System Software Devs Interest List
> > Subject: RE: [ntdev] How do you select a configuration using
> > WdfUsbTargetDeviceSelectConfig()
> >
> > If Windows only supports devices with one configuration then how
have
> I
> > been using a device that has two configurations for the past two
> years?
> > The devices’ first configuration only has a control endpoint and
the
> > second configuration has two bulk endpoints and an interrupt
endpoint.
> > Here is the Device Descriptor and the second Configuration
Descriptor
> > which I retrieved from a USB analyzer trace using an existing
driver.
> > bLength 0x12
> > bDescriptorType 0x01
> > bcdUSB 0x0110
> > bDeviceClass 0xff
> > bDeviceSubClass 0x00
> > bDeviceProtocol 0x00
> > bMaxPacketSize0 0x08
> > idVendor 0xXXXX
> > idProduct 0xXXXX
> > iManufacturer 0x01
> > iProduct 0x02
> > iSerialNumber 0x03
> > bNumConfigurations 0x02
> >
> > The second configuration is:
> > bLength 0x09
> > bDescriptorType 0x02
> > wTotalLength 0x0027
> > bNumInterfaces 0x01
> > bConfigurationValue 0x02
> > iConfiguration 0x00
> > bmAttributes 0xc0
> > bMaxPower 0x00
> >
> > Also the documentation for WdfUsbTargetDeviceSelectConfig()
states:
> > Your driver can select a device configuration by using a
> > WDF_USB_DEVICE_SELECT_CONFIG_PARAMS structure to specify USB
> > descriptors,
> > a URB, or handles to framework USB interface objects.
> > To me this certainly implies that I can select configurations
other
> can
> > the first.
> >
> > - Steve -
> >
> > > -----Original Message-----
> > > From: xxxxx@lists.osr.com [mailto:bounce-240566-
> > > xxxxx@lists.osr.com] On Behalf Of Doron Holan
> > > Sent: Monday, February 20, 2006 11:37 AM
> > > To: Windows System Software Devs Interest List
> > > Subject: RE: [ntdev] How do you select a configuration using
> > > WdfUsbTargetDeviceSelectConfig()
> > >
> > >
> > > Windows only supports devices which have *one* configuration.
That
> > > configuration can have multiple *interfaces* though. To select
> among
> > > different interfaces, you perform the initial select config
(which
> > > defaults to Setting 0 unless you override) and then a
> > > WdfUsbInterfaceSelectSetting on the WDFUSBINTERFACEs that you
want
> to
> > > change.
> > >
> > > Yes, the end point descriptors must come after the interface
> > descriptor.
> > > Your descriptor set must be well formed, although during a
select
> > > config, KMDF uses the config descriptor reported by the device.
> > >
> > > D
> > >
> > > -----Original Message-----
> > > From: xxxxx@lists.osr.com
> > > [mailto:xxxxx@lists.osr.com] On Behalf Of Whitman,
> Steve
> > > Sent: Monday, February 20, 2006 6:35 AM
> > > To: Windows System Software Devs Interest List
> > > Subject: [ntdev] How do you select a configuration using
> > > WdfUsbTargetDeviceSelectConfig()
> > >
> > > I’m trying to select another USB configuration using
> > > WdfUsbTargetDeviceSelectConfig. I’ve been successful at
selecting
> the
> > > first configuration and managed to get the 2nd configuration but
my
> > > solution doesn’t seem right.
> > >
> > > Here is what I did to select a configuration. I used
> > >
WDF_USB_DEVICE_SELECT_CONFIG_PARAMS_INIT_INTERFACES_DESCRIPTORS()
to
> > > build a WDF_USB_DEVICE_SELECT_CONFIG_PARAMS object and then I
call
> > > WdfUsbTargetDeviceSelectConfig() to select the configuration.
> > >
> > > The trouble I had was that my first couple of implementations at
> doing
> > > this failed. On my first attempt I created
> > USB_CONFIGURATION_DESCRIPTOR
> > > and USB_INTERFACE_DESCRIPTOR objects on the stack and then used
> those
> > > objects to create the WDF_USB_DEVICE_SELECT_CONFIG_PARAMS object
by
> > > calling
> > >
WDF_USB_DEVICE_SELECT_CONFIG_PARAMS_INIT_INTERFACES_DESCRIPTORS().
> I
> > > found that if I set wTotalLength of the configuration descriptor
to
> 39
> > > (the size of my configuration, interface and 3 endpoints) then
the
> > call
> > > to WdfUsbTargetDeviceSelectConfig() failed with a status of
> 0xC0000001
> > > (STATUS_UNSUCCESSFUL). I then tried changing wTotalLength to 18
and
> > > this worked but when I called
WdfUsbInterfaceGetNumConfiguredPipes()
> > it
> > > returned 0 which was not correct.
> > > I then changed my code so that the structures were allocated
from
> the
> > > PagedPool and I allocated enough space for the 3 endpoints in
> addition
> > > to the configuration and interface descriptors. This worked and
> > > WdfUsbInterfaceGetNumConfiguredPipes() returned 3 as expected.
> However
> > > when I called WdfUsbInterfaceGetConfiguredPipe() the pipe
> information
> > > returned was clearly wrong. Finally I initialized the 3
> > > USB_ENDPOINT_DESCRIPTORS after the USB_INTERFACE_DESCRIPTORS and
> this
> > > seems to work. The function prototype and documentation for
> > >
WDF_USB_DEVICE_SELECT_CONFIG_PARAMS_INIT_INTERFACES_DESCRIPTORS()
> > > doesn’t make any mention that the interface descriptor need to
have
> > > correctly initialized endpoint descriptors allocated after them
but
> > > without doing this I was unable to select the endpoints.
> > >
> > > My questions are:
> > > 1. Is this the correct way to select a different USB
configuration
> or
> > am
> > > I missing something?
> > > 2. If this is the correct method then when is it safe to free
the
> > memory
> > > that I allocated to create the descriptors? Do I have to hold
this
> > > memory until the device is removed or another configuration is
> > selected?
> > >
> > > Thanks,
> > > - Steve -
> > >
> > >
> > >
> > > —
> > > Questions? First check the Kernel Driver FAQ at
> > > http://www.osronline.com/article.cfm?id=256
> > >
> > > You are currently subscribed to ntdev as: unknown lmsubst tag
> > argument:
> > > ‘’
> > > To unsubscribe send a blank email to
> xxxxx@lists.osr.com
> > >
> > >
> > > —
> > > Questions? First check the Kernel Driver FAQ at
> > > http://www.osronline.com/article.cfm?id=256
> > >
> > > You are currently subscribed to ntdev as: unknown lmsubst tag
> > argument: ‘’
> > > To unsubscribe send a blank email to
xxxxx@lists.osr.com
> >
> >
> > —
> > Questions? First check the Kernel Driver FAQ at
> > http://www.osronline.com/article.cfm?id=256
> >
> > You are currently subscribed to ntdev as: unknown lmsubst tag
> argument:
> > ‘’
> > To unsubscribe send a blank email to
xxxxx@lists.osr.com
> >
> >
> > —
> > Questions? First check the Kernel Driver FAQ at
> > http://www.osronline.com/article.cfm?id=256
> >
> > You are currently subscribed to ntdev as: unknown lmsubst tag
> argument: ‘’
> > To unsubscribe send a blank email to
xxxxx@lists.osr.com
>
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: unknown lmsubst tag
argument:
> ‘’
> To unsubscribe send a blank email to
xxxxx@lists.osr.com
>
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: unknown lmsubst tag
argument: ‘’
> To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag
argument:
‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag
argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag argument:
‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com