Skip to contentSkip to conversation

drm/panel: visionox-r66451: transition to mipi_dsi wrapped functions

PATCH Superseded Tejas Vipin 3 participants 4 messages Feb 8, 2025

Subsystems (3)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/panel: visionox-r66451: transition to mipi_dsi wrapped functions

Change the visionox-r66451 panel to use multi style functions for improved error handling.

---
 drivers/gpu/drm/panel/panel-visionox-r66451.c | 179 ++++++++----------
 1 file changed, 76 insertions(+), 103 deletions(-)
drivers/gpu/drm/panel/panel-visionox-r66451.c +76 -103
index 493f2a6076f8..81d615e1937a 100644
@@ -42,85 +42,84 @@ static void visionox_r66451_reset(struct visionox_r66451 *ctx)
 static int visionox_r66451_on(struct visionox_r66451 *ctx)
 {
 	struct mipi_dsi_device *dsi = ctx->dsi;
+	struct mipi_dsi_multi_context dsi_ctx = { .dsi = dsi };
 
 	dsi->mode_flags |= MIPI_DSI_MODE_LPM;
 
-	mipi_dsi_dcs_write_seq(dsi, 0xb0, 0x00);
-	mipi_dsi_dcs_write_seq(dsi, 0xc2,
-			       0x09, 0x24, 0x0c, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
-			       0x09, 0x3c);
-	mipi_dsi_dcs_write_seq(dsi, 0xd7,
-			       0x00, 0xb9, 0x3c, 0x00, 0x40, 0x04, 0x00, 0xa0, 0x0a,
-			       0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x19,
-			       0x3c, 0x00, 0x40, 0x04, 0x00, 0xa0, 0x0a);
-	mipi_dsi_dcs_write_seq(dsi, 0xb0, 0x80);
-	mipi_dsi_dcs_write_seq(dsi, 0xde,
-			       0x40, 0x00, 0x18, 0x00, 0x18, 0x00, 0x18, 0x00, 0x18,
-			       0x10, 0x00, 0x18, 0x00, 0x18, 0x00, 0x18, 0x02, 0x00, 0x00);
-	mipi_dsi_dcs_write_seq(dsi, 0xb0, 0x04);
-	mipi_dsi_dcs_write_seq(dsi, 0xe8, 0x00, 0x02);
-	mipi_dsi_dcs_write_seq(dsi, 0xe4, 0x00, 0x08);
-	mipi_dsi_dcs_write_seq(dsi, 0xb0, 0x00);
-	mipi_dsi_dcs_write_seq(dsi, 0xc4,
-			       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-			       0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x32);
-	mipi_dsi_dcs_write_seq(dsi, 0xcf,
-			       0x64, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08,
-			       0x00, 0x0b, 0x77, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
-			       0x02, 0x02, 0x02, 0x02, 0x02, 0x03);
-	mipi_dsi_dcs_write_seq(dsi, 0xd3,
-			       0x45, 0x00, 0x00, 0x01, 0x13, 0x15, 0x00, 0x15, 0x07,
-			       0x0f, 0x77, 0x77, 0x77, 0x37, 0xb2, 0x11, 0x00, 0xa0,
-			       0x3c, 0x9c);
-	mipi_dsi_dcs_write_seq(dsi, 0xd7,
-			       0x00, 0xb9, 0x34, 0x00, 0x40, 0x04, 0x00, 0xa0, 0x0a,
-			       0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x19,
-			       0x34, 0x00, 0x40, 0x04, 0x00, 0xa0, 0x0a);
-	mipi_dsi_dcs_write_seq(dsi, 0xd8,
-			       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-			       0x3a, 0x00, 0x3a, 0x00, 0x3a, 0x00, 0x3a, 0x00, 0x3a,
-			       0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-			       0x00, 0x0a, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00,
-			       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a,
-			       0x00, 0x32, 0x00, 0x0a, 0x00, 0x22);
-	mipi_dsi_dcs_write_seq(dsi, 0xdf,
-			       0x50, 0x42, 0x58, 0x81, 0x2d, 0x00, 0x00, 0x00, 0x00,
-			       0x00, 0x00, 0x6b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-			       0x00, 0x00, 0x01, 0x0f, 0xff, 0xd4, 0x0e, 0x00, 0x00,
-			       0x00, 0x00, 0x00, 0x00, 0x0f, 0x53, 0xf1, 0x00, 0x00,
-			       0x00, 0x00, 0x00, 0x00, 0x00, 0x00);
-	mipi_dsi_dcs_write_seq(dsi, 0xf7, 0x01);
-	mipi_dsi_dcs_write_seq(dsi, 0xb0, 0x80);
-	mipi_dsi_dcs_write_seq(dsi, 0xe4, 0x34, 0xb4, 0x00, 0x00, 0x00, 0x39, 0x04, 0x09, 0x34);
-	mipi_dsi_dcs_write_seq(dsi, 0xe6, 0x00);
-	mipi_dsi_dcs_write_seq(dsi, 0xb0, 0x04);
-	mipi_dsi_dcs_write_seq(dsi, 0xdf, 0x50, 0x40);
-	mipi_dsi_dcs_write_seq(dsi, 0xf3, 0x50, 0x00, 0x00, 0x00, 0x00);
-	mipi_dsi_dcs_write_seq(dsi, 0xf2, 0x11);
-	mipi_dsi_dcs_write_seq(dsi, 0xf3, 0x01, 0x00, 0x00, 0x00, 0x01);
-	mipi_dsi_dcs_write_seq(dsi, 0xf4, 0x00, 0x02);
-	mipi_dsi_dcs_write_seq(dsi, 0xf2, 0x19);
-	mipi_dsi_dcs_write_seq(dsi, 0xdf, 0x50, 0x42);
-	mipi_dsi_dcs_set_tear_on(dsi, MIPI_DSI_DCS_TEAR_MODE_VBLANK);
-	mipi_dsi_dcs_set_column_address(dsi, 0, 1080 - 1);
-	mipi_dsi_dcs_set_page_address(dsi, 0, 2340 - 1);
+	mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xb0, 0x00);
+	mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xc2,
+				     0x09, 0x24, 0x0c, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
+				     0x09, 0x3c);
+	mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xd7,
+				     0x00, 0xb9, 0x3c, 0x00, 0x40, 0x04, 0x00, 0xa0, 0x0a,
+				     0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x19,
+				     0x3c, 0x00, 0x40, 0x04, 0x00, 0xa0, 0x0a);
+	mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xb0, 0x80);
+	mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xde,
+				     0x40, 0x00, 0x18, 0x00, 0x18, 0x00, 0x18, 0x00, 0x18,
+				     0x10, 0x00, 0x18, 0x00, 0x18, 0x00, 0x18, 0x02, 0x00, 0x00);
+	mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xb0, 0x04);
+	mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xe8, 0x00, 0x02);
+	mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xe4, 0x00, 0x08);
+	mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xb0, 0x00);
+	mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xc4,
+				     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+				     0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x32);
+	mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xcf,
+				     0x64, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08,
+				     0x00, 0x0b, 0x77, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+				     0x02, 0x02, 0x02, 0x02, 0x02, 0x03);
+	mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xd3,
+				     0x45, 0x00, 0x00, 0x01, 0x13, 0x15, 0x00, 0x15, 0x07,
+				     0x0f, 0x77, 0x77, 0x77, 0x37, 0xb2, 0x11, 0x00, 0xa0,
+				     0x3c, 0x9c);
+	mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xd7,
+				     0x00, 0xb9, 0x34, 0x00, 0x40, 0x04, 0x00, 0xa0, 0x0a,
+				     0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x19,
+				     0x34, 0x00, 0x40, 0x04, 0x00, 0xa0, 0x0a);
+	mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xd8,
+				     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+				     0x3a, 0x00, 0x3a, 0x00, 0x3a, 0x00, 0x3a, 0x00, 0x3a,
+				     0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+				     0x00, 0x0a, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00,
+				     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a,
+				     0x00, 0x32, 0x00, 0x0a, 0x00, 0x22);
+	mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xdf,
+				     0x50, 0x42, 0x58, 0x81, 0x2d, 0x00, 0x00, 0x00, 0x00,
+				     0x00, 0x00, 0x6b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+				     0x00, 0x00, 0x01, 0x0f, 0xff, 0xd4, 0x0e, 0x00, 0x00,
+				     0x00, 0x00, 0x00, 0x00, 0x0f, 0x53, 0xf1, 0x00, 0x00,
+				     0x00, 0x00, 0x00, 0x00, 0x00, 0x00);
+	mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xf7, 0x01);
+	mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xb0, 0x80);
+	mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xe4, 0x34, 0xb4, 0x00, 0x00, 0x00, 0x39,
+				     0x04, 0x09, 0x34);
+	mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xe6, 0x00);
+	mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xb0, 0x04);
+	mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xdf, 0x50, 0x40);
+	mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xf3, 0x50, 0x00, 0x00, 0x00, 0x00);
+	mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xf2, 0x11);
+	mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xf3, 0x01, 0x00, 0x00, 0x00, 0x01);
+	mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xf4, 0x00, 0x02);
+	mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xf2, 0x19);
+	mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xdf, 0x50, 0x42);
+	mipi_dsi_dcs_set_tear_on_multi(&dsi_ctx, MIPI_DSI_DCS_TEAR_MODE_VBLANK);
+	mipi_dsi_dcs_set_column_address_multi(&dsi_ctx, 0, 1080 - 1);
+	mipi_dsi_dcs_set_page_address_multi(&dsi_ctx, 0, 2340 - 1);
 
 	dsi->mode_flags &= ~MIPI_DSI_MODE_LPM;
 
