usbhub.sys: Add support for URB_FUNCTION_CLASS_*.
authorAlexander Morozov <amorozov@etersoft.ru>
Fri, 5 Jun 2009 09:00:07 +0000 (13:00 +0400)
committerAlexander Morozov <amorozov@etersoft.ru>
Tue, 9 Mar 2010 14:14:37 +0000 (17:14 +0300)
dlls/usbhub.sys/usbhub.c

index f83bf04b186db82ed48e8056856d29a02a036e78..ba7780007d8e74a8442198f25016873552a238ce 100644 (file)
@@ -280,6 +280,9 @@ static NTSTATUS WINAPI usbhub_internal_ioctl( DEVICE_OBJECT *device, IRP *irp )
         case URB_FUNCTION_VENDOR_DEVICE:
         case URB_FUNCTION_VENDOR_INTERFACE:
         case URB_FUNCTION_VENDOR_ENDPOINT:
+        case URB_FUNCTION_CLASS_DEVICE:
+        case URB_FUNCTION_CLASS_INTERFACE:
+        case URB_FUNCTION_CLASS_ENDPOINT:
             {
                 libusb_device_handle *husb;
                 struct _URB_CONTROL_VENDOR_OR_CLASS_REQUEST *request =
@@ -287,7 +290,7 @@ static NTSTATUS WINAPI usbhub_internal_ioctl( DEVICE_OBJECT *device, IRP *irp )
                 unsigned char *req_buf = request->TransferBuffer;
                 ULONG size = request->TransferBufferLength;
 
-                TRACE( "URB_FUNCTION_VENDOR_*\n" );
+                TRACE( "URB_FUNCTION_{VENDOR,CLASS}_*\n" );
 
                 if (req_buf == NULL && request->TransferBufferMDL != NULL)
                     req_buf = request->TransferBufferMDL->MappedSystemVa;
@@ -298,14 +301,19 @@ static NTSTATUS WINAPI usbhub_internal_ioctl( DEVICE_OBJECT *device, IRP *irp )
                 }
                 if (!libusb_open( inst->dev, &husb ))
                 {
-                    UCHAR req_type = request->RequestTypeReservedBits | (2 << 5);
+                    UCHAR req_type = request->RequestTypeReservedBits;
                     unsigned char *buf;
                     int ret;
 
-                    if (urb->u.UrbHeader.Function == URB_FUNCTION_VENDOR_INTERFACE)
-                        req_type |= 1;
-                    else if (urb->u.UrbHeader.Function == URB_FUNCTION_VENDOR_ENDPOINT)
-                        req_type |= 2;
+                    switch (urb->u.UrbHeader.Function)
+                    {
+                    case URB_FUNCTION_VENDOR_DEVICE:    req_type |= 0x40; break;
+                    case URB_FUNCTION_VENDOR_INTERFACE: req_type |= 0x41; break;
+                    case URB_FUNCTION_VENDOR_ENDPOINT:  req_type |= 0x42; break;
+                    case URB_FUNCTION_CLASS_DEVICE:     req_type |= 0x20; break;
+                    case URB_FUNCTION_CLASS_INTERFACE:  req_type |= 0x21; break;
+                    case URB_FUNCTION_CLASS_ENDPOINT:   req_type |= 0x22; break;
+                    }
                     buf = HeapAlloc( GetProcessHeap(), 0, size );
                     if (buf != NULL)
                     {
@@ -541,6 +549,9 @@ static NTSTATUS WINAPI usbhub_internal_ioctl( DEVICE_OBJECT *device, IRP *irp )
         case URB_FUNCTION_VENDOR_DEVICE:
         case URB_FUNCTION_VENDOR_INTERFACE:
         case URB_FUNCTION_VENDOR_ENDPOINT:
+        case URB_FUNCTION_CLASS_DEVICE:
+        case URB_FUNCTION_CLASS_INTERFACE:
+        case URB_FUNCTION_CLASS_ENDPOINT:
             {
                 usb_dev_handle *husb;
                 struct _URB_CONTROL_VENDOR_OR_CLASS_REQUEST *request =
@@ -548,7 +559,7 @@ static NTSTATUS WINAPI usbhub_internal_ioctl( DEVICE_OBJECT *device, IRP *irp )
                 unsigned char *req_buf = request->TransferBuffer;
                 ULONG size = request->TransferBufferLength;
 
-                TRACE( "URB_FUNCTION_VENDOR_*\n" );
+                TRACE( "URB_FUNCTION_{VENDOR,CLASS}_*\n" );
 
                 if (req_buf == NULL && request->TransferBufferMDL != NULL)
                     req_buf = request->TransferBufferMDL->MappedSystemVa;
@@ -560,14 +571,19 @@ static NTSTATUS WINAPI usbhub_internal_ioctl( DEVICE_OBJECT *device, IRP *irp )
                 husb = usb_open( inst->dev );
                 if (husb)
                 {
-                    UCHAR req_type = request->RequestTypeReservedBits | (2 << 5);
+                    UCHAR req_type = request->RequestTypeReservedBits;
                     char *buf;
                     int ret;
 
-                    if (urb->u.UrbHeader.Function == URB_FUNCTION_VENDOR_INTERFACE)
-                        req_type |= 1;
-                    else if (urb->u.UrbHeader.Function == URB_FUNCTION_VENDOR_ENDPOINT)
-                        req_type |= 2;
+                    switch (urb->u.UrbHeader.Function)
+                    {
+                    case URB_FUNCTION_VENDOR_DEVICE:    req_type |= 0x40; break;
+                    case URB_FUNCTION_VENDOR_INTERFACE: req_type |= 0x41; break;
+                    case URB_FUNCTION_VENDOR_ENDPOINT:  req_type |= 0x42; break;
+                    case URB_FUNCTION_CLASS_DEVICE:     req_type |= 0x20; break;
+                    case URB_FUNCTION_CLASS_INTERFACE:  req_type |= 0x21; break;
+                    case URB_FUNCTION_CLASS_ENDPOINT:   req_type |= 0x22; break;
+                    }
                     buf = HeapAlloc( GetProcessHeap(), 0, size );
                     if (buf != NULL)
                     {