diff options
author | Russell King <rmk@arm.linux.org.uk> | 2015-10-27 00:27:53 +0000 |
---|---|---|
committer | Russell King <rmk@arm.linux.org.uk> | 2015-11-08 20:09:05 +0000 |
commit | 33d263ad7d77dd08cc1bc426ce90aeff16834103 (patch) | |
tree | fde68057dab0fd91d76a4e7adb7376832f60ce1c | |
parent | 8ce6f85a1a221ace10d01d8ac737d88ab0dbecf6 (diff) |
src: record and use last seen msc/ust, quieten common_drm_vblank_get()
Record the last msc/ust values seen from the kernel for a CRTC, and use
them when requesting the current msc/ust for a CRTC which we're unable
to retrieve the current values for.
Since we're now able to report monotomic msc/ust values, there's no
need for common_drm_vblank_get() to warn when the kernel blocks the
call.
Signed-off-by: Russell King <rmk@arm.linux.org.uk>
-rw-r--r-- | src/common_drm.c | 28 | ||||
-rw-r--r-- | src/common_drm.h | 2 |
2 files changed, 16 insertions, 14 deletions
diff --git a/src/common_drm.c b/src/common_drm.c index 263301e..b92b71c 100644 --- a/src/common_drm.c +++ b/src/common_drm.c @@ -749,8 +749,12 @@ static void common_drm_event(int fd, unsigned int frame, unsigned int tv_sec, unsigned int tv_usec, void *event_data) { struct common_drm_event *event = event_data; + struct common_crtc_info *drmc = common_crtc(event->crtc); uint64_t msc = common_drm_frame_to_msc(event->crtc, frame); + drmc->swap_msc = msc; + drmc->swap_ust = ((CARD64)tv_sec * 1000000) + tv_usec; + event->handler(event, msc, tv_sec, tv_usec); } @@ -1395,34 +1399,30 @@ int common_drm_vblank_get(ScrnInfoPtr pScrn, xf86CrtcPtr crtc, drmVBlank *vbl, const char *func) { struct common_drm_info *drm = GET_DRM_INFO(pScrn); - static int limit = 5; - int ret; vbl->request.type = DRM_VBLANK_RELATIVE | req_crtc(crtc); vbl->request.sequence = 0; - ret = drmWaitVBlank(drm->fd, vbl); - if (ret && limit) { - xf86DrvMsg(pScrn->scrnIndex, X_WARNING, - "%s: get vblank counter failed: %s\n", - func, strerror(errno)); - limit--; - } - return ret; + return drmWaitVBlank(drm->fd, vbl); } _X_EXPORT int common_drm_get_msc(xf86CrtcPtr crtc, uint64_t *ust, uint64_t *msc) { + struct common_crtc_info *drmc = common_crtc(crtc); drmVBlank vbl; int ret; ret = common_drm_vblank_get(crtc->scrn, crtc, &vbl, __FUNCTION__); - if (ret) - return BadMatch; + if (ret == 0) { + drmc->swap_msc = common_drm_frame_to_msc(crtc, + vbl.reply.sequence); + drmc->swap_ust = ((CARD64)vbl.reply.tval_sec * 1000000) + + vbl.reply.tval_usec; + } - *ust = ((CARD64)vbl.reply.tval_sec * 1000000) + vbl.reply.tval_usec; - *msc = common_drm_frame_to_msc(crtc, vbl.reply.sequence); + *ust = drmc->swap_ust; + *msc = drmc->swap_msc; return Success; } diff --git a/src/common_drm.h b/src/common_drm.h index b55a34b..702a920 100644 --- a/src/common_drm.h +++ b/src/common_drm.h @@ -16,6 +16,8 @@ struct common_crtc_info { uint32_t rotate_fb_id; uint32_t last_seq; uint64_t last_msc; + uint64_t swap_msc; + uint64_t swap_ust; }; #define common_crtc(crtc) \ ((struct common_crtc_info *)(crtc)->driver_private) |