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 05/10] drm/dp: Move DP sink link rates reading helper out of i915
Date: Wed, 25 Nov 2026 15:01:09 +0100 [thread overview]
Message-ID: <20261125-feat_move_i915_helper-v2-5-aa04d39bc415@bootlin.com> (raw)
In-Reply-To: <20261125-feat_move_i915_helper-v2-0-aa04d39bc415@bootlin.com>
Move the DP sink link rates reading function out of the i915 driver
into the generic DRM helpers. This function provides everything needed
to properly extract link rate capabilities from the DPCD, limited by
the capabilities of the LTTPRs or the DP tunnel when present.
No functional change intended.
Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>
---
drivers/gpu/drm/display/drm_dp_helper.c | 89 +++++++++++++++++++++++++++++++++
drivers/gpu/drm/i915/display/intel_dp.c | 82 ++++++++----------------------
include/drm/display/drm_dp.h | 1 +
include/drm/display/drm_dp_helper.h | 8 +++
4 files changed, 118 insertions(+), 62 deletions(-)
diff --git a/drivers/gpu/drm/display/drm_dp_helper.c b/drivers/gpu/drm/display/drm_dp_helper.c
index a0afb5eff5bb4..e06264c52bf5e 100644
--- a/drivers/gpu/drm/display/drm_dp_helper.c
+++ b/drivers/gpu/drm/display/drm_dp_helper.c
@@ -5001,3 +5001,92 @@ drm_dp_get_128b132b_link_rates(const u8 lttpr_common_caps[DP_LTTPR_COMMON_CAP_SI
return i;
}
EXPORT_SYMBOL_GPL(drm_dp_get_128b132b_link_rates);
+
+/**
+ * drm_dp_read_dpcd_sink_rates() - read the sink rates from the DPCD
+ * @aux: DisplayPort AUX channel
+ * @dpcd: DPCD receiver capabilities
+ * @lttpr_common_caps: LTTPR common capabilities
+ * @desc: DisplayPort sink descriptor
+ * @tunnel: Tunnel object (NULL if not supported)
+ * @sink_rates: Array of DP_MAX_SUPPORTED_RATES entries to store the sink rates
+ *
+ * Read the link rates supported by a DisplayPort sink from the DPCD
+ * DP_MAX_LINK_RATE and DP_128B132B_SUPPORTED_LINK_RATES registers, limited by
+ * the capabilities of the LTTPRs or the tunnel if any is present.
+ * The rates are stored in @sink_rates in ascending order.
+ *
+ * The DPCD receiver capabilities, the LTTPR common capabilities, the tunnel
+ * and the sink descriptor are passed by the caller instead of being read
+ * from the DPCD. Drivers which already read them, like i915, can pass them
+ * to avoid duplicate DPCD reads.
+ *
+ * Returns: The number of supported sink rates.
+ */
+int drm_dp_read_dpcd_sink_rates(struct drm_dp_aux *aux,
+ const u8 dpcd[DP_RECEIVER_CAP_SIZE],
+ const u8 lttpr_common_caps[DP_LTTPR_COMMON_CAP_SIZE],
+ const struct drm_dp_desc *desc,
+ const struct drm_dp_tunnel *tunnel,
+ int sink_rates[DP_MAX_SUPPORTED_RATES])
+{
+ static const int dp_rates[] = {
+ 162000, 270000, 540000, 810000
+ };
+ int max_rate, max_lttpr_rate = 0, ret, i;
+ u8 uhbr_rates = 0;
+
+ BUILD_BUG_ON(ARRAY_SIZE(dp_rates) + DP_MAX_128B132B_SUPPORTED_RATES >
+ DP_MAX_SUPPORTED_RATES);
+
+ if (drm_dp_has_quirk(desc, DP_DPCD_QUIRK_CAN_DO_MAX_LINK_RATE_3_24_GBPS)) {
+ /* Needed, e.g., for Apple MBP 2017, 15 inch eDP Retina panel */
+ static const int quirk_rates[] = { 162000, 270000, 324000 };
+
+ memcpy(sink_rates, quirk_rates, sizeof(quirk_rates));
+
+ return ARRAY_SIZE(quirk_rates);
+ }
+
+ /*
+ * Sink rates for 8b/10b.
+ */
+ max_rate = drm_dprx_max_rate(tunnel, dpcd);
+ if (lttpr_common_caps && lttpr_common_caps[0] >= DP_LTTPR_REV_SUP_8B10B)
+ max_lttpr_rate = drm_dp_lttpr_max_link_rate(lttpr_common_caps);
+
+ if (max_lttpr_rate)
+ max_rate = min(max_rate, max_lttpr_rate);
+
+ for (i = 0; i < ARRAY_SIZE(dp_rates); i++) {
+ if (dp_rates[i] > max_rate)
+ break;
+ sink_rates[i] = dp_rates[i];
+ }
+
+ /*
+ * The following register must be read unconditionally for the later
+ * DP tunnel 128b132b detection to work, see DP Standard v2.1 5.14.3 .
+ */
+ ret = drm_dp_dpcd_read_byte(aux, DP_128B132B_SUPPORTED_LINK_RATES,
+ &uhbr_rates);
+ if (ret < 0) {
+ drm_dbg_kms(aux->drm_dev,
+ "%s: Failed to read DPCD 128B/132B supported link rates (%d)\n",
+ aux->name, ret);
+ uhbr_rates = 0;
+ }
+
+ /*
+ * Sink rates for 128b/132b. If set, sink should support all 8b/10b
+ * rates and 10 Gbps.
+ */
+ if (drm_dprx_supports_128b132b(tunnel, dpcd))
+ i += drm_dp_get_128b132b_link_rates(lttpr_common_caps,
+ tunnel,
+ uhbr_rates,
+ &sink_rates[i]);
+
+ return i;
+}
+EXPORT_SYMBOL_GPL(drm_dp_read_dpcd_sink_rates);
diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c
index 7ef06e68878d4..8fee2d195c944 100644
--- a/drivers/gpu/drm/i915/display/intel_dp.c
+++ b/drivers/gpu/drm/i915/display/intel_dp.c
@@ -176,70 +176,18 @@ static void intel_dp_set_default_sink_rates(struct intel_dp *intel_dp)
/* update sink rates from dpcd */
static void intel_dp_set_dpcd_sink_rates(struct intel_dp *intel_dp)
{
- struct intel_display *display = to_intel_display(intel_dp);
- static const int dp_rates[] = {
- 162000, 270000, 540000, 810000
- };
- int i, max_rate;
- int max_lttpr_rate;
- u8 uhbr_rates = 0;
-
- if (drm_dp_has_quirk(&intel_dp->desc, DP_DPCD_QUIRK_CAN_DO_MAX_LINK_RATE_3_24_GBPS)) {
- /* Needed, e.g., for Apple MBP 2017, 15 inch eDP Retina panel */
- static const int quirk_rates[] = { 162000, 270000, 324000 };
-
- memcpy(intel_dp->sink_rates, quirk_rates, sizeof(quirk_rates));
- intel_dp->num_sink_rates = ARRAY_SIZE(quirk_rates);
-
- return;
- }
-
- /*
- * Sink rates for 8b/10b.
- */
- max_rate = drm_dprx_max_rate(intel_dp->tunnel, intel_dp->dpcd);
-
- /*
- * Some platforms + eDP panels may not reliably support HBR3
- * due to signal integrity limitations, despite advertising it.
- * Cap the link rate to HBR2 to avoid unstable configurations for the
- * known machines.
- */
- if (intel_dp_is_edp(intel_dp) && intel_has_quirk(display, QUIRK_EDP_LIMIT_RATE_HBR2))
- max_rate = min(max_rate, 540000);
-
- max_lttpr_rate = drm_dp_lttpr_max_link_rate(intel_dp->lttpr_common_caps);
- if (max_lttpr_rate)
- max_rate = min(max_rate, max_lttpr_rate);
+ int num_sink_rates;
- for (i = 0; i < ARRAY_SIZE(dp_rates); i++) {
- if (dp_rates[i] > max_rate)
- break;
- intel_dp->sink_rates[i] = dp_rates[i];
- }
-
- /*
- * The following register must be read unconditionally for the later
- * DP tunnel 128b132b detection to work, see DP Standard v2.1 5.14.3 .
- */
- drm_dp_dpcd_read_byte(&intel_dp->aux, DP_128B132B_SUPPORTED_LINK_RATES, &uhbr_rates);
-
- /*
- * Sink rates for 128b/132b. If set, sink should support all 8b/10b
- * rates and 10 Gbps.
- */
- if (drm_dprx_supports_128b132b(intel_dp->tunnel, intel_dp->dpcd)) {
- BUILD_BUG_ON(ARRAY_SIZE(intel_dp->sink_rates) < ARRAY_SIZE(dp_rates) + 3);
-
- uhbr_rates = drm_dprx_128b132b_link_rates(intel_dp->tunnel, uhbr_rates);
-
- i += drm_dp_get_128b132b_link_rates(intel_dp->lttpr_common_caps,
- intel_dp->tunnel,
- uhbr_rates,
- &intel_dp->sink_rates[i]);
- }
+ num_sink_rates = drm_dp_read_dpcd_sink_rates(&intel_dp->aux,
+ intel_dp->dpcd,
+ intel_dp->lttpr_common_caps,
+ &intel_dp->desc,
+ intel_dp->tunnel,
+ intel_dp->sink_rates);
+ if (num_sink_rates < 0)
+ num_sink_rates = 0;
- intel_dp->num_sink_rates = i;
+ intel_dp->num_sink_rates = num_sink_rates;
}
static void intel_dp_set_sink_rates(struct intel_dp *intel_dp)
@@ -4921,6 +4869,16 @@ intel_edp_set_sink_rates(struct intel_dp *intel_dp)
else
intel_dp_set_sink_rates(intel_dp);
+ /*
+ * Some platforms cannot reliably drive HBR3 rates due to PHY limitations,
+ * even if the sink advertises support. Reject any sink rates above HBR2 on
+ * the known machines for stable output.
+ */
+ if (intel_dp->num_sink_rates && intel_has_quirk(display, QUIRK_EDP_LIMIT_RATE_HBR2))
+ intel_dp->num_sink_rates = intel_dp_rate_limit_len(intel_dp->sink_rates,
+ intel_dp->num_sink_rates,
+ 540000);
+
intel_edp_set_data_override_rates(intel_dp);
}
diff --git a/include/drm/display/drm_dp.h b/include/drm/display/drm_dp.h
index 6efacff09567c..8c1d8b79dc7fd 100644
--- a/include/drm/display/drm_dp.h
+++ b/include/drm/display/drm_dp.h
@@ -1529,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_8B10B 0x14
#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 */
diff --git a/include/drm/display/drm_dp_helper.h b/include/drm/display/drm_dp_helper.h
index a8c382a2c916f..5c4cb57f0fc5e 100644
--- a/include/drm/display/drm_dp_helper.h
+++ b/include/drm/display/drm_dp_helper.h
@@ -34,6 +34,7 @@ struct drm_dp_aux;
struct drm_panel;
struct drm_printer;
struct drm_dp_tunnel;
+struct drm_dp_desc;
bool drm_dp_channel_eq_ok(const u8 link_status[DP_LINK_STATUS_SIZE],
int lane_count);
@@ -713,6 +714,13 @@ int drm_dp_get_128b132b_link_rates(const u8 lttpr_common_caps[DP_LTTPR_COMMON_CA
u8 uhbr_rates,
int link_rates[DP_MAX_128B132B_SUPPORTED_RATES]);
+int drm_dp_read_dpcd_sink_rates(struct drm_dp_aux *aux,
+ const u8 dpcd[DP_RECEIVER_CAP_SIZE],
+ const u8 lttpr_common_caps[DP_LTTPR_COMMON_CAP_SIZE],
+ const struct drm_dp_desc *desc,
+ const struct drm_dp_tunnel *tunnel,
+ int sink_rates[DP_MAX_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 ` [PATCH v2 04/10] drm/dp: Move supported 128b/132b link rates " Kory Maincent
2026-11-25 14:01 ` Kory Maincent [this message]
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-5-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®