diff --git a/driver/xf86-video-tga/configure.ac b/driver/xf86-video-tga/configure.ac index 25882941a..b47a6d0e1 100644 --- a/driver/xf86-video-tga/configure.ac +++ b/driver/xf86-video-tga/configure.ac @@ -22,7 +22,7 @@ AC_PREREQ(2.57) AC_INIT([xf86-video-tga], - 1.1.0, + 1.2.0, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xf86-video-tga) @@ -59,6 +59,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/driver/xf86-video-tga/src/Makefile.am b/driver/xf86-video-tga/src/Makefile.am index 1555548d7..f3d050f2b 100644 --- a/driver/xf86-video-tga/src/Makefile.am +++ b/driver/xf86-video-tga/src/Makefile.am @@ -40,7 +40,8 @@ tga_drv_la_SOURCES = \ tga.h \ tga_line.c \ tga_seg.c \ - tga_regs.h + tga_regs.h \ + tga_pcirename.h tga_seg.c: $(srcdir)/tga_line.c echo "#define POLYSEGMENT" > tga_seg.c diff --git a/driver/xf86-video-tga/src/tga.h b/driver/xf86-video-tga/src/tga.h index 4c60606bd..94279141d 100644 --- a/driver/xf86-video-tga/src/tga.h +++ b/driver/xf86-video-tga/src/tga.h @@ -21,11 +21,12 @@ * * Authors: Alan Hourihane, */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tga/tga.h,v 1.17 2001/05/04 19:05:47 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tga/tga.h,v 1.18 2001/11/21 22:32:58 alanh Exp $ */ #ifndef _TGA_H_ #define _TGA_H_ +#include "tga_pcirename.h" #include "xaa.h" #include "xf86RamDac.h" @@ -33,12 +34,15 @@ typedef struct { unsigned long tgaRegs[0x100]; } TGARegRec, *TGARegPtr; +#define TGA_OLDPRIV (GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) < 4) #define TGAPTR(p) ((TGAPtr)((p)->driverPrivate)) typedef struct { pciVideoPtr PciInfo; +#ifndef XSERVER_LIBPCIACCESS PCITAG PciTag; +#endif int Chipset; RamDacHelperRecPtr RamDac; int ChipRev; diff --git a/driver/xf86-video-tga/src/tga_driver.c b/driver/xf86-video-tga/src/tga_driver.c index 5f6dc1ebc..b3b26ae97 100644 --- a/driver/xf86-video-tga/src/tga_driver.c +++ b/driver/xf86-video-tga/src/tga_driver.c @@ -22,7 +22,6 @@ * Authors: Alan Hourihane, * Matthew Grossman, - acceleration and misc fixes */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tga/tga_driver.c,v 1.60tsi Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -38,9 +37,6 @@ #include "xf86PciInfo.h" #include "xf86Pci.h" -/* module versioning */ -#include "xf86Version.h" - /* RAC stuff */ #include "xf86Resources.h" @@ -118,9 +114,9 @@ void TGASync(ScrnInfoPtr pScrn); #define TGA_VERSION 4000 #define TGA_NAME "TGA" #define TGA_DRIVER_NAME "tga" -#define TGA_MAJOR_VERSION 1 -#define TGA_MINOR_VERSION 1 -#define TGA_PATCHLEVEL 0 +#define TGA_MAJOR_VERSION PACKAGE_VERSION_MAJOR +#define TGA_MINOR_VERSION PACKAGE_VERSION_MINOR +#define TGA_PATCHLEVEL PACKAGE_VERSION_PATCHLEVEL /* * This contains the functions needed by the server after loading the driver @@ -371,6 +367,7 @@ TGAProbe(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. */ +#ifndef XSERVER_LIBPCIACCESS if (xf86GetPciVideoInfo() == NULL) { /* * We won't let anything in the config file override finding no @@ -378,6 +375,7 @@ TGAProbe(DriverPtr drv, int flags) */ return FALSE; } +#endif numUsed = xf86MatchPciInstances(TGA_NAME, PCI_VENDOR_DIGITAL, TGAChipsets, TGAPciChipsets, devSections, numDevSections, @@ -512,9 +510,11 @@ TGAPreInit(ScrnInfoPtr pScrn, int flags) if (pTga->pEnt->location.type == BUS_PCI) { pciPtr = xf86GetPciInfoForEntity(pTga->pEnt->index); pTga->PciInfo = pciPtr; +#ifndef XSERVER_LIBPCIACCESS pTga->PciTag = pciTag(pTga->PciInfo->bus, pTga->PciInfo->device, pTga->PciInfo->func); +#endif } else return FALSE; @@ -538,8 +538,10 @@ TGAPreInit(ScrnInfoPtr pScrn, int flags) from = X_PROBED; xf86DrvMsg(pScrn->scrnIndex, from, "Chipset: \"%s\"\n", pScrn->chipset); +#ifndef XSERVER_LIBPCIACCESS pTga->PciTag = pciTag(pTga->PciInfo->bus, pTga->PciInfo->device, pTga->PciInfo->func); +#endif @@ -672,7 +674,7 @@ TGAPreInit(ScrnInfoPtr pScrn, int flags) pTga->CardAddress = pTga->pEnt->device->MemBase; from = X_CONFIG; } else { - pTga->CardAddress = pTga->PciInfo->memBase[0] & 0xFFC00000;/*??*/ + pTga->CardAddress = PCI_REGION_BASE(pTga->PciInfo, 0, REGION_MEM) & 0xFFC00000;/*??*/ } pTga->FbAddress = pTga->CardAddress; @@ -708,17 +710,53 @@ TGAPreInit(ScrnInfoPtr pScrn, int flags) switch (pTga->Chipset) { case PCI_CHIP_TGA2: +#ifndef XSERVER_LIBPCIACCESS Base = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_MMIO_32BIT, pTga->PciTag, pTga->IOAddress, 0x1000); + +#else + { + void** result = (void**)&Base; + int err = pci_device_map_range(pTga->PciInfo, + pTga->IOAddress, + 0x1000, + PCI_DEV_MAP_FLAG_WRITABLE, + result); + if (err) + return FALSE; + } +#endif pTga->CardType = (*(unsigned int *)((char *)Base+TGA_REVISION_REG) >> 21) & 0x3; pTga->CardType ^= (pTga->CardType == 1) ? 0 : 3; + +#ifndef XSERVER_LIBPCIACCESS xf86UnMapVidMem(pScrn->scrnIndex, Base, 0x1000); +#else + pci_device_unmap_range(pTga->PciInfo, Base, 0x1000); +#endif break; case PCI_CHIP_DEC21030: +#ifndef XSERVER_LIBPCIACCESS Base = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_MMIO_32BIT, pTga->PciTag, pTga->FbAddress, 4); +#else + { + void** result = (void**)&Base; + int err = pci_device_map_range(pTga->PciInfo, + pTga->FbAddress, + 0x4, + PCI_DEV_MAP_FLAG_WRITABLE, + result); + if (err) + return FALSE; + } +#endif pTga->CardType = (*(unsigned int *)Base >> 12) & 0xf; +#ifndef XSERVER_LIBPCIACCESS xf86UnMapVidMem(pScrn->scrnIndex, Base, 4); +#else + pci_device_unmap_range(pTga->PciInfo, Base, 4); +#endif break; } } @@ -1008,34 +1046,87 @@ TGAMapMem(ScrnInfoPtr pScrn) /* TGA doesn't need a sparse memory mapping, because all register accesses are doublewords */ - + +#ifndef XSERVER_LIBPCIACCESS pTga->IOBase = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_MMIO_32BIT, pTga->PciTag, pTga->IOAddress, 0x100000); +#else + { + void** result = (void**)&pTga->IOBase; + int err = pci_device_map_range(pTga->PciInfo, + pTga->IOAddress, + 0x100000, + PCI_DEV_MAP_FLAG_WRITABLE, + result); + if (err) + return FALSE; + } +#endif if (pTga->IOBase == NULL) return FALSE; +#ifndef XSERVER_LIBPCIACCESS pTga->FbBase = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_FRAMEBUFFER, pTga->PciTag, (unsigned long)pTga->FbAddress, pTga->FbMapSize); +#else + { + void** result = (void**)&pTga->FbBase; + int err = pci_device_map_range(pTga->PciInfo, + pTga->FbAddress, + pTga->FbMapSize, + PCI_DEV_MAP_FLAG_WRITABLE | + PCI_DEV_MAP_FLAG_WRITE_COMBINE, + result); + if (err) + return FALSE; + } +#endif if (pTga->FbBase == NULL) return FALSE; if (pTga->Chipset == PCI_CHIP_DEC21030) return TRUE; +#ifndef XSERVER_LIBPCIACCESS pTga->ClkBase = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_MMIO_32BIT, pTga->PciTag, (unsigned long)pTga->CardAddress + TGA2_CLOCK_OFFSET, 0x10000); +#else + { + void** result = (void**)&pTga->ClkBase; + int err = pci_device_map_range(pTga->PciInfo, + pTga->CardAddress + TGA2_CLOCK_OFFSET, + 0x10000, + PCI_DEV_MAP_FLAG_WRITABLE, + result); + if (err) + return FALSE; + } +#endif if (pTga->ClkBase == NULL) return FALSE; +#ifndef XSERVER_LIBPCIACCESS pTga->DACBase = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_MMIO_32BIT, pTga->PciTag, (unsigned long)pTga->CardAddress + TGA2_RAMDAC_OFFSET, 0x10000); +#else + { + void** result = (void**)&pTga->DACBase; + int err = pci_device_map_range(pTga->PciInfo, + pTga->CardAddress + TGA2_RAMDAC_OFFSET, + 0x10000, + PCI_DEV_MAP_FLAG_WRITABLE, + result); + if (err) + return FALSE; + } +#endif if (pTga->DACBase == NULL) return FALSE; @@ -1053,10 +1144,25 @@ TGAMapMem(ScrnInfoPtr pScrn) * framebuffer memory in front of the normal mmap to prevent * SEGVs from happening. */ +#ifndef XSERVER_LIBPCIACCESS pTga->HACKBase = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_FRAMEBUFFER, pTga->PciTag, (unsigned long)pTga->FbAddress - getpagesize(), getpagesize()); +#else + { + void** result = (void**)&pTga->DACBase; + int err = pci_device_map_range(pTga->PciInfo, + pTga->FbAddress - getpagesize(), + getpagesize(), + PCI_DEV_MAP_FLAG_WRITABLE | + PCI_DEV_MAP_FLAG_WRITE_COMBINE, + result); + if (err) + return FALSE; + } +#endif + if (pTga->HACKBase == NULL) return FALSE; @@ -1075,22 +1181,42 @@ TGAUnmapMem(ScrnInfoPtr pScrn) pTga = TGAPTR(pScrn); +#ifndef XSERVER_LIBPCIACCESS xf86UnMapVidMem(pScrn->scrnIndex, (pointer)pTga->IOBase, 0x100000); +#else + pci_device_unmap_range(pTga->PciInfo, pTga->IOBase, 0x100000); +#endif pTga->IOBase = NULL; +#ifndef XSERVER_LIBPCIACCESS xf86UnMapVidMem(pScrn->scrnIndex, (pointer)pTga->FbBase, pTga->FbMapSize); +#else + pci_device_unmap_range(pTga->PciInfo, pTga->FbBase, pTga->FbMapSize); +#endif pTga->FbBase = NULL; if (pTga->Chipset == PCI_CHIP_DEC21030) return TRUE; +#ifndef XSERVER_LIBPCIACCESS xf86UnMapVidMem(pScrn->scrnIndex, (pointer)pTga->ClkBase, 0x10000); +#else + pci_device_unmap_range(pTga->PciInfo, pTga->ClkBase, 0x10000); +#endif pTga->ClkBase = NULL; +#ifndef XSERVER_LIBPCIACCESS xf86UnMapVidMem(pScrn->scrnIndex, (pointer)pTga->DACBase, 0x10000); +#else + pci_device_unmap_range(pTga->PciInfo, pTga->DACBase, 0x10000); +#endif pTga->DACBase = NULL; +#ifndef XSERVER_LIBPCIACCESS xf86UnMapVidMem(pScrn->scrnIndex, (pointer)pTga->HACKBase, getpagesize()); +#else + pci_device_unmap_range(pTga->PciInfo, pTga->HACKBase, getpagesize()); +#endif pTga->HACKBase = NULL; return TRUE; diff --git a/driver/xf86-video-tga/src/tga_line.c b/driver/xf86-video-tga/src/tga_line.c index c8b364980..5625c3196 100644 --- a/driver/xf86-video-tga/src/tga_line.c +++ b/driver/xf86-video-tga/src/tga_line.c @@ -416,7 +416,11 @@ TGAPolySegment( #endif ){ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC); +#if TGA_OLDPRIV XAAGCPtr pGCPriv = (XAAGCPtr) (pGC)->devPrivates[XAAGetGCIndex()].ptr; +#else + XAAGCPtr pGCPriv = (XAAGCPtr)dixLookupPrivate(&(pGC)->devPrivates, XAAGetGCKey()); +#endif BoxPtr pboxInit = REGION_RECTS(pGC->pCompositeClip); int nboxInit = REGION_NUM_RECTS(pGC->pCompositeClip); unsigned int bias = miGetZeroLineBias(pDrawable->pScreen); diff --git a/driver/xf86-video-tga/src/tga_pcirename.h b/driver/xf86-video-tga/src/tga_pcirename.h new file mode 100644 index 000000000..f0f5cf8fb --- /dev/null +++ b/driver/xf86-video-tga/src/tga_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 */