[PATCH v2 3/3] xfree86: dri2: conditionalize libdrm

Jeremy Huddleston jeremyhu at freedesktop.org
Sat Feb 6 10:27:59 PST 2010


Would it be better to do:
+#ifdef WITH_LIBDRM
#include <xf86drm.h>
+#else
+typedef uint32_t drm_magic_t
+#endif

rather than changing all the drm_magic_t to uint32_t?

On Feb 6, 2010, at 04:24, Tiago Vignatti wrote:

> wrap drm bits with macros and change drm_magic type
> 
> Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
> ---
> hw/xfree86/dri2/dri2.c    |   12 +++++++++++-
> hw/xfree86/dri2/dri2.h    |    2 +-
> hw/xfree86/dri2/dri2ext.c |    2 ++
> 3 files changed, 14 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
> index cc09789..f07112d 100644
> --- a/hw/xfree86/dri2/dri2.c
> +++ b/hw/xfree86/dri2/dri2.c
> @@ -35,7 +35,9 @@
> #endif
> 
> #include <errno.h>
> +#ifdef WITH_LIBDRM
> #include <xf86drm.h>
> +#endif
> #include "xf86Module.h"
> #include "scrnintstr.h"
> #include "windowstr.h"
> @@ -798,7 +800,7 @@ DRI2Connect(ScreenPtr pScreen, unsigned int driverType, int *fd,
> }
> 
> Bool
> -DRI2Authenticate(ScreenPtr pScreen, drm_magic_t magic)
> +DRI2Authenticate(ScreenPtr pScreen, uint32_t magic)
> {
>     DRI2ScreenPtr ds = DRI2GetScreen(pScreen);
> 
> @@ -845,8 +847,16 @@ DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info)
> 	ds->AuthMagic = info->AuthMagic;
>     }
> 
> +    /*
> +     * 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
> +     */
>     if (!ds->AuthMagic)
> +#ifdef WITH_LIBDRM
> 	ds->AuthMagic = drmAuthMagic;
> +#else
> +	return FALSE;
> +#endif
> 
>     if (info->version == 3 || info->numDrivers == 0) {
> 	/* Driver too old: use the old-style driverName field */
> diff --git a/hw/xfree86/dri2/dri2.h b/hw/xfree86/dri2/dri2.h
> index f770760..1510fca 100644
> --- a/hw/xfree86/dri2/dri2.h
> +++ b/hw/xfree86/dri2/dri2.h
> @@ -194,7 +194,7 @@ extern _X_EXPORT Bool DRI2Connect(ScreenPtr pScreen,
> 		 const char **driverName,
> 		 const char **deviceName);
> 
> -extern _X_EXPORT Bool DRI2Authenticate(ScreenPtr pScreen, drm_magic_t magic);
> +extern _X_EXPORT Bool DRI2Authenticate(ScreenPtr pScreen, uint32_t magic);
> 
> extern _X_EXPORT int DRI2CreateDrawable(DrawablePtr pDraw);
> 
> diff --git a/hw/xfree86/dri2/dri2ext.c b/hw/xfree86/dri2/dri2ext.c
> index 3e6b03e..e97ed97 100644
> --- a/hw/xfree86/dri2/dri2ext.c
> +++ b/hw/xfree86/dri2/dri2ext.c
> @@ -42,7 +42,9 @@
> #include "scrnintstr.h"
> #include "pixmapstr.h"
> #include "extnsionst.h"
> +#ifdef WITH_LIBDRM
> #include "xf86drm.h"
> +#endif
> #include "xfixes.h"
> #include "dri2.h"
> #include "protocol-versions.h"
> -- 
> 1.6.0.4
> 
> _______________________________________________
> xorg-devel mailing list
> xorg-devel at lists.x.org
> http://lists.x.org/mailman/listinfo/xorg-devel



More information about the xorg-devel mailing list