mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/2] drm/panel: samsung-s6e3ha2: Convert to mipi_dsi_*_multi()
@ 2026-12-01  4:33 Hsieh Hung-En
  2026-12-01  4:33 ` [PATCH 1/2] drm/panel: samsung-s6e3ha2: Ignore DCS errors in disable() Hsieh Hung-En
  2026-12-01  4:33 ` [PATCH 2/2] drm/panel: samsung-s6e3ha2: Use mipi_dsi_*_multi() functions Hsieh Hung-En
  0 siblings, 2 replies; 3+ messages in thread
From: Hsieh Hung-En @ 2026-12-01  4:33 UTC (permalink / raw)
  To: neil.armstrong, jesszhan0024, dianders
  Cc: maarten.lankhorst, mripard, tzimmermann, airlied, simona,
	hoegeun.kwon, human.hwang, dh09.lee, treding, andrzej.hajda,
	dri-devel, linux-samsung-soc, linux-kernel, Hsieh Hung-En

This series converts the Samsung S6E3HA2 MIPI-DSI panel driver to the
mipi_dsi_*_multi() helpers and fixes an error-handling bug in
s6e3ha2_disable() beforehand:

- Patch 1 fixes s6e3ha2_disable() so that DCS command failures are logged
  and ignored rather than returning early and leaving panel->enabled set.
- Patch 2 converts the driver to mipi_dsi_*_multi(), removing the custom
  hidden-return macros and deprecated MIPI DSI helpers. Patch 2 is
  intended to be a functional no-op apart from error logging; see the
  patch notes for how the command sequences were verified.

Note: While converting s6e3ha2_enable(), I noticed that it calls
s6e3ha2_test_key_on_f0(), then calls the brightness update sequence
which ends with s6e3ha2_test_key_off_f0(). As a result, the subsequent
commands (s6e3ha2_aor_control() through s6e3ha2_test()) are sent after
the F0 test key has been locked, followed by a second
s6e3ha2_test_key_off_f0() call. I intentionally left this command
sequence unchanged to avoid altering existing hardware behavior without
access to the panel. Please let me know if this should be handled
differently.

Compile-tested on arm64 with W=1, building each patch individually; not
tested on hardware.

Hsieh Hung-En (2):
  drm/panel: samsung-s6e3ha2: Ignore DCS errors in disable()
  drm/panel: samsung-s6e3ha2: Use mipi_dsi_*_multi() functions

 drivers/gpu/drm/panel/panel-samsung-s6e3ha2.c | 286 ++++++++----------
 1 file changed, 124 insertions(+), 162 deletions(-)


base-commit: 5de4885dae61a0e1708402e1fbf8f9d600ef1f4f
-- 
2.43.0


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

* [PATCH 1/2] drm/panel: samsung-s6e3ha2: Ignore DCS errors in disable()
  2026-12-01  4:33 [PATCH 0/2] drm/panel: samsung-s6e3ha2: Convert to mipi_dsi_*_multi() Hsieh Hung-En
@ 2026-12-01  4:33 ` Hsieh Hung-En
  2026-12-01  4:33 ` [PATCH 2/2] drm/panel: samsung-s6e3ha2: Use mipi_dsi_*_multi() functions Hsieh Hung-En
  1 sibling, 0 replies; 3+ messages in thread
From: Hsieh Hung-En @ 2026-12-01  4:33 UTC (permalink / raw)
  To: neil.armstrong, jesszhan0024, dianders
  Cc: maarten.lankhorst, mripard, tzimmermann, airlied, simona,
	hoegeun.kwon, human.hwang, dh09.lee, treding, andrzej.hajda,
	dri-devel, linux-samsung-soc, linux-kernel, Hsieh Hung-En

If s6e3ha2_disable() returns an error from mipi_dsi_dcs_enter_sleep_mode()
or mipi_dsi_dcs_set_display_off(), drm_panel_disable() skips clearing
panel->enabled and s6e3ha2_disable() also skips updating
bl_dev->props.power. unprepare() still powers the panel off, but the next
drm_panel_enable() sees the panel as already enabled and does nothing,
leaving the panel dark.

Log any DCS command failure, continue with the remaining disable sequence,
and always return 0 from s6e3ha2_disable().

