Re: [PATCH] dri2: Pass a ScreenPtr through to the driver's AuthMagic function. (v3)

2012-06-20 Thread Kristian Høgsberg
On Tue, Jun 19, 2012 at 11:53 PM, Christopher James Halse Rogers
christopher.halse.rog...@canonical.com wrote:
 xwayland drivers need access to their screen private data to authenticate.
 Now that drivers no longer have direct access to the global screen arrays,
 this needs to be passed in as function context.

 v2: Don't break ABI
 v3: Paint the bikeshed blue; drop fd from AuthMagic2ProcPtr prototype

Looks good,

Reviewed-by: Kristian Høgsberg k...@bitplanet.net

 Signed-off-by: Christopher James Halse Rogers 
 christopher.halse.rog...@canonical.com
 ---
  hw/xfree86/dri2/dri2.c |   35 ---
  hw/xfree86/dri2/dri2.h |    9 -
  2 files changed, 36 insertions(+), 8 deletions(-)

 diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
 index babf32f..d0f1789 100644
 --- a/hw/xfree86/dri2/dri2.c
 +++ b/hw/xfree86/dri2/dri2.c
 @@ -104,7 +104,8 @@ typedef struct _DRI2Screen {
     DRI2ScheduleSwapProcPtr ScheduleSwap;
     DRI2GetMSCProcPtr GetMSC;
     DRI2ScheduleWaitMSCProcPtr ScheduleWaitMSC;
 -    DRI2AuthMagicProcPtr AuthMagic;
 +    DRI2AuthMagic2ProcPtr AuthMagic;
 +    DRI2AuthMagicProcPtr LegacyAuthMagic;
     DRI2ReuseBufferNotifyProcPtr ReuseBufferNotify;
     DRI2SwapLimitValidateProcPtr SwapLimitValidate;
     DRI2GetParamProcPtr GetParam;
 @@ -1110,12 +,22 @@ DRI2Connect(ScreenPtr pScreen, unsigned int 
 driverType, int *fd,
     return TRUE;
  }

 +static Bool
 +DRI2AuthMagic (ScreenPtr pScreen, uint32_t magic)
 +{
 +    DRI2ScreenPtr ds = DRI2GetScreen(pScreen);
 +    if (ds == NULL || (*ds-LegacyAuthMagic) (ds-fd, magic))
 +        return FALSE;
 +
 +    return TRUE;
 +}
 +
  Bool
  DRI2Authenticate(ScreenPtr pScreen, uint32_t magic)
  {
     DRI2ScreenPtr ds = DRI2GetScreen(pScreen);

 -    if (ds == NULL || (*ds-AuthMagic) (ds-fd, magic))
 +    if (ds == NULL || (*ds-AuthMagic) (pScreen, magic))
         return FALSE;

     return TRUE;
 @@ -1202,8 +1213,11 @@ DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info)
         cur_minor = 1;
     }

 +    if (info-version = 8) {
 +        ds-AuthMagic = info-AuthMagic2;
 +    }
     if (info-version = 5) {
 -        ds-AuthMagic = info-AuthMagic;
 +        ds-LegacyAuthMagic = info-AuthMagic;
     }

     if (info-version = 6) {
 @@ -1218,14 +1232,21 @@ DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info)

     /*
      * if the driver doesn't provide an AuthMagic function or the info struct
 -     * version is too low, it relies on the old method (using libdrm) or fail
 +     * version is too low, call through LegacyAuthMagic
      */
 -    if (!ds-AuthMagic)
 +    if (!ds-AuthMagic) {
 +        ds-AuthMagic = DRI2AuthMagic;
 +        /*
 +         * If the driver doesn't provide an AuthMagic function
 +         * it relies on the old method (using libdrm) or fails
 +         */
 +        if (!ds-LegacyAuthMagic)
  #ifdef WITH_LIBDRM
 -        ds-AuthMagic = drmAuthMagic;
 +            ds-LegacyAuthMagic = drmAuthMagic;
  #else
 -        goto err_out;
 +            goto err_out;
  #endif
 +    }

     /* Initialize minor if needed and set to minimum provied by DDX */
     if (!dri2_minor || dri2_minor  cur_minor)
 diff --git a/hw/xfree86/dri2/dri2.h b/hw/xfree86/dri2/dri2.h
 index f849be6..4fd0fbc 100644
 --- a/hw/xfree86/dri2/dri2.h
 +++ b/hw/xfree86/dri2/dri2.h
 @@ -64,6 +64,7 @@ typedef void (*DRI2CopyRegionProcPtr) (DrawablePtr pDraw,
                                        DRI2BufferPtr pSrcBuffer);
  typedef void (*DRI2WaitProcPtr) (WindowPtr pWin, unsigned int sequence);
  typedef int (*DRI2AuthMagicProcPtr) (int fd, uint32_t magic);
 +typedef int (*DRI2AuthMagic2ProcPtr) (ScreenPtr pScreen, uint32_t magic);

  /**
  * Schedule a buffer swap
 @@ -192,7 +193,7 @@ typedef int (*DRI2GetParamProcPtr) (ClientPtr client,
  /**
  * Version of the DRI2InfoRec structure defined in this header
  */
 -#define DRI2INFOREC_VERSION 7
 +#define DRI2INFOREC_VERSION 8

  typedef struct {
     unsigned int version;       /** Version of this struct */
 @@ -229,6 +230,12 @@ typedef struct {
     /* added in version 7 */

     DRI2GetParamProcPtr GetParam;
 +
 +    /* added in version 8 */
 +    /* AuthMagic callback which passes extra context */
 +    /* If this is NULL the AuthMagic callback is used */
 +    /* If this is non-NULL the AuthMagic callback is ignored */
 +    DRI2AuthMagic2ProcPtr AuthMagic2;
  } DRI2InfoRec, *DRI2InfoPtr;

  extern _X_EXPORT int DRI2EventBase;
 --
 1.7.10.4

 ___
 xorg-devel@lists.x.org: X.Org development
 Archives: http://lists.x.org/archives/xorg-devel
 Info: http://lists.x.org/mailman/listinfo/xorg-devel
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH] dri2: Pass a ScreenPtr through to the driver's AuthMagic function. (v3)

