diff options
author | Jaymz Julian <jaymz@artificial-stupidity.net> | 2004-06-14 08:43:57 +0000 |
---|---|---|
committer | Jaymz Julian <jaymz@artificial-stupidity.net> | 2004-06-14 08:43:57 +0000 |
commit | 580b9a7da1bf0e20acdcddd676d471b3d6589023 (patch) | |
tree | e1076a6f1fef3433798f07dfa0cbfb039e57859e | |
parent | 95d65cf6bb753d10f4db3d857fb98bb09389228e (diff) |
MGA composite support from Damien Ciabrini - thanks!
-rw-r--r-- | hw/kdrive/mga/Makefile.am | 7 | ||||
-rw-r--r-- | hw/kdrive/mga/mga.h | 30 | ||||
-rw-r--r-- | hw/kdrive/mga/mgadraw.c | 102 |
3 files changed, 108 insertions, 31 deletions
diff --git a/hw/kdrive/mga/Makefile.am b/hw/kdrive/mga/Makefile.am index 0cae19ea6..8242f227e 100644 --- a/hw/kdrive/mga/Makefile.am +++ b/hw/kdrive/mga/Makefile.am @@ -11,9 +11,10 @@ if TSLIB TSLIB_FLAG = -lts endif -libmga_a_SOURCES = \ - mgadraw.c \ - mga.c \ +libmga_a_SOURCES = \ + mgadraw.c \ + g400_composite.c \ + mga.c \ mga.h Xmga_SOURCES = \ diff --git a/hw/kdrive/mga/mga.h b/hw/kdrive/mga/mga.h index ff9716d85..3b3462063 100644 --- a/hw/kdrive/mga/mga.h +++ b/hw/kdrive/mga/mga.h @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright © 2003 Anders Carlsson + * Copyright © 2003-2004 Anders Carlsson * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -59,6 +59,8 @@ #define MGA_REG_SRCORG (0x2cb4) #define MGA_REG_DSTORG (0x2cb8) +#define MGA_G4XX_DEVICE_ID (0x0525) + #define MGA_PW8 (0) #define MGA_PW16 (1) #define MGA_PW24 (2) @@ -66,6 +68,7 @@ /* Drawing opcodes */ #define MGA_OPCOD_TRAP (4) +#define MGA_OPCOD_TEXTURE_TRAP (6) #define MGA_OPCOD_BITBLT (8) #define MGA_DWGCTL_SOLID (1 << 11) @@ -105,6 +108,10 @@ typedef struct _mgaScreenInfo { #define getMgaScreenInfo(kd) ((MgaScreenInfo *) ((kd)->screen->driver)) #define mgaScreenInfo(kd) MgaScreenInfo *mgas = getMgaScreenInfo(kd) + +VOL8 *mmio; + + Bool mgaMapReg (KdCardInfo *card, MgaCardInfo *mgac); @@ -137,4 +144,25 @@ mgaDrawFini (ScreenPtr pScreen); extern KdCardFuncs mgaFuncs; + +void +mgaWaitAvail (int n); + +void +mgaWaitIdle (void); + +Bool +mgaSetup (ScreenPtr pScreen, int dest_bpp, int wait); + + +#if 0 +#define MGA_FALLBACK(x) \ +do { \ + ErrorF x; \ + return FALSE; \ +} while (0); +#else +#define MGA_FALLBACK(x) return FALSE; +#endif + #endif /* _MGA_H_ */ diff --git a/hw/kdrive/mga/mgadraw.c b/hw/kdrive/mga/mgadraw.c index 04cd44fc9..ba0449be7 100644 --- a/hw/kdrive/mga/mgadraw.c +++ b/hw/kdrive/mga/mgadraw.c @@ -1,7 +1,7 @@ /* * $Id$ * - * Copyright © 2003 Anders Carlsson + * Copyright © 2003-2004 Anders Carlsson * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -26,6 +26,8 @@ #include <config.h> #endif #include "mga.h" +#include "g400_common.h" +#include <unistd.h> CARD32 mgaRop[16] = { /* GXclear */ MGA_ATYPE_RPL | 0x00000000, /* 0 */ @@ -46,12 +48,12 @@ CARD32 mgaRop[16] = { /* GXset */ MGA_ATYPE_RPL | 0x000f0000 /* 1 */ }; -static VOL8 *mmio; +VOL8 *mmio; int fifo_size; int pitch, src_pitch; int dir; -static void +void mgaWaitAvail (int n) { if (fifo_size < n) { @@ -62,14 +64,14 @@ mgaWaitAvail (int n) fifo_size -= n; } -static void +void mgaWaitIdle (void) { while (MGA_IN32 (mmio, MGA_REG_STATUS) & 0x10000); } -static Bool -mgaSetup (ScreenPtr pScreen, int wait) +Bool +mgaSetup (ScreenPtr pScreen, int dest_bpp, int wait) { KdScreenPriv (pScreen); mgaScreenInfo (pScreenPriv); @@ -83,7 +85,19 @@ mgaSetup (ScreenPtr pScreen, int wait) return FALSE; mgaWaitAvail (wait + 4); - MGA_OUT32 (mmio, MGA_REG_MACCESS, mgas->pw); + // Set the format of the destination pixmap + switch (dest_bpp) { + case 8: + MGA_OUT32 (mmio, MGA_REG_MACCESS, MGA_PW8); + break; + case 16: + MGA_OUT32 (mmio, MGA_REG_MACCESS, MGA_PW16); + break; + case 24: + case 32: + MGA_OUT32 (mmio, MGA_REG_MACCESS, MGA_PW24); + break; + } MGA_OUT32 (mmio, MGA_REG_CXBNDRY, 0xffff0000); MGA_OUT32 (mmio, MGA_REG_YTOP, 0x00000000); MGA_OUT32 (mmio, MGA_REG_YBOT, 0x007fffff); @@ -94,38 +108,49 @@ mgaSetup (ScreenPtr pScreen, int wait) static Bool mgaPrepareSolid (PixmapPtr pPixmap, int alu, Pixel pm, Pixel fg) { + KdScreenPriv(pPixmap->drawable.pScreen); int cmd; int dst_org; - + // We must pad pm and fg depending on the format of the destination pixmap + switch (pPixmap->drawable.bitsPerPixel) { + case 16: + fg |= fg << 16; + pm |= pm << 16; + break; + case 8: + fg |= (fg << 8) | (fg << 16) | (fg << 24); + pm |= (pm << 8) | (pm << 16) | (pm << 24); + break; + } + cmd = MGA_OPCOD_TRAP | MGA_DWGCTL_SOLID | MGA_DWGCTL_ARZERO | MGA_DWGCTL_SGNZERO | MGA_DWGCTL_SHIFTZERO | mgaRop[alu]; dst_org = (int)pPixmap->devPrivate.ptr - (int)pScreenPriv->screen->memory_base; - mgaSetup (pPixmap->drawable.pScreen, 5); - + mgaSetup (pPixmap->drawable.pScreen, pPixmap->drawable.bitsPerPixel, 5); MGA_OUT32 (mmio, MGA_REG_DSTORG, dst_org); MGA_OUT32 (mmio, MGA_REG_PITCH, pPixmap->devKind / (pPixmap->drawable.bitsPerPixel >> 3)); MGA_OUT32 (mmio, MGA_REG_DWGCTL, cmd); MGA_OUT32 (mmio, MGA_REG_FCOL, fg); MGA_OUT32 (mmio, MGA_REG_PLNWT, pm); - + return TRUE; } static void mgaSolid (int x1, int y1, int x2, int y2) { - mgaWaitAvail (2); - - MGA_OUT32 (mmio, MGA_REG_FXBNDRY, (x2 << 16) | (x1 & 0xffff)); - MGA_OUT32 (mmio, MGA_REG_YDSTLEN | MGA_REG_EXEC, (y1 << 16) | (y2 - y1)); + mgaWaitAvail (2); + MGA_OUT32 (mmio, MGA_REG_FXBNDRY, (x2 << 16) | (x1 & 0xffff)); + MGA_OUT32 (mmio, MGA_REG_YDSTLEN | MGA_REG_EXEC, (y1 << 16) | (y2 - y1)); } static void mgaDoneSolid (void) { + mgaWaitIdle(); } #define BLIT_LEFT 1 @@ -135,7 +160,7 @@ static Bool mgaPrepareCopy (PixmapPtr pSrcPixmap, PixmapPtr pDstPixmap, int dx, int dy, int alu, Pixel pm) { - KdScreenPriv(pSrcPixmap->drawable.pScreen); + KdScreenPriv(pSrcPixmap->drawable.pScreen); int cmd; @@ -148,11 +173,15 @@ mgaPrepareCopy (PixmapPtr pSrcPixmap, PixmapPtr pDstPixmap, if (dx < 0) dir |= BLIT_LEFT; - mgaSetup (pSrcPixmap->drawable.pScreen, 7); + mgaSetup (pSrcPixmap->drawable.pScreen, + pDstPixmap->drawable.bitsPerPixel, 7); - MGA_OUT32 (mmio, MGA_REG_SRCORG, ((int)pSrcPixmap->devPrivate.ptr - (int)pScreenPriv->screen->memory_base)); - MGA_OUT32 (mmio, MGA_REG_DSTORG, ((int)pDstPixmap->devPrivate.ptr - (int)pScreenPriv->screen->memory_base)); - MGA_OUT32 (mmio, MGA_REG_PITCH, pDstPixmap->devKind / (pDstPixmap->drawable.bitsPerPixel >> 3)); + MGA_OUT32 (mmio, MGA_REG_SRCORG, ((int)pSrcPixmap->devPrivate.ptr - + (int)pScreenPriv->screen->memory_base)); + MGA_OUT32 (mmio, MGA_REG_DSTORG, ((int)pDstPixmap->devPrivate.ptr - + (int)pScreenPriv->screen->memory_base)); + MGA_OUT32 (mmio, MGA_REG_PITCH, (pDstPixmap->devKind / + (pDstPixmap->drawable.bitsPerPixel >> 3))); src_pitch = pSrcPixmap->devKind / (pSrcPixmap->drawable.bitsPerPixel >> 3); MGA_OUT32 (mmio, MGA_REG_DWGCTL, cmd); @@ -167,7 +196,7 @@ static void mgaCopy (int srcX, int srcY, int dstX, int dstY, int w, int h) { int start, end; - + if (dir & BLIT_UP) { srcY += h - 1; @@ -192,6 +221,13 @@ mgaCopy (int srcX, int srcY, int dstX, int dstY, int w, int h) static void mgaDoneCopy (void) { + mgaWaitIdle(); +} + +static Bool +mgaUploadToScreen(PixmapPtr pDst, char *src, int src_pitch) { + //fprintf(stderr,"Upload to Screen %p [%d]\n",src,src_pitch); + return TRUE; } KaaScreenInfoRec mgaKaa = { @@ -203,14 +239,28 @@ KaaScreenInfoRec mgaKaa = { mgaCopy, mgaDoneCopy, - 192, /* Offscreen byte alignment */ - 64, /* Offset pitch */ - KAA_OFFSCREEN_PIXMAPS, /* Flags */ + 192, /* 192 Offscreen byte alignment */ + 128, /* Pitch alignment is in sets of 32 pixels, and we need to + cover 32bpp, so 128 bytes */ + KAA_OFFSCREEN_PIXMAPS /* Flags */ }; Bool mgaDrawInit (ScreenPtr pScreen) { + KdScreenPriv(pScreen); + KdCardInfo *card = pScreenPriv->card; + + if (card->attr.deviceID == MGA_G4XX_DEVICE_ID) { + mgaKaa.PrepareBlend=mgaPrepareBlend; + mgaKaa.Blend=mgaBlend; + mgaKaa.DoneBlend=mgaDoneBlend; + mgaKaa.PrepareComposite=mgaPrepareComposite; + mgaKaa.Composite=mgaComposite; + mgaKaa.DoneComposite=mgaDoneComposite; + } + //mgaKaa.UploadToScreen=mgaUploadToScreen; + if (!kaaDrawInit (pScreen, &mgaKaa)) return FALSE; @@ -233,10 +283,8 @@ mgaDrawEnable (ScreenPtr pScreen) mgas->pw = MGA_PW16; break; case 24: - mgas->pw = MGA_PW24; - break; case 32: - mgas->pw = MGA_PW32; + mgas->pw = MGA_PW24; break; default: FatalError ("unsupported pixel format"); |