Skip to contentSkip to conversation

vb2: fix vb2_poll for output streams

PATCH In review Hans Verkuil 2 participants 2 messages Jul 24, 2014 – Jul 25, 2014 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vb2: fix vb2_poll for output streams

vb2_poll should always return POLLOUT | POLLWRNORM as long as there are fewer buffers queued than there are buffers available. Poll for an output stream should only wait if all buffers are queued and nobody is dequeuing them.

---
 drivers/media/v4l2-core/videobuf2-core.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/media/v4l2-core/videobuf2-core.c +7 -0
index f33508f..c359006 100644
@@ -2596,6 +2596,13 @@ unsigned int vb2_poll(struct vb2_queue *q, struct file *file, poll_table *wait)
 	if ((list_empty(&q->queued_list) && !vb2_is_streaming(q)) || q->error)
 		return res | POLLERR;
 
+	/*
+	 * For output streams you can write as long as there are fewer buffers
+	 * queued than there are buffers available.
+	 */
+	if (V4L2_TYPE_IS_OUTPUT(q->type) && q->queued_count < q->num_buffers)
+		return res | POLLOUT | POLLWRNORM;
+
 	if (list_empty(&q->done_list))
 		poll_wait(file, &q->done_wq, wait);
 
Signature · 1 line
2.0.0.rc0
Acked-by on v1 1/1
#1 lore raw

Hello,

Quoted 6 lines · Hans Verkuil

vb2_poll should always return POLLOUT | POLLWRNORM as long as there are fewer buffers queued than there are buffers available. Poll for an output stream should only wait if all buffers are queued and nobody is dequeuing them.

Quoted 12 lines
---
  drivers/media/v4l2-core/videobuf2-core.c | 7 +++++++
  1 file changed, 7 insertions(+)
drivers/media/v4l2-core/videobuf2-core.c +0 -0
index f33508f..c359006 100644
@@ -2596,6 +2596,13 @@ unsigned int vb2_poll(struct vb2_queue *q, struct file *file, poll_table *wait)
  	if ((list_empty(&q->queued_list) && !vb2_is_streaming(q)) || q->error)
  		return res | POLLERR;
 

drivers/media/v4l2-core/videobuf2-core.c unsigned int vb2_poll(struct vb2_queue *q, struct file *file, poll_table *wait) · line 2608

Quoted 10 lines
drivers/media/v4l2-core/videobuf2-core.c +7 -0
+	/*
+	 * For output streams you can write as long as there are fewer buffers
+	 * queued than there are buffers available.
+	 */
+	if (V4L2_TYPE_IS_OUTPUT(q->type) && q->queued_count < q->num_buffers)
+		return res | POLLOUT | POLLWRNORM;
+
  	if (list_empty(&q->done_list))
  		poll_wait(file, &q->done_wq, wait);
 

Best regards

Signature · 2 lines
Marek Szyprowski, PhD
Samsung R&D Institute Poland