Skip to contentSkip to conversation

Support bridge/connector by Tegra HDMI

PATCH Applied Svyatoslav Ryhel 4 participants 9 messages Aug 7, 2023 – Oct 10, 2023

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

v3 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.

---
Changes from v2:
- added missing descriptions to tegra dc and hdmi yamls
- fixed "Warning (unit_address_vs_reg): /host1x@50000000/ dc@54200000/rgb/port@0: node has a unit name, but no reg or ranges property"
- dropped reg from port to avoid same warning with hdmi ports

Changes from v1:
- no changes, re-sending
---

Maxim Schwalm (4):
ARM: dts: tegra: Drop unit-address from parallel RGB output port
dt-bindings: display: tegra: nvidia,tegra20-dc: Add parallel RGB
output port node
dt-bindings: display: tegra: nvidia,tegra20-hdmi: Add HDMI output port
node
drm/tegra: output: hdmi: Support bridge/connector

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

 .../display/tegra/nvidia,tegra20-dc.yaml      | 31 +++++++++++++
 .../display/tegra/nvidia,tegra20-hdmi.yaml    | 32 +++++++++++++-
 .../dts/nvidia/tegra20-acer-a500-picasso.dts  |  2 +-
 .../boot/dts/nvidia/tegra20-asus-tf101.dts    | 24 ++++++++--
 .../dts/nvidia/tegra30-asus-lvds-display.dtsi |  2 +-
 .../boot/dts/nvidia/tegra30-asus-tf700t.dts   |  2 +-
 .../tegra30-asus-transformer-common.dtsi      | 21 ++++++++-
 drivers/gpu/drm/tegra/hdmi.c                  | 44 ++++++++++++++-----
 8 files changed, 136 insertions(+), 22 deletions(-)
Signature · 1 line
2.39.2
#1 lore raw

PATCH v3 1/5 ARM: dts: tegra: Drop unit-address from parallel RGB output port

From: Maxim Schwalm <[email protected]>

Fix the following W=1 build warning:
"Warning (unit_address_vs_reg): /host1x@50000000/dc@54200000/rgb/port@0:
node has a unit name, but no reg or ranges property"

---
 arch/arm/boot/dts/nvidia/tegra20-acer-a500-picasso.dts  | 2 +-
 arch/arm/boot/dts/nvidia/tegra20-asus-tf101.dts         | 2 +-
 arch/arm/boot/dts/nvidia/tegra30-asus-lvds-display.dtsi | 2 +-
 arch/arm/boot/dts/nvidia/tegra30-asus-tf700t.dts        | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)
