Skip to contentSkip to conversation

Support bridge/connector by Tegra HDMI

PATCH Superseded Svyatoslav Ryhel 3 participants 11 messages Jun 18, 2023 – Aug 1, 2023

Subsystems (4)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover Support bridge/connector by Tegra HDMI

This patch adds support for the bridge/connector attached to the HDMI output, allowing to model the hardware properly. It keeps backwards compatibility with existing bindings and is required by devices which have a simple or MHL bridge connected to HDMI output like ASUS P1801-T or LG P880/P895 or HTC One X.

Tested on ASUS Transformers which have no dedicated bridge but have type d HDMI connector directly available. Tests went smoothly.

---

Chandes from v1:
- no changes, re-sending

---

Maxim Schwalm (1):
drm/tegra: output: hdmi: Support bridge/connector

Svyatoslav Ryhel (1):
ARM: tegra: transformers: add connector node

 arch/arm/boot/dts/tegra20-asus-tf101.dts      | 22 ++++++++--
 .../dts/tegra30-asus-transformer-common.dtsi  | 21 ++++++++-
 drivers/gpu/drm/tegra/hdmi.c                  | 44 ++++++++++++++-----
 3 files changed, 71 insertions(+), 16 deletions(-)
Signature · 1 line
2.39.2
#1 lore raw

PATCH v2 1/2 drm/tegra: output: hdmi: Support bridge/connector

From: Maxim Schwalm <[email protected]>

Some Tegra device-trees may specify a video output graph, which involves MHL bridge/simple bridge and/or connector framework. This patch adds support for the bridge/connector attached to the HDMI output, allowing us to model the hardware properly.

Inspired by: 29efdc2 ("drm/tegra: output: rgb: Support LVDS encoder bridge")

---
 drivers/gpu/drm/tegra/hdmi.c | 44 +++++++++++++++++++++++++++---------
 1 file changed, 33 insertions(+), 11 deletions(-)
drivers/gpu/drm/tegra/hdmi.c +33 -11
index 6eac54ae1205..a5b12b169e57 100644
@@ -19,6 +19,7 @@
 #include <soc/tegra/common.h>
 #include <sound/hdmi-codec.h>
 
+#include <drm/drm_bridge_connector.h>
 #include <drm/drm_atomic_helper.h>
 #include <drm/drm_crtc.h>
 #include <drm/drm_debugfs.h>
