dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V2 1/2] drm/bridge: samsung-dsim: Set P divider based on min/max of fin pll
@ 2024-02-11 23:09 ` Adam Ford
  2024-02-11 23:09   ` [PATCH V2 2/2] drm/bridge: samsung-dsim: Fix porch calcalcuation rounding Adam Ford
                     ` (3 more replies)
  0 siblings, 4 replies; 15+ messages in thread
From: Adam Ford @ 2024-02-11 23:09 UTC (permalink / raw)
  To: dri-devel
  Cc: marex, aford, Adam Ford, Frieder Schrempf, Inki Dae, Jagan Teki,
	Marek Szyprowski, Andrzej Hajda, Neil Armstrong, Robert Foss,
	Laurent Pinchart, Jonas Karlman, Jernej Skrabec,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Daniel Vetter, Marco Felsch, Michael Tretter,
	linux-kernel

The P divider should be set based on the min and max values of
the fin pll which may vary between different platforms.
These ranges are defined per platform, but hard-coded values
were used instead which resulted in a smaller range available
on the i.MX8M[MNP] than what was possible.

As noted by Frieder, there are descripencies between the reference
manuals of the Mini, Nano and Plus, so I reached out to my NXP
rep and got the following response regarding the varing notes
in the documentation.

"Yes it is definitely wrong, the one that is part of the NOTE in
MIPI_DPHY_M_PLLPMS register table against PMS_P, PMS_M and PMS_S is
not correct. I will report this to Doc team, the one customer should
be take into account is the Table 13-40 DPHY PLL Parameters and the
Note above."

With this patch, the clock rates now match the values used in NXP's
downstream kernel.

Fixes: 846307185f0f ("drm/bridge: samsung-dsim: update PLL reference clock")
Signed-off-by: Adam Ford <aford173@gmail.com>
Reviewed-by: Frieder Schrempf <frieder.schrempf@kontron.de>
Tested-by: Frieder Schrempf <frieder.schrempf@kontron.de>
---
V2:  Only update the commit message to reflect why these values
     were chosen.  No code change present

diff --git a/drivers/gpu/drm/bridge/samsung-dsim.c b/drivers/gpu/drm/bridge/samsung-dsim.c
index 95fedc68b0ae..8476650c477c 100644
--- a/drivers/gpu/drm/bridge/samsung-dsim.c
+++ b/drivers/gpu/drm/bridge/samsung-dsim.c
@@ -574,8 +574,8 @@ static unsigned long samsung_dsim_pll_find_pms(struct samsung_dsim *dsi,
 	u16 _m, best_m;
 	u8 _s, best_s;
 
-	p_min = DIV_ROUND_UP(fin, (12 * MHZ));
-	p_max = fin / (6 * MHZ);
+	p_min = DIV_ROUND_UP(fin, (driver_data->pll_fin_max * MHZ));
+	p_max = fin / (driver_data->pll_fin_min * MHZ);
 
 	for (_p = p_min; _p <= p_max; ++_p) {
 		for (_s = 0; _s <= 5; ++_s) {
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH V2 2/2] drm/bridge: samsung-dsim: Fix porch calcalcuation rounding
  2024-02-11 23:09 ` [PATCH V2 1/2] drm/bridge: samsung-dsim: Set P divider based on min/max of fin pll Adam Ford
@ 2024-02-11 23:09   ` Adam Ford
  2024-04-16 12:15     ` Adam Ford
                       ` (2 more replies)
  2024-02-27 22:22   ` [PATCH V2 1/2] drm/bridge: samsung-dsim: Set P divider based on min/max of fin pll Adam Ford
                     ` (2 subsequent siblings)
  3 siblings, 3 replies; 15+ messages in thread
From: Adam Ford @ 2024-02-11 23:09 UTC (permalink / raw)
  To: dri-devel
  Cc: marex, aford, Adam Ford, Frieder Schrempf, Inki Dae, Jagan Teki,
	Marek Szyprowski, Andrzej Hajda, Neil Armstrong, Robert Foss,
	Laurent Pinchart, Jonas Karlman, Jernej Skrabec,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Daniel Vetter, Marco Felsch, Michael Tretter,
	linux-kernel

When using video sync pulses, the HFP, HBP, and HSA are divided between
the available lanes if there is more than one lane.  For certain
timings and lane configurations, the HFP may not be evenly divisible.
If the HFP is rounded down, it ends up being too small which can cause
some monitors to not sync properly. In these instances, adjust htotal
and hsync to round the HFP up, and recalculate the htotal.

Tested-by: Frieder Schrempf <frieder.schrempf@kontron.de> # Kontron BL i.MX8MM with HDMI monitor
Signed-off-by: Adam Ford <aford173@gmail.com>
---
V2:  No changes

diff --git a/drivers/gpu/drm/bridge/samsung-dsim.c b/drivers/gpu/drm/bridge/samsung-dsim.c
index 8476650c477c..52939211fe93 100644
--- a/drivers/gpu/drm/bridge/samsung-dsim.c
+++ b/drivers/gpu/drm/bridge/samsung-dsim.c
@@ -1606,6 +1606,27 @@ static int samsung_dsim_atomic_check(struct drm_bridge *bridge,
 		adjusted_mode->flags |= (DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC);
 	}
 
+	/*
+	 * When using video sync pulses, the HFP, HBP, and HSA are divided between
+	 * the available lanes if there is more than one lane.  For certain
+	 * timings and lane configurations, the HFP may not be evenly divisible.
+	 * If the HFP is rounded down, it ends up being too small which can cause
+	 * some monitors to not sync properly. In these instances, adjust htotal
+	 * and hsync to round the HFP up, and recalculate the htotal. Through trial
+	 * and error, it appears that the HBP and HSA do not appearto need the same
+	 * correction that HFP does.
+	 */
+	if (dsi->mode_flags & MIPI_DSI_MODE_VIDEO_SYNC_PULSE && dsi->lanes > 1) {
+		int hfp = adjusted_mode->hsync_start - adjusted_mode->hdisplay;
+		int remainder = hfp % dsi->lanes;
+
+		if (remainder) {
+			adjusted_mode->hsync_start += remainder;
+			adjusted_mode->hsync_end   += remainder;
+			adjusted_mode->htotal      += remainder;
+		}
+	}
+
 	return 0;
 }
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH V2 1/2] drm/bridge: samsung-dsim: Set P divider based on min/max of fin pll
  2024-02-11 23:09 ` [PATCH V2 1/2] drm/bridge: samsung-dsim: Set P divider based on min/max of fin pll Adam Ford
  2024-02-11 23:09   ` [PATCH V2 2/2] drm/bridge: samsung-dsim: Fix porch calcalcuation rounding Adam Ford
@ 2024-02-27 22:22   ` Adam Ford
  2024-04-21 14:05   ` Marek Vasut
  2024-04-25  9:18   ` Marek Szyprowski
  3 siblings, 0 replies; 15+ messages in thread
