From patchwork Tue May 10 11:51:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 15845 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 1ADCBC3256 for ; Tue, 10 May 2022 11:52:05 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 91EB165653; Tue, 10 May 2022 13:52:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1652183524; bh=vVaxZhjLlAQkxGPt/Aih151SXhS9D/3jxSOJe0M5h7Q=; 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=b97q0VgRe5yTGL0SLu1LBJHLpETvtSYB/5NWHuHtDuzeDXNWZuRNTxTyPkqPoh000 08LwEDwy2ET2isXtmlSr3Yu81xkxGYwNK6h33Z9PCdOQK0U9ipmlcQMCyRHeRtwCbA DWb1VbYKoEXhPLL80kV2R42MsGRz4E2XZ23fSGho+FU9Epdwb7cd0x1XRRZWM6T/O2 898Piy762neLsTMuu2+0GRecnzJPzcxBMGZsZDmZuaPi8+RoWIdKqXG0S+UiI4EsP2 IUZQK1tT4Tx6c9hkW7eau17YhMzgCHAA2tWK2U3Grzc9CGRTi91NaiYdC/2nkKEReY WxdaW1whmV/Bg== 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 0FC636564A for ; Tue, 10 May 2022 13:52:01 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="jbDgeBdP"; 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 39982E0C; Tue, 10 May 2022 13:52:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183520; bh=vVaxZhjLlAQkxGPt/Aih151SXhS9D/3jxSOJe0M5h7Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jbDgeBdPaafIyFAbKkC7qKyBITE8IE8DigN3Uded1kQlU63eEft5M+OfzH62Cbuu/ +5DJXHtk5s9OZSlJY3rBQHNrf/jPviyUupITzs7SnO3TihMbjonmgdtvrjjMcLXS1Q PXSJmmFO9xx1t15HRz3WOQER1U3vj+eAZBcV0WYA= To: libcamera-devel@lists.libcamera.org Date: Tue, 10 May 2022 14:51:02 +0300 Message-Id: <20220510115147.19360-6-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 05/50] staging: media: imx: imx7-media-csi: Drop the imx_media notifier 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" The V4L2 async notifier embedded in the imx_media_dev structure is triggered when the CSI bridge subdev is registered. We don't need an async notifier for this, as we can call the .complete() handler directly from the CSI bridge subdev .registered() handler. Signed-off-by: Laurent Pinchart --- drivers/staging/media/imx/imx7-media-csi.c | 63 +++++++--------------- 1 file changed, 19 insertions(+), 44 deletions(-) diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c index e2d6dabad007..984f7bec15af 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -721,11 +721,6 @@ static irqreturn_t imx7_csi_irq_handler(int irq, void *data) * Temporary copy of imx_media_dev helpers */ -static inline struct imx_media_dev *notifier2dev(struct v4l2_async_notifier *n) -{ - return container_of(n, struct imx_media_dev, notifier); -} - /* * adds given video device to given imx-media source pad vdev list. * Continues upstream from the pad entity's sink pads. @@ -848,9 +843,8 @@ static int imx_media_create_pad_vdev_lists(struct imx_media_dev *imxmd) } /* async subdev complete notifier */ -static int __imx_media_probe_complete(struct v4l2_async_notifier *notifier) +static int __imx_media_probe_complete(struct imx_media_dev *imxmd) { - struct imx_media_dev *imxmd = notifier2dev(notifier); int ret; mutex_lock(&imxmd->mutex); @@ -868,33 +862,6 @@ static int __imx_media_probe_complete(struct v4l2_async_notifier *notifier) return media_device_register(&imxmd->md); } -static const struct v4l2_async_notifier_operations imx_media_notifier_ops = { - .complete = __imx_media_probe_complete, -}; - -static int __imx_media_dev_notifier_register(struct imx_media_dev *imxmd, - const struct v4l2_async_notifier_operations *ops) -{ - int ret; - - /* no subdevs? just bail */ - if (list_empty(&imxmd->notifier.asd_list)) { - v4l2_err(&imxmd->v4l2_dev, "no subdevs\n"); - return -ENODEV; - } - - /* prepare the async subdev notifier and register it */ - imxmd->notifier.ops = ops ? ops : &imx_media_notifier_ops; - ret = v4l2_async_nf_register(&imxmd->v4l2_dev, &imxmd->notifier); - if (ret) { - v4l2_err(&imxmd->v4l2_dev, - "v4l2_async_nf_register failed with %d\n", ret); - return ret; - } - - return 0; -} - /* ----------------------------------------------------------------------------- * V4L2 Subdev Operations */ @@ -1247,10 +1214,12 @@ static int imx7_csi_registered(struct v4l2_subdev *sd) ret = imx_media_capture_device_register(csi->vdev, MEDIA_LNK_FL_IMMUTABLE); - if (ret) + if (ret) { imx_media_capture_device_remove(csi->vdev); + return ret; + } - return ret; + return __imx_media_probe_complete(csi->imxmd); } static void imx7_csi_unregistered(struct v4l2_subdev *sd) @@ -1316,8 +1285,16 @@ static int imx7_csi_notify_bound(struct v4l2_async_notifier *notifier, MEDIA_LNK_FL_IMMUTABLE); } +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); +} + static const struct v4l2_async_notifier_operations imx7_csi_notify_ops = { .bound = imx7_csi_notify_bound, + .complete = imx7_csi_notify_complete, }; static int imx7_csi_async_register(struct imx7_csi *csi) @@ -1346,11 +1323,11 @@ static int imx7_csi_async_register(struct imx7_csi *csi) csi->notifier.ops = &imx7_csi_notify_ops; - ret = v4l2_async_subdev_nf_register(&csi->sd, &csi->notifier); + ret = v4l2_async_nf_register(&csi->imxmd->v4l2_dev, &csi->notifier); if (ret) return ret; - return v4l2_async_register_subdev(&csi->sd); + return 0; } static void imx7_csi_media_cleanup(struct imx7_csi *csi) @@ -1378,12 +1355,6 @@ static int imx7_csi_media_init(struct imx7_csi *csi) return ret; } - ret = __imx_media_dev_notifier_register(imxmd, NULL); - if (ret < 0) { - imx7_csi_media_cleanup(csi); - return ret; - } - csi->imxmd = imxmd; return 0; @@ -1458,6 +1429,10 @@ static int imx7_csi_probe(struct platform_device *pdev) if (ret < 0) goto cleanup; + ret = v4l2_device_register_subdev(&csi->imxmd->v4l2_dev, &csi->sd); + if (ret) + goto cleanup; + ret = imx7_csi_async_register(csi); if (ret) goto subdev_notifier_cleanup;