@@ -1544,26 +1545,47 @@ static int tegra_hdmi_init(struct host1x_client *client)
 {
 	struct tegra_hdmi *hdmi = host1x_client_to_hdmi(client);
 	struct drm_device *drm = dev_get_drvdata(client->host);
+	struct drm_connector *connector;
 	int err;
 
 	hdmi->output.dev = client->dev;
 
-	drm_connector_init_with_ddc(drm, &hdmi->output.connector,
-				    &tegra_hdmi_connector_funcs,
-				    DRM_MODE_CONNECTOR_HDMIA,
-				    hdmi->output.ddc);
-	drm_connector_helper_add(&hdmi->output.connector,
-				 &tegra_hdmi_connector_helper_funcs);
-	hdmi->output.connector.dpms = DRM_MODE_DPMS_OFF;
-
 	drm_simple_encoder_init(drm, &hdmi->output.encoder,
 				DRM_MODE_ENCODER_TMDS);
 	drm_encoder_helper_add(&hdmi->output.encoder,
 			       &tegra_hdmi_encoder_helper_funcs);
 
-	drm_connector_attach_encoder(&hdmi->output.connector,
-					  &hdmi->output.encoder);
-	drm_connector_register(&hdmi->output.connector);
+	if (hdmi->output.bridge) {
+		err = drm_bridge_attach(&hdmi->output.encoder, hdmi->output.bridge,
+					NULL, DRM_BRIDGE_ATTACH_NO_CONNECTOR);
+		if (err) {
+			dev_err(client->dev, "failed to attach bridge: %d\n",
+				err);
+			return err;
+		}
+
+		connector = drm_bridge_connector_init(drm, &hdmi->output.encoder);
+		if (IS_ERR(connector)) {
+			dev_err(client->dev,
+				"failed to initialize bridge connector: %pe\n",
+				connector);
+			return PTR_ERR(connector);
+		}
+
+		drm_connector_attach_encoder(connector, &hdmi->output.encoder);
+	} else {
+		drm_connector_init_with_ddc(drm, &hdmi->output.connector,
+					    &tegra_hdmi_connector_funcs,
+					    DRM_MODE_CONNECTOR_HDMIA,
+					    hdmi->output.ddc);
+		drm_connector_helper_add(&hdmi->output.connector,
+					 &tegra_hdmi_connector_helper_funcs);
+		hdmi->output.connector.dpms = DRM_MODE_DPMS_OFF;
+
+		drm_connector_attach_encoder(&hdmi->output.connector,
+					     &hdmi->output.encoder);
+		drm_connector_register(&hdmi->output.connector);
+	}
 
 	err = tegra_output_init(drm, &hdmi->output);
 	if (err < 0) {
Signature · 1 line
2.39.2
#2 lore raw

PATCH v2 2/2 ARM: tegra: transformers: add connector node

In reply to Svyatoslav Ryhel

All ASUS Transformers have micro-HDMI connector directly available. After Tegra HDMI got bridge/connector support, we should use connector framework for proper HW description.

---
 arch/arm/boot/dts/tegra20-asus-tf101.dts      | 22 ++++++++++++++++---
 .../dts/tegra30-asus-transformer-common.dtsi  | 21 ++++++++++++++++--
 2 files changed, 38 insertions(+), 5 deletions(-)
arch/arm/boot/dts/tegra20-asus-tf101.dts +19 -3
index c2a9c3fb5b33..97350f566539 100644
@@ -82,9 +82,11 @@ hdmi@54280000 {
 			pll-supply = <&hdmi_pll_reg>;
 			hdmi-supply = <&vdd_hdmi_en>;
 
-			nvidia,ddc-i2c-bus = <&hdmi_ddc>;
-			nvidia,hpd-gpio = <&gpio TEGRA_GPIO(N, 7)
-				GPIO_ACTIVE_HIGH>;
+			port@0 {
+				hdmi_out: endpoint {
+					remote-endpoint = <&connector_in>;
+				};
+			};
 		};
 	};
 
@@ -963,6 +965,20 @@ clk32k_in: clock-32k-in {
 		#clock-cells = <0>;
 	};
 
+	connector {
+		compatible = "hdmi-connector";
+		type = "d";
+
+		hpd-gpios = <&gpio TEGRA_GPIO(N, 7) GPIO_ACTIVE_HIGH>;
+		ddc-i2c-bus = <&hdmi_ddc>;
+
+		port {
+			connector_in: endpoint {
+				remote-endpoint = <&hdmi_out>;
+			};
+		};
+	};
+
 	cpus {
 		cpu0: cpu@0 {
 			cpu-supply = <&vdd_cpu>;
arch/arm/boot/dts/tegra30-asus-transformer-common.dtsi +19 -2
index bdb898ad6262..153d34a012bd 100644
@@ -80,8 +80,11 @@ hdmi: hdmi@54280000 {
 			pll-supply = <&vdd_1v8_vio>;
 			vdd-supply = <&vdd_3v3_sys>;
 
-			nvidia,hpd-gpio = <&gpio TEGRA_GPIO(N, 7) GPIO_ACTIVE_HIGH>;
-			nvidia,ddc-i2c-bus = <&hdmi_ddc>;
+			port@0 {
+				hdmi_out: endpoint {
+					remote-endpoint = <&connector_in>;
+				};
+			};
 		};
 	};
 
@@ -1492,6 +1495,20 @@ clk32k_in: clock-32k {
 		clock-output-names = "pmic-oscillator";
 	};
 
+	connector {
+		compatible = "hdmi-connector";
+		type = "d";
+
+		hpd-gpios = <&gpio TEGRA_GPIO(N, 7) GPIO_ACTIVE_HIGH>;
+		ddc-i2c-bus = <&hdmi_ddc>;
+
+		port {
+			connector_in: endpoint {
+				remote-endpoint = <&hdmi_out>;
+			};
+		};
+	};
+
 	cpus {
 		cpu0: cpu@0 {
 			cpu-supply = <&vdd_cpu>;
Signature · 1 line
2.39.2
#3 lore raw

Re: [PATCH v2 2/2] ARM: tegra: transformers: add connector node

Quoted 19 lines · Svyatoslav Ryhel

All ASUS Transformers have micro-HDMI connector directly available. After Tegra HDMI got bridge/connector support, we should use connector framework for proper HW description.

---
 arch/arm/boot/dts/tegra20-asus-tf101.dts      | 22 ++++++++++++++++---
 .../dts/tegra30-asus-transformer-common.dtsi  | 21 ++++++++++++++++--
 2 files changed, 38 insertions(+), 5 deletions(-)
arch/arm/boot/dts/tegra20-asus-tf101.dts +0 -0
index c2a9c3fb5b33..97350f566539 100644
@@ -82,9 +82,11 @@ hdmi@54280000 {
 			pll-supply = <&hdmi_pll_reg>;

arch/arm/boot/dts/tegra20-asus-tf101.dts hdmi@54280000 { · line 89

Quoted 10 lines
arch/arm/boot/dts/tegra20-asus-tf101.dts +5 -3
 			hdmi-supply = <&vdd_hdmi_en>;
 
-			nvidia,ddc-i2c-bus = <&hdmi_ddc>;
-			nvidia,hpd-gpio = <&gpio TEGRA_GPIO(N, 7)
-				GPIO_ACTIVE_HIGH>;
+			port@0 {
+				hdmi_out: endpoint {
+					remote-endpoint = <&connector_in>;
+				};
+			};

Does this need a bindings change? nvidia,tegra20-hdmi currently doesn't support OF graphs, so this would probably fail to validate if we merge it without a corresponding DT bindings update.

Thierry

#4 lore raw

Re: [PATCH v2 2/2] ARM: tegra: transformers: add connector node

27 липня 2023 р. 18:11:15 GMT+03:00, Thierry Reding <[email protected]> написав(-ла):

Quoted 22 lines · Svyatoslav Ryhel
Quoted 21 lines

All ASUS Transformers have micro-HDMI connector directly available. After Tegra HDMI got bridge/connector support, we should use connector framework for proper HW description.

---
 arch/arm/boot/dts/tegra20-asus-tf101.dts      | 22 ++++++++++++++++---
 .../dts/tegra30-asus-transformer-common.dtsi  | 21 ++++++++++++++++--
 2 files changed, 38 insertions(+), 5 deletions(-)
arch/arm/boot/dts/tegra20-asus-tf101.dts +0 -0
index c2a9c3fb5b33..97350f566539 100644
@@ -82,9 +82,11 @@ hdmi@54280000 {
 			pll-supply = <&hdmi_pll_reg>;
 			hdmi-supply = <&vdd_hdmi_en>;
 
Quoted 12 lines

arch/arm/boot/dts/tegra20-asus-tf101.dts hdmi@54280000 { · line 89

Quoted 8 lines
arch/arm/boot/dts/tegra20-asus-tf101.dts +5 -3
-			nvidia,ddc-i2c-bus = <&hdmi_ddc>;
-			nvidia,hpd-gpio = <&gpio TEGRA_GPIO(N, 7)
-				GPIO_ACTIVE_HIGH>;
+			port@0 {
+				hdmi_out: endpoint {
+					remote-endpoint = <&connector_in>;
+				};
+			};

Does this need a bindings change? nvidia,tegra20-hdmi currently doesn't support OF graphs, so this would probably fail to validate if we merge it without a corresponding DT bindings update.

drm/tegra patch is backwards compatible and connector node is optional.

Quoted 1 line

Thierry

#5 lore raw

Re: [PATCH v2 2/2] ARM: tegra: transformers: add connector node

Quoted 38 lines · Svyatoslav Ryhel

27 липня 2023 р. 18:11:15 GMT+03:00, Thierry Reding <[email protected]> написав(-ла):

Quoted 22 lines · Svyatoslav Ryhel
Quoted 21 lines

All ASUS Transformers have micro-HDMI connector directly available. After Tegra HDMI got bridge/connector support, we should use connector framework for proper HW description.

---
 arch/arm/boot/dts/tegra20-asus-tf101.dts      | 22 ++++++++++++++++---
 .../dts/tegra30-asus-transformer-common.dtsi  | 21 ++++++++++++++++--
 2 files changed, 38 insertions(+), 5 deletions(-)
arch/arm/boot/dts/tegra20-asus-tf101.dts +0 -0
index c2a9c3fb5b33..97350f566539 100644
@@ -82,9 +82,11 @@ hdmi@54280000 {
 			pll-supply = <&hdmi_pll_reg>;
 			hdmi-supply = <&vdd_hdmi_en>;
 
Quoted 12 lines

arch/arm/boot/dts/tegra20-asus-tf101.dts hdmi@54280000 { · line 89

Quoted 8 lines
arch/arm/boot/dts/tegra20-asus-tf101.dts +5 -3
-			nvidia,ddc-i2c-bus = <&hdmi_ddc>;
-			nvidia,hpd-gpio = <&gpio TEGRA_GPIO(N, 7)
-				GPIO_ACTIVE_HIGH>;
+			port@0 {
+				hdmi_out: endpoint {
+					remote-endpoint = <&connector_in>;
+				};
+			};

Does this need a bindings change? nvidia,tegra20-hdmi currently doesn't support OF graphs, so this would probably fail to validate if we merge it without a corresponding DT bindings update.

Quoted 1 line

drm/tegra patch is backwards compatible and connector node is optional.

We still need to document the connector node, otherwise the DT validation will complain about port@0 being used here, won't it?

Thierry

#6 lore raw

Re: [PATCH v2 2/2] ARM: tegra: transformers: add connector node

27 липня 2023 р. 19:50:35 GMT+03:00, Thierry Reding <[email protected]> написав(-ла):

Quoted 39 lines · Svyatoslav Ryhel
Quoted 38 lines

27 липня 2023 р. 18:11:15 GMT+03:00, Thierry Reding <[email protected]> написав(-ла):

Quoted 34 lines · Svyatoslav Ryhel
Quoted 19 lines

All ASUS Transformers have micro-HDMI connector directly available. After Tegra HDMI got bridge/connector support, we should use connector framework for proper HW description.

---
 arch/arm/boot/dts/tegra20-asus-tf101.dts      | 22 ++++++++++++++++---
 .../dts/tegra30-asus-transformer-common.dtsi  | 21 ++++++++++++++++--
 2 files changed, 38 insertions(+), 5 deletions(-)
arch/arm/boot/dts/tegra20-asus-tf101.dts +0 -0
index c2a9c3fb5b33..97350f566539 100644
@@ -82,9 +82,11 @@ hdmi@54280000 {
 			pll-supply = <&hdmi_pll_reg>;

arch/arm/boot/dts/tegra20-asus-tf101.dts hdmi@54280000 { · line 89

Quoted 10 lines
arch/arm/boot/dts/tegra20-asus-tf101.dts +5 -3
 			hdmi-supply = <&vdd_hdmi_en>;
 
-			nvidia,ddc-i2c-bus = <&hdmi_ddc>;
-			nvidia,hpd-gpio = <&gpio TEGRA_GPIO(N, 7)
-				GPIO_ACTIVE_HIGH>;
+			port@0 {
+				hdmi_out: endpoint {
+					remote-endpoint = <&connector_in>;
+				};
+			};

Does this need a bindings change? nvidia,tegra20-hdmi currently doesn't support OF graphs, so this would probably fail to validate if we merge it without a corresponding DT bindings update.

Quoted 4 lines
Quoted 1 line

drm/tegra patch is backwards compatible and connector node is optional.

We still need to document the connector node, otherwise the DT validation will complain about port@0 being used here, won't it?

Honestly? I have no idea, linux dt yamls are my nightmare and a reason why most of my patches still are hanging in the void of mailing lists.

Quoted 1 line

Thierry

#7 lore raw

Re: [PATCH v2 2/2] ARM: tegra: transformers: add connector node

In reply to Thierry Reding

Hi,

Quoted 39 lines · Thierry Reding
Quoted 38 lines · Svyatoslav Ryhel

27 липня 2023 р. 18:11:15 GMT+03:00, Thierry Reding <[email protected]> написав(-ла):

Quoted 34 lines · Svyatoslav Ryhel
Quoted 19 lines

All ASUS Transformers have micro-HDMI connector directly available. After Tegra HDMI got bridge/connector support, we should use connector framework for proper HW description.

---
 arch/arm/boot/dts/tegra20-asus-tf101.dts      | 22 ++++++++++++++++---
 .../dts/tegra30-asus-transformer-common.dtsi  | 21 ++++++++++++++++--
 2 files changed, 38 insertions(+), 5 deletions(-)
arch/arm/boot/dts/tegra20-asus-tf101.dts +0 -0
index c2a9c3fb5b33..97350f566539 100644
@@ -82,9 +82,11 @@ hdmi@54280000 {
 			pll-supply = <&hdmi_pll_reg>;

arch/arm/boot/dts/tegra20-asus-tf101.dts hdmi@54280000 { · line 89

Quoted 10 lines
arch/arm/boot/dts/tegra20-asus-tf101.dts +5 -3
 			hdmi-supply = <&vdd_hdmi_en>;
 
-			nvidia,ddc-i2c-bus = <&hdmi_ddc>;
-			nvidia,hpd-gpio = <&gpio TEGRA_GPIO(N, 7)
-				GPIO_ACTIVE_HIGH>;
+			port@0 {
+				hdmi_out: endpoint {
+					remote-endpoint = <&connector_in>;
+				};
+			};

Does this need a bindings change? nvidia,tegra20-hdmi currently doesn't support OF graphs, so this would probably fail to validate if we merge it without a corresponding DT bindings update.

Quoted 4 lines
Quoted 1 line

drm/tegra patch is backwards compatible and connector node is optional.

We still need to document the connector node, otherwise the DT validation will complain about port@0 being used here, won't it?

this change indeed causes several new warnings:

/mnt/linux/.output/arch/arm/boot/dts/tegra20-asus-tf101.dtb: hdmi@54280000: 'port@0' does not match any of the regexes: 'pinctrl-[0-9]+'
From schema: /mnt/linux/Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-hdmi.yaml
/mnt/linux/.output/arch/arm/boot/dts/tegra20-asus-tf101.dtb: hdmi@54280000: 'nvidia,ddc-i2c-bus' is a required property
From schema: /mnt/linux/Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-hdmi.yaml
/mnt/linux/.output/arch/arm/boot/dts/tegra20-asus-tf101.dtb: hdmi@54280000: 'nvidia,hpd-gpio' is a required property
From schema: /mnt/linux/Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-hdmi.yaml

BTW, the parallel RGB port isn't properly documented in nvidia,tegra20-dc either.

Best regards,
Maxim

#8 lore raw
In reply to Svyatoslav Ryhel
Quoted 8 lines · Svyatoslav Ryhel

This patch adds support for the bridge/connector attached to the HDMI output, allowing to model the hardware properly. It keeps backwards compatibility with existing bindings and is required by devices which have a simple or MHL bridge connected to HDMI output like ASUS P1801-T or LG P880/P895 or HTC One X.

Tested on ASUS Transformers which have no dedicated bridge but have type d HDMI connector directly available. Tests went smoothly.

If I understand correctly, we still need the drm/tegra patch to be applied before the DT change, otherwise the driver won't know what to do about the connector, right?

That shouldn't be big problem, but it means that the patches need to be staged in correctly to avoid breaking things.

Thierry

#9 lore raw

27 липня 2023 р. 18:09:22 GMT+03:00, Thierry Reding <[email protected]> написав(-ла):

Quoted 10 lines · Svyatoslav Ryhel
Quoted 8 lines

This patch adds support for the bridge/connector attached to the HDMI output, allowing to model the hardware properly. It keeps backwards compatibility with existing bindings and is required by devices which have a simple or MHL bridge connected to HDMI output like ASUS P1801-T or LG P880/P895 or HTC One X.

Tested on ASUS Transformers which have no dedicated bridge but have type d HDMI connector directly available. Tests went smoothly.

Quoted 6 lines

If I understand correctly, we still need the drm/tegra patch to be applied before the DT change, otherwise the driver won't know what to do about the connector, right?

That shouldn't be big problem, but it means that the patches need to be staged in correctly to avoid breaking things.

Patchset contains drm/tegra patch

Quoted 1 line

Thierry

#10 lore raw
Quoted 13 lines · Svyatoslav Ryhel

27 липня 2023 р. 18:09:22 GMT+03:00, Thierry Reding <[email protected]> написав(-ла):

Quoted 10 lines · Svyatoslav Ryhel
Quoted 8 lines

This patch adds support for the bridge/connector attached to the HDMI output, allowing to model the hardware properly. It keeps backwards compatibility with existing bindings and is required by devices which have a simple or MHL bridge connected to HDMI output like ASUS P1801-T or LG P880/P895 or HTC One X.

Tested on ASUS Transformers which have no dedicated bridge but have type d HDMI connector directly available. Tests went smoothly.

Quoted 8 lines
Quoted 6 lines

If I understand correctly, we still need the drm/tegra patch to be applied before the DT change, otherwise the driver won't know what to do about the connector, right?

That shouldn't be big problem, but it means that the patches need to be staged in correctly to avoid breaking things.

Patchset contains drm/tegra patch

I understand, but my point is that if we apply the DT patch before the driver patch, then the display won't be correctly initialized because the old driver code only looks within the HDMI node for the additional properties. Only after the drm/tegra patch is applied will the move in DT be recognized by the driver.

So for now I've picked up the drm/tegra patch and then I'll apply the DT change later on.

Thierry