From: Adam Ford @ 2024-02-27 22:22 UTC (permalink / raw)
  To: dri-devel
  Cc: marex, aford, Frieder Schrempf, Inki Dae, Jagan Teki,
	Marek Szyprowski, Andrzej Hajda, Neil Armstrong, Robert Foss,
	Laurent Pinchart, Jonas Karlman, Jernej Skrabec,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Daniel Vetter, Marco Felsch, Michael Tretter,
	linux-kernel

On Sun, Feb 11, 2024 at 5:09 PM Adam Ford <aford173@gmail.com> wrote:
>
> The P divider should be set based on the min and max values of
> the fin pll which may vary between different platforms.
> These ranges are defined per platform, but hard-coded values
> were used instead which resulted in a smaller range available
> on the i.MX8M[MNP] than what was possible.
>
> As noted by Frieder, there are descripencies between the reference
> manuals of the Mini, Nano and Plus, so I reached out to my NXP
> rep and got the following response regarding the varing notes
> in the documentation.
>
> "Yes it is definitely wrong, the one that is part of the NOTE in
> MIPI_DPHY_M_PLLPMS register table against PMS_P, PMS_M and PMS_S is
> not correct. I will report this to Doc team, the one customer should
> be take into account is the Table 13-40 DPHY PLL Parameters and the
> Note above."
>
> With this patch, the clock rates now match the values used in NXP's
> downstream kernel.
>

Inki,

Any change either or both of these patches could get applied?  It's
been several months since the first submission.

Fabio - Do you have an 8MP-evk that you could test to see if there is
any impact?  Between these two patches, it fixes the 720p@60  and
likely others too.

adam
> Fixes: 846307185f0f ("drm/bridge: samsung-dsim: update PLL reference clock")
> Signed-off-by: Adam Ford <aford173@gmail.com>
> Reviewed-by: Frieder Schrempf <frieder.schrempf@kontron.de>
> Tested-by: Frieder Schrempf <frieder.schrempf@kontron.de>
> ---
> V2:  Only update the commit message to reflect why these values
>      were chosen.  No code change present
>
> diff --git a/drivers/gpu/drm/bridge/samsung-dsim.c b/drivers/gpu/drm/bridge/samsung-dsim.c
> index 95fedc68b0ae..8476650c477c 100644
> --- a/drivers/gpu/drm/bridge/samsung-dsim.c
> +++ b/drivers/gpu/drm/bridge/samsung-dsim.c
> @@ -574,8 +574,8 @@ static unsigned long samsung_dsim_pll_find_pms(struct samsung_dsim *dsi,
>         u16 _m, best_m;
>         u8 _s, best_s;
>
> -       p_min = DIV_ROUND_UP(fin, (12 * MHZ));
> -       p_max = fin / (6 * MHZ);
> +       p_min = DIV_ROUND_UP(fin, (driver_data->pll_fin_max * MHZ));
> +       p_max = fin / (driver_data->pll_fin_min * MHZ);
>
>         for (_p = p_min; _p <= p_max; ++_p) {
>                 for (_s = 0; _s <= 5; ++_s) {
> --
> 2.43.0
>

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH V2 2/2] drm/bridge: samsung-dsim: Fix porch calcalcuation rounding
  2024-02-11 23:09   ` [PATCH V2 2/2] drm/bridge: samsung-dsim: Fix porch calcalcuation rounding Adam Ford
@ 2024-04-16 12:15     ` Adam Ford
  2024-04-21 14:06     ` Marek Vasut
  2024-04-25  9:18     ` Marek Szyprowski
  2 siblings, 0 replies; 15+ messages in thread
From: Adam Ford @ 2024-04-16 12:15 UTC (permalink / raw)
  To: dri-devel
  Cc: marex, aford, Frieder Schrempf, Inki Dae, Jagan Teki,
	Marek Szyprowski, Andrzej Hajda, Neil Armstrong, Robert Foss,
	Laurent Pinchart, Jonas Karlman, Jernej Skrabec,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Daniel Vetter, Marco Felsch, Michael Tretter,
	linux-kernel

On Sun, Feb 11, 2024 at 5:09 PM Adam Ford <aford173@gmail.com> wrote:
>
> When using video sync pulses, the HFP, HBP, and HSA are divided between
> the available lanes if there is more than one lane.  For certain
> timings and lane configurations, the HFP may not be evenly divisible.
> If the HFP is rounded down, it ends up being too small which can cause
> some monitors to not sync properly. In these instances, adjust htotal
> and hsync to round the HFP up, and recalculate the htotal.
>

Marek V and Marek S,

Would either of you be willing to test that this doesn't break your
applications?

thanks

adam

> Tested-by: Frieder Schrempf <frieder.schrempf@kontron.de> # Kontron BL i.MX8MM with HDMI monitor
> Signed-off-by: Adam Ford <aford173@gmail.com>
> ---
> V2:  No changes
>
> diff --git a/drivers/gpu/drm/bridge/samsung-dsim.c b/drivers/gpu/drm/bridge/samsung-dsim.c
> index 8476650c477c..52939211fe93 100644
> --- a/drivers/gpu/drm/bridge/samsung-dsim.c
> +++ b/drivers/gpu/drm/bridge/samsung-dsim.c
> @@ -1606,6 +1606,27 @@ static int samsung_dsim_atomic_check(struct drm_bridge *bridge,
>                 adjusted_mode->flags |= (DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC);
>         }
>
> +       /*
> +        * When using video sync pulses, the HFP, HBP, and HSA are divided between
> +        * the available lanes if there is more than one lane.  For certain
> +        * timings and lane configurations, the HFP may not be evenly divisible.
> +        * If the HFP is rounded down, it ends up being too small which can cause
> +        * some monitors to not sync properly. In these instances, adjust htotal
> +        * and hsync to round the HFP up, and recalculate the htotal. Through trial
> +        * and error, it appears that the HBP and HSA do not appearto need the same
> +        * correction that HFP does.
> +        */
> +       if (dsi->mode_flags & MIPI_DSI_MODE_VIDEO_SYNC_PULSE && dsi->lanes > 1) {
> +               int hfp = adjusted_mode->hsync_start - adjusted_mode->hdisplay;
> +               int remainder = hfp % dsi->lanes;
> +
> +               if (remainder) {
> +                       adjusted_mode->hsync_start += remainder;
> +                       adjusted_mode->hsync_end   += remainder;
> +                       adjusted_mode->htotal      += remainder;
> +               }
> +       }
> +
>         return 0;
>  }
>
> --
> 2.43.0
>

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH V2 1/2] drm/bridge: samsung-dsim: Set P divider based on min/max of fin pll
  2024-02-11 23:09 ` [PATCH V2 1/2] drm/bridge: samsung-dsim: Set P divider based on min/max of fin pll Adam Ford
  2024-02-11 23:09   ` [PATCH V2 2/2] drm/bridge: samsung-dsim: Fix porch calcalcuation rounding Adam Ford
  2024-02-27 22:22   ` [PATCH V2 1/2] drm/bridge: samsung-dsim: Set P divider based on min/max of fin pll Adam Ford
@ 2024-04-21 14:05   ` Marek Vasut
  2024-04-25  9:18   ` Marek Szyprowski
  3 siblings, 0 replies; 15+ messages in thread
From: Marek Vasut @ 2024-04-21 14:05 UTC (permalink / raw)
  To: Adam Ford, dri-devel
  Cc: aford, Frieder Schrempf, Inki Dae, Jagan Teki, Marek Szyprowski,
	Andrzej Hajda, Neil Armstrong, Robert Foss, Laurent Pinchart,
	Jonas Karlman, Jernej Skrabec, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Daniel Vetter, Marco Felsch,
	Michael Tretter, linux-kernel

On 2/12/24 12:09 AM, Adam Ford wrote:
> The P divider should be set based on the min and max values of
> the fin pll which may vary between different platforms.
> These ranges are defined per platform, but hard-coded values
> were used instead which resulted in a smaller range available
> on the i.MX8M[MNP] than what was possible.
> 
> As noted by Frieder, there are descripencies between the reference
> manuals of the Mini, Nano and Plus, so I reached out to my NXP
> rep and got the following response regarding the varing notes
> in the documentation.
> 
> "Yes it is definitely wrong, the one that is part of the NOTE in
> MIPI_DPHY_M_PLLPMS register table against PMS_P, PMS_M and PMS_S is
> not correct. I will report this to Doc team, the one customer should
> be take into account is the Table 13-40 DPHY PLL Parameters and the
> Note above."
> 
> With this patch, the clock rates now match the values used in NXP's
> downstream kernel.
> 
> Fixes: 846307185f0f ("drm/bridge: samsung-dsim: update PLL reference clock")
> Signed-off-by: Adam Ford <aford173@gmail.com>
> Reviewed-by: Frieder Schrempf <frieder.schrempf@kontron.de>
> Tested-by: Frieder Schrempf <frieder.schrempf@kontron.de>
> ---
> V2:  Only update the commit message to reflect why these values
>       were chosen.  No code change present
> 
> diff --git a/drivers/gpu/drm/bridge/samsung-dsim.c b/drivers/gpu/drm/bridge/samsung-dsim.c
> index 95fedc68b0ae..8476650c477c 100644
> --- a/drivers/gpu/drm/bridge/samsung-dsim.c
> +++ b/drivers/gpu/drm/bridge/samsung-dsim.c
> @@ -574,8 +574,8 @@ static unsigned long samsung_dsim_pll_find_pms(struct samsung_dsim *dsi,
>   	u16 _m, best_m;
>   	u8 _s, best_s;
>   
> -	p_min = DIV_ROUND_UP(fin, (12 * MHZ));
> -	p_max = fin / (6 * MHZ);
> +	p_min = DIV_ROUND_UP(fin, (driver_data->pll_fin_max * MHZ));

The parenthesis around driver_data... are not needed.

With that fixed:

Reviewed-by: Marek Vasut <marex@denx.de>

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH V2 2/2] drm/bridge: samsung-dsim: Fix porch calcalcuation rounding
  2024-02-11 23:09   ` [PATCH V2 2/2] drm/bridge: samsung-dsim: Fix porch calcalcuation rounding Adam Ford
  2024-04-16 12:15     ` Adam Ford
@ 2024-04-21 14:06     ` Marek Vasut
  2024-04-22 12:09       ` Adam Ford
  2024-04-25  9:18     ` Marek Szyprowski
  2 siblings, 1 reply; 15+ messages in thread
