mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/2] drm/panel: ilitek-ili9881c: Support in-panel 180° rotation
@ 2024-06-26 14:40 Philipp Zabel
  2024-06-26 14:40 ` [PATCH 1/2] drm/panel: ilitek-ili9881c: Explicitly set address mode, allow " Philipp Zabel
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Philipp Zabel @ 2024-06-26 14:40 UTC (permalink / raw)
  To: Neil Armstrong, Jessica Zhang, Sam Ravnborg, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Daniel Vetter
  Cc: dri-devel, linux-kernel, kernel, Philipp Zabel

The Ilitek IL9881C controller can rotate the image by 180°. This
might be desirable on devices with their display mounted upside down,
that don't have rotation capability in the SoC display controller.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
Philipp Zabel (2):
      drm/panel: ilitek-ili9881c: Explicitly set address mode, allow 180° rotation
      drm/panel: ilitek-ili9881c: Report subpixel order according to rotation

 drivers/gpu/drm/panel/panel-ilitek-ili9881c.c | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)
---
base-commit: 1613e604df0cd359cf2a7fbd9be7a0bcfacfabd0
change-id: 20240626-drm-panel-ili9881c-rotation-54d53a885d7c

Best regards,
-- 
Philipp Zabel <p.zabel@pengutronix.de>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/2] drm/panel: ilitek-ili9881c: Explicitly set address mode, allow 180° rotation
  2024-06-26 14:40 [PATCH 0/2] drm/panel: ilitek-ili9881c: Support in-panel 180° rotation Philipp Zabel
@ 2024-06-26 14:40 ` Philipp Zabel
  2024-10-08  9:07   ` Philipp Zabel
  2024-06-26 14:40 ` [PATCH 2/2] drm/panel: ilitek-ili9881c: Report subpixel order according to rotation Philipp Zabel
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 6+ messages in thread
From: Philipp Zabel @ 2024-06-26 14:40 UTC (permalink / raw)
  To: Neil Armstrong, Jessica Zhang, Sam Ravnborg, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Daniel Vetter
  Cc: dri-devel, linux-kernel, kernel, Philipp Zabel

We can use horizontal and vertical flipping via the MIPI DCS address
mode to rotate the display by 180° using the device tree "rotation"
property. Since the tl050hdv35 panel has been defined as rotated,
we have to invert the bits there.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
 drivers/gpu/drm/panel/panel-ilitek-ili9881c.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/panel/panel-ilitek-ili9881c.c b/drivers/gpu/drm/panel/panel-ilitek-ili9881c.c
