Skip to contentSkip to conversation

chrontel-ch7033: Add byteswap order option

PATCH Applied Chris Morgan 4 participants 10 messages Sep 2, 2022 – Sep 7, 2022

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

v2 cover chrontel-ch7033: Add byteswap order option

From: Chris Morgan <[email protected]>

This series adds the ability to set the byteswap order in the chrontel ch7033 driver via an optional devicetree node. This is necessary because the HDMI DIP of the NTC CHIP requires a byteswap order that differs from the default value of the driver.

Changes from V1:

- Updated devicetree documentation to be easier to understand.

Chris Morgan (2):
dt-bindings: Add byteswap order to chrontel ch7033 drm/bridge: chrontel-ch7033: Add byteswap order setting

 .../bindings/display/bridge/chrontel,ch7033.yaml  | 13 +++++++++++++
 drivers/gpu/drm/bridge/chrontel-ch7033.c          | 15 +++++++++++++--
 2 files changed, 26 insertions(+), 2 deletions(-)
Signature · 1 line
2.25.1
#1 lore raw

PATCH v2 1/2 dt-bindings: Add byteswap order to chrontel ch7033

From: Chris Morgan <[email protected]>

Update dt-binding documentation to add support for setting byteswap of chrontel ch7033.

New property name of chrontel,byteswap added to set the byteswap order. This property is optional.

---
 .../bindings/display/bridge/chrontel,ch7033.yaml    | 13 +++++++++++++
 1 file changed, 13 insertions(+)
Documentation/devicetree/bindings/display/bridge/chrontel,ch7033.yaml +13 -0
index bb6289c7d375..984b90893583 100644
@@ -14,6 +14,19 @@ properties:
   compatible:
     const: chrontel,ch7033
 
+  chrontel,byteswap:
+    $ref: /schemas/types.yaml#/definitions/uint8
+    enum:
+      - 0  # BYTE_SWAP_RGB
+      - 1  # BYTE_SWAP_RBG
+      - 2  # BYTE_SWAP_GRB
+      - 3  # BYTE_SWAP_GBR
+      - 4  # BYTE_SWAP_BRG
+      - 5  # BYTE_SWAP_BGR
+    description: |
+      Set the byteswap value of the bridge. This is optional and if not
+      set value of BYTE_SWAP_BGR is used.
+
   reg:
     maxItems: 1
     description: I2C address of the device
Signature · 1 line
2.25.1
#2 lore raw

Re: [PATCH V2 1/2] dt-bindings: Add byteswap order to chrontel ch7033

Hi Chris,

Thank you for the patch.

Quoted 24 lines · Chris Morgan

From: Chris Morgan <[email protected]>

Update dt-binding documentation to add support for setting byteswap of chrontel ch7033.

New property name of chrontel,byteswap added to set the byteswap order. This property is optional.

---
 .../bindings/display/bridge/chrontel,ch7033.yaml    | 13 +++++++++++++
 1 file changed, 13 insertions(+)
Documentation/devicetree/bindings/display/bridge/chrontel,ch7033.yaml +2 -0
index bb6289c7d375..984b90893583 100644
@@ -14,6 +14,19 @@ properties:
   compatible:
     const: chrontel,ch7033
 
+  chrontel,byteswap:
+    $ref: /schemas/types.yaml#/definitions/uint8

Documentation/devicetree/bindings/display/bridge/chrontel,ch7033.yaml properties: · line 28

Quoted 10 lines
Documentation/devicetree/bindings/display/bridge/chrontel,ch7033.yaml +10 -0
+    enum:
+      - 0  # BYTE_SWAP_RGB
+      - 1  # BYTE_SWAP_RBG
+      - 2  # BYTE_SWAP_GRB
+      - 3  # BYTE_SWAP_GBR
+      - 4  # BYTE_SWAP_BRG
+      - 5  # BYTE_SWAP_BGR
+    description: |
+      Set the byteswap value of the bridge. This is optional and if not
+      set value of BYTE_SWAP_BGR is used.