From: Marek Vasut @ 2024-04-21 14:06 UTC (permalink / raw)
  To: Adam Ford, dri-devel
  Cc: aford, Frieder Schrempf, Inki Dae, Jagan Teki, Marek Szyprowski,
	Andrzej Hajda, Neil Armstrong, Robert Foss, Laurent Pinchart,
	Jonas Karlman, Jernej Skrabec, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Daniel Vetter, Marco Felsch,
	Michael Tretter, linux-kernel

On 2/12/24 12:09 AM, Adam Ford wrote:
> When using video sync pulses, the HFP, HBP, and HSA are divided between
> the available lanes if there is more than one lane.  For certain
> timings and lane configurations, the HFP may not be evenly divisible.
> If the HFP is rounded down, it ends up being too small which can cause
> some monitors to not sync properly. In these instances, adjust htotal
> and hsync to round the HFP up, and recalculate the htotal.
> 
> Tested-by: Frieder Schrempf <frieder.schrempf@kontron.de> # Kontron BL i.MX8MM with HDMI monitor
> Signed-off-by: Adam Ford <aford173@gmail.com>
> ---
> V2:  No changes
> 
> diff --git a/drivers/gpu/drm/bridge/samsung-dsim.c b/drivers/gpu/drm/bridge/samsung-dsim.c
> index 8476650c477c..52939211fe93 100644
> --- a/drivers/gpu/drm/bridge/samsung-dsim.c
> +++ b/drivers/gpu/drm/bridge/samsung-dsim.c
> @@ -1606,6 +1606,27 @@ static int samsung_dsim_atomic_check(struct drm_bridge *bridge,
>   		adjusted_mode->flags |= (DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC);
>   	}
>   
> +	/*
> +	 * When using video sync pulses, the HFP, HBP, and HSA are divided between
> +	 * the available lanes if there is more than one lane.  For certain
> +	 * timings and lane configurations, the HFP may not be evenly divisible.
> +	 * If the HFP is rounded down, it ends up being too small which can cause
> +	 * some monitors to not sync properly. In these instances, adjust htotal
> +	 * and hsync to round the HFP up, and recalculate the htotal. Through trial
> +	 * and error, it appears that the HBP and HSA do not appearto need the same
> +	 * correction that HFP does.
> +	 */
> +	if (dsi->mode_flags & MIPI_DSI_MODE_VIDEO_SYNC_PULSE && dsi->lanes > 1) {

Does this also apply to mode with sync events (I suspect it does), so 
the condition here should likely be if (!...burst mode) , right ?

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH V2 2/2] drm/bridge: samsung-dsim: Fix porch calcalcuation rounding
  2024-04-21 14:06     ` Marek Vasut
@ 2024-04-22 12:09       ` Adam Ford
  2024-04-22 12:30         ` Marek Vasut
  0 siblings, 1 reply; 15+ messages in thread
From: Adam Ford @ 2024-04-22 12:09 UTC (permalink / raw)
  To: Marek Vasut
  Cc: dri-devel, aford, Frieder Schrempf, Inki Dae, Jagan Teki,
	Marek Szyprowski, Andrzej Hajda, Neil Armstrong, Robert Foss,
	Laurent Pinchart, Jonas Karlman, Jernej Skrabec,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Daniel Vetter, Marco Felsch, Michael Tretter,
	linux-kernel

On Sun, Apr 21, 2024 at 9:36 AM Marek Vasut <marex@denx.de> wrote:
>
> On 2/12/24 12:09 AM, Adam Ford wrote:
> > When using video sync pulses, the HFP, HBP, and HSA are divided between
> > the available lanes if there is more than one lane.  For certain
> > timings and lane configurations, the HFP may not be evenly divisible.
> > If the HFP is rounded down, it ends up being too small which can cause
> > some monitors to not sync properly. In these instances, adjust htotal
> > and hsync to round the HFP up, and recalculate the htotal.
> >
> > Tested-by: Frieder Schrempf <frieder.schrempf@kontron.de> # Kontron BL i.MX8MM with HDMI monitor
> > Signed-off-by: Adam Ford <aford173@gmail.com>
> > ---
> > V2:  No changes
> >
> > diff --git a/drivers/gpu/drm/bridge/samsung-dsim.c b/drivers/gpu/drm/bridge/samsung-dsim.c
> > index 8476650c477c..52939211fe93 100644
> > --- a/drivers/gpu/drm/bridge/samsung-dsim.c
> > +++ b/drivers/gpu/drm/bridge/samsung-dsim.c
> > @@ -1606,6 +1606,27 @@ static int samsung_dsim_atomic_check(struct drm_bridge *bridge,
> >               adjusted_mode->flags |= (DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC);
> >       }
> >
> > +     /*
> > +      * When using video sync pulses, the HFP, HBP, and HSA are divided between
> > +      * the available lanes if there is more than one lane.  For certain
> > +      * timings and lane configurations, the HFP may not be evenly divisible.
> > +      * If the HFP is rounded down, it ends up being too small which can cause
> > +      * some monitors to not sync properly. In these instances, adjust htotal
> > +      * and hsync to round the HFP up, and recalculate the htotal. Through trial
> > +      * and error, it appears that the HBP and HSA do not appearto need the same
> > +      * correction that HFP does.
> > +      */
> > +     if (dsi->mode_flags & MIPI_DSI_MODE_VIDEO_SYNC_PULSE && dsi->lanes > 1) {
>
> Does this also apply to mode with sync events (I suspect it does), so
> the condition here should likely be if (!...burst mode) , right ?

Thanks for the review!

I was only able to test it with the DSI->ADV6535 bridge, and I'll
admit I don't know a lot about DSI interface since I don't have a copy
of the spec to read.

Are you proposing this should be:

 if (!(dsi->mode_flags & MIPI_DSI_MODE_VIDEO_BURST) && dsi->lanes > 1) {

I just want to make sure I understand what you're requesting.

thanks

adam

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH V2 2/2] drm/bridge: samsung-dsim: Fix porch calcalcuation rounding
  2024-04-22 12:09       ` Adam Ford
@ 2024-04-22 12:30         ` Marek Vasut
  2024-04-22 13:04           ` Adam Ford
  0 siblings, 1 reply; 15+ messages in thread
From: Marek Vasut @ 2024-04-22 12:30 UTC (permalink / raw)
  To: Adam Ford
  Cc: dri-devel, aford, Frieder Schrempf, Inki Dae, Jagan Teki,
	Marek Szyprowski, Andrzej Hajda, Neil Armstrong, Robert Foss,
	Laurent Pinchart, Jonas Karlman, Jernej Skrabec,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Daniel Vetter, Marco Felsch, Michael Tretter,
	linux-kernel

On 4/22/24 2:09 PM, Adam Ford wrote:
> On Sun, Apr 21, 2024 at 9:36 AM Marek Vasut <marex@denx.de> wrote:
>>
>> On 2/12/24 12:09 AM, Adam Ford wrote:
>>> When using video sync pulses, the HFP, HBP, and HSA are divided between
>>> the available lanes if there is more than one lane.  For certain
>>> timings and lane configurations, the HFP may not be evenly divisible.
>>> If the HFP is rounded down, it ends up being too small which can cause
>>> some monitors to not sync properly. In these instances, adjust htotal
>>> and hsync to round the HFP up, and recalculate the htotal.
>>>
>>> Tested-by: Frieder Schrempf <frieder.schrempf@kontron.de> # Kontron BL i.MX8MM with HDMI monitor
>>> Signed-off-by: Adam Ford <aford173@gmail.com>
>>> ---
>>> V2:  No changes
>>>
>>> diff --git a/drivers/gpu/drm/bridge/samsung-dsim.c b/drivers/gpu/drm/bridge/samsung-dsim.c
>>> index 8476650c477c..52939211fe93 100644
>>> --- a/drivers/gpu/drm/bridge/samsung-dsim.c
>>> +++ b/drivers/gpu/drm/bridge/samsung-dsim.c
>>> @@ -1606,6 +1606,27 @@ static int samsung_dsim_atomic_check(struct drm_bridge *bridge,
>>>                adjusted_mode->flags |= (DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC);
>>>        }
>>>
>>> +     /*
>>> +      * When using video sync pulses, the HFP, HBP, and HSA are divided between
>>> +      * the available lanes if there is more than one lane.  For certain
>>> +      * timings and lane configurations, the HFP may not be evenly divisible.
>>> +      * If the HFP is rounded down, it ends up being too small which can cause
>>> +      * some monitors to not sync properly. In these instances, adjust htotal
>>> +      * and hsync to round the HFP up, and recalculate the htotal. Through trial
>>> +      * and error, it appears that the HBP and HSA do not appearto need the same
>>> +      * correction that HFP does.
>>> +      */
>>> +     if (dsi->mode_flags & MIPI_DSI_MODE_VIDEO_SYNC_PULSE && dsi->lanes > 1) {
>>
>> Does this also apply to mode with sync events (I suspect it does), so
>> the condition here should likely be if (!...burst mode) , right ?
> 
> Thanks for the review!
> 
> I was only able to test it with the DSI->ADV6535 bridge, and I'll
> admit I don't know a lot about DSI interface since I don't have a copy
> of the spec to read.
> 
> Are you proposing this should be:
> 
>   if (!(dsi->mode_flags & MIPI_DSI_MODE_VIDEO_BURST) && dsi->lanes > 1) {
> 
> I just want to make sure I understand what you're requesting.

Yes, exactly this.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH V2 2/2] drm/bridge: samsung-dsim: Fix porch calcalcuation rounding
  2024-04-22 12:30         ` Marek Vasut
@ 2024-04-22 13:04           ` Adam Ford
  2024-04-22 19:43             ` Marek Vasut
  0 siblings, 1 reply; 15+ messages in thread
From: Adam Ford @ 2024-04-22 13:04 UTC (permalink / raw)
  To: Marek Vasut
  Cc: dri-devel, aford, Frieder Schrempf, Inki Dae, Jagan Teki,
	Marek Szyprowski, Andrzej Hajda, Neil Armstrong, Robert Foss,
	Laurent Pinchart, Jonas Karlman, Jernej Skrabec,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Daniel Vetter, Marco Felsch, Michael Tretter,
	linux-kernel

On Mon, Apr 22, 2024 at 8:01 AM Marek Vasut <marex@denx.de> wrote:
>
> On 4/22/24 2:09 PM, Adam Ford wrote:
> > On Sun, Apr 21, 2024 at 9:36 AM Marek Vasut <marex@denx.de> wrote:
> >>
> >> On 2/12/24 12:09 AM, Adam Ford wrote:
> >>> When using video sync pulses, the HFP, HBP, and HSA are divided between
> >>> the available lanes if there is more than one lane.  For certain
> >>> timings and lane configurations, the HFP may not be evenly divisible.
> >>> If the HFP is rounded down, it ends up being too small which can cause
> >>> some monitors to not sync properly. In these instances, adjust htotal
> >>> and hsync to round the HFP up, and recalculate the htotal.
> >>>
> >>> Tested-by: Frieder Schrempf <frieder.schrempf@kontron.de> # Kontron BL i.MX8MM with HDMI monitor
> >>> Signed-off-by: Adam Ford <aford173@gmail.com>
> >>> ---
> >>> V2:  No changes
> >>>
> >>> diff --git a/drivers/gpu/drm/bridge/samsung-dsim.c b/drivers/gpu/drm/bridge/samsung-dsim.c
> >>> index 8476650c477c..52939211fe93 100644
> >>> --- a/drivers/gpu/drm/bridge/samsung-dsim.c
> >>> +++ b/drivers/gpu/drm/bridge/samsung-dsim.c
> >>> @@ -1606,6 +1606,27 @@ static int samsung_dsim_atomic_check(struct drm_bridge *bridge,
> >>>                adjusted_mode->flags |= (DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC);
> >>>        }
> >>>
> >>> +     /*
> >>> +      * When using video sync pulses, the HFP, HBP, and HSA are divided between
> >>> +      * the available lanes if there is more than one lane.  For certain
> >>> +      * timings and lane configurations, the HFP may not be evenly divisible.
> >>> +      * If the HFP is rounded down, it ends up being too small which can cause
> >>> +      * some monitors to not sync properly. In these instances, adjust htotal
> >>> +      * and hsync to round the HFP up, and recalculate the htotal. Through trial
> >>> +      * and error, it appears that the HBP and HSA do not appearto need the same
> >>> +      * correction that HFP does.
> >>> +      */
> >>> +     if (dsi->mode_flags & MIPI_DSI_MODE_VIDEO_SYNC_PULSE && dsi->lanes > 1) {
> >>
> >> Does this also apply to mode with sync events (I suspect it does), so
> >> the condition here should likely be if (!...burst mode) , right ?
> >
> > Thanks for the review!
> >
> > I was only able to test it with the DSI->ADV6535 bridge, and I'll
> > admit I don't know a lot about DSI interface since I don't have a copy
> > of the spec to read.
> >
> > Are you proposing this should be:
> >
> >   if (!(dsi->mode_flags & MIPI_DSI_MODE_VIDEO_BURST) && dsi->lanes > 1) {
> >
> > I just want to make sure I understand what you're requesting.
>
> Yes, exactly this.

Do you think it should also include checks for
MIPI_DSI_MODE_VIDEO_NO_HFP, MIPI_DSI_MODE_VIDEO_NO_HBP or
MIPI_DSI_MODE_VIDEO_NO_HSA?

It seems like if any of these are set, we should skip this rounding stuff.

adam

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH V2 2/2] drm/bridge: samsung-dsim: Fix porch calcalcuation rounding
  2024-04-22 13:04           ` Adam Ford
@ 2024-04-22 19:43             ` Marek Vasut
  0 siblings, 0 replies; 15+ messages in thread
From: Marek Vasut @ 2024-04-22 19:43 UTC (permalink / raw)
  To: Adam Ford
  Cc: dri-devel, aford, Frieder Schrempf, Inki Dae, Jagan Teki,
	Marek Szyprowski, Andrzej Hajda, Neil Armstrong, Robert Foss,
	Laurent Pinchart, Jonas Karlman, Jernej Skrabec,
	Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Daniel Vetter, Marco Felsch, Michael Tretter,
	linux-kernel

On 4/22/24 3:04 PM, Adam Ford wrote:
> On Mon, Apr 22, 2024 at 8:01 AM Marek Vasut <marex@denx.de> wrote:
>>
>> On 4/22/24 2:09 PM, Adam Ford wrote:
>>> On Sun, Apr 21, 2024 at 9:36 AM Marek Vasut <marex@denx.de> wrote:
>>>>
>>>> On 2/12/24 12:09 AM, Adam Ford wrote:
>>>>> When using video sync pulses, the HFP, HBP, and HSA are divided between
>>>>> the available lanes if there is more than one lane.  For certain
>>>>> timings and lane configurations, the HFP may not be evenly divisible.
>>>>> If the HFP is rounded down, it ends up being too small which can cause
>>>>> some monitors to not sync properly. In these instances, adjust htotal
>>>>> and hsync to round the HFP up, and recalculate the htotal.
>>>>>
>>>>> Tested-by: Frieder Schrempf <frieder.schrempf@kontron.de> # Kontron BL i.MX8MM with HDMI monitor
>>>>> Signed-off-by: Adam Ford <aford173@gmail.com>
>>>>> ---
>>>>> V2:  No changes
>>>>>
>>>>> diff --git a/drivers/gpu/drm/bridge/samsung-dsim.c b/drivers/gpu/drm/bridge/samsung-dsim.c
>>>>> index 8476650c477c..52939211fe93 100644
>>>>> --- a/drivers/gpu/drm/bridge/samsung-dsim.c
>>>>> +++ b/drivers/gpu/drm/bridge/samsung-dsim.c
>>>>> @@ -1606,6 +1606,27 @@ static int samsung_dsim_atomic_check(struct drm_bridge *bridge,
>>>>>                 adjusted_mode->flags |= (DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC);
>>>>>         }
>>>>>
>>>>> +     /*
>>>>> +      * When using video sync pulses, the HFP, HBP, and HSA are divided between
>>>>> +      * the available lanes if there is more than one lane.  For certain
>>>>> +      * timings and lane configurations, the HFP may not be evenly divisible.
>>>>> +      * If the HFP is rounded down, it ends up being too small which can cause
>>>>> +      * some monitors to not sync properly. In these instances, adjust htotal
>>>>> +      * and hsync to round the HFP up, and recalculate the htotal. Through trial
>>>>> +      * and error, it appears that the HBP and HSA do not appearto need the same
>>>>> +      * correction that HFP does.
>>>>> +      */
>>>>> +     if (dsi->mode_flags & MIPI_DSI_MODE_VIDEO_SYNC_PULSE && dsi->lanes > 1) {
>>>>
>>>> Does this also apply to mode with sync events (I suspect it does), so
>>>> the condition here should likely be if (!...burst mode) , right ?
>>>
>>> Thanks for the review!
>>>
>>> I was only able to test it with the DSI->ADV6535 bridge, and I'll
>>> admit I don't know a lot about DSI interface since I don't have a copy
>>> of the spec to read.
>>>
>>> Are you proposing this should be:
>>>
>>>    if (!(dsi->mode_flags & MIPI_DSI_MODE_VIDEO_BURST) && dsi->lanes > 1) {
>>>
>>> I just want to make sure I understand what you're requesting.
>>
>> Yes, exactly this.
> 
> Do you think it should also include checks for
> MIPI_DSI_MODE_VIDEO_NO_HFP, MIPI_DSI_MODE_VIDEO_NO_HBP or
> MIPI_DSI_MODE_VIDEO_NO_HSA?
> 
> It seems like if any of these are set, we should skip this rounding stuff.

Now that you ask this question, shouldn't this actually apply 
unconditionally , no matter which mode is in use ?

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH V2 1/2] drm/bridge: samsung-dsim: Set P divider based on min/max of fin pll
  2024-02-11 23:09 ` [PATCH V2 1/2] drm/bridge: samsung-dsim: Set P divider based on min/max of fin pll Adam Ford
                     ` (2 preceding siblings ...)
  2024-04-21 14:05   ` Marek Vasut
@ 2024-04-25  9:18   ` Marek Szyprowski
  3 siblings, 0 replies; 15+ messages in thread
From: Marek Szyprowski @ 2024-04-25  9:18 UTC (permalink / raw)
  To: Adam Ford, dri-devel
  Cc: marex, aford, Frieder Schrempf, Inki Dae, Jagan Teki,
	Andrzej Hajda, Neil Armstrong, Robert Foss, Laurent Pinchart,
	Jonas Karlman, Jernej Skrabec, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Daniel Vetter, Marco Felsch,
	Michael Tretter, linux-kernel

On 12.02.2024 00:09, Adam Ford wrote:
> The P divider should be set based on the min and max values of
> the fin pll which may vary between different platforms.
> These ranges are defined per platform, but hard-coded values
> were used instead which resulted in a smaller range available
> on the i.MX8M[MNP] than what was possible.
>
> As noted by Frieder, there are descripencies between the reference
> manuals of the Mini, Nano and Plus, so I reached out to my NXP
> rep and got the following response regarding the varing notes
> in the documentation.
>
> "Yes it is definitely wrong, the one that is part of the NOTE in
> MIPI_DPHY_M_PLLPMS register table against PMS_P, PMS_M and PMS_S is
> not correct. I will report this to Doc team, the one customer should
> be take into account is the Table 13-40 DPHY PLL Parameters and the
> Note above."
>
> With this patch, the clock rates now match the values used in NXP's
> downstream kernel.
>
> Fixes: 846307185f0f ("drm/bridge: samsung-dsim: update PLL reference clock")
> Signed-off-by: Adam Ford <aford173@gmail.com>
> Reviewed-by: Frieder Schrempf <frieder.schrempf@kontron.de>
> Tested-by: Frieder Schrempf <frieder.schrempf@kontron.de>

Feel free to add:

Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>

although all Exynos based boards have panels with fixed timings afair.

> ---
> V2:  Only update the commit message to reflect why these values
>       were chosen.  No code change present
>
> diff --git a/drivers/gpu/drm/bridge/samsung-dsim.c b/drivers/gpu/drm/bridge/samsung-dsim.c
> index 95fedc68b0ae..8476650c477c 100644
> --- a/drivers/gpu/drm/bridge/samsung-dsim.c
> +++ b/drivers/gpu/drm/bridge/samsung-dsim.c
> @@ -574,8 +574,8 @@ static unsigned long samsung_dsim_pll_find_pms(struct samsung_dsim *dsi,
>   	u16 _m, best_m;
>   	u8 _s, best_s;
>   
> -	p_min = DIV_ROUND_UP(fin, (12 * MHZ));
> -	p_max = fin / (6 * MHZ);
> +	p_min = DIV_ROUND_UP(fin, (driver_data->pll_fin_max * MHZ));
> +	p_max = fin / (driver_data->pll_fin_min * MHZ);
>   
>   	for (_p = p_min; _p <= p_max; ++_p) {
>   		for (_s = 0; _s <= 5; ++_s) {

Best regards
-- 
Marek Szyprowski, PhD
Samsung R&D Institute Poland


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH V2 2/2] drm/bridge: samsung-dsim: Fix porch calcalcuation rounding
  2024-02-11 23:09   ` [PATCH V2 2/2] drm/bridge: samsung-dsim: Fix porch calcalcuation rounding Adam Ford
  2024-04-16 12:15     ` Adam Ford
  2024-04-21 14:06     ` Marek Vasut
@ 2024-04-25  9:18     ` Marek Szyprowski
  2024-04-25 20:30       ` Adam Ford
  2 siblings, 1 reply; 15+ messages in thread
From: Marek Szyprowski @ 2024-04-25  9:18 UTC (permalink / raw)
  To: Adam Ford, dri-devel
  Cc: marex, aford, Frieder Schrempf, Inki Dae, Jagan Teki,
	Andrzej Hajda, Neil Armstrong, Robert Foss, Laurent Pinchart,
	Jonas Karlman, Jernej Skrabec, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Daniel Vetter, Marco Felsch,
	Michael Tretter, linux-kernel

On 12.02.2024 00:09, Adam Ford wrote:
> When using video sync pulses, the HFP, HBP, and HSA are divided between
> the available lanes if there is more than one lane.  For certain
> timings and lane configurations, the HFP may not be evenly divisible.
> If the HFP is rounded down, it ends up being too small which can cause
> some monitors to not sync properly. In these instances, adjust htotal
> and hsync to round the HFP up, and recalculate the htotal.
>
> Tested-by: Frieder Schrempf <frieder.schrempf@kontron.de> # Kontron BL i.MX8MM with HDMI monitor
> Signed-off-by: Adam Ford <aford173@gmail.com>

Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>

> ---
> V2:  No changes
>
> diff --git a/drivers/gpu/drm/bridge/samsung-dsim.c b/drivers/gpu/drm/bridge/samsung-dsim.c
> index 8476650c477c..52939211fe93 100644
> --- a/drivers/gpu/drm/bridge/samsung-dsim.c
> +++ b/drivers/gpu/drm/bridge/samsung-dsim.c
> @@ -1606,6 +1606,27 @@ static int samsung_dsim_atomic_check(struct drm_bridge *bridge,
>   		adjusted_mode->flags |= (DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC);
>   	}
>   
> +	/*
> +	 * When using video sync pulses, the HFP, HBP, and HSA are divided between
> +	 * the available lanes if there is more than one lane.  For certain
> +	 * timings and lane configurations, the HFP may not be evenly divisible.
> +	 * If the HFP is rounded down, it ends up being too small which can cause
> +	 * some monitors to not sync properly. In these instances, adjust htotal
> +	 * and hsync to round the HFP up, and recalculate the htotal. Through trial
> +	 * and error, it appears that the HBP and HSA do not appearto need the same
> +	 * correction that HFP does.
> +	 */
> +	if (dsi->mode_flags & MIPI_DSI_MODE_VIDEO_SYNC_PULSE && dsi->lanes > 1) {
> +		int hfp = adjusted_mode->hsync_start - adjusted_mode->hdisplay;
> +		int remainder = hfp % dsi->lanes;
> +
> +		if (remainder) {
> +			adjusted_mode->hsync_start += remainder;
> +			adjusted_mode->hsync_end   += remainder;
> +			adjusted_mode->htotal      += remainder;
> +		}
> +	}
> +
>   	return 0;
>   }
>   

