diff options
author | Jordan Crouse <jordan.crouse@amd.com> | 2006-08-15 13:14:01 -0600 |
---|---|---|
committer | Jordan Crouse <jordan.crouse@amd.com> | 2006-08-15 13:15:15 -0600 |
commit | 38f3d21beba13daba4844a129f3c268b5f291fb1 (patch) | |
tree | ca46fa7aa0bd48ae281971969a660c279aa7d758 /src | |
parent | 9d8d08c6a7449faf9c52d728eeb5793180eaf98e (diff) |
PATCH: When compression is off, adjust the pitch to be linear, saving memory
Diffstat (limited to 'src')
-rw-r--r-- | src/amd_gx_accel.c | 9 | ||||
-rw-r--r-- | src/amd_gx_driver.c | 45 | ||||
-rw-r--r-- | src/amd_gx_video.c | 24 |
3 files changed, 58 insertions, 20 deletions
diff --git a/src/amd_gx_accel.c b/src/amd_gx_accel.c index 50666e6..20c79ef 100644 --- a/src/amd_gx_accel.c +++ b/src/amd_gx_accel.c @@ -109,8 +109,9 @@ extern FILE *zdfp; do {} while(0) #endif /* if DEBUGLVL > 0 */ -#define CALC_FBOFFSET(x, y) \ - (((ulong)(y) << gu2_yshift) | ((ulong)(x) << gu2_xshift)) +#define CALC_FBOFFSET(x, y) \ + (((ulong)(y) * gu2_pitch) + ((ulong)(x) << gu2_xshift)) + #define FBADDR(x,y) \ ((unsigned char *)pGeode->FBBase + CALC_FBOFFSET(x, y)) @@ -165,6 +166,8 @@ static GDashLine gdln; #endif static unsigned int gu2_xshift, gu2_yshift; +static unsigned int gu2_pitch; + static XAAInfoRecPtr localRecPtr; /* pat 0xF0 */ @@ -2027,6 +2030,7 @@ GXAccelInit(ScreenPtr pScrn) #endif gu2_xshift = pScrni->bitsPerPixel >> 4; + gu2_pitch = pGeode->AccelPitch; switch (pGeode->AccelPitch) { case 1024: @@ -2043,6 +2047,7 @@ GXAccelInit(ScreenPtr pScrn) break; } + #ifdef OPT_ACCEL ACCEL_STRIDE = (pGeode->AccelPitch << 16) | pGeode->AccelPitch; switch (pScrni->bitsPerPixel) { diff --git a/src/amd_gx_driver.c b/src/amd_gx_driver.c index 09a9d40..29d3aa0 100644 --- a/src/amd_gx_driver.c +++ b/src/amd_gx_driver.c @@ -856,21 +856,36 @@ GXPreInit(ScrnInfoPtr pScrni, int flags) * * already takes care of this, we don't worry about setting them here. */ /* Select valid modes from those available */ + /* * * min pitch 1024, max 2048 (Pixel count) * * min height 480, max 1024 (Pixel count) */ + minPitch = 1024; maxPitch = 8192; /* Can support upto 1600x1200 32Bpp */ maxWidth = 1600; minHeight = 400; maxHeight = 1200; /* Can support upto 1600x1200 32Bpp */ - if (pScrni->depth > 16) { - PitchInc = 4096; - } else if (pScrni->depth == 16) { - PitchInc = 2048; - } else { - PitchInc = 1024; + + + if (pGeode->Compression) { + if (pScrni->depth > 16) { + PitchInc = 4096; + } else if (pScrni->depth == 16) { + PitchInc = 2048; + } else { + PitchInc = 1024; + } + } + else { + /* When compression is off - use a linear pitch */ + if (pScrni->depth < 16) + PitchInc = 1600; + else if (pScrni->depth == 16) + PitchInc = 3200; + else + PitchInc = 6400; } PitchInc <<= 3; /* in bits */ @@ -1731,8 +1746,12 @@ GXScreenInit(int scrnIndex, ScreenPtr pScrn, int argc, char **argv) if (!GXMapMem(pScrni)) return FALSE; - pGeode->Pitch = GXCalculatePitchBytes(pScrni->virtualX, - pScrni->bitsPerPixel); + /* If compression is not turned on - adjust the pitch to be linear */ + if (pGeode->Compression) + pGeode->Pitch = GXCalculatePitchBytes(pScrni->virtualX, pScrni->bitsPerPixel); + else + pGeode->Pitch = ((pScrni->virtualX + 3) & ~3) * (pScrni->bitsPerPixel >> 3); + pGeode->AccelPitch = pGeode->Pitch; bytpp = (pScrni->bitsPerPixel + 7) / 8; @@ -2370,6 +2389,8 @@ GXValidMode(int scrnIndex, DisplayModePtr pMode, Bool Verbose, int flags) unsigned int total_memory_required; ScrnInfoPtr pScrni = xf86Screens[scrnIndex]; int ret = -1; + unsigned int ptch; + GeodeRec *pGeode = GEODEPTR(pScrni); DEBUGMSG(1, (0, X_NONE, "GeodeValidateMode: %dx%d %d %d\n", @@ -2402,8 +2423,12 @@ GXValidMode(int scrnIndex, DisplayModePtr pMode, Bool Verbose, int flags) return MODE_NOMODE; } - total_memory_required = GXCalculatePitchBytes(pMode->CrtcHDisplay, - pScrni->bitsPerPixel) * pMode->CrtcVDisplay; + if (pGeode->Compression) + ptch = GXCalculatePitchBytes(pMode->CrtcHDisplay, pScrni->bitsPerPixel); + else + ptch = ((pMode->CrtcHDisplay + 3) & ~3) * (pScrni->bitsPerPixel >> 3); + + total_memory_required = ptch * pMode->CrtcVDisplay; DEBUGMSG(1, (0, X_NONE, "Total Mem %X %lX\n", total_memory_required, pGeode->FBAvail)); diff --git a/src/amd_gx_video.c b/src/amd_gx_video.c index e8ee152..41d0be0 100644 --- a/src/amd_gx_video.c +++ b/src/amd_gx_video.c @@ -377,7 +377,7 @@ GXSetupImageVideo(ScreenPtr pScrn) adapt->PutStill = NULL; adapt->GetVideo = NULL; adapt->GetStill = NULL; - adapt->StopVideo = GXStopVideo; + adapt->StopVideo= GXStopVideo; adapt->SetPortAttribute = GXSetPortAttribute; adapt->GetPortAttribute = GXGetPortAttribute; adapt->QueryBestSize = GXQueryBestSize; @@ -677,19 +677,21 @@ static FBAreaPtr GXAllocateMemory(ScrnInfoPtr pScrni, FBAreaPtr area, int numlines) { ScreenPtr pScrn = screenInfo.screens[pScrni->scrnIndex]; + GeodeRec *pGeode = GEODEPTR(pScrni); FBAreaPtr new_area; + long displayWidth = pGeode->AccelPitch / ((pScrni->bitsPerPixel + 7) / 8); if (area) { if ((area->box.y2 - area->box.y1) >= numlines) return area; - if (xf86ResizeOffscreenArea(area, pScrni->displayWidth, numlines)) + if (xf86ResizeOffscreenArea(area, displayWidth, numlines)) return area; xf86FreeOffscreenArea(area); } - new_area = xf86AllocateOffscreenArea(pScrn, pScrni->displayWidth, + new_area = xf86AllocateOffscreenArea(pScrn, displayWidth, numlines, 0, NULL, NULL, NULL); if (!new_area) { @@ -698,11 +700,13 @@ GXAllocateMemory(ScrnInfoPtr pScrni, FBAreaPtr area, int numlines) xf86QueryLargestOffscreenArea(pScrn, &max_w, &max_h, 0, FAVOR_WIDTH_THEN_AREA, PRIORITY_EXTREME); - if ((max_w < pScrni->displayWidth) || (max_h < numlines)) - return NULL; + if ((max_w < displayWidth) || (max_h < numlines)) { + xf86DrvMsg(pScrni->scrnIndex, X_ERROR, "No room - how sad %x, %x, %x, %x\n", max_w, displayWidth, max_h, numlines); + return NULL; + } xf86PurgeUnlockedOffscreenAreas(pScrn); - new_area = xf86AllocateOffscreenArea(pScrn, pScrni->displayWidth, + new_area = xf86AllocateOffscreenArea(pScrn, displayWidth, numlines, 0, NULL, NULL, NULL); } @@ -1029,9 +1033,13 @@ GXPutImage(ScrnInfoPtr pScrni, if (pPriv->doubleBuffer) new_h <<= 1; #endif - if (!(pPriv->area = GXAllocateMemory(pScrni, pPriv->area, new_h))) - return BadAlloc; + if (!(pPriv->area = GXAllocateMemory(pScrni, pPriv->area, new_h))) { + xf86DrvMsg(pScrni->scrnIndex, X_ERROR, + "Could not allocate area of size %d\n", new_h); + return BadAlloc; + } + /* copy data */ top = By1; left = Bx1 & ~1; |