aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/media/v4l2-core/videobuf2-core.c17
-rw-r--r--include/media/videobuf2-core.h4
2 files changed, 18 insertions, 3 deletions
diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c
index c2126d874549..25d3ae2188cb 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -971,6 +971,7 @@ static int __reqbufs(struct vb2_queue *q, struct v4l2_requestbuffers *req)
971 * to the userspace. 971 * to the userspace.
972 */ 972 */
973 req->count = allocated_buffers; 973 req->count = allocated_buffers;
974 q->waiting_for_buffers = !V4L2_TYPE_IS_OUTPUT(q->type);
974 975
975 return 0; 976 return 0;
976} 977}
@@ -1018,6 +1019,7 @@ static int __create_bufs(struct vb2_queue *q, struct v4l2_create_buffers *create
1018 memset(q->plane_sizes, 0, sizeof(q->plane_sizes)); 1019 memset(q->plane_sizes, 0, sizeof(q->plane_sizes));
1019 memset(q->alloc_ctx, 0, sizeof(q->alloc_ctx)); 1020 memset(q->alloc_ctx, 0, sizeof(q->alloc_ctx));
1020 q->memory = create->memory; 1021 q->memory = create->memory;
1022 q->waiting_for_buffers = !V4L2_TYPE_IS_OUTPUT(q->type);
1021 } 1023 }
1022 1024
1023 num_buffers = min(create->count, VIDEO_MAX_FRAME - q->num_buffers); 1025 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)
1821 */ 1823 */
1822 list_add_tail(&vb->queued_entry, &q->queued_list); 1824 list_add_tail(&vb->queued_entry, &q->queued_list);
1823 q->queued_count++; 1825 q->queued_count++;
1826 q->waiting_for_buffers = false;
1824 vb->state = VB2_BUF_STATE_QUEUED; 1827 vb->state = VB2_BUF_STATE_QUEUED;
1825 if (V4L2_TYPE_IS_OUTPUT(q->type)) { 1828 if (V4L2_TYPE_IS_OUTPUT(q->type)) {
1826 /* 1829 /*
@@ -2287,6 +2290,7 @@ static int vb2_internal_streamoff(struct vb2_queue *q, enum v4l2_buf_type type)
2287 * their normal dequeued state. 2290 * their normal dequeued state.
2288 */ 2291 */
2289 __vb2_queue_cancel(q); 2292 __vb2_queue_cancel(q);
2293 q->waiting_for_buffers = !V4L2_TYPE_IS_OUTPUT(q->type);
2290 2294
2291 dprintk(3, "successful\n"); 2295 dprintk(3, "successful\n");
2292 return 0; 2296 return 0;
@@ -2605,10 +2609,17 @@ unsigned int vb2_poll(struct vb2_queue *q, struct file *file, poll_table *wait)
2605 } 2609 }
2606 2610
2607 /* 2611 /*
2608 * There is nothing to wait for if no buffer has been queued and the 2612 * There is nothing to wait for if the queue isn't streaming, or if the
2609 * queue isn't streaming, or if the error flag is set. 2613 * error flag is set.
2610 */ 2614 */
2611 if ((list_empty(&q->queued_list) && !vb2_is_streaming(q)) || q->error) 2615 if (!vb2_is_streaming(q) || q->error)
2616 return res | POLLERR;
2617 /*
2618 * For compatibility with vb1: if QBUF hasn't been called yet, then
2619 * return POLLERR as well. This only affects capture queues, output
2620 * queues will always initialize waiting_for_buffers to false.
2621 */
2622 if (q->waiting_for_buffers)
2612 return res | POLLERR; 2623 return res | POLLERR;
2613 2624
2614 /* 2625 /*
diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h
index 80fa7253e483..2fefcf491aa8 100644
--- a/include/media/videobuf2-core.h
+++ b/include/media/videobuf2-core.h
@@ -380,6 +380,9 @@ struct v4l2_fh;
380 * @start_streaming_called: start_streaming() was called successfully and we 380 * @start_streaming_called: start_streaming() was called successfully and we
381 * started streaming. 381 * started streaming.
382 * @error: a fatal error occurred on the queue 382 * @error: a fatal error occurred on the queue
383 * @waiting_for_buffers: used in poll() to check if vb2 is still waiting for
384 * buffers. Only set for capture queues if qbuf has not yet been
385 * called since poll() needs to return POLLERR in that situation.
383 * @fileio: file io emulator internal data, used only if emulator is active 386 * @fileio: file io emulator internal data, used only if emulator is active
384 * @threadio: thread io internal data, used only if thread is active 387 * @threadio: thread io internal data, used only if thread is active
385 */ 388 */
@@ -417,6 +420,7 @@ struct vb2_queue {
417 unsigned int streaming:1; 420 unsigned int streaming:1;
418 unsigned int start_streaming_called:1; 421 unsigned int start_streaming_called:1;
419 unsigned int error:1; 422 unsigned int error:1;
423 unsigned int waiting_for_buffers:1;
420 424
421 struct vb2_fileio_data *fileio; 425 struct vb2_fileio_data *fileio;
422 struct vb2_threadio_data *threadio; 426 struct vb2_threadio_data *threadio;