From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A1DBEC3DA7A for ; Fri, 6 Jan 2023 18:42:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231459AbjAFSmj (ORCPT ); Fri, 6 Jan 2023 13:42:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234975AbjAFSmj (ORCPT ); Fri, 6 Jan 2023 13:42:39 -0500 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 736867DE2D; Fri, 6 Jan 2023 10:42:38 -0800 (PST) Received: from pendragon.ideasonboard.com (213-243-189-158.bb.dnainternet.fi [213.243.189.158]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 070694AE; Fri, 6 Jan 2023 19:42:35 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1673030556; bh=yML0SUyUe1TNWY4vG/1mUGO0MBeZuusaJZU39NzomSI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=YfIZEEEuv7EgqRbInoOjCXibsp9AREP8rtpfOdV/+rGFexfq8rQCdVLmYrxd8LKyg qlpfWk4jeGNYSsEl6gMHVtUCRTaPkfZKbqTTPTJIacO1ErOlESHfTW/k2yTHILEo9x v6MDmwbqFdbSqHDoTNQJeup/1SliwjwjKvCeKpHc= Date: Fri, 6 Jan 2023 20:42:30 +0200 From: Laurent Pinchart To: Michael Tretter Cc: linux-media@vger.kernel.org, devicetree@vger.kernel.org, Philipp Zabel , Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Fabio Estevam , kernel@pengutronix.de, linux-imx@nxp.com, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH 6/8] media: imx-pxp: make data_path_ctrl0 platform dependent Message-ID: References: <20230105134729.59542-1-m.tretter@pengutronix.de> <20230105134729.59542-7-m.tretter@pengutronix.de> <20230106141141.GE24101@pengutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20230106141141.GE24101@pengutronix.de> Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org On Fri, Jan 06, 2023 at 03:11:41PM +0100, Michael Tretter wrote: > On Fri, 06 Jan 2023 14:30:52 +0200, Laurent Pinchart wrote: > > On Thu, Jan 05, 2023 at 02:47:27PM +0100, Michael Tretter wrote: > > > Unfortunately, the PXP_HW_VERSION register reports the PXP on the i.MX7D > > > and on the i.MX6ULL as version 3.0, although the PXP versions on these > > > SoCs have significant differences. > > > > > > Use the compatible to configure the ctrl0 register as required dependent > > > on the platform. > > > > > > Signed-off-by: Michael Tretter > > > --- > > > drivers/media/platform/nxp/imx-pxp.c | 27 +++++++++++++++++++++++++-- > > > 1 file changed, 25 insertions(+), 2 deletions(-) > > > > > > diff --git a/drivers/media/platform/nxp/imx-pxp.c b/drivers/media/platform/nxp/imx-pxp.c > > > index 1d649b9cadad..4e182f80a36b 100644 > > > --- a/drivers/media/platform/nxp/imx-pxp.c > > > +++ b/drivers/media/platform/nxp/imx-pxp.c > > > @@ -19,6 +19,7 @@ > > > #include > > > #include > > > #include > > > +#include > > > #include > > > #include > > > > > > @@ -191,6 +192,11 @@ static struct pxp_fmt *find_format(struct v4l2_format *f) > > > return &formats[k]; > > > } > > > > > > +struct pxp_ctx; > > > > Please add a blank line here. > > > > > +struct pxp_pdata { > > > + u32 (*data_path_ctrl0)(struct pxp_ctx *ctx); > > > +}; > > > + > > > struct pxp_dev { > > > struct v4l2_device v4l2_dev; > > > struct video_device vfd; > > > @@ -199,6 +205,7 @@ struct pxp_dev { > > > void __iomem *mmio; > > > > > > u32 hw_version; > > > + const struct pxp_pdata *pdata; > > > > > > atomic_t num_inst; > > > struct mutex dev_mutex; > > > @@ -726,7 +733,7 @@ static void pxp_setup_csc(struct pxp_ctx *ctx) > > > } > > > } > > > > > > -static u32 pxp_data_path_ctrl0(struct pxp_ctx *ctx) > > > +static u32 pxp_imx6ull_data_path_ctrl0(struct pxp_ctx *ctx) > > > { > > > u32 ctrl0; > > > > > > @@ -756,6 +763,16 @@ static u32 pxp_data_path_ctrl0(struct pxp_ctx *ctx) > > > return ctrl0; > > > } > > > > > > +static u32 pxp_data_path_ctrl0(struct pxp_ctx *ctx) > > > +{ > > > + struct pxp_dev *dev = ctx->dev; > > > + > > > + if (dev->pdata && dev->pdata->data_path_ctrl0) > > > + return dev->pdata->data_path_ctrl0(ctx); > > > + > > > + return pxp_imx6ull_data_path_ctrl0(ctx); > > > > Do you need this fallback, given that all compatible strings give you > > valid pdata ? I'd rather be explicit. > > > > This function then becomes so small that I would inline it in the > > caller. > > I was a bit paranoid that there may be cases in which pdata is not set. I will > change this to assume that pdata is always valid and just be explicit. If you're worried that future addition of platform support could add a compatible string with NULL .data, you could catch that in probe(). I'm not worried personally, as it would crash on first use, so the developer submitting the patch should notice. > > > +} > > > + > > > static void pxp_set_data_path(struct pxp_ctx *ctx) > > > { > > > struct pxp_dev *dev = ctx->dev; > > > @@ -1711,6 +1728,8 @@ static int pxp_probe(struct platform_device *pdev) > > > if (!dev) > > > return -ENOMEM; > > > > > > + dev->pdata = of_device_get_match_data(&pdev->dev); > > > + > > > dev->clk = devm_clk_get(&pdev->dev, "axi"); > > > if (IS_ERR(dev->clk)) { > > > ret = PTR_ERR(dev->clk); > > > @@ -1811,8 +1830,12 @@ static int pxp_remove(struct platform_device *pdev) > > > return 0; > > > } > > > > > > +static const struct pxp_pdata pxp_imx6ull_pdata = { > > > + .data_path_ctrl0 = pxp_imx6ull_data_path_ctrl0, > > > +}; > > > + > > > static const struct of_device_id pxp_dt_ids[] = { > > > - { .compatible = "fsl,imx6ull-pxp", .data = NULL }, > > > + { .compatible = "fsl,imx6ull-pxp", .data = &pxp_imx6ull_pdata }, > > > { }, > > > }; > > > MODULE_DEVICE_TABLE(of, pxp_dt_ids); -- Regards, Laurent Pinchart From mboxrd@z Thu Jan 1 00:00:00 1970 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 0C782C3DA7A for ; Fri, 6 Jan 2023 18:43:41 +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:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=PalIDiXqger9CyGQpy/b84zLOGAbipV5n41EkP6fxZU=; b=hLi/4/glJJFNz5 i2xo83L6s8fEejVXzS8VMGVr2lIm/QRVDJ3v+4pWSbq4MGNoPeWS6MRznckl4+EGB3RqrrxUdxXUL RoyKzpOFEl1VFZ1uelKaZa1CVzZhx66Y/dWtIQ4ckcLnUioAC7pJ1cG8gJSFZYX7fsFBjyrgYUJfD NPKV+15g0mg4m4ATZfez293bKWRNSmmm5NhsGY6AN0zidL+t1KHB8dW7JJ9W7B7C3c5oPrQZy9N5O w6wAN8X4xn4w5uXa2thpoBsrMPMwmPmpmlrXlMp3HtjFoEhOrww/M/oRbxjfbrdNlmO/YRSeu/Sh4 2ekewOZJWI2S8vK9stCA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pDrfu-00EQXH-0X; Fri, 06 Jan 2023 18:42:42 +0000 Received: from perceval.ideasonboard.com ([213.167.242.64]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pDrfq-00EQTc-77 for linux-arm-kernel@lists.infradead.org; Fri, 06 Jan 2023 18:42:40 +0000 Received: from pendragon.ideasonboard.com (213-243-189-158.bb.dnainternet.fi [213.243.189.158]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 070694AE; Fri, 6 Jan 2023 19:42:35 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1673030556; bh=yML0SUyUe1TNWY4vG/1mUGO0MBeZuusaJZU39NzomSI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=YfIZEEEuv7EgqRbInoOjCXibsp9AREP8rtpfOdV/+rGFexfq8rQCdVLmYrxd8LKyg qlpfWk4jeGNYSsEl6gMHVtUCRTaPkfZKbqTTPTJIacO1ErOlESHfTW/k2yTHILEo9x v6MDmwbqFdbSqHDoTNQJeup/1SliwjwjKvCeKpHc= Date: Fri, 6 Jan 2023 20:42:30 +0200 From: Laurent Pinchart To: Michael Tretter Cc: linux-media@vger.kernel.org, devicetree@vger.kernel.org, Philipp Zabel , Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski , Fabio Estevam , kernel@pengutronix.de, linux-imx@nxp.com, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH 6/8] media: imx-pxp: make data_path_ctrl0 platform dependent Message-ID: References: <20230105134729.59542-1-m.tretter@pengutronix.de> <20230105134729.59542-7-m.tretter@pengutronix.de> <20230106141141.GE24101@pengutronix.de> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20230106141141.GE24101@pengutronix.de> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230106_104238_455638_775C40EA X-CRM114-Status: GOOD ( 33.01 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Jan 06, 2023 at 03:11:41PM +0100, Michael Tretter wrote: > On Fri, 06 Jan 2023 14:30:52 +0200, Laurent Pinchart wrote: > > On Thu, Jan 05, 2023 at 02:47:27PM +0100, Michael Tretter wrote: > > > Unfortunately, the PXP_HW_VERSION register reports the PXP on the i.MX7D > > > and on the i.MX6ULL as version 3.0, although the PXP versions on these > > > SoCs have significant differences. > > > > > > Use the compatible to configure the ctrl0 register as required dependent > > > on the platform. > > > > > > Signed-off-by: Michael Tretter > > > --- > > > drivers/media/platform/nxp/imx-pxp.c | 27 +++++++++++++++++++++++++-- > > > 1 file changed, 25 insertions(+), 2 deletions(-) > > > > > > diff --git a/drivers/media/platform/nxp/imx-pxp.c b/drivers/media/platform/nxp/imx-pxp.c > > > index 1d649b9cadad..4e182f80a36b 100644 > > > --- a/drivers/media/platform/nxp/imx-pxp.c > > > +++ b/drivers/media/platform/nxp/imx-pxp.c > > > @@ -19,6 +19,7 @@ > > > #include > > > #include > > > #include > > > +#include > > > #include > > > #include > > > > > > @@ -191,6 +192,11 @@ static struct pxp_fmt *find_format(struct v4l2_format *f) > > > return &formats[k]; > > > } > > > > > > +struct pxp_ctx; > > > > Please add a blank line here. > > > > > +struct pxp_pdata { > > > + u32 (*data_path_ctrl0)(struct pxp_ctx *ctx); > > > +}; > > > + > > > struct pxp_dev { > > > struct v4l2_device v4l2_dev; > > > struct video_device vfd; > > > @@ -199,6 +205,7 @@ struct pxp_dev { > > > void __iomem *mmio; > > > > > > u32 hw_version; > > > + const struct pxp_pdata *pdata; > > > > > > atomic_t num_inst; > > > struct mutex dev_mutex; > > > @@ -726,7 +733,7 @@ static void pxp_setup_csc(struct pxp_ctx *ctx) > > > } > > > } > > > > > > -static u32 pxp_data_path_ctrl0(struct pxp_ctx *ctx) > > > +static u32 pxp_imx6ull_data_path_ctrl0(struct pxp_ctx *ctx) > > > { > > > u32 ctrl0; > > > > > > @@ -756,6 +763,16 @@ static u32 pxp_data_path_ctrl0(struct pxp_ctx *ctx) > > > return ctrl0; > > > } > > > > > > +static u32 pxp_data_path_ctrl0(struct pxp_ctx *ctx) > > > +{ > > > + struct pxp_dev *dev = ctx->dev; > > > + > > > + if (dev->pdata && dev->pdata->data_path_ctrl0) > > > + return dev->pdata->data_path_ctrl0(ctx); > > > + > > > + return pxp_imx6ull_data_path_ctrl0(ctx); > > > > Do you need this fallback, given that all compatible strings give you > > valid pdata ? I'd rather be explicit. > > > > This function then becomes so small that I would inline it in the > > caller. > > I was a bit paranoid that there may be cases in which pdata is not set. I will > change this to assume that pdata is always valid and just be explicit. If you're worried that future addition of platform support could add a compatible string with NULL .data, you could catch that in probe(). I'm not worried personally, as it would crash on first use, so the developer submitting the patch should notice. > > > +} > > > + > > > static void pxp_set_data_path(struct pxp_ctx *ctx) > > > { > > > struct pxp_dev *dev = ctx->dev; > > > @@ -1711,6 +1728,8 @@ static int pxp_probe(struct platform_device *pdev) > > > if (!dev) > > > return -ENOMEM; > > > > > > + dev->pdata = of_device_get_match_data(&pdev->dev); > > > + > > > dev->clk = devm_clk_get(&pdev->dev, "axi"); > > > if (IS_ERR(dev->clk)) { > > > ret = PTR_ERR(dev->clk); > > > @@ -1811,8 +1830,12 @@ static int pxp_remove(struct platform_device *pdev) > > > return 0; > > > } > > > > > > +static const struct pxp_pdata pxp_imx6ull_pdata = { > > > + .data_path_ctrl0 = pxp_imx6ull_data_path_ctrl0, > > > +}; > > > + > > > static const struct of_device_id pxp_dt_ids[] = { > > > - { .compatible = "fsl,imx6ull-pxp", .data = NULL }, > > > + { .compatible = "fsl,imx6ull-pxp", .data = &pxp_imx6ull_pdata }, > > > { }, > > > }; > > > MODULE_DEVICE_TABLE(of, pxp_dt_ids); -- Regards, Laurent Pinchart _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel