Skip to contentSkip to conversation

drm: bridge: Add DSI HS clock frequency limits to bridge state

PATCH New Marek Vasut 1 participant 3 messages Oct 26, 2022

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/3 drm: bridge: Add DSI HS clock frequency limits to bridge state

Add the ability to pass DSI HS clock frequency constraints between neighboring DSI bridges via struct drm_bridge_state . This way the DSI HS clock frequency negotiation can be implemented instead of the current ad-hoc method where each bridge attempts to guess the neighbor HS clock frequency setting or expectation.

---
Cc: Laurent Pinchart <[email protected]>
Cc: Lucas Stach <[email protected]>
Cc: Maxime Ripard <[email protected]>
Cc: Robert Foss <[email protected]>
Cc: Sam Ravnborg <[email protected]>

---
 include/drm/drm_atomic.h | 2 ++
 1 file changed, 2 insertions(+)
include/drm/drm_atomic.h +2 -0
index 10b1990bc1f68..eece7557933d2 100644
@@ -1117,6 +1117,8 @@ struct drm_bridge_state {
 	 * @input_bus_cfg: input bus configuration
 	 */
 	struct drm_bus_cfg input_bus_cfg;
+	unsigned long hs_rate_min;
+	unsigned long hs_rate_max;
 
 	/**
 	 * @output_bus_cfg: input bus configuration
Signature · 1 line
2.35.1
#1 lore raw

PATCH 2/3 drm/bridge: tc358767: Report minimum and maximum DSI HS clock to upstream bridge

In case TC358767 operates in DSI-to-DPI mode and its clock are supplied from XTal connected to RefClk, the range of supported input DSI HS clock is limited.

Expose this limitation to the upstream bridge by providing minimum and maximum accepted DSI HS clock frequency via bridge state.

---
Cc: Laurent Pinchart <[email protected]>
Cc: Lucas Stach <[email protected]>
Cc: Maxime Ripard <[email protected]>
Cc: Robert Foss <[email protected]>
Cc: Sam Ravnborg <[email protected]>

---
 drivers/gpu/drm/bridge/tc358767.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
drivers/gpu/drm/bridge/tc358767.c +24 -0
index b5f4e5328eaf9..3f423a29c703b 100644
@@ -1516,10 +1516,34 @@ static int tc_dpi_atomic_check(struct drm_bridge *bridge,
 			       struct drm_crtc_state *crtc_state,
 			       struct drm_connector_state *conn_state)
 {
+	struct tc_data *tc = bridge_to_tc(bridge);
+	unsigned int dpi_max_pixrate;
+
 	/* DSI->DPI interface clock limitation: upto 100 MHz */
 	if (crtc_state->adjusted_mode.clock > 100000)
 		return -EINVAL;
 
+	bridge_state->hs_rate_min =
+		crtc_state->adjusted_mode.clock *
+		mipi_dsi_pixel_format_to_bpp(tc->dsi->format);
+	/* Split video data transfer across multiple lanes */
+	bridge_state->hs_rate_min /= tc->dsi->lanes;
+	/* DSI bus is DDR */
+	bridge_state->hs_rate_min /= 2;
+	/* Apply 1.2 DSI protocol overhead */
+	bridge_state->hs_rate_min =
+		bridge_state->hs_rate_min * 12 / 10;
+
+	/*
+	 * The bridge supports maximum DPI resolution 1366x768 24bpp 60Hz
+	 * and is not capable of running at full 500 MHz in all data lane
+	 * configurations at least in DSI-to-DPI mode.
+	 */
+	dpi_max_pixrate = 1366 * 768 * 24 * 60 / 1000;
+	bridge_state->hs_rate_max =
+		clamp((dpi_max_pixrate * 12 / 10) / tc->dsi->lanes / 2,
+		      0U, 500000U);
+
 	return 0;
 }
 
Signature · 1 line
2.35.1
#2 lore raw

PATCH 3/3 drm: bridge: samsung-dsim: Select DSI HS clock rate from downstream bridge limits

In reply to Marek Vasut

In case the downstream bridge state reports DSI HS clock minimum and maximum limits, find the most suitable DSI HS clock rate and use it for the DSI link.

---
Cc: Laurent Pinchart <[email protected]>
Cc: Lucas Stach <[email protected]>
Cc: Maxime Ripard <[email protected]>
Cc: Robert Foss <[email protected]>
Cc: Sam Ravnborg <[email protected]>

---
 drivers/gpu/drm/bridge/samsung-dsim.c | 34 +++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
drivers/gpu/drm/bridge/samsung-dsim.c +34 -0
index 9623923036292..697329d0faa35 100644
@@ -1399,7 +1399,41 @@ static int samsung_dsim_atomic_check(struct drm_bridge *bridge,
 {
 	struct samsung_dsim *dsi = bridge_to_dsi(bridge);
 	struct drm_display_mode *adjusted_mode = &crtc_state->adjusted_mode;
+	struct drm_bridge *next_bridge = drm_bridge_get_next_bridge(bridge);
+	struct drm_bridge_state *next_bridge_state;
 
+	/* This DSIM bridge can produce HS clock in range of 12..750 MHz */
+	bridge_state->hs_rate_min = 12000;
+	bridge_state->hs_rate_max = 750000;
+
+	if (next_bridge) {
+		next_bridge_state = drm_atomic_get_new_bridge_state(crtc_state->state,
+								    next_bridge);
+		/*
+		 * This bridge ability to provide HS clock does not overlap
+		 * with next bridge HS clock requirements, link constraints
+		 * are not met and link can not be operational.
+		 */
+		if (bridge_state->hs_rate_max < next_bridge_state->hs_rate_min ||
+		    bridge_state->hs_rate_min > next_bridge_state->hs_rate_max)
+			goto exit;
+
+		/*
+		 * In case the nearest bridge specifies DSI HS clock rate
+		 * and supports DSI burst mode, run the DSI link at highest
+		 * supported DSI HS clock frequency to achieve the shortest
+		 * transfer bursts, longest time in LP mode between bursts,
+		 * and thus most power efficient transfer.
+		 *
+		 * Note that DSI HS clock lane frequency is
+		 * DSIM PLL output / 2 .
+		 */
+		dsi->burst_clk_rate = min(bridge_state->hs_rate_max,
+					  next_bridge_state->hs_rate_max) *
+				      2 * 1000;
+	}
+
+exit:
 	/*
 	 * The i.MX8M Mini/Nano glue logic between LCDIF and DSIM
 	 * inverts HS/VS/DE sync signals polarity, therefore, while
Signature · 1 line
2.35.1