I don't think this belongs to the device tree. The source of data connected to the CH7033 input could use different formats. This shouldn't be hardcoded, but queried at runtime, using the input and output media bus formats infrastructure that the DRM bridge framework includes.

Quoted 4 lines
Documentation/devicetree/bindings/display/bridge/chrontel,ch7033.yaml +1 -0
+
   reg:
     maxItems: 1
     description: I2C address of the device
Signature · 3 lines
Regards,

Laurent Pinchart
#3 lore raw

Re: [PATCH V2 1/2] dt-bindings: Add byteswap order to chrontel ch7033

Thanks Laurent,

Quoted 38 lines · Laurent Pinchart

Hi Chris,

Thank you for the patch.

Quoted 32 lines · Chris Morgan

From: Chris Morgan <[email protected]>

Update dt-binding documentation to add support for setting byteswap of chrontel ch7033.

New property name of chrontel,byteswap added to set the byteswap order. This property is optional.

---
 .../bindings/display/bridge/chrontel,ch7033.yaml    | 13 +++++++++++++
 1 file changed, 13 insertions(+)
Documentation/devicetree/bindings/display/bridge/chrontel,ch7033.yaml +10 -0
index bb6289c7d375..984b90893583 100644
@@ -14,6 +14,19 @@ properties:
   compatible:
     const: chrontel,ch7033
 
+  chrontel,byteswap:
+    $ref: /schemas/types.yaml#/definitions/uint8
+    enum:
+      - 0  # BYTE_SWAP_RGB
+      - 1  # BYTE_SWAP_RBG
+      - 2  # BYTE_SWAP_GRB
+      - 3  # BYTE_SWAP_GBR
+      - 4  # BYTE_SWAP_BRG
+      - 5  # BYTE_SWAP_BGR
+    description: |
Quoted 8 lines

Documentation/devicetree/bindings/display/bridge/chrontel,ch7033.yaml properties: · line 28

Quoted 2 lines
Documentation/devicetree/bindings/display/bridge/chrontel,ch7033.yaml +2 -0
+      Set the byteswap value of the bridge. This is optional and if not
+      set value of BYTE_SWAP_BGR is used.

I don't think this belongs to the device tree. The source of data connected to the CH7033 input could use different formats. This shouldn't be hardcoded, but queried at runtime, using the input and output media bus formats infrastructure that the DRM bridge framework includes.

Chris, will you have a look at submitting a fix for this during the coming days?

If not, we can revert this series and apply a fixed version later.

Quoted 10 lines

Documentation/devicetree/bindings/display/bridge/chrontel,ch7033.yaml properties: · line 32

Quoted 5 lines
Documentation/devicetree/bindings/display/bridge/chrontel,ch7033.yaml +1 -0
+
   reg:
     maxItems: 1
     description: I2C address of the device

--
Regards,

Laurent Pinchart

#4 lore raw

Re: [PATCH V2 1/2] dt-bindings: Add byteswap order to chrontel ch7033

Quoted 51 lines · Robert Foss

Thanks Laurent,

Quoted 38 lines · Laurent Pinchart

Hi Chris,

Thank you for the patch.

Quoted 32 lines · Chris Morgan

From: Chris Morgan <[email protected]>

Update dt-binding documentation to add support for setting byteswap of chrontel ch7033.

New property name of chrontel,byteswap added to set the byteswap order. This property is optional.

---
 .../bindings/display/bridge/chrontel,ch7033.yaml    | 13 +++++++++++++
 1 file changed, 13 insertions(+)
Documentation/devicetree/bindings/display/bridge/chrontel,ch7033.yaml +10 -0
index bb6289c7d375..984b90893583 100644
@@ -14,6 +14,19 @@ properties:
   compatible:
     const: chrontel,ch7033
 
+  chrontel,byteswap:
+    $ref: /schemas/types.yaml#/definitions/uint8
+    enum:
+      - 0  # BYTE_SWAP_RGB
+      - 1  # BYTE_SWAP_RBG
+      - 2  # BYTE_SWAP_GRB
+      - 3  # BYTE_SWAP_GBR
+      - 4  # BYTE_SWAP_BRG
+      - 5  # BYTE_SWAP_BGR
+    description: |
Quoted 8 lines

Documentation/devicetree/bindings/display/bridge/chrontel,ch7033.yaml properties: · line 28

Quoted 2 lines
Documentation/devicetree/bindings/display/bridge/chrontel,ch7033.yaml +2 -0
+      Set the byteswap value of the bridge. This is optional and if not
+      set value of BYTE_SWAP_BGR is used.

I don't think this belongs to the device tree. The source of data connected to the CH7033 input could use different formats. This shouldn't be hardcoded, but queried at runtime, using the input and output media bus formats infrastructure that the DRM bridge framework includes.

Quoted 3 lines

Chris, will you have a look at submitting a fix for this during the coming days?

If not, we can revert this series and apply a fixed version later.

I'm not sure I understand (or know) what needs to be fixed. Presumably using something like EDID we can predict what color format we need to use for the connection between the bridge and the HDMI device, but wouldn't the color format between the SoC and bridge need to be constant?

If there's something I'm missing please let me know, I'm relatively unfamiliar with the display subsystems as a whole. I'll be happy to make the change once I'm clear what I need to change.

Thank you for your help.

Quoted 11 lines
Quoted 11 lines

Documentation/devicetree/bindings/display/bridge/chrontel,ch7033.yaml properties: · line 32

Quoted 6 lines
Documentation/devicetree/bindings/display/bridge/chrontel,ch7033.yaml +1 -0
+
   reg:
     maxItems: 1
     description: I2C address of the device

--
Regards,

Laurent Pinchart

#5 lore raw

Re: [PATCH V2 1/2] dt-bindings: Add byteswap order to chrontel ch7033

Hi Chris,

Quoted 46 lines · Chris Morgan
Quoted 45 lines · Robert Foss
Quoted 33 lines · Laurent Pinchart
Quoted 32 lines · Chris Morgan

From: Chris Morgan <[email protected]>

Update dt-binding documentation to add support for setting byteswap of chrontel ch7033.

New property name of chrontel,byteswap added to set the byteswap order. This property is optional.

---
 .../bindings/display/bridge/chrontel,ch7033.yaml    | 13 +++++++++++++
 1 file changed, 13 insertions(+)
Documentation/devicetree/bindings/display/bridge/chrontel,ch7033.yaml +10 -0
index bb6289c7d375..984b90893583 100644
@@ -14,6 +14,19 @@ properties:
   compatible:
     const: chrontel,ch7033
 
+  chrontel,byteswap:
+    $ref: /schemas/types.yaml#/definitions/uint8
+    enum:
+      - 0  # BYTE_SWAP_RGB
+      - 1  # BYTE_SWAP_RBG
+      - 2  # BYTE_SWAP_GRB
+      - 3  # BYTE_SWAP_GBR
+      - 4  # BYTE_SWAP_BRG
+      - 5  # BYTE_SWAP_BGR
+    description: |
Quoted 8 lines

Documentation/devicetree/bindings/display/bridge/chrontel,ch7033.yaml properties: · line 28

Quoted 2 lines
Documentation/devicetree/bindings/display/bridge/chrontel,ch7033.yaml +2 -0
+      Set the byteswap value of the bridge. This is optional and if not
+      set value of BYTE_SWAP_BGR is used.

I don't think this belongs to the device tree. The source of data connected to the CH7033 input could use different formats. This shouldn't be hardcoded, but queried at runtime, using the input and output media bus formats infrastructure that the DRM bridge framework includes.

Chris, will you have a look at submitting a fix for this during the coming days?

Quoted 7 lines
Quoted 1 line

If not, we can revert this series and apply a fixed version later.

I'm not sure I understand (or know) what needs to be fixed. Presumably using something like EDID we can predict what color format we need to use for the connection between the bridge and the HDMI device, but wouldn't the color format between the SoC and bridge need to be constant?

Not necessarily. Some display engines can output different formats. You should be able to get the selected format at the bridge input from the drm_bridge_state. Could you please give that a try ?

