From 11a88238cd59186043e2b55d558ad0690c9a2c8b Mon Sep 17 00:00:00 2001 From: Alexander Morozov Date: Fri, 5 Jun 2009 13:00:09 +0400 Subject: [PATCH] usbhub.sys: Add support for a USB bulk transfer. --- dlls/usbhub.sys/usbhub.c | 73 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/dlls/usbhub.sys/usbhub.c b/dlls/usbhub.sys/usbhub.c index 274839f3ae..8321077136 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 = -- 2.33.8