? man/trident.4 ? src/blade_accel_exa.c ? src/cscope.files ? src/cscope.out Index: man/trident.man =================================================================== RCS file: /cvs/xorg/driver/xf86-video-trident/man/trident.man,v retrieving revision 1.2 diff -u -r1.2 trident.man --- man/trident.man 23 Apr 2004 19:52:01 -0000 1.2 +++ man/trident.man 25 Feb 2006 18:39:30 -0000 @@ -127,7 +127,12 @@ an integer value greater or equal to 0 and less than 128. Default: gamma and brightness control is turned off. Note: This is not supported on all chipsets. +.BI "Option \*qAccelMethod\*q \*q" string \*q +Choose acceleration architecture, either "XAA" or "EXA". XAA is the old +(but stable) XFree86 based acceleration architecture. EXA is a newer and +simpler acceleration architecture designed to better accelerate the X Render +extension. Default: "XAA". .SH "SEE ALSO" __xservername__(__appmansuffix__), __xconfigfile__(__filemansuffix__), xorgconfig(__appmansuffix__), Xserver(__appmansuffix__), X(__miscmansuffix__) .SH AUTHOR -Author: Alan Hourihane +Author: Alan Hourihane, EXA support by Jesse Barnes Index: src/Makefile.am =================================================================== RCS file: /cvs/xorg/driver/xf86-video-trident/src/Makefile.am,v retrieving revision 1.1 diff -u -r1.1 Makefile.am --- src/Makefile.am 26 Jul 2005 23:50:00 -0000 1.1 +++ src/Makefile.am 25 Feb 2006 18:39:30 -0000 @@ -30,6 +30,7 @@ trident_drv_la_SOURCES = \ blade_accel.c \ + blade_accel_exa.c \ image_accel.c \ trident_accel.c \ trident_bank.c \ Index: src/blade_accel.c =================================================================== RCS file: /cvs/xorg/driver/xf86-video-trident/src/blade_accel.c,v retrieving revision 1.4 diff -u -r1.4 blade_accel.c --- src/blade_accel.c 11 Jul 2005 02:30:03 -0000 1.4 +++ src/blade_accel.c 25 Feb 2006 18:39:30 -0000 @@ -150,7 +150,7 @@ } Bool -BladeAccelInit(ScreenPtr pScreen) +BladeXaaInit(ScreenPtr pScreen) { XAAInfoRecPtr infoPtr; ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; Index: src/trident.h =================================================================== RCS file: /cvs/xorg/driver/xf86-video-trident/src/trident.h,v retrieving revision 1.3 diff -u -r1.3 trident.h --- src/trident.h 27 Jan 2006 17:14:03 -0000 1.3 +++ src/trident.h 25 Feb 2006 18:39:31 -0000 @@ -27,6 +27,7 @@ #ifndef _TRIDENT_H_ #define _TRIDENT_H_ +#include "exa.h" #include "xf86Cursor.h" #include "xaa.h" #include "xf86RamDac.h" @@ -59,6 +60,8 @@ pciVideoPtr PciInfo; PCITAG PciTag; EntityInfoPtr pEnt; + ExaDriverPtr EXADriverPtr; + int useEXA; int Chipset; int DACtype; int RamDac; @@ -226,7 +229,8 @@ Bool TridentAccelInit(ScreenPtr pScreen); Bool XPAccelInit(ScreenPtr pScreen); Bool ImageAccelInit(ScreenPtr pScreen); -Bool BladeAccelInit(ScreenPtr pScreen); +Bool BladeXaaInit(ScreenPtr pScreen); +Bool BladeExaInit(ScreenPtr pScreen); Bool TridentHWCursorInit(ScreenPtr pScreen); int TridentFindMode(int xres, int yres, int depth); void TGUISetClock(ScrnInfoPtr pScrn, int clock, unsigned char *a, unsigned char *b); Index: src/trident_driver.c =================================================================== RCS file: /cvs/xorg/driver/xf86-video-trident/src/trident_driver.c,v retrieving revision 1.14 diff -u -r1.14 trident_driver.c --- src/trident_driver.c 1 Feb 2006 14:55:03 -0000 1.14 +++ src/trident_driver.c 25 Feb 2006 18:39:34 -0000 @@ -113,7 +113,7 @@ */ static int pix24bpp = 0; -#define VERSION 4000 +#define TRIDENT_VERSION 4000 #define TRIDENT_NAME "TRIDENT" #define TRIDENT_DRIVER_NAME "trident" #define TRIDENT_MAJOR_VERSION 1 @@ -129,7 +129,7 @@ */ _X_EXPORT DriverRec TRIDENT = { - VERSION, + TRIDENT_VERSION, TRIDENT_DRIVER_NAME, TRIDENTIdentify, TRIDENTProbe, @@ -221,6 +221,7 @@ }; typedef enum { + OPTION_ACCELMETHOD, OPTION_SW_CURSOR, OPTION_PCI_RETRY, OPTION_RGB_BITS, @@ -248,6 +249,7 @@ } TRIDENTOpts; static const OptionInfoRec TRIDENTOptions[] = { + { OPTION_ACCELMETHOD, "AccelMethod", OPTV_ANYSTR, {0}, FALSE }, { OPTION_SW_CURSOR, "SWcursor", OPTV_BOOLEAN, {0}, FALSE }, { OPTION_PCI_RETRY, "PciRetry", OPTV_BOOLEAN, {0}, FALSE }, { OPTION_NOACCEL, "NoAccel", OPTV_BOOLEAN, {0}, FALSE }, @@ -496,6 +498,15 @@ NULL }; +const char *exaSymbols[] = { + "exaGetVersion", + "exaDriverInit", + "exaDriverFini", + "exaOffscreenAlloc", + "exaOffscreenFree", + NULL +}; + static const char *vgahwSymbols[] = { "vgaHWBlankScreenWeak", "vgaHWFreeHWRec", @@ -942,7 +953,7 @@ TRIDENTPciChipsets, NULL, NULL, NULL, NULL, NULL))) { /* Fill in what we can of the ScrnInfoRec */ - pScrn->driverVersion = VERSION; + pScrn->driverVersion = TRIDENT_VERSION; pScrn->driverName = TRIDENT_DRIVER_NAME; pScrn->name = TRIDENT_NAME; pScrn->Probe = TRIDENTProbe; @@ -974,7 +985,7 @@ if ((pScrn = xf86ConfigIsaEntity(pScrn,0,usedChips[i], TRIDENTISAchipsets,NULL, NULL,NULL,NULL,NULL))) { - pScrn->driverVersion = VERSION; + pScrn->driverVersion = TRIDENT_VERSION; pScrn->driverName = TRIDENT_DRIVER_NAME; pScrn->name = TRIDENT_NAME; pScrn->Probe = TRIDENTProbe; @@ -1237,6 +1248,22 @@ #endif } from = X_DEFAULT; + + pTrident->useEXA = FALSE; + if ((s = (char *)xf86GetOptValString(pTrident->Options, + OPTION_ACCELMETHOD))) { + if (!xf86NameCmp(s, "EXA")) { + pTrident->useEXA = TRUE; + from = X_CONFIG; + } + else if (!xf86NameCmp(s, "XAA")) { + pTrident->useEXA = FALSE; + from = X_CONFIG; + } + } + xf86DrvMsg(pScrn->scrnIndex, from, "Using %s for acceleration\n", + pTrident->useEXA ? "EXA" : "XAA"); + pTrident->HWCursor = TRUE; if (xf86ReturnOptValBool(pTrident->Options, OPTION_SW_CURSOR, FALSE)) { from = X_CONFIG; @@ -2421,16 +2448,29 @@ /* Load XAA if needed */ if (!pTrident->NoAccel) { - if (!xf86LoadSubModule(pScrn, "xaa")) { - if (IsPciCard && UseMMIO) { - TRIDENTDisableMMIO(pScrn); - TRIDENTUnmapMem(pScrn); + if (!pTrident->useEXA) { + if (!xf86LoadSubModule(pScrn, "xaa")) { + if (IsPciCard && UseMMIO) { + TRIDENTDisableMMIO(pScrn); + TRIDENTUnmapMem(pScrn); + } + TRIDENTFreeRec(pScrn); + return FALSE; } - TRIDENTFreeRec(pScrn); - return FALSE; + xf86LoaderReqSymLists(xaaSymbols, NULL); } - xf86LoaderReqSymLists(xaaSymbols, NULL); + if (pTrident->useEXA) { + if (!xf86LoadSubModule(pScrn, "exa")) { + if (IsPciCard && UseMMIO) { + TRIDENTDisableMMIO(pScrn); + TRIDENTUnmapMem(pScrn); + } + TRIDENTFreeRec(pScrn); + return FALSE; + } + xf86LoaderReqSymLists(exaSymbols, NULL); + } switch (pScrn->displayWidth * pScrn->bitsPerPixel / 8) { case 512: @@ -2514,8 +2554,8 @@ pTrident->PciTag, (unsigned long)pTrident->FbAddress, pTrident->FbMapSize); - if (pTrident->FbBase == NULL) - return FALSE; + if (pTrident->FbBase == NULL) + return FALSE; } } else @@ -2986,13 +3026,18 @@ (pTrident->Chipset == CYBERBLADEAI1) || (pTrident->Chipset == CYBERBLADEAI1D) || (pTrident->Chipset == CYBERBLADEE4) || - (pTrident->Chipset == BLADE3D)) - BladeAccelInit(pScreen); + (pTrident->Chipset == BLADE3D)) { + if (pTrident->useEXA) + BladeExaInit(pScreen); else + BladeXaaInit(pScreen); + } + else { if (pTrident->Chipset >= BLADEXP) XPAccelInit(pScreen); else ImageAccelInit(pScreen); + } } else { TridentAccelInit(pScreen); } @@ -3162,8 +3207,10 @@ TRIDENTPtr pTrident = TRIDENTPTR(pScrn); vgaHWPtr hwp = VGAHWPTR(pScrn); - if (!pTrident->NoAccel) + if (!pTrident->NoAccel && !pTrident->useEXA) pTrident->AccelInfoRec->Sync(pScrn); + else if (!pTrident->NoAccel && pTrident->useEXA) + pTrident->EXADriverPtr->accel.WaitMarker(pScrn->pScreen, 0); TRIDENTRestore(pScrn); vgaHWLock(hwp); @@ -3189,8 +3236,10 @@ TRIDENTPtr pTrident = TRIDENTPTR(pScrn); if (pScrn->vtSema) { - if (!pTrident->NoAccel) + if (!pTrident->NoAccel && !pTrident->useEXA) pTrident->AccelInfoRec->Sync(pScrn); + else if (!pTrident->NoAccel && pTrident->useEXA) + pTrident->EXADriverPtr->accel.WaitMarker(pScreen, 0); if (xf86IsPc98()) PC98TRIDENTDisable(pScrn); @@ -3202,6 +3251,11 @@ } if (pTrident->AccelInfoRec) XAADestroyInfoRec(pTrident->AccelInfoRec); + if (pTrident->EXADriverPtr) { + exaDriverFini(pScreen); + xfree(pTrident->EXADriverPtr); + pTrident->EXADriverPtr = NULL; + } if (pTrident->CursorInfoRec) xf86DestroyCursorInfoRec(pTrident->CursorInfoRec); if (pTrident->ShadowPtr) Index: src/trident_regs.h =================================================================== RCS file: /cvs/xorg/driver/xf86-video-trident/src/trident_regs.h,v retrieving revision 1.2 diff -u -r1.2 trident_regs.h --- src/trident_regs.h 23 Apr 2004 19:52:01 -0000 1.2 +++ src/trident_regs.h 25 Feb 2006 18:39:34 -0000 @@ -200,6 +200,61 @@ #define GER_DSTCLIP_X 0x214C /* Word */ #define GER_DSTCLIP_Y 0x214E /* Word */ +/* Graphics Engine for Cyberblade/i1 */ +#define GER_SRC1 0x2100 +#define GER_SRC2 0x2104 +#define GER_DST1 0x2108 +#define GER_DST2 0x210C +#define GER_CONTROL 0x2124 +#define GER_CTL_RESET (1 << 7) +#define GER_CTL_RESUME 0 +#define GER_DRAW_CMD 0x2144 +#define GER_OP_NULL 0 +#define GER_OP_RSVD1 (1 << 28) +#define GER_OP_LINE (2 << 28) +#define GER_OP_RSVD2 (3 << 28) +#define GER_OP_RSVD3 (4 << 28) +#define GER_OP_RSVD4 (5 << 28) +#define GER_OP_RSVD5 (6 << 28) +#define GER_OP_RSVD6 (7 << 28) +#define GER_OP_BLT_FB (8 << 28) +#define GER_OP_TXT_FB (9 << 28) +#define GER_OP_BLT_HOST (0xA << 28) +#define GER_OP_TRAP_POLY1 (0xB<< 28) +#define GER_OP_BLT_RE (0xC << 28) +#define GER_OP_TXT_RE (0xD << 28) +#define GER_OP_TRAP_POLY (0xE << 28) +#define GER_OP_RSVD7 (0xF << 28) + +/* Op args */ +#define GER_DRAW_SRC_COLOR (1 << 19) +#define GER_ROP_ENABLE (1 << 4) + +/* Blt, line & poly op operation sources */ +#define GER_BLT_SRC_HOST (0 << 2) +#define GER_BLT_SRC_FB (1 << 2) +#define GER_SRC_CONST (2 << 2) +#define GER_BLK_WRITE (3 << 2) + +#define GER_ROP 0x2148 +#define GER_CLIP0 0x2154 +#define GER_CLIP1 0x2158 +#define GER_FGCOLOR 0x2160 +#define GER_BITMASK 0x2184 +#define GER_PATSTYLE 0x216C +#define GER_DSTBASE0 0x21B8 +#define GER_DSTBASE1 0x21BC +#define GER_DSTBASE2 0x21C0 +#define GER_DSTBASE3 0x21C4 +#define GER_SRCBASE0 0x21C8 +#define GER_SRCBASE1 0x21CC +#define GER_SRCBASE2 0x21D0 +#define GER_SRCBASE3 0x21C4 + +/* Offsets 0x40-0xFF are overloaded for data upload */ +#define GER_DATA3 0x2156 +#define GER_DATA4 0x2160 + /* Wait for VSync */ #define WAITFORVSYNC \ { \ --- /dev/null 2006-02-20 13:36:39.733575000 -0800 +++ src/blade_accel_exa.c 2006-02-20 15:53:58.000000000 -0800 @@ -0,0 +1,397 @@ +/* + * Copyright 1997-2003 by Alan Hourihane, North Wales, UK. + * Copyright (c) 2006, Jesse Barnes + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of the authors not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. The authors make no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + * Authors: Alan Hourihane, + * Jesse Barnes + * + * Trident Blade3D accelerated options. + */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/trident/blade_accel.c,v 1.21 2003/10/30 13:38:01 alanh Exp $ */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "xf86.h" +#include "xf86_OSproc.h" +#include "xf86_ansic.h" + +#include "xf86PciInfo.h" +#include "xf86Pci.h" + +#include "exa.h" + +#include "trident.h" +#include "trident_regs.h" + +#include "xaarop.h" + +#undef REPLICATE +#define REPLICATE(r, bpp) \ +{ \ + if (bpp == 16) { \ + r = ((r & 0xFFFF) << 16) | (r & 0xFFFF); \ + } else \ + if (bpp == 8) { \ + r &= 0xFF; \ + r |= (r<<8); \ + r |= (r<<16); \ + } \ +} + +static int rop_table[16] = +{ + ROP_0, /* GXclear */ + ROP_DSa, /* GXand */ + ROP_SDna, /* GXandReverse */ + ROP_S, /* GXcopy */ + ROP_DSna, /* GXandInverted */ + ROP_D, /* GXnoop */ + ROP_DSx, /* GXxor */ + ROP_DSo, /* GXor */ + ROP_DSon, /* GXnor */ + ROP_DSxn, /* GXequiv */ + ROP_Dn, /* GXinvert*/ + ROP_SDno, /* GXorReverse */ + ROP_Sn, /* GXcopyInverted */ + ROP_DSno, /* GXorInverted */ + ROP_DSan, /* GXnand */ + ROP_1 /* GXset */ +}; + +static int GetCopyROP(int rop) +{ + return rop_table[rop]; +} + +static unsigned long GetDepth(int depth) +{ + unsigned long ret; + + switch (depth) { + case 8: + ret = 0; + break; + case 15: + ret = 5UL << 29; /* 555 */ + case 16: + ret = 1UL << 29; /* 565 */ + break; + case 32: + ret = 2UL << 29; + break; + default: + ret = 0; + break; + } + return ret; +} + +static Bool PrepareSolid(PixmapPtr pPixmap, int rop, Pixel planemask, + Pixel color) +{ + TRIDENTPtr pTrident = + TRIDENTPTR(xf86Screens[pPixmap->drawable.pScreen->myNum]); + + REPLICATE(color, pPixmap->drawable.bitsPerPixel); + BLADE_OUT(GER_FGCOLOR, color); + BLADE_OUT(GER_ROP, GetCopyROP(rop)); + pTrident->BltScanDirection = 0; + + return TRUE; +} + +static void Solid(PixmapPtr pPixmap, int x, int y, int x2, int y2) +{ + TRIDENTPtr pTrident = + TRIDENTPTR(xf86Screens[pPixmap->drawable.pScreen->myNum]); + int dst_stride = (pPixmap->drawable.width + 7) / 8; + int dst_off = exaGetPixmapOffset(pPixmap) / 8; + + BLADE_OUT(GER_DSTBASE0, GetDepth(pPixmap->drawable.bitsPerPixel) | + dst_stride << 20 | dst_off); + + BLADE_OUT(GER_DRAW_CMD, GER_OP_LINE | pTrident->BltScanDirection | + GER_DRAW_SRC_COLOR | GER_ROP_ENABLE | GER_SRC_CONST | + (pTrident->Clipping ? 1 : 0)); + + BLADE_OUT(GER_DST1, y << 16 | x); + BLADE_OUT(GER_DST2, ((y2 - 1) & 0xfff) << 16 | ((x2 - 1) & 0xfff)); +} + +static void DoneSolid(PixmapPtr pPixmap) +{ +} + +static Bool PrepareCopy(PixmapPtr pSrcPixmap, PixmapPtr pDstPixmap, + int xdir, int ydir, int alu, Pixel planemask) +{ + TRIDENTPtr pTrident = + TRIDENTPTR(xf86Screens[pSrcPixmap->drawable.pScreen->myNum]); + int src_stride = (pSrcPixmap->drawable.width + 7) / 8; + int src_off = exaGetPixmapOffset(pSrcPixmap) / 8; + int dst_stride = (pDstPixmap->drawable.width + 7) / 8; + int dst_off = exaGetPixmapOffset(pDstPixmap) / 8; + + pTrident->BltScanDirection = 0; + + /* Blade only supports +xdir,+ydir && -xdir,-ydir */ + if ((xdir * ydir) < 0) + return FALSE; + + REPLICATE(planemask, pSrcPixmap->drawable.bitsPerPixel); + if (planemask != (unsigned int)-1) { + BLADE_OUT(GER_BITMASK, ~planemask); + pTrident->BltScanDirection |= 1 << 5; + } + + BLADE_OUT(GER_SRCBASE0, GetDepth(pSrcPixmap->drawable.bitsPerPixel) | + src_stride << 20 | src_off); + + BLADE_OUT(GER_DSTBASE0, GetDepth(pDstPixmap->drawable.bitsPerPixel) | + dst_stride << 20 | dst_off); + + if ((xdir < 0) || (ydir < 0)) + pTrident->BltScanDirection |= 1 << 1; + + BLADE_OUT(GER_ROP, GetCopyROP(alu)); + + return TRUE; +} + +static void Copy(PixmapPtr pDstPixmap, int x1, int y1, int x2, + int y2, int w, int h) +{ + TRIDENTPtr pTrident = + TRIDENTPTR(xf86Screens[pDstPixmap->drawable.pScreen->myNum]); + + BLADE_OUT(GER_DRAW_CMD, GER_OP_BLT_HOST | GER_DRAW_SRC_COLOR | + GER_ROP_ENABLE | GER_BLT_SRC_FB | pTrident->BltScanDirection | + (pTrident->Clipping ? 1 : 0)); + + if (pTrident->BltScanDirection) { + BLADE_OUT(GER_SRC1, (y1 + h - 1) << 16 | (x1 + w - 1)); + BLADE_OUT(GER_SRC2, y1 << 16 | x1); + BLADE_OUT(GER_DST1, (y2 + h - 1) << 16 | (x2 + w - 1)); + BLADE_OUT(GER_DST2, (y2 & 0xfff) << 16 | (x2 & 0xfff)); + } else { + BLADE_OUT(GER_SRC1, y1 << 16 | x1); + BLADE_OUT(GER_SRC2, (y1 + h - 1) << 16 | (x1 + w - 1)); + BLADE_OUT(GER_DST1, y2 << 16 | x2); + BLADE_OUT(GER_DST2, (((y2 + h - 1) & 0xfff) << 16 | + ((x2 +w - 1) & 0xfff))); + } +} + +static void DoneCopy(PixmapPtr pDstPixmap) +{ +} +#if 0 +/* Composite comes later (if at all) */ +static Bool CheckComposite(int op, PicturePtr pSrcPicture, + PicturePtr pMaskPicture, PicturePtr pDstPicture) +{ + return 0; +} + +static Bool PrepareComposite(int op, PicturePtr pSrcPicture, + PicturePtr pMaskPicture, PicturePtr pDstPicture, + PixmapPtr pSrc, PixmapPtr pMask, PixmapPtr pDst) +{ + return 0; +} + +static void Composite(PixmapPtr pDst, int srcX, int srcY, int maskX, + int maskY, int dstX, int dstY, int width, + int height) +{ +} + +static void DoneComposite(PixmapPtr pDst) +{ +} +#endif +static Bool UploadToScreen(PixmapPtr pDstPixmap, int x, int y, int w, int h, + char *src, int src_stride) +{ + TRIDENTPtr pTrident = + TRIDENTPTR(xf86Screens[pDstPixmap->drawable.pScreen->myNum]); + int dst_stride = (pDstPixmap->drawable.width + 7) / 8; + int dst_off = exaGetPixmapOffset(pDstPixmap) / 8; + int i, copy_width = (src_stride + 7) / 8; /* Write 8 bytes at a time */ + + return FALSE; /* this routine doesn't work yet */ + + ErrorF("UploadToScreen: 0x%p -> 0x%x, (%d, %d), (%d, %d) x %d\n", src, + dst_off, x, y, x + w, y + h, src_stride); + + BLADE_OUT(GER_DSTBASE0, GetDepth(pDstPixmap->drawable.bitsPerPixel) | + dst_stride << 20 | dst_off); + + BLADE_OUT(GER_DRAW_CMD, GER_OP_BLT_HOST | GER_DRAW_SRC_COLOR | + GER_BLT_SRC_HOST | (pTrident->Clipping ? 1 : 0)); + + while (h--) { + int *src_data = (int *)src; + for (i = 0; i < copy_width; i++) { + BLADE_OUT(GER_DATA3, *src_data); + src_data++; + BLADE_OUT(GER_DATA4, *src_data); + src_data++; + } + src += src_stride; + } + + return TRUE; +} + + +static Bool DownloadFromScreen(PixmapPtr pSrc, int x, int y, int w, int h, + char *dst, int dst_pitch) +{ + return FALSE; +} + +static int MarkSync(ScreenPtr pScreen) +{ + return 0; +} + +static void BladeDisableClipping(ScrnInfoPtr pScrn) +{ + TRIDENTPtr pTrident = TRIDENTPTR(pScrn); + pTrident->Clipping = FALSE; +} + +static void WaitMarker(ScreenPtr pScreen, int marker) +{ + TRIDENTPtr pTrident = TRIDENTPTR(xf86Screens[pScreen->myNum]); + int busy; + int cnt = 10000000; + + if (pTrident->Clipping) + BladeDisableClipping(xf86Screens[pScreen->myNum]); + BLADE_OUT(GER_PATSTYLE, 0); /* Clear pattern & style first? */ + + BLADEBUSY(busy); + while (busy != 0) { + if (--cnt < 0) { + ErrorF("GE timeout\n"); + BLADE_OUT(GER_CONTROL, GER_CTL_RESET); + BLADE_OUT(GER_CONTROL, GER_CTL_RESUME); + break; + } + BLADEBUSY(busy); + } +} +#if 0 +static Bool PrepareAccess(PixmapPtr pPix, int index) +{ +} + +static void FinishAccess(PixmapPtr pPix, int index) +{ +} + +static void BladeSetClippingRectangle(ScrnInfoPtr pScrn, int x1, int y1, + int x2, int y2) +{ + TRIDENTPtr pTrident = TRIDENTPTR(pScrn); + + BLADE_OUT(GER_CLIP0, (y1 & 0x0fff) << 16 | (x1 & 0x0fff)); + BLADE_OUT(GER_CLIP1, (y2 & 0x0fff) << 16 | (x2 & 0x0fff)); + pTrident->Clipping = TRUE; +} +#endif +static void BladeInitializeAccelerator(ScrnInfoPtr pScrn) +{ + TRIDENTPtr pTrident = TRIDENTPTR(pScrn); + + BLADE_OUT(GER_DSTBASE0, 0); + BLADE_OUT(GER_DSTBASE1, 0); + BLADE_OUT(GER_DSTBASE2, 0); + BLADE_OUT(GER_DSTBASE3, 0); + BLADE_OUT(GER_SRCBASE0, 0); + BLADE_OUT(GER_SRCBASE1, 0); + BLADE_OUT(GER_SRCBASE2, 0); + BLADE_OUT(GER_SRCBASE3, 0); + BLADE_OUT(GER_PATSTYLE, 0); +} + +Bool BladeExaInit(ScreenPtr pScreen) +{ + ExaDriverPtr ExaDriver; + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + TRIDENTPtr pTrident = TRIDENTPTR(pScrn); + + if (pTrident->NoAccel) + return FALSE; + + ExaDriver = xnfcalloc(sizeof(ExaDriverRec), 1); + if (!ExaDriver) { + pTrident->NoAccel = TRUE; + return FALSE; + } + + pTrident->InitializeAccelerator = BladeInitializeAccelerator; + BladeInitializeAccelerator(pScrn); + + ExaDriver->card.memoryBase = pTrident->FbBase; + ExaDriver->card.memorySize = pScrn->videoRam * 1024; + + ExaDriver->card.offScreenBase = pScrn->virtualX * pScrn->virtualY * + ((pScrn->bitsPerPixel + 7) / 8); + + if(ExaDriver->card.memorySize > ExaDriver->card.offScreenBase) + ExaDriver->card.flags = EXA_OFFSCREEN_PIXMAPS; + else { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Not enough video RAM for " + "offscreen memory manager. Xv disabled\n"); + /* disable Xv here... */ + } + + ExaDriver->card.pixmapOffsetAlign = 32; + ExaDriver->card.pixmapPitchAlign = 32; + ExaDriver->card.maxX = 1280; + ExaDriver->card.maxY = 1024; + + ExaDriver->accel.MarkSync = MarkSync; + ExaDriver->accel.WaitMarker = WaitMarker; + + /* Solid fill & copy, the bare minimum */ + ExaDriver->accel.PrepareSolid = PrepareSolid; + ExaDriver->accel.Solid = Solid; + ExaDriver->accel.DoneSolid = DoneSolid; + ExaDriver->accel.PrepareCopy = PrepareCopy; + ExaDriver->accel.Copy = Copy; + ExaDriver->accel.DoneCopy = DoneCopy; + + /* Composite pointers if implemented... */ + + /* Upload, download to/from Screen, optional */ + ExaDriver->accel.UploadToScreen = UploadToScreen; + ExaDriver->accel.DownloadFromScreen = DownloadFromScreen; + + pTrident->EXADriverPtr = ExaDriver; + + return exaDriverInit(pScreen, pTrident->EXADriverPtr); +}