Best regards
-- 
Marek Szyprowski, PhD
Samsung R&D Institute Poland


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH V2 2/2] drm/bridge: samsung-dsim: Fix porch calcalcuation rounding
  2024-04-25  9:18     ` Marek Szyprowski
@ 2024-04-25 20:30       ` Adam Ford
  2024-04-26  5:28         ` Marek Szyprowski
  2024-05-07  8:40         ` Frieder Schrempf
  0 siblings, 2 replies; 15+ messages in thread
From: Adam Ford @ 2024-04-25 20:30 UTC (permalink / raw)
  To: Marek Szyprowski
  Cc: dri-devel, marex, aford, Frieder Schrempf, Inki Dae, Jagan Teki,
	Andrzej Hajda, Neil Armstrong, Robert Foss, Laurent Pinchart,
	Jonas Karlman, Jernej Skrabec, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Daniel Vetter, Marco Felsch,
	Michael Tretter, linux-kernel

On Thu, Apr 25, 2024 at 4:19 AM Marek Szyprowski
<m.szyprowski@samsung.com> wrote:
>
> On 12.02.2024 00:09, Adam Ford wrote:
> > When using video sync pulses, the HFP, HBP, and HSA are divided between
> > the available lanes if there is more than one lane.  For certain
> > timings and lane configurations, the HFP may not be evenly divisible.
> > If the HFP is rounded down, it ends up being too small which can cause
> > some monitors to not sync properly. In these instances, adjust htotal
> > and hsync to round the HFP up, and recalculate the htotal.
> >
> > Tested-by: Frieder Schrempf <frieder.schrempf@kontron.de> # Kontron BL i.MX8MM with HDMI monitor
> > Signed-off-by: Adam Ford <aford173@gmail.com>
>
> Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>

