Lines Matching full:queue

25  * Video buffers queue management.
31 * the videobuf2 queue operations by serializing calls to videobuf2 and a
32 * spinlock to protect the IRQ queue that holds the buffers to be processed by
37 * videobuf2 queue operations
44 struct uvc_video_queue *queue = vb2_get_drv_priv(vq); in uvc_queue_setup() local
45 struct uvc_video *video = container_of(queue, struct uvc_video, queue); in uvc_queue_setup()
59 struct uvc_video_queue *queue = vb2_get_drv_priv(vb->vb2_queue); in uvc_buffer_prepare() local
69 if (unlikely(queue->flags & UVC_QUEUE_DISCONNECTED)) in uvc_buffer_prepare()
85 struct uvc_video_queue *queue = vb2_get_drv_priv(vb->vb2_queue); in uvc_buffer_queue() local
90 spin_lock_irqsave(&queue->irqlock, flags); in uvc_buffer_queue()
92 if (likely(!(queue->flags & UVC_QUEUE_DISCONNECTED))) { in uvc_buffer_queue()
93 list_add_tail(&buf->queue, &queue->irqqueue); in uvc_buffer_queue()
102 spin_unlock_irqrestore(&queue->irqlock, flags); in uvc_buffer_queue()
113 int uvcg_queue_init(struct uvc_video_queue *queue, enum v4l2_buf_type type, in uvcg_queue_init() argument
118 queue->queue.type = type; in uvcg_queue_init()
119 queue->queue.io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF; in uvcg_queue_init()
120 queue->queue.drv_priv = queue; in uvcg_queue_init()
121 queue->queue.buf_struct_size = sizeof(struct uvc_buffer); in uvcg_queue_init()
122 queue->queue.ops = &uvc_queue_qops; in uvcg_queue_init()
123 queue->queue.lock = lock; in uvcg_queue_init()
124 queue->queue.mem_ops = &vb2_vmalloc_memops; in uvcg_queue_init()
125 queue->queue.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC in uvcg_queue_init()
127 ret = vb2_queue_init(&queue->queue); in uvcg_queue_init()
131 spin_lock_init(&queue->irqlock); in uvcg_queue_init()
132 INIT_LIST_HEAD(&queue->irqqueue); in uvcg_queue_init()
133 queue->flags = 0; in uvcg_queue_init()
141 void uvcg_free_buffers(struct uvc_video_queue *queue) in uvcg_free_buffers() argument
143 vb2_queue_release(&queue->queue); in uvcg_free_buffers()
149 int uvcg_alloc_buffers(struct uvc_video_queue *queue, in uvcg_alloc_buffers() argument
154 ret = vb2_reqbufs(&queue->queue, rb); in uvcg_alloc_buffers()
159 int uvcg_query_buffer(struct uvc_video_queue *queue, struct v4l2_buffer *buf) in uvcg_query_buffer() argument
161 return vb2_querybuf(&queue->queue, buf); in uvcg_query_buffer()
164 int uvcg_queue_buffer(struct uvc_video_queue *queue, struct v4l2_buffer *buf) in uvcg_queue_buffer() argument
169 ret = vb2_qbuf(&queue->queue, NULL, buf); in uvcg_queue_buffer()
173 spin_lock_irqsave(&queue->irqlock, flags); in uvcg_queue_buffer()
174 ret = (queue->flags & UVC_QUEUE_PAUSED) != 0; in uvcg_queue_buffer()
175 queue->flags &= ~UVC_QUEUE_PAUSED; in uvcg_queue_buffer()
176 spin_unlock_irqrestore(&queue->irqlock, flags); in uvcg_queue_buffer()
184 int uvcg_dequeue_buffer(struct uvc_video_queue *queue, struct v4l2_buffer *buf, in uvcg_dequeue_buffer() argument
187 return vb2_dqbuf(&queue->queue, buf, nonblocking); in uvcg_dequeue_buffer()
191 * Poll the video queue.
193 * This function implements video queue polling and is intended to be used by
196 __poll_t uvcg_queue_poll(struct uvc_video_queue *queue, struct file *file, in uvcg_queue_poll() argument
199 return vb2_poll(&queue->queue, file, wait); in uvcg_queue_poll()
202 int uvcg_queue_mmap(struct uvc_video_queue *queue, struct vm_area_struct *vma) in uvcg_queue_mmap() argument
204 return vb2_mmap(&queue->queue, vma); in uvcg_queue_mmap()
213 unsigned long uvcg_queue_get_unmapped_area(struct uvc_video_queue *queue, in uvcg_queue_get_unmapped_area() argument
216 return vb2_get_unmapped_area(&queue->queue, 0, 0, pgoff, 0); in uvcg_queue_get_unmapped_area()
221 * Cancel the video buffers queue.
223 * Cancelling the queue marks all buffers on the irq queue as erroneous,
224 * wakes them up and removes them from the queue.
232 void uvcg_queue_cancel(struct uvc_video_queue *queue, int disconnect) in uvcg_queue_cancel() argument
237 spin_lock_irqsave(&queue->irqlock, flags); in uvcg_queue_cancel()
238 while (!list_empty(&queue->irqqueue)) { in uvcg_queue_cancel()
239 buf = list_first_entry(&queue->irqqueue, struct uvc_buffer, in uvcg_queue_cancel()
240 queue); in uvcg_queue_cancel()
241 list_del(&buf->queue); in uvcg_queue_cancel()
249 * state outside the queue code. in uvcg_queue_cancel()
252 queue->flags |= UVC_QUEUE_DISCONNECTED; in uvcg_queue_cancel()
253 spin_unlock_irqrestore(&queue->irqlock, flags); in uvcg_queue_cancel()
257 * Enable or disable the video buffers queue.
259 * The queue must be enabled before starting video acquisition and must be
260 * disabled after stopping it. This ensures that the video buffers queue
264 * Enabling the video queue initializes parameters (such as sequence number,
265 * sync pattern, ...). If the queue is already enabled, return -EBUSY.
267 * Disabling the video queue cancels the queue and removes all buffers from
268 * the main queue.
273 int uvcg_queue_enable(struct uvc_video_queue *queue, int enable) in uvcg_queue_enable() argument
279 ret = vb2_streamon(&queue->queue, queue->queue.type); in uvcg_queue_enable()
283 queue->sequence = 0; in uvcg_queue_enable()
284 queue->buf_used = 0; in uvcg_queue_enable()
286 ret = vb2_streamoff(&queue->queue, queue->queue.type); in uvcg_queue_enable()
290 spin_lock_irqsave(&queue->irqlock, flags); in uvcg_queue_enable()
291 INIT_LIST_HEAD(&queue->irqqueue); in uvcg_queue_enable()
295 * applications will be able to queue buffers for the next in uvcg_queue_enable()
299 queue->flags &= ~UVC_QUEUE_DISCONNECTED; in uvcg_queue_enable()
300 spin_unlock_irqrestore(&queue->irqlock, flags); in uvcg_queue_enable()
307 struct uvc_buffer *uvcg_queue_next_buffer(struct uvc_video_queue *queue, in uvcg_queue_next_buffer() argument
312 if ((queue->flags & UVC_QUEUE_DROP_INCOMPLETE) && in uvcg_queue_next_buffer()
319 list_del(&buf->queue); in uvcg_queue_next_buffer()
320 if (!list_empty(&queue->irqqueue)) in uvcg_queue_next_buffer()
321 nextbuf = list_first_entry(&queue->irqqueue, struct uvc_buffer, in uvcg_queue_next_buffer()
322 queue); in uvcg_queue_next_buffer()
327 buf->buf.sequence = queue->sequence++; in uvcg_queue_next_buffer()
336 struct uvc_buffer *uvcg_queue_head(struct uvc_video_queue *queue) in uvcg_queue_head() argument
340 if (!list_empty(&queue->irqqueue)) in uvcg_queue_head()
341 buf = list_first_entry(&queue->irqqueue, struct uvc_buffer, in uvcg_queue_head()
342 queue); in uvcg_queue_head()
344 queue->flags |= UVC_QUEUE_PAUSED; in uvcg_queue_head()