arch/arm/boot/dts/nvidia/tegra20-acer-a500-picasso.dts +1 -1
index 486fd244291e..a619ea83ed3b 100644
@@ -65,7 +65,7 @@ dc@54200000 {
 			rgb {
 				status = "okay";
 
-				port@0 {
+				port {
 					lcd_output: endpoint {
 						remote-endpoint = <&lvds_encoder_input>;
 						bus-width = <18>;
arch/arm/boot/dts/nvidia/tegra20-asus-tf101.dts +1 -1
index a3757b7daeda..e118809dc6d9 100644
@@ -66,7 +66,7 @@ dc@54200000 {
 			rgb {
 				status = "okay";
 
-				port@0 {
+				port {
 					lcd_output: endpoint {
 						remote-endpoint = <&lvds_encoder_input>;
 						bus-width = <18>;
arch/arm/boot/dts/nvidia/tegra30-asus-lvds-display.dtsi +1 -1
index bae09d82594d..680edff0f26f 100644
@@ -10,7 +10,7 @@ lcd: dc@54200000 {
 			rgb {
 				status = "okay";
 
-				port@0 {
+				port {
 					dpi_output: endpoint {
 						remote-endpoint = <&bridge_input>;
 						bus-width = <24>;
arch/arm/boot/dts/nvidia/tegra30-asus-tf700t.dts +1 -1
index efde7dad718a..9c480fde2e76 100644
@@ -15,7 +15,7 @@ lcd: dc@54200000 {
 			rgb {
 				status = "okay";
 
-				port@0 {
+				port {
 					dpi_output: endpoint {
 						remote-endpoint = <&bridge_input>;
 						bus-width = <24>;
Signature · 1 line
2.39.2
#2 lore raw

PATCH v3 2/5 dt-bindings: display: tegra: nvidia,tegra20-dc: Add parallel RGB output port node

In reply to Svyatoslav Ryhel

From: Maxim Schwalm <[email protected]>

Either this node, which is optional, or the nvidia,panel property can be present.

---
 .../display/tegra/nvidia,tegra20-dc.yaml      | 31 +++++++++++++++++++
 1 file changed, 31 insertions(+)
Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-dc.yaml +31 -0
index 69be95afd562..102304703062 100644
@@ -127,6 +127,37 @@ allOf:
               $ref: /schemas/types.yaml#/definitions/phandle
               description: phandle of a display panel
 
+            port:
+              $ref: /schemas/graph.yaml#/$defs/port-base
+              description: Parallel RGB output port
+
+              properties:
+                endpoint:
+                  $ref: /schemas/media/video-interfaces.yaml#
+                  unevaluatedProperties: false
+
+              unevaluatedProperties: false
+
+          anyOf:
+            - if:
+                not:
+                  properties:
+                    nvidia,panel: false
+              then:
+                not:
+                  properties:
+                    port: true
+            - if:
+                not:
+                  properties:
+                    port: false
+              then:
+                not:
+                  properties:
+                    nvidia,panel: true
+
+          additionalProperties: false
+
   - if:
       properties:
         compatible:
Signature · 1 line
2.39.2
maintainer
#3 lore raw

Re: [PATCH v3 2/5] dt-bindings: display: tegra: nvidia,tegra20-dc: Add parallel RGB output port node

Quoted 16 lines · Svyatoslav Ryhel

From: Maxim Schwalm <[email protected]>

Either this node, which is optional, or the nvidia,panel property can be present.

---
 .../display/tegra/nvidia,tegra20-dc.yaml      | 31 +++++++++++++++++++
 1 file changed, 31 insertions(+)
Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-dc.yaml +0 -0
index 69be95afd562..102304703062 100644

Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-dc.yaml allOf: · line 136

Quoted 10 lines
Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-dc.yaml +7 -0
@@ -127,6 +127,37 @@ allOf:
               $ref: /schemas/types.yaml#/definitions/phandle
               description: phandle of a display panel
 
+            port:
+              $ref: /schemas/graph.yaml#/$defs/port-base
+              description: Parallel RGB output port
+
+              properties:
+                endpoint:
+                  $ref: /schemas/media/video-interfaces.yaml#

Just to make sure, what properties are you using from this? Usually we'll list them though not a hard requirement. If none, then you just need to ref graph.yaml#/properties/port instead and can drop the rest.

Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-dc.yaml allOf: · line 139

Quoted 3 lines
Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-dc.yaml +3 -0
+                  unevaluatedProperties: false
+
+              unevaluatedProperties: false

In the indented cases, it's easier to read if this is before properties/patternProperties.

Quoted 8 lines
Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-dc.yaml +8 -0
+
+          anyOf:
+            - if:
+                not:
+                  properties:
+                    nvidia,panel: false
+              then:
+                not:

Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-dc.yaml allOf: · line 157

Quoted 10 lines
Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-dc.yaml +10 -0
+                  properties:
+                    port: true
+            - if:
+                not:
+                  properties:
+                    port: false
+              then:
+                not:
+                  properties:
+                    nvidia,panel: true

I would prefer to drop this and mark "nvidia,panel" as deprecated. Eventually I plan to add a mode to the tools to warn on using deprecated properties. Having both could be perfectly fine too. You have the "nvidia,panel" for compatibility with an old OS version and 'port' to work with newer users.

Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-dc.yaml allOf: · line 159

Quoted 2 lines
Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-dc.yaml +2 -0
+
+          additionalProperties: false

Move this up too.

Rob

#4 lore raw

Re: [PATCH v3 2/5] dt-bindings: display: tegra: nvidia,tegra20-dc: Add parallel RGB output port node

Hi Rob,

Quoted 20 lines · Rob Herring
Quoted 19 lines · Svyatoslav Ryhel

From: Maxim Schwalm <[email protected]>

Either this node, which is optional, or the nvidia,panel property can be present.

---
 .../display/tegra/nvidia,tegra20-dc.yaml      | 31 +++++++++++++++++++
 1 file changed, 31 insertions(+)
Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-dc.yaml +0 -0
index 69be95afd562..102304703062 100644
@@ -127,6 +127,37 @@ allOf:
               $ref: /schemas/types.yaml#/definitions/phandle
               description: phandle of a display panel
 
Quoted 11 lines

Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-dc.yaml allOf: · line 136

Quoted 7 lines
Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-dc.yaml +7 -0
+            port:
+              $ref: /schemas/graph.yaml#/$defs/port-base
+              description: Parallel RGB output port
+
+              properties:
+                endpoint:
+                  $ref: /schemas/media/video-interfaces.yaml#

Just to make sure, what properties are you using from this? Usually we'll list them though not a hard requirement. If none, then you just need to ref graph.yaml#/properties/port instead and can drop the rest.

currently, just bus-width is used in devicetrees, but I don't think that it is needed at the moment. So perhaps the property can be dropped.

Quoted 26 lines

Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-dc.yaml allOf: · line 139

Quoted 3 lines
Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-dc.yaml +3 -0
+                  unevaluatedProperties: false
+
+              unevaluatedProperties: false

In the indented cases, it's easier to read if this is before properties/patternProperties.

Quoted 8 lines
Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-dc.yaml +8 -0
+
+          anyOf:
+            - if:
+                not:
+                  properties:
+                    nvidia,panel: false
+              then:
+                not:

Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-dc.yaml allOf: · line 157

Quoted 10 lines
Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-dc.yaml +10 -0
+                  properties:
+                    port: true
+            - if:
+                not:
+                  properties:
+                    port: false
+              then:
+                not:
+                  properties:
+                    nvidia,panel: true
Quoted 5 lines

I would prefer to drop this and mark "nvidia,panel" as deprecated. Eventually I plan to add a mode to the tools to warn on using deprecated properties. Having both could be perfectly fine too. You have the "nvidia,panel" for compatibility with an old OS version and 'port' to work with newer users.

The reason for adding this was that just one of them can be utilized at the same time. Having both could potentially break the display output. I think that all the other nvidia,* properties could marked as deprecated as well because they don't seem to be doing much since commit d9f980ebcd01 ("drm/tegra: output: rgb: Wrap directly-connected panel into DRM bridge").

Quoted 5 lines

Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-dc.yaml allOf: · line 159

Quoted 2 lines
Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-dc.yaml +2 -0
+
+          additionalProperties: false

Move this up too.

Best regards,
Maxim

#5 lore raw

PATCH v3 3/5 dt-bindings: display: tegra: nvidia,tegra20-hdmi: Add HDMI output port node

In reply to Svyatoslav Ryhel

From: Maxim Schwalm <[email protected]>

Either this node, which is optional, or the nvidia,panel property can be present.

---
 .../display/tegra/nvidia,tegra20-hdmi.yaml    | 32 +++++++++++++++++--
 1 file changed, 30 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-hdmi.yaml +30 -2
index f77197e4869f..f8292551b9c8 100644
@@ -82,9 +82,39 @@ properties:
     description: phandle of a display panel
     $ref: /schemas/types.yaml#/definitions/phandle
 
+  port:
+    description: HDMI output port
+    $ref: /schemas/graph.yaml#/properties/port
+
   "#sound-dai-cells":
     const: 0
 
+anyOf:
+  - if:
+      not:
+        properties:
+          nvidia,panel: false
+    then:
+      not:
+        properties:
+          port: true
+  - if:
+      not:
+        properties:
+          port: false
+    then:
+      not:
+        properties:
+          nvidia,panel: true
+
+if:
+  properties:
+    port: false
+then:
+  required:
+    - nvidia,ddc-i2c-bus
+    - nvidia,hpd-gpio
+
 additionalProperties: false
 
 required:
@@ -97,8 +127,6 @@ required:
   - reset-names
   - pll-supply
   - vdd-supply
-  - nvidia,ddc-i2c-bus
-  - nvidia,hpd-gpio
 
 examples:
   - |
Signature · 1 line
2.39.2
#6 lore raw

PATCH v3 4/5 drm/tegra: output: hdmi: Support bridge/connector

In reply to Svyatoslav Ryhel

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
#7 lore raw

PATCH v3 5/5 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.

---
 .../boot/dts/nvidia/tegra20-asus-tf101.dts    | 22 ++++++++++++++++---
 .../tegra30-asus-transformer-common.dtsi      | 21 ++++++++++++++++--
 2 files changed, 38 insertions(+), 5 deletions(-)
arch/arm/boot/dts/nvidia/tegra20-asus-tf101.dts +19 -3
index e118809dc6d9..cd6acbea0318 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 {
+				hdmi_out: endpoint {
+					remote-endpoint = <&connector_in>;
+				};
+			};
 		};
 	};
 
@@ -967,6 +969,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/nvidia/tegra30-asus-transformer-common.dtsi +19 -2
index ead95306840f..9b658b3de7a4 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 {
+				hdmi_out: endpoint {
+					remote-endpoint = <&connector_in>;
+				};
+			};
 		};
 	};
 
@@ -1494,6 +1497,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
#8 lore raw

Re: (subset) [PATCH v3 0/5] Support bridge/connector by Tegra HDMI

In reply to Svyatoslav Ryhel

From: Thierry Reding <[email protected]>

Quoted 10 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.

[...]

Applied, thanks!

[1/5] ARM: dts: tegra: Drop unit-address from parallel RGB output port
(no commit info)

Best regards,

Signature · 1 line
Thierry Reding <[email protected]>