Fixes: ed29f9426d9b ("drm/panel: Add support for S6E3HA2 panel driver on TM2 board")
Signed-off-by: Hsieh Hung-En <hungen3108@gmail.com>
---
 drivers/gpu/drm/panel/panel-samsung-s6e3ha2.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/panel/panel-samsung-s6e3ha2.c b/drivers/gpu/drm/panel/panel-samsung-s6e3ha2.c
index cede897ff69d..3a90b83002e5 100644
--- a/drivers/gpu/drm/panel/panel-samsung-s6e3ha2.c
+++ b/drivers/gpu/drm/panel/panel-samsung-s6e3ha2.c
@@ -504,8 +504,13 @@ static int s6e3ha2_disable(struct drm_panel *panel)
 	struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev);
 	int ret;
 
-	s6e3ha2_call_write_func(ret, mipi_dsi_dcs_enter_sleep_mode(dsi));
-	s6e3ha2_call_write_func(ret, mipi_dsi_dcs_set_display_off(dsi));
+	ret = mipi_dsi_dcs_enter_sleep_mode(dsi);
+	if (ret < 0)
+		dev_err(ctx->dev, "failed to enter sleep mode: %d\n", ret);
+
+	ret = mipi_dsi_dcs_set_display_off(dsi);
+	if (ret < 0)
+		dev_err(ctx->dev, "failed to set display off: %d\n", ret);
 
 	msleep(40);
 	ctx->bl_dev->props.power = BACKLIGHT_POWER_REDUCED;
-- 
2.43.0


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

* [PATCH 2/2] drm/panel: samsung-s6e3ha2: Use mipi_dsi_*_multi() functions
  2026-12-01  4:33 [PATCH 0/2] drm/panel: samsung-s6e3ha2: Convert to mipi_dsi_*_multi() Hsieh Hung-En
  2026-12-01  4:33 ` [PATCH 1/2] drm/panel: samsung-s6e3ha2: Ignore DCS errors in disable() Hsieh Hung-En
@ 2026-12-01  4:33 ` Hsieh Hung-En
  1 sibling, 0 replies; 3+ messages in thread
From: Hsieh Hung-En @ 2026-12-01  4:33 UTC (permalink / raw)
  To: neil.armstrong, jesszhan0024, dianders
  Cc: maarten.lankhorst, mripard, tzimmermann, airlied, simona,
	hoegeun.kwon, human.hwang, dh09.lee, treding, andrzej.hajda,
	dri-devel, linux-samsung-soc, linux-kernel, Hsieh Hung-En

Replace the deprecated MIPI DSI DCS helpers and the custom
s6e3ha2_dcs_write(), s6e3ha2_dcs_write_seq_static(), and
s6e3ha2_call_write_func() wrappers with the mipi_dsi_*_multi() helpers,
as suggested in Documentation/gpu/todo.rst.

Convert the static command helpers to void functions taking a
struct mipi_dsi_multi_context pointer, keeping their original names and
command sequences intact. Use mipi_dsi_usleep_range() in
s6e3ha2_panel_init(), while keeping plain msleep(40) in
s6e3ha2_disable() and clearing accum_err between commands so
SET_DISPLAY_OFF is still attempted if ENTER_SLEEP_MODE fails.

Split the DSI brightness write sequence out of s6e3ha2_set_brightness()
into s6e3ha2_apply_brightness() so that s6e3ha2_enable() can share its
own mipi_dsi_multi_context. This skips brightness writes if any earlier
command in s6e3ha2_enable() failed and propagates the first error. The
range and bl_dev->props.power checks remain in s6e3ha2_set_brightness()
for backlight core callers; when called from s6e3ha2_enable(),
brightness is already bounded by backlight core and props.power is set
to BACKLIGHT_POWER_REDUCED in prepare() and disable(), so behavior is
unchanged. Removing bl_dev from s6e3ha2_update_gamma() also drops the
redundant self-assignment of bl_dev->props.brightness.

The _multi() helpers now log failed DCS transfers automatically;
s6e3ha2_panel_init(), s6e3ha2_enable(), and s6e3ha2_set_brightness()
previously did not log errors, and s6e3ha2_disable() no longer needs
manual dev_err() calls.

Signed-off-by: Hsieh Hung-En <hungen3108@gmail.com>
---

