[Wine-patches] [eterhack 09/23] usbhub.sys: Add support for a USB bulk transfer.

Alexander Morozov =?iso-8859-1?q?amorozov_=CE=C1_etersoft=2Eru?=
Пт Июн 5 13:00:09 MSD 2009


---
 dlls/usbhub.sys/usbhub.c |   73 ++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 73 insertions(+), 0 deletions(-)

diff --git a/dlls/usbhub.sys/usbhub.c b/dlls/usbhub.sys/usbhub.c
index 274839f..8321077 100644
--- a/dlls/usbhub.sys/usbhub.c
+++ b/dlls/usbhub.sys/usbhub.c
@@ -195,6 +195,41 @@ static NTSTATUS WINAPI usbhub_internal_ioctl( DEVICE_OBJECT *device, IRP *irp )
                 }
             }
             break;
+        case URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER:
+            {
+                struct _URB_BULK_OR_INTERRUPT_TRANSFER *request =
+                        &urb->u.UrbBulkOrInterruptTransfer;
+                unsigned char *buf = request->TransferBuffer;
+                libusb_device_handle *husb;
+
+                TRACE( "URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER\n" );
+
+                if (buf == NULL && request->TransferBufferMDL != NULL)
+                    buf = request->TransferBufferMDL->MappedSystemVa;
+                if (!libusb_open( inst->dev, &husb ))
+                {
+                    int ret, transferred;
+
+                    ret = libusb_claim_interface( husb,
+                            ((int)request->PipeHandle >> 8) - 1 );
+                    if (!ret)
+                    {
+                        /* FIXME: add support for an interrupt transfer */
+                        ret = libusb_bulk_transfer( husb,
+                                (unsigned int)request->PipeHandle,
+                                buf, request->TransferBufferLength,
+                                &transferred, 1000 );
+                        if (!libusb_release_interface( husb,
+                                ((int)request->PipeHandle >> 8) - 1 ) && !ret)
+                        {
+                            request->TransferBufferLength = transferred;
+                            status = STATUS_SUCCESS;
+                        }
+                    }
+                    libusb_close( husb );
+                }
+            }
+            break;
         case URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE:
             {
                 struct _URB_CONTROL_DESCRIPTOR_REQUEST *request =
@@ -514,6 +549,44 @@ static NTSTATUS WINAPI usbhub_internal_ioctl( DEVICE_OBJECT *device, IRP *irp )
                 }
             }
             break;
+        case URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER:
+            {
+                struct _URB_BULK_OR_INTERRUPT_TRANSFER *request =
+                        &urb->u.UrbBulkOrInterruptTransfer;
+                char *buf = request->TransferBuffer;
+                usb_dev_handle *husb;
+
+                TRACE( "URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER\n" );
+
+                if (buf == NULL && request->TransferBufferMDL != NULL)
+                    buf = request->TransferBufferMDL->MappedSystemVa;
+                husb = usb_open( inst->dev );
+                if (husb)
+                {
+                    int ret;
+
+                    ret = usb_claim_interface( husb,
+                            ((int)request->PipeHandle >> 8) - 1 );
+                    if (!ret)
+                    {
+                        /* FIXME: add support for an interrupt transfer */
+                        if (request->TransferFlags & USBD_TRANSFER_DIRECTION_IN)
+                            ret = usb_bulk_read( husb, (int)request->PipeHandle & 0xff,
+                                    buf, request->TransferBufferLength, 1000 );
+                        else
+                            ret = usb_bulk_write( husb, (int)request->PipeHandle & 0xff,
+                                    buf, request->TransferBufferLength, 1000 );
+                        if (!usb_release_interface( husb,
+                                ((int)request->PipeHandle >> 8) - 1 ) && ret >= 0)
+                        {
+                            request->TransferBufferLength = ret;
+                            status = STATUS_SUCCESS;
+                        }
+                    }
+                    usb_close( husb );
+                }
+            }
+            break;
         case URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE:
             {
                 struct _URB_CONTROL_DESCRIPTOR_REQUEST *request =
-- 
1.6.3.1



Подробная информация о списке рассылки Wine-patches