Lines Matching refs:stream

17 	struct usb_data_stream *stream = urb->context;  in usb_urb_complete()  local
48stream->complete(stream, b + urb->iso_frame_desc[i].offset, urb->iso_frame_desc[i].actual_length); in usb_urb_complete()
57 stream->complete(stream, b, urb->actual_length); in usb_urb_complete()
66 int usb_urb_kill(struct usb_data_stream *stream) in usb_urb_kill() argument
69 for (i = 0; i < stream->urbs_submitted; i++) { in usb_urb_kill()
73 usb_kill_urb(stream->urb_list[i]); in usb_urb_kill()
75 stream->urbs_submitted = 0; in usb_urb_kill()
79 int usb_urb_submit(struct usb_data_stream *stream) in usb_urb_submit() argument
82 for (i = 0; i < stream->urbs_initialized; i++) { in usb_urb_submit()
84 if ((ret = usb_submit_urb(stream->urb_list[i],GFP_ATOMIC))) { in usb_urb_submit()
86 usb_urb_kill(stream); in usb_urb_submit()
89 stream->urbs_submitted++; in usb_urb_submit()
94 static int usb_free_stream_buffers(struct usb_data_stream *stream) in usb_free_stream_buffers() argument
96 if (stream->state & USB_STATE_URB_BUF) { in usb_free_stream_buffers()
97 while (stream->buf_num) { in usb_free_stream_buffers()
98 stream->buf_num--; in usb_free_stream_buffers()
99 deb_mem("freeing buffer %d\n",stream->buf_num); in usb_free_stream_buffers()
100 usb_free_coherent(stream->udev, stream->buf_size, in usb_free_stream_buffers()
101 stream->buf_list[stream->buf_num], in usb_free_stream_buffers()
102 stream->dma_addr[stream->buf_num]); in usb_free_stream_buffers()
106 stream->state &= ~USB_STATE_URB_BUF; in usb_free_stream_buffers()
111 static int usb_allocate_stream_buffers(struct usb_data_stream *stream, int num, unsigned long size) in usb_allocate_stream_buffers() argument
113 stream->buf_num = 0; in usb_allocate_stream_buffers()
114 stream->buf_size = size; in usb_allocate_stream_buffers()
118 for (stream->buf_num = 0; stream->buf_num < num; stream->buf_num++) { in usb_allocate_stream_buffers()
119 deb_mem("allocating buffer %d\n",stream->buf_num); in usb_allocate_stream_buffers()
120 if (( stream->buf_list[stream->buf_num] = in usb_allocate_stream_buffers()
121 usb_alloc_coherent(stream->udev, size, GFP_KERNEL, in usb_allocate_stream_buffers()
122 &stream->dma_addr[stream->buf_num]) ) == NULL) { in usb_allocate_stream_buffers()
124 usb_free_stream_buffers(stream); in usb_allocate_stream_buffers()
128 stream->buf_num, in usb_allocate_stream_buffers()
129 stream->buf_list[stream->buf_num], (long long)stream->dma_addr[stream->buf_num]); in usb_allocate_stream_buffers()
130 memset(stream->buf_list[stream->buf_num],0,size); in usb_allocate_stream_buffers()
131 stream->state |= USB_STATE_URB_BUF; in usb_allocate_stream_buffers()
138 static int usb_bulk_urb_init(struct usb_data_stream *stream) in usb_bulk_urb_init() argument
142 if ((i = usb_allocate_stream_buffers(stream,stream->props.count, in usb_bulk_urb_init()
143 stream->props.u.bulk.buffersize)) < 0) in usb_bulk_urb_init()
147 for (i = 0; i < stream->props.count; i++) { in usb_bulk_urb_init()
148 stream->urb_list[i] = usb_alloc_urb(0, GFP_KERNEL); in usb_bulk_urb_init()
149 if (!stream->urb_list[i]) { in usb_bulk_urb_init()
152 usb_free_urb(stream->urb_list[j]); in usb_bulk_urb_init()
155 usb_fill_bulk_urb( stream->urb_list[i], stream->udev, in usb_bulk_urb_init()
156 usb_rcvbulkpipe(stream->udev,stream->props.endpoint), in usb_bulk_urb_init()
157 stream->buf_list[i], in usb_bulk_urb_init()
158 stream->props.u.bulk.buffersize, in usb_bulk_urb_init()
159 usb_urb_complete, stream); in usb_bulk_urb_init()
161 stream->urb_list[i]->transfer_flags = URB_NO_TRANSFER_DMA_MAP; in usb_bulk_urb_init()
162 stream->urb_list[i]->transfer_dma = stream->dma_addr[i]; in usb_bulk_urb_init()
163 stream->urbs_initialized++; in usb_bulk_urb_init()
168 static int usb_isoc_urb_init(struct usb_data_stream *stream) in usb_isoc_urb_init() argument
172 if ((i = usb_allocate_stream_buffers(stream,stream->props.count, in usb_isoc_urb_init()
173 stream->props.u.isoc.framesize*stream->props.u.isoc.framesperurb)) < 0) in usb_isoc_urb_init()
177 for (i = 0; i < stream->props.count; i++) { in usb_isoc_urb_init()
181 stream->urb_list[i] = usb_alloc_urb(stream->props.u.isoc.framesperurb, GFP_KERNEL); in usb_isoc_urb_init()
182 if (!stream->urb_list[i]) { in usb_isoc_urb_init()
185 usb_free_urb(stream->urb_list[j]); in usb_isoc_urb_init()
189 urb = stream->urb_list[i]; in usb_isoc_urb_init()
191 urb->dev = stream->udev; in usb_isoc_urb_init()
192 urb->context = stream; in usb_isoc_urb_init()
194 urb->pipe = usb_rcvisocpipe(stream->udev,stream->props.endpoint); in usb_isoc_urb_init()
196 urb->interval = stream->props.u.isoc.interval; in usb_isoc_urb_init()
197 urb->number_of_packets = stream->props.u.isoc.framesperurb; in usb_isoc_urb_init()
198 urb->transfer_buffer_length = stream->buf_size; in usb_isoc_urb_init()
199 urb->transfer_buffer = stream->buf_list[i]; in usb_isoc_urb_init()
200 urb->transfer_dma = stream->dma_addr[i]; in usb_isoc_urb_init()
202 for (j = 0; j < stream->props.u.isoc.framesperurb; j++) { in usb_isoc_urb_init()
204 urb->iso_frame_desc[j].length = stream->props.u.isoc.framesize; in usb_isoc_urb_init()
205 frame_offset += stream->props.u.isoc.framesize; in usb_isoc_urb_init()
208 stream->urbs_initialized++; in usb_isoc_urb_init()
213 int usb_urb_init(struct usb_data_stream *stream, struct usb_data_stream_properties *props) in usb_urb_init() argument
215 if (stream == NULL || props == NULL) in usb_urb_init()
218 memcpy(&stream->props, props, sizeof(*props)); in usb_urb_init()
220 usb_clear_halt(stream->udev,usb_rcvbulkpipe(stream->udev,stream->props.endpoint)); in usb_urb_init()
222 if (stream->complete == NULL) { in usb_urb_init()
227 switch (stream->props.type) { in usb_urb_init()
229 return usb_bulk_urb_init(stream); in usb_urb_init()
231 return usb_isoc_urb_init(stream); in usb_urb_init()
238 int usb_urb_exit(struct usb_data_stream *stream) in usb_urb_exit() argument
242 usb_urb_kill(stream); in usb_urb_exit()
244 for (i = 0; i < stream->urbs_initialized; i++) { in usb_urb_exit()
245 if (stream->urb_list[i] != NULL) { in usb_urb_exit()
248 usb_free_urb(stream->urb_list[i]); in usb_urb_exit()
251 stream->urbs_initialized = 0; in usb_urb_exit()
253 usb_free_stream_buffers(stream); in usb_urb_exit()