-	return 0;
+	return dsi_ctx.accum_err;
 }
 
-static int visionox_r66451_off(struct visionox_r66451 *ctx)
+static void visionox_r66451_off(struct visionox_r66451 *ctx)
 {
 	ctx->dsi->mode_flags &= ~MIPI_DSI_MODE_LPM;
-	return 0;
 }
 
 static int visionox_r66451_prepare(struct drm_panel *panel)
 {
 	struct visionox_r66451 *ctx = to_visionox_r66451(panel);
-	struct mipi_dsi_device *dsi = ctx->dsi;
-	struct device *dev = &dsi->dev;
 	int ret;
 
 	ret = regulator_bulk_enable(ARRAY_SIZE(ctx->supplies),
@@ -132,7 +131,6 @@ static int visionox_r66451_prepare(struct drm_panel *panel)
 
 	ret = visionox_r66451_on(ctx);
 	if (ret < 0) {
-		dev_err(dev, "Failed to initialize panel: %d\n", ret);
 		gpiod_set_value_cansleep(ctx->reset_gpio, 1);
 		regulator_bulk_disable(ARRAY_SIZE(ctx->supplies), ctx->supplies);
 		return ret;
@@ -146,12 +144,8 @@ static int visionox_r66451_prepare(struct drm_panel *panel)
 static int visionox_r66451_unprepare(struct drm_panel *panel)
 {
 	struct visionox_r66451 *ctx = to_visionox_r66451(panel);
-	struct device *dev = &ctx->dsi->dev;
-	int ret;
 
-	ret = visionox_r66451_off(ctx);
-	if (ret < 0)
-		dev_err(dev, "Failed to un-initialize panel: %d\n", ret);
+	visionox_r66451_off(ctx);
 
 	gpiod_set_value_cansleep(ctx->reset_gpio, 1);
 	regulator_bulk_disable(ARRAY_SIZE(ctx->supplies), ctx->supplies);
@@ -179,7 +173,7 @@ static int visionox_r66451_enable(struct drm_panel *panel)
 	struct visionox_r66451 *ctx = to_visionox_r66451(panel);
 	struct mipi_dsi_device *dsi = ctx->dsi;
 	struct drm_dsc_picture_parameter_set pps;
-	int ret;
+	struct mipi_dsi_multi_context dsi_ctx = { .dsi = dsi };
 
 	if (!dsi->dsc) {
 		dev_err(&dsi->dev, "DSC not attached to DSI\n");
@@ -187,25 +181,13 @@ static int visionox_r66451_enable(struct drm_panel *panel)
 	}
 
 	drm_dsc_pps_payload_pack(&pps, dsi->dsc);
-	ret = mipi_dsi_picture_parameter_set(dsi, &pps);
-	if (ret) {
-		dev_err(&dsi->dev, "Failed to set PPS\n");
-		return ret;
-	}
+	mipi_dsi_picture_parameter_set_multi(&dsi_ctx, &pps);
 
-	ret = mipi_dsi_dcs_exit_sleep_mode(dsi);
-	if (ret < 0) {
-		dev_err(&dsi->dev, "Failed to exit sleep mode: %d\n", ret);
-		return ret;
-	}
-	msleep(120);
+	mipi_dsi_dcs_exit_sleep_mode_multi(&dsi_ctx);
+	mipi_dsi_msleep(&dsi_ctx, 120);
 
-	ret = mipi_dsi_dcs_set_display_on(dsi);
-	if (ret < 0) {
-		dev_err(&dsi->dev, "Failed on set display on: %d\n", ret);
-		return ret;
-	}
-	msleep(20);
+	mipi_dsi_dcs_set_display_on_multi(&dsi_ctx);
+	mipi_dsi_msleep(&dsi_ctx, 20);
 
 	return 0;
 }
@@ -214,24 +196,15 @@ static int visionox_r66451_disable(struct drm_panel *panel)
 {
 	struct visionox_r66451 *ctx = to_visionox_r66451(panel);
 	struct mipi_dsi_device *dsi = ctx->dsi;
-	struct device *dev = &dsi->dev;
-	int ret;
+	struct mipi_dsi_multi_context dsi_ctx = { .dsi = dsi };
 
-	ret = mipi_dsi_dcs_set_display_off(dsi);
-	if (ret < 0) {
-		dev_err(dev, "Failed to set display off: %d\n", ret);
-		return ret;
-	}
-	msleep(20);
+	mipi_dsi_dcs_set_display_off_multi(&dsi_ctx);
+	mipi_dsi_msleep(&dsi_ctx, 20);
 
-	ret = mipi_dsi_dcs_enter_sleep_mode(dsi);
-	if (ret < 0) {
-		dev_err(dev, "Failed to enter sleep mode: %d\n", ret);
-		return ret;
-	}
-	msleep(120);
+	mipi_dsi_dcs_enter_sleep_mode_multi(&dsi_ctx);
+	mipi_dsi_msleep(&dsi_ctx, 120);
 
-	return 0;
+	return dsi_ctx.accum_err;
 }
 
 static int visionox_r66451_get_modes(struct drm_panel *panel,
Signature · 1 line
2.48.1
#1 lore raw
Quoted 28 lines · Tejas Vipin

Change the visionox-r66451 panel to use multi style functions for improved error handling.

---
 drivers/gpu/drm/panel/panel-visionox-r66451.c | 179 ++++++++----------
 1 file changed, 76 insertions(+), 103 deletions(-)
drivers/gpu/drm/panel/panel-visionox-r66451.c +3 -11
@@ -187,25 +181,13 @@ static int visionox_r66451_enable(struct drm_panel *panel)
 	}
 
 	drm_dsc_pps_payload_pack(&pps, dsi->dsc);
-	ret = mipi_dsi_picture_parameter_set(dsi, &pps);
-	if (ret) {
-		dev_err(&dsi->dev, "Failed to set PPS\n");
-		return ret;
-	}
+	mipi_dsi_picture_parameter_set_multi(&dsi_ctx, &pps);
 
-	ret = mipi_dsi_dcs_exit_sleep_mode(dsi);
-	if (ret < 0) {
-		dev_err(&dsi->dev, "Failed to exit sleep mode: %d\n", ret);
-		return ret;
-	}
-	msleep(120);
+	mipi_dsi_dcs_exit_sleep_mode_multi(&dsi_ctx);
+	mipi_dsi_msleep(&dsi_ctx, 120);
 

drivers/gpu/drm/panel/panel-visionox-r66451.c static int visionox_r66451_enable(struct drm_panel *panel) · line 192

Quoted 10 lines
drivers/gpu/drm/panel/panel-visionox-r66451.c +2 -6
-	ret = mipi_dsi_dcs_set_display_on(dsi);
-	if (ret < 0) {
-		dev_err(&dsi->dev, "Failed on set display on: %d\n", ret);
-		return ret;
-	}
-	msleep(20);
+	mipi_dsi_dcs_set_display_on_multi(&dsi_ctx);
+	mipi_dsi_msleep(&dsi_ctx, 20);
 
 	return 0;

return dsi_ctx.accum_err;

Quoted 1 line
(quoted diff) +0 -0
 }
Signature · 2 lines
With best wishes
Dmitry
#2 lore raw
In reply to Tejas Vipin

Hi,

Quoted 132 lines · Tejas Vipin

Change the visionox-r66451 panel to use multi style functions for improved error handling.

---
 drivers/gpu/drm/panel/panel-visionox-r66451.c | 179 ++++++++----------
 1 file changed, 76 insertions(+), 103 deletions(-)
drivers/gpu/drm/panel/panel-visionox-r66451.c +53 -59
index 493f2a6076f8..81d615e1937a 100644
@@ -42,85 +42,84 @@ static void visionox_r66451_reset(struct visionox_r66451 *ctx)
 static int visionox_r66451_on(struct visionox_r66451 *ctx)
 {
        struct mipi_dsi_device *dsi = ctx->dsi;
+       struct mipi_dsi_multi_context dsi_ctx = { .dsi = dsi };
 
        dsi->mode_flags |= MIPI_DSI_MODE_LPM;
 
-       mipi_dsi_dcs_write_seq(dsi, 0xb0, 0x00);
-       mipi_dsi_dcs_write_seq(dsi, 0xc2,
-                              0x09, 0x24, 0x0c, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
-                              0x09, 0x3c);
-       mipi_dsi_dcs_write_seq(dsi, 0xd7,
-                              0x00, 0xb9, 0x3c, 0x00, 0x40, 0x04, 0x00, 0xa0, 0x0a,
-                              0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x19,
-                              0x3c, 0x00, 0x40, 0x04, 0x00, 0xa0, 0x0a);
-       mipi_dsi_dcs_write_seq(dsi, 0xb0, 0x80);
-       mipi_dsi_dcs_write_seq(dsi, 0xde,
-                              0x40, 0x00, 0x18, 0x00, 0x18, 0x00, 0x18, 0x00, 0x18,
-                              0x10, 0x00, 0x18, 0x00, 0x18, 0x00, 0x18, 0x02, 0x00, 0x00);
-       mipi_dsi_dcs_write_seq(dsi, 0xb0, 0x04);
-       mipi_dsi_dcs_write_seq(dsi, 0xe8, 0x00, 0x02);
-       mipi_dsi_dcs_write_seq(dsi, 0xe4, 0x00, 0x08);
-       mipi_dsi_dcs_write_seq(dsi, 0xb0, 0x00);
-       mipi_dsi_dcs_write_seq(dsi, 0xc4,
-                              0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-                              0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x32);
-       mipi_dsi_dcs_write_seq(dsi, 0xcf,
-                              0x64, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08,
-                              0x00, 0x0b, 0x77, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
-                              0x02, 0x02, 0x02, 0x02, 0x02, 0x03);
-       mipi_dsi_dcs_write_seq(dsi, 0xd3,
-                              0x45, 0x00, 0x00, 0x01, 0x13, 0x15, 0x00, 0x15, 0x07,
-                              0x0f, 0x77, 0x77, 0x77, 0x37, 0xb2, 0x11, 0x00, 0xa0,
-                              0x3c, 0x9c);
-       mipi_dsi_dcs_write_seq(dsi, 0xd7,
-                              0x00, 0xb9, 0x34, 0x00, 0x40, 0x04, 0x00, 0xa0, 0x0a,
-                              0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x19,
-                              0x34, 0x00, 0x40, 0x04, 0x00, 0xa0, 0x0a);
-       mipi_dsi_dcs_write_seq(dsi, 0xd8,
-                              0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-                              0x3a, 0x00, 0x3a, 0x00, 0x3a, 0x00, 0x3a, 0x00, 0x3a,
-                              0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-                              0x00, 0x0a, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00,
-                              0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a,
-                              0x00, 0x32, 0x00, 0x0a, 0x00, 0x22);
-       mipi_dsi_dcs_write_seq(dsi, 0xdf,
-                              0x50, 0x42, 0x58, 0x81, 0x2d, 0x00, 0x00, 0x00, 0x00,
-                              0x00, 0x00, 0x6b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-                              0x00, 0x00, 0x01, 0x0f, 0xff, 0xd4, 0x0e, 0x00, 0x00,
-                              0x00, 0x00, 0x00, 0x00, 0x0f, 0x53, 0xf1, 0x00, 0x00,
-                              0x00, 0x00, 0x00, 0x00, 0x00, 0x00);
-       mipi_dsi_dcs_write_seq(dsi, 0xf7, 0x01);
-       mipi_dsi_dcs_write_seq(dsi, 0xb0, 0x80);
-       mipi_dsi_dcs_write_seq(dsi, 0xe4, 0x34, 0xb4, 0x00, 0x00, 0x00, 0x39, 0x04, 0x09, 0x34);
-       mipi_dsi_dcs_write_seq(dsi, 0xe6, 0x00);
-       mipi_dsi_dcs_write_seq(dsi, 0xb0, 0x04);
-       mipi_dsi_dcs_write_seq(dsi, 0xdf, 0x50, 0x40);
-       mipi_dsi_dcs_write_seq(dsi, 0xf3, 0x50, 0x00, 0x00, 0x00, 0x00);
-       mipi_dsi_dcs_write_seq(dsi, 0xf2, 0x11);
-       mipi_dsi_dcs_write_seq(dsi, 0xf3, 0x01, 0x00, 0x00, 0x00, 0x01);
-       mipi_dsi_dcs_write_seq(dsi, 0xf4, 0x00, 0x02);
-       mipi_dsi_dcs_write_seq(dsi, 0xf2, 0x19);
-       mipi_dsi_dcs_write_seq(dsi, 0xdf, 0x50, 0x42);
-       mipi_dsi_dcs_set_tear_on(dsi, MIPI_DSI_DCS_TEAR_MODE_VBLANK);
-       mipi_dsi_dcs_set_column_address(dsi, 0, 1080 - 1);
-       mipi_dsi_dcs_set_page_address(dsi, 0, 2340 - 1);
+       mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xb0, 0x00);
+       mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xc2,
+                                    0x09, 0x24, 0x0c, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
+                                    0x09, 0x3c);
+       mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xd7,
+                                    0x00, 0xb9, 0x3c, 0x00, 0x40, 0x04, 0x00, 0xa0, 0x0a,
+                                    0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x19,
+                                    0x3c, 0x00, 0x40, 0x04, 0x00, 0xa0, 0x0a);
+       mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xb0, 0x80);
+       mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xde,
+                                    0x40, 0x00, 0x18, 0x00, 0x18, 0x00, 0x18, 0x00, 0x18,
+                                    0x10, 0x00, 0x18, 0x00, 0x18, 0x00, 0x18, 0x02, 0x00, 0x00);
+       mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xb0, 0x04);
+       mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xe8, 0x00, 0x02);
+       mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xe4, 0x00, 0x08);
+       mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xb0, 0x00);
+       mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xc4,
+                                    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                                    0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x32);
+       mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xcf,
+                                    0x64, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08,
+                                    0x00, 0x0b, 0x77, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+                                    0x02, 0x02, 0x02, 0x02, 0x02, 0x03);
+       mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xd3,
+                                    0x45, 0x00, 0x00, 0x01, 0x13, 0x15, 0x00, 0x15, 0x07,
+                                    0x0f, 0x77, 0x77, 0x77, 0x37, 0xb2, 0x11, 0x00, 0xa0,
+                                    0x3c, 0x9c);
+       mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xd7,
+                                    0x00, 0xb9, 0x34, 0x00, 0x40, 0x04, 0x00, 0xa0, 0x0a,
+                                    0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x19,
+                                    0x34, 0x00, 0x40, 0x04, 0x00, 0xa0, 0x0a);
+       mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xd8,
+                                    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                                    0x3a, 0x00, 0x3a, 0x00, 0x3a, 0x00, 0x3a, 0x00, 0x3a,
+                                    0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                                    0x00, 0x0a, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00,
+                                    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a,
+                                    0x00, 0x32, 0x00, 0x0a, 0x00, 0x22);
+       mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xdf,
+                                    0x50, 0x42, 0x58, 0x81, 0x2d, 0x00, 0x00, 0x00, 0x00,
+                                    0x00, 0x00, 0x6b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+                                    0x00, 0x00, 0x01, 0x0f, 0xff, 0xd4, 0x0e, 0x00, 0x00,
+                                    0x00, 0x00, 0x00, 0x00, 0x0f, 0x53, 0xf1, 0x00, 0x00,
+                                    0x00, 0x00, 0x00, 0x00, 0x00, 0x00);
+       mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xf7, 0x01);
+       mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xb0, 0x80);
+       mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xe4, 0x34, 0xb4, 0x00, 0x00, 0x00, 0x39,
+                                    0x04, 0x09, 0x34);
+       mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xe6, 0x00);
+       mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xb0, 0x04);
+       mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xdf, 0x50, 0x40);
+       mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xf3, 0x50, 0x00, 0x00, 0x00, 0x00);