Thank you very much for testing!

>
> > ---
> > V2:  No changes
> >
> > diff --git a/drivers/gpu/drm/bridge/samsung-dsim.c b/drivers/gpu/drm/bridge/samsung-dsim.c
> > index 8476650c477c..52939211fe93 100644
> > --- a/drivers/gpu/drm/bridge/samsung-dsim.c
> > +++ b/drivers/gpu/drm/bridge/samsung-dsim.c
> > @@ -1606,6 +1606,27 @@ static int samsung_dsim_atomic_check(struct drm_bridge *bridge,
> >               adjusted_mode->flags |= (DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC);
> >       }
> >
> > +     /*
> > +      * When using video sync pulses, the HFP, HBP, and HSA are divided between
> > +      * the available lanes if there is more than one lane.  For certain
> > +      * timings and lane configurations, the HFP may not be evenly divisible.
> > +      * If the HFP is rounded down, it ends up being too small which can cause
> > +      * some monitors to not sync properly. In these instances, adjust htotal
> > +      * and hsync to round the HFP up, and recalculate the htotal. Through trial
> > +      * and error, it appears that the HBP and HSA do not appearto need the same
> > +      * correction that HFP does.
> > +      */
> > +     if (dsi->mode_flags & MIPI_DSI_MODE_VIDEO_SYNC_PULSE && dsi->lanes > 1) {

Frieder  &  Marek S,

Marek V is proposing we eliminate the check against the flags and do
it unconditionally.  If I send you both a different patch, would you
be willing to try them on your platforms?  I don't want to risk
breaking a board.
I used the check above from the NXP downstream kernel, so it felt
safe, but I am not as familiar with the different DSI modes, so I am
not sure what the impact would be if this read:

 if (dsi->lanes > 1) {

Does anyone else have an opinion on this?
> > +             int hfp = adjusted_mode->hsync_start - adjusted_mode->hdisplay;
> > +             int remainder = hfp % dsi->lanes;
> > +
> > +             if (remainder) {
> > +                     adjusted_mode->hsync_start += remainder;
> > +                     adjusted_mode->hsync_end   += remainder;
> > +                     adjusted_mode->htotal      += remainder;
> > +             }
> > +     }
> > +
> >       return 0;
> >   }
> >
>
> Best regards
> --
> Marek Szyprowski, PhD
> Samsung R&D Institute Poland
>

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH V2 2/2] drm/bridge: samsung-dsim: Fix porch calcalcuation rounding
  2024-04-25 20:30       ` Adam Ford
@ 2024-04-26  5:28         ` Marek Szyprowski
  2024-05-07  8:40         ` Frieder Schrempf
  1 sibling, 0 replies; 15+ messages in thread
From: Marek Szyprowski @ 2024-04-26  5:28 UTC (permalink / raw)
  To: Adam Ford
  Cc: dri-devel, marex, aford, Frieder Schrempf, Inki Dae, Jagan Teki,
	Andrzej Hajda, Neil Armstrong, Robert Foss, Laurent Pinchart,
	Jonas Karlman, Jernej Skrabec, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Daniel Vetter, Marco Felsch,
	Michael Tretter, linux-kernel

On 25.04.2024 22:30, Adam Ford wrote:
> On Thu, Apr 25, 2024 at 4:19 AM Marek Szyprowski
> <m.szyprowski@samsung.com> wrote:
>> On 12.02.2024 00:09, Adam Ford wrote:
>>> When using video sync pulses, the HFP, HBP, and HSA are divided between
>>> the available lanes if there is more than one lane.  For certain
>>> timings and lane configurations, the HFP may not be evenly divisible.
>>> If the HFP is rounded down, it ends up being too small which can cause
>>> some monitors to not sync properly. In these instances, adjust htotal
>>> and hsync to round the HFP up, and recalculate the htotal.
>>>
>>> Tested-by: Frieder Schrempf <frieder.schrempf@kontron.de> # Kontron BL i.MX8MM with HDMI monitor
>>> Signed-off-by: Adam Ford <aford173@gmail.com>
>> Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
> Thank you very much for testing!
>
>>> ---
>>> V2:  No changes
>>>
>>> diff --git a/drivers/gpu/drm/bridge/samsung-dsim.c b/drivers/gpu/drm/bridge/samsung-dsim.c
>>> index 8476650c477c..52939211fe93 100644
>>> --- a/drivers/gpu/drm/bridge/samsung-dsim.c
>>> +++ b/drivers/gpu/drm/bridge/samsung-dsim.c
>>> @@ -1606,6 +1606,27 @@ static int samsung_dsim_atomic_check(struct drm_bridge *bridge,
>>>                adjusted_mode->flags |= (DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC);
>>>        }
>>>
>>> +     /*
>>> +      * When using video sync pulses, the HFP, HBP, and HSA are divided between
>>> +      * the available lanes if there is more than one lane.  For certain
>>> +      * timings and lane configurations, the HFP may not be evenly divisible.
>>> +      * If the HFP is rounded down, it ends up being too small which can cause
>>> +      * some monitors to not sync properly. In these instances, adjust htotal
>>> +      * and hsync to round the HFP up, and recalculate the htotal. Through trial
>>> +      * and error, it appears that the HBP and HSA do not appearto need the same
>>> +      * correction that HFP does.
>>> +      */
>>> +     if (dsi->mode_flags & MIPI_DSI_MODE_VIDEO_SYNC_PULSE && dsi->lanes > 1) {
> Frieder  &  Marek S,
>
> Marek V is proposing we eliminate the check against the flags and do
> it unconditionally.  If I send you both a different patch, would you
> be willing to try them on your platforms?  I don't want to risk
> breaking a board.

I'm fine with testing it. I also have some additional spare boards to 
replace the broken one, but so far none was bricked by my weird testing 
activities.

> I used the check above from the NXP downstream kernel, so it felt
> safe, but I am not as familiar with the different DSI modes, so I am
> not sure what the impact would be if this read:
>
>   if (dsi->lanes > 1) {
>
> Does anyone else have an opinion on this?
>>> +             int hfp = adjusted_mode->hsync_start - adjusted_mode->hdisplay;
>>> +             int remainder = hfp % dsi->lanes;
>>> +
>>> +             if (remainder) {
>>> +                     adjusted_mode->hsync_start += remainder;
>>> +                     adjusted_mode->hsync_end   += remainder;
>>> +                     adjusted_mode->htotal      += remainder;
>>> +             }
>>> +     }
>>> +
>>>        return 0;
>>>    }

Best regards
-- 
Marek Szyprowski, PhD
Samsung R&D Institute Poland


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH V2 2/2] drm/bridge: samsung-dsim: Fix porch calcalcuation rounding
  2024-04-25 20:30       ` Adam Ford
  2024-04-26  5:28         ` Marek Szyprowski
@ 2024-05-07  8:40         ` Frieder Schrempf
  1 sibling, 0 replies; 15+ messages in thread
