Mesa (gallium-xorg-driver): xorg: Move personalized bits from the xorg tracker

Jakob Bornecrantz wallbraker at kemper.freedesktop.org
Mon Feb 2 01:05:30 UTC 2009


Module: Mesa
Branch: gallium-xorg-driver
Commit: 606e691f33faa62b72f1046d5772e8f51788dc9f
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=606e691f33faa62b72f1046d5772e8f51788dc9f

Author: Jakob Bornecrantz <wallbraker at gmail.com>
Date:   Mon Feb  2 00:52:30 2009 +0100

xorg: Move personalized bits from the xorg tracker

	Parts of a Xorg driver depends on the device ids
	and final name of the driver. The xorg state tracker
	doesn't know about this so these needs to be defined
	in the winsys build directory.

---

 src/gallium/state_trackers/xorg/xorg_driver.c    |  176 +++++-----------------
 src/gallium/state_trackers/xorg/xorg_winsys.h    |   51 +++++++
 src/gallium/winsys/drm/intel/xorg/intel_device.c |    9 -
 src/gallium/winsys/drm/intel/xorg/intel_xorg.c   |  156 +++++++++++++++++++
 4 files changed, 245 insertions(+), 147 deletions(-)

diff --git a/src/gallium/state_trackers/xorg/xorg_driver.c b/src/gallium/state_trackers/xorg/xorg_driver.c
index 36257fc..12903fc 100644
--- a/src/gallium/state_trackers/xorg/xorg_driver.c
+++ b/src/gallium/state_trackers/xorg/xorg_driver.c
@@ -55,14 +55,15 @@
 #include <pciaccess.h>
 
 #include "xorg_tracker.h"
+#include "xorg_winsys.h"
 
 static void AdjustFrame(int scrnIndex, int x, int y, int flags);
 static Bool CloseScreen(int scrnIndex, ScreenPtr pScreen);
 static Bool EnterVT(int scrnIndex, int flags);
 static Bool SaveHWState(ScrnInfoPtr pScrn);
 static Bool RestoreHWState(ScrnInfoPtr pScrn);
-static void Identify(int flags);
-static const OptionInfoRec *AvailableOptions(int chipid, int busid);
+
+
 static ModeStatus ValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose,
 			    int flags);
 static void FreeScreen(int scrnIndex, int flags);
@@ -72,41 +73,6 @@ static Bool ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc,
 		       char **argv);
 static Bool PreInit(ScrnInfoPtr pScrn, int flags);
 