Notes:
    - Mechanically extracted all 29 static DCS command byte sequences
      from s6e3ha2_dcs_write_seq_static() before and
      mipi_dsi_dcs_write_seq_multi() after, verifying that every
      sequence and byte value matches identically.
    - Mechanically verified the call order in s6e3ha2_panel_init(),
      s6e3ha2_disable(), and s6e3ha2_enable(), and that
      s6e3ha2_apply_brightness() issues the exact same command
      sequence previously in s6e3ha2_set_brightness().
    - For the two non-static writes, s6e3ha2_update_gamma() and
      s6e3ha2_set_vint() keep the same payload computation and only
      switch to mipi_dsi_dcs_write_buffer_multi() and
      mipi_dsi_dcs_write_var_seq_multi().

 drivers/gpu/drm/panel/panel-samsung-s6e3ha2.c | 289 ++++++++----------
 1 file changed, 123 insertions(+), 166 deletions(-)

diff --git a/drivers/gpu/drm/panel/panel-samsung-s6e3ha2.c b/drivers/gpu/drm/panel/panel-samsung-s6e3ha2.c
index 3a90b83002e5..01661428bfac 100644
--- a/drivers/gpu/drm/panel/panel-samsung-s6e3ha2.c
+++ b/drivers/gpu/drm/panel/panel-samsung-s6e3ha2.c
@@ -241,170 +241,129 @@ struct s6e3ha2 {
 	const struct s6e3ha2_panel_desc *desc;
 };
 
-static int s6e3ha2_dcs_write(struct s6e3ha2 *ctx, const void *data, size_t len)
+static void s6e3ha2_test_key_on_f0(struct mipi_dsi_multi_context *dsi_ctx)
 {
-	struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev);
-
-	return mipi_dsi_dcs_write_buffer(dsi, data, len);
-}
-
-#define s6e3ha2_dcs_write_seq_static(ctx, seq...) do {	\
-	static const u8 d[] = { seq };			\
-	int ret;					\
-	ret = s6e3ha2_dcs_write(ctx, d, ARRAY_SIZE(d));	\
-	if (ret < 0)					\
-		return ret;				\
-} while (0)
-
-#define s6e3ha2_call_write_func(ret, func) do {	\
-	ret = (func);				\
-	if (ret < 0)				\
-		return ret;			\
-} while (0)
-
-static int s6e3ha2_test_key_on_f0(struct s6e3ha2 *ctx)
-{
-	s6e3ha2_dcs_write_seq_static(ctx, 0xf0, 0x5a, 0x5a);
-	return 0;
+	mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0xf0, 0x5a, 0x5a);
 }
 
-static int s6e3ha2_test_key_off_f0(struct s6e3ha2 *ctx)
+static void s6e3ha2_test_key_off_f0(struct mipi_dsi_multi_context *dsi_ctx)
 {
-	s6e3ha2_dcs_write_seq_static(ctx, 0xf0, 0xa5, 0xa5);
-	return 0;
+	mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0xf0, 0xa5, 0xa5);
 }
 
-static int s6e3ha2_test_key_on_fc(struct s6e3ha2 *ctx)
+static void s6e3ha2_test_key_on_fc(struct mipi_dsi_multi_context *dsi_ctx)
 {
-	s6e3ha2_dcs_write_seq_static(ctx, 0xfc, 0x5a, 0x5a);
-	return 0;
+	mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0xfc, 0x5a, 0x5a);
 }
 
-static int s6e3ha2_test_key_off_fc(struct s6e3ha2 *ctx)
+static void s6e3ha2_test_key_off_fc(struct mipi_dsi_multi_context *dsi_ctx)
 {
-	s6e3ha2_dcs_write_seq_static(ctx, 0xfc, 0xa5, 0xa5);
-	return 0;
+	mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0xfc, 0xa5, 0xa5);
 }
 
-static int s6e3ha2_single_dsi_set(struct s6e3ha2 *ctx)
+static void s6e3ha2_single_dsi_set(struct mipi_dsi_multi_context *dsi_ctx)
 {
-	s6e3ha2_dcs_write_seq_static(ctx, 0xf2, 0x67);
-	s6e3ha2_dcs_write_seq_static(ctx, 0xf9, 0x09);
-	return 0;
+	mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0xf2, 0x67);
+	mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0xf9, 0x09);
 }
 
