diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2016-04-05 21:35:37 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2016-04-05 21:35:37 +0100 |
commit | afddc9fe7fd0bd8b960f4202071bffec02744f87 (patch) | |
tree | b2bf0a411cd561c5471edd9b4346bb161a8cf12c /src | |
parent | e091ace4d861bbcd67d69f409f0cdf365ee2e685 (diff) |
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@chris-wilson.co.uk>
Diffstat (limited to 'src')
-rw-r--r-- | src/sna/sna_present.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/sna/sna_present.c b/src/sna/sna_present.c index e0a473ae..b880aac3 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; |