[PATCH v3 2/4] xfree86/dri2: add AuthMagic hook for driver side support

Pauli Nieminen ext-pauli.nieminen at nokia.com
Wed Apr 21 01:40:36 PDT 2010


From: Tiago Vignatti <tiago.vignatti at nokia.com>

With this new hook drmAuthMagic becomes useless and should be deprecated.
You might want to implement AuthMagic on driver side instead.

Attention: ABI being break.

Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
Signed-off-by: Pauli Nieminen <ext-pauli.nieminen at nokia.com>
---
v3:
- Bump DRI2INFOREC_VERSION because xserver 1.8.0 was released with version 4.
- Prevent memory access error if ddx was compiled for older version.

 hw/xfree86/dri2/dri2.c |   13 +++++++++++--
 hw/xfree86/dri2/dri2.h |    8 +++++++-
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
index 6c4dabc..8d2acf0 100644
--- a/hw/xfree86/dri2/dri2.c
+++ b/hw/xfree86/dri2/dri2.c
@@ -86,6 +86,7 @@ typedef struct _DRI2Screen {
     DRI2ScheduleSwapProcPtr	 ScheduleSwap;
     DRI2GetMSCProcPtr		 GetMSC;
     DRI2ScheduleWaitMSCProcPtr	 ScheduleWaitMSC;
+    DRI2AuthMagicProcPtr	 AuthMagic;
 
     HandleExposuresProcPtr       HandleExposures;
 } DRI2ScreenRec;
@@ -794,8 +795,8 @@ DRI2Authenticate(ScreenPtr pScreen, drm_magic_t magic)
 {
     DRI2ScreenPtr ds = DRI2GetScreen(pScreen);
 
-    if (ds == NULL || drmAuthMagic(ds->fd, magic))
-	return FALSE;
+    if (ds == NULL || (*ds->AuthMagic)(ds->fd, magic))
+        return FALSE;
 
     return TRUE;
 }
@@ -842,6 +843,14 @@ DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info)
 	cur_minor = 1;
     }
 
+    if (info->version >= 5) {
+        ds->AuthMagic      = info->AuthMagic;
+    }
+
+    if (!ds->AuthMagic)
+        ds->AuthMagic = drmAuthMagic;
+
+
     /* Initialize minor if needed and set to minimum provied by DDX */
     if (!dri2_minor || dri2_minor > cur_minor)
 	dri2_minor = cur_minor;
diff --git a/hw/xfree86/dri2/dri2.h b/hw/xfree86/dri2/dri2.h
index ce8a5df..ea48ee9 100644
--- a/hw/xfree86/dri2/dri2.h
+++ b/hw/xfree86/dri2/dri2.h
@@ -66,6 +66,8 @@ typedef void		(*DRI2CopyRegionProcPtr)(DrawablePtr pDraw,
 						 DRI2BufferPtr pSrcBuffer);
 typedef void		(*DRI2WaitProcPtr)(WindowPtr pWin,
 					   unsigned int sequence);
+typedef int		(*DRI2AuthMagicProcPtr)(int fd, uint32_t magic);
+
 /**
  * Schedule a buffer swap
  *
@@ -155,7 +157,7 @@ typedef int		(*DRI2ScheduleWaitMSCProcPtr)(ClientPtr client,
 /**
  * Version of the DRI2InfoRec structure defined in this header
  */
-#define DRI2INFOREC_VERSION 4
+#define DRI2INFOREC_VERSION 5
 
 typedef struct {
     unsigned int version;	/**< Version of this struct */
@@ -179,6 +181,10 @@ typedef struct {
     /* array of driver names, indexed by DRI2Driver* driver types */
     /* a name of NULL means that driver is not supported */
     const char * const *driverNames;
+
+    /* added in version 5 */
+
+    DRI2AuthMagicProcPtr	AuthMagic;
 }  DRI2InfoRec, *DRI2InfoPtr;
 
 extern _X_EXPORT int DRI2EventBase;
-- 
1.6.3.3



More information about the xorg-devel mailing list