[PATCH 28/42] Move DRI2 from external module to built-in

Daniel Stone daniel at fooishbar.org
Fri Dec 2 03:27:36 PST 2011


Instead of keeping a tiny amount of code in an external module, just man
up and build it into the core server.

Signed-off-by: Daniel Stone <daniel at fooishbar.org>
Reviewed-by: Jamey Sharp <jamey at minilop.net>
---
 hw/xfree86/Makefile.am             |    4 ++-
 hw/xfree86/common/Makefile.am      |    2 +-
 hw/xfree86/common/xf86Config.c     |    3 --
 hw/xfree86/common/xf86Extensions.c |   14 ++++++++++
 hw/xfree86/dri2/Makefile.am        |    9 +++---
 hw/xfree86/dri2/dri2.c             |   48 +++++------------------------------
 hw/xfree86/dri2/dri2ext.c          |   25 ++++++++----------
 hw/xfree86/dri2/dri2int.h          |   30 ++++++++++++++++++++++
 hw/xfree86/loader/Makefile.am      |    2 +-
 hw/xfree86/sdksyms.sh              |    2 -
 test/Makefile.am                   |    8 +++++-
 11 files changed, 78 insertions(+), 69 deletions(-)
 create mode 100644 hw/xfree86/dri2/dri2int.h

diff --git a/hw/xfree86/Makefile.am b/hw/xfree86/Makefile.am
index 0cfbaa2..0ff42eb 100644
--- a/hw/xfree86/Makefile.am
+++ b/hw/xfree86/Makefile.am
@@ -6,6 +6,7 @@ endif
 
 if DRI2
 DRI2_SUBDIR = dri2
+DRI2_LIB = dri2/libdri2.la
 endif
 
 if XF86UTILS
@@ -44,7 +45,7 @@ nodist_Xorg_SOURCES = sdksyms.c
 AM_CFLAGS = $(DIX_CFLAGS) @XORG_CFLAGS@ @DRIPROTO_CFLAGS@ @LIBDRM_CFLAGS@
 INCLUDES = $(XORG_INCS) -I$(srcdir)/parser -I$(top_srcdir)/miext/cw \
 	-I$(srcdir)/ddc -I$(srcdir)/i2c -I$(srcdir)/modes -I$(srcdir)/ramdac \
-	-I$(srcdir)/dri
+	-I$(srcdir)/dri -I$(srcdir)/dri2
 
 LOCAL_LIBS = \
             $(MAIN_LIB) \
@@ -61,6 +62,7 @@ LOCAL_LIBS = \
             $(XORG_LIBS) \
             dixmods/libxorgxkb.la \
             $(DRI_LIB) \
+            $(DRI2_LIB) \
             $(top_builddir)/mi/libmi.la \
             $(top_builddir)/os/libos.la
 Xorg_LDADD = \
diff --git a/hw/xfree86/common/Makefile.am b/hw/xfree86/common/Makefile.am
index 7f1f49b..e64dd92 100644
--- a/hw/xfree86/common/Makefile.am
+++ b/hw/xfree86/common/Makefile.am
@@ -52,7 +52,7 @@ INCLUDES = $(XORG_INCS) -I$(srcdir)/../ddc -I$(srcdir)/../i2c \
 	   -I$(srcdir)/../loader -I$(srcdir)/../parser \
            -I$(srcdir)/../vbe -I$(srcdir)/../int10 \
 	   -I$(srcdir)/../vgahw -I$(srcdir)/../dixmods/extmod \
-	   -I$(srcdir)/../modes -I$(srcdir)/../ramdac
+	   -I$(srcdir)/../modes -I$(srcdir)/../ramdac -I$(srcdir)/../dri2
 
 sdk_HEADERS = compiler.h fourcc.h xf86.h xf86Module.h xf86Opt.h \
               xf86PciInfo.h xf86Priv.h xf86Privstr.h \
diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c
index 8e9d220..d677b04 100644
--- a/hw/xfree86/common/xf86Config.c
+++ b/hw/xfree86/common/xf86Config.c
@@ -112,9 +112,6 @@ static ModuleDefault ModuleDefaults[] = {
 #ifdef GLXEXT
     {.name = "glx",      .toLoad = TRUE,    .load_opt=NULL},
 #endif
-#ifdef DRI2
-    {.name = "dri2",     .toLoad = TRUE,    .load_opt=NULL},
-#endif
     {.name = NULL,       .toLoad = FALSE,   .load_opt=NULL}
 };
 
diff --git a/hw/xfree86/common/xf86Extensions.c b/hw/xfree86/common/xf86Extensions.c
index ed5bab8..882f523 100644
--- a/hw/xfree86/common/xf86Extensions.c
+++ b/hw/xfree86/common/xf86Extensions.c
@@ -54,6 +54,11 @@
 extern void XFree86DRIExtensionInit(void);
 #endif
 
+#ifdef DRI2
+#include <X11/extensions/dri2proto.h>
+#include "dri2int.h"
+#endif
+
 /*
  * DDX-specific extensions.
  */
@@ -85,6 +90,15 @@ static ExtensionModule extensionModules[] = {
         NULL
     },
 #endif
+#ifdef DRI2
+    {
+        DRI2ExtensionInit,
+        DRI2_NAME,
+        &noDRI2Extension,
+        NULL,
+        NULL
+    }
+#endif
 };
 
 static void
diff --git a/hw/xfree86/dri2/Makefile.am b/hw/xfree86/dri2/Makefile.am
index c9fdde2..3c207b2 100644
--- a/hw/xfree86/dri2/Makefile.am
+++ b/hw/xfree86/dri2/Makefile.am
@@ -1,16 +1,15 @@
-libdri2_la_LTLIBRARIES = libdri2.la
-libdri2_la_CFLAGS = \
+noinst_LTLIBRARIES = libdri2.la
+AM_CFLAGS = \
 	-DHAVE_XORG_CONFIG_H \
 	@DRI_CFLAGS@ \
 	@DIX_CFLAGS@ @XORG_CFLAGS@ @DRI2PROTO_CFLAGS@ @LIBDRM_CFLAGS@ \
 	-I$(top_srcdir)/hw/xfree86/common \
 	-I$(top_srcdir)/hw/xfree86/os-support/bus
 
-libdri2_la_LDFLAGS = -module -avoid-version @LIBDRM_LIBS@
-libdri2_ladir = $(moduledir)/extensions
 libdri2_la_SOURCES = \
 	dri2.c \
 	dri2.h \
-	dri2ext.c
+	dri2ext.c \
+	dri2int.h
 
 sdk_HEADERS = dri2.h
diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
index 0d613be..c6ff6b5 100644
--- a/hw/xfree86/dri2/dri2.c
+++ b/hw/xfree86/dri2/dri2.c
@@ -44,6 +44,7 @@
 #include "windowstr.h"
 #include "dixstruct.h"
 #include "dri2.h"
+#include "dri2int.h"
 #include "xf86VGAarbiter.h"
 
 #include "xf86.h"
@@ -60,7 +61,7 @@ static DevPrivateKeyRec dri2WindowPrivateKeyRec;
 static DevPrivateKeyRec dri2PixmapPrivateKeyRec;
 #define dri2PixmapPrivateKey (&dri2PixmapPrivateKeyRec)
 
-static RESTYPE       dri2DrawableRes;
+RESTYPE       dri2DrawableRes;
 
 typedef struct _DRI2Screen *DRI2ScreenPtr;
 
@@ -296,7 +297,8 @@ DRI2CreateDrawable(ClientPtr client, DrawablePtr pDraw, XID id,
     return Success;
 }
 
-static int DRI2DrawableGone(pointer p, XID id)
+int
+DRI2DrawableGone(pointer p, XID id)
 {
     DRI2DrawablePtr pPriv = p;
     DRI2ScreenPtr   ds = pPriv->dri2_screen;
@@ -1234,7 +1236,6 @@ DRI2CloseScreen(ScreenPtr pScreen)
     dixSetPrivate(&pScreen->devPrivates, dri2ScreenPrivateKey, NULL);
 }
 
