Module Name:    xsrc
Committed By:   macallan
Date:           Tue Aug 11 03:57:36 UTC 2015

Modified Files:
        xsrc/external/mit/xf86-video-sunffb/dist/src: ffb.h ffb_accel.c
            ffb_driver.c ffb_regs.h
Added Files:
        xsrc/external/mit/xf86-video-sunffb/dist/src: ffb_exa.c

Log Message:
add basic EXA support


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 xsrc/external/mit/xf86-video-sunffb/dist/src/ffb.h
cvs rdiff -u -r1.3 -r1.4 \
    xsrc/external/mit/xf86-video-sunffb/dist/src/ffb_accel.c
cvs rdiff -u -r1.7 -r1.8 \
    xsrc/external/mit/xf86-video-sunffb/dist/src/ffb_driver.c
cvs rdiff -u -r0 -r1.1 xsrc/external/mit/xf86-video-sunffb/dist/src/ffb_exa.c
cvs rdiff -u -r1.1.1.2 -r1.2 \
    xsrc/external/mit/xf86-video-sunffb/dist/src/ffb_regs.h

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-sunffb/dist/src/ffb.h
diff -u xsrc/external/mit/xf86-video-sunffb/dist/src/ffb.h:1.5 xsrc/external/mit/xf86-video-sunffb/dist/src/ffb.h:1.6
--- xsrc/external/mit/xf86-video-sunffb/dist/src/ffb.h:1.5	Tue Jun  4 22:20:42 2013
+++ xsrc/external/mit/xf86-video-sunffb/dist/src/ffb.h	Tue Aug 11 03:57:36 2015
@@ -34,6 +34,8 @@
 #ifdef HAVE_XAA_H
 #include "xaa.h"
 #endif
+#include "exa.h"
+
 #include <X11/Xmd.h>
 #include "gcstruct.h"
 #include "windowstr.h"
@@ -179,9 +181,6 @@ typedef struct {
 #ifdef HAVE_XAA_H
 	XAAInfoRecPtr pXAAInfo;
 #endif
-	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];
@@ -205,6 +204,12 @@ typedef struct {
 	unsigned char CursorShiftX, CursorShiftY;
 	unsigned char *CursorData;
 
+	/* EXA stuff */
+	ExaDriverPtr 	pExa;
+	int srcpitch, srcoff;
+	int xdir, ydir, rop;
+	CARD32 planemask, fbc, wid;
+
 	PixmapPtr pix32, pix8;
 
 	void *I2C;
@@ -215,6 +220,7 @@ typedef struct {
 
 /* Acceleration */
 extern Bool FFBAccelInit(ScreenPtr, FFBPtr);
+extern Bool FFBInitEXA(ScreenPtr);
 extern void CreatorVtChange (ScreenPtr pScreen, int enter);
 
 /* HW cursor support */

Index: xsrc/external/mit/xf86-video-sunffb/dist/src/ffb_accel.c
diff -u xsrc/external/mit/xf86-video-sunffb/dist/src/ffb_accel.c:1.3 xsrc/external/mit/xf86-video-sunffb/dist/src/ffb_accel.c:1.4
--- xsrc/external/mit/xf86-video-sunffb/dist/src/ffb_accel.c:1.3	Tue Jun  4 22:20:42 2013
+++ xsrc/external/mit/xf86-video-sunffb/dist/src/ffb_accel.c	Tue Aug 11 03:57:36 2015
@@ -102,7 +102,7 @@ CreatorVtChange (ScreenPtr pScreen, int 
 			   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 = (enter ? pFfb->xaa_wid : 0xff);
+	pFfb->wid_cache = (enter ? pFfb->wid : 0xff);
 	FFBFifo(pFfb, 11);
 	ffb->fbc = pFfb->fbc_cache;
 	ffb->ppc = FFB_PPC_XS_WID;
@@ -138,48 +138,6 @@ CreatorVtChange (ScreenPtr pScreen, int 
 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 __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_OLD | (FFB_ROP_OLD << 8)); \
-        unsigned int __fbc = (__fpriv)->xaa_fbc; \
-        (__fpriv)->ppc_cache &= ~__ppc_mask; \
-        (__fpriv)->ppc_cache |= __ppc; \
-        (__fpriv)->regs->ppc = __ppc; \
-        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 CARD32 FFBTextureDstFormats[3] = { PICT_a8b8g8r8, PICT_x8b8g8r8, 0 };
@@ -190,8 +148,8 @@ static void FFB_SetupTextureAttrs(FFBPtr
        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;
+       unsigned int fbc = pFfb->fbc;
+       unsigned int wid = pFfb->wid;
 
        ppc |= FFB_PPC_ABE_ENABLE;
        ppc_mask |= FFB_PPC_ABE_MASK;
@@ -396,11 +354,11 @@ static void FFB_SetupForMono8x8PatternFi
                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;
+       fbc = pFfb->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);
+                    FFB_DRAWOP_RECTANGLE, fg, fbc, pFfb->wid);
        if (bg >= 0)
                FFB_WRITE_BG(pFfb, ffb, bg);
 
@@ -458,7 +416,7 @@ static void FFB_SetupForScanlineCPUToScr
                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;
+       fbc = pFfb->fbc;
        rop = (rop | FFB_ROP_EDIT_BIT) | (FFB_ROP_NEW << 8);
 
        if ((pFfb->ppc_cache & ppc_mask) != ppc ||
@@ -545,20 +503,20 @@ static void FFB_SetupForDashedLine(ScrnI
                "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->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;
+       fbc = pFfb->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);
+                    FFB_DRAWOP_BRLINEOPEN, fg, fbc, pFfb->wid);
        pFfb->rp_active = 1;
 }
 
@@ -602,16 +560,16 @@ static void FFB_SetupForSolidLine(ScrnIn
                "color[%d] rop[%d] pmask[%x]\n",
                color, rop, planemask));
 
