Marco Pieruccetti wrote:
cd2k1 wrote:
Looking at your screenshot, I had the same problem. Now with the
experimental driver it runs smooth :)


I use latest release downloaded (0.2.901).... how can i get experimental driver ?

svn co http://svn.openchrome.org/svn/branches/experimental_branch

But the experimental branch will not bring you anything over the release. It is actually a bit behind trunk/release, but has libpciaccess support added and I do not believe this is the problem you are having.

Alternatively, the attached patch backports experimental branch libpciaccess changes and applies to 0.2.901.


You are not using the modelines you added. Your screen section should look like that :

Section "Screen"
        Identifier      "Default Screen"
        Device          "Scheda video generica"
        Monitor         "SyncMaster"
        DefaultDepth    24
        SubSection "Display"
                Modes           "1280x1024_60.00" "1280x1024R"
        EndSubSection
EndSection


Xavier,
with right lines added, nothing is changed.... :-(
I attach Xorg.0.log, seems that only 1280x1024_60.00 mode was recognized.
It was recognized, but was it used ? You forgot to actually attach the log.

The 1280x1024R mode produce following message:
"monitor doesn't support reduced blanking"

ah, yes. Add Option "ReducedAllowed" "TRUE" to the monitor section. Assuming this is a flat panel that allows reduced blanking, but they all do afaik.

Regards,
Xavier
Index: configure.ac
===================================================================
--- configure.ac	(revision 489)
+++ configure.ac	(working copy)
@@ -77,7 +77,15 @@
 
 # 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],
                       [have_dri_h="yes"], [have_dri_h="no"])
@@ -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,8 +151,10 @@
         echo -n "xf86Module.h not found, "
 fi
 
-CPPFLAGS="$SAVE_CPPFLAGS"
+CFLAGS="$SAVE_CFLAGS"
 
+
+
 if test "x$OLD_XVABI" = xyes; then
                 echo "yes."
 else
@@ -156,6 +162,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])
Index: src/via_driver.c
===================================================================
--- src/via_driver.c	(revision 489)
+++ src/via_driver.c	(working copy)
@@ -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);
@@ -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,7 +455,7 @@
     {0, 0, 0, 0}
 };
 
-XF86ModuleData openchromeModuleData = { &VIAVersRec, VIASetup, NULL };
+_X_EXPORT XF86ModuleData openchromeModuleData = { &VIAVersRec, VIASetup, NULL };
 
 
 static pointer
@@ -412,7 +465,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 +559,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 = "VIA";
+        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;
@@ -543,6 +643,7 @@
         for (i = 0; i < numUsed; i++) {
             ScrnInfoPtr pScrn = xf86AllocateScreen(drv, 0);
             EntityInfoPtr pEnt;
+            
             if ((pScrn = xf86ConfigPciEntity(pScrn, 0, usedChips[i],
                  VIAPciChipsets, 0, 0, 0, 0, 0)))
             {
@@ -610,6 +711,7 @@
     return foundScreen;
 
 } /* VIAProbe */
+#endif /* else XSERVER_LIBPCIACCESS */
 
 #ifdef XF86DRI
 static void kickVblank(ScrnInfoPtr pScrn)
@@ -756,6 +858,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 +1045,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 +1055,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)
@@ -1378,8 +1493,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);
@@ -1407,7 +1524,9 @@
     xf86DrvMsg(pScrn->scrnIndex, X_INFO, 
 	       "...Finished parsing config file options.\n");
 
+#ifndef XSERVER_LIBPCIACCESS
     ViaCheckCardId(pScrn);   
+#endif
 
     /* Read memory bandwidth from registers */
     pVia->MemClk = hwp->readCrtc(hwp, 0x3D) >> 4;
@@ -1440,6 +1559,65 @@
         return FALSE;
     }
 
