[PATCH 12/13] DRI2: support scheduling emulated events with zero delay

Ilija Hadzic ilijahadzic at gmail.com
Wed May 8 19:39:47 PDT 2013


Now that we fully emulating a running CRTC through DPMS-off state
it is possible to come up with a zero delay when scheduling
a swap or MSC-wait (e.g., if a call into respective wait function
was entered very late). This patch wraps the TimerSet function
into our own radeon_dri2_schedule_event such that the latter
calls the event right away if zero delay is specified.

Signed-off-by: Ilija Hadzic <ihadzic at research.bell-labs.com>
---
 src/radeon_dri2.c | 25 +++++++++++++++++--------
 1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/src/radeon_dri2.c b/src/radeon_dri2.c
index 549e45e..ef9bd48 100644
--- a/src/radeon_dri2.c
+++ b/src/radeon_dri2.c
@@ -1073,6 +1073,18 @@ CARD32 radeon_dri2_deferred_event(OsTimerPtr timer, CARD32 now, pointer data)
     return 0;
 }
 
+static
+void radeon_dri2_schedule_event(CARD32 delay, pointer arg)
+{
+    OsTimerPtr timer;
+
+    timer = TimerSet(NULL, 0, delay, radeon_dri2_deferred_event, arg);
+    if (delay == 0) {
+	CARD32 now = GetTimeInMillis();
+	radeon_dri2_deferred_event(timer, now, arg);
+    }
+}
+
 /*
  * Request a DRM event when the requested conditions will be satisfied.
  *
@@ -1129,7 +1141,7 @@ static int radeon_dri2_schedule_wait_msc(ClientPtr client, DrawablePtr draw,
 	delay = radeon_dri2_extrapolate_msc_delay(crtc, &target_msc,
 						  divisor, remainder);
 	wait_info->frame = target_msc;
-	TimerSet(NULL, 0, delay, radeon_dri2_deferred_event, wait_info);
+	radeon_dri2_schedule_event(delay, wait_info);
 	DRI2BlockClient(client, draw);
 	return TRUE;
     }
@@ -1361,7 +1373,7 @@ static int radeon_dri2_schedule_swap(ClientPtr client, DrawablePtr draw,
 	delay = radeon_dri2_extrapolate_msc_delay(crtc, target_msc,
 						  divisor, remainder);
 	swap_info->frame = *target_msc;
-	TimerSet(NULL, 0, delay, radeon_dri2_deferred_event, swap_info);
+	radeon_dri2_schedule_event(delay, swap_info);
 	return TRUE;
     }
 
@@ -1374,9 +1386,8 @@ static int radeon_dri2_schedule_swap(ClientPtr client, DrawablePtr draw,
         xf86DrvMsg(scrn->scrnIndex, X_WARNING,
                 "first get vblank counter failed: %s\n",
                 strerror(errno));
-	TimerSet(NULL, 0, FALLBACK_SWAP_DELAY, radeon_dri2_deferred_event,
-		 swap_info);
 	*target_msc = 0;
+	radeon_dri2_schedule_event(FALLBACK_SWAP_DELAY, swap_info);
 	return TRUE;
     }
 
@@ -1428,9 +1439,8 @@ static int radeon_dri2_schedule_swap(ClientPtr client, DrawablePtr draw,
             xf86DrvMsg(scrn->scrnIndex, X_WARNING,
                     "divisor 0 get vblank counter failed: %s\n",
                     strerror(errno));
-	    TimerSet(NULL, 0, FALLBACK_SWAP_DELAY, radeon_dri2_deferred_event,
-		     swap_info);
 	    *target_msc = 0;
+	    radeon_dri2_schedule_event(FALLBACK_SWAP_DELAY, swap_info);
             return TRUE;
         }
 
@@ -1478,9 +1488,8 @@ static int radeon_dri2_schedule_swap(ClientPtr client, DrawablePtr draw,
         xf86DrvMsg(scrn->scrnIndex, X_WARNING,
                 "final get vblank counter failed: %s\n",
                 strerror(errno));
-	TimerSet(NULL, 0, FALLBACK_SWAP_DELAY, radeon_dri2_deferred_event,
-		 swap_info);
 	*target_msc = 0;
+	radeon_dri2_schedule_event(FALLBACK_SWAP_DELAY, swap_info);
 	return TRUE;
     }
 
-- 
1.8.1.5



More information about the xorg-driver-ati mailing list