-static Bool
-pci_probe(DriverPtr driver,
-	  int entity_num, struct pci_device *device, intptr_t match_data);
-
-static const struct pci_id_match device_match[] = {
-    {0x8086, 0x2592, 0xffff, 0xffff, 0, 0, 0},
-    {0x8086, 0x27A2, 0xffff, 0xffff, 0, 0, 0},
-    {0, 0, 0},
-};
-
-_X_EXPORT DriverRec modesetting = {
-    1,
-    "modesetting",
-    Identify,
-    NULL,
-    AvailableOptions,
-    NULL,
-    0,
-    NULL,
-    device_match,
-    pci_probe
-};
-
-static SymTabRec Chipsets[] = {
-    {0x2592, "Intel Graphics Device"},
-    {0x27A2, "Intel Graphics Device"},
-    {-1, NULL}
-};
-
-static PciChipsets PciDevices[] = {
-    {0x2592, 0x2592, RES_SHARED_VGA},
-    {0x27A2, 0x27A2, RES_SHARED_VGA},
-    {-1, -1, RES_UNDEFINED}
-};
-
 typedef enum
 {
     OPTION_SW_CURSOR,
@@ -117,6 +83,10 @@ static const OptionInfoRec Options[] = {
     {-1, NULL, OPTV_NONE, {0}, FALSE}
 };
 
+/*
+ * Functions that might be needed
+ */
+
 static const char *exaSymbols[] = {
     "exaGetVersion",
     "exaDriverInit",
@@ -139,112 +109,39 @@ static const char *ddcSymbols[] = {
     NULL
 };
 
-static const char *i2cSymbols[] = {
-    "xf86CreateI2CBusRec",
-    "xf86I2CBusInit",
-    NULL
-};
-
-int modesettingEntityIndex = -1;
-
-static MODULESETUPPROTO(Setup);
-
-static XF86ModuleVersionInfo VersRec = {
-    "modesetting",
-    MODULEVENDORSTRING,
-    MODINFOSTRING1,
-    MODINFOSTRING2,
-    XORG_VERSION_CURRENT,
-    0, 1, 0,
-    ABI_CLASS_VIDEODRV,
-    ABI_VIDEODRV_VERSION,
-    MOD_CLASS_VIDEODRV,
-    {0, 0, 0, 0}
-};
-
-extern XF86ModuleData modesettingModuleData;
-
-_X_EXPORT XF86ModuleData modesettingModuleData = { &VersRec, Setup, NULL };
-
-extern void HACK_HACK_FUGLY();
-
-extern void HACK_HACK_FUGLY()
-{
-    void *ptr = &modesettingModuleData;
-    (void)ptr;
-}
-
-static pointer
-Setup(pointer module, pointer opts, int *errmaj, int *errmin)
-{
-    static Bool setupDone = 0;
-
-    /* This module should be loaded only once, but check to be sure.
-     */
-    if (!setupDone) {
-	setupDone = 1;
-	xf86AddDriver(&modesetting, module, HaveDriverFuncs);
-
-	/*
-	 * Tell the loader about symbols from other modules that this module
-	 * might refer to.
-	 */
-	LoaderRefSymLists(exaSymbols, fbSymbols, ddcSymbols, NULL);
-
-	/*
-	 * The return value must be non-NULL on success even though there
-	 * is no TearDownProc.
-	 */
-	return (pointer) 1;
-    } else {
-	if (errmaj)
-	    *errmaj = LDR_ONCEONLY;
-	return NULL;
-    }
-}
+/*
+ * Exported Xorg driver functions to winsys
+ */
 
-static void
-Identify(int flags)
+void
+xorg_tracker_loader_ref_sym_lists()
 {
-    xf86PrintChipsets("modesetting", "Driver for Modesetting Kernel Drivers",
-		      Chipsets);
+    LoaderRefSymLists(exaSymbols, fbSymbols, ddcSymbols, NULL);
 }
 
-static const OptionInfoRec *
-AvailableOptions(int chipid, int busid)
+const OptionInfoRec *
+xorg_tracker_available_options(int chipid, int busid)
 {
     return Options;
 }
 
-static Bool
-pci_probe(DriverPtr driver,
-	  int entity_num, struct pci_device *device, intptr_t match_data)
+void 
+xorg_tracker_set_functions(ScrnInfoPtr scrn)
 {
-    ScrnInfoPtr scrn = NULL;
-    EntityInfoPtr entity;
-
-    scrn = xf86ConfigPciEntity(scrn, 0, entity_num, PciDevices,
-			       NULL, NULL, NULL, NULL, NULL);
-    if (scrn != NULL) {
-	scrn->driverVersion = 1;
-	scrn->driverName = "modesetting";
-	scrn->name = "modesetting";
-	scrn->Probe = NULL;
-
-	entity = xf86GetEntityInfo(entity_num);
-
-	scrn->PreInit = PreInit;
-	scrn->ScreenInit = ScreenInit;
-	scrn->SwitchMode = SwitchMode;
-	scrn->AdjustFrame = AdjustFrame;
-	scrn->EnterVT = EnterVT;
-	scrn->LeaveVT = LeaveVT;
-	scrn->FreeScreen = FreeScreen;
-	scrn->ValidMode = ValidMode;
-    }
-    return scrn != NULL;
+    scrn->PreInit = PreInit;
+    scrn->ScreenInit = ScreenInit;
+    scrn->SwitchMode = SwitchMode;
+    scrn->AdjustFrame = AdjustFrame;
+    scrn->EnterVT = EnterVT;
+    scrn->LeaveVT = LeaveVT;
+    scrn->FreeScreen = FreeScreen;
+    scrn->ValidMode = ValidMode;
 }
 
+/*
+ * Static Xorg funtctions
+ */
+
 static Bool
 GetRec(ScrnInfoPtr pScrn)
 {
@@ -282,8 +179,8 @@ CreateFrontBuffer(ScrnInfoPtr pScrn)
     modesettingPtr ms = modesettingPTR(pScrn);
     ScreenPtr pScreen = pScrn->pScreen;
     PixmapPtr rootPixmap = pScreen->GetScreenPixmap(pScreen);
-    Bool fbAccessDisabled;
-    int flags;
+    //Bool fbAccessDisabled;
+    unsigned int flags;
 
     ms->noEvict = TRUE;
     pScreen->ModifyPixmapHeader(rootPixmap,
@@ -312,10 +209,10 @@ static Bool
 crtc_resize(ScrnInfoPtr pScrn, int width, int height)
 {
     modesettingPtr ms = modesettingPTR(pScrn);
-    ScreenPtr pScreen = pScrn->pScreen;
-    PixmapPtr rootPixmap = pScreen->GetScreenPixmap(pScreen);
-    Bool fbAccessDisabled;
-    CARD8 *fbstart;
+    //ScreenPtr pScreen = pScrn->pScreen;
+    //PixmapPtr rootPixmap = pScreen->GetScreenPixmap(pScreen);
+    //Bool fbAccessDisabled;
+    //CARD8 *fbstart;
 
     if (width == pScrn->virtualX && height == pScrn->virtualY)
 	return TRUE;
@@ -380,9 +277,12 @@ PreInit(ScrnInfoPtr pScrn, int flags)
 
     /* Allocate an entity private if necessary */
     if (xf86IsEntityShared(pScrn->entityList[0])) {
+	FatalError("Entity");
+#if 0
 	msEnt = xf86GetEntityPrivate(pScrn->entityList[0],
 				     modesettingEntityIndex)->ptr;
 	ms->entityPrivate = msEnt;
+#endif
     } else
 	ms->entityPrivate = NULL;
 
diff --git a/src/gallium/state_trackers/xorg/xorg_winsys.h b/src/gallium/state_trackers/xorg/xorg_winsys.h
new file mode 100644
index 0000000..d523080
--- /dev/null
+++ b/src/gallium/state_trackers/xorg/xorg_winsys.h
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * 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, sub license, 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 NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS 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: Alan Hourihane <alanh at tungstengraphics.com>
+ * Author: Jakob Bornecrantz <wallbraker at gmail.com>
+ *
+ */
+
+/*
+ * File with all the junk needed to personalize the a xorg driver.
+ */
+
+#ifndef _XORG_WINSYS_H_
+#define _XORG_WINSYS_H_
+
+#include "xorg-server.h"
+#include "xf86.h"
+#include "xf86Resources.h"
+#include "pciaccess.h"
+
+#ifndef XSERVER_LIBPCIACCESS
+#error "libpciaccess needed"
+#endif
+
+void xorg_tracker_set_functions(ScrnInfoPtr scrn);
+const OptionInfoRec * xorg_tracker_available_options(int chipid, int busid);
+void xorg_tracker_loader_ref_sym_lists(void);
+
+#endif
diff --git a/src/gallium/winsys/drm/intel/xorg/intel_device.c b/src/gallium/winsys/drm/intel/xorg/intel_device.c
index 74d23ad..6b28140 100644
--- a/src/gallium/winsys/drm/intel/xorg/intel_device.c
+++ b/src/gallium/winsys/drm/intel/xorg/intel_device.c
@@ -23,21 +23,12 @@ intel_destroy_winsys(struct pipe_winsys *winsys)
 	free(dev);
 }
 
-extern unsigned modesetting;
-extern unsigned modesettingModuleData;
-
 struct pipe_screen *
 intel_create_screen(int drmFD, int deviceID)
 {
 	struct intel_device *dev;
 	struct pipe_screen *screen;
 
-	/* HACK */
-	void *ptr1 = &modesetting;
-	void *ptr2 = &modesettingModuleData;
-	(void)ptr1;
-	(void)ptr2;
-
 	/* Allocate the private area */
 	dev = malloc(sizeof(*dev));
 	if (!dev)
diff --git a/src/gallium/winsys/drm/intel/xorg/intel_xorg.c b/src/gallium/winsys/drm/intel/xorg/intel_xorg.c
new file mode 100644
index 0000000..aea3924
--- /dev/null
+++ b/src/gallium/winsys/drm/intel/xorg/intel_xorg.c
@@ -0,0 +1,156 @@
+/*
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * 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, sub license, 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 NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS 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: Alan Hourihane <alanh at tungstengraphics.com>
+ * Author: Jakob Bornecrantz <wallbraker at gmail.com>
+ *
+ */
+
+#include "../../../../state_trackers/xorg/xorg_winsys.h"
+
+static void intel_xorg_identify(int flags);
+static Bool intel_xorg_pci_probe(DriverPtr driver,
+				 int entity_num,
+				 struct pci_device *device,
+				 intptr_t match_data);
+
+static const struct pci_id_match intel_xorg_device_match[] = {
+    {0x8086, 0x2592, 0xffff, 0xffff, 0, 0, 0},
+    {0x8086, 0x27A2, 0xffff, 0xffff, 0, 0, 0},
+    {0, 0, 0},
+};
+
+static SymTabRec intel_xorg_chipsets[] = {
+    {0x2592, "Intel Graphics Device"},
+    {0x27A2, "Intel Graphics Device"},
+    {-1, NULL}
+};
+
+static PciChipsets intel_xorg_pci_devices[] = {
+    {0x2592, 0x2592, RES_SHARED_VGA},
+    {0x27A2, 0x27A2, RES_SHARED_VGA},
+    {-1, -1, RES_UNDEFINED}
+};
+
+static XF86ModuleVersionInfo intel_xorg_version = {
+    "modesetting",
+    MODULEVENDORSTRING,
+    MODINFOSTRING1,
+    MODINFOSTRING2,
+    XORG_VERSION_CURRENT,
+    0, 1, 0, /* major, minor, patch */
+    ABI_CLASS_VIDEODRV,
+    ABI_VIDEODRV_VERSION,
+    MOD_CLASS_VIDEODRV,
+    {0, 0, 0, 0}
+};
+
+/*
+ * Xorg driver exported structures
+ */
+
+_X_EXPORT DriverRec modesetting = {
+    1,
+    "modesetting",
+    intel_xorg_identify,
+    NULL,
+    xorg_tracker_available_options,
+    NULL,
+    0,
+    NULL,
+    intel_xorg_device_match,
+    intel_xorg_pci_probe
+};
+
+static MODULESETUPPROTO(intel_xorg_setup);
+
+_X_EXPORT XF86ModuleData modesettingModuleData = {
+    &intel_xorg_version,
+    intel_xorg_setup,
+    NULL
+};
+
+/*
+ * Xorg driver functions
+ */
+
+static pointer
+intel_xorg_setup(pointer module, pointer opts, int *errmaj, int *errmin)
+{
+    static Bool setupDone = 0;
+
+    /* This module should be loaded only once, but check to be sure.
+     */
+    if (!setupDone) {
+	setupDone = 1;
+	xf86AddDriver(&modesetting, module, HaveDriverFuncs);
+
+	/*
+	 * Tell the loader about symbols from other modules that this module
+	 * might refer to.
+	 */
+	xorg_tracker_loader_ref_sym_lists();
+
+	/*
+	 * The return value must be non-NULL on success even though there
+	 * is no TearDownProc.
+	 */
+	return (pointer) 1;
+    } else {
+	if (errmaj)
+	    *errmaj = LDR_ONCEONLY;
+	return NULL;
+    }
+}
+
+static void
+intel_xorg_identify(int flags)
+{
+    xf86PrintChipsets("modesetting", "Driver for Modesetting Kernel Drivers",
+		      intel_xorg_chipsets);
+}
+
+static Bool
+intel_xorg_pci_probe(DriverPtr driver,
+	  int entity_num, struct pci_device *device, intptr_t match_data)
+{
+    ScrnInfoPtr scrn = NULL;
+    EntityInfoPtr entity;
+
+    scrn = xf86ConfigPciEntity(scrn, 0, entity_num, intel_xorg_pci_devices,
+			       NULL, NULL, NULL, NULL, NULL);
+    if (scrn != NULL) {
+	scrn->driverVersion = 1;
+	scrn->driverName = "modesetting";
+	scrn->name = "modesetting";
+	scrn->Probe = NULL;
+
+	entity = xf86GetEntityInfo(entity_num);
+
+	/* Use all the functions from the xorg tracker */
+	xorg_tracker_set_functions(scrn);
+    }
+    return scrn != NULL;
+}




More information about the mesa-commit mailing list