summaryrefslogtreecommitdiff
path: root/src/via_accel.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/via_accel.c')
-rw-r--r--src/via_accel.c66
1 files changed, 23 insertions, 43 deletions
diff --git a/src/via_accel.c b/src/via_accel.c
index 36c9412..93d78b0 100644
--- a/src/via_accel.c
+++ b/src/via_accel.c
@@ -340,7 +340,7 @@ VIASetClippingRectangle(ScrnInfoPtr pScrn, int x1, int y1, int x2, int y2)
pVia->justSetup = 0;
CBUFFER(buf, VIA_REG_GEMODE, tdc->mode);
#ifdef DEBUG_EXTRA
- ErrorF("ClipRect, (%4d,%4d)-(%4d,%4d) \n", x1, y1, x2, y2 );
+ ErrorF("ClipRect, (%4d,%4d)-(%4d,%4d) \n", x1, y1, x2, y2);
#endif
CBUFFER(buf, VIA_REG_CLIPTL, ((y1 << 16) | x1));
@@ -415,8 +415,8 @@ VIASubsequentScreenToScreenCopy(ScrnInfoPtr pScrn, int x1, int y1,
if (!w || !h)
return;
- srcBase = y1*pVia->Bpl + x1*pVia->Bpp;
- dstBase = y2*pVia->Bpl + x2*pVia->Bpp;
+ srcBase = (y1 * pScrn->displayWidth + x1) * pScrn->bitsPerPixel / 8;
+ dstBase = (y2 * pScrn->displayWidth + x2) * pScrn->bitsPerPixel / 8;
x1 = (srcBase & 31);
x2 = (dstBase & 31);
@@ -448,12 +448,11 @@ VIASubsequentScreenToScreenCopy(ScrnInfoPtr pScrn, int x1, int y1,
}
COND_CLEAR_CBUFFER(buf, pVia);
- CBUFFER(buf, VIA_REG_GEMODE, tdc->mode );
+ CBUFFER(buf, VIA_REG_GEMODE, tdc->mode);
/* Set Src and Dst base address and pitch, pitch is qword */
CBUFFER(buf, VIA_REG_SRCBASE, (srcBase & ~31) >> 3);
CBUFFER(buf, VIA_REG_DSTBASE, (dstBase & ~31) >> 3);
- CBUFFER(buf, VIA_REG_PITCH, VIA_PITCH_ENABLE |
- (pVia->Bpl >> 3) | ((pVia->Bpl >> 3) << 16));
+ CBUFFER(buf, VIA_REG_PITCH, pVia->RegPitch);
CBUFFER(buf, VIA_REG_SRCPOS, ((y1 << 16) | x1));
CBUFFER(buf, VIA_REG_DSTPOS, ((y2 << 16) | x2));
CBUFFER(buf, VIA_REG_DIMENSION, (((h - 1) << 16) | (w - 1)));
@@ -501,16 +500,12 @@ VIASubsequentSolidFillRect(ScrnInfoPtr pScrn,
/* Set Src and Dst base address and pitch, pitch is qword */
CBUFFER(buf, VIA_REG_SRCBASE, 0x0);
CBUFFER(buf, VIA_REG_DSTBASE, 0x0);
- CBUFFER(buf, VIA_REG_PITCH, VIA_PITCH_ENABLE |
- ((pScrn->displayWidth * pScrn->bitsPerPixel >> 3) >> 3) |
- (((pScrn->displayWidth * pScrn->bitsPerPixel >> 3) >> 3) << 16));
-
+ CBUFFER(buf, VIA_REG_PITCH, pVia->RegPitch);
CBUFFER(buf, VIA_REG_DSTPOS, ((y << 16) | x));
CBUFFER(buf, VIA_REG_DIMENSION, (((h - 1) << 16) | (w - 1)));
CBUFFER(buf, VIA_REG_FGCOLOR, pVia->SavedFgColor);
CBUFFER(buf, VIA_REG_GECMD, pVia->SavedCmd);
dispatchCBufferAGP(pVia, buf);
-
}
/*
@@ -570,10 +565,7 @@ VIASubsequentMono8x8PatternFillRect(ScrnInfoPtr pScrn, int patOffx, int patOffy,
/* Set Src and Dst base address and pitch, pitch is qword */
CBUFFER(buf, VIA_REG_SRCBASE, 0x0);
CBUFFER(buf, VIA_REG_DSTBASE, 0x0);
- CBUFFER(buf, VIA_REG_PITCH, VIA_PITCH_ENABLE |
- ((pScrn->displayWidth * pScrn->bitsPerPixel >> 3) >> 3) |
- (((pScrn->displayWidth * pScrn->bitsPerPixel >> 3) >> 3) << 16));
-
+ CBUFFER(buf, VIA_REG_PITCH, pVia->RegPitch);
CBUFFER(buf, VIA_REG_DSTPOS, ((y << 16) | x));
CBUFFER(buf, VIA_REG_DIMENSION, (((h - 1) << 16) | (w - 1)));
CBUFFER(buf, VIA_REG_PATADDR, dwPatOffset);
@@ -602,7 +594,8 @@ VIASetupForColor8x8PatternFill(ScrnInfoPtr pScrn, int patternx, int patterny,
#endif
pVia->SavedCmd = cmd;
- pVia->SavedPatternAddr = (patternx * pVia->Bpp + patterny * pVia->Bpl);
+ pVia->SavedPatternAddr = (patternx + patterny * pScrn->displayWidth) *
+ (pScrn->bitsPerPixel >> 3);
}
/*
@@ -628,10 +621,7 @@ VIASubsequentColor8x8PatternFillRect(ScrnInfoPtr pScrn, int patOffx, int patOffy
CBUFFER(buf, VIA_REG_GEMODE, tdc->mode);
CBUFFER(buf, VIA_REG_SRCBASE, 0x0);
CBUFFER(buf, VIA_REG_DSTBASE, 0x0);
- CBUFFER(buf, VIA_REG_PITCH, VIA_PITCH_ENABLE |
- ((pScrn->displayWidth * pScrn->bitsPerPixel >> 3) >> 3) |
- (((pScrn->displayWidth * pScrn->bitsPerPixel >> 3) >> 3) << 16));
-
+ CBUFFER(buf, VIA_REG_PITCH, pVia->RegPitch);
CBUFFER(buf, VIA_REG_DSTPOS, ((y << 16) | x));
CBUFFER(buf, VIA_REG_DIMENSION, (((h - 1) << 16) | (w - 1)));
CBUFFER(buf, VIA_REG_PATADDR, dwPatAddr);
@@ -693,10 +683,7 @@ VIASubsequentScanlineCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, int x, int y,
CBUFFER(buf, VIA_REG_GEMODE, tdc->mode);
CBUFFER(buf, VIA_REG_SRCBASE, 0x0);
CBUFFER(buf, VIA_REG_DSTBASE, 0x0);
- CBUFFER(buf, VIA_REG_PITCH, VIA_PITCH_ENABLE |
- ((pScrn->displayWidth * pScrn->bitsPerPixel >> 3) >> 3) |
- (((pScrn->displayWidth * pScrn->bitsPerPixel >> 3) >> 3) << 16));
-
+ CBUFFER(buf, VIA_REG_PITCH, pVia->RegPitch);
CBUFFER(buf, VIA_REG_SRCPOS, 0);
CBUFFER(buf, VIA_REG_DSTPOS, ((y << 16) | x));
CBUFFER(buf, VIA_REG_DIMENSION, (((h - 1) << 16) | (w - 1)));
@@ -746,8 +733,8 @@ VIASubsequentScreenToScreenColorExpand(ScrnInfoPtr pScrn, int x, int y,
ViaTwodContext *tdc = &pVia->td;
CARD32 srcBase,dstBase;
- srcBase = srcy*pVia->Bpl + srcx*pVia->Bpp;
- dstBase = y*pVia->Bpl + x*pVia->Bpp;
+ srcBase = (srcy * pScrn->displayWidth + srcx) * (pScrn->bitsPerPixel >> 3);
+ dstBase = (y * pScrn->displayWidth + x) * (pScrn->bitsPerPixel >> 3);
x = (dstBase & 31);
srcx = srcBase & 7;
@@ -772,9 +759,7 @@ VIASubsequentScreenToScreenColorExpand(ScrnInfoPtr pScrn, int x, int y,
CBUFFER(buf, VIA_REG_KEYCONTROL, 0x0);
CBUFFER(buf, VIA_REG_SRCBASE, (srcBase & ~7) >> 3);
CBUFFER(buf, VIA_REG_DSTBASE, (dstBase & ~31) >> 3);
- CBUFFER(buf, VIA_REG_PITCH, VIA_PITCH_ENABLE |
- ((pScrn->displayWidth * pScrn->bitsPerPixel >> 3) >> 3) |
- (((pScrn->displayWidth * pScrn->bitsPerPixel >> 3) >> 3) << 16));
+ CBUFFER(buf, VIA_REG_PITCH, pVia->RegPitch);
CBUFFER(buf, VIA_REG_SRCPOS, (srcx << 6) | offset);
CBUFFER(buf, VIA_REG_DSTPOS, ((y << 16) | x));
CBUFFER(buf, VIA_REG_DIMENSION, (((h - 1) << 16) | (w - 1)));
@@ -836,10 +821,7 @@ VIASubsequentImageWriteRect(ScrnInfoPtr pScrn,
CBUFFER(buf, VIA_REG_GEMODE, tdc->mode);
CBUFFER(buf, VIA_REG_SRCBASE, 0x0);
CBUFFER(buf, VIA_REG_DSTBASE, 0x0);
- CBUFFER(buf, VIA_REG_PITCH, VIA_PITCH_ENABLE |
- ((pScrn->displayWidth * pScrn->bitsPerPixel >> 3) >> 3) |
- (((pScrn->displayWidth * pScrn->bitsPerPixel >> 3) >> 3) << 16));
-
+ CBUFFER(buf, VIA_REG_PITCH, pVia->RegPitch);
CBUFFER(buf, VIA_REG_SRCPOS, 0);
CBUFFER(buf, VIA_REG_DSTPOS, ((y << 16) | x));
CBUFFER(buf, VIA_REG_DIMENSION, (((h - 1) << 16) | (w - 1)));
@@ -920,10 +902,7 @@ VIASubsequentSolidTwoPointLine(ScrnInfoPtr pScrn,
/* Set Src and Dst base address and pitch, pitch is qword */
CBUFFER(buf, VIA_REG_SRCBASE, 0x0);
CBUFFER(buf, VIA_REG_DSTBASE, 0x0);
- CBUFFER(buf, VIA_REG_PITCH, VIA_PITCH_ENABLE |
- ((pScrn->displayWidth * pScrn->bitsPerPixel >> 3) >> 3) |
- (((pScrn->displayWidth * pScrn->bitsPerPixel >> 3) >> 3) << 16));
-
+ CBUFFER(buf, VIA_REG_PITCH, pVia->RegPitch);
/* major = 2*dmaj, minor = 2*dmin, err = -dmaj - ((bias >> octant) & 1) */
/* K1 = 2*dmin K2 = 2*(dmin - dmax) */
/* Error Term = (StartX<EndX) ? (2*dmin - dmax - 1) : (2*(dmin - dmax)) */
@@ -953,9 +932,7 @@ VIASubsequentSolidHorVertLine(ScrnInfoPtr pScrn,
CBUFFER(buf, VIA_REG_FGCOLOR, pVia->SavedFgColor);
CBUFFER(buf, VIA_REG_SRCBASE, 0x0);
CBUFFER(buf, VIA_REG_DSTBASE, 0x0);
- CBUFFER(buf, VIA_REG_PITCH, VIA_PITCH_ENABLE |
- ((pScrn->displayWidth * pScrn->bitsPerPixel >> 3) >> 3) |
- (((pScrn->displayWidth * pScrn->bitsPerPixel >> 3) >> 3) << 16));
+ CBUFFER(buf, VIA_REG_PITCH, pVia->RegPitch);
if (dir == DEGREES_0) {
CBUFFER(buf, VIA_REG_DSTPOS, ((y << 16) | x));
@@ -1061,9 +1038,7 @@ VIASubsequentDashedTwoPointLine(ScrnInfoPtr pScrn, int x1, int y1,
/* Set Src and Dst base address and pitch, pitch is qword */
CBUFFER(buf, VIA_REG_SRCBASE, 0x0);
CBUFFER(buf, VIA_REG_DSTBASE, 0x0);
- CBUFFER(buf, VIA_REG_PITCH, VIA_PITCH_ENABLE |
- ((pScrn->displayWidth * pScrn->bitsPerPixel >> 3) >> 3) |
- (((pScrn->displayWidth * pScrn->bitsPerPixel >> 3) >> 3) << 16));
+ CBUFFER(buf, VIA_REG_PITCH, pVia->RegPitch);
/* major = 2*dmaj, minor = 2*dmin, err = -dmaj - ((bias >> octant) & 1) */
/* K1 = 2*dmin K2 = 2*(dmin - dmax) */
@@ -1321,6 +1296,11 @@ VIAInitAccel(ScrnInfoPtr pScrn, ScreenPtr pScreen)
VIAXAAInit(pScrn, pVia->AccelInfoRec);
+ /* used _very_ often. */
+ pVia->RegPitch = (pScrn->displayWidth * pScrn->bitsPerPixel) >> 6;
+ pVia->RegPitch |= pVia->RegPitch << 16;
+ pVia->RegPitch |= VIA_PITCH_ENABLE;
+
pVia->justSetup = 0; /* command buffer tracking... */
return XAAInit(pScreen, pVia->AccelInfoRec);
}