+    from = X_PROBED;
+
+    /* Detect the amount of installed RAM */
+    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 ;
+            break;
+#endif
+        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 ;
+            break;
+#endif
+        case VIA_K8M890:
+        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 ;
+            break;
+#endif
+        default:
+            if (pScrn->videoRam < 16384 || pScrn->videoRam > 65536) {
+                xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
+                          "Using old memory-detection method.");
+                bMemSize = hwp->readSeq(hwp, 0x39);
+                if (bMemSize > 16 && bMemSize <= 128)
+                    pScrn->videoRam = (bMemSize + 1) << 9;
+                else if (bMemSize > 0 && bMemSize < 31)
+                    pScrn->videoRam = bMemSize << 12;
+                else {
+                    from = X_DEFAULT;
+                    xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
+                               "Memory size detection failed: using 16 MB.\n");
+                    pScrn->videoRam = 16 << 10;
+                }
+            } else {
+                from = X_DEFAULT;
+                xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
+                          "No memory-detection done.  Use VideoRAM option.");
+            }
+    }
+
+    if (from == X_PROBED)
+        xf86DrvMsg(pScrn->scrnIndex, from, "Probed VideoRAM = %d kB\n",
+                   pScrn->videoRam);
+
     /* Split FB for SAMM */
     /* FIXME: For now, split FB into two equal sections. This should
      *        be able to be adjusted by user with a config option. */
@@ -2046,27 +2224,75 @@
 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,
                    "Internal error: cound not map registers\n");
@@ -2111,6 +2337,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 +2354,7 @@
 	 * in the OS support layer.
 	 */
 
+#ifndef XSERVER_LIBPCIACCESS
         unsigned char *tmp; 
         tmp = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_MMIO,
 			    pVia->PciTag, pVia->FrameBufferBase,
@@ -2143,10 +2373,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 +2400,7 @@
                        "Internal error: could not map framebuffer\n");
             return FALSE;
         }
+#endif
 
         pVia->FBFreeStart = (pScrn->displayWidth * pScrn->bitsPerPixel >> 3) *
                             pScrn->virtualY;
@@ -2166,7 +2411,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,7 +2433,17 @@
     /* 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);
 
     if (pVia->BltBase)
@@ -2192,6 +2451,7 @@
 
     if (pVia->FBBase)
         xf86UnMapVidMem(pScrn->scrnIndex, (pointer)pVia->FBBase, pVia->videoRambytes);
+#endif
 }
 
 static void
Index: src/via_driver.h
===================================================================
--- src/via_driver.h	(revision 489)
+++ src/via_driver.h	(working copy)
@@ -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;
Index: src/via_dri.c
===================================================================
--- src/via_dri.c	(revision 489)
+++ src/via_dri.c	(working copy)
@@ -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;
Index: src/via.h
===================================================================
--- src/via.h	(revision 489)
+++ src/via.h	(working copy)
@@ -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_ */
Index: src/via_id.c
===================================================================
--- src/via_id.c	(revision 489)
+++ src/via_id.c	(working copy)
@@ -212,6 +212,7 @@
     hwp->writeCrtc(hwp, 0x4F, tmp);
 }
 
+#ifndef XSERVER_LIBPCIACCESS
 void
 ViaCheckCardId(ScrnInfoPtr pScrn)
 {
@@ -238,4 +239,4 @@
 	       pVia->PciInfo->chipType, pVia->PciInfo->subsysVendor, pVia->PciInfo->subsysCard);
     pVia->Id = NULL;
 }
-
+#endif
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 489)
+++ ChangeLog	(working copy)
@@ -1,3 +1,11 @@
+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):
_______________________________________________
openchrome-users mailing list
[email protected]
http://wiki.openchrome.org/mailman/listinfo/openchrome-users
Main page:
http://www.openchrome.org
Wiki:
http://wiki.openchrome.org
User Forum:
http://wiki.openchrome.org/tikiwiki/tiki-view_forum.php?forumId=1

Reply via email to