2022-01-18 02:32:22

by Neil Armstrong

[permalink] [raw]
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.

Reported-by: Biju Das <[email protected]>
Bisected-by: Kieran Bingham <[email protected]>
Tested-by: Kieran Bingham <[email protected]>
Fixes: 0656d1285b79 ("drm/bridge: display-connector: implement bus fmts callbacks").
Signed-off-by: Neil Armstrong <[email protected]>
---
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
index 54d8fdad395f..9f2e1cac0ae2 100644
--- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
+++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
@@ -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:
--
2.25.1


2022-01-18 02:41:51

by Marcel Ziswiler

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

Hi Neil

Sorry, just some trivial spelling fixes.

On Mon, 2022-01-17 at 15:17 +0100, Neil Armstrong wrote:
> When the dw-hdmi bridge is in first place of the bridge chain, this
> means there is now way

no way

> to select an input format of the dw-hdmi HW
> component.
>
> Since introduction of display-connector, negociation

:%s/negociation/negotiation/g

> 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

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

display-connector

> bridge the dw-hdmi
> is no more single, breaking output format.
>
> Reported-by: Biju Das <[email protected]>
> Bisected-by: Kieran Bingham <[email protected]>
> Tested-by: Kieran Bingham <[email protected]>
> Fixes: 0656d1285b79 ("drm/bridge: display-connector: implement bus fmts callbacks").
> Signed-off-by: Neil Armstrong <[email protected]>
> ---
>  drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
> index 54d8fdad395f..9f2e1cac0ae2 100644
> --- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
> +++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
> @@ -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:

Cheers

Marcel

2022-01-19 20:11:58

by Neil Armstrong

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

Hi,

On 17/01/2022 17:53, Marcel Ziswiler wrote:
> Hi Neil
>
> Sorry, just some trivial spelling fixes.
>
> On Mon, 2022-01-17 at 15:17 +0100, Neil Armstrong wrote:
>> When the dw-hdmi bridge is in first place of the bridge chain, this
>> means there is now way
>
> no way
>
>> to select an input format of the dw-hdmi HW
>> component.
>>
>> Since introduction of display-connector, negociation
>
> :%s/negociation/negotiation/g
>
>> 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
>
>> the dw-hdmi was single in the bridge chain, for
>> example on Renesas SoCs, with the disply-connector
>
> display-connector
>
>> bridge the dw-hdmi
>> is no more single, breaking output format.
>>
>> Reported-by: Biju Das <[email protected]>
>> Bisected-by: Kieran Bingham <[email protected]>
>> Tested-by: Kieran Bingham <[email protected]>
>> Fixes: 0656d1285b79 ("drm/bridge: display-connector: implement bus fmts callbacks").
>> Signed-off-by: Neil Armstrong <[email protected]>
>> ---
>>  drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 9 +++++++--
>>  1 file changed, 7 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
>> index 54d8fdad395f..9f2e1cac0ae2 100644
>> --- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
>> +++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
>> @@ -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:
>
> Cheers
>
> Marcel
>

Thanks for the spelling fixes,

Neil