[Intel-gfx] [PATCH 12/22] Xv I830PutImage splitup: extract i830_setup_video_buffer
Daniel Vetter
daniel.vetter at ffwll.ch
Thu Jul 2 14:15:45 CEST 2009
Just move the code and pass back allocation failures.
Signed-off-by: Daniel Vetter <daniel.vetter at ffwll.ch>
---
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 c7c2c96..5b1b37b 100644
--- a/src/i830_video.c
+++ b/src/i830_video.c
@@ -2158,6 +2158,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)
@@ -2326,40 +2368,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
--
1.6.3.3
More information about the Intel-gfx
mailing list