xf86-video-ati: Branch 'pci-rework'

George Sapountzis gsap7 at kemper.freedesktop.org
Tue Mar 13 22:16:59 EET 2007


 src/atimode.c    |    7 ++++--
 src/atipreinit.c |   58 ++++++++++++++++---------------------------------------
 src/atiprobe.c   |    9 +++-----
 src/atividmem.c  |   12 ++++++-----
 4 files changed, 33 insertions(+), 53 deletions(-)

New commits:
diff-tree 5021e6ae0ab2351baf2105c17776e75a8e406e90 (from 0d17cfda5f5d690eb5fbf1cc1d6dbac06dbdee7a)
Author: George Sapountzis <gsap7 at yahoo.gr>
Date:   Tue Mar 13 22:09:08 2007 +0200

    [mach64] Compute MMIO address once during probe.
    
    For MMIO, the MMIO address is set by ATIMach64ProbeIO().
    
    For CPIO, the MMIO address is set when we read the adapter's
    linear aperture configuration, this mapping is a no-op.

diff --git a/src/atimode.c b/src/atimode.c
index 68c1342..2b5d823 100644
--- a/src/atimode.c
+++ b/src/atimode.c
@@ -933,15 +933,16 @@ ATIModeSet
             /* Load Mach64 registers */
             {
                 /* Load MMIO registers */
-                if (pATI->Block0Base)
-                    ATIMach64Set(pATI, pATIHW);
+                ATIMach64Set(pATI, pATIHW);
 
                 outr(CRTC_GEN_CNTL, pATIHW->crtc_gen_cntl);
+
                 outr(CUR_CLR0, pATIHW->cur_clr0);
                 outr(CUR_CLR1, pATIHW->cur_clr1);
                 outr(CUR_OFFSET, pATIHW->cur_offset);
                 outr(CUR_HORZ_VERT_POSN, pATIHW->cur_horz_vert_posn);
                 outr(CUR_HORZ_VERT_OFF, pATIHW->cur_horz_vert_off);
+
                 outr(BUS_CNTL, pATIHW->bus_cntl);
                 outr(MEM_VGA_WP_SEL, pATIHW->mem_vga_wp_sel);
                 outr(MEM_VGA_RP_SEL, pATIHW->mem_vga_rp_sel);
@@ -950,6 +951,7 @@ ATIModeSet
                 outr(GEN_TEST_CNTL, pATIHW->gen_test_cntl);
                 outr(GEN_TEST_CNTL, pATIHW->gen_test_cntl | GEN_GUI_EN);
                 outr(CONFIG_CNTL, pATIHW->config_cntl);
+
                 if (pATI->Chip >= ATI_CHIP_264CT)
                 {
                     outr(CRTC_H_TOTAL_DISP, pATIHW->crtc_h_total_disp);
@@ -957,6 +959,7 @@ ATIModeSet
                     outr(CRTC_V_TOTAL_DISP, pATIHW->crtc_v_total_disp);
                     outr(CRTC_V_SYNC_STRT_WID, pATIHW->crtc_v_sync_strt_wid);
                     outr(CRTC_OFF_PITCH, pATIHW->crtc_off_pitch);
+
                     if (pATI->Chip >= ATI_CHIP_264VTB)
                     {
                         outr(MEM_CNTL, pATIHW->mem_cntl);
diff --git a/src/atipreinit.c b/src/atipreinit.c
index db4d574..0e5b48c 100644
--- a/src/atipreinit.c
+++ b/src/atipreinit.c
@@ -422,46 +422,12 @@ 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;
-        }
-
-            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->MMIOInLinear = TRUE;
-
-                            pATI->Block0Base += 0x007FFC00U;
-                            ATIMach64Map(pScreenInfo->scrnIndex, pATI);
-                            if (pATI->pBlock[0])
-                                break;
-
-                            pATI->Block0Base -= 0x00400000U;
-                            ATIMach64Map(pScreenInfo->scrnIndex, pATI);
-                            if (pATI->pBlock[0])
-                                break;
-                        }
-                }
-
-                ATIMach64Map(pScreenInfo->scrnIndex, pATI);
-            } while (0);
+            /*
+             * For MMIO, the MMIO address is set by ATIMach64ProbeIO().
+             * For CPIO, the MMIO address is set when we read the adapter's
+             * linear aperture configuration, this mapping is a no-op.
+             */
+            ATIMach64Map(pScreenInfo->scrnIndex, pATI);
 
 #ifdef AVOID_CPIO
 
@@ -1803,14 +1769,24 @@ ATIPreInit
             {
                 int AcceleratorVideoRAM = 0, ServerVideoRAM;
 
+                /* 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;
+                }
+
                 /*
                  * Unless specified in PCI configuration space, set MMIO
                  * address to tail end of linear aperture.
                  */
-                if (pATI->MMIOInLinear)
+                if (!pATI->Block0Base)
                 {
                     pATI->Block0Base =
                         pATI->LinearBase + pATI->LinearSize - 0x00000400U;
+                    pATI->MMIOInLinear = TRUE;
                 }
 
                 AcceleratorVideoRAM = pATI->LinearSize >> 10;
diff --git a/src/atiprobe.c b/src/atiprobe.c
index 6e8681a..dcbcd27 100644
--- a/src/atiprobe.c
+++ b/src/atiprobe.c
@@ -227,7 +227,10 @@ ATIMach64Probe
             (pATI->Block0Base < (CARD32)(-1 << pVideo->size[2])))
         {
             pATI->Block0Base += 0x00000400U;
-            goto LastProbe;
+            if (ATIMach64Detect(pATI, ChipType, Chip))
+                return pATI;
+
+            return NULL;
         }
 
         /*
@@ -249,10 +252,6 @@ ATIMach64Probe
                 return pATI;
         }
 
-LastProbe:
-    if (ATIMach64Detect(pATI, ChipType, Chip))
-        return pATI;
-
     return NULL;
 }
 
diff --git a/src/atividmem.c b/src/atividmem.c
index 632987a..043bfe4 100644
--- a/src/atividmem.c
+++ b/src/atividmem.c
@@ -137,9 +137,9 @@ ATIUnmapMMIO
  * This function maps all apertures used by the driver.
  *
  * It is called three times:
- * - to determine between sparse CPIO, block CPIO and MMIO
- * - to setup MMIO (with Block0Base set)
- * - to setup MMIO and FB (with LinearBase set)
+ * - 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
@@ -176,6 +176,7 @@ ATIMapApertures
 #endif /* AVOID_CPIO */
 
     /* Map linear aperture */
+    if (pATI->LinearBase || (pATI->Block0Base && pATI->MMIOInLinear))
     {
         mode = VIDMEM_FRAMEBUFFER;
 
@@ -264,8 +265,9 @@ ATIMapApertures
         pATI->pMMIO = NULL;
 
         /* Check that requested MMIO offset falls in the linear aperture. This
-         * assumes that old mach64 cards with a 4MB linear aperture do not have
-         * an extended BE aperture which would give a size of 8MB.
+         * ensures that we do not poke outside a mapped region and bails early
+         * for old mach64 cards with a 4MB linear aperture (unless they have an
+         * extended BE aperture which would give a size of 8MB).
          */
         if (mmio_offset + 0x00000400U > linear_size)
         {



More information about the xorg-commit mailing list