2012-06-20 Thread Keith Packard
Christopher James Halse Rogers christopher.halse.rog...@canonical.com
writes:

 xwayland drivers need access to their screen private data to authenticate.
 Now that drivers no longer have direct access to the global screen arrays,
 this needs to be passed in as function context.

 v2: Don't break ABI
 v3: Paint the bikeshed blue; drop fd from AuthMagic2ProcPtr prototype

Merged.
   dae317e..3f97284  master - master

-- 
keith.pack...@intel.com


pgpnvw1pz7WcZ.pgp
Description: PGP signature
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH] dri2: Pass a ScreenPtr through to the driver's AuthMagic function.

2012-06-19 Thread Kristian Høgsberg
On Mon, Jun 18, 2012 at 12:58 PM, Keith Packard kei...@keithp.com wrote:
 Christopher James Halse Rogers christopher.halse.rog...@canonical.com
 writes:

 +typedef int (*DRI2AuthMagic2ProcPtr) (ScreenPtr pScreen, int fd, uint32_t 
 magic);

 Bikeshed -- seems like the 'fd' parameter is not needed in this API?
 I'll note that in the implementation of the wrapper, you pull it from
 the screen private instead of using the provided parameter...

Oh, that is a good point, I like that bikeshed color better.

Kristian
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel


Re: [PATCH] dri2: Pass a ScreenPtr through to the driver's AuthMagic function.

