From patchwork Tue May 10 11:51:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 15864 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 12DBCC3271 for ; Tue, 10 May 2022 11:52:27 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B495F65688; Tue, 10 May 2022 13:52:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1652183546; bh=D5kh5m5dVFSdvWBJedF03x3RCtpo2Vy/S76Gby0LnNI=; 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=GsEM763CxqRQrx8nRTSW9eCSFCYo29t5joUkR4Z6WQ/vGu0PBqwO8WRZmmhdwn9y+ zyUR1Uzqc0tOjr+kbKHrFDjT1whftdUOI9IBD81GCL1oFEDGY71rWI28W2msyq0MVI CstI5YDCz73+9KqI+VhTF5rnD848qf9wHfXKAWsCgrThNmdn8Fu9OIChw/F+b9NLnv jrtXz8XuxBBK08jy4h3F1iCmSP9LBjYpdYbywyCasS67nfMzL+sKVIzcMq1HwoWu6O OmrlBs4MG8EsPfD/hm9BFRN4t80ppoyKUz9uTHz9NZRQfKfOO54NAFdNfToV+mIS3S bRrsxBKra7Ppw== 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 960ED6564F for ; Tue, 10 May 2022 13:52:17 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="sU2hVazh"; 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 BAD9A824; Tue, 10 May 2022 13:52:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183537; bh=D5kh5m5dVFSdvWBJedF03x3RCtpo2Vy/S76Gby0LnNI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sU2hVazhFyW3QXWodhFCns0eMkI5EHdNotatgJQpzKpgTFdJGFIGHJUAk6OXzghXq lTVQsfJcy3UzmEqltVBHrLdLuXlb1BMxM3zwRKo3eiGPau1tJGeb4EUAhW4Sutmr6M raOU8MAVSzmbjSUgjpo7xqQs0eiMOx7YkITCF1oQ= To: libcamera-devel@lists.libcamera.org Date: Tue, 10 May 2022 14:51:21 +0300 Message-Id: <20220510115147.19360-25-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 24/50] staging: media: imx: imx7-media-csi: Avoid unnecessary casts 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" Simplify the imx7_csi_media_pipeline_set_stream() function by passing it the imx7_csi pointer, which avoids going from subdev to entity and back to subdev. Signed-off-by: Laurent Pinchart --- drivers/staging/media/imx/imx7-media-csi.c | 31 +++++++--------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c index 1c8ee7c88f46..8600fc4d6be2 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -1067,33 +1067,24 @@ 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) +static int imx7_csi_media_pipeline_set_stream(struct imx7_csi *csi, bool on) { - struct v4l2_subdev *sd; + struct imx_media_dev *imxmd = &csi->imxmd; 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); + ret = __media_pipeline_start(&csi->sd.entity, &imxmd->pipe); if (ret) goto out; - ret = v4l2_subdev_call(sd, video, s_stream, 1); + ret = v4l2_subdev_call(&csi->sd, video, s_stream, 1); if (ret) - __media_pipeline_stop(entity); + __media_pipeline_stop(&csi->sd.entity); } else { - v4l2_subdev_call(sd, video, s_stream, 0); - if (entity->pipe) - __media_pipeline_stop(entity); + v4l2_subdev_call(&csi->sd, video, s_stream, 0); + if (csi->sd.entity.pipe) + __media_pipeline_stop(&csi->sd.entity); } out: @@ -1115,8 +1106,7 @@ static int imx7_csi_video_start_streaming(struct vb2_queue *vq, goto return_bufs; } - ret = imx7_csi_media_pipeline_set_stream(&csi->imxmd, &csi->sd.entity, - true); + ret = imx7_csi_media_pipeline_set_stream(csi, true); if (ret) { dev_err(csi->dev, "pipeline start failed with %d\n", ret); goto return_bufs; @@ -1142,8 +1132,7 @@ static void imx7_csi_video_stop_streaming(struct vb2_queue *vq) unsigned long flags; int ret; - ret = imx7_csi_media_pipeline_set_stream(&csi->imxmd, &csi->sd.entity, - false); + ret = imx7_csi_media_pipeline_set_stream(csi, false); if (ret) dev_warn(csi->dev, "pipeline stop failed with %d\n", ret);