The Miyoo A30 handheld (Allwinner A33) has a 480x640 2-lane MIPI-DSI
panel driven by a Sitronix ST7701S.

Its init table, taken from the stock kernel, doesn't fit the encoding of
st7701_init_sequence(): byte 0 of C2 (INVSEL) lacks the 0x30 bits and
RTNI is not derived from htotal. Send it as-is through the new
init_sequence hook.

The stock configuration runs the panel in non-burst video mode with
sync pulses and without EoT packets; in burst mode the picture is
unstable and the colours are wrong.

Timings and size are from the stock configuration: 23 MHz pixel clock,
htotal 560, vtotal 684, 43x57 mm.

Signed-off-by: Romain TISSERAND <[email protected]>
---
 drivers/gpu/drm/panel/panel-sitronix-st7701.c | 88 +++++++++++++++++++
 1 file changed, 88 insertions(+)

diff --git a/drivers/gpu/drm/panel/panel-sitronix-st7701.c 
b/drivers/gpu/drm/panel/panel-sitronix-st7701.c
index f288c8c8aab8..a87da36dc60a 100644
--- a/drivers/gpu/drm/panel/panel-sitronix-st7701.c
+++ b/drivers/gpu/drm/panel/panel-sitronix-st7701.c
@@ -421,6 +421,64 @@ static void dmt028vghmcmi_1a_gip_sequence(struct st7701 
*st7701)
        ST7701_WRITE(st7701, 0x3A, 0x70);
 }
 
