[PATCH 3/4] DRI2: keep track of last event in crtc private data

Ilija Hadzic ilijahadzic at gmail.com
Fri Dec 14 18:09:12 PST 2012


From: Ilija Hadzic <ihadzic at research.bell-labs.com>

When frame or flip event occurs, record its time and MSC
in CRTC's private data. This tracking also requires that
we pass the CRTC pointer in frame event structure.

Signed-off-by: Ilija Hadzic <ihadzic at research.bell-labs.com>
---
 src/drmmode_display.h |  4 ++++
 src/radeon_dri2.c     | 18 ++++++++++++++++++
 2 files changed, 22 insertions(+)

diff --git a/src/drmmode_display.h b/src/drmmode_display.h
index 45c33cb..679216d 100644
--- a/src/drmmode_display.h
+++ b/src/drmmode_display.h
@@ -72,6 +72,10 @@ typedef struct {
     struct radeon_bo *rotate_bo;
     unsigned rotate_fb_id;
     int dpms_mode;
+    Bool last_event_valid;
+    unsigned int last_event_tv_sec;
+    unsigned int last_event_tv_usec;
+    unsigned int last_event_msc;
     uint16_t lut_r[256], lut_g[256], lut_b[256];
 } drmmode_crtc_private_rec, *drmmode_crtc_private_ptr;
 
diff --git a/src/radeon_dri2.c b/src/radeon_dri2.c
index 8ebc687..a025e16 100644
--- a/src/radeon_dri2.c
+++ b/src/radeon_dri2.c
@@ -676,6 +676,7 @@ typedef struct _DRI2FrameEvent {
     void *event_data;
     DRI2BufferPtr front;
     DRI2BufferPtr back;
+    xf86CrtcPtr crtc;
 
     Bool valid;
 
@@ -817,6 +818,7 @@ radeon_dri2_schedule_flip(ScrnInfoPtr scrn, ClientPtr client,
     flip_info->event_complete = func;
     flip_info->event_data = data;
     flip_info->frame = target_msc;
+    flip_info->crtc = crtc;
 
     xf86DrvMsgVerb(scrn->scrnIndex, X_INFO, RADEON_LOGLEVEL_DEBUG,
 		   "%s:%d fevent[%p]\n", __func__, __LINE__, flip_info);
@@ -958,6 +960,7 @@ void radeon_dri2_frame_event_handler(unsigned int frame, unsigned int tv_sec,
     int swap_type;
     BoxRec box;
     RegionRec region;
+    drmmode_crtc_private_ptr crtc;
 
     if (!event->valid)
 	goto cleanup;
@@ -970,6 +973,12 @@ void radeon_dri2_frame_event_handler(unsigned int frame, unsigned int tv_sec,
     screen = drawable->pScreen;
     scrn = xf86ScreenToScrn(screen);
 
+    crtc = event->crtc->driver_private;
+    crtc->last_event_tv_sec = tv_sec;
+    crtc->last_event_tv_usec = tv_usec;
+    crtc->last_event_msc = frame;
+    crtc->last_event_valid = TRUE;
+
     switch (event->type) {
     case DRI2_FLIP:
 	if (can_flip(scrn, drawable, event->front, event->back) &&
@@ -1116,6 +1125,7 @@ static int radeon_dri2_schedule_wait_msc(ClientPtr client, DrawablePtr draw,
     wait_info->drawable_id = draw->id;
     wait_info->client = client;
     wait_info->type = DRI2_WAITMSC;
+    wait_info->crtc = crtc;
     wait_info->valid = TRUE;
 
     if (ListAddDRI2ClientEvents(client, &wait_info->link)) {
@@ -1219,6 +1229,7 @@ void radeon_dri2_flip_event_handler(unsigned int frame, unsigned int tv_sec,
     ScrnInfoPtr scrn;
     int status;
     PixmapPtr pixmap;
+    drmmode_crtc_private_ptr crtc;
 
     status = dixLookupDrawable(&drawable, flip->drawable_id, serverClient,
 			       M_ANY, DixWriteAccess);
@@ -1230,6 +1241,12 @@ void radeon_dri2_flip_event_handler(unsigned int frame, unsigned int tv_sec,
     screen = drawable->pScreen;
     scrn = xf86ScreenToScrn(screen);
 
+    crtc = flip->crtc->driver_private;
+    crtc->last_event_tv_sec = tv_sec;
+    crtc->last_event_tv_usec = tv_usec;
+    crtc->last_event_msc = frame;
+    crtc->last_event_valid = TRUE;
+
     pixmap = screen->GetScreenPixmap(screen);
     xf86DrvMsgVerb(scrn->scrnIndex, X_INFO, RADEON_LOGLEVEL_DEBUG,
 		   "%s:%d fevent[%p] width %d pitch %d (/4 %d)\n",
@@ -1328,6 +1345,7 @@ static int radeon_dri2_schedule_swap(ClientPtr client, DrawablePtr draw,
     swap_info->event_data = data;
     swap_info->front = front;
     swap_info->back = back;
+    swap_info->crtc = crtc;
     swap_info->valid = TRUE;
     if (ListAddDRI2ClientEvents(client, &swap_info->link)) {
         xf86DrvMsg(scrn->scrnIndex, X_WARNING,
-- 
1.7.12.4



More information about the xorg-driver-ati mailing list