{"id":15842,"url":"https://patchwork.libcamera.org/api/patches/15842/?format=json","web_url":"https://patchwork.libcamera.org/patch/15842/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20220510115147.19360-3-laurent.pinchart@ideasonboard.com>","date":"2022-05-10T11:50:59","name":"[libcamera-devel,02/50] staging: media: imx: imx7-media-csi: Split imx_media_dev from probe()","commit_ref":null,"pull_url":null,"state":"not-applicable","archived":false,"hash":"d1eb6b2e01a8b30f55ecdd2d157401885af05ff4","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/15842/mbox/","series":[{"id":3106,"url":"https://patchwork.libcamera.org/api/series/3106/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3106","date":"2022-05-10T11:50:57","name":"staging: media: imx: Prepare destaging of imx7-media-csi","version":1,"mbox":"https://patchwork.libcamera.org/series/3106/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/15842/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/15842/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 8EDF9C326C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 10 May 2022 11:52:01 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2FA306564F;\n\tTue, 10 May 2022 13:52:01 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8223F65648\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 10 May 2022 13:51:58 +0200 (CEST)","from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 900EFB9A;\n\tTue, 10 May 2022 13:51:57 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1652183521;\n\tbh=biy0GTT1QoP72aKYu5WMI/a8pkSOFL+DXgOcxXmEqYk=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=VY+k/Q/jnDhzxsIfztw2kBhVowzRYa4xGxQJwYpenByxin0jPT5GnkP7IOVAgv44x\n\th0euTW46m9BAvLZSRlfvrzIM0cDDZz9DMoZN92wDc7waznIjTzErdfpP9hCvPmlZDt\n\tB5jVmC+ZHoUd2X8uZRsPHxGCZ0zXefUGOkbCUZA3vjnnTaNvfcPwihnOWMlTtf/i61\n\tCSfc7AVNcpp7FYfI9a/EOzXxy3kbrzK3ufUGpFc7FRn2Pzvs9F8HhYtPgPtr9QvlGg\n\tHE8+8vc/nBm/6Ek3C0Mm3D+cjxLIZeHN9RD1O42MBBdV8t4guJ+Gxw5vaLdaDdfUE1\n\t592uwBnWMGecA==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1652183518;\n\tbh=biy0GTT1QoP72aKYu5WMI/a8pkSOFL+DXgOcxXmEqYk=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=OFIx9VtbfZpvK4FYMar2dLCOnuZ3X+X/6aqhonL4sDKXhr7sfbwQwC1p75ugYV7R8\n\t9YDA7n0GXLHgkWtUckcGO2Cq1Oh+W/FmZl7l//DcsCHdLJg2Tjlz3Vs5OtrNOLaCqA\n\t0dllezY6TwqMZfVZjY6maCTIaWmKD+gB13nFV5RI="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"OFIx9Vtb\"; dkim-atps=neutral","To":"libcamera-devel@lists.libcamera.org","Date":"Tue, 10 May 2022 14:50:59 +0300","Message-Id":"<20220510115147.19360-3-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","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH 02/50] staging: media: imx:\n\timx7-media-csi: Split imx_media_dev from probe()","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","From":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"Martin Kepplinger <martin.kepplinger@puri.sm>, kernel@pengutronix.de,\n\tDorota Czaplejewicz <dorota.czaplejewicz@puri.sm>,\n\tAlexander Stein <alexander.stein@ew.tq-group.com>,\n\tRui Miguel Silva <rmfrfs@gmail.com>,\n\tPhilipp Zabel <p.zabel@pengutronix.de>, \n\tSteve Longerbeam <slongerbeam@gmail.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Prepare for the decoupling of the imx7-media-csi driver from the\nIPUv3-based drivers by moving the imx_media_dev handling from probe()\nfunction to separate functions.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n drivers/staging/media/imx/imx7-media-csi.c | 71 +++++++++++++---------\n 1 file changed, 42 insertions(+), 29 deletions(-)","diff":"diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c\nindex 893620e8fc03..d7c65b8bb3c9 100644\n--- a/drivers/staging/media/imx/imx7-media-csi.c\n+++ b/drivers/staging/media/imx/imx7-media-csi.c\n@@ -1175,11 +1175,45 @@ static int imx7_csi_async_register(struct imx7_csi *csi)\n \treturn v4l2_async_register_subdev(&csi->sd);\n }\n \n+static void imx7_csi_media_cleanup(struct imx7_csi *csi)\n+{\n+\tstruct imx_media_dev *imxmd = csi->imxmd;\n+\n+\tv4l2_device_unregister(&imxmd->v4l2_dev);\n+\tmedia_device_unregister(&imxmd->md);\n+\tmedia_device_cleanup(&imxmd->md);\n+}\n+\n+static int imx7_csi_media_init(struct imx7_csi *csi)\n+{\n+\tstruct imx_media_dev *imxmd;\n+\tint ret;\n+\n+\t/* add media device */\n+\timxmd = imx_media_dev_init(csi->dev, NULL);\n+\tif (IS_ERR(imxmd))\n+\t\treturn PTR_ERR(imxmd);\n+\n+\tret = imx_media_of_add_csi(imxmd, csi->dev->of_node);\n+\tif (ret < 0 && ret != -ENODEV && ret != -EEXIST) {\n+\t\timx7_csi_media_cleanup(csi);\n+\t\treturn ret;\n+\t}\n+\n+\tret = imx_media_dev_notifier_register(imxmd, NULL);\n+\tif (ret < 0) {\n+\t\timx7_csi_media_cleanup(csi);\n+\t\treturn ret;\n+\t}\n+\n+\tcsi->imxmd = imxmd;\n+\n+\treturn 0;\n+}\n+\n static int imx7_csi_probe(struct platform_device *pdev)\n {\n \tstruct device *dev = &pdev->dev;\n-\tstruct device_node *node = dev->of_node;\n-\tstruct imx_media_dev *imxmd;\n \tstruct imx7_csi *csi;\n \tint i, ret;\n \n@@ -1193,6 +1227,7 @@ static int imx7_csi_probe(struct platform_device *pdev)\n \tspin_lock_init(&csi->irqlock);\n \tmutex_init(&csi->lock);\n \n+\t/* Acquire resources and install interrupt handler. */\n \tcsi->mclk = devm_clk_get(&pdev->dev, \"mclk\");\n \tif (IS_ERR(csi->mclk)) {\n \t\tret = PTR_ERR(csi->mclk);\n@@ -1214,7 +1249,6 @@ static int imx7_csi_probe(struct platform_device *pdev)\n \n \tcsi->model = (enum imx_csi_model)(uintptr_t)of_device_get_match_data(&pdev->dev);\n \n-\t/* install interrupt handler */\n \tret = devm_request_irq(dev, csi->irq, imx7_csi_irq_handler, 0, \"csi\",\n \t\t\t       (void *)csi);\n \tif (ret < 0) {\n@@ -1222,22 +1256,11 @@ static int imx7_csi_probe(struct platform_device *pdev)\n \t\tgoto destroy_mutex;\n \t}\n \n-\t/* add media device */\n-\timxmd = imx_media_dev_init(dev, NULL);\n-\tif (IS_ERR(imxmd)) {\n-\t\tret = PTR_ERR(imxmd);\n+\t/* Initialize all the media device infrastructure. */\n+\tret = imx7_csi_media_init(csi);\n+\tif (ret)\n \t\tgoto destroy_mutex;\n-\t}\n \n-\tret = imx_media_of_add_csi(imxmd, node);\n-\tif (ret < 0 && ret != -ENODEV && ret != -EEXIST)\n-\t\tgoto cleanup;\n-\n-\tret = imx_media_dev_notifier_register(imxmd, NULL);\n-\tif (ret < 0)\n-\t\tgoto cleanup;\n-\n-\tcsi->imxmd = imxmd;\n \tv4l2_subdev_init(&csi->sd, &imx7_csi_subdev_ops);\n \tv4l2_set_subdevdata(&csi->sd, csi);\n \tcsi->sd.internal_ops = &imx7_csi_internal_ops;\n@@ -1269,11 +1292,7 @@ static int imx7_csi_probe(struct platform_device *pdev)\n \tv4l2_async_nf_cleanup(&csi->notifier);\n \n cleanup:\n-\tv4l2_async_nf_unregister(&imxmd->notifier);\n-\tv4l2_async_nf_cleanup(&imxmd->notifier);\n-\tv4l2_device_unregister(&imxmd->v4l2_dev);\n-\tmedia_device_unregister(&imxmd->md);\n-\tmedia_device_cleanup(&imxmd->md);\n+\timx7_csi_media_cleanup(csi);\n \n destroy_mutex:\n \tmutex_destroy(&csi->lock);\n@@ -1285,14 +1304,8 @@ static int imx7_csi_remove(struct platform_device *pdev)\n {\n \tstruct v4l2_subdev *sd = platform_get_drvdata(pdev);\n \tstruct imx7_csi *csi = v4l2_get_subdevdata(sd);\n-\tstruct imx_media_dev *imxmd = csi->imxmd;\n \n-\tv4l2_async_nf_unregister(&imxmd->notifier);\n-\tv4l2_async_nf_cleanup(&imxmd->notifier);\n-\n-\tmedia_device_unregister(&imxmd->md);\n-\tv4l2_device_unregister(&imxmd->v4l2_dev);\n-\tmedia_device_cleanup(&imxmd->md);\n+\timx7_csi_media_cleanup(csi);\n \n \tv4l2_async_nf_unregister(&csi->notifier);\n \tv4l2_async_nf_cleanup(&csi->notifier);\n","prefixes":["libcamera-devel","02/50"]}