[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

xserver-xorg-video-ati: Changes to 'upstream-experimental'



 src/Makefile.am                   |    3 
 src/ati_pciids_gen.h              |    1 
 src/atombios_crtc.c               |    9 
 src/bicubic_table.h               |  646 +++++++++++++++++++++
 src/bicubic_table.py              |   72 ++
 src/legacy_crtc.c                 |   26 
 src/legacy_output.c               |    9 
 src/pcidb/ati_pciids.csv          |    1 
 src/radeon.h                      |  525 +++++++++--------
 src/radeon_accel.c                |  265 +++-----
 src/radeon_accelfuncs.c           |  348 +++++------
 src/radeon_atombios.c             |   57 -
 src/radeon_bios.c                 |  320 ++++++++--
 src/radeon_chipinfo_gen.h         |    1 
 src/radeon_chipset_gen.h          |    1 
 src/radeon_common.h               |  496 ----------------
 src/radeon_commonfuncs.c          |   33 -
 src/radeon_crtc.c                 |  117 ---
 src/radeon_cursor.c               |   47 -
 src/radeon_dga.c                  |   49 -
 src/radeon_dri.c                  |  711 +++++++++++------------
 src/radeon_dripriv.h              |   63 --
 src/radeon_driver.c               |  364 ++++++------
 src/radeon_drm.h                  |  755 ++++++++++++++++++++++++
 src/radeon_exa.c                  |  148 ++--
 src/radeon_exa_funcs.c            |  104 +--
 src/radeon_exa_render.c           |  186 +++---
 src/radeon_memory.c               |  118 +++
 src/radeon_output.c               |  151 +---
 src/radeon_pci_chipset_gen.h      |    1 
 src/radeon_pci_device_match_gen.h |    1 
 src/radeon_probe.h                |   12 
 src/radeon_reg.h                  |   28 
 src/radeon_render.c               |   65 +-
 src/radeon_sarea.h                |  231 -------
 src/radeon_textured_video.c       |  124 +++-
 src/radeon_textured_videofuncs.c  | 1150 ++++++++++++++++++++++++++++----------
 src/radeon_tv.c                   |  170 ++++-
 src/radeon_tv.h                   |   19 
 src/radeon_video.c                |  201 +-----
 src/radeon_video.h                |   25 
 41 files changed, 4582 insertions(+), 3071 deletions(-)

New commits:
commit a3cc1d7a421456186024c5c069e403d374a0f0b9
Author: Dave Airlie <airlied@linux.ie>
Date:   Tue Aug 26 08:03:20 2008 +1000

    radeon: fix powerpc build

diff --git a/src/radeon_exa.c b/src/radeon_exa.c
index 3945300..0f86fdd 100644
--- a/src/radeon_exa.c
+++ b/src/radeon_exa.c
@@ -234,7 +234,7 @@ static Bool RADEONPrepareAccess(PixmapPtr pPix, int index)
     }
 #if defined(XF86DRI)
     if (info->directRenderingEnabled && info->allowColorTiling) {
-	drmRadeonSurfaceAlloc drmsurfalloc;
+	struct drm_radeon_surface_alloc drmsurfalloc;
 	int rc;
 
         drmsurfalloc.address = offset;
@@ -277,7 +277,7 @@ static void RADEONFinishAccess(PixmapPtr pPix, int index)
         return;
 #if defined(XF86DRI)
     if (info->directRenderingEnabled && info->allowColorTiling) {
-	drmRadeonSurfaceFree drmsurffree;
+	struct drm_radeon_surface_free drmsurffree;
 
 	drmsurffree.address = offset;
 	drmCommandWrite(info->dri->drmFD, DRM_RADEON_SURF_FREE,

commit 6cebfe257f7ddad855ee743e4eb899bd6fac7f46
Author: Alex Deucher <alexdeucher@gmail.com>
Date:   Fri Jul 11 19:32:06 2008 -0400

    Switch EXA path back to static cursor allocation
    
    pre-AVIVO cards have address limits for the cursor offset

diff --git a/src/radeon_cursor.c b/src/radeon_cursor.c
index 11fd498..22a33d6 100644
--- a/src/radeon_cursor.c
+++ b/src/radeon_cursor.c
@@ -335,21 +335,23 @@ Bool RADEONCursorInit(ScreenPtr pScreen)
     height      = ((size_bytes * xf86_config->num_crtc) + width_bytes - 1) / width_bytes;
     int align = IS_AVIVO_VARIANT ? 4096 : 256;
 
-    for (c = 0; c < xf86_config->num_crtc; c++) {
-	xf86CrtcPtr crtc = xf86_config->crtc[c];
-	RADEONCrtcPrivatePtr radeon_crtc = crtc->driver_private;
-
-	radeon_crtc->cursor_offset =
-	    radeon_allocate_memory(pScrn, &radeon_crtc->cursor_mem, size_bytes, align);
-
-	if (radeon_crtc->cursor_offset == 0)
-	    return FALSE;
-
-	xf86DrvMsg(pScrn->scrnIndex, X_INFO,
-		   "Will use %d kb for hardware cursor %d at offset 0x%08x\n",
-		   (size_bytes * xf86_config->num_crtc) / 1024,
-		   c,
-		   (unsigned int)radeon_crtc->cursor_offset);
+    if (!info->useEXA) {
+	for (c = 0; c < xf86_config->num_crtc; c++) {
+	    xf86CrtcPtr crtc = xf86_config->crtc[c];
+	    RADEONCrtcPrivatePtr radeon_crtc = crtc->driver_private;
+
+	    radeon_crtc->cursor_offset =
+		radeon_allocate_memory(pScrn, &radeon_crtc->cursor_mem, size_bytes, align);
+
+	    if (radeon_crtc->cursor_offset == 0)
+		return FALSE;
+
+	    xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+		       "Will use %d kb for hardware cursor %d at offset 0x%08x\n",
+		       (size_bytes * xf86_config->num_crtc) / 1024,
+		       c,
+		       (unsigned int)radeon_crtc->cursor_offset);
+	}
     }
 
     return xf86_cursors_init (pScreen, CURSOR_WIDTH, CURSOR_HEIGHT,
diff --git a/src/radeon_exa.c b/src/radeon_exa.c
index a1b93b5..3945300 100644
--- a/src/radeon_exa.c
+++ b/src/radeon_exa.c
@@ -386,6 +386,7 @@ Bool RADEONSetupMemEXA (ScreenPtr pScreen)
 {
     ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
     RADEONInfoPtr info = RADEONPTR(pScrn);
+    xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
     int cpp = info->CurrentLayout.pixel_bytes;
     int screen_size;
     int byteStride = pScrn->displayWidth * cpp;
@@ -413,6 +414,27 @@ Bool RADEONSetupMemEXA (ScreenPtr pScreen)
     xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Allocating from a screen of %ld kb\n",
 	       info->accel_state->exa->memorySize / 1024);
 
+    /* Reserve static area for hardware cursor */
+    if (!xf86ReturnOptValBool(info->Options, OPTION_SW_CURSOR, FALSE)) {
+        int cursor_size = 64 * 4 * 64;
+        int align = IS_AVIVO_VARIANT ? 4096 : 256;
+        int c;
+
+        for (c = 0; c < xf86_config->num_crtc; c++) {
+            xf86CrtcPtr crtc = xf86_config->crtc[c];
+            RADEONCrtcPrivatePtr radeon_crtc = crtc->driver_private;
+
+            radeon_crtc->cursor_offset =
+                RADEON_ALIGN(info->accel_state->exa->offScreenBase, align);
+            info->accel_state->exa->offScreenBase = radeon_crtc->cursor_offset + cursor_size;
+
+            xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+                       "Will use %d kb for hardware cursor %d at offset 0x%08x\n",
+                       (cursor_size * xf86_config->num_crtc) / 1024,
+                       c,
+                       (unsigned int)radeon_crtc->cursor_offset);
+        }
+    }
 
 #if defined(XF86DRI)
     if (info->directRenderingEnabled) {

commit 4dff54a3c8d7c9f2d6ec50354ff0b92f1b7fcbdf
Author: Alex Deucher <alexdeucher@gmail.com>
Date:   Fri Jul 11 17:28:03 2008 -0400

    Switch cursors over to generic allocator

diff --git a/src/radeon_cursor.c b/src/radeon_cursor.c
index 13c2b9c..11fd498 100644
--- a/src/radeon_cursor.c
+++ b/src/radeon_cursor.c
@@ -327,49 +327,30 @@ Bool RADEONCursorInit(ScreenPtr pScreen)
     int		       width_bytes;
     int                height;
     int                size_bytes;
-    uint32_t           cursor_offset = 0;
     int                c;
 
     size_bytes  = CURSOR_WIDTH * 4 * CURSOR_HEIGHT;
     width       = pScrn->displayWidth;
     width_bytes = width * (pScrn->bitsPerPixel / 8);
     height      = ((size_bytes * xf86_config->num_crtc) + width_bytes - 1) / width_bytes;
+    int align = IS_AVIVO_VARIANT ? 4096 : 256;
 
-#ifdef USE_XAA
-    if (!info->useEXA) {
-	int align = IS_AVIVO_VARIANT ? 4096 : 256;
-	FBAreaPtr          fbarea;
+    for (c = 0; c < xf86_config->num_crtc; c++) {
+	xf86CrtcPtr crtc = xf86_config->crtc[c];
+	RADEONCrtcPrivatePtr radeon_crtc = crtc->driver_private;
 
-	fbarea = xf86AllocateOffscreenArea(pScreen, width, height,
-					   align, NULL, NULL, NULL);
+	radeon_crtc->cursor_offset =
+	    radeon_allocate_memory(pScrn, &radeon_crtc->cursor_mem, size_bytes, align);
 
-	if (!fbarea) {
-	    cursor_offset    = 0;
-	    xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
-		   "Hardware cursor disabled"
-		   " due to insufficient offscreen memory\n");
+	if (radeon_crtc->cursor_offset == 0)
 	    return FALSE;
-	} else {
-	    cursor_offset  = RADEON_ALIGN((fbarea->box.x1 +
-					   fbarea->box.y1 * width) *
-					  info->CurrentLayout.pixel_bytes,
-					  align);
 
-	    for (c = 0; c < xf86_config->num_crtc; c++) {
-		xf86CrtcPtr crtc = xf86_config->crtc[c];
-		RADEONCrtcPrivatePtr radeon_crtc = crtc->driver_private;
-
-		radeon_crtc->cursor_offset = cursor_offset + (c * size_bytes);
-
-		xf86DrvMsg(pScrn->scrnIndex, X_INFO,
-			   "Using hardware cursor %d (scanline %u)\n", c,
-			   (unsigned)(radeon_crtc->cursor_offset / pScrn->displayWidth
-				      / info->CurrentLayout.pixel_bytes));
-	    }
-
-	}
+	xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+		   "Will use %d kb for hardware cursor %d at offset 0x%08x\n",
+		   (size_bytes * xf86_config->num_crtc) / 1024,
+		   c,
+		   (unsigned int)radeon_crtc->cursor_offset);
     }
-#endif
 
     return xf86_cursors_init (pScreen, CURSOR_WIDTH, CURSOR_HEIGHT,
 			      (HARDWARE_CURSOR_TRUECOLOR_AT_8BPP |
diff --git a/src/radeon_exa.c b/src/radeon_exa.c
index 8beaed7..a1b93b5 100644
--- a/src/radeon_exa.c
+++ b/src/radeon_exa.c
@@ -386,7 +386,6 @@ Bool RADEONSetupMemEXA (ScreenPtr pScreen)
 {
     ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
     RADEONInfoPtr info = RADEONPTR(pScrn);
-    xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
     int cpp = info->CurrentLayout.pixel_bytes;
     int screen_size;
     int byteStride = pScrn->displayWidth * cpp;
@@ -415,30 +414,6 @@ Bool RADEONSetupMemEXA (ScreenPtr pScreen)
 	       info->accel_state->exa->memorySize / 1024);
 
 
-    /* Reserve static area for hardware cursor */
-    if (!xf86ReturnOptValBool(info->Options, OPTION_SW_CURSOR, FALSE)) {
-	int cursor_size = 64 * 4 * 64;
-	int align = IS_AVIVO_VARIANT ? 4096 : 256;
-	int c;
-
-	for (c = 0; c < xf86_config->num_crtc; c++) {
-	    xf86CrtcPtr crtc = xf86_config->crtc[c];
-	    RADEONCrtcPrivatePtr radeon_crtc = crtc->driver_private;
-
-	    radeon_crtc->cursor_offset =
-		RADEON_ALIGN(info->accel_state->exa->offScreenBase, align);
-	    info->accel_state->exa->offScreenBase = radeon_crtc->cursor_offset + cursor_size;
-
-	    xf86DrvMsg(pScrn->scrnIndex, X_INFO,
-		       "Will use %d kb for hardware cursor %d at offset 0x%08x\n",
-		       (cursor_size * xf86_config->num_crtc) / 1024,
-		       c,
-		       (unsigned int)radeon_crtc->cursor_offset);
-	}
-
-
-    }
-
 #if defined(XF86DRI)
     if (info->directRenderingEnabled) {
 	int depthCpp = (info->dri->depthBits - 8) / 4, l, next, depth_size;
diff --git a/src/radeon_memory.c b/src/radeon_memory.c
index d9e6403..178eed0 100644
--- a/src/radeon_memory.c
+++ b/src/radeon_memory.c
@@ -6,7 +6,6 @@
 /* Driver data structures */
 #include "radeon.h"
 
-
 /* Allocates memory, either by resizing the allocation pointed to by mem_struct,
  * or by freeing mem_struct (if non-NULL) and allocating a new space.  The size
  * is measured in bytes, and the offset from the beginning of card space is
@@ -20,9 +19,10 @@ radeon_allocate_memory(ScrnInfoPtr pScrn,
 {
     ScreenPtr pScreen;
     RADEONInfoPtr info = RADEONPTR(pScrn);
-    int offset = 0;
+    uint32_t offset = 0;
 
     pScreen = screenInfo.screens[pScrn->scrnIndex];
+
 #ifdef USE_EXA
     if (info->useEXA) {
 	ExaOffscreenArea *area = *mem_struct;
diff --git a/src/radeon_probe.h b/src/radeon_probe.h
index 8e01b0f..ce4ba93 100644
--- a/src/radeon_probe.h
+++ b/src/radeon_probe.h
@@ -184,6 +184,7 @@ typedef struct
 
 typedef struct _RADEONCrtcPrivateRec {
     void *crtc_rotate_mem;
+    void *cursor_mem;
     int crtc_id;
     int binding;
     uint32_t cursor_offset;

commit 5b1978a4796bcc31ac2f01d303dc8f8f44323025
Author: Alex Deucher <alexdeucher@gmail.com>
Date:   Mon Aug 25 10:05:28 2008 -0400

    Bicubic fixes from the last cherry-pick

diff --git a/src/radeon_textured_video.c b/src/radeon_textured_video.c
index d210a2d..4005df9 100644
--- a/src/radeon_textured_video.c
+++ b/src/radeon_textured_video.c
@@ -213,9 +213,9 @@ RADEONPutImageTextured(ScrnInfoPtr pScrn,
     if (!IS_R500_3D)
 	pPriv->bicubic_enabled = FALSE;
     if (pPriv->bicubic_memory == NULL && pPriv->bicubic_enabled) {
-	pPriv->bicubic_offset = RADEONAllocateMemory(pScrn,
-					&pPriv->bicubic_memory,
-					sizeof(bicubic_tex_512));
+	pPriv->bicubic_offset = radeon_allocate_memory(pScrn,
+						       &pPriv->bicubic_memory,
+						       sizeof(bicubic_tex_512), 64);
 	pPriv->bicubic_src_offset = pPriv->bicubic_offset + info->fbLocation + pScrn->fbOffset;
 	if (pPriv->bicubic_offset == 0)
 		pPriv->bicubic_enabled = FALSE;
diff --git a/src/radeon_video.c b/src/radeon_video.c
index e86a7d4..598bf2b 100644
--- a/src/radeon_video.c
+++ b/src/radeon_video.c
@@ -1614,13 +1614,12 @@ RADEONSetupImageVideo(ScreenPtr pScreen)
 
     pPriv->textured = FALSE;
 
-    if(pPriv->theatre != NULL) 
-    {
+    if(pPriv->theatre != NULL) {
 	/* video decoder is present, extend capabilities */
        adapt->nEncodings = 13;
        adapt->pEncodings = InputVideoEncodings;
        adapt->type |= XvVideoMask;
-       adapt->nAttributes = NUM_DEC_ATTRIBUTES;    
+       adapt->nAttributes = NUM_DEC_ATTRIBUTES;
        adapt->PutVideo = RADEONPutVideo;
     }
 
@@ -1636,8 +1635,19 @@ RADEONStopVideo(ScrnInfoPtr pScrn, pointer data, Bool cleanup)
   unsigned char *RADEONMMIO = info->MMIO;
   RADEONPortPrivPtr pPriv = (RADEONPortPrivPtr)data;
 
-    if (pPriv->textured)
-	return;
+  if (pPriv->textured) {
+      if (cleanup) {
+	  if (pPriv->bicubic_memory != NULL) {
+	      radeon_free_memory(pScrn, pPriv->bicubic_memory);
+	      pPriv->bicubic_memory = NULL;
+	  }
+	  if (pPriv->video_memory != NULL) {
+	      radeon_free_memory(pScrn, pPriv->video_memory);
+	      pPriv->video_memory = NULL;
+	  }
+      }
+      return;
+  }
 
   REGION_EMPTY(pScrn->pScreen, &pPriv->clip);
 
@@ -1660,10 +1670,6 @@ RADEONStopVideo(ScrnInfoPtr pScrn, pointer data, Bool cleanup)
 	 radeon_free_memory(pScrn, pPriv->video_memory);
 	 pPriv->video_memory = NULL;
      }
-     if (pPriv->bicubic_memory != NULL) {
-	 RADEONFreeMemory(pScrn, pPriv->bicubic_memory);
-	 pPriv->bicubic_memory = NULL;
-     }
      pPriv->videoStatus = 0;
   } else {
      if(pPriv->videoStatus & CLIENT_VIDEO_ON) {
@@ -3129,10 +3135,6 @@ RADEONVideoTimerCallback(ScrnInfoPtr pScrn, Time now)
 		    radeon_free_memory(pScrn, pPriv->video_memory);
 		    pPriv->video_memory = NULL;
 		}
-		if (pPriv->bicubic_memory != NULL) {
-		    RADEONFreeMemory(pScrn, pPriv->bicubic_memory);
-		    pPriv->bicubic_memory = NULL;
-		}
 		pPriv->videoStatus = 0;
 		info->VideoTimerCallback = NULL;
 	    }

commit 7daba77ded1c718e93ae8c372a39a6e85228d513
Author: Alex Deucher <alexdeucher@gmail.com>
Date:   Fri Jul 11 02:02:38 2008 -0400

    Convert randr, Xv to a common allocator

diff --git a/src/Makefile.am b/src/Makefile.am
index 97c686b..c79b635 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -88,7 +88,7 @@ radeon_drv_la_LTLIBRARIES = radeon_drv.la
 radeon_drv_la_LDFLAGS = -module -avoid-version
 radeon_drv_ladir = @moduledir@/drivers
 radeon_drv_la_SOURCES = \
-	radeon_accel.c radeon_cursor.c radeon_dga.c \
+	radeon_accel.c radeon_cursor.c radeon_dga.c radeon_memory.c \
 	radeon_driver.c radeon_video.c radeon_bios.c radeon_mm_i2c.c \
 	radeon_vip.c radeon_misc.c radeon_probe.c \
 	legacy_crtc.c legacy_output.c \
@@ -128,7 +128,6 @@ EXTRA_DIST = \
 	radeon_render.c \
 	radeon_accelfuncs.c \
 	radeon_textured_videofuncs.c \
-	\
 	ati.h \
 	ativersion.h \
 	generic_bus.h \
diff --git a/src/radeon.h b/src/radeon.h
index 7ed39f8..6cce736 100644
--- a/src/radeon.h
+++ b/src/radeon.h
@@ -1068,6 +1068,16 @@ extern void RADEONUpdateHVPosition(xf86OutputPtr output, DisplayModePtr mode);
 extern void RADEONInitVideo(ScreenPtr pScreen);
 extern void RADEONResetVideo(ScrnInfoPtr pScrn);
 
+/* radeon_memory.c */
+extern uint32_t
+radeon_allocate_memory(ScrnInfoPtr pScrn,
+		       void **mem_struct,
+		       int size,
+		       int align);
+extern void
+radeon_free_memory(ScrnInfoPtr pScrn,
+		   void *mem_struct);
+
 #ifdef XF86DRI
 #  ifdef USE_XAA
 /* radeon_accelfuncs.c */
diff --git a/src/radeon_crtc.c b/src/radeon_crtc.c
index dce450c..69a87a4 100644
--- a/src/radeon_crtc.c
+++ b/src/radeon_crtc.c
@@ -394,44 +394,6 @@ radeon_crtc_unlock(xf86CrtcPtr crtc)
         RADEON_SYNC(info, pScrn);
 }
 
-#ifdef USE_XAA
-/**
- * Allocates memory from the XF86 linear allocator, but also purges
- * memory if possible to cause the allocation to succeed.
- */
-static FBLinearPtr
-radeon_xf86AllocateOffscreenLinear(ScreenPtr pScreen, int length,
-				 int granularity,
-				 MoveLinearCallbackProcPtr moveCB,
-				 RemoveLinearCallbackProcPtr removeCB,
-				 pointer privData)
-{
-    FBLinearPtr linear;
-    int max_size;
-
-    linear = xf86AllocateOffscreenLinear(pScreen, length, granularity, moveCB,
-					 removeCB, privData);
-    if (linear != NULL)
-	return linear;
-
-    /* The above allocation didn't succeed, so purge unlocked stuff and try
-     * again.
-     */
-    xf86QueryLargestOffscreenLinear(pScreen, &max_size, granularity,
-				    PRIORITY_EXTREME);
-
-    if (max_size < length)
-	return NULL;
-
-    xf86PurgeUnlockedOffscreenAreas(pScreen);
-
-    linear = xf86AllocateOffscreenLinear(pScreen, length, granularity, moveCB,
-					 removeCB, privData);
-
-    return linear;
-}
-#endif
-
 /**
  * Allocates memory for a locked-in-framebuffer shadow of the given
  * width and height for this CRTC's rotated shadow framebuffer.
@@ -441,8 +403,6 @@ static void *
 radeon_crtc_shadow_allocate (xf86CrtcPtr crtc, int width, int height)
 {
     ScrnInfoPtr pScrn = crtc->scrn;
-    /* if this is called during ScreenInit() we don't have pScrn->pScreen yet */
-    ScreenPtr pScreen = screenInfo.screens[pScrn->scrnIndex];
     RADEONInfoPtr  info = RADEONPTR(pScrn);
     RADEONCrtcPrivatePtr radeon_crtc = crtc->driver_private;
     unsigned long rotate_pitch;
@@ -453,49 +413,14 @@ radeon_crtc_shadow_allocate (xf86CrtcPtr crtc, int width, int height)
     rotate_pitch = pScrn->displayWidth * cpp;
     size = rotate_pitch * height;
 
-#ifdef USE_EXA
     /* We could get close to what we want here by just creating a pixmap like
      * normal, but we have to lock it down in framebuffer, and there is no
      * setter for offscreen area locking in EXA currently.  So, we just
      * allocate offscreen memory and fake up a pixmap header for it.
      */
-    if (info->useEXA) {
-	assert(radeon_crtc->rotate_mem_exa == NULL);
-
-	radeon_crtc->rotate_mem_exa = exaOffscreenAlloc(pScreen, size, align,
-						       TRUE, NULL, NULL);
-	if (radeon_crtc->rotate_mem_exa == NULL) {
-	    xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
-		       "Couldn't allocate shadow memory for rotated CRTC\n");
-	    return NULL;
-	}
-	rotate_offset = radeon_crtc->rotate_mem_exa->offset;
-    }
-#endif /* USE_EXA */
-#ifdef USE_XAA
-    if (!info->useEXA) {
-	/* The XFree86 linear allocator operates in units of screen pixels,
-	 * sadly.
-	 */
-	size = (size + cpp - 1) / cpp;
-	align = (align + cpp - 1) / cpp;
-
-	assert(radeon_crtc->rotate_mem_xaa == NULL);
-
-	radeon_crtc->rotate_mem_xaa =
-	    radeon_xf86AllocateOffscreenLinear(pScreen, size, align,
-					       NULL, NULL, NULL);
-	if (radeon_crtc->rotate_mem_xaa == NULL) {
-	    xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
-		       "Couldn't allocate shadow memory for rotated CRTC\n");
-	    return NULL;
-	}
-#ifdef XF86DRI
-	rotate_offset = info->dri->frontOffset +
-	    radeon_crtc->rotate_mem_xaa->offset * cpp;
-#endif
-    }
-#endif /* USE_XAA */
+    rotate_offset = radeon_allocate_memory(pScrn, &radeon_crtc->crtc_rotate_mem, size, align);
+    if (rotate_offset == 0)
+	return NULL;
 
     return info->FB + rotate_offset;
 }
