[Xorg-driver-geode] [PATCH 2/2] Modify Ctrc rotate operation and Graphic memory allocate

Cui, Hunk Hunk.Cui at amd.com
Wed Jun 30 19:28:10 PDT 2010


From: Hunk Cui <Hunk.Cui at amd.com>

*Redistribute the Graphic memory (include in MemorySize).
*Prepare allocate the shadow buffer, normally do Rotate operation.
*Classic exa is made on the assumption that all memory usable for gpu
*acceleration is a linear range between memoryBase and memorySize.
*Before modify, the Rotate_mem after memorySize could belong to another
*device. This is the error key point.
*Rotateeddata has to be allocated between memoryBase and memorySize.
*Recommand normally working: Setup Graphic memory in BIOS >=14MB
*Ubuntu Bugzilla #377929

Signed-off-by: Hunk Cui <Hunk.Cui at amd.com>
---
 src/geode.h      |    4 ++++
 src/lx_display.c |   14 +++++---------
 src/lx_memory.c  |   24 +++++++++++++++++++-----
 3 files changed, 28 insertions(+), 14 deletions(-)

diff --git a/src/geode.h b/src/geode.h
index 8fe67b5..4f5f340 100644
--- a/src/geode.h
+++ b/src/geode.h
@@ -221,6 +221,10 @@ typedef struct _geodeRec
     unsigned int exaBfrOffset;
     unsigned int exaBfrSz;
 
+    /* Rotate structures */
+    unsigned int RotateBfrOffset;
+    unsigned int RotateBfrSz;
+
     /* Other structures */
 
     EntityInfoPtr pEnt;
diff --git a/src/lx_display.c b/src/lx_display.c
index e36fe59..583f848 100644
--- a/src/lx_display.c
+++ b/src/lx_display.c
@@ -368,15 +368,12 @@ 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);
-
-    if (lx_crtc->rotate_mem == NULL) {
+    if (pGeode->RotateBfrOffset == NULL) {
 	xf86DrvMsg(pScrni->scrnIndex, X_ERROR,
 	    "Couldn't allocate the shadow memory for rotation\n");
 	xf86DrvMsg(pScrni->scrnIndex, X_ERROR,
@@ -386,8 +383,9 @@ 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->RotateBfrOffset, 0, size);
+    return pGeode->FBBase + pGeode->RotateBfrOffset;
+
 }
 
 static PixmapPtr
@@ -417,15 +415,13 @@ 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);
 
     if (data) {
 	gp_wait_until_idle();
-	GeodeFreeOffscreen(pGeode, lx_crtc->rotate_mem);
-	lx_crtc->rotate_mem = NULL;
+	memset(data, 0, pGeode->RotateBfrSz);
     }
 }
 
diff --git a/src/lx_memory.c b/src/lx_memory.c
index 3f853d4..782faaa 100644
--- a/src/lx_memory.c
+++ b/src/lx_memory.c
@@ -236,11 +236,21 @@ LXInitOffscreen(ScrnInfoPtr pScrni)
 	pGeode->pExa->offScreenBase = 0;
 	pGeode->pExa->memorySize = 0;
 
+        /* Advance prepare allocate the size of a shadow buffer */
+        size = pScrni->virtualX *
+        (pScrni->virtualY * (pScrni->bitsPerPixel >> 3));
+
+        ptr = GeodeAllocOffscreen(pGeode, size, 4);
+        if (ptr != NULL) {
+            pGeode->RotateBfrOffset = ptr->offset;
+            pGeode->RotateBfrSz = ptr->size;
+        }
+
 	/* This might cause complaints - in order to avoid using
            xorg.conf as much as possible, we make assumptions about
            what a "default" memory map would look like.  After
            discussion, we agreed that the default driver should assume
-           the user will want to use rotation and video overlays, and
+           the user will want to use video overlays, and
 	   EXA will get whatever is leftover. 
         */
 
@@ -250,10 +260,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 +293,14 @@ 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->RotateBfrSz)
+        xf86DrvMsg(pScrni->scrnIndex, X_INFO, " RotateBfrSz: 0x%x
bytes\n",
+            pGeode->RotateBfrSz);
+
     if (pGeode->pExa->offScreenBase)
 	xf86DrvMsg(pScrni->scrnIndex, X_INFO, " EXA: 0x%x bytes\n",
 	    (unsigned int)(pGeode->pExa->memorySize -
-- 
1.7.1




More information about the Xorg-driver-geode mailing list