From: David Heidelberg <[email protected]>

Introduce enable(), disable() and reset() functions.

The enable() and disable() callbacks keep the symmetry in the commands
sent to the panel and also make a clearer distinction between panel
initialization and configuration.

Splitting reset() from prepare() follows clean coding practices and lets
us potentially make reset optional in the future for flicker-less
takeover from a bootloader or framebuffer driver where the panel is
already configured.

Signed-off-by: David Heidelberg <[email protected]>
---
 drivers/gpu/drm/panel/panel-lg-sw43408.c | 47 ++++++++++++++++++++++++--------
 1 file changed, 35 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/panel/panel-lg-sw43408.c 
b/drivers/gpu/drm/panel/panel-lg-sw43408.c
index dcca7873acf8e..dad6b967b92c2 100644
--- a/drivers/gpu/drm/panel/panel-lg-sw43408.c
+++ b/drivers/gpu/drm/panel/panel-lg-sw43408.c
@@ -38,11 +38,10 @@ static inline struct sw43408_panel *to_panel_info(struct 
drm_panel *panel)
        return container_of(panel, struct sw43408_panel, base);
 }
 
-static int sw43408_unprepare(struct drm_panel *panel)
+static int sw43408_disable(struct drm_panel *panel)
 {
        struct sw43408_panel *sw43408 = to_panel_info(panel);
        struct mipi_dsi_multi_context ctx = { .dsi = sw43408->link };
-       int ret;
 
        mipi_dsi_dcs_set_display_off_multi(&ctx);
 
@@ -50,18 +49,25 @@ static int sw43408_unprepare(struct drm_panel *panel)
 
        mipi_dsi_msleep(&ctx, 100);
 
+       return ctx.accum_err;
+}
+
+static int sw43408_unprepare(struct drm_panel *panel)
+{
+       struct sw43408_panel *sw43408 = to_panel_info(panel);
+       int ret;
+
        gpiod_set_value(sw43408->reset_gpio, 1);
 
        ret = regulator_bulk_disable(ARRAY_SIZE(sw43408->supplies), 
sw43408->supplies);
 
-       return ret ? : ctx.accum_err;
+       return ret;
 }
 
 static int sw43408_program(struct drm_panel *panel)
 {
        struct sw43408_panel *sw43408 = to_panel_info(panel);
        struct mipi_dsi_multi_context ctx = { .dsi = sw43408->link };
-       struct drm_dsc_picture_parameter_set pps;
 
        mipi_dsi_dcs_write_seq_multi(&ctx, MIPI_DCS_SET_GAMMA_CURVE, 0x02);
 
@@ -97,6 +103,15 @@ static int sw43408_program(struct drm_panel *panel)
        mipi_dsi_dcs_write_seq_multi(&ctx, 0x55, 0x04, 0x61, 0xdb, 0x04, 0x70, 
0xdb);
        mipi_dsi_dcs_write_seq_multi(&ctx, 0xb0, 0xca);
 
+       return ctx.accum_err;
+}
+
+static int sw43408_enable(struct drm_panel *panel)
+{
+       struct sw43408_panel *sw43408 = to_panel_info(panel);
+       struct mipi_dsi_multi_context ctx = { .dsi = sw43408->link };
+       struct drm_dsc_picture_parameter_set pps;
+
        mipi_dsi_dcs_set_display_on_multi(&ctx);
 
        mipi_dsi_msleep(&ctx, 50);
@@ -116,18 +131,12 @@ static int sw43408_program(struct drm_panel *panel)
         */
        mipi_dsi_compression_mode_ext_multi(&ctx, true,
                                            MIPI_DSI_COMPRESSION_DSC, 1);
+
        return ctx.accum_err;
 }
 
-static int sw43408_prepare(struct drm_panel *panel)
+static void sw43408_reset(struct sw43408_panel *ctx)
 {
-       struct sw43408_panel *ctx = to_panel_info(panel);
-       int ret;
-
-       ret = regulator_bulk_enable(ARRAY_SIZE(ctx->supplies), ctx->supplies);
-       if (ret < 0)
-               return ret;
-
        usleep_range(5000, 6000);
 
        gpiod_set_value(ctx->reset_gpio, 0);
@@ -136,6 +145,18 @@ static int sw43408_prepare(struct drm_panel *panel)
        usleep_range(1000, 2000);
        gpiod_set_value(ctx->reset_gpio, 0);
        usleep_range(9000, 10000);
+}
+
+static int sw43408_prepare(struct drm_panel *panel)
+{
+       struct sw43408_panel *ctx = to_panel_info(panel);
+       int ret;
+
+       ret = regulator_bulk_enable(ARRAY_SIZE(ctx->supplies), ctx->supplies);
+       if (ret < 0)
+               return ret;
+
+       sw43408_reset(ctx);
 
        ret = sw43408_program(panel);
        if (ret)
@@ -208,6 +229,8 @@ static int sw43408_backlight_init(struct sw43408_panel *ctx)
 }
 
 static const struct drm_panel_funcs sw43408_funcs = {
+       .disable = sw43408_disable,
+       .enable = sw43408_enable,
        .unprepare = sw43408_unprepare,
        .prepare = sw43408_prepare,
        .get_modes = sw43408_get_modes,

-- 
2.51.0



Reply via email to