From patchwork Tue Aug 11 14:06:46 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 40684 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 n7BE7VV1022426 for ; Tue, 11 Aug 2009 14:07:31 GMT Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A73E89EFD6; Tue, 11 Aug 2009 07:07:30 -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 2DCC59EFC7 for ; Tue, 11 Aug 2009 07:07:23 -0700 (PDT) Received: by mail.ffwll.ch (Postfix, from userid 1000) id A043520C231; Wed, 12 Aug 2009 00:00:51 +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 B249420C230; Wed, 12 Aug 2009 00:00:08 +0200 (CEST) Received: from daniel by biene with local (Exim 4.69) (envelope-from ) id 1Mas0B-0003et-Uq; Tue, 11 Aug 2009 16:06:59 +0200 From: Daniel Vetter To: intel-gfx@lists.freedesktop.org Date: Tue, 11 Aug 2009 16:06:46 +0200 Message-Id: <361705901f128de9afac9b43d386abf0be87a5b3.1249999028.git.daniel.vetter@ffwll.ch> X-Mailer: git-send-email 1.6.3.3 In-Reply-To: <3f8b26f517d6bea6dc326136b6e9ea9d210e9a5a.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> <52250eeaf73398c9c1f91ca7b2317f785f8eba56.1249999028.git.daniel.vetter@ffwll.ch> <3a4e39fa527e6f1bec9306a0c9d7b69b222532a6.1249999028.git.daniel.vetter@ffwll.ch> <06188abbed359c266f2033d8b3b28aa0aaf8aada.1249999028.git.daniel.vetter@ffwll.ch> <3f8b26f517d6bea6dc326136b6e9ea9d210e9a5a.1249999028.git.daniel.vetter@ffwll.ch> In-Reply-To: References: Cc: Daniel Vetter Subject: [Intel-gfx] [PATCH 16/18] Xv: introduce an overlay hal 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 This is the last preparatory step for overlay support with drmmode. Safe two (specially marked) function calls in the setup code, all hw accessing code goes now through these three new functions with the ums_overlay prefix. Signed-off-by: Daniel Vetter --- src/i830_video.c | 152 ++++++++++++++++++++++++++++++++---------------------- 1 files changed, 91 insertions(+), 61 deletions(-) diff --git a/src/i830_video.c b/src/i830_video.c index 15ada0f..80f7303 100644 --- a/src/i830_video.c +++ b/src/i830_video.c @@ -942,8 +942,8 @@ I830SetupImageVideoOverlay(ScreenPtr pScreen) xvGamma5 = MAKE_ATOM("XV_GAMMA5"); } + /* XXX These two access the overlay regs, dont call with drmmode */ I830ResetVideo(pScrn); - I830UpdateGamma(pScrn); return adapt; @@ -1043,6 +1043,12 @@ i830_free_video_buffers(I830PortPrivPtr pPriv) } static void +ums_overlay_off(ScrnInfoPtr pScrn) +{ + i830_overlay_off (pScrn); +} + +static void I830StopVideo(ScrnInfoPtr pScrn, pointer data, Bool shutdown) { I830PortPrivPtr pPriv = (I830PortPrivPtr) data; @@ -1056,7 +1062,7 @@ I830StopVideo(ScrnInfoPtr pScrn, pointer data, Bool shutdown) if (shutdown) { if (pPriv->videoStatus & CLIENT_VIDEO_ON) { - i830_overlay_off(pScrn); + ums_overlay_off(pScrn); } i830_free_video_buffers(pPriv); @@ -1089,7 +1095,6 @@ I830SetPortAttributeTextured(ScrnInfoPtr pScrn, } else if (attribute == xvSyncToVblank) { if ((value < -1) || (value > 1)) return BadValue; - pPriv->SyncToVblank = value; return Success; } else { @@ -1097,36 +1102,56 @@ I830SetPortAttributeTextured(ScrnInfoPtr pScrn, } } +static void +ums_overlay_update_attrs(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv) +{ + I830Ptr pI830 = I830PTR(pScrn); + I830OverlayRegPtr overlay; + + overlay = I830OVERLAYREG(pI830); + + overlay->OCLRC0 = (pPriv->contrast << 18) | (pPriv->brightness & 0xff); + overlay->OCLRC0 = (pPriv->contrast << 18) | (pPriv->brightness & 0xff); + overlay->OCLRC1 = pPriv->saturation; + + switch (pScrn->depth) { + case 16: + overlay->DCLRKV = RGB16ToColorKey(pPriv->colorKey); + break; + case 15: + overlay->DCLRKV = RGB15ToColorKey(pPriv->colorKey); + break; + default: + overlay->DCLRKV = pPriv->colorKey; + break; + } + + I830UpdateGamma(pScrn); + + i830_overlay_continue(pScrn, FALSE); +} + static int I830SetPortAttributeOverlay(ScrnInfoPtr pScrn, Atom attribute, INT32 value, pointer data) { I830PortPrivPtr pPriv = (I830PortPrivPtr) data; I830Ptr pI830 = I830PTR(pScrn); - I830OverlayRegPtr overlay; - - overlay = I830OVERLAYREG(pI830); if (attribute == xvBrightness) { if ((value < -128) || (value > 127)) return BadValue; pPriv->brightness = value; - overlay->OCLRC0 = (pPriv->contrast << 18) | (pPriv->brightness & 0xff); OVERLAY_DEBUG("BRIGHTNESS\n"); - i830_overlay_continue (pScrn, FALSE); } else if (attribute == xvContrast) { if ((value < 0) || (value > 255)) return BadValue; pPriv->contrast = value; - overlay->OCLRC0 = (pPriv->contrast << 18) | (pPriv->brightness & 0xff); OVERLAY_DEBUG("CONTRAST\n"); - i830_overlay_continue (pScrn, FALSE); } else if (attribute == xvSaturation) { if ((value < 0) || (value > 1023)) return BadValue; pPriv->saturation = value; - overlay->OCLRC1 = pPriv->saturation; - i830_overlay_continue (pScrn, FALSE); } else if (attribute == xvPipe) { xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn); if ((value < -1) || (value > xf86_config->num_crtc)) @@ -1139,7 +1164,7 @@ I830SetPortAttributeOverlay(ScrnInfoPtr pScrn, * Leave this to be updated at the next frame */ } else if (attribute == xvGamma0 && (IS_I9XX(pI830))) { - pPriv->gamma0 = value; + pPriv->gamma0 = value; } else if (attribute == xvGamma1 && (IS_I9XX(pI830))) { pPriv->gamma1 = value; } else if (attribute == xvGamma2 && (IS_I9XX(pI830))) { @@ -1152,20 +1177,7 @@ I830SetPortAttributeOverlay(ScrnInfoPtr pScrn, pPriv->gamma5 = value; } else if (attribute == xvColorKey) { pPriv->colorKey = value; - switch (pScrn->depth) { - case 16: - overlay->DCLRKV = RGB16ToColorKey(pPriv->colorKey); - break; - case 15: - overlay->DCLRKV = RGB15ToColorKey(pPriv->colorKey); - break; - default: - overlay->DCLRKV = pPriv->colorKey; - break; - } OVERLAY_DEBUG("COLORKEY\n"); - i830_overlay_continue (pScrn, FALSE); - REGION_EMPTY(pScrn->pScreen, &pPriv->clip); } else return BadMatch; @@ -1177,9 +1189,13 @@ I830SetPortAttributeOverlay(ScrnInfoPtr pScrn, attribute == xvGamma4 || attribute == xvGamma5) && (IS_I9XX(pI830))) { OVERLAY_DEBUG("GAMMA\n"); - I830UpdateGamma(pScrn); } + ums_overlay_update_attrs(pScrn, pPriv); + + if (attribute == xvColorKey) + REGION_EMPTY(pScrn->pScreen, &pPriv->clip); + return Success; } @@ -1964,7 +1980,7 @@ xvmc_passthrough(int id, Rotation rotation) } static Bool -i830_display_overlay(ScrnInfoPtr pScrn, xf86CrtcPtr crtc, +ums_overlay_put_image(ScrnInfoPtr pScrn, xf86CrtcPtr crtc, int id, short width, short height, int dstPitch, int x1, int y1, int x2, int y2, BoxPtr dstBox, short src_w, short src_h, short drw_w, short drw_h) @@ -1974,29 +1990,12 @@ i830_display_overlay(ScrnInfoPtr pScrn, xf86CrtcPtr crtc, I830OverlayRegPtr overlay = I830OVERLAYREG(pI830); int planar; uint32_t swidth, swidthsw, sheigth; - int tmp; Bool scaleChanged; drm_intel_bo *tmp_buf; - OVERLAY_DEBUG("I830DisplayVideo: %dx%d (pitch %d)\n", width, height, - dstPitch); - -#if VIDEO_DEBUG - CompareOverlay(pI830, (uint32_t *) overlay, 0x100); -#endif - - /* - * If the video isn't visible on any CRTC, turn it off - */ - if (!crtc) - { - pPriv->current_crtc = NULL; - i830_overlay_off (pScrn); - return TRUE; - } - if (crtc != pPriv->current_crtc) { + /* this may adjust pPriv->oneLineMode */ i830_overlay_switch_to_crtc (pScrn, crtc); if (pPriv->overlayOK) { pPriv->current_crtc = crtc; @@ -2007,20 +2006,6 @@ i830_display_overlay(ScrnInfoPtr pScrn, xf86CrtcPtr crtc, if (!pPriv->overlayOK) return TRUE; - i830_update_dst_box_to_crtc_coords(pScrn, crtc, dstBox); - - if (crtc->rotation & (RR_Rotate_90 | RR_Rotate_270)) { - tmp = width; - width = height; - height = tmp; - tmp = drw_w; - drw_w = drw_h; - drw_h = tmp; - tmp = src_w; - src_w = src_h; - src_h = tmp; - } - if (pPriv->oneLineMode) { /* change the coordinates with panel fitting active */ dstBox->y1 = (((dstBox->y1 - 1) * pPriv->scaleRatio) >> 16) + 1; @@ -2101,6 +2086,51 @@ i830_display_overlay(ScrnInfoPtr pScrn, xf86CrtcPtr crtc, } static Bool +i830_display_overlay(ScrnInfoPtr pScrn, xf86CrtcPtr crtc, + int id, short width, short height, + int dstPitch, int x1, int y1, int x2, int y2, BoxPtr dstBox, + short src_w, short src_h, short drw_w, short drw_h) +{ + I830Ptr pI830 = I830PTR(pScrn); + I830PortPrivPtr pPriv = pI830->adaptor->pPortPrivates[0].ptr; + int tmp; + + OVERLAY_DEBUG("I830DisplayVideo: %dx%d (pitch %d)\n", width, height, + dstPitch); + +#if VIDEO_DEBUG + CompareOverlay(pI830, (uint32_t *) overlay, 0x100); +#endif + + /* + * If the video isn't visible on any CRTC, turn it off + */ + if (!crtc) + { + pPriv->current_crtc = NULL; + ums_overlay_off(pScrn); + return TRUE; + } + + i830_update_dst_box_to_crtc_coords(pScrn, crtc, dstBox); + + if (crtc->rotation & (RR_Rotate_90 | RR_Rotate_270)) { + tmp = width; + width = height; + height = tmp; + tmp = drw_w; + drw_w = drw_h; + drw_h = tmp; + tmp = src_w; + src_w = src_h; + src_h = tmp; + } + + return ums_overlay_put_image(pScrn, crtc, id, width, height, dstPitch, + x1, y1, x2, y2, dstBox, src_w, src_h, drw_w, drw_h); +} + +static Bool i830_clip_video_helper (ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, xf86CrtcPtr *crtc_ret, @@ -2606,7 +2636,7 @@ I830VideoBlockHandler(int i, pointer blockData, pointer pTimeout, /* Turn off the overlay */ OVERLAY_DEBUG("BLOCKHANDLER\n"); - i830_overlay_off (pScrn); + ums_overlay_off (pScrn); pPriv->videoStatus = FREE_TIMER; pPriv->freeTime = now + FREE_DELAY;