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 07/10] drm/dp: Add drm_dp_read_dpcd_supported_link_rates() helper
Date: Wed, 25 Nov 2026 15:01:11 +0100 [thread overview]
Message-ID: <20261125-feat_move_i915_helper-v2-7-aa04d39bc415@bootlin.com> (raw)
In-Reply-To: <20261125-feat_move_i915_helper-v2-0-aa04d39bc415@bootlin.com>
Add a new drm_dp_read_dpcd_supported_link_rates() helper which reads
the DPCD DP_SUPPORTED_LINK_RATES registers and converts their values
into link rates. Use it from the i915 eDP sink rates handling.
The custom Intel eDP HBR2 limitation quirk handling stays in the driver.
Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>
---
Changes in v2:
- Fix a small possible issue (sashiko) in case of an intel quirk
and supported link rates exceeding 540000 kHz
- Split the patch in 3 for readability
---
drivers/gpu/drm/display/drm_dp_helper.c | 27 +++++++++++++
drivers/gpu/drm/i915/display/intel_dp.c | 72 +++++++++++++--------------------
include/drm/display/drm_dp_helper.h | 3 ++
3 files changed, 58 insertions(+), 44 deletions(-)
diff --git a/drivers/gpu/drm/display/drm_dp_helper.c b/drivers/gpu/drm/display/drm_dp_helper.c
index 30935d3ae0055..6d684b6b94d0a 100644
--- a/drivers/gpu/drm/display/drm_dp_helper.c
+++ b/drivers/gpu/drm/display/drm_dp_helper.c
@@ -4916,6 +4916,33 @@ int drm_dp_max_dprx_data_rate(int max_link_rate, int max_lanes)
}
EXPORT_SYMBOL(drm_dp_max_dprx_data_rate);
+/**
+ * drm_dp_read_dpcd_supported_link_rates() - read DPCD supported link rates
+ * @aux: DisplayPort AUX channel
+ * @link_rates: Buffer to store the resulting link rates supported
+ *
+ * Attempts to read the DPCD supported link rates for @aux.
+ *
+ * Returns: The number of supported link rates, negative error code otherwise.
+ */
+int drm_dp_read_dpcd_supported_link_rates(struct drm_dp_aux *aux,
+ int link_rates[DP_MAX_SUPPORTED_RATES])
+{
+ __le16 dpcd_link_rates[DP_MAX_SUPPORTED_RATES] = {0};
+ int ret, i;
+
+ ret = drm_dp_dpcd_read_data(aux, DP_SUPPORTED_LINK_RATES,
+ dpcd_link_rates, sizeof(dpcd_link_rates));
+ if (ret < 0)
+ return ret;
+
+ for (i = 0; i < ARRAY_SIZE(dpcd_link_rates) && dpcd_link_rates[i]; i++)
+ link_rates[i] = le16_to_cpu(dpcd_link_rates[i]) * 20;
+
+ return i;
+}
+EXPORT_SYMBOL_GPL(drm_dp_read_dpcd_supported_link_rates);
+
static int drm_dprx_max_rate(const struct drm_dp_tunnel *tunnel,
const u8 dpcd[DP_RECEIVER_CAP_SIZE])
{
diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c
index 8fee2d195c944..798274a7b70ea 100644
--- a/drivers/gpu/drm/i915/display/intel_dp.c
+++ b/drivers/gpu/drm/i915/display/intel_dp.c
@@ -4811,6 +4811,24 @@ intel_edp_set_data_override_rates(struct intel_dp *intel_dp)
intel_dp->num_sink_rates = count;
}
+/*
+ * 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.
+ */
+static void intel_edp_limit_sink_rates_hbr2(struct intel_dp *intel_dp)
+{
+ struct intel_display *display = to_intel_display(intel_dp);
+
+ if (!intel_dp->num_sink_rates ||
+ !intel_has_quirk(display, QUIRK_EDP_LIMIT_RATE_HBR2))
+ return;
+
+ intel_dp->num_sink_rates = intel_dp_rate_limit_len(intel_dp->sink_rates,
+ intel_dp->num_sink_rates,
+ 540000);
+}
+
static void
intel_edp_set_sink_rates(struct intel_dp *intel_dp)
{
@@ -4819,65 +4837,31 @@ intel_edp_set_sink_rates(struct intel_dp *intel_dp)
intel_dp->num_sink_rates = 0;
if (intel_dp->edp_dpcd[0] >= DP_EDP_14) {
- __le16 sink_rates[DP_MAX_SUPPORTED_RATES];
int ret;
- int i;
- ret = drm_dp_dpcd_read_data(&intel_dp->aux,
- DP_SUPPORTED_LINK_RATES,
- sink_rates, sizeof(sink_rates));
+ ret = drm_dp_read_dpcd_supported_link_rates(&intel_dp->aux,
+ intel_dp->sink_rates);
if (ret < 0) {
drm_dbg_kms(display->drm,
"Unable to read eDP supported link rates, using default rates\n");
- memset(sink_rates, 0, sizeof(sink_rates));
+ ret = 0;
}
- for (i = 0; i < ARRAY_SIZE(sink_rates); i++) {
- int rate;
-
- /* Value read multiplied by 200kHz gives the per-lane
- * link rate in kHz. The source rates are, however,
- * stored in terms of LS_Clk kHz. The full conversion
- * back to symbols is
- * (val * 200kHz)*(8/10 ch. encoding)*(1/8 bit to Byte)
- */
- rate = le16_to_cpu(sink_rates[i]) * 200 / 10;
-
- if (rate == 0)
- break;
-
- /*
- * 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 (rate > 540000 &&
- intel_has_quirk(display, QUIRK_EDP_LIMIT_RATE_HBR2))
- break;
-
- intel_dp->sink_rates[i] = rate;
- }
- intel_dp->num_sink_rates = i;
+ intel_dp->num_sink_rates = ret;
}
+ intel_edp_limit_sink_rates_hbr2(intel_dp);
+
/*
* Use DP_LINK_RATE_SET if DP_SUPPORTED_LINK_RATES are available,
* default to DP_MAX_LINK_RATE and DP_LINK_BW_SET otherwise.
*/
- if (intel_dp->num_sink_rates)
+ if (intel_dp->num_sink_rates) {
intel_dp->use_rate_select = true;
- else
+ } 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_limit_sink_rates_hbr2(intel_dp);
+ }
intel_edp_set_data_override_rates(intel_dp);
}
diff --git a/include/drm/display/drm_dp_helper.h b/include/drm/display/drm_dp_helper.h
index dd4c4a6ff17d1..2e018f1e59363 100644
--- a/include/drm/display/drm_dp_helper.h
+++ b/include/drm/display/drm_dp_helper.h
@@ -703,6 +703,9 @@ static inline int drm_dp_dpcd_write_byte(struct drm_dp_aux *aux,
int drm_dp_read_dpcd_caps(struct drm_dp_aux *aux,
u8 dpcd[DP_RECEIVER_CAP_SIZE]);
+int drm_dp_read_dpcd_supported_link_rates(struct drm_dp_aux *aux,
+ int link_rates[DP_MAX_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],
--
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 ` [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 ` Kory Maincent [this message]
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-7-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®