XF4 (mach64) help please

Ani Joshi ajoshi at shell.unixbox.com
Tue Apr 17 14:07:34 EST 2001



On Mon, 16 Apr 2001, Michel [iso-8859-1] Dänzer wrote:

> > fbdevHWInit failed
> > crapping out here
>
> Do you use atyfb in console? The ati driver only works with that with option
> "UseFBDev". No idea what it will do without that option, you'd have to find
> out.

No, the "UseFBDev" option is totally useless in that version of the driver
as it is hardcoded to force the use of fbdevhw.

The attatched patch fixes the ati driver properly without the use of
fbdev.  Don't bother to try the option, it is not even implemented in the
driver.  The patch is against a current cvs tree.  If you try to hand
patch it against that older version with the fbdev hacks you will run into
problems as getting rid of the hacks is painful and time consuming.

I'm fairly sure this patch will be fine for all nonGX mach64's, although
I'm not entirely sure about the Lx/Mobility ones as I don't have one to
hack with.  Feedback is very welcome.


ani
-------------- next part --------------
diff -uNr ati.orig/atimach64.c ati/atimach64.c
--- ati.orig/atimach64.c	Mon Apr 16 19:09:31 2001
+++ ati/atimach64.c	Mon Apr 16 19:09:25 2001
@@ -111,7 +111,13 @@
     }
 
     bus_cntl = inr(BUS_CNTL);
+#if !defined(__powerpc__)
     pATIHW->bus_cntl = (bus_cntl & ~BUS_HOST_ERR_INT_EN) | BUS_HOST_ERR_INT;
+#else
+    pATIHW->bus_cntl = bus_cntl;
+    pATIHW->config_cntl = inr(CONFIG_CNTL);
+#endif
+#if !defined(__powerpc__)
     if (pATI->Chip < ATI_CHIP_264VTB)
     {
         pATIHW->bus_cntl &= ~(BUS_FIFO_ERR_INT_EN | BUS_ROM_DIS);
@@ -175,12 +181,17 @@
         else
             pATIHW->config_cntl |= SetBits(2, CFG_MEM_AP_SIZE);
     }
+#endif /* !__powerpc__ */
 
     if (pATI->Chip >= ATI_CHIP_264VTB)
     {
+#if !defined(__powerpc__)
         pATIHW->mem_cntl = (pATI->LockData.mem_cntl &
             ~(CTL_MEM_LOWER_APER_ENDIAN | CTL_MEM_UPPER_APER_ENDIAN)) |
             SetBits(CTL_MEM_APER_BYTE_ENDIAN, CTL_MEM_LOWER_APER_ENDIAN);
+#else
+	pATIHW->mem_cntl = inr(MEM_CNTL);
+#endif
 
         switch (pATI->bitsPerPixel)
         {
@@ -190,13 +201,21 @@
                 break;
 
             case 16:
+#if X_BYTE_ORDER == X_LITTLE_ENDIAN
                 pATIHW->mem_cntl |= SetBits(CTL_MEM_APER_WORD_ENDIAN,
                     CTL_MEM_UPPER_APER_ENDIAN);
+#else
+		pATIHW->mem_cntl |= 0x4000000;
+#endif
                 break;
 
             case 32:
+#if X_BYTE_ORDER == X_LITTLE_ENDIAN
                 pATIHW->mem_cntl |= SetBits(CTL_MEM_APER_LONG_ENDIAN,
                     CTL_MEM_UPPER_APER_ENDIAN);
+#else
+		pATIHW->mem_cntl |= 0x8000000;
+#endif
                 break;
         }
     }
@@ -781,6 +800,7 @@
         }
     }
 
+#if !defined(__powerpc__)
     /* Aperture setup */
     outr(MEM_VGA_WP_SEL, pATIHW->mem_vga_wp_sel);
     outr(MEM_VGA_RP_SEL, pATIHW->mem_vga_rp_sel);
@@ -789,6 +809,7 @@
 
     outr(CONFIG_CNTL, pATIHW->config_cntl);
     outr(BUS_CNTL, pATIHW->bus_cntl);
+#endif
 
     if (pATI->Chip >= ATI_CHIP_264VTB)
         outr(MEM_CNTL, pATIHW->mem_cntl);
