]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
drm/amd/display: Add set backlight to hw sequencer.
authorYongqiang Sun <yongqiang.sun@amd.com>
Wed, 22 Apr 2020 22:08:01 +0000 (18:08 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 28 Apr 2020 20:19:40 +0000 (16:19 -0400)
[Why & How]
Add set backlight to hw sequencer, dmu communication will
be handled in hw sequencer for new asics.

Signed-off-by: Yongqiang Sun <yongqiang.sun@amd.com>
Reviewed-by: Anthony Koo <Anthony.Koo@amd.com>
Acked-by: Aurabindo Pillai <aurabindo.pillai@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/dc/core/dc_link.c
drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c
drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.h
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_init.c
drivers/gpu/drm/amd/display/dc/dcn20/dcn20_init.c
drivers/gpu/drm/amd/display/dc/dcn21/dcn21_init.c
drivers/gpu/drm/amd/display/dc/inc/hw_sequencer.h

index a54b3e05f66bb0cfac45fc810ffaa5c265c268cf..67c5342cf89a381683fb2f53cd1f891bfc2ae1c8 100644 (file)
@@ -2509,35 +2509,21 @@ bool dc_link_set_backlight_level(const struct dc_link *link,
                uint32_t frame_ramp)
 {
        struct dc  *dc = link->ctx->dc;
-       struct abm *abm = get_abm_from_stream_res(link);
-       struct dmcu *dmcu = dc->res_pool->dmcu;
-       unsigned int controller_id = 0;
-       bool fw_set_brightness = true;
        int i;
-       DC_LOGGER_INIT(link->ctx->logger);
-
-       if (abm == NULL || (abm->funcs->set_backlight_level_pwm == NULL))
-               return false;
-
-       if (dmcu)
-               fw_set_brightness = dmcu->funcs->is_dmcu_initialized(dmcu);
 
+       DC_LOGGER_INIT(link->ctx->logger);
        DC_LOG_BACKLIGHT("New Backlight level: %d (0x%X)\n",
                        backlight_pwm_u16_16, backlight_pwm_u16_16);
 
        if (dc_is_embedded_signal(link->connector_signal)) {
+               struct pipe_ctx *pipe_ctx = NULL;
+
                for (i = 0; i < MAX_PIPES; i++) {
                        if (dc->current_state->res_ctx.pipe_ctx[i].stream) {
                                if (dc->current_state->res_ctx.
                                                pipe_ctx[i].stream->link
                                                == link) {
-                                       /* DMCU -1 for all controller id values,
-                                        * therefore +1 here
-                                        */
-                                       controller_id =
-                                               dc->current_state->
-                                               res_ctx.pipe_ctx[i].stream_res.tg->inst +
-                                               1;
+                                       pipe_ctx = &dc->current_state->res_ctx.pipe_ctx[i];
 
                                        /* Disable brightness ramping when the display is blanked
                                         * as it can hang the DMCU
@@ -2547,13 +2533,14 @@ bool dc_link_set_backlight_level(const struct dc_link *link,
                                }
                        }
                }
-               abm->funcs->set_backlight_level_pwm(
-                               abm,
+
+               if (pipe_ctx == NULL)
+                       ASSERT(false);
+
+               dc->hwss.set_backlight_level(
+                               pipe_ctx,
                                backlight_pwm_u16_16,
-                               frame_ramp,
-                               controller_id,
-                               link->panel_cntl->inst,
-                               fw_set_brightness);
+                               frame_ramp);
        }
 
        return true;
index 9cd130c8894a59604f4a96d7fb1848872b558647..30469026c642893390336aeb134a1bc7a705cd58 100644 (file)
@@ -2714,6 +2714,37 @@ void dce110_set_cursor_attribute(struct pipe_ctx *pipe_ctx)
                                pipe_ctx->plane_res.xfm, attributes);
 }
 
+bool dce110_set_backlight_level(struct pipe_ctx *pipe_ctx,
+               uint32_t backlight_pwm_u16_16,
+               uint32_t frame_ramp)
+{
+       struct dc_link *link = pipe_ctx->stream->link;
+       struct dc  *dc = link->ctx->dc;
+       struct abm *abm = pipe_ctx->stream_res.abm;
+       struct dmcu *dmcu = dc->res_pool->dmcu;
+       bool fw_set_brightness = true;
+       /* DMCU -1 for all controller id values,
+        * therefore +1 here
+        */
+       uint32_t controller_id = pipe_ctx->stream_res.tg->inst + 1;
+
+       if (abm == NULL || (abm->funcs->set_backlight_level_pwm == NULL))
+               return false;
+
+       if (dmcu)
+               fw_set_brightness = dmcu->funcs->is_dmcu_initialized(dmcu);
+
+       abm->funcs->set_backlight_level_pwm(
+                       abm,
+                       backlight_pwm_u16_16,
+                       frame_ramp,
+                       controller_id,
+                       link->panel_cntl->inst,
+                       fw_set_brightness);
+
+       return true;
+}
+
 static const struct hw_sequencer_funcs dce110_funcs = {
        .program_gamut_remap = program_gamut_remap,
        .program_output_csc = program_output_csc,
@@ -2747,7 +2778,8 @@ static const struct hw_sequencer_funcs dce110_funcs = {
        .edp_power_control = dce110_edp_power_control,
        .edp_wait_for_hpd_ready = dce110_edp_wait_for_hpd_ready,
        .set_cursor_position = dce110_set_cursor_position,
-       .set_cursor_attribute = dce110_set_cursor_attribute
+       .set_cursor_attribute = dce110_set_cursor_attribute,
+       .set_backlight_level = dce110_set_backlight_level,
 };
 
 static const struct hwseq_private_funcs dce110_private_funcs = {
index 26a9c14a58b1778d86e6bc9ca3ab605589638b3b..e609a72b4634d0156e537999a5b658ad93e18dda 100644 (file)
@@ -85,5 +85,9 @@ void dce110_edp_wait_for_hpd_ready(
                struct dc_link *link,
                bool power_up);
 
+bool dce110_set_backlight_level(struct pipe_ctx *pipe_ctx,
+               uint32_t backlight_pwm_u16_16,
+               uint32_t frame_ramp);
+
 #endif /* __DC_HWSS_DCE110_H__ */
 
index b88ef9703b2bfd3e97e7eea3b5242bfecbb914ec..6f3dbcdb06f575ef29cb3dfccaaea64ef2d3255d 100644 (file)
@@ -71,6 +71,7 @@ static const struct hw_sequencer_funcs dcn10_funcs = {
        .set_clock = dcn10_set_clock,
        .get_clock = dcn10_get_clock,
        .get_vupdate_offset_from_vsync = dcn10_get_vupdate_offset_from_vsync,
+       .set_backlight_level = dce110_set_backlight_level,
 };
 
 static const struct hwseq_private_funcs dcn10_private_funcs = {
index 1642bf546ceba5a20733d0d8f62c175058d89571..1e33e29b37f8be5ef3d57c8504fd1455eb175001 100644 (file)
@@ -82,6 +82,7 @@ static const struct hw_sequencer_funcs dcn20_funcs = {
        .init_vm_ctx = dcn20_init_vm_ctx,
        .set_flip_control_gsl = dcn20_set_flip_control_gsl,
        .get_vupdate_offset_from_vsync = dcn10_get_vupdate_offset_from_vsync,
+       .set_backlight_level = dce110_set_backlight_level,
 };
 
 static const struct hwseq_private_funcs dcn20_private_funcs = {
index 8410a6305a9adcbd02d5fd7b66cbb65724ea7017..128d5e3729c6f6221d9d378a0cf53edeb7833b85 100644 (file)
@@ -91,6 +91,7 @@ static const struct hw_sequencer_funcs dcn21_funcs = {
        .optimize_pwr_state = dcn21_optimize_pwr_state,
        .exit_optimized_pwr_state = dcn21_exit_optimized_pwr_state,
        .power_down = dce110_power_down,
+       .set_backlight_level = dce110_set_backlight_level,
 };
 
 static const struct hwseq_private_funcs dcn21_private_funcs = {
index 9380721f28b8b568ee9158b5f14d91dc8e8b7770..ed3505cbba6e9922610d7fbbd655b4df3c41c249 100644 (file)
@@ -191,6 +191,10 @@ struct hw_sequencer_funcs {
                        unsigned int bufSize, unsigned int mask);
        void (*clear_status_bits)(struct dc *dc, unsigned int mask);
 
+       bool (*set_backlight_level)(struct pipe_ctx *pipe_ctx,
+                       uint32_t backlight_pwm_u16_16,
+                       uint32_t frame_ramp);
+
 
 };