Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1728383

[PATCH v3 03/15] [media] vb2: check earlier if stream can be started

From Gustavo Padovan <gustavo@padovan.org>
Newsgroups linux.kernel
Subject [PATCH v3 03/15] [media] vb2: check earlier if stream can be started
Date 2017-09-07 20:50 +0200
Message-ID <una2f-3SJ-45@gated-at.bofh.it> (permalink)
References <una2d-3SJ-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Gustavo Padovan <gustavo.padovan@collabora.com>

To support explicit synchronization we need to run all operations that can
fail before we queue the buffer to the driver. With fences the queueing
will be delayed if the fence is not signaled yet and it will be better if
such callback do not fail.

For that we move the vb2_start_streaming() before the queuing for the
buffer may happen.

Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.com>
---
 drivers/media/v4l2-core/videobuf2-core.c | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c
index cb115ba6a1d2..60f8b582396a 100644
--- a/drivers/media/v4l2-core/videobuf2-core.c
+++ b/drivers/media/v4l2-core/videobuf2-core.c
@@ -1399,29 +1399,27 @@ int vb2_core_qbuf(struct vb2_queue *q, unsigned int index, void *pb)
 	trace_vb2_qbuf(q, vb);
 
 	/*
-	 * If already streaming, give the buffer to driver for processing.
-	 * If not, the buffer will be given to driver on next streamon.
-	 */
-	if (q->start_streaming_called)
-		__enqueue_in_driver(vb);
-
-	/* Fill buffer information for the userspace */
-	if (pb)
-		call_void_bufop(q, fill_user_buffer, vb, pb);
-
-	/*
 	 * If streamon has been called, and we haven't yet called
 	 * start_streaming() since not enough buffers were queued, and
 	 * we now have reached the minimum number of queued buffers,
 	 * then we can finally call start_streaming().
+	 *
+	 * If already streaming, give the buffer to driver for processing.
+	 * If not, the buffer will be given to driver on next streamon.
 	 */
 	if (q->streaming && !q->start_streaming_called &&
 	    q->queued_count >= q->min_buffers_needed) {
 		ret = vb2_start_streaming(q);
 		if (ret)
 			return ret;
+	} else if (q->start_streaming_called) {
+		__enqueue_in_driver(vb);
 	}
 
+	/* Fill buffer information for the userspace */
+	if (pb)
+		call_void_bufop(q, fill_user_buffer, vb, pb);
+
 	dprintk(2, "qbuf of buffer %d succeeded\n", vb->index);
 	return 0;
 }
-- 
2.13.5

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v3 00/15] V4L2 Explicit Synchronization support Gustavo Padovan <gustavo@padovan.org> - 2017-09-07 20:50 +0200
  [PATCH v3 14/15] fs/files: export close_fd() symbol Gustavo Padovan <gustavo@padovan.org> - 2017-09-07 20:50 +0200
    Re: [PATCH v3 14/15] fs/files: export close_fd() symbol Eric Biggers <ebiggers3@gmail.com> - 2017-09-07 21:00 +0200
    Re: [PATCH v3 14/15] fs/files: export close_fd() symbol Al Viro <viro@ZenIV.linux.org.uk> - 2017-09-07 22:40 +0200
      Re: [PATCH v3 14/15] fs/files: export close_fd() symbol Gustavo Padovan <gustavo@padovan.org> - 2017-09-07 23:30 +0200
        Re: [PATCH v3 14/15] fs/files: export close_fd() symbol Al Viro <viro@ZenIV.linux.org.uk> - 2017-09-08 00:10 +0200
    Re: [PATCH v3 14/15] fs/files: export close_fd() symbol Hans Verkuil <hverkuil@xs4all.nl> - 2017-09-08 00:10 +0200
      Re: [PATCH v3 14/15] fs/files: export close_fd() symbol Gustavo Padovan <gustavo.padovan@collabora.com> - 2017-09-08 00:20 +0200
  [PATCH v3 08/15] [media] vb2: add .buffer_queued() to notify queueing in the driver Gustavo Padovan <gustavo@padovan.org> - 2017-09-07 20:50 +0200
  [PATCH v3 03/15] [media] vb2: check earlier if stream can be started Gustavo Padovan <gustavo@padovan.org> - 2017-09-07 20:50 +0200
  [PATCH v3 07/15] [media] v4l: add V4L2_EVENT_BUF_QUEUED event Gustavo Padovan <gustavo@padovan.org> - 2017-09-07 20:50 +0200
  [PATCH v3 12/15] [media] vb2: add videobuf2 dma-buf fence helpers Gustavo Padovan <gustavo@padovan.org> - 2017-09-07 20:50 +0200
  [PATCH v3 09/15] [media] v4l: add support to BUF_QUEUED event Gustavo Padovan <gustavo@padovan.org> - 2017-09-07 20:50 +0200
  [PATCH v3 02/15] [media] vb2: add explicit fence user API Gustavo Padovan <gustavo@padovan.org> - 2017-09-07 20:50 +0200
  [PATCH v3 13/15] [media] vb2: add infrastructure to support out-fences Gustavo Padovan <gustavo@padovan.org> - 2017-09-07 20:50 +0200

csiph-web