Re: [PATCH 13/14] drm/imx: dc-fu: Get DPR channel

Frank Li
2025-09-19T15:32:12Z

On Fri, Jul 04, 2025 at 05:04:00PM +0800, Liu Ying wrote:
> Add a helper dc_fu_get_dprc() to get DPR channel for FetchUnit.
> And, call it from dc_{fl,fw)_bind() to get DPR channels for
> FetchLayer and FetchWarp.
>
> Signed-off-by: Liu Ying <victor.liu@nxp.com>

Reviewed-by: Frank Li <Frank.Li@nxp.com>

> ---
> drivers/gpu/drm/imx/dc/dc-fl.c | 7 ++++++-
> drivers/gpu/drm/imx/dc/dc-fu.c | 18 ++++++++++++++++++
> drivers/gpu/drm/imx/dc/dc-fu.h | 5 +++++
> drivers/gpu/drm/imx/dc/dc-fw.c | 7 ++++++-
> 4 files changed, 35 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/imx/dc/dc-fl.c b/drivers/gpu/drm/imx/dc/dc-fl.c
> index 3ce24c72aa13e8aa150c0152a5a1ea3d0fa90b7e..a1835f43da0dc5cf0c83d93f16658b485011e285 100644
> --- a/drivers/gpu/drm/imx/dc/dc-fl.c
> +++ b/drivers/gpu/drm/imx/dc/dc-fl.c
> @@ -101,13 +101,18 @@ static int dc_fl_bind(struct device *dev, struct device *master, void *data)
> void __iomem *base_cfg;
> struct dc_fl *fl;
> struct dc_fu *fu;
> - int i, id;
> + int ret, i, id;
>
> fl = devm_kzalloc(dev, sizeof(*fl), GFP_KERNEL);
> if (!fl)
> return -ENOMEM;
>
> fu = &fl->fu;
> + fu->dev = dev;
> +
> + ret = dc_fu_get_dprc(fu);
> + if (ret)
> + return ret;
>
> res_pec = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>
> diff --git a/drivers/gpu/drm/imx/dc/dc-fu.c b/drivers/gpu/drm/imx/dc/dc-fu.c
> index b36d3034b8d5962eaab212b6b65ebbb5c29f978c..47d436abb65157de7cab74565e44b199be76de52 100644
> --- a/drivers/gpu/drm/imx/dc/dc-fu.c
> +++ b/drivers/gpu/drm/imx/dc/dc-fu.c
> @@ -10,6 +10,7 @@
>
> #include "dc-fu.h"
> #include "dc-pe.h"
> +#include "dc-prg.h"
>
> /* STATICCONTROL */
> #define SHDLDREQSTICKY_MASK GENMASK(31, 24)
> @@ -256,3 +257,20 @@ void dc_fu_common_hw_init(struct dc_fu *fu)
> dc_fu_set_pixel_blend_mode(fu, i);
> }
> }
> +
> +int dc_fu_get_dprc(struct dc_fu *fu)
> +{
> + struct dc_prg *prg;
> +
> + prg = dc_prg_lookup_by_phandle(fu->dev, "fsl,prg", 0);
> + if (!prg)
> + return dev_err_probe(fu->dev, -EPROBE_DEFER,
> + "failed to lookup PRG\n");
> +
> + fu->dprc = dc_prg_get_dprc(prg);
> + if (!fu->dprc)
> + return dev_err_probe(fu->dev, -EPROBE_DEFER,
> + "failed to get DPR channel\n");
> +
> + return 0;
> +}
> diff --git a/drivers/gpu/drm/imx/dc/dc-fu.h b/drivers/gpu/drm/imx/dc/dc-fu.h
> index 518d1af49f5ae9d4f67da5e6c2e80abd7e962120..44b9497e53580589a05bcb180eb2312ea4449da4 100644
> --- a/drivers/gpu/drm/imx/dc/dc-fu.h
> +++ b/drivers/gpu/drm/imx/dc/dc-fu.h
> @@ -8,11 +8,13 @@
>
> #include <linux/bitfield.h>
> #include <linux/bits.h>
> +#include <linux/device.h>
> #include <linux/regmap.h>
> #include <linux/types.h>
>
> #include <drm/drm_fourcc.h>
>
> +#include "dc-dprc.h"
> #include "dc-pe.h"
>
> #define FRAC_OFFSET 0x28
> @@ -99,6 +101,7 @@ struct dc_fu_ops {
> };
>
> struct dc_fu {
> + struct device *dev;
> struct regmap *reg_pec;
> struct regmap *reg_cfg;
> char name[21];
> @@ -114,6 +117,7 @@ struct dc_fu {
> enum dc_link_id link_id;
> struct dc_fu_ops ops;
> struct dc_lb *lb;
> + struct dc_dprc *dprc;
> };
>
> extern const struct dc_fu_ops dc_fu_common_ops;
> @@ -123,6 +127,7 @@ void dc_fu_get_pixel_format_shifts(struct dc_fu *fu, u32 format, u32 *shifts);
> void dc_fu_shdldreq_sticky(struct dc_fu *fu, u8 layer_mask);
> void dc_fu_set_src_bpp(struct dc_fu *fu, enum dc_fu_frac frac, unsigned int bpp);
> void dc_fu_common_hw_init(struct dc_fu *fu);
> +int dc_fu_get_dprc(struct dc_fu *fu);
>
> const struct dc_fu_ops *dc_fu_get_ops(struct dc_fu *fu);
>
> diff --git a/drivers/gpu/drm/imx/dc/dc-fw.c b/drivers/gpu/drm/imx/dc/dc-fw.c
> index acb2d4d9e2ecd6d36dbab050f25b560d9ec9aba5..c2e60741bc871c6976ead53f132b60f19352aab3 100644
> --- a/drivers/gpu/drm/imx/dc/dc-fw.c
> +++ b/drivers/gpu/drm/imx/dc/dc-fw.c
> @@ -131,13 +131,18 @@ static int dc_fw_bind(struct device *dev, struct device *master, void *data)
> void __iomem *base_cfg;
> struct dc_fw *fw;
> struct dc_fu *fu;
> - int i, id;
> + int ret, i, id;
>
> fw = devm_kzalloc(dev, sizeof(*fw), GFP_KERNEL);
> if (!fw)
> return -ENOMEM;
>
> fu = &fw->fu;
> + fu->dev = dev;
> +
> + ret = dc_fu_get_dprc(fu);
> + if (ret)
> + return ret;
>
> base_pec = devm_platform_get_and_ioremap_resource(pdev, 0, &res_pec);
> if (IS_ERR(base_pec))
>
> --
> 2.34.1
>