index 084c37fa7348..b4565ff1a0de 100644
--- a/drivers/gpu/drm/panel/panel-ilitek-ili9881c.c
+++ b/drivers/gpu/drm/panel/panel-ilitek-ili9881c.c
@@ -42,6 +42,7 @@ struct ili9881c_desc {
 	const size_t init_length;
 	const struct drm_display_mode *mode;
 	const unsigned long mode_flags;
+	u8 default_address_mode;
 };
 
 struct ili9881c {
@@ -53,6 +54,7 @@ struct ili9881c {
 	struct gpio_desc	*reset;
 
 	enum drm_panel_orientation	orientation;
+	u8 address_mode;
 };
 
 #define ILI9881C_SWITCH_PAGE_INSTR(_page)	\
@@ -815,8 +817,6 @@ static const struct ili9881c_instr tl050hdv35_init[] = {
 	ILI9881C_COMMAND_INSTR(0xd1, 0x4b),
 	ILI9881C_COMMAND_INSTR(0xd2, 0x60),
 	ILI9881C_COMMAND_INSTR(0xd3, 0x39),
-	ILI9881C_SWITCH_PAGE_INSTR(0),
-	ILI9881C_COMMAND_INSTR(0x36, 0x03),
 };
 
 static const struct ili9881c_instr w552946ab_init[] = {
@@ -1299,6 +1299,14 @@ static int ili9881c_prepare(struct drm_panel *panel)
 	if (ret)
 		return ret;
 
+	if (ctx->address_mode) {
+		ret = mipi_dsi_dcs_write(ctx->dsi, MIPI_DCS_SET_ADDRESS_MODE,
+					 &ctx->address_mode,
+					 sizeof(ctx->address_mode));
+		if (ret < 0)
+			return ret;
+	}
+
 	ret = mipi_dsi_dcs_set_tear_on(ctx->dsi, MIPI_DSI_DCS_TEAR_MODE_VBLANK);
 	if (ret)
 		return ret;
@@ -1521,6 +1529,12 @@ static int ili9881c_dsi_probe(struct mipi_dsi_device *dsi)
 		return ret;
 	}
 
+	ctx->address_mode = ctx->desc->default_address_mode;
+	if (ctx->orientation == DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP) {
+		ctx->address_mode ^= 0x03;
+		ctx->orientation = DRM_MODE_PANEL_ORIENTATION_NORMAL;
+	}
+
 	ctx->panel.prepare_prev_first = true;
 
 	ret = drm_panel_of_backlight(&ctx->panel);
@@ -1572,6 +1586,7 @@ static const struct ili9881c_desc tl050hdv35_desc = {
 	.mode = &tl050hdv35_default_mode,
 	.mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_SYNC_PULSE |
 		      MIPI_DSI_MODE_LPM,
+	.default_address_mode = 0x03,
 };
 
 static const struct ili9881c_desc w552946aba_desc = {

-- 
2.39.2


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 2/2] drm/panel: ilitek-ili9881c: Report subpixel order according to rotation
  2024-06-26 14:40 [PATCH 0/2] drm/panel: ilitek-ili9881c: Support in-panel 180° rotation Philipp Zabel
  2024-06-26 14:40 ` [PATCH 1/2] drm/panel: ilitek-ili9881c: Explicitly set address mode, allow " Philipp Zabel
@ 2024-06-26 14:40 ` Philipp Zabel
  2024-10-09  7:47 ` [PATCH 0/2] drm/panel: ilitek-ili9881c: Support in-panel 180° rotation Neil Armstrong
  2024-10-09  7:55 ` Neil Armstrong
  3 siblings, 0 replies; 6+ messages in thread
From: Philipp Zabel @ 2024-06-26 14:40 UTC (permalink / raw)
  To: Neil Armstrong, Jessica Zhang, Sam Ravnborg, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Daniel Vetter
  Cc: dri-devel, linux-kernel, kernel, Philipp Zabel

Assume a default RGB subpixel order and flip it around if 180° rotation
is configured via address mode. Report subpixel order to userspace.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
 drivers/gpu/drm/panel/panel-ilitek-ili9881c.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/gpu/drm/panel/panel-ilitek-ili9881c.c b/drivers/gpu/drm/panel/panel-ilitek-ili9881c.c
index b4565ff1a0de..28cd7560e5db 100644
--- a/drivers/gpu/drm/panel/panel-ilitek-ili9881c.c
+++ b/drivers/gpu/drm/panel/panel-ilitek-ili9881c.c
@@ -1471,6 +1471,10 @@ static int ili9881c_get_modes(struct drm_panel *panel,
 
 	connector->display_info.width_mm = mode->width_mm;
 	connector->display_info.height_mm = mode->height_mm;
+	if (ctx->address_mode == 0x3)
+		connector->display_info.subpixel_order = SubPixelHorizontalBGR;
+	else
+		connector->display_info.subpixel_order = SubPixelHorizontalRGB;
 
 	/*
 	 * TODO: Remove once all drm drivers call

-- 
2.39.2


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] drm/panel: ilitek-ili9881c: Explicitly set address mode, allow 180° rotation
  2024-06-26 14:40 ` [PATCH 1/2] drm/panel: ilitek-ili9881c: Explicitly set address mode, allow " Philipp Zabel
@ 2024-10-08  9:07   ` Philipp Zabel
  0 siblings, 0 replies; 6+ messages in thread
From: Philipp Zabel @ 2024-10-08  9:07 UTC (permalink / raw)
  To: Neil Armstrong, Jessica Zhang, Sam Ravnborg, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Daniel Vetter
  Cc: dri-devel, linux-kernel, kernel

On Mi, 2024-06-26 at 16:40 +0200, Philipp Zabel wrote:
> We can use horizontal and vertical flipping via the MIPI DCS address
> mode to rotate the display by 180° using the device tree "rotation"
> property. Since the tl050hdv35 panel has been defined as rotated,
> we have to invert the bits there.
> 
> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>

Gentle ping, this still cleanly applies on drm-misc-next.

> ---
>  drivers/gpu/drm/panel/panel-ilitek-ili9881c.c | 19 +++++++++++++++++--
>  1 file changed, 17 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/panel/panel-ilitek-ili9881c.c b/drivers/gpu/drm/panel/panel-ilitek-ili9881c.c
> index 084c37fa7348..b4565ff1a0de 100644
> --- a/drivers/gpu/drm/panel/panel-ilitek-ili9881c.c
> +++ b/drivers/gpu/drm/panel/panel-ilitek-ili9881c.c
> @@ -42,6 +42,7 @@ struct ili9881c_desc {
>  	const size_t init_length;
>  	const struct drm_display_mode *mode;
>  	const unsigned long mode_flags;
> +	u8 default_address_mode;
>  };
>  
>  struct ili9881c {
> @@ -53,6 +54,7 @@ struct ili9881c {
>  	struct gpio_desc	*reset;
>  
>  	enum drm_panel_orientation	orientation;
> +	u8 address_mode;
>  };
>  
>  #define ILI9881C_SWITCH_PAGE_INSTR(_page)	\
> @@ -815,8 +817,6 @@ static const struct ili9881c_instr tl050hdv35_init[] = {
>  	ILI9881C_COMMAND_INSTR(0xd1, 0x4b),
>  	ILI9881C_COMMAND_INSTR(0xd2, 0x60),
>  	ILI9881C_COMMAND_INSTR(0xd3, 0x39),
> -	ILI9881C_SWITCH_PAGE_INSTR(0),
> -	ILI9881C_COMMAND_INSTR(0x36, 0x03),
>  };
>  
>  static const struct ili9881c_instr w552946ab_init[] = {
> @@ -1299,6 +1299,14 @@ static int ili9881c_prepare(struct drm_panel *panel)
>  	if (ret)
>  		return ret;
>  
> +	if (ctx->address_mode) {
> +		ret = mipi_dsi_dcs_write(ctx->dsi, MIPI_DCS_SET_ADDRESS_MODE,
> +					 &ctx->address_mode,
> +					 sizeof(ctx->address_mode));
> +		if (ret < 0)
> +			return ret;
> +	}
> +
>  	ret = mipi_dsi_dcs_set_tear_on(ctx->dsi, MIPI_DSI_DCS_TEAR_MODE_VBLANK);
>  	if (ret)
>  		return ret;
> @@ -1521,6 +1529,12 @@ static int ili9881c_dsi_probe(struct mipi_dsi_device *dsi)
>  		return ret;
>  	}
>  
> +	ctx->address_mode = ctx->desc->default_address_mode;
> +	if (ctx->orientation == DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP) {
> +		ctx->address_mode ^= 0x03;
> +		ctx->orientation = DRM_MODE_PANEL_ORIENTATION_NORMAL;
> +	}
> +

Is there anything wrong with the panel driver eating the bottom-up
panel orientation property by flipping scanout in the panel?

regards
Philipp

>  	ctx->panel.prepare_prev_first = true;
>  
>  	ret = drm_panel_of_backlight(&ctx->panel);
> @@ -1572,6 +1586,7 @@ static const struct ili9881c_desc tl050hdv35_desc = {
>  	.mode = &tl050hdv35_default_mode,
>  	.mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_SYNC_PULSE |
>  		      MIPI_DSI_MODE_LPM,
> +	.default_address_mode = 0x03,
>  };
>  
>  static const struct ili9881c_desc w552946aba_desc = {
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/2] drm/panel: ilitek-ili9881c: Support in-panel 180° rotation
  2024-06-26 14:40 [PATCH 0/2] drm/panel: ilitek-ili9881c: Support in-panel 180° rotation Philipp Zabel
  2024-06-26 14:40 ` [PATCH 1/2] drm/panel: ilitek-ili9881c: Explicitly set address mode, allow " Philipp Zabel
  2024-06-26 14:40 ` [PATCH 2/2] drm/panel: ilitek-ili9881c: Report subpixel order according to rotation Philipp Zabel
@ 2024-10-09  7:47 ` Neil Armstrong
  2024-10-09  7:55 ` Neil Armstrong
  3 siblings, 0 replies; 6+ messages in thread
From: Neil Armstrong @ 2024-10-09  7:47 UTC (permalink / raw)
  To: Philipp Zabel, Jessica Zhang, Sam Ravnborg, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Daniel Vetter
  Cc: dri-devel, linux-kernel, kernel

On 26/06/2024 16:40, Philipp Zabel wrote:
> The Ilitek IL9881C controller can rotate the image by 180°. This
> might be desirable on devices with their display mounted upside down,
> that don't have rotation capability in the SoC display controller.
> 
> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
> ---
> Philipp Zabel (2):
>        drm/panel: ilitek-ili9881c: Explicitly set address mode, allow 180° rotation
>        drm/panel: ilitek-ili9881c: Report subpixel order according to rotation
> 
>   drivers/gpu/drm/panel/panel-ilitek-ili9881c.c | 23 +++++++++++++++++++++--
>   1 file changed, 21 insertions(+), 2 deletions(-)
> ---
> base-commit: 1613e604df0cd359cf2a7fbd9be7a0bcfacfabd0
> change-id: 20240626-drm-panel-ili9881c-rotation-54d53a885d7c
> 
> Best regards,

Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/2] drm/panel: ilitek-ili9881c: Support in-panel 180° rotation
  2024-06-26 14:40 [PATCH 0/2] drm/panel: ilitek-ili9881c: Support in-panel 180° rotation Philipp Zabel
                   ` (2 preceding siblings ...)
  2024-10-09  7:47 ` [PATCH 0/2] drm/panel: ilitek-ili9881c: Support in-panel 180° rotation Neil Armstrong
@ 2024-10-09  7:55 ` Neil Armstrong
  3 siblings, 0 replies; 6+ messages in thread
From: Neil Armstrong @ 2024-10-09  7:55 UTC (permalink / raw)
  To: Jessica Zhang, Sam Ravnborg, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter, Philipp Zabel
  Cc: dri-devel, linux-kernel, kernel

Hi,

On Wed, 26 Jun 2024 16:40:37 +0200, Philipp Zabel wrote:
> The Ilitek IL9881C controller can rotate the image by 180°. This
> might be desirable on devices with their display mounted upside down,
> that don't have rotation capability in the SoC display controller.
> 
> 

Thanks, Applied to https://gitlab.freedesktop.org/drm/misc/kernel.git (drm-misc-next)

[1/2] drm/panel: ilitek-ili9881c: Explicitly set address mode, allow 180° rotation
      https://gitlab.freedesktop.org/drm/misc/kernel/-/commit/b64e7d59ba75b1b080a65da20ffe0bae532854b5
[2/2] drm/panel: ilitek-ili9881c: Report subpixel order according to rotation
      https://gitlab.freedesktop.org/drm/misc/kernel/-/commit/655b92ca60a2d3fac83e8974fd786da6aea7fca2

-- 
Neil


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-10-09  7:56 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-26 14:40 [PATCH 0/2] drm/panel: ilitek-ili9881c: Support in-panel 180° rotation Philipp Zabel
2024-06-26 14:40 ` [PATCH 1/2] drm/panel: ilitek-ili9881c: Explicitly set address mode, allow " Philipp Zabel
2024-10-08  9:07   ` Philipp Zabel
2024-06-26 14:40 ` [PATCH 2/2] drm/panel: ilitek-ili9881c: Report subpixel order according to rotation Philipp Zabel
2024-10-09  7:47 ` [PATCH 0/2] drm/panel: ilitek-ili9881c: Support in-panel 180° rotation Neil Armstrong
2024-10-09  7:55 ` Neil Armstrong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®