Send Multiple URB's to USB Host driver in Bulk Mode



Hello,

I have a device that streams video over a Bulk IN EP. I was using
Cypress Driver & API, but now I must make my own driver.

A typical Example is :

- User mode request 512 KB from Bulk IN EP.
- My Driver splits this IRP (Request now as I'm using WDF) into
multiple USB Read Requests (64KB each) one at a time. As soon as an
USB request is complete, I re-submit one if required and I continue
this process until the whole transfer is done (transfer done has a
special meaning, I'll elaborate below).

I've implemented a queue for IRP, so I can make multiple call to
DeviceIoControl (overlapped IO) to always have requests on USB while I
consume Video Data.

The usb board has a FPGA that streams one Video Frame plus some Info,
at the end of the frame it send an Empty Usb packet (PKTEND
functionnality of Cypress FX2 Chip). As this USB packet is less than
USB Packet Size, the transfer must be considered as over and so I must
complete Request immediately.

So Imagine a PAL frame is 512KB and a NTSC Frame is 480KB (These sizes
are for example only). The Fpga then streams either 512KB or 480KB then
send a PKTEND and after restart a FRAME transfer and so on.

As our USB board can switch dynamically video standard (PAL <-> NTSC),
I always ask from user mode the largest buffer I can receive (In this
example, its' 512 KB). With this method, either the FRAME is 512KB
long, and my buffer is completely filled, or I receive 480KB and my
buffer is filled with 480KB worth of data.


My Problem
------------------

If i want to optimize a little bit the driver, I must submit more than
one USB Request at a time(URBs) like 8 for example.

So the new schema would be :

- User mode request 512KB from Bulk IN EP.
- Driver splits this request into multiple stage and send up to 8
requests (URBs) to USB Host. As soon as a USB request is done, I resend
another one if required.

With this method I'm always sure that USB Host Driver has always
pending requests.

Now if the FPGA sends a PKTEND (that is an empty USB packet), in my
EvCompleteRequest callback for a USB Request, i'll detect this
condition, and so i'll complete IRP. The problem is that I've up to 7
pending Usb Request, and that if they are executed, then these requests
will receive data from a new frame. How should I do it ? Can the Host
Driver identify that an USB transfer is complete and thus doesn't even
submit other pending request (for that EP) and complete them instead ?


A more general question would be :
If I submit 8 USB Read Request to USB Host driver (64KB each) for the
same IRP, I assume that at the end of the transfer I'll get 8*64KB =
512KB. Now if the USB device send a short Packet instead of a full one
(for example 0 byte, instead of 1024 bytes), what will be the behaviour
of the USB Host Driver. Will it cancel all pending request on that EP,
or will it simply complete current request with a size that is less
than 64KB BUT continue to submit other pending requests ?

Thanks,
Fred.

.



Relevant Pages

  • Re: Can USBCAMD2 acquire isochonous data each 125us?
    ... I will read the EHCI specification later to understand more about USB ... effect USBcamd and usb bus driver? ... Each request contains some number of packets, ... If the host controller does not have ...
    (microsoft.public.development.device.drivers)
  • Re: Is it possible to get the current USB frame from the WinUSB dr
    ... you can get the DEVINST for your device through setupdi calls and then you can walk up the tree using the config manager APIs until you find the HC ... Now that I can get the current USB frame number from the host controller, ... USB device? ... your best bet will be a KMDF driver. ...
    (microsoft.public.development.device.drivers)
  • USB 2.0 throughput issue on Windows CE 5.0
    ... I am developing a driver for our TV receiver chip that connects a Windows CE ... USB host; ... USB_START_ISOCH_ASAP precludes the need for a start frame ...
    (microsoft.public.windowsce.platbuilder)
  • Re: Is it possible to get the current USB frame from the WinUSB dr
    ... Maybe the usbview source code can help me with finding a root hub (if ... Does the root hub driver provide an ioctl to get the current frame number? ... Our company makes a fairly simple USB device that the WinUSB driver ...
    (microsoft.public.development.device.drivers)
  • Re: Is it possible to get the current USB frame from the WinUSB dr
    ... The usb driver is a _bit_ picky about the parameters, try to change the code as follows: ... void TestIoctl(HANDLE dev, const char *title) ... I'm trying to get the current frame number from the host controller but I'm ...
    (microsoft.public.development.device.drivers)