From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 53EBA3E274D for ; Thu, 9 Apr 2026 17:09:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.84.56 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775754582; cv=none; b=lnJ7P+Eb420JNGW5e634DaM36RUORajv2rL1SvL9NJP7q1TejiSK6x4hjAoBdJG/bYX6PybrZCusct0Y38gy2j+M/c4mCVACixxPGpFlMHLHVq6Cxyg6nmb0YoQHsc1cBj1hAZ/FTfOasks8n4axbcl5ek0mzI/cpD1zA6yNW3g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775754582; c=relaxed/simple; bh=+3Bz8vg/eFPcDAblCSmDx/RtYSZwrtZY/9Z8YETCo28=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=CPKYShnR6kYWumPrhoqnp6rQOEI/qPqYxY2tS4iFgJPoWivPozsBPOMurZsqrvii7RXfBRplwWH0v/vS7ueLEIXwy7FpvYy3e2ncs4VwdDMGs2IjPdPlXth4HV1u1H9pPtZ44yc2AzHcWPVjlKA20X2K11l/6ZXrDvr8ICCt1Rc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=TdHFtusw; arc=none smtp.client-ip=185.246.84.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="TdHFtusw" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id E65691A3259; Thu, 9 Apr 2026 17:09:38 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id AA0F8603E4; Thu, 9 Apr 2026 17:09:38 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id A4965104501B9; Thu, 9 Apr 2026 19:09:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1775754577; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=80i2+SV+RLyeafvPAz3gjWWOqBFxeYH5P0a7No+38o8=; b=TdHFtuswVi6gUMeZnFkAQ1h9pYxWbUEmNzplgQT7MQIoLxVUeKQh9ZW6VmZx0JcElV0nTT ndiz9X1DMeZeUk8msd8gSMDWTxx2+1v+CUTZ2scRfTPMvu2Bf2YU9h2Xe2RIj4vns7A716 z5h9gRlT4iPBE+tVe1Yp3+1eSh1qr2E6PmB2LNubQzYatkW9NOJ6mwUB2QsEtWFhOjQ3Dm D3KuHtVoL2McBeRsbNBCDGt/hapKZI1sw3s2gEOsQOX2gPJkgiOZUHjeQ0aFejaI+t0+7g optEMjLs5g2b4/YnM4lbdoqcSSe9QIytTPOi6B16/duv4oJJLdD/30s7jfvwqw== From: Kory Maincent Date: Thu, 09 Apr 2026 19:08:28 +0200 Subject: [PATCH RFC 12/12] drm/mediatek: Use dp_connector helpers to report link training state Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260409-feat_link_cap-v1-12-7069e8199ce2@bootlin.com> References: <20260409-feat_link_cap-v1-0-7069e8199ce2@bootlin.com> In-Reply-To: <20260409-feat_link_cap-v1-0-7069e8199ce2@bootlin.com> To: Jani Nikula , Rodrigo Vivi , Joonas Lahtinen , Tvrtko Ursulin , David Airlie , Simona Vetter , Dave Airlie , Jesse Barnes , Eric Anholt , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Chun-Kuang Hu , Philipp Zabel , Matthias Brugger , AngeloGioacchino Del Regno , Chris Wilson Cc: Thomas Petazzoni , Mark Yacoub , Sean Paul , Louis Chauvet , 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 , Kory Maincent X-Mailer: b4 0.14-dev-d4707 X-Last-TLS-Session-Version: TLSv1.3 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 --- 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 #include #include +#include #include #include #include @@ -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