drivers/gpu/drm/panel/panel-visionox-r66451.c static void visionox_r66451_reset(struct visionox_r66451 *ctx) · line 110

Quoted 10 lines
drivers/gpu/drm/panel/panel-visionox-r66451.c +8 -0
+       mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xf2, 0x11);
+       mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xf3, 0x01, 0x00, 0x00, 0x00, 0x01);
+       mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xf4, 0x00, 0x02);
+       mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xf2, 0x19);
+       mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xdf, 0x50, 0x42);
+       mipi_dsi_dcs_set_tear_on_multi(&dsi_ctx, MIPI_DSI_DCS_TEAR_MODE_VBLANK);
+       mipi_dsi_dcs_set_column_address_multi(&dsi_ctx, 0, 1080 - 1);
+       mipi_dsi_dcs_set_page_address_multi(&dsi_ctx, 0, 2340 - 1);
 
        dsi->mode_flags &= ~MIPI_DSI_MODE_LPM;

I think that to match the old behavior the most correctly, you'd only want to clear MIPI_DSI_MODE_LPM if there were no errors, right? All of the old mipi_dsi_dcs_write_seq() calls would have returned early in the case of an error because of that non-obvious control flow.

I'm not a total expert on MIPI_DSI_MODE_LPM, but I suspect your new behavior is actually more correct, but it might not hurt to at least point out this change in behavior in the commit message.