2012-06-19 Thread Christopher James Halse Rogers
On Tue, 2012-06-19 at 14:38 -0400, Kristian Høgsberg wrote:
 On Mon, Jun 18, 2012 at 12:58 PM, Keith Packard kei...@keithp.com wrote:
  Christopher James Halse Rogers christopher.halse.rog...@canonical.com
  writes:
 
  +typedef int (*DRI2AuthMagic2ProcPtr) (ScreenPtr pScreen, int fd, uint32_t 
  magic);
 
  Bikeshed -- seems like the 'fd' parameter is not needed in this API?
  I'll note that in the implementation of the wrapper, you pull it from
  the screen private instead of using the provided parameter...
 
 Oh, that is a good point, I like that bikeshed color better.
 

Technically I pull it from the DRI2Srceen private, which the driver
won't have access to, but {intel,nouveau,ati} also store this fd in
their driver private, so it's not a problem for them.

I'll send a blue-painted patch. :)


signature.asc
Description: This is a digitally signed message part
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

[PATCH] dri2: Pass a ScreenPtr through to the driver's AuthMagic function. (v3)

2012-06-19 Thread Christopher James Halse Rogers
xwayland drivers need access to their screen private data to authenticate.
Now that drivers no longer have direct access to the global screen arrays,
this needs to be passed in as function context.

v2: Don't break ABI
v3: Paint the bikeshed blue; drop fd from AuthMagic2ProcPtr prototype

Signed-off-by: Christopher James Halse Rogers 
christopher.halse.rog...@canonical.com
---
 hw/xfree86/dri2/dri2.c |   35 ---
 hw/xfree86/dri2/dri2.h |9 -
 2 files changed, 36 insertions(+), 8 deletions(-)

diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
index babf32f..d0f1789 100644
--- a/hw/xfree86/dri2/dri2.c
+++ b/hw/xfree86/dri2/dri2.c
@@ -104,7 +104,8 @@ typedef struct _DRI2Screen {
 DRI2ScheduleSwapProcPtr ScheduleSwap;
 DRI2GetMSCProcPtr GetMSC;
 DRI2ScheduleWaitMSCProcPtr ScheduleWaitMSC;
-DRI2AuthMagicProcPtr AuthMagic;
+DRI2AuthMagic2ProcPtr AuthMagic;
+DRI2AuthMagicProcPtr LegacyAuthMagic;
 DRI2ReuseBufferNotifyProcPtr ReuseBufferNotify;
 DRI2SwapLimitValidateProcPtr SwapLimitValidate;
 DRI2GetParamProcPtr GetParam;
@@ -1110,12 +,22 @@ DRI2Connect(ScreenPtr pScreen, unsigned int driverType, 
int *fd,
 return TRUE;
 }
 
+static Bool
+DRI2AuthMagic (ScreenPtr pScreen, uint32_t magic)
+{
+DRI2ScreenPtr ds = DRI2GetScreen(pScreen);
+if (ds == NULL || (*ds-LegacyAuthMagic) (ds-fd, magic))
+return FALSE;
+
+return TRUE;
+}
+
 Bool
 DRI2Authenticate(ScreenPtr pScreen, uint32_t magic)
 {
 DRI2ScreenPtr ds = DRI2GetScreen(pScreen);
 
-if (ds == NULL || (*ds-AuthMagic) (ds-fd, magic))
+if (ds == NULL || (*ds-AuthMagic) (pScreen, magic))
 return FALSE;
 
 return TRUE;
@@ -1202,8 +1213,11 @@ DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info)
 cur_minor = 1;
 }
 
+if (info-version = 8) {
+ds-AuthMagic = info-AuthMagic2;
+}
 if (info-version = 5) {
-ds-AuthMagic = info-AuthMagic;
+ds-LegacyAuthMagic = info-AuthMagic;
 }
 
 if (info-version = 6) {
@@ -1218,14 +1232,21 @@ DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info)
 
 /*
  * if the driver doesn't provide an AuthMagic function or the info struct
- * version is too low, it relies on the old method (using libdrm) or fail
+ * version is too low, call through LegacyAuthMagic
  */
