[PATCH 039/108] drm/i915/dp: Factor out helper to get link rate capabilities

Imre Deak
2026-04-28T12:53:50Z

Factor out a helper to get the supported link rates. This allows to
gather all the link capabilities and pass these to the link capability
module from a single place. A follow-up change will extend this to
gather and pass the maximum lane count capability in the same way.

Signed-off-by: Imre Deak <imre.deak@intel.com>
---
drivers/gpu/drm/i915/display/intel_dp.c | 44 +++++++++++++++----------
1 file changed, 26 insertions(+), 18 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c
index e0f8dc35574f3..347ea9bbe1ef2 100644
--- a/drivers/gpu/drm/i915/display/intel_dp.c
+++ b/drivers/gpu/drm/i915/display/intel_dp.c
@@ -680,33 +680,41 @@ static bool current_common_caps_match(struct intel_dp *intel_dp,
return true;
}

-/* Return %true if any supported or maximum link param changed. */
-static bool intel_dp_set_common_rates(struct intel_dp *intel_dp)
+static void intel_dp_get_common_rates(struct intel_dp *intel_dp,
+ int common_rates[DP_MAX_SUPPORTED_RATES],
+ int *num_common_rates)
{
struct intel_display *display = to_intel_display(intel_dp);
+
+ drm_WARN_ON(display->drm,
+ !intel_dp->num_source_rates || !intel_dp->num_sink_rates);
+
+ *num_common_rates = intersect_rates(intel_dp->source_rates,
+ intel_dp->num_source_rates,
+ intel_dp->sink_rates,
+ intel_dp->num_sink_rates,
+ common_rates);
+
+ /* Paranoia, there should always be something in common. */
+ if (drm_WARN_ON(display->drm, *num_common_rates == 0)) {
+ common_rates[0] = 162000;
+ *num_common_rates = 1;
+ }
+}
+
+/* Return %true if any supported or maximum link param changed. */
+static bool intel_dp_set_common_link_params(struct intel_dp *intel_dp)
+{
int num_old_common_rates = intel_dp->num_common_rates;
int old_max_rate_limit = intel_dp->link.max_rate;
int old_common_rates[DP_MAX_SUPPORTED_RATES];
bool link_params_changed = false;
int len;

- drm_WARN_ON(display->drm,
- !intel_dp->num_source_rates || !intel_dp->num_sink_rates);
-
static_assert(sizeof(old_common_rates) == sizeof(intel_dp->common_rates));
memcpy(old_common_rates, intel_dp->common_rates, sizeof(old_common_rates));

- intel_dp->num_common_rates = intersect_rates(intel_dp->source_rates,
- intel_dp->num_source_rates,
- intel_dp->sink_rates,
- intel_dp->num_sink_rates,
- intel_dp->common_rates);
-
- /* Paranoia, there should always be something in common. */
- if (drm_WARN_ON(display->drm, intel_dp->num_common_rates == 0)) {
- intel_dp->common_rates[0] = 162000;
- intel_dp->num_common_rates = 1;
- }
+ intel_dp_get_common_rates(intel_dp, intel_dp->common_rates, &intel_dp->num_common_rates);

if (!current_common_caps_match(intel_dp, old_common_rates, num_old_common_rates))
link_params_changed = true;
@@ -4752,7 +4760,7 @@ void intel_dp_update_sink_caps(struct intel_dp *intel_dp)

intel_dp_set_sink_rates(intel_dp);
intel_dp_set_max_sink_lane_count(intel_dp);
- if (intel_dp_set_common_rates(intel_dp))
+ if (intel_dp_set_common_link_params(intel_dp))
link_params_changed = true;

current_max_common_lane_count = intel_dp_max_common_lane_count(intel_dp);
@@ -7039,7 +7047,7 @@ intel_dp_init_connector(struct intel_digital_port *dig_port,
}

intel_dp_set_source_rates(intel_dp);
- intel_dp_set_common_rates(intel_dp);
+ intel_dp_set_common_link_params(intel_dp);
intel_dp_reset_link_params(intel_dp);

/* init MST on ports that can support it */
--
2.49.1