[PATCH v2 5/5] DRI2: Allow DDX to validate swap_limit changes

Pauli ext-pauli.nieminen at nokia.com
Fri Nov 26 07:36:38 PST 2010


From: Pauli Nieminen <ext-pauli.nieminen at nokia.com>

DDX can now implement validation for swap_limit changes to prevent
configurations that are not support in driver.

Signed-off-by: Pauli Nieminen <ext-pauli.nieminen at nokia.com>
CC: Mario Kleiner <mario.kleiner at tuebingen.mpg.de>
Reviewed-by: Mario Kleiner <mario.kleiner at tuebingen.mpg.de>
Reviewed-by: Jesse Barnes <jbarnes at virtuousgeek.org>
---
 hw/xfree86/dri2/dri2.c |   12 +++++++++++-
 hw/xfree86/dri2/dri2.h |   14 ++++++++++++++
 2 files changed, 25 insertions(+), 1 deletions(-)

diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
index 255fed0..263ae4f 100644
--- a/hw/xfree86/dri2/dri2.c
+++ b/hw/xfree86/dri2/dri2.c
@@ -102,6 +102,7 @@ typedef struct _DRI2Screen {
     DRI2ScheduleWaitMSCProcPtr	 ScheduleWaitMSC;
     DRI2AuthMagicProcPtr	 AuthMagic;
     DRI2ReuseBufferNotifyProcPtr ReuseBufferNotify;
+    DRI2SwapLimitValidateProcPtr SwapLimitValidate;
 
     HandleExposuresProcPtr       HandleExposures;
 
@@ -195,9 +196,16 @@ Bool
 DRI2SwapLimit(DrawablePtr pDraw, int swap_limit)
 {
     DRI2DrawablePtr pPriv = DRI2GetDrawable(pDraw);
+    DRI2ScreenPtr ds;
     if (!pPriv)
 	return FALSE;
 
+    ds = pPriv->dri2_screen;
+
+    if (!ds->SwapLimitValidate
+	|| !ds->SwapLimitValidate(pDraw, swap_limit))
+	return FALSE;
+
     pPriv->swap_limit = swap_limit;
 
     /* Check throttling */
@@ -1134,8 +1142,10 @@ DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info)
         ds->AuthMagic = info->AuthMagic;
     }
 
-    if (info->version >= 6)
+    if (info->version >= 6) {
 	ds->ReuseBufferNotify = info->ReuseBufferNotify;
+	ds->SwapLimitValidate = info->SwapLimitValidate;
+    }
 
     /*
      * if the driver doesn't provide an AuthMagic function or the info struct
diff --git a/hw/xfree86/dri2/dri2.h b/hw/xfree86/dri2/dri2.h
index 3d01c55..a4bba02 100644
--- a/hw/xfree86/dri2/dri2.h
+++ b/hw/xfree86/dri2/dri2.h
@@ -169,6 +169,19 @@ typedef void		(*DRI2InvalidateProcPtr)(DrawablePtr pDraw,
 						 void *data);
 
 /**
+ * DRI2 calls this hook when ever swap_limit is going to be changed. Default
+ * implementation for the hook only accepts one as swap_limit. If driver can
+ * support other swap_limits it has to implement supported limits with this
+ * callback.
+ *
+ * \param pDraw drawable whos swap_limit is going to be changed
+ * \param swap_limit new swap_limit that going to be set
+ * \return TRUE if limit is support, FALSE if not.
+ */
+typedef Bool		(*DRI2SwapLimitValidateProcPtr)(DrawablePtr pDraw,
+							int swap_limit);
+
+/**
  * Version of the DRI2InfoRec structure defined in this header
  */
 #define DRI2INFOREC_VERSION 6
@@ -203,6 +216,7 @@ typedef struct {
     /* added in version 6 */
 
     DRI2ReuseBufferNotifyProcPtr ReuseBufferNotify;
+    DRI2SwapLimitValidateProcPtr SwapLimitValidate;
 }  DRI2InfoRec, *DRI2InfoPtr;
 
 extern _X_EXPORT int DRI2EventBase;
-- 
1.7.0.4



More information about the xorg-devel mailing list