@@ -535,26 +460,14 @@ static void
 radeon_crtc_shadow_destroy(xf86CrtcPtr crtc, PixmapPtr rotate_pixmap, void *data)
 {
     ScrnInfoPtr pScrn = crtc->scrn;
-    RADEONInfoPtr  info = RADEONPTR(pScrn);
     RADEONCrtcPrivatePtr radeon_crtc = crtc->driver_private;
 
     if (rotate_pixmap)
 	FreeScratchPixmapHeader(rotate_pixmap);
-    
-    if (data) {
-#ifdef USE_EXA
-	if (info->useEXA && radeon_crtc->rotate_mem_exa != NULL) {
-	    exaOffscreenFree(pScrn->pScreen, radeon_crtc->rotate_mem_exa);
-	    radeon_crtc->rotate_mem_exa = NULL;
-	}
-#endif /* USE_EXA */
-#ifdef USE_XAA
-	if (!info->useEXA) {
-	    xf86FreeOffscreenLinear(radeon_crtc->rotate_mem_xaa);
-	    radeon_crtc->rotate_mem_xaa = NULL;
-	}
-#endif /* USE_XAA */
-    }
+
+    if (data)
+	radeon_free_memory(pScrn, radeon_crtc->crtc_rotate_mem);
+
 }
 
 static const xf86CrtcFuncsRec radeon_crtc_funcs = {
diff --git a/src/radeon_memory.c b/src/radeon_memory.c
new file mode 100644
index 0000000..d9e6403
--- /dev/null
+++ b/src/radeon_memory.c
@@ -0,0 +1,118 @@
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+/* Driver data structures */
+#include "radeon.h"
+
+
+/* Allocates memory, either by resizing the allocation pointed to by mem_struct,
+ * or by freeing mem_struct (if non-NULL) and allocating a new space.  The size
+ * is measured in bytes, and the offset from the beginning of card space is
+ * returned.
+ */
+uint32_t
+radeon_allocate_memory(ScrnInfoPtr pScrn,
+		       void **mem_struct,
+		       int size,
+		       int align)
+{
+    ScreenPtr pScreen;
+    RADEONInfoPtr info = RADEONPTR(pScrn);
+    int offset = 0;
+
+    pScreen = screenInfo.screens[pScrn->scrnIndex];
+#ifdef USE_EXA
+    if (info->useEXA) {
+	ExaOffscreenArea *area = *mem_struct;
+
+	if (area != NULL) {
+	    if (area->size >= size)
+		return area->offset;
+
+	    exaOffscreenFree(pScrn->pScreen, area);
+	}
+
+	area = exaOffscreenAlloc(pScrn->pScreen, size, align, TRUE,
+				 NULL, NULL);
+
+	*mem_struct = area;
+	if (area == NULL)
+	    return 0;
+	offset = area->offset;
+    }
+#endif /* USE_EXA */
+#ifdef USE_XAA
+    if (!info->useEXA) {
+	FBLinearPtr linear = *mem_struct;
+	int cpp = info->CurrentLayout.bitsPerPixel / 8;
+
+	/* XAA allocates in units of pixels at the screen bpp, so adjust size
+	 * appropriately.
+	 */
+	size = (size + cpp - 1) / cpp;
+	align = (align + cpp - 1) / cpp;
+
+	if (linear) {
+	    if(linear->size >= size)
+		return linear->offset * cpp;
+
+	    if(xf86ResizeOffscreenLinear(linear, size))
+		return linear->offset * cpp;
+
+	    xf86FreeOffscreenLinear(linear);
+	}
+
+	linear = xf86AllocateOffscreenLinear(pScreen, size, align,
+					     NULL, NULL, NULL);
+	*mem_struct = linear;
+
+	if (!linear) {
+	    int max_size;
+
+	    xf86QueryLargestOffscreenLinear(pScreen, &max_size, align,
+					    PRIORITY_EXTREME);
+
+	    if (max_size < size)
+		return 0;
+
+	    xf86PurgeUnlockedOffscreenAreas(pScreen);
+	    linear = xf86AllocateOffscreenLinear(pScreen, size, align,
+						 NULL, NULL, NULL);
+	    *mem_struct = linear;
+	    if (!linear)
+		return 0;
+	}
+	offset = linear->offset * cpp;
+    }
+#endif /* USE_XAA */
+
+    return offset;
+}
+
+void
+radeon_free_memory(ScrnInfoPtr pScrn,
+		   void *mem_struct)
+{
+    RADEONInfoPtr info = RADEONPTR(pScrn);
+
+#ifdef USE_EXA
+    if (info->useEXA) {
+	ExaOffscreenArea *area = mem_struct;
+
+	if (area != NULL)
+	    exaOffscreenFree(pScrn->pScreen, area);
+	area = NULL;
+    }
+#endif /* USE_EXA */
+#ifdef USE_XAA
+    if (!info->useEXA) {
+	FBLinearPtr linear = mem_struct;
+
+	if (linear != NULL)
+	    xf86FreeOffscreenLinear(linear);
+	linear = NULL;
+    }
+#endif /* USE_XAA */
+}
diff --git a/src/radeon_probe.h b/src/radeon_probe.h
index 3770abf..8e01b0f 100644
--- a/src/radeon_probe.h
+++ b/src/radeon_probe.h
@@ -183,12 +183,7 @@ typedef struct
 } RADEONI2CBusRec, *RADEONI2CBusPtr;
 
 typedef struct _RADEONCrtcPrivateRec {
-#ifdef USE_XAA
-    FBLinearPtr rotate_mem_xaa;
-#endif
-#ifdef USE_EXA
-    ExaOffscreenArea *rotate_mem_exa;
-#endif
+    void *crtc_rotate_mem;
     int crtc_id;
     int binding;
     uint32_t cursor_offset;
diff --git a/src/radeon_textured_video.c b/src/radeon_textured_video.c
index 9e6b37a..d210a2d 100644
--- a/src/radeon_textured_video.c
+++ b/src/radeon_textured_video.c
@@ -197,14 +197,14 @@ RADEONPutImageTextured(ScrnInfoPtr pScrn,
        dstPitch = (dstPitch + 15) & ~15;
 
     if (pPriv->video_memory != NULL && size != pPriv->size) {
-	RADEONFreeMemory(pScrn, pPriv->video_memory);
+	radeon_free_memory(pScrn, pPriv->video_memory);
 	pPriv->video_memory = NULL;
     }
 
     if (pPriv->video_memory == NULL) {
-	pPriv->video_offset = RADEONAllocateMemory(pScrn,
-						       &pPriv->video_memory,
-						       size * 2);
+	pPriv->video_offset = radeon_allocate_memory(pScrn,
+						     &pPriv->video_memory,
+						     size * 2, 64);
 	if (pPriv->video_offset == 0)
 	    return BadAlloc;
     }
diff --git a/src/radeon_video.c b/src/radeon_video.c
index e71f0f8..e86a7d4 100644
--- a/src/radeon_video.c
+++ b/src/radeon_video.c
@@ -240,19 +240,6 @@ radeon_crtc_clip_video(ScrnInfoPtr pScrn,
 #endif
 }
 
-#ifdef USE_EXA
-static void
-ATIVideoSave(ScreenPtr pScreen, ExaOffscreenArea *area)
-{
-    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
-    RADEONInfoPtr info = RADEONPTR(pScrn);
-    RADEONPortPrivPtr pPriv = info->adaptor->pPortPrivates[0].ptr;
-
-    if (pPriv->video_memory == area)
-        pPriv->video_memory = NULL;
-}
-#endif /* USE_EXA */
-
 void RADEONInitVideo(ScreenPtr pScreen)
 {
     ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
@@ -1670,7 +1657,7 @@ RADEONStopVideo(ScrnInfoPtr pScrn, pointer data, Bool cleanup)
         if(pPriv->i2c != NULL) RADEON_board_setmisc(pPriv);
      }
      if (pPriv->video_memory != NULL) {
-	 RADEONFreeMemory(pScrn, pPriv->video_memory);
+	 radeon_free_memory(pScrn, pPriv->video_memory);
 	 pPriv->video_memory = NULL;
      }
      if (pPriv->bicubic_memory != NULL) {
@@ -2426,114 +2413,6 @@ RADEONCopyMungedData(
     }
 }
 
-
-/* Allocates memory, either by resizing the allocation pointed to by mem_struct,
- * or by freeing mem_struct (if non-NULL) and allocating a new space.  The size
- * is measured in bytes, and the offset from the beginning of card space is
- * returned.
- */
-uint32_t
-RADEONAllocateMemory(
-   ScrnInfoPtr pScrn,
-   void **mem_struct,
-   int size
-){
-    ScreenPtr pScreen;
-    RADEONInfoPtr info = RADEONPTR(pScrn);
-    int offset = 0;
-
-    pScreen = screenInfo.screens[pScrn->scrnIndex];
-#ifdef USE_EXA
-    if (info->useEXA) {
-	ExaOffscreenArea *area = *mem_struct;
-
-	if (area != NULL) {
-	    if (area->size >= size)
-		return area->offset;
-
-	    exaOffscreenFree(pScrn->pScreen, area);
-	}
-
-	area = exaOffscreenAlloc(pScrn->pScreen, size, 64, TRUE, ATIVideoSave,
-				 NULL);
-	*mem_struct = area;
-	if (area == NULL)
-	    return 0;
-	offset = area->offset;
-    }
-#endif /* USE_EXA */
-#ifdef USE_XAA
-    if (!info->useEXA) {
-	FBLinearPtr linear = *mem_struct;
-	int cpp = info->CurrentLayout.bitsPerPixel / 8;
-
-	/* XAA allocates in units of pixels at the screen bpp, so adjust size
-	 * appropriately.
-	 */
-	size = (size + cpp - 1) / cpp;
-
-	if (linear) {
-	    if(linear->size >= size)
-		return linear->offset * cpp;
-
-	    if(xf86ResizeOffscreenLinear(linear, size))
-		return linear->offset * cpp;
-
-	    xf86FreeOffscreenLinear(linear);
-	}
-
-	linear = xf86AllocateOffscreenLinear(pScreen, size, 16,
-						NULL, NULL, NULL);
-	*mem_struct = linear;
-
-	if (!linear) {
-	    int max_size;
-
-	    xf86QueryLargestOffscreenLinear(pScreen, &max_size, 16,
-					    PRIORITY_EXTREME);
-
-	    if(max_size < size)
-		return 0;
-
-	    xf86PurgeUnlockedOffscreenAreas(pScreen);
-	    linear = xf86AllocateOffscreenLinear(pScreen, size, 16,
-						     NULL, NULL, NULL);
-	    *mem_struct = linear;
-	    if (!linear)
-		return 0;
-	}
-	offset = linear->offset * cpp;
-    }
-#endif /* USE_XAA */
-
-    return offset;
-}
-
-void
-RADEONFreeMemory(
-   ScrnInfoPtr pScrn,
-   void *mem_struct
-){
-    RADEONInfoPtr info = RADEONPTR(pScrn);
-
-#ifdef USE_EXA
-    if (info->useEXA) {
-	ExaOffscreenArea *area = mem_struct;
-
-	if (area != NULL)
-	    exaOffscreenFree(pScrn->pScreen, area);
-    }
-#endif /* USE_EXA */
-#ifdef USE_XAA
-    if (!info->useEXA) {
-	FBLinearPtr linear = mem_struct;
-
-	if (linear != NULL)
-	    xf86FreeOffscreenLinear(linear);
-    }
-#endif /* USE_XAA */
-}
-
 static void
 RADEONDisplayVideo(
     ScrnInfoPtr pScrn,
@@ -3052,9 +2931,9 @@ RADEONPutImage(
    if (idconv == FOURCC_YV12 || id == FOURCC_I420) {
       new_size += (dstPitch >> 1) * ((height + 1) & ~1);
    }
-   pPriv->video_offset = RADEONAllocateMemory(pScrn, &pPriv->video_memory,
-					      (pPriv->doubleBuffer ?
-					       (new_size * 2) : new_size));
+   pPriv->video_offset = radeon_allocate_memory(pScrn, &pPriv->video_memory,
+						(pPriv->doubleBuffer ?
+						 (new_size * 2) : new_size), 64);
    if (pPriv->video_offset == 0)
       return BadAlloc;
 
@@ -3247,7 +3126,7 @@ RADEONVideoTimerCallback(ScrnInfoPtr pScrn, Time now)
 	} else {  /* FREE_TIMER */
 	    if(pPriv->freeTime < now) {
 		if (pPriv->video_memory != NULL) {
-		    RADEONFreeMemory(pScrn, pPriv->video_memory);
+		    radeon_free_memory(pScrn, pPriv->video_memory);
 		    pPriv->video_memory = NULL;
 		}
 		if (pPriv->bicubic_memory != NULL) {
@@ -3286,7 +3165,7 @@ RADEONAllocateSurface(
     pitch = ((w << 1) + 15) & ~15;
     size = pitch * h;
 
-    offset = RADEONAllocateMemory(pScrn, &surface_memory, size);
+    offset = radeon_allocate_memory(pScrn, &surface_memory, size, 64);
     if (offset == 0)
 	return BadAlloc;
 
@@ -3294,18 +3173,18 @@ RADEONAllocateSurface(
     surface->height = h;
 
     if(!(surface->pitches = xalloc(sizeof(int)))) {
-	RADEONFreeMemory(pScrn, surface_memory);
+	radeon_free_memory(pScrn, surface_memory);
 	return BadAlloc;
     }
     if(!(surface->offsets = xalloc(sizeof(int)))) {
 	xfree(surface->pitches);
-	RADEONFreeMemory(pScrn, surface_memory);
+	radeon_free_memory(pScrn, surface_memory);
 	return BadAlloc;
     }
     if(!(pPriv = xalloc(sizeof(OffscreenPrivRec)))) {
 	xfree(surface->pitches);
 	xfree(surface->offsets);
-	RADEONFreeMemory(pScrn, surface_memory);
+	radeon_free_memory(pScrn, surface_memory);
 	return BadAlloc;
     }
 
@@ -3346,7 +3225,7 @@ RADEONFreeSurface(
 
     if(pPriv->isOn)
 	RADEONStopSurface(surface);
-    RADEONFreeMemory(pScrn, pPriv->surface_memory);
+    radeon_free_memory(pScrn, pPriv->surface_memory);
     xfree(surface->pitches);
     xfree(surface->offsets);
     xfree(surface->devPrivate.ptr);
@@ -3620,9 +3499,9 @@ RADEONPutVideo(
    if (pPriv->capture_vbi_data)
       alloc_size += 2 * 2 * vbi_line_width * 21;
 
-   pPriv->video_offset = RADEONAllocateMemory(pScrn, &pPriv->video_memory,
-					      (pPriv->doubleBuffer ?
-					       (new_size * 2) : new_size));
+   pPriv->video_offset = radeon_allocate_memory(pScrn, &pPriv->video_memory,
+						(pPriv->doubleBuffer ?
+						 (new_size * 2) : new_size), 64);
    if (pPriv->video_offset == 0)
       return BadAlloc;
 
diff --git a/src/radeon_video.h b/src/radeon_video.h
index b9d900d..11b8029 100644
--- a/src/radeon_video.h
+++ b/src/radeon_video.h
@@ -86,9 +86,6 @@ typedef struct {
    xf86CrtcPtr   desired_crtc;
 
    int           size;
-#ifdef USE_EXA
-   ExaOffscreenArea *off_screen;
-#endif
 
    void         *video_memory;
    int           video_offset;
@@ -122,11 +119,6 @@ void RADEONResetI2C(ScrnInfoPtr pScrn, RADEONPortPrivPtr pPriv);
 void RADEONVIP_init(ScrnInfoPtr pScrn, RADEONPortPrivPtr pPriv);
 void RADEONVIP_reset(ScrnInfoPtr pScrn, RADEONPortPrivPtr pPriv);


Reply to: