From: Imre Deak <imre.deak@intel.com>
To: <intel-gfx@lists.freedesktop.org>, <intel-xe@lists.freedesktop.org>
Subject: [PATCH v2 10/28] drm/i915/dp_link_caps: Move link config helpers to link caps
Date: Tue, 16 Jun 2026 23:08:30 +0300 [thread overview]
Message-ID: <20260616200849.3534628-11-imre.deak@intel.com> (raw)
In-Reply-To: <20260616200849.3534628-1-imre.deak@intel.com>
Move the helpers handling link configurations 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.
Signed-off-by: Imre Deak <imre.deak@intel.com>
---
drivers/gpu/drm/i915/display/intel_dp.c | 101 -----------------
drivers/gpu/drm/i915/display/intel_dp.h | 2 -
.../gpu/drm/i915/display/intel_dp_link_caps.c | 102 ++++++++++++++++++
.../gpu/drm/i915/display/intel_dp_link_caps.h | 5 +
4 files changed, 107 insertions(+), 103 deletions(-)
diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c
index c4ad386acc6db..c4b650431eff5 100644
--- a/drivers/gpu/drm/i915/display/intel_dp.c
+++ b/drivers/gpu/drm/i915/display/intel_dp.c
@@ -33,7 +33,6 @@
#include <linux/notifier.h>
#include <linux/seq_buf.h>
#include <linux/slab.h>
-#include <linux/sort.h>
#include <linux/string_helpers.h>
#include <linux/timekeeping.h>
#include <linux/types.h>
@@ -677,106 +676,6 @@ int intel_dp_rate_index(const int *rates, int len, int rate)
return -1;
}
-static int intel_dp_link_config_rate(struct intel_dp *intel_dp,
- const struct intel_dp_link_config_entry *lc)
-{
- return intel_dp_common_rate(intel_dp, lc->link_rate_idx);
-}
-
-static int intel_dp_link_config_lane_count(const struct intel_dp_link_config_entry *lc)
-{
- return 1 << lc->lane_count_exp;
-}
-
-static int intel_dp_link_config_bw(struct intel_dp *intel_dp,
- const struct intel_dp_link_config_entry *lc)
-{
- return drm_dp_max_dprx_data_rate(intel_dp_link_config_rate(intel_dp, lc),
- intel_dp_link_config_lane_count(lc));
-}
-
-static int link_config_cmp_by_bw(const void *a, const void *b, const void *p)
-{
- struct intel_dp *intel_dp = (struct intel_dp *)p; /* remove const */
- const struct intel_dp_link_config_entry *lc_a = a;
- const struct intel_dp_link_config_entry *lc_b = b;
- int bw_a = intel_dp_link_config_bw(intel_dp, lc_a);
- int bw_b = intel_dp_link_config_bw(intel_dp, lc_b);
-
- if (bw_a != bw_b)
- return bw_a - bw_b;
-
- return intel_dp_link_config_rate(intel_dp, lc_a) -
- intel_dp_link_config_rate(intel_dp, lc_b);
-}
-
-static void intel_dp_link_config_init(struct intel_dp *intel_dp)
-{
- struct intel_display *display = to_intel_display(intel_dp);
- struct intel_dp_link_config_entry *lc;
- int num_common_lane_configs;
- int i;
- int j;
-
- if (drm_WARN_ON(display->drm, !is_power_of_2(intel_dp_max_common_lane_count(intel_dp))))
- return;
-
- num_common_lane_configs = ilog2(intel_dp_max_common_lane_count(intel_dp)) + 1;
-
- if (drm_WARN_ON(display->drm, intel_dp->num_common_rates * num_common_lane_configs >
- ARRAY_SIZE(intel_dp->link.configs)))
- return;
-
- intel_dp->link.num_configs = intel_dp->num_common_rates * num_common_lane_configs;
-
- lc = &intel_dp->link.configs[0];
- for (i = 0; i < intel_dp->num_common_rates; i++) {
- for (j = 0; j < num_common_lane_configs; j++) {
- lc->lane_count_exp = j;
- lc->link_rate_idx = i;
-
- lc++;
- }
- }
-
- sort_r(intel_dp->link.configs, intel_dp->link.num_configs,
- sizeof(intel_dp->link.configs[0]),
- link_config_cmp_by_bw, NULL,
- intel_dp);
-}
-
-void intel_dp_link_config_get(struct intel_dp *intel_dp, int idx, int *link_rate, int *lane_count)
-{
- struct intel_display *display = to_intel_display(intel_dp);
- const struct intel_dp_link_config_entry *lc;
-
- if (drm_WARN_ON(display->drm, idx < 0 || idx >= intel_dp->link.num_configs))
- idx = 0;
-
- lc = &intel_dp->link.configs[idx];
-
- *link_rate = intel_dp_link_config_rate(intel_dp, lc);
- *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 link_rate_idx = intel_dp_rate_index(intel_dp->common_rates, intel_dp->num_common_rates,
- link_rate);
- int lane_count_exp = ilog2(lane_count);
- int i;
-
- for (i = 0; i < intel_dp->link.num_configs; i++) {
- const struct intel_dp_link_config_entry *lc = &intel_dp->link.configs[i];
-
- if (lc->lane_count_exp == lane_count_exp &&
- lc->link_rate_idx == link_rate_idx)
- return i;
- }
-
- return -1;
-}
-
/* Return %true if the common rates changed. */
static bool intel_dp_set_common_rates(struct intel_dp *intel_dp)
{
diff --git a/drivers/gpu/drm/i915/display/intel_dp.h b/drivers/gpu/drm/i915/display/intel_dp.h
index 8cc6ea04e000c..fdf9bd88859e7 100644
--- a/drivers/gpu/drm/i915/display/intel_dp.h
+++ b/drivers/gpu/drm/i915/display/intel_dp.h
@@ -108,8 +108,6 @@ int intel_dp_config_required_rate(const struct intel_crtc_state *crtc_state);
int intel_dp_rate_select(struct intel_dp *intel_dp, int rate);
int intel_dp_max_common_lane_count(struct intel_dp *intel_dp);
int intel_dp_rate_index(const int *rates, int len, int rate);
-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);
void intel_dp_update_sink_caps(struct intel_dp *intel_dp);
void intel_dp_reset_link_params(struct intel_dp *intel_dp);
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 8ecdc01af70eb..6a37ba8c35e27 100644
--- a/drivers/gpu/drm/i915/display/intel_dp_link_caps.c
+++ b/drivers/gpu/drm/i915/display/intel_dp_link_caps.c
@@ -4,7 +4,9 @@
*/
#include <linux/debugfs.h>
+#include <linux/log2.h>
#include <linux/slab.h>
+#include <linux/sort.h>
#include <drm/drm_print.h>
@@ -81,6 +83,106 @@ void intel_dp_link_caps_get_forced_params(struct intel_dp_link_caps *link_caps,
forced_params->lane_count = forced_lane_count(link_caps->dp);
}
+static int intel_dp_link_config_rate(struct intel_dp *intel_dp,
+ const struct intel_dp_link_config_entry *lc)
+{
+ return intel_dp_common_rate(intel_dp, lc->link_rate_idx);
+}
+
+static int intel_dp_link_config_lane_count(const struct intel_dp_link_config_entry *lc)
+{
+ return 1 << lc->lane_count_exp;
+}
+
+static int intel_dp_link_config_bw(struct intel_dp *intel_dp,
+ const struct intel_dp_link_config_entry *lc)
+{
+ return drm_dp_max_dprx_data_rate(intel_dp_link_config_rate(intel_dp, lc),
+ intel_dp_link_config_lane_count(lc));
+}
+
+static int link_config_cmp_by_bw(const void *a, const void *b, const void *p)
+{
+ struct intel_dp *intel_dp = (struct intel_dp *)p; /* remove const */
+ const struct intel_dp_link_config_entry *lc_a = a;
+ const struct intel_dp_link_config_entry *lc_b = b;
+ int bw_a = intel_dp_link_config_bw(intel_dp, lc_a);
+ int bw_b = intel_dp_link_config_bw(intel_dp, lc_b);
+
+ if (bw_a != bw_b)
+ return bw_a - bw_b;
+
+ return intel_dp_link_config_rate(intel_dp, lc_a) -
+ intel_dp_link_config_rate(intel_dp, lc_b);
+}
+
+void intel_dp_link_config_init(struct intel_dp *intel_dp)
+{
+ struct intel_display *display = to_intel_display(intel_dp);
+ struct intel_dp_link_config_entry *lc;
+ int num_common_lane_configs;
+ int i;
+ int j;
+
+ if (drm_WARN_ON(display->drm, !is_power_of_2(intel_dp_max_common_lane_count(intel_dp))))
+ return;
+
+ num_common_lane_configs = ilog2(intel_dp_max_common_lane_count(intel_dp)) + 1;
+
+ if (drm_WARN_ON(display->drm, intel_dp->num_common_rates * num_common_lane_configs >
+ ARRAY_SIZE(intel_dp->link.configs)))
+ return;
+
+ intel_dp->link.num_configs = intel_dp->num_common_rates * num_common_lane_configs;
+
+ lc = &intel_dp->link.configs[0];
+ for (i = 0; i < intel_dp->num_common_rates; i++) {
+ for (j = 0; j < num_common_lane_configs; j++) {
+ lc->lane_count_exp = j;
+ lc->link_rate_idx = i;
+
+ lc++;
+ }
+ }
+
+ sort_r(intel_dp->link.configs, intel_dp->link.num_configs,
+ sizeof(intel_dp->link.configs[0]),
+ link_config_cmp_by_bw, NULL,
+ intel_dp);
+}
+
+void intel_dp_link_config_get(struct intel_dp *intel_dp, int idx, int *link_rate, int *lane_count)
+{
+ struct intel_display *display = to_intel_display(intel_dp);
+ const struct intel_dp_link_config_entry *lc;
+
+ if (drm_WARN_ON(display->drm, idx < 0 || idx >= intel_dp->link.num_configs))
+ idx = 0;
+
+ lc = &intel_dp->link.configs[idx];
+
+ *link_rate = intel_dp_link_config_rate(intel_dp, lc);
+ *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 link_rate_idx = intel_dp_rate_index(intel_dp->common_rates, intel_dp->num_common_rates,
+ link_rate);
+ int lane_count_exp = ilog2(lane_count);
+ int i;
+
+ for (i = 0; i < intel_dp->link.num_configs; i++) {
+ const struct intel_dp_link_config_entry *lc = &intel_dp->link.configs[i];
+
+ if (lc->lane_count_exp == lane_count_exp &&
+ lc->link_rate_idx == link_rate_idx)
+ return i;
+ }
+
+ return -1;
+}
+
static int i915_dp_force_link_rate_show(struct seq_file *m, void *data)
{
struct intel_connector *connector = to_intel_connector(m->private);
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 c6a84891db464..dab956e804b95 100644
--- a/drivers/gpu/drm/i915/display/intel_dp_link_caps.h
+++ b/drivers/gpu/drm/i915/display/intel_dp_link_caps.h
@@ -17,6 +17,11 @@ 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);
+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);
+
+void intel_dp_link_config_init(struct intel_dp *intel_dp);
+
void intel_dp_link_caps_debugfs_add(struct intel_connector *connector);
struct intel_dp_link_caps *intel_dp_link_caps_init(struct intel_dp *intel_dp);
--
2.49.1
next prev parent reply other threads:[~2026-06-16 20:09 UTC|newest]
Thread overview: 71+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-16 20:08 [PATCH v2 00/28] drm/i915/dp_link: Refactor DP link capability logic part1 Imre Deak
2026-06-16 20:08 ` [PATCH v2 01/28] drm/i915/dp: Rename intel_dp_link_config to intel_dp_link_config_entry Imre Deak
2026-06-22 13:11 ` Kahola, Mika
2026-06-22 21:53 ` Michał Grzelak
2026-06-24 15:32 ` Imre Deak
2026-06-16 20:08 ` [PATCH v2 02/28] drm/i915/dp: Add struct intel_dp_link_config Imre Deak
2026-06-22 13:11 ` Kahola, Mika
2026-06-16 20:08 ` [PATCH v2 03/28] drm/i915/dp_link_caps: Introduce DP link capability module Imre Deak
2026-06-22 13:21 ` Kahola, Mika
2026-06-16 20:08 ` [PATCH v2 04/28] drm/i915/dp_link_caps: Move common rate helpers to link caps Imre Deak
2026-06-23 7:27 ` Kahola, Mika
2026-06-16 20:08 ` [PATCH v2 05/28] drm/i915/dp_link_caps: Move forced link param " Imre Deak
2026-06-23 9:40 ` Kahola, Mika
2026-06-23 10:22 ` Luca Coelho
2026-06-23 12:42 ` Imre Deak
2026-06-23 12:47 ` Luca Coelho
2026-06-16 20:08 ` [PATCH v2 06/28] drm/i915/dp: Simplify querying of forced link parameters Imre Deak
2026-06-23 9:49 ` Kahola, Mika
2026-06-16 20:08 ` [PATCH v2 07/28] drm/i915/dp_link_caps: Move forced and max link debugfs entries to link caps Imre Deak
2026-06-23 10:28 ` Luca Coelho
2026-06-23 10:29 ` Luca Coelho
2026-06-16 20:08 ` [PATCH v2 08/28] drm/i915/dp_link_training: Use helpers to get forced link params Imre Deak
2026-06-23 10:31 ` Luca Coelho
2026-06-16 20:08 ` [PATCH v2 09/28] drm/i915/dp_link_caps: Move forced link params to link_caps Imre Deak
2026-06-23 10:32 ` Luca Coelho
2026-06-16 20:08 ` Imre Deak [this message]
2026-06-23 10:34 ` [PATCH v2 10/28] drm/i915/dp_link_caps: Move link config helpers to link caps Luca Coelho
2026-06-16 20:08 ` [PATCH v2 11/28] drm/i915/dp_link_caps: Move link config tracking to link_caps Imre Deak
2026-06-23 11:17 ` Kahola, Mika
2026-06-24 11:15 ` Luca Coelho
2026-06-16 20:08 ` [PATCH v2 12/28] drm/i915/dp_link_caps: Rename helper updating the link configurations Imre Deak
2026-06-23 5:11 ` Garg, Nemesa
2026-06-16 20:08 ` [PATCH v2 13/28] drm/i915/dp: Factor out helper to get link rate capabilities Imre Deak
2026-06-24 8:29 ` Kahola, Mika
2026-06-16 20:08 ` [PATCH v2 14/28] drm/i915/dp_link_caps: Pass supported link rates to link caps update Imre Deak
2026-06-24 8:32 ` Kahola, Mika
2026-06-16 20:08 ` [PATCH v2 15/28] drm/i915/dp_link_caps: Add helper to print all supported link rates Imre Deak
2026-06-23 5:21 ` Garg, Nemesa
2026-06-16 20:08 ` [PATCH v2 16/28] drm/i915/dp_link_caps: Add helper to get the number of " Imre Deak
2026-06-24 8:34 ` Kahola, Mika
2026-06-16 20:08 ` [PATCH v2 17/28] drm/i915/dp_link_caps: Add helper to get common rate index Imre Deak
2026-06-24 9:02 ` Kahola, Mika
2026-06-16 20:08 ` [PATCH v2 18/28] drm/i915/dp_link_caps: Move tracking of common rates to link_caps struct Imre Deak
2026-06-24 9:22 ` Kahola, Mika
2026-06-16 20:08 ` [PATCH v2 19/28] drm/i915/dp_link_caps: Track max common lane count in link_caps Imre Deak
2026-06-24 9:46 ` Kahola, Mika
2026-06-16 20:08 ` [PATCH v2 20/28] drm/i915/dp_link_caps: Use max common lane count from link_caps Imre Deak
2026-06-24 11:29 ` Kahola, Mika
2026-06-16 20:08 ` [PATCH v2 21/28] drm/i915/dp_link_caps: Add helpers to get max link limits Imre Deak
2026-06-24 12:44 ` Kahola, Mika
2026-06-16 20:08 ` [PATCH v2 22/28] drm/i915/dp_link_caps: Add helpers to set " Imre Deak
2026-06-24 12:47 ` Kahola, Mika
2026-06-16 20:08 ` [PATCH v2 23/28] drm/i915/dp_link_caps: Add helper to reset " Imre Deak
2026-06-24 12:49 ` Kahola, Mika
2026-06-16 20:08 ` [PATCH v2 24/28] drm/i915/dp_link_caps: Add helper to reset link_caps state Imre Deak
2026-06-24 12:55 ` Kahola, Mika
2026-06-16 20:08 ` [PATCH v2 25/28] drm/i915/dp_link_caps: Move max link limits to link_caps Imre Deak
2026-06-23 5:34 ` Garg, Nemesa
2026-06-16 20:08 ` [PATCH v2 26/28] drm/i915/dp_link_caps: Pass link_caps to static functions Imre Deak
2026-06-23 5:29 ` Garg, Nemesa
2026-06-16 20:08 ` [PATCH v2 27/28] drm/i915/dp_link_caps: Pass link_caps to config update/lookup helpers Imre Deak
2026-06-23 5:25 ` Garg, Nemesa
2026-06-16 20:08 ` [PATCH v2 28/28] drm/i915/dp_link_caps: Pass link_caps to common rate helpers Imre Deak
2026-06-23 5:39 ` Garg, Nemesa
2026-06-16 20:20 ` ✗ CI.checkpatch: warning for drm/i915/dp_link: Refactor DP link capability logic part1 Patchwork
2026-06-16 20:21 ` ✓ CI.KUnit: success " Patchwork
2026-06-16 21:18 ` ✓ Xe.CI.BAT: " Patchwork
2026-06-16 22:58 ` ✓ i915.CI.BAT: " Patchwork
2026-06-17 1:46 ` ✓ Xe.CI.FULL: " Patchwork
2026-06-17 18:08 ` ✓ i915.CI.Full: " Patchwork
2026-06-24 17:13 ` Imre Deak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260616200849.3534628-11-imre.deak@intel.com \
--to=imre.deak@intel.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=intel-xe@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.