Lines Matching refs:stream

16 	struct usb_data_stream *stream = urb->context;  in usb_urb_complete()  local
47stream->complete(stream, b + urb->iso_frame_desc[i].offset, urb->iso_frame_desc[i].actual_length); in usb_urb_complete()
56 stream->complete(stream, b, urb->actual_length); in usb_urb_complete()
65 int usb_urb_kill(struct usb_data_stream *stream) in usb_urb_kill() argument
68 for (i = 0; i < stream->urbs_submitted; i++) { in usb_urb_kill()
72 usb_kill_urb(stream->urb_list[i]); in usb_urb_kill()
74 stream->urbs_submitted = 0; in usb_urb_kill()
78 int usb_urb_submit(struct usb_data_stream *stream) in usb_urb_submit() argument
81 for (i = 0; i < stream->urbs_initialized; i++) { in usb_urb_submit()
83 if ((ret = usb_submit_urb(stream->urb_list[i],GFP_ATOMIC))) { in usb_urb_submit()
85 usb_urb_kill(stream); in usb_urb_submit()
88 stream->urbs_submitted++; in usb_urb_submit()
93 static int usb_free_stream_buffers(struct usb_data_stream *stream) in usb_free_stream_buffers() argument
95 if (stream->state & USB_STATE_URB_BUF) { in usb_free_stream_buffers()
96 while (stream->buf_num) { in usb_free_stream_buffers()
97 stream->buf_num--; in usb_free_stream_buffers()
98 deb_mem("freeing buffer %d\n",stream->buf_num); in usb_free_stream_buffers()
99 usb_free_coherent(stream->udev, stream->buf_size, in usb_free_stream_buffers()
100 stream->buf_list[stream->buf_num], in usb_free_stream_buffers()
101 stream->dma_addr[stream->buf_num]); in usb_free_stream_buffers()
105 stream->state &= ~USB_STATE_URB_BUF; in usb_free_stream_buffers()
110 static int usb_allocate_stream_buffers(struct usb_data_stream *stream, int num, unsigned long size) in usb_allocate_stream_buffers() argument
112 stream->buf_num = 0; in usb_allocate_stream_buffers()
113 stream->buf_size = size; in usb_allocate_stream_buffers()
117 for (stream->buf_num = 0; stream->buf_num < num; stream->buf_num++) { in usb_allocate_stream_buffers()
118 deb_mem("allocating buffer %d\n",stream->buf_num); in usb_allocate_stream_buffers()
119 if (( stream->buf_list[stream->buf_num] = in usb_allocate_stream_buffers()
120 usb_alloc_coherent(stream->udev, size, GFP_ATOMIC, in usb_allocate_stream_buffers()
121 &stream->dma_addr[stream->buf_num]) ) == NULL) { in usb_allocate_stream_buffers()
123 usb_free_stream_buffers(stream); in usb_allocate_stream_buffers()
127 stream->buf_num, in usb_allocate_stream_buffers()
128 stream->buf_list[stream->buf_num], (long long)stream->dma_addr[stream->buf_num]); in usb_allocate_stream_buffers()
129 memset(stream->buf_list[stream->buf_num],0,size); in usb_allocate_stream_buffers()
130 stream->state |= USB_STATE_URB_BUF; in usb_allocate_stream_buffers()
137 static int usb_bulk_urb_init(struct usb_data_stream *stream) in usb_bulk_urb_init() argument
141 if ((i = usb_allocate_stream_buffers(stream,stream->props.count, in usb_bulk_urb_init()
142 stream->props.u.bulk.buffersize)) < 0) in usb_bulk_urb_init()
146 for (i = 0; i < stream->props.count; i++) { in usb_bulk_urb_init()
147 stream->urb_list[i] = usb_alloc_urb(0, GFP_ATOMIC); in usb_bulk_urb_init()
148 if (!stream->urb_list[i]) { in usb_bulk_urb_init()
151 usb_free_urb(stream->urb_list[j]); in usb_bulk_urb_init()
154 usb_fill_bulk_urb( stream->urb_list[i], stream->udev, in usb_bulk_urb_init()
155 usb_rcvbulkpipe(stream->udev,stream->props.endpoint), in usb_bulk_urb_init()
156 stream->buf_list[i], in usb_bulk_urb_init()
157 stream->props.u.bulk.buffersize, in usb_bulk_urb_init()
158 usb_urb_complete, stream); in usb_bulk_urb_init()
160 stream->urb_list[i]->transfer_flags = URB_NO_TRANSFER_DMA_MAP; in usb_bulk_urb_init()
161 stream->urb_list[i]->transfer_dma = stream->dma_addr[i]; in usb_bulk_urb_init()
162 stream->urbs_initialized++; in usb_bulk_urb_init()
167 static int usb_isoc_urb_init(struct usb_data_stream *stream) in usb_isoc_urb_init() argument
171 if ((i = usb_allocate_stream_buffers(stream,stream->props.count, in usb_isoc_urb_init()
172 stream->props.u.isoc.framesize*stream->props.u.isoc.framesperurb)) < 0) in usb_isoc_urb_init()
176 for (i = 0; i < stream->props.count; i++) { in usb_isoc_urb_init()
180 stream->urb_list[i] = usb_alloc_urb(stream->props.u.isoc.framesperurb, GFP_ATOMIC); in usb_isoc_urb_init()
181 if (!stream->urb_list[i]) { in usb_isoc_urb_init()
184 usb_free_urb(stream->urb_list[j]); in usb_isoc_urb_init()
188 urb = stream->urb_list[i]; in usb_isoc_urb_init()
190 urb->dev = stream->udev; in usb_isoc_urb_init()
191 urb->context = stream; in usb_isoc_urb_init()
193 urb->pipe = usb_rcvisocpipe(stream->udev,stream->props.endpoint); in usb_isoc_urb_init()
195 urb->interval = stream->props.u.isoc.interval; in usb_isoc_urb_init()
196 urb->number_of_packets = stream->props.u.isoc.framesperurb; in usb_isoc_urb_init()
197 urb->transfer_buffer_length = stream->buf_size; in usb_isoc_urb_init()
198 urb->transfer_buffer = stream->buf_list[i]; in usb_isoc_urb_init()
199 urb->transfer_dma = stream->dma_addr[i]; in usb_isoc_urb_init()
201 for (j = 0; j < stream->props.u.isoc.framesperurb; j++) { in usb_isoc_urb_init()
203 urb->iso_frame_desc[j].length = stream->props.u.isoc.framesize; in usb_isoc_urb_init()
204 frame_offset += stream->props.u.isoc.framesize; in usb_isoc_urb_init()
207 stream->urbs_initialized++; in usb_isoc_urb_init()
212 int usb_urb_init(struct usb_data_stream *stream, struct usb_data_stream_properties *props) in usb_urb_init() argument
214 if (stream == NULL || props == NULL) in usb_urb_init()
217 memcpy(&stream->props, props, sizeof(*props)); in usb_urb_init()
219 usb_clear_halt(stream->udev,usb_rcvbulkpipe(stream->udev,stream->props.endpoint)); in usb_urb_init()
221 if (stream->complete == NULL) { in usb_urb_init()
226 switch (stream->props.type) { in usb_urb_init()
228 return usb_bulk_urb_init(stream); in usb_urb_init()
230 return usb_isoc_urb_init(stream); in usb_urb_init()
237 int usb_urb_exit(struct usb_data_stream *stream) in usb_urb_exit() argument
241 usb_urb_kill(stream); in usb_urb_exit()
243 for (i = 0; i < stream->urbs_initialized; i++) { in usb_urb_exit()
244 if (stream->urb_list[i] != NULL) { in usb_urb_exit()
247 usb_free_urb(stream->urb_list[i]); in usb_urb_exit()
250 stream->urbs_initialized = 0; in usb_urb_exit()
252 usb_free_stream_buffers(stream); in usb_urb_exit()