rpms/xorg-x11-drv-trident/devel trident-1.2.3-pciaccess.patch, NONE, 1.1 xorg-x11-drv-trident.spec, 1.19, 1.20

Dave Airlie (airlied) fedora-extras-commits at redhat.com
Tue Feb 19 07:52:12 UTC 2008


Author: airlied

Update of /cvs/pkgs/rpms/xorg-x11-drv-trident/devel
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv30502

Modified Files:
	xorg-x11-drv-trident.spec 
Added Files:
	trident-1.2.3-pciaccess.patch 
Log Message:
* Mon Feb 18 2008 Dave Airlie <airlied at redhat.com> - 1.2.3-7
- pciaccess support (#433254)


trident-1.2.3-pciaccess.patch:

--- NEW FILE trident-1.2.3-pciaccess.patch ---
>From a34c4ca7e1e8f2734aa443c0d597840f970e0eef Mon Sep 17 00:00:00 2001
From: Dave Airlie <airlied at redhat.com>
Date: Mon, 18 Feb 2008 16:51:10 +1000
Subject: [PATCH] initial trident pciaccess support

---
 configure.ac           |   13 +++++
 src/trident.h          |    2 +
 src/trident_driver.c   |   70 +++++++++++++++++++++++----
 src/tridentpcirename.h |  122 ++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 197 insertions(+), 10 deletions(-)
 create mode 100644 src/tridentpcirename.h

diff --git a/configure.ac b/configure.ac
index 815670e..45aea41 100644
--- a/configure.ac
+++ b/configure.ac
@@ -58,6 +58,19 @@ XORG_DRIVER_CHECK_EXT(XFreeXDGA, xf86dgaproto)
 PKG_CHECK_MODULES(XORG, [xorg-server >= 1.0.99.901 xproto fontsproto $REQUIRED_MODULES])
 sdkdir=$(pkg-config --variable=sdkdir xorg-server)
 
+SAVE_CPPFLAGS="$CPPFLAGS"
+CPPFLAGS="$CPPFLAGS $XORG_CFLAGS"
+AC_CHECK_DECL(XSERVER_LIBPCIACCESS,
+              [XSERVER_LIBPCIACCESS=yes],[XSERVER_LIBPCIACCESS=no],
+              [#include "xorg-server.h"])
+CPPFLAGS="$SAVE_CPPFLAGS"
+
+if test "x$XSERVER_LIBPCIACCESS" = xyes; then
+    PKG_CHECK_MODULES([PCIACCESS], [pciaccess >= 0.8.0])
+    XORG_CFLAGS="$XORG_CFLAGS $PCIACCESS_CFLAGS"
+fi
+AM_CONDITIONAL(XSERVER_LIBPCIACCESS, test "x$XSERVER_LIBPCIACCESS" = xyes)
+
 # Checks for libraries.
 
 # Checks for header files.
diff --git a/src/trident.h b/src/trident.h
index 48216dd..ceca43e 100644
--- a/src/trident.h
+++ b/src/trident.h
@@ -31,6 +31,8 @@
 #include <string.h>
 #include <math.h>
 
+#include "tridentpcirename.h"
+
 #include "exa.h"
 #include "xf86Cursor.h"
 #include "xaa.h"
diff --git a/src/trident_driver.c b/src/trident_driver.c
index df2260f..5be9ee9 100644
--- a/src/trident_driver.c
+++ b/src/trident_driver.c
@@ -937,7 +937,12 @@ TRIDENTProbe(DriverPtr drv, int flags)
      * All of the cards this driver supports are PCI, so the "probing" just
      * amounts to checking the PCI data that the server has already collected.
      */
-    if (xf86GetPciVideoInfo()) {
+#ifndef XSERVER_LIBPCIACCESS
+    if (xf86GetPciVideoInfo()== NULL) {
+	return FALSE;
+    }
+#endif
+    {
     	numUsed = xf86MatchPciInstances(TRIDENT_NAME, PCI_VENDOR_TRIDENT,
 		   TRIDENTChipsets, TRIDENTPciChipsets, devSections,
 		   numDevSections, drv, &usedChips);
@@ -1092,9 +1097,9 @@ TRIDENTPreInit(ScrnInfoPtr pScrn, int flags)
 	/* This driver can handle ISA and PCI buses */
 	if (pTrident->pEnt->location.type == BUS_PCI) {
 	    pTrident->PciInfo = xf86GetPciInfoForEntity(pTrident->pEnt->index);
-	    pTrident->PciTag = pciTag(pTrident->PciInfo->bus, 
-				  pTrident->PciInfo->device,
-				  pTrident->PciInfo->func);
+#ifndef XSERVER_LIBPCIACCESS
+	    pTrident->PciTag = PCI_DEV_TAG(pTrident->PciInfo);
+#endif
     	    pTrident->Linear = TRUE;
 	} else {
     	    pTrident->Linear = FALSE;
@@ -1491,7 +1496,7 @@ TRIDENTPreInit(ScrnInfoPtr pScrn, int flags)
 	    from = X_CONFIG;
     	} else {
     	    if (IsPciCard)
-	    	pTrident->FbAddress = pTrident->PciInfo->memBase[0]& 0xFFFFFFF0;
+	    	pTrident->FbAddress = PCI_REGION_BASE(pTrident->PciInfo, 0, REGION_MEM) & 0xFFFFFFF0;
 	    else
 	    	pTrident->FbAddress = 0xA0000;
     	}
@@ -1510,7 +1515,7 @@ TRIDENTPreInit(ScrnInfoPtr pScrn, int flags)
 	    from = X_CONFIG;
     	} else {
     	    if (IsPciCard)
-	    	pTrident->IOAddress = pTrident->PciInfo->memBase[1]& 0xFFFFC000;
+	    	pTrident->IOAddress = PCI_REGION_BASE(pTrident->PciInfo, 1, REGION_MEM) & 0xFFFFC000;
 	    else
 	    	/* FIXME - Multihead UNAWARE */
     	    	pTrident->IOAddress = 0xBF000;
@@ -1996,7 +2001,7 @@ TRIDENTPreInit(ScrnInfoPtr pScrn, int flags)
 	    pTrident->NewClockCode = TRUE;
 	    pTrident->frequency = NTSC;
 	    OUTB(0x3C4, 0x5D);
-	    if (pTrident->PciInfo->subsysVendor != 0x1023) {
+	    if (PCI_SUB_VENDOR_ID(pTrident->PciInfo) != 0x1023) {
 	    	chipset = "CyberBladeXP";
 	    	pTrident->IsCyber = TRUE;
 	    } else
@@ -2542,12 +2547,32 @@ TRIDENTMapMem(ScrnInfoPtr pScrn)
     if (Is3Dchip) mapsize = 0x20000;
 
     if (IsPciCard && UseMMIO)
+#ifndef XSERVER_LIBPCIACCESS
     	pTrident->IOBase = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_MMIO, 
 		pTrident->PciTag, pTrident->IOAddress, mapsize);
+#else
+	{
+		void **result = (void **)&pTrident->IOBase;
+		int err = pci_device_map_range(pTrident->PciInfo,
+						pTrident->IOAddress,
+						mapsize,
+						PCI_DEV_MAP_FLAG_WRITABLE,
+						result);
+		if (err) {
+			xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+				"Unable to map IO aperture. %s (%d)\n",
+				strerror(err), err);
+		}
+	}
+#endif
     else {
+#ifndef XSERVER_LIBPCIACCESS
     	pTrident->IOBase = xf86MapDomainMemory(pScrn->scrnIndex, VIDMEM_MMIO, 
 		pTrident->PciTag, pTrident->IOAddress, 0x1000);
     	pTrident->IOBase += 0xF00;
+#else
+	return FALSE;
+#endif
     }
 
     if (pTrident->IOBase == NULL)
@@ -2555,11 +2580,28 @@ TRIDENTMapMem(ScrnInfoPtr pScrn)
 
     if (pTrident->Linear) {
         if (pTrident->FbMapSize != 0) {
+#ifndef XSERVER_LIBPCIACCESS
 	    pTrident->FbBase = xf86MapPciMem(pScrn->scrnIndex, 
 				VIDMEM_FRAMEBUFFER,
 				 pTrident->PciTag,
 				 (unsigned long)pTrident->FbAddress,
 				 pTrident->FbMapSize);
+#else
+	    {
+		void **result = (void **)&pTrident->FbBase;
+		int err = pci_device_map_range(pTrident->PciInfo,
+						pTrident->FbAddress,
+						pTrident->FbMapSize,
+						PCI_DEV_MAP_FLAG_WRITABLE |
+						PCI_DEV_MAP_FLAG_WRITE_COMBINE,
+						result);
+		if (err) {
+			xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+				"Unable to map VRAM aperture. %s (%d)\n",
+				strerror(err), err);
+		}
+	    }
+#endif
 	    if (pTrident->FbBase == NULL)
 		return FALSE;
     	}
@@ -2585,19 +2627,27 @@ TRIDENTUnmapMem(ScrnInfoPtr pScrn)
     /*
      * Unmap IO registers to virtual address space
      */ 
-    if (IsPciCard && UseMMIO) 
+#ifdef XSERVER_LIBPCIACCESS
+    pci_device_unmap_range(pTrident->PciInfo, (pointer)pTrident->IOBase, mapsize);
+#else
+    if (IsPciCard && UseMMIO) {
     	xf86UnMapVidMem(pScrn->scrnIndex, (pointer)pTrident->IOBase, mapsize);
-    else {
+    } else {
     	pTrident->IOBase -= 0xF00;
     	xf86UnMapVidMem(pScrn->scrnIndex, (pointer)pTrident->IOBase, 0x1000);
     }
+#endif
     pTrident->IOBase = NULL;
 
     if (pTrident->Linear) {
     	if (pTrident->FbMapSize != 0) {
+#ifdef XSERVER_LIBPCIACCESS
+	    pci_device_unmap_range(pTrident->PciInfo, (pointer)pTrident->FbBase, pTrident->FbMapSize);
+#else
     	    xf86UnMapVidMem(pScrn->scrnIndex, (pointer)pTrident->FbBase, 
 							pTrident->FbMapSize);
-    	pTrident->FbBase = NULL;
+#endif
+	    pTrident->FbBase = NULL;
         }
     }
 
diff --git a/src/tridentpcirename.h b/src/tridentpcirename.h
new file mode 100644
index 0000000..c93988a
--- /dev/null
+++ b/src/tridentpcirename.h
@@ -0,0 +1,122 @@
+/*
+ * Copyright 2007 George Sapountzis
+ *
+ * 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.
+ */
+
+/**
+ * Macros for porting drivers from legacy xfree86 PCI code to the pciaccess
+ * library. The main purpose being to facilitate source code compatibility.
+ */
+
+#ifndef TRIDENTPCIRENAME_H
+#define TRIDENTPCIRENAME_H
+
+enum region_type {
+    REGION_MEM,
+    REGION_IO 
+};
+
+#ifndef XSERVER_LIBPCIACCESS
+
+/* pciVideoPtr */
+#define PCI_DEV_VENDOR_ID(_pcidev) ((_pcidev)->vendor)
+#define PCI_DEV_DEVICE_ID(_pcidev) ((_pcidev)->chipType)
+#define PCI_DEV_REVISION(_pcidev)  ((_pcidev)->chipRev)
+
+#define PCI_SUB_VENDOR_ID(_pcidev) ((_pcidev)->subsysVendor)
+#define PCI_SUB_DEVICE_ID(_pcidev) ((_pcidev)->subsysCard)
+
+#define PCI_DEV_TAG(_pcidev) pciTag((_pcidev)->bus,    \
+                                    (_pcidev)->device, \
+                                    (_pcidev)->func)
+#define PCI_DEV_BUS(_pcidev)       ((_pcidev)->bus)
+#define PCI_DEV_DEV(_pcidev)       ((_pcidev)->device)
+#define PCI_DEV_FUNC(_pcidev)      ((_pcidev)->func)
+
+/* pciConfigPtr */
+#define PCI_CFG_TAG(_pcidev)  (((pciConfigPtr)(_pcidev)->thisCard)->tag)
+#define PCI_CFG_BUS(_pcidev)  (((pciConfigPtr)(_pcidev)->thisCard)->busnum)
+#define PCI_CFG_DEV(_pcidev)  (((pciConfigPtr)(_pcidev)->thisCard)->devnum)
+#define PCI_CFG_FUNC(_pcidev) (((pciConfigPtr)(_pcidev)->thisCard)->funcnum)
+
+/* region addr: xfree86 uses different fields for memory regions and I/O ports */
+#define PCI_REGION_BASE(_pcidev, _b, _type)             \
+    (((_type) == REGION_MEM) ? (_pcidev)->memBase[(_b)] \
+                             : (_pcidev)->ioBase[(_b)])
+
+/* region size: xfree86 uses the log2 of the region size,
+ * but with zero meaning no region, not size of one XXX */
+#define PCI_REGION_SIZE(_pcidev, _b) \
+    (((_pcidev)->size[(_b)] > 0) ? (1 << (_pcidev)->size[(_b)]) : 0)
+
+/* read/write PCI configuration space */
+#define PCI_READ_BYTE(_pcidev, _value_ptr, _offset) \
+    *(_value_ptr) = pciReadByte(PCI_CFG_TAG(_pcidev), (_offset))
+
+#define PCI_READ_LONG(_pcidev, _value_ptr, _offset) \
+    *(_value_ptr) = pciReadLong(PCI_CFG_TAG(_pcidev), (_offset))
+
+#define PCI_WRITE_LONG(_pcidev, _value, _offset) \
+    pciWriteLong(PCI_CFG_TAG(_pcidev), (_offset), (_value))
+
+#else /* XSERVER_LIBPCIACCESS */
+
+typedef struct pci_device *pciVideoPtr;
+
+#define PCI_DEV_VENDOR_ID(_pcidev) ((_pcidev)->vendor_id)
+#define PCI_DEV_DEVICE_ID(_pcidev) ((_pcidev)->device_id)
+#define PCI_DEV_REVISION(_pcidev)  ((_pcidev)->revision)
+
+#define PCI_SUB_VENDOR_ID(_pcidev) ((_pcidev)->subvendor_id)
+#define PCI_SUB_DEVICE_ID(_pcidev) ((_pcidev)->subdevice_id)
+
+/* pci-rework functions take a 'pci_device' parameter instead of a tag */
+#define PCI_DEV_TAG(_pcidev)        (_pcidev)
+
+/* PCI_DEV macros, typically used in printf's, add domain ? XXX */
+#define PCI_DEV_BUS(_pcidev)       ((_pcidev)->bus)
+#define PCI_DEV_DEV(_pcidev)       ((_pcidev)->dev)
+#define PCI_DEV_FUNC(_pcidev)      ((_pcidev)->func)
+
+/* pci-rework functions take a 'pci_device' parameter instead of a tag */
+#define PCI_CFG_TAG(_pcidev)        (_pcidev)
+
+/* PCI_CFG macros, typically used in DRI init, contain the domain */
+#define PCI_CFG_BUS(_pcidev)      (((_pcidev)->domain << 8) | \
+                                    (_pcidev)->bus)
+#define PCI_CFG_DEV(_pcidev)       ((_pcidev)->dev)
+#define PCI_CFG_FUNC(_pcidev)      ((_pcidev)->func)
+
+#define PCI_REGION_BASE(_pcidev, _b, _type) ((_pcidev)->regions[(_b)].base_addr)
+#define PCI_REGION_SIZE(_pcidev, _b)        ((_pcidev)->regions[(_b)].size)
+
+#define PCI_READ_BYTE(_pcidev, _value_ptr, _offset) \
+    pci_device_cfg_read_u8((_pcidev), (_value_ptr), (_offset))
+
+#define PCI_READ_LONG(_pcidev, _value_ptr, _offset) \
+    pci_device_cfg_read_u32((_pcidev), (_value_ptr), (_offset))
+
+#define PCI_WRITE_LONG(_pcidev, _value, _offset) \
+    pci_device_cfg_write_u32((_pcidev), (_value), (_offset))
+
+#endif /* XSERVER_LIBPCIACCESS */
+
+#endif /* TRIDENTPCIRENAME_H */
-- 
1.5.3.7



Index: xorg-x11-drv-trident.spec
===================================================================
RCS file: /cvs/pkgs/rpms/xorg-x11-drv-trident/devel/xorg-x11-drv-trident.spec,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- xorg-x11-drv-trident.spec	23 Aug 2007 18:38:24 -0000	1.19
+++ xorg-x11-drv-trident.spec	19 Feb 2008 07:51:35 -0000	1.20
@@ -5,7 +5,7 @@
 Summary:   Xorg X11 trident video driver
 Name:      xorg-x11-drv-trident
 Version:   1.2.3
-Release:   6%{?dist}
+Release:   7%{?dist}
 URL:       http://www.x.org
 License: MIT
 Group:     User Interface/X Hardware Support
@@ -15,6 +15,7 @@
 Source1:   trident.xinf
 
 Patch0:    trident-1.2.3-dead-file.patch
+Patch1:    trident-1.2.3-pciaccess.patch
 
 ExcludeArch: s390 s390x
 
@@ -30,6 +31,7 @@
 %prep
 %setup -q -n %{tarball}-%{version}
 %patch0 -p1 -b .dead-file
+%patch1 -p1 -b .pciaccess
 
 %build
 autoreconf -v --install
@@ -58,6 +60,9 @@
 %{_mandir}/man4/trident.4*
 
 %changelog
+* Mon Feb 18 2008 Dave Airlie <airlied at redhat.com> - 1.2.3-7
+- pciaccess support (#433254)
+
 * Thu Aug 23 2007 Adam Jackson <ajax at redhat.com> - 1.2.3-6
 - Rebuild for ppc toolchain bug
 




More information about the fedora-extras-commits mailing list