All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] drm/exynos: calculate vrefresh instead of use a fixed value
@ 2015-05-20 20:56 Gustavo Padovan
  2015-05-20 21:07 ` Tobias Jakobi
  2015-05-20 22:19 ` Tobias Jakobi
  0 siblings, 2 replies; 5+ messages in thread
From: Gustavo Padovan @ 2015-05-20 20:56 UTC (permalink / raw)
  To: linux-samsung-soc; +Cc: tjakobi, dri-devel, Gustavo Padovan

From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>

When mode's vrefresh is zero we should ask DRM core to calculate vrefresh
for us so we can get the correct value instead of relying on fixed value
defined in a macro. But if vrefresh is still zero we should fail the
update.

Suggested-by: Daniel Stone <daniels@collabora.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
---
 drivers/gpu/drm/exynos/exynos_drm_fimd.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimd.c b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
index 9819fa6..3f9646d 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fimd.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
@@ -42,7 +42,6 @@
  * CPU Interface.
  */
 
-#define FIMD_DEFAULT_FRAMERATE 60
 #define MIN_FB_WIDTH_FOR_16WORD_BURST 128
 
 /* position control register for hardware window 0, 2 ~ 4.*/
@@ -329,7 +328,9 @@ static bool fimd_mode_fixup(struct exynos_drm_crtc *crtc,
 		struct drm_display_mode *adjusted_mode)
 {
 	if (adjusted_mode->vrefresh == 0)
-		adjusted_mode->vrefresh = FIMD_DEFAULT_FRAMERATE;
+		adjusted_mode->vrefresh = drm_mode_vrefresh(mode);
+	if (adjusted_mode->vrefresh == 0)
+		return false;
 
 	return true;
 }
@@ -427,7 +428,7 @@ static void fimd_commit(struct exynos_drm_crtc *crtc)
 	if (ctx->driver_data->has_clksel)
 		val |= VIDCON0_CLKSEL_LCD;
 
-	clkdiv = fimd_calc_clkdiv(ctx, mode);
+	clkdiv = fimd_calc_clkdiv(ctx, &crtc->base.state->adjusted_mode);
 	if (clkdiv > 1)
 		val |= VIDCON0_CLKVAL_F(clkdiv - 1) | VIDCON0_CLKDIR;
 
-- 
2.1.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH v3] drm/exynos: calculate vrefresh instead of use a fixed value
  2015-05-20 20:56 [PATCH v3] drm/exynos: calculate vrefresh instead of use a fixed value Gustavo Padovan
@ 2015-05-20 21:07 ` Tobias Jakobi
  2015-05-20 22:19 ` Tobias Jakobi
  1 sibling, 0 replies; 5+ messages in thread
From: Tobias Jakobi @ 2015-05-20 21:07 UTC (permalink / raw)
  To: Gustavo Padovan, linux-samsung-soc
  Cc: dri-devel, inki.dae, jy0922.shim, daniel, Gustavo Padovan

Gustavo Padovan wrote:
> From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
> 
> When mode's vrefresh is zero we should ask DRM core to calculate vrefresh
> for us so we can get the correct value instead of relying on fixed value
> defined in a macro. But if vrefresh is still zero we should fail the
> update.
> 
> Suggested-by: Daniel Stone <daniels@collabora.com>
> Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
> ---
>  drivers/gpu/drm/exynos/exynos_drm_fimd.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimd.c b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
> index 9819fa6..3f9646d 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_fimd.c
> +++ b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
> @@ -42,7 +42,6 @@
>   * CPU Interface.
>   */
>  
> -#define FIMD_DEFAULT_FRAMERATE 60
>  #define MIN_FB_WIDTH_FOR_16WORD_BURST 128
>  
>  /* position control register for hardware window 0, 2 ~ 4.*/
> @@ -329,7 +328,9 @@ static bool fimd_mode_fixup(struct exynos_drm_crtc *crtc,
>  		struct drm_display_mode *adjusted_mode)
>  {
>  	if (adjusted_mode->vrefresh == 0)
> -		adjusted_mode->vrefresh = FIMD_DEFAULT_FRAMERATE;
> +		adjusted_mode->vrefresh = drm_mode_vrefresh(mode);
> +	if (adjusted_mode->vrefresh == 0)
> +		return false;
>  
>  	return true;
>  }
> @@ -427,7 +428,7 @@ static void fimd_commit(struct exynos_drm_crtc *crtc)
>  	if (ctx->driver_data->has_clksel)
>  		val |= VIDCON0_CLKSEL_LCD;
>  
> -	clkdiv = fimd_calc_clkdiv(ctx, mode);
> +	clkdiv = fimd_calc_clkdiv(ctx, &crtc->base.state->adjusted_mode);
I would suggest to just change 'mode' at the top:
struct drm_display_mode *mode = &crtc->base.state->adjusted_mode;

