From patchwork Tue Aug 11 14:06:40 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 40676 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 n7BE7CrT022362 for ; Tue, 11 Aug 2009 14:07:12 GMT Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3B3E69EFA7; Tue, 11 Aug 2009 07:07:12 -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 98F2F9EF55 for ; Tue, 11 Aug 2009 07:07:08 -0700 (PDT) Received: by mail.ffwll.ch (Postfix, from userid 1000) id 05AAB20C22C; Wed, 12 Aug 2009 00:00:36 +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: Received: from biene (unknown [192.168.23.129]) by mail.ffwll.ch (Postfix) with ESMTP id 39C5E20C229; Wed, 12 Aug 2009 00:00:08 +0200 (CEST) Received: from daniel by biene with local (Exim 4.69) (envelope-from ) id 1Mas0B-0003eb-ER; Tue, 11 Aug 2009 16:06:59 +0200 From: Daniel Vetter To: intel-gfx@lists.freedesktop.org Date: Tue, 11 Aug 2009 16:06:40 +0200 Message-Id: <52250eeaf73398c9c1f91ca7b2317f785f8eba56.1249999028.git.daniel.vetter@ffwll.ch> X-Mailer: git-send-email 1.6.3.3 In-Reply-To: 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 10/18] Xv I830PutImage splitup: extract i830_copy_video_data 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 moves the code and passes back allocation failures. Signed-off-by: Daniel Vetter --- src/i830_video.c | 158 ++++++++++++++++++++++++++++++------------------------ 1 files changed, 88 insertions(+), 70 deletions(-) diff --git a/src/i830_video.c b/src/i830_video.c index d447be5..b9385f9 100644 --- a/src/i830_video.c +++ b/src/i830_video.c @@ -2265,6 +2265,90 @@ i830_dst_pitch_and_size(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, short width, #endif } +static Bool +i830_copy_video_data(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, + short width, short height, int *dstPitch, int *dstPitch2, + INT32 x1, INT32 y1, INT32 x2, INT32 y2, + int id, unsigned char *buf) +{ + I830Ptr pI830 = I830PTR(pScrn); + int srcPitch = 0, srcPitch2 = 0; + int top, left, npixels, nlines, size; + int alloc_size; + + if (is_planar_fourcc(id)) { + srcPitch = (width + 0x3) & ~0x3; + srcPitch2 = ((width >> 1) + 0x3) & ~0x3; + } else { + srcPitch = width << 1; + } + + i830_dst_pitch_and_size(pScrn, pPriv, width, height, dstPitch, dstPitch2, + &size, id); + + alloc_size = size; + if (pPriv->doubleBuffer) + alloc_size *= 2; + + if (!i830_setup_video_buffer(pScrn, pPriv, alloc_size, id)) + return FALSE; + + /* fixup pointers */ +#ifdef INTEL_XVMC + if (id == FOURCC_XVMC && IS_I915(pI830)) { + pPriv->YBufOffset = (uint32_t)((uintptr_t)buf); + pPriv->VBufOffset = pPriv->YBufOffset + (*dstPitch2 * height); + pPriv->UBufOffset = pPriv->VBufOffset + (*dstPitch * height / 2); + } else { +#endif + if (pPriv->textured) + pPriv->YBufOffset = 0; + else + pPriv->YBufOffset = pPriv->buf->offset; + + /* switch buffers if double buffered */ + if (!pPriv->textured && pPriv->doubleBuffer) { + if (pPriv->currentBuf == 0) + pPriv->currentBuf = 1; + else + pPriv->currentBuf = 0; + + pPriv->YBufOffset += size*pPriv->currentBuf; + } + + if (pPriv->rotation & (RR_Rotate_90 | RR_Rotate_270)) { + pPriv->UBufOffset = pPriv->YBufOffset + (*dstPitch * 2 * width); + pPriv->VBufOffset = pPriv->UBufOffset + (*dstPitch * width / 2); + } else { + pPriv->UBufOffset = pPriv->YBufOffset + (*dstPitch * 2 * height); + pPriv->VBufOffset = pPriv->UBufOffset + (*dstPitch * height / 2); + } +#ifdef INTEL_XVMC + } +#endif + + /* copy data */ + top = y1 >> 16; + left = (x1 >> 16) & ~1; + npixels = ((((x2 + 0xffff) >> 16) + 1) & ~1) - left; + + if (is_planar_fourcc(id)) { + if (id != FOURCC_XVMC + || pPriv->rotation != RR_Rotate_0) { + top &= ~1; + nlines = ((((y2 + 0xffff) >> 16) + 1) & ~1) - top; + I830CopyPlanarData(pScrn, pPriv, buf, srcPitch, srcPitch2, *dstPitch, + height, top, left, nlines, npixels, id); + } + } else { + nlines = ((y2 + 0xffff) >> 16) - top; + I830CopyPackedData(pScrn, pPriv, buf, srcPitch, *dstPitch, top, left, + nlines, npixels); + } + + return TRUE; +} + /* * The source rectangle of the video is defined by (src_x, src_y, src_w, src_h). * The dest rectangle of the video is defined by (drw_x, drw_y, drw_w, drw_h). @@ -2295,11 +2379,9 @@ I830PutImage(ScrnInfoPtr pScrn, I830OverlayRegPtr overlay; PixmapPtr pPixmap = get_drawable_pixmap(pDraw);; INT32 x1, x2, y1, y2; - int srcPitch = 0, srcPitch2 = 0, dstPitch; + int dstPitch; int dstPitch2 = 0; - int top, left, npixels, nlines, size; BoxRec dstBox; - int alloc_size; xf86CrtcPtr crtc; if (pPriv->textured) @@ -2353,75 +2435,11 @@ I830PutImage(ScrnInfoPtr pScrn, } } - if (is_planar_fourcc(id)) { - srcPitch = (width + 0x3) & ~0x3; - srcPitch2 = ((width >> 1) + 0x3) & ~0x3; - } else { - srcPitch = width << 1; - } - - i830_dst_pitch_and_size(pScrn, pPriv, width, height, &dstPitch, &dstPitch2, - &size, id); - - alloc_size = size; - if (pPriv->doubleBuffer) - alloc_size *= 2; - - if (!i830_setup_video_buffer(pScrn, pPriv, alloc_size, id)) + if (!i830_copy_video_data(pScrn, pPriv, width, height, + &dstPitch, &dstPitch2, + x1, y1, x2, y2, id, buf)) return BadAlloc; - /* fixup pointers */ -#ifdef INTEL_XVMC - if (id == FOURCC_XVMC && IS_I915(pI830)) { - pPriv->YBufOffset = (uint32_t)((uintptr_t)buf); - pPriv->VBufOffset = pPriv->YBufOffset + (dstPitch2 * height); - pPriv->UBufOffset = pPriv->VBufOffset + (dstPitch * height / 2); - } else { -#endif - if (pPriv->textured) - pPriv->YBufOffset = 0; - else - pPriv->YBufOffset = pPriv->buf->offset; - - /* switch buffers if double buffered */ - if (!pPriv->textured && pPriv->doubleBuffer) { - if (pPriv->currentBuf == 0) - pPriv->currentBuf = 1; - else - pPriv->currentBuf = 0; - - pPriv->YBufOffset += size*pPriv->currentBuf; - } - - if (pPriv->rotation & (RR_Rotate_90 | RR_Rotate_270)) { - pPriv->UBufOffset = pPriv->YBufOffset + (dstPitch * 2 * width); - pPriv->VBufOffset = pPriv->UBufOffset + (dstPitch * width / 2); - } else { - pPriv->UBufOffset = pPriv->YBufOffset + (dstPitch * 2 * height); - pPriv->VBufOffset = pPriv->UBufOffset + (dstPitch * height / 2); - } -#ifdef INTEL_XVMC - } -#endif - - /* copy data */ - top = y1 >> 16; - left = (x1 >> 16) & ~1; - npixels = ((((x2 + 0xffff) >> 16) + 1) & ~1) - left; - - if (is_planar_fourcc(id)) { - if (id != FOURCC_XVMC - || pPriv->rotation != RR_Rotate_0) { - top &= ~1; - nlines = ((((y2 + 0xffff) >> 16) + 1) & ~1) - top; - I830CopyPlanarData(pScrn, pPriv, buf, srcPitch, srcPitch2, dstPitch, - height, top, left, nlines, npixels, id); - } - } else { - nlines = ((y2 + 0xffff) >> 16) - top; - I830CopyPackedData(pScrn, pPriv, buf, srcPitch, dstPitch, top, left, - nlines, npixels); - } if (!pPriv->textured) { i830_display_overlay(pScrn, crtc, id, width, height, dstPitch,