Skip to contentSkip to conversation

drm/bridge/synopsys: dsi: use mipi_dsi_device to find panel or bridge

PATCH In review Heiko Stuebner 2 participants 3 messages Dec 17, 2019 – Jan 6, 2020

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

PATCH 1/1 drm/bridge/synopsys: dsi: use mipi_dsi_device to find panel or bridge

From: Heiko Stuebner <[email protected]>

Right now the dsi driver uses drm_of_find_panel_or_bridge() to find a connected panel or bridge. But this requires an of-graph connection between the dsi-host and dsi-device, where normal bindings for regular panels just expect the dsi device to be a subnode of the actual dsi host not requiring ports.

drm_of_find_panel_or_bridge is used to find panel/bridge under the actual device-node of the dsi device, but as this happens in the dsi_host_attach callback we already have the dsi-device and its device-node available and therefore can just call the relevant panel+bridge functions ourself, making it work as well in setups without port-connections.

Tested on a Rockchip px30 single-dsi with panels form Leadtek and Xinpeng as well on Gru-Scarlet (rk3399) with dual-dsi (and thus port-connections to both dsi controllers) connected to the Innotek display variant.

changes in v2:
- rework commit message, rereading what I had written was just too cringe-worthy ;-)

---
 drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +10 -7
index 981d532cdd59..4b4961e7c680 100644
@@ -26,6 +26,7 @@
 #include <drm/drm_mipi_dsi.h>
 #include <drm/drm_modes.h>
 #include <drm/drm_of.h>
+#include <drm/drm_panel.h>
 #include <drm/drm_print.h>
 #include <drm/drm_probe_helper.h>
 