-if (!ds-AuthMagic)
+if (!ds-AuthMagic) {
+ds-AuthMagic = DRI2AuthMagic;
+/*
+ * If the driver doesn't provide an AuthMagic function
+ * it relies on the old method (using libdrm) or fails
+ */
+if (!ds-LegacyAuthMagic)
 #ifdef WITH_LIBDRM
-ds-AuthMagic = drmAuthMagic;
+ds-LegacyAuthMagic = drmAuthMagic;
 #else
-goto err_out;
+goto err_out;
 #endif
+}
 
 /* Initialize minor if needed and set to minimum provied by DDX */
 if (!dri2_minor || dri2_minor  cur_minor)
diff --git a/hw/xfree86/dri2/dri2.h b/hw/xfree86/dri2/dri2.h
index f849be6..4fd0fbc 100644
--- a/hw/xfree86/dri2/dri2.h
+++ b/hw/xfree86/dri2/dri2.h
@@ -64,6 +64,7 @@ typedef void (*DRI2CopyRegionProcPtr) (DrawablePtr pDraw,
DRI2BufferPtr pSrcBuffer);
 typedef void (*DRI2WaitProcPtr) (WindowPtr pWin, unsigned int sequence);
 typedef int (*DRI2AuthMagicProcPtr) (int fd, uint32_t magic);
+typedef int (*DRI2AuthMagic2ProcPtr) (ScreenPtr pScreen, uint32_t magic);
 
 /**
  * Schedule a buffer swap
@@ -192,7 +193,7 @@ typedef int (*DRI2GetParamProcPtr) (ClientPtr client,
 /**
  * Version of the DRI2InfoRec structure defined in this header
  */
-#define DRI2INFOREC_VERSION 7
+#define DRI2INFOREC_VERSION 8
 
 typedef struct {
 unsigned int version;   /** Version of this struct */
@@ -229,6 +230,12 @@ typedef struct {
 /* added in version 7 */
 
 DRI2GetParamProcPtr GetParam;
+
+/* added in version 8 */
+/* AuthMagic callback which passes extra context */
+/* If this is NULL the AuthMagic callback is used */
+/* If this is non-NULL the AuthMagic callback is ignored */
+DRI2AuthMagic2ProcPtr AuthMagic2;
 } DRI2InfoRec, *DRI2InfoPtr;
 
 extern _X_EXPORT int DRI2EventBase;
-- 
1.7.10.4

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel


Re: [PATCH] dri2: Pass a ScreenPtr through to the driver's AuthMagic function.

2012-06-18 Thread Michel Dänzer
On Mon, 2012-06-18 at 11:52 +1000, Christopher James Halse Rogers
wrote: 
 xwayland drivers need access to their screen private data to authenticate.
 Now that drivers no longer have direct access to the global screen arrays,
 this needs to be passed in as function context.
 
 v2: Don't break ABI
 
 Signed-off-by: Christopher James Halse Rogers 
 christopher.halse.rog...@canonical.com

Reviewed-by: Michel Dänzer michel.daen...@amd.com


-- 
Earthling Michel Dänzer   |   http://www.amd.com
Libre software enthusiast |  Debian, X and DRI developer
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH] dri2: Pass a ScreenPtr through to the driver's AuthMagic function.

2012-06-18 Thread Kristian Høgsberg
On Sun, Jun 17, 2012 at 9:52 PM, Christopher James Halse Rogers
christopher.halse.rog...@canonical.com wrote:
 xwayland drivers need access to their screen private data to authenticate.
 Now that drivers no longer have direct access to the global screen arrays,
 this needs to be passed in as function context.

 v2: Don't break ABI

Yeah, looks good to me now.

