summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac10
-rw-r--r--src/Makefile.am7
-rw-r--r--src/ati.c62
-rw-r--r--src/atidri.c25
-rw-r--r--src/atimach64probe.c2
-rw-r--r--src/atipcirename.h110
-rw-r--r--src/atipreinit.c126
-rw-r--r--src/atiprint.c10
-rw-r--r--src/atiprobe.c75
-rw-r--r--src/atistruct.h2
-rw-r--r--src/atividmem.c122
-rw-r--r--src/r128_probe.c2
-rw-r--r--src/radeon_probe.c2
13 files changed, 423 insertions, 132 deletions
diff --git a/configure.ac b/configure.ac
index 7204a314..c662168e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -204,10 +204,20 @@ AC_CHECK_DECL(xf86XVFillKeyHelperDrawable,
[],
[#include <xf86xv.h>])
+AC_CHECK_DECL(XSERVER_LIBPCIACCESS,
+ [XSERVER_LIBPCIACCESS=yes],[XSERVER_LIBPCIACCESS=no],
+ [#include "xorg-server.h"])
+
CPPFLAGS="$SAVE_CPPFLAGS"
AM_CONDITIONAL(USE_EXA, test "x$USE_EXA" = xyes)
+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)
+
AC_SUBST([XORG_CFLAGS])
AC_SUBST([DRI_CFLAGS])
AC_SUBST([moduledir])
diff --git a/src/Makefile.am b/src/Makefile.am
index 709b98c2..16cbb660 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -66,6 +66,9 @@ atimisc_drv_la_SOURCES = \
atiload.c atimisc.c atimach64probe.c $(ATIMISC_CPIO_SOURCES) \
$(ATIMISC_DGA_SOURCES) $(ATIMISC_DRI_SRCS) $(ATIMISC_EXA_SOURCES)
+if XSERVER_LIBPCIACCESS
+# r128, radeon and theatre have not been ported yet
+else
r128_drv_la_LTLIBRARIES = r128_drv.la
r128_drv_la_LDFLAGS = -module -avoid-version
r128_drv_ladir = @moduledir@/drivers
@@ -103,6 +106,7 @@ theatre200_drv_la_CFLAGS = \
$(AM_CFLAGS) -DMICROC_DIR=\"$(theatre200_drv_ladir)\"
theatre200_drv_la_SOURCES = \
theatre200.c theatre200_module.c
+endif
EXTRA_DIST = \
atimach64render.c \
@@ -186,4 +190,5 @@ EXTRA_DIST = \
theatre_detect.h \
theatre.h \
theatre_reg.h \
- atipciids.h
+ atipciids.h \
+ atipcirename.h
diff --git a/src/ati.c b/src/ati.c
index 423fd95a..ada165f1 100644
--- a/src/ati.c
+++ b/src/ati.c
@@ -57,6 +57,11 @@
#include "config.h"
#endif
+#ifdef XSERVER_LIBPCIACCESS
+#include <pciaccess.h>
+#endif
+#include "atipcirename.h"
+
#include "ati.h"
#include "atimodule.h"
#include "ativersion.h"
@@ -65,6 +70,22 @@
#include "radeon_probe.h"
#include "r128_probe.h"
+#ifdef XSERVER_LIBPCIACCESS
+static const struct pci_id_match ati_device_match = {
+ PCI_VENDOR_ATI, PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, 0, 0, 0
+};
+
+/* Stolen from xf86pciBus.c */
+/* PCI classes that get included in xf86PciVideoInfo */
+#define PCIINFOCLASSES(c) \
+ ( (((c) & 0x00ff0000) == (PCI_CLASS_PREHISTORIC << 16)) || \
+ (((c) & 0x00ff0000) == (PCI_CLASS_DISPLAY << 16)) || \
+ ((((c) & 0x00ffff00) == ((PCI_CLASS_MULTIMEDIA << 16) | \
+ (PCI_SUBCLASS_MULTIMEDIA_VIDEO << 8)))) || \
+ ((((c) & 0x00ffff00) == ((PCI_CLASS_PROCESSOR << 16) | \
+ (PCI_SUBCLASS_PROCESSOR_COPROC << 8)))) )
+#endif
+
/*
* ATIIdentify --
*
@@ -99,11 +120,17 @@ ATIProbe
)
{
pciVideoPtr pVideo;
+#ifndef XSERVER_LIBPCIACCESS
pciVideoPtr *xf86PciVideoInfo;
+#else
+ struct pci_device_iterator *pVideoIter;
+#endif
Bool DoMach64 = FALSE;
Bool DoRage128 = FALSE, DoRadeon = FALSE;
ATIChipType Chip;
+#ifndef XSERVER_LIBPCIACCESS
+
xf86PciVideoInfo = xf86GetPciVideoInfo();
if (xf86PciVideoInfo == NULL)
@@ -111,12 +138,37 @@ ATIProbe
while ((pVideo = *xf86PciVideoInfo++) != NULL)
{
- if ((pVideo->vendor != PCI_VENDOR_ATI) ||
- (pVideo->chipType == PCI_CHIP_MACH32))
+ if ((PCI_DEV_VENDOR_ID(pVideo) != PCI_VENDOR_ATI) ||
+ (PCI_DEV_DEVICE_ID(pVideo) == PCI_CHIP_MACH32))
+ continue;
+
+ /* Check for Rage128's, Radeon's and later adapters */
+ Chip = ATIChipID(PCI_DEV_DEVICE_ID(pVideo), PCI_DEV_REVISION(pVideo));
+ if (Chip <= ATI_CHIP_Mach64)
+ DoMach64 = TRUE;
+ else if (Chip <= ATI_CHIP_Rage128)
+ DoRage128 = TRUE;
+ else if (Chip <= ATI_CHIP_Radeon)
+ DoRadeon = TRUE;
+ }
+
+#else /* XSERVER_LIBPCIACCESS */
+
+ pVideoIter = pci_id_match_iterator_create(&ati_device_match);
+
+ while ((pVideo = pci_device_next(pVideoIter)) != NULL)
+ {
+ /* Check for non-video devices */
+ if (!PCIINFOCLASSES(pVideo->device_class))
+ continue;
+
+ /* Check for prehistoric PCI Mach32 */
+ if ((PCI_DEV_VENDOR_ID(pVideo) != PCI_VENDOR_ATI) ||
+ (PCI_DEV_DEVICE_ID(pVideo) == PCI_CHIP_MACH32))
continue;
/* Check for Rage128's, Radeon's and later adapters */
- Chip = ATIChipID(pVideo->chipType, pVideo->chipRev);
+ Chip = ATIChipID(PCI_DEV_DEVICE_ID(pVideo), PCI_DEV_REVISION(pVideo));
if (Chip <= ATI_CHIP_Mach64)
DoMach64 = TRUE;
else if (Chip <= ATI_CHIP_Rage128)
@@ -125,6 +177,10 @@ ATIProbe
DoRadeon = TRUE;
}
+ pci_iterator_destroy(pVideoIter);
+
+#endif /* XSERVER_LIBPCIACCESS */
+
/* Call Radeon driver probe */
if (DoRadeon)
{
diff --git a/src/atidri.c b/src/atidri.c
index 07adda7d..bc862a89 100644
--- a/src/atidri.c
+++ b/src/atidri.c
@@ -774,8 +774,8 @@ static Bool ATIDRISetAgpMode( ScreenPtr pScreen )
xf86DrvMsg( pScreen->myNum, X_INFO,
"[agp] Mode 0x%08lx [AGP 0x%04x/0x%04x; Card 0x%04x/0x%04x]\n",
mode, vendor, device,
- pATI->PCIInfo->vendor,
- pATI->PCIInfo->chipType );
+ PCI_DEV_VENDOR_ID(pATI->PCIInfo),
+ PCI_DEV_DEVICE_ID(pATI->PCIInfo) );
if ( drmAgpEnable( pATI->drmFD, mode ) < 0 ) {
xf86DrvMsg( pScreen->myNum, X_ERROR, "[agp] AGP not enabled\n" );
@@ -1134,18 +1134,15 @@ static Bool ATIDRIIrqInit( ScreenPtr pScreen )
if ( pATI->irq <= 0 ) {
pATI->irq = drmGetInterruptFromBusID(pATI->drmFD,
- ((pciConfigPtr)pATI->PCIInfo
- ->thisCard)->busnum,
- ((pciConfigPtr)pATI->PCIInfo
- ->thisCard)->devnum,
- ((pciConfigPtr)pATI->PCIInfo
- ->thisCard)->funcnum);
+ PCI_CFG_BUS(pATI->PCIInfo),
+ PCI_CFG_DEV(pATI->PCIInfo),
+ PCI_CFG_FUNC(pATI->PCIInfo));
if ( pATI->irq <= 0 ) {
xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR,
"[drm] Couldn't find IRQ for bus id %d:%d:%d\n",
- ((pciConfigPtr)pATI->PCIInfo->thisCard)->busnum,
- ((pciConfigPtr)pATI->PCIInfo->thisCard)->devnum,
- ((pciConfigPtr)pATI->PCIInfo->thisCard)->funcnum);
+ PCI_CFG_BUS(pATI->PCIInfo),
+ PCI_CFG_DEV(pATI->PCIInfo),
+ PCI_CFG_FUNC(pATI->PCIInfo));
pATI->irq = 0;
} else if ((drmCtlInstHandler(pATI->drmFD, pATI->irq)) != 0) {
xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR,
@@ -1243,9 +1240,9 @@ Bool ATIDRIScreenInit( ScreenPtr pScreen )
pDRIInfo->busIdString = xalloc( 64 );
sprintf( pDRIInfo->busIdString,
"PCI:%d:%d:%d",
- pATI->PCIInfo->bus,
- pATI->PCIInfo->device,
- pATI->PCIInfo->func );
+ PCI_DEV_BUS(pATI->PCIInfo),
+ PCI_DEV_DEV(pATI->PCIInfo),
+ PCI_DEV_FUNC(pATI->PCIInfo) );
}
pDRIInfo->ddxDriverMajorVersion = ATI_VERSION_MAJOR;
pDRIInfo->ddxDriverMinorVersion = ATI_VERSION_MINOR;
diff --git a/src/atimach64probe.c b/src/atimach64probe.c
index c5330cc7..2f716a15 100644
--- a/src/atimach64probe.c
+++ b/src/atimach64probe.c
@@ -146,8 +146,10 @@ Mach64Probe(DriverPtr pDriver, int flags)
int numUsed;
Bool ProbeSuccess = FALSE;
+#ifndef XSERVER_LIBPCIACCESS
if (xf86GetPciVideoInfo() == NULL)
return FALSE;
+#endif
if ((numDevSections = xf86MatchDevice(ATI_DRIVER_NAME, &devSections)) <= 0)
return FALSE;
diff --git a/src/atipcirename.h b/src/atipcirename.h
new file mode 100644
index 00000000..e30d10c2
--- /dev/null
+++ b/src/atipcirename.h
@@ -0,0 +1,110 @@
+/*
+ * 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 ATIPCIRENAME_H
+#define ATIPCIRENAME_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_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_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)
+
+/* 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_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 /* ATIPCIRENAME_H */
diff --git a/src/atipreinit.c b/src/atipreinit.c
index d960e88f..8114f512 100644
--- a/src/atipreinit.c
+++ b/src/atipreinit.c
@@ -101,24 +101,6 @@ static const rgb defaultWeight = {0, 0, 0};
static const Gamma defaultGamma = {0.0, 0.0, 0.0};
/*
- * ATIMach64Map --
- *
- * This function attempts to mmap() a Mach64's MMIO aperture.
- */
-static void
-ATIMach64Map
-(
- int iScreen,
- ATIPtr pATI
-)
-{
- (void)ATIMapApertures(iScreen, pATI);
- if (!pATI->pBlock[0] ||
- (pATI->config_chip_id != inr(CONFIG_CHIP_ID)))
- ATIUnmapApertures(iScreen, pATI);
-}
-
-/*
* ATIPrintNoiseIfRequested --
*
* This function formats debugging information on the server's stderr when
@@ -175,7 +157,6 @@ ATIPreInit
resPtr pResources;
pciVideoPtr pVideo;
DisplayModePtr pMode;
- unsigned long Block0Base;
CARD32 IOValue;
int i, j;
int Numerator, Denominator;
@@ -402,6 +383,24 @@ ATIPreInit
return TRUE;
}
+#ifndef AVOID_CPIO
+
+ /* I/O bases might no longer be valid after BIOS initialisation */
+ {
+ if (pATI->CPIODecoding == BLOCK_IO)
+ pATI->CPIOBase = PCI_REGION_BASE(pVideo, 1, REGION_IO);
+
+ pATI->MMIOInLinear = FALSE;
+
+ /* Set MMIO address from PCI configuration space, if available */
+ if ((pATI->Block0Base = PCI_REGION_BASE(pVideo, 2, REGION_MEM)))
+ {
+ pATI->Block0Base += 0x0400U;
+ }
+ }
+
+#endif /* AVOID_CPIO */
+
#ifdef AVOID_CPIO
pScreenInfo->racMemFlags =
@@ -424,51 +423,17 @@ ATIPreInit
/* Finish probing the adapter */
{
-
- if (pATI->CPIODecoding == BLOCK_IO)
- pATI->CPIOBase = pVideo->ioBase[1];
-
- /* Set MMIO address from PCI configuration space, if available */
- if ((pATI->Block0Base = pVideo->memBase[2]))
- {
- if (pATI->Block0Base >= (CARD32)(-1 << pVideo->size[2]))
- pATI->Block0Base = 0;
- else
- pATI->Block0Base += 0x0400U;
- }
-
- Block0Base = pATI->Block0Base; /* save */
-
- do
- {
- /*
- * Find and mmap() MMIO area. Allow only auxiliary aperture if
- * it exists.
- */
- if (!pATI->Block0Base)
- {
- /* Check tail end of linear (8MB or 4MB) aperture */
- if ((pATI->Block0Base = pVideo->memBase[0]))
- {
- pATI->Block0Base += 0x007FFC00U;
- ATIMach64Map(pScreenInfo->scrnIndex, pATI);
- if (pATI->pBlock[0])
- break;
-
- pATI->Block0Base -= 0x00400000U;
- ATIMach64Map(pScreenInfo->scrnIndex, pATI);
- if (pATI->pBlock[0])
- break;
- }
-
- /* Check VGA MMIO aperture */
- pATI->Block0Base = 0x000BFC00U;
- }
-
- ATIMach64Map(pScreenInfo->scrnIndex, pATI);
- } while (0);
-
- pATI->Block0Base = Block0Base; /* restore */
+ /*
+ * For MMIO register access, the MMIO address is computed when probing
+ * and there are no BIOS calls. This mapping should always succeed.
+ *
+ * For CPIO register access, the MMIO address is computed above in the
+ * presence of an auxiliary aperture. Otherwise, it is set to zero and
+ * gets computed when we read the linear aperture configuration. This
+ * mapping is either irrelevant or a no-op.
+ */
+ if (!ATIMapApertures(pScreenInfo->scrnIndex, pATI))
+ return FALSE;
#ifdef AVOID_CPIO
@@ -481,15 +446,25 @@ ATIPreInit
#endif /* AVOID_CPIO */
+ /*
+ * Verify register access by comparing against the CONFIG_CHIP_ID
+ * value saved by adapter detection.
+ */
+ if (pATI->config_chip_id != inr(CONFIG_CHIP_ID))
+ {
+ xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR,
+ "Adapter registers not mapped correctly.\n");
+ ATIUnmapApertures(pScreenInfo->scrnIndex, pATI);
+ return FALSE;
+ }
+
pATIHW->crtc_gen_cntl = inr(CRTC_GEN_CNTL);
if (!(pATIHW->crtc_gen_cntl & CRTC_EN) &&
(pATI->Chip >= ATI_CHIP_264CT))
{
xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR,
"Adapter has not been initialised.\n");
- ATIPrintNoiseIfRequested(pATI, BIOS, BIOSSize);
- ATIUnmapApertures(pScreenInfo->scrnIndex, pATI);
- return FALSE;
+ goto bail_locked;
}
#ifdef AVOID_CPIO
@@ -499,9 +474,7 @@ ATIPreInit
xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR,
"Adapters found to be in VGA mode on server entry are not"
" supported by the MMIO-only version of this driver.\n");
- ATIPrintNoiseIfRequested(pATI, BIOS, BIOSSize);
- ATIUnmapApertures(pScreenInfo->scrnIndex, pATI);
- return FALSE;
+ goto bail_locked;
}
#endif /* AVOID_CPIO */
@@ -1809,8 +1782,9 @@ ATIPreInit
if (pATI->LinearBase && pATI->LinearSize)
{
- int AcceleratorVideoRAM = pATI->LinearSize >> 10;
- int ServerVideoRAM = pATI->VideoRAM;
+ int AcceleratorVideoRAM = 0, ServerVideoRAM;
+
+#ifndef AVOID_CPIO
/*
* Unless specified in PCI configuration space, set MMIO
@@ -1823,6 +1797,10 @@ ATIPreInit
pATI->MMIOInLinear = TRUE;
}
+#endif /* AVOID_CPIO */
+
+ AcceleratorVideoRAM = pATI->LinearSize >> 10;
+
/*
* Account for MMIO area at the tail end of the linear
* aperture, if it is needed or if it cannot be disabled.
@@ -1830,6 +1808,8 @@ ATIPreInit
if (pATI->MMIOInLinear || (pATI->Chip < ATI_CHIP_264VTB))
AcceleratorVideoRAM -= 2;
+ ServerVideoRAM = pATI->VideoRAM;
+
if (pATI->Cursor > ATI_CURSOR_SOFTWARE)
{
/*
@@ -2475,6 +2455,8 @@ ATIPreInit
bail:
ATILock(pATI);
+
+bail_locked:
ATIPrintNoiseIfRequested(pATI, BIOS, BIOSSize);
ATIUnmapApertures(pScreenInfo->scrnIndex, pATI);
diff --git a/src/atiprint.c b/src/atiprint.c
index d435e215..60d9c216 100644
--- a/src/atiprint.c
+++ b/src/atiprint.c
@@ -355,8 +355,6 @@ ATIPrintRegisters
ATIPtr pATI
)
{
- pciVideoPtr pVideo = pATI->PCIInfo;
- pciConfigPtr pPCI = pVideo->thisCard;
int Index;
CARD32 lcd_index, tv_out_index, lcd_gen_ctrl;
CARD8 dac_read, dac_mask, dac_write;
@@ -642,10 +640,14 @@ ATIPrintRegisters
xf86ErrorFVerb(4, "\n\n PCI configuration register values:");
for (Index = 0; Index < 256; Index+= 4)
{
+ pciVideoPtr pVideo = pATI->PCIInfo;
+ uint32_t data;
+
+ PCI_READ_LONG(pVideo, &data, Index);
+
if (!(Index & 15))
xf86ErrorFVerb(4, "\n 0x%02X: ", Index);
- xf86ErrorFVerb(4, " 0x%08lX",
- (unsigned long)pciReadLong(pPCI->tag, Index));
+ xf86ErrorFVerb(4, " 0x%08X", data);
}
}
diff --git a/src/atiprobe.c b/src/atiprobe.c
index 5f220321..78b3eddd 100644
--- a/src/atiprobe.c
+++ b/src/atiprobe.c
@@ -214,29 +214,36 @@ ATIMach64Probe
const ATIChipType Chip
)
{
- CARD16 ChipType = pVideo->chipType;
+ CARD16 ChipType = PCI_DEV_DEVICE_ID(pVideo);
+
+ pATI->MMIOInLinear = FALSE;
/*
* Probe through auxiliary MMIO aperture if one exists. Because such
* apertures can be enabled/disabled only through PCI, this probes no
* further.
*/
- if ((pVideo->size[2] >= 12) &&
- (pATI->Block0Base = pVideo->memBase[2]) &&
- (pATI->Block0Base < (CARD32)(-1 << pVideo->size[2])))
+ if ((PCI_REGION_SIZE(pVideo, 2) >= (1 << 12)) &&
+ (pATI->Block0Base = PCI_REGION_BASE(pVideo, 2, REGION_MEM)))
{
pATI->Block0Base += 0x00000400U;
- goto LastProbe;
+ if (ATIMach64Detect(pATI, ChipType, Chip))
+ return pATI;
+
+ return NULL;
}
/*
* Probe through the primary MMIO aperture that exists at the tail end
* of the linear aperture. Test for both 8MB and 4MB linear apertures.
*/
- if ((pVideo->size[0] >= 22) && (pATI->Block0Base = pVideo->memBase[0]))
+ if ((PCI_REGION_SIZE(pVideo, 0) >= (1 << 22)) &&
+ (pATI->Block0Base = PCI_REGION_BASE(pVideo, 0, REGION_MEM)))
{
+ pATI->MMIOInLinear = TRUE;
+
pATI->Block0Base += 0x007FFC00U;
- if ((pVideo->size[0] >= 23) &&
+ if ((PCI_REGION_SIZE(pVideo, 0) >= (1 << 23)) &&
ATIMach64Detect(pATI, ChipType, Chip))
return pATI;
@@ -245,17 +252,6 @@ ATIMach64Probe
return pATI;
}
- /*
- * A last, perhaps desparate, probe attempt. Note that if this succeeds,
- * there's a VGA in the system and it's likely the PIO version of the
- * driver should be used instead (barring OS issues).
- */
- pATI->Block0Base = 0x000BFC00U;
-
-LastProbe:
- if (ATIMach64Detect(pATI, ChipType, Chip))
- return pATI;
-
return NULL;
}
@@ -276,11 +272,10 @@ ATIMach64Probe
)
{
CARD32 IOValue;
- CARD16 ChipType = pVideo->chipType;
+ CARD16 ChipType = PCI_DEV_DEVICE_ID(pVideo);
if ((pATI->CPIODecoding == BLOCK_IO) &&
- ((pVideo->size[1] < 8) ||
- (pATI->CPIOBase >= (CARD32)(-1 << pVideo->size[1]))))
+ (PCI_REGION_SIZE(pVideo, 1) < (1 << 8)))
return NULL;
if (!ATIMach64Detect(pATI, ChipType, Chip))
@@ -380,21 +375,24 @@ ATIMach64ProbeIO
#ifndef AVOID_CPIO
/* Next, look for sparse I/O Mach64's */
- if (!pVideo->size[1])
+ if (!PCI_REGION_SIZE(pVideo, 1))
{
static const IOADDRESS Mach64SparseIOBases[] = {
0x02ECU,
0x01CCU,
0x01C8U
};
+ uint32_t PciReg;
+ uint32_t j;
+
+#ifndef XSERVER_LIBPCIACCESS
pciConfigPtr pPCI = pVideo->thisCard;
- CARD32 PciReg;
- CARD32 j;
if (pPCI == NULL)
goto SkipSparse;
+#endif
- PciReg = pciReadLong(pPCI->tag, PCI_REG_USERCONFIG);
+ PCI_READ_LONG(pVideo, &PciReg, PCI_REG_USERCONFIG);
j = PciReg & 0x03U;
if (j == 0x03U)
@@ -402,7 +400,7 @@ ATIMach64ProbeIO
xf86Msg(X_WARNING, ATI_NAME ": "
"PCI Mach64 in slot %d:%d:%d cannot be enabled\n"
"because it has neither a block, nor a sparse, I/O base.\n",
- pVideo->bus, pVideo->device, pVideo->func);
+ PCI_DEV_BUS(pVideo), PCI_DEV_DEV(pVideo), PCI_DEV_FUNC(pVideo));
goto SkipSparse;
}
@@ -422,14 +420,17 @@ ATIMach64ProbeIO
xf86Msg(X_WARNING, ATI_NAME ": "
"PCI Mach64 in slot %d:%d:%d will not be probed\n"
"set option \"probe_sparse\" to force sparse I/O probing.\n",
- pVideo->bus, pVideo->device, pVideo->func);
+ PCI_DEV_BUS(pVideo), PCI_DEV_DEV(pVideo), PCI_DEV_FUNC(pVideo));
goto SkipSparse;
}
/* Possibly fix block I/O indicator */
if (PciReg & 0x00000004U)
- pciWriteLong(pPCI->tag, PCI_REG_USERCONFIG, PciReg & ~0x00000004U);
+ {
+ PciReg &= ~0x00000004U;
+ PCI_WRITE_LONG(pVideo, PciReg, PCI_REG_USERCONFIG);
+ }
pATI->CPIOBase = Mach64SparseIOBases[j];
pATI->CPIODecoding = SPARSE_IO;
@@ -439,7 +440,7 @@ ATIMach64ProbeIO
{
xf86Msg(X_WARNING, ATI_NAME ": "
"PCI Mach64 in slot %d:%d:%d could not be detected!\n",
- pVideo->bus, pVideo->device, pVideo->func);
+ PCI_DEV_BUS(pVideo), PCI_DEV_DEV(pVideo), PCI_DEV_FUNC(pVideo));
}
else
{
@@ -447,7 +448,7 @@ ATIMach64ProbeIO
xf86Msg(X_INFO, ATI_NAME ": "
"Shared PCI Mach64 in slot %d:%d:%d with sparse PIO base"
" 0x%04lX detected.\n",
- pVideo->bus, pVideo->device, pVideo->func,
+ PCI_DEV_BUS(pVideo), PCI_DEV_DEV(pVideo), PCI_DEV_FUNC(pVideo),
Mach64SparseIOBases[j]);
if (pATI->VGAAdapter)
@@ -459,7 +460,7 @@ SkipSparse:
#else /* AVOID_CPIO */
- if (!pVideo->size[1])
+ if (!PCI_REGION_SIZE(pVideo, 1))
{
/* The adapter's CPIO base is of little concern here */
pATI->CPIOBase = 0;
@@ -472,23 +473,23 @@ SkipSparse:
xf86Msg(X_INFO, ATI_NAME ": "
"Shared PCI Mach64 in slot %d:%d:%d with Block 0 base"
" 0x%08lX detected.\n",
- pVideo->bus, pVideo->device, pVideo->func,
+ PCI_DEV_BUS(pVideo), PCI_DEV_DEV(pVideo), PCI_DEV_FUNC(pVideo),
pATI->Block0Base);
}
else
{
xf86Msg(X_WARNING, ATI_NAME ": "
"PCI Mach64 in slot %d:%d:%d could not be detected!\n",
- pVideo->bus, pVideo->device, pVideo->func);
+ PCI_DEV_BUS(pVideo), PCI_DEV_DEV(pVideo), PCI_DEV_FUNC(pVideo));
}
}
#endif /* AVOID_CPIO */
/* Lastly, look for block I/O devices */
- if (pVideo->size[1])
+ if (PCI_REGION_SIZE(pVideo, 1))
{
- pATI->CPIOBase = pVideo->ioBase[1];
+ pATI->CPIOBase = PCI_REGION_BASE(pVideo, 1, REGION_IO);
pATI->CPIODecoding = BLOCK_IO;
pATI->PCIInfo = pVideo;
@@ -497,7 +498,7 @@ SkipSparse:
ProbeSuccess = TRUE;
xf86Msg(X_INFO, ATI_NAME ": "
"Shared PCI/AGP Mach64 in slot %d:%d:%d detected.\n",
- pVideo->bus, pVideo->device, pVideo->func);
+ PCI_DEV_BUS(pVideo), PCI_DEV_DEV(pVideo), PCI_DEV_FUNC(pVideo));
#ifndef AVOID_CPIO
@@ -511,7 +512,7 @@ SkipSparse:
{
xf86Msg(X_WARNING, ATI_NAME ": "
"PCI/AGP Mach64 in slot %d:%d:%d could not be detected!\n",
- pVideo->bus, pVideo->device, pVideo->func);
+ PCI_DEV_BUS(pVideo), PCI_DEV_DEV(pVideo), PCI_DEV_FUNC(pVideo));
}
}
diff --git a/src/atistruct.h b/src/atistruct.h
index 99be359b..d5749476 100644
--- a/src/atistruct.h
+++ b/src/atistruct.h
@@ -61,6 +61,8 @@
#include "xf86Pci.h"
#include "xf86Resources.h"
+#include "atipcirename.h"
+
#define CacheSlotOf(____Register) ((____Register) / UnitOf(DWORD_SELECT))
/*
diff --git a/src/atividmem.c b/src/atividmem.c
index b1a7a8dc..8910c73b 100644
--- a/src/atividmem.c
+++ b/src/atividmem.c
@@ -103,14 +103,26 @@ ATIUnmapLinear
ATIPtr pATI
)
{
+ pciVideoPtr pVideo = pATI->PCIInfo;
+
if (pATI->pMemory)
{
+#ifndef XSERVER_LIBPCIACCESS
xf86UnMapVidMem(iScreen, pATI->pMemory, pATI->LinearSize);
+#else
+ pci_device_unmap_range(pVideo, pATI->pMemory, pATI->LinearSize);
+#endif
#if X_BYTE_ORDER != X_LITTLE_ENDIAN
if (pATI->pMemoryLE)
+ {
+#ifndef XSERVER_LIBPCIACCESS
xf86UnMapVidMem(iScreen, pATI->pMemoryLE, pATI->LinearSize);
+#else
+ pci_device_unmap_range(pVideo, pATI->pMemoryLE, pATI->LinearSize);
+#endif
+ }
#endif /* X_BYTE_ORDER */
@@ -131,8 +143,16 @@ ATIUnmapMMIO
ATIPtr pATI
)
{
+ pciVideoPtr pVideo = pATI->PCIInfo;
+
if (pATI->pMMIO)
+ {
+#ifndef XSERVER_LIBPCIACCESS
xf86UnMapVidMem(iScreen, pATI->pMMIO, getpagesize());
+#else
+ pci_device_unmap_range(pVideo, pATI->pMMIO, getpagesize());
+#endif
+ }
pATI->pMMIO = pATI->pBlock[0] = pATI->pBlock[1] = NULL;
}
@@ -149,8 +169,16 @@ ATIUnmapCursor
ATIPtr pATI
)
{
+ pciVideoPtr pVideo = pATI->PCIInfo;
+
if (pATI->pCursorPage)
+ {
+#ifndef XSERVER_LIBPCIACCESS
xf86UnMapVidMem(iScreen, pATI->pCursorPage, getpagesize());
+#else
+ pci_device_unmap_range(pVideo, pATI->pCursorPage, getpagesize());
+#endif
+ }
pATI->pCursorPage = pATI->pCursorImage = NULL;
}
@@ -159,6 +187,11 @@ ATIUnmapCursor
* ATIMapApertures --
*
* This function maps all apertures used by the driver.
+ *
+ * It is called three times:
+ * - to setup MMIO for an MMIO-only driver during Probe
+ * - to setup MMIO for an MMIO-only driver during PreInit
+ * - to setup MMIO (with Block0Base set) and FB (with LinearBase set)
*/
Bool
ATIMapApertures
@@ -168,7 +201,11 @@ ATIMapApertures
)
{
pciVideoPtr pVideo = pATI->PCIInfo;
- PCITAG Tag = ((pciConfigPtr)(pVideo->thisCard))->tag;
+#ifndef XSERVER_LIBPCIACCESS
+ PCITAG Tag = PCI_CFG_TAG(pVideo);
+#else
+ pciVideoPtr Tag = pVideo;
+#endif
unsigned long PageSize = getpagesize();
if (pATI->Mapped)
@@ -197,9 +234,30 @@ ATIMapApertures
/* Map linear aperture */
if (pATI->LinearBase)
{
+
+#ifndef XSERVER_LIBPCIACCESS
+
pATI->pMemory = xf86MapPciMem(iScreen, VIDMEM_FRAMEBUFFER,
Tag, pATI->LinearBase, pATI->LinearSize);
+#else /* XSERVER_LIBPCIACCESS */
+
+ int mode = PCI_DEV_MAP_FLAG_WRITABLE | PCI_DEV_MAP_FLAG_WRITE_COMBINE;
+
+ int err = pci_device_map_range(pVideo,
+ pATI->LinearBase,
+ pATI->LinearSize,
+ mode, &pATI->pMemory);
+
+ if (err)
+ {
+ xf86DrvMsg (iScreen, X_ERROR,
+ "Unable to map linear aperture. %s (%d)\n",
+ strerror (err), err);
+ }
+
+#endif /* XSERVER_LIBPCIACCESS */
+
if (!pATI->pMemory)
{
@@ -230,9 +288,31 @@ ATIMapApertures
* caching of this area is _not_ wanted.
*/
{
+
+#ifndef XSERVER_LIBPCIACCESS
+
pATI->pMemoryLE = xf86MapPciMem(iScreen, VIDMEM_MMIO, Tag,
pATI->LinearBase - 0x00800000U, pATI->LinearSize);
+
+#else /* XSERVER_LIBPCIACCESS */
+
+ int mode = PCI_DEV_MAP_FLAG_WRITABLE;
+
+ int err = pci_device_map_range(pVideo,
+ pATI->LinearBase - 0x00800000U,
+ pATI->LinearSize,
+ mode, &pATI->pMemoryLE);
+
+ if (err)
+ {
+ xf86DrvMsg (iScreen, X_ERROR,
+ "Unable to map extended linear aperture. %s (%d)\n",
+ strerror (err), err);
+ }
+
+#endif /* XSERVER_LIBPCIACCESS */
+
if (!pATI->pMemoryLE)
{
ATIUnmapLinear(iScreen, pATI);
@@ -257,9 +337,29 @@ ATIMapApertures
{
unsigned long MMIOBase = pATI->Block0Base & ~(PageSize - 1);
+#ifndef XSERVER_LIBPCIACCESS
+
pATI->pMMIO = xf86MapPciMem(iScreen, VIDMEM_MMIO,
Tag, MMIOBase, PageSize);
+#else /* XSERVER_LIBPCIACCESS */
+
+ int mode = PCI_DEV_MAP_FLAG_WRITABLE;
+
+ int err = pci_device_map_range(pVideo,
+ MMIOBase,
+ PageSize,
+ mode, &pATI->pMMIO);
+
+ if (err)
+ {
+ xf86DrvMsg (iScreen, X_ERROR,
+ "Unable to map mmio aperture. %s (%d)\n",
+ strerror (err), err);
+ }
+
+#endif /* XSERVER_LIBPCIACCESS */
+
if (!pATI->pMMIO)
{
@@ -308,9 +408,29 @@ ATIMapApertures
{
unsigned long CursorBase = pATI->CursorBase & ~(PageSize - 1);
+#ifndef XSERVER_LIBPCIACCESS
+
pATI->pCursorPage = xf86MapPciMem(iScreen, VIDMEM_FRAMEBUFFER,
Tag, CursorBase, PageSize);
+#else /* XSERVER_LIBPCIACCESS */
+
+ int mode = PCI_DEV_MAP_FLAG_WRITABLE | PCI_DEV_MAP_FLAG_WRITE_COMBINE;
+
+ int err = pci_device_map_range(pVideo,
+ CursorBase,
+ PageSize,
+ mode, &pATI->pCursorPage);
+
+ if (err)
+ {
+ xf86DrvMsg (iScreen, X_ERROR,
+ "Unable to map cursor aperture. %s (%d)\n",
+ strerror (err), err);
+ }
+
+#endif /* XSERVER_LIBPCIACCESS */
+
if (!pATI->pCursorPage)
{
ATIUnmapCursor(iScreen, pATI);
diff --git a/src/r128_probe.c b/src/r128_probe.c
index 81ff663a..b2298dff 100644
--- a/src/r128_probe.c
+++ b/src/r128_probe.c
@@ -144,7 +144,9 @@ R128Probe(DriverPtr drv, int flags)
Bool foundScreen = FALSE;
int i;
+#ifndef XSERVER_LIBPCIACCESS
if (!xf86GetPciVideoInfo()) return FALSE;
+#endif
/* Collect unclaimed device sections for both driver names */
nATIGDev = xf86MatchDevice(ATI_NAME, &ATIGDevs);
diff --git a/src/radeon_probe.c b/src/radeon_probe.c
index 207e5372..5c7d16ff 100644
--- a/src/radeon_probe.c
+++ b/src/radeon_probe.c
@@ -237,7 +237,9 @@ RADEONProbe(DriverPtr drv, int flags)
Bool foundScreen = FALSE;
int i;
+#ifndef XSERVER_LIBPCIACCESS
if (!xf86GetPciVideoInfo()) return FALSE;
+#endif
/* Collect unclaimed device sections for both driver names */
nATIGDev = xf86MatchDevice(ATI_NAME, &ATIGDevs);