All of lore.kernel.org
 help / color / mirror / Atom feed
From: Philipp Zabel <p.zabel@pengutronix.de>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: David Airlie <airlied@gmail.com>, Daniel Vetter <daniel@ffwll.ch>,
	Shawn Guo <shawnguo@kernel.org>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	Sam Ravnborg <sam@ravnborg.org>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Danilo Krummrich <dakr@redhat.com>, Liu Ying <victor.liu@nxp.com>,
	Pengutronix Kernel Team <kernel@pengutronix.de>,
	Fabio Estevam <festevam@gmail.com>,
	NXP Linux Team <linux-imx@nxp.com>,
	dri-devel@lists.freedesktop.org,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v5 2/2] drm/imx/lcdc: Implement DRM driver for imx25
Date: Mon, 6 Mar 2023 12:25:45 +0100	[thread overview]
Message-ID: <20230306112545.GA5486@pengutronix.de> (raw)
In-Reply-To: <20230210180014.173379-3-u.kleine-koenig@pengutronix.de>

Hi Uwe,

just a few nitpicks, see below.

On Fri, Feb 10, 2023 at 07:00:14PM +0100, Uwe Kleine-König wrote:
> From: Marian Cichy <m.cichy@pengutronix.de>
> 
> Add support for the LCD Controller found on i.MX21 and i.MX25.
> 
> It targets to be a drop in replacement for the imx-fb driver.
> 
> Signed-off-by: Marian Cichy <m.cichy@pengutronix.de>
> [ukl: Rebase to a newer kernel version, various smaller fixes and
> improvements]
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> ---
>  drivers/gpu/drm/imx/Kconfig         |   1 +
>  drivers/gpu/drm/imx/Makefile        |   1 +
>  drivers/gpu/drm/imx/lcdc/Kconfig    |   7 +
>  drivers/gpu/drm/imx/lcdc/Makefile   |   1 +
>  drivers/gpu/drm/imx/lcdc/imx-lcdc.c | 553 ++++++++++++++++++++++++++++
>  5 files changed, 563 insertions(+)
>  create mode 100644 drivers/gpu/drm/imx/lcdc/Kconfig
>  create mode 100644 drivers/gpu/drm/imx/lcdc/Makefile
>  create mode 100644 drivers/gpu/drm/imx/lcdc/imx-lcdc.c
> 
[...]
> diff --git a/drivers/gpu/drm/imx/lcdc/imx-lcdc.c b/drivers/gpu/drm/imx/lcdc/imx-lcdc.c
> new file mode 100644
> index 000000000000..c2197fc50306
> --- /dev/null
> +++ b/drivers/gpu/drm/imx/lcdc/imx-lcdc.c
> @@ -0,0 +1,553 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +// SPDX-FileCopyrightText: 2020 Marian Cichy <M.Cichy@pengutronix.de>
> +
> +#include <drm/drm_bridge_connector.h>
> +#include <drm/drm_damage_helper.h>
> +#include <drm/drm_drv.h>
> +#include <drm/drm_fbdev_generic.h>
> +#include <drm/drm_fb_dma_helper.h>
> +#include <drm/drm_fourcc.h>
> +#include <drm/drm_fourcc.h>

Choose one, remove the other.

