linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/bridge: adv7511: Fix low refresh rate selection
@ 2019-04-24 13:22 Matt Redfearn
  2019-05-11 19:32 ` Laurent Pinchart
  0 siblings, 1 reply; 3+ messages in thread
From: Matt Redfearn @ 2019-04-24 13:22 UTC (permalink / raw)
  To: Archit Taneja, Andrzej Hajda, Laurent Pinchart
  Cc: dri-devel, Matthew Redfearn, linux-kernel, Jia-Ju Bai,
	Kieran Bingham, David Airlie, Sean Paul, Daniel Vetter

The driver currently sets register 0xfb (Low Refresh Rate) based on the
value of mode->vrefresh. Firstly, this field is specified to be in Hz,
but the magic numbers used by the code are Hz * 1000. This essentially
leads to the low refresh rate always being set to 0x01, since the
vrefresh value will always be less than 24000. Fix the magic numbers to
be in Hz.
Secondly, according to the comment in drm_modes.h, the field is not
supposed to be used in a functional way anyway. Instead, use the helper
function drm_mode_vrefresh().

Fixes: 9c8af882bf12 ("drm: Add adv7511 encoder driver")
Signed-off-by: Matt Redfearn <matt.redfearn@thinci.com>

---

 drivers/gpu/drm/bridge/adv7511/adv7511_drv.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
index 85c2d407a52..e7ddd3e3db9 100644
--- a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
+++ b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
@@ -747,11 +747,11 @@ static void adv7511_mode_set(struct adv7511 *adv7511,
 			vsync_polarity = 1;
 	}
 
-	if (mode->vrefresh <= 24000)
+	if (drm_mode_vrefresh(mode) <= 24)
 		low_refresh_rate = ADV7511_LOW_REFRESH_RATE_24HZ;
-	else if (mode->vrefresh <= 25000)
+	else if (drm_mode_vrefresh(mode) <= 25)
 		low_refresh_rate = ADV7511_LOW_REFRESH_RATE_25HZ;
-	else if (mode->vrefresh <= 30000)
+	else if (drm_mode_vrefresh(mode) <= 30)
 		low_refresh_rate = ADV7511_LOW_REFRESH_RATE_30HZ;
 	else
 		low_refresh_rate = ADV7511_LOW_REFRESH_RATE_NONE;
-- 
2.17.1


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

* Re: [PATCH] drm/bridge: adv7511: Fix low refresh rate selection
  2019-04-24 13:22 [PATCH] drm/bridge: adv7511: Fix low refresh rate selection Matt Redfearn
@ 2019-05-11 19:32 ` Laurent Pinchart
  2019-05-14 18:12   ` Sean Paul
  0 siblings, 1 reply; 3+ messages in thread
From: Laurent Pinchart @ 2019-05-11 19:32 UTC (permalink / raw)
  To: Matt Redfearn
  Cc: Archit Taneja, Andrzej Hajda, dri-devel, Matthew Redfearn,
	linux-kernel, Jia-Ju Bai, Kieran Bingham, David Airlie,
	Sean Paul, Daniel Vetter

Hi Matt,

Thank you for the patch.

On Wed, Apr 24, 2019 at 01:22:27PM +0000, Matt Redfearn wrote:
> The driver currently sets register 0xfb (Low Refresh Rate) based on the
> value of mode->vrefresh. Firstly, this field is specified to be in Hz,
> but the magic numbers used by the code are Hz * 1000. This essentially
> leads to the low refresh rate always being set to 0x01, since the
> vrefresh value will always be less than 24000. Fix the magic numbers to
> be in Hz.
> Secondly, according to the comment in drm_modes.h, the field is not
> supposed to be used in a functional way anyway. Instead, use the helper
> function drm_mode_vrefresh().
> 
> Fixes: 9c8af882bf12 ("drm: Add adv7511 encoder driver")
> Signed-off-by: Matt Redfearn <matt.redfearn@thinci.com>

Wow, a 4.5 year old bug fix, nice :-)

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
> 
>  drivers/gpu/drm/bridge/adv7511/adv7511_drv.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
> index 85c2d407a52..e7ddd3e3db9 100644
> --- a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
> +++ b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
> @@ -747,11 +747,11 @@ static void adv7511_mode_set(struct adv7511 *adv7511,
>  			vsync_polarity = 1;
>  	}
>  
> -	if (mode->vrefresh <= 24000)
> +	if (drm_mode_vrefresh(mode) <= 24)
>  		low_refresh_rate = ADV7511_LOW_REFRESH_RATE_24HZ;
> -	else if (mode->vrefresh <= 25000)
> +	else if (drm_mode_vrefresh(mode) <= 25)
>  		low_refresh_rate = ADV7511_LOW_REFRESH_RATE_25HZ;
> -	else if (mode->vrefresh <= 30000)
> +	else if (drm_mode_vrefresh(mode) <= 30)
>  		low_refresh_rate = ADV7511_LOW_REFRESH_RATE_30HZ;
>  	else
>  		low_refresh_rate = ADV7511_LOW_REFRESH_RATE_NONE;

-- 
Regards,

Laurent Pinchart

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

* Re: [PATCH] drm/bridge: adv7511: Fix low refresh rate selection
  2019-05-11 19:32 ` Laurent Pinchart
