linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "André Almeida" <andrealmeid@collabora.com>
To: linux-media@vger.kernel.org
Cc: mchehab@kernel.org, hverkuil@xs4all.nl,
	helen.koike@collabora.com, kernel@collabora.com,
	linux-kernel@vger.kernel.org,
	"André Almeida" <andrealmeid@collabora.com>
Subject: [PATCH 4/7] media: vimc: Send null buffer through the pipeline
Date: Tue,  2 Jul 2019 12:47:49 -0300	[thread overview]
Message-ID: <20190702154752.14939-5-andrealmeid@collabora.com> (raw)
In-Reply-To: <20190702154752.14939-1-andrealmeid@collabora.com>

Send a NULL buffer through the video pipeline. If the Capture device
gets a NULL buffer, it uses it default fallback frame. Make the capture
device behave more like real devices when there's no frame to show.

Signed-off-by: André Almeida <andrealmeid@collabora.com>
---
 drivers/media/platform/vimc/vimc-capture.c  | 15 +++++++++++++++
 drivers/media/platform/vimc/vimc-debayer.c  |  3 +++
 drivers/media/platform/vimc/vimc-scaler.c   |  3 +++
 drivers/media/platform/vimc/vimc-streamer.c |  2 +-
 4 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/vimc/vimc-capture.c b/drivers/media/platform/vimc/vimc-capture.c
index e80fa1ee3dc1..4c65bf73530f 100644
--- a/drivers/media/platform/vimc/vimc-capture.c
+++ b/drivers/media/platform/vimc/vimc-capture.c
@@ -37,6 +37,15 @@ static int vimc_cap_start_streaming(struct vb2_queue *vq, unsigned int count)
 
 	vcap->sequence = 0;
 
+	/* this is a fallback frame, it will be used if the pipeline
+	 * is sending NULL frames
+	 */
+	vcap->frame = vmalloc(vcap->format.sizeimage);
+	if (!vcap->frame) {
+		vimc_vid_return_all_buffers(vcap, VB2_BUF_STATE_QUEUED);
+		return -ENOMEM;
+	}
+
 	/* Start the media pipeline */
 	ret = media_pipeline_start(entity, &vcap->stream.pipe);
 	if (ret) {
@@ -65,6 +74,9 @@ void vimc_cap_stop_streaming(struct vb2_queue *vq)
 
 	vimc_streamer_s_stream(&vcap->stream, &vcap->ved, 0);
 
+	vfree(vcap->frame);
+	vcap->frame = NULL;
+
 	media_pipeline_stop(&vcap->vdev.entity);
 
 	vimc_vid_return_all_buffers(vcap, VB2_BUF_STATE_ERROR);
@@ -96,6 +108,9 @@ static void *vimc_cap_process_frame(struct vimc_ent_device *ved,
 	struct vimc_vid_buffer *vimc_buf;
 	void *vbuf;
 
+	if (!frame)
+		frame = &vcap->frame;
+
 	spin_lock(&vcap->qlock);
 
 	/* Get the first entry of the list */
diff --git a/drivers/media/platform/vimc/vimc-debayer.c b/drivers/media/platform/vimc/vimc-debayer.c
index 9e0c7c2c3c72..d5f370f94573 100644
--- a/drivers/media/platform/vimc/vimc-debayer.c
+++ b/drivers/media/platform/vimc/vimc-debayer.c
@@ -483,6 +483,9 @@ static void *vimc_deb_process_frame(struct vimc_ent_device *ved,
 	unsigned int rgb[3];
 	unsigned int i, j;
 
+	if (!sink_frame)
+		return NULL;
+
 	/* If the stream in this node is not active, just return */
 	if (!vdeb->src_frame)
 		return ERR_PTR(-EINVAL);
diff --git a/drivers/media/platform/vimc/vimc-scaler.c b/drivers/media/platform/vimc/vimc-scaler.c
index 2c3e486a29c0..9edad3b14526 100644
--- a/drivers/media/platform/vimc/vimc-scaler.c
+++ b/drivers/media/platform/vimc/vimc-scaler.c
@@ -320,6 +320,9 @@ static void *vimc_sca_process_frame(struct vimc_ent_device *ved,
 	struct vimc_sca_device *vsca = container_of(ved, struct vimc_sca_device,
 						    ved);
 
+	if (!sink_frame)
+		return NULL;
+
 	/* If the stream in this node is not active, just return */
 	if (!ved->stream)
 		return ERR_PTR(-EINVAL);
diff --git a/drivers/media/platform/vimc/vimc-streamer.c b/drivers/media/platform/vimc/vimc-streamer.c
index fd330415ac38..f06c9308a41b 100644
--- a/drivers/media/platform/vimc/vimc-streamer.c
+++ b/drivers/media/platform/vimc/vimc-streamer.c
@@ -133,7 +133,7 @@ static int vimc_streamer_thread(void *data)
 		for (i = stream->pipe_size - 1; i >= 0; i--) {
 			frame = stream->ved_pipeline[i]->process_frame(
 					stream->ved_pipeline[i], frame);
-			if (!frame || IS_ERR(frame))
+			if (IS_ERR(frame))
 				break;
 		}
 
-- 
2.22.0


  parent reply	other threads:[~2019-07-02 15:49 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-02 15:47 [PATCH 0/7] media: vimc: Add a V4L2 output device André Almeida
2019-07-02 15:47 ` [PATCH 1/7] media: vimc: Create video module André Almeida
2019-07-02 15:47 ` [PATCH 2/7] media: vimc: video: Add write file operation André Almeida
2019-07-02 15:47 ` [PATCH 3/7] media: vimc: Create a V4L2 output device André Almeida
2019-07-09 22:20   ` Helen Koike
2019-07-02 15:47 ` André Almeida [this message]
2019-07-02 15:47 ` [PATCH 5/7] media: vimc: core: Add output device on the pipeline André Almeida
2019-07-09 22:20   ` Helen Koike
2019-07-02 15:47 ` [PATCH 6/7] media: vimc.dot: Update default topology diagram André Almeida
2019-07-02 15:47 ` [PATCH 7/7] media: vimc.rst: Add output device André Almeida
2019-07-09 22:19 ` [PATCH 0/7] media: vimc: Add a V4L2 " Helen Koike
2019-07-10  7:33   ` Hans Verkuil
2019-07-12 15:38     ` André Almeida
2019-07-13 10:03       ` Hans Verkuil
2019-07-31  3:00         ` André Almeida

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190702154752.14939-5-andrealmeid@collabora.com \
    --to=andrealmeid@collabora.com \
    --cc=helen.koike@collabora.com \
    --cc=hverkuil@xs4all.nl \
    --cc=kernel@collabora.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).