xf86-video-intel: 7 commits - src/i830_video.c src/i830_video.h src/i915_video.c src/i965_video.c

Eric Anholt anholt at kemper.freedesktop.org
Thu Jan 7 10:25:53 PST 2010


 src/i830_video.c |  337 +++++++++++++++++++++++++++++++------------------------
 src/i830_video.h |    3 
 src/i915_video.c |    2 
 src/i965_video.c |    1 
 4 files changed, 193 insertions(+), 150 deletions(-)

New commits:
commit 229d23fb18d696fb7ad476ce335be14ec9811bd3
Author: Daniel Vetter <daniel.vetter at ffwll.ch>
Date:   Tue Dec 1 14:32:34 2009 +0100

    Xv: don't enable XVMC port on unsupported configs
    
    This just makes it _really_ clear, what's supported. No other changes.
    
    Signed-off-by: Daniel Vetter <daniel.vetter at ffwll.ch>
    Signed-off-by: Eric Anholt <eric at anholt.net>

diff --git a/src/i830_video.c b/src/i830_video.c
index 397a264..964f1e0 100644
--- a/src/i830_video.c
+++ b/src/i830_video.c
@@ -169,7 +169,13 @@ static XF86AttributeRec GammaAttributes[GAMMA_ATTRIBUTES] = {
 	{XvSettable | XvGettable, 0, 0xffffff, "XV_GAMMA5"}
 };
 
+#ifdef INTEL_XVMC
 #define NUM_IMAGES 5
+#define XVMC_IMAGE 1
+#else
+#define NUM_IMAGES 4
+#define XVMC_IMAGE 0
+#endif
 
 static XF86ImageRec Images[NUM_IMAGES] = {
 	XVIMAGE_YUY2,
@@ -469,7 +475,8 @@ static XF86VideoAdaptorPtr I830SetupImageVideoOverlay(ScreenPtr screen)
 		       sizeof(XF86AttributeRec) * GAMMA_ATTRIBUTES);
 		att += GAMMA_ATTRIBUTES;
 	}
-	adapt->nImages = NUM_IMAGES;
+	adapt->nImages = NUM_IMAGES - XVMC_IMAGE;
+
 	adapt->pImages = Images;
 	adapt->PutVideo = NULL;
 	adapt->PutStill = NULL;
