This patch supplies the missing inline function usb_fill_iso_urb in include/linux/usb.h, to assist with URB fill-in in isochronous device drivers.
Historically there hasn't been one of those, but that's no good reason not to add such a feature!
Some comments about this:
- Do you really need the non-ASAP iso scheduling option? (That's what the start_frame hooks are for.) OHCI never implemented them, I don't think I saw any drivers using it, and implementing that correctly can be a real PITA. I'd as soon just abolish all support for non-ASAP iso scheduling, but it's going to be supported then this function should set/clear the URB_ISO_ASAP flag appropriately.
- Did you think about maybe providing the endpoint descriptor, instead of the pipe and interval?
- ALL isochronous endpoint intervals use a logarithmic encoding. The only difference between full and high speeds is the units, which are frames and microframes respectively. (So that part of your patch has a bug.)
- I notice this isn't setting up the individual packets in the (misnamed) urb->iso_frame_desc[] array. Did you consider doing that? Almost all ISO usage just sets them up so each packet is adjacent to the previous one -- easy to automate.
I suspect that if this API were to catch on it'd need to have versions in the 2.4 kernels too.
- Dave
+/**
+ * usb_fill_iso_urb - macro to help initialize a isochronous urb
+ * @urb: pointer to the urb to initialize.
+ * @dev: pointer to the struct usb_device for this urb.
+ * @pipe: the endpoint pipe
+ * @transfer_buffer: pointer to the transfer buffer
+ * @buffer_length: length of the transfer buffer
+ * @complete: pointer to the usb_complete_t function
+ * @context: what to set the urb context to.
+ * @interval: what to set the urb interval to, encoded like
+ * the endpoint descriptor's bInterval value.
+ * @start_frame: what frame number to start in.
+ * Initializes an isochronous urb with proper information needed to submit
+ * it to a device.
+ * Note that high speed isochronous endpoints use a logarithmic encoding of
+ * the endpoint interval, and express polling intervals in microframes
+ * (eight per millisecond) rather than in frames (one per millisecond).
+ */
+static inline void usb_fill_iso_urb (struct urb *urb,
+ struct usb_device *dev,
+ unsigned int pipe,
+ void *transfer_buffer,
+ int buffer_length,
+ usb_complete_t complete,
+ void *context,
+ int interval,
+ int start_frame)
+{
+ spin_lock_init(&urb->lock);
+ urb->dev = dev;
+ urb->pipe = pipe;
+ urb->transfer_buffer = transfer_buffer;
+ urb->transfer_buffer_length = buffer_length;
+ urb->complete = complete;
+ urb->context = context;
+ if (dev->speed == USB_SPEED_HIGH)
+ urb->interval = 1 << (interval - 1);
+ else
+ urb->interval = interval;
+ if (!start_frame)
+ urb->start_frame = -1;
+ else
+ urb->start_frame = start_frame;
+}
+
------------------------------------------------------- This SF.net email is sponsored by: IBM Linux Tutorials. Become an expert in LINUX or just sharpen your skills. Sign up for IBM's Free Linux Tutorials. Learn everything from the bash shell to sys admin. Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click _______________________________________________ [EMAIL PROTECTED] To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
