Two weeks ago, my home computer with the integrated ProSavageDDR video chipset died on me. After several attempts to diagnose the problem, it seems that the mainboard itself is damaged. So I built myself a new machine with an Intel i915 video chipset. Therefore I am no longer able to develop or test patches for the savage driver. Attached are the last two patches that were not yet committed to the git repository. I am resending them because after all this time, the git commit access I requested was still not granted (but is now useless).

--
perl -e '$x=2.3;printf("%.0f + %.0f = %.0f\n",$x,$x,$x+$x);'

>From f4929b64da2ebc2adaabce7a5da716026449b9d9 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Alex=20Villac=C3=ADs=20Lasso?= <a...@karlalex.palosanto.com>
Date: Sat, 11 Apr 2009 19:12:31 -0500
Subject: [PATCH] Implement use of Mastered Image Transfer through AGP for 
UploadToScreen EXA acceleration.

Under some conditions (documented in this patch), the UploadToScreen 
implementation can make use of the AGP scratch buffer used for XVideo as a 
convenient source for Mastered Image Transfer. The previous implementation is 
still available as a fallback for when AGP acceleration is not possible. This 
requires the AGP scratch buffer to be persistent, so the XVideo code is also 
made aware of an existing DRM mapping for the scratch buffer.
---
 man/savage.man     |    6 ++++-
 src/savage_exa.c   |   67 ++++++++++++++++++++++++++++++++++++++++++++++++++-
 src/savage_video.c |   11 ++++++--
 3 files changed, 78 insertions(+), 6 deletions(-)

diff --git a/man/savage.man b/man/savage.man
index 822a233..a1cbb1e 100644
--- a/man/savage.man
+++ b/man/savage.man
@@ -180,7 +180,7 @@ and twister (use BCI for Xv); off for savage4 (do not use 
the BCI for Xv).
 Instructs the BCI Xv pixel formatter to use AGP memory as a scratch buffer.
 Ordinarily the BCI formatter uses a an area in framebuffer memory to hold 
 YV12 planar data to be converted for display. This requires a somewhat 
expensive
-upload of YV12 data to framebuffer memory. The \*qAGPforXv\*q causes the BCI
+upload of YV12 data to framebuffer memory. The \*qAGPforXv\*q option causes 
the BCI
 formatter to place the YV12 data in AGP memory instead, which can be uploaded
 faster than the framebuffer. Use of this option cuts upload overhead by 25%
 according to benchmarks. This option also smooths out most of the shearing
@@ -189,6 +189,10 @@ present when using BCI for pixel conversion. Currently 
this option is
 and is disabled by default. Video width restrictions that apply to 
\*qBCIforXv\*q 
 also apply here. Only valid when \*qDRI\*q and \*qBCIforXv\*q are both active, 
 and only on AGP chipsets. Default: \*qoff\*q.
+.br
+If \*qAccelMethod\*q is set to \*qEXA\*q and \*qAGPforXv\*q is enabled, then 
the
+driver will also attempt to reuse the AGP scratch buffer for UploadToScreen 
+acceleration.
 .TP 
 .BI "Option \*qAGPMode\*q \*q" integer \*q
 Set AGP data transfer rate.
