Module Name:    xsrc
Committed By:   macallan
Date:           Wed Nov 25 18:01:30 UTC 2015

Modified Files:
        xsrc/external/mit/xf86-video-suncg6/dist/src: cg6.h cg6_accel.c
            cg6_driver.c
Added Files:
        xsrc/external/mit/xf86-video-suncg6/dist/src: cg6_exa.c

Log Message:
support EXA


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 xsrc/external/mit/xf86-video-suncg6/dist/src/cg6.h \
    xsrc/external/mit/xf86-video-suncg6/dist/src/cg6_accel.c
cvs rdiff -u -r1.8 -r1.9 \
    xsrc/external/mit/xf86-video-suncg6/dist/src/cg6_driver.c
cvs rdiff -u -r0 -r1.1 xsrc/external/mit/xf86-video-suncg6/dist/src/cg6_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-suncg6/dist/src/cg6.h
diff -u xsrc/external/mit/xf86-video-suncg6/dist/src/cg6.h:1.3 xsrc/external/mit/xf86-video-suncg6/dist/src/cg6.h:1.4
--- xsrc/external/mit/xf86-video-suncg6/dist/src/cg6.h:1.3	Tue Jun  4 22:20:41 2013
+++ xsrc/external/mit/xf86-video-suncg6/dist/src/cg6.h	Wed Nov 25 18:01:29 2015
@@ -32,6 +32,7 @@
 #include "cg6_regs.h"
 #include "xf86sbusBus.h"
 #include "xaa.h"
+#include "exa.h"
 
 /* Various offsets in virtual (ie. mmap()) spaces Linux and Solaris support. */
 #define CG6_FBC_VOFF	0x70000000
@@ -68,6 +69,7 @@ typedef struct {
 	sbusDevicePtr	psdp;
 	Bool		HWCursor;
 	Bool		NoAccel;
+	Bool		useXAA;
 	CloseScreenProcPtr CloseScreen;
 	xf86CursorInfoPtr CursorInfoRec;
 	unsigned int	CursorXY;
@@ -80,6 +82,8 @@ typedef struct {
         int             words_in_scanline, scan_x, scan_y, scan_xe;
         int             clipxa, clipxe;
         XAAInfoRecPtr   pXAA;
+	ExaDriverPtr	pExa;
+	int		srcoff, fg;
 } Cg6Rec, *Cg6Ptr;
 
 extern int  Cg6ScreenPrivateIndex;
@@ -103,6 +107,7 @@ extern int  Cg6WindowPrivateIndex;
 extern int cg6RopTable[];
 
 int CG6AccelInit(ScrnInfoPtr);
-Bool Cg6DGAInit(ScreenPtr pScreen);
+Bool Cg6DGAInit(ScreenPtr);
+int CG6EXAInit(ScreenPtr);
 
 #endif /* CG6_H */
Index: xsrc/external/mit/xf86-video-suncg6/dist/src/cg6_accel.c
diff -u xsrc/external/mit/xf86-video-suncg6/dist/src/cg6_accel.c:1.3 xsrc/external/mit/xf86-video-suncg6/dist/src/cg6_accel.c:1.4
--- xsrc/external/mit/xf86-video-suncg6/dist/src/cg6_accel.c:1.3	Wed Jul 18 00:06:14 2012
+++ xsrc/external/mit/xf86-video-suncg6/dist/src/cg6_accel.c	Wed Nov 25 18:01:29 2015
@@ -166,7 +166,7 @@ unClip(Cg6Ptr pCg6)
     pCg6->fbc->clipmaxx = pCg6->clipxe;
 }
 
