Commit 04b5b362 authored by Tejas Vipin's avatar Tejas Vipin Committed by Douglas Anderson

drm/panel: jdi-fhd-r63452: transition to mipi_dsi wrapped functions

Changes the jdi-fhd-r63452 panel to use multi style functions for
improved error handling.
Reviewed-by: default avatarDouglas Anderson <dianders@chromium.org>
Signed-off-by: default avatarTejas Vipin <tejasvipin76@gmail.com>
Signed-off-by: default avatarDouglas Anderson <dianders@chromium.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20240818060816.848784-3-tejasvipin76@gmail.com
parent 051c86af
...@@ -41,142 +41,89 @@ static void jdi_fhd_r63452_reset(struct jdi_fhd_r63452 *ctx) ...@@ -41,142 +41,89 @@ static void jdi_fhd_r63452_reset(struct jdi_fhd_r63452 *ctx)
static int jdi_fhd_r63452_on(struct jdi_fhd_r63452 *ctx) static int jdi_fhd_r63452_on(struct jdi_fhd_r63452 *ctx)
{ {
struct mipi_dsi_device *dsi = ctx->dsi; struct mipi_dsi_device *dsi = ctx->dsi;
struct device *dev = &dsi->dev; struct mipi_dsi_multi_context dsi_ctx = { .dsi = dsi };
int ret;
dsi->mode_flags |= MIPI_DSI_MODE_LPM; dsi->mode_flags |= MIPI_DSI_MODE_LPM;
mipi_dsi_generic_write_seq(dsi, 0xb0, 0x00); mipi_dsi_generic_write_seq_multi(&dsi_ctx, 0xb0, 0x00);
mipi_dsi_generic_write_seq(dsi, 0xd6, 0x01); mipi_dsi_generic_write_seq_multi(&dsi_ctx, 0xd6, 0x01);
mipi_dsi_generic_write_seq(dsi, 0xec, mipi_dsi_generic_write_seq_multi(&dsi_ctx, 0xec,
0x64, 0xdc, 0xec, 0x3b, 0x52, 0x00, 0x0b, 0x0b, 0x64, 0xdc, 0xec, 0x3b, 0x52, 0x00, 0x0b, 0x0b,
0x13, 0x15, 0x68, 0x0b, 0xb5); 0x13, 0x15, 0x68, 0x0b, 0xb5);
mipi_dsi_generic_write_seq(dsi, 0xb0, 0x03); mipi_dsi_generic_write_seq_multi(&dsi_ctx, 0xb0, 0x03);
ret = mipi_dsi_dcs_set_tear_on(dsi, MIPI_DSI_DCS_TEAR_MODE_VBLANK);
if (ret < 0) {
dev_err(dev, "Failed to set tear on: %d\n", ret);
return ret;
}
mipi_dsi_dcs_write_seq(dsi, MIPI_DCS_SET_ADDRESS_MODE, 0x00);
ret = mipi_dsi_dcs_set_pixel_format(dsi, 0x77); mipi_dsi_dcs_set_tear_on_multi(&dsi_ctx, MIPI_DSI_DCS_TEAR_MODE_VBLANK);
if (ret < 0) {
dev_err(dev, "Failed to set pixel format: %d\n", ret);
return ret;
}
ret = mipi_dsi_dcs_set_column_address(dsi, 0x0000, 0x0437);
if (ret < 0) {
dev_err(dev, "Failed to set column address: %d\n", ret);
return ret;
}
ret = mipi_dsi_dcs_set_page_address(dsi, 0x0000, 0x077f); mipi_dsi_dcs_write_seq_multi(&dsi_ctx, MIPI_DCS_SET_ADDRESS_MODE, 0x00);
if (ret < 0) {
dev_err(dev, "Failed to set page address: %d\n", ret);
return ret;
}
ret = mipi_dsi_dcs_set_tear_scanline(dsi, 0x0000); mipi_dsi_dcs_set_pixel_format_multi(&dsi_ctx, 0x77);
if (ret < 0) { mipi_dsi_dcs_set_column_address_multi(&dsi_ctx, 0x0000, 0x0437);
dev_err(dev, "Failed to set tear scanline: %d\n", ret); mipi_dsi_dcs_set_page_address_multi(&dsi_ctx, 0x0000, 0x077f);
return ret; mipi_dsi_dcs_set_tear_scanline_multi(&dsi_ctx, 0x0000);
} mipi_dsi_dcs_set_display_brightness_multi(&dsi_ctx, 0x00ff);
ret = mipi_dsi_dcs_set_display_brightness(dsi, 0x00ff); mipi_dsi_dcs_write_seq_multi(&dsi_ctx, MIPI_DCS_WRITE_CONTROL_DISPLAY, 0x24);
if (ret < 0) { mipi_dsi_dcs_write_seq_multi(&dsi_ctx, MIPI_DCS_WRITE_POWER_SAVE, 0x00);
dev_err(dev, "Failed to set display brightness: %d\n", ret); mipi_dsi_dcs_write_seq_multi(&dsi_ctx, MIPI_DCS_SET_CABC_MIN_BRIGHTNESS, 0x00);
return ret; mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0x84, 0x00);
}
mipi_dsi_dcs_write_seq(dsi, MIPI_DCS_WRITE_CONTROL_DISPLAY, 0x24); mipi_dsi_dcs_set_display_on_multi(&dsi_ctx);
mipi_dsi_dcs_write_seq(dsi, MIPI_DCS_WRITE_POWER_SAVE, 0x00); mipi_dsi_msleep(&dsi_ctx, 20);
mipi_dsi_dcs_write_seq(dsi, MIPI_DCS_SET_CABC_MIN_BRIGHTNESS, 0x00); mipi_dsi_dcs_exit_sleep_mode_multi(&dsi_ctx);
mipi_dsi_dcs_write_seq(dsi, 0x84, 0x00); mipi_dsi_msleep(&dsi_ctx, 80);
ret = mipi_dsi_dcs_set_display_on(dsi); mipi_dsi_generic_write_seq_multi(&dsi_ctx, 0xb0, 0x04);
if (ret < 0) { mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0x84, 0x00);
dev_err(dev, "Failed to set display on: %d\n", ret); mipi_dsi_generic_write_seq_multi(&dsi_ctx, 0xc8, 0x11);
return ret; mipi_dsi_generic_write_seq_multi(&dsi_ctx, 0xb0, 0x03);
}
msleep(20);
ret = mipi_dsi_dcs_exit_sleep_mode(dsi); return dsi_ctx.accum_err;
if (ret < 0) {
dev_err(dev, "Failed to exit sleep mode: %d\n", ret);
return ret;
}
msleep(80);
mipi_dsi_generic_write_seq(dsi, 0xb0, 0x04);
mipi_dsi_dcs_write_seq(dsi, 0x84, 0x00);
mipi_dsi_generic_write_seq(dsi, 0xc8, 0x11);
mipi_dsi_generic_write_seq(dsi, 0xb0, 0x03);
return 0;
} }
static int jdi_fhd_r63452_off(struct jdi_fhd_r63452 *ctx) static void jdi_fhd_r63452_off(struct jdi_fhd_r63452 *ctx)
{ {
struct mipi_dsi_device *dsi = ctx->dsi; struct mipi_dsi_device *dsi = ctx->dsi;
struct device *dev = &dsi->dev; struct mipi_dsi_multi_context dsi_ctx = { .dsi = dsi };
int ret;
dsi->mode_flags &= ~MIPI_DSI_MODE_LPM; dsi->mode_flags &= ~MIPI_DSI_MODE_LPM;
mipi_dsi_generic_write_seq(dsi, 0xb0, 0x00); mipi_dsi_generic_write_seq_multi(&dsi_ctx, 0xb0, 0x00);
mipi_dsi_generic_write_seq(dsi, 0xd6, 0x01); mipi_dsi_generic_write_seq_multi(&dsi_ctx, 0xd6, 0x01);
mipi_dsi_generic_write_seq(dsi, 0xec, mipi_dsi_generic_write_seq_multi(&dsi_ctx, 0xec,
0x64, 0xdc, 0xec, 0x3b, 0x52, 0x00, 0x0b, 0x0b, 0x64, 0xdc, 0xec, 0x3b, 0x52, 0x00, 0x0b, 0x0b,
0x13, 0x15, 0x68, 0x0b, 0x95); 0x13, 0x15, 0x68, 0x0b, 0x95);
mipi_dsi_generic_write_seq(dsi, 0xb0, 0x03); mipi_dsi_generic_write_seq_multi(&dsi_ctx, 0xb0, 0x03);
ret = mipi_dsi_dcs_set_display_off(dsi); mipi_dsi_dcs_set_display_off_multi(&dsi_ctx);
if (ret < 0) { mipi_dsi_usleep_range(&dsi_ctx, 2000, 3000);
dev_err(dev, "Failed to set display off: %d\n", ret); mipi_dsi_dcs_enter_sleep_mode_multi(&dsi_ctx);
return ret; mipi_dsi_msleep(&dsi_ctx, 120);
}
usleep_range(2000, 3000);
ret = mipi_dsi_dcs_enter_sleep_mode(dsi);
if (ret < 0) {
dev_err(dev, "Failed to enter sleep mode: %d\n", ret);
return ret;
}
msleep(120);
return 0;
} }
static int jdi_fhd_r63452_prepare(struct drm_panel *panel) static int jdi_fhd_r63452_prepare(struct drm_panel *panel)
{ {
struct jdi_fhd_r63452 *ctx = to_jdi_fhd_r63452(panel); struct jdi_fhd_r63452 *ctx = to_jdi_fhd_r63452(panel);
struct device *dev = &ctx->dsi->dev;
int ret; int ret;
jdi_fhd_r63452_reset(ctx); jdi_fhd_r63452_reset(ctx);
ret = jdi_fhd_r63452_on(ctx); ret = jdi_fhd_r63452_on(ctx);
if (ret < 0) { if (ret < 0)
dev_err(dev, "Failed to initialize panel: %d\n", ret);
gpiod_set_value_cansleep(ctx->reset_gpio, 1); gpiod_set_value_cansleep(ctx->reset_gpio, 1);
return ret;
}
return 0; return ret;
} }
static int jdi_fhd_r63452_unprepare(struct drm_panel *panel) static int jdi_fhd_r63452_unprepare(struct drm_panel *panel)
{ {
struct jdi_fhd_r63452 *ctx = to_jdi_fhd_r63452(panel); struct jdi_fhd_r63452 *ctx = to_jdi_fhd_r63452(panel);
struct device *dev = &ctx->dsi->dev;
int ret;
ret = jdi_fhd_r63452_off(ctx); /*
if (ret < 0) * NOTE: We don't return an error here as while the panel won't have
dev_err(dev, "Failed to un-initialize panel: %d\n", ret); * been cleanly turned off at least we've asserted the reset signal
* so it should be safe to power it back on again later
*/
jdi_fhd_r63452_off(ctx);
gpiod_set_value_cansleep(ctx->reset_gpio, 1); gpiod_set_value_cansleep(ctx->reset_gpio, 1);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment