[PATCH 2/6] wineusb.sys: Partially implement URB_FUNCTION_SELECT_CONFIGURATION.

Zebediah Figura z.figura12 at gmail.com
Fri Apr 17 18:03:05 CDT 2020


Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
 dlls/wineusb.sys/wineusb.c | 39 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/dlls/wineusb.sys/wineusb.c b/dlls/wineusb.sys/wineusb.c
index ed82bd3a13..2f436c1bd7 100644
--- a/dlls/wineusb.sys/wineusb.c
+++ b/dlls/wineusb.sys/wineusb.c
@@ -460,6 +460,25 @@ static void queue_irp(struct usb_device *device, IRP *irp, struct libusb_transfe
     LeaveCriticalSection(&wineusb_cs);
 }
 
+struct pipe
+{
+    unsigned char endpoint;
+    unsigned char type;
+};
+
+static HANDLE make_pipe_handle(unsigned char endpoint, USBD_PIPE_TYPE type)
+{
+    union
+    {
+        struct pipe pipe;
+        HANDLE handle;
+    } u;
+
+    u.pipe.endpoint = endpoint;
+    u.pipe.type = type;
+    return u.handle;
+}
+
 static NTSTATUS usb_submit_urb(struct usb_device *device, IRP *irp)
 {
     URB *urb = IoGetCurrentIrpStackLocation(irp)->Parameters.Others.Argument1;
@@ -501,6 +520,26 @@ static NTSTATUS usb_submit_urb(struct usb_device *device, IRP *irp)
             return STATUS_PENDING;
         }
 
+        case URB_FUNCTION_SELECT_CONFIGURATION:
+        {
+            struct _URB_SELECT_CONFIGURATION *req = &urb->UrbSelectConfiguration;
+            ULONG i;
+
+            /* FIXME: In theory, we'd call libusb_set_configuration() here, but
+             * the CASIO FX-9750GII (which has only one configuration) goes into
+             * an error state if it receives a SET_CONFIGURATION request. Maybe
+             * we should skip setting that if and only if the configuration is
+             * already active? */
+
+            for (i = 0; i < req->Interface.NumberOfPipes; ++i)
+            {
+                USBD_PIPE_INFORMATION *pipe = &req->Interface.Pipes[i];
+                pipe->PipeHandle = make_pipe_handle(pipe->EndpointAddress, pipe->PipeType);
+            }
+
+            return STATUS_SUCCESS;
+        }
+
         default:
             FIXME("Unhandled function %#x.\n", urb->UrbHeader.Function);
     }
-- 
2.26.0




More information about the wine-devel mailing list