18 static void usb_urb_complete(
struct urb *
urb)
21 int ptype = usb_pipetype(urb->pipe);
26 "status=%d length=%d/%d pack_num=%d errors=%d\n",
27 __func__, ptype == PIPE_ISOCHRONOUS ?
"isoc" :
"bulk",
28 urb->status, urb->actual_length,
29 urb->transfer_buffer_length,
30 urb->number_of_packets, urb->error_count);
32 switch (urb->status) {
42 "%s: urb completition failed=%d\n",
43 __func__, urb->status);
47 b = (
u8 *) urb->transfer_buffer;
49 case PIPE_ISOCHRONOUS:
50 for (i = 0; i < urb->number_of_packets; i++) {
51 if (urb->iso_frame_desc[i].status != 0)
53 "descriptor has an error=%d\n",
55 urb->iso_frame_desc[i].status);
56 else if (urb->iso_frame_desc[i].actual_length > 0)
58 b + urb->iso_frame_desc[i].offset,
59 urb->iso_frame_desc[i].actual_length);
61 urb->iso_frame_desc[
i].status = 0;
62 urb->iso_frame_desc[
i].actual_length = 0;
66 if (urb->actual_length > 0)
67 stream->
complete(stream, b, urb->actual_length);
70 dev_err(&stream->
udev->dev,
"%s: unknown endpoint type in " \
71 "completition handler\n", KBUILD_MODNAME);
81 dev_dbg(&stream->
udev->dev,
"%s: kill urb=%d\n", __func__, i);
101 dev_dbg(&stream->
udev->dev,
"%s: submit urb=%d\n", __func__, i);
104 dev_err(&stream->
udev->dev,
"%s: could not submit " \
105 "urb no. %d - get them all back\n",
139 for (i = 0; i < stream->
props.count; i++) {
140 dev_dbg(&stream->
udev->dev,
"%s: alloc urb=%d\n", __func__, i);
143 dev_dbg(&stream->
udev->dev,
"%s: failed\n", __func__);
144 for (j = 0; j <
i; j++)
148 usb_fill_bulk_urb(stream->
urb_list[i],
150 usb_rcvbulkpipe(stream->
udev,
151 stream->
props.endpoint),
153 stream->
props.u.bulk.buffersize,
154 usb_urb_complete, stream);
156 stream->
urb_list[
i]->transfer_flags = URB_NO_TRANSFER_DMA_MAP;
168 for (i = 0; i < stream->
props.count; i++) {
171 dev_dbg(&stream->
udev->dev,
"%s: alloc urb=%d\n", __func__, i);
175 dev_dbg(&stream->
udev->dev,
"%s: failed\n", __func__);
176 for (j = 0; j <
i; j++)
183 urb->dev = stream->
udev;
184 urb->context = stream;
186 urb->pipe = usb_rcvisocpipe(stream->
udev,
187 stream->
props.endpoint);
188 urb->transfer_flags = URB_ISO_ASAP | URB_NO_TRANSFER_DMA_MAP;
189 urb->interval = stream->
props.u.isoc.interval;
190 urb->number_of_packets = stream->
props.u.isoc.framesperurb;
191 urb->transfer_buffer_length = stream->
props.u.isoc.framesize *
192 stream->
props.u.isoc.framesperurb;
193 urb->transfer_buffer = stream->
buf_list[
i];
196 for (j = 0; j < stream->
props.u.isoc.framesperurb; j++) {
198 urb->iso_frame_desc[
j].length =
199 stream->
props.u.isoc.framesize;
200 frame_offset += stream->
props.u.isoc.framesize;
232 dev_dbg(&stream->
udev->dev,
"%s: all in all I will use %lu bytes for " \
233 "streaming\n", __func__, num * size);
240 dev_dbg(&stream->
udev->dev,
"%s: alloc buf=%d failed\n",
246 dev_dbg(&stream->
udev->dev,
"%s: alloc buf=%d %p (dma %llu)\n",
267 buf_size = stream->
props.u.bulk.buffersize;
269 buf_size = props->
u.
isoc.framesize * props->
u.
isoc.framesperurb;
271 dev_err(&stream->
udev->dev,
"%s: invalid endpoint type=%d\n",
272 KBUILD_MODNAME, props->
type);
277 dev_err(&stream->
udev->dev,
"%s: cannot reconfigure as " \
278 "allocated buffers are too small\n",
288 props->
u.
bulk.buffersize ==
289 stream->
props.u.bulk.buffersize)
292 props->
u.
isoc.framesperurb ==
293 stream->
props.u.isoc.framesperurb &&
294 props->
u.
isoc.framesize ==
295 stream->
props.u.isoc.framesize &&
296 props->
u.
isoc.interval ==
297 stream->
props.u.isoc.interval)
301 dev_dbg(&stream->
udev->dev,
"%s: re-alloc urbs\n", __func__);
306 return usb_urb_alloc_bulk_urbs(stream);
308 return usb_urb_alloc_isoc_urbs(stream);
318 if (!stream || !props)
324 dev_err(&stream->
udev->dev,
"%s: there is no data callback - " \
325 "this doesn't make sense\n", KBUILD_MODNAME);
329 switch (stream->
props.type) {
332 stream->
props.u.bulk.buffersize);
336 return usb_urb_alloc_bulk_urbs(stream);
339 stream->
props.u.isoc.framesize *
340 stream->
props.u.isoc.framesperurb);
344 return usb_urb_alloc_isoc_urbs(stream);
346 dev_err(&stream->
udev->dev,
"%s: unknown urb-type for data " \
347 "transfer\n", KBUILD_MODNAME);