Skip to contentSkip to conversation

drm/bridge: dw-hdmi: use safe format when first in bridge chain

PATCH Superseded Neil Armstrong 3 participants 5 messages Jan 17, 2022 – Jan 18, 2022

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/bridge: dw-hdmi: use safe format when first in bridge chain

When the dw-hdmi bridge is in first place of the bridge chain, this means there is now way to select an input format of the dw-hdmi HW component.

Since introduction of display-connector, negociation was broken since the dw-hdmi negociation code only worked when the dw-hdmi bridge was in last position of the bridge chain or behind another bridge also supporting input & output format negociation.

Commit 0656d1285b79 ("drm/bridge: display-connector: implement bus fmts callbacks") was introduced to make negociation work again by making display-connector act as a pass-through concerning input & output format negociation.

But in the case were the dw-hdmi was single in the bridge chain, for example on Renesas SoCs, with the disply-connector bridge the dw-hdmi is no more single, breaking output format.

Fixes 0656d1285b79 ("drm/bridge: display-connector: implement bus fmts callbacks").
---
 drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +7 -2
index 54d8fdad395f..9f2e1cac0ae2 100644
@@ -2551,8 +2551,9 @@ static u32 *dw_hdmi_bridge_atomic_get_output_bus_fmts(struct drm_bridge *bridge,
 	if (!output_fmts)
 		return NULL;
 
-	/* If dw-hdmi is the only bridge, avoid negociating with ourselves */
-	if (list_is_singular(&bridge->encoder->bridge_chain)) {
+	/* If dw-hdmi is the first or only bridge, avoid negociating with ourselves */
+	if (list_is_singular(&bridge->encoder->bridge_chain) ||
+	    list_is_first(&bridge->chain_node, &bridge->encoder->bridge_chain)) {
 		*num_output_fmts = 1;
 		output_fmts[0] = MEDIA_BUS_FMT_FIXED;
 
@@ -2673,6 +2674,10 @@ static u32 *dw_hdmi_bridge_atomic_get_input_bus_fmts(struct drm_bridge *bridge,
 	if (!input_fmts)
 		return NULL;
 
+	/* If dw-hdmi is the first bridge fall-back to safe output format */
+	if (list_is_first(&bridge->chain_node, &bridge->encoder->bridge_chain))
+		output_fmt = MEDIA_BUS_FMT_FIXED;
+
 	switch (output_fmt) {
 	/* If MEDIA_BUS_FMT_FIXED is tested, return default bus format */
 	case MEDIA_BUS_FMT_FIXED:
Signature · 1 line
2.25.1
#1 lore raw

Hi Neil,

Thanks for the patch

Quoted 52 lines

Subject: [PATCH] drm/bridge: dw-hdmi: use safe format when first in bridge chain

When the dw-hdmi bridge is in first place of the bridge chain, this means there is now way to select an input format of the dw-hdmi HW component.

Since introduction of display-connector, negociation was broken since the dw-hdmi negociation code only worked when the dw-hdmi bridge was in last position of the bridge chain or behind another bridge also supporting input & output format negociation.

Commit 0656d1285b79 ("drm/bridge: display-connector: implement bus fmts callbacks") was introduced to make negociation work again by making display-connector act as a pass-through concerning input & output format negociation.

But in the case were the dw-hdmi was single in the bridge chain, for example on Renesas SoCs, with the disply-connector bridge the dw-hdmi is no more single, breaking output format.

Fixes 0656d1285b79 ("drm/bridge: display-connector: implement bus fmts

callbacks").

---
 drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +1 -2
index 54d8fdad395f..9f2e1cac0ae2 100644
@@ -2551,8 +2551,9 @@ static u32
 *dw_hdmi_bridge_atomic_get_output_bus_fmts(struct drm_bridge *bridge,
 	if (!output_fmts)
 		return NULL;
 
-	/* If dw-hdmi is the only bridge, avoid negociating with ourselves
 */
-	if (list_is_singular(&bridge->encoder->bridge_chain)) {
+	/* If dw-hdmi is the first or only bridge, avoid negociating with

ourselves */

drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +3 -0
+	if (list_is_singular(&bridge->encoder->bridge_chain) ||
+	    list_is_first(&bridge->chain_node,
+&bridge->encoder->bridge_chain)) {
 		*num_output_fmts = 1;
 		output_fmts[0] = MEDIA_BUS_FMT_FIXED;

drivers/gpu/drm/bridge/synopsys/dw-hdmi.c static u32 · line 2682

Quoted 9 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +4 -0
@@ -2673,6 +2674,10 @@ static u32
 *dw_hdmi_bridge_atomic_get_input_bus_fmts(struct drm_bridge *bridge,
 	if (!input_fmts)
 		return NULL;
 
+	/* If dw-hdmi is the first bridge fall-back to safe output format */
+	if (list_is_first(&bridge->chain_node, &bridge->encoder-
 >bridge_chain))
+		output_fmt = MEDIA_BUS_FMT_FIXED;
+

Based on my debugging, this looks redundant, as get_output_bus_fmts already sets output_fmt = MEDIA_BUS_FMT_FIXED, And *num_output_fmts = 1, so the function parameter output_fmt in input_bus_fmts will have MEDIA_BUS_FMT_FIXED And no need to override output_fmt value. I may be wrong here.

Regards,
Biju

Quoted 5 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +0 -0
 	switch (output_fmt) {
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +0 -1
 	/* If MEDIA_BUS_FMT_FIXED is tested, return default bus format */
 	case MEDIA_BUS_FMT_FIXED:
--

2.25.1

#2 lore raw
Quoted 62 lines · Biju Das

Hi Neil,

Thanks for the patch

Quoted 58 lines

Subject: [PATCH] drm/bridge: dw-hdmi: use safe format when first in bridge chain

When the dw-hdmi bridge is in first place of the bridge chain, this means there is now way to select an input format of the dw-hdmi HW component.

Since introduction of display-connector, negociation was broken since the dw-hdmi negociation code only worked when the dw-hdmi bridge was in last position of the bridge chain or behind another bridge also supporting input & output format negociation.

Commit 0656d1285b79 ("drm/bridge: display-connector: implement bus fmts callbacks") was introduced to make negociation work again by making display-connector act as a pass-through concerning input & output format negociation.

But in the case were the dw-hdmi was single in the bridge chain, for example on Renesas SoCs, with the disply-connector bridge the dw-hdmi is no more single, breaking output format.

Fixes 0656d1285b79 ("drm/bridge: display-connector: implement bus fmts

callbacks").

---
 drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +1 -2
index 54d8fdad395f..9f2e1cac0ae2 100644
@@ -2551,8 +2551,9 @@ static u32
 *dw_hdmi_bridge_atomic_get_output_bus_fmts(struct drm_bridge *bridge,
 	if (!output_fmts)
 		return NULL;
 
-	/* If dw-hdmi is the only bridge, avoid negociating with ourselves
 */
-	if (list_is_singular(&bridge->encoder->bridge_chain)) {
+	/* If dw-hdmi is the first or only bridge, avoid negociating with

ourselves */

drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +5 -0
+	if (list_is_singular(&bridge->encoder->bridge_chain) ||
+	    list_is_first(&bridge->chain_node,
+&bridge->encoder->bridge_chain)) {
 		*num_output_fmts = 1;
 		output_fmts[0] = MEDIA_BUS_FMT_FIXED;
@@ -2673,6 +2674,10 @@ static u32
 *dw_hdmi_bridge_atomic_get_input_bus_fmts(struct drm_bridge *bridge,
 	if (!input_fmts)
 		return NULL;
 
+	/* If dw-hdmi is the first bridge fall-back to safe output format */
+	if (list_is_first(&bridge->chain_node, &bridge->encoder-
Quoted 7 lines

drivers/gpu/drm/bridge/synopsys/dw-hdmi.c static u32 *dw_hdmi_bridge_atomic_get_input_bus_fmts(struct drm_bridge *bridge, · line 2680

Quoted 3 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +2 -0
 > bridge_chain))
+		output_fmt = MEDIA_BUS_FMT_FIXED;
+

Based on my debugging, this looks redundant, as get_output_bus_fmts already sets output_fmt = MEDIA_BUS_FMT_FIXED, And *num_output_fmts = 1, so the function parameter output_fmt in input_bus_fmts will have MEDIA_BUS_FMT_FIXED And no need to override output_fmt value. I may be wrong here.

You're right, I added this in case another bridge than display-connector is used, but in fact it should instead check if first bridge of the chain and output_fmt == MEDIA_BUS_FMT_RGB888_1X24 || output_fmt == MEDIA_BUS_FMT_FIXED otherwise return an error.

I'll send it separately since it's out of the scope of the issue fixed.

Neil

Quoted 10 lines

Regards,
Biju

Quoted 5 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +0 -0
 	switch (output_fmt) {
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +0 -1
 	/* If MEDIA_BUS_FMT_FIXED is tested, return default bus format */
 	case MEDIA_BUS_FMT_FIXED:
--

2.25.1

#3 lore raw
In reply to Neil Armstrong

Hi Neil

Sorry, just some trivial spelling fixes.

Quoted 2 lines · Neil Armstrong

When the dw-hdmi bridge is in first place of the bridge chain, this means there is now way

no way

Quoted 4 lines

to select an input format of the dw-hdmi HW
component.

Since introduction of display-connector, negociation

:%s/negociation/negotiation/g

Quoted 10 lines

was broken since
the dw-hdmi negociation code only worked when the dw-hdmi bridge was in last position of the bridge chain or behind another bridge also supporting input & output format negociation.

Commit 0656d1285b79 ("drm/bridge: display-connector: implement bus fmts callbacks") was introduced to make negociation work again by making display-connector act as a pass-through concerning input & output format negociation.

But in the case were

where

Quoted 2 lines

the dw-hdmi was single in the bridge chain, for example on Renesas SoCs, with the disply-connector

display-connector

Quoted 31 lines

bridge the dw-hdmi
is no more single, breaking output format.

Fixes 0656d1285b79 ("drm/bridge: display-connector: implement bus fmts callbacks").

---
 drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 9 +++++++--

 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +0 -0
index 54d8fdad395f..9f2e1cac0ae2 100644
@@ -2551,8 +2551,9 @@ static u32 *dw_hdmi_bridge_atomic_get_output_bus_fmts(struct drm_bridge *bridge,
         if (!output_fmts)
                 return NULL;


-       /* If dw-hdmi is the only bridge, avoid negociating with ourselves */ -       if (list_is_singular(&bridge->encoder->bridge_chain)) {
+       /* If dw-hdmi is the first or only bridge, avoid negociating with ourselves */ +       if (list_is_singular(&bridge->encoder->bridge_chain) ||
+           list_is_first(&bridge->chain_node, &bridge->encoder->bridge_chain)) { *num_output_fmts = 1;
                output_fmts[0] = MEDIA_BUS_FMT_FIXED;

drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +0 -0
@@ -2673,6 +2674,10 @@ static u32 *dw_hdmi_bridge_atomic_get_input_bus_fmts(struct drm_bridge *bridge,
         if (!input_fmts)
                 return NULL;
Quoted 8 lines


+       /* If dw-hdmi is the first bridge fall-back to safe output format */ +       if (list_is_first(&bridge->chain_node, &bridge->encoder->bridge_chain)) +               output_fmt = MEDIA_BUS_FMT_FIXED;
+
        switch (output_fmt) {
        /* If MEDIA_BUS_FMT_FIXED is tested, return default bus format */ case MEDIA_BUS_FMT_FIXED:

Cheers

Marcel

#4 lore raw

Hi,

Quoted 77 lines · Marcel Ziswiler

Hi Neil

Sorry, just some trivial spelling fixes.

Quoted 2 lines · Neil Armstrong

When the dw-hdmi bridge is in first place of the bridge chain, this means there is now way

no way

Quoted 4 lines

to select an input format of the dw-hdmi HW
component.

Since introduction of display-connector, negociation

:%s/negociation/negotiation/g

Quoted 10 lines

was broken since
the dw-hdmi negociation code only worked when the dw-hdmi bridge was in last position of the bridge chain or behind another bridge also supporting input & output format negociation.

Commit 0656d1285b79 ("drm/bridge: display-connector: implement bus fmts callbacks") was introduced to make negociation work again by making display-connector act as a pass-through concerning input & output format negociation.

But in the case were

where

Quoted 2 lines

the dw-hdmi was single in the bridge chain, for example on Renesas SoCs, with the disply-connector

display-connector

Quoted 31 lines

bridge the dw-hdmi
is no more single, breaking output format.

Fixes 0656d1285b79 ("drm/bridge: display-connector: implement bus fmts callbacks").

---
 drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 9 +++++++--

 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +0 -0
index 54d8fdad395f..9f2e1cac0ae2 100644
@@ -2551,8 +2551,9 @@ static u32 *dw_hdmi_bridge_atomic_get_output_bus_fmts(struct drm_bridge *bridge,
         if (!output_fmts)
                 return NULL;


-       /* If dw-hdmi is the only bridge, avoid negociating with ourselves */ -       if (list_is_singular(&bridge->encoder->bridge_chain)) {
+       /* If dw-hdmi is the first or only bridge, avoid negociating with ourselves */ +       if (list_is_singular(&bridge->encoder->bridge_chain) ||
+           list_is_first(&bridge->chain_node, &bridge->encoder->bridge_chain)) { *num_output_fmts = 1;
                output_fmts[0] = MEDIA_BUS_FMT_FIXED;

drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +0 -0
@@ -2673,6 +2674,10 @@ static u32 *dw_hdmi_bridge_atomic_get_input_bus_fmts(struct drm_bridge *bridge,
         if (!input_fmts)
                 return NULL;
Quoted 8 lines


+       /* If dw-hdmi is the first bridge fall-back to safe output format */ +       if (list_is_first(&bridge->chain_node, &bridge->encoder->bridge_chain)) +               output_fmt = MEDIA_BUS_FMT_FIXED;
+
        switch (output_fmt) {
        /* If MEDIA_BUS_FMT_FIXED is tested, return default bus format */ case MEDIA_BUS_FMT_FIXED:

Cheers

Quoted 2 lines

Marcel

Thanks for the spelling fixes,

Neil