drm/amd/display: isolate link training setting override to its own function
authorWenjing Liu <wenjing.liu@amd.com>
Tue, 4 May 2021 20:39:08 +0000 (16:39 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 8 Jul 2021 19:14:29 +0000 (15:14 -0400)
There is a difference between our default behavior and override
behavior. For default behavior we need to decide link training settings
within specs' limitation and mandates.
For override behavior we do not need to follow all these requirements.
We are isolating override decision to its own function to maintain the
integrity of our specs compliant default behavior.

Signed-off-by: Wenjing Liu <wenjing.liu@amd.com>
Reviewed-by: George Shen <George.Shen@amd.com>
Acked-by: Rodrigo Siqueira <Rodrigo.Siqueira@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/core/dc_link_dp.c
drivers/gpu/drm/amd/display/dc/inc/dc_link_dp.h

index b8832bd..5c3f78b 100644 (file)
@@ -1241,29 +1241,15 @@ enum link_training_result dp_check_link_loss_status(
 static inline void decide_8b_10b_training_settings(
         struct dc_link *link,
        const struct dc_link_settings *link_setting,
-       const struct dc_link_training_overrides *overrides,
        struct link_training_settings *lt_settings)
 {
-       uint32_t lane;
-
        memset(lt_settings, '\0', sizeof(struct link_training_settings));
 
        /* Initialize link settings */
        lt_settings->link_settings.use_link_rate_set = link_setting->use_link_rate_set;
        lt_settings->link_settings.link_rate_set = link_setting->link_rate_set;
-
-       if (link->preferred_link_setting.link_rate != LINK_RATE_UNKNOWN)
-               lt_settings->link_settings.link_rate = link->preferred_link_setting.link_rate;
-       else
-               lt_settings->link_settings.link_rate = link_setting->link_rate;
-
-       if (link->preferred_link_setting.lane_count != LANE_COUNT_UNKNOWN)
-               lt_settings->link_settings.lane_count = link->preferred_link_setting.lane_count;
-       else
-               lt_settings->link_settings.lane_count = link_setting->lane_count;
-
-       /*@todo[vdevulap] move SS to LS, should not be handled by displaypath*/
-
+       lt_settings->link_settings.link_rate = link_setting->link_rate;
+       lt_settings->link_settings.lane_count = link_setting->lane_count;
        /* TODO hard coded to SS for now
         * lt_settings.link_settings.link_spread =
         * dal_display_path_is_ss_supported(
@@ -1271,30 +1257,52 @@ static inline void decide_8b_10b_training_settings(
         * LINK_SPREAD_05_DOWNSPREAD_30KHZ :
         * LINK_SPREAD_DISABLED;
         */
-       /* Initialize link spread */
-       if (link->dp_ss_off)
-               lt_settings->link_settings.link_spread = LINK_SPREAD_DISABLED;
-       else if (overrides->downspread != NULL)
-               lt_settings->link_settings.link_spread
-                       = *overrides->downspread
-                       ? LINK_SPREAD_05_DOWNSPREAD_30KHZ
-                       : LINK_SPREAD_DISABLED;
-       else
-               lt_settings->link_settings.link_spread = LINK_SPREAD_05_DOWNSPREAD_30KHZ;
-
+       lt_settings->link_settings.link_spread = link->dp_ss_off ?
+                       LINK_SPREAD_DISABLED : LINK_SPREAD_05_DOWNSPREAD_30KHZ;
        lt_settings->lttpr_mode = link->lttpr_mode;
+       lt_settings->cr_pattern_time = get_cr_training_aux_rd_interval(link, link_setting);
+       lt_settings->eq_pattern_time = get_eq_training_aux_rd_interval(link, link_setting);
+       lt_settings->pattern_for_cr = decide_cr_training_pattern(link_setting);
+       lt_settings->pattern_for_eq = decide_eq_training_pattern(link, link_setting);
+       lt_settings->enhanced_framing = 1;
+       lt_settings->should_set_fec_ready = true;
+}
 
-       /* Initialize lane settings overrides */
+void dp_decide_training_settings(
+               struct dc_link *link,
+               const struct dc_link_settings *link_settings,
+               struct link_training_settings *lt_settings)
+{
+       if (dp_get_link_encoding_format(link_settings) == DP_8b_10b_ENCODING)
+               decide_8b_10b_training_settings(link, link_settings, lt_settings);
+}
+
+static void override_training_settings(
+               struct dc_link *link,
+               const struct dc_link_training_overrides *overrides,
+               struct link_training_settings *lt_settings)
+{
+       uint32_t lane;
+
+       /* Override link settings */
+       if (link->preferred_link_setting.link_rate != LINK_RATE_UNKNOWN)
+               lt_settings->link_settings.link_rate = link->preferred_link_setting.link_rate;
+       if (link->preferred_link_setting.lane_count != LANE_COUNT_UNKNOWN)
+               lt_settings->link_settings.lane_count = link->preferred_link_setting.lane_count;
+
+       /* Override link spread */
+       if (!link->dp_ss_off && overrides->downspread != NULL)
+               lt_settings->link_settings.link_spread = *overrides->downspread ?
+                               LINK_SPREAD_05_DOWNSPREAD_30KHZ
+                               : LINK_SPREAD_DISABLED;
+
+       /* Override lane settings */
        if (overrides->voltage_swing != NULL)
                lt_settings->voltage_swing = overrides->voltage_swing;
-
        if (overrides->pre_emphasis != NULL)
                lt_settings->pre_emphasis = overrides->pre_emphasis;
-
        if (overrides->post_cursor2 != NULL)
                lt_settings->post_cursor2 = overrides->post_cursor2;
-
-       /* Initialize lane settings (VS/PE/PC2) */
        for (lane = 0; lane < LANE_COUNT_DP_MAX; lane++) {
                lt_settings->lane_settings[lane].VOLTAGE_SWING =
                        lt_settings->voltage_swing != NULL ?
@@ -1313,45 +1321,22 @@ static inline void decide_8b_10b_training_settings(
        /* Initialize training timings */
        if (overrides->cr_pattern_time != NULL)
                lt_settings->cr_pattern_time = *overrides->cr_pattern_time;
-       else
-               lt_settings->cr_pattern_time = get_cr_training_aux_rd_interval(link, link_setting);
 
        if (overrides->eq_pattern_time != NULL)
                lt_settings->eq_pattern_time = *overrides->eq_pattern_time;
-       else
-               lt_settings->eq_pattern_time = get_eq_training_aux_rd_interval(link, link_setting);
 
        if (overrides->pattern_for_cr != NULL)
                lt_settings->pattern_for_cr = *overrides->pattern_for_cr;
-       else
-               lt_settings->pattern_for_cr = decide_cr_training_pattern(link_setting);
        if (overrides->pattern_for_eq != NULL)
                lt_settings->pattern_for_eq = *overrides->pattern_for_eq;
-       else
-               lt_settings->pattern_for_eq = decide_eq_training_pattern(link, link_setting);
 
        if (overrides->enhanced_framing != NULL)
                lt_settings->enhanced_framing = *overrides->enhanced_framing;
-       else
-               lt_settings->enhanced_framing = 1;
 
        if (link->preferred_training_settings.fec_enable != NULL)
                lt_settings->should_set_fec_ready = *link->preferred_training_settings.fec_enable;
-       else
-               lt_settings->should_set_fec_ready = true;
-}
-
-void dp_decide_training_settings(
-               struct dc_link *link,
-               const struct dc_link_settings *link_settings,
-               const struct dc_link_training_overrides *overrides,
-               struct link_training_settings *lt_settings)
-{
-       if (dp_get_link_encoding_format(link_settings) == DP_8b_10b_ENCODING)
-               decide_8b_10b_training_settings(link, link_settings, overrides, lt_settings);
 }
 
-
 uint8_t dp_convert_to_count(uint8_t lttpr_repeater_count)
 {
        switch (lttpr_repeater_count) {
@@ -1581,6 +1566,9 @@ bool dc_link_dp_perform_link_training_skip_aux(
        dp_decide_training_settings(
                        link,
                        link_setting,
+                       &lt_settings);
+       override_training_settings(
+                       link,
                        &link->preferred_training_settings,
                        &lt_settings);
 
@@ -1726,6 +1714,9 @@ enum link_training_result dc_link_dp_perform_link_training(
        dp_decide_training_settings(
                        link,
                        link_settings,
+                       &lt_settings);
+       override_training_settings(
+                       link,
                        &link->preferred_training_settings,
                        &lt_settings);
 
@@ -1940,11 +1931,13 @@ enum link_training_result dc_link_dp_sync_lt_attempt(
        bool fec_enable = false;
 
        dp_decide_training_settings(
-               link,
-               link_settings,
-               lt_overrides,
-               &lt_settings);
-
+                       link,
+                       link_settings,
+                       &lt_settings);
+       override_training_settings(
+                       link,
+                       lt_overrides,
+                       &lt_settings);
        /* Setup MST Mode */
        if (lt_overrides->mst_enable)
                set_dp_mst_mode(link, *lt_overrides->mst_enable);
index e2b58ec..01c3a31 100644 (file)
@@ -174,7 +174,6 @@ bool dp_set_dsc_on_rx(struct pipe_ctx *pipe_ctx, bool enable);
 void dp_decide_training_settings(
        struct dc_link *link,
        const struct dc_link_settings *link_setting,
-       const struct dc_link_training_overrides *overrides,
        struct link_training_settings *lt_settings);
 
 /* Convert PHY repeater count read from DPCD uint8_t. */