Module Name: xsrc Committed By: macallan Date: Sat Dec 10 01:57:54 UTC 2016
Modified Files: xsrc/external/mit/xf86-video-glint/dist/src: glint.h glint_driver.c pm2_accel.c pm2_common.c Added Files: xsrc/external/mit/xf86-video-glint/dist/src: pm2_exa.c Log Message: add crude but working EXA support for Permedia 2 To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 xsrc/external/mit/xf86-video-glint/dist/src/glint.h cvs rdiff -u -r1.9 -r1.10 \ xsrc/external/mit/xf86-video-glint/dist/src/glint_driver.c cvs rdiff -u -r1.4 -r1.5 \ xsrc/external/mit/xf86-video-glint/dist/src/pm2_accel.c cvs rdiff -u -r1.1 -r1.2 \ xsrc/external/mit/xf86-video-glint/dist/src/pm2_common.c cvs rdiff -u -r0 -r1.1 xsrc/external/mit/xf86-video-glint/dist/src/pm2_exa.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: xsrc/external/mit/xf86-video-glint/dist/src/glint.h diff -u xsrc/external/mit/xf86-video-glint/dist/src/glint.h:1.2 xsrc/external/mit/xf86-video-glint/dist/src/glint.h:1.3 --- xsrc/external/mit/xf86-video-glint/dist/src/glint.h:1.2 Fri Dec 2 22:58:26 2016 +++ xsrc/external/mit/xf86-video-glint/dist/src/glint.h Sat Dec 10 01:57:54 2016 @@ -224,9 +224,11 @@ void Permedia2Save(ScrnInfoPtr pScrn, GL Bool Permedia2Init(ScrnInfoPtr pScrn, DisplayModePtr mode); void Permedia2PreInit(ScrnInfoPtr pScrn); Bool Permedia2AccelInit(ScreenPtr pScreen); +Bool Pm2InitEXA(ScreenPtr pScreen); void Permedia2Sync(ScrnInfoPtr pScrn); void Permedia2InitializeEngine(ScrnInfoPtr pScrn); Bool Permedia2HWCursorInit(ScreenPtr pScreen); +void Permedia2LoadCoord(ScrnInfoPtr, int, int, int, int); void PermediaRestore(ScrnInfoPtr pScrn, GLINTRegPtr glintReg); void PermediaSave(ScrnInfoPtr pScrn, GLINTRegPtr glintReg); Index: xsrc/external/mit/xf86-video-glint/dist/src/glint_driver.c diff -u xsrc/external/mit/xf86-video-glint/dist/src/glint_driver.c:1.9 xsrc/external/mit/xf86-video-glint/dist/src/glint_driver.c:1.10 --- xsrc/external/mit/xf86-video-glint/dist/src/glint_driver.c:1.9 Thu Dec 8 18:09:39 2016 +++ xsrc/external/mit/xf86-video-glint/dist/src/glint_driver.c Sat Dec 10 01:57:54 2016 @@ -2112,7 +2112,12 @@ GLINTPreInit(ScrnInfoPtr pScrn, int flag case PCI_VENDOR_3DLABS_CHIP_PERMEDIA2V: case PCI_VENDOR_TI_CHIP_PERMEDIA: case PCI_VENDOR_3DLABS_CHIP_PERMEDIA: - pGlint->pprod = partprodPermedia[pScrn->displayWidth >> 5]; + pScrn->displayWidth = (pScrn->displayWidth + 31) & ~31; + pGlint->pprod = -1; + while ((pGlint->pprod == -1) && (pScrn->displayWidth < 2048)) { + pScrn->displayWidth += 32; + pGlint->pprod = partprodPermedia[pScrn->displayWidth >> 5]; + } pGlint->bppalign = bppand[(pScrn->bitsPerPixel>>3)-1]; break; case PCI_VENDOR_3DLABS_CHIP_500TX: @@ -2896,7 +2901,11 @@ GLINTScreenInit(SCREEN_INIT_ARGS_DECL) case PCI_VENDOR_TI_CHIP_PERMEDIA2: case PCI_VENDOR_3DLABS_CHIP_PERMEDIA2: case PCI_VENDOR_3DLABS_CHIP_PERMEDIA2V: +#ifdef HAVE_XAA_H Permedia2AccelInit(pScreen); +#else + Pm2InitEXA(pScreen); +#endif break; case PCI_VENDOR_3DLABS_CHIP_PERMEDIA3: case PCI_VENDOR_3DLABS_CHIP_PERMEDIA4: Index: xsrc/external/mit/xf86-video-glint/dist/src/pm2_accel.c diff -u xsrc/external/mit/xf86-video-glint/dist/src/pm2_accel.c:1.4 xsrc/external/mit/xf86-video-glint/dist/src/pm2_accel.c:1.5 --- xsrc/external/mit/xf86-video-glint/dist/src/pm2_accel.c:1.4 Sun Dec 4 10:58:12 2016 +++ xsrc/external/mit/xf86-video-glint/dist/src/pm2_accel.c Sat Dec 10 01:57:54 2016 @@ -129,7 +129,6 @@ static void Permedia2SubsequentScanlineC ScrnInfoPtr pScrn, int x, int y, int w, int h, int skipleft); static void Permedia2SubsequentColorExpandScanline(ScrnInfoPtr pScrn, int bufno); -static void Permedia2LoadCoord(ScrnInfoPtr pScrn, int x, int y, int w, int h); static void Permedia2PolylinesThinSolidWrapper(DrawablePtr pDraw, GCPtr pGC, int mode, int npt, DDXPointPtr pPts); static void Permedia2PolySegmentThinSolidWrapper(DrawablePtr pDraw, GCPtr pGC, @@ -276,25 +275,6 @@ Permedia2AccelInit(ScreenPtr pScreen) } #ifdef HAVE_XAA_H -static void Permedia2LoadCoord( - ScrnInfoPtr pScrn, - int x, int y, - int w, int h -){ - GLINTPtr pGlint = GLINTPTR(pScrn); - - if ((h != pGlint->h) || (w != pGlint->w)) { - pGlint->w = w; - pGlint->h = h; - GLINT_WRITE_REG(((h&0x0FFF)<<16)|(w&0x0FFF), RectangleSize); - } - if ((y != pGlint->y) || (x != pGlint->x)) { - pGlint->x = x; - pGlint->y = y; - GLINT_WRITE_REG(((y&0x0FFF)<<16)|(x&0x0FFF), RectangleOrigin); - } -} - static void Permedia2SetClippingRectangle(ScrnInfoPtr pScrn, int x1, int y1, int x2, int y2) Index: xsrc/external/mit/xf86-video-glint/dist/src/pm2_common.c diff -u xsrc/external/mit/xf86-video-glint/dist/src/pm2_common.c:1.1 xsrc/external/mit/xf86-video-glint/dist/src/pm2_common.c:1.2 --- xsrc/external/mit/xf86-video-glint/dist/src/pm2_common.c:1.1 Sat Dec 3 06:38:29 2016 +++ xsrc/external/mit/xf86-video-glint/dist/src/pm2_common.c Sat Dec 10 01:57:54 2016 @@ -172,3 +172,23 @@ Permedia2Sync(ScrnInfoPtr pScrn) } while (GLINT_READ_REG(OutputFIFO) != Sync_tag); } +void +Permedia2LoadCoord( + ScrnInfoPtr pScrn, + int x, int y, + int w, int h +){ + GLINTPtr pGlint = GLINTPTR(pScrn); + + if ((h != pGlint->h) || (w != pGlint->w)) { + pGlint->w = w; + pGlint->h = h; + GLINT_WRITE_REG(((h&0x0FFF)<<16)|(w&0x0FFF), RectangleSize); + } + if ((y != pGlint->y) || (x != pGlint->x)) { + pGlint->x = x; + pGlint->y = y; + GLINT_WRITE_REG(((y&0x0FFF)<<16)|(x&0x0FFF), RectangleOrigin); + } +} + Added files: Index: xsrc/external/mit/xf86-video-glint/dist/src/pm2_exa.c diff -u /dev/null xsrc/external/mit/xf86-video-glint/dist/src/pm2_exa.c:1.1 --- /dev/null Sat Dec 10 01:57:54 2016 +++ xsrc/external/mit/xf86-video-glint/dist/src/pm2_exa.c Sat Dec 10 01:57:54 2016 @@ -0,0 +1,318 @@ +/* + * Copyright 1997-2001 by Alan Hourihane, Wigan, England. + * Copyright 2016 by Michael Lorenz + * + * 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 Alan Hourihane not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Alan Hourihane makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + * Authors: Alan Hourihane, <al...@fairlite.demon.co.uk> + * Dirk Hohndel, <hohn...@suse.de> + * Stefan Dirsch, <sndir...@suse.de> + * Mark Vojkovich, <mvojk...@ucsd.edu> + * Michel Dänzer, <michd...@iiic.ethz.ch> + * + * this work is sponsored by S.u.S.E. GmbH, Fuerth, Elsa GmbH, Aachen and + * Siemens Nixdorf Informationssysteme + * + * Permedia 2 accelerated options, EXA style. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <X11/Xarch.h> +#include "xf86.h" +#include "xf86_OSproc.h" + +#include "xf86Pci.h" + +#include "glint_regs.h" +#include "glint.h" + +//#define PM2_DEBUG + +#ifdef PM2_DEBUG +#define STATIC static +#define ENTER xf86Msg(X_ERROR, "%s>\n", __func__); +#define DPRINTF xf86Msg +#else +#define ENTER +#define STATIC +#define DPRINTF while (0) xf86Msg +#endif + +STATIC void +Pm2WaitMarker(ScreenPtr pScreen, int Marker) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + + Permedia2Sync(pScrn); +} + +STATIC Bool +Pm2PrepareCopy(PixmapPtr pSrcPixmap, PixmapPtr pDstPixmap, + int xdir, int ydir, int rop, Pixel planemask) +{ + ScrnInfoPtr pScrn = xf86Screens[pDstPixmap->drawable.pScreen->myNum]; + GLINTPtr pGlint = GLINTPTR(pScrn); + + ENTER; + + pGlint->BltScanDirection = 0; + if (xdir == 1) pGlint->BltScanDirection |= XPositive; + if (ydir == 1) pGlint->BltScanDirection |= YPositive; + + GLINT_WAIT(4); + DO_PLANEMASK(planemask); + + GLINT_WRITE_REG(UNIT_DISABLE, ColorDDAMode); + if ((rop == GXset) || (rop == GXclear)) { + pGlint->FrameBufferReadMode = pGlint->pprod; + } else + if ((rop == GXcopy) || (rop == GXcopyInverted)) { + pGlint->FrameBufferReadMode = pGlint->pprod |FBRM_SrcEnable; + } else { + pGlint->FrameBufferReadMode = pGlint->pprod | FBRM_SrcEnable | + FBRM_DstEnable; + } + LOADROP(rop); + pGlint->srcoff = exaGetPixmapOffset(pSrcPixmap); + return TRUE; +} + +STATIC void +Pm2Copy(PixmapPtr pDstPixmap, + int srcX, int srcY, int dstX, int dstY, int w, int h) +{ + ScrnInfoPtr pScrn = xf86Screens[pDstPixmap->drawable.pScreen->myNum]; + GLINTPtr pGlint = GLINTPTR(pScrn); + int align; + int dstoff = exaGetPixmapOffset(pDstPixmap); + int pitch = exaGetPixmapPitch(pDstPixmap); + + ENTER; + + /* assuming constant pitch for now */ + srcY += pGlint->srcoff / pitch; + dstY += dstoff / pitch; + + /* We can only use GXcopy for Packed modes */ + if ((pGlint->ROP != GXcopy) || (pScrn->bitsPerPixel != 8)) { + GLINT_WAIT(5); + GLINT_WRITE_REG(pGlint->FrameBufferReadMode, FBReadMode); + Permedia2LoadCoord(pScrn, dstX, dstY, w, h); + GLINT_WRITE_REG(((srcY - dstY) & 0x0FFF) << 16 | + ((srcX - dstX) & 0x0FFF), FBSourceDelta); + } else { + align = (dstX & pGlint->bppalign) - (srcX & pGlint->bppalign); + GLINT_WAIT(6); + GLINT_WRITE_REG(pGlint->FrameBufferReadMode|FBRM_Packed, FBReadMode); + Permedia2LoadCoord(pScrn, dstX >> pGlint->BppShift, dstY, + (w + 7) >> pGlint->BppShift, h); + GLINT_WRITE_REG(align << 29 | dstX << 16 | (dstX + w), PackedDataLimits); + GLINT_WRITE_REG(((srcX - dstX) & 0x0FFF) << 16 | + (((srcX & ~pGlint->bppalign) - (dstX & ~pGlint->bppalign)) & 0x0FFF), + FBSourceDelta); + } + GLINT_WRITE_REG(PrimitiveRectangle | pGlint->BltScanDirection, Render); + + exaMarkSync(pDstPixmap->drawable.pScreen); +} + +STATIC void +Pm2DoneCopy(PixmapPtr pPixmap) +{ + ScrnInfoPtr pScrn = xf86Screens[pPixmap->drawable.pScreen->myNum]; + GLINTPtr pGlint = GLINTPTR(pScrn); + + GLINT_WRITE_REG(0, ScissorMinXY); + GLINT_WRITE_REG(0x0fff0fff, ScissorMaxXY); +} + +STATIC Bool +Pm2PrepareSolid(PixmapPtr pPixmap, int rop, Pixel planemask, Pixel color) +{ + ScrnInfoPtr pScrn = xf86Screens[pPixmap->drawable.pScreen->myNum]; + GLINTPtr pGlint = GLINTPTR(pScrn); + + ENTER; + + REPLICATE(color); + + GLINT_WAIT(6); + DO_PLANEMASK(planemask); + if (rop == GXcopy) { + GLINT_WRITE_REG(UNIT_DISABLE, ColorDDAMode); + GLINT_WRITE_REG(pGlint->pprod, FBReadMode); + GLINT_WRITE_REG(color, FBBlockColor); + } else { + GLINT_WRITE_REG(UNIT_ENABLE, ColorDDAMode); + GLINT_WRITE_REG(color, ConstantColor); + /* We can use Packed mode for filling solid non-GXcopy rasters */ + GLINT_WRITE_REG(pGlint->pprod|FBRM_DstEnable|FBRM_Packed, FBReadMode); + } + LOADROP(rop); + + return TRUE; +} + +STATIC void +Pm2Solid(PixmapPtr pPixmap, int x1, int y1, int x2, int y2) +{ + ScrnInfoPtr pScrn = xf86Screens[pPixmap->drawable.pScreen->myNum]; + GLINTPtr pGlint = GLINTPTR(pScrn); + int offset = exaGetPixmapOffset(pPixmap); + int pitch = exaGetPixmapPitch(pPixmap); + int w = x2 - x1, h = y2 - y1; + int speed = 0; + + ENTER; + + y1 += offset / pitch; + if (pGlint->ROP == GXcopy) { + GLINT_WAIT(3); + Permedia2LoadCoord(pScrn, x1, y1, w, h); + speed = FastFillEnable; + } else { + GLINT_WAIT(4); + Permedia2LoadCoord(pScrn, x1 >> pGlint->BppShift, y1, + (w + 7) >> pGlint->BppShift, h); + GLINT_WRITE_REG(x1 << 16 | (x1 + w), PackedDataLimits); + speed = 0; + } + GLINT_WRITE_REG(PrimitiveRectangle | XPositive | YPositive | speed, Render); + + exaMarkSync(pPixmap->drawable.pScreen); +} + +/* + * Memcpy-based UTS. + */ +STATIC Bool +Pm2UploadToScreen(PixmapPtr pDst, int x, int y, int w, int h, + char *src, int src_pitch) +{ + ScrnInfoPtr pScrn = xf86Screens[pDst->drawable.pScreen->myNum]; + GLINTPtr pGlint = GLINTPTR(pScrn); + char *dst = pGlint->FbBase + exaGetPixmapOffset(pDst); + int dst_pitch = exaGetPixmapPitch(pDst); + + int bpp = pDst->drawable.bitsPerPixel; + int cpp = (bpp + 7) >> 3; + int wBytes = w * cpp; + + ENTER; + dst += (x * cpp) + (y * dst_pitch); + + Permedia3Sync(pScrn); + + while (h--) { + memcpy(dst, src, wBytes); + src += src_pitch; + dst += dst_pitch; + } + return TRUE; +} + +/* + * Memcpy-based DFS. + */ +STATIC Bool +Pm2DownloadFromScreen(PixmapPtr pSrc, int x, int y, int w, int h, + char *dst, int dst_pitch) +{ + ScrnInfoPtr pScrn = xf86Screens[pSrc->drawable.pScreen->myNum]; + GLINTPtr pGlint = GLINTPTR(pScrn); + char *src = pGlint->FbBase + exaGetPixmapOffset(pSrc); + int src_pitch = exaGetPixmapPitch(pSrc); + + ENTER; + int bpp = pSrc->drawable.bitsPerPixel; + int cpp = (bpp + 7) >> 3; + int wBytes = w * cpp; + + src += (x * cpp) + (y * src_pitch); + + Permedia3Sync(pScrn); + + while (h--) { + memcpy(dst, src, wBytes); + src += src_pitch; + dst += dst_pitch; + } + + return TRUE; +} + +Bool +Pm2InitEXA(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + GLINTPtr pGlint = GLINTPTR(pScrn); + ExaDriverPtr pExa; + int stride; + + ENTER; + + pExa = exaDriverAlloc(); + if (!pExa) + return FALSE; + + pGlint->pExa = pExa; + + pExa->exa_major = EXA_VERSION_MAJOR; + pExa->exa_minor = EXA_VERSION_MINOR; + + pExa->memoryBase = pGlint->FbBase; + stride = pScrn->displayWidth * (pScrn->bitsPerPixel >> 3); + pExa->memorySize = min(pGlint->FbMapSize, 2047 * stride); + DPRINTF(X_ERROR, "stride: %d\n", stride); + DPRINTF(X_ERROR, "pprod: %08x\n", pGlint->pprod); + pExa->offScreenBase = stride * pScrn->virtualY; + + /* for now, until I figure out how to do variable stride */ + pExa->pixmapOffsetAlign = stride; + pExa->pixmapPitchAlign = stride; + + pExa->flags = EXA_OFFSCREEN_PIXMAPS + /* | EXA_SUPPORTS_OFFSCREEN_OVERLAPS |*/ + | EXA_MIXED_PIXMAPS; + + pExa->maxX = 2047; + pExa->maxY = 2047; + + pExa->WaitMarker = Pm2WaitMarker; + + pExa->PrepareSolid = Pm2PrepareSolid; + pExa->Solid = Pm2Solid; + pExa->DoneSolid = Pm2DoneCopy; + pExa->PrepareCopy = Pm2PrepareCopy; + pExa->Copy = Pm2Copy; + pExa->DoneCopy = Pm2DoneCopy; + + /* EXA hits more optimized paths when it does not have to fallback + * because of missing UTS/DFS, hook memcpy-based UTS/DFS. + */ + pExa->UploadToScreen = Pm2UploadToScreen; + pExa->DownloadFromScreen = Pm2DownloadFromScreen; + + Permedia2InitializeEngine(pScrn); + + return exaDriverInit(pScreen, pExa); +}