-static int s6e3ha2_freq_calibration(struct s6e3ha2 *ctx)
+static void s6e3ha2_freq_calibration(struct mipi_dsi_multi_context *dsi_ctx,
+				     enum s6e3ha2_type type)
 {
-	s6e3ha2_dcs_write_seq_static(ctx, 0xfd, 0x1c);
-	if (ctx->desc->type == HF2_TYPE)
-		s6e3ha2_dcs_write_seq_static(ctx, 0xf2, 0x67, 0x40, 0xc5);
-	s6e3ha2_dcs_write_seq_static(ctx, 0xfe, 0x20, 0x39);
-	s6e3ha2_dcs_write_seq_static(ctx, 0xfe, 0xa0);
-	s6e3ha2_dcs_write_seq_static(ctx, 0xfe, 0x20);
+	mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0xfd, 0x1c);
+	if (type == HF2_TYPE)
+		mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0xf2, 0x67, 0x40, 0xc5);
+	mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0xfe, 0x20, 0x39);
+	mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0xfe, 0xa0);
+	mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0xfe, 0x20);
 
-	if (ctx->desc->type == HA2_TYPE)
-		s6e3ha2_dcs_write_seq_static(ctx, 0xce, 0x03, 0x3b, 0x12, 0x62,
-						  0x40, 0x80, 0xc0, 0x28, 0x28,
-						  0x28, 0x28, 0x39, 0xc5);
+	if (type == HA2_TYPE)
+		mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0xce, 0x03, 0x3b, 0x12,
+					     0x62, 0x40, 0x80, 0xc0, 0x28, 0x28,
+					     0x28, 0x28, 0x39, 0xc5);
 	else
-		s6e3ha2_dcs_write_seq_static(ctx, 0xce, 0x03, 0x3b, 0x14, 0x6d,
-						  0x40, 0x80, 0xc0, 0x28, 0x28,
-						  0x28, 0x28, 0x39, 0xc5);
-
-	return 0;
+		mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0xce, 0x03, 0x3b, 0x14,
+					     0x6d, 0x40, 0x80, 0xc0, 0x28, 0x28,
+					     0x28, 0x28, 0x39, 0xc5);
 }
 
-static int s6e3ha2_aor_control(struct s6e3ha2 *ctx)
+static void s6e3ha2_aor_control(struct mipi_dsi_multi_context *dsi_ctx)
 {
-	s6e3ha2_dcs_write_seq_static(ctx, 0xb2, 0x03, 0x10);
-	return 0;
+	mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0xb2, 0x03, 0x10);
 }
 
-static int s6e3ha2_caps_elvss_set(struct s6e3ha2 *ctx)
+static void s6e3ha2_caps_elvss_set(struct mipi_dsi_multi_context *dsi_ctx)
 {
-	s6e3ha2_dcs_write_seq_static(ctx, 0xb6, 0x9c, 0x0a);
-	return 0;
+	mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0xb6, 0x9c, 0x0a);
 }
 
-static int s6e3ha2_acl_off(struct s6e3ha2 *ctx)
+static void s6e3ha2_acl_off(struct mipi_dsi_multi_context *dsi_ctx)
 {
-	s6e3ha2_dcs_write_seq_static(ctx, 0x55, 0x00);
-	return 0;
+	mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x55, 0x00);
 }
 
-static int s6e3ha2_acl_off_opr(struct s6e3ha2 *ctx)
+static void s6e3ha2_acl_off_opr(struct mipi_dsi_multi_context *dsi_ctx)
 {
-	s6e3ha2_dcs_write_seq_static(ctx, 0xb5, 0x40);
-	return 0;
+	mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0xb5, 0x40);
 }
 
-static int s6e3ha2_test_global(struct s6e3ha2 *ctx)
+static void s6e3ha2_test_global(struct mipi_dsi_multi_context *dsi_ctx)
 {
-	s6e3ha2_dcs_write_seq_static(ctx, 0xb0, 0x07);
-	return 0;
+	mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0xb0, 0x07);
 }
 