Reviewed-by: Kristian Høgsberg k...@bitplanet.net

 Signed-off-by: Christopher James Halse Rogers 
 christopher.halse.rog...@canonical.com
 ---
  hw/xfree86/dri2/dri2.c |   35 ---
  hw/xfree86/dri2/dri2.h |    9 -
  2 files changed, 36 insertions(+), 8 deletions(-)

 diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
 index babf32f..412feb3 100644
 --- a/hw/xfree86/dri2/dri2.c
 +++ b/hw/xfree86/dri2/dri2.c
 @@ -104,7 +104,8 @@ typedef struct _DRI2Screen {
     DRI2ScheduleSwapProcPtr ScheduleSwap;
     DRI2GetMSCProcPtr GetMSC;
     DRI2ScheduleWaitMSCProcPtr ScheduleWaitMSC;
 -    DRI2AuthMagicProcPtr AuthMagic;
 +    DRI2AuthMagic2ProcPtr AuthMagic;
 +    DRI2AuthMagicProcPtr LegacyAuthMagic;
     DRI2ReuseBufferNotifyProcPtr ReuseBufferNotify;
     DRI2SwapLimitValidateProcPtr SwapLimitValidate;
     DRI2GetParamProcPtr GetParam;
 @@ -1110,12 +,22 @@ DRI2Connect(ScreenPtr pScreen, unsigned int 
 driverType, int *fd,
     return TRUE;
  }

 +static Bool
 +DRI2AuthMagic (ScreenPtr pScreen, int fd, uint32_t magic)
 +{
 +    DRI2ScreenPtr ds = DRI2GetScreen(pScreen);
 +    if (ds == NULL || (*ds-LegacyAuthMagic) (ds-fd, magic))
 +        return FALSE;
 +
 +    return TRUE;
 +}
 +
  Bool
  DRI2Authenticate(ScreenPtr pScreen, uint32_t magic)
  {
     DRI2ScreenPtr ds = DRI2GetScreen(pScreen);

 -    if (ds == NULL || (*ds-AuthMagic) (ds-fd, magic))
 +    if (ds == NULL || (*ds-AuthMagic) (pScreen, ds-fd, magic))
         return FALSE;

     return TRUE;
 @@ -1202,8 +1213,11 @@ DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info)
         cur_minor = 1;
     }

 +    if (info-version = 8) {
 +        ds-AuthMagic = info-AuthMagic2;
 +    }
     if (info-version = 5) {
 -        ds-AuthMagic = info-AuthMagic;
 +        ds-LegacyAuthMagic = info-AuthMagic;
     }

     if (info-version = 6) {
 @@ -1218,14 +1232,21 @@ DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info)

     /*
      * if the driver doesn't provide an AuthMagic function or the info struct
 -     * version is too low, it relies on the old method (using libdrm) or fail
 +     * version is too low, call through LegacyAuthMagic
      */
 -    if (!ds-AuthMagic)
 +    if (!ds-AuthMagic) {
 +        ds-AuthMagic = DRI2AuthMagic;
 +        /*
 +         * If the driver doesn't provide an AuthMagic function
 +         * it relies on the old method (using libdrm) or fails
 +         */
 +        if (!ds-LegacyAuthMagic)
  #ifdef WITH_LIBDRM
 -        ds-AuthMagic = drmAuthMagic;
 +            ds-LegacyAuthMagic = drmAuthMagic;
  #else
 -        goto err_out;
 +            goto err_out;
  #endif
 +    }

     /* Initialize minor if needed and set to minimum provied by DDX */
     if (!dri2_minor || dri2_minor  cur_minor)
 diff --git a/hw/xfree86/dri2/dri2.h b/hw/xfree86/dri2/dri2.h
 index f849be6..004d286 100644
 --- a/hw/xfree86/dri2/dri2.h
 +++ b/hw/xfree86/dri2/dri2.h
 @@ -64,6 +64,7 @@ typedef void (*DRI2CopyRegionProcPtr) (DrawablePtr pDraw,
                                        DRI2BufferPtr pSrcBuffer);
  typedef void (*DRI2WaitProcPtr) (WindowPtr pWin, unsigned int sequence);
  typedef int (*DRI2AuthMagicProcPtr) (int fd, uint32_t magic);
 +typedef int (*DRI2AuthMagic2ProcPtr) (ScreenPtr pScreen, int fd, uint32_t 
 magic);

  /**
  * Schedule a buffer swap
 @@ -192,7 +193,7 @@ typedef int (*DRI2GetParamProcPtr) (ClientPtr client,
  /**
  * Version of the DRI2InfoRec structure defined in this header
  */
 -#define DRI2INFOREC_VERSION 7
 +#define DRI2INFOREC_VERSION 8

  typedef struct {
     unsigned int version;       /** Version of this struct */
 @@ -229,6 +230,12 @@ typedef struct {
     /* added in version 7 */

     DRI2GetParamProcPtr GetParam;
 +
 +    /* added in version 8 */
 +    /* AuthMagic callback which passes extra context */
 +    /* If this is NULL the AuthMagic callback is used */
 +    /* If this is non-NULL the AuthMagic callback is ignored */
 +    DRI2AuthMagic2ProcPtr AuthMagic2;
  } DRI2InfoRec, *DRI2InfoPtr;

  extern _X_EXPORT int DRI2EventBase;
 --
 1.7.10.4

 ___
 xorg-devel@lists.x.org: X.Org development
 Archives: http://lists.x.org/archives/xorg-devel
 Info: http://lists.x.org/mailman/listinfo/xorg-devel
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH] dri2: Pass a ScreenPtr through to the driver's AuthMagic function.

