[PATCH 041/108] drm/i915/dp_link_caps: Add helper to get all supported link rates

Imre Deak
2026-04-28T12:54:39Z

Add intel_dp_link_caps_all_common_rates() to return all supported link
rates tracked by the link_caps module. This prepares for tracking
these capabilities internally within the link caps module.

Signed-off-by: Imre Deak <imre.deak@intel.com>
---
drivers/gpu/drm/i915/display/intel_dp.c | 6 ++++-
.../gpu/drm/i915/display/intel_dp_link_caps.c | 23 +++++++++++++++++++
.../gpu/drm/i915/display/intel_dp_link_caps.h | 2 ++
3 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c
index febcf413bb63b..d92160c522f93 100644
--- a/drivers/gpu/drm/i915/display/intel_dp.c
+++ b/drivers/gpu/drm/i915/display/intel_dp.c
@@ -1531,6 +1531,8 @@ static void intel_dp_print_rates(struct intel_dp *intel_dp)
{
struct intel_display *display = to_intel_display(intel_dp);
DECLARE_SEQ_BUF(s, 128); /* FIXME: too big for stack? */
+ const int *common_rates;
+ int num_common_rates;

if (!drm_debug_enabled(DRM_UT_KMS))
return;
@@ -1543,7 +1545,9 @@ static void intel_dp_print_rates(struct intel_dp *intel_dp)
drm_dbg_kms(display->drm, "sink rates: %s\n", seq_buf_str(&s));

seq_buf_clear(&s);
- seq_buf_print_array(&s, intel_dp->common_rates, intel_dp->num_common_rates);
+ intel_dp_link_caps_all_common_rates(intel_dp->link.caps,
+ &common_rates, &num_common_rates);
+ seq_buf_print_array(&s, common_rates, num_common_rates);
drm_dbg_kms(display->drm, "common rates: %s\n", seq_buf_str(&s));
}

diff --git a/drivers/gpu/drm/i915/display/intel_dp_link_caps.c b/drivers/gpu/drm/i915/display/intel_dp_link_caps.c
index 9f8b7da98305f..94a643b6e68b6 100644
--- a/drivers/gpu/drm/i915/display/intel_dp_link_caps.c
+++ b/drivers/gpu/drm/i915/display/intel_dp_link_caps.c
@@ -66,6 +66,29 @@ int intel_dp_max_common_rate(struct intel_dp *intel_dp)
return intel_dp_common_rate(intel_dp, intel_dp->num_common_rates - 1);
}

+/**
+ * intel_dp_link_caps_all_common_rates - get all common link rates
+ * @link_caps: link capabilities state
+ * @rates: returned pointer to the common rate array
+ * @num_rates: returned number of entries in @rates
+ *
+ * Return all link rates through @rates and @num_rates that are currently
+ * supported by @link_caps, common to both the source and the sink. The
+ * returned array is owned by @link_caps.
+ *
+ * Besides the usual locking requirement for API access, the caller must
+ * also serialize any dereference of the returned array against concurrent
+ * updates to @link_caps.
+ */
+void intel_dp_link_caps_all_common_rates(struct intel_dp_link_caps *link_caps,
+ const int **rates, int *num_rates)
+{
+ struct intel_dp *intel_dp = link_caps->dp;
+
+ *rates = intel_dp->common_rates;
+ *num_rates = intel_dp->num_common_rates;
+}
+
static int forced_lane_count(struct intel_dp *intel_dp)
{
struct intel_dp_link_caps *link_caps = intel_dp->link.caps;
diff --git a/drivers/gpu/drm/i915/display/intel_dp_link_caps.h b/drivers/gpu/drm/i915/display/intel_dp_link_caps.h
index 09e580bc5c9b3..636a1d16dbb47 100644
--- a/drivers/gpu/drm/i915/display/intel_dp_link_caps.h
+++ b/drivers/gpu/drm/i915/display/intel_dp_link_caps.h
@@ -15,6 +15,8 @@ int intel_dp_common_len_rate_limit(const struct intel_dp *intel_dp,
int max_rate);
int intel_dp_common_rate(struct intel_dp *intel_dp, int index);
int intel_dp_max_common_rate(struct intel_dp *intel_dp);
+void intel_dp_link_caps_all_common_rates(struct intel_dp_link_caps *link_caps,
+ const int **rates, int *num_rates);

void intel_dp_link_caps_get_forced_params(struct intel_dp_link_caps *link_caps,
struct intel_dp_link_config *forced_params);
--
2.49.1