-static void
+void
 Cg6InitEngine(Cg6Ptr pCg6)
 {
     pCg6->clipxa = 0;

Index: xsrc/external/mit/xf86-video-suncg6/dist/src/cg6_driver.c
diff -u xsrc/external/mit/xf86-video-suncg6/dist/src/cg6_driver.c:1.8 xsrc/external/mit/xf86-video-suncg6/dist/src/cg6_driver.c:1.9
--- xsrc/external/mit/xf86-video-suncg6/dist/src/cg6_driver.c:1.8	Tue Jun  4 22:20:41 2013
+++ xsrc/external/mit/xf86-video-suncg6/dist/src/cg6_driver.c	Wed Nov 25 18:01:29 2015
@@ -93,13 +93,15 @@ _X_EXPORT DriverRec SUNCG6 = {
 typedef enum {
     OPTION_SW_CURSOR,
     OPTION_HW_CURSOR,
-    OPTION_NOACCEL
+    OPTION_NOACCEL,
+    OPTION_ACCELMETHOD
 } CG6Opts;
 
 static const OptionInfoRec CG6Options[] = {
     { OPTION_SW_CURSOR,		"SWcursor",	OPTV_BOOLEAN,	{0}, FALSE },
     { OPTION_HW_CURSOR,		"HWcursor",	OPTV_BOOLEAN,	{0}, FALSE },
     { OPTION_NOACCEL,		"NoAccel",	OPTV_BOOLEAN,	{0}, FALSE },
+    { OPTION_ACCELMETHOD,	"AccelMethod",	OPTV_STRING,	{0}, FALSE },
     { -1,			NULL,		OPTV_NONE,	{0}, FALSE }
 };
 
@@ -404,7 +406,14 @@ CG6PreInit(ScrnInfoPtr pScrn, int flags)
 	pCg6->NoAccel = TRUE;
 	xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Acceleration disabled\n");
     }
-        
+    pCg6->useXAA = FALSE;
+
+    char *optstr;
+    optstr = (char *)xf86GetOptValString(pCg6->Options, OPTION_ACCELMETHOD);
+    if (optstr == NULL) optstr = "exa";
+    if (xf86NameCmp(optstr, "xaa") == 0)
+        pCg6->useXAA = TRUE;
+
     if (xf86LoadSubModule(pScrn, "fb") == NULL) {
 	CG6FreeRec(pScrn);
 	return FALSE;
@@ -415,11 +424,6 @@ CG6PreInit(ScrnInfoPtr pScrn, int flags)
 	return FALSE;
     }
 
-    if (pCg6->HWCursor && xf86LoadSubModule(pScrn, "xaa") == NULL) {
-        CG6FreeRec(pScrn);
-        return FALSE;
-    }
-
     /*********************
     set up clock and mode stuff
     *********************/
@@ -562,17 +566,37 @@ CG6ScreenInit(SCREEN_INIT_ARGS_DECL)
     xf86SetBlackWhitePixels(pScreen);
 
     if (!pCg6->NoAccel) {
-        BoxRec bx;
-        pCg6->pXAA=XAACreateInfoRec();
-        CG6AccelInit(pScrn);
-        bx.x1=bx.y1=0;
-        bx.x2=pCg6->width;
-        bx.y2=pCg6->maxheight;
-        xf86InitFBManager(pScreen,&bx);
-        if(!XAAInit(pScreen, pCg6->pXAA))
-            return FALSE;
+    	if (pCg6->useXAA) {
+	    BoxRec bx;
+	    if (!xf86LoadSubModule(pScrn, "xaa"))
+	    	return FALSE;
+	    pCg6->pXAA=XAACreateInfoRec();
+	    CG6AccelInit(pScrn);
+	    bx.x1=bx.y1=0;
+	    bx.x2=pCg6->width;
+	    bx.y2=pCg6->maxheight;
+	    xf86InitFBManager(pScreen,&bx);
+	    if(!XAAInit(pScreen, pCg6->pXAA))
+		return FALSE;
 
-        xf86Msg(X_INFO, "%s: Using acceleration\n", pCg6->psdp->device);
+	    xf86Msg(X_INFO, "%s: Using XAA acceleration\n", pCg6->psdp->device);
+	} else {
+	    /* EXA */
+	    XF86ModReqInfo req;
+	    int errmaj, errmin;
+
+	    memset(&req, 0, sizeof(XF86ModReqInfo));
+	    req.majorversion = EXA_VERSION_MAJOR;
+	    req.minorversion = EXA_VERSION_MINOR;
+	    if (!LoadSubModule(pScrn->module, "exa", NULL, NULL, NULL, &req,
+		&errmaj, &errmin)) {
+		LoaderErrorMsg(NULL, "exa", errmaj, errmin);
+		return FALSE;
+	    }
+	    if (!CG6EXAInit(pScreen))
+		return FALSE;
+	    xf86Msg(X_INFO, "%s: Using EXA acceleration\n", pCg6->psdp->device);
+	}
     }
 
     /* setup DGA */

Added files:

Index: xsrc/external/mit/xf86-video-suncg6/dist/src/cg6_exa.c
diff -u /dev/null xsrc/external/mit/xf86-video-suncg6/dist/src/cg6_exa.c:1.1
--- /dev/null	Wed Nov 25 18:01:30 2015
+++ xsrc/external/mit/xf86-video-suncg6/dist/src/cg6_exa.c	Wed Nov 25 18:01:29 2015
@@ -0,0 +1,305 @@
+/*
+ * Sun GX and Turbo GX EXA support
+ *
+ * Copyright (C) 2015 Michael Lorenz
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * MICHAEL LORENZ BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/suncg6/cg6_accel.c $ */
+
+#include "cg6.h"
+#include "cg6_regs.h"
+
+
+static CARD32 Cg6BlitROP[] = {
+    ROP_BLIT(GX_ROP_CLEAR,  GX_ROP_CLEAR),	/* GXclear */
+    ROP_BLIT(GX_ROP_CLEAR,  GX_ROP_NOOP),	/* GXand */
+    ROP_BLIT(GX_ROP_CLEAR,  GX_ROP_INVERT),	/* GXandReverse */
+    ROP_BLIT(GX_ROP_CLEAR,  GX_ROP_SET),	/* GXcopy */
+    ROP_BLIT(GX_ROP_NOOP,   GX_ROP_CLEAR),	/* GXandInverted */
+    ROP_BLIT(GX_ROP_NOOP,   GX_ROP_NOOP),	/* GXnoop */
+    ROP_BLIT(GX_ROP_NOOP,   GX_ROP_INVERT),	/* GXxor */
+    ROP_BLIT(GX_ROP_NOOP,   GX_ROP_SET),	/* GXor */
+    ROP_BLIT(GX_ROP_INVERT, GX_ROP_CLEAR),	/* GXnor */
+    ROP_BLIT(GX_ROP_INVERT, GX_ROP_NOOP),	/* GXequiv */
+    ROP_BLIT(GX_ROP_INVERT, GX_ROP_INVERT),	/* GXinvert */
+    ROP_BLIT(GX_ROP_INVERT, GX_ROP_SET),	/* GXorReverse */
+    ROP_BLIT(GX_ROP_SET,    GX_ROP_CLEAR),	/* GXcopyInverted */
+    ROP_BLIT(GX_ROP_SET,    GX_ROP_NOOP),	/* GXorInverted */
+    ROP_BLIT(GX_ROP_SET,    GX_ROP_INVERT),	/* GXnand */
+    ROP_BLIT(GX_ROP_SET,    GX_ROP_SET),	/* GXset */
+};
+
+static CARD32 Cg6DrawROP[] = {
+    ROP_FILL(GX_ROP_CLEAR,  GX_ROP_CLEAR),	/* GXclear */
+    ROP_FILL(GX_ROP_CLEAR,  GX_ROP_NOOP),	/* GXand */
+    ROP_FILL(GX_ROP_CLEAR,  GX_ROP_INVERT),	/* GXandReverse */
+    ROP_FILL(GX_ROP_CLEAR,  GX_ROP_SET),	/* GXcopy */
+    ROP_FILL(GX_ROP_NOOP,   GX_ROP_CLEAR),	/* GXandInverted */
+    ROP_FILL(GX_ROP_NOOP,   GX_ROP_NOOP),	/* GXnoop */
+    ROP_FILL(GX_ROP_NOOP,   GX_ROP_INVERT),	/* GXxor */
+    ROP_FILL(GX_ROP_NOOP,   GX_ROP_SET),	/* GXor */
+    ROP_FILL(GX_ROP_INVERT, GX_ROP_CLEAR),	/* GXnor */
+    ROP_FILL(GX_ROP_INVERT, GX_ROP_NOOP),	/* GXequiv */
+    ROP_FILL(GX_ROP_INVERT, GX_ROP_INVERT),	/* GXinvert */
+    ROP_FILL(GX_ROP_INVERT, GX_ROP_SET),	/* GXorReverse */
+    ROP_FILL(GX_ROP_SET,    GX_ROP_CLEAR),	/* GXcopyInverted */
+    ROP_FILL(GX_ROP_SET,    GX_ROP_NOOP),	/* GXorInverted */
+    ROP_FILL(GX_ROP_SET,    GX_ROP_INVERT),	/* GXnand */
+    ROP_FILL(GX_ROP_SET,    GX_ROP_SET),	/* GXset */
+};
+
+#define runDraw(pCg6) { volatile CARD32 rubbish = pCg6->fbc->draw; }
+#define runBlit(pCg6) { volatile CARD32 rubbish = pCg6->fbc->blit; }
+
+/*
+ * XXX
+ * was GX_FULL, which apparently isn't enough on some (slower) CG6 like
+ * the one found on the SPARCstation LX mainboard
+ */
+#define waitReady(pCg6) while(pCg6->fbc->s & GX_INPROGRESS)
+
+void Cg6InitEngine(Cg6Ptr);
+
+static void
+Cg6WaitMarker(ScreenPtr pScreen, int Marker)
+{
+	ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+	Cg6Ptr p = GET_CG6_FROM_SCRN(pScrn);
+
+	waitReady(p);
+}
+
+static Bool
+Cg6PrepareCopy
+(
+    PixmapPtr pSrcPixmap,
+    PixmapPtr pDstPixmap,
+    int       xdir,
+    int       ydir,
+    int       alu,
+    Pixel     planemask
+)
+{
+    ScrnInfoPtr pScrn = xf86Screens[pDstPixmap->drawable.pScreen->myNum];
+    Cg6Ptr pCg6 = GET_CG6_FROM_SCRN(pScrn);
+    
+    waitReady(pCg6);
+    
+    pCg6->fbc->mode = GX_BLIT_SRC |
+		GX_MODE_COLOR8 |
+		GX_DRAW_RENDER |
+		GX_BWRITE0_ENABLE |
+		GX_BWRITE1_DISABLE |
+		GX_BREAD_0 |
+		GX_BDISP_0;
+                
+    /* we probably don't need the following three */
+    pCg6->fbc->fg = 0xff;
+    pCg6->fbc->bg = 0x00;
+    pCg6->fbc->s = 0;
+    
+    pCg6->srcoff = exaGetPixmapOffset(pSrcPixmap) / pCg6->width;
+    pCg6->fbc->alu = Cg6BlitROP[alu];
+    pCg6->fbc->pm = planemask;
+    return TRUE;
+}
+
+static void
+Cg6Copy
+(
+    PixmapPtr pDstPixmap,
+    int       xSrc,
+    int       ySrc,
+    int       xDst,
+    int       yDst,
+    int       w,
+    int       h
+)
+{
+    ScrnInfoPtr pScrn = xf86Screens[pDstPixmap->drawable.pScreen->myNum];
+    Cg6Ptr pCg6 = GET_CG6_FROM_SCRN(pScrn);
+    int doff;
+
+    doff = exaGetPixmapOffset(pDstPixmap) / pCg6->width;
+    waitReady(pCg6);
+    pCg6->fbc->x0 = xSrc;
+    pCg6->fbc->y0 = ySrc + pCg6->srcoff;
+    pCg6->fbc->x1 = xSrc + w - 1;
+    pCg6->fbc->y1 = ySrc + pCg6->srcoff + h - 1;
+    pCg6->fbc->x2 = xDst;
+    pCg6->fbc->y2 = yDst + doff;
+    pCg6->fbc->x3 = xDst + w - 1;
+    pCg6->fbc->y3 = yDst + doff + h - 1;
+    runBlit(pCg6);
+    exaMarkSync(pDstPixmap->drawable.pScreen);
+}
+
+static void
+Cg6DoneCopy(PixmapPtr pDstPixmap)
+{
+    ScrnInfoPtr pScrn = xf86Screens[pDstPixmap->drawable.pScreen->myNum];
+    Cg6Ptr pCg6 = GET_CG6_FROM_SCRN(pScrn);
+
+    waitReady(pCg6);
+}
+
+static Bool
+Cg6PrepareSolid(
+    PixmapPtr pPixmap,
+    int alu,
+    Pixel planemask,
+    Pixel fg)
+{
+    ScrnInfoPtr pScrn = xf86Screens[pPixmap->drawable.pScreen->myNum];
+    Cg6Ptr pCg6 = GET_CG6_FROM_SCRN(pScrn);
+    CARD32 c2;
+
+    pCg6->srcoff = exaGetPixmapOffset(pPixmap) / pCg6->width;
+
+    waitReady(pCg6);
+
+    pCg6->fbc->mode = GX_BLIT_SRC |
+		GX_MODE_COLOR8 |
+		GX_DRAW_RENDER |
+		GX_BWRITE0_ENABLE |
+		GX_BWRITE1_DISABLE |
+		GX_BREAD_0 |
+		GX_BDISP_0;
+    pCg6->fbc->fg = fg;
+    pCg6->fbc->s = 0;
+    pCg6->fbc->alu = Cg6DrawROP[alu];
+    pCg6->fbc->pm = planemask;
+    return TRUE;
+}
+
+static void
+Cg6Solid(
+    PixmapPtr pPixmap,
+    int x,
+    int y,
+    int x2,
+    int y2)
+{
+    ScrnInfoPtr pScrn = xf86Screens[pPixmap->drawable.pScreen->myNum];
+    Cg6Ptr pCg6 = GET_CG6_FROM_SCRN(pScrn);
+
+    waitReady(pCg6);
+    pCg6->fbc->arecty = y + pCg6->srcoff;
+    pCg6->fbc->arectx = x;
+    pCg6->fbc->rrecty = y2 - y - 1;
+    pCg6->fbc->rrectx = x2 - x - 1;
+    runDraw(pCg6);
+    exaMarkSync(pPixmap->drawable.pScreen);
+}
+
+/*
+ * Memcpy-based UTS.
+ * TODO: use host blit
+ */
+static Bool
+Cg6UploadToScreen(PixmapPtr pDst, int x, int y, int w, int h,
+    char *src, int src_pitch)
+{
+    ScrnInfoPtr pScrn = xf86Screens[pDst->drawable.pScreen->myNum];
+    Cg6Ptr pCg6       = GET_CG6_FROM_SCRN(pScrn);
+    char  *dst        = pCg6->fb + exaGetPixmapOffset(pDst);
+    int    dst_pitch  = exaGetPixmapPitch(pDst);
+
+
+    dst += x + (y * dst_pitch);
+
+    while (h--) {
+        memcpy(dst, src, w);
+        src += src_pitch;
+        dst += dst_pitch;
+    }
+    return TRUE;
+}
+
+/*
+ * Memcpy-based DFS.
+ */
+static Bool
+Cg6DownloadFromScreen(PixmapPtr pSrc, int x, int y, int w, int h,
+    char *dst, int dst_pitch)
+{
+    ScrnInfoPtr pScrn = xf86Screens[pSrc->drawable.pScreen->myNum];
+    Cg6Ptr pCg6       = GET_CG6_FROM_SCRN(pScrn);
+    char  *src        = pCg6->fb + exaGetPixmapOffset(pSrc);
+    int    src_pitch  = exaGetPixmapPitch(pSrc);
+
+    src += x + (y * src_pitch);
+
+    while (h--) {
+        memcpy(dst, src, w);
+        src += src_pitch;
+        dst += dst_pitch;
+    }
+    return TRUE;
+}
+
+int
+CG6EXAInit(ScreenPtr pScreen)
+{
+    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+    Cg6Ptr pCg6 = GET_CG6_FROM_SCRN(pScrn);
+    ExaDriverPtr pExa;
+    
+    Cg6InitEngine(pCg6);
+
+    pExa = exaDriverAlloc();
+    if (!pExa)
+	return FALSE;
+
+    pCg6->pExa = pExa;
+
+    pExa->exa_major = EXA_VERSION_MAJOR;
+    pExa->exa_minor = EXA_VERSION_MINOR;
+
+    pExa->memoryBase = pCg6->fb;
+    pExa->memorySize = pCg6->vidmem;
+    pExa->offScreenBase = pCg6->width * pCg6->height;
+
+    /*
+     * our blitter can't deal with variable pitches
+     */
+    pExa->pixmapOffsetAlign = pCg6->width;
+    pExa->pixmapPitchAlign = pCg6->width;
+
+    pExa->flags = EXA_OFFSCREEN_PIXMAPS |
+		  EXA_MIXED_PIXMAPS;
+
+    pExa->maxX = 4096;
+    pExa->maxY = 4096;
+
+    pExa->WaitMarker = Cg6WaitMarker;
+
+    pExa->PrepareSolid = Cg6PrepareSolid;
+    pExa->Solid = Cg6Solid;
+    pExa->DoneSolid = Cg6DoneCopy;
+
+    pExa->PrepareCopy = Cg6PrepareCopy;
+    pExa->Copy = Cg6Copy;
+    pExa->DoneCopy = Cg6DoneCopy;
+
+    pExa->UploadToScreen = Cg6UploadToScreen;
+    pExa->DownloadFromScreen = Cg6DownloadFromScreen;
+
+    return exaDriverInit(pScreen, pExa);;
+}

Reply via email to