From patchwork Tue May 10 11:51:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 15863 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 60FEAC3256 for ; Tue, 10 May 2022 11:52:26 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E356165695; Tue, 10 May 2022 13:52:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1652183546; bh=EgNZsoN/7OI10adZIP8tfznFAkRmxK+4iV9hb6MY8ns=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=MZBczqGr+JXV4vgIpTIczvIQkpjkMjR8VDoYdO5ynRLIUgX3dL94oORoCeaPoAJBZ fhMgwe6cq6Xj9zJLFXZY2y7wV6ydUOx+ac/brb2XdKCqVXtNCb598fomVW/LhyanSR cyYPk3/PYO5rzr0IT+o4whSQJlfvETGTHVnn8iP2qBL+7xIF4lkbZOoSsVnp29JARv ZC/M/LCtc2+kjeYcv51pI30qR/2rhQuH7N/D7f94tLdPJ/VsZFC6ijlsM6FSVBAAZS Om4pI/Am0mEInB25Lx2b2th/GLf5dGtWJh+sBUlifEGYWC+FGHpm8dWwQbOzcWe/bQ 7o18U7fExbSeQ== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C649465643 for ; Tue, 10 May 2022 13:52:16 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="B1QHcSLG"; dkim-atps=neutral Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id DD12BBA9; Tue, 10 May 2022 13:52:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183536; bh=EgNZsoN/7OI10adZIP8tfznFAkRmxK+4iV9hb6MY8ns=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B1QHcSLGTIrifMHH1MKn7ezgds0TLqjfWV+0lcrhMiAXqqqTam2AHoI/Xy25/wD6i WCttsfcWKk/wPgriccppZchQFHIwaSj27JqiLMpamb+yg4qJWawhXzbR7hjVoGe/Qp pi2ks4XGY2Tp9JepdPftqR5Oawbr2g9DKlT3IuFA= To: libcamera-devel@lists.libcamera.org Date: Tue, 10 May 2022 14:51:20 +0300 Message-Id: <20220510115147.19360-24-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> References: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 23/50] staging: media: imx: imx7-media-csi: Import imx_media_pipeline_set_stream() X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Cc: Martin Kepplinger , kernel@pengutronix.de, Dorota Czaplejewicz , Alexander Stein , Rui Miguel Silva , Philipp Zabel , Steve Longerbeam Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" 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);