Skip to contentSkip to conversation

drm: bridge: dw_hdmi: Add flag to indicate output port is optional

PATCH In review Marek Vasut 3 participants 11 messages Jan 5, 2025 – Jan 7, 2025

Subsystems (6)
lore
Share & tools
lore

Marek Vasut

author maintainer
#0 lore raw

PATCH v4 1/4 drm: bridge: dw_hdmi: Add flag to indicate output port is optional

Add a flag meant purely to work around broken i.MX8MP DTs which enable HDMI but do not contain the HDMI connector node. This flag allows such DTs to work by creating the connector in the HDMI bridge driver. Do not use this flag, do not proliferate this flag, please fix your DTs and add the connector node this way:

```
/ {
    hdmi-connector {
        compatible = "hdmi-connector";
        label = "FIXME-Board-Specific-Connector-Label"; // Modify this
        type = "a";

        port {
            hdmi_connector_in: endpoint {
                remote-endpoint = <&hdmi_tx_out>;
            };
        };
    };
};

&hdmi_tx {
    ...

    ports {
        port@1 {
            hdmi_tx_out: endpoint {
                remote-endpoint = <&hdmi_connector_in>;
            };
        };
    };
};
```

---
Cc: Andrzej Hajda <[email protected]>
Cc: David Airlie <[email protected]>
Cc: Fabio Estevam <[email protected]>
Cc: Jernej Skrabec <[email protected]>
Cc: Jonas Karlman <[email protected]>
Cc: Laurent Pinchart <[email protected]>
Cc: Liu Ying <[email protected]>
Cc: Maarten Lankhorst <[email protected]>
Cc: Maxime Ripard <[email protected]>
Cc: Neil Armstrong <[email protected]>
Cc: Pengutronix Kernel Team <[email protected]>
Cc: Robert Foss <[email protected]>
Cc: Sascha Hauer <[email protected]>
Cc: Shawn Guo <[email protected]>
Cc: Simona Vetter <[email protected]>
Cc: Stefan Agner <[email protected]>
Cc: Thomas Zimmermann <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
---
V3: New patch
V4: - Add HDMI connector node addition example into commit message
- Bail from dw_hdmi_bridge_attach() if DRM_BRIDGE_ATTACH_NO_CONNECTOR is set and there is no hdmi->next_bridge , so the connector can be created in scanout driver.

---
 drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 8 ++++++--
 include/drm/bridge/dw_hdmi.h              | 2 ++
 2 files changed, 8 insertions(+), 2 deletions(-)
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +6 -2
index 996733ed2c004..e84693faf46dc 100644
@@ -2893,9 +2893,13 @@ static int dw_hdmi_bridge_attach(struct drm_bridge *bridge,
 {
 	struct dw_hdmi *hdmi = bridge->driver_private;
 
-	if (flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR)
+	if (flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR) {
+		if (!hdmi->next_bridge)
+			return 0;
+
 		return drm_bridge_attach(bridge->encoder, hdmi->next_bridge,
 					 bridge, flags);
+	}
 
 	return dw_hdmi_connector_create(hdmi);
 }
@@ -3298,7 +3302,7 @@ static int dw_hdmi_parse_dt(struct dw_hdmi *hdmi)
 					  hdmi->plat_data->output_port,
 					  -1);
 	if (!remote)
-		return -ENODEV;
+		return hdmi->plat_data->output_port_optional ? 0 : -ENODEV;
 
 	hdmi->next_bridge = of_drm_find_bridge(remote);
 	of_node_put(remote);
