|
@@ -971,6 +971,7 @@ static int __reqbufs(struct vb2_queue *q, struct v4l2_requestbuffers *req)
|
|
|
* to the userspace.
|
|
|
*/
|
|
|
req->count = allocated_buffers;
|
|
|
+ q->waiting_for_buffers = !V4L2_TYPE_IS_OUTPUT(q->type);
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
@@ -1018,6 +1019,7 @@ static int __create_bufs(struct vb2_queue *q, struct v4l2_create_buffers *create
|
|
|
memset(q->plane_sizes, 0, sizeof(q->plane_sizes));
|
|
|
memset(q->alloc_ctx, 0, sizeof(q->alloc_ctx));
|
|
|
q->memory = create->memory;
|
|
|
+ q->waiting_for_buffers = !V4L2_TYPE_IS_OUTPUT(q->type);
|
|
|
}
|
|
|
|
|
|
num_buffers = min(create->count, VIDEO_MAX_FRAME - q->num_buffers);
|
|
@@ -1821,6 +1823,7 @@ static int vb2_internal_qbuf(struct vb2_queue *q, struct v4l2_buffer *b)
|
|
|
*/
|
|
|
list_add_tail(&vb->queued_entry, &q->queued_list);
|
|
|
q->queued_count++;
|
|
|
+ q->waiting_for_buffers = false;
|
|
|
vb->state = VB2_BUF_STATE_QUEUED;
|
|
|
if (V4L2_TYPE_IS_OUTPUT(q->type)) {
|
|
|
/*
|
|
@@ -2287,6 +2290,7 @@ static int vb2_internal_streamoff(struct vb2_queue *q, enum v4l2_buf_type type)
|
|
|
* their normal dequeued state.
|
|
|
*/
|
|
|
__vb2_queue_cancel(q);
|
|
|
+ q->waiting_for_buffers = !V4L2_TYPE_IS_OUTPUT(q->type);
|
|
|
|
|
|
dprintk(3, "successful\n");
|
|
|
return 0;
|
|
@@ -2605,10 +2609,17 @@ unsigned int vb2_poll(struct vb2_queue *q, struct file *file, poll_table *wait)
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
- * There is nothing to wait for if no buffer has been queued and the
|
|
|
- * queue isn't streaming, or if the error flag is set.
|
|
|
+ * There is nothing to wait for if the queue isn't streaming, or if the
|
|
|
+ * error flag is set.
|
|
|
*/
|
|
|
- if ((list_empty(&q->queued_list) && !vb2_is_streaming(q)) || q->error)
|
|
|
+ if (!vb2_is_streaming(q) || q->error)
|
|
|
+ return res | POLLERR;
|
|
|
+ /*
|
|
|
+ * For compatibility with vb1: if QBUF hasn't been called yet, then
|
|
|
+ * return POLLERR as well. This only affects capture queues, output
|
|
|
+ * queues will always initialize waiting_for_buffers to false.
|
|
|
+ */
|
|
|
+ if (q->waiting_for_buffers)
|
|
|
return res | POLLERR;
|
|
|
|
|
|
/*
|