Quoted 20 lines
drivers/gpu/drm/panel/panel-visionox-r66451.c +3 -11
@@ -187,25 +181,13 @@ static int visionox_r66451_enable(struct drm_panel *panel)
        }
 
        drm_dsc_pps_payload_pack(&pps, dsi->dsc);
-       ret = mipi_dsi_picture_parameter_set(dsi, &pps);
-       if (ret) {
-               dev_err(&dsi->dev, "Failed to set PPS\n");
-               return ret;
-       }
+       mipi_dsi_picture_parameter_set_multi(&dsi_ctx, &pps);
 
-       ret = mipi_dsi_dcs_exit_sleep_mode(dsi);
-       if (ret < 0) {
-               dev_err(&dsi->dev, "Failed to exit sleep mode: %d\n", ret);
-               return ret;
-       }
-       msleep(120);
+       mipi_dsi_dcs_exit_sleep_mode_multi(&dsi_ctx);
+       mipi_dsi_msleep(&dsi_ctx, 120);
 

drivers/gpu/drm/panel/panel-visionox-r66451.c static int visionox_r66451_enable(struct drm_panel *panel) · line 192

Quoted 10 lines
drivers/gpu/drm/panel/panel-visionox-r66451.c +2 -6
-       ret = mipi_dsi_dcs_set_display_on(dsi);
-       if (ret < 0) {
-               dev_err(&dsi->dev, "Failed on set display on: %d\n", ret);
-               return ret;
-       }
-       msleep(20);
+       mipi_dsi_dcs_set_display_on_multi(&dsi_ctx);
+       mipi_dsi_msleep(&dsi_ctx, 20);
 
        return 0;

