Lines Matching refs:stream
16 int usb_urb_reconfig(struct usb_data_stream *stream,
21 struct usb_data_stream *stream = urb->context; in usb_urb_complete() local
26 dev_dbg_ratelimited(&stream->udev->dev, in usb_urb_complete()
42 dev_dbg_ratelimited(&stream->udev->dev, in usb_urb_complete()
53 dev_dbg(&stream->udev->dev, in usb_urb_complete()
58 stream->complete(stream, in usb_urb_complete()
68 stream->complete(stream, b, urb->actual_length); in usb_urb_complete()
71 dev_err(&stream->udev->dev, in usb_urb_complete()
79 int usb_urb_killv2(struct usb_data_stream *stream) in usb_urb_killv2() argument
82 for (i = 0; i < stream->urbs_submitted; i++) { in usb_urb_killv2()
83 dev_dbg(&stream->udev->dev, "%s: kill urb=%d\n", __func__, i); in usb_urb_killv2()
85 usb_kill_urb(stream->urb_list[i]); in usb_urb_killv2()
87 stream->urbs_submitted = 0; in usb_urb_killv2()
91 int usb_urb_submitv2(struct usb_data_stream *stream, in usb_urb_submitv2() argument
97 ret = usb_urb_reconfig(stream, props); in usb_urb_submitv2()
102 for (i = 0; i < stream->urbs_initialized; i++) { in usb_urb_submitv2()
103 dev_dbg(&stream->udev->dev, "%s: submit urb=%d\n", __func__, i); in usb_urb_submitv2()
104 ret = usb_submit_urb(stream->urb_list[i], GFP_ATOMIC); in usb_urb_submitv2()
106 dev_err(&stream->udev->dev, in usb_urb_submitv2()
109 usb_urb_killv2(stream); in usb_urb_submitv2()
112 stream->urbs_submitted++; in usb_urb_submitv2()
117 static int usb_urb_free_urbs(struct usb_data_stream *stream) in usb_urb_free_urbs() argument
121 usb_urb_killv2(stream); in usb_urb_free_urbs()
123 for (i = stream->urbs_initialized - 1; i >= 0; i--) { in usb_urb_free_urbs()
124 if (stream->urb_list[i]) { in usb_urb_free_urbs()
125 dev_dbg(&stream->udev->dev, "%s: free urb=%d\n", in usb_urb_free_urbs()
128 usb_free_urb(stream->urb_list[i]); in usb_urb_free_urbs()
131 stream->urbs_initialized = 0; in usb_urb_free_urbs()
136 static int usb_urb_alloc_bulk_urbs(struct usb_data_stream *stream) in usb_urb_alloc_bulk_urbs() argument
141 for (i = 0; i < stream->props.count; i++) { in usb_urb_alloc_bulk_urbs()
142 dev_dbg(&stream->udev->dev, "%s: alloc urb=%d\n", __func__, i); in usb_urb_alloc_bulk_urbs()
143 stream->urb_list[i] = usb_alloc_urb(0, GFP_ATOMIC); in usb_urb_alloc_bulk_urbs()
144 if (!stream->urb_list[i]) { in usb_urb_alloc_bulk_urbs()
145 dev_dbg(&stream->udev->dev, "%s: failed\n", __func__); in usb_urb_alloc_bulk_urbs()
147 usb_free_urb(stream->urb_list[j]); in usb_urb_alloc_bulk_urbs()
150 usb_fill_bulk_urb(stream->urb_list[i], in usb_urb_alloc_bulk_urbs()
151 stream->udev, in usb_urb_alloc_bulk_urbs()
152 usb_rcvbulkpipe(stream->udev, in usb_urb_alloc_bulk_urbs()
153 stream->props.endpoint), in usb_urb_alloc_bulk_urbs()
154 stream->buf_list[i], in usb_urb_alloc_bulk_urbs()
155 stream->props.u.bulk.buffersize, in usb_urb_alloc_bulk_urbs()
156 usb_urb_complete, stream); in usb_urb_alloc_bulk_urbs()
158 stream->urbs_initialized++; in usb_urb_alloc_bulk_urbs()
163 static int usb_urb_alloc_isoc_urbs(struct usb_data_stream *stream) in usb_urb_alloc_isoc_urbs() argument
168 for (i = 0; i < stream->props.count; i++) { in usb_urb_alloc_isoc_urbs()
171 dev_dbg(&stream->udev->dev, "%s: alloc urb=%d\n", __func__, i); in usb_urb_alloc_isoc_urbs()
172 stream->urb_list[i] = usb_alloc_urb( in usb_urb_alloc_isoc_urbs()
173 stream->props.u.isoc.framesperurb, GFP_ATOMIC); in usb_urb_alloc_isoc_urbs()
174 if (!stream->urb_list[i]) { in usb_urb_alloc_isoc_urbs()
175 dev_dbg(&stream->udev->dev, "%s: failed\n", __func__); in usb_urb_alloc_isoc_urbs()
177 usb_free_urb(stream->urb_list[j]); in usb_urb_alloc_isoc_urbs()
181 urb = stream->urb_list[i]; in usb_urb_alloc_isoc_urbs()
183 urb->dev = stream->udev; in usb_urb_alloc_isoc_urbs()
184 urb->context = stream; in usb_urb_alloc_isoc_urbs()
186 urb->pipe = usb_rcvisocpipe(stream->udev, in usb_urb_alloc_isoc_urbs()
187 stream->props.endpoint); in usb_urb_alloc_isoc_urbs()
189 urb->interval = stream->props.u.isoc.interval; in usb_urb_alloc_isoc_urbs()
190 urb->number_of_packets = stream->props.u.isoc.framesperurb; in usb_urb_alloc_isoc_urbs()
191 urb->transfer_buffer_length = stream->props.u.isoc.framesize * in usb_urb_alloc_isoc_urbs()
192 stream->props.u.isoc.framesperurb; in usb_urb_alloc_isoc_urbs()
193 urb->transfer_buffer = stream->buf_list[i]; in usb_urb_alloc_isoc_urbs()
195 for (j = 0; j < stream->props.u.isoc.framesperurb; j++) { in usb_urb_alloc_isoc_urbs()
198 stream->props.u.isoc.framesize; in usb_urb_alloc_isoc_urbs()
199 frame_offset += stream->props.u.isoc.framesize; in usb_urb_alloc_isoc_urbs()
202 stream->urbs_initialized++; in usb_urb_alloc_isoc_urbs()
207 static int usb_free_stream_buffers(struct usb_data_stream *stream) in usb_free_stream_buffers() argument
209 if (stream->state & USB_STATE_URB_BUF) { in usb_free_stream_buffers()
210 while (stream->buf_num) { in usb_free_stream_buffers()
211 stream->buf_num--; in usb_free_stream_buffers()
212 kfree(stream->buf_list[stream->buf_num]); in usb_free_stream_buffers()
216 stream->state &= ~USB_STATE_URB_BUF; in usb_free_stream_buffers()
221 static int usb_alloc_stream_buffers(struct usb_data_stream *stream, int num, in usb_alloc_stream_buffers() argument
224 stream->buf_num = 0; in usb_alloc_stream_buffers()
225 stream->buf_size = size; in usb_alloc_stream_buffers()
227 dev_dbg(&stream->udev->dev, in usb_alloc_stream_buffers()
231 for (stream->buf_num = 0; stream->buf_num < num; stream->buf_num++) { in usb_alloc_stream_buffers()
232 stream->buf_list[stream->buf_num] = kzalloc(size, GFP_ATOMIC); in usb_alloc_stream_buffers()
233 if (!stream->buf_list[stream->buf_num]) { in usb_alloc_stream_buffers()
234 dev_dbg(&stream->udev->dev, "%s: alloc buf=%d failed\n", in usb_alloc_stream_buffers()
235 __func__, stream->buf_num); in usb_alloc_stream_buffers()
236 usb_free_stream_buffers(stream); in usb_alloc_stream_buffers()
240 dev_dbg(&stream->udev->dev, "%s: alloc buf=%d %p (dma %llu)\n", in usb_alloc_stream_buffers()
241 __func__, stream->buf_num, in usb_alloc_stream_buffers()
242 stream->buf_list[stream->buf_num], in usb_alloc_stream_buffers()
243 (long long)stream->dma_addr[stream->buf_num]); in usb_alloc_stream_buffers()
244 stream->state |= USB_STATE_URB_BUF; in usb_alloc_stream_buffers()
250 int usb_urb_reconfig(struct usb_data_stream *stream, in usb_urb_reconfig() argument
260 buf_size = stream->props.u.bulk.buffersize; in usb_urb_reconfig()
264 dev_err(&stream->udev->dev, "%s: invalid endpoint type=%d\n", in usb_urb_reconfig()
269 if (stream->buf_num < props->count || stream->buf_size < buf_size) { in usb_urb_reconfig()
270 dev_err(&stream->udev->dev, in usb_urb_reconfig()
277 if (stream->props.type == props->type && in usb_urb_reconfig()
278 stream->props.count == props->count && in usb_urb_reconfig()
279 stream->props.endpoint == props->endpoint) { in usb_urb_reconfig()
282 stream->props.u.bulk.buffersize) in usb_urb_reconfig()
286 stream->props.u.isoc.framesperurb && in usb_urb_reconfig()
288 stream->props.u.isoc.framesize && in usb_urb_reconfig()
290 stream->props.u.isoc.interval) in usb_urb_reconfig()
294 dev_dbg(&stream->udev->dev, "%s: re-alloc urbs\n", __func__); in usb_urb_reconfig()
296 usb_urb_free_urbs(stream); in usb_urb_reconfig()
297 memcpy(&stream->props, props, sizeof(*props)); in usb_urb_reconfig()
299 return usb_urb_alloc_bulk_urbs(stream); in usb_urb_reconfig()
301 return usb_urb_alloc_isoc_urbs(stream); in usb_urb_reconfig()
306 int usb_urb_initv2(struct usb_data_stream *stream, in usb_urb_initv2() argument
311 if (!stream || !props) in usb_urb_initv2()
314 memcpy(&stream->props, props, sizeof(*props)); in usb_urb_initv2()
316 if (!stream->complete) { in usb_urb_initv2()
317 dev_err(&stream->udev->dev, in usb_urb_initv2()
323 switch (stream->props.type) { in usb_urb_initv2()
325 ret = usb_alloc_stream_buffers(stream, stream->props.count, in usb_urb_initv2()
326 stream->props.u.bulk.buffersize); in usb_urb_initv2()
330 return usb_urb_alloc_bulk_urbs(stream); in usb_urb_initv2()
332 ret = usb_alloc_stream_buffers(stream, stream->props.count, in usb_urb_initv2()
333 stream->props.u.isoc.framesize * in usb_urb_initv2()
334 stream->props.u.isoc.framesperurb); in usb_urb_initv2()
338 return usb_urb_alloc_isoc_urbs(stream); in usb_urb_initv2()
340 dev_err(&stream->udev->dev, in usb_urb_initv2()
347 int usb_urb_exitv2(struct usb_data_stream *stream) in usb_urb_exitv2() argument
349 usb_urb_free_urbs(stream); in usb_urb_exitv2()
350 usb_free_stream_buffers(stream); in usb_urb_exitv2()