-extern ExtensionModule dri2ExtensionModule;
 extern Bool DRI2ModuleSetup(void);
 
 /* Called by InitExtensions() */
@@ -1243,52 +1244,17 @@ DRI2ModuleSetup(void)
 {
     dri2DrawableRes = CreateNewResourceType(DRI2DrawableGone, "DRI2Drawable");
     if (!dri2DrawableRes)
-	return FALSE;
+       return FALSE;
 
     return TRUE;
 }
 
-static pointer
-DRI2Setup(pointer module, pointer opts, int *errmaj, int *errmin)
-{
-    static Bool setupDone = FALSE;
-
-    if (!setupDone)
-    {
-	setupDone = TRUE;
-	LoadExtension(&dri2ExtensionModule, FALSE);
-    }
-    else
-    {
-	if (errmaj)
-	    *errmaj = LDR_ONCEONLY;
-    }
-
-    return (pointer) 1;
-}
-
-static XF86ModuleVersionInfo DRI2VersRec =
-{
-    "dri2",
-    MODULEVENDORSTRING,
-    MODINFOSTRING1,
-    MODINFOSTRING2,
-    XORG_VERSION_CURRENT,
-    1, 2, 0,
-    ABI_CLASS_EXTENSION,
-    ABI_EXTENSION_VERSION,
-    MOD_CLASS_NONE,
-    { 0, 0, 0, 0 }
-};
-
-_X_EXPORT XF86ModuleData dri2ModuleData = { &DRI2VersRec, DRI2Setup, NULL };
-
 void
 DRI2Version(int *major, int *minor)
 {
     if (major != NULL)
-	*major = DRI2VersRec.majorversion;
+	*major = 1;
 
     if (minor != NULL)
-	*minor = DRI2VersRec.minorversion;
+	*minor = 2;
 }
diff --git a/hw/xfree86/dri2/dri2ext.c b/hw/xfree86/dri2/dri2ext.c
index e612cf0..7f42133 100644
--- a/hw/xfree86/dri2/dri2ext.c
+++ b/hw/xfree86/dri2/dri2ext.c
@@ -44,11 +44,9 @@
 #include "extnsionst.h"
 #include "xfixes.h"
 #include "dri2.h"
+#include "dri2int.h"
 #include "protocol-versions.h"
 
-/* The only xf86 include */
-#include "xf86Module.h"
-
 static ExtensionEntry	*dri2Extension;
 extern Bool DRI2ModuleSetup(void);
 
@@ -623,9 +621,18 @@ SProcDRI2Dispatch (ClientPtr client)
 
 int DRI2EventBase;
 