Quoted 10 lines

If there's something I'm missing please let me know, I'm relatively unfamiliar with the display subsystems as a whole. I'll be happy to make the change once I'm clear what I need to change.

Thank you for your help.

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Documentation/devicetree/bindings/display/bridge/chrontel,ch7033.yaml +1 -0
+
   reg:
     maxItems: 1
     description: I2C address of the device
Signature · 3 lines
Regards,

Laurent Pinchart
#6 lore raw

PATCH v2 2/2 drm/bridge: chrontel-ch7033: Add byteswap order setting

In reply to Chris Morgan

From: Chris Morgan <[email protected]>

Add the option to set the byteswap order in the devicetree. For the official HDMI DIP for the NTC CHIP the byteswap order needs to be RGB, however the driver sets it as BGR. With this patch the driver will remain at BGR unless manually specified via devicetree.

---
 drivers/gpu/drm/bridge/chrontel-ch7033.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
drivers/gpu/drm/bridge/chrontel-ch7033.c +13 -2
index ba060277c3fd..c5719908ce2d 100644
@@ -68,6 +68,7 @@ enum {
 	BYTE_SWAP_GBR	= 3,
 	BYTE_SWAP_BRG	= 4,
 	BYTE_SWAP_BGR	= 5,
+	BYTE_SWAP_MAX	= 6,
 };
 
 /* Page 0, Register 0x19 */