@@ -1600,6 +1621,24 @@
          */
         switch (iDWord)
         {
+#if X_BYTE_ORDER == X_BIG_ENDIAN
+            case  0:  xf86WriteMmio32Be(pDst +  0, 0, *(pSrc +  0));
+            case  1:  xf86WriteMmio32Be(pDst +  1, 0, *(pSrc +  1));
+            case  2:  xf86WriteMmio32Be(pDst +  2, 0, *(pSrc +  2));
+            case  3:  xf86WriteMmio32Be(pDst +  3, 0, *(pSrc +  3));
+            case  4:  xf86WriteMmio32Be(pDst +  4, 0, *(pSrc +  4));
+            case  5:  xf86WriteMmio32Be(pDst +  5, 0, *(pSrc +  5));
+            case  6:  xf86WriteMmio32Be(pDst +  6, 0, *(pSrc +  6));
+            case  7:  xf86WriteMmio32Be(pDst +  7, 0, *(pSrc +  7));
+            case  8:  xf86WriteMmio32Be(pDst +  8, 0, *(pSrc +  8));
+            case  9:  xf86WriteMmio32Be(pDst +  9, 0, *(pSrc +  9));
+            case 10:  xf86WriteMmio32Be(pDst + 10, 0, *(pSrc + 10));
+            case 11:  xf86WriteMmio32Be(pDst + 11, 0, *(pSrc + 11));
+            case 12:  xf86WriteMmio32Be(pDst + 12, 0, *(pSrc + 12));
+            case 13:  xf86WriteMmio32Be(pDst + 13, 0, *(pSrc + 13));
+            case 14:  xf86WriteMmio32Be(pDst + 14, 0, *(pSrc + 14));
+            case 15:  xf86WriteMmio32Be(pDst + 15, 0, *(pSrc + 15));
+#else
             case  0:  MMIO_OUT32(pDst +  0, 0, *(pSrc +  0));
             case  1:  MMIO_OUT32(pDst +  1, 0, *(pSrc +  1));
             case  2:  MMIO_OUT32(pDst +  2, 0, *(pSrc +  2));
@@ -1616,6 +1655,7 @@
             case 13:  MMIO_OUT32(pDst + 13, 0, *(pSrc + 13));
             case 14:  MMIO_OUT32(pDst + 14, 0, *(pSrc + 14));
             case 15:  MMIO_OUT32(pDst + 15, 0, *(pSrc + 15));
+#endif
 
             default:    /* Muffle compiler */
                 break;
@@ -1682,7 +1722,10 @@
      * Use scanline version of colour expansion, not only for the non-ix86
      * case, but also to avoid PCI retries.
      */
-    pXAAInfo->ScanlineCPUToScreenColorExpandFillFlags =
+#if X_BYTE_ORDER == X_BIG_ENDIAN
+    pXAAInfo->ScanlineCPUToScreenColorExpandFillFlags = BIT_ORDER_IN_BYTE_MSBFIRST;
+#endif
+    pXAAInfo->ScanlineCPUToScreenColorExpandFillFlags |=
         LEFT_EDGE_CLIPPING | LEFT_EDGE_CLIPPING_NEGATIVE_X |
         CPU_TRANSFER_PAD_DWORD | SCANLINE_PAD_DWORD;
     if (pATI->XModifier != 1)
diff -uNr ati.orig/atipreinit.c ati/atipreinit.c
--- ati.orig/atipreinit.c	Mon Apr 16 19:09:31 2001
+++ ati/atipreinit.c	Mon Apr 16 19:09:25 2001
@@ -640,6 +640,7 @@
 
 #endif /* AVOID_CPIO */
 
+#if !defined(__powerpc__)
     pATI->Block0Base = 0;       /* Might no longer be valid */
     if ((pVideo = pATI->PCIInfo))
     {
@@ -655,6 +656,10 @@
                 pATI->Block0Base += 0x0400U;
         }
     }
+#else
+    if ((pVideo = pATI->PCIInfo))
+       pATI->Block0Base = pVideo->memBase[0] + 0x7ff000;
+#endif
 
     pScreenInfo->racIoFlags =
         RAC_FB | RAC_COLORMAP | RAC_VIEWPORT | RAC_CURSOR;
@@ -779,6 +784,7 @@
         case ATI_ADAPTER_MACH64:
             /* Find and mmap() MMIO area */
             Block0Base = pATI->Block0Base;
+#if !defined(__powerpc__)
             do
             {
                 /* Only allow auxiliary aperture if it exists */
@@ -808,6 +814,9 @@
                 ATIMapMach64(pScreenInfo->scrnIndex, pATI);
             } while (0);
             pATI->Block0Base = Block0Base;
+#else
+            ATIMapMach64(pScreenInfo->scrnIndex, pATI);
+#endif
 
 #ifdef AVOID_CPIO
 
@@ -977,6 +986,7 @@
         pATI->ClockDescriptor = ATIClockDescriptors[ATI_CLOCK_FIXED];
         pATI->ClockNumberToProgramme = -1;
 
+#if !defined(__powerpc__)
         ROMTable = BIOSWord(0x48U);
         if ((ROMTable + 0x12U) > BIOSSize)
             ROMTable = 0;
@@ -1022,6 +1032,7 @@
             }
         }
         else
