[PATCH 056/108] drm/i915/dp_link_caps: Pass link_caps to config update/lookup helpers

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

Pass the link_caps pointer to the update/lookup helpers in
intel_dp_link_caps.c, as it holds the state with the relevant
information.

Signed-off-by: Imre Deak <imre.deak@intel.com>
---
drivers/gpu/drm/i915/display/intel_dp.c | 2 +-
drivers/gpu/drm/i915/display/intel_dp_link_caps.c | 14 +++++++-------
drivers/gpu/drm/i915/display/intel_dp_link_caps.h | 8 +++++---
.../gpu/drm/i915/display/intel_dp_link_training.c | 5 +++--
4 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c
index dd4c03893a69f..a3f293af5dbfb 100644
--- a/drivers/gpu/drm/i915/display/intel_dp.c
+++ b/drivers/gpu/drm/i915/display/intel_dp.c
@@ -697,7 +697,7 @@ static bool intel_dp_set_common_link_params(struct intel_dp *intel_dp)
bool link_params_changed = false;

intel_dp_get_common_rates(intel_dp, common_rates, &num_common_rates);
- if (intel_dp_link_caps_update(intel_dp,
+ if (intel_dp_link_caps_update(intel_dp->link.caps,
common_rates, num_common_rates,
intel_dp_max_common_lane_count(intel_dp)))
link_params_changed = true;
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 1f6e391838894..fc569092a4dd6 100644
--- a/drivers/gpu/drm/i915/display/intel_dp_link_caps.c
+++ b/drivers/gpu/drm/i915/display/intel_dp_link_caps.c
@@ -395,10 +395,10 @@ static bool current_common_caps_match(struct intel_dp_link_caps *link_caps,
}

/* Return %true if the supported link parameters have changed. */
-bool intel_dp_link_caps_update(struct intel_dp *intel_dp,
+bool intel_dp_link_caps_update(struct intel_dp_link_caps *link_caps,
const int *rates, int num_rates, int max_lane_count)
{
- struct intel_dp_link_caps *link_caps = intel_dp->link.caps;
+ struct intel_dp *intel_dp = link_caps->dp;
struct intel_display *display = to_intel_display(intel_dp);
struct intel_dp_link_config old_max_limits =
link_caps->max_limits;
@@ -470,10 +470,10 @@ bool intel_dp_link_caps_update(struct intel_dp *intel_dp,
return link_params_changed;
}

-void intel_dp_link_config_get(struct intel_dp *intel_dp, int idx, int *link_rate, int *lane_count)
+void intel_dp_link_config_get(struct intel_dp_link_caps *link_caps,
+ int idx, int *link_rate, int *lane_count)
{
- struct intel_dp_link_caps *link_caps = intel_dp->link.caps;
- struct intel_display *display = to_intel_display(intel_dp);
+ struct intel_display *display = to_intel_display(link_caps->dp);
const struct intel_dp_link_config_entry *lc;

if (drm_WARN_ON(display->drm, idx < 0 || idx >= link_caps->num_configs))
@@ -485,9 +485,9 @@ void intel_dp_link_config_get(struct intel_dp *intel_dp, int idx, int *link_rate
*lane_count = intel_dp_link_config_lane_count(lc);
}

-int intel_dp_link_config_index(struct intel_dp *intel_dp, int link_rate, int lane_count)
+int intel_dp_link_config_index(struct intel_dp_link_caps *link_caps,
+ int link_rate, int lane_count)
{
- struct intel_dp_link_caps *link_caps = intel_dp->link.caps;
int link_rate_idx = intel_dp_rate_index(link_caps->rates, link_caps->num_rates,
link_rate);
int lane_count_exp = ilog2(lane_count);
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 fed8b0ca72ff2..992917505b0d1 100644
--- a/drivers/gpu/drm/i915/display/intel_dp_link_caps.h
+++ b/drivers/gpu/drm/i915/display/intel_dp_link_caps.h
@@ -22,8 +22,10 @@ int intel_dp_link_caps_max_common_lane_count(struct intel_dp_link_caps *link_cap
void intel_dp_link_caps_get_forced_params(struct intel_dp_link_caps *link_caps,
struct intel_dp_link_config *forced_params);

-int intel_dp_link_config_index(struct intel_dp *intel_dp, int link_rate, int lane_count);
-void intel_dp_link_config_get(struct intel_dp *intel_dp, int idx, int *link_rate, int *lane_count);
+int intel_dp_link_config_index(struct intel_dp_link_caps *link_caps,
+ int link_rate, int lane_count);
+void intel_dp_link_config_get(struct intel_dp_link_caps *link_caps,
+ int idx, int *link_rate, int *lane_count);

void intel_dp_link_caps_get_max_limits(struct intel_dp_link_caps *link_caps,
struct intel_dp_link_config *max_link_limits);
@@ -31,7 +33,7 @@ bool intel_dp_link_caps_set_max_limits(struct intel_dp_link_caps *link_caps,
const struct intel_dp_link_config *max_link_limits);
void intel_dp_link_caps_reset_max_limits(struct intel_dp_link_caps *link_caps);

-bool intel_dp_link_caps_update(struct intel_dp *intel_dp,
+bool intel_dp_link_caps_update(struct intel_dp_link_caps *link_caps,
const int *rates, int num_rates, int max_lane_count);
void intel_dp_link_caps_reset(struct intel_dp_link_caps *link_caps);

diff --git a/drivers/gpu/drm/i915/display/intel_dp_link_training.c b/drivers/gpu/drm/i915/display/intel_dp_link_training.c
index 5e60621f4442e..9da8892a80df0 100644
--- a/drivers/gpu/drm/i915/display/intel_dp_link_training.c
+++ b/drivers/gpu/drm/i915/display/intel_dp_link_training.c
@@ -1772,9 +1772,10 @@ static bool reduce_link_params_in_bw_order(struct intel_dp *intel_dp,
forced_rate = forced_params.rate;
forced_lane_count = forced_params.lane_count;

- i = intel_dp_link_config_index(intel_dp, crtc_state->port_clock, crtc_state->lane_count);
+ i = intel_dp_link_config_index(intel_dp->link.caps,
+ crtc_state->port_clock, crtc_state->lane_count);
for (i--; i >= 0; i--) {
- intel_dp_link_config_get(intel_dp, i, &link_rate, &lane_count);
+ intel_dp_link_config_get(intel_dp->link.caps, i, &link_rate, &lane_count);

if ((forced_rate &&
forced_rate != link_rate) ||
--
2.49.1