summaryrefslogtreecommitdiff
path: root/src/tga_driver.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/tga_driver.c')
-rw-r--r--src/tga_driver.c134
1 files changed, 132 insertions, 2 deletions
diff --git a/src/tga_driver.c b/src/tga_driver.c
index 3722a9a..acdf16b 100644
--- a/src/tga_driver.c
+++ b/src/tga_driver.c
@@ -371,6 +371,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 +379,7 @@ TGAProbe(DriverPtr drv, int flags)
*/
return FALSE;
}
+#endif
numUsed = xf86MatchPciInstances(TGA_NAME, PCI_VENDOR_DIGITAL,
TGAChipsets, TGAPciChipsets, devSections, numDevSections,
@@ -512,9 +514,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 +542,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 +678,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 +714,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 +1050,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 +1148,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 +1185,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;