All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] Revert "drm: bridge: mcde_dsi: Drop explicit bridge remove"
@ 2022-04-29  8:53 Jagan Teki
  2022-04-29  8:53 ` [PATCH 2/2] Revert "drm: bridge: mcde_dsi: Switch to devm_drm_of_get_bridge" Jagan Teki
  0 siblings, 1 reply; 3+ messages in thread
From: Jagan Teki @ 2022-04-29  8:53 UTC (permalink / raw)
  To: Linus Walleij, Maxime Ripard, Laurent Pinchart
  Cc: linux-amarula, Jagan Teki, dri-devel

commit <3730bc6147b0> ("drm: bridge: mcde_dsi: Drop explicit bridge
remove") has removed downstream bridge as it's prior commit <3d7039e1e649>
("drm: bridge: mcde_dsi: Switch to devm_drm_of_get_bridge") added
devm_drm_of_get_bridge for looking up if child node has panel or bridge.

However commit <b089c0a9b14c> ("Revert "drm: of: Lookup if child node
has panel or bridge") has reverted panel or bridge child node lookup
from devm_drm_of_get_bridge as it breaks the non-trivial cases the
first child node might not be a panel or bridge.

So, revert this commit to switch the previous behavior of looking up
child panel or bridge.

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 drivers/gpu/drm/mcde/mcde_dsi.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/mcde/mcde_dsi.c b/drivers/gpu/drm/mcde/mcde_dsi.c
index 960b49ea2ee5..083a4728654d 100644
--- a/drivers/gpu/drm/mcde/mcde_dsi.c
+++ b/drivers/gpu/drm/mcde/mcde_dsi.c
@@ -1122,6 +1122,7 @@ static void mcde_dsi_unbind(struct device *dev, struct device *master,
 {
 	struct mcde_dsi *d = dev_get_drvdata(dev);
 
+	drm_bridge_remove(d->bridge_out);
 	regmap_update_bits(d->prcmu, PRCM_DSI_SW_RESET,
 			   PRCM_DSI_SW_RESET_DSI0_SW_RESETN, 0);
 }
-- 
2.25.1


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

* [PATCH 2/2] Revert "drm: bridge: mcde_dsi: Switch to devm_drm_of_get_bridge"
  2022-04-29  8:53 [PATCH 1/2] Revert "drm: bridge: mcde_dsi: Drop explicit bridge remove" Jagan Teki
@ 2022-04-29  8:53 ` Jagan Teki
  2022-04-29 22:26   ` Linus Walleij
  0 siblings, 1 reply; 3+ messages in thread
From: Jagan Teki @ 2022-04-29  8:53 UTC (permalink / raw)
  To: Linus Walleij, Maxime Ripard, Laurent Pinchart
  Cc: linux-amarula, Jagan Teki, dri-devel, Jagan Teki

From: Jagan Teki <jagan@edgeble.ai>

commit <3d7039e1e649> ("drm: bridge: mcde_dsi: Switch to devm_drm_of_get_bridge")
switched to devm_drm_of_get_bridge for looking up if child node has panel
or bridge.

However commit <b089c0a9b14c> ("Revert "drm: of: Lookup if child node
has panel or bridge") has reverted panel or bridge child node lookup
from devm_drm_of_get_bridge as it breaks the non-trivial cases the
first child node might not be a panel or bridge.

So, revert this commit to switch the previous behavior of looking up
child panel or bridge.

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
 drivers/gpu/drm/mcde/mcde_dsi.c | 44 ++++++++++++++++++++++++++++-----
 1 file changed, 38 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/mcde/mcde_dsi.c b/drivers/gpu/drm/mcde/mcde_dsi.c
index 083a4728654d..5651734ce977 100644
--- a/drivers/gpu/drm/mcde/mcde_dsi.c
+++ b/drivers/gpu/drm/mcde/mcde_dsi.c
@@ -19,6 +19,7 @@
 #include <drm/drm_mipi_dsi.h>
 #include <drm/drm_modeset_helper_vtables.h>
 #include <drm/drm_of.h>
+#include <drm/drm_panel.h>
 #include <drm/drm_print.h>
 #include <drm/drm_probe_helper.h>
 
@@ -38,6 +39,7 @@ struct mcde_dsi {
 	struct device *dev;
 	struct mcde *mcde;
 	struct drm_bridge bridge;
+	struct drm_panel *panel;
 	struct drm_bridge *bridge_out;
 	struct mipi_dsi_host dsi_host;
 	struct mipi_dsi_device *mdsi;
@@ -1071,7 +1073,9 @@ static int mcde_dsi_bind(struct device *dev, struct device *master,
 	struct drm_device *drm = data;
 	struct mcde *mcde = to_mcde(drm);
 	struct mcde_dsi *d = dev_get_drvdata(dev);
-	struct drm_bridge *bridge;
+	struct device_node *child;
+	struct drm_panel *panel = NULL;
+	struct drm_bridge *bridge = NULL;
 
 	if (!of_get_available_child_count(dev->of_node)) {
 		dev_info(dev, "unused DSI interface\n");
@@ -1096,10 +1100,37 @@ static int mcde_dsi_bind(struct device *dev, struct device *master,
 		return PTR_ERR(d->lp_clk);
 	}
 
-	bridge = devm_drm_of_get_bridge(dev, dev->of_node, 0, 0);
-	if (IS_ERR(bridge)) {
-		dev_err(dev, "error to get bridge\n");
-		return PTR_ERR(bridge);
+	/* Look for a panel as a child to this node */
+	for_each_available_child_of_node(dev->of_node, child) {
+		panel = of_drm_find_panel(child);
+		if (IS_ERR(panel)) {
+			dev_err(dev, "failed to find panel try bridge (%ld)\n",
+				PTR_ERR(panel));
+			panel = NULL;
+
+			bridge = of_drm_find_bridge(child);
+			if (!bridge) {
+				dev_err(dev, "failed to find bridge\n");
+				return -EINVAL;
+			}
+		}
+	}
+	if (panel) {
+		bridge = drm_panel_bridge_add_typed(panel,
+						    DRM_MODE_CONNECTOR_DSI);
+		if (IS_ERR(bridge)) {
+			dev_err(dev, "error adding panel bridge\n");
+			return PTR_ERR(bridge);
+		}
+		dev_info(dev, "connected to panel\n");
+		d->panel = panel;
+	} else if (bridge) {
+		/* TODO: AV8100 HDMI encoder goes here for example */
+		dev_info(dev, "connected to non-panel bridge (unsupported)\n");
+		return -ENODEV;
+	} else {
+		dev_err(dev, "no panel or bridge\n");
+		return -ENODEV;
 	}
 
 	d->bridge_out = bridge;
@@ -1122,7 +1153,8 @@ static void mcde_dsi_unbind(struct device *dev, struct device *master,
 {
 	struct mcde_dsi *d = dev_get_drvdata(dev);
 
-	drm_bridge_remove(d->bridge_out);
+	if (d->panel)
+		drm_panel_bridge_remove(d->bridge_out);
 	regmap_update_bits(d->prcmu, PRCM_DSI_SW_RESET,
 			   PRCM_DSI_SW_RESET_DSI0_SW_RESETN, 0);
 }
-- 
2.25.1


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

* Re: [PATCH 2/2] Revert "drm: bridge: mcde_dsi: Switch to devm_drm_of_get_bridge"
  2022-04-29  8:53 ` [PATCH 2/2] Revert "drm: bridge: mcde_dsi: Switch to devm_drm_of_get_bridge" Jagan Teki
