$Id$ Add RENDER and X Acceleration Architecture (XAA) support to Sun FFB driver, and use FB framebuffer layer instead of MFB and CFB. This patch by David S. Miller. Forward-port by Fabio M. Di Nitto. diff -ruN xc-old/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_accel.c xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_accel.c --- xc-old/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_accel.c 2004-04-23 21:48:16.000000000 +0200 +++ xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_accel.c 2004-11-16 14:01:53.530947352 +0100 @@ -30,22 +30,9 @@ #include "pixmapstr.h" #include "regionstr.h" #include "mistruct.h" -#include "fontstruct.h" -#include "dixfontstr.h" -#define PSZ 8 -#include "cfb.h" -#undef PSZ -#include "cfb32.h" -#include "mibstore.h" -#include "mifillarc.h" -#include "miwideline.h" #include "miline.h" -#include "fastblt.h" -#include "mergerop.h" -#include "migc.h" -#include "mi.h" - -#include "cfb8_32wid.h" +#include "fb.h" +#include "xaa.h" #include "ffb.h" #include "ffb_fifo.h" @@ -69,635 +56,6 @@ /*XXX*/ { 0x00c0, 0x0a00, 0x04, 0x08, 0x08, 0x50 }, /* Portrait: 1280 x 2048 XXX */ }; -static Bool -CreatorCreateWindow (WindowPtr pWin) -{ - ScreenPtr pScreen = pWin->drawable.pScreen; - FFBPtr pFfb = GET_FFB_FROM_SCREEN(pScreen); - CreatorPrivWinPtr pFfbPrivWin; - unsigned int fbc; - int depth = (pWin->drawable.depth == 8) ? 8 : 24; - int i, visual, visclass; - - if (depth == 8) { - if (!cfbCreateWindow (pWin)) - return FALSE; - } else { - if (!cfb32CreateWindow (pWin)) - return FALSE; - } - - pFfbPrivWin = xalloc(sizeof(CreatorPrivWinRec)); - if (!pFfbPrivWin) - return FALSE; - - fbc = FFB_FBC_WB_A | FFB_FBC_WM_COMBINED | FFB_FBC_RB_A; - fbc |= FFB_FBC_WE_FORCEON; - fbc |= FFB_FBC_SB_BOTH; - fbc |= FFB_FBC_ZE_OFF | FFB_FBC_YE_OFF; - if (depth == 8) - fbc |= (FFB_FBC_RE_MASK | FFB_FBC_GE_OFF | FFB_FBC_BE_OFF); - else - fbc |= FFB_FBC_RGBE_MASK; - fbc |= FFB_FBC_XE_ON; - pFfbPrivWin->fbc_base = fbc; - - visual = wVisual(pWin); - visclass = 0; - for (i = 0; i < pScreen->numVisuals; i++) { - if (pScreen->visuals[i].vid == visual) { - visclass = pScreen->visuals[i].class; - break; - } - } - - pFfbPrivWin->wid = FFBWidAlloc(pFfb, visclass, wColormap(pWin), TRUE); - if (pFfbPrivWin->wid == (unsigned int) -1) { - xfree(pFfbPrivWin); - return FALSE; - } - FFBLOG(("CreatorCreateWindow: pWin %p depth %d wid %x fbc_base %x\n", - pWin, depth, pFfbPrivWin->wid, pFfbPrivWin->fbc_base)); - - pFfbPrivWin->Stipple = NULL; - CreatorSetWindowPrivate(pWin, pFfbPrivWin); - - return TRUE; -} - -static Bool -CreatorDestroyWindow (WindowPtr pWin) -{ - FFBPtr pFfb = GET_FFB_FROM_SCREEN(pWin->drawable.pScreen); - CreatorPrivWinPtr pFfbPrivWin; - int depth = (pWin->drawable.depth == 8) ? 8 : 24; - - FFBLOG(("CreatorDestroyWindow: pWin %p depth %d\n", pWin, depth)); - pFfbPrivWin = CreatorGetWindowPrivate(pWin); - if (pFfbPrivWin->Stipple) - xfree(pFfbPrivWin->Stipple); - FFBWidFree(pFfb, pFfbPrivWin->wid); - xfree(pFfbPrivWin); - - if (depth == 8) - return cfbDestroyWindow (pWin); - else - return cfb32DestroyWindow (pWin); -} - -extern CreatorStipplePtr FFB_tmpStipple; - -static int -CreatorChangeWindowAttributes (WindowPtr pWin, unsigned long mask) -{ - FFBPtr pFfb = GET_FFB_FROM_SCREEN(pWin->drawable.pScreen); - CreatorPrivWinPtr pFfbPrivWin; - CreatorStipplePtr stipple; - Mask index; - WindowPtr pBgWin; - register cfbPrivWin *pPrivWin; - int width, depth; - - FFBLOG(("CreatorChangeWindowAttributes: WIN(%p) mask(%08x)\n", pWin, mask)); - pPrivWin = (cfbPrivWin *)(pWin->devPrivates[cfbWindowPrivateIndex].ptr); - pFfbPrivWin = CreatorGetWindowPrivate(pWin); - depth = pWin->drawable.depth; - - /* - * When background state changes from ParentRelative and - * we had previously rotated the fast border pixmap to match - * the parent relative origin, rerotate to match window - */ - if (mask & (CWBackPixmap | CWBackPixel) && - pWin->backgroundState != ParentRelative && - pPrivWin->fastBorder && - (pPrivWin->oldRotate.x != pWin->drawable.x || - pPrivWin->oldRotate.y != pWin->drawable.y)) { - if (depth == 8) { - cfbXRotatePixmap(pPrivWin->pRotatedBorder, - pWin->drawable.x - pPrivWin->oldRotate.x); - cfbYRotatePixmap(pPrivWin->pRotatedBorder, - pWin->drawable.y - pPrivWin->oldRotate.y); - } else { - cfb32XRotatePixmap(pPrivWin->pRotatedBorder, - pWin->drawable.x - pPrivWin->oldRotate.x); - cfb32YRotatePixmap(pPrivWin->pRotatedBorder, - pWin->drawable.y - pPrivWin->oldRotate.y); - } - pPrivWin->oldRotate.x = pWin->drawable.x; - pPrivWin->oldRotate.y = pWin->drawable.y; - } - while (mask) { - index = lowbit(mask); - mask &= ~index; - switch (index) { - case CWBackPixmap: - stipple = pFfbPrivWin->Stipple; - if (pWin->backgroundState == None || - pWin->backgroundState == ParentRelative) { - pPrivWin->fastBackground = FALSE; - if (stipple) { - xfree (stipple); - pFfbPrivWin->Stipple = NULL; - } - /* Rotate border to match parent origin */ - if (pWin->backgroundState == ParentRelative && - pPrivWin->pRotatedBorder) { - for (pBgWin = pWin->parent; - pBgWin->backgroundState == ParentRelative; - pBgWin = pBgWin->parent); - if (depth == 8) { - cfbXRotatePixmap(pPrivWin->pRotatedBorder, - pBgWin->drawable.x - pPrivWin->oldRotate.x); - cfbYRotatePixmap(pPrivWin->pRotatedBorder, - pBgWin->drawable.y - pPrivWin->oldRotate.y); - } else { - cfb32XRotatePixmap(pPrivWin->pRotatedBorder, - pBgWin->drawable.x - pPrivWin->oldRotate.x); - cfb32YRotatePixmap(pPrivWin->pRotatedBorder, - pBgWin->drawable.y - pPrivWin->oldRotate.y); - } - pPrivWin->oldRotate.x = pBgWin->drawable.x; - pPrivWin->oldRotate.y = pBgWin->drawable.y; - } - break; - } - if (!stipple) { - if (!FFB_tmpStipple) - FFB_tmpStipple = (CreatorStipplePtr) - xalloc (sizeof *FFB_tmpStipple); - stipple = FFB_tmpStipple; - } - if (stipple) { - int ph = FFB_FFPARMS(pFfb).pagefill_height; - - if (CreatorCheckTile (pWin->background.pixmap, stipple, - ((DrawablePtr)pWin)->x & 31, - ((DrawablePtr)pWin)->y & 31, ph)) { - stipple->alu = GXcopy; - pPrivWin->fastBackground = FALSE; - if (stipple == FFB_tmpStipple) { - pFfbPrivWin->Stipple = stipple; - FFB_tmpStipple = 0; - } - break; - } - } - if ((stipple = pFfbPrivWin->Stipple) != NULL) { - xfree (stipple); - pFfbPrivWin->Stipple = NULL; - } - if (((width = (pWin->background.pixmap->drawable.width * - pWin->background.pixmap->drawable.bitsPerPixel)) <= 32) && - !(width & (width - 1))) { - if (depth == 8) { - cfbCopyRotatePixmap(pWin->background.pixmap, - &pPrivWin->pRotatedBackground, - pWin->drawable.x, - pWin->drawable.y); - } else { - cfb32CopyRotatePixmap(pWin->background.pixmap, - &pPrivWin->pRotatedBackground, - pWin->drawable.x, - pWin->drawable.y); - } - if (pPrivWin->pRotatedBackground) { - pPrivWin->fastBackground = TRUE; - pPrivWin->oldRotate.x = pWin->drawable.x; - pPrivWin->oldRotate.y = pWin->drawable.y; - } else - pPrivWin->fastBackground = FALSE; - break; - } - pPrivWin->fastBackground = FALSE; - break; - - case CWBackPixel: - pPrivWin->fastBackground = FALSE; - break; - - case CWBorderPixmap: - /* don't bother with accelerator for border tiles (just lazy) */ - if (((width = (pWin->border.pixmap->drawable.width * - pWin->border.pixmap->drawable.bitsPerPixel)) <= 32) && - !(width & (width - 1))) { - for (pBgWin = pWin; - pBgWin->backgroundState == ParentRelative; - pBgWin = pBgWin->parent) - ; - if (depth == 8) { - cfbCopyRotatePixmap(pWin->border.pixmap, - &pPrivWin->pRotatedBorder, - pBgWin->drawable.x, - pBgWin->drawable.y); - } else { - cfb32CopyRotatePixmap(pWin->border.pixmap, - &pPrivWin->pRotatedBorder, - pBgWin->drawable.x, - pBgWin->drawable.y); - } - if (pPrivWin->pRotatedBorder) { - pPrivWin->fastBorder = TRUE; - pPrivWin->oldRotate.x = pBgWin->drawable.x; - pPrivWin->oldRotate.y = pBgWin->drawable.y; - } else - pPrivWin->fastBorder = FALSE; - } else - pPrivWin->fastBorder = FALSE; - break; - - case CWBorderPixel: - pPrivWin->fastBorder = FALSE; - break; - } - } - return (TRUE); -} - -static void -CreatorPaintWindow(WindowPtr pWin, RegionPtr pRegion, int what) -{ - FFBPtr pFfb = GET_FFB_FROM_SCREEN (pWin->drawable.pScreen); - ffb_fbcPtr ffb = pFfb->regs; - register cfbPrivWin *pPrivWin; - CreatorPrivWinPtr pFfbPrivWin; - CreatorStipplePtr stipple; - WindowPtr pBgWin; - int depth = pWin->drawable.depth; - - if (pFfb->vtSema) - return; - - FFBLOG(("CreatorPaintWindow: WIN(%p) what(%d)\n", pWin, what)); - pPrivWin = cfbGetWindowPrivate(pWin); - pFfbPrivWin = CreatorGetWindowPrivate(pWin); - switch (what) { - case PW_BACKGROUND: - stipple = pFfbPrivWin->Stipple; - switch (pWin->backgroundState) { - case None: - return; - case ParentRelative: - do { - pWin = pWin->parent; - } while (pWin->backgroundState == ParentRelative); - (*pWin->drawable.pScreen->PaintWindowBackground)(pWin, pRegion, what); - return; - case BackgroundPixmap: - if (stipple) { - CreatorFillBoxStipple ((DrawablePtr)pWin, - (int)REGION_NUM_RECTS(pRegion), - REGION_RECTS(pRegion), - stipple); - return; - } - FFB_ATTR_SFB_VAR_WIN(pFfb, 0x00ffffff, GXcopy, pWin); - FFBWait(pFfb, ffb); - if (pPrivWin->fastBackground) { - if (depth == 8) { - cfbFillBoxTile32 ((DrawablePtr)pWin, - (int)REGION_NUM_RECTS(pRegion), - REGION_RECTS(pRegion), - pPrivWin->pRotatedBackground); - } else { - cfb32FillBoxTile32 ((DrawablePtr)pWin, - (int)REGION_NUM_RECTS(pRegion), - REGION_RECTS(pRegion), - pPrivWin->pRotatedBackground); - } - } else { - if (depth == 8) { - cfbFillBoxTileOdd ((DrawablePtr)pWin, - (int)REGION_NUM_RECTS(pRegion), - REGION_RECTS(pRegion), - pWin->background.pixmap, - (int) pWin->drawable.x, - (int) pWin->drawable.y); - } else { - cfb32FillBoxTileOdd ((DrawablePtr)pWin, - (int)REGION_NUM_RECTS(pRegion), - REGION_RECTS(pRegion), - pWin->background.pixmap, - (int) pWin->drawable.x, - (int) pWin->drawable.y); - } - } - return; - case BackgroundPixel: - CreatorFillBoxSolid ((DrawablePtr)pWin, - (int)REGION_NUM_RECTS(pRegion), - REGION_RECTS(pRegion), - pWin->background.pixel); - return; - } - break; - case PW_BORDER: - if (pWin->borderIsPixel) { - CreatorFillBoxSolid ((DrawablePtr)pWin, - (int)REGION_NUM_RECTS(pRegion), - REGION_RECTS(pRegion), - pWin->border.pixel); - return; - } - FFB_ATTR_SFB_VAR_WIN(pFfb, 0x00ffffff, GXcopy, pWin); - FFBWait(pFfb, ffb); - if (pPrivWin->fastBorder) { - if (depth == 8) { - cfbFillBoxTile32 ((DrawablePtr)pWin, - (int)REGION_NUM_RECTS(pRegion), - REGION_RECTS(pRegion), - pPrivWin->pRotatedBorder); - } else { - cfb32FillBoxTile32 ((DrawablePtr)pWin, - (int)REGION_NUM_RECTS(pRegion), - REGION_RECTS(pRegion), - pPrivWin->pRotatedBorder); - } - } else { - for (pBgWin = pWin; - pBgWin->backgroundState == ParentRelative; - pBgWin = pBgWin->parent) - ; - - if (depth == 8) { - cfbFillBoxTileOdd ((DrawablePtr)pWin, - (int)REGION_NUM_RECTS(pRegion), - REGION_RECTS(pRegion), - pWin->border.pixmap, - (int) pBgWin->drawable.x, - (int) pBgWin->drawable.y); - } else { - cfb32FillBoxTileOdd ((DrawablePtr)pWin, - (int)REGION_NUM_RECTS(pRegion), - REGION_RECTS(pRegion), - pWin->border.pixmap, - (int) pBgWin->drawable.x, - (int) pBgWin->drawable.y); - } - } - return; - } -} - -static void -CreatorCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc) -{ - ScreenPtr pScreen = pWin->drawable.pScreen; - FFBPtr pFfb = GET_FFB_FROM_SCREEN (pScreen); - DDXPointPtr pptSrc; - DDXPointPtr ppt; - RegionRec rgnDst; - BoxPtr pbox; - int dx, dy; - int i, nbox; - WindowPtr pwinRoot; - - if (pFfb->vtSema) - return; - - FFBLOG(("CreatorCopyWindow: WIN(%p)\n", pWin)); - - REGION_NULL(pScreen, &rgnDst); - - dx = ptOldOrg.x - pWin->drawable.x; - dy = ptOldOrg.y - pWin->drawable.y; - REGION_TRANSLATE(pScreen, prgnSrc, -dx, -dy); - REGION_INTERSECT(pScreen, &rgnDst, &pWin->borderClip, prgnSrc); - - pbox = REGION_RECTS(&rgnDst); - nbox = REGION_NUM_RECTS(&rgnDst); - if(!(pptSrc = (DDXPointPtr )ALLOCATE_LOCAL(nbox * sizeof(DDXPointRec)))) - return; - - ppt = pptSrc; - for (i = nbox; --i >= 0; ppt++, pbox++) { - ppt->x = pbox->x1 + dx; - ppt->y = pbox->y1 + dy; - } - - /* XXX Optimize this later to only gcopy/vcopy the 8bpp+WID plane - * XXX when possible. -DaveM - */ - - pwinRoot = WindowTable[pScreen->myNum]; - - if (!pFfb->disable_vscroll && (!dx && dy)) { - FFBPtr pFfb = GET_FFB_FROM_SCREEN(pScreen); - - FFB_ATTR_VSCROLL_WINCOPY(pFfb); - CreatorDoVertBitblt ((DrawablePtr)pwinRoot, (DrawablePtr)pwinRoot, - GXcopy, &rgnDst, pptSrc, ~0L); - } else { - FFBPtr pFfb = GET_FFB_FROM_SCREEN(pScreen); - ffb_fbcPtr ffb = pFfb->regs; - - FFB_ATTR_SFB_VAR_WINCOPY(pFfb); - FFBWait(pFfb, ffb); - CreatorDoBitblt ((DrawablePtr)pwinRoot, (DrawablePtr)pwinRoot, - GXcopy, &rgnDst, pptSrc, ~0L); - } - DEALLOCATE_LOCAL(pptSrc); - REGION_UNINIT(pScreen, &rgnDst); -} - -static void -CreatorSaveAreas(PixmapPtr pPixmap, RegionPtr prgnSave, int xorg, int yorg, WindowPtr pWin) -{ - ScreenPtr pScreen = pPixmap->drawable.pScreen; - FFBPtr pFfb = GET_FFB_FROM_SCREEN(pScreen); - cfb8_32WidScreenPtr pScreenPriv = - CFB8_32WID_GET_SCREEN_PRIVATE(pScreen); - ffb_fbcPtr ffb = pFfb->regs; - register DDXPointPtr pPt; - DDXPointPtr pPtsInit; - register BoxPtr pBox; - register int i; - PixmapPtr pScrPix; - - if (pFfb->vtSema) - return; - - FFBLOG(("CreatorSaveAreas: WIN(%p)\n", pWin)); - i = REGION_NUM_RECTS(prgnSave); - pPtsInit = (DDXPointPtr)ALLOCATE_LOCAL(i * sizeof(DDXPointRec)); - if (!pPtsInit) - return; - - pBox = REGION_RECTS(prgnSave); - pPt = pPtsInit; - while (--i >= 0) { - pPt->x = pBox->x1 + xorg; - pPt->y = pBox->y1 + yorg; - pPt++; - pBox++; - } - - if (pWin->drawable.bitsPerPixel == 8) - pScrPix = (PixmapPtr) pScreenPriv->pix8; - else - pScrPix = (PixmapPtr) pScreenPriv->pix32; - - /* SRC is the framebuffer, DST is a pixmap. The SFB_VAR attributes may - * seem silly, but they are needed even in this case to handle - * double-buffered windows properly. - */ - FFB_ATTR_SFB_VAR_WIN(pFfb, 0x00ffffff, GXcopy, pWin); - FFBWait(pFfb, ffb); - CreatorDoBitblt((DrawablePtr) pScrPix, (DrawablePtr)pPixmap, - GXcopy, prgnSave, pPtsInit, ~0L); - - DEALLOCATE_LOCAL (pPtsInit); -} - -static void -CreatorRestoreAreas(PixmapPtr pPixmap, RegionPtr prgnRestore, int xorg, int yorg, WindowPtr pWin) -{ - FFBPtr pFfb; - ffb_fbcPtr ffb; - register DDXPointPtr pPt; - DDXPointPtr pPtsInit; - register BoxPtr pBox; - register int i; - ScreenPtr pScreen = pPixmap->drawable.pScreen; - cfb8_32WidScreenPtr pScreenPriv = - CFB8_32WID_GET_SCREEN_PRIVATE(pScreen); - PixmapPtr pScrPix; - - pFfb = GET_FFB_FROM_SCREEN(pScreen); - if (pFfb->vtSema) - return; - - FFBLOG(("CreatorRestoreAreas: WIN(%p)\n", pWin)); - i = REGION_NUM_RECTS(prgnRestore); - pPtsInit = (DDXPointPtr)ALLOCATE_LOCAL(i*sizeof(DDXPointRec)); - if (!pPtsInit) - return; - - pBox = REGION_RECTS(prgnRestore); - pPt = pPtsInit; - while (--i >= 0) { - pPt->x = pBox->x1 - xorg; - pPt->y = pBox->y1 - yorg; - pPt++; - pBox++; - } - - if (pWin->drawable.bitsPerPixel == 8) - pScrPix = (PixmapPtr) pScreenPriv->pix8; - else - pScrPix = (PixmapPtr) pScreenPriv->pix32; - - pFfb = GET_FFB_FROM_SCREEN(pScreen); - ffb = pFfb->regs; - - /* SRC is a pixmap, DST is the framebuffer */ - FFB_ATTR_SFB_VAR_WIN(pFfb, 0x00ffffff, GXcopy, pWin); - FFBWait(pFfb, ffb); - CreatorDoBitblt((DrawablePtr)pPixmap, (DrawablePtr) pScrPix, - GXcopy, prgnRestore, pPtsInit, ~0L); - - DEALLOCATE_LOCAL (pPtsInit); -} - -static void -CreatorGetImage(DrawablePtr pDrawable, int sx, int sy, int w, int h, unsigned int format, unsigned long planeMask, char* pdstLine) -{ - BoxRec box; - DDXPointRec ptSrc; - RegionRec rgnDst; - ScreenPtr pScreen; - PixmapPtr pPixmap; - - FFBLOG(("CreatorGetImage: s[%08x:%08x] wh[%08x:%08x]\n", sx, sy, w, h)); - if ((w == 0) || (h == 0)) - return; - if (pDrawable->bitsPerPixel == 1) { - mfbGetImage(pDrawable, sx, sy, w, h, format, planeMask, pdstLine); - return; - } - pScreen = pDrawable->pScreen; - /* - * XFree86 DDX empties the root borderClip when the VT is - * switched away; this checks for that case - */ - if (!cfbDrawableEnabled (pDrawable)) - return; - if(format == ZPixmap) { - FFBPtr pFfb = GET_FFB_FROM_SCREEN (pScreen); - ffb_fbcPtr ffb = pFfb->regs; - - /* We have to have the full planemask. */ - if (pDrawable->type == DRAWABLE_WINDOW) { - WindowPtr pWin = (WindowPtr) pDrawable; - - FFB_ATTR_SFB_VAR_WIN(pFfb, 0x00ffffff, GXcopy, pWin); - FFBWait(pFfb, ffb); - } - - if (pDrawable->bitsPerPixel == 8) { - if((planeMask & 0x000000ff) != 0x000000ff) { - cfbGetImage(pDrawable, sx, sy, w, h, - format, planeMask, pdstLine); - return; - } - } else { - if((planeMask & 0x00ffffff) != 0x00ffffff) { - cfb32GetImage(pDrawable, sx, sy, w, h, - format, planeMask, pdstLine); - return; - } - } - - /* SRC is the framebuffer, DST is a pixmap */ - if (pDrawable->type == DRAWABLE_WINDOW && w == 1 && h == 1) { - /* Benchmarks do this make sure the acceleration hardware - * has completed all of it's operations, therefore I feel - * it is not cheating to special case this because if - * anything it gives the benchmarks more accurate results. - */ - if (pDrawable->bitsPerPixel == 32) { - unsigned char *sfb = (unsigned char *)pFfb->sfb32; - unsigned int *dstPixel = (unsigned int *)pdstLine; - unsigned int tmp; - - tmp = *((unsigned int *)(sfb + - ((sy + pDrawable->y) << 13) + - ((sx + pDrawable->x) << 2))); - *dstPixel = (tmp & 0x00ffffff); - } else { - unsigned char *sfb = (unsigned char *)pFfb->sfb8r; - unsigned char *dstPixel = (unsigned char *)pdstLine; - - *dstPixel = *((unsigned char *)(sfb + - ((sy + pDrawable->y) << 11) + - ((sx + pDrawable->x) << 0))); - } - return; - } - pPixmap = GetScratchPixmapHeader(pScreen, w, h, - pDrawable->depth, pDrawable->bitsPerPixel, - PixmapBytePad(w,pDrawable->depth), (pointer)pdstLine); - if (!pPixmap) - return; - ptSrc.x = sx + pDrawable->x; - ptSrc.y = sy + pDrawable->y; - box.x1 = 0; - box.y1 = 0; - box.x2 = w; - box.y2 = h; - REGION_INIT(pScreen, &rgnDst, &box, 1); - CreatorDoBitblt(pDrawable, (DrawablePtr)pPixmap, GXcopy, &rgnDst, - &ptSrc, planeMask); - REGION_UNINIT(pScreen, &rgnDst); - FreeScratchPixmapHeader(pPixmap); - } else - miGetImage(pDrawable, sx, sy, w, h, format, planeMask, pdstLine); -} - -extern void -CreatorGetSpans(DrawablePtr pDrawable, int wMax, DDXPointPtr ppt, - int *pwidth, int nspans, char *pchardstStart); - void CreatorVtChange (ScreenPtr pScreen, int enter) { @@ -705,7 +63,7 @@ ffb_fbcPtr ffb = pFfb->regs; pFfb->rp_active = 1; - FFBWait(pFfb, ffb); + FFBWait(pFfb, ffb); pFfb->fifo_cache = -1; pFfb->fbc_cache = (FFB_FBC_WB_A | FFB_FBC_WM_COMBINED | FFB_FBC_RB_A | FFB_FBC_SB_BOTH| FFB_FBC_XE_OFF | @@ -743,8 +101,8 @@ FFB_FBC_ZE_OFF | FFB_FBC_YE_OFF | FFB_FBC_RGBE_ON); pFfb->ppc_cache &= ~FFB_PPC_XS_MASK; pFfb->ppc_cache |= FFB_PPC_XS_WID; - pFfb->wid_cache = 0xff; - FFBFifo(pFfb, 8); + pFfb->wid_cache = (enter ? pFfb->xaa_wid : 0xff); + FFBFifo(pFfb, 11); ffb->fbc = pFfb->fbc_cache; ffb->ppc = FFB_PPC_XS_WID; ffb->wid = pFfb->wid_cache; @@ -753,7 +111,718 @@ ffb->cmp = 0x80808080; ffb->matchab = 0x80808080; ffb->magnab = 0x80808080; + ffb->blendc = (FFB_BLENDC_FORCE_ONE | + FFB_BLENDC_DF_ONE_M_A | + FFB_BLENDC_SF_A); + ffb->blendc1 = 0; + ffb->blendc2 = 0; + pFfb->rp_active = 1; FFBWait(pFfb, ffb); + + if (enter) { + pFfb->drawop_cache = FFB_DRAWOP_RECTANGLE; + + FFBFifo(pFfb, 5); + ffb->drawop = pFfb->drawop_cache; + FFB_WRITE64(&ffb->by, 0, 0); + FFB_WRITE64_2(&ffb->bh, pFfb->psdp->height, pFfb->psdp->width); + pFfb->rp_active = 1; + FFBWait(pFfb, ffb); + + SET_SYNC_FLAG(pFfb->pXAAInfo); + } +} + +#ifdef DEBUG_FFB +FILE *FDEBUG_FD = NULL; +#endif + +#define FFB_ATTR_SFB_VAR_XAA(__fpriv, __pmask, __alu) \ +do { unsigned int __ppc = FFB_PPC_ABE_DISABLE | FFB_PPC_APE_DISABLE | FFB_PPC_CS_VAR | FFB_PPC_XS_WID; \ + unsigned int __ppc_mask = FFB_PPC_ABE_MASK | FFB_PPC_APE_MASK | FFB_PPC_CS_MASK | FFB_PPC_XS_MASK; \ + unsigned int __rop = (FFB_ROP_EDIT_BIT | (__alu))|(FFB_ROP_NEW<<8); \ + unsigned int __fbc = (__fpriv)->xaa_fbc; \ + unsigned int __wid = (__fpriv)->xaa_wid; \ + if (((__fpriv)->ppc_cache & __ppc_mask) != __ppc || \ + (__fpriv)->fbc_cache != __fbc || \ + (__fpriv)->wid_cache != __wid || \ + (__fpriv)->rop_cache != __rop || \ + (__fpriv)->pmask_cache != (__pmask)) \ + __FFB_Attr_SFB_VAR(__fpriv, __ppc, __ppc_mask, __fbc, \ + __wid, __rop, (__pmask)); \ +} while(0) + +#define FFB_ATTR_VSCROLL_XAA(__fpriv, __pmask) \ +do { unsigned int __rop = (FFB_ROP_OLD | (FFB_ROP_OLD << 8)); \ + unsigned int __fbc = (__fpriv)->xaa_fbc; \ + if ((__fpriv)->fbc_cache != __fbc || \ + (__fpriv)->rop_cache != __rop || \ + (__fpriv)->pmask_cache != (__pmask) || \ + (__fpriv)->drawop_cache != FFB_DRAWOP_VSCROLL) { \ + ffb_fbcPtr __ffb = (__fpriv)->regs; \ + (__fpriv)->fbc_cache = __fbc; \ + (__fpriv)->rop_cache = __rop; \ + (__fpriv)->pmask_cache = (__pmask); \ + (__fpriv)->drawop_cache = FFB_DRAWOP_VSCROLL; \ + (__fpriv)->rp_active = 1; \ + FFBFifo(__fpriv, 4); \ + (__ffb)->fbc = __fbc; \ + (__ffb)->rop = __rop; \ + (__ffb)->pmask = (__pmask); \ + (__ffb)->drawop = FFB_DRAWOP_VSCROLL; \ + } \ +} while(0) + +static CARD32 FFBAlphaTextureFormats[2] = { PICT_a8, 0 }; +static CARD32 FFBTextureFormats[2] = { PICT_a8b8g8r8, 0 }; + +static void FFB_SetupTextureAttrs(FFBPtr pFfb) +{ + ffb_fbcPtr ffb = pFfb->regs; + unsigned int ppc = FFB_PPC_APE_DISABLE | FFB_PPC_CS_VAR | FFB_PPC_XS_VAR; + unsigned int ppc_mask = FFB_PPC_APE_MASK | FFB_PPC_CS_MASK | FFB_PPC_XS_MASK; + unsigned int rop = FFB_ROP_NEW | (FFB_ROP_NEW << 8); + unsigned int fbc = pFfb->xaa_fbc; + unsigned int wid = pFfb->xaa_wid; + + ppc |= FFB_PPC_ABE_ENABLE; + ppc_mask |= FFB_PPC_ABE_MASK; + + if ((pFfb->ppc_cache & ppc_mask) != ppc || + pFfb->fbc_cache != fbc || + pFfb->wid_cache != wid || + pFfb->rop_cache != rop || + pFfb->pmask_cache != 0xffffffff) + __FFB_Attr_SFB_VAR(pFfb, ppc, ppc_mask, fbc, + wid, rop, 0xffffffff); + FFBWait(pFfb, ffb); +} + +static Bool FFB_SetupForCPUToScreenAlphaTexture(ScrnInfoPtr pScrn, int op, + CARD16 red, CARD16 green, CARD16 blue, + CARD16 alpha, int alphaType, + CARD8 *alphaPtr, int alphaPitch, + int width, int height, int flags) +{ + FFBPtr pFfb = GET_FFB_FROM_SCRN(pScrn); + + FFBLOG(("FFB_SetupForCPUToScreenAlphaTexture: " + "argb[%04x:%04x:%04x:%04x] alpha[T(%x):P(%d)] " + "wh[%d:%d] flgs[%x]\n", + alpha, red, green, blue, + alphaType, alphaPitch, + width, height, flags)); + + FFB_SetupTextureAttrs(pFfb); + + pFfb->xaa_tex = (unsigned char *) alphaPtr; + pFfb->xaa_tex_pitch = alphaPitch; + pFfb->xaa_tex_width = width; + pFfb->xaa_tex_height = height; + pFfb->xaa_tex_color = (/*((alpha >> 8) << 24) |*/ + ((blue >> 8) << 16) | + ((green >> 8) << 8) | + ((red >> 8) << 0)); + return TRUE; +} + +static void FFB_SubsequentCPUToScreenAlphaTexture(ScrnInfoPtr pScrn, + int dstx, int dsty, + int srcx, int srcy, + int width, int height) +{ + FFBPtr pFfb = GET_FFB_FROM_SCRN(pScrn); + unsigned char *dst_base, *alpha_base, *sfb32; + unsigned int pixel_base; + int psz_shift = 2; + + FFBLOG(("FFB_SubsequentCPUToScreenAlphaTexture: " + "dst[%d:%d] src[%d:%d] wh[%d:%d]\n", + dstx, dsty, srcx, srcy, width, height)); + + sfb32 = (unsigned char *) pFfb->sfb32; + dst_base = sfb32 + (dsty * (2048 << psz_shift)) + (dstx << psz_shift); + alpha_base = pFfb->xaa_tex; + alpha_base += srcx; + if (srcy) + alpha_base += (srcy * pFfb->xaa_tex_pitch); + pixel_base = pFfb->xaa_tex_color; + while (height--) { + unsigned int *dst = (unsigned int *) dst_base; + unsigned char *alpha = alpha_base; + int w = width; + + while (w--) { + (*dst) = (((unsigned int)*alpha << 24) | pixel_base); + dst++; + alpha++; + } + dst_base += (2048 << psz_shift); + alpha_base += pFfb->xaa_tex_pitch; + } +} + + +static Bool FFB_SetupForCPUToScreenTexture(ScrnInfoPtr pScrn, int op, + int texType, + CARD8 *texPtr, int texPitch, + int width, int height, int flags) +{ + FFBPtr pFfb = GET_FFB_FROM_SCRN(pScrn); + + FFBLOG(("FFB_SetupForCPUToScreenTexture: " + "TEX[T(%x):P(%d)] " + "wh[%d:%d] flgs[%x]\n", + texType, texPitch, + width, height, flags)); + + FFB_SetupTextureAttrs(pFfb); + + pFfb->xaa_tex = (unsigned char *) texPtr; + pFfb->xaa_tex_pitch = texPitch; + pFfb->xaa_tex_width = width; + pFfb->xaa_tex_height = height; + + return TRUE; +} + +static void FFB_SubsequentCPUToScreenTexture(ScrnInfoPtr pScrn, + int dstx, int dsty, + int srcx, int srcy, + int width, int height) +{ + FFBPtr pFfb = GET_FFB_FROM_SCRN(pScrn); + unsigned char *dst_base, *sfb32; + unsigned int *tex_base; + int psz_shift = 2; + + FFBLOG(("FFB_SubsequentCPUToScreenAlphaTexture: " + "dst[%d:%d] src[%d:%d] wh[%d:%d]\n", + dstx, dsty, srcx, srcy, width, height)); + + sfb32 = (unsigned char *) pFfb->sfb32; + dst_base = sfb32 + (dsty * (2048 << psz_shift)) + (dstx << psz_shift); + tex_base = (unsigned int *) pFfb->xaa_tex; + tex_base += srcx; + if (srcy) + tex_base += (srcy * pFfb->xaa_tex_pitch); + while (height--) { + unsigned int *dst = (unsigned int *) dst_base; + unsigned int *tex = tex_base; + int w = width; + while (w--) { + (*dst) = *tex; + + dst++; + tex++; + } + dst_base += (2048 << psz_shift); + tex_base += pFfb->xaa_tex_pitch; + } +} + +static void FFB_WritePixmap(ScrnInfoPtr pScrn, + int x, int y, int w, int h, + unsigned char *src, + int srcwidth, + int rop, + unsigned int planemask, + int trans, int bpp, int depth) +{ + FFBPtr pFfb = GET_FFB_FROM_SCRN(pScrn); + unsigned char *dst, *sfb32; + int psz_shift = 2; + ffb_fbcPtr ffb = pFfb->regs; + + FFBLOG(("FFB_WritePixmap: " + "x[%d] y[%d] w[%d] h[%d] srcw[%d] rop[%d] pmask[%x] " + "trans[%d] bpp[%d] depth[%d]\n", + x, y, w, h, srcwidth, rop, planemask, + trans, bpp, depth)); + + FFB_ATTR_SFB_VAR_XAA(pFfb, planemask, rop); + FFBWait(pFfb, ffb); + + sfb32 = (unsigned char *) pFfb->sfb32; + dst = sfb32 + (y * (2048 << psz_shift)) + (x << psz_shift); + VISmoveImageLR(src, dst, w << psz_shift, h, + srcwidth, (2048 << psz_shift)); +} + +static void FFB_SetupForMono8x8PatternFill(ScrnInfoPtr pScrn, + int pat_word1, int pat_word2, + int fg, int bg, int rop, + unsigned int planemask) +{ + FFBPtr pFfb = GET_FFB_FROM_SCRN(pScrn); + ffb_fbcPtr ffb = pFfb->regs; + unsigned int ppc, ppc_mask, fbc; + int i; + + FFBLOG(("FFB_SetupForMono8x8PatternFill: " + "pat[%08x:%08x] fg[%x] bg[%x] rop[%d] pmask[%x]\n", + pat_word1, pat_word2, + fg, bg, rop, planemask)); + + ppc = FFB_PPC_ABE_DISABLE | FFB_PPC_APE_ENABLE | FFB_PPC_CS_CONST; + if (bg < 0) + ppc |= FFB_PPC_TBE_TRANSPARENT; + else + ppc |= FFB_PPC_TBE_OPAQUE; + ppc_mask = FFB_PPC_ABE_MASK | FFB_PPC_APE_MASK | + FFB_PPC_TBE_MASK | FFB_PPC_CS_MASK; + fbc = pFfb->xaa_fbc; + rop = (rop | FFB_ROP_EDIT_BIT) | (FFB_ROP_NEW << 8); + + FFB_ATTR_RAW(pFfb, ppc, ppc_mask, planemask, rop, + FFB_DRAWOP_RECTANGLE, fg, fbc, pFfb->xaa_wid); + if (bg >= 0) + FFB_WRITE_BG(pFfb, ffb, bg); + + FFBFifo(pFfb, 32); + for (i = 0; i < 32; i += 2) { + CARD32 val1, val2; + int shift = (24 - ((i % 4) * 8)); + + if ((i % 8) < 4) { + val1 = (pat_word1 >> shift) & 0xff; + val2 = (pat_word1 >> (shift + 8)) & 0xff; + } else { + val1 = (pat_word2 >> shift) & 0xff; + val2 = (pat_word2 >> (shift + 8)) & 0xff; + } + val1 |= (val1 << 8) | (val1 << 16) | (val1 << 24); + val2 |= (val2 << 8) | (val2 << 16) | (val2 << 24); + FFB_WRITE64(&ffb->pattern[i], val1, val2); + } + pFfb->rp_active = 1; +} + +static void FFB_SubsequentMono8x8PatternFillRect(ScrnInfoPtr pScrn, + int pat_word1, int pat_word2, + int x, int y, int w, int h) +{ + FFBPtr pFfb = GET_FFB_FROM_SCRN(pScrn); + ffb_fbcPtr ffb = pFfb->regs; + + FFBLOG(("FFB_SubsequentMono8x8PatternFillRect: " + "x[%d] y[%d] w[%d] h[%d]\n", x, y, w, h)); + + FFBFifo(pFfb, 4); + FFB_WRITE64(&ffb->by, y, x); + FFB_WRITE64_2(&ffb->bh, h, w); +} + +static void FFB_SetupForScanlineCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, + int fg, int bg, + int rop, + unsigned int planemask) +{ + FFBPtr pFfb = GET_FFB_FROM_SCRN(pScrn); + ffb_fbcPtr ffb = pFfb->regs; + unsigned int ppc, ppc_mask, fbc; + + FFBLOG(("FFB_SetupForScanlineCPUToScreenColorExpandFill: " + "fg[%x] bg[%x] rop[%d] pmask[%x]\n", + fg, bg, rop, planemask)); + + ppc = FFB_PPC_ABE_DISABLE | FFB_PPC_APE_DISABLE | FFB_PPC_CS_CONST; + if (bg < 0) + ppc |= FFB_PPC_TBE_TRANSPARENT; + else + ppc |= FFB_PPC_TBE_OPAQUE; + ppc_mask = FFB_PPC_ABE_MASK | FFB_PPC_APE_MASK | + FFB_PPC_TBE_MASK | FFB_PPC_CS_MASK; + fbc = pFfb->xaa_fbc; + rop = (rop | FFB_ROP_EDIT_BIT) | (FFB_ROP_NEW << 8); + + if ((pFfb->ppc_cache & ppc_mask) != ppc || + pFfb->fg_cache != fg || + pFfb->fbc_cache != fbc || + pFfb->rop_cache != rop || + pFfb->pmask_cache != planemask || + pFfb->fontinc_cache != ((0<<16) | 32) || + (bg >= 0 && pFfb->bg_cache != bg)) { + pFfb->ppc_cache &= ~ppc_mask; + pFfb->ppc_cache |= ppc; + pFfb->fg_cache = fg; + pFfb->fbc_cache = fbc; + pFfb->rop_cache = rop; + pFfb->pmask_cache = planemask; + pFfb->fontinc_cache = ((0<<16) | 32); + if (bg >= 0) + pFfb->bg_cache = bg; + FFBFifo(pFfb, (bg >= 0 ? 7 : 6)); + ffb->ppc = ppc; + ffb->fg = fg; + ffb->fbc = fbc; + ffb->rop = rop; + ffb->pmask = planemask; + ffb->fontinc = ((0 << 16) | 32); + if(bg >= 0) + ffb->bg = bg; + } + pFfb->rp_active = 1; +} + +static void FFB_SubsequentScanlineCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, + int x, int y, int w, int h, + int skipleft) +{ + FFBPtr pFfb = GET_FFB_FROM_SCRN(pScrn); + FFBLOG(("FFB_SubsequentCPUToScreenColorExpandFill: " + "x[%d] y[%d] w[%d] h[%d] skipleft[%d]\n", + x, y, w, h, skipleft)); + + pFfb->xaa_scanline_x = x; + pFfb->xaa_scanline_y = y; + pFfb->xaa_scanline_w = w; +} + +static void FFB_SubsequentColorExpandScanline(ScrnInfoPtr pScrn, int bufno) +{ + FFBPtr pFfb = GET_FFB_FROM_SCRN(pScrn); + ffb_fbcPtr ffb = pFfb->regs; + CARD32 *bits = (CARD32 *) pFfb->xaa_scanline_buffers[bufno]; + int w; + + FFBFifo(pFfb, 1); + ffb->fontxy = ((pFfb->xaa_scanline_y << 16) | pFfb->xaa_scanline_x); + + w = pFfb->xaa_scanline_w; + if (w >= 32) { + FFB_WRITE_FONTW(pFfb, ffb, 32); + FFBFifo(pFfb, (w / 32)); + do { + ffb->font = *bits++; + w -= 32; + } while (w >= 32); + } + if (w > 0) { + FFB_WRITE_FONTW(pFfb, ffb, w); + FFBFifo(pFfb, 1); + ffb->font = *bits++; + } + + pFfb->xaa_scanline_y++; +} + +static void FFB_SetupForDashedLine(ScrnInfoPtr pScrn, + int fg, int bg, int rop, + unsigned int planemask, + int length, unsigned char *pattern) +{ + FFBPtr pFfb = GET_FFB_FROM_SCRN(pScrn); + CARD32 *pat_ptr = (CARD32 *)pattern; + unsigned int ppc, ppc_mask, fbc; + + FFBLOG(("FFB_SetupForDashedLine: " + "fg[%x] bg[%x] rop[%d] pmask[%x] patlen[%d] pat[%x]\n", + fg, bg, rop, planemask, length, *pat_ptr)); + + pFfb->xaa_planemask = planemask; + pFfb->xaa_rop = rop; + pFfb->xaa_linepat = + (*pat_ptr << FFB_LPAT_PATTERN_SHIFT) | + (1 << FFB_LPAT_SCALEVAL_SHIFT) | + ((length & 0xf) << FFB_LPAT_PATLEN_SHIFT); + + fbc = pFfb->xaa_fbc; + ppc = FFB_PPC_ABE_DISABLE | FFB_PPC_APE_DISABLE | FFB_PPC_CS_CONST | FFB_PPC_XS_WID; + ppc_mask = FFB_PPC_ABE_MASK | FFB_PPC_APE_MASK | FFB_PPC_CS_MASK | FFB_PPC_XS_MASK; + + FFB_ATTR_RAW(pFfb, ppc, ppc_mask, planemask, + (FFB_ROP_EDIT_BIT | rop) | (FFB_ROP_NEW << 8), + FFB_DRAWOP_BRLINEOPEN, fg, fbc, pFfb->xaa_wid); + pFfb->rp_active = 1; +} + +static void FFB_SubsequentDashedTwoPointLine( ScrnInfoPtr pScrn, + int x1, int y1, + int x2, int y2, + int flags, int phase) +{ + FFBPtr pFfb = GET_FFB_FROM_SCRN(pScrn); + ffb_fbcPtr ffb = pFfb->regs; + unsigned int linepat = pFfb->xaa_linepat; + unsigned int drawop; + + FFBLOG(("FFB_SubsequentDashedTwoPointLine: " + "x1[%d] y1[%d] x2[%d] y2[%d] flgs[%x] phase[%d]\n", + x1, y2, x2, y2, flags, phase)); + + linepat |= (phase & 0xf) << FFB_LPAT_PATPTR_SHIFT; + + drawop = (flags & OMIT_LAST) ? + FFB_DRAWOP_BRLINEOPEN : FFB_DRAWOP_BRLINECAP; + FFB_WRITE_DRAWOP(pFfb, ffb, drawop); + + if (pFfb->has_brline_bug) { + FFBFifo(pFfb, 6); + ffb->ppc = 0; + } else + FFBFifo(pFfb, 5); + ffb->lpat = linepat; + FFB_WRITE64(&ffb->by, y1, x1); + FFB_WRITE64_2(&ffb->bh, y2, x2); +} + +static void FFB_SetupForSolidLine(ScrnInfoPtr pScrn, + int color, int rop, unsigned int planemask) +{ + FFBPtr pFfb = GET_FFB_FROM_SCRN(pScrn); + ffb_fbcPtr ffb = pFfb->regs; + unsigned int ppc, ppc_mask, fbc; + FFBLOG(("FFB_SetupForSolidLine: " + "color[%d] rop[%d] pmask[%x]\n", + color, rop, planemask)); + + pFfb->xaa_planemask = planemask; + pFfb->xaa_rop = rop; + + fbc = pFfb->xaa_fbc; + ppc = FFB_PPC_ABE_DISABLE | FFB_PPC_APE_DISABLE | FFB_PPC_CS_CONST | FFB_PPC_XS_WID; + ppc_mask = FFB_PPC_ABE_MASK | FFB_PPC_APE_MASK | FFB_PPC_CS_MASK | FFB_PPC_XS_MASK; + + FFB_ATTR_RAW(pFfb, ppc, ppc_mask, planemask, + (FFB_ROP_EDIT_BIT | rop) | (FFB_ROP_NEW << 8), + FFB_DRAWOP_BRLINEOPEN, color, fbc, pFfb->xaa_wid); + FFBFifo(pFfb, 1); + ffb->lpat = 0; + pFfb->rp_active = 1; +} + +static void FFB_SubsequentSolidTwoPointLine(ScrnInfoPtr pScrn, + int x1, int y1, + int x2, int y2, + int flags) +{ + FFBPtr pFfb = GET_FFB_FROM_SCRN(pScrn); + ffb_fbcPtr ffb = pFfb->regs; + int drawop; + + FFBLOG(("FFB_SubsequentSolidTwoPointLine: " + "x1[%d] y1[%d] x2[%d] y2[%d] flags[%d]\n", + x1, y1, x2, y2, flags)); + + drawop = (flags & OMIT_LAST) ? + FFB_DRAWOP_BRLINEOPEN : FFB_DRAWOP_BRLINECAP; + FFB_WRITE_DRAWOP(pFfb, ffb, drawop); + + if (pFfb->has_brline_bug) { + FFBFifo(pFfb, 5); + ffb->ppc = 0; + } else + FFBFifo(pFfb, 4); + FFB_WRITE64(&ffb->by, y1, x1); + FFB_WRITE64_2(&ffb->bh, y2, x2); +} + +void FFB_SetupForSolidFill(ScrnInfoPtr pScrn, + int color, int rop, unsigned int planemask) +{ + FFBPtr pFfb = GET_FFB_FROM_SCRN(pScrn); + unsigned int ppc, ppc_mask, fbc; + + FFBLOG(("FFB_SetupForSolidFill: " + "color[%d] rop[%d] pmask[%u]\n", + color, rop, planemask)); + + pFfb->xaa_planemask = planemask; + pFfb->xaa_rop = rop; + + fbc = pFfb->xaa_fbc; + if (pFfb->ffb_res == ffb_res_high) + fbc |= FFB_FBC_WB_B; + ppc = FFB_PPC_ABE_DISABLE | FFB_PPC_APE_DISABLE | FFB_PPC_CS_CONST | FFB_PPC_XS_WID; + ppc_mask = FFB_PPC_ABE_MASK | FFB_PPC_APE_MASK | FFB_PPC_CS_MASK | FFB_PPC_XS_MASK; + + FFB_ATTR_RAW(pFfb, ppc, ppc_mask, planemask, + (FFB_ROP_EDIT_BIT | rop) | (FFB_ROP_NEW << 8), + FFB_DRAWOP_RECTANGLE, color, fbc, pFfb->xaa_wid); + pFfb->rp_active = 1; +} + +void FFB_SubsequentSolidFillRect(ScrnInfoPtr pScrn, + int x, int y, + int w, int h) +{ + FFBPtr pFfb = GET_FFB_FROM_SCRN(pScrn); + ffb_fbcPtr ffb = pFfb->regs; + + FFBLOG(("FFB_SubsequentSolidFillRect: " + "x[%d] y[%d] w[%d] h[%d]\n", x, y, w, h)); + + FFBFifo(pFfb, 4); + FFB_WRITE64(&ffb->by, y, x); + FFB_WRITE64_2(&ffb->bh, h, w); +} + +static void FFB_ScreenToScreenBitBlt(ScrnInfoPtr pScrn, + int nbox, + DDXPointPtr pptSrc, + BoxPtr pbox, + int xdir, int ydir, + int rop, unsigned int planemask) +{ + FFBPtr pFfb = GET_FFB_FROM_SCRN(pScrn); + ffb_fbcPtr ffb = pFfb->regs; + int use_vscroll; + + FFBLOG(("FFB_ScreenToScreenBitBlt: " + "nbox[%d] xdir[%d] ydir[%d] rop[%d] pmask[%x]\n", + nbox, xdir, ydir, rop, planemask)); + + use_vscroll = 0; + if (!pFfb->disable_vscroll && + rop == GXcopy) { + int i; + + for (i = 0; i < nbox; i++) + if (pptSrc[i].x != pbox[i].x1 || + pptSrc[i].y == pbox[i].y1) + break; + if (i == nbox) { + /* If/When double buffer extension is re-enabled + * check buffers here. + */ + use_vscroll = 1; + } + } + if (use_vscroll) { + FFB_ATTR_VSCROLL_XAA(pFfb, planemask); + while (nbox--) { + FFBFifo(pFfb, 7); + ffb->drawop = FFB_DRAWOP_VSCROLL; + FFB_WRITE64(&ffb->by, pptSrc->y, pptSrc->x); + FFB_WRITE64_2(&ffb->dy, pbox->y1, pbox->x1); + FFB_WRITE64_3(&ffb->bh, (pbox->y2 - pbox->y1), + (pbox->x2 - pbox->x1)); + + pbox++; + pptSrc++; + } + pFfb->rp_active = 1; + SET_SYNC_FLAG(pFfb->pXAAInfo); + } else { + unsigned char *sfb32 = (unsigned char *) pFfb->sfb32; + int psz_shift = 2; + + FFB_ATTR_SFB_VAR_XAA(pFfb, planemask, rop); + if (pFfb->use_blkread_prefetch) { + unsigned int bit; + + if (xdir < 0) + bit = FFB_MER_EDRA; + else + bit = FFB_MER_EIRA; + FFBFifo(pFfb, 1); + ffb->mer = bit; + pFfb->rp_active = 1; + } + FFBWait(pFfb, ffb); + + while (nbox--) { + unsigned char *src, *dst; + int x1, y1, x2, y2; + int width, height; + int sdkind; + + x1 = pptSrc->x; + y1 = pptSrc->y; + x2 = pbox->x1; + y2 = pbox->y1; + width = (pbox->x2 - pbox->x1); + height = (pbox->y2 - pbox->y1); + + src = sfb32 + (y1 * (2048 << psz_shift)) + + (x1 << psz_shift); + dst = sfb32 + (y2 * (2048 << psz_shift)) + + (x2 << psz_shift); + sdkind = (2048 << psz_shift); + + if (ydir < 0) { + src += ((height - 1) * (2048 << psz_shift)); + dst += ((height - 1) * (2048 << psz_shift)); + sdkind = -sdkind; + } + width <<= psz_shift; + if (xdir < 0) + VISmoveImageRL(src, dst, width, height, + sdkind, sdkind); + else + VISmoveImageLR(src, dst, width, height, + sdkind, sdkind); + pbox++; + pptSrc++; + } + if (pFfb->use_blkread_prefetch) { + FFBFifo(pFfb, 1); + ffb->mer = FFB_MER_DRA; + pFfb->rp_active = 1; + FFBWait(pFfb, ffb); + } + } +} + +void FFB_SetupForScreenToScreenCopy(ScrnInfoPtr pScrn, + int xdir, int ydir, int rop, + unsigned int planemask, + int trans_color) +{ + FFBPtr pFfb = GET_FFB_FROM_SCRN(pScrn); + ffb_fbcPtr ffb = pFfb->regs; + FFBLOG(("FFB_SetupForScreenToScreenCopy: " + "xdir[%d] ydir[%d] rop[%d] pmask[%x] tcolor[%d]\n", + xdir, ydir, rop, planemask, trans_color)); + + pFfb->xaa_planemask = planemask; + pFfb->xaa_xdir = xdir; + pFfb->xaa_ydir = ydir; + pFfb->xaa_rop = rop; + FFB_ATTR_SFB_VAR_XAA(pFfb, planemask, rop); + FFBWait(pFfb, ffb); +} + +void FFB_SubsequentScreenToScreenCopy(ScrnInfoPtr pScrn, + int x1, int y1, + int x2, int y2, + int width, int height) +{ + FFBPtr pFfb = GET_FFB_FROM_SCRN(pScrn); + unsigned char *src, *dst, *sfb32; + int psz_shift = 2; + int sdkind; + + FFBLOG(("FFB_SubsequentScreenToScreenCopy: " + "x1[%d] y1[%d] x2[%d] y2[%u] w[%d] h[%d]\n", + x1, y1, x2, y2, width, height)); + + sfb32 = (unsigned char *) pFfb->sfb32; + src = sfb32 + (y1 * (2048 << psz_shift)) + (x1 << psz_shift); + dst = sfb32 + (y2 * (2048 << psz_shift)) + (x2 << psz_shift); + sdkind = (2048 << psz_shift); + + if (pFfb->xaa_ydir < 0) { + src += ((height - 1) * (2048 << psz_shift)); + dst += ((height - 1) * (2048 << psz_shift)); + sdkind = -sdkind; + } + + width <<= psz_shift; + if (pFfb->xaa_xdir < 0) + VISmoveImageRL(src, dst, width, height, sdkind, sdkind); + else + VISmoveImageLR(src, dst, width, height, sdkind, sdkind); +} + +static void FFB_Sync(ScrnInfoPtr pScrn) +{ + FFBPtr pFfb = GET_FFB_FROM_SCRN(pScrn); + ffb_fbcPtr ffb = pFfb->regs; + + FFB_ATTR_SFB_VAR_XAA(pFfb, 0xffffffff, GXcopy); + FFBWait(pFfb, ffb); } /* Multiplies and divides suck... */ @@ -771,36 +840,15 @@ } } -static Bool -CreatorPositionWindow(WindowPtr pWin, int x, int y) +Bool FFBAccelInit(ScreenPtr pScreen, FFBPtr pFfb) { - if (pWin->drawable.bitsPerPixel == 8) - return cfbPositionWindow(pWin, x, y); - else - return cfb32PositionWindow(pWin, x, y); -} - -extern Bool CreatorCreateGC (GCPtr pGC); - -#ifdef DEBUG_FFB -FILE *FDEBUG_FD = NULL; -#endif - -BSFuncRec CreatorBSFuncRec = { - CreatorSaveAreas, - CreatorRestoreAreas, - (BackingStoreSetClipmaskRgnProcPtr) 0, - (BackingStoreGetImagePixmapProcPtr) 0, - (BackingStoreGetSpansPixmapProcPtr) 0, -}; - -Bool FFBAccelInit (ScreenPtr pScreen, FFBPtr pFfb) -{ - ffb_fbcPtr ffb; + XAAInfoRecPtr infoRec; + ffb_fbcPtr ffb = pFfb->regs; if (serverGeneration != CreatorGeneration) { CreatorScreenPrivateIndex = AllocateScreenPrivateIndex (); - if (CreatorScreenPrivateIndex == -1) return FALSE; + if (CreatorScreenPrivateIndex == -1) + return FALSE; CreatorGCPrivateIndex = AllocateGCPrivateIndex (); CreatorWindowPrivateIndex = AllocateWindowPrivateIndex (); CreatorGeneration = serverGeneration; @@ -810,32 +858,132 @@ return FALSE; if (!AllocateWindowPrivate(pScreen, CreatorWindowPrivateIndex, 0)) return FALSE; + pScreen->devPrivates[CreatorScreenPrivateIndex].ptr = pFfb; - pFfb->fifo_cache = 0; - ffb = pFfb->regs; + pFfb->xaa_fbc = (FFB_FBC_WB_A | FFB_FBC_WM_COMBINED | FFB_FBC_RB_A | + FFB_FBC_WE_FORCEON | + FFB_FBC_SB_BOTH | + FFB_FBC_ZE_OFF | FFB_FBC_YE_OFF | + FFB_FBC_RGBE_MASK | + FFB_FBC_XE_ON); + pFfb->xaa_wid = FFBWidAlloc(pFfb, TrueColor, 0, TRUE); + if (pFfb->xaa_wid == (unsigned int) -1) + return FALSE; + + pFfb->pXAAInfo = infoRec = XAACreateInfoRec(); + if (!infoRec) { + FFBWidFree(pFfb, pFfb->xaa_wid); + return FALSE; + } - /* Replace various screen functions. */ - pScreen->CreateGC = CreatorCreateGC; - pScreen->CreateWindow = CreatorCreateWindow; - pScreen->DestroyWindow = CreatorDestroyWindow; - pScreen->PositionWindow = CreatorPositionWindow; - pScreen->ChangeWindowAttributes = CreatorChangeWindowAttributes; - pScreen->PaintWindowBackground = CreatorPaintWindow; - pScreen->PaintWindowBorder = CreatorPaintWindow; - pScreen->GetSpans = CreatorGetSpans; - pScreen->CopyWindow = CreatorCopyWindow; - pScreen->GetImage = CreatorGetImage; - pScreen->BackingStoreFuncs = CreatorBSFuncRec; + pFfb->xaa_scanline_buffers[0] = xalloc(2048 * 4); + if (!pFfb->xaa_scanline_buffers[0]) { + XAADestroyInfoRec(infoRec); + return FALSE; + } - /* cfb8_32wid took over this to init the WID plane, - * and with how our code works that is not necessary. - */ - pScreen->WindowExposures = miWindowExposures; + pFfb->xaa_scanline_buffers[1] = xalloc(2048 * 4); + if (!pFfb->xaa_scanline_buffers[1]) { + xfree(pFfb->xaa_scanline_buffers[0]); + XAADestroyInfoRec(infoRec); + return FALSE; + } + + infoRec->Sync = FFB_Sync; - /* Set FFB line-bias for clipping. */ + /* Use VIS and VSCROLL for screen to screen copies. */ + infoRec->ScreenToScreenCopyFlags = NO_TRANSPARENCY; + infoRec->SetupForScreenToScreenCopy = + FFB_SetupForScreenToScreenCopy; + infoRec->SubsequentScreenToScreenCopy = + FFB_SubsequentScreenToScreenCopy; + + /* In order to optimize VSCROLL and prefetching properly we + * have to use our own mid-layer routine. + */ + infoRec->ScreenToScreenBitBltFlags = NO_TRANSPARENCY; + infoRec->ScreenToScreenBitBlt = + FFB_ScreenToScreenBitBlt; + + infoRec->SolidFillFlags = 0; + infoRec->SetupForSolidFill = + FFB_SetupForSolidFill; + infoRec->SubsequentSolidFillRect = + FFB_SubsequentSolidFillRect; + + infoRec->SolidLineFlags = 0; + infoRec->SetupForSolidLine = + FFB_SetupForSolidLine; + infoRec->SubsequentSolidTwoPointLine = + FFB_SubsequentSolidTwoPointLine; miSetZeroLineBias(pScreen, OCTANT3 | OCTANT4 | OCTANT6 | OCTANT1); + infoRec->DashedLineFlags = (TRANSPARENCY_ONLY | + LINE_PATTERN_LSBFIRST_LSBJUSTIFIED); + infoRec->DashPatternMaxLength = 16; + infoRec->SetupForDashedLine = + FFB_SetupForDashedLine; + infoRec->SubsequentDashedTwoPointLine = + FFB_SubsequentDashedTwoPointLine; + + /* We cannot use the non-scanline color expansion mechanism on FFB + * for two reasons: + * + * 1) A render pass can only render 32-pixels wide on FFB, XAA expects + * that arbitrary widths are possible per render pass. + * + * 2) The FFB accelerator FIFO is only 100 or so words deep, and + * XAA gives no way to limit the number of words it writes into + * the ColorExpandBase register per rendering pass. + */ + infoRec->ScanlineColorExpandBuffers = pFfb->xaa_scanline_buffers; + infoRec->NumScanlineColorExpandBuffers = 2; + infoRec->ScanlineCPUToScreenColorExpandFillFlags = + CPU_TRANSFER_PAD_DWORD | + SCANLINE_PAD_DWORD | + CPU_TRANSFER_BASE_FIXED | + BIT_ORDER_IN_BYTE_LSBFIRST; + infoRec->SetupForScanlineCPUToScreenColorExpandFill = + FFB_SetupForScanlineCPUToScreenColorExpandFill; + infoRec->SubsequentScanlineCPUToScreenColorExpandFill = + FFB_SubsequentScanlineCPUToScreenColorExpandFill; + infoRec->SubsequentColorExpandScanline = + FFB_SubsequentColorExpandScanline; + + infoRec->Mono8x8PatternFillFlags = + HARDWARE_PATTERN_PROGRAMMED_BITS | + HARDWARE_PATTERN_SCREEN_ORIGIN | + BIT_ORDER_IN_BYTE_LSBFIRST; + infoRec->SetupForMono8x8PatternFill = + FFB_SetupForMono8x8PatternFill; + infoRec->SubsequentMono8x8PatternFillRect = + FFB_SubsequentMono8x8PatternFillRect; + + /* Use VIS for pixmap writes. */ + infoRec->WritePixmap = FFB_WritePixmap; + + /* RENDER optimizations. */ + infoRec->CPUToScreenAlphaTextureFlags = + XAA_RENDER_NO_TILE | + XAA_RENDER_NO_SRC_ALPHA; + infoRec->CPUToScreenAlphaTextureFormats = FFBAlphaTextureFormats; + infoRec->SetupForCPUToScreenAlphaTexture = + FFB_SetupForCPUToScreenAlphaTexture; + infoRec->SubsequentCPUToScreenAlphaTexture = + FFB_SubsequentCPUToScreenAlphaTexture; + + infoRec->CPUToScreenTextureFlags = + XAA_RENDER_NO_TILE | + XAA_RENDER_NO_SRC_ALPHA; + infoRec->CPUToScreenTextureFormats = FFBTextureFormats; + infoRec->SetupForCPUToScreenTexture = + FFB_SetupForCPUToScreenTexture; + infoRec->SubsequentCPUToScreenTexture = + FFB_SubsequentCPUToScreenTexture; + + pFfb->fifo_cache = 0; + FFB_DEBUG_init(); FDEBUG((FDEBUG_FD, "FFB: cfg0(%08x) cfg1(%08x) cfg2(%08x) cfg3(%08x) ppcfg(%08x)\n", @@ -904,26 +1052,31 @@ pFfb->ppc_cache = (FFB_PPC_FW_DISABLE | FFB_PPC_VCE_DISABLE | FFB_PPC_APE_DISABLE | FFB_PPC_CS_CONST | - FFB_PPC_XS_CONST | FFB_PPC_YS_CONST | FFB_PPC_ZS_CONST | + FFB_PPC_XS_WID | FFB_PPC_YS_CONST | FFB_PPC_ZS_CONST | FFB_PPC_DCE_DISABLE | FFB_PPC_ABE_DISABLE | FFB_PPC_TBE_OPAQUE); - + pFfb->wid_cache = pFfb->xaa_wid; pFfb->pmask_cache = ~0; - pFfb->rop_cache = (FFB_ROP_ZERO | (FFB_ROP_NEW << 8)); + pFfb->rop_cache = (FFB_ROP_NEW | (FFB_ROP_NEW << 8)); pFfb->drawop_cache = FFB_DRAWOP_RECTANGLE; pFfb->fg_cache = pFfb->bg_cache = 0; pFfb->fontw_cache = 32; pFfb->fontinc_cache = (1 << 16) | 0; - pFfb->fbc_cache = (FFB_FBC_WB_A | FFB_FBC_WM_COMBINED | - FFB_FBC_RB_A | FFB_FBC_SB_BOTH | FFB_FBC_XE_OFF | - FFB_FBC_ZE_OFF | FFB_FBC_YE_OFF | FFB_FBC_RGBE_MASK); + pFfb->fbc_cache = (FFB_FBC_WB_A | FFB_FBC_WM_COMBINED | FFB_FBC_RB_A | + FFB_FBC_WE_FORCEON | + FFB_FBC_SB_BOTH | + FFB_FBC_ZE_OFF | FFB_FBC_YE_OFF | + FFB_FBC_RGBE_OFF | + FFB_FBC_XE_ON); pFfb->laststipple = NULL; /* We will now clear the screen: we'll draw a rectangle covering all the * viewscreen, using a 'blackness' ROP. */ - FFBFifo(pFfb, 13); + FFBFifo(pFfb, 22); ffb->fbc = pFfb->fbc_cache; ffb->ppc = pFfb->ppc_cache; + ffb->wid = pFfb->wid_cache; + ffb->xpmask = 0xff; ffb->pmask = pFfb->pmask_cache; ffb->rop = pFfb->rop_cache; ffb->drawop = pFfb->drawop_cache; @@ -931,31 +1084,32 @@ ffb->bg = pFfb->bg_cache; ffb->fontw = pFfb->fontw_cache; ffb->fontinc = pFfb->fontinc_cache; + ffb->xclip = FFB_XCLIP_TEST_ALWAYS; + ffb->cmp = 0x80808080; + ffb->matchab = 0x80808080; + ffb->magnab = 0x80808080; + ffb->blendc = (FFB_BLENDC_FORCE_ONE | + FFB_BLENDC_DF_ONE_M_A | + FFB_BLENDC_SF_A); + ffb->blendc1 = 0; + ffb->blendc2 = 0; FFB_WRITE64(&ffb->by, 0, 0); FFB_WRITE64_2(&ffb->bh, pFfb->psdp->height, pFfb->psdp->width); pFfb->rp_active = 1; FFBWait(pFfb, ffb); - /* Fixup the FBC/PPC caches to deal with actually using - * a WID for every ROP. - */ - pFfb->fbc_cache = (FFB_FBC_WB_A | FFB_FBC_WM_COMBINED | - FFB_FBC_RB_A | FFB_FBC_SB_BOTH | FFB_FBC_XE_ON | - FFB_FBC_ZE_OFF | FFB_FBC_YE_OFF | FFB_FBC_RGBE_ON); - pFfb->ppc_cache &= ~FFB_PPC_XS_MASK; - pFfb->ppc_cache |= FFB_PPC_XS_WID; - pFfb->wid_cache = 0xff; - FFBFifo(pFfb, 8); - ffb->fbc = pFfb->fbc_cache; - ffb->ppc = FFB_PPC_XS_WID; - ffb->wid = pFfb->wid_cache; - ffb->xpmask = 0xff; - ffb->xclip = FFB_XCLIP_TEST_ALWAYS; - ffb->cmp = 0x80808080; - ffb->matchab = 0x80808080; - ffb->magnab = 0x80808080; + FFB_ATTR_SFB_VAR_XAA(pFfb, 0xffffffff, GXcopy); FFBWait(pFfb, ffb); + if (!XAAInit(pScreen, infoRec)) { + XAADestroyInfoRec(infoRec); + xfree(pFfb->xaa_scanline_buffers[0]); + xfree(pFfb->xaa_scanline_buffers[1]); + pFfb->pXAAInfo = NULL; + FFBWidFree(pFfb, pFfb->xaa_wid); + return FALSE; + } + /* Success */ return TRUE; } diff -ruN xc-old/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_bcopy.c xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_bcopy.c --- xc-old/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_bcopy.c 2004-04-23 21:48:16.000000000 +0200 +++ xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_bcopy.c 2004-11-16 14:01:46.706984752 +0100 @@ -382,7 +382,6 @@ if (use_prefetch) { FFBFifo(pFfb, 1); pFfb->regs->mer = FFB_MER_EDRA; - pFfb->regs->mer = FFB_MER_EIRA; pFfb->rp_active = 1; } VISmoveImageRL ((psrcBase + diff -ruN xc-old/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_dga.c xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_dga.c --- xc-old/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_dga.c 2004-04-23 21:48:16.000000000 +0200 +++ xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_dga.c 2004-11-16 14:01:46.706984752 +0100 @@ -35,30 +35,16 @@ #include "ffb_stip.h" #include "ffb_loops.h" -static Bool FFB_OpenFramebuffer(ScrnInfoPtr pScrn, char **name, unsigned char **mem, - int *size, int *offset, int *extra); -static void FFB_CloseFramebuffer(ScrnInfoPtr pScrn); -static Bool FFB_SetMode(ScrnInfoPtr pScrn, DGAModePtr pMode); -static void FFB_SetViewport(ScrnInfoPtr pScrn, int x, int y, int flags); -static int FFB_GetViewport(ScrnInfoPtr pScrn); -static void FFB_Flush(ScrnInfoPtr pScrn); - -/* Have to disable all this stuff for now until I figure out where - * we should get the WID values from... ho hum... -DaveM - */ -#if 0 -static void FFB_FillRect(ScrnInfoPtr pScrn, int x, int y, int w, int h, unsigned long color); - -#ifdef USE_VIS -static void FFB_BlitRect(ScrnInfoPtr pScrn, int srcx, int srcy, int w, int h, - int dstx, int dsty); -#else -#define FFB_BlitRect NULL -#endif -#else -#define FFB_FillRect NULL -#define FFB_BlitRect NULL -#endif +static Bool FFB_OpenFramebuffer(ScrnInfoPtr, char **, unsigned char **, + int *, int *, int *); +static void FFB_CloseFramebuffer(ScrnInfoPtr); +static Bool FFB_SetMode(ScrnInfoPtr, DGAModePtr); +static void FFB_SetViewport(ScrnInfoPtr, int, int, int); +static int FFB_GetViewport(ScrnInfoPtr); +static void FFB_Flush(ScrnInfoPtr); +static void FFB_FillRect(ScrnInfoPtr, int, int, int, int, unsigned long); +static void FFB_BlitRect(ScrnInfoPtr, int, int, int, int, + int, int); static DGAFunctionRec FFB_DGAFuncs = { FFB_OpenFramebuffer, @@ -93,10 +79,7 @@ /* Hmmm, what does concurrent access really mean? -DaveM */ mode->flags = (DGA_CONCURRENT_ACCESS | DGA_PIXMAP_AVAILABLE | DGA_FILL_RECT); - -#ifdef USE_VIS mode->flags |= DGA_BLIT_RECT; -#endif mode->imageWidth = 2048; mode->imageHeight = 2048; @@ -195,86 +178,31 @@ FFBWait(pFfb, ffb); } -#if 0 - -extern void CreatorFillBoxSolid (DrawablePtr pDrawable, int nBox, - BoxPtr pBox, unsigned long pixel); +extern void FFB_SetupForSolidFill(ScrnInfoPtr, int, int, unsigned int); +extern void FFB_SubsequentSolidFillRect(ScrnInfoPtr, int, int, int, int); static void FFB_FillRect(ScrnInfoPtr pScrn, int x, int y, int w, int h, unsigned long color) { - DrawableRec draw; - BoxRec box; - - draw.pScreen = pScrn->pScreen; - box.x1 = x; - box.y1 = y; - box.x2 = x + w; - box.y2 = y + h; + FFBPtr pFfb = GET_FFB_FROM_SCRN(pScrn); - CreatorFillBoxSolid(&draw, 1, &box, color); + FFB_SetupForSolidFill(pScrn, color, GXcopy, ~0); + FFB_SubsequentSolidFillRect(pScrn, x, y, w, h); + SET_SYNC_FLAG(pFfb->pXAAInfo); } -#ifdef USE_VIS -extern void VISmoveImageLR(unsigned char *, unsigned char *, long, long, long, long); -extern void VISmoveImageRL(unsigned char *, unsigned char *, long, long, long, long); +extern void FFB_SetupForScreenToScreenCopy(ScrnInfoPtr, int, int, int, + unsigned int, int); +extern void FFB_SubsequentScreenToScreenCopy(ScrnInfoPtr, int, int, + int, int, int, int); static void FFB_BlitRect(ScrnInfoPtr pScrn, int srcx, int srcy, int w, int h, int dstx, int dsty) { FFBPtr pFfb = GET_FFB_FROM_SCRN(pScrn); - ffb_fbcPtr ffb = pFfb->regs; - - if (!pFfb->disable_vscroll && - dstx == srcx && - dsty != dsty) { - FFB_WRITE_ATTRIBUTES_VSCROLL(pFfb, 0x00ffffff); - FFBFifo(pFfb, 7); - ffb->drawop = FFB_DRAWOP_VSCROLL; - FFB_WRITE64(&ffb->by, srcy, srcx); - FFB_WRITE64_2(&ffb->dy, dsty, dstx); - FFB_WRITE64_3(&ffb->bh, h, w); - pFfb->rp_active = 1; - } else { - unsigned char *base = (unsigned char *)pFfb->fb; - int use_prefetch = pFfb->use_blkread_prefetch; + int xdir = ((srcx < dstx) && (srcy == dsty)) ? -1 : 1; + int ydir = (srcy < dsty) ? -1 : 1; - FFB_WRITE_ATTRIBUTES_SFB_VAR(pFfb, 0x00ffffff, GXcopy); - FFBWait(pFfb, ffb); - if (use_prefetch) { - FFBFifo(pFfb, 1); - ffb->mer = FFB_MER_EIRA; - pFfb->rp_active = 1; - FFBWait(pFfb, ffb); - } - if (srcx < dstx) { - VISmoveImageRL((base + - ((srcy + h - 1) * (2048 * 4)) + - (srcx * (32 / 8))), - (base + - ((dsty + h - 1) * (2048 * 4)) + - (dstx * (32 / 8))), - (w * (32 / 8)), - h, - -(2048 * 4), - (2048 * 4)); - } else { - VISmoveImageLR((base + - ((srcy + h - 1) * (2048 * 4)) + - (srcx * (32 / 8))), - (base + - ((dsty + h - 1) * (2048 * 4)) + - (dstx * (32 / 8))), - (w * (32 / 8)), - h, - -(2048 * 4), - (2048 * 4)); - } - if (use_prefetch) { - FFBFifo(pFfb, 1); - ffb->mer = FFB_MER_DRA; - pFfb->rp_active = 1; - FFBWait(pFfb, pFfb->regs); - } - } + FFB_SetupForScreenToScreenCopy(pScrn, xdir, ydir, GXcopy, ~0, -1); + FFB_SubsequentScreenToScreenCopy(pScrn, srcx, srcy, dstx,dsty, w, h); + SET_SYNC_FLAG(pFfb->pXAAInfo); } -#endif - -#endif diff -ruN xc-old/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_driver.c xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_driver.c --- xc-old/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_driver.c 2004-04-23 21:48:16.000000000 +0200 +++ xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_driver.c 2004-11-16 14:01:46.707984600 +0100 @@ -29,12 +29,7 @@ #include "mipointer.h" #include "mibstore.h" #include "micmap.h" - -#define PSZ 8 -#include "cfb.h" -#undef PSZ -#include "cfb32.h" -#include "cfb8_32wid.h" +#include "fb.h" #include "xf86cmap.h" @@ -50,6 +45,7 @@ static void FFBLeaveVT(int scrnIndex, int flags); static Bool FFBCloseScreen(int scrnIndex, ScreenPtr pScreen); static Bool FFBSaveScreen(ScreenPtr pScreen, int mode); +static void FFBDPMSSet(ScrnInfoPtr pScrn, int mode, int flags); /* Required if the driver supports mode switching */ static Bool FFBSwitchMode(int scrnIndex, DisplayModePtr mode, int flags); @@ -416,12 +412,12 @@ return FALSE; } - if (xf86LoadSubModule(pScrn, "cfb32") == NULL) { + if (xf86LoadSubModule(pScrn, "fb") == NULL) { FFBFreeRec(pScrn); return FALSE; } - if (xf86LoadSubModule(pScrn, "cfb") == NULL) { + if (xf86LoadSubModule(pScrn, "xaa") == NULL) { FFBFreeRec(pScrn); return FALSE; } @@ -570,8 +566,6 @@ pFfb->has_z_buffer = 0; } if (sbits & (1 << 0)) { - ErrorF("Double-buffered.\n"); - /* This state really means to the driver that the double * buffers are available for hw accelerate Dbe. When the * FFB is in high-resolution mode, the buffers are combined @@ -581,86 +575,17 @@ if ((ffb->fbcfg0 & FFB_FBCFG0_RES_MASK) != FFB_FBCFG0_RES_HIGH) pFfb->has_double_buffer = 1; else - pFfb->has_double_buffer = 1; + pFfb->has_double_buffer = 0; } else { - ErrorF("Single-buffered.\n"); pFfb->has_double_buffer = 0; } + if (pFfb->has_double_buffer) + ErrorF("Double-buffered.\n"); + else + ErrorF("Single-buffered.\n"); } } -static unsigned long CreatorUnaccelGeneration = 0; -static int CreatorUnaccelWindowPrivateIndex; - -#define CreatorUnaccelGetWid(w) \ - ((w)->devPrivates[CreatorUnaccelWindowPrivateIndex].val) -#define CreatorUnaccelSetWid(w,wid) \ - (((w)->devPrivates[CreatorUnaccelWindowPrivateIndex].val) = (wid)) - -static unsigned int -CreatorWidGet(WindowPtr pWin) -{ - return CreatorUnaccelGetWid(pWin); -} - -static Bool -CreatorWidAlloc(WindowPtr pWin) -{ - ScreenPtr pScreen = pWin->drawable.pScreen; - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - FFBPtr pFfb = GET_FFB_FROM_SCRN(pScrn); - unsigned int wid; - int i, visual, visclass; - - visual = wVisual(pWin); - visclass = 0; - for (i = 0; i < pScreen->numVisuals; i++) { - if (pScreen->visuals[i].vid == visual) { - visclass = pScreen->visuals[i].class; - break; - } - } - - wid = FFBWidAlloc(pFfb, visclass, wColormap(pWin), TRUE); - if (wid == (unsigned int) -1) - return FALSE; - - CreatorUnaccelSetWid(pWin, wid); - - return TRUE; -} - -static void -CreatorWidFree(WindowPtr pWin) -{ - ScrnInfoPtr pScrn = xf86Screens[pWin->drawable.pScreen->myNum]; - FFBPtr pFfb = GET_FFB_FROM_SCRN(pScrn); - unsigned int wid = CreatorUnaccelGetWid(pWin); - - FFBWidFree(pFfb, wid); -} - -static cfb8_32WidOps CreatorUnaccelWidOps = { - CreatorWidGet, - CreatorWidAlloc, - CreatorWidFree, - NULL, - NULL -}; - -static Bool -CreatorUnaccelWidInit(ScreenPtr pScreen) -{ - if (serverGeneration != CreatorUnaccelGeneration) { - CreatorUnaccelWindowPrivateIndex = - AllocateWindowPrivateIndex(); - if (CreatorUnaccelWindowPrivateIndex == -1) - return FALSE; - } - - return TRUE; -} - /* Mandatory */ /* This gets called at the start of each server generation */ @@ -674,10 +599,6 @@ unsigned int afb_fem; VisualPtr visual; - /* Add in our Dbe hook. */ - if (!FFBDbePreInit(pScreen)) - return FALSE; - /* * First get the ScrnInfoRec */ @@ -797,11 +718,6 @@ /* Darken the screen for aesthetic reasons and set the viewport */ FFBSaveScreen(pScreen, SCREEN_SAVER_ON); - if (pFfb->NoAccel == TRUE) { - if (!CreatorUnaccelWidInit(pScreen)) - return FALSE; - } - /* * The next step is to setup the screen's visuals, and initialise the * framebuffer code. In cases where the framebuffer's default @@ -817,14 +733,14 @@ miClearVisualTypes(); /* Setup the visuals we support. */ - if (!miSetVisualTypes(24, TrueColorMask | DirectColorMask, + if (!miSetVisualTypes(24, TrueColorMask, pScrn->rgbBits, TrueColor)) return FALSE; - if (!miSetVisualTypes(8, PseudoColorMask | GrayScaleMask | StaticGrayMask, - pScrn->rgbBits, PseudoColor)) - return FALSE; -#ifdef XF86DRI + if (!miSetPixmapDepths()) + return FALSE; + +#if 0 /*def XF86DRI*/ if (pFfb->ffb_type != afb_m3 && pFfb->ffb_type != afb_m6 && pFfb->NoAccel == FALSE) { pFfb->dri_enabled = FFBDRIScreenInit(pScreen); @@ -843,30 +759,14 @@ * Call the framebuffer layer's ScreenInit function, and fill in other * pScreen fields. */ - if (pFfb->NoAccel == TRUE) { - ret = cfb8_32WidScreenInit(pScreen, pFfb->dfb24, pFfb->dfb8r, pFfb->dfb8x, - pScrn->virtualX, pScrn->virtualY, - pScrn->xDpi, pScrn->yDpi, - 2048, 2048, 2048, 8, - &CreatorUnaccelWidOps); - } else { - /* Use smart framebuffer aperture for cfb8/cfb32. */ - ret = cfb8_32WidScreenInit(pScreen, pFfb->sfb32, pFfb->sfb8r, pFfb->dfb8x, - pScrn->virtualX, pScrn->virtualY, - pScrn->xDpi, pScrn->yDpi, - 2048, 2048, 2048, 8, - &CreatorUnaccelWidOps); - } + ret = fbScreenInit(pScreen, (pFfb->NoAccel ? pFfb->dfb24 : pFfb->sfb32), + pScrn->virtualX, pScrn->virtualY, + pScrn->xDpi, pScrn->yDpi, + 2048, 32); if (!ret) return FALSE; - miInitializeBackingStore(pScreen); - xf86SetBackingStore(pScreen); - xf86SetSilkenMouse(pScreen); - - xf86SetBlackWhitePixels(pScreen); - if (pScrn->bitsPerPixel > 8) { /* Fixup RGB ordering */ visual = pScreen->visuals + pScreen->numVisuals; @@ -882,12 +782,24 @@ } } + if (!fbPictureInit(pScreen, NULL, 0) && + (serverGeneration == 1)) + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, + "RENDER extension initialisation failed.\n"); + + xf86SetBlackWhitePixels(pScreen); + if (!pFfb->NoAccel) { if (!FFBAccelInit(pScreen, pFfb)) return FALSE; xf86Msg(X_INFO, "%s: Using acceleration\n", pFfb->psdp->device); } + + miInitializeBackingStore(pScreen); + xf86SetBackingStore(pScreen); + xf86SetSilkenMouse(pScreen); + /* Initialise cursor functions */ miDCInitialize (pScreen, xf86GetPointerScreenFuncs()); @@ -912,9 +824,6 @@ */ if (!xf86HandleColormaps(pScreen, 256, 8, FFBDacLoadPalette, NULL, -#if 0 - CMAP_PALETTED_TRUECOLOR | -#endif CMAP_LOAD_EVEN_IF_OFFSCREEN | CMAP_RELOAD_ON_MODE_SWITCH)) return FALSE; @@ -923,9 +832,9 @@ if (!pFfb->NoAccel) FFB_InitDGA(pScreen); -#ifdef XF86DRI +#if 0 /*def XF86DRI*/ if (pFfb->dri_enabled) { - /* Now that mi, cfb, drm and others have done their thing, + /* Now that mi, fb, drm and others have done their thing, * complete the DRI setup. */ pFfb->dri_enabled = FFBDRIFinishScreenInit(pScreen); @@ -938,6 +847,8 @@ } #endif + xf86DPMSInit(pScreen, FFBDPMSSet, 0); + pFfb->CloseScreen = pScreen->CloseScreen; pScreen->CloseScreen = FFBCloseScreen; pScreen->SaveScreen = FFBSaveScreen; @@ -1034,34 +945,34 @@ static Bool FFBCloseScreen(int scrnIndex, ScreenPtr pScreen) { - ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; - FFBPtr pFfb = GET_FFB_FROM_SCRN(pScrn); + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + FFBPtr pFfb = GET_FFB_FROM_SCRN(pScrn); -#ifdef XF86DRI - if (pFfb->dri_enabled) - FFBDRICloseScreen(pScreen); +#if 0 /*def XF86DRI*/ + if (pFfb->dri_enabled) + FFBDRICloseScreen(pScreen); #endif - /* Restore kernel ramdac state before we unmap registers. */ - FFBDacFini(pFfb); + /* Restore kernel ramdac state before we unmap registers. */ + FFBDacFini(pFfb); - pScrn->vtSema = FALSE; + pScrn->vtSema = FALSE; - xf86UnmapSbusMem(pFfb->psdp, pFfb->dfb24, 0x1000000); - xf86UnmapSbusMem(pFfb->psdp, pFfb->dfb8r, 0x400000); - xf86UnmapSbusMem(pFfb->psdp, pFfb->dfb8x, 0x400000); - xf86UnmapSbusMem(pFfb->psdp, pFfb->sfb32, 0x1000000); - xf86UnmapSbusMem(pFfb->psdp, pFfb->sfb8r, 0x400000); - xf86UnmapSbusMem(pFfb->psdp, pFfb->sfb8x, 0x400000); - xf86UnmapSbusMem(pFfb->psdp, pFfb->regs, 16384); - xf86UnmapSbusMem(pFfb->psdp, pFfb->dac, 8192); - xf86UnmapSbusMem(pFfb->psdp, (void *)pFfb->strapping_bits, 8192); + xf86UnmapSbusMem(pFfb->psdp, pFfb->dfb24, 0x1000000); + xf86UnmapSbusMem(pFfb->psdp, pFfb->dfb8r, 0x400000); + xf86UnmapSbusMem(pFfb->psdp, pFfb->dfb8x, 0x400000); + xf86UnmapSbusMem(pFfb->psdp, pFfb->sfb32, 0x1000000); + xf86UnmapSbusMem(pFfb->psdp, pFfb->sfb8r, 0x400000); + xf86UnmapSbusMem(pFfb->psdp, pFfb->sfb8x, 0x400000); + xf86UnmapSbusMem(pFfb->psdp, pFfb->regs, 16384); + xf86UnmapSbusMem(pFfb->psdp, pFfb->dac, 8192); + xf86UnmapSbusMem(pFfb->psdp, (void *)pFfb->strapping_bits, 8192); - if (pFfb->HWCursor) - xf86SbusHideOsHwCursor (pFfb->psdp); + if (pFfb->HWCursor) + xf86SbusHideOsHwCursor (pFfb->psdp); - pScreen->CloseScreen = pFfb->CloseScreen; - return (*pScreen->CloseScreen)(scrnIndex, pScreen); + pScreen->CloseScreen = pFfb->CloseScreen; + return (*pScreen->CloseScreen)(scrnIndex, pScreen); } @@ -1071,7 +982,7 @@ static void FFBFreeScreen(int scrnIndex, int flags) { - FFBFreeRec(xf86Screens[scrnIndex]); + FFBFreeRec(xf86Screens[scrnIndex]); } @@ -1081,10 +992,10 @@ static ModeStatus FFBValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags) { - if (mode->Flags & V_INTERLACE) - return(MODE_BAD); + if (mode->Flags & V_INTERLACE) + return MODE_BAD; - return(MODE_OK); + return MODE_OK; } /* Do screen blanking */ @@ -1102,6 +1013,14 @@ return FFBDacSaveScreen(GET_FFB_FROM_SCREEN(pScreen), mode); } +static void +FFBDPMSSet(ScrnInfoPtr pScrn, int mode, int flags) +{ + FFBPtr pFfb = GET_FFB_FROM_SCRN(pScrn); + + FFBDacDPMSMode(pFfb, mode, 0); +} + /* * This is the implementation of the Sync() function. */ diff -ruN xc-old/programs/Xserver/hw/xfree86/drivers/sunffb/ffb.h xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb.h --- xc-old/programs/Xserver/hw/xfree86/drivers/sunffb/ffb.h 2004-04-23 21:48:16.000000000 +0200 +++ xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb.h 2004-11-16 14:01:46.702985360 +0100 @@ -33,6 +33,7 @@ #include "xf86_OSproc.h" #include "xf86_ansic.h" #include "xf86RamDac.h" +#include "xaa.h" #include "Xmd.h" #include "gcstruct.h" #include "windowstr.h" @@ -188,6 +189,19 @@ unsigned char has_z_buffer; unsigned char has_double_buffer; + /* XAA related info */ + XAAInfoRecPtr pXAAInfo; + unsigned int xaa_fbc; + unsigned int xaa_wid; + unsigned int xaa_planemask; + unsigned int xaa_linepat; + int xaa_xdir, xaa_ydir, xaa_rop; + unsigned char *xaa_scanline_buffers[2]; + int xaa_scanline_x, xaa_scanline_y, xaa_scanline_w; + unsigned char *xaa_tex; + int xaa_tex_pitch, xaa_tex_width, xaa_tex_height; + unsigned int xaa_tex_color; + enum ffb_resolution ffb_res; BoxRec ClippedBoxBuf[64]; xRectangle Pf_Fixups[4]; diff -ruN xc-old/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_rcache.h xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_rcache.h --- xc-old/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_rcache.h 2004-04-23 21:48:17.000000000 +0200 +++ xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_rcache.h 2004-11-16 14:01:46.708984448 +0100 @@ -41,13 +41,13 @@ * a nice idea... */ #define FFB_WRITE_PPC(__fpriv, __ffb, __val, __chg_mask) \ -do { unsigned int oldval = (__fpriv)->ppc_cache; \ +do { unsigned int __oldval = (__fpriv)->ppc_cache; \ unsigned int __t; \ - __t = (oldval & (__chg_mask)) ^ (__val); \ + __t = (__oldval & (__chg_mask)) ^ (__val); \ if (__t) { \ - unsigned int newval = oldval & ~(__chg_mask); \ - newval |= (__val); \ - (__fpriv)->ppc_cache = newval; \ + unsigned int __newval = __oldval & ~(__chg_mask); \ + __newval |= (__val); \ + (__fpriv)->ppc_cache = __newval; \ FFBFifo((__fpriv), 1); \ (__ffb)->ppc = (__val); \ } \ @@ -178,22 +178,22 @@ #define FFB_ATTR_FFWIN(__fpriv, __pwin, __ppc, __pixel) \ do { CreatorPrivWinPtr __winpriv = CreatorGetWindowPrivate(__pwin); \ unsigned int ___ppc = (__ppc) | FFB_PPC_XS_WID; \ - unsigned int fbc = (__winpriv)->fbc_base; \ - unsigned int rop = (FFB_ROP_NEW|(FFB_ROP_NEW<<8)); \ + unsigned int __fbc = (__winpriv)->fbc_base; \ + unsigned int __rop = (FFB_ROP_NEW|(FFB_ROP_NEW<<8)); \ if((__fpriv)->has_double_buffer) { \ - fbc &= ~FFB_FBC_WB_MASK; \ - fbc |= FFB_FBC_WB_AB; \ + __fbc &= ~FFB_FBC_WB_MASK; \ + __fbc |= FFB_FBC_WB_AB; \ } \ - fbc &= ~(FFB_FBC_XE_MASK | FFB_FBC_RGBE_MASK); \ - fbc |= FFB_FBC_XE_ON | FFB_FBC_RGBE_ON; \ + __fbc &= ~(FFB_FBC_XE_MASK | FFB_FBC_RGBE_MASK); \ + __fbc |= FFB_FBC_XE_ON | FFB_FBC_RGBE_ON; \ if (pFfb->ffb_res == ffb_res_high) \ - fbc |= FFB_FBC_WB_B; \ + __fbc |= FFB_FBC_WB_B; \ if ((((__fpriv)->ppc_cache & FFB_PPC_WINMASK) != (___ppc))|| \ ((__fpriv)->pmask_cache != 0x00ffffff) || \ - ((__fpriv)->rop_cache!= rop) || \ + ((__fpriv)->rop_cache!= __rop) || \ ((__fpriv)->drawop_cache != FFB_DRAWOP_FASTFILL) || \ ((__fpriv)->fg_cache != (__pixel)) || \ - ((__fpriv)->fbc_cache != fbc) || \ + ((__fpriv)->fbc_cache != __fbc) || \ ((__fpriv)->wid_cache != ((__winpriv)->wid))) \ __FFB_Attr_FastfillWin(__fpriv, __pwin, ___ppc, __pixel);\ } while (0) @@ -215,29 +215,29 @@ FFB_FBC_ZE_OFF | FFB_FBC_YE_OFF | FFB_FBC_RGBE_ON) #define FFB_ATTR_SFB_VAR_WINCOPY(__fpriv) \ -do { unsigned int ppc = FFB_PPC_WINCOPY; \ - unsigned int ppc_mask = FFB_PPC_WINCOPY_MASK; \ - unsigned int rop = FFB_ROP_NEW|(FFB_ROP_NEW<<8); \ - unsigned int fbc = FFB_FBC_WINCOPY; \ +do { unsigned int __ppc = FFB_PPC_WINCOPY; \ + unsigned int __ppc_mask = FFB_PPC_WINCOPY_MASK; \ + unsigned int __rop = FFB_ROP_NEW|(FFB_ROP_NEW<<8); \ + unsigned int __fbc = FFB_FBC_WINCOPY; \ if((__fpriv)->has_double_buffer) { \ - fbc &= ~FFB_FBC_WB_MASK; \ - fbc |= FFB_FBC_WB_AB; \ + __fbc &= ~FFB_FBC_WB_MASK; \ + __fbc |= FFB_FBC_WB_AB; \ } \ - if (((__fpriv)->ppc_cache & ppc_mask) != ppc || \ - (__fpriv)->fbc_cache != fbc || \ - (__fpriv)->rop_cache != rop || \ + if (((__fpriv)->ppc_cache & __ppc_mask) != __ppc || \ + (__fpriv)->fbc_cache != __fbc || \ + (__fpriv)->rop_cache != __rop || \ (__fpriv)->pmask_cache != 0xffffffff) { \ ffb_fbcPtr __ffb = (__fpriv)->regs; \ - (__fpriv)->ppc_cache &= ~ppc_mask; \ - (__fpriv)->ppc_cache |= ppc; \ - (__fpriv)->fbc_cache = fbc; \ - (__fpriv)->rop_cache = rop; \ + (__fpriv)->ppc_cache &= ~__ppc_mask; \ + (__fpriv)->ppc_cache |= __ppc; \ + (__fpriv)->fbc_cache = __fbc; \ + (__fpriv)->rop_cache = __rop; \ (__fpriv)->pmask_cache = 0xffffffff; \ (__fpriv)->rp_active = 1; \ FFBFifo(__fpriv, 4); \ - (__ffb)->ppc = ppc; \ - (__ffb)->fbc = fbc; \ - (__ffb)->rop = rop; \ + (__ffb)->ppc = __ppc; \ + (__ffb)->fbc = __fbc; \ + (__ffb)->rop = __rop; \ (__ffb)->pmask = 0xffffffff; \ (__fpriv)->rp_active = 1; \ } \ @@ -247,21 +247,21 @@ unsigned int wid, unsigned int rop, unsigned int pmask); #define FFB_ATTR_SFB_VAR_WIN(__fpriv, __pmask, __alu, __pwin) \ -do { unsigned int ppc = FFB_PPC_APE_DISABLE | FFB_PPC_CS_VAR | FFB_PPC_XS_WID; \ - unsigned int ppc_mask = FFB_PPC_APE_MASK | FFB_PPC_CS_MASK | FFB_PPC_XS_MASK; \ - unsigned int rop = (FFB_ROP_EDIT_BIT | (__alu))|(FFB_ROP_NEW<<8); \ - unsigned int fbc = FFB_FBC_WIN(__pwin); \ +do { unsigned int __ppc = FFB_PPC_APE_DISABLE | FFB_PPC_CS_VAR | FFB_PPC_XS_WID; \ + unsigned int __ppc_mask = FFB_PPC_APE_MASK | FFB_PPC_CS_MASK | FFB_PPC_XS_MASK; \ + unsigned int __rop = (FFB_ROP_EDIT_BIT | (__alu))|(FFB_ROP_NEW<<8); \ + unsigned int __fbc = FFB_FBC_WIN(__pwin); \ if((__fpriv)->has_double_buffer) { \ - fbc &= ~FFB_FBC_WB_MASK; \ - fbc |= FFB_FBC_WB_AB; \ + __fbc &= ~FFB_FBC_WB_MASK; \ + __fbc |= FFB_FBC_WB_AB; \ } \ - if(((__fpriv)->ppc_cache & ppc_mask) != ppc || \ - (__fpriv)->fbc_cache != fbc || \ + if(((__fpriv)->ppc_cache & __ppc_mask) != __ppc || \ + (__fpriv)->fbc_cache != __fbc || \ (__fpriv)->wid_cache != FFB_WID_WIN(__pwin) || \ - (__fpriv)->rop_cache != rop || \ + (__fpriv)->rop_cache != __rop || \ (__fpriv)->pmask_cache != (__pmask)) \ - __FFB_Attr_SFB_VAR(__fpriv, ppc, ppc_mask, fbc, \ - FFB_WID_WIN(__pwin), rop, (__pmask)); \ + __FFB_Attr_SFB_VAR(__fpriv, __ppc, __ppc_mask, __fbc, \ + FFB_WID_WIN(__pwin), __rop, (__pmask)); \ } while(0) /* VSCROLL Attributes: @@ -277,25 +277,25 @@ * PMASK) all options allowed */ #define FFB_ATTR_VSCROLL_WINCOPY(__fpriv) \ -do { unsigned int rop = (FFB_ROP_OLD | (FFB_ROP_OLD << 8)); \ - unsigned int fbc = FFB_FBC_WINCOPY; \ +do { unsigned int __rop = (FFB_ROP_OLD | (FFB_ROP_OLD << 8)); \ + unsigned int __fbc = FFB_FBC_WINCOPY; \ if((__fpriv)->has_double_buffer) { \ - fbc &= ~FFB_FBC_WB_MASK; \ - fbc |= FFB_FBC_WB_AB; \ + __fbc &= ~FFB_FBC_WB_MASK; \ + __fbc |= FFB_FBC_WB_AB; \ } \ - if((__fpriv)->fbc_cache != fbc || \ - (__fpriv)->rop_cache != rop || \ + if((__fpriv)->fbc_cache != __fbc || \ + (__fpriv)->rop_cache != __rop || \ (__fpriv)->pmask_cache != 0xffffffff || \ (__fpriv)->drawop_cache != FFB_DRAWOP_VSCROLL) { \ ffb_fbcPtr __ffb = (__fpriv)->regs; \ - (__fpriv)->fbc_cache = fbc; \ - (__fpriv)->rop_cache = rop; \ + (__fpriv)->fbc_cache = __fbc; \ + (__fpriv)->rop_cache = __rop; \ (__fpriv)->pmask_cache = 0xffffffff; \ (__fpriv)->drawop_cache = FFB_DRAWOP_VSCROLL; \ (__fpriv)->rp_active = 1; \ FFBFifo(__fpriv, 4); \ - (__ffb)->fbc = fbc; \ - (__ffb)->rop = rop; \ + (__ffb)->fbc = __fbc; \ + (__ffb)->rop = __rop; \ (__ffb)->pmask = 0xffffffff; \ (__ffb)->drawop = FFB_DRAWOP_VSCROLL; \ (__fpriv)->rp_active = 1; \ @@ -303,25 +303,25 @@ } while(0) #define FFB_ATTR_VSCROLL_WIN(__fpriv, __pmask, __pwin) \ -do { unsigned int rop = (FFB_ROP_OLD | (FFB_ROP_OLD << 8)); \ - unsigned int fbc = FFB_FBC_WIN(__pwin); \ +do { unsigned int __rop = (FFB_ROP_OLD | (FFB_ROP_OLD << 8)); \ + unsigned int __fbc = FFB_FBC_WIN(__pwin); \ if((__fpriv)->has_double_buffer) { \ - fbc &= ~FFB_FBC_WB_MASK; \ - fbc |= FFB_FBC_WB_AB; \ + __fbc &= ~FFB_FBC_WB_MASK; \ + __fbc |= FFB_FBC_WB_AB; \ } \ - if((__fpriv)->fbc_cache != fbc || \ - (__fpriv)->rop_cache != rop || \ + if((__fpriv)->fbc_cache != __fbc || \ + (__fpriv)->rop_cache != __rop || \ (__fpriv)->pmask_cache != (__pmask) || \ (__fpriv)->drawop_cache != FFB_DRAWOP_VSCROLL) { \ ffb_fbcPtr __ffb = (__fpriv)->regs; \ - (__fpriv)->fbc_cache = fbc; \ - (__fpriv)->rop_cache = rop; \ + (__fpriv)->fbc_cache = __fbc; \ + (__fpriv)->rop_cache = __rop; \ (__fpriv)->pmask_cache = (__pmask); \ (__fpriv)->drawop_cache = FFB_DRAWOP_VSCROLL; \ (__fpriv)->rp_active = 1; \ FFBFifo(__fpriv, 4); \ - (__ffb)->fbc = fbc; \ - (__ffb)->rop = rop; \ + (__ffb)->fbc = __fbc; \ + (__ffb)->rop = __rop; \ (__ffb)->pmask = (__pmask); \ (__ffb)->drawop = FFB_DRAWOP_VSCROLL; \ } \ diff -ruN xc-old/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_regs.h xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_regs.h --- xc-old/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_regs.h 2004-04-23 21:48:17.000000000 +0200 +++ xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_regs.h 2004-11-16 14:01:46.708984448 +0100 @@ -432,6 +432,19 @@ #define FFB_MER_EDRA 0x000000c0 /* Enable read-ahead, decreasing */ #define FFB_MER_DRA 0x00000040 /* No read-ahead */ +/* Alpha Blend Control */ +#define FFB_BLENDC_FORCE_ONE 0x00000010 /* Defines 0xff as 1.0 */ +#define FFB_BLENDC_DF_MASK 0x0000000c /* Destination Frac Mask */ +#define FFB_BLENDC_DF_ZERO 0x00000000 /* Destination Frac: 0.00 */ +#define FFB_BLENDC_DF_ONE 0x00000004 /* Destination Frac: 1.00 */ +#define FFB_BLENDC_DF_ONE_M_A 0x00000008 /* Destination Frac: 1.00 - Xsrc */ +#define FFB_BLENDC_DF_A 0x0000000c /* Destination Frac: Xsrc */ +#define FFB_BLENDC_SF_MASK 0x00000003 /* Source Frac Mask */ +#define FFB_BLENDC_SF_ZERO 0x00000000 /* Source Frac: 0.00 */ +#define FFB_BLENDC_SF_ONE 0x00000001 /* Source Frac: 1.00 */ +#define FFB_BLENDC_SF_ONE_M_A 0x00000002 /* Source Frac: 1.00 - Xsrc */ +#define FFB_BLENDC_SF_A 0x00000003 /* Source Frac: Xsrc */ + /* FBram Config 0 */ #define FFB_FBCFG0_RFTIME 0xff800000 #define FFB_FBCFG0_XMAX 0x007c0000 diff -ruN xc-old/programs/Xserver/hw/xfree86/drivers/sunffb/Imakefile xc/programs/Xserver/hw/xfree86/drivers/sunffb/Imakefile --- xc-old/programs/Xserver/hw/xfree86/drivers/sunffb/Imakefile 2004-06-16 11:44:00.000000000 +0200 +++ xc/programs/Xserver/hw/xfree86/drivers/sunffb/Imakefile 2004-11-16 14:01:46.700985664 +0100 @@ -78,11 +78,13 @@ INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86OSSRC) \ -I$(SERVERSRC)/mfb -I$(SERVERSRC)/mi \ -I$(SERVERSRC)/Xext -I$(SERVERSRC)/cfb \ - -I$(SERVERSRC)/dbe \ + -I$(SERVERSRC)/dbe -I$(SERVERSRC)/fb \ + -I$(SERVERSRC)/render \ -I$(XF86SRC)/xf8_32wid \ -I$(XF86SRC)/ramdac \ -I$(XF86SRC)/ddc \ -I$(XF86SRC)/i2c \ + -I$(XF86SRC)/xaa \ -I$(FONTINCSRC) -I$(SERVERSRC)/include -I$(XINCLUDESRC) \ -I$(EXTINCSRC) \ $(DRIINCLUDES)