How windows KMDF Driver select different configuration

Hi EveryOne:

As we know, windows KMDF driver seems that it only can select the default configure setting. But when I look for the related material, I find that if I use USBD_SelectConfigUrbAllocateAndBuild to construct URB and use WdfUsbTargetDeviceSelectConfig with this URB. it shows that I can obtain the right pipe handle. But now when I implement this method, I can't find any bulk data transfer by capturing usb sniffer. So I want to know which step is wrong. (PS: before setting new configure, I use WdfUsbTargetDeviceSelectConfig with WDF_USB_DEVICE_SELECT_CONFIG_PARAMS_INIT_DECONFIG to deselect configure setting).
Thank you for your appreciation.

PS: in this case, I hope the I had better not implement USB composite device to let upper level driver to determine configure setting.

You can certainly select another configuration. That’s done by many devices. However, after you do so, the existing device drops off of the wire and re-enumerates. The device object you had been holding goes dormant, so your driver needs to unload.

This is sensible, because the new configuration has an entirely new set of interfaces and probably needs a different set of drivers.

1 Like

hi @Tim_Roberts
Thank you for your reply. Does it mean that the current driver needs to send vendor command to notify Firmware and let Firmware rerun enumeration. Please help confirm it.

Well, the firmware is going to get notified when it receives the SELECT_CONFIGURATION command, right? It drops off, and the host controller controls the re-enumeration. Vendor commands aren’t needed.

1 Like

Hi @Tim_Roberts
Thank you for your reply. I want to summarize the test step.
private driver detect the default configure is not as we expected ==> private use USBD_SelectConfigUrbAllocateAndBuild to set new configure ==> private driver return directly, at the same time, the firmware drops off and on ==> private driver use WdfUsbTargetDeviceRetrieveConfigDescriptor to get the appropriate configure descriptor.
Am I right?

As long as you realize your driver will be unloaded when the firmware drops off. When the device enumerates again, your driver will be loaded again and THAT’S where you check the current configuration.

Hi @Tim_Roberts
OK I see. Thank you.