@ 2022-04-29 22:26   ` Linus Walleij
  0 siblings, 0 replies; 3+ messages in thread
From: Linus Walleij @ 2022-04-29 22:26 UTC (permalink / raw)
  To: Jagan Teki
  Cc: Jagan Teki, linux-amarula, Maxime Ripard, dri-devel, Laurent Pinchart

On Fri, Apr 29, 2022 at 10:56 AM Jagan Teki <jagan@amarulasolutions.com> wrote:

> From: Jagan Teki <jagan@edgeble.ai>
>
> commit <3d7039e1e649> ("drm: bridge: mcde_dsi: Switch to devm_drm_of_get_bridge")
> switched to devm_drm_of_get_bridge for looking up if child node has panel
> or bridge.
>
> However commit <b089c0a9b14c> ("Revert "drm: of: Lookup if child node
> has panel or bridge") has reverted panel or bridge child node lookup
> from devm_drm_of_get_bridge as it breaks the non-trivial cases the
> first child node might not be a panel or bridge.
>
> So, revert this commit to switch the previous behavior of looking up
> child panel or bridge.
>
> Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

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

end of thread, other threads:[~2022-04-29 22:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-29  8:53 [PATCH 1/2] Revert "drm: bridge: mcde_dsi: Drop explicit bridge remove" Jagan Teki
2022-04-29  8:53 ` [PATCH 2/2] Revert "drm: bridge: mcde_dsi: Switch to devm_drm_of_get_bridge" Jagan Teki
2022-04-29 22:26   ` Linus Walleij

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.