Estimate the next vblank timeout from the duration of a frame in the currently programmed display mode. Timeouts are aligned to frame duration, so we can round up to the next alignment.
Signed-off-by: Thomas Zimmermann <[email protected]> --- drivers/gpu/drm/drm_vblank.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/gpu/drm/drm_vblank.c b/drivers/gpu/drm/drm_vblank.c index cecaef98aa52..b5d2fb741b2d 100644 --- a/drivers/gpu/drm/drm_vblank.c +++ b/drivers/gpu/drm/drm_vblank.c @@ -2333,6 +2333,17 @@ bool drm_crtc_vblank_get_vblank_timeout(struct drm_crtc *crtc, ktime_t *vblank_t return false; /* already expired */ framedur_ns = vblank->framedur_ns; + } else if (mode->crtc_clock) { + u64 framesize = mode->crtc_htotal * mode->crtc_vtotal; + + /* + * With the vblank timer being disabled, we don't have an + * expiry time. As the timeouts are aligned to the display + * mode's clock, we can estimate when the expiry time would + * have been. + */ + framedur_ns = div_u64(framesize * 1000000llu, mode->crtc_clock); + *vblank_time = roundup(ktime_get_ns(), framedur_ns); } else { return false; } -- 2.54.0
