linux-omap.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sebastian Reichel <sre@kernel.org>
To: Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Nikhil Devshatwar <nikhil.nd@ti.com>,
	dri-devel@lists.freedesktop.org, linux-omap@vger.kernel.org,
	Sekhar Nori <nsekhar@ti.com>, Tony Lindgren <tony@atomide.com>,
	hns@goldelico.com, Sam Ravnborg <sam@ravnborg.org>
Subject: Re: [PATCH v5 17/29] drm/panel: panel-dsi-cm: add panel database to driver
Date: Mon, 14 Dec 2020 17:04:32 +0100	[thread overview]
Message-ID: <20201214160432.b3exd37yaj74jirg@earth.universe> (raw)
In-Reply-To: <20201208122855.254819-18-tomi.valkeinen@ti.com>

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

On Tue, Dec 08, 2020 at 02:28:43PM +0200, Tomi Valkeinen wrote:
> Add a panel database to the driver instead of reading propertes from DT
> data. This is similar to panel-simple, and I believe it's more future
> safe way to handle the panels.
> 
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
> Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
> ---
>  drivers/gpu/drm/panel/panel-dsi-cm.c | 107 +++++++++++++++++----------
>  1 file changed, 69 insertions(+), 38 deletions(-)
> 
> diff --git a/drivers/gpu/drm/panel/panel-dsi-cm.c b/drivers/gpu/drm/panel/panel-dsi-cm.c
> index fa564aad7f25..3fb5b2856283 100644
> --- a/drivers/gpu/drm/panel/panel-dsi-cm.c
> +++ b/drivers/gpu/drm/panel/panel-dsi-cm.c
> @@ -21,10 +21,7 @@
>  #include <drm/drm_modes.h>
>  #include <drm/drm_panel.h>
>  
> -#include <video/display_timing.h>
>  #include <video/mipi_display.h>
> -#include <video/of_display_timing.h>
> -#include <video/videomode.h>
>  
>  #define DCS_GET_ID1		0xda
>  #define DCS_GET_ID2		0xdb
> @@ -32,6 +29,18 @@
>  
>  #define DCS_REGULATOR_SUPPLY_NUM 2
>  
> +static const struct of_device_id dsicm_of_match[];
> +
> +struct dsic_panel_data {
> +	u32 xres;
> +	u32 yres;
> +	u32 refresh;
> +	u32 width_mm;
> +	u32 height_mm;
> +	u32 max_hs_rate;
> +	u32 max_lp_rate;
> +};
> +
>  struct panel_drv_data {
>  	struct mipi_dsi_device *dsi;
>  	struct drm_panel panel;
> @@ -47,16 +56,14 @@ struct panel_drv_data {
>  					 */
>  	unsigned long	hw_guard_wait;	/* max guard time in jiffies */
>  
> -	/* panel HW configuration from DT or platform data */
> +	const struct dsic_panel_data *panel_data;
> +
>  	struct gpio_desc *reset_gpio;
>  
>  	struct regulator_bulk_data supplies[DCS_REGULATOR_SUPPLY_NUM];
>  
>  	bool use_dsi_backlight;
>  
> -	int width_mm;
> -	int height_mm;
> -
>  	/* runtime variables */
>  	bool enabled;
>  
> @@ -450,11 +457,8 @@ static int dsicm_get_modes(struct drm_panel *panel,
>  		return -ENOMEM;
>  	}
>  
> -	drm_mode_set_name(mode);
> -	mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED;
> -
> -	connector->display_info.width_mm = ddata->width_mm;
> -	connector->display_info.height_mm = ddata->height_mm;
> +	connector->display_info.width_mm = ddata->panel_data->width_mm;
> +	connector->display_info.height_mm = ddata->panel_data->height_mm;
>  
>  	drm_mode_probed_add(connector, mode);
>  
> @@ -471,15 +475,10 @@ static const struct drm_panel_funcs dsicm_panel_funcs = {
>  
>  static int dsicm_probe_of(struct mipi_dsi_device *dsi)
>  {
> -	struct device_node *node = dsi->dev.of_node;
>  	struct backlight_device *backlight;
>  	struct panel_drv_data *ddata = mipi_dsi_get_drvdata(dsi);
> -	struct display_timing timing;
> -	struct videomode vm = {
> -		.hactive = 864,
> -		.vactive = 480,
> -	};
>  	int err;
> +	struct drm_display_mode *mode = &ddata->mode;
>  
>  	ddata->reset_gpio = devm_gpiod_get(&dsi->dev, "reset", GPIOD_OUT_LOW);
>  	if (IS_ERR(ddata->reset_gpio)) {
> @@ -488,23 +487,16 @@ static int dsicm_probe_of(struct mipi_dsi_device *dsi)
>  		return err;
>  	}
>  
> -	err = of_get_display_timing(node, "panel-timing", &timing);
> -	if (!err) {
> -		videomode_from_timing(&timing, &vm);
> -	} else {
> -		dev_warn(&dsi->dev,
> -			 "failed to get video timing, using defaults\n");
> -	}
> -
> -	if (!vm.pixelclock)
> -		vm.pixelclock = vm.hactive * vm.vactive * 60;
> -	drm_display_mode_from_videomode(&vm, &ddata->mode);
> -
> -	ddata->width_mm = 0;
> -	of_property_read_u32(node, "width-mm", &ddata->width_mm);
> -
> -	ddata->height_mm = 0;
> -	of_property_read_u32(node, "height-mm", &ddata->height_mm);
> +	mode->hdisplay = mode->hsync_start = mode->hsync_end = mode->htotal =
> +		ddata->panel_data->xres;
> +	mode->vdisplay = mode->vsync_start = mode->vsync_end = mode->vtotal =
> +		ddata->panel_data->yres;
> +	mode->clock = ddata->panel_data->xres * ddata->panel_data->yres *
> +		ddata->panel_data->refresh / 1000;
> +	mode->width_mm = ddata->panel_data->width_mm;
> +	mode->height_mm = ddata->panel_data->height_mm;
> +	mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED;
> +	drm_mode_set_name(mode);
>  
>  	ddata->supplies[0].supply = "vpnl";
>  	ddata->supplies[1].supply = "vddi";
> @@ -531,6 +523,7 @@ static int dsicm_probe(struct mipi_dsi_device *dsi)
>  	struct panel_drv_data *ddata;
>  	struct backlight_device *bldev = NULL;
>  	struct device *dev = &dsi->dev;
> +	const struct of_device_id *id;
>  	int r;
>  
>  	dev_dbg(dev, "probe\n");
> @@ -542,6 +535,12 @@ static int dsicm_probe(struct mipi_dsi_device *dsi)
>  	mipi_dsi_set_drvdata(dsi, ddata);
>  	ddata->dsi = dsi;
>  
> +	id = of_match_node(dsicm_of_match, dev->of_node);
> +	if (!id)
> +		return -ENODEV;
> +
> +	ddata->panel_data = id->data;

ddata->panel_data = of_device_get_match_data(dev);
if (!ddata->panel_data)
    return -ENODEV;

Otherwise looks good to me:

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.com>

-- Sebastian

>  	r = dsicm_probe_of(dsi);
>  	if (r)
>  		return r;
> @@ -578,8 +577,8 @@ static int dsicm_probe(struct mipi_dsi_device *dsi)
>  	dsi->format = MIPI_DSI_FMT_RGB888;
>  	dsi->mode_flags = MIPI_DSI_CLOCK_NON_CONTINUOUS |
>  			  MIPI_DSI_MODE_EOT_PACKET;
> -	dsi->hs_rate = 300000000;
> -	dsi->lp_rate = 10000000;
> +	dsi->hs_rate = ddata->panel_data->max_hs_rate;
> +	dsi->lp_rate = ddata->panel_data->max_lp_rate;
>  
>  	drm_panel_add(&ddata->panel);
>  
> @@ -617,8 +616,40 @@ static int dsicm_remove(struct mipi_dsi_device *dsi)
>  	return 0;
>  }
>  
> +static const struct dsic_panel_data taal_data = {
> +	.xres = 864,
> +	.yres = 480,
> +	.refresh = 60,
> +	.width_mm = 0,
> +	.height_mm = 0,
> +	.max_hs_rate = 300000000,
> +	.max_lp_rate = 10000000,
> +};
> +
> +static const struct dsic_panel_data himalaya_data = {
> +	.xres = 480,
> +	.yres = 864,
> +	.refresh = 60,
> +	.width_mm = 49,
> +	.height_mm = 88,
> +	.max_hs_rate = 300000000,
> +	.max_lp_rate = 10000000,
> +};
> +
> +static const struct dsic_panel_data droid4_data = {
> +	.xres = 540,
> +	.yres = 960,
> +	.refresh = 60,
> +	.width_mm = 50,
> +	.height_mm = 89,
> +	.max_hs_rate = 300000000,
> +	.max_lp_rate = 10000000,
> +};
> +
>  static const struct of_device_id dsicm_of_match[] = {
> -	{ .compatible = "panel-dsi-cm", },
> +	{ .compatible = "tpo,taal", .data = &taal_data },
> +	{ .compatible = "nokia,himalaya", &himalaya_data },
> +	{ .compatible = "motorola,droid4-panel", &droid4_data },
>  	{},
>  };
>  
> -- 
> Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
> Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
> 

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

  reply	other threads:[~2020-12-14 16:05 UTC|newest]

Thread overview: 72+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-08 12:28 [PATCH v5 00/29] Convert DSI code to use drm_mipi_dsi and drm_panel (second half) Tomi Valkeinen
2020-12-08 12:28 ` [PATCH v5 01/29] drm/panel: panel-dsi-cm: cleanup tear enable Tomi Valkeinen
2020-12-14 13:09   ` Sebastian Reichel
2020-12-08 12:28 ` [PATCH v5 02/29] ARM: dts: omap5: add address-cells & size-cells to dsi Tomi Valkeinen
2020-12-14 13:09   ` Sebastian Reichel
2020-12-08 12:28 ` [PATCH v5 03/29] drm/omap: pll: fix iteration loop check Tomi Valkeinen
2020-12-14 13:10   ` Sebastian Reichel
2020-12-08 12:28 ` [PATCH v5 04/29] drm/omap: dsi: set trans_mode according to client mode_flags Tomi Valkeinen
2020-12-14 13:10   ` Sebastian Reichel
2020-12-08 12:28 ` [PATCH v5 05/29] drm/panel: panel-dsi-cm: set column & page at setup Tomi Valkeinen
2020-12-14 13:10   ` Sebastian Reichel
2020-12-08 12:28 ` [PATCH v5 06/29] drm/omap: dsi: send nop instead of page & column Tomi Valkeinen
2020-12-14 14:22   ` Sebastian Reichel
2020-12-08 12:28 ` [PATCH v5 07/29] drm/omap: dsi: simplify VC handling Tomi Valkeinen
2020-12-14 14:31   ` Sebastian Reichel
2020-12-08 12:28 ` [PATCH v5 08/29] drm/omap: dsi: drop useless channel checks Tomi Valkeinen
2020-12-14 14:32   ` Sebastian Reichel
2020-12-08 12:28 ` [PATCH v5 09/29] drm/omap: dsi: cleanup dispc channel usage Tomi Valkeinen
2020-12-08 15:17   ` Laurent Pinchart
2020-12-14 14:35   ` Sebastian Reichel
2020-12-08 12:28 ` [PATCH v5 10/29] drm/omap: dsi: rename 'channel' to 'vc' Tomi Valkeinen
2020-12-08 15:22   ` Laurent Pinchart
2020-12-14 15:18   ` Sebastian Reichel
2020-12-08 12:28 ` [PATCH v5 11/29] drm/omap: dsi: pass vc to various functions Tomi Valkeinen
2020-12-08 15:38   ` Laurent Pinchart
2020-12-08 15:45     ` Tomi Valkeinen
2020-12-14 15:37   ` Sebastian Reichel
2020-12-08 12:28 ` [PATCH v5 12/29] drm/omap: dsi: untangle vc & channel Tomi Valkeinen
2020-12-08 15:41   ` Laurent Pinchart
2020-12-14 15:47     ` Sebastian Reichel
2020-12-08 12:28 ` [PATCH v5 13/29] drm/omap: dsi: skip dsi_vc_enable_hs when already in correct mode Tomi Valkeinen
2020-12-14 15:50   ` Sebastian Reichel
2020-12-08 12:28 ` [PATCH v5 14/29] drm/omap: dsi: enable HS before sending the frame Tomi Valkeinen
2020-12-08 15:42   ` Laurent Pinchart
2020-12-14 15:51   ` Sebastian Reichel
2020-12-08 12:28 ` [PATCH v5 15/29] drm/omap: dsi: use separate VCs for cmd and video Tomi Valkeinen
2020-12-14 15:54   ` Sebastian Reichel
2020-12-08 12:28 ` [PATCH v5 16/29] drm/panel: panel-dsi-cm: remove extra 'if' Tomi Valkeinen
2020-12-08 15:42   ` Laurent Pinchart
2020-12-14 15:55   ` Sebastian Reichel
2020-12-08 12:28 ` [PATCH v5 17/29] drm/panel: panel-dsi-cm: add panel database to driver Tomi Valkeinen
2020-12-14 16:04   ` Sebastian Reichel [this message]
2020-12-08 12:28 ` [PATCH v5 18/29] drm/panel: panel-dsi-cm: drop unneeded includes Tomi Valkeinen
2020-12-14 16:06   ` Sebastian Reichel
2020-12-08 12:28 ` [PATCH v5 19/29] drm/omap: dsi: move structs & defines to dsi.h Tomi Valkeinen
2020-12-14 16:14   ` Sebastian Reichel
2020-12-08 12:28 ` [PATCH v5 20/29] drm/omap: dsi: move enable/disable to bridge enable/disable Tomi Valkeinen
2020-12-14 16:16   ` Sebastian Reichel
2020-12-08 12:28 ` [PATCH v5 21/29] drm/omap: dsi: display_enable cleanup Tomi Valkeinen
2020-12-14 16:17   ` Sebastian Reichel
2020-12-08 12:28 ` [PATCH v5 22/29] drm/omap: dsi: display_disable cleanup Tomi Valkeinen
2020-12-14 16:20   ` Sebastian Reichel
2020-12-08 12:28 ` [PATCH v5 23/29] drm/omap: dsi: rename dsi_display_* functions Tomi Valkeinen
2020-12-14 16:22   ` Sebastian Reichel
2020-12-08 12:28 ` [PATCH v5 24/29] drm/omap: dsi: cleanup initial vc setup Tomi Valkeinen
2020-12-14 16:34   ` Sebastian Reichel
2020-12-08 12:28 ` [PATCH v5 25/29] drm/omap: dsi: split video mode enable/disable into separate func Tomi Valkeinen
2020-12-14 16:38   ` Sebastian Reichel
2020-12-08 12:28 ` [PATCH v5 26/29] drm/omap: dsi: fix and cleanup ddr_clk_always_on Tomi Valkeinen
2020-12-14 16:39   ` Sebastian Reichel
2020-12-08 12:28 ` [PATCH v5 27/29] drm/omap: dsi: remove ulps support Tomi Valkeinen
2020-12-14 17:39   ` Sebastian Reichel
2020-12-14 18:55     ` Tomi Valkeinen
2020-12-14 22:08       ` Sebastian Reichel
2020-12-08 12:28 ` [PATCH v5 28/29] drm/omap: dsi: fix DCS_CMD_ENABLE Tomi Valkeinen
2020-12-14 16:48   ` Sebastian Reichel
2020-12-08 12:28 ` [PATCH v5 29/29] drm/omap: dsi: allow DSI commands to be sent early Tomi Valkeinen
2020-12-08 15:48   ` Laurent Pinchart
2020-12-10  7:34     ` Tomi Valkeinen
2020-12-10  8:17       ` Tomi Valkeinen
2020-12-14 17:17   ` Sebastian Reichel
2020-12-15 10:05     ` Tomi Valkeinen

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=20201214160432.b3exd37yaj74jirg@earth.universe \
    --to=sre@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=hns@goldelico.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-omap@vger.kernel.org \
    --cc=nikhil.nd@ti.com \
    --cc=nsekhar@ti.com \
    --cc=sam@ravnborg.org \
    --cc=tomi.valkeinen@ti.com \
    --cc=tony@atomide.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;
as well as URLs for NNTP newsgroup(s).