drm/amd/display: Bug in dce_is_panel_backlight_on()
authorPeikang Zhang <peikang.zhang@amd.com>
Thu, 3 Sep 2020 17:45:07 +0000 (13:45 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 22 Sep 2020 16:27:35 +0000 (12:27 -0400)
[Why]
dce_is_panel_backlight_on() will return wrong value if
LVTMA_BLON_OVRD is 0

[How]
When LVTMA_BLON_OVRD is 0, read
LVTMA_PWRSEQ_TARGET_STATE instead

Signed-off-by: Peikang Zhang <peikang.zhang@amd.com>
Reviewed-by: Anthony Koo <Anthony.Koo@amd.com>
Acked-by: Qingqing Zhuo <qingqing.zhuo@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/dc/dce/dce_panel_cntl.c
drivers/gpu/drm/amd/display/dc/dce/dce_panel_cntl.h

index df7f826..74f7619 100644 (file)
@@ -159,11 +159,15 @@ static uint32_t dce_panel_cntl_hw_init(struct panel_cntl *panel_cntl)
 static bool dce_is_panel_backlight_on(struct panel_cntl *panel_cntl)
 {
        struct dce_panel_cntl *dce_panel_cntl = TO_DCE_PANEL_CNTL(panel_cntl);
-       uint32_t value;
+       uint32_t blon, blon_ovrd, pwrseq_target_state;
 
-       REG_GET(PWRSEQ_CNTL, LVTMA_BLON, &value);
+       REG_GET_2(PWRSEQ_CNTL, LVTMA_BLON, &blon, LVTMA_BLON_OVRD, &blon_ovrd);
+       REG_GET(PWRSEQ_CNTL, LVTMA_PWRSEQ_TARGET_STATE, &pwrseq_target_state);
 
-       return value;
+       if (blon_ovrd)
+               return blon;
+       else
+               return pwrseq_target_state;
 }
 
 static bool dce_is_panel_powered_on(struct panel_cntl *panel_cntl)
index 967d04d..6bd1196 100644 (file)
 
 #define DCE_PANEL_CNTL_MASK_SH_LIST(mask_sh) \
        DCE_PANEL_CNTL_SF(LVTMA_PWRSEQ_CNTL, LVTMA_BLON, mask_sh),\
+       DCE_PANEL_CNTL_SF(LVTMA_PWRSEQ_CNTL, LVTMA_BLON_OVRD, mask_sh),\
        DCE_PANEL_CNTL_SF(LVTMA_PWRSEQ_CNTL, LVTMA_DIGON, mask_sh),\
        DCE_PANEL_CNTL_SF(LVTMA_PWRSEQ_CNTL, LVTMA_DIGON_OVRD, mask_sh),\
+       DCE_PANEL_CNTL_SF(LVTMA_PWRSEQ_CNTL, LVTMA_PWRSEQ_TARGET_STATE, mask_sh), \
        DCE_PANEL_CNTL_SF(LVTMA_PWRSEQ_STATE, LVTMA_PWRSEQ_TARGET_STATE_R, mask_sh), \
        DCE_PANEL_CNTL_SF(LVTMA_PWRSEQ_REF_DIV, BL_PWM_REF_DIV, mask_sh), \
        DCE_PANEL_CNTL_SF(BL_PWM_PERIOD_CNTL, BL_PWM_PERIOD, mask_sh), \
 
 #define DCE_PANEL_CNTL_REG_FIELD_LIST(type) \
        type LVTMA_BLON;\
+       type LVTMA_BLON_OVRD;\
        type LVTMA_DIGON;\
        type LVTMA_DIGON_OVRD;\
+       type LVTMA_PWRSEQ_TARGET_STATE; \
        type LVTMA_PWRSEQ_TARGET_STATE_R; \
        type BL_PWM_REF_DIV; \
        type BL_PWM_EN; \