[Intel-gfx] [PATCH 09/22] Xv: kill hw double buffering logic

Daniel Vetter daniel.vetter at ffwll.ch
Thu Jul 2 14:15:42 CEST 2009


The idea for the hw double buffering support is to program two fixed
buffers and then only switch buffers in the OCMD register. But the driver
as-is always programs the new buffer address (in both register sets
when double buffered). Therefore we gain nothing by using this hw
capability. Scrap the software support for it.

When double buffered, we now allocate just a buffer of size 2*size and
switch between the two parts purely in software.

Signed-off-by: Daniel Vetter <daniel.vetter at ffwll.ch>
---
 src/i830_video.c |  125 ++++++++++++++++++------------------------------------
 src/i830_video.h |   10 +---
 src/i915_video.c |   16 +++---
 src/i965_video.c |   12 +++---
 4 files changed, 58 insertions(+), 105 deletions(-)

diff --git a/src/i830_video.c b/src/i830_video.c
index a20af16..3d329ab 100644
--- a/src/i830_video.c
+++ b/src/i830_video.c
@@ -1277,10 +1277,7 @@ I830CopyPackedData(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv,
 	dst_base = pI830->FbBase;
     }
 
-    if (pPriv->currentBuf == 0)
-	dst = dst_base + pPriv->YBuf0offset;
-    else
-	dst = dst_base + pPriv->YBuf1offset;
+    dst = dst_base + pPriv->YBufOffset;
 
     switch (pPriv->rotation) {
     case RR_Rotate_0:
@@ -1438,10 +1435,7 @@ I830CopyPlanarData(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv,
 	dst_base = pI830->FbBase;
     }
 
-    if (pPriv->currentBuf == 0)
-	dst1 = dst_base + pPriv->YBuf0offset;
-    else
-	dst1 = dst_base + pPriv->YBuf1offset;
+    dst1 = dst_base + pPriv->YBufOffset;
 
     i830_memcpy_plane(dst1, src1, h, w, dstPitch2, srcPitch, pPriv->rotation);
 
@@ -1451,17 +1445,10 @@ I830CopyPlanarData(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv,
     ErrorF("src2 is %p, offset is %ld\n", src2,
 	   (unsigned long)src2 - (unsigned long)buf);
 #endif
-    if (pPriv->currentBuf == 0) {
-	if (id == FOURCC_I420)
-	    dst2 = dst_base + pPriv->UBuf0offset;
-	else
-	    dst2 = dst_base + pPriv->VBuf0offset;
-    } else {
-	if (id == FOURCC_I420)
-	    dst2 = dst_base + pPriv->UBuf1offset;
-	else
-	    dst2 = dst_base + pPriv->VBuf1offset;
-    }
+    if (id == FOURCC_I420)
+	dst2 = dst_base + pPriv->UBufOffset;
+    else
+	dst2 = dst_base + pPriv->VBufOffset;
 
     i830_memcpy_plane(dst2, src2, h/2, w/2,
 		    dstPitch, srcPitch2, pPriv->rotation);
@@ -1473,17 +1460,10 @@ I830CopyPlanarData(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv,
     ErrorF("src3 is %p, offset is %ld\n", src3,
 	   (unsigned long)src3 - (unsigned long)buf);
 #endif
-    if (pPriv->currentBuf == 0) {
-	if (id == FOURCC_I420)
-	    dst3 = dst_base + pPriv->VBuf0offset;
-	else
-	    dst3 = dst_base + pPriv->UBuf0offset;
-    } else {
-	if (id == FOURCC_I420)
-	    dst3 = dst_base + pPriv->VBuf1offset;
-	else
-	    dst3 = dst_base + pPriv->UBuf1offset;
-    }
+    if (id == FOURCC_I420)
+	dst3 = dst_base + pPriv->VBufOffset;
+    else
+	dst3 = dst_base + pPriv->UBufOffset;
 
     i830_memcpy_plane(dst3, src3, h/2, w/2,
 		    dstPitch, srcPitch2, pPriv->rotation);
@@ -1730,13 +1710,8 @@ i830_calc_src_regs(I830Ptr pI830, int planar, short width, short height,
 	mask = 0x1f;
     }
 
-    if (pPriv->currentBuf == 0) {
-	offsety = pPriv->YBuf0offset;
-	offsetu = pPriv->UBuf0offset;
-    } else {
-	offsety = pPriv->YBuf1offset;
-	offsetu = pPriv->UBuf1offset;
-    }
+    offsety = pPriv->YBufOffset;
+    offsetu = pPriv->UBufOffset;
 
     if (planar) {
 	*swidth_out = width | ((width/2 & 0x7ff) << 16);
@@ -1823,7 +1798,7 @@ i830_store_coeffs_in_overlay_regs(uint16_t *reg_coeffs, coeffPtr new_coeffs,
 }
 
 static uint32_t
-i830_overlay_cmd(int id, int planar, unsigned char currentBuf)
+i830_overlay_cmd(int id, int planar)
 {
     uint32_t OCMD = OVERLAY_ENABLE;
     
@@ -1842,10 +1817,7 @@ i830_overlay_cmd(int id, int planar, unsigned char currentBuf)
     }
 
     OCMD &= ~(BUFFER_SELECT | FIELD_SELECT);
-    if (currentBuf == 0)
-	OCMD |= BUFFER0;
-    else
-	OCMD |= BUFFER1;
+    OCMD |= BUFFER0;
 
     OVERLAY_DEBUG("OCMD is 0x%x\n", OCMD);
 
@@ -2078,14 +2050,9 @@ i830_display_overlay(ScrnInfoPtr pScrn, xf86CrtcPtr crtc,
 		  dstBox->x1, dstBox->y1, dstBox->x2, dstBox->y2);
 
     /* buffer locations */
-    overlay->OBUF_0Y = pPriv->YBuf0offset;
-    overlay->OBUF_0U = pPriv->UBuf0offset;
-    overlay->OBUF_0V = pPriv->VBuf0offset;
-    if(pPriv->doubleBuffer) {
-	overlay->OBUF_1Y = pPriv->YBuf1offset;
-	overlay->OBUF_1U = pPriv->UBuf1offset;
-	overlay->OBUF_1V = pPriv->VBuf1offset;
-    }
+    overlay->OBUF_0Y = pPriv->YBufOffset;
+    overlay->OBUF_0U = pPriv->UBufOffset;
+    overlay->OBUF_0V = pPriv->VBufOffset;
 
     OVERLAY_DEBUG("pos: 0x%x, size: 0x%x\n",
 		  overlay->DWINPOS, overlay->DWINSZ);
@@ -2105,7 +2072,7 @@ i830_display_overlay(ScrnInfoPtr pScrn, xf86CrtcPtr crtc,
     } else
 	overlay->OSTRIDE = dstPitch;
 
-    overlay->OCMD = i830_overlay_cmd(id, planar, pPriv->currentBuf);
+    overlay->OCMD = i830_overlay_cmd(id, planar);
 
     /* make sure the overlay is on */
     i830_overlay_on (pScrn);
@@ -2388,42 +2355,38 @@ I830PutImage(ScrnInfoPtr pScrn,
     /* fixup pointers */
 #ifdef INTEL_XVMC
     if (id == FOURCC_XVMC && IS_I915(pI830)) {
-	pPriv->YBuf0offset = (uint32_t)((uintptr_t)buf);
-	pPriv->VBuf0offset = pPriv->YBuf0offset + (dstPitch2 * height);
-	pPriv->UBuf0offset = pPriv->VBuf0offset + (dstPitch * height / 2);
+	pPriv->YBufOffset = (uint32_t)((uintptr_t)buf);
+	pPriv->VBufOffset = pPriv->YBufOffset + (dstPitch2 * height);
+	pPriv->UBufOffset = pPriv->VBufOffset + (dstPitch * height / 2);
 	destId = FOURCC_YV12;
     } else {
 #endif
 	if (pPriv->textured)
-	    pPriv->YBuf0offset = 0;
+	    pPriv->YBufOffset = 0;
 	else
-	    pPriv->YBuf0offset = pPriv->buf->offset;
+	    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->UBuf0offset = pPriv->YBuf0offset + (dstPitch * 2 * width);
-	    pPriv->VBuf0offset = pPriv->UBuf0offset + (dstPitch * width / 2);
-	    if(pPriv->doubleBuffer) {
-		pPriv->YBuf1offset = pPriv->YBuf0offset + size;
-		pPriv->UBuf1offset = pPriv->YBuf1offset + (dstPitch * 2 * width);
-		pPriv->VBuf1offset = pPriv->UBuf1offset + (dstPitch * width / 2);
-	    }
+	    pPriv->UBufOffset = pPriv->YBufOffset + (dstPitch * 2 * width);
+	    pPriv->VBufOffset = pPriv->UBufOffset + (dstPitch * width / 2);
 	} else {
-	    pPriv->UBuf0offset = pPriv->YBuf0offset + (dstPitch * 2 * height);
-	    pPriv->VBuf0offset = pPriv->UBuf0offset + (dstPitch * height / 2);
-	    if(pPriv->doubleBuffer) {
-		pPriv->YBuf1offset = pPriv->YBuf0offset + size;
-		pPriv->UBuf1offset = pPriv->YBuf1offset + (dstPitch * 2 * height);
-		pPriv->VBuf1offset = pPriv->UBuf1offset + (dstPitch * height / 2);
-	    }
+	    pPriv->UBufOffset = pPriv->YBufOffset + (dstPitch * 2 * height);
+	    pPriv->VBufOffset = pPriv->UBufOffset + (dstPitch * height / 2);
 	}
 #ifdef INTEL_XVMC
     }
 #endif
 
-    /* Pick the idle buffer */
-    if (!pPriv->textured && pI830->overlayOn && pPriv->doubleBuffer)
-	pPriv->currentBuf = !((INREG(DOVSTA) & OC_BUF) >> 20);
-
     /* copy data */
     top = y1 >> 16;
     left = (x1 >> 16) & ~1;
@@ -2498,9 +2461,9 @@ I830PutImage(ScrnInfoPtr pScrn,
         if (IS_I965G(pI830)) {
 #ifdef INTEL_XVMC
             if (id == FOURCC_XVMC && pPriv->rotation == RR_Rotate_0) {
-                pPriv->YBuf0offset = buf -  pI830->FbBase;
-                pPriv->UBuf0offset = pPriv->YBuf0offset + height*width; 
-                pPriv->VBuf0offset = pPriv->UBuf0offset + height*width/4; 
+                pPriv->YBufOffset = buf -  pI830->FbBase;
+                pPriv->UBufOffset = pPriv->YBufOffset + height*width; 
+                pPriv->VBufOffset = pPriv->UBufOffset + height*width/4; 
             }
 #endif
             I965DisplayVideoTextured(pScrn, pPriv, destId, clipBoxes, width, height,
@@ -2761,7 +2724,6 @@ I830DisplaySurface(XF86SurfacePtr surface,
     OffscreenPrivPtr pPriv = (OffscreenPrivPtr) surface->devPrivate.ptr;
     ScrnInfoPtr pScrn = surface->pScrn;
     ScreenPtr pScreen = screenInfo.screens[pScrn->scrnIndex];
-    I830Ptr pI830 = I830PTR(pScrn);
     I830PortPrivPtr pI830Priv = GET_PORT_PRIVATE(pScrn);
     INT32 x1, y1, x2, y2;
     BoxRec dstBox;
@@ -2785,12 +2747,7 @@ I830DisplaySurface(XF86SurfacePtr surface,
 	return Success;
 
     /* fixup pointers */
-    pI830Priv->YBuf0offset = surface->offsets[0];
-    pI830Priv->YBuf1offset = pI830Priv->YBuf0offset;
-
-    /* Pick the idle buffer */
-    if (!pI830Priv->textured && pI830->overlayOn && pI830Priv->doubleBuffer)
-	pI830Priv->currentBuf = !((INREG(DOVSTA) & OC_BUF) >> 20);
+    pI830Priv->YBufOffset = surface->offsets[0];
 
     i830_display_overlay(pScrn, crtc, surface->id, surface->width, surface->height,
 		     surface->pitches[0], x1, y1, x2, y2, &dstBox,
diff --git a/src/i830_video.h b/src/i830_video.h
index fb4ad29..9093d5d 100644
--- a/src/i830_video.h
+++ b/src/i830_video.h
@@ -28,13 +28,9 @@ THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "xf86_OSproc.h"
 
 typedef struct {
-   uint32_t YBuf0offset;
-   uint32_t UBuf0offset;
-   uint32_t VBuf0offset;
-
-   uint32_t YBuf1offset;
-   uint32_t UBuf1offset;
-   uint32_t VBuf1offset;
+   uint32_t YBufOffset;
+   uint32_t UBufOffset;
+   uint32_t VBufOffset;
 
    unsigned char currentBuf;
 
diff --git a/src/i915_video.c b/src/i915_video.c
index e974dee..2a74938 100644
--- a/src/i915_video.c
+++ b/src/i915_video.c
@@ -158,9 +158,9 @@ I915DisplayVideoTextured(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, int id,
       OUT_BATCH(_3DSTATE_MAP_STATE | 3);
       OUT_BATCH(0x00000001);	/* texture map #1 */
       if (pPriv->buf)
-          OUT_RELOC(pPriv->buf, I915_GEM_DOMAIN_SAMPLER, 0, pPriv->YBuf0offset);
+          OUT_RELOC(pPriv->buf, I915_GEM_DOMAIN_SAMPLER, 0, pPriv->YBufOffset);
       else
-          OUT_BATCH(pPriv->YBuf0offset);
+          OUT_BATCH(pPriv->YBufOffset);
 
       ms3 = MAPSURF_422 | MS3_USE_FENCE_REGS;
       switch (id) {
@@ -270,9 +270,9 @@ I915DisplayVideoTextured(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, int id,
       OUT_BATCH(0x00000007);
 
       if (pPriv->buf)
-          OUT_RELOC(pPriv->buf, I915_GEM_DOMAIN_SAMPLER, 0, pPriv->YBuf0offset);
+          OUT_RELOC(pPriv->buf, I915_GEM_DOMAIN_SAMPLER, 0, pPriv->YBufOffset);
       else
-          OUT_BATCH(pPriv->YBuf0offset);
+          OUT_BATCH(pPriv->YBufOffset);
 
       ms3 = MAPSURF_8BIT | MT_8BIT_I8 | MS3_USE_FENCE_REGS;
       ms3 |= (height - 1) << MS3_HEIGHT_SHIFT;
@@ -287,9 +287,9 @@ I915DisplayVideoTextured(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, int id,
 	  OUT_BATCH(((video_pitch * 2 / 4) - 1) << MS4_PITCH_SHIFT);
 
       if (pPriv->buf)
-          OUT_RELOC(pPriv->buf, I915_GEM_DOMAIN_SAMPLER, 0, pPriv->UBuf0offset);
+          OUT_RELOC(pPriv->buf, I915_GEM_DOMAIN_SAMPLER, 0, pPriv->UBufOffset);
       else
-          OUT_BATCH(pPriv->UBuf0offset);
+          OUT_BATCH(pPriv->UBufOffset);
 
       ms3 = MAPSURF_8BIT | MT_8BIT_I8 | MS3_USE_FENCE_REGS;
       ms3 |= (height / 2 - 1) << MS3_HEIGHT_SHIFT;
@@ -298,9 +298,9 @@ I915DisplayVideoTextured(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, int id,
       OUT_BATCH(((video_pitch / 4) - 1) << MS4_PITCH_SHIFT);
 
       if (pPriv->buf)
-          OUT_RELOC(pPriv->buf, I915_GEM_DOMAIN_SAMPLER, 0, pPriv->VBuf0offset);
+          OUT_RELOC(pPriv->buf, I915_GEM_DOMAIN_SAMPLER, 0, pPriv->VBufOffset);
       else
-          OUT_BATCH(pPriv->VBuf0offset);
+          OUT_BATCH(pPriv->VBufOffset);
 
       ms3 = MAPSURF_8BIT | MT_8BIT_I8 | MS3_USE_FENCE_REGS;
       ms3 |= (height / 2 - 1) << MS3_HEIGHT_SHIFT;
diff --git a/src/i965_video.c b/src/i965_video.c
index 38ccb0a..eba3940 100644
--- a/src/i965_video.c
+++ b/src/i965_video.c
@@ -1000,12 +1000,12 @@ I965DisplayVideoTextured(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, int id,
     ErrorF ("INST_PM 0x%08x\n", INREG(INST_PM));
 #endif
 
-    src_surf_base[0] = pPriv->YBuf0offset;
-    src_surf_base[1] = pPriv->YBuf0offset;
-    src_surf_base[2] = pPriv->VBuf0offset;
-    src_surf_base[3] = pPriv->VBuf0offset;
-    src_surf_base[4] = pPriv->UBuf0offset;
-    src_surf_base[5] = pPriv->UBuf0offset;
+    src_surf_base[0] = pPriv->YBufOffset;
+    src_surf_base[1] = pPriv->YBufOffset;
+    src_surf_base[2] = pPriv->VBufOffset;
+    src_surf_base[3] = pPriv->VBufOffset;
+    src_surf_base[4] = pPriv->UBufOffset;
+    src_surf_base[5] = pPriv->UBufOffset;
 #if 0
     ErrorF ("base 0 0x%x base 1 0x%x base 2 0x%x\n",
 	    src_surf_base[0], src_surf_base[1], src_surf_base[2]);
-- 
1.6.3.3




More information about the Intel-gfx mailing list