From: Hunk Cui <[email protected]>

*Del for deduct the probable size of a shadow buffer.
*Use exaOffscreenAlloc allocate the shadow buffer.
*Rotateeddata has to be allocate in offscreen memory range.
*Ubuntu Bugzilla #377929

Signed-off-by: Hunk Cui <[email protected]>
---
 src/geode.h      |    2 ++
 src/lx_display.c |   46 ++++++++++++++++++++++++++++++++++++++--------
 src/lx_memory.c  |    8 ++++----
 3 files changed, 44 insertions(+), 12 deletions(-)

diff --git a/src/geode.h b/src/geode.h
index 8fe67b5..ad94a02 100644
--- a/src/geode.h
+++ b/src/geode.h
@@ -210,6 +210,8 @@ typedef struct _geodeRec
     int Pitch;                        /* display FB pitch */
     int displaySize;                  /* The size of the visibile area
*/
 
+    ExaOffscreenArea *shadowArea;
+
     /* Framebuffer memory */
 
     unsigned char *FBBase;
diff --git a/src/lx_display.c b/src/lx_display.c
index 856ad95..4f7c4ed 100644
--- a/src/lx_display.c
+++ b/src/lx_display.c
@@ -363,20 +363,48 @@ lx_crtc_gamma_set(xf86CrtcPtr crtc, CARD16 * red,
CARD16 * green,
     WRITE_VID32(DF_DISPLAY_CONFIG, dcfg);
 }
 
+    /* Allocates shadow memory, and allocating a new space for
Rotatation.
+     * The size is measured in bytes, and the offset from the beginning
+     * of card space is returned.
+     */
+
+Bool
+LXAllocShadow(ScrnInfoPtr pScrni, int size)
+{
+    GeodeRec *pGeode = GEODEPTR(pScrni);
+
+    if (pGeode->shadowArea) {
+       if (pGeode->shadowArea->size != size) {
+               exaOffscreenFree(pScrni->pScreen, pGeode->shadowArea);
+               pGeode->shadowArea = NULL;
+       }
+    }
+
+    if (pGeode->shadowArea == NULL) {
+       pGeode->shadowArea =
+               exaOffscreenAlloc(pScrni->pScreen, size, 4, TRUE,
+               NULL, NULL);
+
+       if (pGeode->shadowArea == NULL)
+               return FALSE;
+    }
+
+    pScrni->fbOffset = pGeode->shadowArea->offset;
+}
+
 static void *
 lx_crtc_shadow_allocate(xf86CrtcPtr crtc, int width, int height)
 {
     ScrnInfoPtr pScrni = crtc->scrn;
     GeodePtr pGeode = GEODEPTR(pScrni);
-    LXCrtcPrivatePtr lx_crtc = crtc->driver_private;
     unsigned int rpitch, size;
 
     rpitch = pScrni->displayWidth * (pScrni->bitsPerPixel / 8);
     size = rpitch * height;
 
-    lx_crtc->rotate_mem = GeodeAllocOffscreen(pGeode, size, 4);
+    LXAllocShadow(pScrni, size); /* Allocate shadow memory */
 
-    if (lx_crtc->rotate_mem == NULL) {
+    if (pGeode->shadowArea->offset == NULL) {
        xf86DrvMsg(pScrni->scrnIndex, X_ERROR,
            "Couldn't allocate the shadow memory for rotation\n");
        xf86DrvMsg(pScrni->scrnIndex, X_ERROR,
@@ -386,8 +414,8 @@ lx_crtc_shadow_allocate(xf86CrtcPtr crtc, int width,
int height)
        return NULL;
     }
 
-    memset(pGeode->FBBase + lx_crtc->rotate_mem->offset, 0, size);
-    return pGeode->FBBase + lx_crtc->rotate_mem->offset;
+    memset(pGeode->FBBase + pGeode->shadowArea->offset, 0, size);
+    return pGeode->FBBase + pGeode->shadowArea->offset;
 }
 
 static PixmapPtr
@@ -417,15 +445,17 @@ lx_crtc_shadow_destroy(xf86CrtcPtr crtc, PixmapPtr
rpixmap, void *data)
 {
     ScrnInfoPtr pScrni = crtc->scrn;
     GeodeRec *pGeode = GEODEPTR(pScrni);
-    LXCrtcPrivatePtr lx_crtc = crtc->driver_private;
 
     if (rpixmap)
        FreeScratchPixmapHeader(rpixmap);
 
+    /* Free shadow memory */
     if (data) {
        gp_wait_until_idle();
-       GeodeFreeOffscreen(pGeode, lx_crtc->rotate_mem);
-       lx_crtc->rotate_mem = NULL;
+       if (pGeode->shadowArea != NULL) {
+       exaOffscreenFree(pScrni->pScreen, pGeode->shadowArea);
+       pGeode->shadowArea = NULL;
+       }
     }
 }
 
diff --git a/src/lx_memory.c b/src/lx_memory.c
index 3f853d4..2106526 100644
--- a/src/lx_memory.c
+++ b/src/lx_memory.c
@@ -249,10 +249,6 @@ LXInitOffscreen(ScrnInfoPtr pScrni)
 
        /* Deduct the maxmimum size of a video overlay */
        size -= 0x200000;       
-       
-       /* Deduct the probable size of a shadow buffer */
-       size -= pScrni->virtualX *
-       (pScrni->virtualY * (pScrni->bitsPerPixel >> 3));
 
        /* Align the size to a K boundary */    
        size &= ~1023;
@@ -287,6 +283,10 @@ LXInitOffscreen(ScrnInfoPtr pScrni)
        xf86DrvMsg(pScrni->scrnIndex, X_INFO, " Cursor: 0x%x bytes\n",
            LX_CURSOR_HW_WIDTH * 4 * LX_CURSOR_HW_HEIGHT);
 
+    if (pGeode->exaBfrSz)
+       xf86DrvMsg(pScrni->scrnIndex, X_INFO, " ExaBfrSz: 0x%x bytes\n",
+           pGeode->exaBfrSz);
+
     if (pGeode->pExa->offScreenBase)
        xf86DrvMsg(pScrni->scrnIndex, X_INFO, " EXA: 0x%x bytes\n",
            (unsigned int)(pGeode->pExa->memorySize -
-- 
1.7.1


_______________________________________________
Xorg-driver-geode mailing list
[email protected]
http://lists.x.org/mailman/listinfo/xorg-driver-geode

Reply via email to