linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] vb2: fix vb2_poll for output streams
@ 2014-07-24 12:19 Hans Verkuil
  2014-07-25  5:21 ` Marek Szyprowski
  0 siblings, 1 reply; 2+ messages in thread
From: Hans Verkuil @ 2014-07-24 12:19 UTC (permalink / raw)
  To: linux-media; +Cc: Marek Szyprowski, Pawel Osciak

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.

Signed-off-by: Hans Verkuil <hansverk@cisco.com>
---
 drivers/media/v4l2-core/videobuf2-core.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c
index f33508f..c359006 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -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);
 
-- 
2.0.0.rc0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] vb2: fix vb2_poll for output streams
  2014-07-24 12:19 [PATCH] vb2: fix vb2_poll for output streams Hans Verkuil
@ 2014-07-25  5:21 ` Marek Szyprowski
  0 siblings, 0 replies; 2+ messages in thread
From: Marek Szyprowski @ 2014-07-25  5:21 UTC (permalink / raw)
  To: Hans Verkuil, linux-media; +Cc: Pawel Osciak

Hello,

On 2014-07-24 14:19, Hans Verkuil wrote:
> 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.
>
> Signed-off-by: Hans Verkuil <hansverk@cisco.com>

Acked-by: Marek Szyprowski <m.szyprowski@samsung.com>

> ---
>   drivers/media/v4l2-core/videobuf2-core.c | 7 +++++++
>   1 file changed, 7 insertions(+)
>
> diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c
> index f33508f..c359006 100644
> --- a/drivers/media/v4l2-core/videobuf2-core.c
> +++ b/drivers/media/v4l2-core/videobuf2-core.c
> @@ -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);
>   

Best regards
-- 
Marek Szyprowski, PhD
Samsung R&D Institute Poland


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-07-25  5:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-24 12:19 [PATCH] vb2: fix vb2_poll for output streams Hans Verkuil
2014-07-25  5:21 ` Marek Szyprowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).