+static void miyoo_a30_init_sequence(struct st7701 *st7701)
+{
+       /* Vendor table, from the Miyoo A30 stock kernel (default_panel). */
+       msleep(200);
+
+       st7701_switch_cmd_bkx(st7701, true, 3);
+       ST7701_WRITE(st7701, 0xEF, 0x08);
+
+       st7701_switch_cmd_bkx(st7701, true, 0);
+       ST7701_WRITE(st7701, ST7701_CMD2_BK0_LNESET, 0x4F, 0x00);
+       ST7701_WRITE(st7701, ST7701_CMD2_BK0_PORCTRL, 0x10, 0x0C);
+       ST7701_WRITE(st7701, ST7701_CMD2_BK0_INVSEL, 0x01, 0x14);
+       ST7701_WRITE(st7701, 0xCC, 0x10);
+       ST7701_WRITE(st7701, ST7701_CMD2_BK0_PVGAMCTRL,
+                  0x0A, 0x18, 0x1E, 0x12, 0x16, 0x0C, 0x0E, 0x0D,
+                  0x0C, 0x29, 0x06, 0x14, 0x13, 0x29, 0x33, 0x1C);
+       ST7701_WRITE(st7701, ST7701_CMD2_BK0_NVGAMCTRL,
+                  0x0A, 0x19, 0x21, 0x0A, 0x0C, 0x00, 0x0C, 0x03,
+                  0x03, 0x23, 0x01, 0x0E, 0x0C, 0x27, 0x2B, 0x1C);
+
+       st7701_switch_cmd_bkx(st7701, true, 1);
+       ST7701_WRITE(st7701, ST7701_CMD2_BK1_VRHS, 0x5D);
+       ST7701_WRITE(st7701, ST7701_CMD2_BK1_VCOM, 0x71);
+       ST7701_WRITE(st7701, ST7701_CMD2_BK1_VGHSS, 0x8A);
+       ST7701_WRITE(st7701, ST7701_CMD2_BK1_TESTCMD, 0x80);
+       ST7701_WRITE(st7701, ST7701_CMD2_BK1_VGLS, 0x4D);
+       ST7701_WRITE(st7701, ST7701_CMD2_BK1_PWCTLR1, 0x85);
+       ST7701_WRITE(st7701, ST7701_CMD2_BK1_PWCTLR2, 0x20);
+       ST7701_WRITE(st7701, ST7701_CMD2_BK1_SPD1, 0x78);
+       ST7701_WRITE(st7701, ST7701_CMD2_BK1_SPD2, 0x78);
+       ST7701_WRITE(st7701, ST7701_CMD2_BK1_MIPISET1, 0x88);
+
+       ST7701_WRITE(st7701, 0xE0, 0x00, 0x00, 0x02);
+       ST7701_WRITE(st7701, 0xE1, 0x06, 0xA0, 0x08, 0xA0, 0x05, 0xA0, 0x07,
+                  0xA0, 0x00, 0x44, 0x44);
+       ST7701_WRITE(st7701, 0xE2, 0x20, 0x20, 0x44, 0x44, 0x96, 0xA0, 0x00,
+                  0x00, 0x96, 0xA0, 0x00, 0x00);
+       ST7701_WRITE(st7701, 0xE3, 0x00, 0x00, 0x22, 0x22);
+       ST7701_WRITE(st7701, 0xE4, 0x44, 0x44);
+       ST7701_WRITE(st7701, 0xE5, 0x0D, 0x91, 0x0A, 0xA0, 0x0F, 0x93, 0x0A,
+                  0xA0, 0x09, 0x8D, 0x0A, 0xA0, 0x0B, 0x8F, 0x0A, 0xA0);
+       ST7701_WRITE(st7701, 0xE6, 0x00, 0x00, 0x22, 0x22);
+       ST7701_WRITE(st7701, 0xE7, 0x44, 0x44);
+       ST7701_WRITE(st7701, 0xE8, 0x0C, 0x90, 0x0A, 0xA0, 0x0E, 0x92, 0x0A,
+                  0xA0, 0x08, 0x8C, 0x0A, 0xA0, 0x0A, 0x8E, 0x0A, 0xA0);
+       ST7701_WRITE(st7701, 0xE9, 0x36, 0x00);
+       ST7701_WRITE(st7701, 0xEB, 0x00, 0x01, 0xE4, 0xE4, 0x44, 0x88, 0x40);
+       ST7701_WRITE(st7701, 0xED, 0xFF, 0x45, 0x67, 0xFA, 0x01, 0x2B, 0xCF,
+                  0xFF, 0xFF, 0xFC, 0xB2, 0x10, 0xAF, 0x76, 0x54, 0xFF);
+       ST7701_WRITE(st7701, 0xEF, 0x10, 0x0D, 0x04, 0x08, 0x3F, 0x1F);
+
+       ST7701_WRITE(st7701, MIPI_DCS_EXIT_SLEEP_MODE);
+       msleep(200);
+
+       ST7701_WRITE(st7701, MIPI_DCS_SET_TEAR_ON, 0x00);
+       ST7701_WRITE(st7701, MIPI_DCS_SET_PIXEL_FORMAT, 0x77);
+}
+
 static void kd50t048a_gip_sequence(struct st7701 *st7701)
 {
        /**
@@ -874,6 +932,35 @@ static const struct st7701_panel_desc 
dmt028vghmcmi_1a_desc = {
        .gip_sequence = dmt028vghmcmi_1a_gip_sequence,
 };
 
+static const struct drm_display_mode miyoo_a30_mode = {
+       .clock          = 23000,
+
+       .hdisplay       = 480,
+       .hsync_start    = 480 + 48,
+       .hsync_end      = 480 + 48 + 10,
+       .htotal         = 480 + 48 + 10 + 22,
+
+       .vdisplay       = 640,
+       .vsync_start    = 640 + 26,
+       .vsync_end      = 640 + 26 + 4,
+       .vtotal         = 640 + 26 + 4 + 14,
+
+       .width_mm       = 43,
+       .height_mm      = 57,
+
+       .type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED,
+};
+
+static const struct st7701_panel_desc miyoo_a30_desc = {
+       .mode = &miyoo_a30_mode,
+       .lanes = 2,
+       .format = MIPI_DSI_FMT_RGB888,
+       .init_sequence = miyoo_a30_init_sequence,
+       /* stock sys_config: lcd_dsi_if = 0 (non-burst video), lcd_dsi_eotp = 0 
*/
+       .mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_SYNC_PULSE |
+                     MIPI_DSI_MODE_LPM | MIPI_DSI_MODE_NO_EOT_PACKET,
+};
+
 static const struct drm_display_mode kd50t048a_mode = {
        .clock          = 27500,
 
@@ -1401,6 +1488,7 @@ static const struct of_device_id st7701_dsi_of_match[] = {
        { .compatible = "anbernic,rg-arc-panel", .data = &rg_arc_desc },
        { .compatible = "densitron,dmt028vghmcmi-1a", .data = 
&dmt028vghmcmi_1a_desc },
        { .compatible = "elida,kd50t048a", .data = &kd50t048a_desc },
+       { .compatible = "miyoo,a30-panel", .data = &miyoo_a30_desc },
        { .compatible = "techstar,ts8550b", .data = &ts8550b_desc },
        { .compatible = "winstar,wf40eswaa6mnn0", .data = &wf40eswaa6mnn0_desc 
},
        { }
-- 
2.43.0

Reply via email to