2012-06-18 Thread Keith Packard
Christopher James Halse Rogers christopher.halse.rog...@canonical.com
writes:

 +typedef int (*DRI2AuthMagic2ProcPtr) (ScreenPtr pScreen, int fd, uint32_t 
 magic);

Bikeshed -- seems like the 'fd' parameter is not needed in this API?
I'll note that in the implementation of the wrapper, you pull it from
the screen private instead of using the provided parameter...

-- 
keith.pack...@intel.com


pgpH60QR8VD8D.pgp
Description: PGP signature
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

[PATCH] dri2: Pass a ScreenPtr through to the driver's AuthMagic function.

2012-06-17 Thread Christopher James Halse Rogers
xwayland drivers need access to their screen private data to authenticate.
Now that drivers no longer have direct access to the global screen arrays,
this needs to be passed in as function context.

v2: Don't break ABI

Signed-off-by: Christopher James Halse Rogers 
christopher.halse.rog...@canonical.com
---
 hw/xfree86/dri2/dri2.c |   35 ---
 hw/xfree86/dri2/dri2.h |9 -
 2 files changed, 36 insertions(+), 8 deletions(-)

diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
index babf32f..412feb3 100644
--- a/hw/xfree86/dri2/dri2.c
+++ b/hw/xfree86/dri2/dri2.c
@@ -104,7 +104,8 @@ typedef struct _DRI2Screen {
 DRI2ScheduleSwapProcPtr ScheduleSwap;
 DRI2GetMSCProcPtr GetMSC;
 DRI2ScheduleWaitMSCProcPtr ScheduleWaitMSC;
-DRI2AuthMagicProcPtr AuthMagic;
+DRI2AuthMagic2ProcPtr AuthMagic;
+DRI2AuthMagicProcPtr LegacyAuthMagic;
 DRI2ReuseBufferNotifyProcPtr ReuseBufferNotify;
 DRI2SwapLimitValidateProcPtr SwapLimitValidate;
 DRI2GetParamProcPtr GetParam;
@@ -1110,12 +,22 @@ DRI2Connect(ScreenPtr pScreen, unsigned int driverType, 
int *fd,
 return TRUE;
 }
 
+static Bool
+DRI2AuthMagic (ScreenPtr pScreen, int fd, uint32_t magic)
+{
+DRI2ScreenPtr ds = DRI2GetScreen(pScreen);
+if (ds == NULL || (*ds-LegacyAuthMagic) (ds-fd, magic))
+return FALSE;
+
+return TRUE;
+}
+
 Bool
 DRI2Authenticate(ScreenPtr pScreen, uint32_t magic)
 {
 DRI2ScreenPtr ds = DRI2GetScreen(pScreen);
 
-if (ds == NULL || (*ds-AuthMagic) (ds-fd, magic))
+if (ds == NULL || (*ds-AuthMagic) (pScreen, ds-fd, magic))
 return FALSE;
 
 return TRUE;
@@ -1202,8 +1213,11 @@ DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info)
 cur_minor = 1;
 }
 
