public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Thierry Reding <thierry.reding@gmail.com>
To: Lin Huang <hl@rock-chips.com>
Cc: emil.l.velikov@gmail.com, briannorris@chromium.org,
	robh+dt@kernel.org, zyw@rock-chips.com, seanpaul@chromium.org,
	airlied@linux.ie, linux-kernel@vger.kernel.org,
	dri-devel@lists.freedesktop.org, nickey.yang@rock-chips.com
Subject: Re: [RESEND PATCH v3 1/3] drm/panel: refactor INNOLUX P079ZCA panel driver
Date: Mon, 12 Mar 2018 10:21:10 +0100	[thread overview]
Message-ID: <20180312092110.GC15972@ulmo> (raw)
In-Reply-To: <1512371870-15350-1-git-send-email-hl@rock-chips.com>

[-- Attachment #1: Type: text/plain, Size: 5241 bytes --]

On Mon, Dec 04, 2017 at 03:17:48PM +0800, Lin Huang wrote:
> Refactor Innolux P079ZCA panel driver, let it support
> multi panel.
> 
> Signed-off-by: Lin Huang <hl@rock-chips.com>
> ---
> Changes in v2:
> - Change regulator property name to meet the panel datasheet 
> Changes in v3:
> - this patch only refactor P079ZCA panel to support multi panel, support P097PFG panel in another patch 
> 
>  drivers/gpu/drm/panel/panel-innolux-p079zca.c | 147 ++++++++++++++++++--------
>  1 file changed, 105 insertions(+), 42 deletions(-)
> 
> diff --git a/drivers/gpu/drm/panel/panel-innolux-p079zca.c b/drivers/gpu/drm/panel/panel-innolux-p079zca.c
> index 6ba9344..1597744 100644
> --- a/drivers/gpu/drm/panel/panel-innolux-p079zca.c
> +++ b/drivers/gpu/drm/panel/panel-innolux-p079zca.c
> @@ -20,12 +20,32 @@
>  
>  #include <video/mipi_display.h>
>  
> +struct panel_desc {
> +	const struct drm_display_mode *modes;
> +	unsigned int bpc;
> +	struct {
> +		unsigned int width;
> +		unsigned int height;
> +	} size;
> +};
> +
> +struct panel_desc_dsi {
> +	struct panel_desc desc;
> +
> +	unsigned long flags;
> +	enum mipi_dsi_pixel_format format;
> +	unsigned int lanes;
> +};

There's no need for the two layers here. Just move everything from
struct panel_desc_dsi into struct panel_desc.

> +
>  struct innolux_panel {
>  	struct drm_panel base;
>  	struct mipi_dsi_device *link;
> +	const struct panel_desc_dsi *dsi_desc;

And then this can just become:

	const struct panel_desc *desc;

The _dsi suffix is redundant because this driver is exclusively for DSI
devices.

> -static int innolux_panel_add(struct innolux_panel *innolux)
> +static int innolux_panel_add(struct mipi_dsi_device *dsi,
> +			     const struct panel_desc_dsi *desc)
>  {
> -	struct device *dev = &innolux->link->dev;
> +	struct innolux_panel *innolux;
> +	struct device *dev = &dsi->dev;
>  	struct device_node *np;
>  	int err;
>  
> -	innolux->supply = devm_regulator_get(dev, "power");
> -	if (IS_ERR(innolux->supply))
> -		return PTR_ERR(innolux->supply);
> +	innolux = devm_kzalloc(dev, sizeof(*innolux), GFP_KERNEL);
> +	if (!innolux)
> +		return -ENOMEM;
> +
> +	innolux->dsi_desc = desc;
> +	innolux->vddi = devm_regulator_get(dev, "power");
> +	if (IS_ERR(innolux->vddi))
> +		return PTR_ERR(innolux->vddi);
> +
> +	innolux->avdd = devm_regulator_get(dev, "avdd");
> +	if (IS_ERR(innolux->avdd))
> +		return PTR_ERR(innolux->avdd);
> +
> +	innolux->avee = devm_regulator_get(dev, "avee");
> +	if (IS_ERR(innolux->avee))
> +		return PTR_ERR(innolux->avee);

According to the device tree bindings these regulators are all optional.
Now devm_regulator_get() will return a dummy regulator if one has not
been specified in DT, so this seems like it should work fine, even for
existing DTBs that don't have the avdd and avee regulators. However, the
DT bindings seem to be wrong, because these are in fact required
regulators.

>  
>  	innolux->enable_gpio = devm_gpiod_get_optional(dev, "enable",
>  						       GPIOD_OUT_HIGH);
> @@ -243,14 +306,16 @@ static int innolux_panel_add(struct innolux_panel *innolux)
>  
>  	drm_panel_init(&innolux->base);
>  	innolux->base.funcs = &innolux_panel_funcs;
> -	innolux->base.dev = &innolux->link->dev;
> +	innolux->base.dev = dev;
>  
>  	err = drm_panel_add(&innolux->base);
>  	if (err < 0)
>  		goto put_backlight;
>  
> -	return 0;
> +	dev_set_drvdata(dev, innolux);
> +	innolux->link = dsi;
>  
> +	return 0;
>  put_backlight:
>  	put_device(&innolux->backlight->dev);
>  
> @@ -267,28 +332,25 @@ static void innolux_panel_del(struct innolux_panel *innolux)
>  
>  static int innolux_panel_probe(struct mipi_dsi_device *dsi)
>  {
> -	struct innolux_panel *innolux;
> -	int err;
>  
> -	dsi->lanes = 4;
> -	dsi->format = MIPI_DSI_FMT_RGB888;
> -	dsi->mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_SYNC_PULSE |
> -			  MIPI_DSI_MODE_LPM;
> -
> -	innolux = devm_kzalloc(&dsi->dev, sizeof(*innolux), GFP_KERNEL);
> -	if (!innolux)
> -		return -ENOMEM;
> +	const struct panel_desc_dsi *dsi_desc;
> +	const struct of_device_id *id;
> +	int err;
>  
> -	mipi_dsi_set_drvdata(dsi, innolux);
> +	id = of_match_node(innolux_of_match, dsi->dev.of_node);
> +	if (!id)
> +		return -ENODEV;
>  
> -	innolux->link = dsi;
> +	dsi_desc = id->data;
> +	dsi->mode_flags = dsi_desc->flags;
> +	dsi->format = dsi_desc->format;
> +	dsi->lanes = dsi_desc->lanes;
>  
> -	err = innolux_panel_add(innolux);
> +	err = innolux_panel_add(dsi, dsi_desc);
>  	if (err < 0)
>  		return err;
>  
> -	err = mipi_dsi_attach(dsi);
> -	return err;
> +	return mipi_dsi_attach(dsi);
>  }
>  
>  static int innolux_panel_remove(struct mipi_dsi_device *dsi)
> @@ -326,7 +388,7 @@ static void innolux_panel_shutdown(struct mipi_dsi_device *dsi)
>  
>  static struct mipi_dsi_driver innolux_panel_driver = {
>  	.driver = {
> -		.name = "panel-innolux-p079zca",
> +		.name = "panel-innolux-dsi",

No need to change that. Also, probably a bad idea to change it because
there are (or will be) likely other DSI panels from Innolux that are not
compatible with this driver.

Thierry

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  parent reply	other threads:[~2018-03-12  9:21 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-04  7:17 [RESEND PATCH v3 1/3] drm/panel: refactor INNOLUX P079ZCA panel driver Lin Huang
2017-12-04  7:17 ` [RESEND PATCH v3 2/3] drm/panel: support Innolux P097PFG panel Lin Huang
2017-12-04  7:17 ` [RESEND PATCH v3 3/3] dt-bindings: Add INNOLUX P097PFG panel bindings Lin Huang
2017-12-13 20:46 ` [RESEND PATCH v3 1/3] drm/panel: refactor INNOLUX P079ZCA panel driver Brian Norris
2018-03-12  9:21 ` Thierry Reding [this message]
2018-03-13  3:41   ` hl

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=20180312092110.GC15972@ulmo \
    --to=thierry.reding@gmail.com \
    --cc=airlied@linux.ie \
    --cc=briannorris@chromium.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=emil.l.velikov@gmail.com \
    --cc=hl@rock-chips.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nickey.yang@rock-chips.com \
    --cc=robh+dt@kernel.org \
    --cc=seanpaul@chromium.org \
    --cc=zyw@rock-chips.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox