From: Kory Maincent <kory.maincent@bootlin.com>
To: 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>,
David Airlie <airlied@gmail.com>,
Simona Vetter <simona@ffwll.ch>,
Dave Airlie <airlied@redhat.com>,
Jesse Barnes <jbarnes@virtuousgeek.org>,
Eric Anholt <eric@anholt.net>,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>,
Andrzej Hajda <andrzej.hajda@intel.com>,
Neil Armstrong <neil.armstrong@linaro.org>,
Robert Foss <rfoss@kernel.org>,
Laurent Pinchart <Laurent.pinchart@ideasonboard.com>,
Jonas Karlman <jonas@kwiboo.se>,
Jernej Skrabec <jernej.skrabec@gmail.com>,
Chun-Kuang Hu <chunkuang.hu@kernel.org>,
Philipp Zabel <p.zabel@pengutronix.de>,
Matthias Brugger <matthias.bgg@gmail.com>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>,
Chris Wilson <chris@chris-wilson.co.uk>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
Mark Yacoub <markyacoub@google.com>,
Sean Paul <seanpaul@google.com>,
Louis Chauvet <louis.chauvet@bootlin.com>,
intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
linux-mediatek@lists.infradead.org,
linux-arm-kernel@lists.infradead.org,
Simona Vetter <simona.vetter@ffwll.ch>,
Kory Maincent <kory.maincent@bootlin.com>
Subject: [PATCH RFC 12/12] drm/mediatek: Use dp_connector helpers to report link training state
Date: Thu, 09 Apr 2026 19:08:28 +0200 [thread overview]
Message-ID: <20260409-feat_link_cap-v1-12-7069e8199ce2@bootlin.com> (raw)
In-Reply-To: <20260409-feat_link_cap-v1-0-7069e8199ce2@bootlin.com>
Set DRM_BRIDGE_OP_DP and populate dp_link_train_caps with the supported
link rates, lane counts, voltage swing and pre-emphasis levels so the
bridge connector uses drmm_connector_dp_init() and exposes the link
training state properties to userspace.
Store per-lane voltage swing and pre-emphasis values in
mtk_dp_train_info and report the negotiated link parameters via
drm_connector_dp_set_link_train_properties() on training completion.
Clear them via drm_connector_dp_reset_link_train_properties() when a
disconnect is detected in the HPD event thread.
Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>
---
This patch has still not been tested. I am in the process of finding the
hardware for that.
---
drivers/gpu/drm/mediatek/mtk_dp.c | 34 +++++++++++++++++++++++++++++++++-
1 file changed, 33 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/mediatek/mtk_dp.c b/drivers/gpu/drm/mediatek/mtk_dp.c
index c52cc7c2e2006..119718c1374c5 100644
--- a/drivers/gpu/drm/mediatek/mtk_dp.c
+++ b/drivers/gpu/drm/mediatek/mtk_dp.c
@@ -10,6 +10,7 @@
#include <drm/drm_atomic_helper.h>
#include <drm/drm_bridge.h>
#include <drm/drm_crtc.h>
+#include <drm/drm_dp_connector.h>
#include <drm/drm_edid.h>
#include <drm/drm_of.h>
#include <drm/drm_panel.h>
@@ -72,6 +73,8 @@ struct mtk_dp_train_info {
/* link_rate is in multiple of 0.27Gbps */
int link_rate;
int lane_count;
+ u8 vswing[4];
+ u8 preemphasis[4];
unsigned int channel_eq_pattern;
};
@@ -1561,6 +1564,9 @@ static void mtk_dp_train_update_swing_pre(struct mtk_dp *mtk_dp, int lanes,
mtk_dp_set_swing_pre_emphasis(mtk_dp, lane, swing, preemphasis);
drm_dp_dpcd_writeb(&mtk_dp->aux, DP_TRAINING_LANE0_SET + lane,
val);
+
+ mtk_dp->train_info.vswing[lane] = swing;
+ mtk_dp->train_info.preemphasis[lane] = preemphasis;
}
}
@@ -1812,6 +1818,21 @@ static void mtk_dp_train_change_mode(struct mtk_dp *mtk_dp)
mtk_dp_reset_swing_pre_emphasis(mtk_dp);
}
+static int mtk_dp_report_link_train(struct mtk_dp *mtk_dp)
+{
+ struct drm_connector_dp_link_train dp_link_train;
+
+ dp_link_train.rate = drm_dp_bw_code_to_link_rate(mtk_dp->train_info.link_rate);
+ dp_link_train.nlanes = mtk_dp->train_info.lane_count;
+
+ for (int i = 0; i < mtk_dp->train_info.lane_count; i++) {
+ dp_link_train.v_swing[i] = 1 << mtk_dp->train_info.vswing[i];
+ dp_link_train.pre_emph[i] = 1 << mtk_dp->train_info.preemphasis[i];
+ }
+
+ return drm_connector_dp_set_link_train_properties(mtk_dp->conn, &dp_link_train);
+}
+
static int mtk_dp_training(struct mtk_dp *mtk_dp)
{
int ret;
@@ -1892,7 +1913,7 @@ static int mtk_dp_training(struct mtk_dp *mtk_dp)
mtk_dp_training_set_scramble(mtk_dp, true);
mtk_dp_set_enhanced_frame_mode(mtk_dp);
- return 0;
+ return mtk_dp_report_link_train(mtk_dp);
}
static void mtk_dp_video_enable(struct mtk_dp *mtk_dp, bool enable)
@@ -2004,6 +2025,7 @@ static irqreturn_t mtk_dp_hpd_event_thread(int hpd, void *dev)
mtk_dp->need_debounce = false;
mod_timer(&mtk_dp->debounce_timer,
jiffies + msecs_to_jiffies(100) - 1);
+ drm_connector_dp_reset_link_train_properties(mtk_dp->conn);
} else {
mtk_dp_aux_panel_poweron(mtk_dp, true);
@@ -2742,6 +2764,14 @@ static int mtk_dp_edp_link_panel(struct drm_dp_aux *mtk_aux)
static int mtk_dp_probe(struct platform_device *pdev)
{
+ static const u32 dp_rates[] = {162000, 270000, 540000, 810000};
+ static const struct drm_connector_dp_link_train_caps dp_link_train_caps = {
+ .nlanes = DRM_DP_1LANE | DRM_DP_2LANE | DRM_DP_4LANE,
+ .nrates = ARRAY_SIZE(dp_rates),
+ .rates = dp_rates,
+ .v_swings = DRM_DP_VOLTAGE_SWING_LEVEL_MASK,
+ .pre_emphs = DRM_DP_PRE_EMPH_LEVEL_MASK,
+ };
struct mtk_dp *mtk_dp;
struct device *dev = &pdev->dev;
int ret;
@@ -2809,6 +2839,8 @@ static int mtk_dp_probe(struct platform_device *pdev)
mtk_dp->bridge.of_node = dev->of_node;
mtk_dp->bridge.type = mtk_dp->data->bridge_type;
+ mtk_dp->bridge.dp_link_train_caps = &dp_link_train_caps;
+ mtk_dp->bridge.ops = DRM_BRIDGE_OP_DP;
if (mtk_dp->bridge.type == DRM_MODE_CONNECTOR_eDP) {
/*
--
2.43.0
next prev parent reply other threads:[~2026-04-09 17:09 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-09 17:08 [PATCH RFC 00/12] Add support for DisplayPort link training information report Kory Maincent
2026-04-09 17:08 ` [PATCH RFC 01/12] drm/i915/display/intel_sdvo: Fix double connector destroy in error paths Kory Maincent
2026-04-09 17:08 ` [PATCH RFC 02/12] drm/i915/display/intel_lvds: Drop redundant manual cleanup on init failure Kory Maincent
2026-04-09 17:08 ` [PATCH RFC 03/12] drm/i915/display/intel_dp: Drop redundant intel_dp_aux_fini() " Kory Maincent
2026-04-09 17:08 ` [PATCH RFC 04/12] drm/i915/display: Switch to drmm_mode_config_init() and drop manual cleanup Kory Maincent
2026-04-09 17:08 ` [PATCH RFC 05/12] drm/i915/display: Switch to managed for crtc Kory Maincent
2026-04-09 17:08 ` [PATCH RFC 06/12] drm/i915/display: Switch to managed for plane Kory Maincent
2026-04-09 17:08 ` [PATCH RFC 07/12] drm/i915/display: Switch to managed for encoder Kory Maincent
2026-04-09 17:08 ` [PATCH RFC 08/12] drm/i915/display: Switch to managed for connector Kory Maincent
2026-04-09 17:08 ` [PATCH RFC 09/12] drm: Introduce drmm_connector_dp_init() with link training state properties Kory Maincent
2026-04-09 21:53 ` Dmitry Baryshkov
2026-04-10 16:20 ` Jani Nikula
2026-04-09 17:08 ` [PATCH RFC 10/12] drm/i915/display/dp: Adopt dp_connector helpers to expose link training state Kory Maincent
2026-04-10 16:26 ` Jani Nikula
2026-04-09 17:08 ` [PATCH RFC 11/12] drm/bridge: Wire drmm_connector_dp_init() via new DRM_BRIDGE_OP_DP flag Kory Maincent
2026-04-09 17:08 ` Kory Maincent [this message]
2026-04-09 20:36 ` [PATCH RFC 00/12] Add support for DisplayPort link training information report Ville Syrjälä
2026-04-09 21:36 ` Dmitry Baryshkov
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=20260409-feat_link_cap-v1-12-7069e8199ce2@bootlin.com \
--to=kory.maincent@bootlin.com \
--cc=Laurent.pinchart@ideasonboard.com \
--cc=airlied@gmail.com \
--cc=airlied@redhat.com \
--cc=andrzej.hajda@intel.com \
--cc=angelogioacchino.delregno@collabora.com \
--cc=chris@chris-wilson.co.uk \
--cc=chunkuang.hu@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=eric@anholt.net \
--cc=intel-gfx@lists.freedesktop.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=jani.nikula@linux.intel.com \
--cc=jbarnes@virtuousgeek.org \
--cc=jernej.skrabec@gmail.com \
--cc=jonas@kwiboo.se \
--cc=joonas.lahtinen@linux.intel.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=louis.chauvet@bootlin.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=markyacoub@google.com \
--cc=matthias.bgg@gmail.com \
--cc=mripard@kernel.org \
--cc=neil.armstrong@linaro.org \
--cc=p.zabel@pengutronix.de \
--cc=rfoss@kernel.org \
--cc=rodrigo.vivi@intel.com \
--cc=seanpaul@google.com \
--cc=simona.vetter@ffwll.ch \
--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