@ 2019-05-14 18:12   ` Sean Paul
  0 siblings, 0 replies; 3+ messages in thread
From: Sean Paul @ 2019-05-14 18:12 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: Matt Redfearn, Archit Taneja, David Airlie, Kieran Bingham,
	linux-kernel, Matthew Redfearn, Jia-Ju Bai, Sean Paul, dri-devel

On Sat, May 11, 2019 at 10:32:26PM +0300, Laurent Pinchart wrote:
> Hi Matt,
> 
> Thank you for the patch.
> 
> On Wed, Apr 24, 2019 at 01:22:27PM +0000, Matt Redfearn wrote:
> > The driver currently sets register 0xfb (Low Refresh Rate) based on the
> > value of mode->vrefresh. Firstly, this field is specified to be in Hz,
> > but the magic numbers used by the code are Hz * 1000. This essentially
> > leads to the low refresh rate always being set to 0x01, since the
> > vrefresh value will always be less than 24000. Fix the magic numbers to
> > be in Hz.
> > Secondly, according to the comment in drm_modes.h, the field is not
> > supposed to be used in a functional way anyway. Instead, use the helper
> > function drm_mode_vrefresh().
> > 
> > Fixes: 9c8af882bf12 ("drm: Add adv7511 encoder driver")
> > Signed-off-by: Matt Redfearn <matt.redfearn@thinci.com>
> 
> Wow, a 4.5 year old bug fix, nice :-)
> 
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> 

Applied to drm-misc-next-fixes.

Thanks!

Sean

> > ---
> > 
> >  drivers/gpu/drm/bridge/adv7511/adv7511_drv.c | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
> > index 85c2d407a52..e7ddd3e3db9 100644
> > --- a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
> > +++ b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
> > @@ -747,11 +747,11 @@ static void adv7511_mode_set(struct adv7511 *adv7511,
> >  			vsync_polarity = 1;
> >  	}
> >  
> > -	if (mode->vrefresh <= 24000)
> > +	if (drm_mode_vrefresh(mode) <= 24)
> >  		low_refresh_rate = ADV7511_LOW_REFRESH_RATE_24HZ;
> > -	else if (mode->vrefresh <= 25000)
> > +	else if (drm_mode_vrefresh(mode) <= 25)
> >  		low_refresh_rate = ADV7511_LOW_REFRESH_RATE_25HZ;
> > -	else if (mode->vrefresh <= 30000)
> > +	else if (drm_mode_vrefresh(mode) <= 30)
> >  		low_refresh_rate = ADV7511_LOW_REFRESH_RATE_30HZ;
> >  	else
> >  		low_refresh_rate = ADV7511_LOW_REFRESH_RATE_NONE;
> 
> -- 
> Regards,
> 
> Laurent Pinchart
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Sean Paul, Software Engineer, Google / Chromium OS

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

end of thread, other threads:[~2019-05-14 18:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-24 13:22 [PATCH] drm/bridge: adv7511: Fix low refresh rate selection Matt Redfearn
2019-05-11 19:32 ` Laurent Pinchart
2019-05-14 18:12   ` Sean Paul

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).