From patchwork Tue Aug 11 14:06:39 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 40678 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n7BE7HWJ022376 for ; Tue, 11 Aug 2009 14:07:17 GMT Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 17A3D9EFB2; Tue, 11 Aug 2009 07:07:17 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail.ffwll.ch (cable-static-49-187.intergga.ch [157.161.49.187]) by gabe.freedesktop.org (Postfix) with ESMTP id D0CA39EFC4 for ; Tue, 11 Aug 2009 07:07:12 -0700 (PDT) Received: by mail.ffwll.ch (Postfix, from userid 1000) id 7C49320C22A; Wed, 12 Aug 2009 00:00:40 +0200 (CEST) X-Spam-ASN: X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on orange.ffwll.ch X-Spam-Level: X-Spam-Hammy: 0.000-+--signedoffby, 0.000-+--signed-off-by, 0.000-+--100644 X-Spam-Status: No, score=-4.4 required=6.0 tests=ALL_TRUSTED,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Spammy: 0.970-+--H*Ad:U*daniel.vetter, 0.970-+--H*m:ffwll, 0.946-+--H*Ad:D*ffwll.ch Received: from biene (unknown [192.168.23.129]) by mail.ffwll.ch (Postfix) with ESMTP id 4AC6320C22B; Wed, 12 Aug 2009 00:00:08 +0200 (CEST) Received: from daniel by biene with local (Exim 4.69) (envelope-from ) id 1Mas0B-0003eY-As; Tue, 11 Aug 2009 16:06:59 +0200 From: Daniel Vetter To: intel-gfx@lists.freedesktop.org Date: Tue, 11 Aug 2009 16:06:39 +0200 Message-Id: X-Mailer: git-send-email 1.6.3.3 In-Reply-To: <3e0435569d2d7f58d58eb2f7c8a6952cc29b6934.1249999028.git.daniel.vetter@ffwll.ch> References: <0328734a90544a6cd72d9eaf64015db9d3462921.1249999028.git.daniel.vetter@ffwll.ch> <10614c7dd4ecbb1b4d3dd6a15b949cb389053f1f.1249999028.git.daniel.vetter@ffwll.ch> <891b387c6b31972a3e339508e57bd660b2991a17.1249999028.git.daniel.vetter@ffwll.ch> <2096013512e0099bfbb89439943c1b70cccabc92.1249999028.git.daniel.vetter@ffwll.ch> <8a3ddc0d78dcb40a14f8037b81cf202eaa40c301.1249999028.git.daniel.vetter@ffwll.ch> <3e0435569d2d7f58d58eb2f7c8a6952cc29b6934.1249999028.git.daniel.vetter@ffwll.ch> In-Reply-To: References: Cc: Daniel Vetter Subject: [Intel-gfx] [PATCH 09/18] Xv I830PutImage splitup: extract i830_setup_video_buffer X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.9 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: intel-gfx-bounces@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Just move the code and pass back allocation failures. Signed-off-by: Daniel Vetter --- 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 98e9230..d447be5 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