With best wishes,
Tobias


>  	if (clkdiv > 1)
>  		val |= VIDCON0_CLKVAL_F(clkdiv - 1) | VIDCON0_CLKDIR;
>  
> 

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

* Re: [PATCH v3] drm/exynos: calculate vrefresh instead of use a fixed value
  2015-05-20 20:56 [PATCH v3] drm/exynos: calculate vrefresh instead of use a fixed value Gustavo Padovan
  2015-05-20 21:07 ` Tobias Jakobi
@ 2015-05-20 22:19 ` Tobias Jakobi
  2015-05-21 14:06   ` Gustavo Padovan
  1 sibling, 1 reply; 5+ messages in thread
From: Tobias Jakobi @ 2015-05-20 22:19 UTC (permalink / raw)
  To: Gustavo Padovan, linux-samsung-soc
  Cc: dri-devel, inki.dae, jy0922.shim, daniel, Gustavo Padovan

Gustavo Padovan wrote:
> From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
> 
> When mode's vrefresh is zero we should ask DRM core to calculate vrefresh
> for us so we can get the correct value instead of relying on fixed value
> defined in a macro. But if vrefresh is still zero we should fail the
> update.
This works better for me:
diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimd.c
b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
index dc834b8..26e8ae4 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fimd.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
@@ -346,11 +346,16 @@ static bool fimd_mode_fixup(struct exynos_drm_crtc
*crtc,
 static void fimd_commit(struct exynos_drm_crtc *crtc)
 {
        struct fimd_context *ctx = crtc->ctx;
-       struct drm_display_mode *mode = &crtc->base.mode;
+       struct drm_display_mode *mode;
        struct fimd_driver_data *driver_data = ctx->driver_data;
        void *timing_base = ctx->regs + driver_data->timing_base;
        u32 val, clkdiv;

+       if (crtc->base.state)
+               mode = &crtc->base.state->adjusted_mode;
+       else
+               mode = &crtc->base.mode;
+
        if (ctx->suspended)
                return;

Otherwise I get an oops (nullptr deref) on boot, so 'state' is probably
not initialized yet at this point.


With best wishes,
Tobias Jakobi


> 
> Suggested-by: Daniel Stone <daniels@collabora.com>
> Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
> ---
>  drivers/gpu/drm/exynos/exynos_drm_fimd.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimd.c b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
> index 9819fa6..3f9646d 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_fimd.c
> +++ b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
> @@ -42,7 +42,6 @@
>   * CPU Interface.
>   */
>  
> -#define FIMD_DEFAULT_FRAMERATE 60
>  #define MIN_FB_WIDTH_FOR_16WORD_BURST 128
>  
>  /* position control register for hardware window 0, 2 ~ 4.*/
> @@ -329,7 +328,9 @@ static bool fimd_mode_fixup(struct exynos_drm_crtc *crtc,
>  		struct drm_display_mode *adjusted_mode)
>  {
>  	if (adjusted_mode->vrefresh == 0)
> -		adjusted_mode->vrefresh = FIMD_DEFAULT_FRAMERATE;
> +		adjusted_mode->vrefresh = drm_mode_vrefresh(mode);
> +	if (adjusted_mode->vrefresh == 0)
> +		return false;
>  
>  	return true;
>  }
> @@ -427,7 +428,7 @@ static void fimd_commit(struct exynos_drm_crtc *crtc)
>  	if (ctx->driver_data->has_clksel)
>  		val |= VIDCON0_CLKSEL_LCD;
>  
> -	clkdiv = fimd_calc_clkdiv(ctx, mode);
> +	clkdiv = fimd_calc_clkdiv(ctx, &crtc->base.state->adjusted_mode);
>  	if (clkdiv > 1)
>  		val |= VIDCON0_CLKVAL_F(clkdiv - 1) | VIDCON0_CLKDIR;
>  
> 

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

* Re: [PATCH v3] drm/exynos: calculate vrefresh instead of use a fixed value
  2015-05-20 22:19 ` Tobias Jakobi
@ 2015-05-21 14:06   ` Gustavo Padovan
  2015-05-21 15:10     ` Tobias Jakobi
  0 siblings, 1 reply; 5+ messages in thread
