drm/amd/display: Disable ABM when eDP is disabled
authorAmy Zhang <Amy.Zhang@amd.com>
Fri, 12 May 2017 19:54:29 +0000 (15:54 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 26 Sep 2017 22:07:12 +0000 (18:07 -0400)
- Add immediate ABM disable when eDP is disabled
- Fix purple screen when ABM is mistakenly enabled
on non eDP display

Signed-off-by: Amy Zhang <Amy.Zhang@amd.com>
Reviewed-by: Tony Cheng <Tony.Cheng@amd.com>
Acked-by: Harry Wentland <Harry.Wentland@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/dc.h
drivers/gpu/drm/amd/display/dc/dce/dce_abm.c
drivers/gpu/drm/amd/display/dc/inc/hw/abm.h

index ffc0eeaad175891edc58e259c6bc664d4cd0171f..59977640f938645984d2a9c64e6c1bdc01a362b2 100644 (file)
@@ -1415,6 +1415,22 @@ bool dc_link_set_backlight_level(const struct dc_link *dc_link, uint32_t level,
        return true;
 }
 
+
+bool dc_link_set_abm_disable(const struct dc_link *dc_link)
+{
+       struct core_link *link = DC_LINK_TO_CORE(dc_link);
+       struct core_dc *core_dc = DC_TO_CORE(link->ctx->dc);
+       struct abm *abm = core_dc->res_pool->abm;
+
+       if ((abm == NULL) || (abm->funcs->set_backlight_level == NULL))
+               return false;
+
+       abm->funcs->set_abm_immediate_disable(abm);
+
+       return true;
+}
+
+
 bool dc_link_set_psr_enable(const struct dc_link *dc_link, bool enable)
 {
        struct core_link *link = DC_LINK_TO_CORE(dc_link);
index 9a19d6f5a6a35daaaa5d089e6330521901dd4006..0610805cdb0509d927b870456cdc5748459cfb2d 100644 (file)
@@ -714,6 +714,8 @@ const struct graphics_object_id dc_get_link_id_at_index(
 bool dc_link_set_backlight_level(const struct dc_link *dc_link, uint32_t level,
                uint32_t frame_ramp, const struct dc_stream *stream);
 
+bool dc_link_set_abm_disable(const struct dc_link *dc_link);
+
 bool dc_link_set_psr_enable(const struct dc_link *dc_link, bool enable);
 
 bool dc_link_setup_psr(const struct dc_link *dc_link,
index cefffe164fe0dd37575bc46abd12d9c7106c1477..b4fa78292ad2100b9fc12e322b36572861886312 100644 (file)
@@ -49,6 +49,8 @@
 #define MCP_ABM_PIPE_SET 0x66
 #define MCP_BL_SET 0x67
 
+#define MCP_DISABLE_ABM_IMMEDIATELY 255
+
 struct abm_backlight_registers {
        unsigned int BL_PWM_CNTL;
        unsigned int BL_PWM_CNTL2;
@@ -315,6 +317,24 @@ static bool dce_abm_set_level(struct abm *abm, uint32_t level)
        return true;
 }
 
+static bool dce_abm_immediate_disable(struct abm *abm)
+{
+       struct dce_abm *abm_dce = TO_DCE_ABM(abm);
+
+       REG_WAIT(MASTER_COMM_CNTL_REG, MASTER_COMM_INTERRUPT, 0,
+                       100, 800);
+
+       /* setDMCUParam_ABMLevel */
+       REG_UPDATE_2(MASTER_COMM_CMD_REG,
+                       MASTER_COMM_CMD_REG_BYTE0, MCP_ABM_LEVEL_SET,
+                       MASTER_COMM_CMD_REG_BYTE2, MCP_DISABLE_ABM_IMMEDIATELY);
+
+       /* notifyDMCUMsg */
+       REG_UPDATE(MASTER_COMM_CNTL_REG, MASTER_COMM_INTERRUPT, 1);
+
+       return true;
+}
+
 static bool dce_abm_init_backlight(struct abm *abm)
 {
        struct dce_abm *abm_dce = TO_DCE_ABM(abm);
@@ -414,6 +434,7 @@ static const struct abm_funcs dce_funcs = {
        .init_backlight = dce_abm_init_backlight,
        .set_backlight_level = dce_abm_set_backlight_level,
        .get_current_backlight_8_bit = dce_abm_get_current_backlight_8_bit,
+       .set_abm_immediate_disable = dce_abm_immediate_disable,
        .is_dmcu_initialized = is_dmcu_initialized
 };
 
index da465b3e98e846e298ba706c24afb04638b3c648..c93b9b9a817c21c159e771bafee9b9744cb9c900 100644 (file)
@@ -35,6 +35,7 @@ struct abm {
 struct abm_funcs {
        void (*abm_init)(struct abm *abm);
        bool (*set_abm_level)(struct abm *abm, unsigned int abm_level);
+       bool (*set_abm_immediate_disable)(struct abm *abm);
        bool (*init_backlight)(struct abm *abm);
        bool (*set_backlight_level)(struct abm *abm,
                        unsigned int backlight_level,