[PATCH 7/8] drm/dp: Move eDP sink link rates reading helper out of i915
From: Kory Maincent
Date: Wed Nov 18 2026 - 05:37:16 EST
Move the eDP sink link rates reading function out of the i915 driver
into the generic DRM helpers. The helper reads the rates from the DPCD
DP_SUPPORTED_LINK_RATES registers, available on eDP 1.4 and later
sinks.
No functional change intended.
Signed-off-by: Kory Maincent <kory.maincent@xxxxxxxxxxx>
---
drivers/gpu/drm/display/drm_dp_helper.c | 58 +++++++++++++++++++++++++++++++++
drivers/gpu/drm/i915/display/intel_dp.c | 51 +++++------------------------
include/drm/display/drm_dp_helper.h | 2 ++
3 files changed, 68 insertions(+), 43 deletions(-)
diff --git a/drivers/gpu/drm/display/drm_dp_helper.c b/drivers/gpu/drm/display/drm_dp_helper.c
index 30935d3ae0055..fc3d4db1c7639 100644
--- a/drivers/gpu/drm/display/drm_dp_helper.c
+++ b/drivers/gpu/drm/display/drm_dp_helper.c
@@ -4916,6 +4916,32 @@ 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 or supported link rates, negative error code otherwise.
+ */
+static 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;
+}
+
static int drm_dprx_max_rate(const struct drm_dp_tunnel *tunnel,
const u8 dpcd[DP_RECEIVER_CAP_SIZE])
{
@@ -5086,3 +5112,35 @@ int drm_dp_read_dpcd_sink_rates(struct drm_dp_aux *aux,
return i;
}
EXPORT_SYMBOL_GPL(drm_dp_read_dpcd_sink_rates);
+
+/**
+ * drm_dp_read_edp_sink_rates() - read the sink rates from the eDP DPCD
+ * @aux: DisplayPort AUX channel
+ * @edp_dpcd_rev: eDP DPCD revision of the sink
+ * @sink_rates: Array of DP_MAX_SUPPORTED_RATES entries to store the sink rates
+ *
+ * Read the link rates supported by an eDP sink from the DPCD
+ * DP_SUPPORTED_LINK_RATES registers, available on eDP 1.4 and later sinks.
+ *
+ * Returns: The number of supported sink rates, 0 if the sink does not support
+ * the DP_SUPPORTED_LINK_RATES register.
+ */
+int drm_dp_read_edp_sink_rates(struct drm_dp_aux *aux, u8 edp_dpcd_rev,
+ int sink_rates[DP_MAX_SUPPORTED_RATES])
+{
+ int num_sink_rates;
+
+ if (edp_dpcd_rev < DP_EDP_14)
+ return 0;
+
+ num_sink_rates = drm_dp_read_dpcd_supported_link_rates(aux, sink_rates);
+ if (num_sink_rates < 0) {
+ drm_dbg_kms(aux->drm_dev,
+ "%s: Unable to read eDP supported link rates (%d)\n",
+ aux->name, num_sink_rates);
+ return 0;
+ }
+
+ return num_sink_rates;
+}
+EXPORT_SYMBOL_GPL(drm_dp_read_edp_sink_rates);
diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c
index 8fee2d195c944..225f6ed8c32d8 100644
--- a/drivers/gpu/drm/i915/display/intel_dp.c
+++ b/drivers/gpu/drm/i915/display/intel_dp.c
@@ -4815,56 +4815,21 @@ static void
intel_edp_set_sink_rates(struct intel_dp *intel_dp)
{
struct intel_display *display = to_intel_display(intel_dp);
+ int num_sink_rates;
- 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));
- 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));
- }
-
- 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;
+ num_sink_rates = drm_dp_read_edp_sink_rates(&intel_dp->aux,
+ intel_dp->edp_dpcd[0],
+ intel_dp->sink_rates);
+ if (num_sink_rates < 0)
+ num_sink_rates = 0;
- intel_dp->sink_rates[i] = rate;
- }
- intel_dp->num_sink_rates = i;
- }
+ intel_dp->num_sink_rates = num_sink_rates;
/*
* 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 (num_sink_rates)
intel_dp->use_rate_select = true;
else
intel_dp_set_sink_rates(intel_dp);
diff --git a/include/drm/display/drm_dp_helper.h b/include/drm/display/drm_dp_helper.h
index dd4c4a6ff17d1..81fe87ad47050 100644
--- a/include/drm/display/drm_dp_helper.h
+++ b/include/drm/display/drm_dp_helper.h
@@ -709,6 +709,8 @@ int drm_dp_read_dpcd_sink_rates(struct drm_dp_aux *aux,
const struct drm_dp_desc *desc,
const struct drm_dp_tunnel *tunnel,
int sink_rates[DP_MAX_SUPPORTED_RATES]);
+int drm_dp_read_edp_sink_rates(struct drm_dp_aux *aux, u8 edp_dpcd_rev,
+ 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