From: Frieder Schrempf @ 2024-05-07  8:40 UTC (permalink / raw)
  To: Adam Ford, Marek Szyprowski
  Cc: dri-devel, marex, aford, Inki Dae, Jagan Teki, Andrzej Hajda,
	Neil Armstrong, Robert Foss, Laurent Pinchart, Jonas Karlman,
	Jernej Skrabec, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Daniel Vetter, Marco Felsch,
	Michael Tretter, linux-kernel

On 25.04.24 22:30, Adam Ford wrote:
> On Thu, Apr 25, 2024 at 4:19 AM Marek Szyprowski
> <m.szyprowski@samsung.com> wrote:
>>
>> On 12.02.2024 00:09, Adam Ford wrote:
>>> When using video sync pulses, the HFP, HBP, and HSA are divided between
>>> the available lanes if there is more than one lane.  For certain
>>> timings and lane configurations, the HFP may not be evenly divisible.
>>> If the HFP is rounded down, it ends up being too small which can cause
>>> some monitors to not sync properly. In these instances, adjust htotal
>>> and hsync to round the HFP up, and recalculate the htotal.
>>>
>>> Tested-by: Frieder Schrempf <frieder.schrempf@kontron.de> # Kontron BL i.MX8MM with HDMI monitor
>>> Signed-off-by: Adam Ford <aford173@gmail.com>
>>
>> Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
> 
> Thank you very much for testing!
> 
>>
>>> ---
>>> V2:  No changes
>>>
>>> diff --git a/drivers/gpu/drm/bridge/samsung-dsim.c b/drivers/gpu/drm/bridge/samsung-dsim.c
>>> index 8476650c477c..52939211fe93 100644
>>> --- a/drivers/gpu/drm/bridge/samsung-dsim.c
>>> +++ b/drivers/gpu/drm/bridge/samsung-dsim.c
>>> @@ -1606,6 +1606,27 @@ static int samsung_dsim_atomic_check(struct drm_bridge *bridge,
>>>               adjusted_mode->flags |= (DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC);
>>>       }
>>>
>>> +     /*
>>> +      * When using video sync pulses, the HFP, HBP, and HSA are divided between
>>> +      * the available lanes if there is more than one lane.  For certain
>>> +      * timings and lane configurations, the HFP may not be evenly divisible.
>>> +      * If the HFP is rounded down, it ends up being too small which can cause
>>> +      * some monitors to not sync properly. In these instances, adjust htotal
>>> +      * and hsync to round the HFP up, and recalculate the htotal. Through trial
>>> +      * and error, it appears that the HBP and HSA do not appearto need the same
>>> +      * correction that HFP does.
>>> +      */
>>> +     if (dsi->mode_flags & MIPI_DSI_MODE_VIDEO_SYNC_PULSE && dsi->lanes > 1) {
> 
> Frieder  &  Marek S,
> 
> Marek V is proposing we eliminate the check against the flags and do
> it unconditionally.  If I send you both a different patch, would you
> be willing to try them on your platforms?  I don't want to risk
> breaking a board.
> I used the check above from the NXP downstream kernel, so it felt
> safe, but I am not as familiar with the different DSI modes, so I am
> not sure what the impact would be if this read:
> 
>  if (dsi->lanes > 1) {
> 
> Does anyone else have an opinion on this?

My test only covers hardware with the ADV7535 which sets
MIPI_DSI_MODE_VIDEO_SYNC_PULSE. Doing the test without the check for
this flag won't make any difference in this case and it's therefore not
worth repeating the test.

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2024-05-07  8:40 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20240211230943eucas1p23524077c0e8e7431c2af6f3153935bd5@eucas1p2.samsung.com>
2024-02-11 23:09 ` [PATCH V2 1/2] drm/bridge: samsung-dsim: Set P divider based on min/max of fin pll Adam Ford
2024-02-11 23:09   ` [PATCH V2 2/2] drm/bridge: samsung-dsim: Fix porch calcalcuation rounding Adam Ford
2024-04-16 12:15     ` Adam Ford
2024-04-21 14:06     ` Marek Vasut
2024-04-22 12:09       ` Adam Ford
2024-04-22 12:30         ` Marek Vasut
2024-04-22 13:04           ` Adam Ford
2024-04-22 19:43             ` Marek Vasut
2024-04-25  9:18     ` Marek Szyprowski
2024-04-25 20:30       ` Adam Ford
2024-04-26  5:28         ` Marek Szyprowski
2024-05-07  8:40         ` Frieder Schrempf
2024-02-27 22:22   ` [PATCH V2 1/2] drm/bridge: samsung-dsim: Set P divider based on min/max of fin pll Adam Ford
2024-04-21 14:05   ` Marek Vasut
2024-04-25  9:18   ` Marek Szyprowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).