RFC: xfree: dri2: libdrm as optional

Tiago Vignatti tiago.vignatti at nokia.com
Tue Jan 19 11:18:11 PST 2010


Some drivers use DRI2 protocol but implement their own kernel rendering
mananger. For these drivers, libdrm becomes useless.

The only inconvenient right now to put libdrm optional to X server is
concerning DRI2Authenticate. Such function uses drm_magic_t and drmAuthMagic
symbols from libdrm. So I thought two alternatives.

1. wrap with some macros and set at compilation time:

    #ifndef WITH_DRM
    typedef unsigned int drm_magic_t;
    #endif

    Bool
    DRI2Authenticate(ScreenPtr pScreen, drm_magic_t magic)
    {
    #ifdef WITH_DRM
        DRI2ScreenPtr ds = DRI2GetScreen(pScreen);

        if (ds == NULL || drmAuthMagic(ds->fd, magic))
           return FALSE;

        return TRUE;
    #else
        return FALSE;
    #endif
    }


2. hide all trickery inside xorg driver, adding a new field to DRI2InfoRec:

    Bool
    DRI2Authenticate(ScreenPtr pScreen, unsigned int magic)
    {
        DRI2ScreenPtr ds = DRI2GetScreen(pScreen);
        if (ds == NULL || (*ds->AuthMagic)(ds->fd, magic))
        return FALSE;

        return TRUE;
    }


In the first alternative the implementation is straightforward but should be
adjusted at build time. It's ugly. Also, one would want to implement his own
way of clients authentication, or not (sigh) - note though dri2proto states
that this is not mandatory:

    "A kernel rendering manager can choose not to implement any
    authentication and just allow access to all buffers."

Alternative 2. seems more complete but requires code changes all over the
drivers. I'm more inclined for this alternative... Moreover, for both
alternatives we need to do something with drm_magic_t type - can we just use
unsigned int instead declare such new type?

So what you guys think about this all?


Thanks,

            Tiago


More information about the xorg-devel mailing list