[PATCH] drm/rockchip: Properly adjust to a true clock in adjusted_mode

Yakir Yang ykk at rock-chips.com
Tue Aug 9 02:53:05 UTC 2016


Sean,


On 08/09/2016 03:29 AM, Sean Paul wrote:
> From: Douglas Anderson <dianders at chromium.org>
>
> When fixing up the clock in vop_crtc_mode_fixup() we're not doing it
> quite correctly.  Specifically if we've got the true clock 266666667 Hz,
> we'll perform this calculation:
>     266666667 / 1000 => 266666
>
> Later when we try to set the clock we'll do clk_set_rate(266666 *
> 1000).  The common clock framework won't actually pick the proper clock
> in this case since it always wants clocks <= the specified one.
>
> Let's solve this by using DIV_ROUND_UP.
>
> Signed-off-by: Douglas Anderson <dianders at chromium.org>
> Signed-off-by: Sean Paul <seanpaul at chromium.org>

After discuss with Zheng Xing (Rockchip clock contributor), we think 
this patch looks good, so:

Reviewed-by: Yakir Yang <ykk at rock-chips.com>

> ---
>   drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
> index 31744fe..1bbffaf 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
> @@ -891,7 +891,8 @@ static bool vop_crtc_mode_fixup(struct drm_crtc *crtc,
>   	struct vop *vop = to_vop(crtc);
>   
>   	adjusted_mode->clock =
> -		clk_round_rate(vop->dclk, mode->clock * 1000) / 1000;
> +		DIV_ROUND_UP(clk_round_rate(vop->dclk, mode->clock * 1000),
> +			     1000);
>   
>   	return true;
>   }




More information about the dri-devel mailing list