devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thierry Reding <thierry.reding@gmail.com>
To: Maxime Ripard <maxime.ripard@bootlin.com>
Cc: Mark Rutland <mark.rutland@arm.com>,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	dri-devel@lists.freedesktop.org, Chen-Yu Tsai <wens@csie.org>,
	Rob Herring <robh+dt@kernel.org>,
	Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
	Daniel Vetter <daniel.vetter@intel.com>,
	Maxime Ripard <maxime.ripard@free-electrons.com>,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v3 5/7] drm/panel: Add Ilitek ILI9881c panel driver
Date: Mon, 12 Mar 2018 08:39:33 +0100	[thread overview]
Message-ID: <20180312073933.GD23060@ulmo> (raw)
In-Reply-To: <4ebd47038b1ee1cc6b7d9738313f43f985268463.1520344489.git-series.maxime.ripard@bootlin.com>


[-- Attachment #1.1: Type: text/plain, Size: 4235 bytes --]

On Tue, Mar 06, 2018 at 02:56:02PM +0100, Maxime Ripard wrote:
> From: Maxime Ripard <maxime.ripard@free-electrons.com>
> 
> The LHR050H41 panel is the panel shipped with the BananaPi M2-Magic, and is
> based on the Ilitek ILI9881c Controller. Add a driver for it, modelled
> after the other Ilitek controller drivers.
> 
> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
> ---
>  drivers/gpu/drm/panel/Kconfig                 |   9 +-
>  drivers/gpu/drm/panel/Makefile                |   1 +-
>  drivers/gpu/drm/panel/panel-ilitek-ili9881c.c | 506 +++++++++++++++++++-
>  3 files changed, 516 insertions(+)
>  create mode 100644 drivers/gpu/drm/panel/panel-ilitek-ili9881c.c
[...]
> diff --git a/drivers/gpu/drm/panel/panel-ilitek-ili9881c.c b/drivers/gpu/drm/panel/panel-ilitek-ili9881c.c
[...]
> +static int ili9881c_prepare(struct drm_panel *panel)
> +{
> +	struct ili9881c *ctx = panel_to_ili9881c(panel);
> +	int i, ret;

i can be unsigned.

> +
> +	/* Power the panel */
> +	gpiod_set_value(ctx->power, 1);
> +	mdelay(5);
> +
> +	/* And reset it */
> +	gpiod_set_value(ctx->reset, 1);
> +	mdelay(20);
> +
> +	gpiod_set_value(ctx->reset, 0);
> +	mdelay(20);

5 and 20 milliseconds are much too long to busy loop. Use usleep_range()
and msleep() instead. It's probably fine to use msleep(5) in this case
regardless of the advice in Documentation/timers/timers-howto.txt since
a few milliseconds more aren't going to matter here.

> +
> +	for (i = 0; i < ARRAY_SIZE(ili9881c_init); i++) {
> +		struct ili9881c_instr *instr = &ili9881c_init[i];
> +
> +		if (instr->op == ILI9881C_SWITCH_PAGE)
> +			ret = ili9881c_switch_page(ctx, instr->arg.page);
> +		else if (instr->op == ILI9881C_COMMAND)
> +			ret = ili9881c_send_cmd_data(ctx, instr->arg.cmd.cmd,
> +						      instr->arg.cmd.data);
> +
> +		if (ret)
> +			return ret;
> +	}
> +
> +	ret = ili9881c_switch_page(ctx, 0);
> +	if (ret)
> +		return ret;
> +
> +	ret = mipi_dsi_dcs_set_tear_on(ctx->dsi, MIPI_DSI_DCS_TEAR_MODE_VBLANK);
> +	if (ret)
> +		return ret;
> +
> +	mipi_dsi_dcs_exit_sleep_mode(ctx->dsi);
> +	if (ret)
> +		return ret;
> +
> +	return 0;
> +}
> +
> +static void ili9881c_enable_bl(struct ili9881c *ctx, bool enable)
> +{
> +	if (!ctx->backlight)
> +		return;
> +
> +	if (enable) {
> +		ctx->backlight->props.state &= ~BL_CORE_FBBLANK;
> +		ctx->backlight->props.power = FB_BLANK_UNBLANK;
> +	} else {
> +		ctx->backlight->props.power = FB_BLANK_POWERDOWN;
> +		ctx->backlight->props.state |= BL_CORE_FBBLANK;
> +	}
> +
> +	backlight_update_status(ctx->backlight);
> +}

There's a new pair of functions, backlight_enable() and
backlight_disable() that do this now. Please use those. They also work
fine when passed a NULL pointer, so should be perfect to replace this
with.

> +
> +static int ili9881c_enable(struct drm_panel *panel)
> +{
> +	struct ili9881c *ctx = panel_to_ili9881c(panel);
> +
> +	mdelay(120);

Hogging the CPU for 120 milliseconds like this is a really bad idea. Use
msleep() instead.

> +	mipi_dsi_dcs_set_display_on(ctx->dsi);
> +
> +	ili9881c_enable_bl(ctx, true);
> +
> +	return 0;
> +}
> +
> +static int ili9881c_disable(struct drm_panel *panel)
> +{
> +	struct ili9881c *ctx = panel_to_ili9881c(panel);
> +
> +	ili9881c_enable_bl(ctx, false);
> +
> +	return mipi_dsi_dcs_set_display_off(ctx->dsi);
> +}
> +
> +static int ili9881c_unprepare(struct drm_panel *panel)
> +{
> +	struct ili9881c *ctx = panel_to_ili9881c(panel);
> +
> +	mipi_dsi_dcs_enter_sleep_mode(ctx->dsi);
> +	gpiod_set_value(ctx->power, 0);
> +	gpiod_set_value(ctx->reset, 1);
> +
> +	return 0;
> +}
> +
> +static const struct drm_display_mode default_mode = {
> +	.clock		= 62000,
> +	.vrefresh	= 60,
> +
> +	.hdisplay	= 720,
> +	.hsync_start	= 720 + 10,
> +	.hsync_end	= 720 + 10 + 20,
> +	.htotal		= 720 + 10 + 20 + 30,
> +
> +	.vdisplay	= 1280,
> +	.vsync_start	= 1280 + 10,
> +	.vsync_end	= 1280 + 10 + 10,
> +	.vtotal		= 1280 + 10 + 10 + 20,
> +};

You may want to consider using struct display_timing instead, since that
will allow the driver to be used on a broader range of devices.

Thierry

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

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2018-03-12  7:39 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-06 13:55 [PATCH v3 0/7] drm/sun4i: Allwinner MIPI-DSI support Maxime Ripard
2018-03-06 13:55 ` [PATCH v3 1/7] drm/sun4i: tcon: Add TRI finish interrupt for vblank Maxime Ripard
2018-03-06 13:55 ` [PATCH v3 2/7] dt-bindings: display: Add Allwinner MIPI-DSI bindings Maxime Ripard
2018-03-07 19:26   ` Rob Herring
2018-03-06 13:56 ` [PATCH v3 3/7] drm/sun4i: Add Allwinner A31 MIPI-DSI controller support Maxime Ripard
2018-03-22  2:17   ` Chen-Yu Tsai
2018-03-06 13:56 ` [PATCH v3 4/7] dt-bindings: panel: Add the Ilitek ILI9881c panel documentation Maxime Ripard
2018-03-06 13:56 ` [PATCH v3 5/7] drm/panel: Add Ilitek ILI9881c panel driver Maxime Ripard
2018-03-12  7:39   ` Thierry Reding [this message]
2018-03-06 13:56 ` [PATCH v3 6/7] arm: dts: sun8i: a33: Add the DSI-related nodes Maxime Ripard
2018-03-22  2:23   ` Chen-Yu Tsai
2018-04-04  8:14     ` Maxime Ripard
2018-03-06 13:56 ` [PATCH v3 7/7] [DO NOT MERGE] arm: dts: sun8i: bpi-m2m: Add DSI display Maxime Ripard
2018-03-23 17:06 ` [PATCH v3 0/7] drm/sun4i: Allwinner MIPI-DSI support Jagan Teki
2018-03-26 11:14   ` Maxime Ripard

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=20180312073933.GD23060@ulmo \
    --to=thierry.reding@gmail.com \
    --cc=daniel.vetter@intel.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=maxime.ripard@bootlin.com \
    --cc=maxime.ripard@free-electrons.com \
    --cc=robh+dt@kernel.org \
    --cc=thomas.petazzoni@bootlin.com \
    --cc=wens@csie.org \
    /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).