From: Gustavo Padovan @ 2015-05-21 14:06 UTC (permalink / raw)
  To: Tobias Jakobi
  Cc: linux-samsung-soc, dri-devel, inki.dae, jy0922.shim, daniel,
	Gustavo Padovan

Hi Tobias,

2015-05-21 Tobias Jakobi <tjakobi@math.uni-bielefeld.de>:

> Gustavo Padovan wrote:
> > From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
> > 
> > When mode's vrefresh is zero we should ask DRM core to calculate vrefresh
> > for us so we can get the correct value instead of relying on fixed value
> > defined in a macro. But if vrefresh is still zero we should fail the
> > update.
> This works better for me:
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimd.c
> b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
> index dc834b8..26e8ae4 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_fimd.c
> +++ b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
> @@ -346,11 +346,16 @@ static bool fimd_mode_fixup(struct exynos_drm_crtc
> *crtc,
>  static void fimd_commit(struct exynos_drm_crtc *crtc)
>  {
>         struct fimd_context *ctx = crtc->ctx;
> -       struct drm_display_mode *mode = &crtc->base.mode;
> +       struct drm_display_mode *mode;
>         struct fimd_driver_data *driver_data = ctx->driver_data;
>         void *timing_base = ctx->regs + driver_data->timing_base;
>         u32 val, clkdiv;
> 
> +       if (crtc->base.state)
> +               mode = &crtc->base.state->adjusted_mode;
> +       else
> +               mode = &crtc->base.mode;
> +
>         if (ctx->suspended)
>                 return;
> 
> Otherwise I get an oops (nullptr deref) on boot, so 'state' is probably
> not initialized yet at this point.

Would you like to send a proper git patch of this? You can move the 
drm_mode_vrefresh() part to your patch.

	Gustavo

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

* Re: [PATCH v3] drm/exynos: calculate vrefresh instead of use a fixed value
  2015-05-21 14:06   ` Gustavo Padovan
@ 2015-05-21 15:10     ` Tobias Jakobi
  0 siblings, 0 replies; 5+ messages in thread
From: Tobias Jakobi @ 2015-05-21 15:10 UTC (permalink / raw)
  To: Gustavo Padovan, Tobias Jakobi, linux-samsung-soc, dri-devel,
	inki.dae, jy0922.shim, daniel, Gustavo Padovan

Hey,

On 2015-05-21 16:06, Gustavo Padovan wrote:
> Hi Tobias,
> 
> 2015-05-21 Tobias Jakobi <tjakobi@math.uni-bielefeld.de>:
> 
>> Gustavo Padovan wrote:
>> > From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
>> >
>> > When mode's vrefresh is zero we should ask DRM core to calculate vrefresh
>> > for us so we can get the correct value instead of relying on fixed value
>> > defined in a macro. But if vrefresh is still zero we should fail the
>> > update.
>> This works better for me:
>> diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimd.c
>> b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
>> index dc834b8..26e8ae4 100644
>> --- a/drivers/gpu/drm/exynos/exynos_drm_fimd.c
>> +++ b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
>> @@ -346,11 +346,16 @@ static bool fimd_mode_fixup(struct 
>> exynos_drm_crtc
>> *crtc,
>>  static void fimd_commit(struct exynos_drm_crtc *crtc)
>>  {
>>         struct fimd_context *ctx = crtc->ctx;
>> -       struct drm_display_mode *mode = &crtc->base.mode;
>> +       struct drm_display_mode *mode;
>>         struct fimd_driver_data *driver_data = ctx->driver_data;
>>         void *timing_base = ctx->regs + driver_data->timing_base;
>>         u32 val, clkdiv;
>> 
>> +       if (crtc->base.state)
>> +               mode = &crtc->base.state->adjusted_mode;
>> +       else
>> +               mode = &crtc->base.mode;
>> +
>>         if (ctx->suspended)
>>                 return;
>> 
>> Otherwise I get an oops (nullptr deref) on boot, so 'state' is 
>> probably
>> not initialized yet at this point.
> 
> Would you like to send a proper git patch of this? You can move the
> drm_mode_vrefresh() part to your patch.
I'll try to send out something later this day.


With best wishes,
Tobias




> 
> 	Gustavo

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

end of thread, other threads:[~2015-05-21 15:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-20 20:56 [PATCH v3] drm/exynos: calculate vrefresh instead of use a fixed value Gustavo Padovan
2015-05-20 21:07 ` Tobias Jakobi
2015-05-20 22:19 ` Tobias Jakobi
2015-05-21 14:06   ` Gustavo Padovan
2015-05-21 15:10     ` Tobias Jakobi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.