dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] drm/bridge: ti-sn65dsi86: Add HPD for DisplayPort connector type
@ 2025-05-08 11:54 Jayesh Choudhary
  2025-05-13 12:52 ` Max Krummenacher
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Jayesh Choudhary @ 2025-05-08 11:54 UTC (permalink / raw)
  To: dianders, andrzej.hajda, neil.armstrong, rfoss, Laurent.pinchart,
	dri-devel, tomi.valkeinen, max.krummenacher
  Cc: jonas, jernej.skrabec, maarten.lankhorst, mripard, tzimmermann,
	airlied, simona, kieran.bingham+renesas, linux-kernel, max.oss.09,
	devarsht, j-choudhary

By default, HPD was disabled on SN65DSI86 bridge. When the driver was
added (commit "a095f15c00e27"), the HPD_DISABLE bit was set in pre-enable
call which was moved to other function calls subsequently.
Later on, commit "c312b0df3b13" added detect utility for DP mode. But with
HPD_DISABLE bit set, all the HPD events are disabled[0] and the debounced
state always return 1 (always connected state)

Also, with the suspend and resume calls before every register access, the
bridge starts with disconnected state and the HPD state is reflected
correctly only after debounce time (400ms). However, adding this delay
in the detect function causes frame drop and visible glitch in display.

So to get the detect utility working properly for DP mode without any
performance issues in display, instead of reading HPD state from the
register, rely on aux communication. Use 'drm_dp_dpcd_read_link_status'
to find if we have something connected at the sink.

[0]: <https://www.ti.com/lit/gpn/SN65DSI86> (Pg. 32)

Fixes: c312b0df3b13 ("drm/bridge: ti-sn65dsi86: Implement bridge connector operations for DP")
Cc: Max Krummenacher <max.krummenacher@toradex.com>
Signed-off-by: Jayesh Choudhary <j-choudhary@ti.com>
---

v1 patch link which was sent as RFC:
<https://patchwork.kernel.org/project/dri-devel/patch/20250424105432.255309-1-j-choudhary@ti.com/>

Changelog v1->v2:
- Drop additional property in bindings and use conditional.
- Instead of register read for HPD state, use dpcd read which returns 0
  for success and error codes for no connection
- Add relevant history for the required change in commit message
- Drop RFC subject-prefix in v2 as v2 is in better state after discussion
  in v1 and Max's mail thread
- Add "Cc:" tag 

This approach does not make suspend/resume no-op and no additional
delay needs to be added in the detect hook which causes frame drops.

Here, I am adding conditional to HPD_DISABLE bit even when we are
not using the register read to get HPD state. This is to prevent
unnecessary register updates in every resume call.
(It was adding to latency and leading to ~2-3 frame drop every 10 sec)

Tested and verified on TI's J784S4-EVM platform:
- Display comes up
- Detect utility works with a couple of seconds latency.
  But I guess without interrupt support, this is acceptable.
- No frame-drop observed
 
Discussion thread for Max's patch:
<https://patchwork.kernel.org/project/dri-devel/patch/20250501074805.3069311-1-max.oss.09@gmail.com/>

 drivers/gpu/drm/bridge/ti-sn65dsi86.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/bridge/ti-sn65dsi86.c b/drivers/gpu/drm/bridge/ti-sn65dsi86.c
index 60224f476e1d..9489e78b6da3 100644
--- a/drivers/gpu/drm/bridge/ti-sn65dsi86.c
+++ b/drivers/gpu/drm/bridge/ti-sn65dsi86.c
@@ -352,8 +352,10 @@ static void ti_sn65dsi86_enable_comms(struct ti_sn65dsi86 *pdata,
 	 * change this to be conditional on someone specifying that HPD should
 	 * be used.
 	 */
-	regmap_update_bits(pdata->regmap, SN_HPD_DISABLE_REG, HPD_DISABLE,
-			   HPD_DISABLE);
+
+	if (pdata->bridge.type == DRM_MODE_CONNECTOR_eDP)
+		regmap_update_bits(pdata->regmap, SN_HPD_DISABLE_REG, HPD_DISABLE,
+				   HPD_DISABLE);
 
 	pdata->comms_enabled = true;
 
@@ -1194,13 +1196,14 @@ static enum drm_connector_status ti_sn_bridge_detect(struct drm_bridge *bridge)
 {
 	struct ti_sn65dsi86 *pdata = bridge_to_ti_sn65dsi86(bridge);
 	int val = 0;
+	u8 link_status[DP_LINK_STATUS_SIZE];
 
-	pm_runtime_get_sync(pdata->dev);
-	regmap_read(pdata->regmap, SN_HPD_DISABLE_REG, &val);
-	pm_runtime_put_autosuspend(pdata->dev);
+	val = drm_dp_dpcd_read_link_status(&pdata->aux, link_status);
 
-	return val & HPD_DEBOUNCED_STATE ? connector_status_connected
-					 : connector_status_disconnected;
+	if (val < 0)
+		return connector_status_disconnected;
+	else
+		return connector_status_connected;
 }
 
 static const struct drm_edid *ti_sn_bridge_edid_read(struct drm_bridge *bridge,
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2025-05-28 12:42 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-08 11:54 [PATCH v2] drm/bridge: ti-sn65dsi86: Add HPD for DisplayPort connector type Jayesh Choudhary
2025-05-13 12:52 ` Max Krummenacher
2025-05-22  1:10 ` Doug Anderson
2025-05-22 13:14   ` Dmitry Baryshkov
2025-05-26  7:43     ` Jayesh Choudhary
2025-05-27 15:40     ` Doug Anderson
2025-05-26  8:41 ` Ernest Van Hoecke
2025-05-27 15:44   ` Doug Anderson
2025-05-28 12:18     ` Jayesh Choudhary
2025-05-28 12:41       ` Ernest Van Hoecke

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).