From patchwork Tue May 10 11:58:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 12844947 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F41C9C433FE for ; Tue, 10 May 2022 11:59:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241444AbiEJMDk (ORCPT ); Tue, 10 May 2022 08:03:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241431AbiEJMDj (ORCPT ); Tue, 10 May 2022 08:03:39 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59B0352E73 for ; Tue, 10 May 2022 04:59:42 -0700 (PDT) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 2CE3018D4; Tue, 10 May 2022 13:59:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183969; bh=EgNZsoN/7OI10adZIP8tfznFAkRmxK+4iV9hb6MY8ns=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bixe9dooDVF41rCeQjnWsFDLw2QBUi7ZzVBroJpmAGZQgeSzeNbQav3wB7j5WGa5E I7WMAKK9AGe0jE0+v/PF39IDFbWmdad/juXL3CxAtNR1i+CthqsLBZNT7UVNTlmddZ 8nS1k+dxh20GZBJ628RXi3Lqkp3c9+hHkdDADGlo= From: Laurent Pinchart To: linux-media@vger.kernel.org Cc: Rui Miguel Silva , Steve Longerbeam , Philipp Zabel , Jacopo Mondi , Martin Kepplinger , Alexander Stein , Dorota Czaplejewicz , kernel@pengutronix.de Subject: [PATCH 23/50] staging: media: imx: imx7-media-csi: Import imx_media_pipeline_set_stream() Date: Tue, 10 May 2022 14:58:32 +0300 Message-Id: <20220510115859.19777-24-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115859.19777-1-laurent.pinchart@ideasonboard.com> References: <20220510115859.19777-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org To prepare for code refactoring, copy the imx_media_pipeline_set_stream() helper used by this driver from imx-media-utils.c. Rename the function to avoid name clashes, no functional change intended. Signed-off-by: Laurent Pinchart --- drivers/staging/media/imx/imx7-media-csi.c | 40 ++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c index e1b494183ebc..1c8ee7c88f46 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -1067,6 +1067,40 @@ static int imx7_csi_video_validate_fmt(struct imx7_csi *csi) return 0; } +/* + * Turn current pipeline streaming on/off starting from entity. + */ +static int imx7_csi_media_pipeline_set_stream(struct imx_media_dev *imxmd, + struct media_entity *entity, + bool on) +{ + struct v4l2_subdev *sd; + int ret = 0; + + if (!is_media_entity_v4l2_subdev(entity)) + return -EINVAL; + sd = media_entity_to_v4l2_subdev(entity); + + mutex_lock(&imxmd->md.graph_mutex); + + if (on) { + ret = __media_pipeline_start(entity, &imxmd->pipe); + if (ret) + goto out; + ret = v4l2_subdev_call(sd, video, s_stream, 1); + if (ret) + __media_pipeline_stop(entity); + } else { + v4l2_subdev_call(sd, video, s_stream, 0); + if (entity->pipe) + __media_pipeline_stop(entity); + } + +out: + mutex_unlock(&imxmd->md.graph_mutex); + return ret; +} + static int imx7_csi_video_start_streaming(struct vb2_queue *vq, unsigned int count) { @@ -1081,7 +1115,8 @@ static int imx7_csi_video_start_streaming(struct vb2_queue *vq, goto return_bufs; } - ret = imx_media_pipeline_set_stream(&csi->imxmd, &csi->sd.entity, true); + ret = imx7_csi_media_pipeline_set_stream(&csi->imxmd, &csi->sd.entity, + true); if (ret) { dev_err(csi->dev, "pipeline start failed with %d\n", ret); goto return_bufs; @@ -1107,7 +1142,8 @@ static void imx7_csi_video_stop_streaming(struct vb2_queue *vq) unsigned long flags; int ret; - ret = imx_media_pipeline_set_stream(&csi->imxmd, &csi->sd.entity, false); + ret = imx7_csi_media_pipeline_set_stream(&csi->imxmd, &csi->sd.entity, + false); if (ret) dev_warn(csi->dev, "pipeline stop failed with %d\n", ret);