Skip to content

Commit

Permalink
fixup! drm/panel: Add driver for Samsung AMS497EE01 panel
Browse files Browse the repository at this point in the history
  • Loading branch information
Grimler91 committed Jul 13, 2021
1 parent 049b7de commit d4c06ab
Showing 1 changed file with 55 additions and 26 deletions.
81 changes: 55 additions & 26 deletions drivers/gpu/drm/panel/panel-samsung-ea8061v-ams497ee01.c
Original file line number Diff line number Diff line change
Expand Up @@ -404,10 +404,11 @@ static int ea8061v_ams497ee01_update_aid(struct ea8061v_ams497ee01 *ctx,
unsigned int brightness)
{
int ret;
u8 aid_cmd[5] = { 0xb2, };
int index = map_candela_to_aid[brightness];
u8 aid_cmd[EA8061V_AMS497EE01_AID_CMD_CNT + 1] = { 0xb2, };

memcpy(aid_cmd + 1, seq_ea8061v_ams497ee01_aid +
map_candela_to_aid[brightness], 4);
memcpy(&aid_cmd[1], seq_ea8061v_ams497ee01_aid[index],
EA8061V_AMS497EE01_AID_CMD_CNT);

ret = mipi_dsi_dcs_write_buffer(ctx->dsi, aid_cmd,
ARRAY_SIZE(aid_cmd));
Expand All @@ -420,11 +421,10 @@ static int ea8061v_ams497ee01_update_elvss(struct ea8061v_ams497ee01 *ctx,
unsigned int brightness)
{
int ret;
/* 0x5c for acl off, 0x4c for acl on */
u8 elvss_cmd[3] = { 0xb6, 0x5c };
int index = map_candela_to_elvss[brightness];

memcpy(elvss_cmd + 2, ea8061v_ams497ee01_elvss_tbl +
map_candela_to_elvss[brightness], 1);
/* 0x5c for acl off, 0x4c for acl on */
u8 elvss_cmd[3] = { 0xb6, 0x5c, ea8061v_ams497ee01_elvss_tbl[index] };

ret = mipi_dsi_dcs_write_buffer(ctx->dsi, elvss_cmd,
ARRAY_SIZE(elvss_cmd));
Expand All @@ -436,14 +436,15 @@ static int ea8061v_ams497ee01_update_elvss(struct ea8061v_ams497ee01 *ctx,
static int ea8061v_ams497ee01_update_gamma(struct ea8061v_ams497ee01 *ctx,
unsigned int brightness)
{
struct backlight_device *bl_dev = ctx->bl_dev;
u8 data[EA8061V_AMS497EE01_GAMMA_CMD_CNT + 1] = { 0xca, };
int ret;
struct backlight_device *bl_dev = ctx->bl_dev;
u8 gamma_cmd[EA8061V_AMS497EE01_GAMMA_CMD_CNT + 1] = { 0xca, };

memcpy(data + 1, seq_ea8061v_ams497ee01_lux + brightness,
memcpy(&gamma_cmd[1], seq_ea8061v_ams497ee01_lux[brightness],
EA8061V_AMS497EE01_GAMMA_CMD_CNT);

ret = mipi_dsi_dcs_write_buffer(ctx->dsi, data, ARRAY_SIZE(data));
ret = mipi_dsi_dcs_write_buffer(ctx->dsi, gamma_cmd,
ARRAY_SIZE(gamma_cmd));
if (ret < 0)
return ret;

Expand All @@ -457,19 +458,38 @@ static int ea8061v_ams497ee01_set_brightness(struct backlight_device *bl_dev)
struct ea8061v_ams497ee01 *ctx = bl_get_data(bl_dev);
unsigned int brightness = bl_dev->props.brightness;
struct mipi_dsi_device *dsi = ctx->dsi;
struct device *dev = &dsi->dev;
int ret;

/* aid/aor */
ea8061v_ams497ee01_update_aid(ctx, brightness);
ret = ea8061v_ams497ee01_update_aid(ctx, brightness);
if (ret < 0) {
dev_err(dev, "Failed to send aid sequence: %d\n", ret);
return ret;
}
/* acl opr on */
dsi_dcs_write_seq(dsi, 0xb5, 0x29);
/* acl off (0x55, 0x02 for 15 % ACL) */
dsi_dcs_write_seq(dsi, 0x55, 0x00);
/* elvss b6 */
ea8061v_ams497ee01_update_elvss(ctx, brightness);
ret = ea8061v_ams497ee01_update_elvss(ctx, brightness);
if (ret < 0) {
dev_err(dev, "Failed to update elvss: %d\n", ret);
return ret;
}

/* gamma ca */
ea8061v_ams497ee01_update_gamma(ctx, brightness);
ea8061v_ams497ee01_apply_gamma(ctx);
ret = ea8061v_ams497ee01_update_gamma(ctx, brightness);
if (ret < 0) {
dev_err(dev, "Failed to update gamma: %d\n", ret);
return ret;
}

ret = ea8061v_ams497ee01_apply_gamma(ctx);
if (ret < 0) {
dev_err(dev, "Failed to apply gamma update: %d\n", ret);
return ret;
}

return 0;
}
Expand Down Expand Up @@ -511,13 +531,29 @@ static int ea8061v_ams497ee01_init(struct ea8061v_ams497ee01 *ctx)

/* Brightness control */
/* gamma ca */
ea8061v_ams497ee01_update_gamma(ctx, brightness);
ret = ea8061v_ams497ee01_update_gamma(ctx, brightness);
if (ret < 0) {
dev_err(dev, "Failed to update gamma: %d\n", ret);
return ret;
}
/* aid b2 */
ea8061v_ams497ee01_update_aid(ctx, brightness);
ret = ea8061v_ams497ee01_update_aid(ctx, brightness);
if (ret < 0) {
dev_err(dev, "Failed to send aid sequence: %d\n", ret);
return ret;
}
/* elvss b6 */
ea8061v_ams497ee01_update_elvss(ctx, brightness);
ret = ea8061v_ams497ee01_update_elvss(ctx, brightness);
if (ret < 0) {
dev_err(dev, "Failed to update elvss: %d\n", ret);
return ret;
}
/* apply gamma f7 */
ea8061v_ams497ee01_apply_gamma(ctx);
ret = ea8061v_ams497ee01_apply_gamma(ctx);
if (ret < 0) {
dev_err(dev, "Failed to apply gamma update: %d\n", ret);
return ret;
}

ret = mipi_dsi_dcs_exit_sleep_mode(dsi);
if (ret < 0) {
Expand Down Expand Up @@ -589,13 +625,6 @@ static int ea8061v_ams497ee01_enable(struct drm_panel *panel)
};
msleep(120);

ret = mipi_dsi_dcs_set_display_on(dsi);
if (ret < 0) {
dev_err(&dsi->dev, "Failed to set display on: %d\n", ret);
return ret;
}
msleep(50);

backlight_enable(ctx->bl_dev);

ctx->enabled = true;
Expand Down

0 comments on commit d4c06ab

Please sign in to comment.