[Intel-gfx] [PATCH 06/13] Xv: use is_planar_fourcc helper some more

Daniel Vetter daniel.vetter at ffwll.ch
Tue Jun 30 13:12:48 CEST 2009


Signed-off-by: Daniel Vetter <daniel.vetter at ffwll.ch>
---
 src/i830_video.c |   49 ++++++++++++-------------------------------------
 src/i830_video.h |    2 ++
 src/i915_video.c |   17 +----------------
 src/i965_video.c |   36 ++++++++++++------------------------
 4 files changed, 27 insertions(+), 77 deletions(-)

diff --git a/src/i830_video.c b/src/i830_video.c
index 93df761..a20af16 100644
--- a/src/i830_video.c
+++ b/src/i830_video.c
@@ -1975,7 +1975,7 @@ i830_update_scaling_factors(I830OverlayRegPtr overlay,
     return scaleChanged;
 }
 
-static int
+int
 is_planar_fourcc(int id)
 {
     switch (id) {
@@ -1987,7 +1987,9 @@ is_planar_fourcc(int id)
 	return 1;
     case FOURCC_UYVY:
     case FOURCC_YUY2:
+	return 0;
     default:
+	ErrorF("Unknown format 0x%x\n", id);
 	return 0;
     }
 }
@@ -2279,23 +2281,11 @@ I830PutImage(ScrnInfoPtr pScrn,
      }
 
     destId = id;
