[PATCH 031/108] drm/i915/dp_link_caps: Move forced link param helpers to link caps

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

Move the helpers handling forced link parameters to intel_dp_link_caps.c.
Their functionality is part of the link capability logic and will be
updated to use the link capability state in follow-up changes.

Return the forced link rate and lane count through a
struct intel_dp_link_config, which is the canonical way the rest of the
link capability API will also accept and return link configurations.

Signed-off-by: Imre Deak <imre.deak@intel.com>
---
drivers/gpu/drm/i915/display/intel_dp.c | 40 ++++++++++---------
.../gpu/drm/i915/display/intel_dp_link_caps.c | 22 ++++++++++
.../gpu/drm/i915/display/intel_dp_link_caps.h | 5 +++
3 files changed, 48 insertions(+), 19 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c
index 1f903f9acec15..0aab37dcce97a 100644
--- a/drivers/gpu/drm/i915/display/intel_dp.c
+++ b/drivers/gpu/drm/i915/display/intel_dp.c
@@ -353,17 +353,16 @@ int intel_dp_max_common_lane_count(struct intel_dp *intel_dp)
return min3(source_max, sink_max, lane_max);
}

-static int forced_lane_count(struct intel_dp *intel_dp)
-{
- return clamp(intel_dp->link.force_lane_count, 1, intel_dp_max_common_lane_count(intel_dp));
-}
-
int intel_dp_max_lane_count(struct intel_dp *intel_dp)
{
+ struct intel_dp_link_caps *link_caps = intel_dp->link.caps;
+ struct intel_dp_link_config forced_params;
int lane_count;

+ intel_dp_link_caps_get_forced_params(link_caps, &forced_params);
+
if (intel_dp->link.force_lane_count)
- lane_count = forced_lane_count(intel_dp);
+ lane_count = forced_params.lane_count;
else
lane_count = intel_dp->link.max_lane_count;

@@ -380,8 +379,12 @@ int intel_dp_max_lane_count(struct intel_dp *intel_dp)

static int intel_dp_min_lane_count(struct intel_dp *intel_dp)
{
+ struct intel_dp_link_config forced_params;
+
+ intel_dp_link_caps_get_forced_params(intel_dp->link.caps, &forced_params);
+
if (intel_dp->link.force_lane_count)
- return forced_lane_count(intel_dp);
+ return forced_params.lane_count;

return 1;
}
@@ -1657,21 +1660,16 @@ static void intel_dp_print_rates(struct intel_dp *intel_dp)
drm_dbg_kms(display->drm, "common rates: %s\n", seq_buf_str(&s));
}

-static int forced_link_rate(struct intel_dp *intel_dp)
-{
- int len = intel_dp_common_len_rate_limit(intel_dp, intel_dp->link.force_rate);
-
- if (len == 0)
- return intel_dp_common_rate(intel_dp, 0);
-
- return intel_dp_common_rate(intel_dp, len - 1);
-}
-
int
intel_dp_max_link_rate(struct intel_dp *intel_dp)
{
+ struct intel_dp_link_caps *link_caps = intel_dp->link.caps;
+ struct intel_dp_link_config forced_params;
+
+ intel_dp_link_caps_get_forced_params(link_caps, &forced_params);
+
if (intel_dp->link.force_rate)
- return forced_link_rate(intel_dp);
+ return forced_params.rate;

return intel_dp->link.max_rate;
}
@@ -1679,8 +1677,12 @@ intel_dp_max_link_rate(struct intel_dp *intel_dp)
static int
intel_dp_min_link_rate(struct intel_dp *intel_dp)
{
+ struct intel_dp_link_config forced_params;
+
+ intel_dp_link_caps_get_forced_params(intel_dp->link.caps, &forced_params);
+
if (intel_dp->link.force_rate)
- return forced_link_rate(intel_dp);
+ return forced_params.rate;

return intel_dp_common_rate(intel_dp, 0);
}
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 5711dde8d6eed..0a2db7d65e20d 100644
--- a/drivers/gpu/drm/i915/display/intel_dp_link_caps.c
+++ b/drivers/gpu/drm/i915/display/intel_dp_link_caps.c
@@ -41,6 +41,28 @@ int intel_dp_max_common_rate(struct intel_dp *intel_dp)
return intel_dp_common_rate(intel_dp, intel_dp->num_common_rates - 1);
}

+static int forced_lane_count(struct intel_dp *intel_dp)
+{
+ return clamp(intel_dp->link.force_lane_count, 1, intel_dp_max_common_lane_count(intel_dp));
+}
+
+static int forced_link_rate(struct intel_dp *intel_dp)
+{
+ int len = intel_dp_common_len_rate_limit(intel_dp, intel_dp->link.force_rate);
+
+ if (len == 0)
+ return intel_dp_common_rate(intel_dp, 0);
+
+ return intel_dp_common_rate(intel_dp, len - 1);
+}
+
+void intel_dp_link_caps_get_forced_params(struct intel_dp_link_caps *link_caps,
+ struct intel_dp_link_config *forced_params)
+{
+ forced_params->rate = forced_link_rate(link_caps->dp);
+ forced_params->lane_count = forced_lane_count(link_caps->dp);
+}
+
/**
* intel_dp_link_caps_init - allocate and initialize link caps state
* @intel_dp: DP encoder 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 3248777d1287f..61dbce86ee3d0 100644
--- a/drivers/gpu/drm/i915/display/intel_dp_link_caps.h
+++ b/drivers/gpu/drm/i915/display/intel_dp_link_caps.h
@@ -5,12 +5,17 @@
#define __INTEL_DP_LINK_CAPS_H__

struct intel_dp;
+struct intel_dp_link_caps;
+struct intel_dp_link_config;

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_get_forced_params(struct intel_dp_link_caps *link_caps,
+ struct intel_dp_link_config *forced_params);
+
struct intel_dp_link_caps *intel_dp_link_caps_init(struct intel_dp *intel_dp);
void intel_dp_link_caps_cleanup(struct intel_dp_link_caps *link_caps);

--
2.49.1