-       pFfb->xaa_planemask = planemask;
+       pFfb->planemask = planemask;
        pFfb->xaa_rop = rop;
 
-       fbc = pFfb->xaa_fbc;
+       fbc = pFfb->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);
+                    FFB_DRAWOP_BRLINEOPEN, color, fbc, pFfb->wid);
        FFBFifo(pFfb, 1);
        ffb->lpat = 0;
        pFfb->rp_active = 1;
@@ -653,10 +611,10 @@ void FFB_SetupForSolidFill(ScrnInfoPtr p
                "color[%d] rop[%d] pmask[%u]\n",
                color, rop, planemask));
 
-       pFfb->xaa_planemask = planemask;
+       pFfb->planemask = planemask;
        pFfb->xaa_rop = rop;
 
-       fbc = pFfb->xaa_fbc;
+       fbc = pFfb->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;
@@ -664,7 +622,7 @@ void FFB_SetupForSolidFill(ScrnInfoPtr p
 
        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);
+                    FFB_DRAWOP_RECTANGLE, color, fbc, pFfb->wid);
        pFfb->rp_active = 1;
 }
 
@@ -801,7 +759,7 @@ void FFB_SetupForScreenToScreenCopy(Scrn
                "xdir[%d] ydir[%d] rop[%d] pmask[%x] tcolor[%d]\n",
                xdir, ydir, rop, planemask, trans_color));
 
-       pFfb->xaa_planemask = planemask;
+       pFfb->planemask = planemask;
        pFfb->xaa_xdir = xdir;
        pFfb->xaa_ydir = ydir;
        pFfb->xaa_rop = rop;