-    switch (id) {
-    case FOURCC_YV12:
-    case FOURCC_I420:
-	srcPitch = (width + 0x3) & ~0x3;
-	srcPitch2 = ((width >> 1) + 0x3) & ~0x3;
-	break;
-#ifdef INTEL_XVMC
-    case FOURCC_XVMC:
+    if (is_planar_fourcc(id)) {
 	srcPitch = (width + 0x3) & ~0x3;
 	srcPitch2 = ((width >> 1) + 0x3) & ~0x3;
-	break;
-#endif
-    case FOURCC_UYVY:
-    case FOURCC_YUY2:
-    default:
+    } else {
 	srcPitch = width << 1;
-	break;
     }
 
     /* Only needs to be DWORD-aligned for textured on i915, but overlay has
@@ -2439,33 +2429,18 @@ I830PutImage(ScrnInfoPtr pScrn,
     left = (x1 >> 16) & ~1;
     npixels = ((((x2 + 0xffff) >> 16) + 1) & ~1) - left;
 
-    switch (id) {
-    case FOURCC_YV12:
-    case FOURCC_I420:
-	top &= ~1;
-	nlines = ((((y2 + 0xffff) >> 16) + 1) & ~1) - top;
-	I830CopyPlanarData(pScrn, pPriv, buf, srcPitch, srcPitch2, dstPitch,
-	    	       height, top, left, nlines, npixels, id);
-	break;
-    case FOURCC_UYVY:
-    case FOURCC_YUY2:
-	nlines = ((y2 + 0xffff) >> 16) - top;
-	I830CopyPackedData(pScrn, pPriv, buf, srcPitch, dstPitch, top, left,
-			   nlines, npixels);
-	break;
-#ifdef INTEL_XVMC
-    case FOURCC_XVMC:
-	if (pPriv->rotation != RR_Rotate_0) {
+    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);
 	}
-
-	break;
-#endif
-    default:
-	break;
+    } else {
+	nlines = ((y2 + 0xffff) >> 16) - top;
+	I830CopyPackedData(pScrn, pPriv, buf, srcPitch, dstPitch, top, left,
+			   nlines, npixels);
     }
 
     if (!pPriv->textured) {
diff --git a/src/i830_video.h b/src/i830_video.h
index 03e2ba9..fb4ad29 100644
--- a/src/i830_video.h
+++ b/src/i830_video.h
@@ -91,3 +91,5 @@ void I965DisplayVideoTextured(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv,
 void I830VideoBlockHandler(int i, pointer blockData, pointer pTimeout,
 			   pointer pReadmask);
 void i965_free_video(ScrnInfoPtr scrn);
+
+int is_planar_fourcc(int id);
diff --git a/src/i915_video.c b/src/i915_video.c
index 1ef58ac..e974dee 100644
--- a/src/i915_video.c
+++ b/src/i915_video.c
@@ -53,27 +53,12 @@ I915DisplayVideoTextured(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, int id,
    int nbox_total = REGION_NUM_RECTS(dstRegion);
    int nbox_this_time;
    int dxo, dyo, pix_xoff, pix_yoff;
-   Bool planar;
 
 #if 0
    ErrorF("I915DisplayVideo: %dx%d (pitch %d)\n", width, height,
 	  video_pitch);
 #endif
 
-   switch (id) {
-   case FOURCC_UYVY:
-   case FOURCC_YUY2:
-      planar = FALSE;
-      break;
-   case FOURCC_YV12:
-   case FOURCC_I420:
-      planar = TRUE;
-      break;
-   default:
-      ErrorF("Unknown format 0x%x\n", id);
-      return;
-   }
-
 #define BYTES_FOR_BOXES(n)	((200 + (n) * 20) * 4)
 #define BOXES_IN_BYTES(s)	((((s)/4) - 200) / 20)
 #define BATCH_BYTES(p)		((p)->batch_bo->size - 16)
@@ -147,7 +132,7 @@ I915DisplayVideoTextured(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, int id,
    OUT_RELOC_PIXMAP(pPixmap, I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER, 0);
    ADVANCE_BATCH();
 
-   if (!planar) {
+   if (!is_planar_fourcc(id)) {
       FS_LOCALS(10);
 
       BEGIN_BATCH(16);
diff --git a/src/i965_video.c b/src/i965_video.c
index d459027..f231271 100644
--- a/src/i965_video.c
+++ b/src/i965_video.c
@@ -921,26 +921,7 @@ I965DisplayVideoTextured(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, int id,
 	    src_surf_base[0], src_surf_base[1], src_surf_base[2]);
 #endif
     
-    switch (id) {
-    case FOURCC_UYVY:
-	src_surf_format = BRW_SURFACEFORMAT_YCRCB_SWAPY;
-	n_src_surf = 1;
-	src_width[0] = width;
-	src_height[0] = height;
-	src_pitch[0] = video_pitch;
-	break;
-    case FOURCC_YUY2:
-	src_surf_format = BRW_SURFACEFORMAT_YCRCB_NORMAL;
-	src_width[0] = width;
-	src_height[0] = height;
-	src_pitch[0] = video_pitch;
-	n_src_surf = 1;
-	break;
-#ifdef INTEL_XVMC
-    case FOURCC_XVMC:
-#endif
-    case FOURCC_I420:
-    case FOURCC_YV12:
+    if (is_planar_fourcc(id)) {
 	src_surf_format = BRW_SURFACEFORMAT_R8_UNORM;
 	src_width[1] = src_width[0] = width;
 	src_height[1] = src_height[0] = height;
@@ -949,10 +930,17 @@ I965DisplayVideoTextured(ScrnInfoPtr pScrn, I830PortPrivPtr pPriv, int id,
 	src_height[4] = src_height[5] = src_height[2] = src_height[3] = height / 2;
 	src_pitch[4] = src_pitch[5] = src_pitch[2] = src_pitch[3] = video_pitch;
 	n_src_surf = 6;
-	break;
-    default:
-	return;
-    }    
+    } else {
+	if (id == FOURCC_UYVY)
+	    src_surf_format = BRW_SURFACEFORMAT_YCRCB_SWAPY;
+	else 
+	    src_surf_format = BRW_SURFACEFORMAT_YCRCB_NORMAL;
+
+	src_width[0] = width;
+	src_height[0] = height;
+	src_pitch[0] = video_pitch;
+	n_src_surf = 1;
+    }
 
 #if 0
     ErrorF("dst surf:      0x%08x\n", state_base_offset + dest_surf_offset);
-- 
1.6.3.3




More information about the Intel-gfx mailing list