Skip to content

Commit

Permalink
panel: sw43408: split command sequence
Browse files Browse the repository at this point in the history
This allows sending DCS_COMPRESSION_MODE which got missed earlier.

Also clean up some of the delays etc.

Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org>
  • Loading branch information
sumitsemwal committed Jul 31, 2019
1 parent 1f37b09 commit 2086a4f
Showing 1 changed file with 62 additions and 11 deletions.
73 changes: 62 additions & 11 deletions drivers/gpu/drm/panel/panel-lg-sw43408.c
Expand Up @@ -66,7 +66,8 @@ struct panel_desc {
enum mipi_dsi_pixel_format format;
unsigned int lanes;

const struct panel_cmd *on_cmds;
const struct panel_cmd *on_cmds_1;
const struct panel_cmd *on_cmds_2;
};

struct panel_info {
Expand All @@ -78,6 +79,8 @@ struct panel_info {
u32 brightness;
u32 max_brightness;

u32 init_delay_us;

struct regulator_bulk_data supplies[ARRAY_SIZE(regulator_names)];

struct gpio_desc *reset_gpio;
Expand Down Expand Up @@ -193,7 +196,7 @@ static int lg_panel_unprepare(struct drm_panel *panel)
if (!pinfo->prepared)
return 0;

ret = mipi_dsi_dcs_write(pinfo->link, MIPI_DCS_SET_DISPLAY_OFF, NULL, 0);
ret = mipi_dsi_dcs_set_display_off(pinfo->link);
if (ret < 0) {
DRM_DEV_ERROR(panel->dev,
"set_display_off cmd failed ret = %d\n",
Expand All @@ -203,11 +206,13 @@ static int lg_panel_unprepare(struct drm_panel *panel)
/* 120ms delay required here as per DCS spec */
msleep(120);

ret = mipi_dsi_dcs_write(pinfo->link, MIPI_DCS_ENTER_SLEEP_MODE, NULL, 0);
ret = mipi_dsi_dcs_enter_sleep_mode(pinfo->link);
if (ret < 0) {
DRM_DEV_ERROR(panel->dev,
"enter_sleep cmd failed ret = %d\n", ret);
}
/* 0x64 = 100ms delay */
msleep(100);

ret = lg_panel_power_off(panel);
if (ret < 0)
Expand Down Expand Up @@ -263,18 +268,58 @@ static int lg_panel_prepare(struct drm_panel *panel)
if (pinfo->prepared)
return 0;

usleep_range(pinfo->init_delay_us, pinfo->init_delay_us);

err = lg_panel_power_on(pinfo);
if (err < 0)
goto poweroff;

/* send init code */
err = send_mipi_cmds(panel, pinfo->desc->on_cmds);
/* send first part of init cmds */
err = send_mipi_cmds(panel, pinfo->desc->on_cmds_1);

if (err < 0) {
DRM_DEV_ERROR(panel->dev,
"failed to send DCS Init 1st Code: %d\n", err);
goto poweroff;
}

err = mipi_dsi_dcs_exit_sleep_mode(pinfo->link);
if (err < 0) {
DRM_DEV_ERROR(panel->dev, "failed to exit sleep mode: %d\n",
err);
goto poweroff;
}
/* 0x87 = 135 ms delay */
msleep(135);

/* Set DCS_COMPRESSION_MODE */
err = mipi_dsi_dcs_write(pinfo->link, MIPI_DSI_DCS_COMPRESSION_MODE, (u8[]){ 0x11 }, 1);
if (err < 0) {
DRM_DEV_ERROR(panel->dev,
"failed to set compression mode: %d\n", err);
goto poweroff;
}


/* Send rest of the init cmds */
err = send_mipi_cmds(panel, pinfo->desc->on_cmds_2);

if (err < 0) {
DRM_DEV_ERROR(panel->dev,
"failed to send DCS Init 2nd Code: %d\n", err);
goto poweroff;
}

err = mipi_dsi_dcs_set_display_on(pinfo->link);
if (err < 0) {
DRM_DEV_ERROR(panel->dev,
"failed to send DCS Init Code: %d\n", err);
"failed to Set Display ON: %d\n", err);
goto poweroff;
}

/* 0x32 = 50ms delay */
msleep(120);

pinfo->prepared = true;

return 0;
Expand Down Expand Up @@ -397,14 +442,17 @@ static const struct drm_panel_funcs panel_funcs = {
.get_modes = lg_panel_get_modes,
};

static const struct panel_cmd lg_sw43408_on_cmds[] = {
static const struct panel_cmd lg_sw43408_on_cmds_1[] = {
_INIT_CMD(0x00, 0x26, 0x02), // MIPI_DCS_SET_GAMMA_CURVE, 0x02
_INIT_CMD(0x00, 0x35, 0x00), // MIPI_DCS_SET_TEAR_ON
_INIT_CMD(0x00, 0x53, 0x0C, 0x30),
_INIT_CMD(0x00, 0x55, 0x00, 0x70, 0xDF, 0x00, 0x70, 0xDF),
_INIT_CMD(0x00, 0xF7, 0x01, 0x49, 0x0C),
_INIT_CMD(0x00, 0x11), // MIPI_DCS_EXIT_SLEEP_MODE
_INIT_CMD(0x00, 0x11), // repetition, but what does a 07 DTYPE mean?

{},
};

static const struct panel_cmd lg_sw43408_on_cmds_2[] = {
_INIT_CMD(0x00, 0xB0, 0xAC),
_INIT_CMD(0x00, 0xCD,
0x00, 0x00, 0x00, 0x19, 0x19, 0x19, 0x19, 0x19,
Expand All @@ -422,7 +470,6 @@ static const struct panel_cmd lg_sw43408_on_cmds[] = {
0x01),
_INIT_CMD(0x00, 0x55, 0x04, 0x61, 0xDB, 0x04, 0x70, 0xDB),
_INIT_CMD(0x00, 0xB0, 0xCA),
_INIT_CMD(0x00, 0x29),

{},
};
Expand Down Expand Up @@ -453,7 +500,8 @@ static const struct panel_desc lg_panel_desc = {
.mode_flags = MIPI_DSI_MODE_LPM,
.format = MIPI_DSI_FMT_RGB888,
.lanes = 4,
.on_cmds = lg_sw43408_on_cmds,
.on_cmds_1 = lg_sw43408_on_cmds_1,
.on_cmds_2 = lg_sw43408_on_cmds_2,
};


Expand Down Expand Up @@ -506,6 +554,9 @@ static int panel_add(struct panel_info *pinfo)
struct device *dev = &pinfo->link->dev;
int i, ret;
pr_err("In sw43408 panel add\n");

pinfo->init_delay_us = 5000;

for (i = 0; i < ARRAY_SIZE(pinfo->supplies); i++)
pinfo->supplies[i].supply = regulator_names[i];

Expand Down

0 comments on commit 2086a4f

Please sign in to comment.