First, this
WDF_USB_DEVICE_SELECT_CONFIG_PARAMS_INIT_MULTIPLE_INTERFACES( ¶ms,
numInterfaces, NULL);
Should be this since you are not providing an array of pairs (if you
look at the header for the implementation of this INIT function, you
will see what is going on)
WDF_USB_DEVICE_SELECT_CONFIG_PARAMS_INIT_MULTIPLE_INTERFACES( ¶ms,
0, NULL);
-
The array of pairs is to allow you to specify which alternate
setting index you want to use for each interface. If you pass in NULL,
then alt setting 0 will be used for each interface. If all of your
interfaces only have one setting, why are you even using multiple
interfaces? You typically use multiple interfaces when at least one of
the interfaces can change bandwidth (i.e. isoch endpoints) or as
specified by a usb class spec like CDC
-
In the multiple interface case, params.Types.SingleInterface.*
is not defined. The field name should give you a very large clue here,
SingleInterface. Instead, in the multiple interface case you need to
look at a different part of the structure, the docs for
WDF_USB_DEVICE_SELECT_CONFIG_PARAMS_INIT_MULTIPLE_INTERFACES
(http://msdn2.microsoft.com/en-us/library/aa492481.aspx) tell you this,
all you need to do is read them. Look at
params.Types.MultipleInterface.NumberOfConfiguredInterfaces. since you
did not provide a pairs array, the Pairs field will be NULL.
Since you did not pass a pairs array, you must now iterate over each of
the interfaces (using WdfUsbTargetDeviceGetInterface). For each
WDFUSBINTERFACE, get the number of configured endpoints
(WdfUsbInterfaceGetNumConfiguredPipes) and then process each endpoint.
Instead of going through different code paths for a single or multiple
interface device, you can always use the multiple interface path for
both. The multiple interface init will work on a single interface
device, the only difference between a multiple and single inint is that
for a single interface device we return to you the WDFUSBINTERFACE
handle in the config structure
- Only you can answer that. You have to know how to handle each
interface and if you need to select alternate settings for any of them.
Remember that when you select a different alt setting, the current set
of endpoints (WDFUSBPIPE handles) get destroyed so you must not be
currently performing any i/o on the (soon to be) old handles.
d
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Shreshth Luthra
Sent: Tuesday, July 10, 2007 4:31 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] USB Multiple Interfaces using KMDF
Hi,
I am new to USB Drivers.
I am having a Driver, which works fine with single interfaces USB
Devices.
For single interface USB, i am using
WDF_USB_DEVICE_SELECT_CONFIG_PARAMS_INIT_SINGLE_INTERFACE in it followed
by a call to API WdfUsbTargetDeviceSelectConfig.
Link: download.microsoft.com/download/9/
c/5/9c5b2167-8017-4bae-9fde-d599bac8184a/USB_WDF.doc
It is working absolutely fine for me.
Now when I try to do for a composite USB Device, I am facing certain
issues.
The code looks something like:
numInterfaces =
WdfUsbTargetDeviceGetNumInterfaces(pDeviceContext->WdfUsbTargetDevice);
if (numInterfaces == 1)
WDF_USB_DEVICE_SELECT_CONFIG_PARAMS_INIT_SINGLE_INTERFACE(¶ms);
else
WDF_USB_DEVICE_SELECT_CONFIG_PARAMS_INIT_MULTIPLE_INTERFACES( ¶ms,
numInterfaces, NULL);
status = WdfUsbTargetDeviceSelectConfig(
pDeviceContext->WdfUsbTargetDevice, NULL, ¶ms);
if (NT_SUCCESS(status) &&
WdfUsbTargetDeviceGetNumInterfaces(pDeviceContext->WdfUsbTargetDevice) >
0)
{
pDeviceContext->UsbInterface =
params.Types.SingleInterface.ConfiguredUsbInterface;
pDeviceContext->NumberConfiguredPipes =
params.Types.SingleInterface.NumberConfiguredPipes;
}
Though, this code is not working right now, but I do have some queries
in mind.
-
Since in my case, there is no concept of alternate pairs (as per my
understanding), is it fine to have WDF_USB_INTERFACE_SETTING_PAIR
parameter in
WDF_USB_DEVICE_SELECT_CONFIG_PARAMS_INIT_MULTIPLE_INTERFACES as NULL.
-
In case WdfUsbTargetDeviceSelectConfig runs fine, what will be the
values of pDeviceContext->UsbInterface and
pDeviceContext->NumberConfiguredPipes in case of Composite device
(Multiple interfaces case)?
-
In case the above things are done correctly, is there anything else
as well which I need to take care of, for the sake of completeness.
The above code is somehow not working for me. Please help me resolve it.
Regards,
Shreshth
— Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256 To unsubscribe, visit the
List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer