Lines Matching refs:stream

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