Lines Matching refs:stream

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