drm/amd/display: Fix incorrect DPCD configs while Replay/PSR switch
authorLeon Huang <Leon.Huang1@amd.com>
Tue, 11 Feb 2025 07:45:43 +0000 (15:45 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 10 Mar 2025 17:23:25 +0000 (13:23 -0400)
[Why]
When switching between PSR/Replay,
the DPCD config of previous mode is not cleared,
resulting in unexpected behavior in TCON.

[How]
Initialize the DPCD in setup function

Reviewed-by: Robin Chen <robin.chen@amd.com>
Signed-off-by: Leon Huang <Leon.Huang1@amd.com>
Signed-off-by: Tom Chung <chiahsuan.chung@amd.com>
Tested-by: Daniel Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/dc/link/protocols/link_edp_panel_control.c

index e0e3bb8653595270c8a293b0368b320b67dd6da5..1e4adbc764ea6940661c7d47e8f4eab328e00be2 100644 (file)
@@ -675,6 +675,18 @@ bool edp_setup_psr(struct dc_link *link,
        if (!link)
                return false;
 
+       //Clear PSR cfg
+       memset(&psr_configuration, 0, sizeof(psr_configuration));
+       dm_helpers_dp_write_dpcd(
+               link->ctx,
+               link,
+               DP_PSR_EN_CFG,
+               &psr_configuration.raw,
+               sizeof(psr_configuration.raw));
+
+       if (link->psr_settings.psr_version == DC_PSR_VERSION_UNSUPPORTED)
+               return false;
+
        dc = link->ctx->dc;
        dmcu = dc->res_pool->dmcu;
        psr = dc->res_pool->psr;
@@ -685,9 +697,6 @@ bool edp_setup_psr(struct dc_link *link,
        if (!dc_get_edp_link_panel_inst(dc, link, &panel_inst))
                return false;
 
-
-       memset(&psr_configuration, 0, sizeof(psr_configuration));
-
        psr_configuration.bits.ENABLE                    = 1;
        psr_configuration.bits.CRC_VERIFICATION          = 1;
        psr_configuration.bits.FRAME_CAPTURE_INDICATION  =
@@ -950,6 +959,16 @@ bool edp_setup_replay(struct dc_link *link, const struct dc_stream_state *stream
        if (!link)
                return false;
 
+       //Clear Replay config
+       dm_helpers_dp_write_dpcd(link->ctx, link,
+               DP_SINK_PR_ENABLE_AND_CONFIGURATION,
+               (uint8_t *)&(replay_config.raw), sizeof(uint8_t));
+
+       if (!(link->replay_settings.config.replay_supported))
+               return false;
+
+       link->replay_settings.config.replay_error_status.raw = 0;
+
        dc = link->ctx->dc;
 
        replay = dc->res_pool->replay;