-static int s6e3ha2_test(struct s6e3ha2 *ctx)
+static void s6e3ha2_test(struct mipi_dsi_multi_context *dsi_ctx)
 {
-	s6e3ha2_dcs_write_seq_static(ctx, 0xb8, 0x19);
-	return 0;
+	mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0xb8, 0x19);
 }
 
-static int s6e3ha2_touch_hsync_on1(struct s6e3ha2 *ctx)
+static void s6e3ha2_touch_hsync_on1(struct mipi_dsi_multi_context *dsi_ctx)
 {
-	s6e3ha2_dcs_write_seq_static(ctx, 0xbd, 0x33, 0x11, 0x02,
-					0x16, 0x02, 0x16);
-	return 0;
+	mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0xbd, 0x33, 0x11, 0x02,
+				     0x16, 0x02, 0x16);
 }
 
-static int s6e3ha2_pentile_control(struct s6e3ha2 *ctx)
+static void s6e3ha2_pentile_control(struct mipi_dsi_multi_context *dsi_ctx)
 {
-	s6e3ha2_dcs_write_seq_static(ctx, 0xc0, 0x00, 0x00, 0xd8, 0xd8);
-	return 0;
+	mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0xc0, 0x00, 0x00, 0xd8, 0xd8);
 }
 
-static int s6e3ha2_poc_global(struct s6e3ha2 *ctx)
+static void s6e3ha2_poc_global(struct mipi_dsi_multi_context *dsi_ctx)
 {
-	s6e3ha2_dcs_write_seq_static(ctx, 0xb0, 0x20);
-	return 0;
+	mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0xb0, 0x20);
 }
 
-static int s6e3ha2_poc_setting(struct s6e3ha2 *ctx)
+static void s6e3ha2_poc_setting(struct mipi_dsi_multi_context *dsi_ctx)
 {
-	s6e3ha2_dcs_write_seq_static(ctx, 0xfe, 0x08);
-	return 0;
+	mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0xfe, 0x08);
 }
 
-static int s6e3ha2_pcd_set_off(struct s6e3ha2 *ctx)
+static void s6e3ha2_pcd_set_off(struct mipi_dsi_multi_context *dsi_ctx)
 {
-	s6e3ha2_dcs_write_seq_static(ctx, 0xcc, 0x40, 0x51);
-	return 0;
+	mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0xcc, 0x40, 0x51);
 }
 
-static int s6e3ha2_err_fg_set(struct s6e3ha2 *ctx)
+static void s6e3ha2_err_fg_set(struct mipi_dsi_multi_context *dsi_ctx)
 {
-	s6e3ha2_dcs_write_seq_static(ctx, 0xed, 0x44);
-	return 0;
+	mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0xed, 0x44);
 }
 
-static int s6e3ha2_hbm_off(struct s6e3ha2 *ctx)
+static void s6e3ha2_hbm_off(struct mipi_dsi_multi_context *dsi_ctx)
 {
-	s6e3ha2_dcs_write_seq_static(ctx, 0x53, 0x00);
-	return 0;
+	mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0x53, 0x00);
 }
 
-static int s6e3ha2_te_start_setting(struct s6e3ha2 *ctx)
+static void s6e3ha2_te_start_setting(struct mipi_dsi_multi_context *dsi_ctx)
 {
-	s6e3ha2_dcs_write_seq_static(ctx, 0xb9, 0x10, 0x09, 0xff, 0x00, 0x09);
-	return 0;
+	mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0xb9, 0x10, 0x09, 0xff, 0x00,
+				     0x09);
 }
 
-static int s6e3ha2_gamma_update(struct s6e3ha2 *ctx)
+static void s6e3ha2_gamma_update(struct mipi_dsi_multi_context *dsi_ctx)
 {
-	s6e3ha2_dcs_write_seq_static(ctx, 0xf7, 0x03);
+	mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0xf7, 0x03);
 	ndelay(100); /* need for 100ns delay */
-	s6e3ha2_dcs_write_seq_static(ctx, 0xf7, 0x00);
-	return 0;
+	mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0xf7, 0x00);
 }
 
 static int s6e3ha2_get_brightness(struct backlight_device *bl_dev)
@@ -412,15 +371,13 @@ static int s6e3ha2_get_brightness(struct backlight_device *bl_dev)
 	return bl_dev->props.brightness;
 }
 
