diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2014-05-21 08:26:21 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2014-05-21 09:15:48 +0100 |
commit | 0b3ea29727075bf2b0d86bbeca7dd78201936913 (patch) | |
tree | f0cdbfed15018e31093646215351e4df1cf8520e /src/sna/sna.h | |
parent | 183a0728ba52be9d052f5a5f6e6b54c4a9ee8253 (diff) |
sna/dri2: Tidy recording of the last swap sequence number and time
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src/sna/sna.h')
-rw-r--r-- | src/sna/sna.h | 54 |
1 files changed, 49 insertions, 5 deletions
diff --git a/src/sna/sna.h b/src/sna/sna.h index a5141811..59e44725 100644 --- a/src/sna/sna.h +++ b/src/sna/sna.h @@ -289,6 +289,17 @@ struct sna { unsigned serial; uint32_t *encoders; + + struct { + uint64_t msc; + unsigned int tv_sec; + unsigned int tv_usec; + } last_swap[MAX_PIPES]; + + struct { + uint32_t last; + uint32_t wraps; + } msc[MAX_PIPES]; } mode; struct { @@ -317,11 +328,6 @@ struct sna { #if HAVE_DRI2 void *flip_pending; - struct { - uint64_t msc; - unsigned int tv_sec; - unsigned int tv_usec; - } last_swap[MAX_PIPES]; #endif } dri2; @@ -463,6 +469,44 @@ extern xf86CrtcPtr sna_covering_crtc(struct sna *sna, extern bool sna_wait_for_scanline(struct sna *sna, PixmapPtr pixmap, xf86CrtcPtr crtc, const BoxRec *clip); +static inline uint64_t msc64(struct sna *sna, int pipe, uint32_t seq) +{ + assert((unsigned)pipe < MAX_PIPES); + if (seq < sna->mode.msc[pipe].last) + sna->mode.msc[pipe].wraps++; + sna->mode.msc[pipe].last = seq; + return (uint64_t)sna->mode.msc[pipe].wraps << 32 | seq; +} + +static inline uint64_t sna_mode_record_swap(struct sna *sna, int pipe, + int tv_sec, int tv_usec, unsigned seq) +{ + DBG(("%s: recording last swap on pipe=%d, frame %d, time %d.%06d\n", + __FUNCTION__, pipe, seq, tv_sec, tv_usec)); + assert((unsigned)pipe < MAX_PIPES); + sna->mode.last_swap[pipe].tv_sec = tv_sec; + sna->mode.last_swap[pipe].tv_usec = tv_usec; + return sna->mode.last_swap[pipe].msc = msc64(sna, pipe, seq); +} + +static inline uint64_t sna_mode_record_vblank(struct sna *sna, int pipe, + const union drm_wait_vblank *vbl) +{ + return sna_mode_record_swap(sna, pipe, + vbl->reply.tval_sec, + vbl->reply.tval_usec, + vbl->reply.sequence); +} + +static inline uint64_t sna_mode_record_event(struct sna *sna, int pipe, + struct drm_event_vblank *event) +{ + return sna_mode_record_swap(sna, pipe, + event->tv_sec, + event->tv_usec, + event->sequence); +} + static inline uint64_t ust64(int tv_sec, int tv_usec) { return (uint64_t)tv_sec * 1000000 + tv_usec; |