From patchwork Fri Jan 13 09:54:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tretter X-Patchwork-Id: 13100415 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6ECE8C61DB3 for ; Fri, 13 Jan 2023 09:58:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=pgOzUygdgxArcgZemxt6SL2CIx5T1oryhbB0oq1WS2Q=; b=B/shSWz8NFLDAi y2G9W/dks2knWrU+gr9HUcdN5Lc//MFR+1amlLGO8zKMUJlakIMOnQ2j0fvEqxOT7eKZ7io1sfqoZ 2MWjphag2fyYjNi/qR4Ej/WCgAM8z2AWdThUL4hKGxc8qh+xf3JljhoyNCGdtQjbIXAYM3k+FoXt1 NEiUDJalned7LuoZ4+Q4ebISrKu/DeNuYYo11PDAM7ijM6uSH0yozPAJFqLIWsxeIu3/WVPb3VVG4 /Oo5G1fvqgCFeRaz5mx7SpRxSXB8lW/lz5K6Ti7HZfYMeKDp3+eQg7xElX7cp7KR/FQ+yNqYTRHDw QNg0KAcdA1k3RNC8FAbQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pGGoH-001bHH-2g; Fri, 13 Jan 2023 09:57:18 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pGGla-001Zxq-C5 for linux-arm-kernel@bombadil.infradead.org; Fri, 13 Jan 2023 09:54:30 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Cc:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Sender:Reply-To:Content-ID:Content-Description; bh=CpK6OuiPYd15SeSF+19WSjq1OkyQBaOrQtGy34qkbQs=; b=aOu0Velcwr8hrNPhtSiZF/FEsz wtGu772fihWXY2PXy8vnAauCVyHY1RdXNVny7Gu6NlxsQy1k7xCmgVTiVsknVyi9tWIU9luZsUEbB GA7NRyV7rimOBOMZZt+4/CC7JIsG1U1b/LvA6CNY/Ewittheue7od33zqJJL8osJgaNolUFatLeob +PocdJKHOnXJ7KUlZW3XInrYC8SCavrqm+Xz9e0i2RhPTQzFGXRNr5YiDDhbpVEVDzr0IeNWTr/zB 4UNLlSvNiw+rKfKxj9AXY7ZswZWGlN24fwpU0/b3ueu90BuBQ/UxdOE4dUTAmOwUtJ0ICWj3FgUNk jicj1LjQ==; Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pGGlN-004JVz-09 for linux-arm-kernel@lists.infradead.org; Fri, 13 Jan 2023 09:54:20 +0000 Received: from dude05.red.stw.pengutronix.de ([2a0a:edc0:0:1101:1d::54]) by metis.ext.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1pGGlL-0003cp-Ts; Fri, 13 Jan 2023 10:54:15 +0100 From: Michael Tretter Date: Fri, 13 Jan 2023 10:54:17 +0100 Subject: [PATCH v2 11/16] media: imx-pxp: Add media controller support MIME-Version: 1.0 Message-Id: <20230112-imx-pxp-v2-11-e2281da1db55@pengutronix.de> References: <20230112-imx-pxp-v2-0-e2281da1db55@pengutronix.de> In-Reply-To: <20230112-imx-pxp-v2-0-e2281da1db55@pengutronix.de> To: linux-media@vger.kernel.org, devicetree@vger.kernel.org, Philipp Zabel , Laurent Pinchart Cc: Michael Tretter , Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Fabio Estevam , Alexander Stein , kernel@pengutronix.de, linux-imx@nxp.com, linux-arm-kernel@lists.infradead.org X-Mailer: b4 0.11.2 X-SA-Exim-Connect-IP: 2a0a:edc0:0:1101:1d::54 X-SA-Exim-Mail-From: m.tretter@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230113_095417_272379_A24DDF6C X-CRM114-Status: GOOD ( 14.96 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Laurent Pinchart Register a media device for the PXP, using the v4l2-mem2mem MC infrastructure to populate the media graph. No media device operation is implemented, the main use of the MC API is to allow consistent discovery of media devices for userspace. Signed-off-by: Laurent Pinchart Reviewed-by: Michael Tretter Signed-off-by: Michael Tretter Reviewed-by: Philipp Zabel --- Changelog Changes since v1: - Drop manual setting of bus_info - Pick from https://lore.kernel.org/linux-media/20230112172507.30579-1-laurent.pinchart@ideasonboard.com --- drivers/media/platform/nxp/imx-pxp.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/drivers/media/platform/nxp/imx-pxp.c b/drivers/media/platform/nxp/imx-pxp.c index 86ccc3c4aae3..351e76ee32ca 100644 --- a/drivers/media/platform/nxp/imx-pxp.c +++ b/drivers/media/platform/nxp/imx-pxp.c @@ -24,6 +24,7 @@ #include #include +#include #include #include #include @@ -201,6 +202,9 @@ struct pxp_pdata { struct pxp_dev { struct v4l2_device v4l2_dev; struct video_device vfd; +#ifdef CONFIG_MEDIA_CONTROLLER + struct media_device mdev; +#endif struct clk *clk; void __iomem *mmio; @@ -1815,8 +1819,34 @@ static int pxp_probe(struct platform_device *pdev) goto err_m2m; } +#ifdef CONFIG_MEDIA_CONTROLLER + dev->mdev.dev = &pdev->dev; + strscpy(dev->mdev.model, MEM2MEM_NAME, sizeof(dev->mdev.model)); + media_device_init(&dev->mdev); + dev->v4l2_dev.mdev = &dev->mdev; + + ret = v4l2_m2m_register_media_controller(dev->m2m_dev, vfd, + MEDIA_ENT_F_PROC_VIDEO_PIXEL_FORMATTER); + if (ret) { + dev_err(&pdev->dev, "Failed to initialize media device\n"); + goto err_vfd; + } + + ret = media_device_register(&dev->mdev); + if (ret) { + dev_err(&pdev->dev, "Failed to register media device\n"); + goto err_m2m_mc; + } +#endif + return 0; +#ifdef CONFIG_MEDIA_CONTROLLER +err_m2m_mc: + v4l2_m2m_unregister_media_controller(dev->m2m_dev); +err_vfd: + video_unregister_device(vfd); +#endif err_m2m: v4l2_m2m_release(dev->m2m_dev); err_v4l2: @@ -1837,6 +1867,11 @@ static int pxp_remove(struct platform_device *pdev) clk_disable_unprepare(dev->clk); v4l2_info(&dev->v4l2_dev, "Removing " MEM2MEM_NAME); + +#ifdef CONFIG_MEDIA_CONTROLLER + media_device_unregister(&dev->mdev); + v4l2_m2m_unregister_media_controller(dev->m2m_dev); +#endif video_unregister_device(&dev->vfd); v4l2_m2m_release(dev->m2m_dev); v4l2_device_unregister(&dev->v4l2_dev);