[xserver-commit] xserver/hw/kdrive/ati ati_draw.c,1.3,1.4

Eric Anholt xserver-commit@pdx.freedesktop.org
Sun, 23 Nov 2003 02:12:06 -0800


Committed by: anholt

Update of /cvs/xserver/xserver/hw/kdrive/ati
In directory pdx:/home/anholt/xserver/hw/kdrive/ati

Modified Files:
	ati_draw.c 
Log Message:
- Fix Radeon offscreen pixmap pitch alignment.
- Remove usleeps from idle and waitavail code, recommended by keithp.
- Add a workaround for apparent broken acceleration with Rage 128 and
  offset alignment with 8-bit acceleration (24-hack and plain 8-bit).
- Minor cleanup of setup code.


Index: ati_draw.c
===================================================================
RCS file: /cvs/xserver/xserver/hw/kdrive/ati/ati_draw.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- ati_draw.c	20 Nov 2003 07:49:45 -0000	1.3
+++ ati_draw.c	23 Nov 2003 10:12:04 -0000	1.4
@@ -86,19 +86,14 @@
 		return;
 	}
 	if (is_radeon) {
-		fifo_size = MMIO_IN32(mmio, RADEON_REG_RBBM_STATUS) &
-		    RADEON_RBBM_FIFOCNT_MASK;
-		while (fifo_size < n) {
-			usleep(1);
+		do {
 			fifo_size = MMIO_IN32(mmio, RADEON_REG_RBBM_STATUS) &
 			    RADEON_RBBM_FIFOCNT_MASK;
-		}
+		} while (fifo_size < n);
 	} else {
-		fifo_size = MMIO_IN32(mmio, R128_REG_GUI_STAT) & 0xfff;
-		while (fifo_size < n) {
+		do {
 			fifo_size = MMIO_IN32(mmio, R128_REG_GUI_STAT) & 0xfff;
-			usleep(1);
-		}
+		} while (fifo_size < n);
 	}
 	fifo_size -= n;
 }
@@ -112,7 +107,7 @@
 
 	while ((MMIO_IN32(mmio, RADEON_REG_RBBM_STATUS) &
 	    RADEON_RBBM_ACTIVE) != 0)
-		usleep(1);
+		;
 
 	/* Flush pixel cache */
 	temp = MMIO_IN32(mmio, RADEON_REG_RB2D_DSTCACHE_CTLSTAT);
@@ -121,7 +116,7 @@
 
 	while ((MMIO_IN32(mmio, RADEON_REG_RB2D_DSTCACHE_CTLSTAT) &
 	    RADEON_RB2D_DC_BUSY) != 0)
-		usleep(1);
+		;
 }
 
 static void
@@ -159,9 +154,9 @@
 }
 
 static Bool
-ATISetup(ScreenPtr pScreen, PixmapPtr pDst, PixmapPtr pSrc)
+ATISetup(PixmapPtr pDst, PixmapPtr pSrc)
 {
-	KdScreenPriv(pScreen);
+	KdScreenPriv(pDst->drawable.pScreen);
 	ATICardInfo(pScreenPriv);
 	int dst_offset, dst_pitch, src_offset = 0, src_pitch = 0;
 	int bpp = pScreenPriv->screen->fb[0].bitsPerPixel;
@@ -181,7 +176,7 @@
 		    pScreenPriv->screen->memory_base);
 	}
 
-	ATIWaitAvail(3);
+	ATIWaitAvail((pSrc != NULL) ? 3 : 2);
 	if (is_radeon) {
 		MMIO_OUT32(mmio, RADEON_REG_DST_PITCH_OFFSET,
 		    ((dst_pitch >> 6) << 22) | (dst_offset >> 10));
@@ -225,7 +220,7 @@
 			return FALSE;
 	}
 
-	if (!ATISetup(pPixmap->drawable.pScreen, pPixmap, NULL))
+	if (!ATISetup(pPixmap, NULL))
 		return FALSE;
 
 	ATIWaitAvail(4);
@@ -273,7 +268,7 @@
 	if (is_24bpp && pm != 0xffffffff)
 		return FALSE;
 
-	if (!ATISetup(pDst->drawable.pScreen, pDst, pSrc))
+	if (!ATISetup(pDst, pSrc))
 		return FALSE;
 
 	ATIWaitAvail(3);
@@ -377,10 +372,15 @@
 
 	if (is_radeon) {
 		ATIKaa.offscreenByteAlign = 1024;
-		ATIKaa.offscreenPitch = 64;
+		ATIKaa.offscreenPitch = 1024;
 	} else {
 		ATIKaa.offscreenByteAlign = 8;
-		ATIKaa.offscreenPitch = pScreenPriv->screen->fb[0].bitsPerPixel;
+		/* Workaround for corrupation at 8 and 24bpp. Why? */
+		if (atis->datatype == 2)
+			ATIKaa.offscreenPitch = 16;
+		else
+			ATIKaa.offscreenPitch =
+			    pScreenPriv->screen->fb[0].bitsPerPixel;
 	}
 	if (!kaaDrawInit(pScreen, &ATIKaa))
 		return FALSE;