drm/panel/s6e3ha2: add panel id read code
authorAndrzej Hajda <a.hajda@samsung.com>
Fri, 19 Aug 2016 11:46:57 +0000 (13:46 +0200)
committerSeung-Woo Kim <sw0312.kim@samsung.com>
Wed, 14 Dec 2016 04:52:36 +0000 (13:52 +0900)
The patch adds helper to DCS read commands and reporting Display ID.

Change-Id: I9924bfd1ef18130fd36b6120cec0cd6c9dcfc279
Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
drivers/gpu/drm/panel/panel-s6e3ha2.c

index 771f342..934a1f0 100644 (file)
@@ -352,6 +352,29 @@ static void s6e3ha2_write_nseq(struct s6e3ha2 *ctx, const u8 *nseq)
        }
 }
 
+static void s6e3ha2_dcs_read(struct s6e3ha2 *ctx, u8 cmd, void *buf, size_t len)
+{
+       struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev);
+       int ret;
+
+       if (ctx->error < 0)
+               return;
+
+       ret = mipi_dsi_set_maximum_return_packet_size(dsi, len);
+       if (ret < 0) {
+               dev_err(ctx->dev, "error setting maximum return packet size to %lu\n",
+                       len);
+               ctx->error = ret;
+               return;
+       }
+
+       ret = mipi_dsi_dcs_read(dsi, cmd, buf, len);
+       if (ret < 0) {
+               dev_err(ctx->dev, "error %d reading dcs seq(%#x)\n", ret, cmd);
+               ctx->error = ret;
+       }
+}
+
 static void s6e3ha2_test_key_on_f0(struct s6e3ha2 *ctx)
 {
        s6e3ha2_dcs_write_seq_static(ctx, 0xf0, 0x5a, 0x5a);
@@ -755,6 +778,7 @@ static void s6e3ha2_hmt_set(struct s6e3ha2 *ctx, bool enable);
 static int s6e3ha2_enable(struct drm_panel *panel)
 {
        struct s6e3ha2 *ctx = panel_to_s6e3ha2(panel);
+       u8 id[3];
 
        /*
         * This function is called by mipi dsi driver
@@ -768,6 +792,10 @@ static int s6e3ha2_enable(struct drm_panel *panel)
 
        msleep(120);
 
+       s6e3ha2_dcs_read(ctx, MIPI_DCS_GET_DISPLAY_ID, id, ARRAY_SIZE(id));
+       if (ctx->error >= 0)
+               dev_info(ctx->dev, "Id: %*ph\n", (int)ARRAY_SIZE(id), id);
+
        /* common setting */
        s6e3ha2_dcs_write_seq_static(ctx, MIPI_DCS_SET_TEAR_ON, MIPI_DSI_DCS_TEAR_MODE_VBLANK);