diff options
author | Daniel Vetter <daniel.vetter@ffwll.ch> | 2009-08-11 16:06:39 +0200 |
---|---|---|
committer | Eric Anholt <eric@anholt.net> | 2009-10-05 13:07:42 -0700 |
commit | 81fc74cc4ce81b9be8b9ba3bcacf1284c47ce80c (patch) | |
tree | 5104b18adaabe5bf651ff424f9985477cc68aed2 /src | |
parent | 0bf4cc5130482ee0f3924f34e37fa5fc988119b3 (diff) |
Xv I830PutImage splitup: extract i830_setup_video_buffer
Just move the code and pass back allocation failures.
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Eric Anholt <eric@anholt.net>
Diffstat (limited to 'src')
-rw-r--r-- | src/i830_video.c | 78 |
1 files changed, 44 insertions, 34 deletions
diff --git a/src/i830_video.c b/src/i830_video.c index e72eda66..8ecd3888 100644 --- a/src/i830_video.c +++ b/src/i830_video.c @@ -2157,6 +2157,48 @@ i830_fill_colorkey (ScreenPtr pScreen, uint32_t key, RegionPtr clipboxes) FreeScratchGC (gc); } +static Bool +i830_setup_video_buffer(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, + int alloc_size, int id) +{ + I830Ptr pI830 = I830PTR(pScrn); + /* Free the current buffer if we're going to have to reallocate */ + if (pPriv->buf && pPriv->buf->size < alloc_size) { + if (!pPriv->textured) + drm_intel_bo_unpin(pPriv->buf); + drm_intel_bo_unreference(pPriv->buf); + pPriv->buf = NULL; + } + +#ifdef INTEL_XVMC + if (id == FOURCC_XVMC && + pPriv->rotation == RR_Rotate_0) { + if (pPriv->buf) { + assert(pPriv->textured); + drm_intel_bo_unreference(pPriv->buf); + pPriv->buf = NULL; + } + } else { +#endif + if (pPriv->buf == NULL) { + pPriv->buf = drm_intel_bo_alloc(pI830->bufmgr, + "xv buffer", alloc_size, 4096); + if (pPriv->buf == NULL) + return FALSE; + if (!pPriv->textured && drm_intel_bo_pin(pPriv->buf, 4096) != 0) { + drm_intel_bo_unreference(pPriv->buf); + pPriv->buf = NULL; + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Failed to pin xv buffer\n"); + return FALSE; + } + } +#ifdef INTEL_XVMC + } +#endif + return TRUE; +} + static void i830_dst_pitch_and_size(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, short width, short height, int *dstPitch, int *dstPitch2, int *size, int id) @@ -2325,40 +2367,8 @@ I830PutImage(ScrnInfoPtr pScrn, if (pPriv->doubleBuffer) alloc_size *= 2; - /* Free the current buffer if we're going to have to reallocate */ - if (pPriv->buf && pPriv->buf->size < alloc_size) { - if (!pPriv->textured) - drm_intel_bo_unpin(pPriv->buf); - drm_intel_bo_unreference(pPriv->buf); - pPriv->buf = NULL; - } - -#ifdef INTEL_XVMC - if (id == FOURCC_XVMC && - pPriv->rotation == RR_Rotate_0) { - if (pPriv->buf) { - assert(pPriv->textured); - drm_intel_bo_unreference(pPriv->buf); - pPriv->buf = NULL; - } - } else { -#endif - if (pPriv->buf == NULL) { - pPriv->buf = drm_intel_bo_alloc(pI830->bufmgr, - "xv buffer", alloc_size, 4096); - if (pPriv->buf == NULL) - return BadAlloc; - if (!pPriv->textured && drm_intel_bo_pin(pPriv->buf, 4096) != 0) { - drm_intel_bo_unreference(pPriv->buf); - pPriv->buf = NULL; - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "Failed to pin xv buffer\n"); - return BadAlloc; - } - } -#ifdef INTEL_XVMC - } -#endif + if (!i830_setup_video_buffer(pScrn, pPriv, alloc_size, id)) + return BadAlloc; /* fixup pointers */ #ifdef INTEL_XVMC |