As Dmitry said, return dsi_ctx.accum_err

-Doug

#3 lore raw
Quoted 28 lines · Doug Anderson

Hi,

Quoted 25 lines · Tejas Vipin

Change the visionox-r66451 panel to use multi style functions for improved error handling.

---
 drivers/gpu/drm/panel/panel-visionox-r66451.c | 179 ++++++++----------
 1 file changed, 76 insertions(+), 103 deletions(-)
drivers/gpu/drm/panel/panel-visionox-r66451.c +1 -4
index 493f2a6076f8..81d615e1937a 100644
@@ -42,85 +42,84 @@ static void visionox_r66451_reset(struct visionox_r66451 *ctx)
 static int visionox_r66451_on(struct visionox_r66451 *ctx)
 {
        struct mipi_dsi_device *dsi = ctx->dsi;
+       struct mipi_dsi_multi_context dsi_ctx = { .dsi = dsi };
 
        dsi->mode_flags |= MIPI_DSI_MODE_LPM;
 
-       mipi_dsi_dcs_write_seq(dsi, 0xb0, 0x00);
-       mipi_dsi_dcs_write_seq(dsi, 0xc2,
-                              0x09, 0x24, 0x0c, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
-                              0x09, 0x3c);

[...]

Quoted 8 lines

drivers/gpu/drm/panel/panel-visionox-r66451.c static void visionox_r66451_reset(struct visionox_r66451 *ctx) · line 110

Quoted 7 lines
drivers/gpu/drm/panel/panel-visionox-r66451.c +5 -0
+       mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xf2, 0x19);
+       mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xdf, 0x50, 0x42);
+       mipi_dsi_dcs_set_tear_on_multi(&dsi_ctx, MIPI_DSI_DCS_TEAR_MODE_VBLANK);
+       mipi_dsi_dcs_set_column_address_multi(&dsi_ctx, 0, 1080 - 1);
+       mipi_dsi_dcs_set_page_address_multi(&dsi_ctx, 0, 2340 - 1);
 
        dsi->mode_flags &= ~MIPI_DSI_MODE_LPM;
Quoted 8 lines

I think that to match the old behavior the most correctly, you'd only want to clear MIPI_DSI_MODE_LPM if there were no errors, right? All of the old mipi_dsi_dcs_write_seq() calls would have returned early in the case of an error because of that non-obvious control flow.

I'm not a total expert on MIPI_DSI_MODE_LPM, but I suspect your new behavior is actually more correct, but it might not hurt to at least point out this change in behavior in the commit message.

Yes, I think new behaviour is more correct. We should drop LPM flag after sending init sequence.

Signature · 2 lines
With best wishes
Dmitry