include/drm/bridge/dw_hdmi.h +2 -0
index 6a46baa0737cd..3bb6e633424a8 100644
@@ -127,6 +127,8 @@ struct dw_hdmi_plat_data {
 	struct regmap *regm;
 
 	unsigned int output_port;
+	/* Used purely by MX8MP HDMI to work around broken DTs without HDMI connector node. */
+	bool output_port_optional;
 
 	unsigned long input_bus_encoding;
 	bool use_drm_infoframe;
Signature · 1 line
2.45.2
author maintainer
#1 lore raw

PATCH v4 2/4 drm/bridge: imx8mp-hdmi-tx: switch to bridge DRM_BRIDGE_ATTACH_NO_CONNECTOR

The dw-hdmi output_port is set to 1 in order to look for a connector next bridge in order to get DRM_BRIDGE_ATTACH_NO_CONNECTOR working. The output_port set to 1 makes the DW HDMI driver core look up the next bridge in DT, where the next bridge is often the hdmi-connector .

Similar to 0af5e0b41110 ("drm/meson: encoder_hdmi: switch to bridge DRM_BRIDGE_ATTACH_NO_CONNECTOR")

Note that looking at the upstream arch/arm64/boot/dts/freescale/imx8mp*dts , the oldest commit which adds HDMI support is commit:

3e67a1ddd56d ("arm64: dts: imx8mp: Enable HDMI on TQMa8MPxL/MBa8MPxL")

That already contains the HDMI connector node. Most follow up additions of HDMI support to another devices has been a variation of the same commit, including connector node, which is the proper way of eanbling HDMI on the i.MX8MP.

The rest should be covered by output_port_optional which should make systems with DTs without HDMI connector node work, but such DTs should be updated and the HDMI connector node should be added.

---
Cc: Andrzej Hajda <[email protected]>
Cc: David Airlie <[email protected]>
Cc: Fabio Estevam <[email protected]>
Cc: Jernej Skrabec <[email protected]>
Cc: Jonas Karlman <[email protected]>
Cc: Laurent Pinchart <[email protected]>
Cc: Liu Ying <[email protected]>
Cc: Maarten Lankhorst <[email protected]>
Cc: Maxime Ripard <[email protected]>
Cc: Neil Armstrong <[email protected]>
Cc: Pengutronix Kernel Team <[email protected]>
Cc: Robert Foss <[email protected]>
Cc: Sascha Hauer <[email protected]>
Cc: Shawn Guo <[email protected]>
Cc: Simona Vetter <[email protected]>
Cc: Stefan Agner <[email protected]>
Cc: Thomas Zimmermann <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
---
V2: No change
V3: - Update commit message
- Move select DRM_DISPLAY_CONNECTOR to DRM_IMX8MP_DW_HDMI_BRIDGE
- Enable output_port_optional
V4: - Remove select DRM_DISPLAY_CONNECTOR

---
 drivers/gpu/drm/bridge/imx/imx8mp-hdmi-tx.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/bridge/imx/imx8mp-hdmi-tx.c +2 -0
index 1e7a789ec2890..3d63200e468bf 100644
@@ -101,6 +101,8 @@ static int imx8mp_dw_hdmi_probe(struct platform_device *pdev)
 	plat_data->phy_name = "SAMSUNG HDMI TX PHY";
 	plat_data->priv_data = hdmi;
 	plat_data->phy_force_vendor = true;
+	plat_data->output_port = 1;
+	plat_data->output_port_optional = true;
 
 	hdmi->dw_hdmi = dw_hdmi_probe(pdev, plat_data);
 	if (IS_ERR(hdmi->dw_hdmi))
Signature · 1 line
2.45.2
maintainer
#2 lore raw

Re: [PATCH v4 2/4] drm/bridge: imx8mp-hdmi-tx: switch to bridge DRM_BRIDGE_ATTACH_NO_CONNECTOR

Quoted 58 lines · Marek Vasut

The dw-hdmi output_port is set to 1 in order to look for a connector next bridge in order to get DRM_BRIDGE_ATTACH_NO_CONNECTOR working. The output_port set to 1 makes the DW HDMI driver core look up the next bridge in DT, where the next bridge is often the hdmi-connector .

Similar to 0af5e0b41110 ("drm/meson: encoder_hdmi: switch to bridge DRM_BRIDGE_ATTACH_NO_CONNECTOR")

Note that looking at the upstream arch/arm64/boot/dts/freescale/imx8mp*dts , the oldest commit which adds HDMI support is commit:

3e67a1ddd56d ("arm64: dts: imx8mp: Enable HDMI on TQMa8MPxL/MBa8MPxL")

That already contains the HDMI connector node. Most follow up additions of HDMI support to another devices has been a variation of the same commit, including connector node, which is the proper way of eanbling HDMI on the i.MX8MP.

The rest should be covered by output_port_optional which should make systems with DTs without HDMI connector node work, but such DTs should be updated and the HDMI connector node should be added.

---
Cc: Andrzej Hajda <[email protected]>
Cc: David Airlie <[email protected]>
Cc: Fabio Estevam <[email protected]>
Cc: Jernej Skrabec <[email protected]>
Cc: Jonas Karlman <[email protected]>
Cc: Laurent Pinchart <[email protected]>
Cc: Liu Ying <[email protected]>
Cc: Maarten Lankhorst <[email protected]>
Cc: Maxime Ripard <[email protected]>
Cc: Neil Armstrong <[email protected]>
Cc: Pengutronix Kernel Team <[email protected]>
Cc: Robert Foss <[email protected]>
Cc: Sascha Hauer <[email protected]>
Cc: Shawn Guo <[email protected]>
Cc: Simona Vetter <[email protected]>
Cc: Stefan Agner <[email protected]>
Cc: Thomas Zimmermann <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
---
V2: No change
V3: - Update commit message
- Move select DRM_DISPLAY_CONNECTOR to DRM_IMX8MP_DW_HDMI_BRIDGE
- Enable output_port_optional
V4: - Remove select DRM_DISPLAY_CONNECTOR

---
 drivers/gpu/drm/bridge/imx/imx8mp-hdmi-tx.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/bridge/imx/imx8mp-hdmi-tx.c +0 -0
index 1e7a789ec2890..3d63200e468bf 100644

drivers/gpu/drm/bridge/imx/imx8mp-hdmi-tx.c static int imx8mp_dw_hdmi_probe(struct platform_device *pdev) · line 104

Quoted 4 lines
drivers/gpu/drm/bridge/imx/imx8mp-hdmi-tx.c +1 -0
@@ -101,6 +101,8 @@ static int imx8mp_dw_hdmi_probe(struct platform_device *pdev)
 	plat_data->phy_name = "SAMSUNG HDMI TX PHY";
 	plat_data->priv_data = hdmi;
 	plat_data->phy_force_vendor = true;
+	plat_data->output_port = 1;

How would you keep the behaviour of the connector after adding DRM_BRIDGE_ATTACH_NO_CONNECTOR in display controller driver? dw_hdmi_connector_create() implements CEC support at least. This was pointed out in v2 and v3 comments.

https://lore.kernel.org/all/vvsj6ri2ke25nzocbq736yv7rphzma6pn3yk2uh7iu43zfe2sa@2fwye4k4w6he/

Quoted 4 lines
drivers/gpu/drm/bridge/imx/imx8mp-hdmi-tx.c +1 -0
+	plat_data->output_port_optional = true;
 
 	hdmi->dw_hdmi = dw_hdmi_probe(pdev, plat_data);
 	if (IS_ERR(hdmi->dw_hdmi))
Signature · 2 lines
Regards,
Liu Ying
author maintainer
#3 lore raw

Re: [PATCH v4 2/4] drm/bridge: imx8mp-hdmi-tx: switch to bridge DRM_BRIDGE_ATTACH_NO_CONNECTOR

Quoted 69 lines · Liu Ying
Quoted 58 lines · Marek Vasut

The dw-hdmi output_port is set to 1 in order to look for a connector next bridge in order to get DRM_BRIDGE_ATTACH_NO_CONNECTOR working. The output_port set to 1 makes the DW HDMI driver core look up the next bridge in DT, where the next bridge is often the hdmi-connector .

Similar to 0af5e0b41110 ("drm/meson: encoder_hdmi: switch to bridge DRM_BRIDGE_ATTACH_NO_CONNECTOR")

Note that looking at the upstream arch/arm64/boot/dts/freescale/imx8mp*dts , the oldest commit which adds HDMI support is commit:

3e67a1ddd56d ("arm64: dts: imx8mp: Enable HDMI on TQMa8MPxL/MBa8MPxL")

That already contains the HDMI connector node. Most follow up additions of HDMI support to another devices has been a variation of the same commit, including connector node, which is the proper way of eanbling HDMI on the i.MX8MP.

The rest should be covered by output_port_optional which should make systems with DTs without HDMI connector node work, but such DTs should be updated and the HDMI connector node should be added.

---
Cc: Andrzej Hajda <[email protected]>
Cc: David Airlie <[email protected]>
Cc: Fabio Estevam <[email protected]>
Cc: Jernej Skrabec <[email protected]>
Cc: Jonas Karlman <[email protected]>
Cc: Laurent Pinchart <[email protected]>
Cc: Liu Ying <[email protected]>
Cc: Maarten Lankhorst <[email protected]>
Cc: Maxime Ripard <[email protected]>
Cc: Neil Armstrong <[email protected]>
Cc: Pengutronix Kernel Team <[email protected]>
Cc: Robert Foss <[email protected]>
Cc: Sascha Hauer <[email protected]>
Cc: Shawn Guo <[email protected]>
Cc: Simona Vetter <[email protected]>
Cc: Stefan Agner <[email protected]>
Cc: Thomas Zimmermann <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
---
V2: No change
V3: - Update commit message
- Move select DRM_DISPLAY_CONNECTOR to DRM_IMX8MP_DW_HDMI_BRIDGE
- Enable output_port_optional
V4: - Remove select DRM_DISPLAY_CONNECTOR

---
  drivers/gpu/drm/bridge/imx/imx8mp-hdmi-tx.c | 2 ++
  1 file changed, 2 insertions(+)
drivers/gpu/drm/bridge/imx/imx8mp-hdmi-tx.c +0 -0
index 1e7a789ec2890..3d63200e468bf 100644

drivers/gpu/drm/bridge/imx/imx8mp-hdmi-tx.c static int imx8mp_dw_hdmi_probe(struct platform_device *pdev) · line 104

Quoted 4 lines
drivers/gpu/drm/bridge/imx/imx8mp-hdmi-tx.c +1 -0
@@ -101,6 +101,8 @@ static int imx8mp_dw_hdmi_probe(struct platform_device *pdev)
  	plat_data->phy_name = "SAMSUNG HDMI TX PHY";
  	plat_data->priv_data = hdmi;
  	plat_data->phy_force_vendor = true;
+	plat_data->output_port = 1;

How would you keep the behaviour of the connector after adding DRM_BRIDGE_ATTACH_NO_CONNECTOR in display controller driver? dw_hdmi_connector_create() implements CEC support at least. This was pointed out in v2 and v3 comments.

Quoted 1 line

https://lore.kernel.org/all/vvsj6ri2ke25nzocbq736yv7rphzma6pn3yk2uh7iu43zfe2sa@2fwye4k4w6he/

As far as I understand it, the CEC is being worked on separately already ?

author maintainer
#4 lore raw

PATCH v4 3/4 drm/mxsfb: add DRM_BRIDGE_ATTACH_NO_CONNECTOR flag to drm_bridge_attach

In reply to Marek Vasut

Commit a25b988ff83f ("drm/bridge: Extend bridge API to disable connector creation") added DRM_BRIDGE_ATTACH_NO_CONNECTOR bridge flag and all bridges handle this flag in some way since then.
Newly added bridge drivers must no longer contain the connector creation and will fail probing if this flag isn't set.

In order to be able to connect to those newly added bridges as well, make use of drm_bridge_connector API and have the connector initialized by the display controller.

Based on 2e87bf389e13 ("drm/rockchip: add DRM_BRIDGE_ATTACH_NO_CONNECTOR flag to drm_bridge_attach")

This makes LT9611 work with i.MX8M Mini.

---
Cc: Andrzej Hajda <[email protected]>
Cc: David Airlie <[email protected]>
Cc: Fabio Estevam <[email protected]>
Cc: Jernej Skrabec <[email protected]>
Cc: Jonas Karlman <[email protected]>
Cc: Laurent Pinchart <[email protected]>
Cc: Liu Ying <[email protected]>
Cc: Maarten Lankhorst <[email protected]>
Cc: Maxime Ripard <[email protected]>
Cc: Neil Armstrong <[email protected]>
Cc: Pengutronix Kernel Team <[email protected]>
Cc: Robert Foss <[email protected]>
Cc: Sascha Hauer <[email protected]>
Cc: Shawn Guo <[email protected]>
Cc: Simona Vetter <[email protected]>
Cc: Stefan Agner <[email protected]>
Cc: Thomas Zimmermann <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
---
V2: Cache connector from drm_bridge_connector_init()
V3: - Add RB from Dmitry
- Select DRM_DISPLAY_HELPER
- Use return dev_err_probe() directly
- Drop the single use fail path
V4: - Swap the DRM_BRIDGE_CONNECTOR and DRM_DISPLAY_HELPER in the right symbols
- Reorder the patches, swap 3/4 and 4/4 in the series

---
 drivers/gpu/drm/mxsfb/Kconfig     |  2 ++
 drivers/gpu/drm/mxsfb/mxsfb_drv.c | 31 ++++++++++++++++++++-----------
 2 files changed, 22 insertions(+), 11 deletions(-)
drivers/gpu/drm/mxsfb/Kconfig +2 -0
index 264e74f455547..26bb2dbba49e3 100644
@@ -10,8 +10,10 @@ config DRM_MXSFB
 	depends on COMMON_CLK
 	depends on ARCH_MXS || ARCH_MXC || COMPILE_TEST
 	select DRM_CLIENT_SELECTION
+	select DRM_DISPLAY_HELPER
 	select DRM_MXS
 	select DRM_KMS_HELPER
+	select DRM_BRIDGE_CONNECTOR
 	select DRM_GEM_DMA_HELPER
 	select DRM_PANEL
 	select DRM_PANEL_BRIDGE
drivers/gpu/drm/mxsfb/mxsfb_drv.c +20 -11
index 59020862cf65e..07784c4f5be48 100644
@@ -20,6 +20,7 @@
 #include <drm/clients/drm_client_setup.h>
 #include <drm/drm_atomic_helper.h>
 #include <drm/drm_bridge.h>
+#include <drm/drm_bridge_connector.h>
 #include <drm/drm_connector.h>
 #include <drm/drm_drv.h>
 #include <drm/drm_fbdev_dma.h>
@@ -119,9 +120,9 @@ static const struct drm_mode_config_helper_funcs mxsfb_mode_config_helpers = {
 static int mxsfb_attach_bridge(struct mxsfb_drm_private *mxsfb)
 {
 	struct drm_device *drm = mxsfb->drm;
-	struct drm_connector_list_iter iter;
-	struct drm_panel *panel;
+	struct drm_connector *connector;
 	struct drm_bridge *bridge;
+	struct drm_panel *panel;
 	int ret;
 
 	ret = drm_of_find_panel_or_bridge(drm->dev->of_node, 0, 0, &panel,
@@ -139,19 +140,27 @@ static int mxsfb_attach_bridge(struct mxsfb_drm_private *mxsfb)
 	if (!bridge)
 		return -ENODEV;
 
-	ret = drm_bridge_attach(&mxsfb->encoder, bridge, NULL, 0);
+	ret = drm_bridge_attach(&mxsfb->encoder, bridge, NULL,
+				DRM_BRIDGE_ATTACH_NO_CONNECTOR);
 	if (ret)
 		return dev_err_probe(drm->dev, ret, "Failed to attach bridge\n");
 
-	mxsfb->bridge = bridge;
+	connector = drm_bridge_connector_init(drm, &mxsfb->encoder);
+	if (IS_ERR(connector)) {
+		return dev_err_probe(drm->dev, PTR_ERR(connector),
+				     "Failed to initialize bridge connector: %pe\n",
+				     connector);
+	}
 
-	/*
-	 * Get hold of the connector. This is a bit of a hack, until the bridge
-	 * API gives us bus flags and formats.
-	 */
-	drm_connector_list_iter_begin(drm, &iter);
-	mxsfb->connector = drm_connector_list_iter_next(&iter);
-	drm_connector_list_iter_end(&iter);
+	ret = drm_connector_attach_encoder(connector, &mxsfb->encoder);
+	if (ret < 0) {
+		drm_connector_cleanup(connector);
+		return dev_err_probe(drm->dev, ret,
+				     "Failed to attach encoder.\n");
+	}
+
+	mxsfb->bridge = bridge;
+	mxsfb->connector = connector;
 
 	return 0;
 }
Signature · 1 line
2.45.2
author maintainer
#5 lore raw

PATCH v4 4/4 drm/lcdif: add DRM_BRIDGE_ATTACH_NO_CONNECTOR flag to drm_bridge_attach

In reply to Marek Vasut

Commit a25b988ff83f ("drm/bridge: Extend bridge API to disable connector creation") added DRM_BRIDGE_ATTACH_NO_CONNECTOR bridge flag and all bridges handle this flag in some way since then.
Newly added bridge drivers must no longer contain the connector creation and will fail probing if this flag isn't set.

In order to be able to connect to those newly added bridges as well, make use of drm_bridge_connector API and have the connector initialized by the display controller.

Based on 2e87bf389e13 ("drm/rockchip: add DRM_BRIDGE_ATTACH_NO_CONNECTOR flag to drm_bridge_attach")

This makes LT9611 work with i.MX8M Plus.

---
Cc: Andrzej Hajda <[email protected]>
Cc: David Airlie <[email protected]>
Cc: Fabio Estevam <[email protected]>
Cc: Jernej Skrabec <[email protected]>
Cc: Jonas Karlman <[email protected]>
Cc: Laurent Pinchart <[email protected]>
Cc: Liu Ying <[email protected]>
Cc: Maarten Lankhorst <[email protected]>
Cc: Maxime Ripard <[email protected]>
Cc: Neil Armstrong <[email protected]>
Cc: Pengutronix Kernel Team <[email protected]>
Cc: Robert Foss <[email protected]>
Cc: Sascha Hauer <[email protected]>
Cc: Shawn Guo <[email protected]>
Cc: Simona Vetter <[email protected]>
Cc: Stefan Agner <[email protected]>
Cc: Thomas Zimmermann <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
---
V2: Add RB from Dmitry
V3: - Select DRM_DISPLAY_HELPER
- Use return dev_err_probe() directly
- Add missing of_node_put(ep)
- Add test using drm_bridge_get_next_bridge() to try and determine if the HDMI connector was missing in DT or not, and if it was missing, if it was created by the HDMI bridge driver.
V4: - Swap the DRM_BRIDGE_CONNECTOR and DRM_DISPLAY_HELPER in the right symbols
- Reorder the patches, swap 3/4 and 4/4 in the series
- Drop the HDMI bridge test, create connector here

---
 drivers/gpu/drm/mxsfb/Kconfig     |  2 ++
 drivers/gpu/drm/mxsfb/lcdif_drv.c | 24 ++++++++++++++++++++++--
 2 files changed, 24 insertions(+), 2 deletions(-)
drivers/gpu/drm/mxsfb/Kconfig +2 -0
index 26bb2dbba49e3..eb51d38455a6c 100644
@@ -30,8 +30,10 @@ config DRM_IMX_LCDIF
 	depends on COMMON_CLK
 	depends on ARCH_MXC || COMPILE_TEST
 	select DRM_CLIENT_SELECTION
+	select DRM_DISPLAY_HELPER
 	select DRM_MXS
 	select DRM_KMS_HELPER
+	select DRM_BRIDGE_CONNECTOR
 	select DRM_GEM_DMA_HELPER
 	select DRM_PANEL
 	select DRM_PANEL_BRIDGE
drivers/gpu/drm/mxsfb/lcdif_drv.c +22 -2
index 8ee00f59ca821..d6a4100e6080a 100644
@@ -17,6 +17,7 @@
 #include <drm/clients/drm_client_setup.h>
 #include <drm/drm_atomic_helper.h>
 #include <drm/drm_bridge.h>
+#include <drm/drm_bridge_connector.h>
 #include <drm/drm_drv.h>
 #include <drm/drm_encoder.h>
 #include <drm/drm_fbdev_dma.h>
@@ -48,8 +49,10 @@ static const struct drm_encoder_funcs lcdif_encoder_funcs = {
 static int lcdif_attach_bridge(struct lcdif_drm_private *lcdif)
 {
 	struct device *dev = lcdif->drm->dev;
-	struct device_node *ep;
+	struct drm_device *drm = lcdif->drm;
+	struct drm_connector *connector;
 	struct drm_bridge *bridge;
+	struct device_node *ep;
 	int ret;
 
 	for_each_endpoint_of_node(dev->of_node, ep) {
@@ -97,13 +100,30 @@ static int lcdif_attach_bridge(struct lcdif_drm_private *lcdif)
 			return ret;
 		}
 
-		ret = drm_bridge_attach(encoder, bridge, NULL, 0);
+		ret = drm_bridge_attach(encoder, bridge, NULL,
+					DRM_BRIDGE_ATTACH_NO_CONNECTOR);
 		if (ret) {
 			of_node_put(ep);
 			return dev_err_probe(dev, ret,
 					     "Failed to attach bridge for endpoint%u\n",
 					     of_ep.id);
 		}
+
+		connector = drm_bridge_connector_init(drm, encoder);
+		if (IS_ERR(connector)) {
+			of_node_put(ep);
+			return dev_err_probe(drm->dev, PTR_ERR(connector),
+					     "Failed to initialize bridge connector: %pe\n",
+					     connector);
+		}
+
+		ret = drm_connector_attach_encoder(connector, encoder);
+		if (ret < 0) {
+			of_node_put(ep);
+			drm_connector_cleanup(connector);
+			return dev_err_probe(drm->dev, ret,
+					     "Failed to attach encoder.\n");
+		}
 	}
 
 	return 0;
Signature · 1 line
2.45.2
#6 lore raw
In reply to Marek Vasut

Hi Marek,

Thank you for the patch.

Quoted 25 lines · Marek Vasut

Add a flag meant purely to work around broken i.MX8MP DTs which enable HDMI but do not contain the HDMI connector node. This flag allows such DTs to work by creating the connector in the HDMI bridge driver. Do not use this flag, do not proliferate this flag, please fix your DTs and add the connector node this way:

```
/ {
    hdmi-connector {
        compatible = "hdmi-connector";
        label = "FIXME-Board-Specific-Connector-Label"; // Modify this
        type = "a";

        port {
            hdmi_connector_in: endpoint {
                remote-endpoint = <&hdmi_tx_out>;
            };
        };
    };
};

&hdmi_tx {
    ...

    ports {
Quoted 8 lines
        port@1 {
            hdmi_tx_out: endpoint {
                remote-endpoint = <&hdmi_connector_in>;
            };
        };
    };
};
```

Are there any in-tree DT sources that use the old bindings ?

Quoted 53 lines

---
Cc: Andrzej Hajda <[email protected]>
Cc: David Airlie <[email protected]>
Cc: Fabio Estevam <[email protected]>
Cc: Jernej Skrabec <[email protected]>
Cc: Jonas Karlman <[email protected]>
Cc: Laurent Pinchart <[email protected]>
Cc: Liu Ying <[email protected]>
Cc: Maarten Lankhorst <[email protected]>
Cc: Maxime Ripard <[email protected]>
Cc: Neil Armstrong <[email protected]>
Cc: Pengutronix Kernel Team <[email protected]>
Cc: Robert Foss <[email protected]>
Cc: Sascha Hauer <[email protected]>
Cc: Shawn Guo <[email protected]>
Cc: Simona Vetter <[email protected]>
Cc: Stefan Agner <[email protected]>
Cc: Thomas Zimmermann <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
---
V3: New patch
V4: - Add HDMI connector node addition example into commit message
- Bail from dw_hdmi_bridge_attach() if DRM_BRIDGE_ATTACH_NO_CONNECTOR is set and there is no hdmi->next_bridge , so the connector can be created in scanout driver.

---
 drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 8 ++++++--
 include/drm/bridge/dw_hdmi.h              | 2 ++
 2 files changed, 8 insertions(+), 2 deletions(-)
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +5 -1
index 996733ed2c004..e84693faf46dc 100644
@@ -2893,9 +2893,13 @@ static int dw_hdmi_bridge_attach(struct drm_bridge *bridge,
 {
 	struct dw_hdmi *hdmi = bridge->driver_private;
 
-	if (flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR)
+	if (flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR) {
+		if (!hdmi->next_bridge)
+			return 0;
+
 		return drm_bridge_attach(bridge->encoder, hdmi->next_bridge,
 					 bridge, flags);
+	}
 
 	return dw_hdmi_connector_create(hdmi);
 }

drivers/gpu/drm/bridge/synopsys/dw-hdmi.c static int dw_hdmi_parse_dt(struct dw_hdmi *hdmi) · line 3305

Quoted 5 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +1 -1
@@ -3298,7 +3302,7 @@ static int dw_hdmi_parse_dt(struct dw_hdmi *hdmi)
 					  hdmi->plat_data->output_port,
 					  -1);
 	if (!remote)
-		return -ENODEV;
+		return hdmi->plat_data->output_port_optional ? 0 : -ENODEV;

Let's complain loudly with a WARN_ON if output_port_optional is set.

Quoted 16 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +0 -0
 	hdmi->next_bridge = of_drm_find_bridge(remote);
 	of_node_put(remote);
include/drm/bridge/dw_hdmi.h +2 -0
index 6a46baa0737cd..3bb6e633424a8 100644
@@ -127,6 +127,8 @@ struct dw_hdmi_plat_data {
 	struct regmap *regm;
 
 	unsigned int output_port;
+	/* Used purely by MX8MP HDMI to work around broken DTs without HDMI connector node. */
+	bool output_port_optional;
 
 	unsigned long input_bus_encoding;
 	bool use_drm_infoframe;
Signature · 3 lines
Regards,

Laurent Pinchart
author maintainer
#7 lore raw
Quoted 1 line · Laurent Pinchart

Hi Marek,

Hi,

Quoted 37 lines

Thank you for the patch.

Quoted 25 lines · Marek Vasut

Add a flag meant purely to work around broken i.MX8MP DTs which enable HDMI but do not contain the HDMI connector node. This flag allows such DTs to work by creating the connector in the HDMI bridge driver. Do not use this flag, do not proliferate this flag, please fix your DTs and add the connector node this way:

```
/ {
     hdmi-connector {
         compatible = "hdmi-connector";
         label = "FIXME-Board-Specific-Connector-Label"; // Modify this
         type = "a";

         port {
             hdmi_connector_in: endpoint {
                 remote-endpoint = <&hdmi_tx_out>;
             };
         };
     };
};

&hdmi_tx {
     ...

     ports {
Quoted 8 lines
         port@1 {
             hdmi_tx_out: endpoint {
                 remote-endpoint = <&hdmi_connector_in>;
             };
         };
     };
};
```
Quoted 1 line

Are there any in-tree DT sources that use the old bindings ?

See https://lore.kernel.org/dri-devel/AM7PR04MB704688150ACD5D209290246A98092@AM7PR04MB7046.eurprd04.prod.outlook.com/

The rest is fixed, thanks.

#8 lore raw
Quoted 42 lines · Marek Vasut
Quoted 1 line · Laurent Pinchart

Hi Marek,

Hi,

Quoted 37 lines

Thank you for the patch.

Quoted 33 lines · Marek Vasut

Add a flag meant purely to work around broken i.MX8MP DTs which enable HDMI but do not contain the HDMI connector node. This flag allows such DTs to work by creating the connector in the HDMI bridge driver. Do not use this flag, do not proliferate this flag, please fix your DTs and add the connector node this way:

```
/ {
     hdmi-connector {
         compatible = "hdmi-connector";
         label = "FIXME-Board-Specific-Connector-Label"; // Modify this
         type = "a";

         port {
             hdmi_connector_in: endpoint {
                 remote-endpoint = <&hdmi_tx_out>;
             };
         };
     };
};

&hdmi_tx {
     ...

     ports {
         port@1 {
             hdmi_tx_out: endpoint {
                 remote-endpoint = <&hdmi_connector_in>;
             };
         };
     };
};
```
Quoted 4 lines
Quoted 1 line

Are there any in-tree DT sources that use the old bindings ?

See
https://lore.kernel.org/dri-devel/AM7PR04MB704688150ACD5D209290246A98092@AM7PR04MB7046.eurprd04.prod.outlook.com/

Maybe I'm missing something obvious, but where is the patch series that moves the DT sources mentioned in that mail thread to the new bindings ?

Quoted 1 line

The rest is fixed, thanks.

Signature · 3 lines
Regards,

Laurent Pinchart
author maintainer
#9 lore raw
Quoted 43 lines · Laurent Pinchart
Quoted 42 lines · Marek Vasut
Quoted 1 line · Laurent Pinchart

Hi Marek,

Hi,

Quoted 37 lines

Thank you for the patch.

Quoted 33 lines · Marek Vasut

Add a flag meant purely to work around broken i.MX8MP DTs which enable HDMI but do not contain the HDMI connector node. This flag allows such DTs to work by creating the connector in the HDMI bridge driver. Do not use this flag, do not proliferate this flag, please fix your DTs and add the connector node this way:

```
/ {
      hdmi-connector {
          compatible = "hdmi-connector";
          label = "FIXME-Board-Specific-Connector-Label"; // Modify this
          type = "a";

          port {
              hdmi_connector_in: endpoint {
                  remote-endpoint = <&hdmi_tx_out>;
              };
          };
      };
};

&hdmi_tx {
      ...

      ports {
          port@1 {
              hdmi_tx_out: endpoint {
                  remote-endpoint = <&hdmi_connector_in>;
              };
          };
      };
};
```
Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Are there any in-tree DT sources that use the old bindings ?

See
https://lore.kernel.org/dri-devel/AM7PR04MB704688150ACD5D209290246A98092@AM7PR04MB7046.eurprd04.prod.outlook.com/

Maybe I'm missing something obvious, but where is the patch series that moves the DT sources mentioned in that mail thread to the new bindings ?

Since this optional flag is added, that DT update series can be done separately.

#10 lore raw
Quoted 46 lines · Marek Vasut
Quoted 45 lines · Laurent Pinchart
Quoted 44 lines · Marek Vasut
Quoted 1 line · Laurent Pinchart

Hi Marek,

Hi,

Quoted 38 lines

Thank you for the patch.

Quoted 25 lines · Marek Vasut

Add a flag meant purely to work around broken i.MX8MP DTs which enable HDMI but do not contain the HDMI connector node. This flag allows such DTs to work by creating the connector in the HDMI bridge driver. Do not use this flag, do not proliferate this flag, please fix your DTs and add the connector node this way:

```
/ {
      hdmi-connector {
          compatible = "hdmi-connector";
          label = "FIXME-Board-Specific-Connector-Label"; // Modify this
          type = "a";

          port {
              hdmi_connector_in: endpoint {
                  remote-endpoint = <&hdmi_tx_out>;
              };
          };
      };
};

&hdmi_tx {
      ...

      ports {
Quoted 8 lines
          port@1 {
              hdmi_tx_out: endpoint {
                  remote-endpoint = <&hdmi_connector_in>;
              };
          };
      };
};
```

Are there any in-tree DT sources that use the old bindings ?

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

See
https://lore.kernel.org/dri-devel/AM7PR04MB704688150ACD5D209290246A98092@AM7PR04MB7046.eurprd04.prod.outlook.com/

Maybe I'm missing something obvious, but where is the patch series that moves the DT sources mentioned in that mail thread to the new bindings ?

Since this optional flag is added, that DT update series can be done separately.

It can, but I'd like to see it merged in the same time frame as this series, so it should be posted (and reviewed and tested).

Signature · 3 lines
Regards,

Laurent Pinchart