Module Name:    xsrc
Committed By:   macallan
Date:           Thu Nov 26 17:18:55 UTC 2015

Modified Files:
        xsrc/external/mit/xf86-video-suncg6/dist/src: cg6_exa.c

Log Message:
- round available video memory to full scanlines in order to avoid a bug
  in EXA
- use host blits for UploadToScreen() - no more unaligned accesses needed


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 \
    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_exa.c
diff -u xsrc/external/mit/xf86-video-suncg6/dist/src/cg6_exa.c:1.1 xsrc/external/mit/xf86-video-suncg6/dist/src/cg6_exa.c:1.2
--- xsrc/external/mit/xf86-video-suncg6/dist/src/cg6_exa.c:1.1	Wed Nov 25 18:01:29 2015
+++ xsrc/external/mit/xf86-video-suncg6/dist/src/cg6_exa.c	Thu Nov 26 17:18:55 2015
@@ -218,17 +218,57 @@ Cg6UploadToScreen(PixmapPtr pDst, int x,
 {
     ScrnInfoPtr pScrn = xf86Screens[pDst->drawable.pScreen->myNum];
     Cg6Ptr pCg6       = GET_CG6_FROM_SCRN(pScrn);
-    char  *dst        = pCg6->fb + exaGetPixmapOffset(pDst);
+    uint32_t *sline;
     int    dst_pitch  = exaGetPixmapPitch(pDst);
+    int    dst_line   = y + exaGetPixmapOffset(pDst) / pCg6->width;
+    int    i, bits;
+    int    words = (w + 3) >> 2;
+
+    /* clip to the destination */
+    pCg6->fbc->clipmaxx = x + w - 1;
+    pCg6->fbc->clipminx = x;
+
+    /* see if the source is aligned, if not adjust */
+    bits = ((long)src) & 3;
+    if (bits != 0) {
+    	src -= bits;
+    	w += bits;
+	words = (w + 3) >> 2;
+	x -= bits;
+    }
 
-
-    dst += x + (y * dst_pitch);
-
+    /* we assume that source pitch is always a multiple of 4 */
+    if ((src_pitch & 3) != 0)
+    	xf86Msg(X_ERROR, "pitch %d\n", src_pitch);
+    waitReady(pCg6);
+    
+    pCg6->fbc->mode = GX_BLIT_NOSRC |
+		GX_MODE_COLOR8 |
+		GX_DRAW_RENDER |
+		GX_BWRITE0_ENABLE |
+		GX_BWRITE1_DISABLE |
+		GX_BREAD_0 |
+		GX_BDISP_0;
+    
+    pCg6->fbc->alu = Cg6BlitROP[GXcopy];
+    pCg6->fbc->pm = 0xffffffff;
+    pCg6->fbc->incx = 4;
+    pCg6->fbc->incy = 0;
     while (h--) {
-        memcpy(dst, src, w);
+        pCg6->fbc->x0 = x;
+        pCg6->fbc->x1 = x + 3;
+        pCg6->fbc->y0 = dst_line;
+        sline = (uint32_t *)src;
+        for (i = 0; i < words; i++) {
+        	pCg6->fbc->font = *sline;
+        	sline++;
+        }
         src += src_pitch;
-        dst += dst_pitch;
+        dst_line++;
     }
+    pCg6->fbc->clipmaxx = 4096;
+    pCg6->fbc->clipminx = 0;
+    exaMarkSync(pDst->drawable.pScreen);
     return TRUE;
 }
 
@@ -243,13 +283,14 @@ Cg6DownloadFromScreen(PixmapPtr pSrc, in
     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--) {
+    while (h > 0) {
         memcpy(dst, src, w);
         src += src_pitch;
         dst += dst_pitch;
+        h--;
     }
     return TRUE;
 }
@@ -273,7 +314,9 @@ CG6EXAInit(ScreenPtr pScreen)
     pExa->exa_minor = EXA_VERSION_MINOR;
 
     pExa->memoryBase = pCg6->fb;
-    pExa->memorySize = pCg6->vidmem;
+
+    /* round to multiple of pixmap pitch */
+    pExa->memorySize = (pCg6->vidmem / pCg6->width) * pCg6->width;
     pExa->offScreenBase = pCg6->width * pCg6->height;
 
     /*

Reply via email to