[USBPORT] Implement interface setting in USBPORT_OpenInterface.
authorThomas Faber <thomas.faber@reactos.org>
Wed, 6 Mar 2019 08:59:41 +0000 (09:59 +0100)
committerThomas Faber <thomas.faber@reactos.org>
Mon, 11 Mar 2019 07:54:01 +0000 (08:54 +0100)
drivers/usb/usbport/device.c

index 8676571..dbabb31 100644 (file)
@@ -249,7 +249,7 @@ USBPORT_OpenInterface(IN PURB Urb,
                       IN PUSBPORT_CONFIGURATION_HANDLE ConfigHandle,
                       IN PUSBD_INTERFACE_INFORMATION InterfaceInfo,
                       IN OUT PUSBPORT_INTERFACE_HANDLE *iHandle,
-                      IN BOOLEAN IsSetInterface)
+                      IN BOOLEAN SendSetInterface)
 {
     PUSB_INTERFACE_DESCRIPTOR InterfaceDescriptor;
     PUSBPORT_INTERFACE_HANDLE InterfaceHandle = NULL;
@@ -259,6 +259,7 @@ USBPORT_OpenInterface(IN PURB Urb,
     BOOLEAN HasAlternates;
     ULONG NumEndpoints;
     SIZE_T Length;
+    USB_DEFAULT_PIPE_SETUP_PACKET SetupPacket;
     SIZE_T HandleLength;
     BOOLEAN IsAllocated = FALSE;
     USHORT MaxPacketSize;
@@ -279,9 +280,29 @@ USBPORT_OpenInterface(IN PURB Urb,
     Length = FIELD_OFFSET(USBD_INTERFACE_INFORMATION, Pipes) +
              NumEndpoints * sizeof(USBD_PIPE_INFORMATION);
 
-    if (HasAlternates && IsSetInterface)
+    if (HasAlternates && SendSetInterface)
     {
-        DPRINT1("USBPORT_OpenInterface: InterfaceInfo->AlternateSetting && IsSetInterface !\n");
+        RtlZeroMemory(&SetupPacket, sizeof(SetupPacket));
+
+        SetupPacket.bmRequestType.Dir = BMREQUEST_HOST_TO_DEVICE;
+        SetupPacket.bmRequestType.Type = BMREQUEST_STANDARD;
+        SetupPacket.bmRequestType.Recipient = BMREQUEST_TO_INTERFACE;
+        SetupPacket.bRequest = USB_REQUEST_SET_INTERFACE;
+        SetupPacket.wValue.W = InterfaceInfo->AlternateSetting;
+        SetupPacket.wIndex.W = InterfaceInfo->InterfaceNumber;
+        SetupPacket.wLength = 0;
+
+        USBPORT_SendSetupPacket(DeviceHandle,
+                                FdoDevice,
+                                &SetupPacket,
+                                NULL,
+                                0,
+                                NULL,
+                                &USBDStatus);
+        if (!USBD_SUCCESS(USBDStatus))
+        {
+            goto Exit;
+        }
     }
 
     if (*iHandle)
@@ -1533,7 +1554,7 @@ USBPORT_HandleSelectInterface(IN PDEVICE_OBJECT FdoDevice,
                                        ConfigurationHandle,
                                        Interface,
                                        &iHandle,
-                                       1);
+                                       TRUE);
 
     if (USBDStatus)
     {