[PATCH 042/108] drm/i915/dp_link_caps: Add helper to get the number of supported link rates

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

Add intel_dp_link_caps_num_common_rates() to return the number of
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 | 4 ++--
drivers/gpu/drm/i915/display/intel_dp_link_caps.c | 5 +++++
drivers/gpu/drm/i915/display/intel_dp_link_caps.h | 1 +
3 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c
index d92160c522f93..666bb8e51f59e 100644
--- a/drivers/gpu/drm/i915/display/intel_dp.c
+++ b/drivers/gpu/drm/i915/display/intel_dp.c
@@ -1768,7 +1768,7 @@ intel_dp_compute_link_config_wide(struct intel_dp *intel_dp,
int link_bpp_x16 =
intel_dp_output_format_link_bpp_x16(pipe_config->output_format, bpp);

- for (i = 0; i < intel_dp->num_common_rates; i++) {
+ for (i = 0; i < intel_dp_link_caps_num_common_rates(intel_dp->link.caps); i++) {
link_rate = intel_dp_common_rate(intel_dp, i);
if (link_rate < limits->min_rate ||
link_rate > limits->max_rate)
@@ -1997,7 +1997,7 @@ static int dsc_compute_link_config(struct intel_dp *intel_dp,
int link_rate, lane_count;
int i;

- for (i = 0; i < intel_dp->num_common_rates; i++) {
+ for (i = 0; i < intel_dp_link_caps_num_common_rates(intel_dp->link.caps); i++) {
link_rate = intel_dp_common_rate(intel_dp, i);
if (link_rate < limits->min_rate || link_rate > limits->max_rate)
continue;
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 94a643b6e68b6..b1b78e7cda897 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,11 @@ int intel_dp_max_common_rate(struct intel_dp *intel_dp)
return intel_dp_common_rate(intel_dp, intel_dp->num_common_rates - 1);
}

+int intel_dp_link_caps_num_common_rates(struct intel_dp_link_caps *link_caps)
+{
+ return link_caps->dp->num_common_rates;
+}
+
/**
* intel_dp_link_caps_all_common_rates - get all common link rates
* @link_caps: link capabilities state
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 636a1d16dbb47..b2eb61272652e 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,7 @@ 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);
+int intel_dp_link_caps_num_common_rates(struct intel_dp_link_caps *link_caps);
void intel_dp_link_caps_all_common_rates(struct intel_dp_link_caps *link_caps,
const int **rates, int *num_rates);

--
2.49.1