From: Kory Maincent <kory.maincent@bootlin.com>
To: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>,
David Airlie <airlied@gmail.com>,
Simona Vetter <simona@ffwll.ch>,
Jani Nikula <jani.nikula@linux.intel.com>,
Rodrigo Vivi <rodrigo.vivi@intel.com>,
Joonas Lahtinen <joonas.lahtinen@linux.intel.com>,
Tvrtko Ursulin <tursulin@ursulin.net>
Cc: Louis Chauvet <louis.chauvet@bootlin.com>,
Luca Ceresoli <luca.ceresoli@bootlin.com>,
Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
Mark Yacoub <markyacoub@google.com>,
Sean Paul <seanpaul@google.com>,
Manasi Navare <navaremanasi@google.com>,
Drew Davenport <ddavenport@google.com>,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org,
Kory Maincent <kory.maincent@bootlin.com>
Subject: [PATCH v2 04/10] drm/dp: Move supported 128b/132b link rates helper out of i915
Date: Wed, 25 Nov 2026 15:01:08 +0100 [thread overview]
Message-ID: <20261125-feat_move_i915_helper-v2-4-aa04d39bc415@bootlin.com> (raw)
In-Reply-To: <20261125-feat_move_i915_helper-v2-0-aa04d39bc415@bootlin.com>
Move the drm_dp_get_128b132b_link_rates() helper from the i915 driver
into the generic DRM helpers. It limits the UHBR rate mask by the
capabilities of the DP tunnel and of the LTTPRs, if any is present,
then expands the remaining rates in ascending order.
Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>
---
drivers/gpu/drm/display/drm_dp_helper.c | 52 +++++++++++++++++++++++++++++++++
drivers/gpu/drm/i915/display/intel_dp.c | 25 +++-------------
include/drm/display/drm_dp.h | 2 ++
include/drm/display/drm_dp_helper.h | 4 +++
4 files changed, 62 insertions(+), 21 deletions(-)
diff --git a/drivers/gpu/drm/display/drm_dp_helper.c b/drivers/gpu/drm/display/drm_dp_helper.c
index c92d89ecf96e4..a0afb5eff5bb4 100644
--- a/drivers/gpu/drm/display/drm_dp_helper.c
+++ b/drivers/gpu/drm/display/drm_dp_helper.c
@@ -4949,3 +4949,55 @@ bool drm_dprx_supports_128b132b(const struct drm_dp_tunnel *tunnel,
return drm_dp_128b132b_supported(dpcd);
}
EXPORT_SYMBOL_GPL(drm_dprx_supports_128b132b);
+
+/**
+ * drm_dp_get_128b132b_link_rates() - get the supported 128b/132b link rates
+ * @lttpr_common_caps: LTTPR common capabilities
+ * @tunnel: DP tunnel object (NULL if not supported)
+ * @uhbr_rates: UHBR rate mask read from the DPCD
+ * DP_128B132B_SUPPORTED_LINK_RATES register
+ * @link_rates: Buffer of DP_MAX_128B132B_SUPPORTED_RATES entries to store the
+ * resulting link rates
+ *
+ * Limit the UHBR rate mask @uhbr_rates by the capabilities of the DP tunnel
+ * and of the LTTPRs, if any is present, then expand the remaining rates into
+ * @link_rates in ascending order.
+ *
+ * Returns: The number of link rates stored in @link_rates.
+ */
+int
+drm_dp_get_128b132b_link_rates(const u8 lttpr_common_caps[DP_LTTPR_COMMON_CAP_SIZE],
+ const struct drm_dp_tunnel *tunnel,
+ u8 uhbr_rates,
+ int link_rates[DP_MAX_128B132B_SUPPORTED_RATES])
+{
+ int i = 0;
+
+ if (tunnel)
+ uhbr_rates = drm_dprx_128b132b_link_rates(tunnel, uhbr_rates);
+
+ if (lttpr_common_caps && drm_dp_lttpr_count(lttpr_common_caps) > 0) {
+ /* We have a repeater */
+ if (lttpr_common_caps[0] >= DP_LTTPR_REV_SUP_128B132B &&
+ dp_lttpr_common_cap(lttpr_common_caps,
+ DP_MAIN_LINK_CHANNEL_CODING_PHY_REPEATER) &
+ DP_PHY_REPEATER_128B132B_SUPPORTED) {
+ /* Repeater supports 128b/132b, valid UHBR rates */
+ uhbr_rates &= dp_lttpr_common_cap(lttpr_common_caps,
+ DP_PHY_REPEATER_128B132B_RATES);
+ } else {
+ /* Does not support 128b/132b */
+ uhbr_rates = 0;
+ }
+ }
+
+ if (uhbr_rates & DP_UHBR10)
+ link_rates[i++] = 1000000;
+ if (uhbr_rates & DP_UHBR13_5)
+ link_rates[i++] = 1350000;
+ if (uhbr_rates & DP_UHBR20)
+ link_rates[i++] = 2000000;
+
+ return i;
+}
+EXPORT_SYMBOL_GPL(drm_dp_get_128b132b_link_rates);
diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c
index 2ba89fee097d6..7ef06e68878d4 100644
--- a/drivers/gpu/drm/i915/display/intel_dp.c
+++ b/drivers/gpu/drm/i915/display/intel_dp.c
@@ -233,27 +233,10 @@ static void intel_dp_set_dpcd_sink_rates(struct intel_dp *intel_dp)
uhbr_rates = drm_dprx_128b132b_link_rates(intel_dp->tunnel, uhbr_rates);
- if (drm_dp_lttpr_count(intel_dp->lttpr_common_caps)) {
- /* We have a repeater */
- if (intel_dp->lttpr_common_caps[0] >= 0x20 &&
- intel_dp->lttpr_common_caps[DP_MAIN_LINK_CHANNEL_CODING_PHY_REPEATER -
- DP_LT_TUNABLE_PHY_REPEATER_FIELD_DATA_STRUCTURE_REV] &
- DP_PHY_REPEATER_128B132B_SUPPORTED) {
- /* Repeater supports 128b/132b, valid UHBR rates */
- uhbr_rates &= intel_dp->lttpr_common_caps[DP_PHY_REPEATER_128B132B_RATES -
- DP_LT_TUNABLE_PHY_REPEATER_FIELD_DATA_STRUCTURE_REV];
- } else {
- /* Does not support 128b/132b */
- uhbr_rates = 0;
- }
- }
-
- if (uhbr_rates & DP_UHBR10)
- intel_dp->sink_rates[i++] = 1000000;
- if (uhbr_rates & DP_UHBR13_5)
- intel_dp->sink_rates[i++] = 1350000;
- if (uhbr_rates & DP_UHBR20)
- intel_dp->sink_rates[i++] = 2000000;
+ i += drm_dp_get_128b132b_link_rates(intel_dp->lttpr_common_caps,
+ intel_dp->tunnel,
+ uhbr_rates,
+ &intel_dp->sink_rates[i]);
}
intel_dp->num_sink_rates = i;
diff --git a/include/drm/display/drm_dp.h b/include/drm/display/drm_dp.h
index a2a7338552e13..6efacff09567c 100644
--- a/include/drm/display/drm_dp.h
+++ b/include/drm/display/drm_dp.h
@@ -1228,6 +1228,7 @@
# define DP_UHBR10 (1 << 0)
# define DP_UHBR20 (1 << 1)
# define DP_UHBR13_5 (1 << 2)
+# define DP_MAX_128B132B_SUPPORTED_RATES 3
#define DP_128B132B_TRAINING_AUX_RD_INTERVAL 0x2216 /* 2.0 */
# define DP_128B132B_TRAINING_AUX_RD_INTERVAL_1MS_UNIT (1 << 7)
@@ -1528,6 +1529,7 @@
/* LTTPR: Link Training (LT)-tunable PHY Repeaters */
#define DP_LT_TUNABLE_PHY_REPEATER_FIELD_DATA_STRUCTURE_REV 0xf0000 /* 1.3 */
+#define DP_LTTPR_REV_SUP_128B132B 0x20
#define DP_MAX_LINK_RATE_PHY_REPEATER 0xf0001 /* 1.4a */
#define DP_PHY_REPEATER_CNT 0xf0002 /* 1.3 */
#define DP_PHY_REPEATER_MODE 0xf0003 /* 1.3 */
diff --git a/include/drm/display/drm_dp_helper.h b/include/drm/display/drm_dp_helper.h
index b67bb06f6e07e..a8c382a2c916f 100644
--- a/include/drm/display/drm_dp_helper.h
+++ b/include/drm/display/drm_dp_helper.h
@@ -708,6 +708,10 @@ u8 drm_dprx_128b132b_link_rates(const struct drm_dp_tunnel *tunnel,
u8 uhbr_rates);
bool drm_dprx_supports_128b132b(const struct drm_dp_tunnel *tunnel,
const u8 dpcd[DP_RECEIVER_CAP_SIZE]);
+int drm_dp_get_128b132b_link_rates(const u8 lttpr_common_caps[DP_LTTPR_COMMON_CAP_SIZE],
+ const struct drm_dp_tunnel *tunnel,
+ u8 uhbr_rates,
+ int link_rates[DP_MAX_128B132B_SUPPORTED_RATES]);
int drm_dp_dpcd_read_link_status(struct drm_dp_aux *aux,
u8 status[DP_LINK_STATUS_SIZE]);
--
2.43.0
next prev parent reply other threads:[~2026-11-25 14:01 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 14:01 [PATCH v2 00/10] Move DRM helpers out of i915 driver Kory Maincent
2026-11-25 14:01 ` [PATCH v2 01/10] drm/dp: Move max DPRX link rate helper out of i915 Kory Maincent
2026-11-25 14:01 ` [PATCH v2 02/10] drm/dp: Move DPRX 128b/132b link rates " Kory Maincent
2026-11-25 14:01 ` [PATCH v2 03/10] drm/dp: Move DPRX 128b/132b support " Kory Maincent
2026-11-25 14:01 ` Kory Maincent [this message]
2026-11-25 14:01 ` [PATCH v2 05/10] drm/dp: Move DP sink link rates reading " Kory Maincent
2026-11-25 14:01 ` [PATCH v2 06/10] drm/dp: Make the DPRX link rates helpers static Kory Maincent
2026-11-25 14:01 ` [PATCH v2 07/10] drm/dp: Add drm_dp_read_dpcd_supported_link_rates() helper Kory Maincent
2026-11-25 14:01 ` [PATCH v2 08/10] drm/dp: Move eDP sink link rates reading helper out of i915 Kory Maincent
2026-11-25 14:01 ` [PATCH v2 09/10] drm/dp: Make the eDP supported link rates helper static Kory Maincent
2026-11-25 14:01 ` [PATCH v2 10/10] drm: Move DSC capability reading helper out of i915 Kory Maincent
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=20261125-feat_move_i915_helper-v2-4-aa04d39bc415@bootlin.com \
--to=kory.maincent@bootlin.com \
--cc=airlied@gmail.com \
--cc=ddavenport@google.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=jani.nikula@linux.intel.com \
--cc=joonas.lahtinen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=louis.chauvet@bootlin.com \
--cc=luca.ceresoli@bootlin.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=markyacoub@google.com \
--cc=mripard@kernel.org \
--cc=navaremanasi@google.com \
--cc=rodrigo.vivi@intel.com \
--cc=seanpaul@google.com \
--cc=simona@ffwll.ch \
--cc=thomas.petazzoni@bootlin.com \
--cc=tursulin@ursulin.net \
--cc=tzimmermann@suse.de \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®