-static void
+void
 DRI2ExtensionInit(void)
 {
+    static Bool beenHere = FALSE;
+
+    if (!beenHere)
+    {
+        dri2DrawableRes = CreateNewResourceType(DRI2DrawableGone,
+                                                "DRI2Drawable");
+        beenHere = TRUE;
+    }
+
     dri2Extension = AddExtension(DRI2_NAME,
 				 DRI2NumberEvents,
 				 DRI2NumberErrors,
@@ -638,13 +645,3 @@ DRI2ExtensionInit(void)
 
     DRI2ModuleSetup();
 }
-
-extern Bool noDRI2Extension;
-
-_X_HIDDEN ExtensionModule dri2ExtensionModule = {
-    DRI2ExtensionInit,
-    DRI2_NAME,
-    &noDRI2Extension,
-    NULL,
-    NULL
-};
diff --git a/hw/xfree86/dri2/dri2int.h b/hw/xfree86/dri2/dri2int.h
new file mode 100644
index 0000000..37dd071
--- /dev/null
+++ b/hw/xfree86/dri2/dri2int.h
@@ -0,0 +1,30 @@
+/*
+ * Copyright © 2011 Daniel Stone
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Author: Daniel Stone <daniel at fooishbar.org>
+ */
+
+extern RESTYPE dri2DrawableRes;
+
+extern void DRI2ExtensionInit(void);
+
+int DRI2DrawableGone(pointer p, XID id);
diff --git a/hw/xfree86/loader/Makefile.am b/hw/xfree86/loader/Makefile.am
index df1020b..475e3e8 100644
--- a/hw/xfree86/loader/Makefile.am
+++ b/hw/xfree86/loader/Makefile.am
@@ -2,7 +2,7 @@ noinst_LTLIBRARIES = libloader.la
 
 INCLUDES = $(XORG_INCS) -I$(srcdir)/../parser -I$(top_srcdir)/miext/cw \
 	   -I$(srcdir)/../ddc -I$(srcdir)/../i2c -I$(srcdir)/../modes \
-	   -I$(srcdir)/../ramdac -I$(srcdir)/../dri
+	   -I$(srcdir)/../ramdac -I$(srcdir)/../dri -I$(srcdir)/../dri2
 
 #AM_LDFLAGS = -r
 AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) @DRIPROTO_CFLAGS@ @LIBDRM_CFLAGS@
diff --git a/hw/xfree86/sdksyms.sh b/hw/xfree86/sdksyms.sh
index 69351a3..7349bc6 100755
--- a/hw/xfree86/sdksyms.sh
+++ b/hw/xfree86/sdksyms.sh
@@ -93,11 +93,9 @@ cat > sdksyms.c << EOF
 
 
 /* hw/xfree86/dri2/Makefile.am -- module */
-/*
 #if DRI2
 # include "dri2.h"
 #endif
- */
 
 
 /* hw/xfree86/vgahw/Makefile.am -- module */
diff --git a/test/Makefile.am b/test/Makefile.am
index d6317a6..0fd5fd0 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -10,7 +10,8 @@ AM_CFLAGS = $(DIX_CFLAGS) @XORG_CFLAGS@ @DRIPROTO_CFLAGS@ @LIBDRM_CFLAGS@
 INCLUDES = $(XORG_INCS) -I$(top_srcdir)/hw/xfree86/parser \
 	-I$(top_srcdir)/miext/cw -I$(top_srcdir)/hw/xfree86/ddc \
 	-I$(top_srcdir)/hw/xfree86/i2c -I$(top_srcdir)/hw/xfree86/modes \
-	-I$(top_srcdir)/hw/xfree86/ramdac -I$(top_srcdir)/hw/xfree86/dri
+	-I$(top_srcdir)/hw/xfree86/ramdac -I$(top_srcdir)/hw/xfree86/dri \
+	-I$(top_srcdir)/hw/xfree86/dri2
 TEST_LDADD=libxservertest.la $(XORG_SYS_LIBS) $(XSERVER_SYS_LIBS) @LIBDRM_LIBS@
 
 if SPECIAL_DTRACE_OBJECTS
@@ -29,6 +30,10 @@ if DRI
 DRI_LIB = $(top_builddir)/hw/xfree86/dri/libdri.la
 endif
 
+if DRI2
+DRI2_LIB = $(top_builddir)/hw/xfree86/dri2/libdri2.la
+endif
+
 nodist_libxservertest_la_SOURCES = $(top_builddir)/hw/xfree86/sdksyms.c
 libxservertest_la_LIBADD = \
             $(XSERVER_LIBS) \
@@ -43,6 +48,7 @@ libxservertest_la_LIBADD = \
             $(top_builddir)/hw/xfree86/i2c/libi2c.la \
             $(top_builddir)/hw/xfree86/dixmods/libxorgxkb.la \
             $(DRI_LIB) \
+            $(DRI2_LIB) \
             $(top_builddir)/mi/libmi.la \
             $(top_builddir)/os/libos.la \
             @XORG_LIBS@
-- 
1.7.7.3



More information about the xorg-devel mailing list