Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3504627ybi; Tue, 2 Jul 2019 08:51:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqwiIhHVwol/DHpbiRMKTwr3xdsX/msUoLs006aXzDen/dabE2M9DMzDm1aPgOO8OQD/Q3op X-Received: by 2002:a17:90a:1b48:: with SMTP id q66mr6096118pjq.83.1562082677071; Tue, 02 Jul 2019 08:51:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562082677; cv=none; d=google.com; s=arc-20160816; b=usRFK1uudDIPXu4+m7ohLpjo9e89hO3t8mzHZfezPVSpRiT3ZBisPglKlIhtu099nD sUal6V7P6v9FGvuYMcl3B+KSO3mQlBqInRBtPu2LmasYGl25gwC7+6uOOebMjOZp0dVL 8H04cNtMPV4e9MRD0cPOLQZ74O7Iy3pbm/pPlQXBqtWByBNQXar7sc1hOFA2aic7Ff7/ wWLslO0yuQV332diAt/c34VcY9LsdLkam4YOeY//5P0FqLvTyffT4vTOfvxrkCvOhazy nwzfM2jSN8mEm/6b9xiQew7+3JTXlBJTxXUtGG7J9E0SO46rtDEkr/c9gfMWySEhW3WP JxOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=axeMVXupj629iANI+OIugi2bvOX74zzyKRQOigCFjH0=; b=FlUjtpFgsVj/9bEBn9WREDoUDLuhxSfGVpKGQ/5aHDGabAs0Nwd1sGauKfkRYy72Ft rQzprzfopZajs+Bx8sU7p4ce1HHGRDP/fQdpnUziFE+G8m+4bYQqIHBa43FMa2wqn3We 1pqY5gYreU3LsOysyS9Y1YlvS+Kg46ujCyJ4n6CbJa/1KuzVbHeGLMtnLQm1hKImOZSI l2BHF/ID2LyZVzjgadZ6RjZ1jqD5pNafekk7u1D3K+ghcLmPKfR6e/AZyYlK8ULUcd3Y Qt3dogcUgIBZbjiV8/Lk2NtMp50tm6HPfmbBbeF6awyZsCHRAgLlSemTtm0qZFee4QMi 9CCw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f9si13494933pgg.450.2019.07.02.08.51.02; Tue, 02 Jul 2019 08:51:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727188AbfGBPtO (ORCPT + 99 others); Tue, 2 Jul 2019 11:49:14 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:58382 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727168AbfGBPtM (ORCPT ); Tue, 2 Jul 2019 11:49:12 -0400 Received: from turingmachine.home (unknown [IPv6:2804:431:c7f4:61e7:d711:794d:1c68:5ed3]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: tonyk) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id 30796289C8A; Tue, 2 Jul 2019 16:49:07 +0100 (BST) From: =?UTF-8?q?Andr=C3=A9=20Almeida?= 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, =?UTF-8?q?Andr=C3=A9=20Almeida?= Subject: [PATCH 4/7] media: vimc: Send null buffer through the pipeline Date: Tue, 2 Jul 2019 12:47:49 -0300 Message-Id: <20190702154752.14939-5-andrealmeid@collabora.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190702154752.14939-1-andrealmeid@collabora.com> References: <20190702154752.14939-1-andrealmeid@collabora.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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