From: Allen Pan <[email protected]>

[Why]
Link rate testing needs a way to override the max DP link rate that
VBIOS reports for the link encoder, including rates above it.

[How]
Add force_dp_link_rate to dc_debug_options. When set, the DCN4.2 link
encoder reports it as its max link rate instead of the rate VBIOS
reports. dp_get_max_link_cap() still lowers it to the sink's DPCD max
link rate and the cable ID and LTTPR caps, and link settings are
decided as before.

Cc: Charlene Liu <[email protected]>
Signed-off-by: Allen Pan <[email protected]>
Signed-off-by: Chenyu Chen <[email protected]>
---
 drivers/gpu/drm/amd/display/dc/dc.h                  |  1 +
 .../display/dc/dio/dcn42/dcn42_dio_link_encoder.c    | 12 +++++++++++-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dc.h 
b/drivers/gpu/drm/amd/display/dc/dc.h
index 58e443672411..75d1ede366c7 100644
--- a/drivers/gpu/drm/amd/display/dc/dc.h
+++ b/drivers/gpu/drm/amd/display/dc/dc.h
@@ -1269,6 +1269,7 @@ struct dc_debug_options {
        bool enable_dp_dig_pixel_rate_div_policy;
        bool using_dml21;
        enum lttpr_mode lttpr_mode_override;
+       enum dc_link_rate force_dp_link_rate;
        unsigned int dsc_delay_factor_wa_x1000;
        unsigned int min_prefetch_in_strobe_ns;
        bool disable_unbounded_requesting;
diff --git a/drivers/gpu/drm/amd/display/dc/dio/dcn42/dcn42_dio_link_encoder.c 
b/drivers/gpu/drm/amd/display/dc/dio/dcn42/dcn42_dio_link_encoder.c
index 3b11be9991c3..687df8cb4b60 100644
--- a/drivers/gpu/drm/amd/display/dc/dio/dcn42/dcn42_dio_link_encoder.c
+++ b/drivers/gpu/drm/amd/display/dc/dio/dcn42/dcn42_dio_link_encoder.c
@@ -64,6 +64,16 @@ bool dcn42_program_hpd_filter(struct link_encoder *enc, int 
delay_on_connect_in_
        return true;
 }
 
+/* DMs load debug options after link encoders are constructed */
+static void dcn42_link_encoder_get_max_link_cap(struct link_encoder *enc,
+       struct dc_link_settings *link_settings)
+{
+       dcn32_link_encoder_get_max_link_cap(enc, link_settings);
+
+       if (enc->ctx->dc->debug.force_dp_link_rate != LINK_RATE_UNKNOWN)
+               link_settings->link_rate = 
enc->ctx->dc->debug.force_dp_link_rate;
+}
+
 static const struct link_encoder_funcs dcn42_link_enc_funcs = {
        .read_state = link_enc2_read_state,
        .validate_output_with_stream =
@@ -92,7 +102,7 @@ static const struct link_encoder_funcs dcn42_link_enc_funcs 
= {
        .get_dig_frontend = dcn10_get_dig_frontend,
        .get_dig_mode = dcn401_get_dig_mode,
        .is_in_alt_mode = dcn32_link_encoder_is_in_alt_mode,
-       .get_max_link_cap = dcn32_link_encoder_get_max_link_cap,
+       .get_max_link_cap = dcn42_link_encoder_get_max_link_cap,
        .dpcstx_set_order_invert_18_bit = NULL,
        .set_phy_source = NULL,
        .dpcs_initialize_phy = NULL,
-- 
2.43.0

Reply via email to