diff --git a/src/savage_exa.c b/src/savage_exa.c
index 538e000..08524f0 100644
--- a/src/savage_exa.c
+++ b/src/savage_exa.c
@@ -463,10 +463,73 @@ SavageUploadToScreen(PixmapPtr pDst, int x, int y, int w, 
int h, char *src, int
     BCI_GET_PTR;
     int i, j, dwords, queue, Bpp;
     unsigned int cmd;
-    CARD32 * srcp; 
+    CARD32 * srcp;
+    unsigned int dst_pitch;
+    unsigned int dst_yoffset;
+    int agp_possible;
     
+    exaWaitSync(pDst->drawable.pScreen);
+
     Bpp = pDst->drawable.bitsPerPixel / 8;
 
+    /* Test for conditions for AGP Mastered Image Transfer (MIT). AGP memory
+       needs to be available, the XVideo AGP needs to be enabled, the 
+       framebuffer destination must be a multiple of 32 bytes, and the source
+       pitch must span the entirety of the destination pitch. This last 
+       condition allows the code to consider this upload as equivalent to a 
+       plain memcpy() call. */
+    dst_pitch = exaGetPixmapPitch(pDst);
+    dst_yoffset = exaGetPixmapOffset(pDst) + y * dst_pitch;
+    agp_possible = 
+        (!psav->IsPCI && psav->drmFD > 0 && psav->DRIServerInfo != NULL &&
+        psav->DRIServerInfo->agpXVideo.size > 0 &&
+        x == 0 && src_pitch == dst_pitch && w * Bpp == dst_pitch &&
+        (dst_yoffset & 0x1f) == 0);
+
+    if (agp_possible) {
+       SAVAGEDRIServerPrivatePtr pSAVAGEDRIServer = psav->DRIServerInfo;
+        if (pSAVAGEDRIServer->agpXVideo.map != NULL || 
+            0 <= drmMap( psav->drmFD,
+               pSAVAGEDRIServer->agpXVideo.handle,
+               pSAVAGEDRIServer->agpXVideo.size,
+               &pSAVAGEDRIServer->agpXVideo.map)) {
+        
+            unsigned char * agpMap = pSAVAGEDRIServer->agpXVideo.map;
+            unsigned int agpOffset = drmAgpBase(psav->drmFD) + 
pSAVAGEDRIServer->agpXVideo.offset;
+            unsigned int bytesTotal = dst_pitch * h;            
+
+            while (bytesTotal > 0) {
+                unsigned int bytesTransfer = 
+                    (bytesTotal > pSAVAGEDRIServer->agpXVideo.size) 
+                    ? pSAVAGEDRIServer->agpXVideo.size 
+                    : bytesTotal;
+                unsigned int qwordsTransfer = bytesTransfer >> 3;
+
+                /* Copy source into AGP buffer */
+                memcpy(agpMap, src, bytesTransfer);
+                
+                psav->WaitQueue(psav,6);
+                BCI_SEND(BCI_SET_REGISTER | BCI_SET_REGISTER_COUNT(2) | 0x51);
+                BCI_SEND(agpOffset | 3);        /* Source buffer in AGP memory 
*/
+                BCI_SEND(dst_yoffset);          /* Destination buffer in 
framebuffer */
+
+                BCI_SEND(BCI_SET_REGISTER | BCI_SET_REGISTER_COUNT(1) | 0x50);
+                BCI_SEND(0x00000002 | ((qwordsTransfer - 1) << 3)); /* Select 
MIT, sysmem to framebuffer */
+
+                /* I want to wait here for any reads from AGP memory and any 
+                   framebuffer writes performed by the MIT to stop. */
+                BCI_SEND(0xC0000000 | ((0x08 | 0x01) << 16));
+
+                bytesTotal -= bytesTransfer;
+                src += bytesTransfer;
+                dst_yoffset += bytesTransfer;
+            }
+            exaMarkSync(pDst->drawable.pScreen);
+            return TRUE;
+        }
+    }
+
+    /* If we reach here, AGP transfer is not possible, or failed to drmMap() */
     psav->sbd_offset = exaGetPixmapOffset(pDst);
     psav->sbd_high = SavageSetBD(psav, pDst);
 
@@ -515,7 +578,7 @@ SavageUploadToScreen(PixmapPtr pDst, int x, int y, int w, 
int h, char *src, int
     }
 
     /*exaWaitSync(pDst->drawable.pScreen);*/
-
+    exaMarkSync(pDst->drawable.pScreen);
     return TRUE;
 }
 
diff --git a/src/savage_video.c b/src/savage_video.c
index bccb801..cf51ba0 100644
--- a/src/savage_video.c
+++ b/src/savage_video.c
@@ -1048,8 +1048,12 @@ SavageStopVideo(ScrnInfoPtr pScrn, pointer data, Bool 
shutdown)
 
        if (pPriv->agpBufferMap != NULL) {
            SAVAGEDRIServerPrivatePtr pSAVAGEDRIServer = psav->DRIServerInfo;
-           drmUnmap(pPriv->agpBufferMap, pSAVAGEDRIServer->agpXVideo.size);
-           pSAVAGEDRIServer->agpXVideo.map = NULL;
+
+            /* agpXVideo is reused to implement UploadToScreen in EXA */       
     
+            if (!psav->useEXA) {
+               drmUnmap(pPriv->agpBufferMap, pSAVAGEDRIServer->agpXVideo.size);
+               pSAVAGEDRIServer->agpXVideo.map = NULL;
+            }
            pPriv->agpBufferMap = NULL;
            pPriv->agpBufferOffset = 0;
        }
