On 5/9/2025 1:59 AM, Neil Armstrong wrote:
In order to support a panel variant, add plumbing code to pass
init sequence and mode as compatible data.

Signed-off-by: Neil Armstrong <neil.armstr...@linaro.org>

Reviewed-by: Jessica Zhang <quic_jessz...@quicinc.com>

---
  drivers/gpu/drm/panel/panel-visionox-rm69299.c | 58 ++++++++++++++------------
  1 file changed, 32 insertions(+), 26 deletions(-)

diff --git a/drivers/gpu/drm/panel/panel-visionox-rm69299.c 
b/drivers/gpu/drm/panel/panel-visionox-rm69299.c
index 
be3a9797fbced5222b313cf83f8078b919e2c219..156bca0197481b470fa85b2eab7c979b76e489b6
 100644
--- a/drivers/gpu/drm/panel/panel-visionox-rm69299.c
+++ b/drivers/gpu/drm/panel/panel-visionox-rm69299.c
@@ -5,6 +5,7 @@
#include <linux/delay.h>
  #include <linux/module.h>
+#include <linux/property.h>
  #include <linux/mod_devicetable.h>
  #include <linux/gpio/consumer.h>
  #include <linux/regulator/consumer.h>
@@ -15,11 +16,22 @@
  #include <drm/drm_modes.h>
  #include <drm/drm_panel.h>
+struct visionox_rm69299_panel_desc {
+       const struct drm_display_mode *mode;
+       const u8 *init_seq;
+       unsigned int init_seq_len;
+};
+
  struct visionox_rm69299 {
        struct drm_panel panel;
        struct regulator_bulk_data supplies[2];
        struct gpio_desc *reset_gpio;
        struct mipi_dsi_device *dsi;
+       const struct visionox_rm69299_panel_desc *desc;
+};
+
+static const u8 visionox_rm69299_1080x2248_60hz_init_seq[][2] = {
+       { 0xfe, 0x00 }, { 0xc2, 0x08 }, { 0x35, 0x00 }, { 0x51, 0xff },
  };
static inline struct visionox_rm69299 *panel_to_ctx(struct drm_panel *panel)
@@ -84,7 +96,7 @@ static int visionox_rm69299_unprepare(struct drm_panel *panel)
  static int visionox_rm69299_prepare(struct drm_panel *panel)
  {
        struct visionox_rm69299 *ctx = panel_to_ctx(panel);
-       int ret;
+       int ret, i;
ret = visionox_rm69299_power_on(ctx);
        if (ret < 0)
@@ -92,28 +104,12 @@ static int visionox_rm69299_prepare(struct drm_panel 
*panel)
ctx->dsi->mode_flags |= MIPI_DSI_MODE_LPM; - ret = mipi_dsi_dcs_write_buffer(ctx->dsi, (u8[]) { 0xfe, 0x00 }, 2);
-       if (ret < 0) {
-               dev_err(ctx->panel.dev, "cmd set tx 0 failed, ret = %d\n", ret);
-               goto power_off;
-       }
-
-       ret = mipi_dsi_dcs_write_buffer(ctx->dsi, (u8[]) { 0xc2, 0x08 }, 2);
-       if (ret < 0) {
-               dev_err(ctx->panel.dev, "cmd set tx 1 failed, ret = %d\n", ret);
-               goto power_off;
-       }
-
-       ret = mipi_dsi_dcs_write_buffer(ctx->dsi, (u8[]) { 0x35, 0x00 }, 2);
-       if (ret < 0) {
-               dev_err(ctx->panel.dev, "cmd set tx 2 failed, ret = %d\n", ret);
-               goto power_off;
-       }
-
-       ret = mipi_dsi_dcs_write_buffer(ctx->dsi, (u8[]) { 0x51, 0xff }, 2);
-       if (ret < 0) {
-               dev_err(ctx->panel.dev, "cmd set tx 3 failed, ret = %d\n", ret);
-               goto power_off;
+       for (i = 0; i < ctx->desc->init_seq_len; i++) {
+               ret = mipi_dsi_dcs_write_buffer(ctx->dsi, 
&ctx->desc->init_seq[i * 2], 2);
+               if (ret < 0) {
+                       dev_err(ctx->panel.dev,      "cmd tx failed, ret = 
%d\n", ret);
+                       return ret;
+               }
        }
ret = mipi_dsi_dcs_write(ctx->dsi, MIPI_DCS_EXIT_SLEEP_MODE, NULL, 0);
@@ -160,8 +156,7 @@ static int visionox_rm69299_get_modes(struct drm_panel 
*panel,
        struct visionox_rm69299 *ctx = panel_to_ctx(panel);
        struct drm_display_mode *mode;
- mode = drm_mode_duplicate(connector->dev,
-                                 &visionox_rm69299_1080x2248_60hz);
+       mode = drm_mode_duplicate(connector->dev, ctx->desc->mode);
        if (!mode) {
                dev_err(ctx->panel.dev, "failed to create a new display 
mode\n");
                return 0;
@@ -191,6 +186,10 @@ static int visionox_rm69299_probe(struct mipi_dsi_device 
*dsi)
        if (!ctx)
                return -ENOMEM;
+ ctx->desc = device_get_match_data(dev);
+       if (!ctx->desc)
+               return -EINVAL;
+
        mipi_dsi_set_drvdata(dsi, ctx);
ctx->dsi = dsi;
@@ -239,8 +238,15 @@ static void visionox_rm69299_remove(struct mipi_dsi_device 
*dsi)
        drm_panel_remove(&ctx->panel);
  }
+const struct visionox_rm69299_panel_desc visionox_rm69299_1080p_display_desc = {
+       .mode = &visionox_rm69299_1080x2248_60hz,
+       .init_seq = (const u8 *)visionox_rm69299_1080x2248_60hz_init_seq,
+       .init_seq_len = ARRAY_SIZE(visionox_rm69299_1080x2248_60hz_init_seq),
+};
+
  static const struct of_device_id visionox_rm69299_of_match[] = {
-       { .compatible = "visionox,rm69299-1080p-display", },
+       { .compatible = "visionox,rm69299-1080p-display",
+         .data = &visionox_rm69299_1080p_display_desc },
        { /* sentinel */ }
  };
  MODULE_DEVICE_TABLE(of, visionox_rm69299_of_match);


Reply via email to