[...]
> +struct imx_lcdc {
> +	struct drm_device drm;
> +	struct drm_simple_display_pipe pipe;
> +	const struct drm_display_mode *mode;

The mode pointer appears to be unused.

> +	struct drm_bridge *bridge;

The bridge could be a local variable in _probe().

> +	struct drm_connector *connector;
> +	void __iomem *base;
> +
> +	struct clk *clk_ipg;
> +	struct clk *clk_ahb;
> +	struct clk *clk_per;
> +};
> +
> +static const u32 imx_lcdc_formats[] = {
> +	DRM_FORMAT_RGB565, DRM_FORMAT_XRGB8888,
> +};
> +
> +static inline struct imx_lcdc *imx_lcdc_from_drmdev(struct drm_device *drm)
> +{
> +	return container_of(drm, struct imx_lcdc, drm);
> +}
> +
> +static unsigned int imx_lcdc_get_format(unsigned int drm_format)
> +{
> +	unsigned int bpp;
> +
> +	switch (drm_format) {
> +	default:
> +		DRM_WARN("Format not supported - fallback to XRGB8888\n");
> +		fallthrough;
> +
> +	case DRM_FORMAT_XRGB8888:
> +		bpp = BPP_XRGB8888;
> +		break;

This could just return directly, no need for the local bpp variable.

> +
> +	case DRM_FORMAT_RGB565:
> +		bpp = BPP_RGB565;
> +		break;
> +	}
> +
> +	return bpp;
> +}
> +
[...]
> +
> +static int imx_lcdc_probe(struct platform_device *pdev)
> +{
> +	struct imx_lcdc *lcdc;
> +	struct drm_device *drm;
> +	int irq;
> +	int ret;
> +	struct device *dev = &pdev->dev;
> +
> +	lcdc = devm_drm_dev_alloc(dev, &imx_lcdc_drm_driver,
> +				  struct imx_lcdc, drm);
> +	if (!lcdc)
> +		return -ENOMEM;
> +
> +	drm = &lcdc->drm;
> +
> +	lcdc->base = devm_platform_ioremap_resource(pdev, 0);
> +	if (IS_ERR(lcdc->base))
> +		return dev_err_probe(dev, PTR_ERR(lcdc->base), "Cannot get IO memory\n");
> +
> +	lcdc->bridge = devm_drm_of_get_bridge(dev, dev->of_node, 0, 0);
> +	if (IS_ERR(lcdc->bridge))
> +		return dev_err_probe(dev, PTR_ERR(lcdc->bridge), "Failed to find bridge\n");
[...]
> +	ret = drm_bridge_attach(&lcdc->pipe.encoder, lcdc->bridge, NULL, DRM_BRIDGE_ATTACH_NO_CONNECTOR);
> +	if (ret)
> +		return dev_err_probe(drm->dev, ret, "Cannot attach bridge\n");

The bridge could be a local variable.

With those addressed,

Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>

regards
Philipp

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

WARNING: multiple messages have this Message-ID (diff)
From: Philipp Zabel <p.zabel@pengutronix.de>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: Pengutronix Kernel Team <kernel@pengutronix.de>,
	Liu Ying <victor.liu@nxp.com>, Shawn Guo <shawnguo@kernel.org>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	dri-devel@lists.freedesktop.org,
	Danilo Krummrich <dakr@redhat.com>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Sam Ravnborg <sam@ravnborg.org>,
	linux-arm-kernel@lists.infradead.org,
	NXP Linux Team <linux-imx@nxp.com>
Subject: Re: [PATCH v5 2/2] drm/imx/lcdc: Implement DRM driver for imx25
Date: Mon, 6 Mar 2023 12:25:45 +0100	[thread overview]
Message-ID: <20230306112545.GA5486@pengutronix.de> (raw)
In-Reply-To: <20230210180014.173379-3-u.kleine-koenig@pengutronix.de>

Hi Uwe,

just a few nitpicks, see below.

On Fri, Feb 10, 2023 at 07:00:14PM +0100, Uwe Kleine-König wrote:
> From: Marian Cichy <m.cichy@pengutronix.de>
> 
> Add support for the LCD Controller found on i.MX21 and i.MX25.
> 
> It targets to be a drop in replacement for the imx-fb driver.
> 
> Signed-off-by: Marian Cichy <m.cichy@pengutronix.de>
> [ukl: Rebase to a newer kernel version, various smaller fixes and
> improvements]
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> ---
>  drivers/gpu/drm/imx/Kconfig         |   1 +
>  drivers/gpu/drm/imx/Makefile        |   1 +
>  drivers/gpu/drm/imx/lcdc/Kconfig    |   7 +
>  drivers/gpu/drm/imx/lcdc/Makefile   |   1 +
>  drivers/gpu/drm/imx/lcdc/imx-lcdc.c | 553 ++++++++++++++++++++++++++++
>  5 files changed, 563 insertions(+)
>  create mode 100644 drivers/gpu/drm/imx/lcdc/Kconfig
>  create mode 100644 drivers/gpu/drm/imx/lcdc/Makefile
>  create mode 100644 drivers/gpu/drm/imx/lcdc/imx-lcdc.c
> 
[...]
> diff --git a/drivers/gpu/drm/imx/lcdc/imx-lcdc.c b/drivers/gpu/drm/imx/lcdc/imx-lcdc.c
> new file mode 100644
> index 000000000000..c2197fc50306
> --- /dev/null
> +++ b/drivers/gpu/drm/imx/lcdc/imx-lcdc.c
> @@ -0,0 +1,553 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +// SPDX-FileCopyrightText: 2020 Marian Cichy <M.Cichy@pengutronix.de>
> +
> +#include <drm/drm_bridge_connector.h>
> +#include <drm/drm_damage_helper.h>
> +#include <drm/drm_drv.h>
> +#include <drm/drm_fbdev_generic.h>
> +#include <drm/drm_fb_dma_helper.h>
> +#include <drm/drm_fourcc.h>
> +#include <drm/drm_fourcc.h>

Choose one, remove the other.

[...]
> +struct imx_lcdc {
> +	struct drm_device drm;
> +	struct drm_simple_display_pipe pipe;
> +	const struct drm_display_mode *mode;

The mode pointer appears to be unused.

> +	struct drm_bridge *bridge;

The bridge could be a local variable in _probe().

> +	struct drm_connector *connector;
> +	void __iomem *base;
> +
> +	struct clk *clk_ipg;
> +	struct clk *clk_ahb;
> +	struct clk *clk_per;
> +};
> +
> +static const u32 imx_lcdc_formats[] = {
> +	DRM_FORMAT_RGB565, DRM_FORMAT_XRGB8888,
> +};
> +
> +static inline struct imx_lcdc *imx_lcdc_from_drmdev(struct drm_device *drm)
> +{
> +	return container_of(drm, struct imx_lcdc, drm);
> +}
> +
> +static unsigned int imx_lcdc_get_format(unsigned int drm_format)
> +{
> +	unsigned int bpp;
> +
> +	switch (drm_format) {
> +	default:
> +		DRM_WARN("Format not supported - fallback to XRGB8888\n");
> +		fallthrough;
> +
> +	case DRM_FORMAT_XRGB8888:
> +		bpp = BPP_XRGB8888;
> +		break;

This could just return directly, no need for the local bpp variable.

> +
> +	case DRM_FORMAT_RGB565:
> +		bpp = BPP_RGB565;
> +		break;
> +	}
> +
> +	return bpp;
> +}
> +
[...]
> +
> +static int imx_lcdc_probe(struct platform_device *pdev)
> +{
> +	struct imx_lcdc *lcdc;
> +	struct drm_device *drm;
> +	int irq;
> +	int ret;
> +	struct device *dev = &pdev->dev;
> +
> +	lcdc = devm_drm_dev_alloc(dev, &imx_lcdc_drm_driver,
> +				  struct imx_lcdc, drm);
> +	if (!lcdc)
> +		return -ENOMEM;
> +
> +	drm = &lcdc->drm;
> +
> +	lcdc->base = devm_platform_ioremap_resource(pdev, 0);
> +	if (IS_ERR(lcdc->base))
> +		return dev_err_probe(dev, PTR_ERR(lcdc->base), "Cannot get IO memory\n");
> +
> +	lcdc->bridge = devm_drm_of_get_bridge(dev, dev->of_node, 0, 0);
> +	if (IS_ERR(lcdc->bridge))
> +		return dev_err_probe(dev, PTR_ERR(lcdc->bridge), "Failed to find bridge\n");
[...]
> +	ret = drm_bridge_attach(&lcdc->pipe.encoder, lcdc->bridge, NULL, DRM_BRIDGE_ATTACH_NO_CONNECTOR);
> +	if (ret)
> +		return dev_err_probe(drm->dev, ret, "Cannot attach bridge\n");

The bridge could be a local variable.

With those addressed,

Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>

regards
Philipp

  parent reply	other threads:[~2023-03-06 11:27 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-10 18:00 [PATCH v5 0/2] drm/imx/lcdc: Implement DRM driver for imx25 Uwe Kleine-König
2023-02-10 18:00 ` Uwe Kleine-König
2023-02-10 18:00 ` Uwe Kleine-König
2023-02-10 18:00 ` [PATCH v5 1/2] dt-bindings: display: imx: Describe drm binding for fsl,imx-lcdc Uwe Kleine-König
2023-02-10 18:00   ` [PATCH v5 1/2] dt-bindings: display: imx: Describe drm binding for fsl, imx-lcdc Uwe Kleine-König
2023-02-10 18:00   ` [PATCH v5 1/2] dt-bindings: display: imx: Describe drm binding for fsl,imx-lcdc Uwe Kleine-König
2023-02-15 18:24   ` Rob Herring
2023-02-15 18:24     ` Rob Herring
2023-02-15 18:24     ` Rob Herring
2023-02-10 18:00 ` [PATCH v5 2/2] drm/imx/lcdc: Implement DRM driver for imx25 Uwe Kleine-König
2023-02-10 18:00   ` Uwe Kleine-König
2023-02-10 20:59   ` Uwe Kleine-König
2023-02-10 20:59     ` Uwe Kleine-König
2023-03-06 11:25   ` Philipp Zabel [this message]
2023-03-06 11:25     ` Philipp Zabel
  -- strict thread matches above, loose matches on Subject: below --
2023-02-12 13:23 kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230306112545.GA5486@pengutronix.de \
    --to=p.zabel@pengutronix.de \
    --cc=airlied@gmail.com \
    --cc=dakr@redhat.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=festevam@gmail.com \
    --cc=kernel@pengutronix.de \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-imx@nxp.com \
    --cc=s.hauer@pengutronix.de \
    --cc=sam@ravnborg.org \
    --cc=shawnguo@kernel.org \
    --cc=u.kleine-koenig@pengutronix.de \
    --cc=victor.liu@nxp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.