Send Multiple URB's to USB Host driver in Bulk Mode
- From: "fredsky" <hardware.evs@xxxxxxxxx>
- Date: 15 Sep 2006 01:46:49 -0700
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.
.
- Follow-Ups:
- Re: Send Multiple URB's to USB Host driver in Bulk Mode
- From: Maxim S. Shatskih
- Re: Send Multiple URB's to USB Host driver in Bulk Mode
- Prev by Date: Re: Writing URB's to buffer
- Next by Date: Re: Assigning Virtual Com Port
- Previous by thread: Loading USB Functional driver
- Next by thread: Re: Send Multiple URB's to USB Host driver in Bulk Mode
- Index(es):
Relevant Pages
|