[PATCH xf86-video-amdgpu 08/13] DRI2: Split out helper for getting UST and MSC of a specific CRTC
Michel Dänzer
michel at daenzer.net
Tue Jun 2 02:21:26 PDT 2015
From: Michel Dänzer <michel.daenzer at amd.com>
(Cherry picked from radeon commits 76c2923ac5c7230a8b2f9f8329c308d28b44d9c0
and d7c82731a8bf3d381bc571b94d80d9bb2dd6e40d)
Signed-off-by: Michel Dänzer <michel.daenzer at amd.com>
---
src/amdgpu_dri2.c | 34 +++++++++++-----------------------
src/drmmode_display.c | 27 +++++++++++++++++++++++++++
src/drmmode_display.h | 1 +
3 files changed, 39 insertions(+), 23 deletions(-)
diff --git a/src/amdgpu_dri2.c b/src/amdgpu_dri2.c
index 95db216..28c56e7 100644
--- a/src/amdgpu_dri2.c
+++ b/src/amdgpu_dri2.c
@@ -851,17 +851,13 @@ CARD32 amdgpu_dri2_extrapolate_msc_delay(xf86CrtcPtr crtc, CARD64 * target_msc,
}
/*
- * Get current frame count and frame count timestamp, based on drawable's
- * crtc.
+ * Get current interpolated frame count and frame count timestamp, based on
+ * drawable's crtc.
*/
static int amdgpu_dri2_get_msc(DrawablePtr draw, CARD64 * ust, CARD64 * msc)
{
- ScreenPtr screen = draw->pScreen;
- ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
- AMDGPUInfoPtr info = AMDGPUPTR(scrn);
- drmVBlank vbl;
- int ret;
xf86CrtcPtr crtc = amdgpu_dri2_drawable_crtc(draw, TRUE);
+ int ret;
/* Drawable not displayed, make up a value */
if (crtc == NULL) {
@@ -869,29 +865,20 @@ static int amdgpu_dri2_get_msc(DrawablePtr draw, CARD64 * ust, CARD64 * msc)
*msc = 0;
return TRUE;
}
+
if (amdgpu_crtc_is_enabled(crtc)) {
/* CRTC is running, read vblank counter and timestamp */
- vbl.request.type = DRM_VBLANK_RELATIVE;
- vbl.request.type |= amdgpu_populate_vbl_request_type(crtc);
- vbl.request.sequence = 0;
-
- ret = drmWaitVBlank(info->dri2.drm_fd, &vbl);
- if (ret) {
- xf86DrvMsg(scrn->scrnIndex, X_WARNING,
- "get vblank counter failed: %s\n",
- strerror(errno));
+ ret = drmmode_crtc_get_ust_msc(crtc, ust, msc);
+ if (ret != Success)
return FALSE;
- }
- *ust =
- ((CARD64) vbl.reply.tval_sec * 1000000) +
- vbl.reply.tval_usec;
- *msc =
- vbl.reply.sequence + amdgpu_get_interpolated_vblanks(crtc);
+ *msc += amdgpu_get_interpolated_vblanks(crtc);
*msc &= 0xffffffff;
} else {
/* CRTC is not running, extrapolate MSC and timestamp */
drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+ ScrnInfoPtr scrn = crtc->scrn;
+ AMDGPUInfoPtr info = AMDGPUPTR(scrn);
CARD64 now, delta_t, delta_seq;
if (!drmmode_crtc->dpms_last_ust)
@@ -914,7 +901,8 @@ static int amdgpu_dri2_get_msc(DrawablePtr draw, CARD64 * ust, CARD64 * msc)
*msc += delta_seq;
*msc &= 0xffffffff;
}
- return TRUE;
+
+ return ret == Success;
}
static
diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index aa7c8c4..01fe860 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -204,6 +204,33 @@ int drmmode_get_current_ust(int drm_fd, CARD64 * ust)
return 0;
}
+/*
+ * Get current frame count and frame count timestamp of the crtc.
+ */
+int drmmode_crtc_get_ust_msc(xf86CrtcPtr crtc, CARD64 *ust, CARD64 *msc)
+{
+ ScrnInfoPtr scrn = crtc->scrn;
+ AMDGPUInfoPtr info = AMDGPUPTR(scrn);
+ drmVBlank vbl;
+ int ret;
+
+ vbl.request.type = DRM_VBLANK_RELATIVE;
+ vbl.request.type |= amdgpu_populate_vbl_request_type(crtc);
+ vbl.request.sequence = 0;
+
+ ret = drmWaitVBlank(info->dri2.drm_fd, &vbl);
+ if (ret) {
+ xf86DrvMsg(scrn->scrnIndex, X_WARNING,
+ "get vblank counter failed: %s\n", strerror(errno));
+ return ret;
+ }
+
+ *ust = ((CARD64)vbl.reply.tval_sec * 1000000) + vbl.reply.tval_usec;
+ *msc = vbl.reply.sequence;
+
+ return Success;
+}
+
static void drmmode_crtc_dpms(xf86CrtcPtr crtc, int mode)
{
drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
diff --git a/src/drmmode_display.h b/src/drmmode_display.h
index 9cf6932..90ab537 100644
--- a/src/drmmode_display.h
+++ b/src/drmmode_display.h
@@ -125,6 +125,7 @@ Bool amdgpu_do_pageflip(ScrnInfoPtr scrn, ClientPtr client,
struct amdgpu_buffer *new_front, uint64_t id, void *data,
int ref_crtc_hw_id, amdgpu_drm_handler_proc handler,
amdgpu_drm_abort_proc abort);
+int drmmode_crtc_get_ust_msc(xf86CrtcPtr crtc, CARD64 *ust, CARD64 *msc);
int drmmode_get_current_ust(int drm_fd, CARD64 * ust);
#endif
--
2.1.4
More information about the xorg-driver-ati
mailing list