mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v3 0/3] drm/panel: visionox-rm69299: Add backlight support and small fixes
@ 2025-09-10 16:39 Guido Günther
  2025-09-10 16:39 ` [PATCH v3 1/3] drm/panel: visionox-rm69299: Fix clock frequency for SHIFT6mq Guido Günther
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Guido Günther @ 2025-09-10 16:39 UTC (permalink / raw)
  To: Neil Armstrong, Jessica Zhang, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter,
	Matthias Kaehlcke, Sam Ravnborg
  Cc: dri-devel, linux-kernel, phone-devel, Guido Günther

This adds optional backlight support via DSI commands. If
a max_brightness is set in the panel description the backlight
is created.

While at that we fold in the already sent out clock fix and
a fix that prevents us from clearing all mode flags when we
only want HS mode.

Signed-off-by: Guido Günther <agx@sigxcpu.org>
---
Changes in v3:
- Use clock formula in `visionox_rm69299_1080x2160_60hz` rather than the
  calculated value, thanks Dmitry Baryshkov
- Link to v2: https://lore.kernel.org/r/20250906-shift6mq-panel-v2-0-aa5e585d8717@sigxcpu.org

Changes in v2:
- Add Fixes: to the first two commits to make backports simpler
- Collect Reviewed-by:, thanks Neil Armstrong
- Link to v1: https://lore.kernel.org/r/20250901-shift6mq-panel-v1-0-444b4abbfaea@sigxcpu.org

---
Guido Günther (3):
      drm/panel: visionox-rm69299: Fix clock frequency for SHIFT6mq
      drm/panel: visionox-rm69299: Don't clear all mode flags
      drm/panel: visionox-rm69299: Add backlight support

 drivers/gpu/drm/panel/panel-visionox-rm69299.c | 71 +++++++++++++++++++++++++-
 1 file changed, 69 insertions(+), 2 deletions(-)
---
base-commit: b320789d6883cc00ac78ce83bccbfe7ed58afcf0
change-id: 20250901-shift6mq-panel-959b3087ecd2

Best regards,
-- 
Guido Günther <agx@sigxcpu.org>


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

* [PATCH v3 1/3] drm/panel: visionox-rm69299: Fix clock frequency for SHIFT6mq
  2025-09-10 16:39 [PATCH v3 0/3] drm/panel: visionox-rm69299: Add backlight support and small fixes Guido Günther
@ 2025-09-10 16:39 ` Guido Günther
  2025-09-10 19:46   ` Dmitry Baryshkov
  2025-09-10 16:39 ` [PATCH v3 2/3] drm/panel: visionox-rm69299: Don't clear all mode flags Guido Günther
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: Guido Günther @ 2025-09-10 16:39 UTC (permalink / raw)
  To: Neil Armstrong, Jessica Zhang, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter,
	Matthias Kaehlcke, Sam Ravnborg
  Cc: dri-devel, linux-kernel, phone-devel, Guido Günther

Make the clock frequency match what the sdm845 downstream kernel
uses. Otherwise the panel stays black.

Fixes: 783334f366b18 ("drm/panel: visionox-rm69299: support the variant found in the SHIFT6mq")
Signed-off-by: Guido Günther <agx@sigxcpu.org>
Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
---
 drivers/gpu/drm/panel/panel-visionox-rm69299.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/panel/panel-visionox-rm69299.c b/drivers/gpu/drm/panel/panel-visionox-rm69299.c
index 909c280eab1fb408a713d84051a1afbb252c45e8..5491d601681cff52eca1d72ad4489731d2276c30 100644
--- a/drivers/gpu/drm/panel/panel-visionox-rm69299.c
+++ b/drivers/gpu/drm/panel/panel-visionox-rm69299.c
@@ -247,7 +247,7 @@ static const struct drm_display_mode visionox_rm69299_1080x2248_60hz = {
 };
 
 static const struct drm_display_mode visionox_rm69299_1080x2160_60hz = {
-	.clock = 158695,
+	.clock = (2160 + 8 + 4 + 4) * (1080 + 26 + 2 + 36) * 60 / 1000,
 	.hdisplay = 1080,
 	.hsync_start = 1080 + 26,
 	.hsync_end = 1080 + 26 + 2,

-- 
2.51.0


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

* [PATCH v3 2/3] drm/panel: visionox-rm69299: Don't clear all mode flags
  2025-09-10 16:39 [PATCH v3 0/3] drm/panel: visionox-rm69299: Add backlight support and small fixes Guido Günther
  2025-09-10 16:39 ` [PATCH v3 1/3] drm/panel: visionox-rm69299: Fix clock frequency for SHIFT6mq Guido Günther
@ 2025-09-10 16:39 ` Guido Günther
  2025-09-10 19:47   ` Dmitry Baryshkov
  2025-09-10 16:39 ` [PATCH v3 3/3] drm/panel: visionox-rm69299: Add backlight support Guido Günther
  2025-10-01  7:15 ` (subset) [PATCH v3 0/3] drm/panel: visionox-rm69299: Add backlight support and small fixes Neil Armstrong
  3 siblings, 1 reply; 8+ messages in thread
From: Guido Günther @ 2025-09-10 16:39 UTC (permalink / raw)
  To: Neil Armstrong, Jessica Zhang, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter,
	Matthias Kaehlcke, Sam Ravnborg
  Cc: dri-devel, linux-kernel, phone-devel, Guido Günther

Don't clear all mode flags. We only want to maek sure we use HS mode
during unprepare.

Fixes: c7f66d32dd431 ("drm/panel: add support for rm69299 visionox panel")
Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
Signed-off-by: Guido Günther <agx@sigxcpu.org>
---
 drivers/gpu/drm/panel/panel-visionox-rm69299.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/panel/panel-visionox-rm69299.c b/drivers/gpu/drm/panel/panel-visionox-rm69299.c
index 5491d601681cff52eca1d72ad4489731d2276c30..66c30db3b73a71f23b587b6e994a22dba5e85d25 100644
--- a/drivers/gpu/drm/panel/panel-visionox-rm69299.c
+++ b/drivers/gpu/drm/panel/panel-visionox-rm69299.c
@@ -192,7 +192,7 @@ static int visionox_rm69299_unprepare(struct drm_panel *panel)
 	struct visionox_rm69299 *ctx = panel_to_ctx(panel);
 	struct mipi_dsi_multi_context dsi_ctx = { .dsi = ctx->dsi };
 
-	ctx->dsi->mode_flags = 0;
+	ctx->dsi->mode_flags &= ~MIPI_DSI_MODE_LPM;
 
 	mipi_dsi_dcs_set_display_off_multi(&dsi_ctx);
 

-- 
2.51.0


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

* [PATCH v3 3/3] drm/panel: visionox-rm69299: Add backlight support
  2025-09-10 16:39 [PATCH v3 0/3] drm/panel: visionox-rm69299: Add backlight support and small fixes Guido Günther
  2025-09-10 16:39 ` [PATCH v3 1/3] drm/panel: visionox-rm69299: Fix clock frequency for SHIFT6mq Guido Günther
  2025-09-10 16:39 ` [PATCH v3 2/3] drm/panel: visionox-rm69299: Don't clear all mode flags Guido Günther
@ 2025-09-10 16:39 ` Guido Günther
  2025-09-10 19:47   ` Dmitry Baryshkov
  2025-10-01  7:15 ` (subset) [PATCH v3 0/3] drm/panel: visionox-rm69299: Add backlight support and small fixes Neil Armstrong
  3 siblings, 1 reply; 8+ messages in thread
From: Guido Günther @ 2025-09-10 16:39 UTC (permalink / raw)
  To: Neil Armstrong, Jessica Zhang, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter,
	Matthias Kaehlcke, Sam Ravnborg
  Cc: dri-devel, linux-kernel, phone-devel, Guido Günther

The shift6mq's variant supports controlling the backlight via DSI
commands. Use that if a max_brightness is set in the device specific
data.

Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
Signed-off-by: Guido Günther <agx@sigxcpu.org>
---
 drivers/gpu/drm/panel/panel-visionox-rm69299.c | 67 ++++++++++++++++++++++++++
 1 file changed, 67 insertions(+)

diff --git a/drivers/gpu/drm/panel/panel-visionox-rm69299.c b/drivers/gpu/drm/panel/panel-visionox-rm69299.c
index 66c30db3b73a71f23b587b6e994a22dba5e85d25..e5e688cf98fdc571ae9726f3c9afe7c83db1caf7 100644
--- a/drivers/gpu/drm/panel/panel-visionox-rm69299.c
+++ b/drivers/gpu/drm/panel/panel-visionox-rm69299.c
@@ -3,6 +3,7 @@
  * Copyright (c) 2019, The Linux Foundation. All rights reserved.
  */
 
+#include <linux/backlight.h>
 #include <linux/delay.h>
 #include <linux/module.h>
 #include <linux/property.h>
@@ -20,6 +21,8 @@ struct visionox_rm69299_panel_desc {
 	const struct drm_display_mode *mode;
 	const u8 *init_seq;
 	unsigned int init_seq_len;
+	int max_brightness;
+	int initial_brightness;
 };
 
 struct visionox_rm69299 {
@@ -285,6 +288,63 @@ static const struct drm_panel_funcs visionox_rm69299_drm_funcs = {
 	.get_modes = visionox_rm69299_get_modes,
 };
 
+static int visionox_rm69299_bl_get_brightness(struct backlight_device *bl)
+{
+	struct mipi_dsi_device *dsi = bl_get_data(bl);
+	u16 brightness;
+	int ret;
+
+	dsi->mode_flags &= ~MIPI_DSI_MODE_LPM;
+
+	ret = mipi_dsi_dcs_get_display_brightness(dsi, &brightness);
+	if (ret < 0)
+		return ret;
+
+	dsi->mode_flags |= MIPI_DSI_MODE_LPM;
+
+	return brightness;
+}
+
+static int visionox_rm69299_bl_update_status(struct backlight_device *bl)
+{
+	struct mipi_dsi_device *dsi = bl_get_data(bl);
+	u16 brightness = backlight_get_brightness(bl);
+	int ret;
+
+	dsi->mode_flags &= ~MIPI_DSI_MODE_LPM;
+
+	ret = mipi_dsi_dcs_set_display_brightness(dsi, brightness);
+	if (ret < 0)
+		return ret;
+
+	dsi->mode_flags |= MIPI_DSI_MODE_LPM;
+
+	return 0;
+}
+
+static const struct backlight_ops visionox_rm69299_bl_ops = {
+	.update_status = visionox_rm69299_bl_update_status,
+	.get_brightness = visionox_rm69299_bl_get_brightness,
+};
+
+static struct backlight_device *
+visionox_rm69299_create_backlight(struct visionox_rm69299 *ctx)
+{
+	struct device *dev = &ctx->dsi->dev;
+	const struct backlight_properties props = {
+		.type = BACKLIGHT_RAW,
+		.brightness = ctx->desc->initial_brightness,
+		.max_brightness = ctx->desc->max_brightness,
+	};
+
+	if (!ctx->desc->max_brightness)
+		return 0;
+
+	return devm_backlight_device_register(dev, dev_name(dev), dev, ctx->dsi,
+					      &visionox_rm69299_bl_ops,
+					      &props);
+}
+
 static int visionox_rm69299_probe(struct mipi_dsi_device *dsi)
 {
 	struct device *dev = &dsi->dev;
@@ -316,6 +376,11 @@ static int visionox_rm69299_probe(struct mipi_dsi_device *dsi)
 		return PTR_ERR(ctx->reset_gpio);
 	}
 
+	ctx->panel.backlight = visionox_rm69299_create_backlight(ctx);
+	if (IS_ERR(ctx->panel.backlight))
+		return dev_err_probe(dev, PTR_ERR(ctx->panel.backlight),
+				     "Failed to create backlight\n");
+
 	drm_panel_add(&ctx->panel);
 
 	dsi->lanes = 4;
@@ -353,6 +418,8 @@ const struct visionox_rm69299_panel_desc visionox_rm69299_shift_desc = {
 	.mode = &visionox_rm69299_1080x2160_60hz,
 	.init_seq = (const u8 *)visionox_rm69299_1080x2160_60hz_init_seq,
 	.init_seq_len = ARRAY_SIZE(visionox_rm69299_1080x2160_60hz_init_seq),
+	.max_brightness = 255,
+	.initial_brightness = 50,
 };
 
 static const struct of_device_id visionox_rm69299_of_match[] = {

-- 
2.51.0


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

* Re: [PATCH v3 1/3] drm/panel: visionox-rm69299: Fix clock frequency for SHIFT6mq
  2025-09-10 16:39 ` [PATCH v3 1/3] drm/panel: visionox-rm69299: Fix clock frequency for SHIFT6mq Guido Günther
@ 2025-09-10 19:46   ` Dmitry Baryshkov
  0 siblings, 0 replies; 8+ messages in thread
From: Dmitry Baryshkov @ 2025-09-10 19:46 UTC (permalink / raw)
  To: Guido Günther
  Cc: Neil Armstrong, Jessica Zhang, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter,
	Matthias Kaehlcke, Sam Ravnborg, dri-devel, linux-kernel,
	phone-devel

On Wed, Sep 10, 2025 at 06:39:56PM +0200, Guido Günther wrote:
> Make the clock frequency match what the sdm845 downstream kernel
> uses. Otherwise the panel stays black.
> 
> Fixes: 783334f366b18 ("drm/panel: visionox-rm69299: support the variant found in the SHIFT6mq")
> Signed-off-by: Guido Günther <agx@sigxcpu.org>
> Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
> ---
>  drivers/gpu/drm/panel/panel-visionox-rm69299.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>


-- 
With best wishes
Dmitry

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

* Re: [PATCH v3 3/3] drm/panel: visionox-rm69299: Add backlight support
  2025-09-10 16:39 ` [PATCH v3 3/3] drm/panel: visionox-rm69299: Add backlight support Guido Günther
@ 2025-09-10 19:47   ` Dmitry Baryshkov
  0 siblings, 0 replies; 8+ messages in thread
From: Dmitry Baryshkov @ 2025-09-10 19:47 UTC (permalink / raw)
  To: Guido Günther
  Cc: Neil Armstrong, Jessica Zhang, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter,
	Matthias Kaehlcke, Sam Ravnborg, dri-devel, linux-kernel,
	phone-devel

On Wed, Sep 10, 2025 at 06:39:58PM +0200, Guido Günther wrote:
> The shift6mq's variant supports controlling the backlight via DSI
> commands. Use that if a max_brightness is set in the device specific
> data.
> 
> Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
> Signed-off-by: Guido Günther <agx@sigxcpu.org>
> ---
>  drivers/gpu/drm/panel/panel-visionox-rm69299.c | 67 ++++++++++++++++++++++++++
>  1 file changed, 67 insertions(+)
> 

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>


-- 
With best wishes
Dmitry

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

* Re: [PATCH v3 2/3] drm/panel: visionox-rm69299: Don't clear all mode flags
  2025-09-10 16:39 ` [PATCH v3 2/3] drm/panel: visionox-rm69299: Don't clear all mode flags Guido Günther
@ 2025-09-10 19:47   ` Dmitry Baryshkov
  0 siblings, 0 replies; 8+ messages in thread
From: Dmitry Baryshkov @ 2025-09-10 19:47 UTC (permalink / raw)
  To: Guido Günther
  Cc: Neil Armstrong, Jessica Zhang, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter,
	Matthias Kaehlcke, Sam Ravnborg, dri-devel, linux-kernel,
	phone-devel

On Wed, Sep 10, 2025 at 06:39:57PM +0200, Guido Günther wrote:
> Don't clear all mode flags. We only want to maek sure we use HS mode
> during unprepare.
> 
> Fixes: c7f66d32dd431 ("drm/panel: add support for rm69299 visionox panel")
> Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
> Signed-off-by: Guido Günther <agx@sigxcpu.org>
> ---
>  drivers/gpu/drm/panel/panel-visionox-rm69299.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>


-- 
With best wishes
Dmitry

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

* Re: (subset) [PATCH v3 0/3] drm/panel: visionox-rm69299: Add backlight support and small fixes
  2025-09-10 16:39 [PATCH v3 0/3] drm/panel: visionox-rm69299: Add backlight support and small fixes Guido Günther
                   ` (2 preceding siblings ...)
  2025-09-10 16:39 ` [PATCH v3 3/3] drm/panel: visionox-rm69299: Add backlight support Guido Günther
@ 2025-10-01  7:15 ` Neil Armstrong
  3 siblings, 0 replies; 8+ messages in thread
From: Neil Armstrong @ 2025-10-01  7:15 UTC (permalink / raw)
  To: Jessica Zhang, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter,
	Matthias Kaehlcke, Sam Ravnborg, Guido Günther
  Cc: dri-devel, linux-kernel, phone-devel

Hi,

On Wed, 10 Sep 2025 18:39:55 +0200, Guido Günther wrote:
> This adds optional backlight support via DSI commands. If
> a max_brightness is set in the panel description the backlight
> is created.
> 
> While at that we fold in the already sent out clock fix and
> a fix that prevents us from clearing all mode flags when we
> only want HS mode.
> 
> [...]

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

[1/3] drm/panel: visionox-rm69299: Fix clock frequency for SHIFT6mq
      https://gitlab.freedesktop.org/drm/misc/kernel/-/commit/d298062312724606855294503acebc7ee55ffbca
[2/3] drm/panel: visionox-rm69299: Don't clear all mode flags
      https://gitlab.freedesktop.org/drm/misc/kernel/-/commit/39144b611e9cd4f5814f4098c891b545dd70c536
[3/3] drm/panel: visionox-rm69299: Add backlight support
      https://gitlab.freedesktop.org/drm/misc/kernel/-/commit/7911d8cab55453b6bf59cd1f806503c3dbf0e990

-- 
Neil


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

end of thread, other threads:[~2025-10-01  7:15 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-10 16:39 [PATCH v3 0/3] drm/panel: visionox-rm69299: Add backlight support and small fixes Guido Günther
2025-09-10 16:39 ` [PATCH v3 1/3] drm/panel: visionox-rm69299: Fix clock frequency for SHIFT6mq Guido Günther
2025-09-10 19:46   ` Dmitry Baryshkov
2025-09-10 16:39 ` [PATCH v3 2/3] drm/panel: visionox-rm69299: Don't clear all mode flags Guido Günther
2025-09-10 19:47   ` Dmitry Baryshkov
2025-09-10 16:39 ` [PATCH v3 3/3] drm/panel: visionox-rm69299: Add backlight support Guido Günther
2025-09-10 19:47   ` Dmitry Baryshkov
2025-10-01  7:15 ` (subset) [PATCH v3 0/3] drm/panel: visionox-rm69299: Add backlight support and small fixes 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®