xf86-video-intel: src/sna/sna_present.c

Chris Wilson ickle at kemper.freedesktop.org
Tue Apr 5 20:38:42 UTC 2016


 src/sna/sna_present.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

New commits:
commit afddc9fe7fd0bd8b960f4202071bffec02744f87
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Apr 5 21:35:37 2016 +0100

    sna/present: Arm the fake vblank timer to wake up one frame early
    
    If we wake up early from the timer, we can use the hw to give us a more
    precise wakeup for the vblank (rather than estimating to the approximate
    millisecond).
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/sna_present.c b/src/sna/sna_present.c
index e0a473a..b880aac 100644
--- a/src/sna/sna_present.c
+++ b/src/sna/sna_present.c
@@ -145,8 +145,12 @@ static uint32_t msc_to_delay(xf86CrtcPtr crtc, uint64_t target)
 	const struct ust_msc *swap = sna_crtc_last_swap(crtc);
 	int64_t delay, subframe;
 
-	delay = (target - swap->msc) * mode->VTotal * mode->HTotal / mode->Clock;
+	delay = target - swap->msc;
+	if (delay > 1) /* try to use the hw vblank for the last frame */
+		delay--;
+	delay *= mode->VTotal * mode->HTotal / mode->Clock;
 	subframe = gettime_ust64() - swap_ust(swap);
+	subframe += 500;
 	subframe /= 1000;
 	if (subframe < delay)
 		delay -= subframe;


More information about the xorg-commit mailing list