diff -Naur configure.ac configure.ac
--- configure.ac 2008-01-02 21:02:58.000000000 +0100
+++ configure.ac 2008-01-10 12:40:12.000000000 +0100
@@ -77,6 +77,14 @@
# Checks for header files.
AC_HEADER_STDC
+AC_CHECK_HEADER(xf86Modes.h,[XMODES=yes],[XMODES=no],[#include "xorg-server.h"])
+AC_CHECK_DECL(XSERVER_LIBPCIACCESS,
+ [XSERVER_LIBPCIACCESS=yes],[XSERVER_LIBPCIACCESS=no],
+ [#include "xorg/xorg-server.h"])
+
+if test x$XSERVER_LIBPCIACCESS = xyes; then
+ PKG_CHECK_MODULES([PCIACCESS], [pciaccess >= 0.8.0])
+fi
if test "$DRI" != no; then
AC_CHECK_FILE([${sdkdir}/dri.h],
@@ -129,16 +137,12 @@
[have_xf86Module_h="yes"], [have_xf86Module_h="no"])
# Check the ABI_VIDEODRV_VERSION
-SAVE_CPPFLAGS="$CPPFLAGS"
-CPPFLAGS="$CPPFLAGS $XORG_CFLAGS"
+SAVE_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS $XORG_CFLAGS"
if test "x$have_xf86Module_h" = xyes; then
AC_MSG_CHECKING([whether to use old Xv ABI])
AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[
-#include "xf86Module.h"
-#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) < 1
-#error Old Xv ABI
-#endif
]])],
[OLD_XVABI=no],
[OLD_XVABI=yes])
@@ -147,7 +151,7 @@
echo -n "xf86Module.h not found, "
fi
-CPPFLAGS="$SAVE_CPPFLAGS"
+CFLAGS="$SAVE_CFLAGS"
if test "x$OLD_XVABI" = xyes; then
echo "yes."
@@ -156,6 +160,11 @@
AC_DEFINE(USE_NEW_XVABI, 1, [Use new Xv ABI (7.1RC1+)])
fi
+AM_CONDITIONAL(XSERVER_LIBPCIACCESS, test x$XSERVER_LIBPCIACCESS = xyes)
+if test "$XSERVER_LIBPCIACCESS" = yes; then
+ AC_DEFINE(XSERVER_LIBPCIACCESS,1,[Enable libpciaccess])
+fi
+
AM_CONDITIONAL(DEBUG, test x$DEBUG = xyes)
if test "$DEBUG" = yes; then
AC_DEFINE(HAVE_DEBUG,1,[Enable debug support])
diff -Naur src/via_driver.h src/via_driver.h
--- src/via_driver.h 2008-01-02 19:01:32.000000000 +0100
+++ src/via_driver.h 2008-01-10 12:20:18.000000000 +0100
@@ -66,6 +66,10 @@
#include "via_dmabuffer.h"
#include "via_3d.h"
+#ifdef XSERVER_LIBPCIACCESS
+#include <pciaccess.h>
+#endif
+
#ifdef XF86DRI
#define _XF86DRI_SERVER_
#include "sarea.h"
@@ -234,8 +238,15 @@
int agpMem;
CloseScreenProcPtr CloseScreen;
- pciVideoPtr PciInfo;
- PCITAG PciTag;
+ #if XSERVER_LIBPCIACCESS
+ struct pci_device *PciInfo;
+ int mmio_bar;
+ int fb_bar;
+ PCITAG PciTag;
+ #else
+ pciVideoPtr PciInfo;
+ PCITAG PciTag;
+ #endif
int Chipset;
int ChipId;
int ChipRev;
diff -Naur src/via_dri.c src/via_dri.c
--- src/via_dri.c 2007-06-14 22:45:45.000000000 +0200
+++ src/via_dri.c 2008-01-10 12:20:18.000000000 +0100
@@ -111,9 +111,15 @@
pVIADRI->irqEnabled = drmGetInterruptFromBusID
(pVia->drmFD,
+#if XSERVER_LIBPCIACCESS
+ ((pVia->PciInfo->domain << 8) | pVia->PciInfo->bus),
+ pVia->PciInfo->dev, pVia->PciInfo->func
+#else
((pciConfigPtr)pVia->PciInfo->thisCard)->busnum,
((pciConfigPtr)pVia->PciInfo->thisCard)->devnum,
- ((pciConfigPtr)pVia->PciInfo->thisCard)->funcnum);
+ ((pciConfigPtr)pVia->PciInfo->thisCard)->funcnum
+#endif
+ );
if ((drmCtlInstHandler(pVia->drmFD, pVIADRI->irqEnabled))) {
xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
"[drm] Failure adding irq handler. "
@@ -677,9 +683,15 @@
pDRIInfo->clientDriverName = VIAClientDriverName;
pDRIInfo->busIdString = xalloc(64);
sprintf(pDRIInfo->busIdString, "PCI:%d:%d:%d",
+#if XSERVER_LIBPCIACCESS
+ ((pVia->PciInfo->domain << 8) | pVia->PciInfo->bus),
+ pVia->PciInfo->dev, pVia->PciInfo->func
+#else
((pciConfigPtr)pVia->PciInfo->thisCard)->busnum,
((pciConfigPtr)pVia->PciInfo->thisCard)->devnum,
- ((pciConfigPtr)pVia->PciInfo->thisCard)->funcnum);
+ ((pciConfigPtr)pVia->PciInfo->thisCard)->funcnum
+#endif
+ );
pDRIInfo->ddxDriverMajorVersion = VIA_DRIDDX_VERSION_MAJOR;
pDRIInfo->ddxDriverMinorVersion = VIA_DRIDDX_VERSION_MINOR;
pDRIInfo->ddxDriverPatchVersion = VIA_DRIDDX_VERSION_PATCH;
diff -Naur src/via.h src/via.h
--- src/via.h 2007-09-10 22:51:07.000000000 +0200
+++ src/via.h 2008-01-10 12:20:18.000000000 +0100
@@ -25,7 +25,7 @@
#ifndef _VIA_H_
#define _VIA_H_ 1
-#include "xorgVersion.h"
+//#include "xorgVersion.h"
#include <errno.h>
#include <string.h>
@@ -664,4 +664,20 @@
#define VBE_DEFAULT_REFRESH 6000
+#if XSERVER_LIBPCIACCESS
+#define VIA_MEMBASE(p,n) (p)->regions[(n)].base_addr
+#define VENDOR_ID(p) (p)->vendor_id
+#define DEVICE_ID(p) (p)->device_id
+#define SUBVENDOR_ID(p) (p)->subvendor_id
+#define SUBSYS_ID(p) (p)->subdevice_id
+#define CHIP_REVISION(p) (p)->revision
+#else
+#define VIA_MEMBASE(p,n) (p)->memBase[n]
+#define VENDOR_ID(p) (p)->vendor
+#define DEVICE_ID(p) (p)->chipType
+#define SUBVENDOR_ID(p) (p)->subsysVendor
+#define SUBSYS_ID(p) (p)->subsysCard
+#define CHIP_REVISION(p) (p)->chipRev
+#endif
+
#endif /* _VIA_H_ */
diff -Naur ChangeLog ChangeLog
--- ChangeLog 2008-01-02 19:31:02.000000000 +0100
+++ ChangeLog 2008-01-10 12:20:18.000000000 +0100
@@ -1,3 +1,21 @@
+2008-03-06 Jon Nettleton <jon-dot-nettleton-at-gmail-dot-com>
+
+ * src/via.h:
+ * src/via_driver.c: (VIAPreInit):
+ * src/via_id.c: (ViaCheckCardId):
+
+ Switched ViaCheckCardId to use the macros defined in
+ via.h. This allows it to work with libpciaccess enabled
+ xorg servers as well as legacy versions.
+
+2007-12-31 Jon Nettleton <jon-dot-nettleton-at-gmail-dot-com>
+
+ * src/via_driver.c: (VIAPreInit), (VIAMapMMIO):
+
+ Finally got a chance to work some more on libpciaccess.
+ Memory detection is still not 100% proper but should be
+ more functional and working at least.
+
2007-10-29 Benno Schulenberg <bensberg-at-justemail-dot-net>
* src/via_driver.c: (VIAPreInit):
--- src/via_id.c 2008-03-06 20:30:31.000000000 +0100
+++ src/via_id.c 2008-03-06 22:25:29.000000000 +0100
@@ -30,6 +30,7 @@
#endif
#include "via_driver.h"
+#include "via.h"
#include "via_id.h"
/*
@@ -218,15 +218,15 @@
struct ViaCardIdStruct *Id;
VIAPtr pVia = VIAPTR(pScrn);
- if ((pVia->PciInfo->subsysVendor == pVia->PciInfo->vendor) &&
- (pVia->PciInfo->subsysCard == pVia->PciInfo->chipType))
+ if ((SUBVENDOR_ID(pVia->PciInfo) == VENDOR_ID(pVia->PciInfo)) &&
+ (SUBSYS_ID(pVia->PciInfo) == DEVICE_ID(pVia->PciInfo)))
xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
"Manufacturer plainly copied main PCI IDs to subsystem/card IDs.\n");
for (Id = ViaCardId; Id->String; Id++) {
if ((Id->Chip == pVia->Chipset) &&
- (Id->Vendor == pVia->PciInfo->subsysVendor) &&
- (Id->Device == pVia->PciInfo->subsysCard)) {
+ (Id->Vendor == SUBVENDOR_ID(pVia->PciInfo)) &&
+ (Id->Device == SUBSYS_ID(pVia->PciInfo))) {
xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "Detected %s.\n", Id->String);
pVia->Id = Id;
return;
@@ -235,7 +235,7 @@
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
"Unknown Card-Ids (%4X|%4X|%4X); please report to openchrome-users@openchrome.org\n",
- pVia->PciInfo->chipType, pVia->PciInfo->subsysVendor, pVia->PciInfo->subsysCard);
+ DEVICE_ID(pVia->PciInfo), SUBVENDOR_ID(pVia->PciInfo), SUBSYS_ID(pVia->PciInfo));
pVia->Id = NULL;
}
--- src/via_driver.c 2008-01-02 18:58:40.000000000 +0100
+++ src/via_driver.c 2008-03-07 22:39:15.000000000 +0100
@@ -50,7 +50,30 @@
/* Prototypes. */
static void VIAIdentify(int flags);
+#if XSERVER_LIBPCIACCESS
+struct pci_device *
+via_host_bridge (void)
+{
+ static const struct pci_slot_match bridge_match = {
+ 0, 0, 0, PCI_MATCH_ANY, 0
+ };
+ struct pci_device_iterator *slot_iterator;
+ struct pci_device *bridge;
+
+ slot_iterator = pci_slot_match_iterator_create (&bridge_match);
+ bridge = pci_device_next (slot_iterator);
+ pci_iterator_destroy (slot_iterator);
+ return bridge;
+}
+
+static Bool via_pci_probe (DriverPtr drv,
+ int entity_num,
+ struct pci_device *dev,
+ intptr_t match_data);
+#else
static Bool VIAProbe(DriverPtr drv, int flags);
+#endif
+
static Bool VIASetupDefaultOptions(ScrnInfoPtr pScrn);
static Bool VIAPreInit(ScrnInfoPtr pScrn, int flags);
static Bool VIAEnterVT(int scrnIndex, int flags);
@@ -67,7 +90,7 @@
static Bool VIASwitchMode(int scrnIndex, DisplayModePtr mode, int flags);
static void VIAAdjustFrame(int scrnIndex, int y, int x, int flags);
static void VIADPMS(ScrnInfoPtr pScrn, int mode, int flags);
-static const OptionInfoRec *VIAAvailableOptions(int chipid, int busid);
+static const OptionInfoRec * VIAAvailableOptions(int chipid, int busid);
static Bool VIAMapMMIO(ScrnInfoPtr pScrn);
static Bool VIAMapFB(ScrnInfoPtr pScrn);
@@ -76,14 +99,44 @@
static void VIALoadRgbLut(ScrnInfoPtr pScrn, int numColors, int *indices,
LOCO *colors, VisualPtr pVisual);
-DriverRec VIA = {
+#if XSERVER_LIBPCIACCESS
+
+#define VIA_DEVICE_MATCH(d,i) \
+ { 0x1106, (d), PCI_MATCH_ANY, PCI_MATCH_ANY, 0, 0, (i) }
+
+static const struct pci_id_match via_device_match[] = {
+ VIA_DEVICE_MATCH (PCI_CHIP_VT3204, 0 ),
+ VIA_DEVICE_MATCH (PCI_CHIP_VT3259, 0 ),
+ VIA_DEVICE_MATCH (PCI_CHIP_CLE3122, 0 ),
+ VIA_DEVICE_MATCH (PCI_CHIP_VT3205, 0 ),
+ VIA_DEVICE_MATCH (PCI_CHIP_VT3314, 0 ),
+ VIA_DEVICE_MATCH (PCI_CHIP_VT3336, 0 ),
+ VIA_DEVICE_MATCH (PCI_CHIP_VT3364, 0 ),
+ VIA_DEVICE_MATCH (PCI_CHIP_VT3324, 0 ),
+ VIA_DEVICE_MATCH (PCI_CHIP_VT3327, 0 ),
+ { 0, 0, 0 },
+};
+
+#endif /* XSERVER_LIBPCIACCESS */
+
+_X_EXPORT DriverRec VIA = {
VIA_VERSION,
DRIVER_NAME,
VIAIdentify,
+#if XSERVER_LIBPCIACCESS
+ NULL,
+#else
VIAProbe,
+#endif
VIAAvailableOptions,
NULL,
- 0
+ 0,
+ NULL,
+#if XSERVER_LIBPCIACCESS
+ via_device_match,
+ via_pci_probe
+#endif
+
};
/* Supported chipsets */
@@ -402,8 +455,7 @@
{0, 0, 0, 0}
};
-XF86ModuleData openchromeModuleData = { &VIAVersRec, VIASetup, NULL };
-
+_X_EXPORT XF86ModuleData openchromeModuleData = { &VIAVersRec, VIASetup, NULL};
static pointer
VIASetup(pointer module, pointer opts, int *errmaj, int *errmin)
@@ -412,7 +464,13 @@
if (!setupDone) {
setupDone = TRUE;
- xf86AddDriver(&VIA, module, 0);
+ xf86AddDriver(&VIA, module,
+#if XSERVER_LIBPCIACCESS
+ HaveDriverFuncs
+#else
+ 0
+#endif
+ );
LoaderRefSymLists(vgaHWSymbols,
#ifdef USE_FB
fbSymbols,
@@ -500,6 +558,47 @@
VIAChipsets);
} /* VIAIdentify */
+#if XSERVER_LIBPCIACCESS
+static Bool via_pci_probe (DriverPtr driver,
+ int entity_num,
+ struct pci_device *device,
+ intptr_t match_data)
+{
+ ScrnInfoPtr scrn = NULL;
+ EntityInfoPtr entity;
+ DevUnion *private;
+
+ scrn = xf86ConfigPciEntity (scrn, 0, entity_num, VIAPciChipsets,
+ NULL,
+ NULL, NULL, NULL, NULL);
+
+ if (scrn != NULL)
+ {
+ scrn->driverVersion = VIA_VERSION;
+ scrn->driverName = DRIVER_NAME;
+ scrn->name = "CHROME";
+ scrn->Probe = NULL;
+
+ entity = xf86GetEntityInfo (entity_num);
+
+ scrn->PreInit = VIAPreInit;
+ scrn->ScreenInit = VIAScreenInit;
+ scrn->SwitchMode = VIASwitchMode;
+ scrn->AdjustFrame = VIAAdjustFrame;
+ scrn->EnterVT = VIAEnterVT;
+ scrn->LeaveVT = VIALeaveVT;
+ scrn->FreeScreen = VIAFreeScreen;
+ scrn->ValidMode = ViaValidMode;
+
+ xf86Msg(X_NOTICE, "VIA Technologies does not support or endorse this driver in any way.\n");
+ xf86Msg(X_NOTICE, "For support, please refer to http://www.openchrome.org/ or\n");
+ xf86Msg(X_NOTICE, "your X vendor.\n");
+ }
+ return scrn != NULL;
+}
+#else /* XSERVER_LIBPCIACCESS */
+
+
static Bool VIAProbe(DriverPtr drv, int flags)
{
GDevPtr *devSections;
@@ -610,6 +709,7 @@
return foundScreen;
} /* VIAProbe */
+#endif /* else XSERVER_LIBPCIACCESS */
#ifdef XF86DRI
static void kickVblank(ScrnInfoPtr pScrn)
@@ -756,6 +856,10 @@
vgaHWPtr hwp;
int i, bMemSize = 0;
+#if XSERVER_LIBPCIACCESS
+ struct pci_device *bridge = via_host_bridge ();
+#endif
+
DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "VIAPreInit\n"));
if (pScrn->numEntities > 1)
@@ -939,7 +1043,8 @@
pEnt->device->chipID);
} else {
from = X_PROBED;
- pVia->ChipId = pVia->PciInfo->chipType;
+ //pVia->ChipId = pVia->PciInfo->chipType;
+ pVia->ChipId = DEVICE_ID(pVia->PciInfo);
pVia->Chipset = LookupChipID(VIAPciChipsets, pVia->ChipId);
pScrn->chipset = (char *)xf86TokenToString(VIAChipsets,
pVia->Chipset);
@@ -948,12 +1053,20 @@
xf86DrvMsg(pScrn->scrnIndex, from, "Chipset: \"%s\"\n", pScrn->chipset);
if (pEnt->device->chipRev >= 0) {
+ xf86DrvMsg(pScrn->scrnIndex, from, "Borked 1\n");
pVia->ChipRev = pEnt->device->chipRev;
xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "ChipRev override: %d\n",
pVia->ChipRev);
} else {
/* Read PCI bus 0, dev 0, function 0, index 0xF6 to get chip revision */
+#if XSERVER_LIBPCIACCESS
+ struct pci_device *bridge = via_host_bridge ();
+
+ pci_device_cfg_read_u32 (bridge, & pVia->ChipRev, 0xF6);
+#else
+ xf86DrvMsg(pScrn->scrnIndex, from, "Borked 2\n");
pVia->ChipRev = pciReadByte(pciTag(0, 0, 0), 0xF6);
+#endif
}
if (pVia->Chipset == VIA_CLE266)
@@ -968,18 +1081,33 @@
switch (pVia->Chipset) {
case VIA_CLE266:
case VIA_KM400:
+#if XSERVER_LIBPCIACCESS
+ pci_device_cfg_read_u32 (bridge, & pScrn->videoRam, 0xE1);
+ pScrn->videoRam = (1 << ( ( pScrn->videoRam & 0x70) >> 4 )) << 10 ;
+#else
pScrn->videoRam = ( 1 << ( ( pciReadByte(pciTag(0, 0, 0), 0xE1) & 0x70 ) >> 4 ) ) << 10 ;
+#endif
break;
case VIA_PM800:
case VIA_VM800:
case VIA_K8M800:
+#if XSERVER_LIBPCIACCESS
+ pci_device_cfg_read_u32 (bridge, & pScrn->videoRam, 0xA1);
+ pScrn->videoRam = (1 << ( ( pScrn->videoRam & 0x70) >> 4 )) << 10 ;
+#else
pScrn->videoRam = ( 1 << ( ( pciReadByte(pciTag(0, 0, 3), 0xA1) & 0x70 ) >> 4 ) ) << 10 ;
+#endif
break;
case VIA_K8M890:
case VIA_P4M890:
case VIA_P4M900:
case VIA_CX700:
+#if XSERVER_LIBPCIACCESS
+ pci_device_cfg_read_u32 (bridge, & pScrn->videoRam, 0xA1);
+ pScrn->videoRam = (1 << ( ( pScrn->videoRam & 0x70) >> 4 )) << 12 ;
+#else
pScrn->videoRam = ( 1 << ( ( pciReadByte(pciTag(0, 0, 3), 0xA1) & 0x70 ) >> 4 ) ) << 12 ;
+#endif
break;
default:
if (pScrn->videoRam < 16384 || pScrn->videoRam > 65536) {
@@ -1378,8 +1506,10 @@
/* maybe throw in some more sanity checks here */
+#if !XSERVER_LIBPCIACCESS
pVia->PciTag = pciTag(pVia->PciInfo->bus, pVia->PciInfo->device,
pVia->PciInfo->func);
+#endif
if (!VIAMapMMIO(pScrn)) {
VIAFreeRec(pScrn);
@@ -2046,26 +2176,74 @@
VIAMapMMIO(ScrnInfoPtr pScrn)
{
VIAPtr pVia = VIAPTR(pScrn);
+#if XSERVER_LIBPCIACCESS
+ int err;
+#endif
DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "VIAMapMMIO\n"));
+#if XSERVER_LIBPCIACCESS
+ pVia->FrameBufferBase = pVia->PciInfo->regions[0].base_addr;
+ pVia->MmioBase = pVia->PciInfo->regions[1].base_addr;
+#else
pVia->FrameBufferBase = pVia->PciInfo->memBase[0];
pVia->MmioBase = pVia->PciInfo->memBase[1];
+#endif
xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
"mapping MMIO @ 0x%lx with size 0x%x\n",
pVia->MmioBase, VIA_MMIO_REGSIZE);
- pVia->MapBase = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_MMIO, pVia->PciTag,
- pVia->MmioBase, VIA_MMIO_REGSIZE);
+ #if XSERVER_LIBPCIACCESS
+ err = pci_device_map_range (pVia->PciInfo,
+ pVia->MmioBase,
+ VIA_MMIO_REGSIZE,
+ (PCI_DEV_MAP_FLAG_WRITABLE
+ |PCI_DEV_MAP_FLAG_WRITE_COMBINE),
+ (void **) &pVia->MapBase);
+
+ if (err)
+ {
+ xf86DrvMsg (pScrn->scrnIndex, X_ERROR,
+ "Unable to map mmio BAR. %s (%d)\n",
+ strerror (err), err);
+ return FALSE;
+ }
+ #else
+ pVia->MapBase = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_MMIO,
+ pVia->PciTag,
+ pVia->MmioBase, VIA_MMIO_REGSIZE);
+ if (!pVia->MapBase)
+ return FALSE;
+ #endif
xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
"mapping BitBlt MMIO @ 0x%lx with size 0x%x\n",
pVia->MmioBase + VIA_MMIO_BLTBASE, VIA_MMIO_BLTSIZE);
- pVia->BltBase = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_MMIO, pVia->PciTag,
- pVia->MmioBase + VIA_MMIO_BLTBASE,
- VIA_MMIO_BLTSIZE);
+ #if XSERVER_LIBPCIACCESS
+ err = pci_device_map_range (pVia->PciInfo,
+ pVia->MmioBase + VIA_MMIO_BLTBASE,
+ VIA_MMIO_BLTSIZE,
+ (PCI_DEV_MAP_FLAG_WRITABLE
+ |PCI_DEV_MAP_FLAG_WRITE_COMBINE),
+ (void **) &pVia->BltBase);
+
+ if (err)
+ {
+ xf86DrvMsg (pScrn->scrnIndex, X_ERROR,
+ "Unable to map blt BAR. %s (%d)\n",
+ strerror (err), err);
+ return FALSE;
+ }
+ #else
+ pVia->BltBase = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_MMIO,
+ pVia->PciTag,
+ pVia->MmioBase + VIA_MMIO_BLTBASE,
+ VIA_MMIO_BLTSIZE);
+ if (!pVia->BltBase)
+ return FALSE;
+ #endif
if (!pVia->MapBase || !pVia->BltBase) {
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
@@ -2111,6 +2289,9 @@
VIAMapFB(ScrnInfoPtr pScrn)
{
VIAPtr pVia = VIAPTR(pScrn);
+#if XSERVER_LIBPCIACCESS
+ int err;
+#endif
DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO, "VIAMapFB\n"));
xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
@@ -2125,6 +2306,7 @@
* in the OS support layer.
*/
+#ifndef XSERVER_LIBPCIACCESS
unsigned char *tmp;
tmp = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_MMIO,
pVia->PciTag, pVia->FrameBufferBase,
@@ -2143,10 +2325,24 @@
xf86UnMapVidMem(pScrn->scrnIndex, (pointer)tmp,
pVia->videoRambytes);
+#endif
/*
* End of hack.
*/
+#if XSERVER_LIBPCIACCESS
+ err = pci_device_map_range (pVia->PciInfo, pVia->FrameBufferBase,
+ pVia->videoRambytes,
+ PCI_DEV_MAP_FLAG_WRITABLE,
+ (void **) &pVia->FBBase);
+ if (err)
+ {
+ xf86DrvMsg (pScrn->scrnIndex, X_ERROR,
+ "Unable to map mmio BAR. %s (%d)\n",
+ strerror (err), err);
+ return FALSE;
+ }
+#else
pVia->FBBase = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_FRAMEBUFFER,
pVia->PciTag, pVia->FrameBufferBase,
pVia->videoRambytes);
@@ -2156,6 +2352,7 @@
"Internal error: could not map framebuffer\n");
return FALSE;
}
+#endif
pVia->FBFreeStart = (pScrn->displayWidth * pScrn->bitsPerPixel >> 3) *
pScrn->virtualY;
@@ -2166,7 +2363,11 @@
pVia->FBBase, pVia->FBFreeStart, pVia->FBFreeEnd);
}
+#if XSERVER_LIBPCIACCESS
+ pScrn->memPhysBase = pVia->PciInfo->regions[0].base_addr;
+#else
pScrn->memPhysBase = pVia->PciInfo->memBase[0];
+#endif
pScrn->fbOffset = 0;
if(pVia->IsSecondary) pScrn->fbOffset = pScrn->videoRam << 10;
@@ -2184,6 +2385,16 @@
/* Disable MMIO */
ViaSeqMask(VGAHWPTR(pScrn), 0x1A, 0x00, 0x60);
+#ifdef XSERVER_LIBPCIACCESS
+ if (pVia->MapBase)
+ pci_device_unmap_range(pVia->PciInfo, (pointer)pVia->MapBase, VIA_MMIO_REGSIZE);
+
+ if (pVia->BltBase)
+ pci_device_unmap_range(pVia->PciInfo, (pointer)pVia->BltBase, VIA_MMIO_BLTSIZE);
+
+ if (pVia->FBBase)
+ pci_device_unmap_range(pVia->PciInfo, (pointer)pVia->FBBase, pVia->videoRambytes);
+#else
if (pVia->MapBase)
xf86UnMapVidMem(pScrn->scrnIndex, (pointer)pVia->MapBase, VIA_MMIO_REGSIZE);
@@ -2192,6 +2403,7 @@
if (pVia->FBBase)
xf86UnMapVidMem(pScrn->scrnIndex, (pointer)pVia->FBBase, pVia->videoRambytes);
+#endif
}
static void