Commit 1bc6c29f authored by Wenjing Liu's avatar Wenjing Liu Committed by Alex Deucher

drm/amd/display: isolate link training setting override to its own function

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: default avatarWenjing Liu <wenjing.liu@amd.com>
Reviewed-by: default avatarGeorge Shen <George.Shen@amd.com>
Acked-by: default avatarRodrigo Siqueira <Rodrigo.Siqueira@amd.com>
Tested-by: default avatarDaniel Wheeler <daniel.wheeler@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 4d9f771e
...@@ -1241,29 +1241,15 @@ enum link_training_result dp_check_link_loss_status( ...@@ -1241,29 +1241,15 @@ enum link_training_result dp_check_link_loss_status(
static inline void decide_8b_10b_training_settings( static inline void decide_8b_10b_training_settings(
struct dc_link *link, struct dc_link *link,
const struct dc_link_settings *link_setting, const struct dc_link_settings *link_setting,
const struct dc_link_training_overrides *overrides,
struct link_training_settings *lt_settings) struct link_training_settings *lt_settings)
{ {
uint32_t lane;
memset(lt_settings, '\0', sizeof(struct link_training_settings)); memset(lt_settings, '\0', sizeof(struct link_training_settings));
/* Initialize link settings */ /* Initialize link settings */
lt_settings->link_settings.use_link_rate_set = link_setting->use_link_rate_set; 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; lt_settings->link_settings.link_rate_set = link_setting->link_rate_set;
lt_settings->link_settings.link_rate = link_setting->link_rate;
if (link->preferred_link_setting.link_rate != LINK_RATE_UNKNOWN) lt_settings->link_settings.lane_count = link_setting->lane_count;
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*/
/* TODO hard coded to SS for now /* TODO hard coded to SS for now
* lt_settings.link_settings.link_spread = * lt_settings.link_settings.link_spread =
* dal_display_path_is_ss_supported( * dal_display_path_is_ss_supported(
...@@ -1271,30 +1257,52 @@ static inline void decide_8b_10b_training_settings( ...@@ -1271,30 +1257,52 @@ static inline void decide_8b_10b_training_settings(
* LINK_SPREAD_05_DOWNSPREAD_30KHZ : * LINK_SPREAD_05_DOWNSPREAD_30KHZ :
* LINK_SPREAD_DISABLED; * LINK_SPREAD_DISABLED;
*/ */
/* Initialize link spread */ lt_settings->link_settings.link_spread = link->dp_ss_off ?
if (link->dp_ss_off) LINK_SPREAD_DISABLED : LINK_SPREAD_05_DOWNSPREAD_30KHZ;
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->lttpr_mode = link->lttpr_mode; 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) if (overrides->voltage_swing != NULL)
lt_settings->voltage_swing = overrides->voltage_swing; lt_settings->voltage_swing = overrides->voltage_swing;
if (overrides->pre_emphasis != NULL) if (overrides->pre_emphasis != NULL)
lt_settings->pre_emphasis = overrides->pre_emphasis; lt_settings->pre_emphasis = overrides->pre_emphasis;
if (overrides->post_cursor2 != NULL) if (overrides->post_cursor2 != NULL)
lt_settings->post_cursor2 = overrides->post_cursor2; lt_settings->post_cursor2 = overrides->post_cursor2;
/* Initialize lane settings (VS/PE/PC2) */
for (lane = 0; lane < LANE_COUNT_DP_MAX; lane++) { for (lane = 0; lane < LANE_COUNT_DP_MAX; lane++) {
lt_settings->lane_settings[lane].VOLTAGE_SWING = lt_settings->lane_settings[lane].VOLTAGE_SWING =
lt_settings->voltage_swing != NULL ? lt_settings->voltage_swing != NULL ?
...@@ -1313,45 +1321,22 @@ static inline void decide_8b_10b_training_settings( ...@@ -1313,45 +1321,22 @@ static inline void decide_8b_10b_training_settings(
/* Initialize training timings */ /* Initialize training timings */
if (overrides->cr_pattern_time != NULL) if (overrides->cr_pattern_time != NULL)
lt_settings->cr_pattern_time = *overrides->cr_pattern_time; 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) if (overrides->eq_pattern_time != NULL)
lt_settings->eq_pattern_time = *overrides->eq_pattern_time; 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) if (overrides->pattern_for_cr != NULL)
lt_settings->pattern_for_cr = *overrides->pattern_for_cr; 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) if (overrides->pattern_for_eq != NULL)
lt_settings->pattern_for_eq = *overrides->pattern_for_eq; 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) if (overrides->enhanced_framing != NULL)
lt_settings->enhanced_framing = *overrides->enhanced_framing; lt_settings->enhanced_framing = *overrides->enhanced_framing;
else
lt_settings->enhanced_framing = 1;
if (link->preferred_training_settings.fec_enable != NULL) if (link->preferred_training_settings.fec_enable != NULL)
lt_settings->should_set_fec_ready = *link->preferred_training_settings.fec_enable; 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) uint8_t dp_convert_to_count(uint8_t lttpr_repeater_count)
{ {
switch (lttpr_repeater_count) { switch (lttpr_repeater_count) {
...@@ -1581,6 +1566,9 @@ bool dc_link_dp_perform_link_training_skip_aux( ...@@ -1581,6 +1566,9 @@ bool dc_link_dp_perform_link_training_skip_aux(
dp_decide_training_settings( dp_decide_training_settings(
link, link,
link_setting, link_setting,
&lt_settings);
override_training_settings(
link,
&link->preferred_training_settings, &link->preferred_training_settings,
&lt_settings); &lt_settings);
...@@ -1726,6 +1714,9 @@ enum link_training_result dc_link_dp_perform_link_training( ...@@ -1726,6 +1714,9 @@ enum link_training_result dc_link_dp_perform_link_training(
dp_decide_training_settings( dp_decide_training_settings(
link, link,
link_settings, link_settings,
&lt_settings);
override_training_settings(
link,
&link->preferred_training_settings, &link->preferred_training_settings,
&lt_settings); &lt_settings);
...@@ -1940,11 +1931,13 @@ enum link_training_result dc_link_dp_sync_lt_attempt( ...@@ -1940,11 +1931,13 @@ enum link_training_result dc_link_dp_sync_lt_attempt(
bool fec_enable = false; bool fec_enable = false;
dp_decide_training_settings( dp_decide_training_settings(
link, link,
link_settings, link_settings,
lt_overrides, &lt_settings);
&lt_settings); override_training_settings(
link,
lt_overrides,
&lt_settings);
/* Setup MST Mode */ /* Setup MST Mode */
if (lt_overrides->mst_enable) if (lt_overrides->mst_enable)
set_dp_mst_mode(link, *lt_overrides->mst_enable); set_dp_mst_mode(link, *lt_overrides->mst_enable);
......
...@@ -174,7 +174,6 @@ bool dp_set_dsc_on_rx(struct pipe_ctx *pipe_ctx, bool enable); ...@@ -174,7 +174,6 @@ bool dp_set_dsc_on_rx(struct pipe_ctx *pipe_ctx, bool enable);
void dp_decide_training_settings( void dp_decide_training_settings(
struct dc_link *link, struct dc_link *link,
const struct dc_link_settings *link_setting, const struct dc_link_settings *link_setting,
const struct dc_link_training_overrides *overrides,
struct link_training_settings *lt_settings); struct link_training_settings *lt_settings);
/* Convert PHY repeater count read from DPCD uint8_t. */ /* Convert PHY repeater count read from DPCD uint8_t. */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment