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

Ilija Hadzic ilijahadzic at gmail.com
Sun Apr 28 13:07:56 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 fc8f328..2373915 100644
--- a/src/radeon_dri2.c
+++ b/src/radeon_dri2.c
@@ -1049,6 +1049,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.
  *
@@ -1104,7 +1116,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;
     }
@@ -1335,7 +1347,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;
     }
 
@@ -1348,9 +1360,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;
     }
 
@@ -1402,9 +1413,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;
         }
 
@@ -1452,9 +1462,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