summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@gnome.org>2003-09-22 21:14:59 +0000
committerAnders Carlsson <andersca@gnome.org>2003-09-22 21:14:59 +0000
commit20bbd750d0d359e55cbdcc86aeea6013ac665bce (patch)
tree0f77688474a77d2e10b9cbfdceb1ba0f5a3b71c6
parent49771e3f074cae3947b0084e6514a19dc4c4cad1 (diff)
Accelerate server.
-rw-r--r--hw/kdrive/mga/mga.h20
-rw-r--r--hw/kdrive/mga/mgadraw.c79
2 files changed, 91 insertions, 8 deletions
diff --git a/hw/kdrive/mga/mga.h b/hw/kdrive/mga/mga.h
index ce8f583a5..17f7e9095 100644
--- a/hw/kdrive/mga/mga.h
+++ b/hw/kdrive/mga/mga.h
@@ -38,6 +38,15 @@
#define MGA_REG_PLNWT (0x1c1c)
#define MGA_REG_FCOL (0x1c24)
#define MGA_REG_MACCESS (0x1c04)
+#define MGA_REG_SGN (0x1c58)
+#define MGA_REG_AR0 (0x1c60)
+#define MGA_REG_AR1 (0x1c64)
+#define MGA_REG_AR2 (0x1c68)
+#define MGA_REG_AR3 (0x1c6C)
+#define MGA_REG_AR4 (0x1c70)
+#define MGA_REG_AR5 (0x1c74)
+#define MGA_REG_AR6 (0x1c78)
+
#define MGA_REG_CXBNDRY (0x1c80)
#define MGA_REG_FXBNDRY (0x1c84)
#define MGA_REG_YDSTLEN (0x1c88)
@@ -46,6 +55,7 @@
#define MGA_REG_YBOT (0x1c9c)
#define MGA_REG_FIFOSTATUS (0x1e10)
#define MGA_REG_STATUS (0x1e14)
+#define MGA_REG_SRCORG (0x2cb4)
#define MGA_REG_DSTORG (0x2cb8)
#define MGA_PW8 (0)
@@ -54,13 +64,21 @@
#define MGA_PW32 (3)
/* Drawing opcodes */
-#define MGA_OPCOD_TRAP (4)
+#define MGA_OPCOD_TRAP (4)
+#define MGA_OPCOD_BITBLT (8)
#define MGA_DWGCTL_SOLID (1 << 11)
#define MGA_DWGCTL_ARZERO (1 << 12)
#define MGA_DWGCTL_SGNZERO (1 << 13)
#define MGA_DWGCTL_SHIFTZERO (1 << 14)
+#define MGA_DWGCTL_BFCOL (2 << 25)
+
+#define MGA_ATYPE_RPL (0 << 4)
+#define MGA_ATYPE_RSTR (1 << 4)
+#define MGA_ATYPE_ZI (3 << 4)
+#define MGA_ATYPE_BLK (4 << 4)
+#define MGA_ATYPE_I (7 << 4)
typedef volatile CARD8 VOL8;
typedef volatile CARD16 VOL16;
diff --git a/hw/kdrive/mga/mgadraw.c b/hw/kdrive/mga/mgadraw.c
index 7a1d2c87c..07ceea517 100644
--- a/hw/kdrive/mga/mgadraw.c
+++ b/hw/kdrive/mga/mgadraw.c
@@ -27,8 +27,29 @@
#endif
#include "mga.h"
+CARD32 mgaRop[16] = {
+ /* GXclear */ MGA_ATYPE_RPL | 0x00000000, /* 0 */
+ /* GXand */ MGA_ATYPE_RSTR | 0x00080000, /* src AND dst */
+ /* GXandReverse */ MGA_ATYPE_RSTR | 0x00040000, /* src AND NOT dst */
+ /* GXcopy */ MGA_ATYPE_RSTR | 0x000c0000, /* src */
+ /* GXandInverted */ MGA_ATYPE_RSTR | 0x00020000, /* NOT src AND dst */
+ /* GXnoop */ MGA_ATYPE_RSTR | 0x000a0000, /* dst */
+ /* GXxor */ MGA_ATYPE_RSTR | 0x00060000, /* src XOR dst */
+ /* GXor */ MGA_ATYPE_RSTR | 0x000e0000, /* src OR dst */
+ /* GXnor */ MGA_ATYPE_RSTR | 0x00010000, /* NOT src AND NOT dst */
+ /* GXequiv */ MGA_ATYPE_RSTR | 0x00090000, /* NOT src XOR dst */
+ /* GXinvert */ MGA_ATYPE_RSTR | 0x00050000, /* NOT dst */
+ /* GXorReverse */ MGA_ATYPE_RSTR | 0x000d0000, /* src OR NOT dst */
+ /* GXcopyInverted */ MGA_ATYPE_RPL | 0x00030000, /* NOT src */
+ /* GXorInverted */ MGA_ATYPE_RSTR | 0x000b0000, /* NOT src OR dst */
+ /* GXnand */ MGA_ATYPE_RSTR | 0x00070000, /* NOT src OR NOT dst */
+ /* GXset */ MGA_ATYPE_RPL | 0x000f0000 /* 1 */
+};
+
static VOL8 *mmio;
int fifo_size;
+int pitch;
+int dir;
void
mgaWaitAvail (int n)
@@ -58,12 +79,14 @@ mgaSetup (ScreenPtr pScreen, int wait)
fifo_size = 0;
mmio = mgac->reg_base;
-
+ pitch = mgas->pitch;
+
if (!mmio)
return FALSE;
- mgaWaitAvail (wait + 6);
+ mgaWaitAvail (wait + 7);
MGA_OUT32 (mmio, MGA_REG_PITCH, mgas->pitch);
+ MGA_OUT32 (mmio, MGA_REG_SRCORG, 0);
MGA_OUT32 (mmio, MGA_REG_DSTORG, 0);
MGA_OUT32 (mmio, MGA_REG_MACCESS, mgas->pw);
MGA_OUT32 (mmio, MGA_REG_CXBNDRY, 0xffff0000);
@@ -77,14 +100,13 @@ mgaPrepareSolid (DrawablePtr pDrawable, int alu, Pixel pm, Pixel fg)
int cmd;
cmd = MGA_OPCOD_TRAP | MGA_DWGCTL_SOLID | MGA_DWGCTL_ARZERO | MGA_DWGCTL_SGNZERO |
- MGA_DWGCTL_SHIFTZERO;
- /* XXX */
- cmd |= (12 << 16);
+ MGA_DWGCTL_SHIFTZERO | mgaRop[alu];
- mgaSetup (pDrawable->pScreen, 4);
+ mgaSetup (pDrawable->pScreen, 3);
MGA_OUT32 (mmio, MGA_REG_DWGCTL, cmd);
MGA_OUT32 (mmio, MGA_REG_FCOL, fg);
MGA_OUT32 (mmio, MGA_REG_PLNWT, pm);
+
return TRUE;
}
@@ -101,15 +123,58 @@ mgaDoneSolid (void)
{
}
+#define BLIT_LEFT 1
+#define BLIT_UP 4
+
Bool
mgaPrepareCopy (DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, int dx, int dy, int alu, Pixel pm)
{
- return FALSE;
+ int cmd;
+
+ cmd = MGA_OPCOD_BITBLT | MGA_DWGCTL_BFCOL | MGA_DWGCTL_SHIFTZERO | mgaRop[alu];
+
+ dir = 0;
+
+ if (dy < 0)
+ dir |= BLIT_UP;
+ if (dx < 0)
+ dir |= BLIT_LEFT;
+
+ mgaSetup (pDstDrawable->pScreen, 4);
+
+ MGA_OUT32 (mmio, MGA_REG_DWGCTL, cmd);
+ MGA_OUT32 (mmio, MGA_REG_SGN, dir);
+ MGA_OUT32 (mmio, MGA_REG_PLNWT, pm);
+ MGA_OUT32 (mmio, MGA_REG_AR5, pitch * (dy < 0 ? -1 : 1) );
+
+ return TRUE;
}
void
mgaCopy (int srcX, int srcY, int dstX, int dstY, int w, int h)
{
+ int start, end;
+
+ if (dir & BLIT_UP)
+ {
+ srcY += h - 1;
+ dstY += h - 1;
+ }
+
+ w--;
+ start = end = srcY * pitch + srcX;
+
+ if (dir & BLIT_LEFT)
+ start += w;
+ else
+ end += w;
+
+ mgaWaitAvail (4);
+ MGA_OUT32 (mmio, MGA_REG_AR0, end);
+ MGA_OUT32 (mmio, MGA_REG_AR3, start);
+ MGA_OUT32 (mmio, MGA_REG_FXBNDRY, ((dstX + w) << 16) | (dstX & 0xffff));
+
+ MGA_OUT32 (mmio, MGA_REG_YDSTLEN | MGA_REG_EXEC, (dstY << 16) | h);
}
void