mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/2] video: ipuv3: use closest fractional divider
@ 2018-11-12 16:22 Lucas Stach
  2018-11-12 16:22 ` [PATCH 2/2] video: ipuv3: use non-fractional clock for parallel display Lucas Stach
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Lucas Stach @ 2018-11-12 16:22 UTC (permalink / raw)
  To: barebox

Currently the divider is always rounded down, which may lead to a
rather big overshoot of the display clock. Try to match the clock
better by rounding to closest.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
 drivers/video/imx-ipu-v3/ipu-di.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/video/imx-ipu-v3/ipu-di.c b/drivers/video/imx-ipu-v3/ipu-di.c
index b6e64fe16a85..5751c678b28e 100644
--- a/drivers/video/imx-ipu-v3/ipu-di.c
+++ b/drivers/video/imx-ipu-v3/ipu-di.c
@@ -140,10 +140,7 @@ static int ipu_di_clk_calc_div(unsigned long inrate, unsigned long outrate)
 	int div;
 
 	tmp *= 16;
-
-	do_div(tmp, outrate);
-
-	div = tmp;
+	div = DIV_ROUND_CLOSEST(tmp, outrate);
 
 	if (div < 0x10)
 		div = 0x10;
-- 
2.19.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 2/2] video: ipuv3: use non-fractional clock for parallel display
  2018-11-12 16:22 [PATCH 1/2] video: ipuv3: use closest fractional divider Lucas Stach
@ 2018-11-12 16:22 ` Lucas Stach
  2018-11-14  8:59 ` [PATCH 1/2] video: ipuv3: use closest fractional divider Sascha Hauer
  2018-11-19 10:05 ` Sascha Hauer
  2 siblings, 0 replies; 4+ messages in thread
From: Lucas Stach @ 2018-11-12 16:22 UTC (permalink / raw)
  To: barebox

There is no need to keep DI and parent clock in sync for the parallel
display interface, but some displays really don't like the jitter
introduced by using a fractional clock.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
 drivers/video/imx-ipu-v3/imx-pd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/video/imx-ipu-v3/imx-pd.c b/drivers/video/imx-ipu-v3/imx-pd.c
index 09d8a3ae2a84..601be35880ac 100644
--- a/drivers/video/imx-ipu-v3/imx-pd.c
+++ b/drivers/video/imx-ipu-v3/imx-pd.c
@@ -45,7 +45,7 @@ static int imx_pd_ioctl(struct vpl *vpl, unsigned int port,
 	case IMX_IPU_VPL_DI_MODE:
 		mode = data;
 
-		mode->di_clkflags = IPU_DI_CLKMODE_SYNC;
+		mode->di_clkflags = IPU_DI_CLKMODE_NON_FRACTIONAL;
 		mode->bus_format = imx_pd->bus_format;
 		return 0;
 
-- 
2.19.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH 1/2] video: ipuv3: use closest fractional divider
  2018-11-12 16:22 [PATCH 1/2] video: ipuv3: use closest fractional divider Lucas Stach
  2018-11-12 16:22 ` [PATCH 2/2] video: ipuv3: use non-fractional clock for parallel display Lucas Stach
@ 2018-11-14  8:59 ` Sascha Hauer
  2018-11-19 10:05 ` Sascha Hauer
  2 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2018-11-14  8:59 UTC (permalink / raw)
  To: Lucas Stach; +Cc: barebox

On Mon, Nov 12, 2018 at 05:22:56PM +0100, Lucas Stach wrote:
> Currently the divider is always rounded down, which may lead to a
> rather big overshoot of the display clock. Try to match the clock
> better by rounding to closest.
> 
> Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
> ---
>  drivers/video/imx-ipu-v3/ipu-di.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)

Applied, thanks

Sascha

> 
> diff --git a/drivers/video/imx-ipu-v3/ipu-di.c b/drivers/video/imx-ipu-v3/ipu-di.c
> index b6e64fe16a85..5751c678b28e 100644
> --- a/drivers/video/imx-ipu-v3/ipu-di.c
> +++ b/drivers/video/imx-ipu-v3/ipu-di.c
> @@ -140,10 +140,7 @@ static int ipu_di_clk_calc_div(unsigned long inrate, unsigned long outrate)
>  	int div;
>  
>  	tmp *= 16;
> -
> -	do_div(tmp, outrate);
> -
> -	div = tmp;
> +	div = DIV_ROUND_CLOSEST(tmp, outrate);
>  
>  	if (div < 0x10)
>  		div = 0x10;
> -- 
> 2.19.1
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH 1/2] video: ipuv3: use closest fractional divider
  2018-11-12 16:22 [PATCH 1/2] video: ipuv3: use closest fractional divider Lucas Stach
  2018-11-12 16:22 ` [PATCH 2/2] video: ipuv3: use non-fractional clock for parallel display Lucas Stach
  2018-11-14  8:59 ` [PATCH 1/2] video: ipuv3: use closest fractional divider Sascha Hauer
@ 2018-11-19 10:05 ` Sascha Hauer
  2 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2018-11-19 10:05 UTC (permalink / raw)
  To: Lucas Stach; +Cc: barebox

