From patchwork Wed Apr 15 01:30:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Helen Koike X-Patchwork-Id: 11489597 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DD800112C for ; Wed, 15 Apr 2020 01:31:18 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BB48D20737 for ; Wed, 15 Apr 2020 01:31:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="bVaAW6t1" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BB48D20737 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=collabora.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Xyfo+bRdm9y5UALeu0Go943EGS6n+4eMrfCfpBHI/t8=; b=bVaAW6t1uQjM7w w1nx1LBnVH7siJ+h0PDI3/zNSSPsUSkn6ndR9uZnNcB/vLpZzrrkv9lJ+M/Vyfl0Y4to73YhEz9Dp g1S/EU77+i9jjJ3wKwjqLbWxPMUMw0dwwNZjSw2Ap9GdcV7RJXsDHLAT/PMWeGpFpjHaRlykQyLIL 4Paz8ar8pECzgwcHuwXJrc85NQn/2CEMxoeF/9hD52oSAOdPCn6Jl6XBmN1W/SR+LvUZXLmd0x1dN btJtFkwWwZzP926d3CJgIpIGvA/b67D1rQKedhdWKKpXK48gzY8v3drqkivQDjrr9qGwn6sy51Q0H Cm51H3TedK42qy3fD0fw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jOWtX-0004SN-LR; Wed, 15 Apr 2020 01:31:15 +0000 Received: from bhuna.collabora.co.uk ([2a00:1098:0:82:1000:25:2eeb:e3e3]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jOWtV-0004Py-1j for linux-rockchip@lists.infradead.org; Wed, 15 Apr 2020 01:31:14 +0000 Received: from floko.floko.floko (unknown [IPv6:2804:431:e7cc:79a2:b6f7:4033:5775:cc3a]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: koike) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id 4329B2A1C4B; Wed, 15 Apr 2020 02:31:06 +0100 (BST) From: Helen Koike To: linux-media@vger.kernel.org Subject: [PATCH v3 4/4] media: vimc: use v4l2_pipeline_stream_{enable, disable} helpers Date: Tue, 14 Apr 2020 22:30:44 -0300 Message-Id: <20200415013044.1778572-5-helen.koike@collabora.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200415013044.1778572-1-helen.koike@collabora.com> References: <20200415013044.1778572-1-helen.koike@collabora.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200414_183113_364074_71F7E99C X-CRM114-Status: GOOD ( 15.65 ) X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mchehab@kernel.org, linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org, Helen Koike , hans.verkuil@cisco.com, skhan@linuxfoundation.org, niklas.soderlund@ragnatech.se, kernel@collabora.com Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org Use v4l2_pipeline_stream_{enable,disable} to call .s_stream() subdevice callbacks through the pipeline. Tested streaming works with: media-ctl -d /dev/media0 -V '"Sensor A":0[fmt:SBGGR8_1X8/640x480]' media-ctl -d /dev/media0 -V '"Debayer A":0[fmt:SBGGR8_1X8/640x480]' media-ctl -d /dev/media0 -V '"Sensor B":0[fmt:SBGGR8_1X8/640x480]' media-ctl -d /dev/media0 -V '"Debayer B":0[fmt:SBGGR8_1X8/640x480]' media-ctl -d /dev/media0 -V '"Scaler":0[fmt:RGB888_1X24/640x480]' media-ctl -d /dev/media0 -V '"Scaler":0[crop:(100,50)/400x150]' media-ctl -d /dev/media0 -V '"Scaler":1[fmt:RGB888_1X24/1920x1440]' v4l2-ctl -d /dev/video2 -v width=1200,height=450 v4l2-ctl -d /dev/video0 -v pixelformat=BA81 v4l2-ctl -d /dev/video1 -v pixelformat=BA81 v4l2-ctl --stream-mmap --stream-count=10 -d /dev/video2 --stream-to=/tmp/test.raw Signed-off-by: Helen Koike --- Changes in v3: - rebase on top of new helpers prototypes Changes in v2: - rebase on top of new helpers prototypes .../media/test_drivers/vimc/vimc-capture.c | 28 +++++++---- .../media/test_drivers/vimc/vimc-streamer.c | 49 ++----------------- 2 files changed, 23 insertions(+), 54 deletions(-) diff --git a/drivers/media/test_drivers/vimc/vimc-capture.c b/drivers/media/test_drivers/vimc/vimc-capture.c index 5315c201314c9..73707634010e9 100644 --- a/drivers/media/test_drivers/vimc/vimc-capture.c +++ b/drivers/media/test_drivers/vimc/vimc-capture.c @@ -233,21 +233,27 @@ static int vimc_cap_start_streaming(struct vb2_queue *vq, unsigned int count) vcap->sequence = 0; - /* Start the media pipeline */ ret = media_pipeline_start(entity, &vcap->stream.pipe); - if (ret) { - vimc_cap_return_all_buffers(vcap, VB2_BUF_STATE_QUEUED); - return ret; - } + if (ret) + goto err_return_all_buffers; + + ret = v4l2_pipeline_stream_enable(&vcap->vdev, &vcap->stream.pipe); + if (ret) + goto err_stop_media_pipe; ret = vimc_streamer_s_stream(&vcap->stream, &vcap->ved, 1); - if (ret) { - media_pipeline_stop(entity); - vimc_cap_return_all_buffers(vcap, VB2_BUF_STATE_QUEUED); - return ret; - } + if (ret) + goto err_stop_stream; return 0; + +err_stop_stream: + v4l2_pipeline_stream_disable(&vcap->vdev, &vcap->stream.pipe); +err_stop_media_pipe: + media_pipeline_stop(entity); +err_return_all_buffers: + vimc_cap_return_all_buffers(vcap, VB2_BUF_STATE_QUEUED); + return ret; } /* @@ -260,6 +266,8 @@ static void vimc_cap_stop_streaming(struct vb2_queue *vq) vimc_streamer_s_stream(&vcap->stream, &vcap->ved, 0); + v4l2_pipeline_stream_disable(&vcap->vdev, &vcap->stream.pipe); + /* Stop the media pipeline */ media_pipeline_stop(&vcap->vdev.entity); diff --git a/drivers/media/test_drivers/vimc/vimc-streamer.c b/drivers/media/test_drivers/vimc/vimc-streamer.c index 65feb3c596db5..c0085f4695c2f 100644 --- a/drivers/media/test_drivers/vimc/vimc-streamer.c +++ b/drivers/media/test_drivers/vimc/vimc-streamer.c @@ -36,33 +36,6 @@ static struct media_entity *vimc_get_source_entity(struct media_entity *ent) return NULL; } -/** - * vimc_streamer_pipeline_terminate - Disable stream in all ved in stream - * - * @stream: the pointer to the stream structure with the pipeline to be - * disabled. - * - * Calls s_stream to disable the stream in each entity of the pipeline - * - */ -static void vimc_streamer_pipeline_terminate(struct vimc_stream *stream) -{ - struct vimc_ent_device *ved; - struct v4l2_subdev *sd; - - while (stream->pipe_size) { - stream->pipe_size--; - ved = stream->ved_pipeline[stream->pipe_size]; - stream->ved_pipeline[stream->pipe_size] = NULL; - - if (!is_media_entity_v4l2_subdev(ved->ent)) - continue; - - sd = media_entity_to_v4l2_subdev(ved->ent); - v4l2_subdev_call(sd, video, s_stream, 0); - } -} - /** * vimc_streamer_pipeline_init - Initializes the stream structure * @@ -82,27 +55,15 @@ static int vimc_streamer_pipeline_init(struct vimc_stream *stream, struct media_entity *entity; struct video_device *vdev; struct v4l2_subdev *sd; - int ret = 0; stream->pipe_size = 0; while (stream->pipe_size < VIMC_STREAMER_PIPELINE_MAX_SIZE) { if (!ved) { - vimc_streamer_pipeline_terminate(stream); + stream->pipe_size = 0; return -EINVAL; } stream->ved_pipeline[stream->pipe_size++] = ved; - if (is_media_entity_v4l2_subdev(ved->ent)) { - sd = media_entity_to_v4l2_subdev(ved->ent); - ret = v4l2_subdev_call(sd, video, s_stream, 1); - if (ret && ret != -ENOIOCTLCMD) { - dev_err(ved->dev, "subdev_call error %s\n", - ved->ent->name); - vimc_streamer_pipeline_terminate(stream); - return ret; - } - } - entity = vimc_get_source_entity(ved->ent); /* Check if the end of the pipeline was reached */ if (!entity) { @@ -111,7 +72,7 @@ static int vimc_streamer_pipeline_init(struct vimc_stream *stream, dev_err(ved->dev, "first entity in the pipe '%s' is not a source\n", ved->ent->name); - vimc_streamer_pipeline_terminate(stream); + stream->pipe_size = 0; return -EPIPE; } return 0; @@ -129,7 +90,7 @@ static int vimc_streamer_pipeline_init(struct vimc_stream *stream, } } - vimc_streamer_pipeline_terminate(stream); + stream->pipe_size = 0; return -EINVAL; } @@ -210,7 +171,7 @@ int vimc_streamer_s_stream(struct vimc_stream *stream, if (IS_ERR(stream->kthread)) { ret = PTR_ERR(stream->kthread); dev_err(ved->dev, "kthread_run failed with %d\n", ret); - vimc_streamer_pipeline_terminate(stream); + stream->pipe_size = 0; stream->kthread = NULL; return ret; } @@ -231,7 +192,7 @@ int vimc_streamer_s_stream(struct vimc_stream *stream, stream->kthread = NULL; - vimc_streamer_pipeline_terminate(stream); + stream->pipe_size = 0; } return 0;