From patchwork Tue Aug 11 14:06:31 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 40667 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 n7BE6k3n022182 for ; Tue, 11 Aug 2009 14:06:46 GMT Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B558A9EDA4; Tue, 11 Aug 2009 07:06:45 -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 620EC9ECC6 for ; Tue, 11 Aug 2009 07:06:44 -0700 (PDT) Received: by mail.ffwll.ch (Postfix, from userid 1000) id A2DDC20C234; Wed, 12 Aug 2009 00:00:12 +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-+--signed-off-by, 0.000-+--signedoffby, 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.974-+--H*m:ffwll, 0.971-+--H*Ad:U*daniel.vetter, 0.947-+--H*Ad:D*ffwll.ch Received: from biene (unknown [192.168.23.129]) by mail.ffwll.ch (Postfix) with ESMTP id 35AFD20C218; Wed, 12 Aug 2009 00:00:07 +0200 (CEST) Received: from daniel by biene with local (Exim 4.69) (envelope-from ) id 1Mas0A-0003eA-HI; Tue, 11 Aug 2009 16:06:58 +0200 From: Daniel Vetter To: intel-gfx@lists.freedesktop.org Date: Tue, 11 Aug 2009 16:06:31 +0200 Message-Id: <0328734a90544a6cd72d9eaf64015db9d3462921.1249999028.git.daniel.vetter@ffwll.ch> X-Mailer: git-send-email 1.6.3.3 In-Reply-To: References: In-Reply-To: References: Cc: Daniel Vetter Subject: [Intel-gfx] [PATCH 01/18] Xv i830_display_video splitup: extract i830_calc_src_regs 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 Also introduce an is_planar_fourcc helper. I'll use that one later. In i830_display_video this changeset moves the XVMC case (previously obscured as the default case) around. I've figured this default case does not make sense, here's why: XvMC is everywhere else handled as a planar format (e.g. in the register programming a few lines down). Furthermore the id variable gets mapped to FOURCC_YV12 if IS_I915(pI830) is true in I830PutImage. There's a second caller in the offscreen overlay support code. But I think that code is bitrotten and not reliable as an information source. So we have a different behaviour only for id=FOURCC_XVMC and i965 class hw (i830 class doesn't have xvmc). I've crawled through various sources/intel documentations. Finally in the textured video implemention for i965 class hw (src/i965_video.c) I've found a switch statement that puts XVMC into the same case as I420 and YV12. So also in i965 class hw xvmc uses a planar format. In conclusion I claim that this code was bogus and XvMC on i965 class hw over Xv overlay was most likely broken. Signed-off-by: Daniel Vetter --- src/i830_video.c | 113 +++++++++++++++++++++++++++++++----------------------- 1 files changed, 65 insertions(+), 48 deletions(-) diff --git a/src/i830_video.c b/src/i830_video.c index 9fb0b56..2944563 100644 --- a/src/i830_video.c +++ b/src/i830_video.c @@ -1782,6 +1782,46 @@ i830_swidth (I830Ptr pI830, unsigned int offset, } static void +i830_calc_src_regs(I830Ptr pI830, int planar, short width, short height, + uint32_t *swidth_out, uint32_t *swidthsw_out, uint32_t *sheigth_out) +{ + unsigned int mask, shift, offsety, offsetu; + unsigned int swidth, swidthy, swidthuv; + I830PortPrivPtr pPriv = pI830->adaptor->pPortPrivates[0].ptr; + + if (IS_I9XX(pI830)) { + shift = 6; + mask = 0x3f; + } else { + shift = 5; + mask = 0x1f; + } + + if (pPriv->currentBuf == 0) { + offsety = pPriv->YBuf0offset; + offsetu = pPriv->UBuf0offset; + } else { + offsety = pPriv->YBuf1offset; + offsetu = pPriv->UBuf1offset; + } + + if (planar) { + *swidth_out = width | ((width/2 & 0x7ff) << 16); + swidthy = i830_swidth (pI830, offsety, width, mask, shift); + swidthuv = i830_swidth (pI830, offsetu, width/2, mask, shift); + *swidthsw_out = (swidthy) | (swidthuv << 16); + *sheigth_out = height | ((height / 2) << 16); + } else { + *swidth_out = width; + swidth = i830_swidth (pI830, offsety, width << 1, mask, shift); + *swidthsw_out = swidth; + *sheigth_out = height; + } + + return; +} + +static void i830_update_dst_box_to_crtc_coords(ScrnInfoPtr pScrn, xf86CrtcPtr crtc, BoxPtr dstBox) { @@ -1833,6 +1873,23 @@ i830_update_dst_box_to_crtc_coords(ScrnInfoPtr pScrn, xf86CrtcPtr crtc, return; } +static int +is_planar_fourcc(int id) +{ + switch (id) { + case FOURCC_YV12: + case FOURCC_I420: +#ifdef INTEL_XVMC + case FOURCC_XVMC: +#endif + return 1; + case FOURCC_UYVY: + case FOURCC_YUY2: + default: + return 0; + } +} + static void i830_store_coeffs_in_overlay_regs(uint16_t *reg_coeffs, coeffPtr new_coeffs, int max_taps) @@ -1981,8 +2038,8 @@ i830_display_video(ScrnInfoPtr pScrn, xf86CrtcPtr crtc, I830Ptr pI830 = I830PTR(pScrn); I830PortPrivPtr pPriv = pI830->adaptor->pPortPrivates[0].ptr; I830OverlayRegPtr overlay = I830OVERLAYREG(pI830); - unsigned int swidth, swidthy, swidthuv; - unsigned int mask, shift, offsety, offsetu; + int planar; + uint32_t swidth, swidthsw, sheigth; int tmp; uint32_t OCMD; Bool scaleChanged = FALSE; @@ -2039,54 +2096,14 @@ i830_display_video(ScrnInfoPtr pScrn, xf86CrtcPtr crtc, drw_h = ((drw_h * pPriv->scaleRatio) >> 16) + 1; } - if (IS_I9XX(pI830)) { - shift = 6; - mask = 0x3f; - } else { - shift = 5; - mask = 0x1f; - } - - if (pPriv->currentBuf == 0) { - offsety = pPriv->YBuf0offset; - offsetu = pPriv->UBuf0offset; - } else { - offsety = pPriv->YBuf1offset; - offsetu = pPriv->UBuf1offset; - } - - switch (id) { - case FOURCC_YV12: - case FOURCC_I420: - overlay->SWIDTH = width | ((width/2 & 0x7ff) << 16); - swidthy = i830_swidth (pI830, offsety, width, mask, shift); - swidthuv = i830_swidth (pI830, offsetu, width/2, mask, shift); - overlay->SWIDTHSW = (swidthy) | (swidthuv << 16); - overlay->SHEIGHT = height | ((height / 2) << 16); - break; - case FOURCC_UYVY: - case FOURCC_YUY2: - default: - overlay->SWIDTH = width; - swidth = ((offsety + (width << 1) + mask) >> shift) - - (offsety >> shift); - - if (IS_I9XX(pI830)) - swidth <<= 1; + planar = is_planar_fourcc(id); - swidth -= 1; + i830_calc_src_regs(pI830, planar, width, height, + &swidth, &swidthsw, &sheigth); - swidth <<= 2; - - OVERLAY_DEBUG("swidthsw is old %d new %d\n", - swidth, - i830_swidth (pI830, offsety, width << 1, - mask, shift)); - - overlay->SWIDTHSW = swidth; - overlay->SHEIGHT = height; - break; - } + overlay->SWIDTH = swidth; + overlay->SWIDTHSW = swidthsw; + overlay->SHEIGHT = sheigth; overlay->DWINPOS = (dstBox->y1 << 16) | dstBox->x1;