+#endif /* !__powerpc__ */
         {
             /*
              * Compensate for BIOS absence.  Note that the reference
diff -uNr ati.orig/atiprobe.c ati/atiprobe.c
--- ati.orig/atiprobe.c	Mon Apr 16 19:09:31 2001
+++ ati/atiprobe.c	Mon Apr 16 19:09:25 2001
@@ -641,6 +641,15 @@
         pATI->PCIInfo = pVideo;
         ChipType = pVideo->chipType;
 
+# if defined(__powerpc__)
+        pATI->Block0Base = pVideo->memBase[0] + 0x7ff000;
+        if (ATIDetectMach64(pATI, ChipType, Chip)) {
+            return pATI;
+        } else {
+            return NULL;
+        } 
+#endif   
+
         /*
          * Probe through auxiliary MMIO aperture if one exists.  Because such
          * apertures can be enabled/disabled only through PCI, this probes no
@@ -1331,6 +1340,7 @@
 
     if (xf86PciVideoInfo)
     {
+#if !defined(__powerpc__)
         if (nATIGDev)
         {
 
@@ -1699,6 +1709,7 @@
 #endif /* AVOID_CPIO */
 
         }
+#endif
 
         /* Lastly, look for block I/O devices */
         for (i = 0;  (pVideo = xf86PciVideoInfo[i++]);  )
@@ -1750,7 +1761,11 @@
             /* Probe for it */
             xf86SetPciVideo(pVideo, MEM_IO);
 
+#if defined(__powerpc__)
+	    pATI = ATIMach64Probe(pVideo, pVideo->memBase[0], MEM_IO, Chip);
+#else
             pATI = ATIMach64Probe(pVideo, pVideo->ioBase[1], BLOCK_IO, Chip);
+#endif
             if (pATI)
             {
                 sprintf(Identifier, "Shared PCI/AGP Mach64 in slot %d:%d:%d",
diff -uNr ati.orig/atiregs.h ati/atiregs.h
--- ati.orig/atiregs.h	Mon Apr 16 19:09:31 2001
+++ ati/atiregs.h	Mon Apr 16 19:09:25 2001
@@ -53,9 +53,14 @@
 #define SPARSE_IO_PORT		(SPARSE_IO_BASE | IO_BYTE_SELECT)
 #define BLOCK_IO_PORT		(BLOCK_IO_BASE | IO_BYTE_SELECT)
 
+#if !defined(__powerpc__)
 #define IOPortTag(_SparseIOSelect, _BlockIOSelect)	\
 	(SetBits(_SparseIOSelect, SPARSE_IO_SELECT) |	\
 	 SetBits(_BlockIOSelect, DWORD_SELECT))
+#else
+#define IOPortTag(_SparseIOSelect, _BlockIOSelect)     \
+	SetBits(_BlockIOSelect, BLOCK_SELECT | MM_IO_SELECT)
+#endif
 #define SparseIOTag(_IOSelect)	IOPortTag(_IOSelect, 0)
 #define BlockIOTag(_IOSelect)	IOPortTag(0, _IOSelect)
 
diff -uNr ati.orig/atiscreen.c ati/atiscreen.c
--- ati.orig/atiscreen.c	Mon Apr 16 19:09:31 2001
+++ ati/atiscreen.c	Mon Apr 16 19:09:25 2001
@@ -225,8 +225,10 @@
 
 #endif /* AVOID_CPIO */
 
+#if !defined(__powerpc__)
     /* Initialise DGA support */
     (void)ATIDGAInit(pScreenInfo, pScreen, pATI);
+#endif
 
     /* Setup acceleration */
     if (!ATIInitializeAcceleration(pScreenInfo, pScreen, pATI))
diff -uNr ati.orig/atividmem.c ati/atividmem.c
--- ati.orig/atividmem.c	Mon Apr 16 19:09:31 2001
+++ ati/atividmem.c	Mon Apr 16 19:09:25 2001
@@ -133,7 +133,11 @@
 )
 {
     if (pATI->pMMIO)
+#if !defined(__powerpc__)
         xf86UnMapVidMem(iScreen, pATI->pMMIO, getpagesize());
+#else
+	xf86UnMapVidMem(iScreen, pATI->pMMIO, 0x1c00);
+#endif
 
     pATI->pMMIO = pATI->pBlock[0] = pATI->pBlock[1] = NULL;
 }
@@ -261,9 +265,15 @@
     {
         unsigned long MMIOBase = pATI->Block0Base & ~(PageSize - 1);
 
-        if (pVideo)
+        if (pVideo) {
             pATI->pMMIO = xf86MapPciMem(iScreen, VIDMEM_MMIO,
+#if !defined(__powerpc__)
                 Tag, MMIOBase, PageSize);
+#else
+		Tag, MMIOBase, 0x1c00);
+	    pATI->pMMIO += 0xc00;
+#endif
+	}
         else
             pATI->pMMIO = xf86MapVidMem(iScreen, VIDMEM_MMIO,
                 MMIOBase, PageSize);


More information about the Linuxppc-dev mailing list