+if (info-version = 8) {
+ds-AuthMagic = info-AuthMagic2;
+}
 if (info-version = 5) {
-ds-AuthMagic = info-AuthMagic;
+ds-LegacyAuthMagic = info-AuthMagic;
 }
 
 if (info-version = 6) {
@@ -1218,14 +1232,21 @@ DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info)
 
 /*
  * if the driver doesn't provide an AuthMagic function or the info struct
- * version is too low, it relies on the old method (using libdrm) or fail
+ * version is too low, call through LegacyAuthMagic
  */
-if (!ds-AuthMagic)
+if (!ds-AuthMagic) {
+ds-AuthMagic = DRI2AuthMagic;
+/*
+ * If the driver doesn't provide an AuthMagic function
+ * it relies on the old method (using libdrm) or fails
+ */
+if (!ds-LegacyAuthMagic)
 #ifdef WITH_LIBDRM
-ds-AuthMagic = drmAuthMagic;
+ds-LegacyAuthMagic = drmAuthMagic;
 #else
-goto err_out;
+goto err_out;
 #endif
+}
 
 /* Initialize minor if needed and set to minimum provied by DDX */
 if (!dri2_minor || dri2_minor  cur_minor)
diff --git a/hw/xfree86/dri2/dri2.h b/hw/xfree86/dri2/dri2.h
index f849be6..004d286 100644
--- a/hw/xfree86/dri2/dri2.h
+++ b/hw/xfree86/dri2/dri2.h
@@ -64,6 +64,7 @@ typedef void (*DRI2CopyRegionProcPtr) (DrawablePtr pDraw,
DRI2BufferPtr pSrcBuffer);
 typedef void (*DRI2WaitProcPtr) (WindowPtr pWin, unsigned int sequence);
 typedef int (*DRI2AuthMagicProcPtr) (int fd, uint32_t magic);
+typedef int (*DRI2AuthMagic2ProcPtr) (ScreenPtr pScreen, int fd, uint32_t 
magic);
 
 /**
  * Schedule a buffer swap
@@ -192,7 +193,7 @@ typedef int (*DRI2GetParamProcPtr) (ClientPtr client,
 /**
  * Version of the DRI2InfoRec structure defined in this header
  */
-#define DRI2INFOREC_VERSION 7
+#define DRI2INFOREC_VERSION 8
 
 typedef struct {
 unsigned int version;   /** Version of this struct */
@@ -229,6 +230,12 @@ typedef struct {
 /* added in version 7 */
 
 DRI2GetParamProcPtr GetParam;
+
+/* added in version 8 */
+/* AuthMagic callback which passes extra context */
+/* If this is NULL the AuthMagic callback is used */
+/* If this is non-NULL the AuthMagic callback is ignored */
+DRI2AuthMagic2ProcPtr AuthMagic2;
 } DRI2InfoRec, *DRI2InfoPtr;
 
 extern _X_EXPORT int DRI2EventBase;
-- 
1.7.10.4

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel