diff -Nau -x '*.swp' -x CVS -x 'Makefile*' -x '*o' -x '*a' xf86-video-ati/src/atiaccel.c xf86-video-ati-exa/src/atiaccel.c --- xf86-video-ati/src/atiaccel.c 2006-02-05 16:26:43.000000000 +0200 +++ xf86-video-ati-exa/src/atiaccel.c 2006-03-05 22:46:51.000000000 +0200 @@ -33,6 +33,7 @@ #include "atimach64accel.h" #include "atistruct.h" +#ifdef USE_XAA /* * ATIInitializeAcceleration -- * @@ -73,10 +74,10 @@ #ifdef XF86DRI_DEVEL - /* If DRI is enabled, we've already set up the FB manager in ATIScreenInit */ - if (!pATI->directRenderingEnabled) + /* If DRI is enabled, we've already set up the FB manager in ATIScreenInit */ + if (!pATI->directRenderingEnabled) -#endif /* XF86DRI */ +#endif /* XF86DRI_DEVEL */ { /* * Note: If PixelArea exceeds the engine's maximum, the excess is @@ -97,7 +98,9 @@ pATI->pXAAInfo = NULL; return FALSE; } +#endif /* USE_XAA */ +#ifdef USE_XAA FBLinearPtr ATIResizeOffscreenLinear ( @@ -144,3 +147,4 @@ return pLinear; } +#endif /* USE_XAA */ diff -Nau -x '*.swp' -x CVS -x 'Makefile*' -x '*o' -x '*a' xf86-video-ati/src/aticonfig.c xf86-video-ati-exa/src/aticonfig.c --- xf86-video-ati/src/aticonfig.c 2006-02-05 16:26:43.000000000 +0200 +++ xf86-video-ati-exa/src/aticonfig.c 2006-02-20 23:05:36.000000000 +0200 @@ -151,6 +151,7 @@ # define ProbeClocks PublicOption[ATI_OPTION_PROBE_CLOCKS].value.bool # define ShadowFB PublicOption[ATI_OPTION_SHADOW_FB].value.bool # define SWCursor PublicOption[ATI_OPTION_SWCURSOR].value.bool +# define AccelMethod PublicOption[ATI_OPTION_ACCELMETHOD].value.str # define LCDSync PrivateOption[ATI_OPTION_LCDSYNC].value.bool # define ReferenceClock \ @@ -338,5 +339,25 @@ } } + pATI->useEXA = FALSE; + if (pATI->OptionAccel) + { + MessageType from = X_DEFAULT; +#if defined(USE_EXA) +#if defined(USE_XAA) + if (AccelMethod != NULL) { + from = X_CONFIG; + if (xf86NameCmp(AccelMethod, "EXA") == 0) + pATI->useEXA = TRUE; + } +#else /* USE_XAA */ + pATI->useEXA = TRUE; +#endif /* !USE_XAA */ +#endif /* USE_EXA */ + xf86DrvMsg(pScreenInfo->scrnIndex, from, + "Using %s acceleration architecture\n", + pATI->useEXA ? "EXA" : "XAA"); + } + xfree(PublicOption); } diff -Nau -x '*.swp' -x CVS -x 'Makefile*' -x '*o' -x '*a' xf86-video-ati/src/aticonsole.c xf86-video-ati-exa/src/aticonsole.c --- xf86-video-ati/src/aticonsole.c 2005-07-11 05:29:44.000000000 +0300 +++ xf86-video-ati-exa/src/aticonsole.c 2006-02-23 17:35:58.000000000 +0200 @@ -37,6 +37,7 @@ #include "atilock.h" #include "atimach64.h" #include "atimach64io.h" +#include "atimach64iodri.h" #include "atimode.h" #include "atistruct.h" #include "ativga.h" diff -Nau -x '*.swp' -x CVS -x 'Makefile*' -x '*o' -x '*a' xf86-video-ati/src/atidga.c xf86-video-ati-exa/src/atidga.c --- xf86-video-ati/src/atidga.c 2005-07-11 05:29:44.000000000 +0300 +++ xf86-video-ati-exa/src/atidga.c 2006-02-23 00:35:15.000000000 +0200 @@ -186,6 +186,8 @@ ) { ATIPtr pATI = ATIPTR(pScreenInfo); +/*FIXME : use EXA if available */ +#ifdef USE_XAA XAAInfoRecPtr pXAAInfo = pATI->pXAAInfo; (*pXAAInfo->SetupForSolidFill)(pScreenInfo, (int)colour, GXcopy, @@ -194,6 +196,7 @@ if (pScreenInfo->bitsPerPixel == pATI->bitsPerPixel) SET_SYNC_FLAG(pXAAInfo); +#endif } /* @@ -215,6 +218,8 @@ ) { ATIPtr pATI = ATIPTR(pScreenInfo); +/*FIXME : use EXA if available */ +#ifdef USE_XAA XAAInfoRecPtr pXAAInfo = pATI->pXAAInfo; int xdir = ((xSrc < xDst) && (ySrc == yDst)) ? -1 : 1; int ydir = (ySrc < yDst) ? -1 : 1; @@ -226,6 +231,7 @@ if (pScreenInfo->bitsPerPixel == pATI->bitsPerPixel) SET_SYNC_FLAG(pXAAInfo); +#endif } /* @@ -248,6 +254,8 @@ ) { ATIPtr pATI = ATIPTR(pScreenInfo); +/*FIXME : use EXA if available */ +#ifdef USE_XAA XAAInfoRecPtr pXAAInfo = pATI->pXAAInfo; int xdir = ((xSrc < xDst) && (ySrc == yDst)) ? -1 : 1; int ydir = (ySrc < yDst) ? -1 : 1; @@ -264,6 +272,7 @@ if (pScreenInfo->bitsPerPixel == pATI->bitsPerPixel) SET_SYNC_FLAG(pXAAInfo); +#endif } /* @@ -333,8 +342,10 @@ pDGAMode->flags |= DGA_PIXMAP_AVAILABLE; pDGAMode->address = pATI->pMemory; +#ifdef USE_XAA if (pATI->pXAAInfo) pDGAMode->flags &= ~DGA_CONCURRENT_ACCESS; +#endif } if ((pMode->Flags & V_DBLSCAN) || (pMode->VScan > 1)) pDGAMode->flags |= DGA_DOUBLESCAN; @@ -395,7 +406,9 @@ ATIPtr pATI ) { +#ifdef USE_XAA XAAInfoRecPtr pXAAInfo; +#endif int flags; if (!pATI->nDGAMode) @@ -420,6 +433,7 @@ pATI->ATIDGAFunctions.GetViewport = ATIDGAGetViewport; flags = 0; +#ifdef USE_XAA if ((pXAAInfo = pATI->pXAAInfo)) { pATI->ATIDGAFunctions.Sync = pXAAInfo->Sync; @@ -437,6 +451,7 @@ pATI->ATIDGAFunctions.BlitTransRect = ATIDGABlitTransRect; } } +#endif if (!flags) flags = DGA_CONCURRENT_ACCESS; diff -Nau -x '*.swp' -x CVS -x 'Makefile*' -x '*o' -x '*a' xf86-video-ati/src/atidri.c xf86-video-ati-exa/src/atidri.c --- xf86-video-ati/src/atidri.c 2006-02-20 15:32:57.000000000 +0200 +++ xf86-video-ati-exa/src/atidri.c 2006-03-06 03:02:24.000000000 +0200 @@ -40,6 +40,7 @@ #include "ativersion.h" #include "atimach64io.h" +#include "atimach64iodri.h" #include "mach64_dri.h" #include "mach64_common.h" #include "mach64_sarea.h" @@ -289,9 +290,9 @@ ScrnInfoPtr pScreenInfo = xf86Screens[pScreen->myNum]; ATIPtr pATI = ATIPTR(pScreenInfo); - if ( pATI->directRenderingEnabled && pATI->pXAAInfo ) { - pATI->pXAAInfo->NeedToSync = TRUE; - pATI->NeedDRISync = TRUE; + if ( pATI->directRenderingEnabled ) { + ATIDRIMarkSyncInt(pScreenInfo); + ATIDRIMarkSyncExt(pScreenInfo); } } @@ -334,6 +335,10 @@ ScrnInfoPtr pScreenInfo = xf86Screens[pScreen->myNum]; ATIPtr pATI = ATIPTR(pScreenInfo); +#ifdef USE_XAA + if (pATI->useEXA) + return; + if (pATI->backArea) { xf86FreeOffscreenArea(pATI->backArea); pATI->backArea = NULL; @@ -342,6 +347,8 @@ xf86FreeOffscreenArea(pATI->depthTexArea); pATI->depthTexArea = NULL; } +#endif + pATI->have3DWindows = FALSE; } @@ -349,9 +356,14 @@ { ScrnInfoPtr pScreenInfo = xf86Screens[pScreen->myNum]; ATIPtr pATI = ATIPTR(pScreenInfo); +#ifdef USE_XAA FBAreaPtr fbArea; int width, height; + /* EXA allocates these areas up front, in memory manager setup */ + if (pATI->useEXA) + return; + xf86PurgeUnlockedOffscreenAreas(pScreen); xf86QueryLargestOffscreenArea(pScreen, &width, &height, 0, 0, 0); @@ -393,6 +405,7 @@ if (fbArea) xf86FreeOffscreenArea(fbArea); +#endif pATI->have3DWindows = TRUE; } @@ -400,6 +413,7 @@ /* Initialize the state of the back and depth buffers. */ static void ATIDRIInitBuffers( WindowPtr pWin, RegionPtr prgn, CARD32 indx ) { +#ifdef USE_XAA ScreenPtr pScreen = pWin->drawable.pScreen; ScrnInfoPtr pScreenInfo = xf86Screens[pScreen->myNum]; ATIPtr pATI = ATIPTR(pScreenInfo); @@ -450,7 +464,8 @@ pbox->x2 - pbox->x1, pbox->y2 - pbox->y1); - pXAAInfo->NeedToSync = TRUE; + ATIDRIMarkSyncInt(pScreenInfo); +#endif } /* Copy the back and depth buffers when the X server moves a window. @@ -465,6 +480,7 @@ static void ATIDRIMoveBuffers( WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc, CARD32 indx ) { +#ifdef USE_XAA ScreenPtr pScreen = pWin->drawable.pScreen; ScrnInfoPtr pScreenInfo = xf86Screens[pScreen->myNum]; ATIPtr pATI = ATIPTR(pScreenInfo); @@ -628,7 +644,8 @@ DEALLOCATE_LOCAL(pptNew1); DEALLOCATE_LOCAL(pboxNew1); - pXAAInfo->NeedToSync = TRUE; + ATIDRIMarkSyncInt(pScreenInfo); +#endif } /* Compute log base 2 of val. */ diff -Nau -x '*.swp' -x CVS -x 'Makefile*' -x '*o' -x '*a' xf86-video-ati/src/atiload.c xf86-video-ati-exa/src/atiload.c --- xf86-video-ati/src/atiload.c 2005-07-11 05:29:44.000000000 +0300 +++ xf86-video-ati-exa/src/atiload.c 2006-02-27 15:39:41.000000000 +0200 @@ -144,6 +144,18 @@ NULL }; +#ifdef USE_EXA +const char *ATIexaSymbols[] = +{ + "exaDriverInit", + "exaDriverFini", + "exaOffscreenAlloc", + "exaOffscreenFree", + NULL +}; +#endif + +#ifdef USE_XAA const char *ATIxaaSymbols[] = { "XAACreateInfoRec", @@ -151,6 +163,7 @@ "XAAInit", NULL }; +#endif const char *ATIramdacSymbols[] = { @@ -205,21 +218,13 @@ ATIPtr pATI ) { + pointer fbPtr = NULL; + /* Load shadow frame buffer code if needed */ if (pATI->OptionShadowFB && !ATILoadModule(pScreenInfo, "shadowfb", ATIshadowfbSymbols)) return NULL; - /* Load XAA if needed */ - if (pATI->OptionAccel && - !ATILoadModule(pScreenInfo, "xaa", ATIxaaSymbols)) - return NULL; - - /* Load ramdac module if needed */ - if ((pATI->Cursor > ATI_CURSOR_SOFTWARE) && - !ATILoadModule(pScreenInfo, "ramdac", ATIramdacSymbols)) - return NULL; - /* Load depth-specific entry points */ switch (pATI->bitsPerPixel) { @@ -227,10 +232,12 @@ #ifndef AVOID_CPIO case 1: - return ATILoadModule(pScreenInfo, "xf1bpp", ATIxf1bppSymbols); + fbPtr = ATILoadModule(pScreenInfo, "xf1bpp", ATIxf1bppSymbols); + break; case 4: - return ATILoadModule(pScreenInfo, "xf4bpp", ATIxf4bppSymbols); + fbPtr = ATILoadModule(pScreenInfo, "xf4bpp", ATIxf4bppSymbols); + break; #endif /* AVOID_CPIO */ @@ -238,11 +245,34 @@ case 16: case 24: case 32: - return ATILoadModule(pScreenInfo, "fb", ATIfbSymbols); + fbPtr = ATILoadModule(pScreenInfo, "fb", ATIfbSymbols); + break; default: return NULL; } + if (!fbPtr) + return NULL; + + /* Load ramdac module if needed */ + if ((pATI->Cursor > ATI_CURSOR_SOFTWARE) && + !ATILoadModule(pScreenInfo, "ramdac", ATIramdacSymbols)) + return NULL; + +#ifdef USE_EXA + /* Load EXA if needed */ + if (pATI->useEXA && pATI->OptionAccel && + !ATILoadModule(pScreenInfo, "exa", ATIexaSymbols)) + return NULL; +#endif +#ifdef USE_XAA + /* Load XAA if needed */ + if (!pATI->useEXA && pATI->OptionAccel && + !ATILoadModule(pScreenInfo, "xaa", ATIxaaSymbols)) + return NULL; +#endif + + return fbPtr; } #endif /* XFree86LOADER */ diff -Nau -x '*.swp' -x CVS -x 'Makefile*' -x '*o' -x '*a' xf86-video-ati/src/atiload.h xf86-video-ati-exa/src/atiload.h --- xf86-video-ati/src/atiload.h 2004-09-21 21:10:34.000000000 +0300 +++ xf86-video-ati-exa/src/atiload.h 2006-02-20 21:42:24.000000000 +0200 @@ -47,7 +47,20 @@ #endif /* XF86DRI_DEVEL */ - *ATIfbSymbols[], *ATIshadowfbSymbols[], *ATIxaaSymbols[], + *ATIfbSymbols[], *ATIshadowfbSymbols[], + +#ifdef USE_EXA + + *ATIexaSymbols[], + +#endif /* USE_EXA */ + +#ifdef USE_XAA + + *ATIxaaSymbols[], + +#endif /* USE_XAA */ + *ATIramdacSymbols[], *ATIi2cSymbols[]; extern pointer ATILoadModule(ScrnInfoPtr, const char *, const char **); diff -Nau -x '*.swp' -x CVS -x 'Makefile*' -x '*o' -x '*a' xf86-video-ati/src/atimach64accel.c xf86-video-ati-exa/src/atimach64accel.c --- xf86-video-ati/src/atimach64accel.c 2006-02-05 16:26:44.000000000 +0200 +++ xf86-video-ati-exa/src/atimach64accel.c 2006-03-06 22:26:37.000000000 +0200 @@ -57,6 +57,7 @@ #include "atichip.h" #include "atimach64accel.h" #include "atimach64io.h" +#include "atimach64iodri.h" #include "atipriv.h" #include "atiregs.h" @@ -79,7 +80,7 @@ /* * X-to-Mach64 mix translation table. */ -static CARD8 ATIMach64ALU[16] = +CARD8 ATIMach64ALU[16] = { MIX_0, /* GXclear */ MIX_AND, /* GXand */ @@ -105,7 +106,7 @@ * This function ensures the current scissor settings do not interfere with * the current draw request. */ -static void +void ATIMach64ValidateClip ( ATIPtr pATI, @@ -130,6 +131,67 @@ } } +static __inline__ void TestRegisterCachingXV +( + ScrnInfoPtr pScreenInfo +) +{ + ATIPtr pATI = ATIPTR(pScreenInfo); + + if (pATI->Block1Base) + { + TestRegisterCaching(OVERLAY_Y_X_START); + TestRegisterCaching(OVERLAY_Y_X_END); + + TestRegisterCaching(OVERLAY_GRAPHICS_KEY_CLR); + TestRegisterCaching(OVERLAY_GRAPHICS_KEY_MSK); + + TestRegisterCaching(OVERLAY_KEY_CNTL); + + TestRegisterCaching(OVERLAY_SCALE_INC); + TestRegisterCaching(OVERLAY_SCALE_CNTL); + + TestRegisterCaching(SCALER_HEIGHT_WIDTH); + + TestRegisterCaching(SCALER_TEST); + + TestRegisterCaching(VIDEO_FORMAT); + + if (pATI->Chip < ATI_CHIP_264VTB) + { + TestRegisterCaching(BUF0_OFFSET); + TestRegisterCaching(BUF0_PITCH); + TestRegisterCaching(BUF1_OFFSET); + TestRegisterCaching(BUF1_PITCH); + } + else + { + TestRegisterCaching(SCALER_BUF0_OFFSET); + TestRegisterCaching(SCALER_BUF1_OFFSET); + TestRegisterCaching(SCALER_BUF_PITCH); + + TestRegisterCaching(OVERLAY_EXCLUSIVE_HORZ); + TestRegisterCaching(OVERLAY_EXCLUSIVE_VERT); + + if (pATI->Chip >= ATI_CHIP_264GTPRO) + { + TestRegisterCaching(SCALER_COLOUR_CNTL); + + TestRegisterCaching(SCALER_H_COEFF0); + TestRegisterCaching(SCALER_H_COEFF1); + TestRegisterCaching(SCALER_H_COEFF2); + TestRegisterCaching(SCALER_H_COEFF3); + TestRegisterCaching(SCALER_H_COEFF4); + + TestRegisterCaching(SCALER_BUF0_OFFSET_U); + TestRegisterCaching(SCALER_BUF0_OFFSET_V); + TestRegisterCaching(SCALER_BUF1_OFFSET_U); + TestRegisterCaching(SCALER_BUF1_OFFSET_V); + } + } + } +} + /* * ATIMach64Sync -- * @@ -159,6 +221,7 @@ UncacheRegister(DP_BKGD_CLR); UncacheRegister(DP_FRGD_CLR); UncacheRegister(DP_WRITE_MASK); + UncacheRegister(DP_PIX_WIDTH); UncacheRegister(DP_MIX); UncacheRegister(CLR_CMP_CNTL); } @@ -204,6 +267,7 @@ CacheRegister(DP_BKGD_CLR); CacheRegister(DP_FRGD_CLR); CacheRegister(DP_WRITE_MASK); + CacheRegister(DP_PIX_WIDTH); CacheRegister(DP_MIX); CacheRegister(CLR_CMP_CNTL); } @@ -219,61 +283,8 @@ TestRegisterCaching(CLR_CMP_CLR); TestRegisterCaching(CLR_CMP_MSK); - if (pATI->Block1Base) - { - TestRegisterCaching(OVERLAY_Y_X_START); - TestRegisterCaching(OVERLAY_Y_X_END); - - TestRegisterCaching(OVERLAY_GRAPHICS_KEY_CLR); - TestRegisterCaching(OVERLAY_GRAPHICS_KEY_MSK); - - TestRegisterCaching(OVERLAY_KEY_CNTL); - - TestRegisterCaching(OVERLAY_SCALE_INC); - TestRegisterCaching(OVERLAY_SCALE_CNTL); - - TestRegisterCaching(SCALER_HEIGHT_WIDTH); - - TestRegisterCaching(SCALER_TEST); - - TestRegisterCaching(VIDEO_FORMAT); - - if (pATI->Chip < ATI_CHIP_264VTB) - { - TestRegisterCaching(BUF0_OFFSET); - TestRegisterCaching(BUF0_PITCH); - TestRegisterCaching(BUF1_OFFSET); - TestRegisterCaching(BUF1_PITCH); - } - else - { - TestRegisterCaching(SCALER_BUF0_OFFSET); - TestRegisterCaching(SCALER_BUF1_OFFSET); - TestRegisterCaching(SCALER_BUF_PITCH); - - TestRegisterCaching(OVERLAY_EXCLUSIVE_HORZ); - TestRegisterCaching(OVERLAY_EXCLUSIVE_VERT); - - if (pATI->Chip >= ATI_CHIP_264GTPRO) - { - TestRegisterCaching(SCALER_COLOUR_CNTL); - - TestRegisterCaching(SCALER_H_COEFF0); - TestRegisterCaching(SCALER_H_COEFF1); - TestRegisterCaching(SCALER_H_COEFF2); - TestRegisterCaching(SCALER_H_COEFF3); - TestRegisterCaching(SCALER_H_COEFF4); - - TestRegisterCaching(SCALER_BUF0_OFFSET_U); - TestRegisterCaching(SCALER_BUF0_OFFSET_V); - TestRegisterCaching(SCALER_BUF1_OFFSET_U); - TestRegisterCaching(SCALER_BUF1_OFFSET_V); - } - } - } - } - pATI->NeedDRISync = FALSE; - + TestRegisterCachingXV(pScreenInfo); + } } else @@ -316,79 +327,29 @@ TestRegisterCaching(DP_BKGD_CLR); TestRegisterCaching(DP_FRGD_CLR); TestRegisterCaching(DP_WRITE_MASK); + TestRegisterCaching(DP_PIX_WIDTH); TestRegisterCaching(DP_MIX); TestRegisterCaching(CLR_CMP_CLR); TestRegisterCaching(CLR_CMP_MSK); TestRegisterCaching(CLR_CMP_CNTL); - if (pATI->Block1Base) - { - TestRegisterCaching(OVERLAY_Y_X_START); - TestRegisterCaching(OVERLAY_Y_X_END); - - TestRegisterCaching(OVERLAY_GRAPHICS_KEY_CLR); - TestRegisterCaching(OVERLAY_GRAPHICS_KEY_MSK); - - TestRegisterCaching(OVERLAY_KEY_CNTL); - - TestRegisterCaching(OVERLAY_SCALE_INC); - TestRegisterCaching(OVERLAY_SCALE_CNTL); - - TestRegisterCaching(SCALER_HEIGHT_WIDTH); - - TestRegisterCaching(SCALER_TEST); - - TestRegisterCaching(VIDEO_FORMAT); - - if (pATI->Chip < ATI_CHIP_264VTB) - { - TestRegisterCaching(BUF0_OFFSET); - TestRegisterCaching(BUF0_PITCH); - TestRegisterCaching(BUF1_OFFSET); - TestRegisterCaching(BUF1_PITCH); - } - else - { - TestRegisterCaching(SCALER_BUF0_OFFSET); - TestRegisterCaching(SCALER_BUF1_OFFSET); - TestRegisterCaching(SCALER_BUF_PITCH); - - TestRegisterCaching(OVERLAY_EXCLUSIVE_HORZ); - TestRegisterCaching(OVERLAY_EXCLUSIVE_VERT); - - if (pATI->Chip >= ATI_CHIP_264GTPRO) - { - TestRegisterCaching(SCALER_COLOUR_CNTL); - - TestRegisterCaching(SCALER_H_COEFF0); - TestRegisterCaching(SCALER_H_COEFF1); - TestRegisterCaching(SCALER_H_COEFF2); - TestRegisterCaching(SCALER_H_COEFF3); - TestRegisterCaching(SCALER_H_COEFF4); - - TestRegisterCaching(SCALER_BUF0_OFFSET_U); - TestRegisterCaching(SCALER_BUF0_OFFSET_V); - TestRegisterCaching(SCALER_BUF1_OFFSET_U); - TestRegisterCaching(SCALER_BUF1_OFFSET_V); - } - } - } + TestRegisterCachingXV(pScreenInfo); } } + ATIDRIUnmarkSync(pScreenInfo); + /* * For VTB's and later, the first CPU read of the framebuffer will return * zeroes, so do it here. This appears to be due to some kind of engine * caching of framebuffer data I haven't found any way of disabling, or * otherwise circumventing. Thanks to Mark Vojkovich for the suggestion. */ - if (pATI->pXAAInfo) - pATI->pXAAInfo->NeedToSync = FALSE; - pATI = *(volatile ATIPtr *)pATI->pMemory; } +#ifdef USE_XAA /* * ATIMach64SetupForScreenToScreenCopy -- * @@ -1035,3 +996,4 @@ return ATIMach64MaxY; } +#endif /* USE_XAA */ diff -Nau -x '*.swp' -x CVS -x 'Makefile*' -x '*o' -x '*a' xf86-video-ati/src/atimach64accel.h xf86-video-ati-exa/src/atimach64accel.h --- xf86-video-ati/src/atimach64accel.h 2006-02-05 16:26:44.000000000 +0200 +++ xf86-video-ati-exa/src/atimach64accel.h 2006-03-06 00:19:00.000000000 +0200 @@ -27,11 +27,17 @@ #include "atipriv.h" #include "xaa.h" +#include "exa.h" #define ATIMach64MaxX 8191 #define ATIMach64MaxY 32767 +#ifdef USE_EXA +extern Bool ATIMach64ExaInit(ScreenPtr); +#endif +#ifdef USE_XAA extern int ATIMach64AccelInit(ATIPtr, XAAInfoRecPtr); +#endif extern void ATIMach64Sync(ScrnInfoPtr); #endif /* ___ATIMACH64ACCEL_H___ */ diff -Nau -x '*.swp' -x CVS -x 'Makefile*' -x '*o' -x '*a' xf86-video-ati/src/atimach64.c xf86-video-ati-exa/src/atimach64.c --- xf86-video-ati/src/atimach64.c 2005-07-11 05:29:44.000000000 +0300 +++ xf86-video-ati-exa/src/atimach64.c 2006-03-05 12:40:53.000000000 +0200 @@ -60,6 +60,7 @@ #include "atimach64.h" #include "atimach64accel.h" #include "atimach64io.h" +#include "atimach64iodri.h" #include "atirgb514.h" #ifndef DPMS_SERVER @@ -850,9 +851,7 @@ outf(HOST_CNTL, pATIHW->host_cntl); /* Set host transfer window address and size clamp */ - pATI->pHOST_DATA = - (CARD8 *)pATI->pBlock[GetBits(HOST_DATA_0, BLOCK_SELECT)] + - (HOST_DATA_0 & MM_IO_SELECT); + pATI->pHOST_DATA = inh(HOST_DATA_0); pATI->nHostFIFOEntries = pATI->nFIFOEntries >> 1; if (pATI->nHostFIFOEntries > 16) pATI->nHostFIFOEntries = 16; diff -Nau -x '*.swp' -x CVS -x 'Makefile*' -x '*o' -x '*a' xf86-video-ati/src/atimach64cursor.c xf86-video-ati-exa/src/atimach64cursor.c --- xf86-video-ati/src/atimach64cursor.c 2005-07-11 05:29:44.000000000 +0300 +++ xf86-video-ati-exa/src/atimach64cursor.c 2006-02-23 17:36:35.000000000 +0200 @@ -30,6 +30,7 @@ #include "atimach64accel.h" #include "atimach64cursor.h" #include "atimach64io.h" +#include "atimach64iodri.h" /* * ATIMach64SetCursorColours -- diff -Nau -x '*.swp' -x CVS -x 'Makefile*' -x '*o' -x '*a' xf86-video-ati/src/atimach64exa.c xf86-video-ati-exa/src/atimach64exa.c --- xf86-video-ati/src/atimach64exa.c 1970-01-01 02:00:00.000000000 +0200 +++ xf86-video-ati-exa/src/atimach64exa.c 2006-03-06 22:13:50.000000000 +0200 @@ -0,0 +1,739 @@ +/* + * FIXME: put copyright here + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "ati.h" +#include "atichip.h" +#include "atimach64accel.h" +#include "atimach64io.h" +#include "atimach64iodri.h" +#include "atipriv.h" +#include "atiregs.h" + +#ifdef XF86DRI_DEVEL +#include "mach64_dri.h" +#include "mach64_sarea.h" +#endif + +#ifdef USE_EXA +static void +ATIMach64WaitMarker +( + ScreenPtr pScreenInfo, + int Marker +) +{ + ATIMach64Sync(xf86Screens[pScreenInfo->myNum]); +} + +extern CARD8 ATIMach64ALU[]; + +extern void +ATIMach64ValidateClip(ATIPtr pATI, + int sc_left, int sc_right, int sc_top, int sc_bottom); + +static void +ATIGetOffsetPitch(int bpp, CARD32 *pitch_offset, int offset, int pitch) +{ + if (bpp == 24) + bpp = 8; + + /* pixels / 8 = ((bytes * 8) / bpp) / 8 = bytes / bpp */ + pitch = pitch / bpp; + + /* bytes / 8 */ + offset = offset >> 3; + + *pitch_offset = ((pitch << 22) | /* USR1_DST_PITCH */ + (offset << 0) | /* USR1_DST_OFFSET */ + 0); +} + +static Bool +ATIGetPixmapOffsetPitch(PixmapPtr pPix, CARD32 *pitch_offset) +{ + ScrnInfoPtr pScreenInfo = xf86Screens[pPix->drawable.pScreen->myNum]; + ATIPtr pATI = ATIPTR(pScreenInfo); + CARD32 pitch, offset; + int bpp; + + bpp = pPix->drawable.bitsPerPixel; + + pitch = exaGetPixmapPitch(pPix); + offset = exaGetPixmapOffset(pPix); + + ATIGetOffsetPitch(bpp, pitch_offset, offset, pitch); + + return TRUE; +} + +static Bool +ATIMach64PrepareCopy(PixmapPtr pSrcPixmap, PixmapPtr pDstPixmap, int xdir, int ydir, + int alu, Pixel planemask) +{ + ScrnInfoPtr pScreenInfo = xf86Screens[pSrcPixmap->drawable.pScreen->myNum]; + ATIPtr pATI = ATIPTR(pScreenInfo); + CARD32 src_pitch_offset, dst_pitch_offset; + + ATIDRISync(pScreenInfo); + + ATIGetPixmapOffsetPitch(pSrcPixmap,&src_pitch_offset); + ATIGetPixmapOffsetPitch(pDstPixmap,&dst_pitch_offset); + ATIMach64WaitForFIFO(pATI, 5); + outf(DP_WRITE_MASK, planemask); + outf(SRC_OFF_PITCH,src_pitch_offset); + outf(DST_OFF_PITCH,dst_pitch_offset); + + outf(DP_SRC, DP_MONO_SRC_ALLONES | + SetBits(SRC_BLIT, DP_FRGD_SRC) | SetBits(SRC_BKGD, DP_BKGD_SRC)); + outf(DP_MIX, SetBits(ATIMach64ALU[alu], DP_FRGD_MIX)); + + outf(CLR_CMP_CNTL, CLR_CMP_FN_FALSE); + + pATI->dst_cntl = 0; + + if (ydir > 0) + pATI->dst_cntl |= DST_Y_DIR; + if (xdir > 0) + pATI->dst_cntl |= DST_X_DIR; + + if (pATI->XModifier == 1) + outf(DST_CNTL, pATI->dst_cntl); + else + pATI->dst_cntl |= DST_24_ROT_EN; + + return TRUE; +} + +static void +ATIMach64Copy (PixmapPtr pDstPixmap, int srcX, int srcY, int dstX, int dstY, int w, int h) +{ + ScrnInfoPtr pScreenInfo = xf86Screens[pDstPixmap->drawable.pScreen->myNum]; + ATIPtr pATI = ATIPTR(pScreenInfo); + + srcX *= pATI->XModifier; + dstY *= pATI->XModifier; + w *= pATI->XModifier; + + ATIDRISync(pScreenInfo); + + /* Disable clipping if it gets in the way */ + ATIMach64ValidateClip(pATI, dstX, dstX + w - 1, dstY, dstY + h - 1); + + if (!(pATI->dst_cntl & DST_X_DIR)) + { + srcX += w - 1; + dstX += w - 1; + } + + if (!(pATI->dst_cntl & DST_Y_DIR)) + { + srcY += h - 1; + dstY += h - 1; + } + + if (pATI->XModifier != 1) + outf(DST_CNTL, pATI->dst_cntl | SetBits((dstX / 4) % 6, DST_24_ROT)); + + ATIMach64WaitForFIFO(pATI, 4); + outf(SRC_Y_X, SetWord(srcX, 1) | SetWord(srcY, 0)); + outf(SRC_WIDTH1, w); + outf(DST_Y_X, SetWord(dstX, 1) | SetWord(dstY, 0)); + outf(DST_HEIGHT_WIDTH, SetWord(w, 1) | SetWord(h, 0)); +} + +static void +ATIMach64DoneCopy (PixmapPtr pDstPixmap) +{ +} + +static Bool +ATIMach64PrepareSolid +( + PixmapPtr pPixmap, + int alu, + Pixel planemask, + Pixel fg +) +{ + ScrnInfoPtr pScreenInfo = xf86Screens[pPixmap->drawable.pScreen->myNum]; + ATIPtr pATI = ATIPTR(pScreenInfo); + + CARD32 dst_pitch_offset; + + ATIDRISync(pScreenInfo); + + ATIGetPixmapOffsetPitch(pPixmap,&dst_pitch_offset); + ATIMach64WaitForFIFO(pATI, 6); + outf(DP_WRITE_MASK, planemask); + outf(DST_OFF_PITCH,dst_pitch_offset); + outf(DP_SRC, DP_MONO_SRC_ALLONES | + SetBits(SRC_FRGD, DP_FRGD_SRC) | SetBits(SRC_BKGD, DP_BKGD_SRC)); + outf(DP_FRGD_CLR, fg); + outf(DP_MIX, SetBits(ATIMach64ALU[alu], DP_FRGD_MIX)); + + outf(CLR_CMP_CNTL, CLR_CMP_FN_FALSE); + + if (pATI->XModifier == 1) + outf(DST_CNTL, DST_X_DIR | DST_Y_DIR); + return TRUE; +} + +static void +ATIMach64Solid +( + PixmapPtr pPixmap, + int x1, + int y1, + int x2, + int y2 +) +{ + int x = x1; + int y = y1; + int w = x2-x1; + int h = y2-y1; + ScrnInfoPtr pScreenInfo = xf86Screens[pPixmap->drawable.pScreen->myNum]; + ATIPtr pATI = ATIPTR(pScreenInfo); + + ATIDRISync(pScreenInfo); + + if (pATI->XModifier != 1) + { + x *= pATI->XModifier; + w *= pATI->XModifier; + + outf(DST_CNTL, SetBits((x / 4) % 6, DST_24_ROT) | + (DST_X_DIR | DST_Y_DIR | DST_24_ROT_EN)); + } + + /* Disable clipping if it gets in the way */ + ATIMach64ValidateClip(pATI, x, x + w - 1, y, y + h - 1); + + ATIMach64WaitForFIFO(pATI, 2); + outf(DST_Y_X, SetWord(x, 1) | SetWord(y, 0)); + outf(DST_HEIGHT_WIDTH, SetWord(w, 1) | SetWord(h, 0)); +} + +static void +ATIMach64DoneSolid(PixmapPtr pPixmap) +{ +} + +/* FIXME: profile for thresholds */ +#define ATI_DMA_MIN_UPLOAD 2048 +#define ATI_DMA_MIN_DOWNLOAD 256 + +/** + * Hostdata Blit, based on CPUToScreenColorExpand from XAA. + * + * FIXME: + * Radeon XAA states that plain memcpy is faster than hostdata blits for + * image uploads and explicitly disables their use for this purpose. + * It would be educative to profile this anyway ... + * + * A faster way for uploads may be to use the drm blit which uses DMA: + * allocate a set of DMA buffers, fill in the pixmap and fire the blit, + * see mach64UploadLocalSubImage from the mach64 DRI driver. + */ +static Bool +ATIMach64UploadToScreen(PixmapPtr pDst, int x, int y, int w, int h, + char *src, int src_pitch) +{ + ScrnInfoPtr pScrn = xf86Screens[pDst->drawable.pScreen->myNum]; + ATIPtr pATI = ATIPTR(pScrn); + + char *dst; + int dst_pitch = exaGetPixmapPitch(pDst); + int dst_offset= exaGetPixmapOffset(pDst); + CARD32 dst_pitch_offset; + + int bpp = pDst->drawable.bitsPerPixel; + int cpp = (bpp + 7) / 8; + int wBytes = w * cpp; + int i, j; + + int scanline_h; + int scanline_words; + unsigned int planemask; + int format; + int shift; + + switch (bpp) { + case 8: + shift = 3; + planemask = 0xff; + format = + SetBits(PIX_WIDTH_8BPP, DP_DST_PIX_WIDTH) | + SetBits(PIX_WIDTH_8BPP, DP_SRC_PIX_WIDTH) | + SetBits(PIX_WIDTH_8BPP, DP_HOST_PIX_WIDTH); + break; + case 16: + shift = 1; + planemask = 0xffff; + format = + SetBits(PIX_WIDTH_16BPP, DP_DST_PIX_WIDTH) | + SetBits(PIX_WIDTH_16BPP, DP_SRC_PIX_WIDTH) | + SetBits(PIX_WIDTH_16BPP, DP_HOST_PIX_WIDTH); + break; + case 32: + shift = 0; + planemask = 0xffffffff; + format = + SetBits(PIX_WIDTH_32BPP, DP_DST_PIX_WIDTH) | + SetBits(PIX_WIDTH_32BPP, DP_SRC_PIX_WIDTH) | + SetBits(PIX_WIDTH_32BPP, DP_HOST_PIX_WIDTH); + break; + default: + break; + } +#if X_BYTE_ORDER == X_LITTLE_ENDIAN + format |= DP_BYTE_PIX_ORDER; +#endif /* X_BYTE_ORDER */ + + /* FIXME: Do we need that sync here ? */ + exaWaitSync(pScrn->pScreen); + + /* Fallback: + * "small" pixmaps go faster with memcpy, + * "narrow" pixmaps (<= 64 byte) require special handling ??? FIXME + */ +#if 0 + if (h * wBytes < ATI_DMA_MIN_UPLOAD || wBytes <= 64) { + dst = pATI->pExa->card.memoryBase + dst_offset; + + while (h--) { + memcpy(dst, src, wBytes); + dst += dst_pitch; + src += src_pitch; + } + return TRUE; + } +#endif + + /* HostData Blit */ + ATIDRISync(pScrn); + + ATIGetOffsetPitch(bpp, &dst_pitch_offset, dst_offset, dst_pitch); + + ATIMach64WaitForFIFO(pATI, 6); + + if (pATI->XModifier == 1) + outf(DST_CNTL, DST_X_DIR | DST_Y_DIR); + + if (pATI->XModifier != 1) + { + x *= pATI->XModifier; + w *= pATI->XModifier; + + outf(DST_CNTL, SetBits((x / 4) % 6, DST_24_ROT) | + (DST_X_DIR | DST_Y_DIR | DST_24_ROT_EN)); + } + + /* XAA wants HOST_PIX_WIDTH to be 1bpp for color expansion, + * EXA wants HOST_PIX_WIDTH to be the FB bpp for hostdata blit + * + * FIXME: + * I added DP_PIX_WIDTH to MMIOCache invalidation in ATIMach64Sync + */ + outf(DP_PIX_WIDTH, format); + outf(DP_WRITE_MASK, planemask); + + outf(DP_SRC, + DP_MONO_SRC_ALLONES | + SetBits(SRC_HOST, DP_FRGD_SRC) | /* get src from host */ + SetBits(SRC_BKGD, DP_BKGD_SRC) ); + + outf(DP_MIX, + SetBits(MIX_SRC, DP_FRGD_MIX) | /* copy src */ + SetBits(MIX_DST, DP_BKGD_MIX) ); + + outf(CLR_CMP_CNTL, CLR_CMP_FN_FALSE); + + /* Have to pad the width here and use clipping engine */ + pATI->sc_left = x; + pATI->sc_right = x + w - 1; + pATI->sc_top = y; + pATI->sc_bottom = y + h - 1; + + ATIMach64WaitForFIFO(pATI, 5); + outf(SC_LEFT_RIGHT, + SetWord(pATI->sc_right, 1) | + SetWord(pATI->sc_left, 0) ); + outf(SC_TOP_BOTTOM, + SetWord(pATI->sc_bottom, 1) | + SetWord(pATI->sc_top, 0) ); + + scanline_h = h; + scanline_words = (w * bpp + 31) >> 5;; + + w = (w + shift) & ~shift; + + outf(DST_OFF_PITCH, dst_pitch_offset); + outf(DST_Y_X, SetWord(x, 1) | SetWord(y, 0)); + outf(DST_HEIGHT_WIDTH, SetWord(w, 1) | SetWord(h, 0)); + + for (i = 0; i < scanline_h; i++) { + CARD32 *scanline = (CARD32 *)(src + i * src_pitch); + int j = scanline_words; + + ATIDRISync(pScrn); + + /* FIXME: + * check if feeding the data in packs of 32 bytes improves + * performance, see RADEONSubsequentScanline. + */ + while (j > 0) { + /* + * Transfers are done in chunks of up to 64 bytes in length, + * 16 HOST_DATA x 4 bytes per HOST_DATA_XX. + */ + int nDWord = j; + if (nDWord > pATI->nHostFIFOEntries) + nDWord = pATI->nHostFIFOEntries; + + /* Make enough FIFO slots available */ + ATIMach64WaitForFIFO(pATI, nDWord); + +# undef ATIMove32 +# if defined(ATIMove32) + if (nDWord == 16) + { + /* FIXME: ATIMove32 not working */ + ATIMove32(pATI->pHOST_DATA, scanline, nDWord); + } + else +# else + { + volatile CARD32 *pDst; + CARD32 *pSrc; + unsigned int iDWord; + + iDWord = 16 - nDWord; + pDst = (volatile CARD32 *)pATI->pHOST_DATA - iDWord; + pSrc = scanline - iDWord; + + switch (iDWord) + { + case 0: MMIO_MOVE32(pDst + 0, 0, *(pSrc + 0)); + case 1: MMIO_MOVE32(pDst + 1, 0, *(pSrc + 1)); + case 2: MMIO_MOVE32(pDst + 2, 0, *(pSrc + 2)); + case 3: MMIO_MOVE32(pDst + 3, 0, *(pSrc + 3)); + case 4: MMIO_MOVE32(pDst + 4, 0, *(pSrc + 4)); + case 5: MMIO_MOVE32(pDst + 5, 0, *(pSrc + 5)); + case 6: MMIO_MOVE32(pDst + 6, 0, *(pSrc + 6)); + case 7: MMIO_MOVE32(pDst + 7, 0, *(pSrc + 7)); + case 8: MMIO_MOVE32(pDst + 8, 0, *(pSrc + 8)); + case 9: MMIO_MOVE32(pDst + 9, 0, *(pSrc + 9)); + case 10: MMIO_MOVE32(pDst + 10, 0, *(pSrc + 10)); + case 11: MMIO_MOVE32(pDst + 11, 0, *(pSrc + 11)); + case 12: MMIO_MOVE32(pDst + 12, 0, *(pSrc + 12)); + case 13: MMIO_MOVE32(pDst + 13, 0, *(pSrc + 13)); + case 14: MMIO_MOVE32(pDst + 14, 0, *(pSrc + 14)); + case 15: MMIO_MOVE32(pDst + 15, 0, *(pSrc + 15)); + + default: /* Muffle compiler */ + break; + } + } +# endif + + /* Step to next chunk */ + scanline += nDWord; + j -= nDWord; + pATI->nAvailableFIFOEntries -= nDWord; + } + + pATI->EngineIsBusy = TRUE; + } + + return TRUE; +} + +static Bool +ATIMach64DownloadFromScreen(PixmapPtr pSrc, int x, int y, int w, int h, + char *dst, int dst_pitch) +{ + ScrnInfoPtr pScrn = xf86Screens[pSrc->drawable.pScreen->myNum]; + ATIPtr pATI = ATIPTR(pScrn); + + char *src; + int src_pitch = exaGetPixmapPitch(pSrc); + int src_offset = exaGetPixmapOffset(pSrc); + int bpp = pSrc->drawable.bitsPerPixel; + + return FALSE; +} + +static Bool ATIMach64CheckComposite ( + int op, + PicturePtr pSrcPicture, + PicturePtr pMaskPicture, + PicturePtr pDstPicture) +{ + return FALSE; +} + +static Bool +ATIMach64PrepareComposite ( + int op, + PicturePtr pSrcPicture, + PicturePtr pMaskPicture, + PicturePtr pDstPicture, + PixmapPtr pSrc, + PixmapPtr pMask, + PixmapPtr pDst) +{ + ScrnInfoPtr pScrn = xf86Screens[pSrc->drawable.pScreen->myNum]; + ATIPtr pATI = ATIPTR(pScrn); + + int src_pitch = exaGetPixmapPitch(pSrc); + int dst_pitch = exaGetPixmapPitch(pDst); + + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Comp: pSrc: %p (%4d), pDst: %p (%4d), pMask: %p, op: %d\n", + pSrc, src_pitch, pDst, dst_pitch, pMaskPicture, op); + + return FALSE; +} + +/* Compute log base 2 of val. */ +static __inline__ int +ATILog2(int val) +{ + int bits; + + for (bits = 0; val != 0; val >>= 1, ++bits) + ; + return bits - 1; +} + +/* + * Memory layour for EXA with DRI: + * | front | back | depth | textures | pixmaps, xv | c | + * + * 1024x768@16bpp with 8 MB: + * | 1.5 MB | 1.5 MB | 1.5 MB | 0 | ~3.5 MB | c | + * + * 1024x768@32bpp with 8 MB: + * | 3.0 MB | 3.0 MB | 1.5 MB | 0 | ~0.5 MB | c | + * + * "c" is the hw cursor which occupies 1KB + */ +static void +ATIMach64SetupMemEXA (ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ATIPtr pATI = ATIPTR(pScrn); + + int cpp = (pScrn->bitsPerPixel + 7) / 8; + /* front and back buffer */ + int bufferSize = pScrn->virtualY * pScrn->displayWidth * cpp; + /* always 16-bit z-buffer */ + int depthSize = pScrn->virtualY * pScrn->displayWidth * 2; + + ExaDriverPtr pExa = pATI->pExa; + + pExa->card.memoryBase = pATI->pMemory; + pExa->card.memorySize = pScrn->videoRam * 1024; + pExa->card.offScreenBase = bufferSize; + +#ifdef XF86DRI_DEVEL + if (pATI->directRenderingEnabled) { + ATIDRIServerInfoPtr pATIDRIServer = pATI->pDRIServerInfo; + Bool is_pci = pATIDRIServer->IsPCI; + + int textureSize = 0; + int pixmapCache = 0; + int next = 0; + int err = 0x0; + + /* front buffer */ + pATIDRIServer->frontOffset = 0; + pATIDRIServer->frontPitch = pScrn->displayWidth; + next += bufferSize; + + /* back buffer */ + pATIDRIServer->backOffset = next; + pATIDRIServer->backPitch = pScrn->displayWidth; + next += bufferSize; + + /* depth buffer */ + pATIDRIServer->depthOffset = next; + pATIDRIServer->depthPitch = pScrn->displayWidth; + next += depthSize; + + /* ATIScreenInit does check for the this condition. */ + if (next > pExa->card.memorySize) { + xf86DrvMsg(pScreen->myNum, X_WARNING, + "DRI static buffer allocation failed, disabling DRI --" + "need at least %d kB video memory\n", next / 1024 ); + ATIDRICloseScreen(pScreen); + pATI->directRenderingEnabled = FALSE; + + err |= 0x1; + } + + /* local textures */ + + /* Reserve approx. half of offscreen memory for local textures */ + textureSize = (pExa->card.memorySize - next) / 2; + + /* In case DRI requires more offscreen memory than available, + * should not happen as ATIScreenInit would have not enabled DRI */ + if (textureSize < 0) + textureSize = 0; + + /* Try for enough pixmap cache for a full viewport */ + pixmapCache = (pExa->card.memorySize - next) - textureSize; + if (pixmapCache < bufferSize) + textureSize = 0; + + /* Don't allocate a local texture heap for AGP unless requested */ + if ( !is_pci && !pATI->OptionLocalTextures ) + textureSize = 0; + + if (textureSize > 0) { + int l = ATILog2(textureSize / MACH64_NR_TEX_REGIONS); + if (l < MACH64_LOG_TEX_GRANULARITY) + l = MACH64_LOG_TEX_GRANULARITY; + pATIDRIServer->logTextureGranularity = l; + + /* Round the texture size up to the nearest whole number of + * texture regions. Again, be greedy about this, round up. + */ + textureSize = (textureSize >> l) << l; + } + + /* Set a minimum usable local texture heap size. This will fit + * two 256x256 textures. We check this after any rounding of + * the texture area. + */ + if (textureSize < 256*256 * cpp * 2) + textureSize = 0; + + /* Disable DRI for PCI if cannot allocate a local texture heap */ + if ( is_pci && textureSize == 0 ) { + xf86DrvMsg(pScreen->myNum, X_WARNING, + "Not enough memory for local textures, disabling DRI\n"); + ATIDRICloseScreen(pScreen); + pATI->directRenderingEnabled = FALSE; + + err |= 0x2; + } + + if (!err) { + pATIDRIServer->textureOffset = next; + pATIDRIServer->textureSize = textureSize; + next += textureSize; + + pExa->card.offScreenBase = next; + } + } +#endif /* XF86DRI_DEVEL */ + + xf86DrvMsg(pScreen->myNum, X_INFO, + "EXA memory management initialized\n" + " base : 0x%08x (0x%8x)\n" + " offscreen: +%8x\n" + " size : +%8x\n" + " cursor : 0x%08x (0x%8x)\n", + pExa->card.memoryBase, pATI->LinearBase, + pExa->card.offScreenBase, + pExa->card.memorySize, + pATI->pCursorImage, pATI->CursorBase); + + if (TRUE || xf86GetVerbosity() > 1) { + int offscreen = pExa->card.memorySize - pExa->card.offScreenBase; + int viewport = bufferSize; + int dvdframe = 720*480*cpp; /* enough for single-buffered DVD */ + + xf86DrvMsg(pScreen->myNum, X_INFO, + "Will use %d kB of offscreen memory for EXA\n" + " or %5.2f viewports (composite)\n" + " or %5.2f dvdframes (xvideo)\n", + offscreen / 1024, + 1.0 * offscreen / viewport, + 1.0 * offscreen / dvdframe); + } + +#ifdef XF86DRI_DEVEL + if (pATI->directRenderingEnabled) { + ATIDRIServerInfoPtr pATIDRIServer = pATI->pDRIServerInfo; + + xf86DrvMsg(pScreen->myNum, X_INFO, + "Will use back buffer at offset 0x%x\n", + pATIDRIServer->backOffset); + + xf86DrvMsg(pScreen->myNum, X_INFO, + "Will use depth buffer at offset 0x%x\n", + pATIDRIServer->depthOffset); + + if (pATIDRIServer->textureSize > 0) { + xf86DrvMsg(pScreen->myNum, X_INFO, + "Will use %d kB for local textures at offset 0x%x\n", + pATIDRIServer->textureSize/1024, + pATIDRIServer->textureOffset); + } + } +#endif /* XF86DRI_DEVEL */ + + /* FIXME: set to 64 if that helps for hostdata blits */ + /* FIXME: must be multiple of 8 pixels; 32 is ok for 16bpp, 32bpp */ + pExa->card.pixmapOffsetAlign = 64; + pExa->card.pixmapPitchAlign = 64; + + pExa->card.maxX = ATIMach64MaxX; + pExa->card.maxY = ATIMach64MaxY; + + pExa->card.flags = EXA_OFFSCREEN_PIXMAPS; + +#if 0 + /* Rage 128 compositing wants power-of-two pitches. */ + pExa->card.flags |= EXA_OFFSCREEN_ALIGN_POT; +#endif +} + +Bool ATIMach64ExaInit (ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + ATIPtr pATI = ATIPTR(pScrn); + ExaDriverPtr pExa; + + pExa = xnfcalloc(sizeof(ExaDriverRec), 1); + if (!pExa) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Failed to allocate EXADriverRec.\n"); + return FALSE; + } + pATI->pExa = pExa; + + ATIMach64SetupMemEXA(pScreen); + + pExa->accel.WaitMarker=ATIMach64WaitMarker; + + pExa->accel.PrepareSolid=ATIMach64PrepareSolid; + pExa->accel.Solid=ATIMach64Solid; + pExa->accel.DoneSolid=ATIMach64DoneSolid; + + pExa->accel.PrepareCopy=ATIMach64PrepareCopy; + pExa->accel.Copy=ATIMach64Copy; + pExa->accel.DoneCopy=ATIMach64DoneCopy; + +#if 0 + pExa->accel.UploadToScreen=ATIMach64UploadToScreen; + pExa->accel.DownloadFromScreen=ATIMach64DownloadFromScreen; +#endif + +#if 0 + pExa->accel.CheckComposite=ATIMach64CheckComposite; + pExa->accel.PrepareComposite=ATIMach64PrepareComposite; +#endif + + return exaDriverInit(pScreen, pATI->pExa); +} +#endif diff -Nau -x '*.swp' -x CVS -x 'Makefile*' -x '*o' -x '*a' xf86-video-ati/src/atimach64iodri.h xf86-video-ati-exa/src/atimach64iodri.h --- xf86-video-ati/src/atimach64iodri.h 1970-01-01 02:00:00.000000000 +0200 +++ xf86-video-ati-exa/src/atimach64iodri.h 2006-02-23 18:38:05.000000000 +0200 @@ -0,0 +1,139 @@ +/* + * Copyright 2000 through 2004 by Marc Aurele La France (TSI @ UQV), tsi@xfree86.org + * + * 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 Marc Aurele La France not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. Marc Aurele La France makes no representations + * about the suitability of this software for any purpose. It is provided + * "as-is" without express or implied warranty. + * + * MARC AURELE LA FRANCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO + * EVENT SHALL MARC AURELE LA FRANCE 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. + * + * DRI support by: + * Manuel Teira + * Leif Delgass + */ + +#ifndef ___ATIMACH64IODRI_H___ +#define ___ATIMACH64IODRI_H___ 1 + +#ifdef XF86DRI_DEVEL + +#define ATIDRIWaitForIdle(_pATI) \ +do { \ + ATIDRIServerInfoPtr pATIDRIServer = _pATI->pDRIServerInfo; \ + int ret; \ + \ + if (pATIDRIServer && pATI->directRenderingEnabled) { \ + /* Wait for DMA to complete */ \ + ret = drmCommandNone(_pATI->drmFD, DRM_MACH64_IDLE); \ + if (ret) { \ + drmCommandNone(_pATI->drmFD, DRM_MACH64_RESET); \ + } \ + \ + /* Force updating of FIFO entry counters */ \ + pATI->EngineIsBusy = TRUE; \ + ATIMach64PollEngineStatus(_pATI); \ + } else { \ + ATIMach64WaitForIdle(_pATI); \ + } \ +} while (0) + +/* + * Set upon DRISwapContext and when DRI accesses the engine + * from within the server, see DRIInitBuffers/DRIMoveBuffers in atidri.c. + */ +static __inline__ void ATIDRIMarkSyncInt(ScrnInfoPtr _pScrInfo) +{ + ATIPtr _pATI=ATIPTR(_pScrInfo); +#ifdef USE_EXA + if (_pATI->useEXA) + exaMarkSync(_pScrInfo->pScreen); +#endif +#ifdef USE_XAA + if (!_pATI->useEXA) + SET_SYNC_FLAG(_pATI->pXAAInfo); /* NeedToSync = TRUE */ +#endif +} + +/* + * Set upon DRISwapContext and when the server acquires the DRI lock + */ +static __inline__ void ATIDRIMarkSyncExt(ScrnInfoPtr _pScrInfo) +{ + ATIPtr _pATI=ATIPTR(_pScrInfo); + _pATI->NeedDRISync = TRUE; +} + +static __inline__ void ATIDRISync(ScrnInfoPtr _pScrInfo) +{ + ATIPtr _pATI=ATIPTR(_pScrInfo); +#ifdef USE_EXA + if (_pATI->directRenderingEnabled && _pATI->pExa) + { + exaWaitSync(_pScrInfo->pScreen); + } +#endif +#ifdef USE_XAA + if (_pATI->directRenderingEnabled && _pATI->pXAAInfo) + { + if (_pATI->NeedDRISync) (*_pATI->pXAAInfo->Sync)(_pScrInfo); + } +#endif +} + +static __inline__ void ATIDRIUnmarkSync(ScrnInfoPtr _pScrInfo) +{ + ATIPtr _pATI=ATIPTR(_pScrInfo); +#ifdef USE_XAA + if (!_pATI->useEXA) { + if (_pATI->directRenderingEnabled) + _pATI->NeedDRISync = FALSE; + if (_pATI->pXAAInfo) + _pATI->pXAAInfo->NeedToSync = FALSE; + } +#endif +} + +#define ATIDRILock(_pScrInfo) \ +do \ +{ \ + ATIPtr _pATI=ATIPTR(_pScrInfo); \ + if (_pATI->directRenderingEnabled) \ + { \ + DRILock(_pScrInfo->pScreen, 0); \ + ATIDRIMarkSyncExt(_pScrInfo); \ + } \ +} while (0) + +#define ATIDRIUnlock(_pScrInfo) \ +do \ +{ \ + ATIPtr _pATI=ATIPTR(_pScrInfo); \ + if (_pATI->directRenderingEnabled) \ + { \ + DRIUnlock(_pScrInfo->pScreen); \ + } \ +} while (0) + +#else /* XF86DRI_DEVEL */ + + +#define ATIDRIWaitForIdle(_pATI) +#define ATIDRILock(_pScrInfo) +#define ATIDRIUnlock(_pScrInfo) +#define ATIDRISync(_pScrInfo) + +#endif /* XF86DRI_DEVEL */ + +#endif /* ___ATIMACH64IODRI_H___ */ diff -Nau -x '*.swp' -x CVS -x 'Makefile*' -x '*o' -x '*a' xf86-video-ati/src/atimach64io.h xf86-video-ati-exa/src/atimach64io.h --- xf86-video-ati/src/atimach64io.h 2004-09-21 21:10:34.000000000 +0300 +++ xf86-video-ati-exa/src/atimach64io.h 2006-03-04 02:36:00.000000000 +0200 @@ -204,70 +204,6 @@ while ((_pATI)->EngineIsBusy) \ ATIMach64PollEngineStatus(_pATI) -#ifdef XF86DRI_DEVEL - -#define ATIDRIWaitForIdle(_pATI) \ -do { \ - ATIDRIServerInfoPtr pATIDRIServer = _pATI->pDRIServerInfo; \ - int ret; \ - \ - if (pATIDRIServer && pATI->directRenderingEnabled) { \ - /* Wait for DMA to complete */ \ - ret = drmCommandNone(_pATI->drmFD, DRM_MACH64_IDLE); \ - if (ret) { \ - drmCommandNone(_pATI->drmFD, DRM_MACH64_RESET); \ - } \ - \ - /* Force updating of FIFO entry counters */ \ - pATI->EngineIsBusy = TRUE; \ - ATIMach64PollEngineStatus(_pATI); \ - } else { \ - ATIMach64WaitForIdle(_pATI); \ - } \ -} while (0) - -#define ATIDRILock(_pScrInfo) \ -do \ -{ \ - ATIPtr _pATI=ATIPTR(_pScrInfo); \ - if (_pATI->directRenderingEnabled) \ - { \ - DRILock(_pScrInfo->pScreen, 0); \ - pATI->NeedDRISync = TRUE; \ - } \ -} while (0) - -#define ATIDRIUnlock(_pScrInfo) \ -do \ -{ \ - ATIPtr _pATI=ATIPTR(_pScrInfo); \ - if (_pATI->directRenderingEnabled) \ - { \ - DRIUnlock(_pScrInfo->pScreen); \ - } \ -} while (0) - -#define ATIDRISync(_pScrInfo) \ -do \ -{ \ - ATIPtr _pATI=ATIPTR(_pScrInfo); \ - if (_pATI->directRenderingEnabled && _pATI->pXAAInfo) \ - { \ - if (_pATI->NeedDRISync) (*_pATI->pXAAInfo->Sync)(_pScrInfo); \ - } \ -} while (0) - -#else /* XF86DRI_DEVEL */ - - -#define ATIDRIWaitForIdle(_pATI) -#define ATIDRILock(_pScrInfo) -#define ATIDRIUnlock(_pScrInfo) -#define ATIDRISync(_pScrInfo) - -#endif /* XF86DRI_DEVEL */ - - /* * An outf() variant to write two registers such that the second register is * is always written whenever either is to be changed. @@ -345,6 +281,11 @@ * Block transfer definitions. */ +/* for HOST_DATA_X only, used in hostdata blits */ +#define inh(_Register) \ + ((CARD8 *)pATI->pBlock[GetBits(_Register, BLOCK_SELECT)] + \ + ((_Register) & MM_IO_SELECT)) + #if defined(GCCUSESGAS) && \ (defined(i386) || defined(__i386) || defined(__i386__)) diff -Nau -x '*.swp' -x CVS -x 'Makefile*' -x '*o' -x '*a' xf86-video-ati/src/atimach64xv.c xf86-video-ati-exa/src/atimach64xv.c --- xf86-video-ati/src/atimach64xv.c 2005-07-11 05:29:44.000000000 +0300 +++ xf86-video-ati-exa/src/atimach64xv.c 2006-03-06 22:19:37.000000000 +0200 @@ -499,6 +499,25 @@ return Success; } +static pointer +ATIMach64XVMemAlloc +( + ScreenPtr pScreen, + pointer pVideo, + int size, + int *offset, + ATIPtr pATI +); + +static void +ATIMach64XVMemFree +( + ScreenPtr pScreen, + pointer pVideo, + ATIPtr pATI +); + +#ifdef USE_XAA /* * ATIMach64RemoveLinearCallback -- * @@ -517,6 +536,7 @@ pATI->pXVBuffer = NULL; outf(OVERLAY_SCALE_CNTL, SCALE_EN); } +#endif /* USE_XAA */ /* * ATIMach64StopVideo -- @@ -541,19 +561,23 @@ REGION_EMPTY(pScreen, &pATI->VideoClip); - if (!Cleanup) +#ifdef USE_XAA + if (!pATI->useEXA && !Cleanup) { /* * Free offscreen buffer if/when its allocation is needed by XAA's * pixmap cache. */ - if (pATI->pXVBuffer) - pATI->pXVBuffer->RemoveLinearCallback = + FBLinearPtr linear = (FBLinearPtr)pATI->pXVBuffer; + if (linear) + linear->RemoveLinearCallback = ATIMach64RemoveLinearCallback; return; } +#endif /* USE_XAA */ - pATI->pXVBuffer = ATIResizeOffscreenLinear(pScreen, pATI->pXVBuffer, 0); + ATIMach64XVMemFree(pScreen, pATI->pXVBuffer, pATI); + pATI->pXVBuffer = NULL; outf(OVERLAY_SCALE_CNTL, SCALE_EN); } @@ -953,6 +977,7 @@ int SrcTop, SrcLeft, DstWidth, DstHeight; int Top, Bottom, Left, Right, nLine, nPixel, Offset; int OffsetV, OffsetU; + int XVOffset; int tmp; CARD8 *pDst; @@ -978,11 +1003,11 @@ */ DstPitch = /* bytes */ (DstWidth + DstWidth + 15) & ~15; - DstSize = /* pixels */ - ((DstPitch * DstHeight) + pATI->AdjustDepth - 1) / pATI->AdjustDepth; + DstSize = /* bytes */ + (DstPitch * DstHeight); - pATI->pXVBuffer = ATIResizeOffscreenLinear(pScreen, pATI->pXVBuffer, - (pATI->DoubleBuffer + 1) * DstSize); + pATI->pXVBuffer = ATIMach64XVMemAlloc(pScreen, pATI->pXVBuffer, + (pATI->DoubleBuffer + 1) * DstSize, &XVOffset, pATI); if (!pATI->pXVBuffer) { @@ -990,7 +1015,7 @@ return BadAlloc; pATI->pXVBuffer = - ATIResizeOffscreenLinear(pScreen, pATI->pXVBuffer, DstSize); + ATIMach64XVMemAlloc(pScreen, pATI->pXVBuffer, DstSize, &XVOffset, pATI); if (!pATI->pXVBuffer) return BadAlloc; @@ -1009,8 +1034,7 @@ /* Synchronise video memory accesses */ ATIMach64Sync(pScreenInfo); - Offset = (pATI->pXVBuffer->offset * pATI->AdjustDepth) + - (pATI->CurrentBuffer * DstSize * pATI->AdjustDepth); + Offset = XVOffset + pATI->CurrentBuffer * DstSize; pDst = pATI->pMemoryLE; pDst += Offset; @@ -1110,6 +1134,7 @@ { ScreenPtr pScreen; ATIPtr pATI = ATIPTR(pScreenInfo); + int XVOffset; if (pATI->ActiveSurface) return BadAlloc; @@ -1123,13 +1148,12 @@ pScreen = pScreenInfo->pScreen; - pATI->pXVBuffer = ATIResizeOffscreenLinear(pScreen, pATI->pXVBuffer, - ((Height * pATI->SurfacePitch) + pATI->AdjustDepth - 1) / - pATI->AdjustDepth); + pATI->pXVBuffer = ATIMach64XVMemAlloc(pScreen, pATI->pXVBuffer, + Height * pATI->SurfacePitch, &XVOffset, pATI); if (!pATI->pXVBuffer) return BadAlloc; - pATI->SurfaceOffset = pATI->pXVBuffer->offset * pATI->AdjustDepth; + pATI->SurfaceOffset = XVOffset; pSurface->pScrn = pScreenInfo; pSurface->id = ImageID; @@ -1164,8 +1188,8 @@ return Success; outf(OVERLAY_SCALE_CNTL, SCALE_EN); - pATI->pXVBuffer = ATIResizeOffscreenLinear(pSurface->pScrn->pScreen, - pATI->pXVBuffer, 0); + ATIMach64XVMemFree(pSurface->pScrn->pScreen, pATI->pXVBuffer, pATI); + pATI->pXVBuffer = NULL; pATI->ActiveSurface = FALSE; return Success; @@ -1495,3 +1519,84 @@ REGION_UNINIT(pScreen, &pATI->VideoClip); } + +static pointer +ATIMach64XVMemAlloc +( + ScreenPtr pScreen, + pointer pVideo, + int size, + int *offset, + ATIPtr pATI +) +{ +#ifdef USE_EXA + if (pATI->useEXA) { + ExaOffscreenArea *area = (ExaOffscreenArea *)pVideo; + + if (area != NULL) { + if (area->size >= size) { + *offset = area->offset; + return area; + } + + exaOffscreenFree(pScreen, area); + } + + area = exaOffscreenAlloc(pScreen, size, 64, TRUE, NULL, NULL); + if (area != NULL) { + *offset = area->offset; + return area; + } + } +#endif /* USE_EXA */ + +#ifdef USE_XAA + if (!pATI->useEXA) { + FBLinearPtr linear = (FBLinearPtr)pVideo; + int cpp = pATI->AdjustDepth; + + /* XAA allocates in units of pixels at the screen bpp, so adjust size + * appropriately. + */ + size = (size + cpp - 1) / cpp; + + linear = ATIResizeOffscreenLinear(pScreen, linear, size); + if (linear != NULL) { + *offset = linear->offset * cpp; + return linear; + } + } +#endif /* USE_XAA */ + + *offset = 0; + return NULL; +} + +static void +ATIMach64XVMemFree +( + ScreenPtr pScreen, + pointer pVideo, + ATIPtr pATI +) +{ +#ifdef USE_EXA + if (pATI->useEXA) { + ExaOffscreenArea *area = (ExaOffscreenArea *)pVideo; + + if (area != NULL) + exaOffscreenFree(pScreen, area); + } +#endif /* USE_EXA */ + +#ifdef USE_XAA + if (!pATI->useEXA) { + FBLinearPtr linear = (FBLinearPtr)pVideo; + + if (linear != NULL) + ATIResizeOffscreenLinear(pScreen, linear, 0); + } +#endif /* USE_XAA */ +} + diff -Nau -x '*.swp' -x CVS -x 'Makefile*' -x '*o' -x '*a' xf86-video-ati/src/atimisc.c xf86-video-ati-exa/src/atimisc.c --- xf86-video-ati/src/atimisc.c 2005-07-11 05:29:44.000000000 +0300 +++ xf86-video-ati-exa/src/atimisc.c 2006-02-20 21:42:24.000000000 +0200 @@ -127,7 +127,19 @@ ATIfbSymbols, ATIshadowfbSymbols, + +#ifdef USE_EXA + + ATIexaSymbols, + +#endif /* USE_EXA */ + +#ifdef USE_XAA + ATIxaaSymbols, + +#endif /* USE_XAA */ + ATIramdacSymbols, ATIi2cSymbols, NULL); diff -Nau -x '*.swp' -x CVS -x 'Makefile*' -x '*o' -x '*a' xf86-video-ati/src/atioption.c xf86-video-ati-exa/src/atioption.c --- xf86-video-ati/src/atioption.c 2006-02-05 16:26:44.000000000 +0200 +++ xf86-video-ati-exa/src/atioption.c 2006-02-20 21:42:25.000000000 +0200 @@ -219,6 +219,13 @@ FALSE, }, { + ATI_OPTION_ACCELMETHOD, + "AccelMethod", + OPTV_STRING, + {0}, + FALSE + }, + { -1, NULL, OPTV_NONE, diff -Nau -x '*.swp' -x CVS -x 'Makefile*' -x '*o' -x '*a' xf86-video-ati/src/atioption.h xf86-video-ati-exa/src/atioption.h --- xf86-video-ati/src/atioption.h 2006-02-05 16:26:44.000000000 +0200 +++ xf86-video-ati-exa/src/atioption.h 2006-02-20 21:42:25.000000000 +0200 @@ -69,7 +69,8 @@ ATI_OPTION_PROBE_CLOCKS, ATI_OPTION_REFERENCE_CLOCK, ATI_OPTION_SHADOW_FB, - ATI_OPTION_SWCURSOR + ATI_OPTION_SWCURSOR, + ATI_OPTION_ACCELMETHOD } ATIPublicOptionType; #ifdef TV_OUT diff -Nau -x '*.swp' -x CVS -x 'Makefile*' -x '*o' -x '*a' xf86-video-ati/src/atiscreen.c xf86-video-ati-exa/src/atiscreen.c --- xf86-video-ati/src/atiscreen.c 2006-02-23 15:42:09.000000000 +0200 +++ xf86-video-ati-exa/src/atiscreen.c 2006-03-06 14:56:30.000000000 +0200 @@ -123,6 +123,200 @@ for (bits = 0; val; val >>= 1, ++bits); return bits; } + +#ifdef USE_XAA +#ifdef XF86DRI_DEVEL +/* + * Memory layour for XAA with DRI: + * | front | pixmaps, xv | back | depth | textures | c | + * + * 1024x768@16bpp with 8 MB: + * | 1.5 MB | ~3.5 MB | 1.5 MB | 1.5 MB | 0 | c | + * + * 1024x768@32bpp with 8 MB: + * | 3.0 MB | ~0.5 MB | 3.0 MB | 1.5 MB | 0 | c | + * + * "c" is the hw cursor which occupies 1KB + */ +static Bool +ATIMach64SetupMemXAA( + int iScreen, + ScreenPtr pScreen +) +{ + ScrnInfoPtr pScreenInfo = xf86Screens[iScreen]; + ATIPtr pATI = ATIPTR(pScreenInfo); + + ATIDRIServerInfoPtr pATIDRIServer = pATI->pDRIServerInfo; + int cpp = pATI->bitsPerPixel >> 3; + int widthBytes = pScreenInfo->displayWidth * cpp; + int zWidthBytes = pScreenInfo->displayWidth * 2; /* always 16-bit z-buffer */ + int fbSize = pScreenInfo->videoRam * 1024; + int bufferSize = pScreenInfo->virtualY * widthBytes; + int zBufferSize = pScreenInfo->virtualY * zWidthBytes; + int offscreenBytes, total, scanlines; + + pATIDRIServer->fbX = 0; + pATIDRIServer->fbY = 0; + pATIDRIServer->frontOffset = 0; + pATIDRIServer->frontPitch = pScreenInfo->displayWidth; + + /* Calculate memory remaining for pixcache and textures after + * front, back, and depth buffers + */ + offscreenBytes = fbSize - ( 2 * bufferSize + zBufferSize ); + + if ( !pATIDRIServer->IsPCI && !pATI->OptionLocalTextures ) { + /* Don't allocate a local texture heap for AGP unless requested */ + pATIDRIServer->textureSize = 0; + } else { + int l, maxPixcache; + +#ifdef XvExtension + + int xvBytes; + + /* Try for enough pixmap cache for DVD and a full viewport + */ + xvBytes = 720*480*cpp; /* enough for single-buffered DVD */ + maxPixcache = xvBytes > bufferSize ? xvBytes : bufferSize; + +#else /* XvExtension */ + + /* Try for one viewport */ + maxPixcache = bufferSize; + +#endif /* XvExtension */ + + pATIDRIServer->textureSize = offscreenBytes - maxPixcache; + + /* If that gives us less than half the offscreen mem available for textures, split + * the available mem between textures and pixmap cache + */ + if (pATIDRIServer->textureSize < (offscreenBytes/2)) { + pATIDRIServer->textureSize = offscreenBytes/2; + } + + if (pATIDRIServer->textureSize <= 0) + pATIDRIServer->textureSize = 0; + + l = ATIMinBits((pATIDRIServer->textureSize-1) / MACH64_NR_TEX_REGIONS); + if (l < MACH64_LOG_TEX_GRANULARITY) l = MACH64_LOG_TEX_GRANULARITY; + + /* Round the texture size up to the nearest whole number of + * texture regions. Again, be greedy about this, don't round + * down. + */ + pATIDRIServer->logTextureGranularity = l; + pATIDRIServer->textureSize = + (pATIDRIServer->textureSize >> l) << l; + } + + total = fbSize - pATIDRIServer->textureSize; + scanlines = total / widthBytes; + if (scanlines > ATIMach64MaxY) scanlines = ATIMach64MaxY; + + /* Recalculate the texture offset and size to accomodate any + * rounding to a whole number of scanlines. + * FIXME: Is this actually needed? + */ + pATIDRIServer->textureOffset = scanlines * widthBytes; + pATIDRIServer->textureSize = fbSize - pATIDRIServer->textureOffset; + + /* Set a minimum usable local texture heap size. This will fit + * two 256x256 textures. We check this after any rounding of + * the texture area. + */ + if (pATIDRIServer->textureSize < 256*256 * cpp * 2) { + pATIDRIServer->textureOffset = 0; + pATIDRIServer->textureSize = 0; + scanlines = fbSize / widthBytes; + if (scanlines > ATIMach64MaxY) scanlines = ATIMach64MaxY; + } + + pATIDRIServer->depthOffset = scanlines * widthBytes - zBufferSize; + pATIDRIServer->depthPitch = pScreenInfo->displayWidth; + pATIDRIServer->depthY = pATIDRIServer->depthOffset/widthBytes; + pATIDRIServer->depthX = (pATIDRIServer->depthOffset - + (pATIDRIServer->depthY * widthBytes)) / cpp; + + pATIDRIServer->backOffset = pATIDRIServer->depthOffset - bufferSize; + pATIDRIServer->backPitch = pScreenInfo->displayWidth; + pATIDRIServer->backY = pATIDRIServer->backOffset/widthBytes; + pATIDRIServer->backX = (pATIDRIServer->backOffset - + (pATIDRIServer->backY * widthBytes)) / cpp; + + scanlines = fbSize / widthBytes; + if (scanlines > ATIMach64MaxY) scanlines = ATIMach64MaxY; + + if ( pATIDRIServer->IsPCI && pATIDRIServer->textureSize == 0 ) { + xf86DrvMsg(iScreen, X_WARNING, + "Not enough memory for local textures, disabling DRI\n"); + ATIDRICloseScreen(pScreen); + pATI->directRenderingEnabled = FALSE; + } else { + BoxRec ScreenArea; + + ScreenArea.x1 = 0; + ScreenArea.y1 = 0; + ScreenArea.x2 = pATI->displayWidth; + ScreenArea.y2 = scanlines; + + if (!xf86InitFBManager(pScreen, &ScreenArea)) { + xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR, + "Memory manager initialization to (%d,%d) (%d,%d) failed\n", + ScreenArea.x1, ScreenArea.y1, + ScreenArea.x2, ScreenArea.y2); + return FALSE; + } else { + int width, height; + + xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, + "Memory manager initialized to (%d,%d) (%d,%d)\n", + ScreenArea.x1, ScreenArea.y1, ScreenArea.x2, ScreenArea.y2); + + if (xf86QueryLargestOffscreenArea(pScreen, &width, &height, 0, 0, 0)) { + xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, + "Largest offscreen area available: %d x %d\n", + width, height); + + /* lines in offscreen area needed for depth buffer and textures */ + pATI->depthTexLines = scanlines + - pATIDRIServer->depthOffset / widthBytes; + pATI->backLines = scanlines + - pATIDRIServer->backOffset / widthBytes + - pATI->depthTexLines; + pATI->depthTexArea = NULL; + pATI->backArea = NULL; + } else { + xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR, + "Unable to determine largest offscreen area available\n"); + return FALSE; + } + + } + + xf86DrvMsg(iScreen, X_INFO, "Will use %d kB of offscreen memory for XAA\n", + (offscreenBytes - pATIDRIServer->textureSize)/1024); + + xf86DrvMsg(iScreen, X_INFO, "Will use back buffer at offset 0x%x\n", + pATIDRIServer->backOffset); + + xf86DrvMsg(iScreen, X_INFO, "Will use depth buffer at offset 0x%x\n", + pATIDRIServer->depthOffset); + + if (pATIDRIServer->textureSize > 0) { + xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, + "Will use %d kB for local textures at offset 0x%x\n", + pATIDRIServer->textureSize/1024, + pATIDRIServer->textureOffset); + } + } + + return TRUE; +} +#endif /* XF86DRI_DEVEL */ +#endif /* USE_XAA */ /* * ATIScreenInit -- @@ -142,9 +336,6 @@ ATIPtr pATI = ATIPTR(pScreenInfo); pointer pFB; int VisualMask; -#ifdef XF86DRI_DEVEL - BoxRec ScreenArea; -#endif /* Set video hardware state */ if (!ATIEnterGraphics(pScreen, pScreenInfo, pATI)) @@ -327,186 +518,38 @@ #endif /* AVOID_CPIO */ - /* Memory manager setup */ +#ifdef USE_XAA + + /* Memory manager setup */ #ifdef XF86DRI_DEVEL if (pATI->directRenderingEnabled) { - ATIDRIServerInfoPtr pATIDRIServer = pATI->pDRIServerInfo; - int cpp = pATI->bitsPerPixel >> 3; - int widthBytes = pScreenInfo->displayWidth * cpp; - int zWidthBytes = pScreenInfo->displayWidth * 2; /* always 16-bit z-buffer */ - int fbSize = pScreenInfo->videoRam * 1024; - int bufferSize = pScreenInfo->virtualY * widthBytes; - int zBufferSize = pScreenInfo->virtualY * zWidthBytes; - int offscreenBytes, total, scanlines; - - pATIDRIServer->fbX = 0; - pATIDRIServer->fbY = 0; - pATIDRIServer->frontOffset = 0; - pATIDRIServer->frontPitch = pScreenInfo->displayWidth; - - /* Calculate memory remaining for pixcache and textures after - * front, back, and depth buffers - */ - offscreenBytes = fbSize - ( 2 * bufferSize + zBufferSize ); - - if ( !pATIDRIServer->IsPCI && !pATI->OptionLocalTextures ) { - /* Don't allocate a local texture heap for AGP unless requested */ - pATIDRIServer->textureSize = 0; - } else { - int l, maxPixcache; - -#ifdef XvExtension - - int xvBytes; - - /* Try for enough pixmap cache for DVD and a full viewport - */ - xvBytes = 720*480*cpp; /* enough for single-buffered DVD */ - maxPixcache = xvBytes > bufferSize ? xvBytes : bufferSize; - -#else /* XvExtension */ - - /* Try for one viewport */ - maxPixcache = bufferSize; - -#endif /* XvExtension */ - - pATIDRIServer->textureSize = offscreenBytes - maxPixcache; - - /* If that gives us less than half the offscreen mem available for textures, split - * the available mem between textures and pixmap cache - */ - if (pATIDRIServer->textureSize < (offscreenBytes/2)) { - pATIDRIServer->textureSize = offscreenBytes/2; - } - - if (pATIDRIServer->textureSize <= 0) - pATIDRIServer->textureSize = 0; - - l = ATIMinBits((pATIDRIServer->textureSize-1) / MACH64_NR_TEX_REGIONS); - if (l < MACH64_LOG_TEX_GRANULARITY) l = MACH64_LOG_TEX_GRANULARITY; - - /* Round the texture size up to the nearest whole number of - * texture regions. Again, be greedy about this, don't round - * down. - */ - pATIDRIServer->logTextureGranularity = l; - pATIDRIServer->textureSize = - (pATIDRIServer->textureSize >> l) << l; - } - - total = fbSize - pATIDRIServer->textureSize; - scanlines = total / widthBytes; - if (scanlines > ATIMach64MaxY) scanlines = ATIMach64MaxY; - - /* Recalculate the texture offset and size to accomodate any - * rounding to a whole number of scanlines. - * FIXME: Is this actually needed? - */ - pATIDRIServer->textureOffset = scanlines * widthBytes; - pATIDRIServer->textureSize = fbSize - pATIDRIServer->textureOffset; - - /* Set a minimum usable local texture heap size. This will fit - * two 256x256 textures. We check this after any rounding of - * the texture area. - */ - if (pATIDRIServer->textureSize < 256*256 * cpp * 2) { - pATIDRIServer->textureOffset = 0; - pATIDRIServer->textureSize = 0; - scanlines = fbSize / widthBytes; - if (scanlines > ATIMach64MaxY) scanlines = ATIMach64MaxY; - } - - pATIDRIServer->depthOffset = scanlines * widthBytes - zBufferSize; - pATIDRIServer->depthPitch = pScreenInfo->displayWidth; - pATIDRIServer->depthY = pATIDRIServer->depthOffset/widthBytes; - pATIDRIServer->depthX = (pATIDRIServer->depthOffset - - (pATIDRIServer->depthY * widthBytes)) / cpp; - - pATIDRIServer->backOffset = pATIDRIServer->depthOffset - bufferSize; - pATIDRIServer->backPitch = pScreenInfo->displayWidth; - pATIDRIServer->backY = pATIDRIServer->backOffset/widthBytes; - pATIDRIServer->backX = (pATIDRIServer->backOffset - - (pATIDRIServer->backY * widthBytes)) / cpp; - - scanlines = fbSize / widthBytes; - if (scanlines > ATIMach64MaxY) scanlines = ATIMach64MaxY; - - if ( pATIDRIServer->IsPCI && pATIDRIServer->textureSize == 0 ) { - xf86DrvMsg(iScreen, X_WARNING, - "Not enough memory for local textures, disabling DRI\n"); - ATIDRICloseScreen(pScreen); - pATI->directRenderingEnabled = FALSE; - } else { - - ScreenArea.x1 = 0; - ScreenArea.y1 = 0; - ScreenArea.x2 = pATI->displayWidth; - ScreenArea.y2 = scanlines; - - if (!xf86InitFBManager(pScreen, &ScreenArea)) { - xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR, - "Memory manager initialization to (%d,%d) (%d,%d) failed\n", - ScreenArea.x1, ScreenArea.y1, - ScreenArea.x2, ScreenArea.y2); - return FALSE; - } else { - int width, height; - - xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, - "Memory manager initialized to (%d,%d) (%d,%d)\n", - ScreenArea.x1, ScreenArea.y1, ScreenArea.x2, ScreenArea.y2); - - if (xf86QueryLargestOffscreenArea(pScreen, &width, &height, 0, 0, 0)) { - xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, - "Largest offscreen area available: %d x %d\n", - width, height); - - /* lines in offscreen area needed for depth buffer and textures */ - pATI->depthTexLines = scanlines - - pATIDRIServer->depthOffset / widthBytes; - pATI->backLines = scanlines - - pATIDRIServer->backOffset / widthBytes - - pATI->depthTexLines; - pATI->depthTexArea = NULL; - pATI->backArea = NULL; - } else { - xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR, - "Unable to determine largest offscreen area available\n"); - return FALSE; - } - - } - - xf86DrvMsg(iScreen, X_INFO, "Will use %d kB of offscreen memory for XAA\n", - (offscreenBytes - pATIDRIServer->textureSize)/1024); - - xf86DrvMsg(iScreen, X_INFO, "Will use back buffer at offset 0x%x\n", - pATIDRIServer->backOffset); - - xf86DrvMsg(iScreen, X_INFO, "Will use depth buffer at offset 0x%x\n", - pATIDRIServer->depthOffset); - - if (pATIDRIServer->textureSize > 0) { - xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO, - "Will use %d kB for local textures at offset 0x%x\n", - pATIDRIServer->textureSize/1024, - pATIDRIServer->textureOffset); - } - } + if (!pATI->useEXA && !ATIMach64SetupMemXAA(iScreen, pScreen)) + return FALSE; } #endif /* XF86DRI_DEVEL */ /* Setup acceleration */ + /* If direct rendering is not enabled, the framebuffer memory * manager is initialized by this function call */ - if (!ATIInitializeAcceleration(pScreen, pScreenInfo, pATI)) + if (!pATI->useEXA && !ATIInitializeAcceleration(pScreen, pScreenInfo, pATI)) + return FALSE; + +#endif /* USE_XAA */ + +#ifdef USE_EXA + + /* EXA initializes both memory manager and acceleration here */ + + if (pATI->useEXA && !ATIMach64ExaInit(pScreen)) return FALSE; +#endif /* USE_EXA */ + #ifndef AVOID_DGA /* Initialise DGA support */ @@ -621,11 +664,20 @@ ATICloseXVideo(pScreen, pScreenInfo, pATI); +#ifdef USE_EXA + if (pATI->pExa) { + exaDriverFini(pScreen); + xfree(pATI->pExa); + pATI->pExa = NULL; + } +#endif +#ifdef USE_XAA if (pATI->pXAAInfo) { XAADestroyInfoRec(pATI->pXAAInfo); pATI->pXAAInfo = NULL; } +#endif if ((pScreen->CloseScreen = pATI->CloseScreen)) { @@ -643,9 +695,14 @@ ATILeaveGraphics(pScreenInfo, pATI); - xfree(pATI->ExpansionBitmapScanlinePtr[1]); - pATI->ExpansionBitmapScanlinePtr[0] = +#ifdef USE_XAA + if (!pATI->useEXA) + { + xfree(pATI->ExpansionBitmapScanlinePtr[1]); + pATI->ExpansionBitmapScanlinePtr[0] = NULL; pATI->ExpansionBitmapScanlinePtr[1] = NULL; + } +#endif xfree(pATI->pShadow); pATI->pShadow = NULL; diff -Nau -x '*.swp' -x CVS -x 'Makefile*' -x '*o' -x '*a' xf86-video-ati/src/atistruct.h xf86-video-ati-exa/src/atistruct.h --- xf86-video-ati/src/atistruct.h 2005-07-31 20:19:27.000000000 +0300 +++ xf86-video-ati-exa/src/atistruct.h 2006-03-05 18:00:00.000000000 +0200 @@ -52,7 +52,12 @@ #endif /* TV_OUT */ +#ifdef USE_EXA +#include "exa.h" +#endif +#ifdef USE_XAA #include "xaa.h" +#endif #include "xf86Cursor.h" #include "xf86Pci.h" #include "xf86Resources.h" @@ -296,15 +301,23 @@ /* * XAA interface. */ + Bool useEXA; +#ifdef USE_EXA + ExaDriverPtr pExa; +#endif +#ifdef USE_XAA XAAInfoRecPtr pXAAInfo; +#endif int nAvailableFIFOEntries, nFIFOEntries, nHostFIFOEntries; CARD8 EngineIsBusy, EngineIsLocked, XModifier; CARD32 dst_cntl; /* For SetupFor/Subsequent communication */ CARD32 sc_left_right, sc_top_bottom; CARD16 sc_left, sc_right, sc_top, sc_bottom; /* Current scissors */ pointer pHOST_DATA; /* Current HOST_DATA_* transfer window address */ +#ifdef USE_XAA CARD32 *ExpansionBitmapScanlinePtr[2]; int ExpansionBitmapWidth; +#endif /* * Cursor-related definitions. @@ -382,7 +395,7 @@ * XVideo-related data. */ DevUnion XVPortPrivate[1]; - FBLinearPtr pXVBuffer; + pointer pXVBuffer; /* USE_EXA: ExaOffscreenArea*, USE_XAA: FBLinearPtr */ RegionRec VideoClip; int SurfacePitch, SurfaceOffset; CARD8 AutoPaint, DoubleBuffer, CurrentBuffer, ActiveSurface; @@ -485,10 +498,12 @@ Bool have3DWindows; /* offscreen memory management */ +#ifdef USE_XAA int backLines; FBAreaPtr backArea; int depthTexLines; FBAreaPtr depthTexArea; +#endif CARD8 OptionIsPCI; /* Force PCI mode */ CARD8 OptionDMAMode; /* async, sync, mmio */ CARD8 OptionAGPMode; /* AGP mode */