-static int s6e3ha2_set_vint(struct s6e3ha2 *ctx)
+static void s6e3ha2_set_vint(struct mipi_dsi_multi_context *dsi_ctx,
+			     unsigned int brightness)
 {
-	struct backlight_device *bl_dev = ctx->bl_dev;
-	unsigned int brightness = bl_dev->props.brightness;
-	unsigned char data[] = { 0xf4, 0x8b,
-			vint_table[brightness * (S6E3HA2_VINT_STATUS_MAX - 1) /
-			S6E3HA2_MAX_BRIGHTNESS] };
+	unsigned int idx = brightness * (S6E3HA2_VINT_STATUS_MAX - 1) /
+			   S6E3HA2_MAX_BRIGHTNESS;
 
-	return s6e3ha2_dcs_write(ctx, data, ARRAY_SIZE(data));
+	mipi_dsi_dcs_write_var_seq_multi(dsi_ctx, 0xf4, 0x8b, vint_table[idx]);
 }
 
 static unsigned int s6e3ha2_get_brightness_index(unsigned int brightness)
@@ -429,28 +386,33 @@ static unsigned int s6e3ha2_get_brightness_index(unsigned int brightness)
 		S6E3HA2_MAX_BRIGHTNESS;
 }
 
-static int s6e3ha2_update_gamma(struct s6e3ha2 *ctx, unsigned int brightness)
+static void s6e3ha2_update_gamma(struct mipi_dsi_multi_context *dsi_ctx,
+				 unsigned int brightness)
 {
-	struct backlight_device *bl_dev = ctx->bl_dev;
 	unsigned int index = s6e3ha2_get_brightness_index(brightness);
 	u8 data[S6E3HA2_GAMMA_CMD_CNT + 1] = { 0xca, };
-	int ret;
 
 	memcpy(data + 1, gamma_tbl + index, S6E3HA2_GAMMA_CMD_CNT);
-	s6e3ha2_call_write_func(ret,
-				s6e3ha2_dcs_write(ctx, data, ARRAY_SIZE(data)));
-
-	s6e3ha2_call_write_func(ret, s6e3ha2_gamma_update(ctx));
-	bl_dev->props.brightness = brightness;
+	mipi_dsi_dcs_write_buffer_multi(dsi_ctx, data, ARRAY_SIZE(data));
+	s6e3ha2_gamma_update(dsi_ctx);
+}
 
-	return 0;
+static void s6e3ha2_apply_brightness(struct mipi_dsi_multi_context *dsi_ctx,
+				     unsigned int brightness)
+{
+	s6e3ha2_test_key_on_f0(dsi_ctx);
+	s6e3ha2_update_gamma(dsi_ctx, brightness);
+	s6e3ha2_aor_control(dsi_ctx);
+	s6e3ha2_set_vint(dsi_ctx, brightness);
+	s6e3ha2_test_key_off_f0(dsi_ctx);
 }
 
 static int s6e3ha2_set_brightness(struct backlight_device *bl_dev)
 {
 	struct s6e3ha2 *ctx = bl_get_data(bl_dev);
+	struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev);
+	struct mipi_dsi_multi_context dsi_ctx = { .dsi = dsi };
 	unsigned int brightness = bl_dev->props.brightness;