@@ -1971,7 +1975,8 @@ SavagePutImage(
         
        pPriv->tried_agp = TRUE;
        if (pSAVAGEDRIServer->agpXVideo.size >= max(new_size, planarFrameSize)) 
{
-           if ( drmMap( psav->drmFD,
+           if (pSAVAGEDRIServer->agpXVideo.map == NULL &&
+               drmMap( psav->drmFD,
                pSAVAGEDRIServer->agpXVideo.handle,
                pSAVAGEDRIServer->agpXVideo.size,
                &pSAVAGEDRIServer->agpXVideo.map ) < 0 ) {
-- 
1.6.0.6

>From 4028dd0e0a351bdca9af2032717e97f5c7added6 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Alex=20Villac=C3=ADs=20Lasso?= <a_villa...@palosanto.com>
Date: Sun, 12 Apr 2009 16:07:06 -0500
Subject: [PATCH] Do not use XAAGetCopyROP outside of XAA-specific code

The DRI code attempts to use XAAGetCopyROP without checking whether XAA or EXA 
is in effect. This results in the server crashing with an undefined-symbol 
error when enabling EXA, then starting glxgears under GNOME/Metacity and 
attempting to drag the glxgears window.

The EXA code happens to have a functional duplicate of the required code under 
the name SavageGetCopyROP(). This patch moves the code to savage_accel.c where 
it is now shared between EXA and the DRI code.

It is disturbing that this has not been caught before.
---
 src/savage_accel.c |   26 ++++++++++++++++++++++++++
 src/savage_dri.c   |    5 ++++-
 src/savage_exa.c   |   27 ++-------------------------
 3 files changed, 32 insertions(+), 26 deletions(-)

diff --git a/src/savage_accel.c b/src/savage_accel.c
index 450b402..73c2d90 100644
--- a/src/savage_accel.c
+++ b/src/savage_accel.c
@@ -1537,6 +1537,32 @@ SavageInitAccel(ScreenPtr pScreen)
        return SavageXAAInit(pScreen);
 }
 
+int SavageGetCopyROP(int rop) {
+
+    int ALUCopyROP[16] =
+    {
+       0x00, /*ROP_0 GXclear */
+       0x88, /*ROP_DSa GXand */
+       0x44, /*ROP_SDna GXandReverse */
+       0xCC, /*ROP_S GXcopy */
+       0x22, /*ROP_DSna GXandInverted */
+       0xAA, /*ROP_D GXnoop */
+       0x66, /*ROP_DSx GXxor */
+       0xEE, /*ROP_DSo GXor */
+       0x11, /*ROP_DSon GXnor */
+       0x99, /*ROP_DSxn GXequiv */
+       0x55, /*ROP_Dn GXinvert*/
+       0xDD, /*ROP_SDno GXorReverse */
+       0x33, /*ROP_Sn GXcopyInverted */
+       0xBB, /*ROP_DSno GXorInverted */
+       0x77, /*ROP_DSan GXnand */
+       0xFF, /*ROP_1 GXset */
+    };
+
+    return (ALUCopyROP[rop]);
+
+}
+
 /* Routines for debugging. */
 
 
diff --git a/src/savage_dri.c b/src/savage_dri.c
index 216c915..190e8ee 100644
--- a/src/savage_dri.c
+++ b/src/savage_dri.c
@@ -1578,6 +1578,9 @@ SAVAGEDRIMoveBuffers(WindowPtr pParent, DDXPointRec 
ptOldOrg,
        psav->AccelInfoRec->NeedToSync = TRUE;
 }
 
+/* Definition in savage_accel.c */
+int SavageGetCopyROP(int rop);
+
 static void 
 SAVAGEDRISetupForScreenToScreenCopy(
     ScrnInfoPtr pScrn,
@@ -1591,7 +1594,7 @@ SAVAGEDRISetupForScreenToScreenCopy(
     int cmd =0;
 
     cmd = BCI_CMD_RECT | BCI_CMD_DEST_PBD | BCI_CMD_SRC_PBD_COLOR;
-    BCI_CMD_SET_ROP( cmd, XAAGetCopyROP(rop) );
+    BCI_CMD_SET_ROP( cmd, SavageGetCopyROP(rop) );
     if (transparency_color != -1)
         cmd |= BCI_CMD_SEND_COLOR | BCI_CMD_SRC_TRANSPARENT;
 
diff --git a/src/savage_exa.c b/src/savage_exa.c
index 08524f0..3fc8f30 100644
--- a/src/savage_exa.c
+++ b/src/savage_exa.c
@@ -69,31 +69,8 @@ SavageDownloadFromScreen(PixmapPtr pSrc, int x, int y, int 
w, int h, char *dst,
 #define        GXset   0xFF
 #endif
 
-static int SavageGetCopyROP(int rop) {
-
-    int ALUCopyROP[16] =
-    {
-       0x00, /*ROP_0 GXclear */
-       0x88, /*ROP_DSa GXand */
-       0x44, /*ROP_SDna GXandReverse */
-       0xCC, /*ROP_S GXcopy */
-       0x22, /*ROP_DSna GXandInverted */
-       0xAA, /*ROP_D GXnoop */
-       0x66, /*ROP_DSx GXxor */
-       0xEE, /*ROP_DSo GXor */
-       0x11, /*ROP_DSon GXnor */
-       0x99, /*ROP_DSxn GXequiv */
-       0x55, /*ROP_Dn GXinvert*/
-       0xDD, /*ROP_SDno GXorReverse */
-       0x33, /*ROP_Sn GXcopyInverted */
-       0xBB, /*ROP_DSno GXorInverted */
-       0x77, /*ROP_DSan GXnand */
-       0xFF, /*ROP_1 GXset */
-    };
-
-    return (ALUCopyROP[rop]);
-
-}
+/* Definition moved to savage_accel.c */
+int SavageGetCopyROP(int rop);
 
 static int SavageGetSolidROP(int rop) {
 
-- 
1.6.0.6

_______________________________________________
xorg mailing list
xorg@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/xorg

Reply via email to