@@ -355,6 +356,8 @@ static void ch7033_bridge_mode_set(struct drm_bridge *bridge,
 	int hsynclen = mode->hsync_end - mode->hsync_start;
 	int vbporch = mode->vsync_start - mode->vdisplay;
 	int vsynclen = mode->vsync_end - mode->vsync_start;
+	u8 byte_swap;
+	int ret;
 
 	/*
 	 * Page 4
@@ -398,8 +401,16 @@ static void ch7033_bridge_mode_set(struct drm_bridge *bridge,
 	regmap_write(priv->regmap, 0x15, vbporch);
 	regmap_write(priv->regmap, 0x16, vsynclen);
 
-	/* Input color swap. */
-	regmap_update_bits(priv->regmap, 0x18, SWAP, BYTE_SWAP_BGR);
+	/* Input color swap. Byte order is optional and will default to
+	 * BYTE_SWAP_BGR to preserve backwards compatibility with existing
+	 * driver.
+	 */
+	ret = of_property_read_u8(priv->bridge.of_node, "chrontel,byteswap",
+				  &byte_swap);
+	if (!ret && byte_swap < BYTE_SWAP_MAX)
+		regmap_update_bits(priv->regmap, 0x18, SWAP, byte_swap);
+	else
+		regmap_update_bits(priv->regmap, 0x18, SWAP, BYTE_SWAP_BGR);
 
 	/* Input clock and sync polarity. */
 	regmap_update_bits(priv->regmap, 0x19, 0x1, mode->clock >> 16);
Signature · 1 line
2.25.1
#7 lore raw

Re: [PATCH V2 2/2] drm/bridge: chrontel-ch7033: Add byteswap order setting

Hi Chris,

Thank you for the patch.

Quoted 36 lines · Chris Morgan

From: Chris Morgan <[email protected]>

Add the option to set the byteswap order in the devicetree. For the official HDMI DIP for the NTC CHIP the byteswap order needs to be RGB, however the driver sets it as BGR. With this patch the driver will remain at BGR unless manually specified via devicetree.

---
 drivers/gpu/drm/bridge/chrontel-ch7033.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
drivers/gpu/drm/bridge/chrontel-ch7033.c +3 -0
index ba060277c3fd..c5719908ce2d 100644
@@ -68,6 +68,7 @@ enum {
 	BYTE_SWAP_GBR	= 3,
 	BYTE_SWAP_BRG	= 4,
 	BYTE_SWAP_BGR	= 5,
+	BYTE_SWAP_MAX	= 6,
 };
 
 /* Page 0, Register 0x19 */
@@ -355,6 +356,8 @@ static void ch7033_bridge_mode_set(struct drm_bridge *bridge,
 	int hsynclen = mode->hsync_end - mode->hsync_start;
 	int vbporch = mode->vsync_start - mode->vdisplay;
 	int vsynclen = mode->vsync_end - mode->vsync_start;
+	u8 byte_swap;
+	int ret;
 
 	/*
 	 * Page 4
@@ -398,8 +401,16 @@ static void ch7033_bridge_mode_set(struct drm_bridge *bridge,
 	regmap_write(priv->regmap, 0x15, vbporch);

drivers/gpu/drm/bridge/chrontel-ch7033.c static void ch7033_bridge_mode_set(struct drm_bridge *bridge, · line 409

Quoted 10 lines
drivers/gpu/drm/bridge/chrontel-ch7033.c +6 -2
 	regmap_write(priv->regmap, 0x16, vsynclen);
 
-	/* Input color swap. */
-	regmap_update_bits(priv->regmap, 0x18, SWAP, BYTE_SWAP_BGR);
+	/* Input color swap. Byte order is optional and will default to
+	 * BYTE_SWAP_BGR to preserve backwards compatibility with existing
+	 * driver.
+	 */
+	ret = of_property_read_u8(priv->bridge.of_node, "chrontel,byteswap",
+				  &byte_swap);

That's quite inefficient, please parse the device tree at probe time, and cache the value.

Quoted 7 lines
drivers/gpu/drm/bridge/chrontel-ch7033.c +4 -0
+	if (!ret && byte_swap < BYTE_SWAP_MAX)
+		regmap_update_bits(priv->regmap, 0x18, SWAP, byte_swap);
+	else
+		regmap_update_bits(priv->regmap, 0x18, SWAP, BYTE_SWAP_BGR);
 
 	/* Input clock and sync polarity. */
 	regmap_update_bits(priv->regmap, 0x19, 0x1, mode->clock >> 16);
Signature · 3 lines
Regards,

Laurent Pinchart
Applied
#8 lore raw
In reply to Chris Morgan
Quoted 18 lines · Chris Morgan

From: Chris Morgan <[email protected]>

This series adds the ability to set the byteswap order in the chrontel ch7033 driver via an optional devicetree node. This is necessary because the HDMI DIP of the NTC CHIP requires a byteswap order that differs from the default value of the driver.

Changes from V1:

- Updated devicetree documentation to be easier to understand.

Chris Morgan (2):
dt-bindings: Add byteswap order to chrontel ch7033 drm/bridge: chrontel-ch7033: Add byteswap order setting

Quoted 7 lines
 .../bindings/display/bridge/chrontel,ch7033.yaml  | 13 +++++++++++++
 drivers/gpu/drm/bridge/chrontel-ch7033.c          | 15 +++++++++++++--
 2 files changed, 26 insertions(+), 2 deletions(-)

--
2.25.1

Applied to drm-misc-next.

#9 lore raw

Hi Rob,

Quoted 19 lines · Robert Foss
Quoted 18 lines · Chris Morgan

From: Chris Morgan <[email protected]>

This series adds the ability to set the byteswap order in the chrontel ch7033 driver via an optional devicetree node. This is necessary because the HDMI DIP of the NTC CHIP requires a byteswap order that differs from the default value of the driver.

Changes from V1:

- Updated devicetree documentation to be easier to understand.

Chris Morgan (2):
dt-bindings: Add byteswap order to chrontel ch7033 drm/bridge: chrontel-ch7033: Add byteswap order setting

Quoted 5 lines
Quoted 3 lines
 .../bindings/display/bridge/chrontel,ch7033.yaml  | 13 +++++++++++++
 drivers/gpu/drm/bridge/chrontel-ch7033.c          | 15 +++++++++++++--
 2 files changed, 26 insertions(+), 2 deletions(-)

Applied to drm-misc-next.

I've just reviewed the series, and I don't think this is right. Patch 2/2 has a small issue that could be fixed on top, but more importantly, I don't think this belongs to DT. See the reply to 1/2.

Signature · 3 lines
Regards,

Laurent Pinchart