From patchwork Tue May 10 11:51:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 15866 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 9597DC326E for ; Tue, 10 May 2022 11:52:28 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 44B4E65699; Tue, 10 May 2022 13:52:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1652183548; bh=HbKz4y1G2znjiWeWjvthgfOCUuheE0gfBZq5dYC849s=; 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=CUeDBr4Q7Hkmg/130QevGGl0EGG2owl9FfhWNhWde0MhdMYGB6Kh3YccbMUffIONS eezQhhmKO+4ZSKp+iDa7x3Uxyc9uD1zLl2VCownQ3pLtqB+g0VXr3USbdUxATKvx29 6XHBUwmORx778QDJ+74akOIKnINHEbrCzeaFZ920s6jDt0QKhuf3IoUzsTCZtaNnfz ntsNaG7S4b8RvgQvKbfuJkCmNTSjpBJFy9jmegxqMyul1YKzkT00ydj29kwNsrFq9L teoFc0WeQp1m6EoRJJRnp0FHk9JPydKMho6wYfU/Juhen2qFlSF9ldSUbaFC7q/nC2 3WhCJ9HzRAQKQ== 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 4E9A165685 for ; Tue, 10 May 2022 13:52:19 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="Bkbt9/eY"; 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 70FBFB60; Tue, 10 May 2022 13:52:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183539; bh=HbKz4y1G2znjiWeWjvthgfOCUuheE0gfBZq5dYC849s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Bkbt9/eY+VsGZl5AkUCIcvFUJS5KoGs4y+nWr95YKvbBbu5Z3OvuI4dDN5C/nM6iF erQVQCcb+3zVIa4ziqXAxvYEv4WHp6OtS8TcvOBf1t2OjYCOWcymN+fvvBsx447D4T ZsDAKJ7VU2ZhkPyg0TBuGwbJA7V0YBIOoHs+TGBg= To: libcamera-devel@lists.libcamera.org Date: Tue, 10 May 2022 14:51:23 +0300 Message-Id: <20220510115147.19360-27-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 26/50] staging: media: imx: imx7-media-csi: Fold imx_media_dev into imx7_csi 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" Now that the driver doesn't use any helper that relies on the imx_media_dev structure anymore, merge the three fields of the imx_media_dev structure directly in the imx7_csi structure. Update all the users accordingly. Signed-off-by: Laurent Pinchart --- drivers/staging/media/imx/imx7-media-csi.c | 61 +++++++++++----------- 1 file changed, 30 insertions(+), 31 deletions(-) diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c index 44c19c73da97..b116f6ab96f0 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -183,8 +183,10 @@ struct imx7_csi { spinlock_t irqlock; /* Protects last_eof */ /* Media and V4L2 device */ - struct imx_media_dev imxmd; + struct media_device mdev; + struct v4l2_device v4l2_dev; struct v4l2_async_notifier notifier; + struct media_pipeline pipe; struct v4l2_subdev *src_sd; bool is_csi2; @@ -1081,9 +1083,9 @@ static int imx7_csi_video_start_streaming(struct vb2_queue *vq, goto err_buffers; } - mutex_lock(&csi->imxmd.md.graph_mutex); + mutex_lock(&csi->mdev.graph_mutex); - ret = __media_pipeline_start(&csi->sd.entity, &csi->imxmd.pipe); + ret = __media_pipeline_start(&csi->sd.entity, &csi->pipe); if (ret) goto err_unlock; @@ -1091,14 +1093,14 @@ static int imx7_csi_video_start_streaming(struct vb2_queue *vq, if (ret) goto err_stop; - mutex_unlock(&csi->imxmd.md.graph_mutex); + mutex_unlock(&csi->mdev.graph_mutex); return 0; err_stop: __media_pipeline_stop(&csi->sd.entity); err_unlock: - mutex_unlock(&csi->imxmd.md.graph_mutex); + mutex_unlock(&csi->mdev.graph_mutex); dev_err(csi->dev, "pipeline start failed with %d\n", ret); err_buffers: spin_lock_irqsave(&csi->q_lock, flags); @@ -1117,10 +1119,10 @@ static void imx7_csi_video_stop_streaming(struct vb2_queue *vq) struct imx_media_buffer *tmp; unsigned long flags; - mutex_lock(&csi->imxmd.md.graph_mutex); + mutex_lock(&csi->mdev.graph_mutex); v4l2_subdev_call(&csi->sd, video, s_stream, 0); __media_pipeline_stop(&csi->sd.entity); - mutex_unlock(&csi->imxmd.md.graph_mutex); + mutex_unlock(&csi->mdev.graph_mutex); /* release all active buffers */ spin_lock_irqsave(&csi->q_lock, flags); @@ -1704,11 +1706,11 @@ static int imx7_csi_registered(struct v4l2_subdev *sd) if (ret) return ret; - ret = v4l2_device_register_subdev_nodes(&csi->imxmd.v4l2_dev); + ret = v4l2_device_register_subdev_nodes(&csi->v4l2_dev); if (ret) goto err_unreg; - ret = media_device_register(&csi->imxmd.md); + ret = media_device_register(&csi->mdev); if (ret) goto err_unreg; @@ -1778,7 +1780,7 @@ static int imx7_csi_notify_complete(struct v4l2_async_notifier *notifier) { struct imx7_csi *csi = imx7_csi_notifier_to_dev(notifier); - return v4l2_device_register_subdev_nodes(&csi->imxmd.v4l2_dev); + return v4l2_device_register_subdev_nodes(&csi->v4l2_dev); } static const struct v4l2_async_notifier_operations imx7_csi_notify_ops = { @@ -1812,7 +1814,7 @@ static int imx7_csi_async_register(struct imx7_csi *csi) csi->notifier.ops = &imx7_csi_notify_ops; - ret = v4l2_async_nf_register(&csi->imxmd.v4l2_dev, &csi->notifier); + ret = v4l2_async_nf_register(&csi->v4l2_dev, &csi->notifier); if (ret) return ret; @@ -1821,11 +1823,9 @@ static int imx7_csi_async_register(struct imx7_csi *csi) static void imx7_csi_media_cleanup(struct imx7_csi *csi) { - struct imx_media_dev *imxmd = &csi->imxmd; - - v4l2_device_unregister(&imxmd->v4l2_dev); - media_device_unregister(&imxmd->md); - media_device_cleanup(&imxmd->md); + v4l2_device_unregister(&csi->v4l2_dev); + media_device_unregister(&csi->mdev); + media_device_cleanup(&csi->mdev); } static const struct media_device_ops imx7_csi_media_ops = { @@ -1834,26 +1834,25 @@ static const struct media_device_ops imx7_csi_media_ops = { static int imx7_csi_media_dev_init(struct imx7_csi *csi) { - struct imx_media_dev *imxmd = &csi->imxmd; int ret; - dev_set_drvdata(csi->dev, imxmd); + dev_set_drvdata(csi->dev, csi); - strscpy(imxmd->md.model, "imx-media", sizeof(imxmd->md.model)); - imxmd->md.ops = &imx7_csi_media_ops; - imxmd->md.dev = csi->dev; + strscpy(csi->mdev.model, "imx-media", sizeof(csi->mdev.model)); + csi->mdev.ops = &imx7_csi_media_ops; + csi->mdev.dev = csi->dev; - imxmd->v4l2_dev.mdev = &imxmd->md; - strscpy(imxmd->v4l2_dev.name, "imx-media", - sizeof(imxmd->v4l2_dev.name)); - snprintf(imxmd->md.bus_info, sizeof(imxmd->md.bus_info), - "platform:%s", dev_name(imxmd->md.dev)); + csi->v4l2_dev.mdev = &csi->mdev; + strscpy(csi->v4l2_dev.name, "imx-media", + sizeof(csi->v4l2_dev.name)); + snprintf(csi->mdev.bus_info, sizeof(csi->mdev.bus_info), + "platform:%s", dev_name(csi->mdev.dev)); - media_device_init(&imxmd->md); + media_device_init(&csi->mdev); - ret = v4l2_device_register(csi->dev, &imxmd->v4l2_dev); + ret = v4l2_device_register(csi->dev, &csi->v4l2_dev); if (ret < 0) { - v4l2_err(&imxmd->v4l2_dev, + v4l2_err(&csi->v4l2_dev, "Failed to register v4l2_device: %d\n", ret); goto cleanup; } @@ -1861,7 +1860,7 @@ static int imx7_csi_media_dev_init(struct imx7_csi *csi) return 0; cleanup: - media_device_cleanup(&imxmd->md); + media_device_cleanup(&csi->mdev); return ret; } @@ -1894,7 +1893,7 @@ static int imx7_csi_media_init(struct imx7_csi *csi) if (ret < 0) return ret; - return v4l2_device_register_subdev(&csi->imxmd.v4l2_dev, &csi->sd); + return v4l2_device_register_subdev(&csi->v4l2_dev, &csi->sd); } static int imx7_csi_probe(struct platform_device *pdev)