rpms/xorg-x11-drv-tseng/devel tseng-pciaccess.patch, NONE, 1.1 xorg-x11-drv-tseng.spec, 1.17, 1.18

Dave Airlie (airlied) fedora-extras-commits at redhat.com
Mon Mar 10 04:55:34 UTC 2008


Author: airlied

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

Modified Files:
	xorg-x11-drv-tseng.spec 
Added Files:
	tseng-pciaccess.patch 
Log Message:
* Mon Mar 10 2008 Dave Airlie <airlied at redhat.com> 1.1.0-9
- pciaccess conversion


tseng-pciaccess.patch:

--- NEW FILE tseng-pciaccess.patch ---
diff --git a/configure.ac b/configure.ac
index dd17541..e47d253 100644
--- a/configure.ac
+++ b/configure.ac
@@ -62,6 +62,20 @@ PKG_CHECK_MODULES(XORG, [xorg-server >= 1.0.99.901 xproto fontsproto $REQUIRED_M
 sdkdir=$(pkg-config --variable=sdkdir xorg-server)
 
 # Checks for libraries.
+SAVE_CPPFLAGS="$CPPFLAGS"
+CPPFLAGS="$CPPFLAGS $XORG_CFLAGS"
+AC_CHECK_DECL(XSERVER_LIBPCIACCESS,
+              [XSERVER_LIBPCIACCESS=yes],[XSERVER_LIBPCIACCESS=no],
+              [#include "xorg-server.h"])
+AC_CHECK_HEADER(xf1bpp.h,[AC_DEFINE(HAVE_XF1BPP, 1, [Have 1bpp support])],[])
+AC_CHECK_HEADER(xf4bpp.h,[AC_DEFINE(HAVE_XF4BPP, 1, [Have 4bpp support])],[])
+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 header files.
 AC_HEADER_STDC
diff --git a/src/tseng.h b/src/tseng.h
index ec3c461..c83883d 100644
--- a/src/tseng.h
+++ b/src/tseng.h
@@ -4,6 +4,7 @@
 #ifndef _TSENG_H
 #define _TSENG_H
 
+#include "tseng_pcirename.h"
 #include <string.h>
 
 /* All drivers should typically include these */
@@ -35,8 +36,12 @@
 #include "micmap.h"
 
 /* Needed for the 1 and 4 bpp framebuffers */
+#ifdef HAVE_XF1BPP
 #include "xf1bpp.h"
+#endif
+#ifdef HAVE_XF4BPP
 #include "xf4bpp.h"
+#endif
 #include "fb.h"
 
 /* Drivers using the XAA interface ... */
@@ -106,7 +111,9 @@ typedef struct {
     unsigned char *BresenhamTable;
     /* normal stuff starts here */
     pciVideoPtr PciInfo;
+#ifndef XSERVER_LIBPCIACCESS
     PCITAG PciTag;
+#endif
 
     Bool UsePCIRetry;		       /* Do we use PCI-retry or busy-waiting */
     Bool UseAccel;		       /* Do we use the XAA acceleration architecture */
diff --git a/src/tseng_driver.c b/src/tseng_driver.c
index cdfe3d7..2c70dc4 100644
--- a/src/tseng_driver.c
+++ b/src/tseng_driver.c
@@ -417,9 +417,11 @@ TsengProbe(DriverPtr drv, int flags)
 	return FALSE;
     }
 
+#ifndef XSERVER_LIBPCIACCESS
     /* PCI only driver now. */
     if (!xf86GetPciVideoInfo())
         return FALSE;
+#endif
 
     /* XXX maybe this can go some time soon */
     /*
@@ -476,7 +478,7 @@ TsengPreInitPCI(ScrnInfoPtr pScrn)
     /* Set up ChipType, ChipRev and pScrn->chipset.
      * This last one is usually not done manually, but
      * it's for informative use only anyway. */
-    switch (pTseng->PciInfo->chipType) {
+    switch (PCI_DEV_DEVICE_ID(pTseng->PciInfo)) {
     case PCI_CHIP_ET4000_W32P_A:
 	pTseng->ChipType = ET4000;
 	pTseng->ChipRev = REV_A;
@@ -500,7 +502,7 @@ TsengPreInitPCI(ScrnInfoPtr pScrn)
     case PCI_CHIP_ET6000:
 	pTseng->ChipType = ET6000;
 
-        if (pTseng->PciInfo->chipRev < 0x70) {
+        if (PCI_DEV_REVISION(pTseng->PciInfo) < 0x70) {
             pScrn->chipset = "ET6000";
             pTseng->ChipRev = REV_ET6000;
         } else {
@@ -510,24 +512,26 @@ TsengPreInitPCI(ScrnInfoPtr pScrn)
 	break;
     default:
 	xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Unknown Tseng PCI ID: %X\n",
-                   pTseng->PciInfo->chipType);
+                   PCI_DEV_DEVICE_ID(pTseng->PciInfo));
 	return FALSE;
     }
 
     xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "Chipset: \"%s\"\n", pScrn->chipset);
 
+#ifndef XSERVER_LIBPCIACCESS
     pTseng->PciTag = pciTag(pTseng->PciInfo->bus, pTseng->PciInfo->device,
 	pTseng->PciInfo->func);
+#endif
 
     /* only the ET6000 implements a PCI IO address */
     if (pTseng->ChipType == ET6000) {
-        if (!pTseng->PciInfo->ioBase[1]) {
+        if (!PCI_REGION_BASE(pTseng->PciInfo, 1, REGION_IO)) {
             xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
                        "No valid PCI I/O address in PCI config space\n");
             return FALSE;
         }
 
-        pTseng->ET6000IOAddress = pTseng->PciInfo->ioBase[1];
+        pTseng->ET6000IOAddress = PCI_REGION_BASE(pTseng->PciInfo, 1, REGION_IO);
         
         xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "ET6000 PCI I/O registers at 0x%lX\n",
                    (unsigned long)pTseng->ET6000IOAddress);
@@ -942,12 +946,12 @@ TsengGetFbAddress(ScrnInfoPtr pScrn)
     PDEBUG("	TsengGetFbAddress\n");
 
     /* base0 is the framebuffer and base1 is the PCI IO space. */
-    if (!pTseng->PciInfo->memBase[0]) {
+    if (PCI_REGION_BASE(pTseng->PciInfo, 0, REGION_MEM)) {
         xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
                    "No valid Framebuffer address in PCI config space;\n");
         return FALSE;
     } else
-        pTseng->FbAddress = pTseng->PciInfo->memBase[0];
+        pTseng->FbAddress = PCI_REGION_BASE(pTseng->PciInfo, 0, REGION_MEM);
 
 
     if (xf86RegisterResources(pTseng->pEnt->index,NULL,ResNone)) {
@@ -1233,6 +1237,7 @@ TsengPreInit(ScrnInfoPtr pScrn, int flags)
 
     /* Load bpp-specific modules */
     switch (pScrn->bitsPerPixel) {
+#ifdef HAVE_XF1BPP
     case 1:
 	if (xf86LoadSubModule(pScrn, "xf1bpp") == NULL) {
 	  TsengFreeRec(pScrn);
@@ -1240,6 +1245,8 @@ TsengPreInit(ScrnInfoPtr pScrn, int flags)
 	}
 	xf86LoaderReqSymbols("xf1bppScreenInit", NULL);
 	break;
+#endif
+#ifdef HAVE_XF4BPP
     case 4:
 	if (xf86LoadSubModule(pScrn, "xf4bpp") == NULL) {
 	  TsengFreeRec(pScrn);
@@ -1247,6 +1254,7 @@ TsengPreInit(ScrnInfoPtr pScrn, int flags)
 	}
 	xf86LoaderReqSymbols("xf4bppScreenInit", NULL);
 	break;
+#endif
     default:
 	if (xf86LoadSubModule(pScrn, "fb") == NULL) {
 	  TsengFreeRec(pScrn);
@@ -1451,18 +1459,22 @@ TsengScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
      */
 
     switch (pScrn->bitsPerPixel) {
+#ifdef HAVE_XF1BPP
     case 1:
 	ret = xf1bppScreenInit(pScreen, pTseng->FbBase,
 			pScrn->virtualX, pScrn->virtualY,
 			pScrn->xDpi, pScrn->yDpi,
 			pScrn->displayWidth);
 	break;
+#endif
+#ifdef HAVE_XF4BPP
     case 4:
 	ret = xf4bppScreenInit(pScreen, pTseng->FbBase,
 			pScrn->virtualX, pScrn->virtualY,
 			pScrn->xDpi, pScrn->yDpi,
 			pScrn->displayWidth);
 	break;
+#endif
     default:
         ret  = fbScreenInit(pScreen, pTseng->FbBase,
 			pScrn->virtualX, pScrn->virtualY,
@@ -1680,10 +1692,25 @@ TsengMapMem(ScrnInfoPtr pScrn)
 	return FALSE;
     }
 
+#ifndef XSERVER_LIBPCIACCESS
     pTseng->FbBase = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_FRAMEBUFFER,
                                    pTseng->PciTag,
                                    (unsigned long)pTseng->FbAddress,
                                    pTseng->FbMapSize);
+#else
+    {
+      void** result = (void**)&pTseng->FbBase;
+      int err = pci_device_map_range(pTseng->PciInfo,
+				     pTseng->FbAddress,
+				     pTseng->FbMapSize,
+				     PCI_DEV_MAP_FLAG_WRITABLE |
+				     PCI_DEV_MAP_FLAG_WRITE_COMBINE,
+				     result);
+      
+      if (err) 
+	return FALSE;
+    }
+#endif
     if (pTseng->FbBase == NULL) {
         xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
                    "Could not mmap linear video memory.\n");
@@ -1692,10 +1719,14 @@ TsengMapMem(ScrnInfoPtr pScrn)
 
     /* need some sanity here */
     if (pTseng->UseAccel) {
+#ifndef XSERVER_LIBPCIACCESS
         pTseng->MMioBase = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_MMIO,
                                          pTseng->PciTag,
                                          (unsigned long)pTseng->FbAddress,
                                          pTseng->FbMapSize);
+#else
+	pTseng->MMioBase = pTseng->FbBase;
+#endif
         if (!pTseng->MMioBase) {
 	    xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
 		       "Could not mmap mmio memory.\n");
@@ -1717,7 +1748,11 @@ TsengUnmapMem(ScrnInfoPtr pScrn)
 
     PDEBUG("	TsengUnmapMem\n");
 
+#ifndef XSERVER_LIBPCIACCESS
     xf86UnMapVidMem(pScrn->scrnIndex, (pointer) pTseng->FbBase, pTseng->FbMapSize);
+#else
+    pci_device_unmap_range(pTseng->PciInfo, pTseng->FbBase, pTseng->FbMapSize);
+#endif
 
     vgaHWUnmapMem(pScrn);
 
diff --git a/src/tseng_pcirename.h b/src/tseng_pcirename.h
new file mode 100644
index 0000000..f0f5cf8
--- /dev/null
+++ b/src/tseng_pcirename.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 CIRPCIRENAME_H
+#define CIRPCIRENAME_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 /* CIRPCIRENAME_H */


Index: xorg-x11-drv-tseng.spec
===================================================================
RCS file: /cvs/pkgs/rpms/xorg-x11-drv-tseng/devel/xorg-x11-drv-tseng.spec,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- xorg-x11-drv-tseng.spec	20 Feb 2008 07:52:01 -0000	1.17
+++ xorg-x11-drv-tseng.spec	10 Mar 2008 04:54:44 -0000	1.18
@@ -5,7 +5,7 @@
 Summary:   Xorg X11 tseng video driver
 Name:      xorg-x11-drv-tseng
 Version:   1.1.0
-Release:   8%{?dist}
+Release:   9%{?dist}
 URL:       http://www.x.org
 License: MIT
 Group:     User Interface/X Hardware Support
@@ -15,9 +15,11 @@
 Source1:   tseng.xinf
 
 Patch0: tseng-1.1.0-defaultdepth.patch
+Patch1: tseng-pciaccess.patch
 
 ExcludeArch: s390 s390x
 
+BuildRequires: automake autoconf libtool
 BuildRequires: xorg-x11-server-sdk >= 1.3.0.0-6
 
 Requires:  hwdata
@@ -29,8 +31,10 @@
 %prep
 %setup -q -n %{tarball}-%{version}
 %patch0 -p1 -b .defaultdepth
+%patch1 -p1 -b .pciaccess
 
 %build
+autoreconf -v --install
 %configure --disable-static
 make
 
@@ -56,6 +60,9 @@
 %{_mandir}/man4/tseng.4*
 
 %changelog
+* Mon Mar 10 2008 Dave Airlie <airlied at redhat.com> 1.1.0-9
+- pciaccess conversion
+
 * Wed Feb 20 2008 Fedora Release Engineering <rel-eng at fedoraproject.org> - 1.1.0-8
 - Autorebuild for GCC 4.3
 




More information about the fedora-extras-commits mailing list