@@ -310,16 +311,16 @@ static int dw_mipi_dsi_host_attach(struct mipi_dsi_host *host,
 	dsi->format = device->format;
 	dsi->mode_flags = device->mode_flags;
 
-	ret = drm_of_find_panel_or_bridge(host->dev->of_node, 1, 0,
-					  &panel, &bridge);
-	if (ret)
-		return ret;
-
-	if (panel) {
+	panel = of_drm_find_panel(device->dev.of_node);
+	if (!IS_ERR(panel)) {
 		bridge = drm_panel_bridge_add_typed(panel,
 						    DRM_MODE_CONNECTOR_DSI);
 		if (IS_ERR(bridge))
 			return PTR_ERR(bridge);
+	} else {
+		bridge = of_drm_find_bridge(device->dev.of_node);
+		if (!bridge)
+			return -EPROBE_DEFER;
 	}
 
 	dsi->panel_bridge = bridge;
@@ -340,6 +341,7 @@ static int dw_mipi_dsi_host_detach(struct mipi_dsi_host *host,
 {
 	struct dw_mipi_dsi *dsi = host_to_dsi(host);
 	const struct dw_mipi_dsi_plat_data *pdata = dsi->plat_data;
+	struct drm_bridge *bridge;
 	int ret;
 
 	if (pdata->host_ops && pdata->host_ops->detach) {
@@ -348,7 +350,8 @@ static int dw_mipi_dsi_host_detach(struct mipi_dsi_host *host,
 			return ret;
 	}
 
-	drm_of_panel_bridge_remove(host->dev->of_node, 1, 0);
+	bridge = of_drm_find_bridge(device->dev.of_node);
+	drm_panel_bridge_remove(bridge);
 
 	drm_bridge_remove(&dsi->bridge);
 
Signature · 6 lines
2.24.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw

Hello Heiko,
I test with success your patch on a board stm32mp1 with a panel raydium rm68200.
I need more time to test with a HDMI bridge  like ad7533.

Best regards

Yannick Fertré

Quoted 71 lines · Heiko Stuebner

From: Heiko Stuebner <[email protected]>

Right now the dsi driver uses drm_of_find_panel_or_bridge() to find a connected panel or bridge. But this requires an of-graph connection between the dsi-host and dsi-device, where normal bindings for regular panels just expect the dsi device to be a subnode of the actual dsi host not requiring ports.

drm_of_find_panel_or_bridge is used to find panel/bridge under the actual device-node of the dsi device, but as this happens in the dsi_host_attach callback we already have the dsi-device and its device-node available and therefore can just call the relevant panel+bridge functions ourself, making it work as well in setups without port-connections.

Tested on a Rockchip px30 single-dsi with panels form Leadtek and Xinpeng as well on Gru-Scarlet (rk3399) with dual-dsi (and thus port-connections to both dsi controllers) connected to the Innotek display variant.

changes in v2:
- rework commit message, rereading what I had written was just too cringe-worthy ;-)

---
  drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 17 ++++++++++-------
  1 file changed, 10 insertions(+), 7 deletions(-)
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +8 -6
index 981d532cdd59..4b4961e7c680 100644
@@ -26,6 +26,7 @@
  #include <drm/drm_mipi_dsi.h>
  #include <drm/drm_modes.h>
  #include <drm/drm_of.h>
+#include <drm/drm_panel.h>
  #include <drm/drm_print.h>
  #include <drm/drm_probe_helper.h>
 
@@ -310,16 +311,16 @@ static int dw_mipi_dsi_host_attach(struct mipi_dsi_host *host,
  	dsi->format = device->format;
  	dsi->mode_flags = device->mode_flags;
 
-	ret = drm_of_find_panel_or_bridge(host->dev->of_node, 1, 0,
-					  &panel, &bridge);
-	if (ret)
-		return ret;
-
-	if (panel) {
+	panel = of_drm_find_panel(device->dev.of_node);
+	if (!IS_ERR(panel)) {
  		bridge = drm_panel_bridge_add_typed(panel,
  						    DRM_MODE_CONNECTOR_DSI);
  		if (IS_ERR(bridge))
  			return PTR_ERR(bridge);
+	} else {
+		bridge = of_drm_find_bridge(device->dev.of_node);
+		if (!bridge)
+			return -EPROBE_DEFER;
  	}
 
  	dsi->panel_bridge = bridge;
@@ -340,6 +341,7 @@ static int dw_mipi_dsi_host_detach(struct mipi_dsi_host *host,
  {
  	struct dw_mipi_dsi *dsi = host_to_dsi(host);
  	const struct dw_mipi_dsi_plat_data *pdata = dsi->plat_data;
+	struct drm_bridge *bridge;
  	int ret;
 
  	if (pdata->host_ops && pdata->host_ops->detach) {

drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c static int dw_mipi_dsi_host_detach(struct mipi_dsi_host *host, · line 357

Quoted 9 lines
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +2 -1
@@ -348,7 +350,8 @@ static int dw_mipi_dsi_host_detach(struct mipi_dsi_host *host,
  			return ret;
  	}
 
-	drm_of_panel_bridge_remove(host->dev->of_node, 1, 0);
+	bridge = of_drm_find_bridge(device->dev.of_node);
+	drm_panel_bridge_remove(bridge);
 
  	drm_bridge_remove(&dsi->bridge);
 

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#2 lore raw

Hi Yannick,

Am Freitag, 20. Dezember 2019, 16:52:47 CET schrieb Yannick FERTRE:

Quoted 4 lines

Hello Heiko,
I test with success your patch on a board stm32mp1 with a panel raydium rm68200.
I need more time to test with a HDMI bridge like ad7533.

I guess this was too short before the holiday season, so just a soft reminder, that you wanted to check that on that mentioned hdmi bridge :-)

Thanks
Heiko

Quoted 75 lines · Heiko Stuebner
Quoted 74 lines

From: Heiko Stuebner <[email protected]>

Right now the dsi driver uses drm_of_find_panel_or_bridge() to find a connected panel or bridge. But this requires an of-graph connection between the dsi-host and dsi-device, where normal bindings for regular panels just expect the dsi device to be a subnode of the actual dsi host not requiring ports.

drm_of_find_panel_or_bridge is used to find panel/bridge under the actual device-node of the dsi device, but as this happens in the dsi_host_attach callback we already have the dsi-device and its device-node available and therefore can just call the relevant panel+bridge functions ourself, making it work as well in setups without port-connections.

Tested on a Rockchip px30 single-dsi with panels form Leadtek and Xinpeng as well on Gru-Scarlet (rk3399) with dual-dsi (and thus port-connections to both dsi controllers) connected to the Innotek display variant.

changes in v2:
- rework commit message, rereading what I had written was just too cringe-worthy ;-)

---
  drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c | 17 ++++++++++-------
  1 file changed, 10 insertions(+), 7 deletions(-)
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +8 -6
index 981d532cdd59..4b4961e7c680 100644
@@ -26,6 +26,7 @@
  #include <drm/drm_mipi_dsi.h>
  #include <drm/drm_modes.h>
  #include <drm/drm_of.h>
+#include <drm/drm_panel.h>
  #include <drm/drm_print.h>
  #include <drm/drm_probe_helper.h>
 
@@ -310,16 +311,16 @@ static int dw_mipi_dsi_host_attach(struct mipi_dsi_host *host,
  	dsi->format = device->format;
  	dsi->mode_flags = device->mode_flags;
 
-	ret = drm_of_find_panel_or_bridge(host->dev->of_node, 1, 0,
-					  &panel, &bridge);
-	if (ret)
-		return ret;
-
-	if (panel) {
+	panel = of_drm_find_panel(device->dev.of_node);
+	if (!IS_ERR(panel)) {
  		bridge = drm_panel_bridge_add_typed(panel,
  						    DRM_MODE_CONNECTOR_DSI);
  		if (IS_ERR(bridge))
  			return PTR_ERR(bridge);
+	} else {
+		bridge = of_drm_find_bridge(device->dev.of_node);
+		if (!bridge)
+			return -EPROBE_DEFER;
  	}
 
  	dsi->panel_bridge = bridge;
@@ -340,6 +341,7 @@ static int dw_mipi_dsi_host_detach(struct mipi_dsi_host *host,
  {
  	struct dw_mipi_dsi *dsi = host_to_dsi(host);
  	const struct dw_mipi_dsi_plat_data *pdata = dsi->plat_data;
+	struct drm_bridge *bridge;
  	int ret;
 
  	if (pdata->host_ops && pdata->host_ops->detach) {
@@ -348,7 +350,8 @@ static int dw_mipi_dsi_host_detach(struct mipi_dsi_host *host,
  			return ret;
  	}
 
Quoted 7 lines

drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c static int dw_mipi_dsi_host_detach(struct mipi_dsi_host *host, · line 357

Quoted 6 lines
drivers/gpu/drm/bridge/synopsys/dw-mipi-dsi.c +2 -1
-	drm_of_panel_bridge_remove(host->dev->of_node, 1, 0);
+	bridge = of_drm_find_bridge(device->dev.of_node);
+	drm_panel_bridge_remove(bridge);
 
  	drm_bridge_remove(&dsi->bridge);
 

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel