summaryrefslogtreecommitdiff
path: root/src/radeon_video.c
diff options
context:
space:
mode:
authorAlex Deucher <alexdeucher@gmail.com>2008-07-11 02:02:38 -0400
committerAlex Deucher <alexdeucher@gmail.com>2008-08-25 09:49:28 -0400
commit7daba77ded1c718e93ae8c372a39a6e85228d513 (patch)
tree45ae247155398deb0f3faf1e1a1443852bee283b /src/radeon_video.c
parent610fe1a937da78f4ac813ac919c158dde8f42442 (diff)
Convert randr, Xv to a common allocator
Diffstat (limited to 'src/radeon_video.c')
-rw-r--r--src/radeon_video.c147
1 files changed, 13 insertions, 134 deletions
diff --git a/src/radeon_video.c b/src/radeon_video.c
index e71f0f85..e86a7d4c 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;