-	int ret;
 
 	if (brightness < S6E3HA2_MIN_BRIGHTNESS ||
 		brightness > bl_dev->props.max_brightness) {
@@ -461,13 +423,9 @@ static int s6e3ha2_set_brightness(struct backlight_device *bl_dev)
 	if (bl_dev->props.power > BACKLIGHT_POWER_REDUCED)
 		return -EPERM;
 
-	s6e3ha2_call_write_func(ret, s6e3ha2_test_key_on_f0(ctx));
-	s6e3ha2_call_write_func(ret, s6e3ha2_update_gamma(ctx, brightness));
-	s6e3ha2_call_write_func(ret, s6e3ha2_aor_control(ctx));
-	s6e3ha2_call_write_func(ret, s6e3ha2_set_vint(ctx));
-	s6e3ha2_call_write_func(ret, s6e3ha2_test_key_off_f0(ctx));
+	s6e3ha2_apply_brightness(&dsi_ctx, brightness);
 
-	return 0;
+	return dsi_ctx.accum_err;
 }
 
 static const struct backlight_ops s6e3ha2_bl_ops = {
@@ -478,19 +436,19 @@ static const struct backlight_ops s6e3ha2_bl_ops = {
 static int s6e3ha2_panel_init(struct s6e3ha2 *ctx)
 {
 	struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev);
-	int ret;
+	struct mipi_dsi_multi_context dsi_ctx = { .dsi = dsi };
 
-	s6e3ha2_call_write_func(ret, mipi_dsi_dcs_exit_sleep_mode(dsi));
-	usleep_range(5000, 6000);
+	mipi_dsi_dcs_exit_sleep_mode_multi(&dsi_ctx);
+	mipi_dsi_usleep_range(&dsi_ctx, 5000, 6000);
 
-	s6e3ha2_call_write_func(ret, s6e3ha2_test_key_on_f0(ctx));
-	s6e3ha2_call_write_func(ret, s6e3ha2_single_dsi_set(ctx));
-	s6e3ha2_call_write_func(ret, s6e3ha2_test_key_on_fc(ctx));
-	s6e3ha2_call_write_func(ret, s6e3ha2_freq_calibration(ctx));
-	s6e3ha2_call_write_func(ret, s6e3ha2_test_key_off_fc(ctx));
-	s6e3ha2_call_write_func(ret, s6e3ha2_test_key_off_f0(ctx));
+	s6e3ha2_test_key_on_f0(&dsi_ctx);
+	s6e3ha2_single_dsi_set(&dsi_ctx);
+	s6e3ha2_test_key_on_fc(&dsi_ctx);
+	s6e3ha2_freq_calibration(&dsi_ctx, ctx->desc->type);
+	s6e3ha2_test_key_off_fc(&dsi_ctx);
+	s6e3ha2_test_key_off_f0(&dsi_ctx);
 
-	return 0;
+	return dsi_ctx.accum_err;
 }
 
 static int s6e3ha2_power_off(struct s6e3ha2 *ctx)
@@ -502,15 +460,13 @@ static int s6e3ha2_disable(struct drm_panel *panel)
 {
 	struct s6e3ha2 *ctx = container_of(panel, struct s6e3ha2, panel);
 	struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev);
-	int ret;
+	struct mipi_dsi_multi_context dsi_ctx = { .dsi = dsi };
 
-	ret = mipi_dsi_dcs_enter_sleep_mode(dsi);
-	if (ret < 0)
-		dev_err(ctx->dev, "failed to enter sleep mode: %d\n", ret);
+	mipi_dsi_dcs_enter_sleep_mode_multi(&dsi_ctx);
 
-	ret = mipi_dsi_dcs_set_display_off(dsi);
-	if (ret < 0)
-		dev_err(ctx->dev, "failed to set display off: %d\n", ret);
+	/* Attempt to turn display off even if enter sleep mode failed. */
+	dsi_ctx.accum_err = 0;
+	mipi_dsi_dcs_set_display_off_multi(&dsi_ctx);
 
 	msleep(40);
 	ctx->bl_dev->props.power = BACKLIGHT_POWER_REDUCED;
@@ -572,43 +528,44 @@ static int s6e3ha2_enable(struct drm_panel *panel)
 {
 	struct s6e3ha2 *ctx = container_of(panel, struct s6e3ha2, panel);
 	struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev);
-	int ret;
+	struct mipi_dsi_multi_context dsi_ctx = { .dsi = dsi };
 
 	/* common setting */
-	s6e3ha2_call_write_func(ret,
-		mipi_dsi_dcs_set_tear_on(dsi, MIPI_DSI_DCS_TEAR_MODE_VBLANK));
+	mipi_dsi_dcs_set_tear_on_multi(&dsi_ctx, MIPI_DSI_DCS_TEAR_MODE_VBLANK);
 
-	s6e3ha2_call_write_func(ret, s6e3ha2_test_key_on_f0(ctx));
-	s6e3ha2_call_write_func(ret, s6e3ha2_test_key_on_fc(ctx));
-	s6e3ha2_call_write_func(ret, s6e3ha2_touch_hsync_on1(ctx));
-	s6e3ha2_call_write_func(ret, s6e3ha2_pentile_control(ctx));
-	s6e3ha2_call_write_func(ret, s6e3ha2_poc_global(ctx));
-	s6e3ha2_call_write_func(ret, s6e3ha2_poc_setting(ctx));
-	s6e3ha2_call_write_func(ret, s6e3ha2_test_key_off_fc(ctx));
+	s6e3ha2_test_key_on_f0(&dsi_ctx);
+	s6e3ha2_test_key_on_fc(&dsi_ctx);
+	s6e3ha2_touch_hsync_on1(&dsi_ctx);
+	s6e3ha2_pentile_control(&dsi_ctx);
+	s6e3ha2_poc_global(&dsi_ctx);
+	s6e3ha2_poc_setting(&dsi_ctx);
+	s6e3ha2_test_key_off_fc(&dsi_ctx);
 
 	/* pcd setting off for TB */
-	s6e3ha2_call_write_func(ret, s6e3ha2_pcd_set_off(ctx));
-	s6e3ha2_call_write_func(ret, s6e3ha2_err_fg_set(ctx));
-	s6e3ha2_call_write_func(ret, s6e3ha2_te_start_setting(ctx));
+	s6e3ha2_pcd_set_off(&dsi_ctx);
+	s6e3ha2_err_fg_set(&dsi_ctx);
+	s6e3ha2_te_start_setting(&dsi_ctx);
 
 	/* brightness setting */
-	s6e3ha2_call_write_func(ret, s6e3ha2_set_brightness(ctx->bl_dev));
-	s6e3ha2_call_write_func(ret, s6e3ha2_aor_control(ctx));
-	s6e3ha2_call_write_func(ret, s6e3ha2_caps_elvss_set(ctx));
-	s6e3ha2_call_write_func(ret, s6e3ha2_gamma_update(ctx));
-	s6e3ha2_call_write_func(ret, s6e3ha2_acl_off(ctx));
-	s6e3ha2_call_write_func(ret, s6e3ha2_acl_off_opr(ctx));
-	s6e3ha2_call_write_func(ret, s6e3ha2_hbm_off(ctx));
+	s6e3ha2_apply_brightness(&dsi_ctx, ctx->bl_dev->props.brightness);
+	s6e3ha2_aor_control(&dsi_ctx);
+	s6e3ha2_caps_elvss_set(&dsi_ctx);
+	s6e3ha2_gamma_update(&dsi_ctx);
+	s6e3ha2_acl_off(&dsi_ctx);
+	s6e3ha2_acl_off_opr(&dsi_ctx);
+	s6e3ha2_hbm_off(&dsi_ctx);
 
 	/* elvss temp compensation */
-	s6e3ha2_call_write_func(ret, s6e3ha2_test_global(ctx));
-	s6e3ha2_call_write_func(ret, s6e3ha2_test(ctx));
-	s6e3ha2_call_write_func(ret, s6e3ha2_test_key_off_f0(ctx));
+	s6e3ha2_test_global(&dsi_ctx);
+	s6e3ha2_test(&dsi_ctx);
+	s6e3ha2_test_key_off_f0(&dsi_ctx);
 
-	s6e3ha2_call_write_func(ret, mipi_dsi_dcs_set_display_on(dsi));
-	ctx->bl_dev->props.power = BACKLIGHT_POWER_ON;
+	mipi_dsi_dcs_set_display_on_multi(&dsi_ctx);
 
-	return 0;
+	if (!dsi_ctx.accum_err)
+		ctx->bl_dev->props.power = BACKLIGHT_POWER_ON;
+
+	return dsi_ctx.accum_err;
 }
 
 static const struct drm_display_mode s6e3ha2_mode = {
-- 
2.43.0


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

end of thread, other threads:[~2026-12-01  4:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-12-01  4:33 [PATCH 0/2] drm/panel: samsung-s6e3ha2: Convert to mipi_dsi_*_multi() Hsieh Hung-En
2026-12-01  4:33 ` [PATCH 1/2] drm/panel: samsung-s6e3ha2: Ignore DCS errors in disable() Hsieh Hung-En
2026-12-01  4:33 ` [PATCH 2/2] drm/panel: samsung-s6e3ha2: Use mipi_dsi_*_multi() functions Hsieh Hung-En

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®