@@ -528,6 +535,8 @@ static XF86VideoAdaptorPtr I830SetupImageVideoOverlay(ScreenPtr screen)
 
 static XF86VideoAdaptorPtr I830SetupImageVideoTextured(ScreenPtr screen)
 {
+	ScrnInfoPtr scrn = xf86Screens[screen->myNum];
+	intel_screen_private *intel = intel_get_screen_private(scrn);
 	XF86VideoAdaptorPtr adapt;
 	XF86AttributePtr attrs;
 	intel_adaptor_private *adaptor_privs;
@@ -565,7 +574,11 @@ static XF86VideoAdaptorPtr I830SetupImageVideoTextured(ScreenPtr screen)
 	adapt->pAttributes = attrs;
 	memcpy(attrs, TexturedAttributes,
 	       nAttributes * sizeof(XF86AttributeRec));
-	adapt->nImages = NUM_IMAGES;
+	if (IS_I915(intel))
+		adapt->nImages = NUM_IMAGES - XVMC_IMAGE;
+	else
+		adapt->nImages = NUM_IMAGES;
+
 	adapt->pImages = Images;
 	adapt->PutVideo = NULL;
 	adapt->PutStill = NULL;
commit ce7ba18f577cc9aedddaff303dbc9662a276b4cf
Author: Daniel Vetter <daniel.vetter at ffwll.ch>
Date:   Tue Dec 1 14:32:33 2009 +0100

    Xv: consolidate xmvc passthrough handling
    
    It's now all in I830PutImageTextured. Also kill some leftovers
    from XVMC-on-overlay support and ums-XVMC-on-i915 support. Plus
    a small comment as a reminder for where to add i915 xvmc support
    back in.
    
    Signed-off-by: Daniel Vetter <daniel.vetter at ffwll.ch>
    Signed-off-by: Eric Anholt <eric at anholt.net>

diff --git a/src/i830_video.c b/src/i830_video.c
index 2f38b2b..397a264 100644
--- a/src/i830_video.c
+++ b/src/i830_video.c
@@ -1355,22 +1355,12 @@ i830_setup_video_buffer(ScrnInfoPtr scrn, intel_adaptor_private *adaptor_priv,
 		adaptor_priv->buf = NULL;
 	}
 
-	if (xvmc_passthrough(id)) {
-		i830_free_video_buffers(adaptor_priv);
-		if (IS_I965G(intel)) {
-			adaptor_priv->buf =
-				drm_intel_bo_gem_create_from_name(intel->bufmgr,
-								  "xvmc surface",
-								  (uintptr_t)buf);
-		}
-	} else {
-		if (adaptor_priv->buf == NULL) {
-			adaptor_priv->buf = drm_intel_bo_alloc(intel->bufmgr,
-							"xv buffer", alloc_size,
-							4096);
-			if (adaptor_priv->buf == NULL)
-				return FALSE;
-		}
+	if (adaptor_priv->buf == NULL) {
+		adaptor_priv->buf = drm_intel_bo_alloc(intel->bufmgr,
+						"xv buffer", alloc_size,
+						4096);
+		if (adaptor_priv->buf == NULL)
+			return FALSE;
 	}
 
 	return TRUE;
@@ -1389,11 +1379,6 @@ i830_dst_pitch_and_size(ScrnInfoPtr scrn, intel_adaptor_private *adaptor_priv, s
 	 */
 	if (adaptor_priv->textured) {
 		pitchAlignMask = 3;
-#ifdef INTEL_XVMC
-		/* for i915 xvmc, hw requires at least 1kb aligned surface */
-		if ((id == FOURCC_XVMC) && IS_I915(intel))
-			pitchAlignMask = 0x3ff;
-#endif
 	} else {
 		if (IS_I965G(intel))
 			pitchAlignMask = 255;
@@ -1471,38 +1456,25 @@ i830_copy_video_data(ScrnInfoPtr scrn, intel_adaptor_private *adaptor_priv,
 		return FALSE;
 
 	/* fixup pointers */
-#ifdef INTEL_XVMC
-	if (id == FOURCC_XVMC && IS_I915(intel)) {
-		adaptor_priv->YBufOffset = (uint32_t) ((uintptr_t) buf);
-		adaptor_priv->VBufOffset = adaptor_priv->YBufOffset + (*dstPitch2 * height);
+	adaptor_priv->YBufOffset = 0;
+
+	if (adaptor_priv->rotation & (RR_Rotate_90 | RR_Rotate_270)) {
 		adaptor_priv->UBufOffset =
-		    adaptor_priv->VBufOffset + (*dstPitch * height / 2);
+		    adaptor_priv->YBufOffset + (*dstPitch * 2 * width);
+		adaptor_priv->VBufOffset =
+		    adaptor_priv->UBufOffset + (*dstPitch * width / 2);
 	} else {
-#endif
-		adaptor_priv->YBufOffset = 0;
-
-		if (adaptor_priv->rotation & (RR_Rotate_90 | RR_Rotate_270)) {
-			adaptor_priv->UBufOffset =
-			    adaptor_priv->YBufOffset + (*dstPitch * 2 * width);
-			adaptor_priv->VBufOffset =
-			    adaptor_priv->UBufOffset + (*dstPitch * width / 2);
-		} else {
-			adaptor_priv->UBufOffset =
-			    adaptor_priv->YBufOffset + (*dstPitch * 2 * height);
-			adaptor_priv->VBufOffset =
-			    adaptor_priv->UBufOffset + (*dstPitch * height / 2);
-		}
-#ifdef INTEL_XVMC
+		adaptor_priv->UBufOffset =
+		    adaptor_priv->YBufOffset + (*dstPitch * 2 * height);
+		adaptor_priv->VBufOffset =
+		    adaptor_priv->UBufOffset + (*dstPitch * height / 2);
 	}
-#endif
 
 	/* copy data */
 	if (is_planar_fourcc(id)) {
-		if (!xvmc_passthrough(id)) {
-			I830CopyPlanarData(adaptor_priv, buf, srcPitch, srcPitch2,
-					   *dstPitch, height, top, left, nlines,
-					   npixels, id);
-		}
+		I830CopyPlanarData(adaptor_priv, buf, srcPitch, srcPitch2,
+				   *dstPitch, height, top, left, nlines,
+				   npixels, id);
 	} else {
 		I830CopyPackedData(adaptor_priv, buf, srcPitch, *dstPitch, top, left,
 				   nlines, npixels);
@@ -1561,10 +1533,24 @@ I830PutImageTextured(ScrnInfoPtr scrn,
 				    width, height))
 		return Success;
 
-	if (!i830_copy_video_data(scrn, adaptor_priv, width, height,
-				  &dstPitch, &dstPitch2,
-				  top, left, npixels, nlines, id, buf))
-		return BadAlloc;
+	if (xvmc_passthrough(id)) {
+		i830_free_video_buffers(adaptor_priv);
+		if (IS_I965G(intel)) {
+			adaptor_priv->buf =
+				drm_intel_bo_gem_create_from_name(intel->bufmgr,
+								  "xvmc surface",
+								  (uintptr_t)buf);
+		} else {
+			/* XXX: i915 is not support and needs some serious care.
+			 * grep for KMS in i915_hwmc.c */
+			return BadAlloc;
+		}
+	} else {
+		if (!i830_copy_video_data(scrn, adaptor_priv, width, height,
+					  &dstPitch, &dstPitch2,
+					  top, left, npixels, nlines, id, buf))
+			return BadAlloc;
+	}
 
 	if (crtc && adaptor_priv->SyncToVblank != 0) {
 		i830_wait_for_scanline(scrn, pixmap, crtc, clipBoxes);
commit 1ac7c94083a3266e2d5dd932709118436074dd00
Author: Daniel Vetter <daniel.vetter at ffwll.ch>
Date:   Tue Dec 1 14:32:32 2009 +0100

    Xv: hide ugly semantics in i830_clip_video_helper
    
    I'm still curious as to why fixed-point semantics are necessary
    for this generic XV helper function that's been causing all this.
    Can modern X really run on hw without floating-point support?
    
    Anyway, the ugliness is now all nicely under the carpet (in
    i830_clip_video_helper).
    
    Signed-off-by: Daniel Vetter <daniel.vetter at ffwll.ch>
    Signed-off-by: Eric Anholt <eric at anholt.net>

diff --git a/src/i830_video.c b/src/i830_video.c
index 30017f0..2f38b2b 100644
--- a/src/i830_video.c
+++ b/src/i830_video.c
@@ -1210,22 +1210,36 @@ i830_clip_video_helper(ScrnInfoPtr scrn,
 		       intel_adaptor_private *adaptor_priv,
 		       xf86CrtcPtr * crtc_ret,
 		       BoxPtr dst,
-		       INT32 * xa,
-		       INT32 * xb,
-		       INT32 * ya,
-		       INT32 * yb, RegionPtr reg, INT32 width, INT32 height)
+		       short src_x, short src_y,
+		       short drw_x, short drw_y,
+		       short src_w, short src_h,
+		       short drw_w, short drw_h,
+		       int id,
+		       int *top, int* left, int* npixels, int *nlines,
+		       RegionPtr reg, INT32 width, INT32 height)
 {
 	Bool ret;
 	RegionRec crtc_region_local;
 	RegionPtr crtc_region = reg;
 	BoxRec crtc_box;
+	INT32 x1, x2, y1, y2;
+	xf86CrtcPtr crtc;
+
+	x1 = src_x;
+	x2 = src_x + src_w;
+	y1 = src_y;
+	y2 = src_y + src_h;
+
+	dst->x1 = drw_x;
+	dst->x2 = drw_x + drw_w;
+	dst->y1 = drw_y;
+	dst->y2 = drw_y + drw_h;
 
 	/*
 	 * For overlay video, compute the relevant CRTC and
 	 * clip video to that
 	 */
-	xf86CrtcPtr crtc = i830_covering_crtc(scrn, dst,
-					      adaptor_priv->desired_crtc,
+	crtc = i830_covering_crtc(scrn, dst, adaptor_priv->desired_crtc,
 					      &crtc_box);
 
 	/* For textured video, we don't actually want to clip at all. */
@@ -1237,10 +1251,20 @@ i830_clip_video_helper(ScrnInfoPtr scrn,
 	}
 	*crtc_ret = crtc;
 
-	ret = xf86XVClipVideoHelper(dst, xa, xb, ya, yb,
+	ret = xf86XVClipVideoHelper(dst, &x1, &x2, &y1, &y2,
 				    crtc_region, width, height);
 	if (crtc_region != reg)
 		REGION_UNINIT(screen, &crtc_region_local);
+
+	*top = y1 >> 16;
+	*left = (x1 >> 16) & ~1;
+	*npixels = ((((x2 + 0xffff) >> 16) + 1) & ~1) - *left;
+	if (is_planar_fourcc(id)) {
+		*top &= ~1;
+		*nlines = ((((y2 + 0xffff) >> 16) + 1) & ~1) - *top;
+	} else
+		*nlines = ((y2 + 0xffff) >> 16) - *top;
+
 	return ret;
 }
 
@@ -1514,7 +1538,6 @@ I830PutImageTextured(ScrnInfoPtr scrn,
 	intel_screen_private *intel = intel_get_screen_private(scrn);
 	intel_adaptor_private *adaptor_priv = (intel_adaptor_private *) data;
 	PixmapPtr pixmap = get_drawable_pixmap(drawable);
-	INT32 x1, x2, y1, y2;
 	int dstPitch;
 	int dstPitch2 = 0;
 	BoxRec dstBox;
@@ -1527,33 +1550,17 @@ I830PutImageTextured(ScrnInfoPtr scrn,
 	       drw_y, drw_w, drw_h, width, height);
 #endif
 
-	/* Clip */
-	x1 = src_x;
-	x2 = src_x + src_w;
-	y1 = src_y;
-	y2 = src_y + src_h;
-
-	dstBox.x1 = drw_x;
-	dstBox.x2 = drw_x + drw_w;
-	dstBox.y1 = drw_y;
-	dstBox.y2 = drw_y + drw_h;
-
 	if (!i830_clip_video_helper(scrn,
 				    adaptor_priv,
 				    &crtc,
-				    &dstBox, &x1, &x2, &y1, &y2, clipBoxes,
+				    &dstBox,
+				    src_x, src_y, drw_x, drw_y,
+				    src_w, src_h, drw_w, drw_h,
+				    id,
+				    &top, &left, &npixels, &nlines, clipBoxes,
 				    width, height))
 		return Success;
 
-	top = y1 >> 16;
-	left = (x1 >> 16) & ~1;
-	npixels = ((((x2 + 0xffff) >> 16) + 1) & ~1) - left;
-	if (is_planar_fourcc(id)) {
-		top &= ~1;
-		nlines = ((((y2 + 0xffff) >> 16) + 1) & ~1) - top;
-	} else
-		nlines = ((y2 + 0xffff) >> 16) - top;
-
 	if (!i830_copy_video_data(scrn, adaptor_priv, width, height,
 				  &dstPitch, &dstPitch2,
 				  top, left, npixels, nlines, id, buf))
@@ -1594,7 +1601,6 @@ I830PutImageOverlay(ScrnInfoPtr scrn,
 {
 	intel_adaptor_private *adaptor_priv = (intel_adaptor_private *) data;
 	ScreenPtr screen = screenInfo.screens[scrn->scrnIndex];
-	INT32 x1, x2, y1, y2;
 	int dstPitch;
 	int dstPitch2 = 0;
 	BoxRec dstBox;
@@ -1616,21 +1622,14 @@ I830PutImageOverlay(ScrnInfoPtr scrn,
 	if (src_h >= (drw_h * 8))
 		drw_h = src_h / 7;
 
-	/* Clip */
-	x1 = src_x;
-	x2 = src_x + src_w;
-	y1 = src_y;
-	y2 = src_y + src_h;
-
-	dstBox.x1 = drw_x;
-	dstBox.x2 = drw_x + drw_w;
-	dstBox.y1 = drw_y;
-	dstBox.y2 = drw_y + drw_h;
-
 	if (!i830_clip_video_helper(scrn,
 				    adaptor_priv,
 				    &crtc,
-				    &dstBox, &x1, &x2, &y1, &y2, clipBoxes,
+				    &dstBox,
+				    src_x, src_y, drw_x, drw_y,
+				    src_w, src_h, drw_w, drw_h,
+				    id,
+				    &top, &left, &npixels, &nlines, clipBoxes,
 				    width, height))
 		return Success;
 
@@ -1643,15 +1642,6 @@ I830PutImageOverlay(ScrnInfoPtr scrn,
 		return Success;
 	}
 
-	top = y1 >> 16;
-	left = (x1 >> 16) & ~1;
-	npixels = ((((x2 + 0xffff) >> 16) + 1) & ~1) - left;
-	if (is_planar_fourcc(id)) {
-		top &= ~1;
-		nlines = ((((y2 + 0xffff) >> 16) + 1) & ~1) - top;
-	} else
-		nlines = ((y2 + 0xffff) >> 16) - top;
-
 	if (!i830_copy_video_data(scrn, adaptor_priv, width, height,
 				  &dstPitch, &dstPitch2,
 				  top, left, npixels, nlines, id, buf))
commit 31f13fa8a0d4cd28067de37d0d31d23e8200d0ff
Author: Daniel Vetter <daniel.vetter at ffwll.ch>
Date:   Tue Dec 1 14:32:31 2009 +0100

    Xv: move users of x1, x2, y1, y2 to PutImage
    
    After this there are no other external users of these strange variables,
    so we can nicely hide them somewhere in the next changeset.
    
    Signed-off-by: Daniel Vetter <daniel.vetter at ffwll.ch>
    Signed-off-by: Eric Anholt <eric at anholt.net>

diff --git a/src/i830_video.c b/src/i830_video.c
index c078399..30017f0 100644
--- a/src/i830_video.c
+++ b/src/i830_video.c
@@ -1427,14 +1427,11 @@ i830_dst_pitch_and_size(ScrnInfoPtr scrn, intel_adaptor_private *adaptor_priv, s
 static Bool
 i830_copy_video_data(ScrnInfoPtr scrn, intel_adaptor_private *adaptor_priv,
 		     short width, short height, int *dstPitch, int *dstPitch2,
-		     INT32 x1, INT32 y1, INT32 x2, INT32 y2,
+		     int top, int left, int npixels, int nlines,
 		     int id, unsigned char *buf)
 {
-#ifdef INTEL_XVMC
-	intel_screen_private *intel = intel_get_screen_private(scrn);
-#endif
 	int srcPitch = 0, srcPitch2 = 0;
-	int top, left, npixels, nlines, size;
+	int size;
 
 	if (is_planar_fourcc(id)) {
 		srcPitch = (width + 0x3) & ~0x3;
@@ -1476,20 +1473,13 @@ i830_copy_video_data(ScrnInfoPtr scrn, intel_adaptor_private *adaptor_priv,
 #endif
 
 	/* copy data */
-	top = y1 >> 16;
-	left = (x1 >> 16) & ~1;
-	npixels = ((((x2 + 0xffff) >> 16) + 1) & ~1) - left;
-
 	if (is_planar_fourcc(id)) {
 		if (!xvmc_passthrough(id)) {
-			top &= ~1;
-			nlines = ((((y2 + 0xffff) >> 16) + 1) & ~1) - top;
 			I830CopyPlanarData(adaptor_priv, buf, srcPitch, srcPitch2,
 					   *dstPitch, height, top, left, nlines,
 					   npixels, id);
 		}
 	} else {
-		nlines = ((y2 + 0xffff) >> 16) - top;
 		I830CopyPackedData(adaptor_priv, buf, srcPitch, *dstPitch, top, left,
 				   nlines, npixels);
 	}
@@ -1529,6 +1519,7 @@ I830PutImageTextured(ScrnInfoPtr scrn,
 	int dstPitch2 = 0;
 	BoxRec dstBox;
 	xf86CrtcPtr crtc;
+	int top, left, npixels, nlines;
 
 #if 0
 	ErrorF("I830PutImage: src: (%d,%d)(%d,%d), dst: (%d,%d)(%d,%d)\n"
@@ -1554,9 +1545,18 @@ I830PutImageTextured(ScrnInfoPtr scrn,
 				    width, height))
 		return Success;
 
+	top = y1 >> 16;
+	left = (x1 >> 16) & ~1;
+	npixels = ((((x2 + 0xffff) >> 16) + 1) & ~1) - left;
+	if (is_planar_fourcc(id)) {
+		top &= ~1;
+		nlines = ((((y2 + 0xffff) >> 16) + 1) & ~1) - top;
+	} else
+		nlines = ((y2 + 0xffff) >> 16) - top;
+
 	if (!i830_copy_video_data(scrn, adaptor_priv, width, height,
 				  &dstPitch, &dstPitch2,
-				  x1, y1, x2, y2, id, buf))
+				  top, left, npixels, nlines, id, buf))
 		return BadAlloc;
 
 	if (crtc && adaptor_priv->SyncToVblank != 0) {
@@ -1599,6 +1599,7 @@ I830PutImageOverlay(ScrnInfoPtr scrn,
 	int dstPitch2 = 0;
 	BoxRec dstBox;
 	xf86CrtcPtr crtc;
+	int top, left, npixels, nlines;
 
 #if 0
 	ErrorF("I830PutImage: src: (%d,%d)(%d,%d), dst: (%d,%d)(%d,%d)\n"
@@ -1642,9 +1643,18 @@ I830PutImageOverlay(ScrnInfoPtr scrn,
 		return Success;
 	}
 
+	top = y1 >> 16;
+	left = (x1 >> 16) & ~1;
+	npixels = ((((x2 + 0xffff) >> 16) + 1) & ~1) - left;
+	if (is_planar_fourcc(id)) {
+		top &= ~1;
+		nlines = ((((y2 + 0xffff) >> 16) + 1) & ~1) - top;
+	} else
+		nlines = ((y2 + 0xffff) >> 16) - top;
+
 	if (!i830_copy_video_data(scrn, adaptor_priv, width, height,
 				  &dstPitch, &dstPitch2,
-				  x1, y1, x2, y2, id, buf))
+				  top, left, npixels, nlines, id, buf))
 		return BadAlloc;
 
 	if (!i830_display_overlay
commit ce6526b9b4df304ccd83a0a02a95621300dbaed3
Author: Daniel Vetter <daniel.vetter at ffwll.ch>
Date:   Tue Dec 1 14:32:30 2009 +0100

    Xv: kill unnecessary parameters for hw PutImage functions
    
    This is the first part of my small crusade to rip out x1, x2, y1, y2
    from I830PutImage*. These variables have strange semantics (they
    change from simple integers to fixed-point values somewhere in
    the middle) and don't really seem to be what we actually need.
    
    Signed-off-by: Daniel Vetter <daniel.vetter at ffwll.ch>
    Signed-off-by: Eric Anholt <eric at anholt.net>

diff --git a/src/i830_video.c b/src/i830_video.c
index aa3a604..c078399 100644
--- a/src/i830_video.c
+++ b/src/i830_video.c
@@ -261,7 +261,7 @@ static void drmmode_overlay_off(ScrnInfoPtr scrn)
 static Bool
 drmmode_overlay_put_image(ScrnInfoPtr scrn, xf86CrtcPtr crtc,
 			  int id, short width, short height,
-			  int dstPitch, int x1, int y1, int x2, int y2,
+			  int dstPitch,
 			  BoxPtr dstBox, short src_w, short src_h, short drw_w,
 			  short drw_h)
 {
@@ -1168,7 +1168,7 @@ static int xvmc_passthrough(int id)
 static Bool
 i830_display_overlay(ScrnInfoPtr scrn, xf86CrtcPtr crtc,
 		     int id, short width, short height,
-		     int dstPitch, int x1, int y1, int x2, int y2,
+		     int dstPitch,
 		     BoxPtr dstBox, short src_w, short src_h, short drw_w,
 		     short drw_h)
 {
@@ -1201,7 +1201,7 @@ i830_display_overlay(ScrnInfoPtr scrn, xf86CrtcPtr crtc,
 	}
 
 	return drmmode_overlay_put_image(scrn, crtc, id, width, height,
-					 dstPitch, x1, y1, x2, y2, dstBox,
+					 dstPitch, dstBox,
 					 src_w, src_h, drw_w, drw_h);
 }
 
@@ -1565,13 +1565,13 @@ I830PutImageTextured(ScrnInfoPtr scrn,
 
 	if (IS_I965G(intel)) {
 		I965DisplayVideoTextured(scrn, adaptor_priv, id, clipBoxes,
-					 width, height, dstPitch, x1,
-					 y1, x2, y2, src_w, src_h,
+					 width, height, dstPitch,
+					 src_w, src_h,
 					 drw_w, drw_h, pixmap);
 	} else {
 		I915DisplayVideoTextured(scrn, adaptor_priv, id, clipBoxes,
 					 width, height, dstPitch,
-					 dstPitch2, x1, y1, x2, y2,
+					 dstPitch2,
 					 src_w, src_h, drw_w, drw_h,
 					 pixmap);
 	}
@@ -1648,7 +1648,7 @@ I830PutImageOverlay(ScrnInfoPtr scrn,
 		return BadAlloc;
 
 	if (!i830_display_overlay
-	    (scrn, crtc, id, width, height, dstPitch, x1, y1, x2, y2,
+	    (scrn, crtc, id, width, height, dstPitch,
 	     &dstBox, src_w, src_h, drw_w, drw_h))
 		return BadAlloc;
 
diff --git a/src/i830_video.h b/src/i830_video.h
index 8bb536c..fcdae73 100644
--- a/src/i830_video.h
+++ b/src/i830_video.h
@@ -70,7 +70,6 @@ void I915DisplayVideoTextured(ScrnInfoPtr scrn,
 			      intel_adaptor_private *adaptor_priv,
 			      int id, RegionPtr dstRegion, short width,
 			      short height, int video_pitch, int video_pitch2,
-			      int x1, int y1, int x2, int y2,
 			      short src_w, short src_h,
 			      short drw_w, short drw_h, PixmapPtr pixmap);
 
@@ -78,7 +77,6 @@ void I965DisplayVideoTextured(ScrnInfoPtr scrn,
 			      intel_adaptor_private *adaptor_priv,
 			      int id, RegionPtr dstRegion, short width,
 			      short height, int video_pitch,
-			      int x1, int y1, int x2, int y2,
 			      short src_w, short src_h,
 			      short drw_w, short drw_h, PixmapPtr pixmap);
 
diff --git a/src/i915_video.c b/src/i915_video.c
index 4e4ec03..927047b 100644
--- a/src/i915_video.c
+++ b/src/i915_video.c
@@ -44,7 +44,7 @@ I915DisplayVideoTextured(ScrnInfoPtr scrn,
 			 intel_adaptor_private *adaptor_priv, int id,
 			 RegionPtr dstRegion,
 			 short width, short height, int video_pitch,
-			 int video_pitch2, int x1, int y1, int x2, int y2,
+			 int video_pitch2,
 			 short src_w, short src_h, short drw_w, short drw_h,
 			 PixmapPtr pixmap)
 {
diff --git a/src/i965_video.c b/src/i965_video.c
index e0a8215..0ba9511 100644
--- a/src/i965_video.c
+++ b/src/i965_video.c
@@ -981,7 +981,6 @@ I965DisplayVideoTextured(ScrnInfoPtr scrn,
 			 intel_adaptor_private *adaptor_priv, int id,
 			 RegionPtr dstRegion,
 			 short width, short height, int video_pitch,
-			 int x1, int y1, int x2, int y2,
 			 short src_w, short src_h,
 			 short drw_w, short drw_h, PixmapPtr pixmap)
 {
commit cf74caaa91667457bba3583b216dfc157d09f39e
Author: Daniel Vetter <daniel.vetter at ffwll.ch>
Date:   Tue Dec 1 14:32:29 2009 +0100

    Xv: kill an unnecessary if
    
    We always pass a non-null pointer for crtc_ret, no point to check
    for this.
    
    Signed-off-by: Daniel Vetter <daniel.vetter at ffwll.ch>
    Signed-off-by: Eric Anholt <eric at anholt.net>

diff --git a/src/i830_video.c b/src/i830_video.c
index 59236ae..aa3a604 100644
--- a/src/i830_video.c
+++ b/src/i830_video.c
@@ -1218,26 +1218,25 @@ i830_clip_video_helper(ScrnInfoPtr scrn,
 	Bool ret;
 	RegionRec crtc_region_local;
 	RegionPtr crtc_region = reg;
+	BoxRec crtc_box;
 
 	/*
 	 * For overlay video, compute the relevant CRTC and
 	 * clip video to that
 	 */
-	if (crtc_ret) {
-		BoxRec crtc_box;
-		xf86CrtcPtr crtc = i830_covering_crtc(scrn, dst,
-						      adaptor_priv->desired_crtc,
-						      &crtc_box);
-
-		/* For textured video, we don't actually want to clip at all. */
-		if (crtc && !adaptor_priv->textured) {
-			REGION_INIT(screen, &crtc_region_local, &crtc_box, 1);
-			crtc_region = &crtc_region_local;
-			REGION_INTERSECT(screen, crtc_region, crtc_region,
-					 reg);
-		}
-		*crtc_ret = crtc;
+	xf86CrtcPtr crtc = i830_covering_crtc(scrn, dst,
+					      adaptor_priv->desired_crtc,
+					      &crtc_box);
+
+	/* For textured video, we don't actually want to clip at all. */
+	if (crtc && !adaptor_priv->textured) {
+		REGION_INIT(screen, &crtc_region_local, &crtc_box, 1);
+		crtc_region = &crtc_region_local;
+		REGION_INTERSECT(screen, crtc_region, crtc_region,
+				 reg);
 	}
+	*crtc_ret = crtc;
+
 	ret = xf86XVClipVideoHelper(dst, xa, xb, ya, yb,
 				    crtc_region, width, height);
 	if (crtc_region != reg)
commit d8353c737b5b8077f499461b1e6c78f09544d226
Author: Daniel Vetter <daniel.vetter at ffwll.ch>
Date:   Tue Dec 1 14:32:28 2009 +0100

    Xv: split up I830PutImage into textured and !textured case
    
    This wasn't making much sense anymore, and further cleanups will
    make this even more apparent. This change just makes two copies of
    I830PutImage and kills the not-applicable if-clauses in both
    versions.
    
    There is one small functional change in here: The textured video
    path doesn't munch around with adaptor_priv->videoStatus anymore,
    which is only used by the overlay. This could prevent the overlay
    from being switched off if someone would use textured video at the
    same time.
    
    Signed-off-by: Daniel Vetter <daniel.vetter at ffwll.ch>
    Signed-off-by: Eric Anholt <eric at anholt.net>

diff --git a/src/i830_video.c b/src/i830_video.c
index 8f6bfd2..59236ae 100644
--- a/src/i830_video.c
+++ b/src/i830_video.c
@@ -95,7 +95,10 @@ static int I830GetPortAttribute(ScrnInfoPtr, Atom, INT32 *, pointer);
 static void I830QueryBestSize(ScrnInfoPtr, Bool,
 			      short, short, short, short, unsigned int *,
 			      unsigned int *, pointer);
-static int I830PutImage(ScrnInfoPtr, short, short, short, short, short, short,
+static int I830PutImageTextured(ScrnInfoPtr, short, short, short, short, short, short,
+			short, short, int, unsigned char *, short, short,
+			Bool, RegionPtr, pointer, DrawablePtr);
+static int I830PutImageOverlay(ScrnInfoPtr, short, short, short, short, short, short,
 			short, short, int, unsigned char *, short, short,
 			Bool, RegionPtr, pointer, DrawablePtr);
 static int I830QueryImageAttributes(ScrnInfoPtr, int, unsigned short *,
@@ -476,7 +479,7 @@ static XF86VideoAdaptorPtr I830SetupImageVideoOverlay(ScreenPtr screen)
 	adapt->SetPortAttribute = I830SetPortAttributeOverlay;
 	adapt->GetPortAttribute = I830GetPortAttribute;
 	adapt->QueryBestSize = I830QueryBestSize;
-	adapt->PutImage = I830PutImage;
+	adapt->PutImage = I830PutImageOverlay;
 	adapt->QueryImageAttributes = I830QueryImageAttributes;
 
 	adaptor_priv->textured = FALSE;
@@ -572,7 +575,7 @@ static XF86VideoAdaptorPtr I830SetupImageVideoTextured(ScreenPtr screen)
 	adapt->SetPortAttribute = I830SetPortAttributeTextured;
 	adapt->GetPortAttribute = I830GetPortAttribute;
 	adapt->QueryBestSize = I830QueryBestSize;
-	adapt->PutImage = I830PutImage;
+	adapt->PutImage = I830PutImageTextured;
 	adapt->QueryImageAttributes = I830QueryImageAttributes;
 
 	for (i = 0; i < nports; i++) {
@@ -1509,7 +1512,7 @@ i830_copy_video_data(ScrnInfoPtr scrn, intel_adaptor_private *adaptor_priv,
  * compositing.  It's a new argument to the function in the 1.1 server.
  */
 static int
-I830PutImage(ScrnInfoPtr scrn,
+I830PutImageTextured(ScrnInfoPtr scrn,
 	     short src_x, short src_y,
 	     short drw_x, short drw_y,
 	     short src_w, short src_h,
@@ -1521,7 +1524,6 @@ I830PutImage(ScrnInfoPtr scrn,
 {
 	intel_screen_private *intel = intel_get_screen_private(scrn);
 	intel_adaptor_private *adaptor_priv = (intel_adaptor_private *) data;
-	ScreenPtr screen = screenInfo.screens[scrn->scrnIndex];
 	PixmapPtr pixmap = get_drawable_pixmap(drawable);
 	INT32 x1, x2, y1, y2;
 	int dstPitch;
@@ -1535,17 +1537,85 @@ I830PutImage(ScrnInfoPtr scrn,
 	       drw_y, drw_w, drw_h, width, height);
 #endif
 
-	if (!adaptor_priv->textured) {
-		/* If dst width and height are less than 1/8th the src size, the
-		 * src/dst scale factor becomes larger than 8 and doesn't fit in
-		 * the scale register. */
-		if (src_w >= (drw_w * 8))
-			drw_w = src_w / 7;
+	/* Clip */
+	x1 = src_x;
+	x2 = src_x + src_w;
+	y1 = src_y;
+	y2 = src_y + src_h;
+
+	dstBox.x1 = drw_x;
+	dstBox.x2 = drw_x + drw_w;
+	dstBox.y1 = drw_y;
+	dstBox.y2 = drw_y + drw_h;
 
-		if (src_h >= (drw_h * 8))
-			drw_h = src_h / 7;
+	if (!i830_clip_video_helper(scrn,
+				    adaptor_priv,
+				    &crtc,
+				    &dstBox, &x1, &x2, &y1, &y2, clipBoxes,
+				    width, height))
+		return Success;
+
+	if (!i830_copy_video_data(scrn, adaptor_priv, width, height,
+				  &dstPitch, &dstPitch2,
+				  x1, y1, x2, y2, id, buf))
+		return BadAlloc;
+
+	if (crtc && adaptor_priv->SyncToVblank != 0) {
+		i830_wait_for_scanline(scrn, pixmap, crtc, clipBoxes);
 	}
 
+	if (IS_I965G(intel)) {
+		I965DisplayVideoTextured(scrn, adaptor_priv, id, clipBoxes,
+					 width, height, dstPitch, x1,
+					 y1, x2, y2, src_w, src_h,
+					 drw_w, drw_h, pixmap);
+	} else {
+		I915DisplayVideoTextured(scrn, adaptor_priv, id, clipBoxes,
+					 width, height, dstPitch,
+					 dstPitch2, x1, y1, x2, y2,
+					 src_w, src_h, drw_w, drw_h,
+					 pixmap);
+	}
+
+	DamageDamageRegion(drawable, clipBoxes);
+
+	return Success;
+}
+
+static int
+I830PutImageOverlay(ScrnInfoPtr scrn,
+	     short src_x, short src_y,
+	     short drw_x, short drw_y,
+	     short src_w, short src_h,
+	     short drw_w, short drw_h,
+	     int id, unsigned char *buf,
+	     short width, short height,
+	     Bool sync, RegionPtr clipBoxes, pointer data,
+	     DrawablePtr drawable)
+{
+	intel_adaptor_private *adaptor_priv = (intel_adaptor_private *) data;
+	ScreenPtr screen = screenInfo.screens[scrn->scrnIndex];
+	INT32 x1, x2, y1, y2;
+	int dstPitch;
+	int dstPitch2 = 0;
+	BoxRec dstBox;
+	xf86CrtcPtr crtc;
+
+#if 0
+	ErrorF("I830PutImage: src: (%d,%d)(%d,%d), dst: (%d,%d)(%d,%d)\n"
+	       "width %d, height %d\n", src_x, src_y, src_w, src_h, drw_x,
+	       drw_y, drw_w, drw_h, width, height);
+#endif
+
+	/* If dst width and height are less than 1/8th the src size, the
+	 * src/dst scale factor becomes larger than 8 and doesn't fit in
+	 * the scale register. */
+	if (src_w >= (drw_w * 8))
+		drw_w = src_w / 7;
+
+	if (src_h >= (drw_h * 8))
+		drw_h = src_h / 7;
+
 	/* Clip */
 	x1 = src_x;
 	x2 = src_x + src_w;
@@ -1564,15 +1634,13 @@ I830PutImage(ScrnInfoPtr scrn,
 				    width, height))
 		return Success;
 
-	if (!adaptor_priv->textured) {
-		/* texture video handles rotation differently. */
-		if (crtc)
-			adaptor_priv->rotation = crtc->rotation;
-		else {
-			xf86DrvMsg(scrn->scrnIndex, X_WARNING,
-				   "Fail to clip video to any crtc!\n");
-			return Success;
-		}
+	/* overlay can't handle rotation natively, store it for the copy func */
+	if (crtc)
+		adaptor_priv->rotation = crtc->rotation;
+	else {
+		xf86DrvMsg(scrn->scrnIndex, X_WARNING,
+			   "Fail to clip video to any crtc!\n");
+		return Success;
 	}
 
 	if (!i830_copy_video_data(scrn, adaptor_priv, width, height,
@@ -1580,36 +1648,15 @@ I830PutImage(ScrnInfoPtr scrn,
 				  x1, y1, x2, y2, id, buf))
 		return BadAlloc;
 
-	if (!adaptor_priv->textured) {
-		if (!i830_display_overlay
-		    (scrn, crtc, id, width, height, dstPitch, x1, y1, x2, y2,
-		     &dstBox, src_w, src_h, drw_w, drw_h))
-			return BadAlloc;
-
-		/* update cliplist */
-		if (!REGION_EQUAL(scrn->pScreen, &adaptor_priv->clip, clipBoxes)) {
-			REGION_COPY(scrn->pScreen, &adaptor_priv->clip, clipBoxes);
-			i830_fill_colorkey(screen, adaptor_priv->colorKey, clipBoxes);
-		}
-	} else {
-		if (crtc && adaptor_priv->SyncToVblank != 0) {
-			i830_wait_for_scanline(scrn, pixmap, crtc, clipBoxes);
-		}
-
-		if (IS_I965G(intel)) {
-			I965DisplayVideoTextured(scrn, adaptor_priv, id, clipBoxes,
-						 width, height, dstPitch, x1,
-						 y1, x2, y2, src_w, src_h,
-						 drw_w, drw_h, pixmap);
-		} else {
-			I915DisplayVideoTextured(scrn, adaptor_priv, id, clipBoxes,
-						 width, height, dstPitch,
-						 dstPitch2, x1, y1, x2, y2,
-						 src_w, src_h, drw_w, drw_h,
-						 pixmap);
-		}
+	if (!i830_display_overlay
+	    (scrn, crtc, id, width, height, dstPitch, x1, y1, x2, y2,
+	     &dstBox, src_w, src_h, drw_w, drw_h))
+		return BadAlloc;
 
-		DamageDamageRegion(drawable, clipBoxes);
+	/* update cliplist */
+	if (!REGION_EQUAL(scrn->pScreen, &adaptor_priv->clip, clipBoxes)) {
+		REGION_COPY(scrn->pScreen, &adaptor_priv->clip, clipBoxes);
+		i830_fill_colorkey(screen, adaptor_priv->colorKey, clipBoxes);
 	}
 
 	adaptor_priv->videoStatus = CLIENT_VIDEO_ON;
diff --git a/src/i830_video.h b/src/i830_video.h
index a2beae0..8bb536c 100644
--- a/src/i830_video.h
+++ b/src/i830_video.h
@@ -47,6 +47,7 @@ typedef struct {
 	uint32_t gamma4;
 	uint32_t gamma5;
 
+	/* only used by the overlay */
 	uint32_t videoStatus;
 	Time offTime;
 	Time freeTime;


More information about the xorg-commit mailing list