@@ -873,19 +831,19 @@ Bool FFBAccelInit(ScreenPtr pScreen, FFB
 	XAAInfoRecPtr infoRec;
 	ffb_fbcPtr ffb = pFfb->regs;
 
-	pFfb->xaa_fbc = (FFB_FBC_WB_A | FFB_FBC_WM_COMBINED | FFB_FBC_RB_A |
+	pFfb->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)
+	pFfb->wid = FFBWidAlloc(pFfb, TrueColor, 0, TRUE);
+	if (pFfb->wid == (unsigned int) -1)
 		return FALSE;
 
 	pFfb->pXAAInfo = infoRec = XAACreateInfoRec();
 	if (!infoRec) {
-		FFBWidFree(pFfb, pFfb->xaa_wid);
+		FFBWidFree(pFfb, pFfb->wid);
 		return FALSE;
 	}
 
@@ -1068,7 +1026,7 @@ Bool FFBAccelInit(ScreenPtr pScreen, FFB
 			   FFB_PPC_VCE_DISABLE | FFB_PPC_APE_DISABLE | FFB_PPC_CS_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->wid_cache = pFfb->wid;
 	pFfb->pmask_cache = ~0;
 	pFfb->rop_cache = (FFB_ROP_NEW | (FFB_ROP_NEW << 8));
 	pFfb->drawop_cache = FFB_DRAWOP_RECTANGLE;
@@ -1120,7 +1078,7 @@ Bool FFBAccelInit(ScreenPtr pScreen, FFB
 		free(pFfb->xaa_scanline_buffers[0]);
 		free(pFfb->xaa_scanline_buffers[1]);
 		pFfb->pXAAInfo = NULL;
-		FFBWidFree(pFfb, pFfb->xaa_wid);
+		FFBWidFree(pFfb, pFfb->wid);
 		return FALSE;
 	}
 	/* Success */

Index: xsrc/external/mit/xf86-video-sunffb/dist/src/ffb_driver.c
diff -u xsrc/external/mit/xf86-video-sunffb/dist/src/ffb_driver.c:1.7 xsrc/external/mit/xf86-video-sunffb/dist/src/ffb_driver.c:1.8
--- xsrc/external/mit/xf86-video-sunffb/dist/src/ffb_driver.c:1.7	Tue Jun  4 22:20:42 2013
+++ xsrc/external/mit/xf86-video-sunffb/dist/src/ffb_driver.c	Tue Aug 11 03:57:36 2015
@@ -95,6 +95,7 @@ _X_EXPORT DriverRec SUNFFB = {
 typedef enum {
     OPTION_SW_CURSOR,
     OPTION_HW_CURSOR,
+    OPTION_ACCELMETHOD,
     OPTION_NOACCEL
 } FFBOpts;
 
@@ -102,6 +103,7 @@ static const OptionInfoRec FFBOptions[] 
     { 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 }
 };
 
@@ -417,11 +419,6 @@ FFBPreInit(ScrnInfoPtr pScrn, int flags)
 	return FALSE;
     }
 
-    if (xf86LoadSubModule(pScrn, "xaa") == NULL) {
-	FFBFreeRec(pScrn);
-	return FALSE;
-    }
-
     if (pFfb->HWCursor && xf86LoadSubModule(pScrn, "ramdac") == NULL) {
 	FFBFreeRec(pScrn);
 	return FALSE;
@@ -760,9 +757,22 @@ FFBScreenInit(SCREEN_INIT_ARGS_DECL)
     xf86SetBlackWhitePixels(pScreen);
 
     if (!pFfb->NoAccel) {
-	if (!FFBAccelInit(pScreen, pFfb))
-	    return FALSE;
-	xf86Msg(X_INFO, "%s: Using acceleration\n", pFfb->psdp->device);
+	char *optstr;
+	optstr = (char *)xf86GetOptValString(pFfb->Options, OPTION_ACCELMETHOD);
+	if (optstr == NULL) optstr = "xaa";
+	if (xf86NameCmp(optstr, "EXA") == 0) {
+	    xf86Msg(X_INFO, "using EXA\n");
+	    if (xf86LoadSubModule(pScrn, "exa") != NULL) {
+		if (!FFBInitEXA(pScreen))
+		    return FALSE;
+    	    }
+    	} else if (xf86NameCmp(optstr, "XAA") == 0) {
+	    xf86Msg(X_INFO, "using XAA\n");
+	    if (xf86LoadSubModule(pScrn, "xaa") != NULL) {
+		if (!FFBAccelInit(pScreen, pFfb))
+		    return FALSE;
+	    }
+	}
     }
 
 

Index: xsrc/external/mit/xf86-video-sunffb/dist/src/ffb_regs.h
diff -u xsrc/external/mit/xf86-video-sunffb/dist/src/ffb_regs.h:1.1.1.2 xsrc/external/mit/xf86-video-sunffb/dist/src/ffb_regs.h:1.2
--- xsrc/external/mit/xf86-video-sunffb/dist/src/ffb_regs.h:1.1.1.2	Tue Jun  4 21:46:23 2013
+++ xsrc/external/mit/xf86-video-sunffb/dist/src/ffb_regs.h	Tue Aug 11 03:57:36 2015
@@ -518,4 +518,45 @@ do {	volatile unsigned int *__p = (__reg
 	FFB_WRITE64(__regp, __lo32, __hi32)
 #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)->fbc; \
+       unsigned int __wid = (__fpriv)->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 __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_OLD | (FFB_ROP_OLD << 8)); \
+        unsigned int __fbc = (__fpriv)->fbc; \
+        (__fpriv)->ppc_cache &= ~__ppc_mask; \
+        (__fpriv)->ppc_cache |= __ppc; \
+        (__fpriv)->regs->ppc = __ppc; \
+        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)
+
 #endif /* FFBREGS_H */

Added files:

Index: xsrc/external/mit/xf86-video-sunffb/dist/src/ffb_exa.c
diff -u /dev/null xsrc/external/mit/xf86-video-sunffb/dist/src/ffb_exa.c:1.1
--- /dev/null	Tue Aug 11 03:57:36 2015
+++ xsrc/external/mit/xf86-video-sunffb/dist/src/ffb_exa.c	Tue Aug 11 03:57:36 2015
@@ -0,0 +1,389 @@
+/* $NetBSD: ffb_exa.c,v 1.1 2015/08/11 03:57:36 macallan Exp $ */
+/*
+ * Copyright (c) 2015 Michael Lorenz
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *    - Redistributions of source code must retain the above copyright
+ *      notice, this list of conditions and the following disclaimer.
+ *    - Redistributions in binary form must reproduce the above
+ *      copyright notice, this list of conditions and the following
+ *      disclaimer in the documentation and/or other materials provided
+ *      with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+ 
+#include <sys/types.h>
+
+/* all driver need this */
+#include "xf86.h"
+#include "xf86_OSproc.h"
+#include "compiler.h"
+#include "exa.h"
+
+#include "ffb_fifo.h"
+#include "ffb_rcache.h"
+#include "ffb.h"
+#include "ffb_regs.h"
+
+extern void VISmoveImageRL(unsigned char *, unsigned char *, long, long, long, long);
+extern void VISmoveImageLR(unsigned char *, unsigned char *, long, long, long, long);
+
+/*#define FFB_DEBUG*/
+
+#ifdef FFB_DEBUG
+#define ENTER xf86Msg(X_ERROR, "%s>\n", __func__);
+#define DPRINTF xf86Msg
+#else
+#define ENTER
+#define DPRINTF while (0) xf86Msg
+#endif
+
+static void
+FFBWaitMarker(ScreenPtr pScreen, int Marker)
+{
+	ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+	FFBPtr pFfb = GET_FFB_FROM_SCRN(pScrn);
+	ffb_fbcPtr ffb = pFfb->regs;
+
+	FFBWait(pFfb, ffb);
+}
+
+static Bool
+FFBPrepareCopy(PixmapPtr pSrcPixmap, PixmapPtr pDstPixmap,
+		int xdir, int ydir, int alu, Pixel planemask)
+{
+	ScrnInfoPtr pScrn = xf86Screens[pDstPixmap->drawable.pScreen->myNum];
+	FFBPtr pFfb = GET_FFB_FROM_SCRN(pScrn);
+	ffb_fbcPtr ffb = pFfb->regs;
+
+	ENTER;
+	pFfb->srcpitch = exaGetPixmapPitch(pSrcPixmap);
+	pFfb->srcoff = exaGetPixmapOffset(pSrcPixmap);
+	pFfb->xdir = xdir;
+	pFfb->ydir = ydir;
+	pFfb->rop = alu;
+	pFfb->planemask = planemask;
+	return TRUE;
+}
+
+static void
+FFBCopy(PixmapPtr pDstPixmap,
+         int srcX, int srcY, int dstX, int dstY, int w, int h)
+{
+	ScrnInfoPtr pScrn = xf86Screens[pDstPixmap->drawable.pScreen->myNum];
+	FFBPtr pFfb = GET_FFB_FROM_SCRN(pScrn);
+	ffb_fbcPtr ffb = pFfb->regs;
+	unsigned char *src, *dst, *sfb32;
+	int psz_shift = 2;
+	int sdkind;
+
+	ENTER;
+	if ((srcX == dstX) && (srcY != dstY) && (pFfb->rop == GXcopy)) {
+		/* we can use the vscroll command */
+		FFB_ATTR_VSCROLL_XAA(pFfb, pFfb->planemask);
+		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);
+		exaMarkSync(pDstPixmap->drawable.pScreen);
+		return;
+	}
+	FFB_ATTR_SFB_VAR_XAA(pFfb, pFfb->planemask, pFfb->rop);
+	FFBWait(pFfb, ffb);
+	sfb32 = (unsigned char *) pFfb->sfb32;
+	src = sfb32 + (srcY * (2048 << psz_shift)) + (srcX << psz_shift);
+	dst = sfb32 + (dstY * (2048 << psz_shift)) + (dstX << psz_shift);
+	sdkind = (2048 << psz_shift);
+
+	if (pFfb->ydir < 0) {
+		src += ((h - 1) * (2048 << psz_shift));
+		dst += ((h - 1) * (2048 << psz_shift));
+		sdkind = -sdkind;
+	}
+	w <<= psz_shift;
+	if (pFfb->xdir < 0)
+		VISmoveImageRL(src, dst, w, h, sdkind, sdkind);
+	else
+		VISmoveImageLR(src, dst, w, h, sdkind, sdkind);
+}
+
+static void
+FFBDoneCopy(PixmapPtr pDstPixmap)
+{
+}
+
+static Bool
+FFBPrepareSolid(PixmapPtr pPixmap, int alu, Pixel planemask, Pixel fg)
+{
+	ScrnInfoPtr pScrn = xf86Screens[pPixmap->drawable.pScreen->myNum];
+	FFBPtr pFfb = GET_FFB_FROM_SCRN(pScrn);
+	ffb_fbcPtr ffb = pFfb->regs;
+	unsigned int ppc, ppc_mask, fbc;
+
+	ENTER;
+	FFBWait(pFfb, ffb);
+	pFfb->planemask = planemask;
+	pFfb->rop = alu;
+
+	fbc = pFfb->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 | alu) | (FFB_ROP_NEW << 8),
+                    FFB_DRAWOP_RECTANGLE, fg, fbc, pFfb->wid);
+
+	return TRUE;
+}
+
+static void
+FFBSolid(PixmapPtr pPixmap, int x1, int y1, int x2, int y2)
+{
+	ScrnInfoPtr pScrn = xf86Screens[pPixmap->drawable.pScreen->myNum];
+	FFBPtr pFfb = GET_FFB_FROM_SCRN(pScrn);
+	ffb_fbcPtr ffb = pFfb->regs;
+
+	ENTER;
+	FFBFifo(pFfb, 4);
+	FFB_WRITE64(&ffb->by, y1, x1);
+	FFB_WRITE64_2(&ffb->bh, y2 - y1, x2 - x1);
+	exaMarkSync(pPixmap->drawable.pScreen);
+}
+
+static Bool
+FFBUploadToScreen(PixmapPtr pDst, int x, int y, int w, int h,
+    char *src, int src_pitch)
+{
+	ScrnInfoPtr pScrn = xf86Screens[pDst->drawable.pScreen->myNum];
+	FFBPtr pFfb = GET_FFB_FROM_SCRN(pScrn);
+	unsigned char *dst, *sfb32;
+	int psz_shift = 2;
+	ffb_fbcPtr ffb = pFfb->regs;
+
+	ENTER;
+	FFB_ATTR_SFB_VAR_XAA(pFfb, 0xffffffff, GXcopy);
+	FFBWait(pFfb, ffb);
+
+	sfb32 = (unsigned char *) pFfb->sfb32;
+	dst = sfb32 + (y * (2048 << psz_shift)) + (x << psz_shift);
+	VISmoveImageLR(src, dst, w << psz_shift, h,
+		src_pitch, (2048 << psz_shift));
+	return TRUE;
+}
+
+static Bool
+FFBDownloadFromScreen(PixmapPtr pSrc, int x, int y, int w, int h,
+    char *dst, int dst_pitch)
+{
+	ScrnInfoPtr pScrn = xf86Screens[pSrc->drawable.pScreen->myNum];
+	FFBPtr pFfb = GET_FFB_FROM_SCRN(pScrn);
+	unsigned char *src, *sfb32;
+	int psz_shift = 2;
+	ffb_fbcPtr ffb = pFfb->regs;
+
+	ENTER;
+	FFB_ATTR_SFB_VAR_XAA(pFfb, 0xffffffff, GXcopy);
+	FFBWait(pFfb, ffb);
+
+	sfb32 = (unsigned char *) pFfb->sfb32;
+	src = sfb32 + (y * (2048 << psz_shift)) + (x << psz_shift);
+	VISmoveImageLR(src, dst, w << psz_shift, h,
+		(2048 << psz_shift), dst_pitch);
+	return TRUE;
+}
+
+#if 0
+
+Bool
+FFBCheckComposite(int op, PicturePtr pSrcPicture,
+                           PicturePtr pMaskPicture,
+                           PicturePtr pDstPicture)
+{
+	return FALSE;
+}
+
+Bool
+FFBPrepareComposite(int op, PicturePtr pSrcPicture,
+                             PicturePtr pMaskPicture,
+                             PicturePtr pDstPicture,
+                             PixmapPtr  pSrc,
+                             PixmapPtr  pMask,
+                             PixmapPtr  pDst)
+{
+	ScrnInfoPtr pScrn = xf86Screens[pDst->drawable.pScreen->myNum];
+	FFBPtr pFfb = GET_FFB_FROM_SCRN(pScrn);
+
+	ENTER;
+	return FALSE;
+}
+
+void
+FFBComposite(PixmapPtr pDst, int srcX, int srcY,
+                              int maskX, int maskY,
+                              int dstX, int dstY,
+                              int width, int height)
+{
+	ScrnInfoPtr pScrn = xf86Screens[pDst->drawable.pScreen->myNum];
+	FFBPtr pFfb = GET_FFB_FROM_SCRN(pScrn);
+	exaMarkSync(pDst->drawable.pScreen);
+}
+
+#endif
+
+static Bool
+FFBPrepareAccess(PixmapPtr pPix, int index)
+{
+	ScrnInfoPtr pScrn = xf86Screens[pPix->drawable.pScreen->myNum];
+	FFBPtr pFfb = GET_FFB_FROM_SCRN(pScrn);
+	ffb_fbcPtr ffb = pFfb->regs;
+
+	ENTER;
+	FFB_ATTR_SFB_VAR_XAA(pFfb, 0xffffffff, GXcopy);
+	FFBWait(pFfb, ffb);
+
+	return TRUE;	
+}
+
+static void
+FFBFinishAccess(PixmapPtr pPix, int index)
+{
+}
+
+Bool
+FFBInitEXA(ScreenPtr pScreen)
+{
+	ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+	FFBPtr pFfb = GET_FFB_FROM_SCRN(pScrn);
+	ffb_fbcPtr ffb = pFfb->regs;
+	ExaDriverPtr pExa;
+
+	pFfb->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->wid = FFBWidAlloc(pFfb, TrueColor, 0, TRUE);
+	if (pFfb->wid == (unsigned int) -1)
+		return FALSE;
+
+	pFfb->ppc_cache = (FFB_PPC_FW_DISABLE |
+			   FFB_PPC_VCE_DISABLE | FFB_PPC_APE_DISABLE | FFB_PPC_CS_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->wid;
+	pFfb->pmask_cache = ~0;
+	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_WE_FORCEON |
+			   FFB_FBC_SB_BOTH |
+			   FFB_FBC_ZE_OFF | FFB_FBC_YE_OFF |
+			   FFB_FBC_RGBE_OFF |
+			   FFB_FBC_XE_ON);
+
+	/* We will now clear the screen: we'll draw a rectangle covering all the
+	 * viewscreen, using a 'blackness' ROP.
+	 */
+	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;
+	ffb->fg = pFfb->fg_cache;
+	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);
+	FFBWait(pFfb, ffb);
+	
+	FFB_ATTR_SFB_VAR_XAA(pFfb, 0xffffffff, GXcopy);
+	FFBWait(pFfb, ffb);
+
+	pExa = exaDriverAlloc();
+	if (!pExa)
+		return FALSE;
+
+	pFfb->pExa = pExa;
+
+	pExa->exa_major = EXA_VERSION_MAJOR;
+	pExa->exa_minor = EXA_VERSION_MINOR;
+
+
+	pExa->memoryBase = (char *)pFfb->sfb32;
+	/*
+	 * we don't have usable off-screen memory but EXA craps out if we don't
+	 * pretend that we do, so register a ridiculously small amount and
+	 * cross fingers
+	 */
+	pExa->memorySize = 8192 * pFfb->psdp->height + 4;
+	pExa->offScreenBase = pExa->memorySize - 4;
+
+	/* we want to use 64bit aligned accesses */	
+	pExa->pixmapOffsetAlign = 8;
+	pExa->pixmapPitchAlign = 8;
+
+	pExa->flags = EXA_OFFSCREEN_PIXMAPS |
+		      /*EXA_SUPPORTS_OFFSCREEN_OVERLAPS |*/
+		      EXA_MIXED_PIXMAPS;
+
+	pExa->maxX = 2048;
+	pExa->maxY = 2048;
+
+	pExa->WaitMarker = FFBWaitMarker;
+
+	pExa->PrepareSolid = FFBPrepareSolid;
+	pExa->Solid = FFBSolid;
+	pExa->DoneSolid = FFBDoneCopy;
+	pExa->PrepareCopy = FFBPrepareCopy;
+	pExa->Copy = FFBCopy;
+	pExa->DoneCopy = FFBDoneCopy;
+	pExa->UploadToScreen = FFBUploadToScreen;
+	pExa->DownloadFromScreen = FFBDownloadFromScreen;
+	pExa->PrepareAccess = FFBPrepareAccess;
+	pExa->FinishAccess = FFBFinishAccess;
+#if 0
+	pExa->CheckComposite = CG14CheckComposite;
+	pExa->PrepareComposite = CG14PrepareComposite;
+	pExa->Composite = CG14Composite;
+	pExa->DoneComposite = CG14DoneCopy;
+#endif
+
+	return exaDriverInit(pScreen, pExa);
+}

Reply via email to