[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

xserver-xorg-video-mga: Changes to 'upstream-experimental'



 .gitignore        |    1 
 configure.ac      |   14 
 mga_PInS.txt      |   28 +
 src/clientlx.c    |   16 
 src/mga.h         |   90 ++++
 src/mga_bios.c    |   15 
 src/mga_dac3026.c |   10 
 src/mga_dacG.c    |   63 ++-
 src/mga_dri.c     |  293 ++++++++++++---
 src/mga_driver.c  | 1053 +++++++++++++++++++++++++++++++++++-------------------
 src/mga_exa.c     |  133 +++++-
 src/mga_macros.h  |   20 -
 src/mga_merge.c   |    6 
 src/mga_storm.c   |  215 -----------
 src/mga_vga.c     |  211 +++++++++-
 src/mga_video.c   |  780 +++++++++++++++++++++++++++++++++++++++-
 util/stormdwg.c   |   10 
 17 files changed, 2229 insertions(+), 729 deletions(-)

New commits:
commit d7f0f657504b2646a94f652baf0f71ff4117fac4
Author: Tilman Sauerbeck <tilman@code-monkey.de>
Date:   Wed Sep 5 18:06:57 2007 +0200

    Bumped version to 1.4.7.

diff --git a/configure.ac b/configure.ac
index 1605dee..9f8f1a7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -24,7 +24,7 @@ AC_PREREQ(2.57)
 
 # When the version number is modified here, also modify it in src/mga.h.
 AC_INIT([xf86-video-mga],
-        1.4.6.1,
+        1.4.7,
         [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
         xf86-video-mga)
 

commit 4bfc1e1ea11604e3af150a4228663cb1cb1bf9f3
Author: James Cloos <cloos@jhcloos.com>
Date:   Mon Sep 3 05:52:35 2007 -0400

    Add *~ to .gitignore to skip patch/emacs droppings

diff --git a/.gitignore b/.gitignore
index 564d950..cec124b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -24,3 +24,4 @@ man/mga.?
 util/stormdwg
 .deps
 .libs
+*~

commit 923176f5aad777b4023003a457bb77da21373389
Author: Ian Romanick <idr@us.ibm.com>
Date:   Fri Aug 31 11:05:57 2007 -0700

    Use XSERVER_LIBPCIACCESS to detect pci-rework.

diff --git a/configure.ac b/configure.ac
index 7d37153..1605dee 100644
--- a/configure.ac
+++ b/configure.ac
@@ -60,11 +60,6 @@ AC_ARG_ENABLE(exa,
                              [Disable EXA support [[default=enabled]]]),
               [EXA="$enableval"],
               [EXA=yes])
-AC_ARG_ENABLE(pciaccess,
-              AS_HELP_STRING([--enable-pciaccess],
-                             [Enable use of libpciaccess (default: disabled)]),
-              [PCIACCESS=$enableval],
-              [PCIACCESS=no])
 
 # Checks for extensions
 XORG_DRIVER_CHECK_EXT(RANDR, randrproto)
@@ -76,13 +71,6 @@ XORG_DRIVER_CHECK_EXT(DPMSExtension, xextproto)
 PKG_CHECK_MODULES(XORG, [xorg-server >= 1.1.0 xproto fontsproto $REQUIRED_MODULES])
 sdkdir=$(pkg-config --variable=sdkdir xorg-server)
 
-AM_CONDITIONAL(PCIACCESS, [test "x$PCIACCESS" = xyes])
-if test "x$PCIACCESS" = xyes; then
-    AC_DEFINE(PCIACCESS, 1, [Use libpciaccess])
-    PKG_CHECK_MODULES([PCIACCESS], [pciaccess >= 0.7.0])
-    XORG_CFLAGS="$XORG_CFLAGS $PCIACCESS_CFLAGS"
-fi
-
 # Checks for libraries.
 
 # Checks for header files.
@@ -116,6 +104,18 @@ if test "x$DRI" = xyes; then
         AC_DEFINE(XF86DRI_DEVEL,1,[Enable developmental DRI driver support])
 fi
 
+save_CFLAGS="$CFLAGS"
+CFLAGS="$XORG_CFLAGS"
+AC_CHECK_DECL(XSERVER_LIBPCIACCESS,
+              [XSERVER_LIBPCIACCESS=yes], [XSERVER_LIBPCIACCESS=no],
+              [#include "xorg-server.h"])
+CFLAGS="$save_CFLAGS"
+
+if test "x$XSERVER_LIBPCIACCESS" = xyes; then
+    PKG_CHECK_MODULES([PCIACCESS], [pciaccess >= 0.8.0])
+fi
+AM_CONDITIONAL(XSERVER_LIBPCIACCESS, test "x$XSERVER_LIBPCIACCESS" = xyes)
+
 AM_CONDITIONAL(USE_XAA, true)
 AC_DEFINE(USE_XAA, 1, [Build support for XAA])
 
diff --git a/src/clientlx.c b/src/clientlx.c
index 8c08026..9c6ab50 100644
--- a/src/clientlx.c
+++ b/src/clientlx.c
@@ -67,7 +67,7 @@ ULONG ClientReadConfigSpaceByte(LPBOARDHANDLE pBoard, ULONG ulOffset,
 
     ASSERT_HANDLER(pBoard);
 
-#ifdef PCIACCESS
+#ifdef XSERVER_LIBPCIACCESS
     pci_device_cfg_read_u8(pMga->PciInfo, pucByte, ulOffset);
 #else
     *pucByte = pciReadByte(pMga->PciTag,ulOffset);
@@ -99,7 +99,7 @@ ULONG ClientReadConfigSpaceDword(LPBOARDHANDLE pBoard, ULONG ulOffset,
 
     ASSERT_HANDLER(pBoard);
 
-#ifdef PCIACCESS
+#ifdef XSERVER_LIBPCIACCESS
     pci_device_cfg_read_u32(pMga->PciInfo, (uint32_t *) pulDword, ulOffset);
 #else
     *pulDword = pciReadLong(pMga->PciTag,ulOffset);
@@ -131,7 +131,7 @@ ULONG ClientWriteConfigSpaceByte(LPBOARDHANDLE pBoard, ULONG ulOffset,
 
     ASSERT_HANDLER(pBoard);
 
-#ifdef PCIACCESS
+#ifdef XSERVER_LIBPCIACCESS
     pci_device_cfg_write_u8(pMga->PciInfo, ucByte, ulOffset);
 #else
     pciWriteByte(pMga->PciTag,ulOffset, ucByte);
@@ -163,7 +163,7 @@ ULONG ClientWriteConfigSpaceDword(LPBOARDHANDLE pBoard, ULONG ulOffset,
 
     ASSERT_HANDLER(pBoard);
 
-#ifdef PCIACCESS
+#ifdef XSERVER_LIBPCIACCESS
     pci_device_cfg_write_u32(pMga->PciInfo, (uint32_t) ulDword, ulOffset);
 #else
     pciWriteLong(pMga->PciTag,ulOffset, ulDword);
diff --git a/src/mga.h b/src/mga.h
index 673ec1d..c46fdbb 100644
--- a/src/mga.h
+++ b/src/mga.h
@@ -14,7 +14,7 @@
 #ifndef MGA_H
 #define MGA_H
 
-#ifdef PCIACCESS
+#ifdef XSERVER_LIBPCIACCESS
 #include <pciaccess.h>
 #endif
 #include <string.h>
@@ -289,7 +289,7 @@ typedef struct {
 
 #ifdef DISABLE_VGA_IO
 typedef struct mgaSave {
-#ifdef PCIACCESS
+#ifdef XSERVER_LIBPCIACCESS
     struct pci_device * pvp;
 #else
     pciVideoPtr pvp;
@@ -441,7 +441,7 @@ typedef struct {
     EntityInfoPtr	pEnt;
     struct mga_bios_values bios;
     CARD8               BiosOutputMode;
-#ifdef PCIACCESS
+#ifdef XSERVER_LIBPCIACCESS
     struct pci_device *	PciInfo;
 #else
     pciVideoPtr		PciInfo;
@@ -482,7 +482,7 @@ typedef struct {
      */
     int                 iload_bar;
 
-#ifndef PCIACCESS
+#ifndef XSERVER_LIBPCIACCESS
     unsigned long	IOAddress;
     unsigned long	ILOADAddress;
     unsigned long	BiosAddress;
diff --git a/src/mga_bios.c b/src/mga_bios.c
index 46a8c46..aece217 100644
--- a/src/mga_bios.c
+++ b/src/mga_bios.c
@@ -409,7 +409,7 @@ Bool mga_read_and_process_bios( ScrnInfoPtr pScrn )
     CARD8  bios_data[0x20000];
     unsigned offset;
     MGAPtr pMga = MGAPTR(pScrn);
-#ifndef PCIACCESS
+#ifndef XSERVER_LIBPCIACCESS
     Bool pciBIOS = TRUE;
 #endif
     int rlen;
@@ -446,7 +446,7 @@ Bool mga_read_and_process_bios( ScrnInfoPtr pScrn )
      * might be controlled by the PCI config space.
      */
 
-#ifdef PCIACCESS
+#ifdef XSERVER_LIBPCIACCESS
     err = pci_device_read_rom(pMga->PciInfo, bios_data);
 #else
     if (pMga->BiosFrom == X_DEFAULT) {
diff --git a/src/mga_dac3026.c b/src/mga_dac3026.c
index 254f6e2..e33f914 100644
--- a/src/mga_dac3026.c
+++ b/src/mga_dac3026.c
@@ -746,7 +746,7 @@ MGA3026Restore(ScrnInfoPtr pScrn, vgaRegPtr vgaReg, MGARegPtr mgaReg,
 	for (i = 0; i < 6; i++)
 		OUTREG16(0x1FDE, (mgaReg->ExtVga[i] << 8) | i);
 
-#ifdef PCIACCESS
+#ifdef XSERVER_LIBPCIACCESS
 	pci_device_cfg_write_bits(pMga->PciInfo, OPTION_MASK, mgaReg->Option,
 				  PCI_OPTION_REG);
 #else
@@ -871,7 +871,7 @@ MGA3026Save(ScrnInfoPtr pScrn, vgaRegPtr vgaReg, MGARegPtr mgaReg,
 	for (i = 0; i < DACREGSIZE; i++)
 		mgaReg->DacRegs[i]	 = inTi3026(MGADACregs[i]);
 	
-#ifdef PCIACCESS
+#ifdef XSERVER_LIBPCIACCESS
 	pci_device_cfg_read_u32(pMga->PciInfo, & mgaReg->Option, 
 				PCI_OPTION_REG);
 #else
diff --git a/src/mga_dacG.c b/src/mga_dacG.c
index f135ad5..1a6a565 100644
--- a/src/mga_dacG.c
+++ b/src/mga_dacG.c
@@ -771,7 +771,7 @@ MGA_NOT_HAL(
 	   
 	   if (!MGAISGx50(pMga)) {
 	       /* restore pci_option register */
-#ifdef PCIACCESS
+#ifdef XSERVER_LIBPCIACCESS
 	       pci_device_cfg_write_bits(pMga->PciInfo, optionMask, 
 					 mgaReg->Option, PCI_OPTION_REG);
 
@@ -960,7 +960,7 @@ MGAGSave(ScrnInfoPtr pScrn, vgaRegPtr vgaReg, MGARegPtr mgaReg,
 
         mgaReg->PIXPLLCSaved = TRUE;
 
-#ifdef PCIACCESS
+#ifdef XSERVER_LIBPCIACCESS
 	pci_device_cfg_read_u32(pMga->PciInfo, & mgaReg->Option,
 				PCI_OPTION_REG);
 	pci_device_cfg_read_u32(pMga->PciInfo, & mgaReg->Option2,
@@ -971,7 +971,7 @@ MGAGSave(ScrnInfoPtr pScrn, vgaRegPtr vgaReg, MGARegPtr mgaReg,
 	mgaReg->Option2 = pciReadLong(pMga->PciTag, PCI_MGA_OPTION2);
 #endif
 	if (pMga->Chipset == PCI_CHIP_MGAG400 || pMga->Chipset == PCI_CHIP_MGAG550)
-#ifdef PCIACCESS
+#ifdef XSERVER_LIBPCIACCESS
 		    pci_device_cfg_read_u32(pMga->PciInfo, & mgaReg->Option3,
 					    PCI_MGA_OPTION3);
 #else
diff --git a/src/mga_dri.c b/src/mga_dri.c
index a8bea66..43fcaa8 100644
--- a/src/mga_dri.c
+++ b/src/mga_dri.c
@@ -851,7 +851,7 @@ static void MGADRIIrqInit(MGAPtr pMga, ScreenPtr pScreen)
 
    if (!pMga->irq) {
       pMga->irq = drmGetInterruptFromBusID(pMga->drmFD,
-#ifdef PCIACCESS
+#ifdef XSERVER_LIBPCIACCESS
 					   ((pMga->PciInfo->domain << 8) |
 					    pMga->PciInfo->bus),
 					   pMga->PciInfo->dev,
@@ -1160,7 +1160,7 @@ Bool MGADRIScreenInit( ScreenPtr pScreen )
    } else {
       pDRIInfo->busIdString = xalloc(64);
       sprintf( pDRIInfo->busIdString, "PCI:%d:%d:%d",
-#ifdef PCIACCESS
+#ifdef XSERVER_LIBPCIACCESS
 	       ((pMga->PciInfo->domain << 8) | pMga->PciInfo->bus),
 	       pMga->PciInfo->dev, pMga->PciInfo->func
 #else
diff --git a/src/mga_driver.c b/src/mga_driver.c
index 927e9a4..d9b786f 100644
--- a/src/mga_driver.c
+++ b/src/mga_driver.c
@@ -64,7 +64,7 @@
 #include "xf86PciInfo.h"
 
 /* Drivers that need to access the PCI config space directly need this */
-#ifndef PCIACCESS
+#ifndef XSERVER_LIBPCIACCESS
 #include "xf86Pci.h"
 #endif
 
@@ -111,7 +111,7 @@
 /* Mandatory functions */
 static const OptionInfoRec *	MGAAvailableOptions(int chipid, int busid);
 static void	MGAIdentify(int flags);
-#ifdef PCIACCESS
+#ifdef XSERVER_LIBPCIACCESS
 static Bool MGAPciProbe(DriverPtr drv, int entity_num,
     struct pci_device * dev, intptr_t match_data);
 #else
@@ -192,7 +192,7 @@ static const struct mga_device_attributes attribs[8] = {
             (TRANSC_SOLID_FILL | TWO_PASS_COLOR_EXPAND | USE_LINEAR_EXPANSION) },
 };
 
-#ifdef PCIACCESS
+#ifdef XSERVER_LIBPCIACCESS
 #define MGA_DEVICE_MATCH(d, i) \
     { 0x102B, (d), PCI_MATCH_ANY, PCI_MATCH_ANY, 0, 0, (i) }
 #define MGA_SUBDEVICE_MATCH(d, s, i) \
@@ -264,7 +264,7 @@ _X_EXPORT DriverRec MGA_C_NAME = {
     MGA_VERSION,
     MGA_DRIVER_NAME,
     MGAIdentify,
-#ifdef PCIACCESS
+#ifdef XSERVER_LIBPCIACCESS
     NULL,
 #else
     MGAProbe,
@@ -274,7 +274,7 @@ _X_EXPORT DriverRec MGA_C_NAME = {
     0,
     NULL,
      
-#ifdef PCIACCESS
+#ifdef XSERVER_LIBPCIACCESS
     mga_device_match,
     MGAPciProbe
 #endif
@@ -635,7 +635,7 @@ MGAIdentify(int flags)
 }
 
 
-#ifdef PCIACCESS
+#ifdef XSERVER_LIBPCIACCESS
 Bool
 MGAPciProbe(DriverPtr drv, int entity_num, struct pci_device * dev,
 	    intptr_t match_data)
@@ -978,7 +978,7 @@ MGACountRam(ScrnInfoPtr pScrn)
 	it.  At least, my cards don't advertise the documented
 	values (my 8 and 16 Meg G200s have the same values) */
     if (pMga->Primary) { /* can only trust this for primary cards */
-#ifdef PCIACCESS
+#ifdef XSERVER_LIBPCIACCESS
 	pci_device_cfg_read_u32(pMga->PciInfo, & biosInfo,
 				PCI_OPTION_REG);
 #else
@@ -1289,7 +1289,7 @@ static void
 VgaIOSave(int i, void *arg)
 {
     MgaSavePtr sMga = arg;
-#ifndef PCIACCESS
+#ifndef XSERVER_LIBPCIACCESS
     PCITAG tag = pciTag(sMga->pvp->bus,sMga->pvp->device,sMga->pvp->func);
 #endif
     uint32_t temp;
@@ -1298,7 +1298,7 @@ VgaIOSave(int i, void *arg)
     ErrorF("mga: VgaIOSave: %d:%d:%d\n", sMga->pvp->bus, sMga->pvp->device,
 	   sMga->pvp->func);
 #endif
-#ifdef PCIACCESS
+#ifdef XSERVER_LIBPCIACCESS
     pci_device_cfg_read_u32(pMga->PciInfo, & temp, PCI_OPTION_REG);
 #else
     temp = pciReadLong(tag, PCI_OPTION_REG);
@@ -1310,7 +1310,7 @@ static void
 VgaIORestore(int i, void *arg)
 {
     MgaSavePtr sMga = arg;
-#ifndef PCIACCESS
+#ifndef XSERVER_LIBPCIACCESS
     PCITAG tag = pciTag(sMga->pvp->bus,sMga->pvp->device,sMga->pvp->func);
 #endif
 
@@ -1318,7 +1318,7 @@ VgaIORestore(int i, void *arg)
     ErrorF("mga: VgaIORestore: %d:%d:%d\n", sMga->pvp->bus, sMga->pvp->device,
 	   sMga->pvp->func);
 #endif
-#ifdef PCIACCESS
+#ifdef XSERVER_LIBPCIACCESS
     pci_device_cfg_write_bits(pMga->PciInfo, 0x00000100, sMga->enable,
 			      PCI_OPTION_REG);
 #else
@@ -1338,7 +1338,7 @@ VgaIODisable(void *arg)
 	   BOOLTOSTRING(xf86ResAccessEnter));
 #endif
     /* Turn off the vgaioen bit. */
-#ifdef PCIACCESS
+#ifdef XSERVER_LIBPCIACCESS
     pci_device_cfg_write_bits(pMga->PciInfo, 0x00000100, 0x00000000,
 			      PCI_OPTION_REG);
 #else
@@ -1359,7 +1359,7 @@ VgaIOEnable(void *arg)
 #endif
     /* Turn on the vgaioen bit. */
     if (pMga->Primary) {
-#ifdef PCIACCESS
+#ifdef XSERVER_LIBPCIACCESS
 	pci_device_cfg_write_bits(pMga->PciInfo, 0x00000100, 0x00000100,
 				  PCI_OPTION_REG);
 #else
@@ -1479,7 +1479,7 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
     if (!vgaHWGetHWRec(pScrn))
 	return FALSE;
 
-#ifndef PCIACCESS
+#ifndef XSERVER_LIBPCIACCESS
     /* Find the PCI info for this screen */
     pMga->PciInfo = xf86GetPciInfoForEntity(pMga->pEnt->index);
     pMga->PciTag = pciTag(pMga->PciInfo->bus, pMga->PciInfo->device,
@@ -1731,7 +1731,7 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
 
     if (pMga->is_G200SE) {
         /* Disable MTRR support on PCIe systems */
-#ifdef PCIACCESS
+#ifdef XSERVER_LIBPCIACCESS
 	uint32_t temp;
 
 	pci_device_cfg_read_u32(pMga->PciInfo, & temp, 0xDC);
@@ -2022,7 +2022,7 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
     }
 
 
-#ifdef PCIACCESS
+#ifdef XSERVER_LIBPCIACCESS
     pMga->FbAddress = pMga->PciInfo->regions[pMga->framebuffer_bar].base_addr;
 #else
     pMga->FbAddress = pMga->PciInfo->memBase[pMga->framebuffer_bar] & 0xff800000;
@@ -2031,7 +2031,7 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
     xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "Linear framebuffer at 0x%lX\n",
 	       (unsigned long)pMga->FbAddress);
 
-#ifdef PCIACCESS
+#ifdef XSERVER_LIBPCIACCESS
     xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "MMIO registers at 0x%lX\n",
 	       (unsigned long) pMga->PciInfo->regions[pMga->io_bar].base_addr);
 #else
@@ -2042,7 +2042,7 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
 #endif
 
     if (pMga->iload_bar != -1) {
-#ifdef PCIACCESS
+#ifdef XSERVER_LIBPCIACCESS
 	xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
 		   "Pseudo-DMA transfer window at 0x%lX\n",
 		   (unsigned long) pMga->PciInfo->regions[pMga->iload_bar].base_addr);
@@ -2057,7 +2057,7 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
     }
 
 
-#ifndef PCIACCESS
+#ifndef XSERVER_LIBPCIACCESS
     /*
      * Find the BIOS base.  Get it from the PCI config if possible.  Otherwise
      * use the VGA default.  Allow the config file to override this.
@@ -2096,7 +2096,7 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
      * Read the BIOS data struct
      */
 
-#if defined(__alpha__) && !defined(PCIACCESS)
+#if defined(__alpha__) && !defined(XSERVER_LIBPCIACCESS)
     /* 
      * Some old Digital-OEMed Matrox Millennium I cards have a VGA
      * disable switch.  If the disable is on, we can't read the BIOS,
@@ -2509,7 +2509,7 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
 	     && pMga->chip_attribs->probe_for_sdram) {
 	    uint32_t option_reg;
 	    
-#ifdef PCIACCESS
+#ifdef XSERVER_LIBPCIACCESS
 	    pci_device_cfg_read_u32(pMga->PciInfo, & option_reg,
 				    PCI_OPTION_REG);
 #else
@@ -2773,14 +2773,14 @@ static Bool
 MGAMapMem(ScrnInfoPtr pScrn)
 {
     MGAPtr pMga = MGAPTR(pScrn);
-#ifdef PCIACCESS
+#ifdef XSERVER_LIBPCIACCESS
     struct pci_device *const dev = pMga->PciInfo;
     int err;
 #endif
 
 
     if (!pMga->FBDev) {
-#ifdef PCIACCESS
+#ifdef XSERVER_LIBPCIACCESS
 	err = pci_device_map_region(dev, 0, TRUE);
 	if (err) {
 	    xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
@@ -2838,7 +2838,7 @@ MGAMapMem(ScrnInfoPtr pScrn)
 
     pMga->ILOADBase = NULL;
     if (pMga->iload_bar != -1) {
-#ifdef PCIACCESS
+#ifdef XSERVER_LIBPCIACCESS
 	err = pci_device_map_region(dev, pMga->iload_bar, TRUE);
 	if (err) {
 	    xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
@@ -2870,13 +2870,13 @@ static Bool
 MGAUnmapMem(ScrnInfoPtr pScrn)
 {
     MGAPtr pMga = MGAPTR(pScrn);
-#ifdef PCIACCESS
+#ifdef XSERVER_LIBPCIACCESS
     struct pci_device * const dev = pMga->PciInfo;
 #endif
 
     
     if (!pMga->FBDev) {
-#ifdef PCIACCESS
+#ifdef XSERVER_LIBPCIACCESS
 	pci_device_unmap_region(dev, 0);
 	pci_device_unmap_region(dev, 1);
 #else
@@ -2890,13 +2890,13 @@ MGAUnmapMem(ScrnInfoPtr pScrn)
     }
 
     if ((pMga->iload_bar != -1)
-#ifdef PCIACCESS
+#ifdef XSERVER_LIBPCIACCESS
 	 && (dev->regions[pMga->iload_bar].memory != NULL)
 #else
 	 && (pMga->ILOADBase != NULL)
 #endif
 	) {
-#ifdef PCIACCESS
+#ifdef XSERVER_LIBPCIACCESS
 	pci_device_unmap_region(dev, pMga->iload_bar);
 #else
 	xf86UnMapVidMem(pScrn->scrnIndex, (pointer)pMga->ILOADBase, 0x800000);
@@ -3540,7 +3540,7 @@ MGAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
     else {
 	fbdevHWSave(pScrn);
 	/* Disable VGA core, and leave memory access on */
-#ifdef PCIACCESS
+#ifdef XSERVER_LIBPCIACCESS
 	pci_device_cfg_write_bits(pMga->PciInfo, 0x00000100, 0x00000000, 
 				  PCI_OPTION_REG);
 #else
diff --git a/src/mga_macros.h b/src/mga_macros.h
index 3de9618..69dc8e3 100644
--- a/src/mga_macros.h
+++ b/src/mga_macros.h
@@ -3,7 +3,7 @@
 #ifndef _MGA_MACROS_H_
 #define _MGA_MACROS_H_
 
-#ifdef PCIACCESS
+#ifdef XSERVER_LIBPCIACCESS
 #define MGA_IO_ADDRESS(p) (p)->PciInfo->regions[(p)->io_bar].base_addr
 #define VENDOR_ID(p)      (p)->vendor_id
 #define DEVICE_ID(p)      (p)->device_id
diff --git a/src/mga_merge.c b/src/mga_merge.c
index 141b0c3..359cdcf 100644
--- a/src/mga_merge.c
+++ b/src/mga_merge.c
@@ -272,7 +272,7 @@ MGAPreInitMergedFB(ScrnInfoPtr pScrn1, int flags)
 	return TRUE;
     }
 
-#ifndef PCIACCESS
+#ifndef XSERVER_LIBPCIACCESS
     pMga->PciTag = pMga1->PciTag;
 #endif
     pMga->Primary = pMga1->Primary;
@@ -372,7 +372,7 @@ MGAPreInitMergedFB(ScrnInfoPtr pScrn1, int flags)
 
     pMga->FbAddress = pMga1->FbAddress;
     pMga->PciInfo = pMga1->PciInfo;
-#ifndef PCIACCESS
+#ifndef XSERVER_LIBPCIACCESS
     pMga->IOAddress = pMga1->IOAddress;
     pMga->ILOADAddress = pMga1->ILOADAddress;
     pMga->BiosFrom = pMga1->BiosFrom;

commit 90beb8c27b4206b593898d346bf37ab49e75b975
Author: Ian Romanick <idr@us.ibm.com>
Date:   Wed Aug 22 11:19:46 2007 -0700

    Set pScrn to NULL before calling xf86ConfigPciEntity.
    
    Why is the interface to xf86ConfigPciEntity so filled with hate?

diff --git a/src/mga_driver.c b/src/mga_driver.c
index 2d054cf..927e9a4 100644
--- a/src/mga_driver.c
+++ b/src/mga_driver.c
@@ -792,7 +792,7 @@ MGAProbe(DriverPtr drv, int flags)
     if (flags & PROBE_DETECT)
 	foundScreen = TRUE;
     else for (i = 0; i < numUsed; i++) {
-	ScrnInfoPtr pScrn;
+	ScrnInfoPtr pScrn = NULL;
 	EntityInfoPtr pEnt;
 #ifdef DISABLE_VGA_IO
 	MgaSavePtr smga;

commit 55d219394ad6af8e25ff604bcbb49d5a551bd348
Author: Ian Romanick <idr@us.ibm.com>
Date:   Wed Aug 22 10:43:39 2007 -0700

    Merge PCI-rework support and "classic" PCI interface support into one tree
    
    First pass at merging both trees.  So far, this has only been tested
    on the PCI-rework build on a PCI G450.

diff --git a/configure.ac b/configure.ac
index fed3e39..7d37153 100644
--- a/configure.ac
+++ b/configure.ac
@@ -60,6 +60,11 @@ AC_ARG_ENABLE(exa,
                              [Disable EXA support [[default=enabled]]]),
               [EXA="$enableval"],
               [EXA=yes])
+AC_ARG_ENABLE(pciaccess,
+              AS_HELP_STRING([--enable-pciaccess],
+                             [Enable use of libpciaccess (default: disabled)]),
+              [PCIACCESS=$enableval],
+              [PCIACCESS=no])
 
 # Checks for extensions
 XORG_DRIVER_CHECK_EXT(RANDR, randrproto)
@@ -71,12 +76,19 @@ XORG_DRIVER_CHECK_EXT(DPMSExtension, xextproto)
 PKG_CHECK_MODULES(XORG, [xorg-server >= 1.1.0 xproto fontsproto $REQUIRED_MODULES])
 sdkdir=$(pkg-config --variable=sdkdir xorg-server)
 
+AM_CONDITIONAL(PCIACCESS, [test "x$PCIACCESS" = xyes])
+if test "x$PCIACCESS" = xyes; then
+    AC_DEFINE(PCIACCESS, 1, [Use libpciaccess])
+    PKG_CHECK_MODULES([PCIACCESS], [pciaccess >= 0.7.0])
+    XORG_CFLAGS="$XORG_CFLAGS $PCIACCESS_CFLAGS"
+fi
+
 # Checks for libraries.
 
 # Checks for header files.
 AC_HEADER_STDC
 
-if test "x$DRI" = xauto; then
+if test "x$DRI" != xno; then
         AC_CHECK_FILE([${sdkdir}/dri.h],
                       [have_dri_h="yes"], [have_dri_h="no"])
         AC_CHECK_FILE([${sdkdir}/sarea.h],
@@ -99,7 +111,7 @@ AC_MSG_RESULT([$DRI])
 
 AM_CONDITIONAL(DRI, test "x$DRI" = xyes)
 if test "x$DRI" = xyes; then
-        PKG_CHECK_MODULES(DRI, [libdrm >= 2.0 xf86driproto glproto])
+        PKG_CHECK_MODULES(DRI, [libdrm >= 2.0 xf86driproto])
         AC_DEFINE(XF86DRI,1,[Enable DRI driver support])
         AC_DEFINE(XF86DRI_DEVEL,1,[Enable developmental DRI driver support])
 fi
diff --git a/src/clientlx.c b/src/clientlx.c
index 7291718..8c08026 100644
--- a/src/clientlx.c
+++ b/src/clientlx.c
@@ -67,7 +67,11 @@ ULONG ClientReadConfigSpaceByte(LPBOARDHANDLE pBoard, ULONG ulOffset,
 
     ASSERT_HANDLER(pBoard);
 
+#ifdef PCIACCESS
     pci_device_cfg_read_u8(pMga->PciInfo, pucByte, ulOffset);
+#else
+    *pucByte = pciReadByte(pMga->PciTag,ulOffset);
+#endif
 
     return 0;
 }
@@ -95,7 +99,11 @@ ULONG ClientReadConfigSpaceDword(LPBOARDHANDLE pBoard, ULONG ulOffset,
 
     ASSERT_HANDLER(pBoard);
 
+#ifdef PCIACCESS
     pci_device_cfg_read_u32(pMga->PciInfo, (uint32_t *) pulDword, ulOffset);
+#else
+    *pulDword = pciReadLong(pMga->PciTag,ulOffset);
+#endif
 
     return 0;
 }
@@ -123,7 +131,11 @@ ULONG ClientWriteConfigSpaceByte(LPBOARDHANDLE pBoard, ULONG ulOffset,
 
     ASSERT_HANDLER(pBoard);
 
+#ifdef PCIACCESS
     pci_device_cfg_write_u8(pMga->PciInfo, ucByte, ulOffset);
+#else
+    pciWriteByte(pMga->PciTag,ulOffset, ucByte);
+#endif
 
     return 0;
 }
@@ -151,7 +163,11 @@ ULONG ClientWriteConfigSpaceDword(LPBOARDHANDLE pBoard, ULONG ulOffset,
 
     ASSERT_HANDLER(pBoard);
 
+#ifdef PCIACCESS
     pci_device_cfg_write_u32(pMga->PciInfo, (uint32_t) ulDword, ulOffset);
+#else
+    pciWriteLong(pMga->PciTag,ulOffset, ulDword);
+#endif
 
     return 0;
 }
diff --git a/src/mga.h b/src/mga.h
index 00f4741..673ec1d 100644
--- a/src/mga.h
+++ b/src/mga.h
@@ -14,7 +14,9 @@
 #ifndef MGA_H
 #define MGA_H
 
+#ifdef PCIACCESS
 #include <pciaccess.h>
+#endif
 #include <string.h>
 #include <stdio.h>
 
@@ -287,7 +289,11 @@ typedef struct {
 
 #ifdef DISABLE_VGA_IO
 typedef struct mgaSave {
+#ifdef PCIACCESS
     struct pci_device * pvp;
+#else
+    pciVideoPtr pvp;
+#endif
     Bool enable;
 } MgaSave, *MgaSavePtr;
 #endif
@@ -435,7 +441,12 @@ typedef struct {
     EntityInfoPtr	pEnt;
     struct mga_bios_values bios;
     CARD8               BiosOutputMode;
+#ifdef PCIACCESS
     struct pci_device *	PciInfo;
+#else
+    pciVideoPtr		PciInfo;
+    PCITAG		PciTag;
+#endif
     const struct mga_device_attributes * chip_attribs;
     xf86AccessRec	Access;
     int			Chipset;
@@ -471,7 +482,12 @@ typedef struct {
      */
     int                 iload_bar;
 
-
+#ifndef PCIACCESS
+    unsigned long	IOAddress;
+    unsigned long	ILOADAddress;
+    unsigned long	BiosAddress;
+    MessageType		BiosFrom;
+#endif
     unsigned long	FbAddress;
     unsigned char *     IOBase;
     unsigned char *	FbBase;
diff --git a/src/mga_bios.c b/src/mga_bios.c
index 34dcf7a..46a8c46 100644
--- a/src/mga_bios.c
+++ b/src/mga_bios.c
@@ -406,9 +406,12 @@ static void mga_parse_bios_ver_5( struct mga_bios_values * bios,
 
 Bool mga_read_and_process_bios( ScrnInfoPtr pScrn )
 {
-    CARD8  bios_data[0x10000];
+    CARD8  bios_data[0x20000];
     unsigned offset;
     MGAPtr pMga = MGAPTR(pScrn);
+#ifndef PCIACCESS
+    Bool pciBIOS = TRUE;
+#endif
     int rlen;
     static const unsigned expected_length[] = { 0, 64, 64, 64, 128, 128 };
     unsigned version;
@@ -443,7 +446,28 @@ Bool mga_read_and_process_bios( ScrnInfoPtr pScrn )
      * might be controlled by the PCI config space.
      */
 
+#ifdef PCIACCESS
     err = pci_device_read_rom(pMga->PciInfo, bios_data);
+#else
+    if (pMga->BiosFrom == X_DEFAULT) {
+	pciBIOS = FALSE;
+    }
+    else if (pMga->BiosFrom == X_CONFIG && pMga->BiosAddress < 0x100000) {
+	pciBIOS = TRUE;
+    }
+
+    if (pciBIOS) {
+	rlen = xf86ReadPciBIOS(0, pMga->PciTag, pMga->framebuffer_bar,
+			       bios_data, sizeof(bios_data));
+    }
+    else {
+	rlen = xf86ReadDomainMemory(pMga->PciTag, pMga->BiosAddress,
+				    sizeof(bios_data), bios_data);
+    }
+
+    err = rlen < (bios_data[2] << 9);
+#endif
+
     if (err) {
 	xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
 		   "Could not retrieve video BIOS!\n");
diff --git a/src/mga_dac3026.c b/src/mga_dac3026.c
index 9926017..254f6e2 100644
--- a/src/mga_dac3026.c
+++ b/src/mga_dac3026.c
@@ -746,8 +746,13 @@ MGA3026Restore(ScrnInfoPtr pScrn, vgaRegPtr vgaReg, MGARegPtr mgaReg,
 	for (i = 0; i < 6; i++)
 		OUTREG16(0x1FDE, (mgaReg->ExtVga[i] << 8) | i);
 
+#ifdef PCIACCESS
 	pci_device_cfg_write_bits(pMga->PciInfo, OPTION_MASK, mgaReg->Option,
 				  PCI_OPTION_REG);
+#else
+	pciSetBitsLong(pMga->PciTag, PCI_OPTION_REG, OPTION_MASK,
+		       mgaReg->Option);
+#endif
 
 	MGA_NOT_HAL(
 	/* select pixel clock PLL as clock source */
@@ -866,8 +871,12 @@ MGA3026Save(ScrnInfoPtr pScrn, vgaRegPtr vgaReg, MGARegPtr mgaReg,
 	for (i = 0; i < DACREGSIZE; i++)
 		mgaReg->DacRegs[i]	 = inTi3026(MGADACregs[i]);
 	
+#ifdef PCIACCESS
 	pci_device_cfg_read_u32(pMga->PciInfo, & mgaReg->Option, 
 				PCI_OPTION_REG);
+#else
+	mgaReg->Option = pciReadLong(pMga->PciTag, PCI_OPTION_REG);
+#endif
 	
 #ifdef DEBUG		
 	ErrorF("read: %02X %02X %02X	%02X %02X %02X	%08lX\n",
diff --git a/src/mga_dacG.c b/src/mga_dacG.c
index 350c160..f135ad5 100644
--- a/src/mga_dacG.c
+++ b/src/mga_dacG.c
@@ -771,6 +771,7 @@ MGA_NOT_HAL(
 	   
 	   if (!MGAISGx50(pMga)) {
 	       /* restore pci_option register */
+#ifdef PCIACCESS
 	       pci_device_cfg_write_bits(pMga->PciInfo, optionMask, 
 					 mgaReg->Option, PCI_OPTION_REG);
 
@@ -785,6 +786,17 @@ MGA_NOT_HAL(
 						PCI_MGA_OPTION3);
 		  }
 	      }
+#else
+	      /* restore pci_option register */
+	      pciSetBitsLong(pMga->PciTag, PCI_OPTION_REG, optionMask,
+			     mgaReg->Option);
+	      if (pMga->Chipset != PCI_CHIP_MGA1064)
+		 pciSetBitsLong(pMga->PciTag, PCI_MGA_OPTION2, OPTION2_MASK,
+				mgaReg->Option2);
+	      if (pMga->Chipset == PCI_CHIP_MGAG400 || pMga->Chipset == PCI_CHIP_MGAG550)
+		 pciSetBitsLong(pMga->PciTag, PCI_MGA_OPTION3, OPTION3_MASK,
+				mgaReg->Option3);
+#endif
 	   }
 );	/* MGA_NOT_HAL */
 #ifdef USEMGAHAL
@@ -948,14 +960,23 @@ MGAGSave(ScrnInfoPtr pScrn, vgaRegPtr vgaReg, MGARegPtr mgaReg,
 
         mgaReg->PIXPLLCSaved = TRUE;
 
+#ifdef PCIACCESS
 	pci_device_cfg_read_u32(pMga->PciInfo, & mgaReg->Option,
 				PCI_OPTION_REG);
 	pci_device_cfg_read_u32(pMga->PciInfo, & mgaReg->Option2,
 				PCI_MGA_OPTION2);
+#else
+	mgaReg->Option = pciReadLong(pMga->PciTag, PCI_OPTION_REG);
 
+	mgaReg->Option2 = pciReadLong(pMga->PciTag, PCI_MGA_OPTION2);
+#endif
 	if (pMga->Chipset == PCI_CHIP_MGAG400 || pMga->Chipset == PCI_CHIP_MGAG550)
+#ifdef PCIACCESS
 		    pci_device_cfg_read_u32(pMga->PciInfo, & mgaReg->Option3,
 					    PCI_MGA_OPTION3);
+#else
+	    mgaReg->Option3 = pciReadLong(pMga->PciTag, PCI_MGA_OPTION3);
+#endif
 	);	/* MGA_NOT_HAL */
 
 	for (i = 0; i < 6; i++)
diff --git a/src/mga_dri.c b/src/mga_dri.c
index bb2cc39..a8bea66 100644
--- a/src/mga_dri.c
+++ b/src/mga_dri.c
@@ -608,8 +608,8 @@ static Bool MGADRIBootstrapDMA(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,
-		    pMga->PciInfo->vendor_id,
-		    pMga->PciInfo->device_id );
+		    VENDOR_ID(pMga->PciInfo),
+		    DEVICE_ID(pMga->PciInfo));
 
 	if ( drmAgpEnable( pMga->drmFD, mode ) < 0 ) {
 	    xf86DrvMsg( pScreen->myNum, X_ERROR, "[agp] AGP not enabled\n" );
@@ -756,7 +756,7 @@ static Bool MGADRIBootstrapDMA(ScreenPtr pScreen)
 	pMGADRIServer->registers.size = MGAIOMAPSIZE;
 
 	if ( drmAddMap( pMga->drmFD,
-			(drm_handle_t)pMga->PciInfo->regions[ pMga->io_bar ].base_addr,
+			(drm_handle_t) MGA_IO_ADDRESS(pMga),
 			pMGADRIServer->registers.size,
 			DRM_REGISTERS, DRM_READ_ONLY,
 			&pMGADRIServer->registers.handle ) < 0 ) {
@@ -851,10 +851,17 @@ static void MGADRIIrqInit(MGAPtr pMga, ScreenPtr pScreen)
 
    if (!pMga->irq) {
       pMga->irq = drmGetInterruptFromBusID(pMga->drmFD,
+#ifdef PCIACCESS
 					   ((pMga->PciInfo->domain << 8) |
 					    pMga->PciInfo->bus),
 					   pMga->PciInfo->dev,
-					   pMga->PciInfo->func);
+					   pMga->PciInfo->func
+#else
+	 ((pciConfigPtr)pMga->PciInfo->thisCard)->busnum,
+	 ((pciConfigPtr)pMga->PciInfo->thisCard)->devnum,
+	 ((pciConfigPtr)pMga->PciInfo->thisCard)->funcnum
+#endif
+					   );
 
       if((drmCtlInstHandler(pMga->drmFD, pMga->irq)) != 0) {
 	 xf86DrvMsg(pScrn->scrnIndex, X_INFO,
@@ -1153,10 +1160,15 @@ Bool MGADRIScreenInit( ScreenPtr pScreen )
    } else {
       pDRIInfo->busIdString = xalloc(64);
       sprintf( pDRIInfo->busIdString, "PCI:%d:%d:%d",
-					    ((pMga->PciInfo->domain << 8) |
-					     pMga->PciInfo->bus),
-					    pMga->PciInfo->dev,
-					    pMga->PciInfo->func );
+#ifdef PCIACCESS
+	       ((pMga->PciInfo->domain << 8) | pMga->PciInfo->bus),
+	       pMga->PciInfo->dev, pMga->PciInfo->func
+#else
+	       ((pciConfigPtr)pMga->PciInfo->thisCard)->busnum,
+	       ((pciConfigPtr)pMga->PciInfo->thisCard)->devnum,
+	       ((pciConfigPtr)pMga->PciInfo->thisCard)->funcnum
+#endif
+	       );
    }
    pDRIInfo->ddxDriverMajorVersion = PACKAGE_VERSION_MAJOR;
    pDRIInfo->ddxDriverMinorVersion = PACKAGE_VERSION_MINOR;
diff --git a/src/mga_driver.c b/src/mga_driver.c
index 008cd55..2d054cf 100644
--- a/src/mga_driver.c
+++ b/src/mga_driver.c
@@ -63,6 +63,11 @@
 /* Drivers for PCI hardware need this */
 #include "xf86PciInfo.h"
 
+/* Drivers that need to access the PCI config space directly need this */
+#ifndef PCIACCESS
+#include "xf86Pci.h"
+#endif
+
 /* All drivers initialising the SW cursor need this */
 #include "mipointer.h"
 
@@ -106,8 +111,12 @@
 /* Mandatory functions */
 static const OptionInfoRec *	MGAAvailableOptions(int chipid, int busid);
 static void	MGAIdentify(int flags);
+#ifdef PCIACCESS
 static Bool MGAPciProbe(DriverPtr drv, int entity_num,
     struct pci_device * dev, intptr_t match_data);
+#else
+static Bool	MGAProbe(DriverPtr drv, int flags);
+#endif
 static Bool	MGAPreInit(ScrnInfoPtr pScrn, int flags);
 static Bool	MGAScreenInit(int Index, ScreenPtr pScreen, int argc,
 			      char **argv);
@@ -183,6 +192,7 @@ static const struct mga_device_attributes attribs[8] = {
             (TRANSC_SOLID_FILL | TWO_PASS_COLOR_EXPAND | USE_LINEAR_EXPANSION) },
 };
 
+#ifdef PCIACCESS
 #define MGA_DEVICE_MATCH(d, i) \
     { 0x102B, (d), PCI_MATCH_ANY, PCI_MATCH_ANY, 0, 0, (i) }
 #define MGA_SUBDEVICE_MATCH(d, s, i) \
@@ -205,6 +215,7 @@ static const struct pci_id_match mga_device_match[] = {
 



Reply to: