Lines Matching refs:queue
45 static void uvc_queue_return_buffers(struct uvc_video_queue *queue, in uvc_queue_return_buffers() argument
52 while (!list_empty(&queue->irqqueue)) { in uvc_queue_return_buffers()
53 struct uvc_buffer *buf = list_first_entry(&queue->irqqueue, in uvc_queue_return_buffers()
55 queue); in uvc_queue_return_buffers()
56 list_del(&buf->queue); in uvc_queue_return_buffers()
70 struct uvc_video_queue *queue = vb2_get_drv_priv(vq); in uvc_queue_setup() local
80 stream = uvc_queue_to_stream(queue); in uvc_queue_setup()
101 struct uvc_video_queue *queue = vb2_get_drv_priv(vb->vb2_queue); in uvc_buffer_prepare() local
106 uvc_dbg(uvc_queue_to_stream(queue)->dev, CAPTURE, in uvc_buffer_prepare()
111 if (unlikely(queue->flags & UVC_QUEUE_DISCONNECTED)) in uvc_buffer_prepare()
129 struct uvc_video_queue *queue = vb2_get_drv_priv(vb->vb2_queue); in uvc_buffer_queue() local
133 spin_lock_irqsave(&queue->irqlock, flags); in uvc_buffer_queue()
134 if (likely(!(queue->flags & UVC_QUEUE_DISCONNECTED))) { in uvc_buffer_queue()
136 list_add_tail(&buf->queue, &queue->irqqueue); in uvc_buffer_queue()
146 spin_unlock_irqrestore(&queue->irqlock, flags); in uvc_buffer_queue()
152 struct uvc_video_queue *queue = vb2_get_drv_priv(vb->vb2_queue); in uvc_buffer_finish() local
153 struct uvc_streaming *stream = uvc_queue_to_stream(queue); in uvc_buffer_finish()
162 struct uvc_video_queue *queue = vb2_get_drv_priv(vq); in uvc_start_streaming() local
163 struct uvc_streaming *stream = uvc_queue_to_stream(queue); in uvc_start_streaming()
168 queue->buf_used = 0; in uvc_start_streaming()
174 spin_lock_irq(&queue->irqlock); in uvc_start_streaming()
175 uvc_queue_return_buffers(queue, UVC_BUF_STATE_QUEUED); in uvc_start_streaming()
176 spin_unlock_irq(&queue->irqlock); in uvc_start_streaming()
183 struct uvc_video_queue *queue = vb2_get_drv_priv(vq); in uvc_stop_streaming() local
188 uvc_video_stop_streaming(uvc_queue_to_stream(queue)); in uvc_stop_streaming()
190 spin_lock_irq(&queue->irqlock); in uvc_stop_streaming()
191 uvc_queue_return_buffers(queue, UVC_BUF_STATE_ERROR); in uvc_stop_streaming()
192 spin_unlock_irq(&queue->irqlock); in uvc_stop_streaming()
215 int uvc_queue_init(struct uvc_video_queue *queue, enum v4l2_buf_type type, in uvc_queue_init() argument
220 queue->queue.type = type; in uvc_queue_init()
221 queue->queue.io_modes = VB2_MMAP | VB2_USERPTR; in uvc_queue_init()
222 queue->queue.drv_priv = queue; in uvc_queue_init()
223 queue->queue.buf_struct_size = sizeof(struct uvc_buffer); in uvc_queue_init()
224 queue->queue.mem_ops = &vb2_vmalloc_memops; in uvc_queue_init()
225 queue->queue.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC in uvc_queue_init()
227 queue->queue.lock = &queue->mutex; in uvc_queue_init()
231 queue->queue.ops = &uvc_meta_queue_qops; in uvc_queue_init()
234 queue->queue.io_modes |= VB2_DMABUF; in uvc_queue_init()
235 queue->queue.ops = &uvc_queue_qops; in uvc_queue_init()
239 ret = vb2_queue_init(&queue->queue); in uvc_queue_init()
243 mutex_init(&queue->mutex); in uvc_queue_init()
244 spin_lock_init(&queue->irqlock); in uvc_queue_init()
245 INIT_LIST_HEAD(&queue->irqqueue); in uvc_queue_init()
246 queue->flags = drop_corrupted ? UVC_QUEUE_DROP_CORRUPTED : 0; in uvc_queue_init()
251 void uvc_queue_release(struct uvc_video_queue *queue) in uvc_queue_release() argument
253 mutex_lock(&queue->mutex); in uvc_queue_release()
254 vb2_queue_release(&queue->queue); in uvc_queue_release()
255 mutex_unlock(&queue->mutex); in uvc_queue_release()
262 int uvc_request_buffers(struct uvc_video_queue *queue, in uvc_request_buffers() argument
267 mutex_lock(&queue->mutex); in uvc_request_buffers()
268 ret = vb2_reqbufs(&queue->queue, rb); in uvc_request_buffers()
269 mutex_unlock(&queue->mutex); in uvc_request_buffers()
274 int uvc_query_buffer(struct uvc_video_queue *queue, struct v4l2_buffer *buf) in uvc_query_buffer() argument
278 mutex_lock(&queue->mutex); in uvc_query_buffer()
279 ret = vb2_querybuf(&queue->queue, buf); in uvc_query_buffer()
280 mutex_unlock(&queue->mutex); in uvc_query_buffer()
285 int uvc_create_buffers(struct uvc_video_queue *queue, in uvc_create_buffers() argument
290 mutex_lock(&queue->mutex); in uvc_create_buffers()
291 ret = vb2_create_bufs(&queue->queue, cb); in uvc_create_buffers()
292 mutex_unlock(&queue->mutex); in uvc_create_buffers()
297 int uvc_queue_buffer(struct uvc_video_queue *queue, in uvc_queue_buffer() argument
302 mutex_lock(&queue->mutex); in uvc_queue_buffer()
303 ret = vb2_qbuf(&queue->queue, mdev, buf); in uvc_queue_buffer()
304 mutex_unlock(&queue->mutex); in uvc_queue_buffer()
309 int uvc_export_buffer(struct uvc_video_queue *queue, in uvc_export_buffer() argument
314 mutex_lock(&queue->mutex); in uvc_export_buffer()
315 ret = vb2_expbuf(&queue->queue, exp); in uvc_export_buffer()
316 mutex_unlock(&queue->mutex); in uvc_export_buffer()
321 int uvc_dequeue_buffer(struct uvc_video_queue *queue, struct v4l2_buffer *buf, in uvc_dequeue_buffer() argument
326 mutex_lock(&queue->mutex); in uvc_dequeue_buffer()
327 ret = vb2_dqbuf(&queue->queue, buf, nonblocking); in uvc_dequeue_buffer()
328 mutex_unlock(&queue->mutex); in uvc_dequeue_buffer()
333 int uvc_queue_streamon(struct uvc_video_queue *queue, enum v4l2_buf_type type) in uvc_queue_streamon() argument
337 mutex_lock(&queue->mutex); in uvc_queue_streamon()
338 ret = vb2_streamon(&queue->queue, type); in uvc_queue_streamon()
339 mutex_unlock(&queue->mutex); in uvc_queue_streamon()
344 int uvc_queue_streamoff(struct uvc_video_queue *queue, enum v4l2_buf_type type) in uvc_queue_streamoff() argument
348 mutex_lock(&queue->mutex); in uvc_queue_streamoff()
349 ret = vb2_streamoff(&queue->queue, type); in uvc_queue_streamoff()
350 mutex_unlock(&queue->mutex); in uvc_queue_streamoff()
355 int uvc_queue_mmap(struct uvc_video_queue *queue, struct vm_area_struct *vma) in uvc_queue_mmap() argument
357 return vb2_mmap(&queue->queue, vma); in uvc_queue_mmap()
361 unsigned long uvc_queue_get_unmapped_area(struct uvc_video_queue *queue, in uvc_queue_get_unmapped_area() argument
364 return vb2_get_unmapped_area(&queue->queue, 0, 0, pgoff, 0); in uvc_queue_get_unmapped_area()
368 __poll_t uvc_queue_poll(struct uvc_video_queue *queue, struct file *file, in uvc_queue_poll() argument
373 mutex_lock(&queue->mutex); in uvc_queue_poll()
374 ret = vb2_poll(&queue->queue, file, wait); in uvc_queue_poll()
375 mutex_unlock(&queue->mutex); in uvc_queue_poll()
387 int uvc_queue_allocated(struct uvc_video_queue *queue) in uvc_queue_allocated() argument
391 mutex_lock(&queue->mutex); in uvc_queue_allocated()
392 allocated = vb2_is_busy(&queue->queue); in uvc_queue_allocated()
393 mutex_unlock(&queue->mutex); in uvc_queue_allocated()
410 void uvc_queue_cancel(struct uvc_video_queue *queue, int disconnect) in uvc_queue_cancel() argument
414 spin_lock_irqsave(&queue->irqlock, flags); in uvc_queue_cancel()
415 uvc_queue_return_buffers(queue, UVC_BUF_STATE_ERROR); in uvc_queue_cancel()
424 queue->flags |= UVC_QUEUE_DISCONNECTED; in uvc_queue_cancel()
425 spin_unlock_irqrestore(&queue->irqlock, flags); in uvc_queue_cancel()
435 __uvc_queue_get_current_buffer(struct uvc_video_queue *queue) in __uvc_queue_get_current_buffer() argument
437 if (list_empty(&queue->irqqueue)) in __uvc_queue_get_current_buffer()
440 return list_first_entry(&queue->irqqueue, struct uvc_buffer, queue); in __uvc_queue_get_current_buffer()
443 struct uvc_buffer *uvc_queue_get_current_buffer(struct uvc_video_queue *queue) in uvc_queue_get_current_buffer() argument
448 spin_lock_irqsave(&queue->irqlock, flags); in uvc_queue_get_current_buffer()
449 nextbuf = __uvc_queue_get_current_buffer(queue); in uvc_queue_get_current_buffer()
450 spin_unlock_irqrestore(&queue->irqlock, flags); in uvc_queue_get_current_buffer()
462 static void uvc_queue_buffer_requeue(struct uvc_video_queue *queue, in uvc_queue_buffer_requeue() argument
477 struct uvc_video_queue *queue = vb2_get_drv_priv(vb->vb2_queue); in uvc_queue_buffer_complete() local
479 if ((queue->flags & UVC_QUEUE_DROP_CORRUPTED) && buf->error) { in uvc_queue_buffer_complete()
480 uvc_queue_buffer_requeue(queue, buf); in uvc_queue_buffer_complete()
503 struct uvc_buffer *uvc_queue_next_buffer(struct uvc_video_queue *queue, in uvc_queue_next_buffer() argument
509 spin_lock_irqsave(&queue->irqlock, flags); in uvc_queue_next_buffer()
510 list_del(&buf->queue); in uvc_queue_next_buffer()
511 nextbuf = __uvc_queue_get_current_buffer(queue); in uvc_queue_next_buffer()
512 spin_unlock_irqrestore(&queue->irqlock, flags); in uvc_queue_next_buffer()