summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac10
-rw-r--r--src/Makefile.am4
-rw-r--r--src/ati.c54
-rw-r--r--src/atimach64probe.c2
-rw-r--r--src/atipcirename.h6
-rw-r--r--src/atiprobe.c2
-rw-r--r--src/atividmem.c57
-rw-r--r--src/r128_probe.c2
-rw-r--r--src/radeon_probe.c2
9 files changed, 131 insertions, 8 deletions
diff --git a/configure.ac b/configure.ac
index 0c413c80..03b3440c 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 dd7007e4..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 \
diff --git a/src/ati.c b/src/ati.c
index 3f6cc0c2..ada165f1 100644
--- a/src/ati.c
+++ b/src/ati.c
@@ -57,6 +57,9 @@
#include "config.h"
#endif
+#ifdef XSERVER_LIBPCIACCESS
+#include <pciaccess.h>
+#endif
#include "atipcirename.h"
#include "ati.h"
@@ -67,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 --
*
@@ -101,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)
@@ -127,6 +152,35 @@ ATIProbe
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(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;
+ }
+
+ pci_iterator_destroy(pVideoIter);
+
+#endif /* XSERVER_LIBPCIACCESS */
+
/* Call Radeon driver probe */
if (DoRadeon)
{
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
index 280a81af..e30d10c2 100644
--- a/src/atipcirename.h
+++ b/src/atipcirename.h
@@ -34,7 +34,7 @@ enum region_type {
REGION_IO
};
-#ifndef PCIACCESS
+#ifndef XSERVER_LIBPCIACCESS
/* pciVideoPtr */
#define PCI_DEV_VENDOR_ID(_pcidev) ((_pcidev)->vendor)
@@ -71,7 +71,7 @@ enum region_type {
#define PCI_WRITE_LONG(_pcidev, _value, _offset) \
pciWriteLong(PCI_CFG_TAG(_pcidev), (_offset), (_value))
-#else /* PCIACCESS */
+#else /* XSERVER_LIBPCIACCESS */
typedef struct pci_device *pciVideoPtr;
@@ -105,6 +105,6 @@ typedef struct pci_device *pciVideoPtr;
#define PCI_WRITE_LONG(_pcidev, _value, _offset) \
pci_device_cfg_write_u32((_pcidev), (_value), (_offset))
-#endif /* PCIACCESS */
+#endif /* XSERVER_LIBPCIACCESS */
#endif /* ATIPCIRENAME_H */
diff --git a/src/atiprobe.c b/src/atiprobe.c
index cddcc613..78b3eddd 100644
--- a/src/atiprobe.c
+++ b/src/atiprobe.c
@@ -385,10 +385,12 @@ ATIMach64ProbeIO
uint32_t PciReg;
uint32_t j;
+#ifndef XSERVER_LIBPCIACCESS
pciConfigPtr pPCI = pVideo->thisCard;
if (pPCI == NULL)
goto SkipSparse;
+#endif
PCI_READ_LONG(pVideo, &PciReg, PCI_REG_USERCONFIG);
j = PciReg & 0x03U;
diff --git a/src/atividmem.c b/src/atividmem.c
index 7ab203e9..69d89ef9 100644
--- a/src/atividmem.c
+++ b/src/atividmem.c
@@ -73,9 +73,16 @@ const char *ATIMemoryTypeNames_264xT[] =
*
* It is called implicitely by xf86MapPciMem(VIDMEM_FRAMEBUFFER).
*/
+#ifndef XSERVER_LIBPCIACCESS
#define nop_setWC(_screenNum, _base, _size, _enable) \
do { \
} while (0)
+#else
+#define nop_setWC(_screenNum, _base, _size, _enable) \
+do { \
+ /* XXX */ \
+} while (0)
+#endif
#ifndef AVOID_CPIO
@@ -120,7 +127,11 @@ ATIUnmapLinear
if (pATI->LinearBase)
nop_setWC(iScreen, pATI->LinearBase, pATI->LinearSize, FALSE);
+#ifndef XSERVER_LIBPCIACCESS
xf86UnMapVidMem(iScreen, pATI->pMemoryLE, (1U << pVideo->size[0]));
+#else
+ pci_device_unmap_region(pVideo, 0);
+#endif
}
pATI->pMemory = pATI->pMemoryLE = NULL;
@@ -140,8 +151,16 @@ ATIUnmapMMIO
ATIPtr pATI
)
{
+ pciVideoPtr pVideo = pATI->PCIInfo;
+
if (pATI->pMMIO)
+ {
+#ifndef XSERVER_LIBPCIACCESS
xf86UnMapVidMem(iScreen, pATI->pMMIO, getpagesize());
+#else
+ pci_device_unmap_region(pVideo, 2);
+#endif
+ }
pATI->pMMIO = pATI->pBlock[0] = pATI->pBlock[1] = NULL;
}
@@ -163,8 +182,7 @@ ATIMapApertures
ATIPtr pATI
)
{
- pciVideoPtr pVideo = pATI->PCIInfo;
- int mode;
+ pciVideoPtr pVideo = pATI->PCIInfo;
if (pATI->Mapped)
return TRUE;
@@ -192,18 +210,32 @@ ATIMapApertures
/* Map linear aperture */
if (pATI->LinearBase || (pATI->Block0Base && pATI->MMIOInLinear))
{
- mode = VIDMEM_FRAMEBUFFER;
+#ifndef XSERVER_LIBPCIACCESS
+
+ int mode = VIDMEM_FRAMEBUFFER;
+
/* Reset write-combining for the whole FB when MMIO registers fall in
* the linear aperture.
*/
if (pATI->MMIOInLinear)
mode = VIDMEM_MMIO;
-
+
pATI->pMemoryLE = xf86MapPciMem(iScreen, mode, PCI_CFG_TAG(pVideo),
pVideo->memBase[0],
(1U << pVideo->size[0]));
+#else /* XSERVER_LIBPCIACCESS */
+
+ int err = pci_device_map_region(pVideo, 0, TRUE);
+
+ if (err)
+ pATI->pMemoryLE = NULL;
+ else
+ pATI->pMemoryLE = pVideo->regions[0].memory;
+
+#endif /* XSERVER_LIBPCIACCESS */
+
if (!pATI->pMemoryLE)
goto bail;
@@ -230,11 +262,26 @@ ATIMapApertures
/* Map MMIO aperture */
if (pATI->Block0Base && !pATI->MMIOInLinear)
{
- mode = VIDMEM_MMIO;
+
+#ifndef XSERVER_LIBPCIACCESS
+
+ int mode = VIDMEM_MMIO;
+
pATI->pMMIO = xf86MapPciMem(iScreen, mode, PCI_CFG_TAG(pVideo),
pVideo->memBase[2],
getpagesize());
+#else /* XSERVER_LIBPCIACCESS */
+
+ int err = pci_device_map_region(pVideo, 2, TRUE);
+
+ if (err)
+ pATI->pMMIO = NULL;
+ else
+ pATI->pMMIO = pVideo->regions[2].memory;
+
+#endif /* XSERVER_LIBPCIACCESS */
+
if (!pATI->pMMIO)
goto bail;
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 c697f65c..b7c38ad0 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);