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

Kristian Høgsberg hoegsberg at gmail.com
Fri Jun 15 07:37:56 PDT 2012


On Fri, Jun 15, 2012 at 12:35:00PM +0200, Michel Dänzer wrote:
> On Fre, 2012-06-15 at 19:01 +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. The way it was working
> > was ugly, anyway.
> > 
> > Signed-off-by: Christopher James Halse Rogers <christopher.halse.rogers at canonical.com>
> > ---
> > 
> > This came up when I got around to fixing the nouveau xwayland patch review
> > comments; with things no longer meant to access the global xf86Screens array
> > the authmagic callback needed some other way to access driver private data.
> > 
> > Nouveau patch using this follows; I'll send it upstream once this gets
> > applied somewhere.
> > 
> > CCd to xorg-devel mainly for sanity review, but could be applied; as Airlied
> > has pointed out, there's no particular reason for the xwayland branch to
> > diverge on core infrastructure.
> 
> [...]
> 
> > @@ -1202,9 +1215,17 @@ DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info)
> >          cur_minor = 1;
> >      }
> >  
> > -    if (info->version >= 5) {
> > +    if (info->version >= 7) {
> >          ds->AuthMagic = info->AuthMagic;
> >      }
> > +    else if (info->version >= 5) {
> > +        /*
> > +         * This cast is safe; if the driver has provided a V5 or V6 InfoRec
> > +         * then AuthMagic is of type DRI2LegacyAuthMagicProcPtr, and the C
> > +         * standard guarantees that we can typecast it back and call it.
> > +         */
> > +        ds->LegacyAuthMagic = (DRI2LegacyAuthMagicProcPtr)info->AuthMagic;
> > +    }
> 
> This is nifty, but it's an ABI break, as servers without this change
> will treat the version 7 AuthMagic field incorrectly. Wouldn't it be
> easier to add a second AuthMagic field at the end of version 7?

Drivers can use DRI2Version to see if the xserver is recent enough to
understand this trick, but I agree just adding a field to the structs
is simpler.

Kristian


More information about the wayland-devel mailing list