Skip to contentSkip to conversation

drm/panel: visionox-rm69299: Add backlight support and small fixes

PATCH Applied Guido Günther 3 participants 8 messages Sep 10, 2025 – Oct 1, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v3 cover drm/panel: visionox-rm69299: Add backlight support and small fixes

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.

---
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/[email protected]

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/[email protected]

---
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,

Signature · 1 line
Guido Günther <[email protected]>
#1 lore raw

PATCH v3 1/3 drm/panel: visionox-rm69299: Fix clock frequency for SHIFT6mq

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")
---
 drivers/gpu/drm/panel/panel-visionox-rm69299.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/panel/panel-visionox-rm69299.c +1 -1
index 909c280eab1fb408a713d84051a1afbb252c45e8..5491d601681cff52eca1d72ad4489731d2276c30 100644
@@ -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,
Signature · 1 line
2.51.0
Reviewed-by on v3 1/3
#2 lore raw

Re: [PATCH v3 1/3] drm/panel: visionox-rm69299: Fix clock frequency for SHIFT6mq

Quoted 10 lines · 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")
---
 drivers/gpu/drm/panel/panel-visionox-rm69299.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Signature · 2 lines
With best wishes
Dmitry
#3 lore raw

PATCH v3 2/3 drm/panel: visionox-rm69299: Don't clear all mode flags

In reply to 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")
---
 drivers/gpu/drm/panel/panel-visionox-rm69299.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/panel/panel-visionox-rm69299.c +1 -1
index 5491d601681cff52eca1d72ad4489731d2276c30..66c30db3b73a71f23b587b6e994a22dba5e85d25 100644
@@ -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);
 
Signature · 1 line
2.51.0
Reviewed-by on v3 2/3
#4 lore raw

Re: [PATCH v3 2/3] drm/panel: visionox-rm69299: Don't clear all mode flags

Quoted 10 lines · 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")
---
 drivers/gpu/drm/panel/panel-visionox-rm69299.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Signature · 2 lines
With best wishes
Dmitry
#5 lore raw

PATCH v3 3/3 drm/panel: visionox-rm69299: Add backlight support

In reply to 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.

---
 drivers/gpu/drm/panel/panel-visionox-rm69299.c | 67 ++++++++++++++++++++++++++
 1 file changed, 67 insertions(+)
drivers/gpu/drm/panel/panel-visionox-rm69299.c +67 -0
index 66c30db3b73a71f23b587b6e994a22dba5e85d25..e5e688cf98fdc571ae9726f3c9afe7c83db1caf7 100644
@@ -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[] = {
Signature · 1 line
2.51.0
Reviewed-by on v3 3/3
#6 lore raw

Re: [PATCH v3 3/3] drm/panel: visionox-rm69299: Add backlight support

Quoted 10 lines · 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.

---
 drivers/gpu/drm/panel/panel-visionox-rm69299.c | 67 ++++++++++++++++++++++++++
 1 file changed, 67 insertions(+)
Signature · 2 lines
With best wishes
Dmitry
maintainer Applied
#7 lore raw

Re: (subset) [PATCH v3 0/3] drm/panel: visionox-rm69299: Add backlight support and small fixes

In reply to Guido Günther

Hi,

Quoted 9 lines · 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.

[...]

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
Signature · 1 line
Neil