On Mon, Nov 12, 2018 at 05:22:56PM +0100, Lucas Stach wrote:
> Currently the divider is always rounded down, which may lead to a
> rather big overshoot of the display clock. Try to match the clock
> better by rounding to closest.
> 
> Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
> ---
>  drivers/video/imx-ipu-v3/ipu-di.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/drivers/video/imx-ipu-v3/ipu-di.c b/drivers/video/imx-ipu-v3/ipu-di.c
> index b6e64fe16a85..5751c678b28e 100644
> --- a/drivers/video/imx-ipu-v3/ipu-di.c
> +++ b/drivers/video/imx-ipu-v3/ipu-di.c
> @@ -140,10 +140,7 @@ static int ipu_di_clk_calc_div(unsigned long inrate, unsigned long outrate)
>  	int div;
>  
>  	tmp *= 16;
> -
> -	do_div(tmp, outrate);
> -
> -	div = tmp;
> +	div = DIV_ROUND_CLOSEST(tmp, outrate);
>  

On ARM32 this fails with:

undefined reference to `__aeabi_uldivmod'

Fixed up like this:

----------------------------8<-------------------------

From 6b14328204f3978abeb91e8e779f6444c3c74df8 Mon Sep 17 00:00:00 2001
From: Lucas Stach <l.stach@pengutronix.de>
Date: Mon, 12 Nov 2018 17:22:56 +0100
Subject: [PATCH] video: ipuv3: use closest fractional divider

Currently the divider is always rounded down, which may lead to a
rather big overshoot of the display clock. Try to match the clock
better by rounding to closest.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/video/imx-ipu-v3/ipu-di.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/video/imx-ipu-v3/ipu-di.c b/drivers/video/imx-ipu-v3/ipu-di.c
index b6e64fe16a..b4302412e0 100644
--- a/drivers/video/imx-ipu-v3/ipu-di.c
+++ b/drivers/video/imx-ipu-v3/ipu-di.c
@@ -140,6 +140,7 @@ static int ipu_di_clk_calc_div(unsigned long inrate, unsigned long outrate)
 	int div;
 
 	tmp *= 16;
+	tmp += outrate / 2;
 
 	do_div(tmp, outrate);
 
-- 
2.19.1

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2018-11-19 10:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-12 16:22 [PATCH 1/2] video: ipuv3: use closest fractional divider Lucas Stach
2018-11-12 16:22 ` [PATCH 2/2] video: ipuv3: use non-fractional clock for parallel display Lucas Stach
2018-11-14  8:59 ` [PATCH 1/2] video: ipuv3: use closest fractional divider Sascha Hauer
2018-11-19 10:05 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox