All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/12] Rework intel 2D driver glamor support
@ 2014-07-24 23:18 Keith Packard
  2014-07-24 23:18 ` [PATCH 01/12] Stop trying to out-guess mesa for BO allocation Keith Packard
                   ` (6 more replies)
  0 siblings, 7 replies; 35+ messages in thread
From: Keith Packard @ 2014-07-24 23:18 UTC (permalink / raw)
  To: xorg-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	intel-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

I spent the day just cleaning up this patch series and testing. I
think it's ready for others to use and review. I've been running it on
two machines for a couple of days now and it's been solid.

I ran three different desktop environments (current Debian unstable versions):

 XFCE		4.10
 Gnome		3.12
 KDE		4.13.3

I have not merged DRI2 support when running with Glamor; I've got that
working locally, but if you accidentally try indirect rendering,
you'll crash the X server with an assert failure. So, this is DRI3
only, at least for now.

This patch series also adds a "none" acceleration mode. It's different
from other unaccelerated drivers in offering DRI2 and DRI3 support so
that you can run direct rendering.

A brief synopsis of the series

1-4	cleanup patches

5	Identify and isolate UXA code; UXA-specific functions are
	renamed and moved into uxa-specific files.

6	Remove UXA-based Glamor support. This pulls out all of the
	Glamor calls from UXA rendering paths. This patch only builds
	with glamor disabled; I didn't worry about the existing glamor
	code or support for glamor within the rest of the driver.

7-9	Prepare for glamor support. Creates a couple of abstract
	functions for accel-dependent functionality needed by the
	initialization and modesetting code. Gets rid of the
	glamor stubs in intel_glamor.h

10	Add glamor support back in, using the regular glamor
	API.

11	Add an unaccelerated option ("none"). This offers fb-only
	support and is always compiled in to the driver.

12	Delay initial mode set operation until the root window
	is painted and the server is ready to go. This includes
	potentially copying an existing fbcon frame buffer to the
	root window in background none mode, providing support
	for this in all three acceleration modes. The driver used
	to support this by copying the fbcon buffer to the screen
	buffer during early server initialization; this change allows
	the driver to use regular GC-based CopyArea instead of needing
	custom rendering code.

_______________________________________________
xorg-devel-go0+a7rfsptAfugRpC6u6w@public.gmane.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH 01/12] Stop trying to out-guess mesa for BO allocation
  2014-07-24 23:18 [PATCH 00/12] Rework intel 2D driver glamor support Keith Packard
@ 2014-07-24 23:18 ` Keith Packard
       [not found]   ` <1406243908-1123-2-git-send-email-keithp-aN4HjG94KOLQT0dZR+AlfA@public.gmane.org>
  2014-07-24 23:18 ` [PATCH 03/12] Don't use GetScratchPixmapHeader for shadow pixmaps Keith Packard
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 35+ messages in thread
From: Keith Packard @ 2014-07-24 23:18 UTC (permalink / raw)
  To: xorg-devel, intel-gfx

---
 src/uxa/intel_uxa.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/uxa/intel_uxa.c b/src/uxa/intel_uxa.c
index b396188..717754f 100644
--- a/src/uxa/intel_uxa.c
+++ b/src/uxa/intel_uxa.c
@@ -758,6 +758,7 @@ free_priv:
 			goto free_priv;
 		}
 
+#if 0
 		if (tiling != I915_TILING_NONE) {
 			int height;
 
@@ -780,6 +781,7 @@ free_priv:
 			bo = NULL;
 			goto free_priv;
 		}
+#endif
 	}
 
   BAIL:
-- 
2.0.1

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 02/12] Fix present debug output
       [not found] ` <1406243908-1123-1-git-send-email-keithp-aN4HjG94KOLQT0dZR+AlfA@public.gmane.org>
@ 2014-07-24 23:18   ` Keith Packard
  2014-07-24 23:18   ` [PATCH 07/12] Add intel_flush to abstract flushing pending acceleration operations Keith Packard
                     ` (5 subsequent siblings)
  6 siblings, 0 replies; 35+ messages in thread
From: Keith Packard @ 2014-07-24 23:18 UTC (permalink / raw)
  To: xorg-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	intel-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

Was using 'low_msc', which isn't defined anymore.

Signed-off-by: Keith Packard <keithp-aN4HjG94KOLQT0dZR+AlfA@public.gmane.org>
---
 src/uxa/intel_present.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/uxa/intel_present.c b/src/uxa/intel_present.c
index 18fcbf8..5f98da8 100644
--- a/src/uxa/intel_present.c
+++ b/src/uxa/intel_present.c
@@ -193,7 +193,8 @@ intel_present_queue_vblank(RRCrtcPtr                    crtc,
 		if (errno != EBUSY || !intel_present_flush_drm_events(screen))
 			return BadAlloc;
 	}
-	DebugPresent(("\t\tiq %lld seq %u msc %u (hw msc %u)\n", event_id, seq, low_msc, vbl.request.sequence));
+	DebugPresent(("\t\tiq %lld seq %u msc %llu (hw msc %u)\n",
+                      (long long) event_id, seq, (long long) msc, vbl.request.sequence));
 	return Success;
 }
 
-- 
2.0.1

_______________________________________________
xorg-devel-go0+a7rfsptAfugRpC6u6w@public.gmane.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 03/12] Don't use GetScratchPixmapHeader for shadow pixmaps
  2014-07-24 23:18 [PATCH 00/12] Rework intel 2D driver glamor support Keith Packard
  2014-07-24 23:18 ` [PATCH 01/12] Stop trying to out-guess mesa for BO allocation Keith Packard
@ 2014-07-24 23:18 ` Keith Packard
       [not found]   ` <1406243908-1123-4-git-send-email-keithp-aN4HjG94KOLQT0dZR+AlfA@public.gmane.org>
  2014-07-24 23:18 ` [PATCH 04/12] Move intel_alloc_framebuffer to intel_memory.c Keith Packard
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 35+ messages in thread
From: Keith Packard @ 2014-07-24 23:18 UTC (permalink / raw)
  To: xorg-devel, intel-gfx

GetScratchPixmapHeader should only be used for local memory pixmaps,
as used by PutImage and friends. That's because when you free the
scratch pixmap header, it doesn't actually free the pixmap; instead,
it gets stuffed in pScreen->pScratchPixmap and any private data stored
on it will be left hanging around forever.

In the case of glamor, that private data includes all of the GL
state. Using that scratch pixmap later results in glamor getting
mightily confused as the pixmap and underlying objects do not match.

Avoid this by allocating pixmap headers explicitly for this purpose.

Signed-off-by: Keith Packard <keithp@keithp.com>
---
 src/uxa/intel_display.c | 44 ++++++++++++++++++++++++++++++--------------
 1 file changed, 30 insertions(+), 14 deletions(-)

diff --git a/src/uxa/intel_display.c b/src/uxa/intel_display.c
index 0b83140..bcaafaa 100644
--- a/src/uxa/intel_display.c
+++ b/src/uxa/intel_display.c
@@ -545,13 +545,31 @@ intel_crtc_shadow_allocate(xf86CrtcPtr crtc, int width, int height)
 		return NULL;
 	}
 
-	drm_intel_bo_disable_reuse(intel_crtc->rotate_bo);
-
 	intel_crtc->rotate_pitch = rotate_pitch;
 	return intel_crtc->rotate_bo;
 }
 
 static PixmapPtr
+intel_create_pixmap_header(ScreenPtr pScreen, int width, int height, int depth,
+                           int bitsPerPixel, int devKind, void *pPixData)
+{
+        PixmapPtr pixmap;
+
+        /* width and height of 0 means don't allocate any pixmap data */
+        pixmap = (*pScreen->CreatePixmap) (pScreen, 0, 0, depth, 0);
+
+        if (pixmap) {
+                if ((*pScreen->ModifyPixmapHeader) (pixmap, width, height, depth,
+                                                    bitsPerPixel, devKind, pPixData))
+                {
+                        return pixmap;
+                }
+                (*pScreen->DestroyPixmap) (pixmap);
+        }
+        return NullPixmap;
+}
+
+static PixmapPtr
 intel_crtc_shadow_create(xf86CrtcPtr crtc, void *data, int width, int height)
 {
 	ScrnInfoPtr scrn = crtc->scrn;
@@ -573,12 +591,12 @@ intel_crtc_shadow_create(xf86CrtcPtr crtc, void *data, int width, int height)
 		return NULL;
 	}
 
-	rotate_pixmap = GetScratchPixmapHeader(scrn->pScreen,
-					       width, height,
-					       scrn->depth,
-					       scrn->bitsPerPixel,
-					       intel_crtc->rotate_pitch,
-					       NULL);
+	rotate_pixmap = intel_create_pixmap_header(scrn->pScreen,
+                                                   width, height,
+                                                   scrn->depth,
+                                                   scrn->bitsPerPixel,
+                                                   intel_crtc->rotate_pitch,
+                                                   NULL);
 
 	if (rotate_pixmap == NULL) {
 		xf86DrvMsg(scrn->scrnIndex, X_ERROR,
@@ -602,8 +620,8 @@ intel_crtc_shadow_destroy(xf86CrtcPtr crtc, PixmapPtr rotate_pixmap, void *data)
 	struct intel_mode *mode = intel_crtc->mode;
 
 	if (rotate_pixmap) {
-		intel_set_pixmap_bo(rotate_pixmap, NULL);
-		FreeScratchPixmapHeader(rotate_pixmap);
+                intel_set_pixmap_bo(rotate_pixmap, NULL);
+                rotate_pixmap->drawable.pScreen->DestroyPixmap(rotate_pixmap);
 	}
 
 	if (data) {
@@ -1415,7 +1433,6 @@ intel_xf86crtc_resize(ScrnInfoPtr scrn, int width, int height)
 	int	    i, old_width, old_height, old_pitch;
 	int pitch;
 	uint32_t tiling;
-	ScreenPtr screen;
 
 	if (scrn->virtualX == width && scrn->virtualY == height)
 		return TRUE;
@@ -1430,8 +1447,7 @@ intel_xf86crtc_resize(ScrnInfoPtr scrn, int width, int height)
 	old_front = intel->front_buffer;
 
 	if (intel->back_pixmap) {
-		screen = intel->back_pixmap->drawable.pScreen;
-		screen->DestroyPixmap(intel->back_pixmap);
+		scrn->pScreen->DestroyPixmap(intel->back_pixmap);
 		intel->back_pixmap = NULL;
 	}
 
@@ -1454,7 +1470,6 @@ intel_xf86crtc_resize(ScrnInfoPtr scrn, int width, int height)
 	if (ret)
 		goto fail;
 
-	drm_intel_bo_disable_reuse(intel->front_buffer);
 	intel->front_pitch = pitch;
 	intel->front_tiling = tiling;
 
@@ -2204,6 +2219,7 @@ Bool intel_crtc_on(xf86CrtcPtr crtc)
 	return ret;
 }
 
+
 static PixmapPtr
 intel_create_pixmap_for_bo(ScreenPtr pScreen, dri_bo *bo,
 			   int width, int height,
-- 
2.0.1

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 04/12] Move intel_alloc_framebuffer to intel_memory.c
  2014-07-24 23:18 [PATCH 00/12] Rework intel 2D driver glamor support Keith Packard
  2014-07-24 23:18 ` [PATCH 01/12] Stop trying to out-guess mesa for BO allocation Keith Packard
  2014-07-24 23:18 ` [PATCH 03/12] Don't use GetScratchPixmapHeader for shadow pixmaps Keith Packard
@ 2014-07-24 23:18 ` Keith Packard
  2014-07-24 23:18 ` [PATCH 05/12] Rename uxa-specific functions and structs Keith Packard
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 35+ messages in thread
From: Keith Packard @ 2014-07-24 23:18 UTC (permalink / raw)
  To: xorg-devel, intel-gfx

UXA and Glamor both share this function, so move it out of the UXA file.

Signed-off-by: Keith Packard <keithp@keithp.com>
---
 src/uxa/intel.h        |   5 ++
 src/uxa/intel_memory.c | 138 ++++++++++++++++++++++++++++++++++++++++++
 src/uxa/intel_uxa.c    | 158 ++++---------------------------------------------
 3 files changed, 154 insertions(+), 147 deletions(-)

diff --git a/src/uxa/intel.h b/src/uxa/intel.h
index 409635d..8110c2e 100644
--- a/src/uxa/intel.h
+++ b/src/uxa/intel.h
@@ -539,6 +539,11 @@ unsigned long intel_get_fence_pitch(intel_screen_private *intel, unsigned long p
 Bool intel_check_display_stride(ScrnInfoPtr scrn, int stride, Bool tiling);
 void intel_set_gem_max_sizes(ScrnInfoPtr scrn);
 
+unsigned int
+intel_compute_size(struct intel_screen_private *intel,
+                   int w, int h, int bpp, unsigned usage,
+                   uint32_t *tiling, int *stride);
+
 drm_intel_bo *intel_allocate_framebuffer(ScrnInfoPtr scrn,
 					 int width, int height, int cpp,
 					 int *out_stride,
diff --git a/src/uxa/intel_memory.c b/src/uxa/intel_memory.c
index 809b636..188a557 100644
--- a/src/uxa/intel_memory.c
+++ b/src/uxa/intel_memory.c
@@ -190,3 +190,141 @@ void intel_set_gem_max_sizes(ScrnInfoPtr scrn)
 	 */
 	intel->max_bo_size = intel->max_gtt_map_size;
 }
+
+unsigned int
+intel_compute_size(struct intel_screen_private *intel,
+                   int w, int h, int bpp, unsigned usage,
+                   uint32_t *tiling, int *stride)
+{
+	int pitch, size;
+
+	if (*tiling != I915_TILING_NONE) {
+		/* First check whether tiling is necessary. */
+		pitch = (w * bpp  + 7) / 8;
+		pitch = ALIGN(pitch, 64);
+		size = pitch * ALIGN (h, 2);
+		if (INTEL_INFO(intel)->gen < 040) {
+			/* Gen 2/3 has a maximum stride for tiling of
+			 * 8192 bytes.
+			 */
+			if (pitch > KB(8))
+				*tiling = I915_TILING_NONE;
+
+			/* Narrower than half a tile? */
+			if (pitch < 256)
+				*tiling = I915_TILING_NONE;
+
+			/* Older hardware requires fences to be pot size
+			 * aligned with a minimum of 1 MiB, so causes
+			 * massive overallocation for small textures.
+			 */
+			if (size < 1024*1024/2 && !intel->has_relaxed_fencing)
+				*tiling = I915_TILING_NONE;
+		} else if (!(usage & INTEL_CREATE_PIXMAP_DRI2) && size <= 4096) {
+			/* Disable tiling beneath a page size, we will not see
+			 * any benefit from reducing TLB misses and instead
+			 * just incur extra cost when we require a fence.
+			 */
+			*tiling = I915_TILING_NONE;
+		}
+	}
+
+	pitch = (w * bpp + 7) / 8;
+	if (!(usage & INTEL_CREATE_PIXMAP_DRI2) && pitch <= 256)
+		*tiling = I915_TILING_NONE;
+
+	if (*tiling != I915_TILING_NONE) {
+		int aligned_h, tile_height;
+
+		if (IS_GEN2(intel))
+			tile_height = 16;
+		else if (*tiling == I915_TILING_X)
+			tile_height = 8;
+		else
+			tile_height = 32;
+		aligned_h = ALIGN(h, 2*tile_height);
+
+		*stride = intel_get_fence_pitch(intel,
+						ALIGN(pitch, 512),
+						*tiling);
+
+		/* Round the object up to the size of the fence it will live in
+		 * if necessary.  We could potentially make the kernel allocate
+		 * a larger aperture space and just bind the subset of pages in,
+		 * but this is easier and also keeps us out of trouble (as much)
+		 * with drm_intel_bufmgr_check_aperture().
+		 */
+		size = intel_get_fence_size(intel, *stride * aligned_h);
+
+		if (size > intel->max_tiling_size)
+			*tiling = I915_TILING_NONE;
+	}
+
+	if (*tiling == I915_TILING_NONE) {
+		/* We only require a 64 byte alignment for scanouts, but
+		 * a 256 byte alignment for sharing with PRIME.
+		 */
+		*stride = ALIGN(pitch, 256);
+		/* Round the height up so that the GPU's access to a 2x2 aligned
+		 * subspan doesn't address an invalid page offset beyond the
+		 * end of the GTT.
+		 */
+		size = *stride * ALIGN(h, 2);
+	}
+
+	return size;
+}
+
+drm_intel_bo *intel_allocate_framebuffer(ScrnInfoPtr scrn,
+					 int width, int height, int cpp,
+					 int *out_stride,
+					 uint32_t *out_tiling)
+{
+	intel_screen_private *intel = intel_get_screen_private(scrn);
+	uint32_t tiling;
+	int stride, size;
+	drm_intel_bo *bo;
+
+	intel_set_gem_max_sizes(scrn);
+
+	if (intel->tiling & INTEL_TILING_FB)
+		tiling = I915_TILING_X;
+	else
+		tiling = I915_TILING_NONE;
+
+retry:
+	size = intel_compute_size(intel,
+                                  width, height,
+                                  intel->cpp*8, 0,
+                                  &tiling, &stride);
+	if (!intel_check_display_stride(scrn, stride, tiling)) {
+		if (tiling != I915_TILING_NONE) {
+			tiling = I915_TILING_NONE;
+			goto retry;
+		}
+
+		xf86DrvMsg(scrn->scrnIndex, X_ERROR,
+			   "Front buffer stride %d kB "
+			   "exceeds display limit\n", stride / 1024);
+		return NULL;
+	}
+
+	bo = drm_intel_bo_alloc(intel->bufmgr, "front buffer", size, 0);
+	if (bo == NULL)
+		return FALSE;
+
+	if (tiling != I915_TILING_NONE)
+		drm_intel_bo_set_tiling(bo, &tiling, stride);
+
+	xf86DrvMsg(scrn->scrnIndex, X_INFO,
+		   "Allocated new frame buffer %dx%d stride %d, %s\n",
+		   width, height, stride,
+		   tiling == I915_TILING_NONE ? "untiled" : "tiled");
+
+	drm_intel_bo_disable_reuse(bo);
+
+	*out_stride = stride;
+	*out_tiling = tiling;
+	return bo;
+}
+
diff --git a/src/uxa/intel_uxa.c b/src/uxa/intel_uxa.c
index 717754f..5e1fbff 100644
--- a/src/uxa/intel_uxa.c
+++ b/src/uxa/intel_uxa.c
@@ -155,142 +155,6 @@ intel_get_aperture_space(ScrnInfoPtr scrn, drm_intel_bo ** bo_table,
 	return TRUE;
 }
 
-static unsigned int
-intel_uxa_compute_size(struct intel_screen_private *intel,
-		       int w, int h, int bpp, unsigned usage,
-		       uint32_t *tiling, int *stride)
-{
-	int pitch, size;
-
-	if (*tiling != I915_TILING_NONE) {
-		/* First check whether tiling is necessary. */
-		pitch = (w * bpp  + 7) / 8;
-		pitch = ALIGN(pitch, 64);
-		size = pitch * ALIGN (h, 2);
-		if (INTEL_INFO(intel)->gen < 040) {
-			/* Gen 2/3 has a maximum stride for tiling of
-			 * 8192 bytes.
-			 */
-			if (pitch > KB(8))
-				*tiling = I915_TILING_NONE;
-
-			/* Narrower than half a tile? */
-			if (pitch < 256)
-				*tiling = I915_TILING_NONE;
-
-			/* Older hardware requires fences to be pot size
-			 * aligned with a minimum of 1 MiB, so causes
-			 * massive overallocation for small textures.
-			 */
-			if (size < 1024*1024/2 && !intel->has_relaxed_fencing)
-				*tiling = I915_TILING_NONE;
-		} else if (!(usage & INTEL_CREATE_PIXMAP_DRI2) && size <= 4096) {
-			/* Disable tiling beneath a page size, we will not see
-			 * any benefit from reducing TLB misses and instead
-			 * just incur extra cost when we require a fence.
-			 */
-			*tiling = I915_TILING_NONE;
-		}
-	}
-
-	pitch = (w * bpp + 7) / 8;
-	if (!(usage & INTEL_CREATE_PIXMAP_DRI2) && pitch <= 256)
-		*tiling = I915_TILING_NONE;
-
-	if (*tiling != I915_TILING_NONE) {
-		int aligned_h, tile_height;
-
-		if (IS_GEN2(intel))
-			tile_height = 16;
-		else if (*tiling == I915_TILING_X)
-			tile_height = 8;
-		else
-			tile_height = 32;
-		aligned_h = ALIGN(h, 2*tile_height);
-
-		*stride = intel_get_fence_pitch(intel,
-						ALIGN(pitch, 512),
-						*tiling);
-
-		/* Round the object up to the size of the fence it will live in
-		 * if necessary.  We could potentially make the kernel allocate
-		 * a larger aperture space and just bind the subset of pages in,
-		 * but this is easier and also keeps us out of trouble (as much)
-		 * with drm_intel_bufmgr_check_aperture().
-		 */
-		size = intel_get_fence_size(intel, *stride * aligned_h);
-
-		if (size > intel->max_tiling_size)
-			*tiling = I915_TILING_NONE;
-	}
-
-	if (*tiling == I915_TILING_NONE) {
-		/* We only require a 64 byte alignment for scanouts, but
-		 * a 256 byte alignment for sharing with PRIME.
-		 */
-		*stride = ALIGN(pitch, 256);
-		/* Round the height up so that the GPU's access to a 2x2 aligned
-		 * subspan doesn't address an invalid page offset beyond the
-		 * end of the GTT.
-		 */
-		size = *stride * ALIGN(h, 2);
-	}
-
-	return size;
-}
-
-drm_intel_bo *intel_allocate_framebuffer(ScrnInfoPtr scrn,
-					 int width, int height, int cpp,
-					 int *out_stride,
-					 uint32_t *out_tiling)
-{
-	intel_screen_private *intel = intel_get_screen_private(scrn);
-	uint32_t tiling;
-	int stride, size;
-	drm_intel_bo *bo;
-
-	if (intel->tiling & INTEL_TILING_FB)
-		tiling = I915_TILING_X;
-	else
-		tiling = I915_TILING_NONE;
-
-retry:
-	size = intel_uxa_compute_size(intel,
-				      width, height,
-				      intel->cpp*8, 0,
-				      &tiling, &stride);
-	if (!intel_check_display_stride(scrn, stride, tiling)) {
-		if (tiling != I915_TILING_NONE) {
-			tiling = I915_TILING_NONE;
-			goto retry;
-		}
-
-		xf86DrvMsg(scrn->scrnIndex, X_ERROR,
-			   "Front buffer stride %d kB "
-			   "exceeds display limit\n", stride / 1024);
-		return NULL;
-	}
-
-	bo = drm_intel_bo_alloc(intel->bufmgr, "front buffer", size, 0);
-	if (bo == NULL)
-		return FALSE;
-
-	if (tiling != I915_TILING_NONE)
-		drm_intel_bo_set_tiling(bo, &tiling, stride);
-
-	xf86DrvMsg(scrn->scrnIndex, X_INFO,
-		   "Allocated new frame buffer %dx%d stride %d, %s\n",
-		   width, height, stride,
-		   tiling == I915_TILING_NONE ? "untiled" : "tiled");
-
-	drm_intel_bo_disable_reuse(bo);
-
-	intel_set_gem_max_sizes(scrn);
-	*out_stride = stride;
-	*out_tiling = tiling;
-	return bo;
-}
-
 static Bool
 intel_uxa_check_solid(DrawablePtr drawable, int alu, Pixel planemask)
 {
@@ -906,10 +770,10 @@ static Bool intel_uxa_put_image(PixmapPtr pixmap,
 			dri_bo *bo;
 
 			/* Replace busy bo. */
-			size = intel_uxa_compute_size(intel,
-						      w, h,
-						      pixmap->drawable.bitsPerPixel, pixmap->usage_hint,
-						      &tiling, &stride);
+			size = intel_compute_size(intel,
+                                                  w, h,
+                                                  pixmap->drawable.bitsPerPixel, pixmap->usage_hint,
+                                                  &tiling, &stride);
 			if (size > intel->max_gtt_map_size)
 				return FALSE;
 
@@ -1169,9 +1033,9 @@ intel_uxa_create_pixmap(ScreenPtr screen, int w, int h, int depth,
 		    if (h <= 16 && tiling == I915_TILING_Y)
 			tiling = I915_TILING_X;
 		}
-		size = intel_uxa_compute_size(intel,
-					      w, h, pixmap->drawable.bitsPerPixel, usage,
-					      &tiling, &stride);
+		size = intel_compute_size(intel,
+                                          w, h, pixmap->drawable.bitsPerPixel, usage,
+                                          &tiling, &stride);
 
 		/* Fail very large allocations.  Large BOs will tend to hit SW fallbacks
 		 * frequently, and also will tend to fail to successfully map when doing
@@ -1324,10 +1188,10 @@ intel_uxa_share_pixmap_backing(PixmapPtr ppix, ScreenPtr slave, void **fd_handle
 
 	        tiling = I915_TILING_NONE;
 
-		size = intel_uxa_compute_size(intel,
-					      ppix->drawable.width, ppix->drawable.height,
-					      ppix->drawable.bitsPerPixel, INTEL_CREATE_PIXMAP_DRI2,
-					      &tiling, &stride);
+		size = intel_compute_size(intel,
+                                          ppix->drawable.width, ppix->drawable.height,
+                                          ppix->drawable.bitsPerPixel, INTEL_CREATE_PIXMAP_DRI2,
+                                          &tiling, &stride);
 
 		newbo = drm_intel_bo_alloc_for_render(intel->bufmgr,
 						      "pixmap",
-- 
2.0.1

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 05/12] Rename uxa-specific functions and structs
  2014-07-24 23:18 [PATCH 00/12] Rework intel 2D driver glamor support Keith Packard
                   ` (2 preceding siblings ...)
  2014-07-24 23:18 ` [PATCH 04/12] Move intel_alloc_framebuffer to intel_memory.c Keith Packard
@ 2014-07-24 23:18 ` Keith Packard
  2014-07-24 23:18 ` [PATCH 06/12] Remove glamor support from UXA acceleration Keith Packard
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 35+ messages in thread
From: Keith Packard @ 2014-07-24 23:18 UTC (permalink / raw)
  To: xorg-devel, intel-gfx

This starts to separate uxa from the rest of the driver by renaming
uxa-specific functions and structs to make it clear which portions of
the driver are uxa-specific and which are common.

Signed-off-by: Keith Packard <keithp@keithp.com>
---
 src/uxa/Makefile.am           |    4 +
 src/uxa/i830_render.c         |   82 +--
 src/uxa/i915_render.c         |  100 ++--
 src/uxa/i915_video.c          |   10 +-
 src/uxa/i965_render.c         |   98 +--
 src/uxa/i965_video.c          |   48 +-
 src/uxa/intel.h               |  267 +--------
 src/uxa/intel_batchbuffer.c   |    8 +-
 src/uxa/intel_batchbuffer.h   |    4 +-
 src/uxa/intel_display.c       |   78 +++
 src/uxa/intel_dri.c           |   26 +-
 src/uxa/intel_dri3.c          |   10 +-
 src/uxa/intel_driver.c        |   39 +-
 src/uxa/intel_glamor.c        |    4 +-
 src/uxa/intel_uxa.c           |  136 +++--
 src/uxa/intel_uxa.h           |  300 ++++++++++
 src/uxa/intel_uxa_video.c     |  389 ++++++++++++
 src/uxa/intel_video.c         | 1312 +++++++----------------------------------
 src/uxa/intel_video.h         |  156 +++--
 src/uxa/intel_video_overlay.c |  554 +++++++++++++++++
 src/uxa/intel_video_overlay.h |   51 ++
 21 files changed, 2004 insertions(+), 1672 deletions(-)
 create mode 100644 src/uxa/intel_uxa.h
 create mode 100644 src/uxa/intel_uxa_video.c
 create mode 100644 src/uxa/intel_video_overlay.c
 create mode 100644 src/uxa/intel_video_overlay.h

diff --git a/src/uxa/Makefile.am b/src/uxa/Makefile.am
index 0e10a2b..23b074d 100644
--- a/src/uxa/Makefile.am
+++ b/src/uxa/Makefile.am
@@ -25,6 +25,7 @@ AM_CFLAGS += -I$(top_srcdir)/xvmc -I$(top_srcdir)/src -I$(top_srcdir)/src/render
 noinst_LTLIBRARIES = libuxa.la
 libuxa_la_LIBADD = $(UDEV_LIBS) $(DRMINTEL_LIBS) $(DRM_LIBS)
 libuxa_la_SOURCES = \
+	intel_uxa.h \
 	brw_defines.h \
 	brw_structs.h \
 	common.h \
@@ -38,6 +39,9 @@ libuxa_la_SOURCES = \
 	intel_uxa.c \
 	intel_video.c \
 	intel_video.h \
+	intel_video_overlay.c \
+	intel_video_overlay.h \
+	intel_uxa_video.c \
 	i830_3d.c \
 	i830_render.c \
 	i830_reg.h \
diff --git a/src/uxa/i830_render.c b/src/uxa/i830_render.c
index ee68ec3..51374de 100644
--- a/src/uxa/i830_render.c
+++ b/src/uxa/i830_render.c
@@ -166,7 +166,7 @@ static Bool i830_get_dest_format(PicturePtr dest_picture, uint32_t * dst_format)
 		break;
 	default:
 		scrn = xf86ScreenToScrn(dest_picture->pDrawable->pScreen);
-		intel_debug_fallback(scrn, "Unsupported dest format 0x%x\n",
+		intel_uxa_debug_fallback(scrn, "Unsupported dest format 0x%x\n",
 				     (int)dest_picture->format);
 		return FALSE;
 	}
@@ -197,7 +197,7 @@ static Bool i830_get_blend_cntl(ScrnInfoPtr scrn, int op, PicturePtr mask,
 	 */
 	if (dst_format == PICT_a8 && ((sblend == BLENDFACTOR_DST_ALPHA ||
 				       sblend == BLENDFACTOR_INV_DST_ALPHA))) {
-		intel_debug_fallback(scrn, "Can't do dst alpha blending with "
+		intel_uxa_debug_fallback(scrn, "Can't do dst alpha blending with "
 				     "PICT_a8 dest.\n");
 		return FALSE;
 	}
@@ -257,7 +257,7 @@ static void i830_texture_setup(PicturePtr picture, PixmapPtr pixmap, int unit)
 	intel->scale_units[unit][1] = pixmap->drawable.height;
 	intel->transform[unit] = picture->transform;
 
-	if (intel_transform_is_affine(intel->transform[unit]))
+	if (intel_uxa_transform_is_affine(intel->transform[unit]))
 		texcoordtype = TEXCOORDTYPE_CARTESIAN;
 	else
 		texcoordtype = TEXCOORDTYPE_HOMOGENEOUS;
@@ -293,9 +293,9 @@ static void i830_texture_setup(PicturePtr picture, PixmapPtr pixmap, int unit)
 	}
 	filter |= (MIPFILTER_NONE << TM0S3_MIP_FILTER_SHIFT);
 
-	if (intel_pixmap_tiled(pixmap)) {
+	if (intel_uxa_pixmap_tiled(pixmap)) {
 		tiling_bits = TM0S1_TILED_SURFACE;
-		if (intel_get_pixmap_private(pixmap)->tiling
+		if (intel_uxa_get_pixmap_private(pixmap)->tiling
 				== I915_TILING_Y)
 			tiling_bits |= TM0S1_TILE_WALK;
 	} else
@@ -352,7 +352,7 @@ i830_check_composite(int op,
 
 	/* Check for unsupported compositing operations. */
 	if (op >= sizeof(i830_blend_op) / sizeof(i830_blend_op[0])) {
-		intel_debug_fallback(scrn, "Unsupported Composite op 0x%x\n",
+		intel_uxa_debug_fallback(scrn, "Unsupported Composite op 0x%x\n",
 				     op);
 		return FALSE;
 	}
@@ -365,7 +365,7 @@ i830_check_composite(int op,
 		 */
 		if (i830_blend_op[op].src_alpha &&
 		    (i830_blend_op[op].src_blend != BLENDFACTOR_ZERO)) {
-			intel_debug_fallback(scrn, "Component alpha not "
+			intel_uxa_debug_fallback(scrn, "Component alpha not "
 					     "supported with source alpha and "
 					     "source value blending.\n");
 			return FALSE;
@@ -373,12 +373,12 @@ i830_check_composite(int op,
 	}
 
 	if (!i830_get_dest_format(dest_picture, &tmp1)) {
-		intel_debug_fallback(scrn, "Get Color buffer format\n");
+		intel_uxa_debug_fallback(scrn, "Get Color buffer format\n");
 		return FALSE;
 	}
 
 	if (width > 2048 || height > 2048) {
-		intel_debug_fallback(scrn, "Operation is too large (%d, %d)\n", width, height);
+		intel_uxa_debug_fallback(scrn, "Operation is too large (%d, %d)\n", width, height);
 		return FALSE;
 	}
 
@@ -391,7 +391,7 @@ i830_check_composite_target(PixmapPtr pixmap)
 	if (pixmap->drawable.width > 2048 || pixmap->drawable.height > 2048)
 		return FALSE;
 
-	if(!intel_check_pitch_3d(pixmap))
+	if(!intel_uxa_check_pitch_3d(pixmap))
 		return FALSE;
 
 	return TRUE;
@@ -404,14 +404,14 @@ i830_check_composite_texture(ScreenPtr screen, PicturePtr picture)
 	intel_screen_private *intel = intel_get_screen_private(scrn);
 
 	if (picture->repeatType > RepeatReflect) {
-		intel_debug_fallback(scrn, "Unsupported picture repeat %d\n",
+		intel_uxa_debug_fallback(scrn, "Unsupported picture repeat %d\n",
 			     picture->repeatType);
 		return FALSE;
 	}
 
 	if (picture->filter != PictFilterNearest &&
 	    picture->filter != PictFilterBilinear) {
-		intel_debug_fallback(scrn, "Unsupported filter 0x%x\n",
+		intel_uxa_debug_fallback(scrn, "Unsupported filter 0x%x\n",
 				     picture->filter);
 		return FALSE;
 	}
@@ -422,7 +422,7 @@ i830_check_composite_texture(ScreenPtr screen, PicturePtr picture)
 		w = picture->pDrawable->width;
 		h = picture->pDrawable->height;
 		if ((w > 2048) || (h > 2048)) {
-			intel_debug_fallback(scrn,
+			intel_uxa_debug_fallback(scrn,
 					     "Picture w/h too large (%dx%d)\n",
 					     w, h);
 			return FALSE;
@@ -430,7 +430,7 @@ i830_check_composite_texture(ScreenPtr screen, PicturePtr picture)
 
 		/* XXX we can use the xrgb32 types if there the picture covers the clip */
 		if (!i8xx_get_card_format(intel, picture)) {
-			intel_debug_fallback(scrn, "Unsupported picture format "
+			intel_uxa_debug_fallback(scrn, "Unsupported picture format "
 					     "0x%x\n",
 					     (int)picture->format);
 			return FALSE;
@@ -451,9 +451,9 @@ i830_prepare_composite(int op, PicturePtr source_picture,
 	intel_screen_private *intel = intel_get_screen_private(scrn);
 	drm_intel_bo *bo_table[] = {
 		NULL,		/* batch_bo */
-		intel_get_pixmap_bo(source),
-		mask ? intel_get_pixmap_bo(mask) : NULL,
-		intel_get_pixmap_bo(dest),
+		intel_uxa_get_pixmap_bo(source),
+		mask ? intel_uxa_get_pixmap_bo(mask) : NULL,
+		intel_uxa_get_pixmap_bo(dest),
 	};
 
 	intel->render_source_picture = source_picture;
@@ -463,7 +463,7 @@ i830_prepare_composite(int op, PicturePtr source_picture,
 	intel->render_dest_picture = dest_picture;
 	intel->render_dest = dest;
 
-	if (!intel_check_pitch_3d(source))
+	if (!intel_uxa_check_pitch_3d(source))
 		return FALSE;
 	if (mask) {
 		if (mask_picture->componentAlpha &&
@@ -474,22 +474,22 @@ i830_prepare_composite(int op, PicturePtr source_picture,
 			 */
 			if (i830_blend_op[op].src_alpha &&
 			    (i830_blend_op[op].src_blend != BLENDFACTOR_ZERO)) {
-				intel_debug_fallback(scrn, "Component alpha not "
+				intel_uxa_debug_fallback(scrn, "Component alpha not "
 						     "supported with source alpha and "
 						     "source value blending.\n");
 				return FALSE;
 			}
 		}
-		if (!intel_check_pitch_3d(mask))
+		if (!intel_uxa_check_pitch_3d(mask))
 			return FALSE;
 	}
-	if (!intel_check_pitch_3d(dest))
+	if (!intel_uxa_check_pitch_3d(dest))
 		return FALSE;
 
 	if (!i830_get_dest_format(dest_picture, &intel->render_dest_format))
 		return FALSE;
 
-	if (!intel_get_aperture_space(scrn, bo_table, ARRAY_SIZE(bo_table)))
+	if (!intel_uxa_get_aperture_space(scrn, bo_table, ARRAY_SIZE(bo_table)))
 		return FALSE;
 
 	if (mask) {
@@ -564,7 +564,7 @@ i830_prepare_composite(int op, PicturePtr source_picture,
 		intel->s8_blendctl = blendctl;
 	}
 
-	if (intel_pixmap_is_dirty(source) || intel_pixmap_is_dirty(mask))
+	if (intel_uxa_pixmap_is_dirty(source) || intel_uxa_pixmap_is_dirty(mask))
 		intel_batch_emit_flush(scrn);
 
 	intel->needs_render_state_emit = TRUE;
@@ -585,9 +585,9 @@ static void i830_emit_composite_state(ScrnInfoPtr scrn)
 
 	assert(intel->in_batch_atomic);
 
-	if (intel_pixmap_tiled(intel->render_dest)) {
+	if (intel_uxa_pixmap_tiled(intel->render_dest)) {
 		tiling_bits = BUF_3D_TILED_SURFACE;
-		if (intel_get_pixmap_private(intel->render_dest)->tiling
+		if (intel_uxa_get_pixmap_private(intel->render_dest)->tiling
 				== I915_TILING_Y)
 			tiling_bits |= BUF_3D_TILE_WALK_Y;
 	} else
@@ -636,12 +636,12 @@ static void i830_emit_composite_state(ScrnInfoPtr scrn)
 		  DISABLE_STENCIL_WRITE | ENABLE_TEX_CACHE |
 		  DISABLE_DITHER | ENABLE_COLOR_WRITE | DISABLE_DEPTH_WRITE);
 
-	if (intel_transform_is_affine(intel->render_source_picture->transform))
+	if (intel_uxa_transform_is_affine(intel->render_source_picture->transform))
 		texcoordfmt |= (TEXCOORDFMT_2D << 0);
 	else
 		texcoordfmt |= (TEXCOORDFMT_3D << 0);
 	if (intel->render_mask) {
-		if (intel_transform_is_affine
+		if (intel_uxa_transform_is_affine
 		    (intel->render_mask_picture->transform))
 			texcoordfmt |= (TEXCOORDFMT_2D << 2);
 		else
@@ -677,23 +677,23 @@ i830_emit_composite_primitive(PixmapPtr dest,
 	{
 		float x = srcX, y = srcY;
 
-		is_affine_src = intel_transform_is_affine(intel->transform[0]);
+		is_affine_src = intel_uxa_transform_is_affine(intel->transform[0]);
 		if (is_affine_src) {
-			if (!intel_get_transformed_coordinates(x, y,
+			if (!intel_uxa_get_transformed_coordinates(x, y,
 							      intel->
 							      transform[0],
 							      &src_x[0],
 							      &src_y[0]))
 				return;
 
-			if (!intel_get_transformed_coordinates(x, y + h,
+			if (!intel_uxa_get_transformed_coordinates(x, y + h,
 							      intel->
 							      transform[0],
 							      &src_x[1],
 							      &src_y[1]))
 				return;
 
-			if (!intel_get_transformed_coordinates(x + w, y + h,
+			if (!intel_uxa_get_transformed_coordinates(x + w, y + h,
 							      intel->
 							      transform[0],
 							      &src_x[2],
@@ -702,7 +702,7 @@ i830_emit_composite_primitive(PixmapPtr dest,
 
 			per_vertex += 2;	/* src x/y */
 		} else {
-			if (!intel_get_transformed_coordinates_3d(x, y,
+			if (!intel_uxa_get_transformed_coordinates_3d(x, y,
 								 intel->
 								 transform[0],
 								 &src_x[0],
@@ -710,7 +710,7 @@ i830_emit_composite_primitive(PixmapPtr dest,
 								 &src_w[0]))
 				return;
 
-			if (!intel_get_transformed_coordinates_3d(x, y + h,
+			if (!intel_uxa_get_transformed_coordinates_3d(x, y + h,
 								 intel->
 								 transform[0],
 								 &src_x[1],
@@ -718,7 +718,7 @@ i830_emit_composite_primitive(PixmapPtr dest,
 								 &src_w[1]))
 				return;
 
-			if (!intel_get_transformed_coordinates_3d(x + w, y + h,
+			if (!intel_uxa_get_transformed_coordinates_3d(x + w, y + h,
 								 intel->
 								 transform[0],
 								 &src_x[2],
@@ -733,23 +733,23 @@ i830_emit_composite_primitive(PixmapPtr dest,
 	if (intel->render_mask) {
 		float x = maskX, y = maskY;
 
-		is_affine_mask = intel_transform_is_affine(intel->transform[1]);
+		is_affine_mask = intel_uxa_transform_is_affine(intel->transform[1]);
 		if (is_affine_mask) {
-			if (!intel_get_transformed_coordinates(x, y,
+			if (!intel_uxa_get_transformed_coordinates(x, y,
 							      intel->
 							      transform[1],
 							      &mask_x[0],
 							      &mask_y[0]))
 				return;
 
-			if (!intel_get_transformed_coordinates(x, y + h,
+			if (!intel_uxa_get_transformed_coordinates(x, y + h,
 							      intel->
 							      transform[1],
 							      &mask_x[1],
 							      &mask_y[1]))
 				return;
 
-			if (!intel_get_transformed_coordinates(x + w, y + h,
+			if (!intel_uxa_get_transformed_coordinates(x + w, y + h,
 							      intel->
 							      transform[1],
 							      &mask_x[2],
@@ -758,7 +758,7 @@ i830_emit_composite_primitive(PixmapPtr dest,
 
 			per_vertex += 2;	/* mask x/y */
 		} else {
-			if (!intel_get_transformed_coordinates_3d(x, y,
+			if (!intel_uxa_get_transformed_coordinates_3d(x, y,
 								 intel->
 								 transform[1],
 								 &mask_x[0],
@@ -766,7 +766,7 @@ i830_emit_composite_primitive(PixmapPtr dest,
 								 &mask_w[0]))
 				return;
 
-			if (!intel_get_transformed_coordinates_3d(x, y + h,
+			if (!intel_uxa_get_transformed_coordinates_3d(x, y + h,
 								 intel->
 								 transform[1],
 								 &mask_x[1],
@@ -774,7 +774,7 @@ i830_emit_composite_primitive(PixmapPtr dest,
 								 &mask_w[1]))
 				return;
 
-			if (!intel_get_transformed_coordinates_3d(x + w, y + h,
+			if (!intel_uxa_get_transformed_coordinates_3d(x + w, y + h,
 								 intel->
 								 transform[1],
 								 &mask_x[2],
diff --git a/src/uxa/i915_render.c b/src/uxa/i915_render.c
index 577abac..5238d8f 100644
--- a/src/uxa/i915_render.c
+++ b/src/uxa/i915_render.c
@@ -174,7 +174,7 @@ static Bool i915_get_dest_format(PicturePtr dest_picture, uint32_t * dst_format)
 		break;
 	default:
 		scrn = xf86ScreenToScrn(dest_picture->pDrawable->pScreen);
-		intel_debug_fallback(scrn,
+		intel_uxa_debug_fallback(scrn,
 				     "Unsupported dest format 0x%x\n",
 				     (int)dest_picture->format);
 		return FALSE;
@@ -195,7 +195,7 @@ i915_check_composite(int op,
 
 	/* Check for unsupported compositing operations. */
 	if (op >= sizeof(i915_blend_op) / sizeof(i915_blend_op[0])) {
-		intel_debug_fallback(scrn, "Unsupported Composite op 0x%x\n",
+		intel_uxa_debug_fallback(scrn, "Unsupported Composite op 0x%x\n",
 				     op);
 		return FALSE;
 	}
@@ -208,7 +208,7 @@ i915_check_composite(int op,
 		if (i915_blend_op[op].src_alpha &&
 		    (i915_blend_op[op].src_blend != BLENDFACT_ZERO)) {
 			if (op != PictOpOver) {
-				intel_debug_fallback(scrn,
+				intel_uxa_debug_fallback(scrn,
 						     "Component alpha not supported "
 						     "with source alpha and source "
 						     "value blending.\n");
@@ -218,7 +218,7 @@ i915_check_composite(int op,
 	}
 
 	if (!i915_get_dest_format(dest_picture, &tmp1)) {
-		intel_debug_fallback(scrn, "Get Color buffer format\n");
+		intel_uxa_debug_fallback(scrn, "Get Color buffer format\n");
 		return FALSE;
 	}
 
@@ -234,7 +234,7 @@ i915_check_composite_target(PixmapPtr pixmap)
 	if (pixmap->drawable.width > 2048 || pixmap->drawable.height > 2048)
 		return FALSE;
 
-	if(!intel_check_pitch_3d(pixmap))
+	if(!intel_uxa_check_pitch_3d(pixmap))
 		return FALSE;
 
 	return TRUE;
@@ -245,7 +245,7 @@ i915_check_composite_texture(ScreenPtr screen, PicturePtr picture)
 {
 	if (picture->repeatType > RepeatReflect) {
 		ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
-		intel_debug_fallback(scrn, "Unsupported picture repeat %d\n",
+		intel_uxa_debug_fallback(scrn, "Unsupported picture repeat %d\n",
 			     picture->repeatType);
 		return FALSE;
 	}
@@ -253,7 +253,7 @@ i915_check_composite_texture(ScreenPtr screen, PicturePtr picture)
 	if (picture->filter != PictFilterNearest &&
 	    picture->filter != PictFilterBilinear) {
 		ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
-		intel_debug_fallback(scrn, "Unsupported filter 0x%x\n",
+		intel_uxa_debug_fallback(scrn, "Unsupported filter 0x%x\n",
 				     picture->filter);
 		return FALSE;
 	}
@@ -268,7 +268,7 @@ i915_check_composite_texture(ScreenPtr screen, PicturePtr picture)
 		h = picture->pDrawable->height;
 		if ((w > 2048) || (h > 2048)) {
 			ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
-			intel_debug_fallback(scrn,
+			intel_uxa_debug_fallback(scrn,
 					     "Picture w/h too large (%dx%d)\n",
 					     w, h);
 			return FALSE;
@@ -283,7 +283,7 @@ i915_check_composite_texture(ScreenPtr screen, PicturePtr picture)
 		if (i == sizeof(i915_tex_formats) / sizeof(i915_tex_formats[0]))
 		{
 			ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
-			intel_debug_fallback(scrn, "Unsupported picture format "
+			intel_uxa_debug_fallback(scrn, "Unsupported picture format "
 					     "0x%x\n",
 					     (int)picture->format);
 			return FALSE;
@@ -313,7 +313,7 @@ static Bool i915_texture_setup(PicturePtr picture, PixmapPtr pixmap, int unit)
 			break;
 	}
 	if (i == sizeof(i915_tex_formats) / sizeof(i915_tex_formats[0])) {
-		intel_debug_fallback(scrn, "unknown texture format\n");
+		intel_uxa_debug_fallback(scrn, "unknown texture format\n");
 		return FALSE;
 	}
 	format = i915_tex_formats[i].card_fmt;
@@ -345,15 +345,15 @@ static Bool i915_texture_setup(PicturePtr picture, PixmapPtr pixmap, int unit)
 		    (FILTER_LINEAR << SS2_MIN_FILTER_SHIFT);
 		break;
 	default:
-		intel_debug_fallback(scrn, "Bad filter 0x%x\n",
+		intel_uxa_debug_fallback(scrn, "Bad filter 0x%x\n",
 				     picture->filter);
 		return FALSE;
 	}
 
 	/* offset filled in at emit time */
-	if (intel_pixmap_tiled(pixmap)) {
+	if (intel_uxa_pixmap_tiled(pixmap)) {
 		tiling_bits = MS3_TILED_SURFACE;
-		if (intel_get_pixmap_private(pixmap)->tiling
+		if (intel_uxa_get_pixmap_private(pixmap)->tiling
 				== I915_TILING_Y)
 			tiling_bits |= MS3_TILE_WALK;
 	} else
@@ -415,19 +415,19 @@ i915_emit_composite_primitive_affine_source(intel_screen_private *intel,
 {
 	float src_x[3], src_y[3];
 
-	if (!intel_get_transformed_coordinates(srcX, srcY,
+	if (!intel_uxa_get_transformed_coordinates(srcX, srcY,
 					      intel->transform[0],
 					      &src_x[0],
 					      &src_y[0]))
 		return;
 
-	if (!intel_get_transformed_coordinates(srcX, srcY + h,
+	if (!intel_uxa_get_transformed_coordinates(srcX, srcY + h,
 					      intel->transform[0],
 					      &src_x[1],
 					      &src_y[1]))
 		return;
 
-	if (!intel_get_transformed_coordinates(srcX + w, srcY + h,
+	if (!intel_uxa_get_transformed_coordinates(srcX + w, srcY + h,
 					      intel->transform[0],
 					      &src_x[2],
 					      &src_y[2]))
@@ -492,30 +492,30 @@ i915_emit_composite_primitive(intel_screen_private *intel,
 
 	src_unit = tex_unit++;
 
-	is_affine_src = intel_transform_is_affine(intel->transform[src_unit]);
+	is_affine_src = intel_uxa_transform_is_affine(intel->transform[src_unit]);
 	if (is_affine_src) {
-		if (!intel_get_transformed_coordinates(srcX, srcY,
+		if (!intel_uxa_get_transformed_coordinates(srcX, srcY,
 						      intel->
 						      transform[src_unit],
 						      &src_x[0],
 						      &src_y[0]))
 			return;
 
-		if (!intel_get_transformed_coordinates(srcX, srcY + h,
+		if (!intel_uxa_get_transformed_coordinates(srcX, srcY + h,
 						      intel->
 						      transform[src_unit],
 						      &src_x[1],
 						      &src_y[1]))
 			return;
 
-		if (!intel_get_transformed_coordinates(srcX + w, srcY + h,
+		if (!intel_uxa_get_transformed_coordinates(srcX + w, srcY + h,
 						      intel->
 						      transform[src_unit],
 						      &src_x[2],
 						      &src_y[2]))
 			return;
 	} else {
-		if (!intel_get_transformed_coordinates_3d(srcX, srcY,
+		if (!intel_uxa_get_transformed_coordinates_3d(srcX, srcY,
 							 intel->
 							 transform[src_unit],
 							 &src_x[0],
@@ -523,7 +523,7 @@ i915_emit_composite_primitive(intel_screen_private *intel,
 							 &src_w[0]))
 			return;
 
-		if (!intel_get_transformed_coordinates_3d(srcX, srcY + h,
+		if (!intel_uxa_get_transformed_coordinates_3d(srcX, srcY + h,
 							 intel->
 							 transform[src_unit],
 							 &src_x[1],
@@ -531,7 +531,7 @@ i915_emit_composite_primitive(intel_screen_private *intel,
 							 &src_w[1]))
 			return;
 
-		if (!intel_get_transformed_coordinates_3d(srcX + w, srcY + h,
+		if (!intel_uxa_get_transformed_coordinates_3d(srcX + w, srcY + h,
 							 intel->
 							 transform[src_unit],
 							 &src_x[2],
@@ -543,30 +543,30 @@ i915_emit_composite_primitive(intel_screen_private *intel,
 	if (intel->render_mask) {
 		mask_unit = tex_unit++;
 
-		is_affine_mask = intel_transform_is_affine(intel->transform[mask_unit]);
+		is_affine_mask = intel_uxa_transform_is_affine(intel->transform[mask_unit]);
 		if (is_affine_mask) {
-			if (!intel_get_transformed_coordinates(maskX, maskY,
+			if (!intel_uxa_get_transformed_coordinates(maskX, maskY,
 							      intel->
 							      transform[mask_unit],
 							      &mask_x[0],
 							      &mask_y[0]))
 				return;
 
-			if (!intel_get_transformed_coordinates(maskX, maskY + h,
+			if (!intel_uxa_get_transformed_coordinates(maskX, maskY + h,
 							      intel->
 							      transform[mask_unit],
 							      &mask_x[1],
 							      &mask_y[1]))
 				return;
 
-			if (!intel_get_transformed_coordinates(maskX + w, maskY + h,
+			if (!intel_uxa_get_transformed_coordinates(maskX + w, maskY + h,
 							      intel->
 							      transform[mask_unit],
 							      &mask_x[2],
 							      &mask_y[2]))
 				return;
 		} else {
-			if (!intel_get_transformed_coordinates_3d(maskX, maskY,
+			if (!intel_uxa_get_transformed_coordinates_3d(maskX, maskY,
 								 intel->
 								 transform[mask_unit],
 								 &mask_x[0],
@@ -574,7 +574,7 @@ i915_emit_composite_primitive(intel_screen_private *intel,
 								 &mask_w[0]))
 				return;
 
-			if (!intel_get_transformed_coordinates_3d(maskX, maskY + h,
+			if (!intel_uxa_get_transformed_coordinates_3d(maskX, maskY + h,
 								 intel->
 								 transform[mask_unit],
 								 &mask_x[1],
@@ -582,7 +582,7 @@ i915_emit_composite_primitive(intel_screen_private *intel,
 								 &mask_w[1]))
 				return;
 
-			if (!intel_get_transformed_coordinates_3d(maskX + w, maskY + h,
+			if (!intel_uxa_get_transformed_coordinates_3d(maskX + w, maskY + h,
 								 intel->
 								 transform[mask_unit],
 								 &mask_x[2],
@@ -653,9 +653,9 @@ i915_prepare_composite(int op, PicturePtr source_picture,
 	intel_screen_private *intel = intel_get_screen_private(scrn);
 	drm_intel_bo *bo_table[] = {
 		NULL,		/* batch_bo */
-		intel_get_pixmap_bo(dest),
-		intel_get_pixmap_bo(source),
-		mask ? intel_get_pixmap_bo(mask) : NULL,
+		intel_uxa_get_pixmap_bo(dest),
+		intel_uxa_get_pixmap_bo(source),
+		mask ? intel_uxa_get_pixmap_bo(mask) : NULL,
 	};
 	int tex_unit = 0;
 	int floats_per_vertex;
@@ -667,20 +667,20 @@ i915_prepare_composite(int op, PicturePtr source_picture,
 	intel->render_dest_picture = dest_picture;
 	intel->render_dest = dest;
 
-	if (!intel_check_pitch_3d(source))
+	if (!intel_uxa_check_pitch_3d(source))
 		return FALSE;
 
-	if (mask && !intel_check_pitch_3d(mask))
+	if (mask && !intel_uxa_check_pitch_3d(mask))
 		return FALSE;
 
-	if (!intel_check_pitch_3d(dest))
+	if (!intel_uxa_check_pitch_3d(dest))
 		return FALSE;
 
 	if (!i915_get_dest_format(dest_picture,
 				  &intel->i915_render_state.dst_format))
 		return FALSE;
 
-	if (!intel_get_aperture_space(scrn, bo_table, ARRAY_SIZE(bo_table)))
+	if (!intel_uxa_get_aperture_space(scrn, bo_table, ARRAY_SIZE(bo_table)))
 		return FALSE;
 
 	if (mask_picture != NULL && mask_picture->componentAlpha &&
@@ -703,11 +703,11 @@ i915_prepare_composite(int op, PicturePtr source_picture,
 
 	floats_per_vertex = 2;		/* dest x/y */
 	if (!i915_texture_setup(source_picture, source, tex_unit++)) {
-		intel_debug_fallback(scrn, "fail to setup src texture\n");
+		intel_uxa_debug_fallback(scrn, "fail to setup src texture\n");
 		return FALSE;
 	}
 
-	if (intel_transform_is_affine(source_picture->transform))
+	if (intel_uxa_transform_is_affine(source_picture->transform))
 		floats_per_vertex += 2;	/* src x/y */
 	else
 		floats_per_vertex += 4;	/* src x/y/z/w */
@@ -715,12 +715,12 @@ i915_prepare_composite(int op, PicturePtr source_picture,
 	if (mask_picture != NULL) {
 		assert(mask != NULL);
 		if (!i915_texture_setup(mask_picture, mask, tex_unit++)) {
-			intel_debug_fallback(scrn,
+			intel_uxa_debug_fallback(scrn,
 					     "fail to setup mask texture\n");
 			return FALSE;
 		}
 
-		if (intel_transform_is_affine(mask_picture->transform))
+		if (intel_uxa_transform_is_affine(mask_picture->transform))
 			floats_per_vertex += 2;	/* mask x/y */
 		else
 			floats_per_vertex += 4;	/* mask x/y/z/w */
@@ -728,7 +728,7 @@ i915_prepare_composite(int op, PicturePtr source_picture,
 
 	intel->i915_render_state.op = op;
 
-	if (intel_pixmap_is_dirty(source) || intel_pixmap_is_dirty(mask))
+	if (intel_uxa_pixmap_is_dirty(source) || intel_uxa_pixmap_is_dirty(mask))
 		intel_batch_emit_flush(scrn);
 
 	intel->needs_render_state_emit = TRUE;
@@ -737,7 +737,7 @@ i915_prepare_composite(int op, PicturePtr source_picture,
 	if (!mask) {
 		if (intel->transform[0] == NULL)
 			intel->prim_emit = i915_emit_composite_primitive_identity_source;
-		else if (intel_transform_is_affine(intel->transform[0]))
+		else if (intel_uxa_transform_is_affine(intel->transform[0]))
 			intel->prim_emit = i915_emit_composite_primitive_affine_source;
 	} else {
 		if (intel->transform[0] == NULL) {
@@ -775,7 +775,7 @@ i915_composite_emit_shader(intel_screen_private *intel, CARD8 op)
 		else
 			src_reg = FS_OC;
 
-		if (intel_transform_is_affine(intel->transform[0]))
+		if (intel_uxa_transform_is_affine(intel->transform[0]))
 			i915_fs_texld(src_reg, FS_S0, FS_T0);
 		else
 			i915_fs_texldp(src_reg, FS_S0, FS_T0);
@@ -787,7 +787,7 @@ i915_composite_emit_shader(intel_screen_private *intel, CARD8 op)
 		i915_fs_dcl(FS_S1);
 
 		/* Load the source_picture texel */
-		if (intel_transform_is_affine(intel->transform[0]))
+		if (intel_uxa_transform_is_affine(intel->transform[0]))
 			i915_fs_texld(FS_R0, FS_S0, FS_T0);
 		else
 			i915_fs_texldp(FS_R0, FS_S0, FS_T0);
@@ -795,7 +795,7 @@ i915_composite_emit_shader(intel_screen_private *intel, CARD8 op)
 		src_reg = FS_R0;
 
 		/* Load the mask_picture texel */
-		if (intel_transform_is_affine(intel->transform[1]))
+		if (intel_uxa_transform_is_affine(intel->transform[1]))
 			i915_fs_texld(FS_R1, FS_S1, FS_T1);
 		else
 			i915_fs_texldp(FS_R1, FS_S1, FS_T1);
@@ -883,9 +883,9 @@ static void i915_emit_composite_setup(ScrnInfoPtr scrn)
 	if (1) {
 		uint32_t tiling_bits;
 
-		if (intel_pixmap_tiled(dest)) {
+		if (intel_uxa_pixmap_tiled(dest)) {
 			tiling_bits = BUF_3D_TILED_SURFACE;
-			if (intel_get_pixmap_private(dest)->tiling
+			if (intel_uxa_get_pixmap_private(dest)->tiling
 			    == I915_TILING_Y)
 				tiling_bits |= BUF_3D_TILE_WALK_Y;
 		} else
@@ -916,12 +916,12 @@ static void i915_emit_composite_setup(ScrnInfoPtr scrn)
 		ss2 = ~0;
 		ss2 &= ~S2_TEXCOORD_FMT(0, TEXCOORDFMT_NOT_PRESENT);
 		ss2 |= S2_TEXCOORD_FMT(0,
-				       intel_transform_is_affine(intel->transform[0]) ?
+				       intel_uxa_transform_is_affine(intel->transform[0]) ?
 				       TEXCOORDFMT_2D : TEXCOORDFMT_4D);
 		if (mask) {
 		    ss2 &= ~S2_TEXCOORD_FMT(1, TEXCOORDFMT_NOT_PRESENT);
 		    ss2 |= S2_TEXCOORD_FMT(1,
-					   intel_transform_is_affine(intel->transform[1]) ?
+					   intel_uxa_transform_is_affine(intel->transform[1]) ?
 					   TEXCOORDFMT_2D : TEXCOORDFMT_4D);
 		}
 
diff --git a/src/uxa/i915_video.c b/src/uxa/i915_video.c
index 16389cd..1996e8c 100644
--- a/src/uxa/i915_video.c
+++ b/src/uxa/i915_video.c
@@ -67,7 +67,7 @@ I915DisplayVideoTextured(ScrnInfoPtr scrn,
 	dyo = dstRegion->extents.y1;
 
 	if (pixmap->drawable.width > 2048 || pixmap->drawable.height > 2048 ||
-	    !intel_check_pitch_3d(pixmap)) {
+	    !intel_uxa_check_pitch_3d(pixmap)) {
 		ScreenPtr screen = pixmap->drawable.pScreen;
 
 		target = screen->CreatePixmap(screen,
@@ -78,7 +78,7 @@ I915DisplayVideoTextured(ScrnInfoPtr scrn,
 		if (target == NULL)
 			return;
 
-		if (intel_get_pixmap_bo(target) == NULL) {
+		if (intel_uxa_get_pixmap_bo(target) == NULL) {
 			screen->DestroyPixmap(target);
 			return;
 		}
@@ -159,9 +159,9 @@ I915DisplayVideoTextured(ScrnInfoPtr scrn,
 			  DSTORG_VERT_BIAS(0x8) | format);
 
 		/* front buffer, pitch, offset */
-		if (intel_pixmap_tiled(target)) {
+		if (intel_uxa_pixmap_tiled(target)) {
 			tiling = BUF_3D_TILED_SURFACE;
-			if (intel_get_pixmap_private(target)->tiling == I915_TILING_Y)
+			if (intel_uxa_get_pixmap_private(target)->tiling == I915_TILING_Y)
 				tiling |= BUF_3D_TILE_WALK_Y;
 		} else
 			tiling = 0;
@@ -488,5 +488,5 @@ I915DisplayVideoTextured(ScrnInfoPtr scrn,
 		target->drawable.pScreen->DestroyPixmap(target);
 	}
 
-	intel_debug_flush(scrn);
+	intel_uxa_debug_flush(scrn);
 }
diff --git a/src/uxa/i965_render.c b/src/uxa/i965_render.c
index 74f57af..205744d 100644
--- a/src/uxa/i965_render.c
+++ b/src/uxa/i965_render.c
@@ -186,7 +186,7 @@ i965_check_composite(int op,
 
 	/* Check for unsupported compositing operations. */
 	if (op >= sizeof(i965_blend_op) / sizeof(i965_blend_op[0])) {
-		intel_debug_fallback(scrn,
+		intel_uxa_debug_fallback(scrn,
 				     "Unsupported Composite op 0x%x\n", op);
 		return FALSE;
 	}
@@ -199,7 +199,7 @@ i965_check_composite(int op,
 		 */
 		if (i965_blend_op[op].src_alpha &&
 		    (i965_blend_op[op].src_blend != BRW_BLENDFACTOR_ZERO)) {
-			intel_debug_fallback(scrn,
+			intel_uxa_debug_fallback(scrn,
 					     "Component alpha not supported "
 					     "with source alpha and source "
 					     "value blending.\n");
@@ -208,7 +208,7 @@ i965_check_composite(int op,
 	}
 
 	if (i965_get_dest_format(dest_picture) == -1) {
-		intel_debug_fallback(scrn, "Usupported Color buffer format 0x%x\n",
+		intel_uxa_debug_fallback(scrn, "Usupported Color buffer format 0x%x\n",
 				     (int)dest_picture->format);
 		return FALSE;
 	}
@@ -221,7 +221,7 @@ i965_check_composite_texture(ScreenPtr screen, PicturePtr picture)
 {
 	if (picture->repeatType > RepeatReflect) {
 		ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
-		intel_debug_fallback(scrn,
+		intel_uxa_debug_fallback(scrn,
 				     "extended repeat (%d) not supported\n",
 				     picture->repeatType);
 		return FALSE;
@@ -230,7 +230,7 @@ i965_check_composite_texture(ScreenPtr screen, PicturePtr picture)
 	if (picture->filter != PictFilterNearest &&
 	    picture->filter != PictFilterBilinear) {
 		ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
-		intel_debug_fallback(scrn, "Unsupported filter 0x%x\n",
+		intel_uxa_debug_fallback(scrn, "Unsupported filter 0x%x\n",
 				     picture->filter);
 		return FALSE;
 	}
@@ -242,7 +242,7 @@ i965_check_composite_texture(ScreenPtr screen, PicturePtr picture)
 		h = picture->pDrawable->height;
 		if ((w > 8192) || (h > 8192)) {
 			ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
-			intel_debug_fallback(scrn,
+			intel_uxa_debug_fallback(scrn,
 					     "Picture w/h too large (%dx%d)\n",
 					     w, h);
 			return FALSE;
@@ -257,7 +257,7 @@ i965_check_composite_texture(ScreenPtr screen, PicturePtr picture)
 		if (i == sizeof(i965_tex_formats) / sizeof(i965_tex_formats[0]))
 		{
 			ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
-			intel_debug_fallback(scrn,
+			intel_uxa_debug_fallback(scrn,
 					     "Unsupported picture format "
 					     "0x%x\n",
 					     (int)picture->format);
@@ -791,7 +791,7 @@ static drm_intel_bo *gen4_create_sf_state(intel_screen_private *intel,
 	sf_state = memset(sf_state_bo->virtual, 0, sizeof(*sf_state));
 	sf_state->thread0.grf_reg_count = BRW_GRF_BLOCKS(SF_KERNEL_NUM_GRF);
 	sf_state->thread0.kernel_start_pointer =
-	    intel_emit_reloc(sf_state_bo,
+	    intel_uxa_emit_reloc(sf_state_bo,
 			     offsetof(struct brw_sf_unit_state, thread0),
 			     kernel_bo, sf_state->thread0.grf_reg_count << 1,
 			     I915_GEM_DOMAIN_INSTRUCTION, 0) >> 6;
@@ -838,7 +838,7 @@ static drm_intel_bo *sampler_border_color_create(intel_screen_private *intel)
 	sampler_border_color.color[2] = 0;	/* B */
 	sampler_border_color.color[3] = 0;	/* A */
 
-	return intel_bo_alloc_for_data(intel,
+	return intel_uxa_bo_alloc_for_data(intel,
 				       &sampler_border_color,
 				       sizeof(sampler_border_color),
 				       "gen4 render sampler border color");
@@ -902,7 +902,7 @@ gen4_sampler_state_init(drm_intel_bo * sampler_state_bo,
 	}
 
 	sampler_state->ss2.border_color_pointer =
-	    intel_emit_reloc(sampler_state_bo, sampler_state_offset +
+	    intel_uxa_emit_reloc(sampler_state_bo, sampler_state_offset +
 			     offsetof(struct brw_sampler_state, ss2),
 			     border_color_bo, 0,
 			     I915_GEM_DOMAIN_SAMPLER, 0) >> 5;
@@ -968,7 +968,7 @@ gen7_sampler_state_init(drm_intel_bo * sampler_state_bo,
 	}
 
 	sampler_state->ss2.default_color_pointer =
-	    intel_emit_reloc(sampler_state_bo, sampler_state_offset +
+	    intel_uxa_emit_reloc(sampler_state_bo, sampler_state_offset +
 			     offsetof(struct gen7_sampler_state, ss2),
 			     border_color_bo, 0,
 			     I915_GEM_DOMAIN_SAMPLER, 0) >> 5;
@@ -1084,7 +1084,7 @@ cc_state_init(drm_intel_bo * cc_state_bo,
 	cc_state->cc3.alpha_test = 0;	/* disable alpha test */
 
 	cc_state->cc4.cc_viewport_state_offset =
-	    intel_emit_reloc(cc_state_bo, cc_state_offset +
+	    intel_uxa_emit_reloc(cc_state_bo, cc_state_offset +
 			     offsetof(struct brw_cc_unit_state, cc4),
 			     cc_vp_bo, 0, I915_GEM_DOMAIN_INSTRUCTION, 0) >> 5;
 
@@ -1125,7 +1125,7 @@ static drm_intel_bo *gen4_create_wm_state(intel_screen_private *intel,
 	state = memset(wm_state_bo->virtual, 0, sizeof(*state));
 	state->thread0.grf_reg_count = BRW_GRF_BLOCKS(PS_KERNEL_NUM_GRF);
 	state->thread0.kernel_start_pointer =
-	    intel_emit_reloc(wm_state_bo,
+	    intel_uxa_emit_reloc(wm_state_bo,
 			     offsetof(struct brw_wm_unit_state, thread0),
 			     kernel_bo, state->thread0.grf_reg_count << 1,
 			     I915_GEM_DOMAIN_INSTRUCTION, 0) >> 6;
@@ -1149,7 +1149,7 @@ static drm_intel_bo *gen4_create_wm_state(intel_screen_private *intel,
 		state->wm4.sampler_count = 1;	/* 1-4 samplers used */
 
 	state->wm4.sampler_state_pointer =
-	    intel_emit_reloc(wm_state_bo,
+	    intel_uxa_emit_reloc(wm_state_bo,
 			     offsetof(struct brw_wm_unit_state, wm4),
 			     sampler_bo,
 			     state->wm4.sampler_count << 2,
@@ -1219,7 +1219,7 @@ static drm_intel_bo *gen4_create_vs_unit_state(intel_screen_private *intel)
 	vs_state.vs6.vs_enable = 0;
 	vs_state.vs6.vert_cache_disable = 1;
 
-	return intel_bo_alloc_for_data(intel, &vs_state, sizeof(vs_state),
+	return intel_uxa_bo_alloc_for_data(intel, &vs_state, sizeof(vs_state),
 				       "gen4 render VS state");
 }
 
@@ -1309,7 +1309,7 @@ gen4_set_picture_surface_state(intel_screen_private *intel,
 			       PicturePtr picture, PixmapPtr pixmap,
 			       Bool is_dst)
 {
-	struct intel_pixmap *priv = intel_get_pixmap_private(pixmap);
+	struct intel_uxa_pixmap *priv = intel_uxa_get_pixmap_private(pixmap);
 	struct brw_surface_state *ss;
 	uint32_t write_domain, read_domains;
 	int offset;
@@ -1341,7 +1341,7 @@ gen4_set_picture_surface_state(intel_screen_private *intel,
 	ss->ss2.width = pixmap->drawable.width - 1;
 	ss->ss3.pitch = intel_pixmap_pitch(pixmap) - 1;
 	ss->ss3.tile_walk = 0;	/* Tiled X */
-	ss->ss3.tiled_surface = intel_pixmap_tiled(pixmap) ? 1 : 0;
+	ss->ss3.tiled_surface = intel_uxa_pixmap_tiled(pixmap) ? 1 : 0;
 
 	dri_bo_emit_reloc(intel->surface_bo,
 			  read_domains, write_domain,
@@ -1361,7 +1361,7 @@ gen7_set_picture_surface_state(intel_screen_private *intel,
 			       PicturePtr picture, PixmapPtr pixmap,
 			       Bool is_dst)
 {
-	struct intel_pixmap *priv = intel_get_pixmap_private(pixmap);
+	struct intel_uxa_pixmap *priv = intel_uxa_get_pixmap_private(pixmap);
 	struct gen7_surface_state *ss;
 	uint32_t write_domain, read_domains;
 	int offset;
@@ -1386,7 +1386,7 @@ gen7_set_picture_surface_state(intel_screen_private *intel,
 		ss->ss0.surface_format = i965_get_card_format(picture);
 
 	ss->ss0.tile_walk = 0;	/* Tiled X */
-	ss->ss0.tiled_surface = intel_pixmap_tiled(pixmap) ? 1 : 0;
+	ss->ss0.tiled_surface = intel_uxa_pixmap_tiled(pixmap) ? 1 : 0;
 	ss->ss1.base_addr = priv->bo->offset;
 
 	ss->ss2.height = pixmap->drawable.height - 1;
@@ -1819,19 +1819,19 @@ i965_emit_composite_primitive_affine_source(intel_screen_private *intel,
 {
 	float src_x[3], src_y[3];
 
-	if (!intel_get_transformed_coordinates(srcX, srcY,
+	if (!intel_uxa_get_transformed_coordinates(srcX, srcY,
 					      intel->transform[0],
 					      &src_x[0],
 					      &src_y[0]))
 		return;
 
-	if (!intel_get_transformed_coordinates(srcX, srcY + h,
+	if (!intel_uxa_get_transformed_coordinates(srcX, srcY + h,
 					      intel->transform[0],
 					      &src_x[1],
 					      &src_y[1]))
 		return;
 
-	if (!intel_get_transformed_coordinates(srcX + w, srcY + h,
+	if (!intel_uxa_get_transformed_coordinates(srcX + w, srcY + h,
 					      intel->transform[0],
 					      &src_x[2],
 					      &src_y[2]))
@@ -1893,39 +1893,39 @@ i965_emit_composite_primitive(intel_screen_private *intel,
 	Bool is_affine = intel->gen4_render_state->composite_op.is_affine;
 
 	if (is_affine) {
-		if (!intel_get_transformed_coordinates(srcX, srcY,
+		if (!intel_uxa_get_transformed_coordinates(srcX, srcY,
 						       intel->transform[0],
 						       &src_x[0],
 						       &src_y[0]))
 			return;
 
-		if (!intel_get_transformed_coordinates(srcX, srcY + h,
+		if (!intel_uxa_get_transformed_coordinates(srcX, srcY + h,
 						       intel->transform[0],
 						       &src_x[1],
 						       &src_y[1]))
 			return;
 
-		if (!intel_get_transformed_coordinates(srcX + w, srcY + h,
+		if (!intel_uxa_get_transformed_coordinates(srcX + w, srcY + h,
 						       intel->transform[0],
 						       &src_x[2],
 						       &src_y[2]))
 			return;
 	} else {
-		if (!intel_get_transformed_coordinates_3d(srcX, srcY,
+		if (!intel_uxa_get_transformed_coordinates_3d(srcX, srcY,
 							  intel->transform[0],
 							  &src_x[0],
 							  &src_y[0],
 							  &src_w[0]))
 			return;
 
-		if (!intel_get_transformed_coordinates_3d(srcX, srcY + h,
+		if (!intel_uxa_get_transformed_coordinates_3d(srcX, srcY + h,
 							  intel->transform[0],
 							  &src_x[1],
 							  &src_y[1],
 							  &src_w[1]))
 			return;
 
-		if (!intel_get_transformed_coordinates_3d(srcX + w, srcY + h,
+		if (!intel_uxa_get_transformed_coordinates_3d(srcX + w, srcY + h,
 							  intel->transform[0],
 							  &src_x[2],
 							  &src_y[2],
@@ -1935,39 +1935,39 @@ i965_emit_composite_primitive(intel_screen_private *intel,
 
 	if (intel->render_mask) {
 		if (is_affine) {
-			if (!intel_get_transformed_coordinates(maskX, maskY,
+			if (!intel_uxa_get_transformed_coordinates(maskX, maskY,
 							      intel->transform[1],
 							      &mask_x[0],
 							      &mask_y[0]))
 				return;
 
-			if (!intel_get_transformed_coordinates(maskX, maskY + h,
+			if (!intel_uxa_get_transformed_coordinates(maskX, maskY + h,
 							      intel->transform[1],
 							      &mask_x[1],
 							      &mask_y[1]))
 				return;
 
-			if (!intel_get_transformed_coordinates(maskX + w, maskY + h,
+			if (!intel_uxa_get_transformed_coordinates(maskX + w, maskY + h,
 							      intel->transform[1],
 							      &mask_x[2],
 							      &mask_y[2]))
 				return;
 		} else {
-			if (!intel_get_transformed_coordinates_3d(maskX, maskY,
+			if (!intel_uxa_get_transformed_coordinates_3d(maskX, maskY,
 								 intel->transform[1],
 								 &mask_x[0],
 								 &mask_y[0],
 								 &mask_w[0]))
 				return;
 
-			if (!intel_get_transformed_coordinates_3d(maskX, maskY + h,
+			if (!intel_uxa_get_transformed_coordinates_3d(maskX, maskY + h,
 								 intel->transform[1],
 								 &mask_x[1],
 								 &mask_y[1],
 								 &mask_w[1]))
 				return;
 
-			if (!intel_get_transformed_coordinates_3d(maskX + w, maskY + h,
+			if (!intel_uxa_get_transformed_coordinates_3d(maskX + w, maskY + h,
 								 intel->transform[1],
 								 &mask_x[2],
 								 &mask_y[2],
@@ -2029,14 +2029,14 @@ i965_prepare_composite(int op, PicturePtr source_picture,
 	composite_op->src_filter =
 	    sampler_state_filter_from_picture(source_picture->filter);
 	if (composite_op->src_filter == SS_INVALID_FILTER) {
-		intel_debug_fallback(scrn, "Bad src filter 0x%x\n",
+		intel_uxa_debug_fallback(scrn, "Bad src filter 0x%x\n",
 				     source_picture->filter);
 		return FALSE;
 	}
 	composite_op->src_extend =
 	    sampler_state_extend_from_picture(source_picture->repeatType);
 	if (composite_op->src_extend == SS_INVALID_EXTEND) {
-		intel_debug_fallback(scrn, "Bad src repeat 0x%x\n",
+		intel_uxa_debug_fallback(scrn, "Bad src repeat 0x%x\n",
 				     source_picture->repeatType);
 		return FALSE;
 	}
@@ -2050,7 +2050,7 @@ i965_prepare_composite(int op, PicturePtr source_picture,
 			 */
 			if (i965_blend_op[op].src_alpha &&
 			    (i965_blend_op[op].src_blend != BRW_BLENDFACTOR_ZERO)) {
-				intel_debug_fallback(scrn,
+				intel_uxa_debug_fallback(scrn,
 						     "Component alpha not supported "
 						     "with source alpha and source "
 						     "value blending.\n");
@@ -2061,14 +2061,14 @@ i965_prepare_composite(int op, PicturePtr source_picture,
 		composite_op->mask_filter =
 		    sampler_state_filter_from_picture(mask_picture->filter);
 		if (composite_op->mask_filter == SS_INVALID_FILTER) {
-			intel_debug_fallback(scrn, "Bad mask filter 0x%x\n",
+			intel_uxa_debug_fallback(scrn, "Bad mask filter 0x%x\n",
 					     mask_picture->filter);
 			return FALSE;
 		}
 		composite_op->mask_extend =
 		    sampler_state_extend_from_picture(mask_picture->repeatType);
 		if (composite_op->mask_extend == SS_INVALID_EXTEND) {
-			intel_debug_fallback(scrn, "Bad mask repeat 0x%x\n",
+			intel_uxa_debug_fallback(scrn, "Bad mask repeat 0x%x\n",
 					     mask_picture->repeatType);
 			return FALSE;
 		}
@@ -2078,7 +2078,7 @@ i965_prepare_composite(int op, PicturePtr source_picture,
 	}
 
 	/* Flush any pending writes prior to relocating the textures. */
-	if (intel_pixmap_is_dirty(source) || intel_pixmap_is_dirty(mask))
+	if (intel_uxa_pixmap_is_dirty(source) || intel_uxa_pixmap_is_dirty(mask))
 		intel_batch_emit_flush(scrn);
 
 	composite_op->op = op;
@@ -2093,7 +2093,7 @@ i965_prepare_composite(int op, PicturePtr source_picture,
 	intel->scale_units[0][1] = 1. / source->drawable.height;
 
 	intel->transform[0] = source_picture->transform;
-	composite_op->is_affine = intel_transform_is_affine(intel->transform[0]);
+	composite_op->is_affine = intel_uxa_transform_is_affine(intel->transform[0]);
 
 	if (mask_picture == NULL) {
 		intel->transform[1] = NULL;
@@ -2105,7 +2105,7 @@ i965_prepare_composite(int op, PicturePtr source_picture,
 		intel->scale_units[1][0] = 1. / mask->drawable.width;
 		intel->scale_units[1][1] = 1. / mask->drawable.height;
 		composite_op->is_affine &=
-		    intel_transform_is_affine(intel->transform[1]);
+		    intel_uxa_transform_is_affine(intel->transform[1]);
 	}
 
 	if (mask) {
@@ -2159,7 +2159,7 @@ i965_prepare_composite(int op, PicturePtr source_picture,
 	if (!i965_composite_check_aperture(intel)) {
 		intel_batch_submit(scrn);
 		if (!i965_composite_check_aperture(intel)) {
-			intel_debug_fallback(scrn,
+			intel_uxa_debug_fallback(scrn,
 					     "Couldn't fit render operation "
 					     "in aperture\n");
 			return FALSE;
@@ -2367,21 +2367,21 @@ void gen4_render_state_init(ScrnInfoPtr scrn)
 
 	/* Set up the two SF states (one for blending with a mask, one without) */
 	if (IS_GEN5(intel)) {
-		sf_kernel_bo = intel_bo_alloc_for_data(intel,
+		sf_kernel_bo = intel_uxa_bo_alloc_for_data(intel,
 						       sf_kernel_static_gen5,
 						       sizeof
 						       (sf_kernel_static_gen5),
 						       "sf kernel gen5");
 		sf_kernel_mask_bo =
-		    intel_bo_alloc_for_data(intel, sf_kernel_mask_static_gen5,
+		    intel_uxa_bo_alloc_for_data(intel, sf_kernel_mask_static_gen5,
 					    sizeof(sf_kernel_mask_static_gen5),
 					    "sf mask kernel");
 	} else {
-		sf_kernel_bo = intel_bo_alloc_for_data(intel,
+		sf_kernel_bo = intel_uxa_bo_alloc_for_data(intel,
 						       sf_kernel_static,
 						       sizeof(sf_kernel_static),
 						       "sf kernel");
-		sf_kernel_mask_bo = intel_bo_alloc_for_data(intel,
+		sf_kernel_mask_bo = intel_uxa_bo_alloc_for_data(intel,
 							    sf_kernel_mask_static,
 							    sizeof
 							    (sf_kernel_mask_static),
@@ -2395,7 +2395,7 @@ void gen4_render_state_init(ScrnInfoPtr scrn)
 	wm_kernels = IS_GEN5(intel) ? wm_kernels_gen5 : wm_kernels_gen4;
 	for (m = 0; m < KERNEL_COUNT; m++) {
 		render->wm_kernel_bo[m] =
-			intel_bo_alloc_for_data(intel,
+			intel_uxa_bo_alloc_for_data(intel,
 					wm_kernels[m].data,
 					wm_kernels[m].size,
 					"WM kernel");
@@ -2919,7 +2919,7 @@ gen6_render_state_init(ScrnInfoPtr scrn)
 	wm_kernels = IS_GEN7(intel) ? wm_kernels_gen7 : wm_kernels_gen6;
 	for (m = 0; m < KERNEL_COUNT; m++) {
 		render->wm_kernel_bo[m] =
-			intel_bo_alloc_for_data(intel,
+			intel_uxa_bo_alloc_for_data(intel,
 					wm_kernels[m].data,
 					wm_kernels[m].size,
 					"WM kernel gen6/7");
diff --git a/src/uxa/i965_video.c b/src/uxa/i965_video.c
index 54f5fa7..252a6a0 100644
--- a/src/uxa/i965_video.c
+++ b/src/uxa/i965_video.c
@@ -388,7 +388,7 @@ static void i965_create_dst_surface_state(ScrnInfoPtr scrn,
 {
 	intel_screen_private *intel = intel_get_screen_private(scrn);
 	struct brw_surface_state dest_surf_state;
-	drm_intel_bo *pixmap_bo = intel_get_pixmap_bo(pixmap);
+	drm_intel_bo *pixmap_bo = intel_uxa_get_pixmap_bo(pixmap);
 	assert(pixmap_bo != NULL);
 
 	memset(&dest_surf_state, 0, sizeof(dest_surf_state));
@@ -414,7 +414,7 @@ static void i965_create_dst_surface_state(ScrnInfoPtr scrn,
 	dest_surf_state.ss0.render_cache_read_mode = 0;
 
 	dest_surf_state.ss1.base_addr =
-	    intel_emit_reloc(surf_bo, offset + offsetof(struct brw_surface_state, ss1),
+	    intel_uxa_emit_reloc(surf_bo, offset + offsetof(struct brw_surface_state, ss1),
 			     pixmap_bo, 0, I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER);
 
 	dest_surf_state.ss2.height = pixmap->drawable.height - 1;
@@ -422,7 +422,7 @@ static void i965_create_dst_surface_state(ScrnInfoPtr scrn,
 	dest_surf_state.ss2.mip_count = 0;
 	dest_surf_state.ss2.render_target_rotation = 0;
 	dest_surf_state.ss3.pitch = intel_pixmap_pitch(pixmap) - 1;
-	dest_surf_state.ss3.tiled_surface = intel_pixmap_tiled(pixmap);
+	dest_surf_state.ss3.tiled_surface = intel_uxa_pixmap_tiled(pixmap);
 	dest_surf_state.ss3.tile_walk = 0;	/* TileX */
 
 	dri_bo_subdata(surf_bo,
@@ -465,7 +465,7 @@ static void i965_create_src_surface_state(ScrnInfoPtr scrn,
 
 	if (src_bo) {
 		src_surf_state.ss1.base_addr =
-		    intel_emit_reloc(surface_bo,
+		    intel_uxa_emit_reloc(surface_bo,
 				     offset + offsetof(struct brw_surface_state, ss1),
 				     src_bo, src_offset,
 				     I915_GEM_DOMAIN_SAMPLER, 0);
@@ -485,13 +485,13 @@ static void gen7_create_dst_surface_state(ScrnInfoPtr scrn,
 {
 	intel_screen_private *intel = intel_get_screen_private(scrn);
 	struct gen7_surface_state dest_surf_state;
-	drm_intel_bo *pixmap_bo = intel_get_pixmap_bo(pixmap);
+	drm_intel_bo *pixmap_bo = intel_uxa_get_pixmap_bo(pixmap);
 	assert(pixmap_bo != NULL);
 
 	memset(&dest_surf_state, 0, sizeof(dest_surf_state));
 
 	dest_surf_state.ss0.surface_type = BRW_SURFACE_2D;
-	dest_surf_state.ss0.tiled_surface = intel_pixmap_tiled(pixmap);
+	dest_surf_state.ss0.tiled_surface = intel_uxa_pixmap_tiled(pixmap);
 	dest_surf_state.ss0.tile_walk = 0;	/* TileX */
 
 	if (intel->cpp == 2) {
@@ -501,7 +501,7 @@ static void gen7_create_dst_surface_state(ScrnInfoPtr scrn,
 	}
 
 	dest_surf_state.ss1.base_addr =
-		intel_emit_reloc(surf_bo,
+		intel_uxa_emit_reloc(surf_bo,
 				offset + offsetof(struct gen7_surface_state, ss1),
 				pixmap_bo, 0,
 				I915_GEM_DOMAIN_SAMPLER, 0);
@@ -543,7 +543,7 @@ static void gen7_create_src_surface_state(ScrnInfoPtr scrn,
 
 	if (src_bo) {
 		src_surf_state.ss1.base_addr =
-			intel_emit_reloc(surface_bo,
+			intel_uxa_emit_reloc(surface_bo,
 					offset + offsetof(struct gen7_surface_state, ss1),
 					src_bo, src_offset,
 					I915_GEM_DOMAIN_SAMPLER, 0);
@@ -596,7 +596,7 @@ static drm_intel_bo *i965_create_sampler_state(ScrnInfoPtr scrn)
 	sampler_state.ss1.s_wrap_mode = BRW_TEXCOORDMODE_CLAMP;
 	sampler_state.ss1.t_wrap_mode = BRW_TEXCOORDMODE_CLAMP;
 
-	return intel_bo_alloc_for_data(intel,
+	return intel_uxa_bo_alloc_for_data(intel,
 				       &sampler_state, sizeof(sampler_state),
 				       "textured video sampler state");
 }
@@ -613,7 +613,7 @@ static drm_intel_bo *gen7_create_sampler_state(ScrnInfoPtr scrn)
 	sampler_state.ss3.s_wrap_mode = BRW_TEXCOORDMODE_CLAMP;
 	sampler_state.ss3.t_wrap_mode = BRW_TEXCOORDMODE_CLAMP;
 
-	return intel_bo_alloc_for_data(intel,
+	return intel_uxa_bo_alloc_for_data(intel,
 				       &sampler_state, sizeof(sampler_state),
 				       "textured video sampler state");
 }
@@ -633,7 +633,7 @@ static drm_intel_bo *i965_create_vs_state(ScrnInfoPtr scrn)
 	vs_state.vs6.vs_enable = 0;
 	vs_state.vs6.vert_cache_disable = 1;
 
-	return intel_bo_alloc_for_data(intel,
+	return intel_uxa_bo_alloc_for_data(intel,
 				       &vs_state, sizeof(vs_state),
 				       "textured video vs state");
 }
@@ -643,7 +643,7 @@ static drm_intel_bo *i965_create_program(ScrnInfoPtr scrn,
 					 unsigned int program_size)
 {
 	intel_screen_private *intel = intel_get_screen_private(scrn);
-	return intel_bo_alloc_for_data(intel,
+	return intel_uxa_bo_alloc_for_data(intel,
 				       program, program_size,
 				       "textured video program");
 }
@@ -680,7 +680,7 @@ static drm_intel_bo *i965_create_sf_state(ScrnInfoPtr scrn)
 	memset(&sf_state, 0, sizeof(sf_state));
 	sf_state.thread0.grf_reg_count = BRW_GRF_BLOCKS(SF_KERNEL_NUM_GRF);
 	sf_state.thread0.kernel_start_pointer =
-	    intel_emit_reloc(sf_bo, offsetof(struct brw_sf_unit_state, thread0),
+	    intel_uxa_emit_reloc(sf_bo, offsetof(struct brw_sf_unit_state, thread0),
 			     kernel_bo, sf_state.thread0.grf_reg_count << 1,
 			     I915_GEM_DOMAIN_INSTRUCTION, 0) >> 6;
 	sf_state.sf1.single_program_flow = 1;	/* XXX */
@@ -764,7 +764,7 @@ static drm_intel_bo *i965_create_wm_state(ScrnInfoPtr scrn,
 	memset(&wm_state, 0, sizeof(wm_state));
 	wm_state.thread0.grf_reg_count = BRW_GRF_BLOCKS(PS_KERNEL_NUM_GRF);
 	wm_state.thread0.kernel_start_pointer =
-	    intel_emit_reloc(wm_bo, offsetof(struct brw_wm_unit_state, thread0),
+	    intel_uxa_emit_reloc(wm_bo, offsetof(struct brw_wm_unit_state, thread0),
 			     kernel_bo, wm_state.thread0.grf_reg_count << 1,
 			     I915_GEM_DOMAIN_INSTRUCTION, 0) >> 6;
 	wm_state.thread1.single_program_flow = 1;	/* XXX */
@@ -791,7 +791,7 @@ static drm_intel_bo *i965_create_wm_state(ScrnInfoPtr scrn,
 	wm_state.thread3.urb_entry_read_offset = 0;	/* XXX */
 	wm_state.wm4.stats_enable = 1;
 	wm_state.wm4.sampler_state_pointer =
-	    intel_emit_reloc(wm_bo, offsetof(struct brw_wm_unit_state, wm4),
+	    intel_uxa_emit_reloc(wm_bo, offsetof(struct brw_wm_unit_state, wm4),
 			     sampler_bo, 0,
 			     I915_GEM_DOMAIN_INSTRUCTION, 0) >> 5;
 	if (IS_GEN5(intel))
@@ -818,7 +818,7 @@ static drm_intel_bo *i965_create_cc_vp_state(ScrnInfoPtr scrn)
 	cc_viewport.min_depth = -1.e35;
 	cc_viewport.max_depth = 1.e35;
 
-	return intel_bo_alloc_for_data(intel,
+	return intel_uxa_bo_alloc_for_data(intel,
 				       &cc_viewport, sizeof(cc_viewport),
 				       "textured video cc viewport");
 }
@@ -850,7 +850,7 @@ static drm_intel_bo *i965_create_cc_state(ScrnInfoPtr scrn)
 	cc_state.cc3.blend_enable = 0;	/* disable color blend */
 	cc_state.cc3.alpha_test = 0;	/* disable alpha test */
 	cc_state.cc4.cc_viewport_state_offset =
-	    intel_emit_reloc(cc_bo, offsetof(struct brw_cc_unit_state, cc4),
+	    intel_uxa_emit_reloc(cc_bo, offsetof(struct brw_cc_unit_state, cc4),
 			     cc_vp_bo, 0, I915_GEM_DOMAIN_INSTRUCTION, 0) >> 5;
 	cc_state.cc5.dither_enable = 0;	/* disable dither */
 	cc_state.cc5.logicop_func = 0xc;	/* WHITE */
@@ -1287,7 +1287,7 @@ I965DisplayVideoTextured(ScrnInfoPtr scrn,
 		vb[i++] = (float)box_x1 + pix_xoff;
 		vb[i++] = (float)box_y1 + pix_yoff;
 
-		bo_table[0] = intel_bo_alloc_for_data(intel,
+		bo_table[0] = intel_uxa_bo_alloc_for_data(intel,
 						      vb, sizeof(vb),
 						      "textured video vbo");
 
@@ -1341,7 +1341,7 @@ I965DisplayVideoTextured(ScrnInfoPtr scrn,
 	/* release reference once we're finished */
 	drm_intel_bo_unreference(surface_state_binding_table_bo);
 
-	intel_debug_flush(scrn);
+	intel_uxa_debug_flush(scrn);
 }
 
 void i965_free_video(ScrnInfoPtr scrn)
@@ -1387,7 +1387,7 @@ gen6_create_cc_state(ScrnInfoPtr scrn)
 	cc_state.constant_b = 1.0;
 	cc_state.constant_a = 1.0;
 
-	return intel_bo_alloc_for_data(intel,
+	return intel_uxa_bo_alloc_for_data(intel,
 				       &cc_state, sizeof(cc_state),
 				       "textured video cc state");
 }
@@ -1403,7 +1403,7 @@ gen6_create_blend_state(ScrnInfoPtr scrn)
 	blend_state.blend1.logic_op_func = 0xc;
 	blend_state.blend1.pre_blend_clamp_enable = 1;
 
-	return intel_bo_alloc_for_data(intel,
+	return intel_uxa_bo_alloc_for_data(intel,
 				       &blend_state, sizeof(blend_state),
 				       "textured video blend state");
 }
@@ -1415,7 +1415,7 @@ gen6_create_depth_stencil_state(ScrnInfoPtr scrn)
 	struct gen6_depth_stencil_state depth_stencil_state;
 
 	memset(&depth_stencil_state, 0, sizeof(depth_stencil_state));
-	return intel_bo_alloc_for_data(intel,
+	return intel_uxa_bo_alloc_for_data(intel,
 				       &depth_stencil_state,
 				       sizeof(depth_stencil_state),
 				       "textured video blend state");
@@ -1917,7 +1917,7 @@ void Gen6DisplayVideoTextured(ScrnInfoPtr scrn,
 		vb[i++] = (float)box_x1 + pix_xoff;
 		vb[i++] = (float)box_y1 + pix_yoff;
 
-		bo_table[0] = intel_bo_alloc_for_data(intel,
+		bo_table[0] = intel_uxa_bo_alloc_for_data(intel,
 						      vb, sizeof(vb),
 						      "video vbo");
 
@@ -1936,5 +1936,5 @@ void Gen6DisplayVideoTextured(ScrnInfoPtr scrn,
 
 	/* release reference once we're finished */
 	drm_intel_bo_unreference(surface_state_binding_table_bo);
-	intel_debug_flush(scrn);
+	intel_uxa_debug_flush(scrn);
 }
diff --git a/src/uxa/intel.h b/src/uxa/intel.h
index 8110c2e..ade8742 100644
--- a/src/uxa/intel.h
+++ b/src/uxa/intel.h
@@ -93,64 +93,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #define MAX_PIPES 4 /* consider making all users dynamic */
 
-struct intel_pixmap {
-	dri_bo *bo;
-
-	struct list batch;
-
-	uint16_t stride;
-	uint8_t tiling;
-	int8_t busy :2;
-	uint8_t dirty :1;
-	uint8_t offscreen :1;
-	uint8_t pinned :5;
-#define PIN_SCANOUT 0x1
-#define PIN_DRI2 0x2
-#define PIN_DRI3 0x4
-#define PIN_PRIME 0x8
-#define PIN_GLAMOR 0x10
-};
-
-#if HAS_DEVPRIVATEKEYREC
-extern DevPrivateKeyRec uxa_pixmap_index;
-#else
-extern int uxa_pixmap_index;
-#endif
-
-static inline struct intel_pixmap *intel_get_pixmap_private(PixmapPtr pixmap)
-{
-#if HAS_DEVPRIVATEKEYREC
-	return dixGetPrivate(&pixmap->devPrivates, &uxa_pixmap_index);
-#else
-	return dixLookupPrivate(&pixmap->devPrivates, &uxa_pixmap_index);
-#endif
-}
-
-static inline Bool intel_pixmap_is_busy(struct intel_pixmap *priv)
-{
-	if (priv->busy == -1)
-		priv->busy = drm_intel_bo_busy(priv->bo);
-	return priv->busy;
-}
-
-static inline void intel_set_pixmap_private(PixmapPtr pixmap, struct intel_pixmap *intel)
-{
-	dixSetPrivate(&pixmap->devPrivates, &uxa_pixmap_index, intel);
-}
-
-static inline Bool intel_pixmap_is_dirty(PixmapPtr pixmap)
-{
-	return pixmap && intel_get_pixmap_private(pixmap)->dirty;
-}
-
-static inline Bool intel_pixmap_tiled(PixmapPtr pixmap)
-{
-	return intel_get_pixmap_private(pixmap)->tiling != I915_TILING_NONE;
-}
-
-dri_bo *intel_get_pixmap_bo(PixmapPtr pixmap);
-void intel_set_pixmap_bo(PixmapPtr pixmap, dri_bo * bo);
-
 #include "common.h"
 
 #define PITCH_NONE 0
@@ -500,22 +442,10 @@ intel_get_screen_private(ScrnInfoPtr scrn)
 #define MIN(a,b)	((a) < (b) ? (a) : (b))
 #endif
 
-static inline unsigned long intel_pixmap_pitch(PixmapPtr pixmap)
-{
-	return (unsigned long)pixmap->devKind;
-}
-
-/* Batchbuffer support macros and functions */
-#include "intel_batchbuffer.h"
-
-/* I830 specific functions */
-extern void IntelEmitInvarientState(ScrnInfoPtr scrn);
-extern void I830EmitInvarientState(ScrnInfoPtr scrn);
-extern void I915EmitInvarientState(ScrnInfoPtr scrn);
+extern void intel_video_init(ScreenPtr pScreen);
+extern void intel_box_intersect(BoxPtr dest, BoxPtr a, BoxPtr b);
+extern void intel_crtc_box(xf86CrtcPtr crtc, BoxPtr crtc_box);
 
-extern void I830EmitFlush(ScrnInfoPtr scrn);
-
-extern void I830InitVideo(ScreenPtr pScreen);
 extern xf86CrtcPtr intel_covering_crtc(ScrnInfoPtr scrn, BoxPtr box,
 				      xf86CrtcPtr desired, BoxPtr crtc_box_ret);
 
@@ -549,170 +479,6 @@ drm_intel_bo *intel_allocate_framebuffer(ScrnInfoPtr scrn,
 					 int *out_stride,
 					 uint32_t *out_tiling);
 
-/* i830_render.c */
-Bool i830_check_composite(int op,
-			  PicturePtr sourcec, PicturePtr mask, PicturePtr dest,
-			  int width, int height);
-Bool i830_check_composite_target(PixmapPtr pixmap);
-Bool i830_check_composite_texture(ScreenPtr screen, PicturePtr picture);
-Bool i830_prepare_composite(int op, PicturePtr sourcec, PicturePtr mask,
-			    PicturePtr dest, PixmapPtr sourcecPixmap,
-			    PixmapPtr maskPixmap, PixmapPtr destPixmap);
-void i830_composite(PixmapPtr dest, int srcX, int srcY,
-		    int maskX, int maskY, int dstX, int dstY, int w, int h);
-void i830_vertex_flush(intel_screen_private *intel);
-
-/* i915_render.c */
-Bool i915_check_composite(int op,
-			  PicturePtr sourcec, PicturePtr mask, PicturePtr dest,
-			  int width, int height);
-Bool i915_check_composite_target(PixmapPtr pixmap);
-Bool i915_check_composite_texture(ScreenPtr screen, PicturePtr picture);
-Bool i915_prepare_composite(int op, PicturePtr sourcec, PicturePtr mask,
-			    PicturePtr dest, PixmapPtr sourcecPixmap,
-			    PixmapPtr maskPixmap, PixmapPtr destPixmap);
-void i915_composite(PixmapPtr dest, int srcX, int srcY,
-		    int maskX, int maskY, int dstX, int dstY, int w, int h);
-void i915_vertex_flush(intel_screen_private *intel);
-void i915_batch_commit_notify(intel_screen_private *intel);
-void i830_batch_commit_notify(intel_screen_private *intel);
-/* i965_render.c */
-unsigned int gen4_render_state_size(ScrnInfoPtr scrn);
-void gen4_render_state_init(ScrnInfoPtr scrn);
-void gen4_render_state_cleanup(ScrnInfoPtr scrn);
-Bool i965_check_composite(int op,
-			  PicturePtr sourcec, PicturePtr mask, PicturePtr dest,
-			  int width, int height);
-Bool i965_check_composite_texture(ScreenPtr screen, PicturePtr picture);
-Bool i965_prepare_composite(int op, PicturePtr sourcec, PicturePtr mask,
-			    PicturePtr dest, PixmapPtr sourcecPixmap,
-			    PixmapPtr maskPixmap, PixmapPtr destPixmap);
-void i965_composite(PixmapPtr dest, int srcX, int srcY,
-		    int maskX, int maskY, int dstX, int dstY, int w, int h);
-
-void i965_vertex_flush(intel_screen_private *intel);
-void i965_batch_flush(intel_screen_private *intel);
-void i965_batch_commit_notify(intel_screen_private *intel);
-
-/* i965_3d.c */
-void gen6_upload_invariant_states(intel_screen_private *intel);
-void gen6_upload_viewport_state_pointers(intel_screen_private *intel,
-					 drm_intel_bo *cc_vp_bo);
-void gen7_upload_viewport_state_pointers(intel_screen_private *intel,
-					 drm_intel_bo *cc_vp_bo);
-void gen6_upload_urb(intel_screen_private *intel);
-void gen7_upload_urb(intel_screen_private *intel);
-void gen6_upload_cc_state_pointers(intel_screen_private *intel,
-				   drm_intel_bo *blend_bo, drm_intel_bo *cc_bo,
-				   drm_intel_bo *depth_stencil_bo,
-				   uint32_t blend_offset);
-void gen7_upload_cc_state_pointers(intel_screen_private *intel,
-				   drm_intel_bo *blend_bo, drm_intel_bo *cc_bo,
-				   drm_intel_bo *depth_stencil_bo,
-				   uint32_t blend_offset);
-void gen6_upload_sampler_state_pointers(intel_screen_private *intel,
-					drm_intel_bo *sampler_bo);
-void gen7_upload_sampler_state_pointers(intel_screen_private *intel,
-					drm_intel_bo *sampler_bo);
-void gen7_upload_bypass_states(intel_screen_private *intel);
-void gen6_upload_gs_state(intel_screen_private *intel);
-void gen6_upload_vs_state(intel_screen_private *intel);
-void gen6_upload_clip_state(intel_screen_private *intel);
-void gen6_upload_sf_state(intel_screen_private *intel, int num_sf_outputs, int read_offset);
-void gen7_upload_sf_state(intel_screen_private *intel, int num_sf_outputs, int read_offset);
-void gen6_upload_binding_table(intel_screen_private *intel, uint32_t ps_binding_table_offset);
-void gen7_upload_binding_table(intel_screen_private *intel, uint32_t ps_binding_table_offset);
-void gen6_upload_depth_buffer_state(intel_screen_private *intel);
-void gen7_upload_depth_buffer_state(intel_screen_private *intel);
-
-Bool intel_transform_is_affine(PictTransformPtr t);
-Bool
-intel_get_transformed_coordinates(int x, int y, PictTransformPtr transform,
-				 float *x_out, float *y_out);
-
-Bool
-intel_get_transformed_coordinates_3d(int x, int y, PictTransformPtr transform,
-				    float *x_out, float *y_out, float *z_out);
-
-static inline void
-intel_debug_fallback(ScrnInfoPtr scrn, const char *format, ...) _X_ATTRIBUTE_PRINTF(2, 3);
-
-static inline void
-intel_debug_fallback(ScrnInfoPtr scrn, const char *format, ...)
-{
-	intel_screen_private *intel = intel_get_screen_private(scrn);
-	va_list ap;
-
-	va_start(ap, format);
-	if (intel->fallback_debug) {
-		xf86DrvMsg(scrn->scrnIndex, X_INFO, "fallback: ");
-		LogVMessageVerb(X_INFO, 1, format, ap);
-	}
-	va_end(ap);
-}
-
-static inline Bool
-intel_check_pitch_2d(PixmapPtr pixmap)
-{
-	uint32_t pitch = intel_pixmap_pitch(pixmap);
-	if (pitch > KB(32)) {
-		ScrnInfoPtr scrn = xf86ScreenToScrn(pixmap->drawable.pScreen);
-		intel_debug_fallback(scrn, "pitch exceeds 2d limit 32K\n");
-		return FALSE;
-	}
-	return TRUE;
-}
-
-/* For pre-965 chip only, as they have 8KB limit for 3D */
-static inline Bool
-intel_check_pitch_3d(PixmapPtr pixmap)
-{
-	uint32_t pitch = intel_pixmap_pitch(pixmap);
-	if (pitch > KB(8)) {
-		ScrnInfoPtr scrn = xf86ScreenToScrn(pixmap->drawable.pScreen);
-		intel_debug_fallback(scrn, "pitch exceeds 3d limit 8K\n");
-		return FALSE;
-	}
-	return TRUE;
-}
-
-/**
- * Little wrapper around drm_intel_bo_reloc to return the initial value you
- * should stuff into the relocation entry.
- *
- * If only we'd done this before settling on the library API.
- */
-static inline uint32_t
-intel_emit_reloc(drm_intel_bo * bo, uint32_t offset,
-		 drm_intel_bo * target_bo, uint32_t target_offset,
-		 uint32_t read_domains, uint32_t write_domain)
-{
-	drm_intel_bo_emit_reloc(bo, offset, target_bo, target_offset,
-				read_domains, write_domain);
-
-	return target_bo->offset + target_offset;
-}
-
-static inline drm_intel_bo *intel_bo_alloc_for_data(intel_screen_private *intel,
-						    const void *data,
-						    unsigned int size,
-						    const char *name)
-{
-	drm_intel_bo *bo;
-	int ret;
-
-	bo = drm_intel_bo_alloc(intel->bufmgr, name, size, 4096);
-	assert(bo);
-
-	ret = drm_intel_bo_subdata(bo, 0, size, data);
-	assert(ret == 0);
-
-	return bo;
-	(void)ret;
-}
-
-void intel_debug_flush(ScrnInfoPtr scrn);
-
 static inline PixmapPtr get_drawable_pixmap(DrawablePtr drawable)
 {
 	ScreenPtr screen = drawable->pScreen;
@@ -730,24 +496,19 @@ static inline Bool pixmap_is_scanout(PixmapPtr pixmap)
 	return pixmap == screen->GetScreenPixmap(screen);
 }
 
-Bool intel_uxa_init(ScreenPtr pScreen);
-Bool intel_uxa_create_screen_resources(ScreenPtr pScreen);
-void intel_uxa_block_handler(intel_screen_private *intel);
-Bool intel_get_aperture_space(ScrnInfoPtr scrn, drm_intel_bo ** bo_table,
-			      int num_bos);
-
-static inline Bool intel_pixmap_is_offscreen(PixmapPtr pixmap)
+static inline unsigned long
+intel_pixmap_pitch(PixmapPtr pixmap)
 {
-	struct intel_pixmap *priv = intel_get_pixmap_private(pixmap);
-	return priv && priv->offscreen;
+	return (unsigned long)pixmap->devKind;
 }
 
+/*
+ * intel_sync.c
+ */
+
 #if HAVE_DRI3
 Bool intel_sync_init(ScreenPtr screen);
 void intel_sync_close(ScreenPtr screen);
-#else
-static inline Bool intel_sync_init(ScreenPtr screen) { return 0; }
-void intel_sync_close(ScreenPtr screen);
 #endif
 
 /*
@@ -766,4 +527,12 @@ Bool intel_present_screen_init(ScreenPtr screen);
 static inline Bool intel_present_screen_init(ScreenPtr screen) { return 0; }
 #endif
 
+#include "intel_uxa.h"
+
+dri_bo *
+intel_get_pixmap_bo(PixmapPtr pixmap);
+
+void
+intel_set_pixmap_bo(PixmapPtr pixmap, dri_bo *bo);
+
 #endif /* _I830_H_ */
diff --git a/src/uxa/intel_batchbuffer.c b/src/uxa/intel_batchbuffer.c
index dedf7f8..25349fc 100644
--- a/src/uxa/intel_batchbuffer.c
+++ b/src/uxa/intel_batchbuffer.c
@@ -142,7 +142,7 @@ void intel_batch_teardown(ScrnInfoPtr scrn)
 static void intel_batch_do_flush(ScrnInfoPtr scrn)
 {
 	intel_screen_private *intel = intel_get_screen_private(scrn);
-	struct intel_pixmap *priv;
+	struct intel_uxa_pixmap *priv;
 
 	list_for_each_entry(priv, &intel->batch_pixmaps, batch)
 		priv->dirty = 0;
@@ -289,10 +289,10 @@ void intel_batch_submit(ScrnInfoPtr scrn)
 	}
 
 	while (!list_is_empty(&intel->batch_pixmaps)) {
-		struct intel_pixmap *entry;
+		struct intel_uxa_pixmap *entry;
 
 		entry = list_first_entry(&intel->batch_pixmaps,
-					 struct intel_pixmap,
+					 struct intel_uxa_pixmap,
 					 batch);
 
 		entry->busy = -1;
@@ -311,7 +311,7 @@ void intel_batch_submit(ScrnInfoPtr scrn)
 	intel->current_batch = 0;
 }
 
-void intel_debug_flush(ScrnInfoPtr scrn)
+void intel_uxa_debug_flush(ScrnInfoPtr scrn)
 {
 	intel_screen_private *intel = intel_get_screen_private(scrn);
 
diff --git a/src/uxa/intel_batchbuffer.h b/src/uxa/intel_batchbuffer.h
index 79e2ab0..e5fb8d0 100644
--- a/src/uxa/intel_batchbuffer.h
+++ b/src/uxa/intel_batchbuffer.h
@@ -129,7 +129,7 @@ intel_batch_emit_reloc(intel_screen_private *intel,
 
 static inline void
 intel_batch_mark_pixmap_domains(intel_screen_private *intel,
-				struct intel_pixmap *priv,
+				struct intel_uxa_pixmap *priv,
 				uint32_t read_domains, uint32_t write_domain)
 {
 	assert (read_domains);
@@ -149,7 +149,7 @@ intel_batch_emit_reloc_pixmap(intel_screen_private *intel, PixmapPtr pixmap,
 			      uint32_t read_domains, uint32_t write_domain,
 			      uint32_t delta, int needs_fence)
 {
-	struct intel_pixmap *priv = intel_get_pixmap_private(pixmap);
+	struct intel_uxa_pixmap *priv = intel_uxa_get_pixmap_private(pixmap);
 
 	intel_batch_mark_pixmap_domains(intel, priv, read_domains, write_domain);
 
diff --git a/src/uxa/intel_display.c b/src/uxa/intel_display.c
index bcaafaa..a4cbf00 100644
--- a/src/uxa/intel_display.c
+++ b/src/uxa/intel_display.c
@@ -2347,3 +2347,81 @@ cleanup_dst:
 cleanup_src:
 	(*pScreen->DestroyPixmap)(src);
 }
+
+void intel_box_intersect(BoxPtr dest, BoxPtr a, BoxPtr b)
+{
+	dest->x1 = a->x1 > b->x1 ? a->x1 : b->x1;
+	dest->x2 = a->x2 < b->x2 ? a->x2 : b->x2;
+	if (dest->x1 >= dest->x2) {
+		dest->x1 = dest->x2 = dest->y1 = dest->y2 = 0;
+		return;
+	}
+
+	dest->y1 = a->y1 > b->y1 ? a->y1 : b->y1;
+	dest->y2 = a->y2 < b->y2 ? a->y2 : b->y2;
+	if (dest->y1 >= dest->y2)
+		dest->x1 = dest->x2 = dest->y1 = dest->y2 = 0;
+}
+
+void intel_crtc_box(xf86CrtcPtr crtc, BoxPtr crtc_box)
+{
+	if (crtc->enabled) {
+		crtc_box->x1 = crtc->x;
+		crtc_box->x2 =
+		    crtc->x + xf86ModeWidth(&crtc->mode, crtc->rotation);
+		crtc_box->y1 = crtc->y;
+		crtc_box->y2 =
+		    crtc->y + xf86ModeHeight(&crtc->mode, crtc->rotation);
+	} else
+		crtc_box->x1 = crtc_box->x2 = crtc_box->y1 = crtc_box->y2 = 0;
+}
+
+static int intel_box_area(BoxPtr box)
+{
+	return (int)(box->x2 - box->x1) * (int)(box->y2 - box->y1);
+}
+
+/*
+ * Return the crtc covering 'box'. If two crtcs cover a portion of
+ * 'box', then prefer 'desired'. If 'desired' is NULL, then prefer the crtc
+ * with greater coverage
+ */
+
+xf86CrtcPtr
+intel_covering_crtc(ScrnInfoPtr scrn,
+		    BoxPtr box, xf86CrtcPtr desired, BoxPtr crtc_box_ret)
+{
+	xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
+	xf86CrtcPtr crtc, best_crtc;
+	int coverage, best_coverage;
+	int c;
+	BoxRec crtc_box, cover_box;
+
+	best_crtc = NULL;
+	best_coverage = 0;
+	crtc_box_ret->x1 = 0;
+	crtc_box_ret->x2 = 0;
+	crtc_box_ret->y1 = 0;
+	crtc_box_ret->y2 = 0;
+	for (c = 0; c < xf86_config->num_crtc; c++) {
+		crtc = xf86_config->crtc[c];
+
+		/* If the CRTC is off, treat it as not covering */
+		if (!intel_crtc_on(crtc))
+			continue;
+
+		intel_crtc_box(crtc, &crtc_box);
+		intel_box_intersect(&cover_box, &crtc_box, box);
+		coverage = intel_box_area(&cover_box);
+		if (coverage && crtc == desired) {
+			*crtc_box_ret = crtc_box;
+			return crtc;
+		}
+		if (coverage > best_coverage) {
+			*crtc_box_ret = crtc_box;
+			best_crtc = crtc;
+			best_coverage = coverage;
+		}
+	}
+	return best_crtc;
+}
diff --git a/src/uxa/intel_dri.c b/src/uxa/intel_dri.c
index ef66aa5..65612f7 100644
--- a/src/uxa/intel_dri.c
+++ b/src/uxa/intel_dri.c
@@ -82,7 +82,7 @@ static int i830_client_key;
 
 static uint32_t pixmap_flink(PixmapPtr pixmap)
 {
-	struct intel_pixmap *priv = intel_get_pixmap_private(pixmap);
+	struct intel_uxa_pixmap *priv = intel_uxa_get_pixmap_private(pixmap);
 	uint32_t name;
 
 	if (priv == NULL || priv->bo == NULL)
@@ -113,7 +113,7 @@ static PixmapPtr fixup_glamor(DrawablePtr drawable, PixmapPtr pixmap)
 	ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
 	intel_screen_private *intel = intel_get_screen_private(scrn);
 	PixmapPtr old = get_drawable_pixmap(drawable);
-	struct intel_pixmap *priv = intel_get_pixmap_private(pixmap);
+	struct intel_uxa_pixmap *priv = intel_uxa_get_pixmap_private(pixmap);
 	GCPtr gc;
 
 	/* With a glamor pixmap, 2D pixmaps are created in texture
@@ -140,12 +140,12 @@ static PixmapPtr fixup_glamor(DrawablePtr drawable, PixmapPtr pixmap)
 		FreeScratchGC(gc);
 	}
 
-	intel_set_pixmap_private(pixmap, NULL);
+	intel_uxa_set_pixmap_private(pixmap, NULL);
 
 	/* Exchange the underlying texture/image. */
 	intel_glamor_exchange_buffers(intel, old, pixmap);
 	/* And redirect the pixmap to the new bo (for 3D). */
-	intel_set_pixmap_private(old, priv);
+	intel_uxa_set_pixmap_private(old, priv);
 	old->refcnt++;
 
 	screen->ModifyPixmapHeader(old,
@@ -739,10 +739,10 @@ i830_dri2_del_frame_event(DRI2FrameEventPtr info)
 	free(info);
 }
 
-static struct intel_pixmap *
+static struct intel_uxa_pixmap *
 intel_exchange_pixmap_buffers(struct intel_screen_private *intel, PixmapPtr front, PixmapPtr back)
 {
-	struct intel_pixmap *new_front, *new_back;
+	struct intel_uxa_pixmap *new_front = NULL, *new_back;
 	RegionRec region;
 
 	/* Post damage on the front buffer so that listeners, such
@@ -755,10 +755,10 @@ intel_exchange_pixmap_buffers(struct intel_screen_private *intel, PixmapPtr fron
 	region.data = NULL;
 	DamageRegionAppend(&front->drawable, &region);
 
-	new_front = intel_get_pixmap_private(back);
-	new_back = intel_get_pixmap_private(front);
-	intel_set_pixmap_private(front, new_front);
-	intel_set_pixmap_private(back, new_back);
+	new_front = intel_uxa_get_pixmap_private(back);
+	new_back = intel_uxa_get_pixmap_private(front);
+	intel_uxa_set_pixmap_private(front, new_front);
+	intel_uxa_set_pixmap_private(back, new_back);
 	new_front->busy = 1;
 	new_back->busy = -1;
 
@@ -774,7 +774,7 @@ I830DRI2ExchangeBuffers(struct intel_screen_private *intel, DRI2BufferPtr front,
 {
 	I830DRI2BufferPrivatePtr front_priv, back_priv;
 	int tmp;
-	struct intel_pixmap *new_front;
+	struct intel_uxa_pixmap *new_front;
 
 	front_priv = front->driverPrivate;
 	back_priv = back->driverPrivate;
@@ -967,8 +967,8 @@ can_exchange(DrawablePtr drawable, DRI2BufferPtr front, DRI2BufferPtr back)
 	I830DRI2BufferPrivatePtr back_priv = back->driverPrivate;
 	PixmapPtr front_pixmap = front_priv->pixmap;
 	PixmapPtr back_pixmap = back_priv->pixmap;
-	struct intel_pixmap *front_intel = intel_get_pixmap_private(front_pixmap);
-	struct intel_pixmap *back_intel = intel_get_pixmap_private(back_pixmap);
+	struct intel_uxa_pixmap *front_intel = intel_uxa_get_pixmap_private(front_pixmap);
+	struct intel_uxa_pixmap *back_intel = intel_uxa_get_pixmap_private(back_pixmap);
 
 	if (!pScrn->vtSema)
 		return FALSE;
diff --git a/src/uxa/intel_dri3.c b/src/uxa/intel_dri3.c
index dc8d762..16a2463 100644
--- a/src/uxa/intel_dri3.c
+++ b/src/uxa/intel_dri3.c
@@ -56,7 +56,7 @@ static PixmapPtr intel_dri3_pixmap_from_fd(ScreenPtr screen,
 {
 	ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
 	intel_screen_private *intel = intel_get_screen_private(scrn);
-	struct intel_pixmap *priv;
+	struct intel_uxa_pixmap *priv;
 	PixmapPtr pixmap;
 	dri_bo *bo;
 
@@ -84,10 +84,10 @@ static PixmapPtr intel_dri3_pixmap_from_fd(ScreenPtr screen,
 	if (bo == NULL)
 		goto free_pixmap;
 
-	intel_set_pixmap_bo(pixmap, bo);
+	intel_uxa_set_pixmap_bo(pixmap, bo);
 	dri_bo_unreference(bo);
 
-	priv = intel_get_pixmap_private(pixmap);
+	priv = intel_uxa_get_pixmap_private(pixmap);
 	if (priv == NULL)
 		goto free_pixmap;
 
@@ -105,10 +105,10 @@ static int intel_dri3_fd_from_pixmap(ScreenPtr screen,
 				     CARD16 *stride,
 				     CARD32 *size)
 {
-	struct intel_pixmap *priv;
+	struct intel_uxa_pixmap *priv;
 	int fd;
 
-	priv = intel_get_pixmap_private(pixmap);
+	priv = intel_uxa_get_pixmap_private(pixmap);
 	if (!priv)
 		return -1;
 
diff --git a/src/uxa/intel_driver.c b/src/uxa/intel_driver.c
index a7ca906..8ab2252 100644
--- a/src/uxa/intel_driver.c
+++ b/src/uxa/intel_driver.c
@@ -169,6 +169,18 @@ static Bool i830CreateScreenResources(ScreenPtr screen)
 	return TRUE;
 }
 
+void
+intel_set_pixmap_bo(PixmapPtr pixmap, dri_bo *bo)
+{
+        intel_uxa_set_pixmap_bo(pixmap, bo);
+}
+
+dri_bo *
+intel_get_pixmap_bo(PixmapPtr pixmap)
+{
+        return intel_uxa_get_pixmap_bo(pixmap);
+}
+
 static void PreInitCleanup(ScrnInfoPtr scrn)
 {
 	if (!scrn || !scrn->driverPrivate)
@@ -612,29 +624,6 @@ static Bool I830PreInit(ScrnInfoPtr scrn, int flags)
 	return TRUE;
 }
 
-/**
- * Intialiazes the hardware for the 3D pipeline use in the 2D driver.
- *
- * Some state caching is performed to avoid redundant state emits.  This
- * function is also responsible for marking the state as clobbered for DRI
- * clients.
- */
-void IntelEmitInvarientState(ScrnInfoPtr scrn)
-{
-	intel_screen_private *intel = intel_get_screen_private(scrn);
-
-	/* If we've emitted our state since the last clobber by another client,
-	 * skip it.
-	 */
-	if (intel->last_3d != LAST_3D_OTHER)
-		return;
-
-	if (IS_GEN2(intel))
-		I830EmitInvarientState(scrn);
-	else if IS_GEN3(intel)
-		I915EmitInvarientState(scrn);
-}
-
 #ifdef INTEL_PIXMAP_SHARING
 static void
 redisplay_dirty(ScreenPtr screen, PixmapDirtyUpdatePtr dirty)
@@ -660,7 +649,7 @@ redisplay_dirty(ScreenPtr screen, PixmapDirtyUpdatePtr dirty)
 
 	intel_batch_submit(scrn);
 	if (!intel->has_prime_vmap_flush) {
-		drm_intel_bo *bo = intel_get_pixmap_bo(dirty->slave_dst->master_pixmap);
+		drm_intel_bo *bo = intel_uxa_get_pixmap_bo(dirty->slave_dst->master_pixmap);
 		was_blocked = xf86BlockSIGIO();
 		drm_intel_bo_map(bo, FALSE);
 		drm_intel_bo_unmap(bo);
@@ -1000,7 +989,7 @@ I830ScreenInit(SCREEN_INIT_ARGS_DECL)
 #endif
 	/* Init video */
 	if (intel->XvEnabled)
-		I830InitVideo(screen);
+		intel_video_init(screen);
 
 #if HAVE_DRI2
 	switch (intel->dri2) {
diff --git a/src/uxa/intel_glamor.c b/src/uxa/intel_glamor.c
index 0be87b8..21636d1 100644
--- a/src/uxa/intel_glamor.c
+++ b/src/uxa/intel_glamor.c
@@ -156,12 +156,12 @@ intel_glamor_create_textured_pixmap(PixmapPtr pixmap)
 {
 	ScrnInfoPtr scrn = xf86ScreenToScrn(pixmap->drawable.pScreen);
 	intel_screen_private *intel = intel_get_screen_private(scrn);
-	struct intel_pixmap *priv;
+	struct intel_uxa_pixmap *priv;
 
 	if ((intel->uxa_flags & UXA_USE_GLAMOR) == 0)
 		return TRUE;
 
-	priv = intel_get_pixmap_private(pixmap);
+	priv = intel_uxa_get_pixmap_private(pixmap);
 	if (glamor_egl_create_textured_pixmap(pixmap, priv->bo->handle,
 					      priv->stride)) {
 		drm_intel_bo_disable_reuse(priv->bo);
diff --git a/src/uxa/intel_uxa.c b/src/uxa/intel_uxa.c
index 5e1fbff..7ea9325 100644
--- a/src/uxa/intel_uxa.c
+++ b/src/uxa/intel_uxa.c
@@ -131,13 +131,13 @@ gen4_context_switch(intel_screen_private *intel,
 }
 
 Bool
-intel_get_aperture_space(ScrnInfoPtr scrn, drm_intel_bo ** bo_table,
+intel_uxa_get_aperture_space(ScrnInfoPtr scrn, drm_intel_bo ** bo_table,
 			 int num_bos)
 {
 	intel_screen_private *intel = intel_get_screen_private(scrn);
 
 	if (intel->batch_bo == NULL) {
-		intel_debug_fallback(scrn, "VT inactive\n");
+		intel_uxa_debug_fallback(scrn, "VT inactive\n");
 		return FALSE;
 	}
 
@@ -147,7 +147,7 @@ intel_get_aperture_space(ScrnInfoPtr scrn, drm_intel_bo ** bo_table,
 		bo_table[0] = intel->batch_bo;
 		if (drm_intel_bufmgr_check_aperture_space(bo_table, num_bos) !=
 		    0) {
-			intel_debug_fallback(scrn, "Couldn't get aperture "
+			intel_uxa_debug_fallback(scrn, "Couldn't get aperture "
 					    "space for BOs\n");
 			return FALSE;
 		}
@@ -161,7 +161,7 @@ intel_uxa_check_solid(DrawablePtr drawable, int alu, Pixel planemask)
 	ScrnInfoPtr scrn = xf86ScreenToScrn(drawable->pScreen);
 
 	if (!UXA_PM_IS_SOLID(drawable, planemask)) {
-		intel_debug_fallback(scrn, "planemask is not solid\n");
+		intel_uxa_debug_fallback(scrn, "planemask is not solid\n");
 		return FALSE;
 	}
 
@@ -187,13 +187,13 @@ intel_uxa_prepare_solid(PixmapPtr pixmap, int alu, Pixel planemask, Pixel fg)
 	intel_screen_private *intel = intel_get_screen_private(scrn);
 	drm_intel_bo *bo_table[] = {
 		NULL,		/* batch_bo */
-		intel_get_pixmap_bo(pixmap),
+		intel_uxa_get_pixmap_bo(pixmap),
 	};
 
-	if (!intel_check_pitch_2d(pixmap))
+	if (!intel_uxa_check_pitch_2d(pixmap))
 		return FALSE;
 
-	if (!intel_get_aperture_space(scrn, bo_table, ARRAY_SIZE(bo_table)))
+	if (!intel_uxa_get_aperture_space(scrn, bo_table, ARRAY_SIZE(bo_table)))
 		return FALSE;
 
 	intel->BR[13] = (I830PatternROP[alu] & 0xff) << 16;
@@ -245,7 +245,7 @@ static void intel_uxa_solid(PixmapPtr pixmap, int x1, int y1, int x2, int y2)
 			cmd |=
 			    XY_COLOR_BLT_WRITE_ALPHA | XY_COLOR_BLT_WRITE_RGB;
 
-		if (INTEL_INFO(intel)->gen >= 040 && intel_pixmap_tiled(pixmap)) {
+		if (INTEL_INFO(intel)->gen >= 040 && intel_uxa_pixmap_tiled(pixmap)) {
 			assert((pitch % 512) == 0);
 			pitch >>= 2;
 			cmd |= XY_COLOR_BLT_TILED;
@@ -274,12 +274,12 @@ intel_uxa_check_copy(PixmapPtr source, PixmapPtr dest,
 	ScrnInfoPtr scrn = xf86ScreenToScrn(dest->drawable.pScreen);
 
 	if (!UXA_PM_IS_SOLID(&source->drawable, planemask)) {
-		intel_debug_fallback(scrn, "planemask is not solid");
+		intel_uxa_debug_fallback(scrn, "planemask is not solid");
 		return FALSE;
 	}
 
 	if (source->drawable.bitsPerPixel != dest->drawable.bitsPerPixel) {
-		intel_debug_fallback(scrn, "mixed bpp copies unsupported\n");
+		intel_uxa_debug_fallback(scrn, "mixed bpp copies unsupported\n");
 		return FALSE;
 	}
 	switch (source->drawable.bitsPerPixel) {
@@ -291,9 +291,9 @@ intel_uxa_check_copy(PixmapPtr source, PixmapPtr dest,
 		return FALSE;
 	}
 
-	if (!intel_check_pitch_2d(source))
+	if (!intel_uxa_check_pitch_2d(source))
 		return FALSE;
-	if (!intel_check_pitch_2d(dest))
+	if (!intel_uxa_check_pitch_2d(dest))
 		return FALSE;
 
 	return TRUE;
@@ -307,11 +307,11 @@ intel_uxa_prepare_copy(PixmapPtr source, PixmapPtr dest, int xdir,
 	intel_screen_private *intel = intel_get_screen_private(scrn);
 	drm_intel_bo *bo_table[] = {
 		NULL,		/* batch_bo */
-		intel_get_pixmap_bo(source),
-		intel_get_pixmap_bo(dest),
+		intel_uxa_get_pixmap_bo(source),
+		intel_uxa_get_pixmap_bo(dest),
 	};
 
-	if (!intel_get_aperture_space(scrn, bo_table, ARRAY_SIZE(bo_table)))
+	if (!intel_uxa_get_aperture_space(scrn, bo_table, ARRAY_SIZE(bo_table)))
 		return FALSE;
 
 	intel->render_source = source;
@@ -386,13 +386,13 @@ intel_uxa_copy(PixmapPtr dest, int src_x1, int src_y1, int dst_x1,
 			    XY_SRC_COPY_BLT_WRITE_RGB;
 
 		if (INTEL_INFO(intel)->gen >= 040) {
-			if (intel_pixmap_tiled(dest)) {
+			if (intel_uxa_pixmap_tiled(dest)) {
 				assert((dst_pitch % 512) == 0);
 				dst_pitch >>= 2;
 				cmd |= XY_SRC_COPY_BLT_DST_TILED;
 			}
 
-			if (intel_pixmap_tiled(intel->render_source)) {
+			if (intel_uxa_pixmap_tiled(intel->render_source)) {
 				assert((src_pitch % 512) == 0);
 				src_pitch >>= 2;
 				cmd |= XY_SRC_COPY_BLT_SRC_TILED;
@@ -432,7 +432,7 @@ static void intel_uxa_done(PixmapPtr pixmap)
 		ADVANCE_BATCH();
 	}
 
-	intel_debug_flush(scrn);
+	intel_uxa_debug_flush(scrn);
 }
 
 /**
@@ -448,7 +448,7 @@ static void i830_done_composite(PixmapPtr dest)
 	if (intel->vertex_flush)
 		intel->vertex_flush(intel);
 
-	intel_debug_flush(scrn);
+	intel_uxa_debug_flush(scrn);
 }
 
 #define xFixedToFloat(val) \
@@ -476,7 +476,7 @@ _intel_transform_point(PictTransformPtr transform,
  * transform may be null.
  */
 Bool
-intel_get_transformed_coordinates(int x, int y, PictTransformPtr transform,
+intel_uxa_get_transformed_coordinates(int x, int y, PictTransformPtr transform,
 				  float *x_out, float *y_out)
 {
 	if (transform == NULL) {
@@ -501,7 +501,7 @@ intel_get_transformed_coordinates(int x, int y, PictTransformPtr transform,
  * transform may be null.
  */
 Bool
-intel_get_transformed_coordinates_3d(int x, int y, PictTransformPtr transform,
+intel_uxa_get_transformed_coordinates_3d(int x, int y, PictTransformPtr transform,
 				     float *x_out, float *y_out, float *w_out)
 {
 	if (transform == NULL) {
@@ -527,18 +527,18 @@ intel_get_transformed_coordinates_3d(int x, int y, PictTransformPtr transform,
  *
  * transform may be null.
  */
-Bool intel_transform_is_affine(PictTransformPtr t)
+Bool intel_uxa_transform_is_affine(PictTransformPtr t)
 {
 	if (t == NULL)
 		return TRUE;
 	return t->matrix[2][0] == 0 && t->matrix[2][1] == 0;
 }
 
-dri_bo *intel_get_pixmap_bo(PixmapPtr pixmap)
+dri_bo *intel_uxa_get_pixmap_bo(PixmapPtr pixmap)
 {
-	struct intel_pixmap *intel;
+	struct intel_uxa_pixmap *intel;
 
-	intel = intel_get_pixmap_private(pixmap);
+	intel = intel_uxa_get_pixmap_private(pixmap);
 	if (intel == NULL)
 		return NULL;
 
@@ -562,13 +562,13 @@ static unsigned intel_get_tile_width(intel_screen_private *intel, int tiling, in
 	return tile_width;
 }
 
-void intel_set_pixmap_bo(PixmapPtr pixmap, dri_bo * bo)
+void intel_uxa_set_pixmap_bo(PixmapPtr pixmap, dri_bo * bo)
 {
 	ScrnInfoPtr scrn = xf86ScreenToScrn(pixmap->drawable.pScreen);
 	intel_screen_private *intel = intel_get_screen_private(scrn);
-	struct intel_pixmap *priv;
+	struct intel_uxa_pixmap *priv;
 
-	priv = intel_get_pixmap_private(pixmap);
+	priv = intel_uxa_get_pixmap_private(pixmap);
 	if (priv == NULL && bo == NULL)
 		return;
 
@@ -587,9 +587,9 @@ free_priv:
 	if (bo != NULL) {
 		uint32_t tiling, swizzle_mode;
 		unsigned tile_width;
-		int size, stride;
+		int stride;
 
-		priv = calloc(1, sizeof (struct intel_pixmap));
+		priv = calloc(1, sizeof (struct intel_uxa_pixmap));
 		if (priv == NULL)
 			goto BAIL;
 
@@ -649,19 +649,14 @@ free_priv:
 	}
 
   BAIL:
-	intel_set_pixmap_private(pixmap, priv);
-}
-
-static Bool intel_uxa_pixmap_is_offscreen(PixmapPtr pixmap)
-{
-	return intel_pixmap_is_offscreen(pixmap);
+	intel_uxa_set_pixmap_private(pixmap, priv);
 }
 
 static Bool intel_uxa_prepare_access(PixmapPtr pixmap, uxa_access_t access)
 {
 	ScrnInfoPtr scrn = xf86ScreenToScrn(pixmap->drawable.pScreen);
 	intel_screen_private *intel = intel_get_screen_private(scrn);
-	struct intel_pixmap *priv = intel_get_pixmap_private(pixmap);
+	struct intel_uxa_pixmap *priv = intel_uxa_get_pixmap_private(pixmap);
 	dri_bo *bo = priv->bo;
 	int ret;
 
@@ -698,12 +693,12 @@ static Bool intel_uxa_prepare_access(PixmapPtr pixmap, uxa_access_t access)
 
 static void intel_uxa_finish_access(PixmapPtr pixmap, uxa_access_t access)
 {
-	struct intel_pixmap *priv;
+	struct intel_uxa_pixmap *priv;
 
 	if (access == UXA_GLAMOR_ACCESS_RW || access == UXA_GLAMOR_ACCESS_RO)
 		return;
 
-	priv = intel_get_pixmap_private(pixmap);
+	priv = intel_uxa_get_pixmap_private(pixmap);
 	if (priv == NULL)
 		return;
 
@@ -715,7 +710,7 @@ static Bool intel_uxa_pixmap_put_image(PixmapPtr pixmap,
 				       char *src, int src_pitch,
 				       int x, int y, int w, int h)
 {
-	struct intel_pixmap *priv = intel_get_pixmap_private(pixmap);
+	struct intel_uxa_pixmap *priv = intel_uxa_get_pixmap_private(pixmap);
 	int stride = intel_pixmap_pitch(pixmap);
 	int cpp = pixmap->drawable.bitsPerPixel/8;
 	int ret = FALSE;
@@ -750,10 +745,10 @@ static Bool intel_uxa_put_image(PixmapPtr pixmap,
 				int w, int h,
 				char *src, int src_pitch)
 {
-	struct intel_pixmap *priv;
+	struct intel_uxa_pixmap *priv;
 
-	priv = intel_get_pixmap_private(pixmap);
-	if (!intel_pixmap_is_busy(priv)) {
+	priv = intel_uxa_get_pixmap_private(pixmap);
+	if (!intel_uxa_pixmap_is_busy(priv)) {
 		/* bo is not busy so can be replaced without a stall, upload in-place. */
 		return intel_uxa_pixmap_put_image(pixmap, src, src_pitch, x, y, w, h);
 	} else {
@@ -790,7 +785,7 @@ static Bool intel_uxa_put_image(PixmapPtr pixmap,
 						   w, h,
 						   0, 0,
 						   stride, NULL);
-			intel_set_pixmap_bo(pixmap, bo);
+			intel_uxa_set_pixmap_bo(pixmap, bo);
 			dri_bo_unreference(bo);
 
 			return intel_uxa_pixmap_put_image(pixmap, src, src_pitch, 0, 0, w, h);
@@ -837,7 +832,7 @@ static Bool intel_uxa_pixmap_get_image(PixmapPtr pixmap,
 				       int x, int y, int w, int h,
 				       char *dst, int dst_pitch)
 {
-	struct intel_pixmap *priv = intel_get_pixmap_private(pixmap);
+	struct intel_uxa_pixmap *priv = intel_uxa_get_pixmap_private(pixmap);
 	int stride = intel_pixmap_pitch(pixmap);
 	int cpp = pixmap->drawable.bitsPerPixel/8;
 
@@ -869,7 +864,7 @@ static Bool intel_uxa_get_image(PixmapPtr pixmap,
 				int w, int h,
 				char *dst, int dst_pitch)
 {
-	struct intel_pixmap *priv;
+	struct intel_uxa_pixmap *priv;
 	PixmapPtr scratch = NULL;
 	Bool ret;
 
@@ -880,8 +875,8 @@ static Bool intel_uxa_get_image(PixmapPtr pixmap,
 	 * Also the gpu is much faster at detiling.
 	 */
 
-	priv = intel_get_pixmap_private(pixmap);
-	if (intel_pixmap_is_busy(priv) || priv->tiling != I915_TILING_NONE) {
+	priv = intel_uxa_get_pixmap_private(pixmap);
+	if (intel_uxa_pixmap_is_busy(priv) || priv->tiling != I915_TILING_NONE) {
 		ScreenPtr screen = pixmap->drawable.pScreen;
 		GCPtr gc;
 
@@ -983,7 +978,7 @@ intel_uxa_create_pixmap(ScreenPtr screen, int w, int h, int depth,
 {
 	ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
 	intel_screen_private *intel = intel_get_screen_private(scrn);
-	struct intel_pixmap *priv;
+	struct intel_uxa_pixmap *priv;
 	PixmapPtr pixmap, new_pixmap = NULL;
 
 	if (!(usage & INTEL_CREATE_PIXMAP_DRI2)) {
@@ -1044,7 +1039,7 @@ intel_uxa_create_pixmap(ScreenPtr screen, int w, int h, int depth,
 		if (size > intel->max_bo_size || stride >= KB(32))
 			goto fallback_pixmap;
 
-		priv = calloc(1, sizeof (struct intel_pixmap));
+		priv = calloc(1, sizeof (struct intel_uxa_pixmap));
 		if (priv == NULL)
 			goto fallback_pixmap;
 
@@ -1068,7 +1063,7 @@ intel_uxa_create_pixmap(ScreenPtr screen, int w, int h, int depth,
 		priv->offscreen = 1;
 
 		list_init(&priv->batch);
-		intel_set_pixmap_private(pixmap, priv);
+		intel_uxa_set_pixmap_private(pixmap, priv);
 
 		screen->ModifyPixmapHeader(pixmap, w, h, 0, 0, stride, NULL);
 
@@ -1114,7 +1109,7 @@ static Bool intel_uxa_destroy_pixmap(PixmapPtr pixmap)
 {
 	if (pixmap->refcnt == 1) {
 		intel_glamor_destroy_pixmap(pixmap);
-		intel_set_pixmap_bo(pixmap, NULL);
+		intel_uxa_set_pixmap_bo(pixmap, NULL);
 	}
 	fbDestroyPixmap(pixmap);
 	return TRUE;
@@ -1147,14 +1142,14 @@ Bool intel_uxa_create_screen_resources(ScreenPtr screen)
 					NULL))
 		return FALSE;
 
-	intel_set_pixmap_bo(pixmap, bo);
-	if (intel_get_pixmap_private(pixmap) == NULL)
+	intel_uxa_set_pixmap_bo(pixmap, bo);
+	if (intel_uxa_get_pixmap_private(pixmap) == NULL)
 		goto err;
 
 	if (!intel_glamor_create_screen_resources(screen))
 		goto err;
 
-	intel_get_pixmap_private(pixmap)->pinned |= PIN_SCANOUT;
+	intel_uxa_get_pixmap_private(pixmap)->pinned |= PIN_SCANOUT;
 	scrn->displayWidth = intel->front_pitch / intel->cpp;
 
 	return TRUE;
@@ -1171,9 +1166,9 @@ intel_uxa_share_pixmap_backing(PixmapPtr ppix, ScreenPtr slave, void **fd_handle
 {
 	ScrnInfoPtr scrn = xf86ScreenToScrn(ppix->drawable.pScreen);
 	intel_screen_private *intel = intel_get_screen_private(scrn);
-	struct intel_pixmap *priv = intel_get_pixmap_private(ppix);
+	struct intel_uxa_pixmap *priv = intel_uxa_get_pixmap_private(ppix);
 	unsigned int size, tiling, swizzle;
-	dri_bo *bo = intel_get_pixmap_bo(ppix), *newbo;
+	dri_bo *bo = intel_uxa_get_pixmap_bo(ppix), *newbo;
 	int stride;
 	int handle;
 
@@ -1201,7 +1196,7 @@ intel_uxa_share_pixmap_backing(PixmapPtr ppix, ScreenPtr slave, void **fd_handle
 			drm_intel_bo_set_tiling(newbo, &tiling, stride);
 		priv->stride = stride;
 		priv->tiling = tiling;
-		intel_set_pixmap_bo(ppix, newbo);
+		intel_uxa_set_pixmap_bo(ppix, newbo);
 
 		ppix->drawable.pScreen->ModifyPixmapHeader(ppix, ppix->drawable.width,
 					   ppix->drawable.height, 0, 0,
@@ -1229,7 +1224,7 @@ intel_uxa_set_shared_pixmap_backing(PixmapPtr ppix, void *fd_handle)
 	if (!bo)
 		return FALSE;
 
-	intel_set_pixmap_bo(ppix, bo);
+	intel_uxa_set_pixmap_bo(ppix, bo);
 	close(ihandle);
 	return TRUE;
 }
@@ -1298,6 +1293,29 @@ static Bool intel_option_accel_blt(intel_screen_private *intel)
 	return strcasecmp(s, "blt") == 0;
 }
 
+/**
+ * Intialiazes the hardware for the 3D pipeline use in the 2D driver.
+ *
+ * Some state caching is performed to avoid redundant state emits.  This
+ * function is also responsible for marking the state as clobbered for DRI
+ * clients.
+ */
+void IntelEmitInvarientState(ScrnInfoPtr scrn)
+{
+	intel_screen_private *intel = intel_get_screen_private(scrn);
+
+	/* If we've emitted our state since the last clobber by another client,
+	 * skip it.
+	 */
+	if (intel->last_3d != LAST_3D_OTHER)
+		return;
+
+	if (IS_GEN2(intel))
+		I830EmitInvarientState(scrn);
+	else if IS_GEN3(intel)
+		I915EmitInvarientState(scrn);
+}
+
 Bool intel_uxa_init(ScreenPtr screen)
 {
 	ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
diff --git a/src/uxa/intel_uxa.h b/src/uxa/intel_uxa.h
new file mode 100644
index 0000000..34903a3
--- /dev/null
+++ b/src/uxa/intel_uxa.h
@@ -0,0 +1,300 @@
+/*
+ * Copyright © 2014 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * that the name of the copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission.  The copyright holders make no representations
+ * about the suitability of this software for any purpose.  It is provided "as
+ * is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#ifndef _INTEL_UXA_H_
+#define _INTEL_UXA_H_
+
+#include "intel_video.h"
+
+struct intel_uxa_pixmap {
+	dri_bo *bo;
+
+	struct list batch;
+
+	uint16_t stride;
+	uint8_t tiling;
+	int8_t busy :2;
+	uint8_t dirty :1;
+	uint8_t offscreen :1;
+	uint8_t pinned :5;
+#define PIN_SCANOUT 0x1
+#define PIN_DRI2 0x2
+#define PIN_DRI3 0x4
+#define PIN_PRIME 0x8
+#define PIN_GLAMOR 0x10
+};
+
+#if HAS_DEVPRIVATEKEYREC
+extern DevPrivateKeyRec uxa_pixmap_index;
+#else
+extern int uxa_pixmap_index;
+#endif
+
+static inline struct intel_uxa_pixmap *intel_uxa_get_pixmap_private(PixmapPtr pixmap)
+{
+#if HAS_DEVPRIVATEKEYREC
+	return dixGetPrivate(&pixmap->devPrivates, &uxa_pixmap_index);
+#else
+	return dixLookupPrivate(&pixmap->devPrivates, &uxa_pixmap_index);
+#endif
+}
+
+static inline Bool intel_uxa_pixmap_is_busy(struct intel_uxa_pixmap *priv)
+{
+	if (priv->busy == -1)
+		priv->busy = drm_intel_bo_busy(priv->bo);
+	return priv->busy;
+}
+
+static inline void intel_uxa_set_pixmap_private(PixmapPtr pixmap, struct intel_uxa_pixmap *intel)
+{
+	dixSetPrivate(&pixmap->devPrivates, &uxa_pixmap_index, intel);
+}
+
+static inline Bool intel_uxa_pixmap_is_dirty(PixmapPtr pixmap)
+{
+	return pixmap && intel_uxa_get_pixmap_private(pixmap)->dirty;
+}
+
+static inline Bool intel_uxa_pixmap_tiled(PixmapPtr pixmap)
+{
+	return intel_uxa_get_pixmap_private(pixmap)->tiling != I915_TILING_NONE;
+}
+
+dri_bo *intel_uxa_get_pixmap_bo(PixmapPtr pixmap);
+void intel_uxa_set_pixmap_bo(PixmapPtr pixmap, dri_bo * bo);
+
+Bool intel_uxa_init(ScreenPtr pScreen);
+Bool intel_uxa_create_screen_resources(ScreenPtr pScreen);
+void intel_uxa_block_handler(intel_screen_private *intel);
+
+static inline Bool intel_uxa_pixmap_is_offscreen(PixmapPtr pixmap)
+{
+	struct intel_uxa_pixmap *priv = intel_uxa_get_pixmap_private(pixmap);
+	return priv && priv->offscreen;
+}
+
+/* Batchbuffer support macros and functions */
+#include "intel_batchbuffer.h"
+
+/* I830 specific functions */
+extern void IntelEmitInvarientState(ScrnInfoPtr scrn);
+extern void I830EmitInvarientState(ScrnInfoPtr scrn);
+extern void I915EmitInvarientState(ScrnInfoPtr scrn);
+
+extern void I830EmitFlush(ScrnInfoPtr scrn);
+
+/* i830_render.c */
+Bool i830_check_composite(int op,
+			  PicturePtr sourcec, PicturePtr mask, PicturePtr dest,
+			  int width, int height);
+Bool i830_check_composite_target(PixmapPtr pixmap);
+Bool i830_check_composite_texture(ScreenPtr screen, PicturePtr picture);
+Bool i830_prepare_composite(int op, PicturePtr sourcec, PicturePtr mask,
+			    PicturePtr dest, PixmapPtr sourcecPixmap,
+			    PixmapPtr maskPixmap, PixmapPtr destPixmap);
+void i830_composite(PixmapPtr dest, int srcX, int srcY,
+		    int maskX, int maskY, int dstX, int dstY, int w, int h);
+void i830_vertex_flush(intel_screen_private *intel);
+
+/* i915_render.c */
+Bool i915_check_composite(int op,
+			  PicturePtr sourcec, PicturePtr mask, PicturePtr dest,
+			  int width, int height);
+Bool i915_check_composite_target(PixmapPtr pixmap);
+Bool i915_check_composite_texture(ScreenPtr screen, PicturePtr picture);
+Bool i915_prepare_composite(int op, PicturePtr sourcec, PicturePtr mask,
+			    PicturePtr dest, PixmapPtr sourcecPixmap,
+			    PixmapPtr maskPixmap, PixmapPtr destPixmap);
+void i915_composite(PixmapPtr dest, int srcX, int srcY,
+		    int maskX, int maskY, int dstX, int dstY, int w, int h);
+void i915_vertex_flush(intel_screen_private *intel);
+void i915_batch_commit_notify(intel_screen_private *intel);
+void i830_batch_commit_notify(intel_screen_private *intel);
+/* i965_render.c */
+unsigned int gen4_render_state_size(ScrnInfoPtr scrn);
+void gen4_render_state_init(ScrnInfoPtr scrn);
+void gen4_render_state_cleanup(ScrnInfoPtr scrn);
+Bool i965_check_composite(int op,
+			  PicturePtr sourcec, PicturePtr mask, PicturePtr dest,
+			  int width, int height);
+Bool i965_check_composite_texture(ScreenPtr screen, PicturePtr picture);
+Bool i965_prepare_composite(int op, PicturePtr sourcec, PicturePtr mask,
+			    PicturePtr dest, PixmapPtr sourcecPixmap,
+			    PixmapPtr maskPixmap, PixmapPtr destPixmap);
+void i965_composite(PixmapPtr dest, int srcX, int srcY,
+		    int maskX, int maskY, int dstX, int dstY, int w, int h);
+
+void i965_vertex_flush(intel_screen_private *intel);
+void i965_batch_flush(intel_screen_private *intel);
+void i965_batch_commit_notify(intel_screen_private *intel);
+
+/* i965_3d.c */
+void gen6_upload_invariant_states(intel_screen_private *intel);
+void gen6_upload_viewport_state_pointers(intel_screen_private *intel,
+					 drm_intel_bo *cc_vp_bo);
+void gen7_upload_viewport_state_pointers(intel_screen_private *intel,
+					 drm_intel_bo *cc_vp_bo);
+void gen6_upload_urb(intel_screen_private *intel);
+void gen7_upload_urb(intel_screen_private *intel);
+void gen6_upload_cc_state_pointers(intel_screen_private *intel,
+				   drm_intel_bo *blend_bo, drm_intel_bo *cc_bo,
+				   drm_intel_bo *depth_stencil_bo,
+				   uint32_t blend_offset);
+void gen7_upload_cc_state_pointers(intel_screen_private *intel,
+				   drm_intel_bo *blend_bo, drm_intel_bo *cc_bo,
+				   drm_intel_bo *depth_stencil_bo,
+				   uint32_t blend_offset);
+void gen6_upload_sampler_state_pointers(intel_screen_private *intel,
+					drm_intel_bo *sampler_bo);
+void gen7_upload_sampler_state_pointers(intel_screen_private *intel,
+					drm_intel_bo *sampler_bo);
+void gen7_upload_bypass_states(intel_screen_private *intel);
+void gen6_upload_gs_state(intel_screen_private *intel);
+void gen6_upload_vs_state(intel_screen_private *intel);
+void gen6_upload_clip_state(intel_screen_private *intel);
+void gen6_upload_sf_state(intel_screen_private *intel, int num_sf_outputs, int read_offset);
+void gen7_upload_sf_state(intel_screen_private *intel, int num_sf_outputs, int read_offset);
+void gen6_upload_binding_table(intel_screen_private *intel, uint32_t ps_binding_table_offset);
+void gen7_upload_binding_table(intel_screen_private *intel, uint32_t ps_binding_table_offset);
+void gen6_upload_depth_buffer_state(intel_screen_private *intel);
+void gen7_upload_depth_buffer_state(intel_screen_private *intel);
+
+Bool intel_uxa_transform_is_affine(PictTransformPtr t);
+
+Bool
+intel_uxa_get_transformed_coordinates(int x, int y, PictTransformPtr transform,
+				 float *x_out, float *y_out);
+
+Bool
+intel_uxa_get_transformed_coordinates_3d(int x, int y, PictTransformPtr transform,
+				    float *x_out, float *y_out, float *z_out);
+
+static inline void
+intel_uxa_debug_fallback(ScrnInfoPtr scrn, const char *format, ...) _X_ATTRIBUTE_PRINTF(2, 3);
+
+static inline void
+intel_uxa_debug_fallback(ScrnInfoPtr scrn, const char *format, ...)
+{
+	intel_screen_private *intel = intel_get_screen_private(scrn);
+	va_list ap;
+
+	va_start(ap, format);
+	if (intel->fallback_debug) {
+		xf86DrvMsg(scrn->scrnIndex, X_INFO, "fallback: ");
+		LogVMessageVerb(X_INFO, 1, format, ap);
+	}
+	va_end(ap);
+}
+
+static inline Bool
+intel_uxa_check_pitch_2d(PixmapPtr pixmap)
+{
+	uint32_t pitch = intel_pixmap_pitch(pixmap);
+	if (pitch > KB(32)) {
+		ScrnInfoPtr scrn = xf86ScreenToScrn(pixmap->drawable.pScreen);
+		intel_uxa_debug_fallback(scrn, "pitch exceeds 2d limit 32K\n");
+		return FALSE;
+	}
+	return TRUE;
+}
+
+/* For pre-965 chip only, as they have 8KB limit for 3D */
+static inline Bool
+intel_uxa_check_pitch_3d(PixmapPtr pixmap)
+{
+	uint32_t pitch = intel_pixmap_pitch(pixmap);
+	if (pitch > KB(8)) {
+		ScrnInfoPtr scrn = xf86ScreenToScrn(pixmap->drawable.pScreen);
+		intel_uxa_debug_fallback(scrn, "pitch exceeds 3d limit 8K\n");
+		return FALSE;
+	}
+	return TRUE;
+}
+
+/**
+ * Little wrapper around drm_intel_bo_reloc to return the initial value you
+ * should stuff into the relocation entry.
+ *
+ * If only we'd done this before settling on the library API.
+ */
+static inline uint32_t
+intel_uxa_emit_reloc(drm_intel_bo * bo, uint32_t offset,
+		 drm_intel_bo * target_bo, uint32_t target_offset,
+		 uint32_t read_domains, uint32_t write_domain)
+{
+	drm_intel_bo_emit_reloc(bo, offset, target_bo, target_offset,
+				read_domains, write_domain);
+
+	return target_bo->offset + target_offset;
+}
+
+static inline drm_intel_bo *intel_uxa_bo_alloc_for_data(intel_screen_private *intel,
+						    const void *data,
+						    unsigned int size,
+						    const char *name)
+{
+	drm_intel_bo *bo;
+	int ret;
+
+	bo = drm_intel_bo_alloc(intel->bufmgr, name, size, 4096);
+	assert(bo);
+
+	ret = drm_intel_bo_subdata(bo, 0, size, data);
+	assert(ret == 0);
+
+	return bo;
+	(void)ret;
+}
+
+void intel_uxa_debug_flush(ScrnInfoPtr scrn);
+
+
+Bool intel_uxa_get_aperture_space(ScrnInfoPtr scrn, drm_intel_bo ** bo_table,
+                                  int num_bos);
+
+XF86VideoAdaptorPtr intel_uxa_video_setup_image_textured(ScreenPtr screen);
+
+void I915DisplayVideoTextured(ScrnInfoPtr scrn,
+			      intel_adaptor_private *adaptor_priv,
+			      int id, RegionPtr dstRegion, short width,
+			      short height, int video_pitch, int video_pitch2,
+			      short src_w, short src_h,
+			      short drw_w, short drw_h, PixmapPtr pixmap);
+
+void I965DisplayVideoTextured(ScrnInfoPtr scrn,
+			      intel_adaptor_private *adaptor_priv,
+			      int id, RegionPtr dstRegion, short width,
+			      short height, int video_pitch, int video_pitch2,
+			      short src_w, short src_h,
+			      short drw_w, short drw_h, PixmapPtr pixmap);
+
+void Gen6DisplayVideoTextured(ScrnInfoPtr scrn,
+			      intel_adaptor_private *adaptor_priv,
+			      int id, RegionPtr dstRegion, short width,
+			      short height, int video_pitch, int video_pitch2,
+			      short src_w, short src_h,
+			      short drw_w, short drw_h, PixmapPtr pixmap);
+
+void i965_free_video(ScrnInfoPtr scrn);
+
+#endif /* _INTEL_UXA_H_ */
diff --git a/src/uxa/intel_uxa_video.c b/src/uxa/intel_uxa_video.c
new file mode 100644
index 0000000..7ff909f
--- /dev/null
+++ b/src/uxa/intel_uxa_video.c
@@ -0,0 +1,389 @@
+/***************************************************************************
+
+ Copyright 2000 Intel Corporation.  All Rights Reserved.
+
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sub license, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice (including the
+ next paragraph) shall be included in all copies or substantial portions
+ of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ IN NO EVENT SHALL INTEL, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
+ THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+ **************************************************************************/
+
+/*
+ * i830_video.c: i830/i845 Xv driver.
+ *
+ * Copyright © 2002 by Alan Hourihane and David Dawes
+ *
+ * Authors:
+ *	Alan Hourihane <alanh@tungstengraphics.com>
+ *	David Dawes <dawes@xfree86.org>
+ *
+ * Derived from i810 Xv driver:
+ *
+ * Authors of i810 code:
+ * 	Jonathan Bian <jonathan.bian@intel.com>
+ *      Offscreen Images:
+ *        Matt Sottek <matthew.j.sottek@intel.com>
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <inttypes.h>
+#include <math.h>
+#include <string.h>
+#include <assert.h>
+#include <errno.h>
+
+#include "xorg-server.h"
+#include "xf86.h"
+#include "xf86_OSproc.h"
+#include "compiler.h"
+#include "xf86Pci.h"
+#include "xf86fbman.h"
+#include "xf86drm.h"
+#include "regionstr.h"
+#include "randrstr.h"
+#include "windowstr.h"
+#include "damage.h"
+#include "intel.h"
+#include "intel_video.h"
+#include "i830_reg.h"
+#include "xf86xv.h"
+#include <X11/extensions/Xv.h>
+#include "dixstruct.h"
+#include "fourcc.h"
+
+#ifdef INTEL_XVMC
+#define _INTEL_XVMC_SERVER_
+#include "intel_xvmc.h"
+#endif
+#include "intel_glamor.h"
+
+/* overlay debugging printf function */
+#if 0
+#define UXA_VIDEO_DEBUG ErrorF
+#else
+#define UXA_VIDEO_DEBUG if (0) ErrorF
+#endif
+
+static int intel_uxa_video_put_image_textured(ScrnInfoPtr, short, short, short, short, short, short,
+			short, short, int, unsigned char *, short, short,
+			Bool, RegionPtr, pointer, DrawablePtr);
+
+static int
+intel_uxa_video_set_port_attribute(ScrnInfoPtr scrn,
+			     Atom attribute, INT32 value, pointer data)
+{
+	intel_adaptor_private *adaptor_priv = (intel_adaptor_private *) data;
+
+	if (attribute == intel_xv_Brightness) {
+		if ((value < -128) || (value > 127))
+			return BadValue;
+		adaptor_priv->brightness = value;
+		return Success;
+	} else if (attribute == intel_xv_Contrast) {
+		if ((value < 0) || (value > 255))
+			return BadValue;
+		adaptor_priv->contrast = value;
+		return Success;
+	} else if (attribute == intel_xv_SyncToVblank) {
+		if ((value < -1) || (value > 1))
+			return BadValue;
+		adaptor_priv->SyncToVblank = value;
+		return Success;
+	} else {
+		return BadMatch;
+	}
+}
+
+
+static int xvmc_passthrough(int id)
+{
+#ifdef INTEL_XVMC
+	return id == FOURCC_XVMC;
+#else
+	return 0;
+#endif
+}
+
+
+static void
+intel_wait_for_scanline(ScrnInfoPtr scrn, PixmapPtr pixmap,
+			xf86CrtcPtr crtc, RegionPtr clipBoxes)
+{
+	intel_screen_private *intel = intel_get_screen_private(scrn);
+	pixman_box16_t box, crtc_box;
+	int pipe, event;
+	Bool full_height;
+	int y1, y2;
+
+	pipe = -1;
+	if (scrn->vtSema && pixmap_is_scanout(pixmap))
+		pipe = intel_crtc_to_pipe(crtc);
+	if (pipe < 0)
+		return;
+
+	box = *REGION_EXTENTS(unused, clipBoxes);
+
+	if (crtc->transform_in_use)
+		pixman_f_transform_bounds(&crtc->f_framebuffer_to_crtc, &box);
+
+	/* We could presume the clip was correctly computed... */
+	intel_crtc_box(crtc, &crtc_box);
+	intel_box_intersect(&box, &crtc_box, &box);
+
+	/*
+	 * Make sure we don't wait for a scanline that will
+	 * never occur
+	 */
+	y1 = (crtc_box.y1 <= box.y1) ? box.y1 - crtc_box.y1 : 0;
+	y2 = (box.y2 <= crtc_box.y2) ?
+		box.y2 - crtc_box.y1 : crtc_box.y2 - crtc_box.y1;
+	if (y2 <= y1)
+		return;
+
+	full_height = FALSE;
+	if (y1 == 0 && y2 == (crtc_box.y2 - crtc_box.y1))
+		full_height = TRUE;
+
+	/*
+	 * Pre-965 doesn't have SVBLANK, so we need a bit
+	 * of extra time for the blitter to start up and
+	 * do its job for a full height blit
+	 */
+	if (full_height && INTEL_INFO(intel)->gen < 040)
+		y2 -= 2;
+
+	if (pipe == 0) {
+		pipe = MI_LOAD_SCAN_LINES_DISPLAY_PIPEA;
+		event = MI_WAIT_FOR_PIPEA_SCAN_LINE_WINDOW;
+		if (full_height && INTEL_INFO(intel)->gen >= 040)
+			event = MI_WAIT_FOR_PIPEA_SVBLANK;
+	} else {
+		pipe = MI_LOAD_SCAN_LINES_DISPLAY_PIPEB;
+		event = MI_WAIT_FOR_PIPEB_SCAN_LINE_WINDOW;
+		if (full_height && INTEL_INFO(intel)->gen >= 040)
+			event = MI_WAIT_FOR_PIPEB_SVBLANK;
+	}
+
+	if (crtc->mode.Flags & V_INTERLACE) {
+		/* DSL count field lines */
+		y1 /= 2;
+		y2 /= 2;
+	}
+
+	BEGIN_BATCH(5);
+	/* The documentation says that the LOAD_SCAN_LINES command
+	 * always comes in pairs. Don't ask me why. */
+	OUT_BATCH(MI_LOAD_SCAN_LINES_INCL | pipe);
+	OUT_BATCH((y1 << 16) | (y2-1));
+	OUT_BATCH(MI_LOAD_SCAN_LINES_INCL | pipe);
+	OUT_BATCH((y1 << 16) | (y2-1));
+	OUT_BATCH(MI_WAIT_FOR_EVENT | event);
+	ADVANCE_BATCH();
+}
+
+/*
+ * The source rectangle of the video is defined by (src_x, src_y, src_w, src_h).
+ * The dest rectangle of the video is defined by (drw_x, drw_y, drw_w, drw_h).
+ * id is a fourcc code for the format of the video.
+ * buf is the pointer to the source data in system memory.
+ * width and height are the w/h of the source data.
+ * If "sync" is TRUE, then we must be finished with *buf at the point of return
+ * (which we always are).
+ * clipBoxes is the clipping region in screen space.
+ * data is a pointer to our port private.
+ * drawable is some Drawable, which might not be the screen in the case of
+ * compositing.  It's a new argument to the function in the 1.1 server.
+ */
+static int
+intel_uxa_video_put_image_textured(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_screen_private *intel = intel_get_screen_private(scrn);
+	intel_adaptor_private *adaptor_priv = (intel_adaptor_private *) data;
+	PixmapPtr pixmap = get_drawable_pixmap(drawable);
+	int dstPitch, dstPitch2;
+	BoxRec dstBox;
+	xf86CrtcPtr crtc;
+	int top, left, npixels, nlines;
+
+	if (!intel_uxa_pixmap_is_offscreen(pixmap))
+		return BadAlloc;
+
+#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 (!intel_clip_video_helper(scrn,
+				    adaptor_priv,
+				    &crtc,
+				    &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;
+
+	if (xvmc_passthrough(id)) {
+		uint32_t *gem_handle = (uint32_t *)buf;
+		int size;
+
+		intel_setup_dst_params(scrn, adaptor_priv, width, height,
+				&dstPitch, &dstPitch2, &size, id);
+
+		if (IS_I915G(intel) || IS_I915GM(intel)) {
+			/* XXX: i915 is not support and needs some
+			 * serious care.  grep for KMS in i915_hwmc.c */
+			return BadAlloc;
+		}
+
+		if (adaptor_priv->buf)
+			drm_intel_bo_unreference(adaptor_priv->buf);
+
+		adaptor_priv->buf =
+			drm_intel_bo_gem_create_from_name(intel->bufmgr,
+							  "xvmc surface",
+							  *gem_handle);
+		if (adaptor_priv->buf == NULL)
+			return BadAlloc;
+
+		adaptor_priv->reusable = FALSE;
+	} else {
+		if (!intel_video_copy_data(scrn, adaptor_priv, width, height,
+					  &dstPitch, &dstPitch2,
+					  top, left, npixels, nlines, id, buf))
+			return BadAlloc;
+	}
+
+	if (crtc && adaptor_priv->SyncToVblank != 0 && INTEL_INFO(intel)->gen < 060) {
+		intel_wait_for_scanline(scrn, pixmap, crtc, clipBoxes);
+	}
+
+	if (INTEL_INFO(intel)->gen >= 060) {
+		Gen6DisplayVideoTextured(scrn, adaptor_priv, id, clipBoxes,
+					 width, height, dstPitch, dstPitch2,
+					 src_w, src_h,
+					 drw_w, drw_h, pixmap);
+	} else if (INTEL_INFO(intel)->gen >= 040) {
+		I965DisplayVideoTextured(scrn, adaptor_priv, id, clipBoxes,
+					 width, height, dstPitch, dstPitch2,
+					 src_w, src_h,
+					 drw_w, drw_h, pixmap);
+	} else {
+		I915DisplayVideoTextured(scrn, adaptor_priv, id, clipBoxes,
+					 width, height, dstPitch, dstPitch2,
+					 src_w, src_h, drw_w, drw_h,
+					 pixmap);
+	}
+
+	intel_get_screen_private(scrn)->needs_flush = TRUE;
+	DamageDamageRegion(drawable, clipBoxes);
+
+	/* And make sure the WAIT_FOR_EVENT is queued before any
+	 * modesetting/dpms operations on the pipe.
+	 */
+	intel_batch_submit(scrn);
+
+	return Success;
+}
+
+XF86VideoAdaptorPtr intel_uxa_video_setup_image_textured(ScreenPtr screen)
+{
+	ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
+	intel_screen_private *intel = intel_get_screen_private(scrn);
+	XF86VideoAdaptorPtr adapt;
+	intel_adaptor_private *adaptor_privs;
+	DevUnion *devUnions;
+	int nports = 16, i;
+
+	UXA_VIDEO_DEBUG("intel_video_overlay_setup_image\n");
+
+	adapt = calloc(1, sizeof(XF86VideoAdaptorRec));
+	adaptor_privs = calloc(nports, sizeof(intel_adaptor_private));
+	devUnions = calloc(nports, sizeof(DevUnion));
+	if (adapt == NULL || adaptor_privs == NULL || devUnions == NULL) {
+		free(adapt);
+		free(adaptor_privs);
+		free(devUnions);
+		return NULL;
+	}
+
+	adapt->type = XvWindowMask | XvInputMask | XvImageMask;
+	adapt->flags = 0;
+	adapt->name = "Intel(R) Textured Video";
+	adapt->nEncodings = 1;
+	adapt->pEncodings = xnfalloc(sizeof(intel_xv_dummy_encoding));
+	memcpy(adapt->pEncodings, intel_xv_dummy_encoding, sizeof(intel_xv_dummy_encoding));
+	adapt->nFormats = NUM_FORMATS;
+	adapt->pFormats = intel_xv_formats;
+	adapt->nPorts = nports;
+	adapt->pPortPrivates = devUnions;
+	adapt->nAttributes = 0;
+	adapt->pAttributes = NULL;
+	if (IS_I915G(intel) || IS_I915GM(intel))
+		adapt->nImages = NUM_IMAGES - XVMC_IMAGE;
+	else
+		adapt->nImages = NUM_IMAGES;
+
+	adapt->pImages = intel_xv_images;
+	adapt->PutVideo = NULL;
+	adapt->PutStill = NULL;
+	adapt->GetVideo = NULL;
+	adapt->GetStill = NULL;
+	adapt->StopVideo = intel_video_stop_video;
+	adapt->SetPortAttribute = intel_uxa_video_set_port_attribute;
+	adapt->GetPortAttribute = intel_video_get_port_attribute;
+	adapt->QueryBestSize = intel_video_query_best_size;
+	adapt->PutImage = intel_uxa_video_put_image_textured;
+	adapt->QueryImageAttributes = intel_video_query_image_attributes;
+
+	for (i = 0; i < nports; i++) {
+		intel_adaptor_private *adaptor_priv = &adaptor_privs[i];
+
+		adaptor_priv->textured = TRUE;
+		adaptor_priv->videoStatus = 0;
+		adaptor_priv->buf = NULL;
+		adaptor_priv->old_buf[0] = NULL;
+		adaptor_priv->old_buf[1] = NULL;
+
+		adaptor_priv->rotation = RR_Rotate_0;
+		adaptor_priv->SyncToVblank = 1;
+
+		/* gotta uninit this someplace, XXX: shouldn't be necessary for textured */
+		REGION_NULL(screen, &adaptor_priv->clip);
+
+		adapt->pPortPrivates[i].ptr = (pointer) (adaptor_priv);
+	}
+
+	intel_xv_SyncToVblank = MAKE_ATOM("XV_SYNC_TO_VBLANK");
+
+	return adapt;
+}
diff --git a/src/uxa/intel_video.c b/src/uxa/intel_video.c
index 73fb611..310b6c9 100644
--- a/src/uxa/intel_video.c
+++ b/src/uxa/intel_video.c
@@ -1,35 +1,35 @@
 /***************************************************************************
 
- Copyright 2000 Intel Corporation.  All Rights Reserved. 
-
- Permission is hereby granted, free of charge, to any person obtaining a 
- copy of this software and associated documentation files (the 
- "Software"), to deal in the Software without restriction, including 
- without limitation the rights to use, copy, modify, merge, publish, 
- distribute, sub license, and/or sell copies of the Software, and to 
- permit persons to whom the Software is furnished to do so, subject to 
- the following conditions: 
-
- The above copyright notice and this permission notice (including the 
- next paragraph) shall be included in all copies or substantial portions 
- of the Software. 
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 
- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 
- IN NO EVENT SHALL INTEL, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, 
- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 
- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR 
+ Copyright 2000 Intel Corporation.  All Rights Reserved.
+
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sub license, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice (including the
+ next paragraph) shall be included in all copies or substantial portions
+ of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ IN NO EVENT SHALL INTEL, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
  THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
  **************************************************************************/
 
 /*
- * i830_video.c: i830/i845 Xv driver. 
+ * i830_video.c: i830/i845 Xv driver.
  *
  * Copyright © 2002 by Alan Hourihane and David Dawes
  *
- * Authors: 
+ * Authors:
  *	Alan Hourihane <alanh@tungstengraphics.com>
  *	David Dawes <dawes@xfree86.org>
  *
@@ -79,55 +79,15 @@
 #include "intel_xvmc.h"
 #endif
 #include "intel_glamor.h"
+#include "intel_uxa.h"
+#include "intel_video_overlay.h"
 
-#define OFF_DELAY	250	/* milliseconds */
-
-#define OFF_TIMER	0x01
-#define CLIENT_VIDEO_ON	0x02
-
-static XF86VideoAdaptorPtr I830SetupImageVideoOverlay(ScreenPtr);
-static XF86VideoAdaptorPtr I830SetupImageVideoTextured(ScreenPtr);
-static void I830StopVideo(ScrnInfoPtr, pointer, Bool);
-static int I830SetPortAttributeOverlay(ScrnInfoPtr, Atom, INT32, pointer);
-static int I830SetPortAttributeTextured(ScrnInfoPtr, Atom, INT32, pointer);
-static int I830GetPortAttribute(ScrnInfoPtr, Atom, INT32 *, pointer);
-static void I830QueryBestSize(ScrnInfoPtr, Bool,
-			      short, short, short, short, unsigned int *,
-			      unsigned int *, pointer);
-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 *,
-				    unsigned short *, int *, int *);
-
-#define MAKE_ATOM(a) MakeAtom(a, sizeof(a) - 1, TRUE)
-
-static Atom xvBrightness, xvContrast, xvSaturation, xvColorKey, xvPipe;
-static Atom xvGamma0, xvGamma1, xvGamma2, xvGamma3, xvGamma4, xvGamma5;
-static Atom xvSyncToVblank;
-
-/* Limits for the overlay/textured video source sizes.  The documented hardware
- * limits are 2048x2048 or better for overlay and both of our textured video
- * implementations.  Additionally, on the 830 and 845, larger sizes resulted in
- * the card hanging, so we keep the limits lower there.
- */
-#define IMAGE_MAX_WIDTH		2048
-#define IMAGE_MAX_HEIGHT	2048
-#define IMAGE_MAX_WIDTH_LEGACY	1024
-#define IMAGE_MAX_HEIGHT_LEGACY	1088
-
-/* overlay debugging printf function */
-#if 0
-#define OVERLAY_DEBUG ErrorF
-#else
-#define OVERLAY_DEBUG if (0) ErrorF
-#endif
+Atom intel_xv_Brightness, intel_xv_Contrast, intel_xv_Saturation, intel_xv_ColorKey, intel_xv_Pipe;
+Atom intel_xv_Gamma0, intel_xv_Gamma1, intel_xv_Gamma2, intel_xv_Gamma3, intel_xv_Gamma4, intel_xv_Gamma5;
+Atom intel_xv_SyncToVblank;
 
 /* client libraries expect an encoding */
-static const XF86VideoEncodingRec DummyEncoding[1] = {
+const XF86VideoEncodingRec intel_xv_dummy_encoding[1] = {
 	{
 	 0,
 	 "XV_IMAGE",
@@ -136,14 +96,11 @@ static const XF86VideoEncodingRec DummyEncoding[1] = {
 	 }
 };
 
-#define NUM_FORMATS 3
-
-static XF86VideoFormatRec Formats[NUM_FORMATS] = {
+XF86VideoFormatRec intel_xv_formats[NUM_FORMATS] = {
 	{15, TrueColor}, {16, TrueColor}, {24, TrueColor}
 };
 
-#define NUM_ATTRIBUTES 5
-static XF86AttributeRec Attributes[NUM_ATTRIBUTES] = {
+XF86AttributeRec intel_xv_attributes[NUM_ATTRIBUTES] = {
 	{XvSettable | XvGettable, 0, (1 << 24) - 1, "XV_COLORKEY"},
 	{XvSettable | XvGettable, -128, 127, "XV_BRIGHTNESS"},
 	{XvSettable | XvGettable, 0, 255, "XV_CONTRAST"},
@@ -152,7 +109,7 @@ static XF86AttributeRec Attributes[NUM_ATTRIBUTES] = {
 };
 
 #define GAMMA_ATTRIBUTES 6
-static XF86AttributeRec GammaAttributes[GAMMA_ATTRIBUTES] = {
+XF86AttributeRec intel_xv_gamma_attributes[GAMMA_ATTRIBUTES] = {
 	{XvSettable | XvGettable, 0, 0xffffff, "XV_GAMMA0"},
 	{XvSettable | XvGettable, 0, 0xffffff, "XV_GAMMA1"},
 	{XvSettable | XvGettable, 0, 0xffffff, "XV_GAMMA2"},
@@ -169,7 +126,7 @@ static XF86AttributeRec GammaAttributes[GAMMA_ATTRIBUTES] = {
 #define XVMC_IMAGE 0
 #endif
 
-static XF86ImageRec Images[NUM_IMAGES] = {
+XF86ImageRec intel_xv_images[NUM_IMAGES] = {
 	XVIMAGE_YUY2,
 	XVIMAGE_YV12,
 	XVIMAGE_I420,
@@ -201,144 +158,20 @@ static XF86ImageRec Images[NUM_IMAGES] = {
 #endif
 };
 
-/* kernel modesetting overlay functions */
-static Bool intel_has_overlay(intel_screen_private *intel)
-{
-	struct drm_i915_getparam gp;
-	int has_overlay = 0;
-	int ret;
-
-	gp.param = I915_PARAM_HAS_OVERLAY;
-	gp.value = &has_overlay;
-	ret = drmCommandWriteRead(intel->drmSubFD, DRM_I915_GETPARAM, &gp, sizeof(gp));
-
-	return ret == 0 && !! has_overlay;
-}
-
-static Bool intel_overlay_update_attrs(intel_screen_private *intel)
-{
-	intel_adaptor_private *adaptor_priv = intel_get_adaptor_private(intel);
-	struct drm_intel_overlay_attrs attrs;
-
-	attrs.flags = I915_OVERLAY_UPDATE_ATTRS;
-	attrs.brightness = adaptor_priv->brightness;
-	attrs.contrast = adaptor_priv->contrast;
-	attrs.saturation = adaptor_priv->saturation;
-	attrs.color_key = adaptor_priv->colorKey;
-	attrs.gamma0 = adaptor_priv->gamma0;
-	attrs.gamma1 = adaptor_priv->gamma1;
-	attrs.gamma2 = adaptor_priv->gamma2;
-	attrs.gamma3 = adaptor_priv->gamma3;
-	attrs.gamma4 = adaptor_priv->gamma4;
-	attrs.gamma5 = adaptor_priv->gamma5;
-
-	return drmCommandWriteRead(intel->drmSubFD, DRM_I915_OVERLAY_ATTRS,
-				   &attrs, sizeof(attrs)) == 0;
-}
-
-static void intel_overlay_off(intel_screen_private *intel)
-{
-	struct drm_intel_overlay_put_image request;
-	int ret;
-
-	request.flags = 0;
-
-	ret = drmCommandWrite(intel->drmSubFD, DRM_I915_OVERLAY_PUT_IMAGE,
-			      &request, sizeof(request));
-	(void) ret;
-}
-
-static Bool
-intel_overlay_put_image(intel_screen_private *intel,
-			  xf86CrtcPtr crtc,
-			  int id, short width, short height,
-			  int dstPitch, int dstPitch2,
-			  BoxPtr dstBox, short src_w, short src_h, short drw_w,
-			  short drw_h)
-{
-	intel_adaptor_private *adaptor_priv = intel_get_adaptor_private(intel);
-	struct drm_intel_overlay_put_image request;
-	int ret;
-	int planar = is_planar_fourcc(id);
-	float scale;
-	dri_bo *tmp;
-
-	request.flags = I915_OVERLAY_ENABLE;
-
-	request.bo_handle = adaptor_priv->buf->handle;
-	if (planar) {
-		request.stride_Y = dstPitch2;
-		request.stride_UV = dstPitch;
-	} else {
-		request.stride_Y = dstPitch;
-		request.stride_UV = 0;
-	}
-	request.offset_Y = adaptor_priv->YBufOffset;
-	request.offset_U = adaptor_priv->UBufOffset;
-	request.offset_V = adaptor_priv->VBufOffset;
-	OVERLAY_DEBUG("off_Y: %i, off_U: %i, off_V: %i\n", request.offset_Y,
-		      request.offset_U, request.offset_V);
-
-	request.crtc_id = intel_crtc_id(crtc);
-	request.dst_x = dstBox->x1;
-	request.dst_y = dstBox->y1;
-	request.dst_width = dstBox->x2 - dstBox->x1;
-	request.dst_height = dstBox->y2 - dstBox->y1;
-
-	request.src_width = width;
-	request.src_height = height;
-	/* adjust src dimensions */
-	if (request.dst_height > 1) {
-		scale = ((float)request.dst_height - 1) / ((float)drw_h - 1);
-		request.src_scan_height = src_h * scale;
-	} else
-		request.src_scan_height = 1;
-
-	if (request.dst_width > 1) {
-		scale = ((float)request.dst_width - 1) / ((float)drw_w - 1);
-		request.src_scan_width = src_w * scale;
-	} else
-		request.src_scan_width = 1;
-
-	if (planar) {
-		request.flags |= I915_OVERLAY_YUV_PLANAR | I915_OVERLAY_YUV420;
-	} else {
-		request.flags |= I915_OVERLAY_YUV_PACKED | I915_OVERLAY_YUV422;
-		if (id == FOURCC_UYVY)
-			request.flags |= I915_OVERLAY_Y_SWAP;
-	}
-
-	ret = drmCommandWrite(intel->drmSubFD, DRM_I915_OVERLAY_PUT_IMAGE,
-			      &request, sizeof(request));
-	if (ret)
-		return FALSE;
-
-	if (!adaptor_priv->reusable) {
-		drm_intel_bo_unreference(adaptor_priv->buf);
-		adaptor_priv->buf = NULL;
-		adaptor_priv->reusable = TRUE;
-	}
-
-	tmp = adaptor_priv->old_buf[1];
-	adaptor_priv->old_buf[1] = adaptor_priv->old_buf[0];
-	adaptor_priv->old_buf[0] = adaptor_priv->buf;
-	adaptor_priv->buf = tmp;
-
-	return TRUE;
-}
-
-void I830InitVideo(ScreenPtr screen)
+void intel_video_init(ScreenPtr screen)
 {
 	ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
 	intel_screen_private *intel = intel_get_screen_private(scrn);
 	XF86VideoAdaptorPtr *adaptors = NULL, *newAdaptors = NULL;
 	XF86VideoAdaptorPtr overlayAdaptor = NULL, texturedAdaptor = NULL, glamorAdaptor = NULL;
 	int num_adaptors = xf86XVListGenericAdaptors(scrn, &adaptors);
+
 	/* Give our adaptor list enough space for the overlay and/or texture video
 	 * adaptors.
 	 */
 	newAdaptors = realloc(adaptors,
 			      (num_adaptors + 3) * sizeof(XF86VideoAdaptorPtr));
+
 	if (newAdaptors == NULL) {
 		free(adaptors);
 		return;
@@ -348,30 +181,29 @@ void I830InitVideo(ScreenPtr screen)
 	/* Add the adaptors supported by our hardware.  First, set up the atoms
 	 * that will be used by both output adaptors.
 	 */
-	xvBrightness = MAKE_ATOM("XV_BRIGHTNESS");
-	xvContrast = MAKE_ATOM("XV_CONTRAST");
-
-	/* Set up textured video if we can do it at this depth and we are on
-	 * supported hardware.
-	 */
-	if (!intel->force_fallback &&
-	    scrn->bitsPerPixel >= 16 &&
-	    INTEL_INFO(intel)->gen >= 030 &&
-	    INTEL_INFO(intel)->gen < 0100) {
-		texturedAdaptor = I830SetupImageVideoTextured(screen);
-		if (texturedAdaptor != NULL) {
-			xf86DrvMsg(scrn->scrnIndex, X_INFO,
-				   "Set up textured video\n");
-		} else {
-			xf86DrvMsg(scrn->scrnIndex, X_ERROR,
-				   "Failed to set up textured video\n");
-		}
-	}
-
-	/* Set up overlay video if it is available */
-	intel->use_overlay = intel_has_overlay(intel);
-	if (intel->use_overlay) {
-		overlayAdaptor = I830SetupImageVideoOverlay(screen);
+	intel_xv_Brightness = MAKE_ATOM("XV_BRIGHTNESS");
+	intel_xv_Contrast = MAKE_ATOM("XV_CONTRAST");
+
+        /* Set up textured video if we can do it at this depth and we are on
+         * supported hardware.
+         */
+        if (!intel->force_fallback &&
+            scrn->bitsPerPixel >= 16 &&
+            INTEL_INFO(intel)->gen >= 030 &&
+            INTEL_INFO(intel)->gen < 0100) {
+                texturedAdaptor = intel_uxa_video_setup_image_textured(screen);
+                if (texturedAdaptor != NULL) {
+                        xf86DrvMsg(scrn->scrnIndex, X_INFO,
+                                   "Set up textured video\n");
+                } else {
+                        xf86DrvMsg(scrn->scrnIndex, X_ERROR,
+                                   "Failed to set up textured video\n");
+                }
+        }
+
+        overlayAdaptor = intel_video_overlay_setup_image(screen);
+
+        if (intel->use_overlay) {
 		if (overlayAdaptor != NULL) {
 			xf86DrvMsg(scrn->scrnIndex, X_INFO,
 				   "Set up overlay video\n");
@@ -386,6 +218,7 @@ void I830InitVideo(ScreenPtr screen)
 		xf86DrvMsg(scrn->scrnIndex, X_INFO,
 			   "Set up textured video using glamor\n");
 
+
 	if (overlayAdaptor && intel->XvPreferOverlay)
 		adaptors[num_adaptors++] = overlayAdaptor;
 
@@ -406,195 +239,13 @@ void I830InitVideo(ScreenPtr screen)
 		intel->XvEnabled = FALSE;
 	}
 
-#ifdef INTEL_XVMC
-	if (texturedAdaptor)
-		intel_xvmc_adaptor_init(screen);
-#endif
-	free(adaptors);
-}
+        if (texturedAdaptor)
+                intel_xvmc_adaptor_init(screen);
 
-static XF86VideoAdaptorPtr I830SetupImageVideoOverlay(ScreenPtr screen)
-{
-	ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
-	intel_screen_private *intel = intel_get_screen_private(scrn);
-	XF86VideoAdaptorPtr adapt;
-	intel_adaptor_private *adaptor_priv;
-	XF86AttributePtr att;
-
-	OVERLAY_DEBUG("I830SetupImageVideoOverlay\n");
-
-	if (!(adapt = calloc(1,
-			     sizeof(XF86VideoAdaptorRec) +
-			     sizeof(intel_adaptor_private) +
-			     sizeof(DevUnion))))
-		return NULL;
-
-	adapt->type = XvWindowMask | XvInputMask | XvImageMask;
-	adapt->flags = VIDEO_OVERLAID_IMAGES /*| VIDEO_CLIP_TO_VIEWPORT */ ;
-	adapt->name = "Intel(R) Video Overlay";
-	adapt->nEncodings = 1;
-	adapt->pEncodings = xnfalloc(sizeof(DummyEncoding));
-	memcpy(adapt->pEncodings, DummyEncoding, sizeof(DummyEncoding));
-	if (IS_845G(intel) || IS_I830(intel)) {
-		adapt->pEncodings->width = IMAGE_MAX_WIDTH_LEGACY;
-		adapt->pEncodings->height = IMAGE_MAX_HEIGHT_LEGACY;
-	}
-	adapt->nFormats = NUM_FORMATS;
-	adapt->pFormats = Formats;
-	adapt->nPorts = 1;
-	adapt->pPortPrivates = (DevUnion *) (&adapt[1]);
-
-	adaptor_priv = (intel_adaptor_private *)&adapt->pPortPrivates[1];
-
-	adapt->pPortPrivates[0].ptr = (pointer) (adaptor_priv);
-	adapt->nAttributes = NUM_ATTRIBUTES;
-	if (INTEL_INFO(intel)->gen >= 030)
-		adapt->nAttributes += GAMMA_ATTRIBUTES;	/* has gamma */
-	adapt->pAttributes =
-	    xnfalloc(sizeof(XF86AttributeRec) * adapt->nAttributes);
-	/* Now copy the attributes */
-	att = adapt->pAttributes;
-	memcpy((char *)att, (char *)Attributes,
-	       sizeof(XF86AttributeRec) * NUM_ATTRIBUTES);
-	att += NUM_ATTRIBUTES;
-	if (INTEL_INFO(intel)->gen >= 030) {
-		memcpy((char *)att, (char *)GammaAttributes,
-		       sizeof(XF86AttributeRec) * GAMMA_ATTRIBUTES);
-	}
-	adapt->nImages = NUM_IMAGES - XVMC_IMAGE;
-
-	adapt->pImages = Images;
-	adapt->PutVideo = NULL;
-	adapt->PutStill = NULL;
-	adapt->GetVideo = NULL;
-	adapt->GetStill = NULL;
-	adapt->StopVideo = I830StopVideo;
-	adapt->SetPortAttribute = I830SetPortAttributeOverlay;
-	adapt->GetPortAttribute = I830GetPortAttribute;
-	adapt->QueryBestSize = I830QueryBestSize;
-	adapt->PutImage = I830PutImageOverlay;
-	adapt->QueryImageAttributes = I830QueryImageAttributes;
-
-	adaptor_priv->textured = FALSE;
-	adaptor_priv->colorKey = intel->colorKey & ((1 << scrn->depth) - 1);
-	adaptor_priv->videoStatus = 0;
-	adaptor_priv->brightness = -19;	/* (255/219) * -16 */
-	adaptor_priv->contrast = 75;	/* 255/219 * 64 */
-	adaptor_priv->saturation = 146;	/* 128/112 * 128 */
-	adaptor_priv->desired_crtc = NULL;
-	adaptor_priv->buf = NULL;
-	adaptor_priv->old_buf[0] = NULL;
-	adaptor_priv->old_buf[1] = NULL;
-	adaptor_priv->gamma5 = 0xc0c0c0;
-	adaptor_priv->gamma4 = 0x808080;
-	adaptor_priv->gamma3 = 0x404040;
-	adaptor_priv->gamma2 = 0x202020;
-	adaptor_priv->gamma1 = 0x101010;
-	adaptor_priv->gamma0 = 0x080808;
-
-	adaptor_priv->rotation = RR_Rotate_0;
-
-	/* gotta uninit this someplace */
-	REGION_NULL(screen, &adaptor_priv->clip);
-
-	intel->adaptor = adapt;
-
-	xvColorKey = MAKE_ATOM("XV_COLORKEY");
-	xvBrightness = MAKE_ATOM("XV_BRIGHTNESS");
-	xvContrast = MAKE_ATOM("XV_CONTRAST");
-	xvSaturation = MAKE_ATOM("XV_SATURATION");
-
-	/* Allow the pipe to be switched from pipe A to B when in clone mode */
-	xvPipe = MAKE_ATOM("XV_PIPE");
-
-	if (INTEL_INFO(intel)->gen >= 030) {
-		xvGamma0 = MAKE_ATOM("XV_GAMMA0");
-		xvGamma1 = MAKE_ATOM("XV_GAMMA1");
-		xvGamma2 = MAKE_ATOM("XV_GAMMA2");
-		xvGamma3 = MAKE_ATOM("XV_GAMMA3");
-		xvGamma4 = MAKE_ATOM("XV_GAMMA4");
-		xvGamma5 = MAKE_ATOM("XV_GAMMA5");
-	}
-
-	intel_overlay_update_attrs(intel);
-
-	return adapt;
-}
-
-static XF86VideoAdaptorPtr I830SetupImageVideoTextured(ScreenPtr screen)
-{
-	ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
-	intel_screen_private *intel = intel_get_screen_private(scrn);
-	XF86VideoAdaptorPtr adapt;
-	intel_adaptor_private *adaptor_privs;
-	DevUnion *devUnions;
-	int nports = 16, i;
-
-	OVERLAY_DEBUG("I830SetupImageVideoOverlay\n");
-
-	adapt = calloc(1, sizeof(XF86VideoAdaptorRec));
-	adaptor_privs = calloc(nports, sizeof(intel_adaptor_private));
-	devUnions = calloc(nports, sizeof(DevUnion));
-	if (adapt == NULL || adaptor_privs == NULL || devUnions == NULL) {
-		free(adapt);
-		free(adaptor_privs);
-		free(devUnions);
-		return NULL;
-	}
-
-	adapt->type = XvWindowMask | XvInputMask | XvImageMask;
-	adapt->flags = 0;
-	adapt->name = "Intel(R) Textured Video";
-	adapt->nEncodings = 1;
-	adapt->pEncodings = xnfalloc(sizeof(DummyEncoding));
-	memcpy(adapt->pEncodings, DummyEncoding, sizeof(DummyEncoding));
-	adapt->nFormats = NUM_FORMATS;
-	adapt->pFormats = Formats;
-	adapt->nPorts = nports;
-	adapt->pPortPrivates = devUnions;
-	adapt->nAttributes = 0;
-	adapt->pAttributes = NULL;
-	if (IS_I915G(intel) || IS_I915GM(intel))
-		adapt->nImages = NUM_IMAGES - XVMC_IMAGE;
-	else
-		adapt->nImages = NUM_IMAGES;
-
-	adapt->pImages = Images;
-	adapt->PutVideo = NULL;
-	adapt->PutStill = NULL;
-	adapt->GetVideo = NULL;
-	adapt->GetStill = NULL;
-	adapt->StopVideo = I830StopVideo;
-	adapt->SetPortAttribute = I830SetPortAttributeTextured;
-	adapt->GetPortAttribute = I830GetPortAttribute;
-	adapt->QueryBestSize = I830QueryBestSize;
-	adapt->PutImage = I830PutImageTextured;
-	adapt->QueryImageAttributes = I830QueryImageAttributes;
-
-	for (i = 0; i < nports; i++) {
-		intel_adaptor_private *adaptor_priv = &adaptor_privs[i];
-
-		adaptor_priv->textured = TRUE;
-		adaptor_priv->videoStatus = 0;
-		adaptor_priv->buf = NULL;
-		adaptor_priv->old_buf[0] = NULL;
-		adaptor_priv->old_buf[1] = NULL;
-
-		adaptor_priv->rotation = RR_Rotate_0;
-		adaptor_priv->SyncToVblank = 1;
-
-		/* gotta uninit this someplace, XXX: shouldn't be necessary for textured */
-		REGION_NULL(screen, &adaptor_priv->clip);
-
-		adapt->pPortPrivates[i].ptr = (pointer) (adaptor_priv);
-	}
-
-	xvSyncToVblank = MAKE_ATOM("XV_SYNC_TO_VBLANK");
-
-	return adapt;
+	free(adaptors);
 }
 
-static void intel_free_video_buffers(intel_adaptor_private *adaptor_priv)
+void intel_free_video_buffers(intel_adaptor_private *adaptor_priv)
 {
 	int i;
 
@@ -612,137 +263,20 @@ static void intel_free_video_buffers(intel_adaptor_private *adaptor_priv)
 	}
 }
 
-static void I830StopVideo(ScrnInfoPtr scrn, pointer data, Bool shutdown)
-{
-	intel_adaptor_private *adaptor_priv = (intel_adaptor_private *) data;
-
-	if (adaptor_priv->textured)
-		return;
-
-	OVERLAY_DEBUG("I830StopVideo\n");
-
-	REGION_EMPTY(scrn->pScreen, &adaptor_priv->clip);
-
-	if (shutdown) {
-		if (adaptor_priv->videoStatus & CLIENT_VIDEO_ON)
-			intel_overlay_off(intel_get_screen_private(scrn));
-
-		intel_free_video_buffers(adaptor_priv);
-		adaptor_priv->videoStatus = 0;
-	} else {
-		if (adaptor_priv->videoStatus & CLIENT_VIDEO_ON) {
-			adaptor_priv->videoStatus |= OFF_TIMER;
-			adaptor_priv->offTime = currentTime.milliseconds + OFF_DELAY;
-		}
-	}
-
-}
-
-static int
-I830SetPortAttributeTextured(ScrnInfoPtr scrn,
-			     Atom attribute, INT32 value, pointer data)
-{
-	intel_adaptor_private *adaptor_priv = (intel_adaptor_private *) data;
-
-	if (attribute == xvBrightness) {
-		if ((value < -128) || (value > 127))
-			return BadValue;
-		adaptor_priv->brightness = value;
-		return Success;
-	} else if (attribute == xvContrast) {
-		if ((value < 0) || (value > 255))
-			return BadValue;
-		adaptor_priv->contrast = value;
-		return Success;
-	} else if (attribute == xvSyncToVblank) {
-		if ((value < -1) || (value > 1))
-			return BadValue;
-		adaptor_priv->SyncToVblank = value;
-		return Success;
-	} else {
-		return BadMatch;
-	}
-}
-
-static int
-I830SetPortAttributeOverlay(ScrnInfoPtr scrn,
-			    Atom attribute, INT32 value, pointer data)
-{
-	intel_adaptor_private *adaptor_priv = (intel_adaptor_private *) data;
-	intel_screen_private *intel = intel_get_screen_private(scrn);
-
-	if (attribute == xvBrightness) {
-		if ((value < -128) || (value > 127))
-			return BadValue;
-		adaptor_priv->brightness = value;
-		OVERLAY_DEBUG("BRIGHTNESS\n");
-	} else if (attribute == xvContrast) {
-		if ((value < 0) || (value > 255))
-			return BadValue;
-		adaptor_priv->contrast = value;
-		OVERLAY_DEBUG("CONTRAST\n");
-	} else if (attribute == xvSaturation) {
-		if ((value < 0) || (value > 1023))
-			return BadValue;
-		adaptor_priv->saturation = value;
-	} else if (attribute == xvPipe) {
-		xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
-		if ((value < -1) || (value >= xf86_config->num_crtc))
-			return BadValue;
-		if (value < 0)
-			adaptor_priv->desired_crtc = NULL;
-		else
-			adaptor_priv->desired_crtc = xf86_config->crtc[value];
-	} else if (attribute == xvGamma0 && (INTEL_INFO(intel)->gen >= 030)) {
-		adaptor_priv->gamma0 = value;
-	} else if (attribute == xvGamma1 && (INTEL_INFO(intel)->gen >= 030)) {
-		adaptor_priv->gamma1 = value;
-	} else if (attribute == xvGamma2 && (INTEL_INFO(intel)->gen >= 030)) {
-		adaptor_priv->gamma2 = value;
-	} else if (attribute == xvGamma3 && (INTEL_INFO(intel)->gen >= 030)) {
-		adaptor_priv->gamma3 = value;
-	} else if (attribute == xvGamma4 && (INTEL_INFO(intel)->gen >= 030)) {
-		adaptor_priv->gamma4 = value;
-	} else if (attribute == xvGamma5 && (INTEL_INFO(intel)->gen >= 030)) {
-		adaptor_priv->gamma5 = value;
-	} else if (attribute == xvColorKey) {
-		adaptor_priv->colorKey = value;
-		OVERLAY_DEBUG("COLORKEY\n");
-	} else
-		return BadMatch;
-
-	if ((attribute == xvGamma0 ||
-	     attribute == xvGamma1 ||
-	     attribute == xvGamma2 ||
-	     attribute == xvGamma3 ||
-	     attribute == xvGamma4 ||
-	     attribute == xvGamma5) && (INTEL_INFO(intel)->gen >= 030)) {
-		OVERLAY_DEBUG("GAMMA\n");
-	}
-
-	if (!intel_overlay_update_attrs(intel))
-		return BadValue;
-
-	if (attribute == xvColorKey)
-		REGION_EMPTY(scrn->pScreen, &adaptor_priv->clip);
-
-	return Success;
-}
-
-static int
-I830GetPortAttribute(ScrnInfoPtr scrn,
-		     Atom attribute, INT32 * value, pointer data)
+int
+intel_video_get_port_attribute(ScrnInfoPtr scrn,
+                               Atom attribute, INT32 * value, pointer data)
 {
 	intel_screen_private *intel = intel_get_screen_private(scrn);
 	intel_adaptor_private *adaptor_priv = (intel_adaptor_private *) data;
 
-	if (attribute == xvBrightness) {
+	if (attribute == intel_xv_Brightness) {
 		*value = adaptor_priv->brightness;
-	} else if (attribute == xvContrast) {
+	} else if (attribute == intel_xv_Contrast) {
 		*value = adaptor_priv->contrast;
-	} else if (attribute == xvSaturation) {
+	} else if (attribute == intel_xv_Saturation) {
 		*value = adaptor_priv->saturation;
-	} else if (attribute == xvPipe) {
+	} else if (attribute == intel_xv_Pipe) {
 		int c;
 		xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
 		for (c = 0; c < xf86_config->num_crtc; c++)
@@ -751,21 +285,21 @@ I830GetPortAttribute(ScrnInfoPtr scrn,
 		if (c == xf86_config->num_crtc)
 			c = -1;
 		*value = c;
-	} else if (attribute == xvGamma0 && (INTEL_INFO(intel)->gen >= 030)) {
+	} else if (attribute == intel_xv_Gamma0 && (INTEL_INFO(intel)->gen >= 030)) {
 		*value = adaptor_priv->gamma0;
-	} else if (attribute == xvGamma1 && (INTEL_INFO(intel)->gen >= 030)) {
+	} else if (attribute == intel_xv_Gamma1 && (INTEL_INFO(intel)->gen >= 030)) {
 		*value = adaptor_priv->gamma1;
-	} else if (attribute == xvGamma2 && (INTEL_INFO(intel)->gen >= 030)) {
+	} else if (attribute == intel_xv_Gamma2 && (INTEL_INFO(intel)->gen >= 030)) {
 		*value = adaptor_priv->gamma2;
-	} else if (attribute == xvGamma3 && (INTEL_INFO(intel)->gen >= 030)) {
+	} else if (attribute == intel_xv_Gamma3 && (INTEL_INFO(intel)->gen >= 030)) {
 		*value = adaptor_priv->gamma3;
-	} else if (attribute == xvGamma4 && (INTEL_INFO(intel)->gen >= 030)) {
+	} else if (attribute == intel_xv_Gamma4 && (INTEL_INFO(intel)->gen >= 030)) {
 		*value = adaptor_priv->gamma4;
-	} else if (attribute == xvGamma5 && (INTEL_INFO(intel)->gen >= 030)) {
+	} else if (attribute == intel_xv_Gamma5 && (INTEL_INFO(intel)->gen >= 030)) {
 		*value = adaptor_priv->gamma5;
-	} else if (attribute == xvColorKey) {
+	} else if (attribute == intel_xv_ColorKey) {
 		*value = adaptor_priv->colorKey;
-	} else if (attribute == xvSyncToVblank) {
+	} else if (attribute == intel_xv_SyncToVblank) {
 		*value = adaptor_priv->SyncToVblank;
 	} else
 		return BadMatch;
@@ -773,8 +307,8 @@ I830GetPortAttribute(ScrnInfoPtr scrn,
 	return Success;
 }
 
-static void
-I830QueryBestSize(ScrnInfoPtr scrn,
+void
+intel_video_query_best_size(ScrnInfoPtr scrn,
 		  Bool motion,
 		  short vid_w, short vid_h,
 		  short drw_w, short drw_h,
@@ -790,16 +324,16 @@ I830QueryBestSize(ScrnInfoPtr scrn,
 }
 
 static Bool
-I830CopyPackedData(intel_adaptor_private *adaptor_priv,
-		   unsigned char *buf,
-		   int srcPitch, int dstPitch, int top, int left, int h, int w)
+intel_video_copy_packed_data(intel_adaptor_private *adaptor_priv,
+                                 unsigned char *buf,
+                                 int srcPitch, int dstPitch, int top, int left, int h, int w)
 {
 	unsigned char *src, *dst, *dst_base;
 	int i, j;
 	unsigned char *s;
 
 #if 0
-	ErrorF("I830CopyPackedData: (%d,%d) (%d,%d)\n"
+	ErrorF("intel_video_copy_packed_data: (%d,%d) (%d,%d)\n"
 	       "srcPitch: %d, dstPitch: %d\n", top, left, h, w,
 	       srcPitch, dstPitch);
 #endif
@@ -954,7 +488,7 @@ static void intel_memcpy_plane(unsigned char *dst, unsigned char *src,
 }
 
 static Bool
-I830CopyPlanarData(intel_adaptor_private *adaptor_priv,
+intel_video_copy_planar_data(intel_adaptor_private *adaptor_priv,
 		   unsigned char *buf, int srcPitch, int srcPitch2,
 		   int dstPitch, int dstPitch2,
 		   int srcH, int top, int left,
@@ -963,7 +497,7 @@ I830CopyPlanarData(intel_adaptor_private *adaptor_priv,
 	unsigned char *src1, *src2, *src3, *dst_base, *dst1, *dst2, *dst3;
 
 #if 0
-	ErrorF("I830CopyPlanarData: srcPitch %d, srcPitch %d, dstPitch %d\n"
+	ErrorF("intel_video_copy_planar_data: srcPitch %d, srcPitch %d, dstPitch %d\n"
 	       "nlines %d, npixels %d, top %d, left %d\n",
 	       srcPitch, srcPitch2, dstPitch, h, w, top, left);
 #endif
@@ -1025,366 +559,7 @@ I830CopyPlanarData(intel_adaptor_private *adaptor_priv,
 	return TRUE;
 }
 
-static void intel_box_intersect(BoxPtr dest, BoxPtr a, BoxPtr b)
-{
-	dest->x1 = a->x1 > b->x1 ? a->x1 : b->x1;
-	dest->x2 = a->x2 < b->x2 ? a->x2 : b->x2;
-	if (dest->x1 >= dest->x2) {
-		dest->x1 = dest->x2 = dest->y1 = dest->y2 = 0;
-		return;
-	}
-
-	dest->y1 = a->y1 > b->y1 ? a->y1 : b->y1;
-	dest->y2 = a->y2 < b->y2 ? a->y2 : b->y2;
-	if (dest->y1 >= dest->y2)
-		dest->x1 = dest->x2 = dest->y1 = dest->y2 = 0;
-}
-
-static void intel_crtc_box(xf86CrtcPtr crtc, BoxPtr crtc_box)
-{
-	if (crtc->enabled) {
-		crtc_box->x1 = crtc->x;
-		crtc_box->x2 =
-		    crtc->x + xf86ModeWidth(&crtc->mode, crtc->rotation);
-		crtc_box->y1 = crtc->y;
-		crtc_box->y2 =
-		    crtc->y + xf86ModeHeight(&crtc->mode, crtc->rotation);
-	} else
-		crtc_box->x1 = crtc_box->x2 = crtc_box->y1 = crtc_box->y2 = 0;
-}
-
-static int intel_box_area(BoxPtr box)
-{
-	return (int)(box->x2 - box->x1) * (int)(box->y2 - box->y1);
-}
-
-/*
- * Return the crtc covering 'box'. If two crtcs cover a portion of
- * 'box', then prefer 'desired'. If 'desired' is NULL, then prefer the crtc
- * with greater coverage
- */
-
-xf86CrtcPtr
-intel_covering_crtc(ScrnInfoPtr scrn,
-		    BoxPtr box, xf86CrtcPtr desired, BoxPtr crtc_box_ret)
-{
-	xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
-	xf86CrtcPtr crtc, best_crtc;
-	int coverage, best_coverage;
-	int c;
-	BoxRec crtc_box, cover_box;
-
-	best_crtc = NULL;
-	best_coverage = 0;
-	crtc_box_ret->x1 = 0;
-	crtc_box_ret->x2 = 0;
-	crtc_box_ret->y1 = 0;
-	crtc_box_ret->y2 = 0;
-	for (c = 0; c < xf86_config->num_crtc; c++) {
-		crtc = xf86_config->crtc[c];
-
-		/* If the CRTC is off, treat it as not covering */
-		if (!intel_crtc_on(crtc))
-			continue;
-
-		intel_crtc_box(crtc, &crtc_box);
-		intel_box_intersect(&cover_box, &crtc_box, box);
-		coverage = intel_box_area(&cover_box);
-		if (coverage && crtc == desired) {
-			*crtc_box_ret = crtc_box;
-			return crtc;
-		}
-		if (coverage > best_coverage) {
-			*crtc_box_ret = crtc_box;
-			best_crtc = crtc;
-			best_coverage = coverage;
-		}
-	}
-	return best_crtc;
-}
-
-static void
-intel_update_dst_box_to_crtc_coords(ScrnInfoPtr scrn, xf86CrtcPtr crtc,
-				    BoxPtr dstBox)
-{
-	int tmp;
-
-	/* for overlay, we should take it from crtc's screen
-	 * coordinate to current crtc's display mode.
-	 * yeah, a bit confusing.
-	 */
-	switch (crtc->rotation & 0xf) {
-	case RR_Rotate_0:
-		dstBox->x1 -= crtc->x;
-		dstBox->x2 -= crtc->x;
-		dstBox->y1 -= crtc->y;
-		dstBox->y2 -= crtc->y;
-		break;
-	case RR_Rotate_90:
-		tmp = dstBox->x1;
-		dstBox->x1 = dstBox->y1 - crtc->x;
-		dstBox->y1 = scrn->virtualX - tmp - crtc->y;
-		tmp = dstBox->x2;
-		dstBox->x2 = dstBox->y2 - crtc->x;
-		dstBox->y2 = scrn->virtualX - tmp - crtc->y;
-		tmp = dstBox->y1;
-		dstBox->y1 = dstBox->y2;
-		dstBox->y2 = tmp;
-		break;
-	case RR_Rotate_180:
-		tmp = dstBox->x1;
-		dstBox->x1 = scrn->virtualX - dstBox->x2 - crtc->x;
-		dstBox->x2 = scrn->virtualX - tmp - crtc->x;
-		tmp = dstBox->y1;
-		dstBox->y1 = scrn->virtualY - dstBox->y2 - crtc->y;
-		dstBox->y2 = scrn->virtualY - tmp - crtc->y;
-		break;
-	case RR_Rotate_270:
-		tmp = dstBox->x1;
-		dstBox->x1 = scrn->virtualY - dstBox->y1 - crtc->x;
-		dstBox->y1 = tmp - crtc->y;
-		tmp = dstBox->x2;
-		dstBox->x2 = scrn->virtualY - dstBox->y2 - crtc->x;
-		dstBox->y2 = tmp - crtc->y;
-		tmp = dstBox->x1;
-		dstBox->x1 = dstBox->x2;
-		dstBox->x2 = tmp;
-		break;
-	}
-
-	return;
-}
-
-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:
-		return 0;
-	default:
-		ErrorF("Unknown format 0x%x\n", id);
-		return 0;
-	}
-}
-
-static int xvmc_passthrough(int id)
-{
-#ifdef INTEL_XVMC
-	return id == FOURCC_XVMC;
-#else
-	return 0;
-#endif
-}
-
-static Bool
-intel_display_overlay(ScrnInfoPtr scrn, xf86CrtcPtr crtc,
-		      int id, short width, short height,
-		      int dstPitch, int dstPitch2,
-		      BoxPtr dstBox, short src_w, short src_h, short drw_w,
-		      short drw_h)
-{
-	intel_screen_private *intel = intel_get_screen_private(scrn);
-	int tmp;
-
-	OVERLAY_DEBUG("I830DisplayVideo: %dx%d (pitch %d)\n", width, height,
-		      dstPitch);
-
-	/*
-	 * If the video isn't visible on any CRTC, turn it off
-	 */
-	if (!crtc) {
-		intel_overlay_off(intel);
-		return TRUE;
-	}
-
-	intel_update_dst_box_to_crtc_coords(scrn, 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 intel_overlay_put_image(intel, crtc, id,
-					 width, height,
-					 dstPitch, dstPitch2, dstBox,
-					 src_w, src_h, drw_w, drw_h);
-}
-
-static Bool
-intel_clip_video_helper(ScrnInfoPtr scrn,
-			intel_adaptor_private *adaptor_priv,
-			xf86CrtcPtr * crtc_ret,
-			BoxPtr dst,
-			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
-	 */
-	crtc = intel_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, &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 = ALIGN(((x2 + 0xffff) >> 16), 2) - *left;
-	if (is_planar_fourcc(id)) {
-		*top &= ~1;
-		*nlines = ALIGN(((y2 + 0xffff) >> 16), 2) - *top;
-	} else
-		*nlines = ((y2 + 0xffff) >> 16) - *top;
-
-	return ret;
-}
-
-static void
-intel_wait_for_scanline(ScrnInfoPtr scrn, PixmapPtr pixmap,
-			xf86CrtcPtr crtc, RegionPtr clipBoxes)
-{
-	intel_screen_private *intel = intel_get_screen_private(scrn);
-	pixman_box16_t box, crtc_box;
-	int pipe, event;
-	Bool full_height;
-	int y1, y2;
-
-	pipe = -1;
-	if (scrn->vtSema && pixmap_is_scanout(pixmap))
-		pipe = intel_crtc_to_pipe(crtc);
-	if (pipe < 0)
-		return;
-
-	box = *REGION_EXTENTS(unused, clipBoxes);
-
-	if (crtc->transform_in_use)
-		pixman_f_transform_bounds(&crtc->f_framebuffer_to_crtc, &box);
-
-	/* We could presume the clip was correctly computed... */
-	intel_crtc_box(crtc, &crtc_box);
-	intel_box_intersect(&box, &crtc_box, &box);
-
-	/*
-	 * Make sure we don't wait for a scanline that will
-	 * never occur
-	 */
-	y1 = (crtc_box.y1 <= box.y1) ? box.y1 - crtc_box.y1 : 0;
-	y2 = (box.y2 <= crtc_box.y2) ?
-		box.y2 - crtc_box.y1 : crtc_box.y2 - crtc_box.y1;
-	if (y2 <= y1)
-		return;
-
-	full_height = FALSE;
-	if (y1 == 0 && y2 == (crtc_box.y2 - crtc_box.y1))
-		full_height = TRUE;
-
-	/*
-	 * Pre-965 doesn't have SVBLANK, so we need a bit
-	 * of extra time for the blitter to start up and
-	 * do its job for a full height blit
-	 */
-	if (full_height && INTEL_INFO(intel)->gen < 040)
-		y2 -= 2;
-
-	if (pipe == 0) {
-		pipe = MI_LOAD_SCAN_LINES_DISPLAY_PIPEA;
-		event = MI_WAIT_FOR_PIPEA_SCAN_LINE_WINDOW;
-		if (full_height && INTEL_INFO(intel)->gen >= 040)
-			event = MI_WAIT_FOR_PIPEA_SVBLANK;
-	} else {
-		pipe = MI_LOAD_SCAN_LINES_DISPLAY_PIPEB;
-		event = MI_WAIT_FOR_PIPEB_SCAN_LINE_WINDOW;
-		if (full_height && INTEL_INFO(intel)->gen >= 040)
-			event = MI_WAIT_FOR_PIPEB_SVBLANK;
-	}
-
-	if (crtc->mode.Flags & V_INTERLACE) {
-		/* DSL count field lines */
-		y1 /= 2;
-		y2 /= 2;
-	}
-
-	BEGIN_BATCH(5);
-	/* The documentation says that the LOAD_SCAN_LINES command
-	 * always comes in pairs. Don't ask me why. */
-	OUT_BATCH(MI_LOAD_SCAN_LINES_INCL | pipe);
-	OUT_BATCH((y1 << 16) | (y2-1));
-	OUT_BATCH(MI_LOAD_SCAN_LINES_INCL | pipe);
-	OUT_BATCH((y1 << 16) | (y2-1));
-	OUT_BATCH(MI_WAIT_FOR_EVENT | event);
-	ADVANCE_BATCH();
-}
-
-static Bool
-intel_setup_video_buffer(ScrnInfoPtr scrn, intel_adaptor_private *adaptor_priv,
-			 int alloc_size, int id, unsigned char *buf)
-{
-	intel_screen_private *intel = intel_get_screen_private(scrn);
-
-	/* Free the current buffer if we're going to have to reallocate */
-	if (adaptor_priv->buf && adaptor_priv->buf->size < alloc_size)
-		intel_free_video_buffers(adaptor_priv);
-
-	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;
-
-		adaptor_priv->reusable = TRUE;
-	}
-
-	return TRUE;
-}
-
-static void
+void
 intel_setup_dst_params(ScrnInfoPtr scrn, intel_adaptor_private *adaptor_priv, short width,
 		       short height, int *dstPitch, int *dstPitch2, int *size,
 		       int id)
@@ -1462,10 +637,32 @@ intel_setup_dst_params(ScrnInfoPtr scrn, intel_adaptor_private *adaptor_priv, sh
 }
 
 static Bool
-intel_copy_video_data(ScrnInfoPtr scrn, intel_adaptor_private *adaptor_priv,
-		     short width, short height, int *dstPitch, int *dstPitch2,
-		     int top, int left, int npixels, int nlines,
-		     int id, unsigned char *buf)
+intel_setup_video_buffer(ScrnInfoPtr scrn, intel_adaptor_private *adaptor_priv,
+			 int alloc_size, int id, unsigned char *buf)
+{
+	intel_screen_private *intel = intel_get_screen_private(scrn);
+
+	/* Free the current buffer if we're going to have to reallocate */
+	if (adaptor_priv->buf && adaptor_priv->buf->size < alloc_size)
+		intel_free_video_buffers(adaptor_priv);
+
+	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;
+
+		adaptor_priv->reusable = TRUE;
+	}
+
+	return TRUE;
+}
+
+Bool
+intel_video_copy_data(ScrnInfoPtr scrn, intel_adaptor_private *adaptor_priv,
+                      short width, short height, int *dstPitch, int *dstPitch2,
+                      int top, int left, int npixels, int nlines,
+                      int id, unsigned char *buf)
 {
 	int srcPitch = 0, srcPitch2 = 0;
 	int size;
@@ -1485,217 +682,108 @@ intel_copy_video_data(ScrnInfoPtr scrn, intel_adaptor_private *adaptor_priv,
 
 	/* copy data */
 	if (is_planar_fourcc(id)) {
-		return I830CopyPlanarData(adaptor_priv, buf, srcPitch, srcPitch2,
+		return intel_video_copy_planar_data(adaptor_priv, buf, srcPitch, srcPitch2,
 					  *dstPitch, *dstPitch2,
 					  height, top, left, nlines,
 					  npixels, id);
 	} else {
-		return I830CopyPackedData(adaptor_priv, buf, srcPitch, *dstPitch, top, left,
+		return intel_video_copy_packed_data(adaptor_priv, buf, srcPitch, *dstPitch, top, left,
 					  nlines, npixels);
 	}
 }
 
-/*
- * The source rectangle of the video is defined by (src_x, src_y, src_w, src_h).
- * The dest rectangle of the video is defined by (drw_x, drw_y, drw_w, drw_h).
- * id is a fourcc code for the format of the video.
- * buf is the pointer to the source data in system memory.
- * width and height are the w/h of the source data.
- * If "sync" is TRUE, then we must be finished with *buf at the point of return
- * (which we always are).
- * clipBoxes is the clipping region in screen space.
- * data is a pointer to our port private.
- * drawable is some Drawable, which might not be the screen in the case of
- * compositing.  It's a new argument to the function in the 1.1 server.
- */
-static int
-I830PutImageTextured(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)
+int is_planar_fourcc(int id)
 {
-	intel_screen_private *intel = intel_get_screen_private(scrn);
-	intel_adaptor_private *adaptor_priv = (intel_adaptor_private *) data;
-	PixmapPtr pixmap = get_drawable_pixmap(drawable);
-	int dstPitch, dstPitch2;
-	BoxRec dstBox;
-	xf86CrtcPtr crtc;
-	int top, left, npixels, nlines;
-
-	if (!intel_pixmap_is_offscreen(pixmap))
-		return BadAlloc;
-
-#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);
+	switch (id) {
+	case FOURCC_YV12:
+	case FOURCC_I420:
+#ifdef INTEL_XVMC
+	case FOURCC_XVMC:
 #endif
-
-	if (!intel_clip_video_helper(scrn,
-				    adaptor_priv,
-				    &crtc,
-				    &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;
-
-	if (xvmc_passthrough(id)) {
-		uint32_t *gem_handle = (uint32_t *)buf;
-		int size;
-
-		intel_setup_dst_params(scrn, adaptor_priv, width, height,
-				&dstPitch, &dstPitch2, &size, id);
-
-		if (IS_I915G(intel) || IS_I915GM(intel)) {
-			/* XXX: i915 is not support and needs some
-			 * serious care.  grep for KMS in i915_hwmc.c */
-			return BadAlloc;
-		}
-
-		if (adaptor_priv->buf)
-			drm_intel_bo_unreference(adaptor_priv->buf);
-
-		adaptor_priv->buf =
-			drm_intel_bo_gem_create_from_name(intel->bufmgr,
-							  "xvmc surface",
-							  *gem_handle);
-		if (adaptor_priv->buf == NULL)
-			return BadAlloc;
-
-		adaptor_priv->reusable = FALSE;
-	} else {
-		if (!intel_copy_video_data(scrn, adaptor_priv, width, height,
-					  &dstPitch, &dstPitch2,
-					  top, left, npixels, nlines, id, buf))
-			return BadAlloc;
-	}
-
-	if (crtc && adaptor_priv->SyncToVblank != 0 && INTEL_INFO(intel)->gen < 060) {
-		intel_wait_for_scanline(scrn, pixmap, crtc, clipBoxes);
-	}
-
-	if (INTEL_INFO(intel)->gen >= 060) {
-		Gen6DisplayVideoTextured(scrn, adaptor_priv, id, clipBoxes,
-					 width, height, dstPitch, dstPitch2,
-					 src_w, src_h,
-					 drw_w, drw_h, pixmap);
-	} else if (INTEL_INFO(intel)->gen >= 040) {
-		I965DisplayVideoTextured(scrn, adaptor_priv, id, clipBoxes,
-					 width, height, dstPitch, dstPitch2,
-					 src_w, src_h,
-					 drw_w, drw_h, pixmap);
-	} else {
-		I915DisplayVideoTextured(scrn, adaptor_priv, id, clipBoxes,
-					 width, height, dstPitch, dstPitch2,
-					 src_w, src_h, drw_w, drw_h,
-					 pixmap);
+		return 1;
+	case FOURCC_UYVY:
+	case FOURCC_YUY2:
+		return 0;
+	default:
+		ErrorF("Unknown format 0x%x\n", id);
+		return 0;
 	}
-
-	intel_get_screen_private(scrn)->needs_flush = TRUE;
-	DamageDamageRegion(drawable, clipBoxes);
-
-	/* And make sure the WAIT_FOR_EVENT is queued before any
-	 * modesetting/dpms operations on the pipe.
-	 */
-	intel_batch_submit(scrn);
-
-	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)
+Bool
+intel_clip_video_helper(ScrnInfoPtr scrn,
+			intel_adaptor_private *adaptor_priv,
+			xf86CrtcPtr * crtc_ret,
+			BoxPtr dst,
+			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)
 {
-	intel_adaptor_private *adaptor_priv = (intel_adaptor_private *) data;
-	int dstPitch, dstPitch2;
-	BoxRec dstBox;
+	Bool ret;
+	RegionRec crtc_region_local;
+	RegionPtr crtc_region = reg;
+	BoxRec crtc_box;
+	INT32 x1, x2, y1, y2;
 	xf86CrtcPtr crtc;
-	int top, left, npixels, nlines;
 
-#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
+	x1 = src_x;
+	x2 = src_x + src_w;
+	y1 = src_y;
+	y2 = src_y + src_h;
 
-	/* 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;
-
-	if (!intel_clip_video_helper(scrn,
-				    adaptor_priv,
-				    &crtc,
-				    &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;
-
-	/* 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;
-	}
+	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
+	 */
+	crtc = intel_covering_crtc(scrn, dst, adaptor_priv->desired_crtc,
+				   &crtc_box);
 
-	if (!intel_copy_video_data(scrn, adaptor_priv, width, height,
-				  &dstPitch, &dstPitch2,
-				  top, left, npixels, nlines, id, buf))
-		return BadAlloc;
-
-	if (!intel_display_overlay
-	    (scrn, crtc, id, width, height, dstPitch, dstPitch2,
-	     &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);
-		xf86XVFillKeyHelperDrawable(drawable,
-					    adaptor_priv->colorKey,
-					    clipBoxes);
+	/* 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;
 
-	adaptor_priv->videoStatus = CLIENT_VIDEO_ON;
+	ret = xf86XVClipVideoHelper(dst, &x1, &x2, &y1, &y2,
+				    crtc_region, width, height);
+	if (crtc_region != reg)
+		REGION_UNINIT(screen, &crtc_region_local);
 
-	return Success;
+	*top = y1 >> 16;
+	*left = (x1 >> 16) & ~1;
+	*npixels = ALIGN(((x2 + 0xffff) >> 16), 2) - *left;
+	if (is_planar_fourcc(id)) {
+		*top &= ~1;
+		*nlines = ALIGN(((y2 + 0xffff) >> 16), 2) - *top;
+	} else
+		*nlines = ((y2 + 0xffff) >> 16) - *top;
+
+	return ret;
 }
 
-static int
-I830QueryImageAttributes(ScrnInfoPtr scrn,
-			 int id,
-			 unsigned short *w, unsigned short *h,
-			 int *pitches, int *offsets)
+int
+intel_video_query_image_attributes(ScrnInfoPtr scrn,
+                                   int id,
+                                   unsigned short *w, unsigned short *h,
+                                   int *pitches, int *offsets)
 {
 	intel_screen_private *intel = intel_get_screen_private(scrn);
 	int size, tmp;
 
 #if 0
-	ErrorF("I830QueryImageAttributes: w is %d, h is %d\n", *w, *h);
+	ErrorF("intel_video_query_image_attributes: w is %d, h is %d\n", *w, *h);
 #endif
 
 	if (IS_845G(intel) || IS_I830(intel)) {
@@ -1771,6 +859,30 @@ I830QueryImageAttributes(ScrnInfoPtr scrn,
 	return size;
 }
 
+void intel_video_stop_video(ScrnInfoPtr scrn, pointer data, Bool shutdown)
+{
+	intel_adaptor_private *adaptor_priv = (intel_adaptor_private *) data;
+
+	if (adaptor_priv->textured)
+		return;
+
+	REGION_EMPTY(scrn->pScreen, &adaptor_priv->clip);
+
+	if (shutdown) {
+		if (adaptor_priv->videoStatus & CLIENT_VIDEO_ON)
+			intel_video_overlay_off(intel_get_screen_private(scrn));
+
+		intel_free_video_buffers(adaptor_priv);
+		adaptor_priv->videoStatus = 0;
+	} else {
+		if (adaptor_priv->videoStatus & CLIENT_VIDEO_ON) {
+			adaptor_priv->videoStatus |= OFF_TIMER;
+			adaptor_priv->offTime = currentTime.milliseconds + OFF_DELAY;
+		}
+	}
+
+}
+
 void
 intel_video_block_handler(intel_screen_private *intel)
 {
@@ -1785,7 +897,7 @@ intel_video_block_handler(intel_screen_private *intel)
 		Time now = currentTime.milliseconds;
 		if (adaptor_priv->offTime < now) {
 			/* Turn off the overlay */
-			intel_overlay_off(intel);
+			intel_video_overlay_off(intel);
 			intel_free_video_buffers(adaptor_priv);
 			adaptor_priv->videoStatus = 0;
 		}
diff --git a/src/uxa/intel_video.h b/src/uxa/intel_video.h
index f405d40..09cc477 100644
--- a/src/uxa/intel_video.h
+++ b/src/uxa/intel_video.h
@@ -1,29 +1,32 @@
 /***************************************************************************
- 
-Copyright 2000 Intel Corporation.  All Rights Reserved. 
-
-Permission is hereby granted, free of charge, to any person obtaining a 
-copy of this software and associated documentation files (the 
-"Software"), to deal in the Software without restriction, including 
-without limitation the rights to use, copy, modify, merge, publish, 
-distribute, sub license, and/or sell copies of the Software, and to 
-permit persons to whom the Software is furnished to do so, subject to 
-the following conditions: 
-
-The above copyright notice and this permission notice (including the 
-next paragraph) shall be included in all copies or substantial portions 
-of the Software. 
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 
-OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 
-IN NO EVENT SHALL INTEL, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, 
-DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 
-OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR 
+
+Copyright 2000 Intel Corporation.  All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL INTEL, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
+DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
 THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 **************************************************************************/
 
+#ifndef _INTEL_VIDEO_H_
+#define _INTEL_VIDEO_H_
+
 #include "xf86.h"
 #include "xf86_OSproc.h"
 
@@ -61,35 +64,100 @@ typedef struct {
 	int SyncToVblank;	/* -1: auto, 0: off, 1: on */
 } intel_adaptor_private;
 
+#define OFF_DELAY	250	/* milliseconds */
+
+#define OFF_TIMER	0x01
+#define CLIENT_VIDEO_ON	0x02
+
 static inline intel_adaptor_private *
 intel_get_adaptor_private(intel_screen_private *intel)
 {
 	return intel->adaptor->pPortPrivates[0].ptr;
 }
 
-void I915DisplayVideoTextured(ScrnInfoPtr scrn,
-			      intel_adaptor_private *adaptor_priv,
-			      int id, RegionPtr dstRegion, short width,
-			      short height, int video_pitch, int video_pitch2,
-			      short src_w, short src_h,
-			      short drw_w, short drw_h, PixmapPtr pixmap);
-
-void I965DisplayVideoTextured(ScrnInfoPtr scrn,
-			      intel_adaptor_private *adaptor_priv,
-			      int id, RegionPtr dstRegion, short width,
-			      short height, int video_pitch, int video_pitch2,
-			      short src_w, short src_h,
-			      short drw_w, short drw_h, PixmapPtr pixmap);
-
-void Gen6DisplayVideoTextured(ScrnInfoPtr scrn,
-			      intel_adaptor_private *adaptor_priv,
-			      int id, RegionPtr dstRegion, short width,
-			      short height, int video_pitch, int video_pitch2,
-			      short src_w, short src_h,
-			      short drw_w, short drw_h, PixmapPtr pixmap);
-
-void i965_free_video(ScrnInfoPtr scrn);
-
 int is_planar_fourcc(int id);
 
 void intel_video_block_handler(intel_screen_private *intel);
+
+int intel_video_query_image_attributes(ScrnInfoPtr, int, unsigned short *,
+                                       unsigned short *, int *, int *);
+
+Bool
+intel_video_copy_data(ScrnInfoPtr scrn, intel_adaptor_private *adaptor_priv,
+                      short width, short height, int *dstPitch, int *dstPitch2,
+                      int top, int left, int npixels, int nlines,
+                      int id, unsigned char *buf);
+
+Bool
+intel_clip_video_helper(ScrnInfoPtr scrn,
+			intel_adaptor_private *adaptor_priv,
+			xf86CrtcPtr * crtc_ret,
+			BoxPtr dst,
+			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);
+
+void
+intel_free_video_buffers(intel_adaptor_private *adaptor_priv);
+
+int
+intel_video_get_port_attribute(ScrnInfoPtr scrn,
+                               Atom attribute, INT32 * value, pointer data);
+
+void
+intel_video_query_best_size(ScrnInfoPtr, Bool,
+                            short, short, short, short, unsigned int *,
+                            unsigned int *, pointer);
+
+void
+intel_setup_dst_params(ScrnInfoPtr scrn, intel_adaptor_private *adaptor_priv, short width,
+		       short height, int *dstPitch, int *dstPitch2, int *size,
+		       int id);
+
+void intel_video_stop_video(ScrnInfoPtr scrn, pointer data, Bool shutdown);
+
+extern Atom intel_xv_Brightness, intel_xv_Contrast, intel_xv_Saturation, intel_xv_ColorKey, intel_xv_Pipe;
+extern Atom intel_xv_Gamma0, intel_xv_Gamma1, intel_xv_Gamma2, intel_xv_Gamma3, intel_xv_Gamma4, intel_xv_Gamma5;
+extern Atom intel_xv_SyncToVblank;
+
+#define MAKE_ATOM(a) MakeAtom(a, sizeof(a) - 1, TRUE)
+
+/* Limits for the overlay/textured video source sizes.  The documented hardware
+ * limits are 2048x2048 or better for overlay and both of our textured video
+ * implementations.  Additionally, on the 830 and 845, larger sizes resulted in
+ * the card hanging, so we keep the limits lower there.
+ */
+#define IMAGE_MAX_WIDTH		2048
+#define IMAGE_MAX_HEIGHT	2048
+#define IMAGE_MAX_WIDTH_LEGACY	1024
+#define IMAGE_MAX_HEIGHT_LEGACY	1088
+
+extern const XF86VideoEncodingRec intel_xv_dummy_encoding[1];
+
+#define NUM_FORMATS 3
+
+extern XF86VideoFormatRec intel_xv_formats[NUM_FORMATS];
+
+#define NUM_ATTRIBUTES 5
+
+extern XF86AttributeRec intel_xv_attributes[NUM_ATTRIBUTES];
+
+#define GAMMA_ATTRIBUTES 6
+
+extern XF86AttributeRec intel_xv_gamma_attributes[GAMMA_ATTRIBUTES];
+
+#ifdef INTEL_XVMC
+#define NUM_IMAGES 5
+#define XVMC_IMAGE 1
+#else
+#define NUM_IMAGES 4
+#define XVMC_IMAGE 0
+#endif
+
+extern XF86ImageRec intel_xv_images[NUM_IMAGES];
+
+#endif /* _INTEL_VIDEO_H_ */
diff --git a/src/uxa/intel_video_overlay.c b/src/uxa/intel_video_overlay.c
new file mode 100644
index 0000000..8e0eb7a
--- /dev/null
+++ b/src/uxa/intel_video_overlay.c
@@ -0,0 +1,554 @@
+/***************************************************************************
+
+ Copyright 2000 Intel Corporation.  All Rights Reserved.
+
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sub license, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice (including the
+ next paragraph) shall be included in all copies or substantial portions
+ of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ IN NO EVENT SHALL INTEL, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
+ THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+ **************************************************************************/
+
+/*
+ * i830_video.c: i830/i845 Xv driver.
+ *
+ * Copyright © 2002 by Alan Hourihane and David Dawes
+ *
+ * Authors:
+ *	Alan Hourihane <alanh@tungstengraphics.com>
+ *	David Dawes <dawes@xfree86.org>
+ *
+ * Derived from i810 Xv driver:
+ *
+ * Authors of i810 code:
+ * 	Jonathan Bian <jonathan.bian@intel.com>
+ *      Offscreen Images:
+ *        Matt Sottek <matthew.j.sottek@intel.com>
+ */
+
+/*
+ * XXX Could support more formats.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <inttypes.h>
+#include <math.h>
+#include <string.h>
+#include <assert.h>
+#include <errno.h>
+
+#include "xorg-server.h"
+#include "xf86.h"
+#include "xf86_OSproc.h"
+#include "compiler.h"
+#include "xf86Pci.h"
+#include "xf86fbman.h"
+#include "xf86drm.h"
+#include "regionstr.h"
+#include "randrstr.h"
+#include "windowstr.h"
+#include "damage.h"
+#include "intel.h"
+#include "intel_video.h"
+#include "i830_reg.h"
+#include "xf86xv.h"
+#include <X11/extensions/Xv.h>
+#include "dixstruct.h"
+#include "fourcc.h"
+#include "intel_video_overlay.h"
+
+/* overlay debugging printf function */
+#if 0
+#define OVERLAY_DEBUG ErrorF
+#else
+#define OVERLAY_DEBUG if (0) ErrorF
+#endif
+
+/* kernel modesetting overlay functions */
+static Bool intel_has_overlay(intel_screen_private *intel)
+{
+	struct drm_i915_getparam gp;
+	int has_overlay = 0;
+	int ret;
+
+	gp.param = I915_PARAM_HAS_OVERLAY;
+	gp.value = &has_overlay;
+	ret = drmCommandWriteRead(intel->drmSubFD, DRM_I915_GETPARAM, &gp, sizeof(gp));
+
+	return ret == 0 && !! has_overlay;
+}
+
+static Bool intel_overlay_update_attrs(intel_screen_private *intel)
+{
+	intel_adaptor_private *adaptor_priv = intel_get_adaptor_private(intel);
+	struct drm_intel_overlay_attrs attrs;
+
+	attrs.flags = I915_OVERLAY_UPDATE_ATTRS;
+	attrs.brightness = adaptor_priv->brightness;
+	attrs.contrast = adaptor_priv->contrast;
+	attrs.saturation = adaptor_priv->saturation;
+	attrs.color_key = adaptor_priv->colorKey;
+	attrs.gamma0 = adaptor_priv->gamma0;
+	attrs.gamma1 = adaptor_priv->gamma1;
+	attrs.gamma2 = adaptor_priv->gamma2;
+	attrs.gamma3 = adaptor_priv->gamma3;
+	attrs.gamma4 = adaptor_priv->gamma4;
+	attrs.gamma5 = adaptor_priv->gamma5;
+
+	return drmCommandWriteRead(intel->drmSubFD, DRM_I915_OVERLAY_ATTRS,
+				   &attrs, sizeof(attrs)) == 0;
+}
+
+void intel_video_overlay_off(intel_screen_private *intel)
+{
+	struct drm_intel_overlay_put_image request;
+	int ret;
+
+	request.flags = 0;
+
+	ret = drmCommandWrite(intel->drmSubFD, DRM_I915_OVERLAY_PUT_IMAGE,
+			      &request, sizeof(request));
+	(void) ret;
+}
+static int
+intel_video_overlay_set_port_attribute(ScrnInfoPtr scrn,
+                                       Atom attribute, INT32 value, pointer data)
+{
+	intel_adaptor_private *adaptor_priv = (intel_adaptor_private *) data;
+	intel_screen_private *intel = intel_get_screen_private(scrn);
+
+	if (attribute == intel_xv_Brightness) {
+		if ((value < -128) || (value > 127))
+			return BadValue;
+		adaptor_priv->brightness = value;
+		OVERLAY_DEBUG("BRIGHTNESS\n");
+	} else if (attribute == intel_xv_Contrast) {
+		if ((value < 0) || (value > 255))
+			return BadValue;
+		adaptor_priv->contrast = value;
+		OVERLAY_DEBUG("CONTRAST\n");
+	} else if (attribute == intel_xv_Saturation) {
+		if ((value < 0) || (value > 1023))
+			return BadValue;
+		adaptor_priv->saturation = value;
+	} else if (attribute == intel_xv_Pipe) {
+		xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
+		if ((value < -1) || (value >= xf86_config->num_crtc))
+			return BadValue;
+		if (value < 0)
+			adaptor_priv->desired_crtc = NULL;
+		else
+			adaptor_priv->desired_crtc = xf86_config->crtc[value];
+	} else if (attribute == intel_xv_Gamma0 && (INTEL_INFO(intel)->gen >= 030)) {
+		adaptor_priv->gamma0 = value;
+	} else if (attribute == intel_xv_Gamma1 && (INTEL_INFO(intel)->gen >= 030)) {
+		adaptor_priv->gamma1 = value;
+	} else if (attribute == intel_xv_Gamma2 && (INTEL_INFO(intel)->gen >= 030)) {
+		adaptor_priv->gamma2 = value;
+	} else if (attribute == intel_xv_Gamma3 && (INTEL_INFO(intel)->gen >= 030)) {
+		adaptor_priv->gamma3 = value;
+	} else if (attribute == intel_xv_Gamma4 && (INTEL_INFO(intel)->gen >= 030)) {
+		adaptor_priv->gamma4 = value;
+	} else if (attribute == intel_xv_Gamma5 && (INTEL_INFO(intel)->gen >= 030)) {
+		adaptor_priv->gamma5 = value;
+	} else if (attribute == intel_xv_ColorKey) {
+		adaptor_priv->colorKey = value;
+		OVERLAY_DEBUG("COLORKEY\n");
+	} else
+		return BadMatch;
+
+	if ((attribute == intel_xv_Gamma0 ||
+	     attribute == intel_xv_Gamma1 ||
+	     attribute == intel_xv_Gamma2 ||
+	     attribute == intel_xv_Gamma3 ||
+	     attribute == intel_xv_Gamma4 ||
+	     attribute == intel_xv_Gamma5) && (INTEL_INFO(intel)->gen >= 030)) {
+		OVERLAY_DEBUG("GAMMA\n");
+	}
+
+	if (!intel_overlay_update_attrs(intel))
+		return BadValue;
+
+	if (attribute == intel_xv_ColorKey)
+		REGION_EMPTY(scrn->pScreen, &adaptor_priv->clip);
+
+	return Success;
+}
+
+static Bool
+intel_overlay_put_image(intel_screen_private *intel,
+                        xf86CrtcPtr crtc,
+                        int id, short width, short height,
+                        int dstPitch, int dstPitch2,
+                        BoxPtr dstBox, short src_w, short src_h, short drw_w,
+                        short drw_h)
+{
+	intel_adaptor_private *adaptor_priv = intel_get_adaptor_private(intel);
+	struct drm_intel_overlay_put_image request;
+	int ret;
+	int planar = is_planar_fourcc(id);
+	float scale;
+	dri_bo *tmp;
+
+	request.flags = I915_OVERLAY_ENABLE;
+
+	request.bo_handle = adaptor_priv->buf->handle;
+	if (planar) {
+		request.stride_Y = dstPitch2;
+		request.stride_UV = dstPitch;
+	} else {
+		request.stride_Y = dstPitch;
+		request.stride_UV = 0;
+	}
+	request.offset_Y = adaptor_priv->YBufOffset;
+	request.offset_U = adaptor_priv->UBufOffset;
+	request.offset_V = adaptor_priv->VBufOffset;
+	OVERLAY_DEBUG("off_Y: %i, off_U: %i, off_V: %i\n", request.offset_Y,
+		      request.offset_U, request.offset_V);
+
+	request.crtc_id = intel_crtc_id(crtc);
+	request.dst_x = dstBox->x1;
+	request.dst_y = dstBox->y1;
+	request.dst_width = dstBox->x2 - dstBox->x1;
+	request.dst_height = dstBox->y2 - dstBox->y1;
+
+	request.src_width = width;
+	request.src_height = height;
+	/* adjust src dimensions */
+	if (request.dst_height > 1) {
+		scale = ((float)request.dst_height - 1) / ((float)drw_h - 1);
+		request.src_scan_height = src_h * scale;
+	} else
+		request.src_scan_height = 1;
+
+	if (request.dst_width > 1) {
+		scale = ((float)request.dst_width - 1) / ((float)drw_w - 1);
+		request.src_scan_width = src_w * scale;
+	} else
+		request.src_scan_width = 1;
+
+	if (planar) {
+		request.flags |= I915_OVERLAY_YUV_PLANAR | I915_OVERLAY_YUV420;
+	} else {
+		request.flags |= I915_OVERLAY_YUV_PACKED | I915_OVERLAY_YUV422;
+		if (id == FOURCC_UYVY)
+			request.flags |= I915_OVERLAY_Y_SWAP;
+	}
+
+	ret = drmCommandWrite(intel->drmSubFD, DRM_I915_OVERLAY_PUT_IMAGE,
+			      &request, sizeof(request));
+	if (ret)
+		return FALSE;
+
+	if (!adaptor_priv->reusable) {
+		drm_intel_bo_unreference(adaptor_priv->buf);
+		adaptor_priv->buf = NULL;
+		adaptor_priv->reusable = TRUE;
+	}
+
+	tmp = adaptor_priv->old_buf[1];
+	adaptor_priv->old_buf[1] = adaptor_priv->old_buf[0];
+	adaptor_priv->old_buf[0] = adaptor_priv->buf;
+	adaptor_priv->buf = tmp;
+
+	return TRUE;
+}
+
+static void
+intel_update_dst_box_to_crtc_coords(ScrnInfoPtr scrn, xf86CrtcPtr crtc,
+				    BoxPtr dstBox)
+{
+	int tmp;
+
+	/* for overlay, we should take it from crtc's screen
+	 * coordinate to current crtc's display mode.
+	 * yeah, a bit confusing.
+	 */
+	switch (crtc->rotation & 0xf) {
+	case RR_Rotate_0:
+		dstBox->x1 -= crtc->x;
+		dstBox->x2 -= crtc->x;
+		dstBox->y1 -= crtc->y;
+		dstBox->y2 -= crtc->y;
+		break;
+	case RR_Rotate_90:
+		tmp = dstBox->x1;
+		dstBox->x1 = dstBox->y1 - crtc->x;
+		dstBox->y1 = scrn->virtualX - tmp - crtc->y;
+		tmp = dstBox->x2;
+		dstBox->x2 = dstBox->y2 - crtc->x;
+		dstBox->y2 = scrn->virtualX - tmp - crtc->y;
+		tmp = dstBox->y1;
+		dstBox->y1 = dstBox->y2;
+		dstBox->y2 = tmp;
+		break;
+	case RR_Rotate_180:
+		tmp = dstBox->x1;
+		dstBox->x1 = scrn->virtualX - dstBox->x2 - crtc->x;
+		dstBox->x2 = scrn->virtualX - tmp - crtc->x;
+		tmp = dstBox->y1;
+		dstBox->y1 = scrn->virtualY - dstBox->y2 - crtc->y;
+		dstBox->y2 = scrn->virtualY - tmp - crtc->y;
+		break;
+	case RR_Rotate_270:
+		tmp = dstBox->x1;
+		dstBox->x1 = scrn->virtualY - dstBox->y1 - crtc->x;
+		dstBox->y1 = tmp - crtc->y;
+		tmp = dstBox->x2;
+		dstBox->x2 = scrn->virtualY - dstBox->y2 - crtc->x;
+		dstBox->y2 = tmp - crtc->y;
+		tmp = dstBox->x1;
+		dstBox->x1 = dstBox->x2;
+		dstBox->x2 = tmp;
+		break;
+	}
+
+	return;
+}
+
+static Bool
+intel_video_overlay_display(ScrnInfoPtr scrn, xf86CrtcPtr crtc,
+                            int id, short width, short height,
+                            int dstPitch, int dstPitch2,
+                            BoxPtr dstBox, short src_w, short src_h, short drw_w,
+                            short drw_h)
+{
+	intel_screen_private *intel = intel_get_screen_private(scrn);
+	int tmp;
+
+	OVERLAY_DEBUG("I830DisplayVideo: %dx%d (pitch %d)\n", width, height,
+		      dstPitch);
+
+	/*
+	 * If the video isn't visible on any CRTC, turn it off
+	 */
+	if (!crtc) {
+		intel_video_overlay_off(intel);
+		return TRUE;
+	}
+
+	intel_update_dst_box_to_crtc_coords(scrn, 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 intel_overlay_put_image(intel, crtc, id,
+					 width, height,
+					 dstPitch, dstPitch2, dstBox,
+					 src_w, src_h, drw_w, drw_h);
+}
+
+static int
+intel_video_overlay_put_image(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;
+	int dstPitch, dstPitch2;
+	BoxRec dstBox;
+	xf86CrtcPtr crtc;
+	int top, left, npixels, nlines;
+
+#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;
+
+	if (!intel_clip_video_helper(scrn,
+				    adaptor_priv,
+				    &crtc,
+				    &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;
+
+	/* 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 (!intel_video_copy_data(scrn, adaptor_priv, width, height,
+				  &dstPitch, &dstPitch2,
+				  top, left, npixels, nlines, id, buf))
+		return BadAlloc;
+
+	if (!intel_video_overlay_display
+	    (scrn, crtc, id, width, height, dstPitch, dstPitch2,
+	     &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);
+		xf86XVFillKeyHelperDrawable(drawable,
+					    adaptor_priv->colorKey,
+					    clipBoxes);
+	}
+
+	adaptor_priv->videoStatus = CLIENT_VIDEO_ON;
+
+	return Success;
+}
+
+XF86VideoAdaptorPtr intel_video_overlay_setup_image(ScreenPtr screen)
+{
+	ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
+	intel_screen_private *intel = intel_get_screen_private(scrn);
+	XF86VideoAdaptorPtr adapt;
+	intel_adaptor_private *adaptor_priv;
+	XF86AttributePtr att;
+
+	/* Set up overlay video if it is available */
+	intel->use_overlay = intel_has_overlay(intel);
+	if (!intel->use_overlay)
+                return NULL;
+
+	OVERLAY_DEBUG("intel_video_overlay_setup_image\n");
+
+	if (!(adapt = calloc(1,
+			     sizeof(XF86VideoAdaptorRec) +
+			     sizeof(intel_adaptor_private) +
+			     sizeof(DevUnion))))
+		return NULL;
+
+	adapt->type = XvWindowMask | XvInputMask | XvImageMask;
+	adapt->flags = VIDEO_OVERLAID_IMAGES /*| VIDEO_CLIP_TO_VIEWPORT */ ;
+	adapt->name = "Intel(R) Video Overlay";
+	adapt->nEncodings = 1;
+	adapt->pEncodings = xnfalloc(sizeof(intel_xv_dummy_encoding));
+	memcpy(adapt->pEncodings, intel_xv_dummy_encoding, sizeof(intel_xv_dummy_encoding));
+	if (IS_845G(intel) || IS_I830(intel)) {
+		adapt->pEncodings->width = IMAGE_MAX_WIDTH_LEGACY;
+		adapt->pEncodings->height = IMAGE_MAX_HEIGHT_LEGACY;
+	}
+	adapt->nFormats = NUM_FORMATS;
+	adapt->pFormats = intel_xv_formats;
+	adapt->nPorts = 1;
+	adapt->pPortPrivates = (DevUnion *) (&adapt[1]);
+
+	adaptor_priv = (intel_adaptor_private *)&adapt->pPortPrivates[1];
+
+	adapt->pPortPrivates[0].ptr = (pointer) (adaptor_priv);
+	adapt->nAttributes = NUM_ATTRIBUTES;
+	if (INTEL_INFO(intel)->gen >= 030)
+		adapt->nAttributes += GAMMA_ATTRIBUTES;	/* has gamma */
+	adapt->pAttributes =
+	    xnfalloc(sizeof(XF86AttributeRec) * adapt->nAttributes);
+	/* Now copy the attributes */
+	att = adapt->pAttributes;
+	memcpy((char *)att, (char *)intel_xv_attributes,
+	       sizeof(XF86AttributeRec) * NUM_ATTRIBUTES);
+	att += NUM_ATTRIBUTES;
+	if (INTEL_INFO(intel)->gen >= 030) {
+		memcpy((char *)att, (char *)intel_xv_gamma_attributes,
+		       sizeof(XF86AttributeRec) * GAMMA_ATTRIBUTES);
+	}
+	adapt->nImages = NUM_IMAGES - XVMC_IMAGE;
+
+	adapt->pImages = intel_xv_images;
+	adapt->PutVideo = NULL;
+	adapt->PutStill = NULL;
+	adapt->GetVideo = NULL;
+	adapt->GetStill = NULL;
+	adapt->StopVideo = intel_video_stop_video;
+	adapt->SetPortAttribute = intel_video_overlay_set_port_attribute;
+	adapt->GetPortAttribute = intel_video_get_port_attribute;
+	adapt->QueryBestSize = intel_video_query_best_size;
+	adapt->PutImage = intel_video_overlay_put_image;
+	adapt->QueryImageAttributes = intel_video_query_image_attributes;
+
+	adaptor_priv->textured = FALSE;
+	adaptor_priv->colorKey = intel->colorKey & ((1 << scrn->depth) - 1);
+	adaptor_priv->videoStatus = 0;
+	adaptor_priv->brightness = -19;	/* (255/219) * -16 */
+	adaptor_priv->contrast = 75;	/* 255/219 * 64 */
+	adaptor_priv->saturation = 146;	/* 128/112 * 128 */
+	adaptor_priv->desired_crtc = NULL;
+	adaptor_priv->buf = NULL;
+	adaptor_priv->old_buf[0] = NULL;
+	adaptor_priv->old_buf[1] = NULL;
+	adaptor_priv->gamma5 = 0xc0c0c0;
+	adaptor_priv->gamma4 = 0x808080;
+	adaptor_priv->gamma3 = 0x404040;
+	adaptor_priv->gamma2 = 0x202020;
+	adaptor_priv->gamma1 = 0x101010;
+	adaptor_priv->gamma0 = 0x080808;
+
+	adaptor_priv->rotation = RR_Rotate_0;
+
+	/* gotta uninit this someplace */
+	REGION_NULL(screen, &adaptor_priv->clip);
+
+	intel->adaptor = adapt;
+
+	intel_xv_ColorKey = MAKE_ATOM("XV_COLORKEY");
+	intel_xv_Brightness = MAKE_ATOM("XV_BRIGHTNESS");
+	intel_xv_Contrast = MAKE_ATOM("XV_CONTRAST");
+	intel_xv_Saturation = MAKE_ATOM("XV_SATURATION");
+
+	/* Allow the pipe to be switched from pipe A to B when in clone mode */
+	intel_xv_Pipe = MAKE_ATOM("XV_PIPE");
+
+	if (INTEL_INFO(intel)->gen >= 030) {
+		intel_xv_Gamma0 = MAKE_ATOM("XV_GAMMA0");
+		intel_xv_Gamma1 = MAKE_ATOM("XV_GAMMA1");
+		intel_xv_Gamma2 = MAKE_ATOM("XV_GAMMA2");
+		intel_xv_Gamma3 = MAKE_ATOM("XV_GAMMA3");
+		intel_xv_Gamma4 = MAKE_ATOM("XV_GAMMA4");
+		intel_xv_Gamma5 = MAKE_ATOM("XV_GAMMA5");
+	}
+
+	intel_overlay_update_attrs(intel);
+
+	return adapt;
+}
diff --git a/src/uxa/intel_video_overlay.h b/src/uxa/intel_video_overlay.h
new file mode 100644
index 0000000..b318a05
--- /dev/null
+++ b/src/uxa/intel_video_overlay.h
@@ -0,0 +1,51 @@
+/***************************************************************************
+
+ Copyright 2000 Intel Corporation.  All Rights Reserved.
+
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sub license, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice (including the
+ next paragraph) shall be included in all copies or substantial portions
+ of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ IN NO EVENT SHALL INTEL, AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
+ THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+ **************************************************************************/
+
+/*
+ * i830_video.c: i830/i845 Xv driver.
+ *
+ * Copyright © 2002 by Alan Hourihane and David Dawes
+ *
+ * Authors:
+ *	Alan Hourihane <alanh@tungstengraphics.com>
+ *	David Dawes <dawes@xfree86.org>
+ *
+ * Derived from i810 Xv driver:
+ *
+ * Authors of i810 code:
+ * 	Jonathan Bian <jonathan.bian@intel.com>
+ *      Offscreen Images:
+ *        Matt Sottek <matthew.j.sottek@intel.com>
+ */
+
+#ifndef _INTEL_VIDEO_OVERLAY_H_
+#define _INTEL_VIDEO_OVERLAY_H_
+
+XF86VideoAdaptorPtr intel_video_overlay_setup_image(ScreenPtr);
+
+void intel_video_overlay_off(intel_screen_private *intel);
+
+#endif /* _INTEL_VIDEO_OVERLAY_H_ */
-- 
2.0.1


_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 06/12] Remove glamor support from UXA acceleration
  2014-07-24 23:18 [PATCH 00/12] Rework intel 2D driver glamor support Keith Packard
                   ` (3 preceding siblings ...)
  2014-07-24 23:18 ` [PATCH 05/12] Rename uxa-specific functions and structs Keith Packard
@ 2014-07-24 23:18 ` Keith Packard
       [not found]   ` <1406243908-1123-7-git-send-email-keithp-aN4HjG94KOLQT0dZR+AlfA@public.gmane.org>
  2014-07-24 23:18 ` [PATCH 09/12] Do more checks for proposed flip pixmaps Keith Packard
       [not found] ` <1406243908-1123-1-git-send-email-keithp-aN4HjG94KOLQT0dZR+AlfA@public.gmane.org>
  6 siblings, 1 reply; 35+ messages in thread
From: Keith Packard @ 2014-07-24 23:18 UTC (permalink / raw)
  To: xorg-devel, intel-gfx

Makes UXA no longer include calls to glamor acceleration functions.

Signed-off-by: Keith Packard <keithp@keithp.com>
---
 src/uxa/Makefile.am    |   9 --
 src/uxa/intel_dri.c    |  60 +------------
 src/uxa/intel_driver.c |   1 -
 src/uxa/intel_uxa.c    |  49 -----------
 src/uxa/intel_uxa.h    |   1 -
 src/uxa/uxa-accel.c    | 230 -------------------------------------------------
 src/uxa/uxa-glamor.h   |  65 --------------
 src/uxa/uxa-glyphs.c   |  28 ------
 src/uxa/uxa-render.c   |  79 -----------------
 src/uxa/uxa.c          |   7 --
 src/uxa/uxa.h          |  16 ----
 11 files changed, 2 insertions(+), 543 deletions(-)
 delete mode 100644 src/uxa/uxa-glamor.h

diff --git a/src/uxa/Makefile.am b/src/uxa/Makefile.am
index 23b074d..b9618c9 100644
--- a/src/uxa/Makefile.am
+++ b/src/uxa/Makefile.am
@@ -34,7 +34,6 @@ libuxa_la_SOURCES = \
 	intel_batchbuffer.h \
 	intel_display.c \
 	intel_driver.c \
-	intel_glamor.h \
 	intel_memory.c \
 	intel_uxa.c \
 	intel_video.c \
@@ -65,14 +64,6 @@ libuxa_la_SOURCES = \
 	uxa-unaccel.c
 	$(NULL)
 
-if GLAMOR
-AM_CFLAGS += $(LIBGLAMOR_CFLAGS)
-libuxa_la_LIBADD += $(LIBGLAMOR_LIBS)
-libuxa_la_SOURCES += \
-	 intel_glamor.c \
-	 $(NULL)
-endif
-
 if DRI2
 AM_CFLAGS += $(DRI2_CFLAGS)
 libuxa_la_SOURCES += \
diff --git a/src/uxa/intel_dri.c b/src/uxa/intel_dri.c
index 65612f7..79978ab 100644
--- a/src/uxa/intel_dri.c
+++ b/src/uxa/intel_dri.c
@@ -793,38 +793,6 @@ I830DRI2ExchangeBuffers(struct intel_screen_private *intel, DRI2BufferPtr front,
 	dri_bo_reference (intel->front_buffer);
 }
 
-static PixmapPtr
-intel_glamor_create_back_pixmap(ScreenPtr screen,
-				PixmapPtr front_pixmap,
-				drm_intel_bo *back_bo)
-{
-	PixmapPtr back_pixmap;
-
-	back_pixmap = screen->CreatePixmap(screen,
-					   0,
-					   0,
-				           front_pixmap->drawable.depth,
-				           0);
-	if (back_pixmap == NULL)
-		return NULL;
-
-	screen->ModifyPixmapHeader(back_pixmap,
-				   front_pixmap->drawable.width,
-				   front_pixmap->drawable.height,
-				   0, 0,
-				   front_pixmap->devKind,
-				   0);
-	intel_set_pixmap_bo(back_pixmap, back_bo);
-	if (!intel_glamor_create_textured_pixmap(back_pixmap)) {
-		ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
-		xf86DrvMsg(scrn->scrnIndex, X_WARNING,
-			   "Failed to create textured back pixmap.\n");
-		screen->DestroyPixmap(back_pixmap);
-		return NULL;
-	}
-	return back_pixmap;
-}
-
 static drm_intel_bo *get_pixmap_bo(I830DRI2BufferPrivatePtr priv)
 {
 	drm_intel_bo *bo = intel_get_pixmap_bo(priv->pixmap);
@@ -883,10 +851,6 @@ I830DRI2ScheduleFlip(struct intel_screen_private *intel,
 	}
 
 	if (intel->back_buffer == NULL) {
-		I830DRI2BufferPrivatePtr drvpriv;
-		PixmapPtr front_pixmap, back_pixmap;
-		ScreenPtr screen;
-
 		new_back = drm_intel_bo_alloc(intel->bufmgr, "front buffer",
 					      intel->front_buffer->size, 0);
 		if (new_back == NULL)
@@ -903,21 +867,6 @@ I830DRI2ScheduleFlip(struct intel_screen_private *intel,
 
 		drm_intel_bo_disable_reuse(new_back);
 		dri_bo_flink(new_back, &intel->back_name);
-
-		if ((intel->uxa_flags & UXA_USE_GLAMOR)) {
-			screen = draw->pScreen;
-			drvpriv = info->front->driverPrivate;
-			front_pixmap = drvpriv->pixmap;
-
-			back_pixmap = intel_glamor_create_back_pixmap(screen,
-								      front_pixmap,
-								      new_back);
-			if (back_pixmap == NULL) {
-				drm_intel_bo_unreference(new_back);
-				return FALSE;
-			}
-			intel->back_pixmap = back_pixmap;
-		}
 	} else {
 		new_back = intel->back_buffer;
 		intel->back_buffer = NULL;
@@ -937,13 +886,8 @@ I830DRI2ScheduleFlip(struct intel_screen_private *intel,
 
 	intel->back_buffer = intel->front_buffer;
 	drm_intel_bo_reference(intel->back_buffer);
-	if (!(intel->uxa_flags & UXA_USE_GLAMOR)) {
-		intel_set_pixmap_bo(priv->pixmap, new_back);
-		drm_intel_bo_unreference(new_back);
-	}
-	else
-		intel_exchange_pixmap_buffers(intel, priv->pixmap,
-					      intel->back_pixmap);
+        intel_set_pixmap_bo(priv->pixmap, new_back);
+        drm_intel_bo_unreference(new_back);
 
 	tmp_name = info->front->name;
 	info->front->name = intel->back_name;
diff --git a/src/uxa/intel_driver.c b/src/uxa/intel_driver.c
index 8ab2252..d9f918b 100644
--- a/src/uxa/intel_driver.c
+++ b/src/uxa/intel_driver.c
@@ -963,7 +963,6 @@ I830ScreenInit(SCREEN_INIT_ARGS_DECL)
 	intel->CreateScreenResources = screen->CreateScreenResources;
 	screen->CreateScreenResources = i830CreateScreenResources;
 
-	intel_glamor_init(screen);
 	if (!xf86CrtcScreenInit(screen))
 		return FALSE;
 
diff --git a/src/uxa/intel_uxa.c b/src/uxa/intel_uxa.c
index 7ea9325..da4eb97 100644
--- a/src/uxa/intel_uxa.c
+++ b/src/uxa/intel_uxa.c
@@ -40,7 +40,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include <unistd.h>
 
 #include "intel.h"
-#include "intel_glamor.h"
 #include "uxa.h"
 
 #include "i830_reg.h"
@@ -660,16 +659,6 @@ static Bool intel_uxa_prepare_access(PixmapPtr pixmap, uxa_access_t access)
 	dri_bo *bo = priv->bo;
 	int ret;
 
-	/* Transitioning to glamor acceleration, we need to flush all pending
-	 * usage by UXA. */
-	if (access == UXA_GLAMOR_ACCESS_RW || access == UXA_GLAMOR_ACCESS_RO) {
-		if (!list_is_empty(&priv->batch))
-			intel_batch_submit(scrn);
-		return TRUE;
-	}
-
-	/* When falling back to swrast, flush all pending operations */
-	intel_glamor_flush(intel);
 	if (access == UXA_ACCESS_RW || priv->dirty)
 		intel_batch_submit(scrn);
 
@@ -695,9 +684,6 @@ static void intel_uxa_finish_access(PixmapPtr pixmap, uxa_access_t access)
 {
 	struct intel_uxa_pixmap *priv;
 
-	if (access == UXA_GLAMOR_ACCESS_RW || access == UXA_GLAMOR_ACCESS_RO)
-		return;
-
 	priv = intel_uxa_get_pixmap_private(pixmap);
 	if (priv == NULL)
 		return;
@@ -967,7 +953,6 @@ void intel_uxa_block_handler(intel_screen_private *intel)
 	 * and beyond rendering results may not hit the
 	 * framebuffer until significantly later.
 	 */
-	intel_glamor_flush(intel);
 	intel_flush_rendering(intel);
 	intel_throttle(intel);
 }
@@ -981,12 +966,6 @@ intel_uxa_create_pixmap(ScreenPtr screen, int w, int h, int depth,
 	struct intel_uxa_pixmap *priv;
 	PixmapPtr pixmap, new_pixmap = NULL;
 
-	if (!(usage & INTEL_CREATE_PIXMAP_DRI2)) {
-		pixmap = intel_glamor_create_pixmap(screen, w, h, depth, usage);
-		if (pixmap)
-			return pixmap;
-	}
-
 	if (w > 32767 || h > 32767)
 		return NullPixmap;
 
@@ -1067,34 +1046,10 @@ intel_uxa_create_pixmap(ScreenPtr screen, int w, int h, int depth,
 
 		screen->ModifyPixmapHeader(pixmap, w, h, 0, 0, stride, NULL);
 
-		if (!intel_glamor_create_textured_pixmap(pixmap))
-			goto fallback_glamor;
 	}
 
 	return pixmap;
 
-fallback_glamor:
-	if (usage & INTEL_CREATE_PIXMAP_DRI2) {
-	/* XXX need further work to handle the DRI2 failure case.
-	 * Glamor don't know how to handle a BO only pixmap. Put
-	 * a warning indicator here.
-	 */
-		xf86DrvMsg(scrn->scrnIndex, X_WARNING,
-			   "Failed to create textured DRI2 pixmap.");
-		return pixmap;
-	}
-	/* Create textured pixmap failed means glamor failed to
-	 * create a texture from current BO for some reasons. We turn
-	 * to create a new glamor pixmap and clean up current one.
-	 * One thing need to be noted, this new pixmap doesn't
-	 * has a priv and bo attached to it. It's glamor's responsbility
-	 * to take care of it. Glamor will mark this new pixmap as a
-	 * texture only pixmap and will never fallback to DDX layer
-	 * afterwards.
-	 */
-	new_pixmap = intel_glamor_create_pixmap(screen, w, h,
-						depth, usage);
-	dri_bo_unreference(priv->bo);
 fallback_priv:
 	free(priv);
 fallback_pixmap:
@@ -1108,7 +1063,6 @@ fallback_pixmap:
 static Bool intel_uxa_destroy_pixmap(PixmapPtr pixmap)
 {
 	if (pixmap->refcnt == 1) {
-		intel_glamor_destroy_pixmap(pixmap);
 		intel_uxa_set_pixmap_bo(pixmap, NULL);
 	}
 	fbDestroyPixmap(pixmap);
@@ -1146,9 +1100,6 @@ Bool intel_uxa_create_screen_resources(ScreenPtr screen)
 	if (intel_uxa_get_pixmap_private(pixmap) == NULL)
 		goto err;
 
-	if (!intel_glamor_create_screen_resources(screen))
-		goto err;
-
 	intel_uxa_get_pixmap_private(pixmap)->pinned |= PIN_SCANOUT;
 	scrn->displayWidth = intel->front_pitch / intel->cpp;
 
diff --git a/src/uxa/intel_uxa.h b/src/uxa/intel_uxa.h
index 34903a3..69500a8 100644
--- a/src/uxa/intel_uxa.h
+++ b/src/uxa/intel_uxa.h
@@ -40,7 +40,6 @@ struct intel_uxa_pixmap {
 #define PIN_DRI2 0x2
 #define PIN_DRI3 0x4
 #define PIN_PRIME 0x8
-#define PIN_GLAMOR 0x10
 };
 
 #if HAS_DEVPRIVATEKEYREC
diff --git a/src/uxa/uxa-accel.c b/src/uxa/uxa-accel.c
index 757b276..b0d3c80 100644
--- a/src/uxa/uxa-accel.c
+++ b/src/uxa/uxa-accel.c
@@ -32,7 +32,6 @@
 #include <dix-config.h>
 #endif
 #include "uxa-priv.h"
-#include "uxa-glamor.h"
 #include <X11/fonts/fontstruct.h>
 #include "dixfontstr.h"
 #include "uxa.h"
@@ -50,21 +49,6 @@ uxa_fill_spans(DrawablePtr pDrawable, GCPtr pGC, int n,
 	int x1, x2, y;
 	int off_x, off_y;
 
-	if (uxa_screen->info->flags & UXA_USE_GLAMOR) {
-		int ok = 0;
-
-		if (uxa_prepare_access(pDrawable, UXA_GLAMOR_ACCESS_RW)) {
-			ok = glamor_fill_spans_nf(pDrawable,
-						  pGC, n, ppt, pwidth, fSorted);
-			uxa_finish_access(pDrawable, UXA_GLAMOR_ACCESS_RW);
-		}
-
-		if (!ok)
-			goto fallback;
-
-		return;
-	}
-
 	if (uxa_screen->force_fallback)
 		goto fallback;
 
@@ -210,26 +194,9 @@ static void
 uxa_put_image(DrawablePtr pDrawable, GCPtr pGC, int depth, int x, int y,
 	      int w, int h, int leftPad, int format, char *bits)
 {
-	uxa_screen_t *uxa_screen = uxa_get_screen(pDrawable->pScreen);
-
-	if (uxa_screen->info->flags & UXA_USE_GLAMOR) {
-		int ok = 0;
-
-		if (uxa_prepare_access(pDrawable, UXA_GLAMOR_ACCESS_RW)) {
-			ok = glamor_put_image_nf(pDrawable,
-						 pGC, depth, x, y, w, h,
-						 leftPad, format, bits);
-			uxa_finish_access(pDrawable, UXA_GLAMOR_ACCESS_RW);
-		}
-		if (!ok)
-			goto fallback;
-
-		return;
-	}
 
 	if (!uxa_do_put_image(pDrawable, pGC, depth, x, y, w, h, format, bits,
 			      PixmapBytePad(w, pDrawable->depth))) {
-fallback:
 		uxa_check_put_image(pDrawable, pGC, depth, x, y, w, h, leftPad,
 				    format, bits);
 	}
@@ -374,26 +341,6 @@ uxa_copy_n_to_n(DrawablePtr pSrcDrawable,
 	int dst_off_x, dst_off_y;
 	PixmapPtr pSrcPixmap, pDstPixmap;
 
-	if (uxa_screen->info->flags & UXA_USE_GLAMOR) {
-		int ok = 0;
-
-		if (uxa_prepare_access(pSrcDrawable, UXA_GLAMOR_ACCESS_RO)) {
-			if (uxa_prepare_access(pDstDrawable, UXA_GLAMOR_ACCESS_RW)) {
-				ok = glamor_copy_n_to_n_nf(pSrcDrawable, pDstDrawable,
-							   pGC, pbox, nbox, dx, dy,
-							   reverse, upsidedown, bitplane,
-							   closure);
-				uxa_finish_access(pDstDrawable, UXA_GLAMOR_ACCESS_RW);
-			}
-			uxa_finish_access(pSrcDrawable, UXA_GLAMOR_ACCESS_RO);
-		}
-
-		if (!ok)
-			goto fallback;
-
-		return;
-	}
-
 	if (uxa_screen->force_fallback)
 		goto fallback;
 
@@ -560,19 +507,6 @@ uxa_poly_point(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
 {
 	int i;
 	xRectangle *prect;
-	uxa_screen_t *uxa_screen = uxa_get_screen(pDrawable->pScreen);
-
-	if (uxa_screen->info->flags & UXA_USE_GLAMOR) {
-		int ok = 0;
-
-		if (uxa_prepare_access(pDrawable, UXA_GLAMOR_ACCESS_RW)) {
-			ok = glamor_poly_point_nf(pDrawable, pGC, mode, npt, ppt);
-			uxa_finish_access(pDrawable, UXA_GLAMOR_ACCESS_RW);
-		}
-
-		if (ok)
-			return;
-	}
 
 	/* If we can't reuse the current GC as is, don't bother accelerating the
 	 * points.
@@ -611,19 +545,6 @@ uxa_poly_lines(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
 	xRectangle *prect;
 	int x1, x2, y1, y2;
 	int i;
-	uxa_screen_t *uxa_screen = uxa_get_screen(pDrawable->pScreen);
-
-	if (uxa_screen->info->flags & UXA_USE_GLAMOR) {
-		int ok = 0;
-
-		if (uxa_prepare_access(pDrawable, UXA_GLAMOR_ACCESS_RW)) {
-			ok = glamor_poly_lines_nf(pDrawable, pGC, mode, npt, ppt);
-			uxa_finish_access(pDrawable, UXA_GLAMOR_ACCESS_RW);
-		}
-
-		if (ok)
-			return;
-	}
 
 	/* Don't try to do wide lines or non-solid fill style. */
 	if (pGC->lineWidth != 0 || pGC->lineStyle != LineSolid ||
@@ -685,19 +606,6 @@ uxa_poly_segment(DrawablePtr pDrawable, GCPtr pGC, int nseg, xSegment * pSeg)
 {
 	xRectangle *prect;
 	int i;
-	uxa_screen_t *uxa_screen = uxa_get_screen(pDrawable->pScreen);
-
-	if (uxa_screen->info->flags & UXA_USE_GLAMOR) {
-		int ok = 0;
-
-		if (uxa_prepare_access(pDrawable, UXA_GLAMOR_ACCESS_RW)) {
-			ok = glamor_poly_segment_nf(pDrawable, pGC, nseg, pSeg);
-			uxa_finish_access(pDrawable, UXA_GLAMOR_ACCESS_RW);
-		}
-
-		if (ok)
-			return;
-	}
 
 	/* Don't try to do wide lines or non-solid fill style. */
 	if (pGC->lineWidth != 0 || pGC->lineStyle != LineSolid ||
@@ -762,20 +670,6 @@ uxa_poly_fill_rect(DrawablePtr pDrawable,
 	int xorg, yorg;
 	int n;
 
-	if (uxa_screen->info->flags & UXA_USE_GLAMOR) {
-		int ok = 0;
-
-		if (uxa_prepare_access(pDrawable, UXA_GLAMOR_ACCESS_RW)) {
-			ok = glamor_poly_fill_rect_nf(pDrawable, pGC, nrect, prect);
-			uxa_finish_access(pDrawable, UXA_GLAMOR_ACCESS_RW);
-		}
-
-		if (!ok)
-			uxa_check_poly_fill_rect(pDrawable, pGC, nrect, prect);
-
-		return;
-	}
-
 	/* Compute intersection of rects and clip region */
 	pReg = RECTS_TO_REGION(pScreen, nrect, prect, CT_UNSORTED);
 	REGION_TRANSLATE(pScreen, pReg, pDrawable->x, pDrawable->y);
@@ -885,25 +779,6 @@ uxa_get_spans(DrawablePtr pDrawable,
 	      int wMax,
 	      DDXPointPtr ppt, int *pwidth, int nspans, char *pdstStart)
 {
-	ScreenPtr screen = pDrawable->pScreen;
-	uxa_screen_t *uxa_screen = uxa_get_screen(screen);
-
-	if (uxa_screen->info->flags & UXA_USE_GLAMOR) {
-		int ok = 0;
-
-		if (uxa_prepare_access(pDrawable, UXA_GLAMOR_ACCESS_RW)) {
-			ok = glamor_get_spans_nf(pDrawable, wMax, ppt,
-						 pwidth, nspans, pdstStart);
-			uxa_finish_access(pDrawable, UXA_GLAMOR_ACCESS_RW);
-		}
-
-		if (!ok)
-			goto fallback;
-
-		return;
-	}
-
-fallback:
 	uxa_check_get_spans(pDrawable, wMax, ppt, pwidth, nspans, pdstStart);
 }
 
@@ -911,25 +786,6 @@ static void
 uxa_set_spans(DrawablePtr pDrawable, GCPtr gc, char *src,
                  DDXPointPtr points, int *widths, int n, int sorted)
 {
-	ScreenPtr screen = pDrawable->pScreen;
-	uxa_screen_t *uxa_screen = uxa_get_screen(screen);
-
-	if (uxa_screen->info->flags & UXA_USE_GLAMOR) {
-		int ok = 0;
-
-		if (uxa_prepare_access(pDrawable, UXA_GLAMOR_ACCESS_RW)) {
-			ok = glamor_set_spans_nf(pDrawable, gc, src,
-						 points, widths, n, sorted);
-			uxa_finish_access(pDrawable, UXA_GLAMOR_ACCESS_RW);
-		}
-
-		if (!ok)
-			goto fallback;
-
-		return;
-	}
-
-fallback:
 	uxa_check_set_spans(pDrawable, gc, src, points, widths, n, sorted);
 }
 
@@ -938,27 +794,6 @@ uxa_copy_plane(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
 	       int srcx, int srcy, int w, int h, int dstx, int dsty,
 	       unsigned long bitPlane)
 {
-	ScreenPtr screen = pDst->pScreen;
-	uxa_screen_t *uxa_screen = uxa_get_screen(screen);
-
-	if (uxa_screen->info->flags & UXA_USE_GLAMOR) {
-		RegionPtr region = NULL;
-		int ok = 0;
-
-		if (uxa_prepare_access(pDst, UXA_GLAMOR_ACCESS_RW)) {
-			if (uxa_prepare_access(pSrc, UXA_GLAMOR_ACCESS_RO)) {
-				ok = glamor_copy_plane_nf(pSrc, pDst, pGC, srcx, srcy, w, h,
-							  dstx, dsty, bitPlane, &region);
-				uxa_finish_access(pSrc, UXA_GLAMOR_ACCESS_RO);
-			}
-			uxa_finish_access(pDst, UXA_GLAMOR_ACCESS_RW);
-		}
-		if (!ok)
-			goto fallback;
-		return region;
-	}
-
-fallback:
 	return uxa_check_copy_plane(pSrc, pDst, pGC, srcx, srcy, w, h,
 				    dstx, dsty, bitPlane);
 }
@@ -968,22 +803,6 @@ uxa_image_glyph_blt(DrawablePtr pDrawable, GCPtr pGC,
 		    int x, int y, unsigned int nglyph,
 		    CharInfoPtr * ppci, pointer pglyphBase)
 {
-	ScreenPtr screen = pDrawable->pScreen;
-	uxa_screen_t *uxa_screen = uxa_get_screen(screen);
-
-	if (uxa_screen->info->flags & UXA_USE_GLAMOR) {
-		int ok = 0;
-
-		if (uxa_prepare_access(pDrawable, UXA_GLAMOR_ACCESS_RW)) {
-			ok = glamor_image_glyph_blt_nf(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
-			uxa_finish_access(pDrawable, UXA_GLAMOR_ACCESS_RW);
-		}
-		if (!ok)
-			goto fallback;
-		return;
-	}
-
-fallback:
 	uxa_check_image_glyph_blt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
 }
 
@@ -992,22 +811,6 @@ uxa_poly_glyph_blt(DrawablePtr pDrawable, GCPtr pGC,
 		   int x, int y, unsigned int nglyph,
 		   CharInfoPtr * ppci, pointer pglyphBase)
 {
-	ScreenPtr screen = pDrawable->pScreen;
-	uxa_screen_t *uxa_screen = uxa_get_screen(screen);
-
-	if (uxa_screen->info->flags & UXA_USE_GLAMOR) {
-		int ok = 0;
-
-		if (uxa_prepare_access(pDrawable, UXA_GLAMOR_ACCESS_RW)) {
-			ok = glamor_poly_glyph_blt_nf(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
-			uxa_finish_access(pDrawable, UXA_GLAMOR_ACCESS_RW);
-		}
-		if (!ok)
-			goto fallback;
-		return;
-	}
-
-fallback:
 	uxa_check_poly_glyph_blt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
 }
 
@@ -1015,25 +818,6 @@ static void
 uxa_push_pixels(GCPtr pGC, PixmapPtr pBitmap,
 		DrawablePtr pDrawable, int w, int h, int x, int y)
 {
-	ScreenPtr screen = pDrawable->pScreen;
-	uxa_screen_t *uxa_screen = uxa_get_screen(screen);
-
-	if (uxa_screen->info->flags & UXA_USE_GLAMOR) {
-		int ok = 0;
-
-		if (uxa_prepare_access(pDrawable, UXA_GLAMOR_ACCESS_RW)) {
-			if (uxa_prepare_access(&pBitmap->drawable, UXA_GLAMOR_ACCESS_RO)) {
-				ok = glamor_push_pixels_nf(pGC, pBitmap, pDrawable, w, h, x, y);
-				uxa_finish_access(&pBitmap->drawable, UXA_GLAMOR_ACCESS_RO);
-			}
-			uxa_finish_access(pDrawable, UXA_GLAMOR_ACCESS_RW);
-		}
-		if (!ok)
-			goto fallback;
-		return;
-	}
-
-fallback:
 	uxa_check_push_pixels(pGC, pBitmap, pDrawable, w, h, x, y);
 }
 
@@ -1244,20 +1028,6 @@ uxa_get_image(DrawablePtr pDrawable, int x, int y, int w, int h,
 	Box.x2 = Box.x1 + w;
 	Box.y2 = Box.y1 + h;
 
-	if (uxa_screen->info->flags & UXA_USE_GLAMOR) {
-		ok = 0;
-		if (uxa_prepare_access(pDrawable, UXA_GLAMOR_ACCESS_RW)) {
-			ok = glamor_get_image_nf(pDrawable, x, y, w, h,
-						 format, planeMask, d);
-			uxa_finish_access(pDrawable, UXA_GLAMOR_ACCESS_RW);
-		}
-
-		if (!ok)
-			goto fallback;
-
-		return;
-	}
-
 	if (uxa_screen->force_fallback)
 		goto fallback;
 
diff --git a/src/uxa/uxa-glamor.h b/src/uxa/uxa-glamor.h
deleted file mode 100644
index 5ff19e0..0000000
--- a/src/uxa/uxa-glamor.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright © 2011 Intel Corporation.
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without
- * restriction, including without limitation the rights to use, copy,
- * modify, merge, publish, distribute, sublicense, and/or sell copies
- * of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including
- * the next paragraph) shall be included in all copies or substantial
- * portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
- * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- *    Zhigang Gong <zhigang.gong@linux.intel.com>
- *
- */
-
-#ifndef UXA_GLAMOR_H
-#define UXA_GLAMOR_H
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#ifdef USE_GLAMOR
-#include "glamor.h"
-#else
-#define glamor_fill_spans_nf(...)	FALSE
-#define glamor_poly_fill_rect_nf(...)	FALSE
-#define glamor_put_image_nf(...)	FALSE
-#define glamor_copy_n_to_n_nf(...)	FALSE
-#define glamor_get_spans_nf(...)	FALSE
-#define glamor_set_spans_nf(...)	FALSE
-#define glamor_get_image_nf(...)	FALSE
-#define glamor_glyphs_nf(...)		FALSE
-#define glamor_glyph_unrealize(...)	do { } while(0)
-#define glamor_composite_nf(...)	FALSE
-#define glamor_composite_rects_nf(...)	FALSE
-#define glamor_trapezoids_nf(...)	FALSE
-#define glamor_triangles_nf(...)	FALSE
-#define glamor_add_traps_nf(...)	FALSE
-#define glamor_create_gc(...)		FALSE
-#define glamor_validate_gc(...)		do { } while(0)
-#define glamor_poly_point_nf(...)	FALSE
-#define glamor_poly_segment_nf(...)	FALSE
-#define glamor_poly_lines_nf(...)	FALSE
-#define glamor_push_pixels_nf(...)	FALSE
-#define glamor_copy_plane_nf(...)	FALSE
-#define glamor_image_glyph_blt_nf(...)	FALSE
-#define glamor_poly_glyph_blt_nf(...)	FALSE
-#endif
-
-#endif /* UXA_GLAMOR_H */
diff --git a/src/uxa/uxa-glyphs.c b/src/uxa/uxa-glyphs.c
index 7f35863..d24ba51 100644
--- a/src/uxa/uxa-glyphs.c
+++ b/src/uxa/uxa-glyphs.c
@@ -65,7 +65,6 @@
 #include <stdlib.h>
 
 #include "uxa-priv.h"
-#include "uxa-glamor.h"
 #include "common.h"
 
 /* Width of the pixmaps we use for the caches; this should be less than
@@ -210,10 +209,6 @@ bail:
 Bool uxa_glyphs_init(ScreenPtr pScreen)
 {
 
-	uxa_screen_t *uxa_screen = uxa_get_screen(pScreen);
-
-	if (uxa_screen->info->flags & UXA_USE_GLAMOR)
-		return TRUE;
 #if HAS_DIXREGISTERPRIVATEKEY
 	if (!dixRegisterPrivateKey(&uxa_glyph_key, PRIVATE_GLYPH, 0))
 		return FALSE;
@@ -308,12 +303,6 @@ uxa_glyph_unrealize(ScreenPtr screen,
 		    GlyphPtr glyph)
 {
 	struct uxa_glyph *priv;
-	uxa_screen_t *uxa_screen = uxa_get_screen(screen);
-
-	if (uxa_screen->info->flags & UXA_USE_GLAMOR) {
-		glamor_glyph_unrealize(screen, glyph);
-		return;
-	}
 
 	/* Use Lookup in case we have not attached to this glyph. */
 	priv = dixLookupPrivate(&glyph->devPrivates, &uxa_glyph_key);
@@ -975,23 +964,6 @@ uxa_glyphs(CARD8 op,
 	ScreenPtr screen = pDst->pDrawable->pScreen;
 	uxa_screen_t *uxa_screen = uxa_get_screen(screen);
 
-	if (uxa_screen->info->flags & UXA_USE_GLAMOR) {
-		int ok;
-
-		uxa_picture_prepare_access(pDst, UXA_GLAMOR_ACCESS_RW);
-		uxa_picture_prepare_access(pSrc, UXA_GLAMOR_ACCESS_RO);
-		ok = glamor_glyphs_nf(op,
-				     pSrc, pDst, maskFormat,
-				     xSrc, ySrc, nlist, list, glyphs);
-		uxa_picture_finish_access(pSrc, UXA_GLAMOR_ACCESS_RO);
-		uxa_picture_finish_access(pDst, UXA_GLAMOR_ACCESS_RW);
-
-		if (!ok)
-			goto fallback;
-
-		return;
-	}
-
 	if (!uxa_screen->info->prepare_composite ||
 	    uxa_screen->force_fallback ||
 	    !uxa_drawable_is_offscreen(pDst->pDrawable) ||
diff --git a/src/uxa/uxa-render.c b/src/uxa/uxa-render.c
index a138f16..438623c 100644
--- a/src/uxa/uxa-render.c
+++ b/src/uxa/uxa-render.c
@@ -29,7 +29,6 @@
 #include <stdlib.h>
 
 #include "uxa-priv.h"
-#include "uxa-glamor.h"
 
 #ifdef RENDER
 #include "mipict.h"
@@ -1357,30 +1356,6 @@ uxa_composite(CARD8 op,
 	RegionRec region;
 	int tx, ty;
 
-	if (uxa_screen->info->flags & UXA_USE_GLAMOR) {
-		int ok;
-
-		uxa_picture_prepare_access(pDst, UXA_GLAMOR_ACCESS_RW);
-		uxa_picture_prepare_access(pSrc, UXA_GLAMOR_ACCESS_RO);
-		if (pMask)
-			uxa_picture_prepare_access(pMask, UXA_GLAMOR_ACCESS_RO);
-
-		ok = glamor_composite_nf(op,
-					 pSrc, pMask, pDst, xSrc, ySrc,
-					 xMask, yMask, xDst, yDst,
-					 width, height);
-
-		if (pMask)
-			uxa_picture_finish_access(pMask, UXA_GLAMOR_ACCESS_RO);
-		uxa_picture_finish_access(pSrc, UXA_GLAMOR_ACCESS_RO);
-		uxa_picture_finish_access(pDst, UXA_GLAMOR_ACCESS_RW);
-
-		if (!ok)
-			goto fallback;
-
-		return;
-	}
-
 	if (uxa_screen->force_fallback)
 		goto fallback;
 
@@ -1722,25 +1697,7 @@ uxa_trapezoids(CARD8 op, PicturePtr src, PicturePtr dst,
 	BoxRec bounds;
 	Bool direct;
 
-	if (uxa_screen->info->flags & UXA_USE_GLAMOR) {
-		int ok;
-
-		uxa_picture_prepare_access(dst, UXA_GLAMOR_ACCESS_RW);
-		uxa_picture_prepare_access(src, UXA_GLAMOR_ACCESS_RO);
-		ok = glamor_trapezoids_nf(op,
-					  src, dst, maskFormat, xSrc,
-					  ySrc, ntrap, traps);
-		uxa_picture_finish_access(src, UXA_GLAMOR_ACCESS_RO);
-		uxa_picture_finish_access(dst, UXA_GLAMOR_ACCESS_RW);
-
-		if (!ok)
-			goto fallback;
-
-		return;
-	}
-
 	if (uxa_screen->force_fallback) {
-fallback:
 		uxa_check_trapezoids(op, src, dst, maskFormat, xSrc, ySrc, ntrap, traps);
 		return;
 	}
@@ -1951,25 +1908,7 @@ uxa_triangles(CARD8 op, PicturePtr pSrc, PicturePtr pDst,
 	BoxRec bounds;
 	Bool direct;
 
-	if (uxa_screen->info->flags & UXA_USE_GLAMOR) {
-		int ok;
-
-		uxa_picture_prepare_access(pDst, UXA_GLAMOR_ACCESS_RW);
-		uxa_picture_prepare_access(pSrc, UXA_GLAMOR_ACCESS_RO);
-		ok = glamor_triangles_nf(op,
-				        pSrc, pDst, maskFormat, xSrc,
-					ySrc, ntri, tris);
-		uxa_picture_finish_access(pSrc, UXA_GLAMOR_ACCESS_RO);
-		uxa_picture_finish_access(pDst, UXA_GLAMOR_ACCESS_RW);
-
-		if (!ok)
-			goto fallback;
-
-		return;
-	}
-
 	if (uxa_screen->force_fallback) {
-fallback:
 		uxa_check_triangles(op, pSrc, pDst, maskFormat,
 				    xSrc, ySrc, ntri, tris);
 		return;
@@ -2051,23 +1990,5 @@ void
 uxa_add_traps(PicturePtr pPicture,
 	      INT16 x_off, INT16 y_off, int ntrap, xTrap * traps)
 {
-	ScreenPtr pScreen = pPicture->pDrawable->pScreen;
-	uxa_screen_t *uxa_screen = uxa_get_screen(pScreen);
-
-	if (uxa_screen->info->flags & UXA_USE_GLAMOR) {
-		int ok;
-
-		uxa_picture_prepare_access(pPicture, UXA_GLAMOR_ACCESS_RW);
-		ok = glamor_add_traps_nf(pPicture,
-					 x_off, y_off, ntrap, traps);
-		uxa_picture_finish_access(pPicture, UXA_GLAMOR_ACCESS_RW);
-
-		if (!ok)
-			goto fallback;
-
-		return;
-	}
-
-fallback:
 	uxa_check_add_traps(pPicture, x_off, y_off, ntrap, traps);
 }
diff --git a/src/uxa/uxa.c b/src/uxa/uxa.c
index c8d7900..905667d 100644
--- a/src/uxa/uxa.c
+++ b/src/uxa/uxa.c
@@ -38,7 +38,6 @@
 #include <X11/fonts/fontstruct.h>
 #include "dixfontstr.h"
 #include "uxa.h"
-#include "uxa-glamor.h"
 
 #if HAS_DEVPRIVATEKEYREC
 DevPrivateKeyRec uxa_screen_index;
@@ -184,7 +183,6 @@ void uxa_finish_access(DrawablePtr pDrawable, uxa_access_t access)
 static void
 uxa_validate_gc(GCPtr pGC, unsigned long changes, DrawablePtr pDrawable)
 {
-	uxa_screen_t *uxa_screen = uxa_get_screen(pGC->pScreen);
 	/* fbValidateGC will do direct access to pixmaps if the tiling has
 	 * changed.
 	 * Preempt fbValidateGC by doing its work and masking the change out, so
@@ -195,10 +193,6 @@ uxa_validate_gc(GCPtr pGC, unsigned long changes, DrawablePtr pDrawable)
 	 * may be pure GLAMOR pixmap, then we should let the glamor
 	 * to do the validation.
 	 */
-	if (uxa_screen->info->flags & UXA_USE_GLAMOR) {
-		glamor_validate_gc(pGC, changes, pDrawable);
-		goto set_ops;
-	}
 #ifdef FB_24_32BIT
 	if ((changes & GCTile) && fbGetRotatedPixmap(pGC)) {
 		(*pGC->pScreen->DestroyPixmap) (fbGetRotatedPixmap(pGC));
@@ -267,7 +261,6 @@ uxa_validate_gc(GCPtr pGC, unsigned long changes, DrawablePtr pDrawable)
 		fbValidateGC(pGC, changes, pDrawable);
 	}
 
-set_ops:
 	pGC->ops = (GCOps *) & uxa_ops;
 }
 
diff --git a/src/uxa/uxa.h b/src/uxa/uxa.h
index b8569f0..d08c601 100644
--- a/src/uxa/uxa.h
+++ b/src/uxa/uxa.h
@@ -46,8 +46,6 @@
 typedef enum {
 	UXA_ACCESS_RO,
 	UXA_ACCESS_RW,
-	UXA_GLAMOR_ACCESS_RO,
-	UXA_GLAMOR_ACCESS_RW
 } uxa_access_t;
 
 /**
@@ -545,20 +543,6 @@ typedef struct _UxaDriver {
  */
 #define UXA_TWO_BITBLT_DIRECTIONS	(1 << 2)
 
-/**
- * UXA_USE_GLAMOR indicates to use glamor acceleration to perform rendering.
- * And if glamor fail to accelerate the rendering, then goto fallback to
- * use CPU to do the rendering. This flag will be set only when glamor get
- * initialized successfully.
- * Note, in ddx close screen, this bit need to be cleared.
- */
-#define UXA_USE_GLAMOR			(1 << 3)
-
-/* UXA_GLAMOR_EGL_INITIALIZED indicates glamor egl layer get initialized
- * successfully. UXA layer does not use this flag, before call to
- * glamor_init, ddx need to check this flag. */
-#define UXA_GLAMOR_EGL_INITIALIZED	(1 << 4)
-
 /** @} */
 /** @name UXA CreatePixmap hint flags
  * @{
-- 
2.0.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 07/12] Add intel_flush to abstract flushing pending acceleration operations
       [not found] ` <1406243908-1123-1-git-send-email-keithp-aN4HjG94KOLQT0dZR+AlfA@public.gmane.org>
  2014-07-24 23:18   ` [PATCH 02/12] Fix present debug output Keith Packard
@ 2014-07-24 23:18   ` Keith Packard
       [not found]     ` <1406243908-1123-8-git-send-email-keithp-aN4HjG94KOLQT0dZR+AlfA@public.gmane.org>
  2014-07-24 23:18   ` [PATCH 08/12] Get rid of glamor stubs in intel_glamor.h Keith Packard
                     ` (4 subsequent siblings)
  6 siblings, 1 reply; 35+ messages in thread
From: Keith Packard @ 2014-07-24 23:18 UTC (permalink / raw)
  To: xorg-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	intel-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

intel_flush flushes any pending acceleration operations to the
hardware, just like intel_uxa_batch_submit does today except that it is
not uxa-specific.

Signed-off-by: Keith Packard <keithp-aN4HjG94KOLQT0dZR+AlfA@public.gmane.org>
---
 src/uxa/intel.h         |  3 +++
 src/uxa/intel_display.c | 11 +++--------
 src/uxa/intel_driver.c  | 14 +++++++++-----
 3 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/src/uxa/intel.h b/src/uxa/intel.h
index ade8742..64f573b 100644
--- a/src/uxa/intel.h
+++ b/src/uxa/intel.h
@@ -535,4 +535,7 @@ intel_get_pixmap_bo(PixmapPtr pixmap);
 void
 intel_set_pixmap_bo(PixmapPtr pixmap, dri_bo *bo);
 
+void
+intel_flush(intel_screen_private *intel);
+
 #endif /* _I830_H_ */
diff --git a/src/uxa/intel_display.c b/src/uxa/intel_display.c
index a4cbf00..add09b0 100644
--- a/src/uxa/intel_display.c
+++ b/src/uxa/intel_display.c
@@ -57,8 +57,6 @@
 #include "fb.h"
 #include "uxa.h"
 
-#include "intel_glamor.h"
-
 #define KNOWN_MODE_FLAGS ((1<<14)-1)
 
 struct intel_drm_queue {
@@ -437,8 +435,7 @@ intel_crtc_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode,
 	crtc->y = y;
 	crtc->rotation = rotation;
 
-	intel_glamor_flush(intel);
-	intel_batch_submit(crtc->scrn);
+        intel_flush(intel);
 
 	mode_to_kmode(crtc->scrn, &intel_crtc->kmode, mode);
 	ret = intel_crtc_apply(crtc);
@@ -1437,8 +1434,7 @@ intel_xf86crtc_resize(ScrnInfoPtr scrn, int width, int height)
 	if (scrn->virtualX == width && scrn->virtualY == height)
 		return TRUE;
 
-	intel_glamor_flush(intel);
-	intel_batch_submit(scrn);
+        intel_flush(intel);
 
 	old_width = scrn->virtualX;
 	old_height = scrn->virtualY;
@@ -1552,8 +1548,7 @@ intel_do_pageflip(intel_screen_private *intel,
 		goto error_out;
 
 	drm_intel_bo_disable_reuse(new_front);
-	intel_glamor_flush(intel);
-	intel_batch_submit(scrn);
+        intel_flush(intel);
 
 	mode->pageflip_data = pageflip_data;
 	mode->pageflip_handler = pageflip_handler;
diff --git a/src/uxa/intel_driver.c b/src/uxa/intel_driver.c
index d9f918b..a764b97 100644
--- a/src/uxa/intel_driver.c
+++ b/src/uxa/intel_driver.c
@@ -181,6 +181,12 @@ intel_get_pixmap_bo(PixmapPtr pixmap)
         return intel_uxa_get_pixmap_bo(pixmap);
 }
 
+void
+intel_flush(intel_screen_private *intel)
+{
+        intel_batch_submit(intel->scrn);
+}
+
 static void PreInitCleanup(ScrnInfoPtr scrn)
 {
 	if (!scrn || !scrn->driverPrivate)
@@ -647,7 +653,7 @@ redisplay_dirty(ScreenPtr screen, PixmapDirtyUpdatePtr dirty)
 	PixmapSyncDirtyHelper(dirty, &pixregion);
 	RegionUninit(&pixregion);
 
-	intel_batch_submit(scrn);
+        intel_flush(intel);
 	if (!intel->has_prime_vmap_flush) {
 		drm_intel_bo *bo = intel_uxa_get_pixmap_bo(dirty->slave_dst->master_pixmap);
 		was_blocked = xf86BlockSIGIO();
@@ -732,10 +738,8 @@ intel_flush_callback(CallbackListPtr *list,
 		     pointer user_data, pointer call_data)
 {
 	ScrnInfoPtr scrn = user_data;
-	if (scrn->vtSema) {
-		intel_batch_submit(scrn);
-		intel_glamor_flush(intel_get_screen_private(scrn));
-	}
+	if (scrn->vtSema)
+                intel_flush(intel_get_screen_private(scrn));
 }
 
 #if HAVE_UDEV
-- 
2.0.1

_______________________________________________
xorg-devel-go0+a7rfsptAfugRpC6u6w@public.gmane.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 08/12] Get rid of glamor stubs in intel_glamor.h
       [not found] ` <1406243908-1123-1-git-send-email-keithp-aN4HjG94KOLQT0dZR+AlfA@public.gmane.org>
  2014-07-24 23:18   ` [PATCH 02/12] Fix present debug output Keith Packard
  2014-07-24 23:18   ` [PATCH 07/12] Add intel_flush to abstract flushing pending acceleration operations Keith Packard
@ 2014-07-24 23:18   ` Keith Packard
       [not found]     ` <1406243908-1123-9-git-send-email-keithp-aN4HjG94KOLQT0dZR+AlfA@public.gmane.org>
  2014-07-24 23:18   ` [PATCH 10/12] Add glamor back into the driver Keith Packard
                     ` (3 subsequent siblings)
  6 siblings, 1 reply; 35+ messages in thread
From: Keith Packard @ 2014-07-24 23:18 UTC (permalink / raw)
  To: xorg-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	intel-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

This eliminates the stubs in intel_glamor.h and replaces them with
ifdefs instead.

Signed-off-by: Keith Packard <keithp-aN4HjG94KOLQT0dZR+AlfA@public.gmane.org>
---
 src/uxa/intel_dri.c     | 20 ++++++++++++++++++--
 src/uxa/intel_driver.c  |  6 ++++++
 src/uxa/intel_glamor.h  | 21 ---------------------
 src/uxa/intel_present.c |  2 ++
 src/uxa/intel_video.c   |  4 ++++
 5 files changed, 30 insertions(+), 23 deletions(-)

diff --git a/src/uxa/intel_dri.c b/src/uxa/intel_dri.c
index 79978ab..78734cb 100644
--- a/src/uxa/intel_dri.c
+++ b/src/uxa/intel_dri.c
@@ -66,7 +66,9 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #include "dri2.h"
 
+#if USE_GLAMOR
 #include "intel_glamor.h"
+#endif
 #include "uxa.h"
 
 typedef struct {
@@ -107,6 +109,7 @@ static PixmapPtr get_front_buffer(DrawablePtr drawable)
 	return pixmap;
 }
 
+#if USE_GLAMOR
 static PixmapPtr fixup_glamor(DrawablePtr drawable, PixmapPtr pixmap)
 {
 	ScreenPtr screen = drawable->pScreen;
@@ -158,6 +161,7 @@ static PixmapPtr fixup_glamor(DrawablePtr drawable, PixmapPtr pixmap)
 	intel_get_screen_private(xf86ScreenToScrn(screen))->needs_flush = TRUE;
 	return old;
 }
+#endif
 
 #if DRI2INFOREC_VERSION < 2
 static DRI2BufferPtr
@@ -170,7 +174,9 @@ I830DRI2CreateBuffers(DrawablePtr drawable, unsigned int *attachments,
 	DRI2BufferPtr buffers;
 	I830DRI2BufferPrivatePtr privates;
 	PixmapPtr pixmap, pDepthPixmap;
+#if USE_GLAMOR
 	Bool is_glamor_pixmap = FALSE;
+#endif
 	int i;
 
 	buffers = calloc(count, sizeof *buffers);
@@ -187,11 +193,12 @@ I830DRI2CreateBuffers(DrawablePtr drawable, unsigned int *attachments,
 		pixmap = NULL;
 		if (attachments[i] == DRI2BufferFrontLeft) {
 			pixmap = get_front_buffer(drawable);
-
+#if USE_GLAMOR
 			if (pixmap == NULL) {
 				drawable = &(get_drawable_pixmap(drawable)->drawable);
 				is_glamor_pixmap = TRUE;
 			}
+#endif
 		} else if (attachments[i] == DRI2BufferStencil && pDepthPixmap) {
 			pixmap = pDepthPixmap;
 			pixmap->refcnt++;
@@ -230,8 +237,10 @@ I830DRI2CreateBuffers(DrawablePtr drawable, unsigned int *attachments,
 				goto unwind;
 			}
 
+#if USE_GLAMOR
 			if (is_glamor_pixmap)
 				pixmap = fixup_glamor(drawable, pixmap);
+#endif
 		}
 
 		if (attachments[i] == DRI2BufferDepth)
@@ -292,7 +301,9 @@ I830DRI2CreateBuffer(DrawablePtr drawable, unsigned int attachment,
 	DRI2Buffer2Ptr buffer;
 	I830DRI2BufferPrivatePtr privates;
 	PixmapPtr pixmap;
+#if USE_GLAMOR
 	Bool is_glamor_pixmap = FALSE;
+#endif
 
 	buffer = calloc(1, sizeof *buffer);
 	if (buffer == NULL)
@@ -306,11 +317,12 @@ I830DRI2CreateBuffer(DrawablePtr drawable, unsigned int attachment,
 	pixmap = NULL;
 	if (attachment == DRI2BufferFrontLeft) {
 		pixmap = get_front_buffer(drawable);
-
+#if USE_GLAMOR
 		if (pixmap == NULL) {
 			drawable = &(get_drawable_pixmap(drawable)->drawable);
 			is_glamor_pixmap = TRUE;
 		}
+#endif
 	}
 
 	if (pixmap == NULL) {
@@ -383,8 +395,10 @@ I830DRI2CreateBuffer(DrawablePtr drawable, unsigned int attachment,
 			free(buffer);
 			return NULL;
 		}
+#if USE_GLAMOR
 		if (is_glamor_pixmap)
 			pixmap = fixup_glamor(drawable, pixmap);
+#endif
 	}
 
 	buffer->attachment = attachment;
@@ -762,7 +776,9 @@ intel_exchange_pixmap_buffers(struct intel_screen_private *intel, PixmapPtr fron
 	new_front->busy = 1;
 	new_back->busy = -1;
 
+#if USE_GLAMOR
 	intel_glamor_exchange_buffers(intel, front, back);
+#endif
 
 	DamageRegionProcessPending(&front->drawable);
 
diff --git a/src/uxa/intel_driver.c b/src/uxa/intel_driver.c
index a764b97..6d38cfe 100644
--- a/src/uxa/intel_driver.c
+++ b/src/uxa/intel_driver.c
@@ -72,7 +72,9 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #include "i915_drm.h"
 
+#if USE_GLAMOR
 #include "intel_glamor.h"
+#endif
 #include "intel_options.h"
 
 static void i830AdjustFrame(ADJUST_FRAME_ARGS_DECL);
@@ -610,12 +612,14 @@ static Bool I830PreInit(ScrnInfoPtr scrn, int flags)
 		return FALSE;
 	}
 
+#if USE_GLAMOR
 	if (!intel_glamor_pre_init(scrn)) {
 		PreInitCleanup(scrn);
 		xf86DrvMsg(scrn->scrnIndex, X_ERROR,
 			"Failed to pre init glamor display.\n");
 		return FALSE;
 	}
+#endif
 
 	/* Load the dri modules if requested. */
 #if HAVE_DRI2
@@ -1125,7 +1129,9 @@ static Bool I830CloseScreen(CLOSE_SCREEN_ARGS_DECL)
 
 	DeleteCallback(&FlushCallback, intel_flush_callback, scrn);
 
+#if USE_GLAMOR
 	intel_glamor_close_screen(screen);
+#endif
 
 	TimerFree(intel->cache_expire);
 	intel->cache_expire = NULL;
diff --git a/src/uxa/intel_glamor.h b/src/uxa/intel_glamor.h
index 2e305fc..97c2257 100644
--- a/src/uxa/intel_glamor.h
+++ b/src/uxa/intel_glamor.h
@@ -32,8 +32,6 @@
 
 #include <xf86xv.h>
 
-#ifdef USE_GLAMOR
-
 Bool intel_glamor_pre_init(ScrnInfoPtr scrn);
 Bool intel_glamor_init(ScreenPtr screen);
 Bool intel_glamor_create_screen_resources(ScreenPtr screen);
@@ -48,24 +46,5 @@ PixmapPtr intel_glamor_create_pixmap(ScreenPtr screen, int w, int h,
 				     int depth, unsigned int usage);
 void intel_glamor_exchange_buffers(struct intel_screen_private *intel, PixmapPtr src, PixmapPtr dst);
 XF86VideoAdaptorPtr intel_glamor_xv_init(ScreenPtr screen, int num_ports);
-#else
-
-static inline Bool intel_glamor_pre_init(ScrnInfoPtr scrn) { return TRUE; }
-static inline Bool intel_glamor_init(ScreenPtr screen) { return TRUE; }
-static inline Bool intel_glamor_create_screen_resources(ScreenPtr screen) { return TRUE; }
-static inline Bool intel_glamor_close_screen(ScreenPtr screen) { return TRUE; }
-static inline void intel_glamor_free_screen(int scrnIndex, int flags) { }
-
-static inline void intel_glamor_flush(intel_screen_private * intel) { }
-
-static inline Bool intel_glamor_create_textured_pixmap(PixmapPtr pixmap) { return TRUE; }
-static inline void intel_glamor_destroy_pixmap(PixmapPtr pixmap) { }
-
-static inline PixmapPtr intel_glamor_create_pixmap(ScreenPtr screen, int w, int h,
-						   int depth, unsigned int usage) { return NULL; }
-
-static inline void intel_glamor_exchange_buffers(struct intel_screen_private *intel, PixmapPtr src, PixmapPtr dst) {}
-static inline XF86VideoAdaptorPtr intel_glamor_xv_init(ScreenPtr screen, int num_ports) { return NULL; }
-#endif
 
 #endif /* INTEL_GLAMOR_H */
diff --git a/src/uxa/intel_present.c b/src/uxa/intel_present.c
index 5f98da8..c53d71d 100644
--- a/src/uxa/intel_present.c
+++ b/src/uxa/intel_present.c
@@ -54,7 +54,9 @@
 
 #include "present.h"
 
+#if USE_GLAMOR
 #include "intel_glamor.h"
+#endif
 #include "uxa.h"
 
 struct intel_present_vblank_event {
diff --git a/src/uxa/intel_video.c b/src/uxa/intel_video.c
index 310b6c9..ae3d351 100644
--- a/src/uxa/intel_video.c
+++ b/src/uxa/intel_video.c
@@ -78,7 +78,9 @@
 #define _INTEL_XVMC_SERVER_
 #include "intel_xvmc.h"
 #endif
+#if USE_GLAMOR
 #include "intel_glamor.h"
+#endif
 #include "intel_uxa.h"
 #include "intel_video_overlay.h"
 
@@ -213,10 +215,12 @@ void intel_video_init(ScreenPtr screen)
 		}
 	}
 
+#if USE_GLAMOR
 	glamorAdaptor = intel_glamor_xv_init(screen, 16);
 	if (glamorAdaptor != NULL)
 		xf86DrvMsg(scrn->scrnIndex, X_INFO,
 			   "Set up textured video using glamor\n");
+#endif
 
 
 	if (overlayAdaptor && intel->XvPreferOverlay)
-- 
2.0.1

_______________________________________________
xorg-devel-go0+a7rfsptAfugRpC6u6w@public.gmane.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 09/12] Do more checks for proposed flip pixmaps
  2014-07-24 23:18 [PATCH 00/12] Rework intel 2D driver glamor support Keith Packard
                   ` (4 preceding siblings ...)
  2014-07-24 23:18 ` [PATCH 06/12] Remove glamor support from UXA acceleration Keith Packard
@ 2014-07-24 23:18 ` Keith Packard
       [not found]   ` <1406243908-1123-10-git-send-email-keithp-aN4HjG94KOLQT0dZR+AlfA@public.gmane.org>
       [not found] ` <1406243908-1123-1-git-send-email-keithp-aN4HjG94KOLQT0dZR+AlfA@public.gmane.org>
  6 siblings, 1 reply; 35+ messages in thread
From: Keith Packard @ 2014-07-24 23:18 UTC (permalink / raw)
  To: xorg-devel, intel-gfx

Make sure the pitch and tiling are correct.
Make sure there's a BO we can get at.

Signed-off-by: Keith Packard <keithp@keithp.com>
---
 src/uxa/intel_present.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/src/uxa/intel_present.c b/src/uxa/intel_present.c
index c53d71d..b901fb1 100644
--- a/src/uxa/intel_present.c
+++ b/src/uxa/intel_present.c
@@ -248,6 +248,8 @@ intel_present_check_flip(RRCrtcPtr              crtc,
 	ScreenPtr               screen = window->drawable.pScreen;
 	ScrnInfoPtr             scrn = xf86ScreenToScrn(screen);
 	intel_screen_private    *intel = intel_get_screen_private(scrn);
+        dri_bo                  *bo;
+        uint32_t                tiling, swizzle;
 
 	if (!scrn->vtSema)
 		return FALSE;
@@ -261,6 +263,22 @@ intel_present_check_flip(RRCrtcPtr              crtc,
 	if (crtc && !intel_crtc_on(crtc->devPrivate))
 		return FALSE;
 
+        /* Check stride, can't change that on flip */
+        if (pixmap->devKind != intel->front_pitch)
+                return FALSE;
+
+        /* Make sure there's a bo we can get to */
+        bo = intel_get_pixmap_bo(pixmap);
+        if (!bo)
+                return FALSE;
+
+        /* Check tiling, can't change that on flip */
+        if (drm_intel_bo_get_tiling((drm_intel_bo *) bo, &tiling, &swizzle) != 0)
+                return FALSE;
+
+        if (tiling != intel->front_tiling)
+                return FALSE;
+
 	return TRUE;
 }
 
-- 
2.0.1

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 10/12] Add glamor back into the driver
       [not found] ` <1406243908-1123-1-git-send-email-keithp-aN4HjG94KOLQT0dZR+AlfA@public.gmane.org>
                     ` (2 preceding siblings ...)
  2014-07-24 23:18   ` [PATCH 08/12] Get rid of glamor stubs in intel_glamor.h Keith Packard
@ 2014-07-24 23:18   ` Keith Packard
       [not found]     ` <1406243908-1123-11-git-send-email-keithp-aN4HjG94KOLQT0dZR+AlfA@public.gmane.org>
  2014-07-24 23:18   ` [PATCH 11/12] Add "none" acceleration option Keith Packard
                     ` (2 subsequent siblings)
  6 siblings, 1 reply; 35+ messages in thread
From: Keith Packard @ 2014-07-24 23:18 UTC (permalink / raw)
  To: xorg-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	intel-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

This adds glamor support back into the driver, but instad of going
through UXA, this uses it directly instead.

Signed-off-by: Keith Packard <keithp-aN4HjG94KOLQT0dZR+AlfA@public.gmane.org>
---
 src/uxa/intel.h         |  17 +++
 src/uxa/intel_display.c |  30 ++++-
 src/uxa/intel_dri.c     |  20 +++
 src/uxa/intel_driver.c  | 247 ++++++++++++++++++++++++++++---------
 src/uxa/intel_glamor.c  | 316 +++++++++++++++++++++++++-----------------------
 src/uxa/intel_glamor.h  |  18 ++-
 src/uxa/intel_present.c |   5 -
 src/uxa/intel_uxa.c     |   5 +
 src/uxa/intel_video.c   |  75 +++++++-----
 9 files changed, 480 insertions(+), 253 deletions(-)

diff --git a/src/uxa/intel.h b/src/uxa/intel.h
index 64f573b..5fbb2c7 100644
--- a/src/uxa/intel.h
+++ b/src/uxa/intel.h
@@ -111,10 +111,21 @@ enum dri_type {
 	DRI_ACTIVE
 };
 
+enum accel_type {
+#if USE_GLAMOR
+        ACCEL_GLAMOR,
+#endif
+#if USE_UXA
+        ACCEL_UXA,
+#endif
+};
+
 typedef struct intel_screen_private {
 	ScrnInfoPtr scrn;
 	int cpp;
 
+        enum accel_type accel;
+
 #define RENDER_BATCH			I915_EXEC_RENDER
 #define BLT_BATCH			I915_EXEC_BLT
 	unsigned int current_batch;
@@ -127,6 +138,7 @@ typedef struct intel_screen_private {
 
 	dri_bufmgr *bufmgr;
 
+#if USE_UXA
 	uint32_t batch_ptr[4096];
 	/** Byte offset in batch_ptr for the next dword to be emitted. */
 	unsigned int batch_used;
@@ -142,6 +154,7 @@ typedef struct intel_screen_private {
 	struct list batch_pixmaps;
 	drm_intel_bo *wa_scratch_bo;
 	OsTimerPtr cache_expire;
+#endif
 
 	/* For Xvideo */
 	Bool use_overlay;
@@ -178,8 +191,10 @@ typedef struct intel_screen_private {
 	void (*batch_flush) (struct intel_screen_private *intel);
 	void (*batch_commit_notify) (struct intel_screen_private *intel);
 
+#if USE_UXA
 	struct _UxaDriver *uxa_driver;
 	int uxa_flags;
+#endif
 	Bool need_sync;
 	int accel_pixmap_offset_alignment;
 	int accel_max_x;
@@ -212,6 +227,7 @@ typedef struct intel_screen_private {
 		drm_intel_bo *gen6_depth_stencil_bo;
 	} video;
 
+#if USE_UXA
 	/* Render accel state */
 	float scale_units[2][2];
 	/** Transform pointers for src/mask, or NULL if identity */
@@ -269,6 +285,7 @@ typedef struct intel_screen_private {
 
 	/* 965 render acceleration state */
 	struct gen4_render_state *gen4_render_state;
+#endif
 
 	/* DRI enabled this generation. */
 	enum dri_type dri2, dri3;
diff --git a/src/uxa/intel_display.c b/src/uxa/intel_display.c
index add09b0..a4c4b82 100644
--- a/src/uxa/intel_display.c
+++ b/src/uxa/intel_display.c
@@ -56,6 +56,9 @@
 #include "xf86DDC.h"
 #include "fb.h"
 #include "uxa.h"
+#if USE_GLAMOR
+#include "intel_glamor.h"
+#endif
 
 #define KNOWN_MODE_FLAGS ((1<<14)-1)
 
@@ -182,7 +185,7 @@ intel_output_backlight_init(xf86OutputPtr output)
 {
 	struct intel_output *intel_output = output->driver_private;
 	intel_screen_private *intel = intel_get_screen_private(output->scrn);
-	char *str;
+	const char *str;
 
 #if !USE_BACKLIGHT
 	return;
@@ -683,7 +686,10 @@ intel_set_scanout_pixmap(xf86CrtcPtr crtc, PixmapPtr ppix)
 		return TRUE;
 	}
 
-	bo = intel_get_pixmap_bo(ppix);
+        bo = intel_get_pixmap_bo(ppix);
+        if (!bo)
+                return FALSE;
+
 	if (intel->front_buffer) {
 		ErrorF("have front buffer\n");
 	}
@@ -1472,8 +1478,20 @@ intel_xf86crtc_resize(ScrnInfoPtr scrn, int width, int height)
 	scrn->virtualX = width;
 	scrn->virtualY = height;
 
-	if (!intel_uxa_create_screen_resources(scrn->pScreen))
-		goto fail;
+        switch (intel->accel) {
+#if USE_GLAMOR
+        case ACCEL_GLAMOR:
+                if (!intel_glamor_create_screen_resources(scrn->pScreen))
+                        goto fail;
+                break;
+#endif
+#if USE_UXA
+        case ACCEL_UXA:
+                if (!intel_uxa_create_screen_resources(scrn->pScreen))
+                        goto fail;
+                break;
+#endif
+        }
 
 	for (i = 0; i < xf86_config->num_crtc; i++) {
 		xf86CrtcPtr crtc = xf86_config->crtc[i];
@@ -1532,7 +1550,7 @@ intel_do_pageflip(intel_screen_private *intel,
 	xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
 	struct intel_crtc *crtc = config->crtc[0]->driver_private;
 	struct intel_mode *mode = crtc->mode;
-	unsigned int pitch = scrn->displayWidth * intel->cpp;
+        unsigned int pitch = scrn->displayWidth * intel->cpp;
 	struct intel_pageflip *flip;
 	uint32_t new_fb_id;
 	uint32_t flags;
@@ -2235,7 +2253,7 @@ intel_create_pixmap_for_bo(ScreenPtr pScreen, dri_bo *bo,
 		return NullPixmap;
 	}
 
-	intel_set_pixmap_bo(pixmap, bo);
+        intel_set_pixmap_bo(pixmap, bo);
 	return pixmap;
 }
 
diff --git a/src/uxa/intel_dri.c b/src/uxa/intel_dri.c
index 78734cb..2055346 100644
--- a/src/uxa/intel_dri.c
+++ b/src/uxa/intel_dri.c
@@ -883,6 +883,26 @@ I830DRI2ScheduleFlip(struct intel_screen_private *intel,
 
 		drm_intel_bo_disable_reuse(new_back);
 		dri_bo_flink(new_back, &intel->back_name);
+#if USE_GLAMOR
+		if (intel->accel == ACCEL_GLAMOR) {
+                        I830DRI2BufferPrivatePtr drvpriv;
+                        PixmapPtr front_pixmap, back_pixmap;
+                        ScreenPtr screen;
+
+			screen = draw->pScreen;
+			drvpriv = info->front->driverPrivate;
+			front_pixmap = drvpriv->pixmap;
+
+			back_pixmap = intel_glamor_create_back_pixmap(screen,
+								      front_pixmap,
+								      new_back);
+			if (back_pixmap == NULL) {
+				drm_intel_bo_unreference(new_back);
+				return FALSE;
+			}
+			intel->back_pixmap = back_pixmap;
+		}
+#endif
 	} else {
 		new_back = intel->back_buffer;
 		intel->back_buffer = NULL;
diff --git a/src/uxa/intel_driver.c b/src/uxa/intel_driver.c
index 6d38cfe..065c679 100644
--- a/src/uxa/intel_driver.c
+++ b/src/uxa/intel_driver.c
@@ -164,29 +164,83 @@ static Bool i830CreateScreenResources(ScreenPtr screen)
 	if (!(*screen->CreateScreenResources) (screen))
 		return FALSE;
 
-	if (!intel_uxa_create_screen_resources(screen))
-		return FALSE;
+        switch (intel->accel) {
+#if USE_GLAMOR
+        case ACCEL_GLAMOR:
+                if (!intel_glamor_create_screen_resources(screen))
+                        return FALSE;
+                break;
+#endif
+#if USE_UXA
+        case ACCEL_UXA:
+                if (!intel_uxa_create_screen_resources(screen))
+                        return FALSE;
+                intel_copy_fb(scrn);
+#endif
+        }
 
-	intel_copy_fb(scrn);
 	return TRUE;
 }
 
 void
 intel_set_pixmap_bo(PixmapPtr pixmap, dri_bo *bo)
 {
-        intel_uxa_set_pixmap_bo(pixmap, bo);
+	ScrnInfoPtr scrn = xf86ScreenToScrn(pixmap->drawable.pScreen);
+	intel_screen_private *intel = intel_get_screen_private(scrn);
+
+        switch (intel->accel) {
+#if USE_GLAMOR
+        case ACCEL_GLAMOR:
+                intel_glamor_set_pixmap_bo(pixmap, bo);
+                break;
+#endif
+#if USE_UXA
+        case ACCEL_UXA:
+                intel_uxa_set_pixmap_bo(pixmap, bo);
+                break;
+#endif
+        default:
+                ErrorF("No accel architecture, cannot set pixmap bo\n");
+                break;
+        }
 }
 
 dri_bo *
 intel_get_pixmap_bo(PixmapPtr pixmap)
 {
-        return intel_uxa_get_pixmap_bo(pixmap);
+	ScrnInfoPtr scrn = xf86ScreenToScrn(pixmap->drawable.pScreen);
+	intel_screen_private *intel = intel_get_screen_private(scrn);
+
+	switch (intel->accel) {
+#if USE_GLAMOR
+	case ACCEL_GLAMOR:
+		return intel_glamor_get_pixmap_bo(pixmap);
+#endif
+#if USE_UXA
+        case ACCEL_UXA:
+		return intel_uxa_get_pixmap_bo(pixmap);
+#endif
+        default:
+                ErrorF("No accel architecture, cannot set pixmap bo\n");
+	        return NULL;
+        }
 }
 
 void
 intel_flush(intel_screen_private *intel)
 {
-        intel_batch_submit(intel->scrn);
+	switch (intel->accel) {
+#if USE_GLAMOR
+	case ACCEL_GLAMOR:
+                intel_glamor_flush(intel);
+                break;
+#endif
+#if USE_UXA
+        case ACCEL_UXA:
+                intel_batch_submit(intel->scrn);
+                break;
+#endif
+        }
 }
 
 static void PreInitCleanup(ScrnInfoPtr scrn)
@@ -204,6 +258,41 @@ static void intel_check_chipset_option(ScrnInfoPtr scrn)
 	intel_detect_chipset(scrn, intel->pEnt);
 }
 
+static void intel_check_accel_option(ScrnInfoPtr scrn)
+{
+	intel_screen_private *intel = intel_get_screen_private(scrn);
+	enum { NONE, SNA, UXA, GLAMOR } accel_method = DEFAULT_ACCEL_METHOD;
+	const char *s;
+
+	s = xf86GetOptValString(intel->Options, OPTION_ACCEL_METHOD);
+	if (s != NULL) {
+#if USE_GLAMOR
+                if (strcasecmp(s, "glamor") == 0)
+                        accel_method = GLAMOR;
+                else
+#endif
+#if USE_UXA
+                if (strcasecmp(s, "uxa") == 0)
+                        accel_method = UXA;
+                else
+#endif
+                        accel_method = DEFAULT_ACCEL_METHOD;
+        }
+        switch (accel_method) {
+        default:
+#if USE_GLAMOR
+        case GLAMOR:
+                intel->accel = ACCEL_GLAMOR;
+                break;
+#endif
+#if USE_UXA
+        case UXA:
+                intel->accel = ACCEL_UXA;
+                break;
+#endif
+        }
+}
+
 static Bool I830GetEarlyOptions(ScrnInfoPtr scrn)
 {
 	intel_screen_private *intel = intel_get_screen_private(scrn);
@@ -213,6 +302,7 @@ static Bool I830GetEarlyOptions(ScrnInfoPtr scrn)
 	if (!intel->Options)
 		return FALSE;
 
+#if USE_UXA
 	intel->fallback_debug = xf86ReturnOptValBool(intel->Options,
 						     OPTION_FALLBACKDEBUG,
 						     FALSE);
@@ -234,6 +324,7 @@ static Bool I830GetEarlyOptions(ScrnInfoPtr scrn)
 				 FALSE))
 		intel->debug_flush |= DEBUG_FLUSH_WAIT;
 
+#endif
 	return TRUE;
 }
 
@@ -526,6 +617,7 @@ static Bool I830PreInit(ScrnInfoPtr scrn, int flags)
 	intel_setup_capabilities(scrn);
 	intel_check_chipset_option(scrn);
 	intel_check_dri_option(scrn);
+        intel_check_accel_option(scrn);
 
 	if (!intel_init_bufmgr(intel)) {
 		PreInitCleanup(scrn);
@@ -612,24 +704,33 @@ static Bool I830PreInit(ScrnInfoPtr scrn, int flags)
 		return FALSE;
 	}
 
+        switch (intel->accel) {
 #if USE_GLAMOR
-	if (!intel_glamor_pre_init(scrn)) {
-		PreInitCleanup(scrn);
-		xf86DrvMsg(scrn->scrnIndex, X_ERROR,
-			"Failed to pre init glamor display.\n");
-		return FALSE;
-	}
+        case ACCEL_GLAMOR:
+                if (!intel_glamor_pre_init(scrn)) {
+                        PreInitCleanup(scrn);
+                        xf86DrvMsg(scrn->scrnIndex, X_ERROR,
+                                   "Failed to pre init glamor display.\n");
+                        intel->accel = ACCEL_UXA;
+                }
+                break;
 #endif
-
-	/* Load the dri modules if requested. */
+#if USE_UXA
+        case ACCEL_UXA:
+                /* Load the dri modules if requested. */
 #if HAVE_DRI2
-	if (intel->dri2 != DRI_DISABLED && !xf86LoadSubModule(scrn, "dri2"))
-		intel->dri2 = DRI_DISABLED;
+                if (intel->dri2 != DRI_DISABLED && !xf86LoadSubModule(scrn, "dri2"))
+                        intel->dri2 = DRI_DISABLED;
 #endif
 #if HAVE_DRI3
-	if (intel->dri3 != DRI_DISABLED && !xf86LoadSubModule(scrn, "dri3"))
-		intel->dri3 = DRI_DISABLED;
+                if (intel->dri3 != DRI_DISABLED && !xf86LoadSubModule(scrn, "dri3"))
+                        intel->dri3 = DRI_DISABLED;
+#endif
+                break;
 #endif
+        default:
+                break;
+        }
 
 	return TRUE;
 }
@@ -876,11 +977,6 @@ I830ScreenInit(SCREEN_INIT_ARGS_DECL)
 	if (!intel_init_initial_framebuffer(scrn))
 		return FALSE;
 
-	intel_batch_init(scrn);
-
-	if (INTEL_INFO(intel)->gen >= 040 && INTEL_INFO(intel)->gen < 0100)
-		gen4_render_state_init(scrn);
-
 	miClearVisualTypes();
 	if (!miSetVisualTypes(scrn->depth,
 			      miGetDefaultVisualMask(scrn->depth),
@@ -915,23 +1011,37 @@ I830ScreenInit(SCREEN_INIT_ARGS_DECL)
 
 	xf86SetBlackWhitePixels(screen);
 
-	if (!intel_uxa_init(screen)) {
-		xf86DrvMsg(scrn->scrnIndex, X_ERROR,
-			   "Hardware acceleration initialization failed\n");
-		return FALSE;
-	}
-
+        switch (intel->accel) {
+#if USE_GLAMOR
+        case ACCEL_GLAMOR:
+                if (!intel_glamor_init(screen)) {
+                        xf86DrvMsg(scrn->scrnIndex, X_ERROR,
+                                   "Glamor acceleration initialization failed\n");
+                        return FALSE;
+                }
+                break;
+#endif
+#if USE_UXA
+        case ACCEL_UXA:
+                if (!intel_uxa_init(screen)) {
+                        xf86DrvMsg(scrn->scrnIndex, X_ERROR,
+                                   "Hardware acceleration initialization failed\n");
+                        return FALSE;
+                }
 #if HAVE_DRI2
-	if (intel->dri2 == DRI_NONE && I830DRI2ScreenInit(screen))
-		intel->dri2 = DRI_ACTIVE;
+                if (intel->dri2 == DRI_NONE && I830DRI2ScreenInit(screen))
+                        intel->dri2 = DRI_ACTIVE;
 #endif
 
 #if HAVE_DRI3
-	if (!intel_sync_init(screen))
-		intel->dri3 = DRI_DISABLED;
-	if (intel->dri3 == DRI_NONE && intel_dri3_screen_init(screen))
-		intel->dri3 = DRI_ACTIVE;
+                if (!intel_sync_init(screen))
+                        intel->dri3 = DRI_DISABLED;
+                if (intel->dri3 == DRI_NONE && intel_dri3_screen_init(screen))
+                        intel->dri3 = DRI_ACTIVE;
+#endif
+                break;
 #endif
+        }
 
 	if (xf86ReturnOptValBool(intel->Options, OPTION_PRESENT, TRUE))
 		intel_present_screen_init(screen);
@@ -1129,18 +1239,33 @@ static Bool I830CloseScreen(CLOSE_SCREEN_ARGS_DECL)
 
 	DeleteCallback(&FlushCallback, intel_flush_callback, scrn);
 
+        switch (intel->accel) {
 #if USE_GLAMOR
-	intel_glamor_close_screen(screen);
+        case ACCEL_GLAMOR:
+                intel_glamor_close_screen(screen);
+                break;
 #endif
+#if USE_UXA
+        case ACCEL_UXA:
 
-	TimerFree(intel->cache_expire);
-	intel->cache_expire = NULL;
+                TimerFree(intel->cache_expire);
+                intel->cache_expire = NULL;
 
-	if (intel->uxa_driver) {
-		uxa_driver_fini(screen);
-		free(intel->uxa_driver);
-		intel->uxa_driver = NULL;
-	}
+                intel_batch_teardown(scrn);
+
+                if (INTEL_INFO(intel)->gen >= 040 && INTEL_INFO(intel)->gen < 0100)
+                        gen4_render_state_cleanup(scrn);
+
+                if (intel->uxa_driver) {
+                        uxa_driver_fini(screen);
+                        free(intel->uxa_driver);
+                        intel->uxa_driver = NULL;
+                }
+                break;
+#endif
+        default:
+                break;
+        }
 
 	if (intel->back_pixmap) {
 		screen->DestroyPixmap(intel->back_pixmap);
@@ -1162,11 +1287,6 @@ static Bool I830CloseScreen(CLOSE_SCREEN_ARGS_DECL)
 		I830LeaveVT(VT_FUNC_ARGS(0));
 	}
 
-	intel_batch_teardown(scrn);
-
-	if (INTEL_INFO(intel)->gen >= 040 && INTEL_INFO(intel)->gen < 0100)
-		gen4_render_state_cleanup(scrn);
-
 	xf86_cursors_fini(screen);
 
 	i965_free_video(scrn);
@@ -1174,17 +1294,28 @@ static Bool I830CloseScreen(CLOSE_SCREEN_ARGS_DECL)
 	screen->CloseScreen = intel->CloseScreen;
 	(*screen->CloseScreen) (CLOSE_SCREEN_ARGS);
 
-	if (intel->dri2 == DRI_ACTIVE) {
-		I830DRI2CloseScreen(screen);
-		intel->dri2 = DRI_NONE;
-	}
-
-	if (intel->dri3 == DRI_ACTIVE) {
-		/* nothing to do here? */
-		intel->dri3 = DRI_NONE;
-	}
+        switch (intel->accel) {
+#if USE_UXA
+        case ACCEL_UXA:
+#if HAVE_DRI2
+                if (intel->dri2 == DRI_ACTIVE) {
+                        I830DRI2CloseScreen(screen);
+                        intel->dri2 = DRI_NONE;
+                }
+#endif
+#if HAVE_DRI3
+                if (intel->dri3 == DRI_ACTIVE) {
+                        /* nothing to do here? */
+                        intel->dri3 = DRI_NONE;
+                }
+                intel_sync_close(screen);
+#endif
 
-	intel_sync_close(screen);
+                break;
+#endif
+        default:
+                break;
+        }
 
 	xf86GARTCloseScreen(scrn->scrnIndex);
 
diff --git a/src/uxa/intel_glamor.c b/src/uxa/intel_glamor.c
index 21636d1..e2bc24c 100644
--- a/src/uxa/intel_glamor.c
+++ b/src/uxa/intel_glamor.c
@@ -35,31 +35,89 @@
 #include <xf86.h>
 #define GLAMOR_FOR_XORG  1
 #include <glamor.h>
+#include <unistd.h>
 
 #include "intel.h"
 #include "i915_drm.h"
 #include "intel_glamor.h"
-#include "uxa.h"
 #include "intel_options.h"
 
-void
-intel_glamor_exchange_buffers(struct intel_screen_private *intel,
-			      PixmapPtr src,
-			      PixmapPtr dst)
+struct intel_glamor_pixmap {
+        dri_bo  *bo;
+};
+
+static DevPrivateKeyRec intel_glamor_pixmap_key;
+
+static inline struct intel_glamor_pixmap *intel_glamor_get_pixmap(PixmapPtr pixmap)
 {
-	if (!(intel->uxa_flags & UXA_USE_GLAMOR))
-		return;
-	glamor_egl_exchange_buffers(src, dst);
+        return dixGetPrivateAddr(&pixmap->devPrivates, &intel_glamor_pixmap_key);
 }
 
-XF86VideoAdaptorPtr intel_glamor_xv_init(ScreenPtr screen, int num_ports)
+dri_bo *
+intel_glamor_get_pixmap_bo(PixmapPtr pixmap)
 {
-	ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
-	intel_screen_private *intel = intel_get_screen_private(scrn);
+        dri_bo  *bo = intel_glamor_get_pixmap(pixmap)->bo;
+
+        if (!bo) {
+                ScreenPtr       screen = pixmap->drawable.pScreen;
+                CARD16          stride;
+                CARD32          size;
+                int             fd;
+
+                fd = glamor_fd_from_pixmap(screen,
+                                           pixmap,
+                                           &stride,
+                                           &size);
+
+                if (fd >= 0) {
+                        ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
+                        intel_screen_private *intel = intel_get_screen_private(scrn);
+
+                        bo = drm_intel_bo_gem_create_from_prime(intel->bufmgr,
+                                                                fd,
+                                                                size);
+                        close(fd);
+                        intel_glamor_get_pixmap(pixmap)->bo = bo;
+                }
+        }
+        return bo;
+}
 
-	if ((intel->uxa_flags & UXA_USE_GLAMOR) == 0)
-		return NULL;
+static void
+intel_glamor_reference_pixmap_bo(PixmapPtr pixmap, drm_intel_bo *bo)
+{
+        struct intel_glamor_pixmap      *glamor_pixmap = intel_glamor_get_pixmap(pixmap);
+
+        if (glamor_pixmap->bo) {
+                ErrorF("Unreference bo %d size %lu from pixmap %d x %d\n",
+                       glamor_pixmap->bo->handle, glamor_pixmap->bo->size, pixmap->drawable.width, pixmap->drawable.height);
+                drm_intel_bo_unreference(glamor_pixmap->bo);
+                glamor_pixmap->bo = NULL;
+        }
+
+        if (bo) {
+                ErrorF("Reference bo %d size %lu from pixmap %d x %d\n",
+                       bo->handle, bo->size, pixmap->drawable.width, pixmap->drawable.height);
+                drm_intel_bo_reference(bo);
+                glamor_pixmap->bo = bo;
+        }
+}
 
+Bool
+intel_glamor_set_pixmap_bo(PixmapPtr pixmap, drm_intel_bo *bo)
+{
+        if (bo == NULL || glamor_egl_create_textured_pixmap(pixmap,
+                                                            bo->handle,
+                                                            intel_pixmap_pitch(pixmap)))
+        {
+                intel_glamor_reference_pixmap_bo(pixmap, bo);
+                return TRUE;
+        }
+        return FALSE;
+}
+
+XF86VideoAdaptorPtr intel_glamor_xv_init(ScreenPtr screen, int num_ports)
+{
 	return glamor_xv_init(screen, num_ports);
 }
 
@@ -68,33 +126,42 @@ intel_glamor_create_screen_resources(ScreenPtr screen)
 {
 	ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
 	intel_screen_private *intel = intel_get_screen_private(scrn);
-
-	if (!(intel->uxa_flags & UXA_USE_GLAMOR))
-		return TRUE;
+        PixmapPtr pixmap = screen->GetScreenPixmap(screen);
+        int     old_width, old_height, old_pitch;
+        Bool    ret;
 
 	if (!glamor_glyphs_init(screen))
 		return FALSE;
 
-	if (!glamor_egl_create_textured_screen_ext(screen,
-						   intel->front_buffer->handle,
-						   intel->front_pitch,
-						   &intel->back_pixmap))
+        old_width = pixmap->drawable.width;
+        old_height = pixmap->drawable.height;
+        old_pitch = pixmap->devKind;
+
+	if (!screen->ModifyPixmapHeader(pixmap,
+					scrn->virtualX,
+					scrn->virtualY,
+					-1, -1,
+					intel->front_pitch,
+					NULL))
 		return FALSE;
 
-	return TRUE;
-}
+        ret = glamor_egl_create_textured_screen_ext(screen,
+                                                    intel->front_buffer->handle,
+                                                    intel->front_pitch,
+                                                    &intel->back_pixmap);
 
-static Bool
-intel_glamor_enabled(intel_screen_private *intel)
-{
-	enum { SNA, UXA, GLAMOR } default_accel_method = DEFAULT_ACCEL_METHOD;
-	const char *s;
+        if (!ret)
+                goto fail;
+
+        intel_glamor_reference_pixmap_bo(pixmap, intel->front_buffer);
+
+        return TRUE;
 
-	s = xf86GetOptValString(intel->Options, OPTION_ACCEL_METHOD);
-	if (s == NULL)
-		return default_accel_method == GLAMOR;
+fail:
+        screen->ModifyPixmapHeader(pixmap,
+                                   old_width, old_height, -1, -1, old_pitch, NULL);
 
-	return strcasecmp(s, "glamor") == 0;
+        return FALSE;
 }
 
 Bool
@@ -104,9 +171,6 @@ intel_glamor_pre_init(ScrnInfoPtr scrn)
 	pointer glamor_module;
 	CARD32 version;
 
-	if (!intel_glamor_enabled(intel))
-		return TRUE;
-
 #if XORG_VERSION_CURRENT < XORG_VERSION_NUMERIC(1,15,0,0,0)
 	if (!xf86LoaderCheckSymbol("glamor_egl_init")) {
 		xf86DrvMsg(scrn->scrnIndex,  X_ERROR,
@@ -117,139 +181,57 @@ intel_glamor_pre_init(ScrnInfoPtr scrn)
 #endif
 
 	/* Load glamor module */
-	if ((glamor_module = xf86LoadSubModule(scrn, GLAMOR_EGL_MODULE_NAME))) {
-		version = xf86GetModuleVersion(glamor_module);
-		if (version < MODULE_VERSION_NUMERIC(0,3,1)) {
-			xf86DrvMsg(scrn->scrnIndex, X_ERROR,
-			"Incompatible glamor version, required >= 0.3.0.\n");
-		} else {
-			if (glamor_egl_init(scrn, intel->drmSubFD)) {
-				xf86DrvMsg(scrn->scrnIndex, X_INFO,
-					   "glamor detected, initialising egl layer.\n");
-				intel->uxa_flags = UXA_GLAMOR_EGL_INITIALIZED;
-			} else
-				xf86DrvMsg(scrn->scrnIndex, X_WARNING,
-					   "glamor detected, failed to initialize egl.\n");
-		}
-	} else
+        glamor_module = xf86LoadSubModule(scrn, GLAMOR_EGL_MODULE_NAME);
+	if (!glamor_module) {
 		xf86DrvMsg(scrn->scrnIndex, X_WARNING,
 			   "glamor not available\n");
+                return TRUE;
+        }
+
+        version = xf86GetModuleVersion(glamor_module);
+        if (version < MODULE_VERSION_NUMERIC(0,3,1)) {
+                xf86DrvMsg(scrn->scrnIndex, X_ERROR,
+                           "Incompatible glamor version, required >= 0.3.0.\n");
+                return TRUE;
+        }
+        if (!glamor_egl_init(scrn, intel->drmSubFD)) {
+                xf86DrvMsg(scrn->scrnIndex, X_WARNING,
+                           "glamor detected, failed to initialize egl.\n");
+                return TRUE;
+        }
+        xf86DrvMsg(scrn->scrnIndex, X_INFO,
+                   "glamor detected, initialising egl layer.\n");
 
 	return TRUE;
 }
 
-PixmapPtr
-intel_glamor_create_pixmap(ScreenPtr screen, int w, int h,
-			   int depth, unsigned int usage)
-{
-	ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
-	intel_screen_private *intel = intel_get_screen_private(scrn);
-
-	if (intel->uxa_flags & UXA_USE_GLAMOR)
-		return glamor_create_pixmap(screen, w, h, depth, usage);
-	else
-		return NULL;
-}
-
-Bool
-intel_glamor_create_textured_pixmap(PixmapPtr pixmap)
-{
-	ScrnInfoPtr scrn = xf86ScreenToScrn(pixmap->drawable.pScreen);
-	intel_screen_private *intel = intel_get_screen_private(scrn);
-	struct intel_uxa_pixmap *priv;
-
-	if ((intel->uxa_flags & UXA_USE_GLAMOR) == 0)
-		return TRUE;
-
-	priv = intel_uxa_get_pixmap_private(pixmap);
-	if (glamor_egl_create_textured_pixmap(pixmap, priv->bo->handle,
-					      priv->stride)) {
-		drm_intel_bo_disable_reuse(priv->bo);
-		priv->pinned |= PIN_GLAMOR;
-		return TRUE;
-	} else
-		return FALSE;
-}
-
-void
-intel_glamor_destroy_pixmap(PixmapPtr pixmap)
-{
-	ScrnInfoPtr scrn = xf86ScreenToScrn(pixmap->drawable.pScreen);
-	intel_screen_private * intel;
-
-	intel = intel_get_screen_private(scrn);
-	if (intel->uxa_flags & UXA_USE_GLAMOR)
-		glamor_egl_destroy_textured_pixmap(pixmap);
-}
-
-static void
-intel_glamor_need_flush(DrawablePtr pDrawable)
-{
-	ScrnInfoPtr scrn = xf86ScreenToScrn(pDrawable->pScreen);
-	intel_screen_private * intel;
-
-	intel = intel_get_screen_private(scrn);
-	intel->needs_flush = TRUE;
-}
-
-static void
-intel_glamor_finish_access(PixmapPtr pixmap, uxa_access_t access)
-{
-	switch(access) {
-	case UXA_ACCESS_RO:
-	case UXA_ACCESS_RW:
-	case UXA_GLAMOR_ACCESS_RO:
-		break;
-	case UXA_GLAMOR_ACCESS_RW:
-		intel_glamor_need_flush(&pixmap->drawable);
-		break;
-	default:
-		ErrorF("Invalid access mode %d\n", access);
-	}
-
-	return;
-}
-
 Bool
 intel_glamor_init(ScreenPtr screen)
 {
 	ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
-	intel_screen_private *intel = intel_get_screen_private(scrn);
 
-	if ((intel->uxa_flags & UXA_GLAMOR_EGL_INITIALIZED) == 0)
-		goto fail;
+	if (!dixPrivateKeyRegistered(&intel_glamor_pixmap_key))
+                if (!dixRegisterPrivateKey(&intel_glamor_pixmap_key, PRIVATE_PIXMAP, sizeof (struct intel_glamor_pixmap)))
+                        return FALSE;
 
 	if (!glamor_init(screen,
-#if defined(GLAMOR_NO_DRI3)
-			 /* Not doing DRI3 yet, since Present support hasn't landed. */
-			 GLAMOR_NO_DRI3 |
-#endif
 			 GLAMOR_INVERTED_Y_AXIS |
-			 GLAMOR_USE_EGL_SCREEN)) {
+			 GLAMOR_USE_EGL_SCREEN |
+                         GLAMOR_USE_SCREEN |
+                         GLAMOR_USE_PICTURE_SCREEN))
+        {
 		xf86DrvMsg(scrn->scrnIndex, X_ERROR,
 			   "Failed to initialize glamor.\n");
-		goto fail;
+		return FALSE;
 	}
 
 	if (!glamor_egl_init_textured_pixmap(screen)) {
 		xf86DrvMsg(scrn->scrnIndex, X_ERROR,
 			   "Failed to initialize textured pixmap of screen for glamor.\n");
-		goto fail;
+		return FALSE;
 	}
 
-	intel->uxa_driver->flags |= UXA_USE_GLAMOR;
-	intel->uxa_flags |= intel->uxa_driver->flags;
-
-	intel->uxa_driver->finish_access = intel_glamor_finish_access;
-
-	xf86DrvMsg(scrn->scrnIndex, X_INFO,
-		   "Use GLAMOR acceleration.\n");
 	return TRUE;
-
-  fail:
-	xf86DrvMsg(scrn->scrnIndex, X_INFO,
-		   "Use legacy UXA acceleration.\n");
-	return FALSE;
 }
 
 void
@@ -258,18 +240,52 @@ intel_glamor_flush(intel_screen_private * intel)
 	ScreenPtr screen;
 
 	screen = xf86ScrnToScreen(intel->scrn);
-	if (intel->uxa_flags & UXA_USE_GLAMOR)
-		glamor_block_handler(screen);
+        glamor_block_handler(screen);
 }
 
 Bool
 intel_glamor_close_screen(ScreenPtr screen)
 {
-	ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
-	intel_screen_private *intel = intel_get_screen_private(scrn);
+	return TRUE;
+}
 
-	if (intel->uxa_flags & UXA_USE_GLAMOR)
-		intel->uxa_flags &= ~UXA_USE_GLAMOR;
+#if HAVE_DRI2
+void
+intel_glamor_exchange_buffers(struct intel_screen_private *intel,
+			      PixmapPtr src,
+			      PixmapPtr dst)
+{
+	glamor_egl_exchange_buffers(src, dst);
+}
 
-	return TRUE;
+PixmapPtr
+intel_glamor_create_back_pixmap(ScreenPtr screen,
+				PixmapPtr front_pixmap,
+				drm_intel_bo *back_bo)
+{
+	PixmapPtr back_pixmap;
+
+	back_pixmap = screen->CreatePixmap(screen,
+					   0,
+					   0,
+				           front_pixmap->drawable.depth,
+				           0);
+	if (back_pixmap == NULL)
+		return NULL;
+
+	screen->ModifyPixmapHeader(back_pixmap,
+				   front_pixmap->drawable.width,
+				   front_pixmap->drawable.height,
+				   0, 0,
+				   front_pixmap->devKind,
+				   0);
+	if (!intel_glamor_set_pixmap_bo(back_pixmap, back_bo)) {
+		ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
+		xf86DrvMsg(scrn->scrnIndex, X_WARNING,
+			   "Failed to create textured back pixmap.\n");
+		screen->DestroyPixmap(back_pixmap);
+		return NULL;
+	}
+	return back_pixmap;
 }
+#endif
diff --git a/src/uxa/intel_glamor.h b/src/uxa/intel_glamor.h
index 97c2257..2fcabdf 100644
--- a/src/uxa/intel_glamor.h
+++ b/src/uxa/intel_glamor.h
@@ -40,11 +40,21 @@ void intel_glamor_free_screen(int scrnIndex, int flags);
 
 void intel_glamor_flush(intel_screen_private * intel);
 
-Bool intel_glamor_create_textured_pixmap(PixmapPtr pixmap);
-void intel_glamor_destroy_pixmap(PixmapPtr pixmap);
-PixmapPtr intel_glamor_create_pixmap(ScreenPtr screen, int w, int h,
-				     int depth, unsigned int usage);
+#if HAVE_DRI2
+PixmapPtr
+intel_glamor_create_back_pixmap(ScreenPtr screen,
+				PixmapPtr front_pixmap,
+				drm_intel_bo *back_bo);
+
 void intel_glamor_exchange_buffers(struct intel_screen_private *intel, PixmapPtr src, PixmapPtr dst);
+#endif
+
 XF86VideoAdaptorPtr intel_glamor_xv_init(ScreenPtr screen, int num_ports);
 
+dri_bo *
+intel_glamor_get_pixmap_bo(PixmapPtr pixmap);
+
+Bool
+intel_glamor_set_pixmap_bo(PixmapPtr pixmap, dri_bo *bo);
+
 #endif /* INTEL_GLAMOR_H */
diff --git a/src/uxa/intel_present.c b/src/uxa/intel_present.c
index b901fb1..04aeb78 100644
--- a/src/uxa/intel_present.c
+++ b/src/uxa/intel_present.c
@@ -54,11 +54,6 @@
 
 #include "present.h"
 
-#if USE_GLAMOR
-#include "intel_glamor.h"
-#endif
-#include "uxa.h"
-
 struct intel_present_vblank_event {
 	uint64_t        event_id;
 };
diff --git a/src/uxa/intel_uxa.c b/src/uxa/intel_uxa.c
index da4eb97..e9d905b 100644
--- a/src/uxa/intel_uxa.c
+++ b/src/uxa/intel_uxa.c
@@ -1272,6 +1272,11 @@ Bool intel_uxa_init(ScreenPtr screen)
 	ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
 	intel_screen_private *intel = intel_get_screen_private(scrn);
 
+	intel_batch_init(scrn);
+
+	if (INTEL_INFO(intel)->gen >= 040 && INTEL_INFO(intel)->gen < 0100)
+		gen4_render_state_init(scrn);
+
 #if HAS_DIXREGISTERPRIVATEKEY
 	if (!dixRegisterPrivateKey(&uxa_pixmap_index, PRIVATE_PIXMAP, 0))
 #else
diff --git a/src/uxa/intel_video.c b/src/uxa/intel_video.c
index ae3d351..73920e6 100644
--- a/src/uxa/intel_video.c
+++ b/src/uxa/intel_video.c
@@ -81,7 +81,10 @@
 #if USE_GLAMOR
 #include "intel_glamor.h"
 #endif
+#if USE_UXA
 #include "intel_uxa.h"
+#endif
+
 #include "intel_video_overlay.h"
 
 Atom intel_xv_Brightness, intel_xv_Contrast, intel_xv_Saturation, intel_xv_ColorKey, intel_xv_Pipe;
@@ -165,14 +168,14 @@ void intel_video_init(ScreenPtr screen)
 	ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
 	intel_screen_private *intel = intel_get_screen_private(scrn);
 	XF86VideoAdaptorPtr *adaptors = NULL, *newAdaptors = NULL;
-	XF86VideoAdaptorPtr overlayAdaptor = NULL, texturedAdaptor = NULL, glamorAdaptor = NULL;
+	XF86VideoAdaptorPtr overlayAdaptor = NULL, texturedAdaptor = NULL;
 	int num_adaptors = xf86XVListGenericAdaptors(scrn, &adaptors);
 
 	/* Give our adaptor list enough space for the overlay and/or texture video
 	 * adaptors.
 	 */
 	newAdaptors = realloc(adaptors,
-			      (num_adaptors + 3) * sizeof(XF86VideoAdaptorPtr));
+			      (num_adaptors + 2) * sizeof(XF86VideoAdaptorPtr));
 
 	if (newAdaptors == NULL) {
 		free(adaptors);
@@ -186,21 +189,37 @@ void intel_video_init(ScreenPtr screen)
 	intel_xv_Brightness = MAKE_ATOM("XV_BRIGHTNESS");
 	intel_xv_Contrast = MAKE_ATOM("XV_CONTRAST");
 
-        /* Set up textured video if we can do it at this depth and we are on
-         * supported hardware.
-         */
-        if (!intel->force_fallback &&
-            scrn->bitsPerPixel >= 16 &&
-            INTEL_INFO(intel)->gen >= 030 &&
-            INTEL_INFO(intel)->gen < 0100) {
-                texturedAdaptor = intel_uxa_video_setup_image_textured(screen);
-                if (texturedAdaptor != NULL) {
-                        xf86DrvMsg(scrn->scrnIndex, X_INFO,
-                                   "Set up textured video\n");
-                } else {
-                        xf86DrvMsg(scrn->scrnIndex, X_ERROR,
-                                   "Failed to set up textured video\n");
+        switch (intel->accel) {
+#if USE_UXA
+        case ACCEL_UXA:
+                /* Set up textured video if we can do it at this depth and we are on
+                 * supported hardware.
+                 */
+                if (!intel->force_fallback &&
+                    scrn->bitsPerPixel >= 16 &&
+                    INTEL_INFO(intel)->gen >= 030 &&
+                    INTEL_INFO(intel)->gen < 0100) {
+                        texturedAdaptor = intel_uxa_video_setup_image_textured(screen);
+                        if (texturedAdaptor != NULL) {
+                                xf86DrvMsg(scrn->scrnIndex, X_INFO,
+                                           "Set up textured video\n");
+                        } else {
+                                xf86DrvMsg(scrn->scrnIndex, X_ERROR,
+                                           "Failed to set up textured video\n");
+                        }
                 }
+                break;
+#endif
+#if USE_GLAMOR
+        case ACCEL_GLAMOR:
+                texturedAdaptor = intel_glamor_xv_init(screen, 16);
+                if (texturedAdaptor != NULL)
+                        xf86DrvMsg(scrn->scrnIndex, X_INFO,
+                                   "Set up textured video using glamor\n");
+                break;
+#endif
+        default:
+                break;
         }
 
         overlayAdaptor = intel_video_overlay_setup_image(screen);
@@ -215,23 +234,12 @@ void intel_video_init(ScreenPtr screen)
 		}
 	}
 
-#if USE_GLAMOR
-	glamorAdaptor = intel_glamor_xv_init(screen, 16);
-	if (glamorAdaptor != NULL)
-		xf86DrvMsg(scrn->scrnIndex, X_INFO,
-			   "Set up textured video using glamor\n");
-#endif
-
-
 	if (overlayAdaptor && intel->XvPreferOverlay)
 		adaptors[num_adaptors++] = overlayAdaptor;
 
 	if (texturedAdaptor)
 		adaptors[num_adaptors++] = texturedAdaptor;
 
-	if (glamorAdaptor)
-		adaptors[num_adaptors++] = glamorAdaptor;
-
 	if (overlayAdaptor && !intel->XvPreferOverlay)
 		adaptors[num_adaptors++] = overlayAdaptor;
 
@@ -243,9 +251,16 @@ void intel_video_init(ScreenPtr screen)
 		intel->XvEnabled = FALSE;
 	}
 
-        if (texturedAdaptor)
-                intel_xvmc_adaptor_init(screen);
-
+#if defined(INTEL_XVMC) && defined(USE_UXA)
+        switch (intel->accel) {
+        case ACCEL_UXA:
+                if (texturedAdaptor)
+                        intel_xvmc_adaptor_init(screen);
+                break;
+        default:
+                break;
+        }
+#endif
 	free(adaptors);
 }
 
-- 
2.0.1

_______________________________________________
xorg-devel-go0+a7rfsptAfugRpC6u6w@public.gmane.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 11/12] Add "none" acceleration option
       [not found] ` <1406243908-1123-1-git-send-email-keithp-aN4HjG94KOLQT0dZR+AlfA@public.gmane.org>
                     ` (3 preceding siblings ...)
  2014-07-24 23:18   ` [PATCH 10/12] Add glamor back into the driver Keith Packard
@ 2014-07-24 23:18   ` Keith Packard
  2014-07-24 23:18   ` [PATCH 12/12] Delay initial modeset until root window contents are prepared Keith Packard
  2014-07-31  2:29   ` [PATCH 00/12] Rework intel 2D driver glamor support Eric Anholt
  6 siblings, 0 replies; 35+ messages in thread
From: Keith Packard @ 2014-07-24 23:18 UTC (permalink / raw)
  To: xorg-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	intel-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

This just uses fb directly

Signed-off-by: Keith Packard <keithp@keithp.com>
---
 configure.ac            |  24 ++++-
 src/Makefile.am         |   9 +-
 src/intel_module.c      |  12 ++-
 src/uxa/Makefile.am     |  46 ++++++---
 src/uxa/intel.h         |   5 +
 src/uxa/intel_display.c |   6 ++
 src/uxa/intel_dri3.c    |  49 ++++++----
 src/uxa/intel_driver.c  | 245 ++++++++++++++++++++++++++++++------------------
 src/uxa/intel_glamor.c  |  10 ++
 src/uxa/intel_none.c    | 189 +++++++++++++++++++++++++++++++++++++
 src/uxa/intel_none.h    |  38 ++++++++
 src/uxa/intel_uxa.c     |   9 ++
 12 files changed, 504 insertions(+), 138 deletions(-)
 create mode 100644 src/uxa/intel_none.c
 create mode 100644 src/uxa/intel_none.h

diff --git a/configure.ac b/configure.ac
index 5c3dd20..46c3143 100644
--- a/configure.ac
+++ b/configure.ac
@@ -396,7 +396,6 @@ if test "x$UXA" = "xauto"; then
 fi
 if test "x$UXA" != "xno"; then
 	AC_DEFINE(USE_UXA, 1, [Enable UXA support])
-	PKG_CHECK_MODULES(DRMINTEL, [libdrm_intel >= $uxa_requires_libdrm])
 	required_pixman_version=0.24
 	UXA=yes
 fi
@@ -407,9 +406,6 @@ AC_ARG_ENABLE(glamor,
 	      [GLAMOR="$enableval"],
 	      [GLAMOR="no"])
 if test "x$GLAMOR" != "xno"; then
-	if test "x$UXA" != "xyes"; then
-		AC_MSG_ERROR([Glamor acceleration requested but UXA is not enabled])
-	fi
 	if pkg-config --exists "xorg-server >= 1.15.99.901"; then
 		GLAMOR="yes (using Xorg glamor module)"
 	else
@@ -417,9 +413,12 @@ if test "x$GLAMOR" != "xno"; then
 		PKG_CHECK_MODULES(LIBGLAMOR_EGL, [glamor-egl])
 		GLAMOR="yes (using libglamor)"
 	fi
+	GLAMOR=yes
 	AC_DEFINE(USE_GLAMOR, 1, [Enable glamor acceleration])
 fi
 
+PKG_CHECK_MODULES(DRMINTEL, [libdrm_intel >= $uxa_requires_libdrm])
+
 PKG_CHECK_MODULES(XORG, [xorg-server >= $required_xorg_server_version xproto fontsproto pixman-1 >= $required_pixman_version $REQUIRED_MODULES])
 ABI_VERSION=`$PKG_CONFIG --variable=abi_videodrv xorg-server`
 
@@ -661,6 +660,12 @@ if test "x$accel" = "xauto"; then
 	else
 		if test "x$UXA" != "xno"; then
 			accel="uxa"
+		else
+			if test "x$GLAMOR" != "xno"; then
+				accel="glamor"
+			else
+				accel="none"
+			fi
 		fi
 	fi
 	if test "x$accel" = "xauto" -a "x$KMS" = "xyes"; then
@@ -696,6 +701,11 @@ if test "x$accel" = "xglamor"; then
 	fi
 fi
 
+if test "x$accel" = "xnone"; then
+	AC_DEFINE(DEFAULT_ACCEL_METHOD, NONE, [Default acceleration method])
+	have_accel="yes"
+fi
+
 if test "x$have_accel" = "xnone"; then
 	if test "x$KMS" = "xyes"; then
 		AC_MSG_ERROR([Invalid default acceleration option])
@@ -886,6 +896,12 @@ if test "x$GLAMOR" != "xno"; then
 	fi
 fi
 
+if test "$accel" = "none"; then
+	accel_msg="$accel_msg *none"
+else
+	accel_msg="$accel_msg none"
+fi
+
 if test "x$dri_msg" = "x"; then
 	dri_msg=" none"
 fi
diff --git a/src/Makefile.am b/src/Makefile.am
index aa8b47e..ce6f836 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -18,7 +18,7 @@
 #  IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 #  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
-SUBDIRS = render_program legacy
+SUBDIRS = render_program legacy uxa
 
 # this is obnoxious:
 # -module lets us name the module exactly how we want
@@ -41,18 +41,13 @@ endif
 intel_drv_la_LTLIBRARIES = intel_drv.la
 intel_drv_la_LDFLAGS = -module -avoid-version
 intel_drv_ladir = $(moduledir)/drivers
-intel_drv_la_LIBADD = legacy/liblegacy.la $(PCIACCESS_LIBS) $(XORG_LIBS)
+intel_drv_la_LIBADD = legacy/liblegacy.la uxa/libuxa.la $(PCIACCESS_LIBS) $(XORG_LIBS)
 
 if SNA
 SUBDIRS += sna
 intel_drv_la_LIBADD += sna/libsna.la
 endif
 
-if UXA
-SUBDIRS += uxa
-intel_drv_la_LIBADD += uxa/libuxa.la
-endif
-
 NULL:=#
 
 intel_drv_la_SOURCES = \
diff --git a/src/intel_module.c b/src/intel_module.c
index d6a0d3c..b8d7f91 100644
--- a/src/intel_module.c
+++ b/src/intel_module.c
@@ -489,7 +489,7 @@ _xf86findDriver(const char *ident, XF86ConfDevicePtr p)
 	return NULL;
 }
 
-static enum accel_method { SNA, UXA, GLAMOR } get_accel_method(void)
+static enum accel_method { NONE, SNA, UXA, GLAMOR } get_accel_method(void)
 {
 	enum accel_method accel_method = DEFAULT_ACCEL_METHOD;
 	XF86ConfDevicePtr dev;
@@ -509,6 +509,8 @@ static enum accel_method { SNA, UXA, GLAMOR } get_accel_method(void)
 				accel_method = UXA;
 			else if (strcasecmp(s, "glamor") == 0)
 				accel_method = GLAMOR;
+                        else if (strcasecmp(s, "none") == 0)
+                                 accel_method = NONE;
 		}
 	}
 
@@ -564,12 +566,14 @@ intel_scrn_create(DriverPtr		driver,
 #if USE_SNA
 	case SNA: return sna_init_scrn(scrn, entity_num);
 #endif
-#if USE_UXA
+#if USE_GLAMOR
 	case GLAMOR:
+#endif
+#if USE_UXA
 	case UXA:
-		  return intel_init_scrn(scrn);
 #endif
-
+        case NONE:
+		  return intel_init_scrn(scrn);
 	default: break;
 	}
 #endif
diff --git a/src/uxa/Makefile.am b/src/uxa/Makefile.am
index b9618c9..b7b5138 100644
--- a/src/uxa/Makefile.am
+++ b/src/uxa/Makefile.am
@@ -25,21 +25,27 @@ AM_CFLAGS += -I$(top_srcdir)/xvmc -I$(top_srcdir)/src -I$(top_srcdir)/src/render
 noinst_LTLIBRARIES = libuxa.la
 libuxa_la_LIBADD = $(UDEV_LIBS) $(DRMINTEL_LIBS) $(DRM_LIBS)
 libuxa_la_SOURCES = \
-	intel_uxa.h \
-	brw_defines.h \
-	brw_structs.h \
 	common.h \
 	intel.h \
-	intel_batchbuffer.c \
-	intel_batchbuffer.h \
 	intel_display.c \
 	intel_driver.c \
 	intel_memory.c \
-	intel_uxa.c \
+	intel_none.c \
+	intel_none.h \
 	intel_video.c \
 	intel_video.h \
 	intel_video_overlay.c \
 	intel_video_overlay.h \
+	$(NULL)
+
+if UXA
+libuxa_la_SOURCES += \
+	intel_uxa.h \
+	intel_batchbuffer.c \
+	intel_batchbuffer.h \
+	brw_defines.h \
+	brw_structs.h \
+	intel_uxa.c \
 	intel_uxa_video.c \
 	i830_3d.c \
 	i830_render.c \
@@ -61,9 +67,20 @@ libuxa_la_SOURCES = \
 	uxa-glyphs.c \
 	uxa-render.c \
 	uxa-priv.h \
-	uxa-unaccel.c
+	uxa-unaccel.c \
+	 $(NULL)
+endif
+
+if GLAMOR
+AM_CFLAGS += $(LIBGLAMOR_CFLAGS)
+libuxa_la_LIBADD += $(LIBGLAMOR_LIBS)
+libuxa_la_SOURCES += \
+	intel_glamor.h \
+	intel_glamor.c \
 	$(NULL)
+endif
 
+if UXA
 if DRI2
 AM_CFLAGS += $(DRI2_CFLAGS)
 libuxa_la_SOURCES += \
@@ -75,6 +92,15 @@ libuxa_la_LIBADD += \
 	$(NULL)
 endif
 
+if XVMC
+AM_CFLAGS += -I$(top_srcdir)/xvmc
+libuxa_la_SOURCES += \
+	intel_hwmc.c \
+	$(NULL)
+endif
+
+endif
+
 if DRI3
 libuxa_la_SOURCES += \
 	intel_dri3.c \
@@ -88,9 +114,3 @@ libuxa_la_SOURCES += \
 	$(NULL)
 endif
 
-if XVMC
-AM_CFLAGS += -I$(top_srcdir)/xvmc
-libuxa_la_SOURCES += \
-	intel_hwmc.c \
-	$(NULL)
-endif
diff --git a/src/uxa/intel.h b/src/uxa/intel.h
index 5fbb2c7..ae33938 100644
--- a/src/uxa/intel.h
+++ b/src/uxa/intel.h
@@ -112,6 +112,7 @@ enum dri_type {
 };
 
 enum accel_type {
+        ACCEL_NONE,
 #if USE_GLAMOR
         ACCEL_GLAMOR,
 #endif
@@ -126,9 +127,11 @@ typedef struct intel_screen_private {
 
         enum accel_type accel;
 
+#if USE_UXA
 #define RENDER_BATCH			I915_EXEC_RENDER
 #define BLT_BATCH			I915_EXEC_BLT
 	unsigned int current_batch;
+#endif
 
 	void *modes;
 	drm_intel_bo *front_buffer, *back_buffer;
@@ -544,7 +547,9 @@ Bool intel_present_screen_init(ScreenPtr screen);
 static inline Bool intel_present_screen_init(ScreenPtr screen) { return 0; }
 #endif
 
+#if USE_UXA
 #include "intel_uxa.h"
+#endif
 
 dri_bo *
 intel_get_pixmap_bo(PixmapPtr pixmap);
diff --git a/src/uxa/intel_display.c b/src/uxa/intel_display.c
index a4c4b82..1d4ba3c 100644
--- a/src/uxa/intel_display.c
+++ b/src/uxa/intel_display.c
@@ -56,9 +56,11 @@
 #include "xf86DDC.h"
 #include "fb.h"
 #include "uxa.h"
+
 #if USE_GLAMOR
 #include "intel_glamor.h"
 #endif
+#include "intel_none.h"
 
 #define KNOWN_MODE_FLAGS ((1<<14)-1)
 
@@ -1491,6 +1493,10 @@ intel_xf86crtc_resize(ScrnInfoPtr scrn, int width, int height)
                         goto fail;
                 break;
 #endif
+        case ACCEL_NONE:
+                if (!intel_none_create_screen_resources(scrn->pScreen))
+                        goto fail;
+                break;
         }
 
 	for (i = 0; i < xf86_config->num_crtc; i++) {
diff --git a/src/uxa/intel_dri3.c b/src/uxa/intel_dri3.c
index 16a2463..be7af49 100644
--- a/src/uxa/intel_dri3.c
+++ b/src/uxa/intel_dri3.c
@@ -56,7 +56,6 @@ static PixmapPtr intel_dri3_pixmap_from_fd(ScreenPtr screen,
 {
 	ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
 	intel_screen_private *intel = intel_get_screen_private(scrn);
-	struct intel_uxa_pixmap *priv;
 	PixmapPtr pixmap;
 	dri_bo *bo;
 
@@ -84,14 +83,19 @@ static PixmapPtr intel_dri3_pixmap_from_fd(ScreenPtr screen,
 	if (bo == NULL)
 		goto free_pixmap;
 
-	intel_uxa_set_pixmap_bo(pixmap, bo);
+	intel_set_pixmap_bo(pixmap, bo);
 	dri_bo_unreference(bo);
 
-	priv = intel_uxa_get_pixmap_private(pixmap);
-	if (priv == NULL)
-		goto free_pixmap;
+#if USE_UXA
+        if (intel->accel == ACCEL_UXA) {
+                struct intel_uxa_pixmap *priv;
+                priv = intel_uxa_get_pixmap_private(pixmap);
+                if (priv == NULL)
+                        goto free_pixmap;
 
-	priv->pinned |= PIN_DRI3;
+                priv->pinned |= PIN_DRI3;
+        }
+#endif
 
 	return pixmap;
 
@@ -105,23 +109,30 @@ static int intel_dri3_fd_from_pixmap(ScreenPtr screen,
 				     CARD16 *stride,
 				     CARD32 *size)
 {
-	struct intel_uxa_pixmap *priv;
-	int fd;
-
-	priv = intel_uxa_get_pixmap_private(pixmap);
-	if (!priv)
-		return -1;
+        dri_bo *bo;
+        int fd;
 
-	if (priv->stride > UINT16_MAX)
-		return -1;
+        bo = intel_get_pixmap_bo(pixmap);
+        if (!bo)
+                return -1;
 
-	if (drm_intel_bo_gem_export_to_prime(priv->bo, &fd) < 0)
+	if (drm_intel_bo_gem_export_to_prime(bo, &fd) < 0)
 		return -1;
 
-	priv->pinned |= PIN_DRI3;
-
-	*stride = priv->stride;
-	*size = priv->bo->size;
+#if USE_UXA
+        if (intel_get_screen_private(xf86ScreenToScrn(screen))->accel== ACCEL_UXA) {
+                struct intel_uxa_pixmap *priv;
+
+                priv = intel_uxa_get_pixmap_private(pixmap);
+                if (!priv)
+                        return -1;
+                if (priv->stride > UINT16_MAX)
+                        return -1;
+                priv->pinned |= PIN_DRI3;
+        }
+#endif
+	*stride = bo->size / pixmap->drawable.height;
+	*size = bo->size;
 	return fd;
 }
 
diff --git a/src/uxa/intel_driver.c b/src/uxa/intel_driver.c
index 065c679..316de64 100644
--- a/src/uxa/intel_driver.c
+++ b/src/uxa/intel_driver.c
@@ -62,6 +62,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "intel.h"
 #include "intel_video.h"
 #include "uxa_module.h"
+#include "intel_none.h"
 
 #ifdef INTEL_XVMC
 #define _INTEL_XVMC_SERVER_
@@ -177,6 +178,10 @@ static Bool i830CreateScreenResources(ScreenPtr screen)
                         return FALSE;
                 intel_copy_fb(scrn);
 #endif
+        case ACCEL_NONE:
+                if (!intel_none_create_screen_resources(screen))
+                        return FALSE;
+                break;
         }
 
 	return TRUE;
@@ -199,6 +204,9 @@ intel_set_pixmap_bo(PixmapPtr pixmap, dri_bo *bo)
                 intel_uxa_set_pixmap_bo(pixmap, bo);
                 break;
 #endif
+        case ACCEL_NONE:
+                intel_none_set_pixmap_bo(pixmap, bo);
+                break;
         default:
                 ErrorF("No accel architecture, cannot set pixmap bo\n");
                 break;
@@ -220,6 +228,8 @@ intel_get_pixmap_bo(PixmapPtr pixmap)
         case ACCEL_UXA:
 		return intel_uxa_get_pixmap_bo(pixmap);
 #endif
+        case ACCEL_NONE:
+                return intel_none_get_pixmap_bo(pixmap);
         default:
                 ErrorF("No accel architecture, cannot set pixmap bo\n");
 	        return NULL;
@@ -240,6 +250,8 @@ intel_flush(intel_screen_private *intel)
                 intel_batch_submit(intel->scrn);
                 break;
 #endif
+        default:
+                break;
         }
 }
 
@@ -276,6 +288,9 @@ static void intel_check_accel_option(ScrnInfoPtr scrn)
                         accel_method = UXA;
                 else
 #endif
+                if (strcasecmp(s, "none") == 0)
+                        accel_method = NONE;
+                else
                         accel_method = DEFAULT_ACCEL_METHOD;
         }
         switch (accel_method) {
@@ -290,6 +305,9 @@ static void intel_check_accel_option(ScrnInfoPtr scrn)
                 intel->accel = ACCEL_UXA;
                 break;
 #endif
+        case NONE:
+                intel->accel = ACCEL_NONE;
+                break;
         }
 }
 
@@ -376,10 +394,13 @@ static int intel_init_bufmgr(intel_screen_private *intel)
 	if (!intel->bufmgr)
 		return FALSE;
 
-	if (xf86ReturnOptValBool(intel->Options, OPTION_BUFFER_CACHE, TRUE))
-		drm_intel_bufmgr_gem_enable_reuse(intel->bufmgr);
-	drm_intel_bufmgr_gem_set_vma_cache_size(intel->bufmgr, 512);
-	drm_intel_bufmgr_gem_enable_fenced_relocs(intel->bufmgr);
+#if USE_UXA
+        if (intel->accel == ACCEL_UXA) {
+                if (xf86ReturnOptValBool(intel->Options, OPTION_BUFFER_CACHE, TRUE))
+                        drm_intel_bufmgr_gem_enable_reuse(intel->bufmgr);
+                drm_intel_bufmgr_gem_set_vma_cache_size(intel->bufmgr, 512);
+                drm_intel_bufmgr_gem_enable_fenced_relocs(intel->bufmgr);
+        }
 
 	list_init(&intel->batch_pixmaps);
 
@@ -388,6 +409,7 @@ static int intel_init_bufmgr(intel_screen_private *intel)
 			drm_intel_bo_alloc(intel->bufmgr, "wa scratch",
 					   4096, 4096);
 	}
+#endif
 
 	return TRUE;
 }
@@ -397,7 +419,10 @@ static void intel_bufmgr_fini(intel_screen_private *intel)
 	if (intel->bufmgr == NULL)
 		return;
 
-	drm_intel_bo_unreference(intel->wa_scratch_bo);
+#if USE_UXA
+        if (intel->accel == ACCEL_UXA)
+                drm_intel_bo_unreference(intel->wa_scratch_bo);
+#endif
 	drm_intel_bufmgr_destroy(intel->bufmgr);
 }
 
@@ -711,7 +736,11 @@ static Bool I830PreInit(ScrnInfoPtr scrn, int flags)
                         PreInitCleanup(scrn);
                         xf86DrvMsg(scrn->scrnIndex, X_ERROR,
                                    "Failed to pre init glamor display.\n");
+#if USE_UXA
                         intel->accel = ACCEL_UXA;
+#else
+                        intel->accel = ACCEL_NONE;
+#endif
                 }
                 break;
 #endif
@@ -722,12 +751,14 @@ static Bool I830PreInit(ScrnInfoPtr scrn, int flags)
                 if (intel->dri2 != DRI_DISABLED && !xf86LoadSubModule(scrn, "dri2"))
                         intel->dri2 = DRI_DISABLED;
 #endif
+                /* fall through ... */
+#endif
+        case ACCEL_NONE:
 #if HAVE_DRI3
                 if (intel->dri3 != DRI_DISABLED && !xf86LoadSubModule(scrn, "dri3"))
                         intel->dri3 = DRI_DISABLED;
 #endif
                 break;
-#endif
         default:
                 break;
         }
@@ -760,7 +791,7 @@ redisplay_dirty(ScreenPtr screen, PixmapDirtyUpdatePtr dirty)
 
         intel_flush(intel);
 	if (!intel->has_prime_vmap_flush) {
-		drm_intel_bo *bo = intel_uxa_get_pixmap_bo(dirty->slave_dst->master_pixmap);
+		drm_intel_bo *bo = (drm_intel_bo *) intel_get_pixmap_bo(dirty->slave_dst->master_pixmap);
 		was_blocked = xf86BlockSIGIO();
 		drm_intel_bo_map(bo, FALSE);
 		drm_intel_bo_unmap(bo);
@@ -804,8 +835,12 @@ I830BlockHandler(BLOCKHANDLER_ARGS_DECL)
 	intel->BlockHandler = screen->BlockHandler;
 	screen->BlockHandler = I830BlockHandler;
 
-	intel_uxa_block_handler(intel);
-	intel_video_block_handler(intel);
+#if USE_UXA
+        if (intel->accel == ACCEL_UXA) {
+                intel_uxa_block_handler(intel);
+                intel_video_block_handler(intel);
+        }
+#endif
 #ifdef INTEL_PIXMAP_SHARING
 	intel_dirty_update(screen);
 #endif
@@ -957,9 +992,11 @@ I830ScreenInit(SCREEN_INIT_ARGS_DECL)
 	ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
 	intel_screen_private *intel = intel_get_screen_private(scrn);
 	VisualPtr visual;
+#if USE_UXA
 #ifdef INTEL_XVMC
 	MessageType from;
 #endif
+#endif
 	struct pci_device *const device = intel->PciInfo;
 	int fb_bar = IS_GEN2(intel) ? 0 : 2;
 
@@ -985,32 +1022,6 @@ I830ScreenInit(SCREEN_INIT_ARGS_DECL)
 	if (!miSetPixmapDepths())
 		return FALSE;
 
-	/* Must be first, before anything else installs screen callbacks. */
-	if (!fbScreenInit(screen, NULL,
-			  scrn->virtualX, scrn->virtualY,
-			  scrn->xDpi, scrn->yDpi,
-			  scrn->displayWidth, scrn->bitsPerPixel))
-		return FALSE;
-
-	if (scrn->bitsPerPixel > 8) {
-		/* Fixup RGB ordering */
-		visual = screen->visuals + screen->numVisuals;
-		while (--visual >= screen->visuals) {
-			if ((visual->class | DynamicClass) == DirectColor) {
-				visual->offsetRed = scrn->offset.red;
-				visual->offsetGreen = scrn->offset.green;
-				visual->offsetBlue = scrn->offset.blue;
-				visual->redMask = scrn->mask.red;
-				visual->greenMask = scrn->mask.green;
-				visual->blueMask = scrn->mask.blue;
-			}
-		}
-	}
-
-	fbPictureInit(screen, NULL, 0);
-
-	xf86SetBlackWhitePixels(screen);
-
         switch (intel->accel) {
 #if USE_GLAMOR
         case ACCEL_GLAMOR:
@@ -1028,11 +1039,26 @@ I830ScreenInit(SCREEN_INIT_ARGS_DECL)
                                    "Hardware acceleration initialization failed\n");
                         return FALSE;
                 }
+                break;
+#endif
+        case ACCEL_NONE:
+                if (!intel_none_init(screen)) {
+                        xf86DrvMsg(scrn->scrnIndex, X_ERROR,
+                                   "Screen initialization failed\n");
+                        return FALSE;
+                }
+        }
+
+        switch (intel->accel) {
+#if USE_UXA
+        case ACCEL_UXA:
 #if HAVE_DRI2
                 if (intel->dri2 == DRI_NONE && I830DRI2ScreenInit(screen))
                         intel->dri2 = DRI_ACTIVE;
 #endif
-
+                /* fall through ... */
+#endif /* USE_UXA */
+        case ACCEL_NONE:
 #if HAVE_DRI3
                 if (!intel_sync_init(screen))
                         intel->dri3 = DRI_DISABLED;
@@ -1040,9 +1066,27 @@ I830ScreenInit(SCREEN_INIT_ARGS_DECL)
                         intel->dri3 = DRI_ACTIVE;
 #endif
                 break;
-#endif
+        default:
+                break;
         }
 
+	if (scrn->bitsPerPixel > 8) {
+		/* Fixup RGB ordering */
+		visual = screen->visuals + screen->numVisuals;
+		while (--visual >= screen->visuals) {
+			if ((visual->class | DynamicClass) == DirectColor) {
+				visual->offsetRed = scrn->offset.red;
+				visual->offsetGreen = scrn->offset.green;
+				visual->offsetBlue = scrn->offset.blue;
+				visual->redMask = scrn->mask.red;
+				visual->greenMask = scrn->mask.green;
+				visual->blueMask = scrn->mask.blue;
+			}
+		}
+	}
+
+	xf86SetBlackWhitePixels(screen);
+
 	if (xf86ReturnOptValBool(intel->Options, OPTION_PRESENT, TRUE))
 		intel_present_screen_init(screen);
 
@@ -1095,58 +1139,66 @@ I830ScreenInit(SCREEN_INIT_ARGS_DECL)
 
 	xf86DPMSInit(screen, xf86DPMSSet, 0);
 
+        switch (intel->accel) {
+#if USE_UXA
+        case ACCEL_UXA:
 #ifdef INTEL_XVMC
-	if (INTEL_INFO(intel)->gen >= 040)
-		intel->XvMCEnabled = TRUE;
-	from = (intel->dri2 == DRI_ACTIVE &&
-		xf86GetOptValBool(intel->Options, OPTION_XVMC,
-				  &intel->XvMCEnabled) ? X_CONFIG : X_DEFAULT);
-	xf86DrvMsg(scrn->scrnIndex, from, "Intel XvMC decoder %sabled\n",
-		   intel->XvMCEnabled ? "en" : "dis");
+                if (INTEL_INFO(intel)->gen >= 040)
+                        intel->XvMCEnabled = TRUE;
+                from = (intel->dri2 == DRI_ACTIVE &&
+                        xf86GetOptValBool(intel->Options, OPTION_XVMC,
+                                          &intel->XvMCEnabled) ? X_CONFIG : X_DEFAULT);
+                xf86DrvMsg(scrn->scrnIndex, from, "Intel XvMC decoder %sabled\n",
+                           intel->XvMCEnabled ? "en" : "dis");
 #endif
-	/* Init video */
-	if (intel->XvEnabled)
-		intel_video_init(screen);
-
 #if HAVE_DRI2
-	switch (intel->dri2) {
-	case DRI_ACTIVE:
-		xf86DrvMsg(scrn->scrnIndex, X_INFO,
-			   "DRI2: Enabled\n");
-		break;
-	case DRI_DISABLED:
-		xf86DrvMsg(scrn->scrnIndex, X_INFO,
-			   "DRI2: Disabled\n");
-		break;
-	case DRI_NONE:
-		xf86DrvMsg(scrn->scrnIndex, X_INFO,
-			   "DRI2: Failed\n");
-		break;
-	}
+                switch (intel->dri2) {
+                case DRI_ACTIVE:
+                        xf86DrvMsg(scrn->scrnIndex, X_INFO,
+                                   "DRI2: Enabled\n");
+                        break;
+                case DRI_DISABLED:
+                        xf86DrvMsg(scrn->scrnIndex, X_INFO,
+                                   "DRI2: Disabled\n");
+                        break;
+                case DRI_NONE:
+                        xf86DrvMsg(scrn->scrnIndex, X_INFO,
+                                   "DRI2: Failed\n");
+                        break;
+                }
 #else
-	xf86DrvMsg(scrn->scrnIndex, X_INFO,
-		   "DRI2: Not available\n");
+                xf86DrvMsg(scrn->scrnIndex, X_INFO,
+                           "DRI2: Not available\n");
 #endif
 
 #if HAVE_DRI3
-	switch (intel->dri3) {
-	case DRI_ACTIVE:
-		xf86DrvMsg(scrn->scrnIndex, X_INFO,
-			   "DRI3: Enabled\n");
-		break;
-	case DRI_DISABLED:
-		xf86DrvMsg(scrn->scrnIndex, X_INFO,
-			   "DRI3: Disabled\n");
-		break;
-	case DRI_NONE:
-		xf86DrvMsg(scrn->scrnIndex, X_INFO,
-			   "DRI3: Failed\n");
-		break;
-	}
+                switch (intel->dri3) {
+                case DRI_ACTIVE:
+                        xf86DrvMsg(scrn->scrnIndex, X_INFO,
+                                   "DRI3: Enabled\n");
+                        break;
+                case DRI_DISABLED:
+                        xf86DrvMsg(scrn->scrnIndex, X_INFO,
+                                   "DRI3: Disabled\n");
+                        break;
+                case DRI_NONE:
+                        xf86DrvMsg(scrn->scrnIndex, X_INFO,
+                                   "DRI3: Failed\n");
+                        break;
+                }
 #else
-	xf86DrvMsg(scrn->scrnIndex, X_INFO,
-		   "DRI3: Not available\n");
+                xf86DrvMsg(scrn->scrnIndex, X_INFO,
+                           "DRI3: Not available\n");
 #endif
+                break;
+#endif
+        default:
+                break;
+        }
+
+	/* Init video */
+	if (intel->XvEnabled)
+		intel_video_init(screen);
 
 	if (serverGeneration == 1)
 		xf86ShowUnusedOptions(scrn->scrnIndex, scrn->options);
@@ -1247,16 +1299,9 @@ static Bool I830CloseScreen(CLOSE_SCREEN_ARGS_DECL)
 #endif
 #if USE_UXA
         case ACCEL_UXA:
-
-                TimerFree(intel->cache_expire);
-                intel->cache_expire = NULL;
-
-                intel_batch_teardown(scrn);
-
-                if (INTEL_INFO(intel)->gen >= 040 && INTEL_INFO(intel)->gen < 0100)
-                        gen4_render_state_cleanup(scrn);
-
                 if (intel->uxa_driver) {
+                        TimerFree(intel->cache_expire);
+                        intel->cache_expire = NULL;
                         uxa_driver_fini(screen);
                         free(intel->uxa_driver);
                         intel->uxa_driver = NULL;
@@ -1287,9 +1332,28 @@ static Bool I830CloseScreen(CLOSE_SCREEN_ARGS_DECL)
 		I830LeaveVT(VT_FUNC_ARGS(0));
 	}
 
+        switch (intel->accel) {
+#if USE_UXA
+        case ACCEL_UXA:
+                intel_batch_teardown(scrn);
+
+                if (INTEL_INFO(intel)->gen >= 040 && INTEL_INFO(intel)->gen < 0100)
+                        gen4_render_state_cleanup(scrn);
+
+                i965_free_video(scrn);
+                /* fall through ... */
+#endif
+        case ACCEL_NONE:
+#if HAVE_DRI3
+                intel_sync_close(screen);
+#endif
+                break;
+        default:
+                break;
+        }
+
 	xf86_cursors_fini(screen);
 
-	i965_free_video(scrn);
 
 	screen->CloseScreen = intel->CloseScreen;
 	(*screen->CloseScreen) (CLOSE_SCREEN_ARGS);
@@ -1310,7 +1374,6 @@ static Bool I830CloseScreen(CLOSE_SCREEN_ARGS_DECL)
                 }
                 intel_sync_close(screen);
 #endif
-
                 break;
 #endif
         default:
diff --git a/src/uxa/intel_glamor.c b/src/uxa/intel_glamor.c
index e2bc24c..cc98eb4 100644
--- a/src/uxa/intel_glamor.c
+++ b/src/uxa/intel_glamor.c
@@ -36,6 +36,7 @@
 #define GLAMOR_FOR_XORG  1
 #include <glamor.h>
 #include <unistd.h>
+#include <mipict.h>
 
 #include "intel.h"
 #include "i915_drm.h"
@@ -210,6 +211,15 @@ intel_glamor_init(ScreenPtr screen)
 {
 	ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
 
+	/* Must be first, before anything else installs screen callbacks. */
+	if (!fbScreenInit(screen, NULL,
+			  scrn->virtualX, scrn->virtualY,
+			  scrn->xDpi, scrn->yDpi,
+			  scrn->displayWidth, scrn->bitsPerPixel))
+		return FALSE;
+
+	fbPictureInit(screen, NULL, 0);
+
 	if (!dixPrivateKeyRegistered(&intel_glamor_pixmap_key))
                 if (!dixRegisterPrivateKey(&intel_glamor_pixmap_key, PRIVATE_PIXMAP, sizeof (struct intel_glamor_pixmap)))
                         return FALSE;
diff --git a/src/uxa/intel_none.c b/src/uxa/intel_none.c
new file mode 100644
index 0000000..470ea07
--- /dev/null
+++ b/src/uxa/intel_none.c
@@ -0,0 +1,189 @@
+/*
+ * Copyright © 2014 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * that the name of the copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission.  The copyright holders make no representations
+ * about the suitability of this software for any purpose.  It is provided "as
+ * is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <assert.h>
+#include <string.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+
+#include "xorg-server.h"
+#include "xf86.h"
+#include "xf86_OSproc.h"
+#include "xf86cmap.h"
+#include "xf86drm.h"
+#include "compiler.h"
+#include "mipointer.h"
+#include "micmap.h"
+#include <X11/extensions/randr.h>
+#include "fb.h"
+#include "miscstruct.h"
+#include "dixstruct.h"
+#include "xf86xv.h"
+#include "shadow.h"
+#include "intel.h"
+#include "intel_video.h"
+#include "intel_none.h"
+#include "intel_bufmgr.h"
+
+struct intel_none_screen {
+        DestroyPixmapProcPtr    DestroyPixmap;
+};
+
+static DevPrivateKeyRec intel_none_screen_key;
+
+static inline struct intel_none_screen *intel_none_get_screen(ScreenPtr screen)
+{
+        return dixGetPrivateAddr(&screen->devPrivates, &intel_none_screen_key);
+}
+
+struct intel_none_pixmap {
+        drm_intel_bo  *bo;
+};
+
+static DevPrivateKeyRec intel_none_pixmap_key;
+
+static inline struct intel_none_pixmap *intel_none_get_pixmap(PixmapPtr pixmap)
+{
+        return dixGetPrivateAddr(&pixmap->devPrivates, &intel_none_pixmap_key);
+}
+
+dri_bo *
+intel_none_get_pixmap_bo(PixmapPtr pixmap)
+{
+        return (dri_bo *) intel_none_get_pixmap(pixmap)->bo;
+}
+
+Bool
+intel_none_set_pixmap_bo(PixmapPtr pixmap, dri_bo *d_bo)
+{
+        struct intel_none_pixmap        *none_pixmap = intel_none_get_pixmap(pixmap);
+        drm_intel_bo                    *bo = (drm_intel_bo *) d_bo;
+
+        if (bo) {
+                if (drm_intel_gem_bo_map_gtt(bo) != 0)
+                        return FALSE;
+        }
+
+        if (none_pixmap->bo) {
+                drm_intel_bo_unreference(none_pixmap->bo);
+                none_pixmap->bo = NULL;
+                pixmap->devPrivate.ptr = NULL;
+        }
+
+        if (bo) {
+                pixmap->devPrivate.ptr = bo->virtual;
+                dri_bo_reference(d_bo);
+                none_pixmap->bo = bo;
+        }
+        return TRUE;
+}
+
+static Bool
+intel_none_destroy_pixmap(PixmapPtr pixmap)
+{
+        ScreenPtr                       screen = pixmap->drawable.pScreen;
+	struct intel_none_screen        *none_screen = intel_none_get_screen(screen);
+        struct intel_none_pixmap        *none_pixmap = intel_none_get_pixmap(pixmap);
+        Bool                            ret;
+
+        screen->DestroyPixmap = none_screen->DestroyPixmap;
+        if (pixmap->refcnt <= 1) {
+                if (none_pixmap->bo) {
+                        drm_intel_bo_unreference(none_pixmap->bo);
+                        none_pixmap->bo = NULL;
+                }
+        }
+
+        ret = screen->DestroyPixmap(pixmap);
+
+        none_screen->DestroyPixmap = screen->DestroyPixmap;
+        screen->DestroyPixmap = intel_none_destroy_pixmap;
+        return ret;
+}
+
+Bool
+intel_none_init(ScreenPtr screen)
+{
+	ScrnInfoPtr                     scrn = xf86ScreenToScrn(screen);
+	intel_screen_private            *intel = intel_get_screen_private(scrn);
+        struct intel_none_screen        *none_screen;
+	dri_bo                          *bo = intel->front_buffer;
+        int                             ret;
+
+	ret = drm_intel_gem_bo_map_gtt(bo);
+        if (ret)
+                return FALSE;
+
+        if (!fbScreenInit(screen, bo->virtual,
+                          scrn->virtualX, scrn->virtualY,
+                          scrn->xDpi, scrn->yDpi,
+                          scrn->displayWidth, scrn->bitsPerPixel))
+                return FALSE;
+
+	fbPictureInit(screen, NULL, 0);
+
+        if (!dixRegisterPrivateKey(&intel_none_screen_key, PRIVATE_SCREEN, sizeof (struct intel_none_screen)))
+                return FALSE;
+
+        if (!dixRegisterPrivateKey(&intel_none_pixmap_key, PRIVATE_PIXMAP, sizeof (struct intel_none_pixmap)))
+                return FALSE;
+
+        none_screen = intel_none_get_screen(screen);
+
+        none_screen->DestroyPixmap = screen->DestroyPixmap;
+        screen->DestroyPixmap = intel_none_destroy_pixmap;
+
+        return TRUE;
+}
+
+Bool
+intel_none_create_screen_resources(ScreenPtr screen)
+{
+	ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
+	PixmapPtr pixmap;
+	intel_screen_private *intel = intel_get_screen_private(scrn);
+	dri_bo *bo = intel->front_buffer;
+
+	pixmap = screen->GetScreenPixmap(screen);
+
+        if (!intel_none_set_pixmap_bo(pixmap, bo))
+                return FALSE;
+
+	if (!screen->ModifyPixmapHeader(pixmap,
+					scrn->virtualX,
+					scrn->virtualY,
+					-1, -1,
+					intel->front_pitch,
+					NULL))
+		return FALSE;
+
+	scrn->displayWidth = intel->front_pitch / intel->cpp;
+
+	return TRUE;
+}
diff --git a/src/uxa/intel_none.h b/src/uxa/intel_none.h
new file mode 100644
index 0000000..1c20b02
--- /dev/null
+++ b/src/uxa/intel_none.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright © 2014 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * that the name of the copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission.  The copyright holders make no representations
+ * about the suitability of this software for any purpose.  It is provided "as
+ * is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#ifndef _INTEL_NONE_H_
+#define _INTEL_NONE_H_
+
+Bool
+intel_none_init(ScreenPtr screen);
+
+Bool
+intel_none_create_screen_resources(ScreenPtr screen);
+
+dri_bo *
+intel_none_get_pixmap_bo(PixmapPtr pixmap);
+
+Bool
+intel_none_set_pixmap_bo(PixmapPtr pixmap, dri_bo *dri_bo);
+
+#endif /* _INTEL_NONE_H_ */
diff --git a/src/uxa/intel_uxa.c b/src/uxa/intel_uxa.c
index e9d905b..358960e 100644
--- a/src/uxa/intel_uxa.c
+++ b/src/uxa/intel_uxa.c
@@ -1272,6 +1272,15 @@ Bool intel_uxa_init(ScreenPtr screen)
 	ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
 	intel_screen_private *intel = intel_get_screen_private(scrn);
 
+	/* Must be first, before anything else installs screen callbacks. */
+	if (!fbScreenInit(screen, NULL,
+			  scrn->virtualX, scrn->virtualY,
+			  scrn->xDpi, scrn->yDpi,
+			  scrn->displayWidth, scrn->bitsPerPixel))
+		return FALSE;
+
+	fbPictureInit(screen, NULL, 0);
+
 	intel_batch_init(scrn);
 
 	if (INTEL_INFO(intel)->gen >= 040 && INTEL_INFO(intel)->gen < 0100)
-- 
2.0.1

_______________________________________________
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH 12/12] Delay initial modeset until root window contents are prepared
       [not found] ` <1406243908-1123-1-git-send-email-keithp-aN4HjG94KOLQT0dZR+AlfA@public.gmane.org>
                     ` (4 preceding siblings ...)
  2014-07-24 23:18   ` [PATCH 11/12] Add "none" acceleration option Keith Packard
@ 2014-07-24 23:18   ` Keith Packard
  2014-07-31  2:29   ` [PATCH 00/12] Rework intel 2D driver glamor support Eric Anholt
  6 siblings, 0 replies; 35+ messages in thread
From: Keith Packard @ 2014-07-24 23:18 UTC (permalink / raw)
  To: xorg-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	intel-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

Wait until the root window has been painted for the first time before
doing the modeset. This avoids flashing black while the root window
gets set up.

Signed-off-by: Keith Packard <keithp-aN4HjG94KOLQT0dZR+AlfA@public.gmane.org>
---
 src/uxa/intel.h         |  2 ++
 src/uxa/intel_display.c | 39 ++++++++++++++++++---------------------
 src/uxa/intel_driver.c  | 40 +++++++++++++++++++++++++++++++++++-----
 3 files changed, 55 insertions(+), 26 deletions(-)

diff --git a/src/uxa/intel.h b/src/uxa/intel.h
index ae33938..fa2aa64 100644
--- a/src/uxa/intel.h
+++ b/src/uxa/intel.h
@@ -194,6 +194,8 @@ typedef struct intel_screen_private {
 	void (*batch_flush) (struct intel_screen_private *intel);
 	void (*batch_commit_notify) (struct intel_screen_private *intel);
 
+        Bool need_entervt;
+
 #if USE_UXA
 	struct _UxaDriver *uxa_driver;
 	int uxa_flags;
diff --git a/src/uxa/intel_display.c b/src/uxa/intel_display.c
index 1d4ba3c..758f01f 100644
--- a/src/uxa/intel_display.c
+++ b/src/uxa/intel_display.c
@@ -2319,7 +2319,7 @@ void intel_copy_fb(ScrnInfoPtr scrn)
 	ScreenPtr pScreen = xf86ScrnToScreen(scrn);
 	intel_screen_private *intel = intel_get_screen_private(scrn);
 	PixmapPtr src, dst;
-	unsigned int pitch = scrn->displayWidth * intel->cpp;
+        GCPtr gc;
 	struct intel_crtc *intel_crtc;
 	int i, fbcon_id;
 
@@ -2339,30 +2339,27 @@ void intel_copy_fb(ScrnInfoPtr scrn)
 	if (src == NULL)
 		return;
 
-	/* We dont have a screen Pixmap yet */
-	dst = intel_create_pixmap_for_bo(pScreen, intel->front_buffer,
-					 scrn->virtualX, scrn->virtualY,
-					 scrn->depth, scrn->bitsPerPixel,
-					 pitch);
+        dst = (*pScreen->GetScreenPixmap)(pScreen);
+
 	if (dst == NullPixmap)
 		goto cleanup_src;
 
-	if (!intel->uxa_driver->prepare_copy(src, dst,
-					     -1, -1,
-					     GXcopy, FB_ALLONES))
-		goto cleanup_dst;
-
-	intel->uxa_driver->copy(dst,
-				0, 0,
-				0, 0,
-				scrn->virtualX, scrn->virtualY);
-	intel->uxa_driver->done_copy(dst);
-#if ABI_VIDEODRV_VERSION >= SET_ABI_VERSION(10, 0)
-	pScreen->canDoBGNoneRoot = TRUE;
-#endif
+        gc = GetScratchGC(scrn->depth, pScreen);
+
+        if (!gc)
+                goto cleanup_src;
+
+        ValidateGC(&dst->drawable, gc);
+
+        (*gc->ops->CopyArea)(&src->drawable,
+                             &dst->drawable,
+                             gc,
+                             0, 0,
+                             scrn->virtualX, scrn->virtualY,
+                             0, 0);
+
+        FreeScratchGC(gc);
 
-cleanup_dst:
-	(*pScreen->DestroyPixmap)(dst);
 cleanup_src:
 	(*pScreen->DestroyPixmap)(src);
 }
diff --git a/src/uxa/intel_driver.c b/src/uxa/intel_driver.c
index 316de64..0475a17 100644
--- a/src/uxa/intel_driver.c
+++ b/src/uxa/intel_driver.c
@@ -170,13 +170,19 @@ static Bool i830CreateScreenResources(ScreenPtr screen)
         case ACCEL_GLAMOR:
                 if (!intel_glamor_create_screen_resources(screen))
                         return FALSE;
+#if ABI_VIDEODRV_VERSION >= SET_ABI_VERSION(10, 0)
+                screen->canDoBGNoneRoot = TRUE;
+#endif
                 break;
 #endif
 #if USE_UXA
         case ACCEL_UXA:
                 if (!intel_uxa_create_screen_resources(screen))
                         return FALSE;
-                intel_copy_fb(scrn);
+#if ABI_VIDEODRV_VERSION >= SET_ABI_VERSION(10, 0)
+                screen->canDoBGNoneRoot = TRUE;
+#endif
+                break;
 #endif
         case ACCEL_NONE:
                 if (!intel_none_create_screen_resources(screen))
@@ -830,6 +836,29 @@ I830BlockHandler(BLOCKHANDLER_ARGS_DECL)
 
 	screen->BlockHandler = intel->BlockHandler;
 
+        /* At server init time, get the root window bits from fbcon if
+         * available and then update the protocol-level information
+         * for both RandR and XINERAMA
+         */
+        if (intel->need_entervt) {
+                intel->need_entervt = FALSE;
+
+                if (screen->root->backgroundState == None)
+                        intel_copy_fb(scrn);
+
+                /* Must force it before EnterVT, so we are in control of VT and
+                 * later memory should be bound when allocating, e.g rotate_mem */
+                scrn->vtSema = TRUE;
+
+                if (!I830EnterVT(VT_FUNC_ARGS(0))) {
+                        xf86DrvMsg(scrn->scrnIndex, X_ERROR,
+                                   "Failed to perform initial modeset.\n");
+                        FatalError("Mode set failed\n");
+                }
+
+                xf86RandR12CreateScreenResources(screen);
+        }
+
 	(*screen->BlockHandler) (BLOCKHANDLER_ARGS);
 
 	intel->BlockHandler = screen->BlockHandler;
@@ -1211,11 +1240,12 @@ I830ScreenInit(SCREEN_INIT_ARGS_DECL)
 	I830UeventInit(scrn);
 #endif
 
-	/* Must force it before EnterVT, so we are in control of VT and
-	 * later memory should be bound when allocating, e.g rotate_mem */
-	scrn->vtSema = TRUE;
+        /* Delay the call to I830EnterVT until
+         * the server is all ready to accept protocol requests.
+         */
+        intel->need_entervt = TRUE;
 
-	return I830EnterVT(VT_FUNC_ARGS(0));
+        return TRUE;
 }
 
 static void i830AdjustFrame(ADJUST_FRAME_ARGS_DECL)
-- 
2.0.1

_______________________________________________
xorg-devel-go0+a7rfsptAfugRpC6u6w@public.gmane.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* Re: [PATCH 01/12] Stop trying to out-guess mesa for BO allocation
       [not found]   ` <1406243908-1123-2-git-send-email-keithp-aN4HjG94KOLQT0dZR+AlfA@public.gmane.org>
@ 2014-07-31  1:28     ` Eric Anholt
  2014-07-31  5:45       ` Keith Packard
  0 siblings, 1 reply; 35+ messages in thread
From: Eric Anholt @ 2014-07-31  1:28 UTC (permalink / raw)
  To: Keith Packard, xorg-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	intel-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW


[-- Attachment #1.1: Type: text/plain, Size: 893 bytes --]

Keith Packard <keithp-aN4HjG94KOLQT0dZR+AlfA@public.gmane.org> writes:

I don't see anything indicating that this code path is only used by
glamor.

> ---
>  src/uxa/intel_uxa.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/src/uxa/intel_uxa.c b/src/uxa/intel_uxa.c
> index b396188..717754f 100644
> --- a/src/uxa/intel_uxa.c
> +++ b/src/uxa/intel_uxa.c
> @@ -758,6 +758,7 @@ free_priv:
>  			goto free_priv;
>  		}
>  
> +#if 0
>  		if (tiling != I915_TILING_NONE) {
>  			int height;
>  
> @@ -780,6 +781,7 @@ free_priv:
>  			bo = NULL;
>  			goto free_priv;
>  		}
> +#endif
>  	}
>  
>    BAIL:
> -- 
> 2.0.1
>
> _______________________________________________
> xorg-devel-go0+a7rfsptAfugRpC6u6w@public.gmane.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: http://lists.x.org/mailman/listinfo/xorg-devel

[-- Attachment #1.2: Type: application/pgp-signature, Size: 818 bytes --]

[-- Attachment #2: Type: text/plain, Size: 219 bytes --]

_______________________________________________
xorg-devel-go0+a7rfsptAfugRpC6u6w@public.gmane.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH 03/12] Don't use GetScratchPixmapHeader for shadow pixmaps
       [not found]   ` <1406243908-1123-4-git-send-email-keithp-aN4HjG94KOLQT0dZR+AlfA@public.gmane.org>
@ 2014-07-31  1:33     ` Eric Anholt
  2014-07-31  5:49       ` Keith Packard
  0 siblings, 1 reply; 35+ messages in thread
From: Eric Anholt @ 2014-07-31  1:33 UTC (permalink / raw)
  To: Keith Packard, xorg-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	intel-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW


[-- Attachment #1.1: Type: text/plain, Size: 3254 bytes --]

Keith Packard <keithp-aN4HjG94KOLQT0dZR+AlfA@public.gmane.org> writes:

> GetScratchPixmapHeader should only be used for local memory pixmaps,
> as used by PutImage and friends. That's because when you free the
> scratch pixmap header, it doesn't actually free the pixmap; instead,
> it gets stuffed in pScreen->pScratchPixmap and any private data stored
> on it will be left hanging around forever.
>
> In the case of glamor, that private data includes all of the GL
> state. Using that scratch pixmap later results in glamor getting
> mightily confused as the pixmap and underlying objects do not match.
>
> Avoid this by allocating pixmap headers explicitly for this purpose.
>
> Signed-off-by: Keith Packard <keithp-aN4HjG94KOLQT0dZR+AlfA@public.gmane.org>
> ---
>  src/uxa/intel_display.c | 44 ++++++++++++++++++++++++++++++--------------
>  1 file changed, 30 insertions(+), 14 deletions(-)
>
> diff --git a/src/uxa/intel_display.c b/src/uxa/intel_display.c
> index 0b83140..bcaafaa 100644
> --- a/src/uxa/intel_display.c
> +++ b/src/uxa/intel_display.c
> @@ -545,13 +545,31 @@ intel_crtc_shadow_allocate(xf86CrtcPtr crtc, int width, int height)
>  		return NULL;
>  	}
>  
> -	drm_intel_bo_disable_reuse(intel_crtc->rotate_bo);
> -
>  	intel_crtc->rotate_pitch = rotate_pitch;
>  	return intel_crtc->rotate_bo;
>  }

See comment below...

> @@ -602,8 +620,8 @@ intel_crtc_shadow_destroy(xf86CrtcPtr crtc, PixmapPtr rotate_pixmap, void *data)
>  	struct intel_mode *mode = intel_crtc->mode;
>  
>  	if (rotate_pixmap) {
> -		intel_set_pixmap_bo(rotate_pixmap, NULL);
> -		FreeScratchPixmapHeader(rotate_pixmap);
> +                intel_set_pixmap_bo(rotate_pixmap, NULL);
> +                rotate_pixmap->drawable.pScreen->DestroyPixmap(rotate_pixmap);
>  	}
>  
>  	if (data) {
> @@ -1415,7 +1433,6 @@ intel_xf86crtc_resize(ScrnInfoPtr scrn, int width, int height)
>  	int	    i, old_width, old_height, old_pitch;
>  	int pitch;
>  	uint32_t tiling;
> -	ScreenPtr screen;
>  
>  	if (scrn->virtualX == width && scrn->virtualY == height)
>  		return TRUE;
> @@ -1430,8 +1447,7 @@ intel_xf86crtc_resize(ScrnInfoPtr scrn, int width, int height)
>  	old_front = intel->front_buffer;
>  
>  	if (intel->back_pixmap) {
> -		screen = intel->back_pixmap->drawable.pScreen;
> -		screen->DestroyPixmap(intel->back_pixmap);
> +		scrn->pScreen->DestroyPixmap(intel->back_pixmap);
>  		intel->back_pixmap = NULL;
>  	}
>  

Grumble, unrelated noise in the patch.

> @@ -1454,7 +1470,6 @@ intel_xf86crtc_resize(ScrnInfoPtr scrn, int width, int height)
>  	if (ret)
>  		goto fail;
>  
> -	drm_intel_bo_disable_reuse(intel->front_buffer);
>  	intel->front_pitch = pitch;
>  	intel->front_tiling = tiling;
>  

This change appears to be unrelated, and possibly harmful (if X has
dropped the last ref to the BO, but it's still the scanout buffer, a new
allocation would now reuse the BO and scribble on scanout until the next
modeset happens).

> @@ -2204,6 +2219,7 @@ Bool intel_crtc_on(xf86CrtcPtr crtc)
>  	return ret;
>  }
>  
> +
>  static PixmapPtr
>  intel_create_pixmap_for_bo(ScreenPtr pScreen, dri_bo *bo,
>  			   int width, int height,

Unrelated whitespace.

[-- Attachment #1.2: Type: application/pgp-signature, Size: 818 bytes --]

[-- Attachment #2: Type: text/plain, Size: 219 bytes --]

_______________________________________________
xorg-devel-go0+a7rfsptAfugRpC6u6w@public.gmane.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH 06/12] Remove glamor support from UXA acceleration
       [not found]   ` <1406243908-1123-7-git-send-email-keithp-aN4HjG94KOLQT0dZR+AlfA@public.gmane.org>
@ 2014-07-31  1:42     ` Eric Anholt
  2014-07-31  5:52       ` Keith Packard
  0 siblings, 1 reply; 35+ messages in thread
From: Eric Anholt @ 2014-07-31  1:42 UTC (permalink / raw)
  To: Keith Packard, xorg-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	intel-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW


[-- Attachment #1.1: Type: text/plain, Size: 1779 bytes --]

Keith Packard <keithp-aN4HjG94KOLQT0dZR+AlfA@public.gmane.org> writes:

> Makes UXA no longer include calls to glamor acceleration functions.
>
> Signed-off-by: Keith Packard <keithp-aN4HjG94KOLQT0dZR+AlfA@public.gmane.org>
> ---
>  src/uxa/Makefile.am    |   9 --
>  src/uxa/intel_dri.c    |  60 +------------
>  src/uxa/intel_driver.c |   1 -
>  src/uxa/intel_uxa.c    |  49 -----------
>  src/uxa/intel_uxa.h    |   1 -
>  src/uxa/uxa-accel.c    | 230 -------------------------------------------------
>  src/uxa/uxa-glamor.h   |  65 --------------
>  src/uxa/uxa-glyphs.c   |  28 ------
>  src/uxa/uxa-render.c   |  79 -----------------
>  src/uxa/uxa.c          |   7 --
>  src/uxa/uxa.h          |  16 ----
>  11 files changed, 2 insertions(+), 543 deletions(-)
>  delete mode 100644 src/uxa/uxa-glamor.h
>
> diff --git a/src/uxa/Makefile.am b/src/uxa/Makefile.am
> index 23b074d..b9618c9 100644
> --- a/src/uxa/Makefile.am
> +++ b/src/uxa/Makefile.am
> @@ -34,7 +34,6 @@ libuxa_la_SOURCES = \
>  	intel_batchbuffer.h \
>  	intel_display.c \
>  	intel_driver.c \
> -	intel_glamor.h \
>  	intel_memory.c \
>  	intel_uxa.c \
>  	intel_video.c \
> @@ -65,14 +64,6 @@ libuxa_la_SOURCES = \
>  	uxa-unaccel.c
>  	$(NULL)
>  
> -if GLAMOR
> -AM_CFLAGS += $(LIBGLAMOR_CFLAGS)
> -libuxa_la_LIBADD += $(LIBGLAMOR_LIBS)
> -libuxa_la_SOURCES += \
> -	 intel_glamor.c \
> -	 $(NULL)
> -endif
> -

Something weird happened in this commit.

uxa-glamor.h is removed from the repo, but the makefile only drops
intel_glamor.h, which keeps getting used.  I suspect make distcheck is
broken.

intel_glamor.c is no longer built, but USE_GLAMOR might still be defined
I think, and if so intel_glamor_flush() from it is still getting called.

[-- Attachment #1.2: Type: application/pgp-signature, Size: 818 bytes --]

[-- Attachment #2: Type: text/plain, Size: 219 bytes --]

_______________________________________________
xorg-devel-go0+a7rfsptAfugRpC6u6w@public.gmane.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH 07/12] Add intel_flush to abstract flushing pending acceleration operations
       [not found]     ` <1406243908-1123-8-git-send-email-keithp-aN4HjG94KOLQT0dZR+AlfA@public.gmane.org>
@ 2014-07-31  1:44       ` Eric Anholt
  0 siblings, 0 replies; 35+ messages in thread
From: Eric Anholt @ 2014-07-31  1:44 UTC (permalink / raw)
  To: Keith Packard, xorg-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	intel-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW


[-- Attachment #1.1: Type: text/plain, Size: 524 bytes --]

Keith Packard <keithp-aN4HjG94KOLQT0dZR+AlfA@public.gmane.org> writes:

> intel_flush flushes any pending acceleration operations to the
> hardware, just like intel_uxa_batch_submit does today except that it is
> not uxa-specific.

This seems like an obvious cleanup (and in one case a fix), and we ought
to even apply it right away as long as it still calls
intel_glamor_flush().  If it did, it gets:

Reviewed-by: Eric Anholt <eric-WhKQ6XTQaPysTnJN9+BGXg@public.gmane.org>

even before we sort out the rest of the series.

[-- Attachment #1.2: Type: application/pgp-signature, Size: 818 bytes --]

[-- Attachment #2: Type: text/plain, Size: 219 bytes --]

_______________________________________________
xorg-devel-go0+a7rfsptAfugRpC6u6w@public.gmane.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH 08/12] Get rid of glamor stubs in intel_glamor.h
       [not found]     ` <1406243908-1123-9-git-send-email-keithp-aN4HjG94KOLQT0dZR+AlfA@public.gmane.org>
@ 2014-07-31  1:47       ` Eric Anholt
  2014-07-31  5:53         ` Keith Packard
  0 siblings, 1 reply; 35+ messages in thread
From: Eric Anholt @ 2014-07-31  1:47 UTC (permalink / raw)
  To: Keith Packard, xorg-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	intel-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW


[-- Attachment #1.1: Type: text/plain, Size: 356 bytes --]

Keith Packard <keithp-aN4HjG94KOLQT0dZR+AlfA@public.gmane.org> writes:

> This eliminates the stubs in intel_glamor.h and replaces them with
> ifdefs instead.

I don't feel strongly about this either way -- ifdefs are more
traditional userland style, while stubs are more kernel style.

Acked-by: Eric Anholt <eric-WhKQ6XTQaPysTnJN9+BGXg@public.gmane.org>

[-- Attachment #1.2: Type: application/pgp-signature, Size: 818 bytes --]

[-- Attachment #2: Type: text/plain, Size: 219 bytes --]

_______________________________________________
xorg-devel-go0+a7rfsptAfugRpC6u6w@public.gmane.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH 09/12] Do more checks for proposed flip pixmaps
       [not found]   ` <1406243908-1123-10-git-send-email-keithp-aN4HjG94KOLQT0dZR+AlfA@public.gmane.org>
@ 2014-07-31  1:54     ` Eric Anholt
  2014-07-31  6:01       ` Keith Packard
  0 siblings, 1 reply; 35+ messages in thread
From: Eric Anholt @ 2014-07-31  1:54 UTC (permalink / raw)
  To: Keith Packard, xorg-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	intel-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW


[-- Attachment #1.1: Type: text/plain, Size: 284 bytes --]

Keith Packard <keithp-aN4HjG94KOLQT0dZR+AlfA@public.gmane.org> writes:

> Make sure the pitch and tiling are correct.
> Make sure there's a BO we can get at.

I thought we couldn't change these parameters, but now I can't find what
prevents them from changing.  Can you cite sources?

[-- Attachment #1.2: Type: application/pgp-signature, Size: 818 bytes --]

[-- Attachment #2: Type: text/plain, Size: 219 bytes --]

_______________________________________________
xorg-devel-go0+a7rfsptAfugRpC6u6w@public.gmane.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH 10/12] Add glamor back into the driver
       [not found]     ` <1406243908-1123-11-git-send-email-keithp-aN4HjG94KOLQT0dZR+AlfA@public.gmane.org>
@ 2014-07-31  2:28       ` Eric Anholt
       [not found]         ` <8761iedzxh.fsf-omZaPlIz5HhaEpDpdNBo/KxOck334EZe@public.gmane.org>
  0 siblings, 1 reply; 35+ messages in thread
From: Eric Anholt @ 2014-07-31  2:28 UTC (permalink / raw)
  To: Keith Packard, xorg-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	intel-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW


[-- Attachment #1.1: Type: text/plain, Size: 3421 bytes --]

Keith Packard <keithp-aN4HjG94KOLQT0dZR+AlfA@public.gmane.org> writes:

> This adds glamor support back into the driver, but instad of going
> through UXA, this uses it directly instead.

This is hard to read with the conditionalizing all of the UXA code in
the same commit as adding the glamor code.  Then there are a bunch of
unrelated whitespace changes, or flattening of a bunch of nested
conditionals.

The only substantive problem I see is intel_glamor_set_pixmap_bo().

> +static void intel_check_accel_option(ScrnInfoPtr scrn)
> +{
> +	intel_screen_private *intel = intel_get_screen_private(scrn);
> +	enum { NONE, SNA, UXA, GLAMOR } accel_method = DEFAULT_ACCEL_METHOD;
> +	const char *s;
> +
> +	s = xf86GetOptValString(intel->Options, OPTION_ACCEL_METHOD);
> +	if (s != NULL) {
> +#if USE_GLAMOR
> +                if (strcasecmp(s, "glamor") == 0)
> +                        accel_method = GLAMOR;
> +                else
> +#endif
> +#if USE_UXA
> +                if (strcasecmp(s, "uxa") == 0)
> +                        accel_method = UXA;
> +                else
> +#endif
> +                        accel_method = DEFAULT_ACCEL_METHOD;
> +        }
> +        switch (accel_method) {
> +        default:
> +#if USE_GLAMOR
> +        case GLAMOR:
> +                intel->accel = ACCEL_GLAMOR;
> +                break;
> +#endif
> +#if USE_UXA
> +        case UXA:
> +                intel->accel = ACCEL_UXA;
> +                break;
> +#endif
> +        }

The extra enum and temporary variable introduced here seems pretty
pointless (even if that pattern had happened before).

> diff --git a/src/uxa/intel_glamor.c b/src/uxa/intel_glamor.c
> index 21636d1..e2bc24c 100644
> --- a/src/uxa/intel_glamor.c
> +++ b/src/uxa/intel_glamor.c

> +Bool
> +intel_glamor_set_pixmap_bo(PixmapPtr pixmap, drm_intel_bo *bo)
> +{
> +        if (bo == NULL || glamor_egl_create_textured_pixmap(pixmap,
> +                                                            bo->handle,
> +                                                            intel_pixmap_pitch(pixmap)))
> +        {
> +                intel_glamor_reference_pixmap_bo(pixmap, bo);
> +                return TRUE;
> +        }
> +        return FALSE;
> +}

I don't think this will work -- glamor_egl uses a different fd from
intel->bufmgr, so you're attaching some unrelated BO, if you're even
that lucky.

>  Bool
>  intel_glamor_init(ScreenPtr screen)
>  {
>  	ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
> -	intel_screen_private *intel = intel_get_screen_private(scrn);
>  
> -	if ((intel->uxa_flags & UXA_GLAMOR_EGL_INITIALIZED) == 0)
> -		goto fail;
> +	if (!dixPrivateKeyRegistered(&intel_glamor_pixmap_key))
> +                if (!dixRegisterPrivateKey(&intel_glamor_pixmap_key, PRIVATE_PIXMAP, sizeof (struct intel_glamor_pixmap)))
> +                        return FALSE;

No need to check for initiailization -- double-calling it is safe (as
long as the size is consistent).

>  void
> @@ -258,18 +240,52 @@ intel_glamor_flush(intel_screen_private * intel)
>  	ScreenPtr screen;
>  
>  	screen = xf86ScrnToScreen(intel->scrn);
> -	if (intel->uxa_flags & UXA_USE_GLAMOR)
> -		glamor_block_handler(screen);
> +        glamor_block_handler(screen);
>  }

glamor_block_handler() is pretty awfully named.  We should do something
about that.


[-- Attachment #1.2: Type: application/pgp-signature, Size: 818 bytes --]

[-- Attachment #2: Type: text/plain, Size: 219 bytes --]

_______________________________________________
xorg-devel-go0+a7rfsptAfugRpC6u6w@public.gmane.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH 00/12] Rework intel 2D driver glamor support
       [not found] ` <1406243908-1123-1-git-send-email-keithp-aN4HjG94KOLQT0dZR+AlfA@public.gmane.org>
                     ` (5 preceding siblings ...)
  2014-07-24 23:18   ` [PATCH 12/12] Delay initial modeset until root window contents are prepared Keith Packard
@ 2014-07-31  2:29   ` Eric Anholt
  2014-07-31  6:25     ` Keith Packard
  2014-07-31  6:56     ` Keith Packard
  6 siblings, 2 replies; 35+ messages in thread
From: Eric Anholt @ 2014-07-31  2:29 UTC (permalink / raw)
  To: Keith Packard, xorg-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	intel-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW


[-- Attachment #1.1: Type: text/plain, Size: 449 bytes --]

Keith Packard <keithp-aN4HjG94KOLQT0dZR+AlfA@public.gmane.org> writes:

> I spent the day just cleaning up this patch series and testing. I
> think it's ready for others to use and review. I've been running it on
> two machines for a couple of days now and it's been solid.

Patches 2, 4 are:

Reviewed-by: Eric Anholt <eric-WhKQ6XTQaPysTnJN9+BGXg@public.gmane.org>

Patch 5 is:

Acked-by: Eric Anholt <eric-WhKQ6XTQaPysTnJN9+BGXg@public.gmane.org>

[-- Attachment #1.2: Type: application/pgp-signature, Size: 818 bytes --]

[-- Attachment #2: Type: text/plain, Size: 219 bytes --]

_______________________________________________
xorg-devel-go0+a7rfsptAfugRpC6u6w@public.gmane.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH 01/12] Stop trying to out-guess mesa for BO allocation
  2014-07-31  1:28     ` Eric Anholt
@ 2014-07-31  5:45       ` Keith Packard
  2014-08-04 16:58         ` Eric Anholt
  0 siblings, 1 reply; 35+ messages in thread
From: Keith Packard @ 2014-07-31  5:45 UTC (permalink / raw)
  To: Eric Anholt, xorg-devel, intel-gfx


[-- Attachment #1.1: Type: text/plain, Size: 533 bytes --]

Eric Anholt <eric@anholt.net> writes:

> Keith Packard <keithp@keithp.com> writes:
>
> I don't see anything indicating that this code path is only used by
> glamor.

True. It's a fix for DRI3 for either UXA or "none". Mesa allocates a
single page for a 1x1 texture, but this code thinks that should take two
pages causing a texture-to-pixmap operation to fail.

In particular, gnome-shell fails without this patch.

It's useful independent of this series, which is why I stuck it first.

-- 
keith.packard@intel.com

[-- Attachment #1.2: Type: application/pgp-signature, Size: 810 bytes --]

[-- Attachment #2: Type: text/plain, Size: 159 bytes --]

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH 03/12] Don't use GetScratchPixmapHeader for shadow pixmaps
  2014-07-31  1:33     ` Eric Anholt
@ 2014-07-31  5:49       ` Keith Packard
  2014-08-04 16:58         ` Eric Anholt
  0 siblings, 1 reply; 35+ messages in thread
From: Keith Packard @ 2014-07-31  5:49 UTC (permalink / raw)
  To: Eric Anholt, xorg-devel, intel-gfx


[-- Attachment #1.1: Type: text/plain, Size: 703 bytes --]

Eric Anholt <eric@anholt.net> writes:

> This change appears to be unrelated, and possibly harmful (if X has
> dropped the last ref to the BO, but it's still the scanout buffer, a new
> allocation would now reuse the BO and scribble on scanout until the next
> modeset happens).

Yeah, it's unrelated. intel_allocate_framebuffer calls disable_reuse, so
there's no need to call it from these two other places. I'll split that
change out into a separate patch with separate comment.

> Unrelated whitespace.

There are a bunch of whitespace fixups; should I pull those into a
separate patch or just leave them scattered in the first patch to change
a file?

-- 
keith.packard@intel.com

[-- Attachment #1.2: Type: application/pgp-signature, Size: 810 bytes --]

[-- Attachment #2: Type: text/plain, Size: 159 bytes --]

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH 06/12] Remove glamor support from UXA acceleration
  2014-07-31  1:42     ` Eric Anholt
@ 2014-07-31  5:52       ` Keith Packard
  0 siblings, 0 replies; 35+ messages in thread
From: Keith Packard @ 2014-07-31  5:52 UTC (permalink / raw)
  To: Eric Anholt, xorg-devel, intel-gfx


[-- Attachment #1.1: Type: text/plain, Size: 911 bytes --]

Eric Anholt <eric@anholt.net> writes:

> Something weird happened in this commit.
>
> uxa-glamor.h is removed from the repo, but the makefile only drops
> intel_glamor.h, which keeps getting used.  I suspect make distcheck is
> broken.

Yeah, almost certainly. In fact, after this patch, the driver does *not*
build if you ask for glamor.

> intel_glamor.c is no longer built, but USE_GLAMOR might still be defined
> I think, and if so intel_glamor_flush() from it is still getting
> called.

Right, the driver explicitly doesn't build with --enable-glamor after
this patch. Cleaning it up so that it would build makes more of a mess
though, so I just didn't worry about it as I was re-adding glamor when
all of the USE_GLAMOR bits would be needed again.

I can make it work if you like, but this patch and the re-enable glamor
patch would both get larger.

-- 
keith.packard@intel.com

[-- Attachment #1.2: Type: application/pgp-signature, Size: 810 bytes --]

[-- Attachment #2: Type: text/plain, Size: 159 bytes --]

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH 08/12] Get rid of glamor stubs in intel_glamor.h
  2014-07-31  1:47       ` Eric Anholt
@ 2014-07-31  5:53         ` Keith Packard
  0 siblings, 0 replies; 35+ messages in thread
From: Keith Packard @ 2014-07-31  5:53 UTC (permalink / raw)
  To: Eric Anholt, xorg-devel, intel-gfx


[-- Attachment #1.1: Type: text/plain, Size: 485 bytes --]

Eric Anholt <eric@anholt.net> writes:

> Keith Packard <keithp@keithp.com> writes:
>
>> This eliminates the stubs in intel_glamor.h and replaces them with
>> ifdefs instead.
>
> I don't feel strongly about this either way -- ifdefs are more
> traditional userland style, while stubs are more kernel style.

Right, just trying to keep things all the same and #ifdef USE_GLAMOR
seemed more common.

> Acked-by: Eric Anholt <eric@anholt.net>

-- 
keith.packard@intel.com

[-- Attachment #1.2: Type: application/pgp-signature, Size: 810 bytes --]

[-- Attachment #2: Type: text/plain, Size: 159 bytes --]

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH 09/12] Do more checks for proposed flip pixmaps
  2014-07-31  1:54     ` Eric Anholt
@ 2014-07-31  6:01       ` Keith Packard
  2014-07-31 14:43         ` Ville Syrjälä
  0 siblings, 1 reply; 35+ messages in thread
From: Keith Packard @ 2014-07-31  6:01 UTC (permalink / raw)
  To: Eric Anholt, xorg-devel, intel-gfx


[-- Attachment #1.1: Type: text/plain, Size: 997 bytes --]

Eric Anholt <eric@anholt.net> writes:

> Keith Packard <keithp@keithp.com> writes:
>
>> Make sure the pitch and tiling are correct.
>> Make sure there's a BO we can get at.
>
> I thought we couldn't change these parameters, but now I can't find what
> prevents them from changing.  Can you cite sources?

Looks like we *can* change tiling format. That actually makes me kinda
happy as that explains why we were able to allocate a linear frame
buffer for the X front buffer (due to a bug) and page flip to DRI3
buffers which are always tiled.

However, we can't change the pitch. From the kernel driver:

	/*
	 * TILEOFF/LINOFF registers can't be changed via MI display flips.
	 * Note that pitch changes could also affect these register.
	 */
	if (INTEL_INFO(dev)->gen > 3 &&
	    (fb->offsets[0] != crtc->primary->fb->offsets[0] ||
	     fb->pitches[0] != crtc->primary->fb->pitches[0]))
		return -EINVAL;

I'll remove the tiling check.

-- 
keith.packard@intel.com

[-- Attachment #1.2: Type: application/pgp-signature, Size: 810 bytes --]

[-- Attachment #2: Type: text/plain, Size: 159 bytes --]

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH 10/12] Add glamor back into the driver
       [not found]         ` <8761iedzxh.fsf-omZaPlIz5HhaEpDpdNBo/KxOck334EZe@public.gmane.org>
@ 2014-07-31  6:23           ` Keith Packard
  0 siblings, 0 replies; 35+ messages in thread
From: Keith Packard @ 2014-07-31  6:23 UTC (permalink / raw)
  To: Eric Anholt, xorg-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	intel-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW


[-- Attachment #1.1: Type: text/plain, Size: 2845 bytes --]

Eric Anholt <eric-WhKQ6XTQaPysTnJN9+BGXg@public.gmane.org> writes:

> Keith Packard <keithp-aN4HjG94KOLQT0dZR+AlfA@public.gmane.org> writes:
>
>> This adds glamor support back into the driver, but instad of going
>> through UXA, this uses it directly instead.
>
> This is hard to read with the conditionalizing all of the UXA code in
> the same commit as adding the glamor code.  Then there are a bunch of
> unrelated whitespace changes, or flattening of a bunch of nested
> conditionals.

I'm not sure how to make the patch easier to review; I guess I could
make UXA conditional first? That would be 'crazy' in that the driver
would fail to ever work if you didn't ask for UXA, but might make the
patch easier to read?

> The only substantive problem I see is intel_glamor_set_pixmap_bo().

> The extra enum and temporary variable introduced here seems pretty
> pointless (even if that pattern had happened before).

Agreed. The problem is that 'DEFAULT_ACCEL_METHOD' is defined as
'GLAMOR', 'UXA' or 'NONE' by configure.ac. This seemed like the cleanest
solution in some ways. I also liked having the accel_type enum *not*
define acceleration types which weren't compiled into the driver; that
caught a few missing #ifdefs

> I don't think this will work -- glamor_egl uses a different fd from
> intel->bufmgr, so you're attaching some unrelated BO, if you're even
> that lucky.

This API uses the same FD as the intel bufmgr.

From intel_glamor.c:

        if (!glamor_egl_init(scrn, intel->drmSubFD)) {

From glamor_egl.c:

        Bool
        glamor_egl_init(ScrnInfoPtr scrn, int fd)
        ...

	    glamor_egl->fd = fd;
        ...                
	    glamor_egl->has_gem = glamor_egl_check_has_gem(fd);

        ...
        Bool
	glamor_egl_create_textured_pixmap(PixmapPtr pixmap, int handle, int stride)
	...
            if (glamor_egl->has_gem) {
                if (!glamor_get_flink_name(glamor_egl->fd, handle, &name)) {

So, you pass in a GEM handle for the intel driver bufmgr and glamor
does the flink to get a global name.

We should be using an FD passing mechanism here instead, to avoid
creating more global names...

> No need to check for initiailization -- double-calling it is safe (as
> long as the size is consistent).

Thanks. Will fix.

>>  void
>> @@ -258,18 +240,52 @@ intel_glamor_flush(intel_screen_private * intel)
>>  	ScreenPtr screen;
>>  
>>  	screen = xf86ScrnToScreen(intel->scrn);
>> -	if (intel->uxa_flags & UXA_USE_GLAMOR)
>> -		glamor_block_handler(screen);
>> +        glamor_block_handler(screen);
>>  }
>
> glamor_block_handler() is pretty awfully named.  We should do something
> about that.

Suggestions welcome :-)

Thanks for the careful review.

-- 
keith.packard-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org

[-- Attachment #1.2: Type: application/pgp-signature, Size: 810 bytes --]

[-- Attachment #2: Type: text/plain, Size: 219 bytes --]

_______________________________________________
xorg-devel-go0+a7rfsptAfugRpC6u6w@public.gmane.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH 00/12] Rework intel 2D driver glamor support
  2014-07-31  2:29   ` [PATCH 00/12] Rework intel 2D driver glamor support Eric Anholt
@ 2014-07-31  6:25     ` Keith Packard
  2014-07-31  6:56     ` Keith Packard
  1 sibling, 0 replies; 35+ messages in thread
From: Keith Packard @ 2014-07-31  6:25 UTC (permalink / raw)
  To: Eric Anholt, xorg-devel, intel-gfx


[-- Attachment #1.1: Type: text/plain, Size: 477 bytes --]

Eric Anholt <eric@anholt.net> writes:

> Keith Packard <keithp@keithp.com> writes:
>
>> I spent the day just cleaning up this patch series and testing. I
>> think it's ready for others to use and review. I've been running it on
>> two machines for a couple of days now and it's been solid.
>
> Patches 2, 4 are:
>
> Reviewed-by: Eric Anholt <eric@anholt.net>
>
> Patch 5 is:
>
> Acked-by: Eric Anholt <eric@anholt.net>

Thanks.

-- 
keith.packard@intel.com

[-- Attachment #1.2: Type: application/pgp-signature, Size: 810 bytes --]

[-- Attachment #2: Type: text/plain, Size: 159 bytes --]

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH 00/12] Rework intel 2D driver glamor support
  2014-07-31  2:29   ` [PATCH 00/12] Rework intel 2D driver glamor support Eric Anholt
  2014-07-31  6:25     ` Keith Packard
@ 2014-07-31  6:56     ` Keith Packard
  1 sibling, 0 replies; 35+ messages in thread
From: Keith Packard @ 2014-07-31  6:56 UTC (permalink / raw)
  To: Eric Anholt, xorg-devel, intel-gfx


[-- Attachment #1.1: Type: text/plain, Size: 1311 bytes --]

Eric Anholt <eric@anholt.net> writes:

> Keith Packard <keithp@keithp.com> writes:
>
>> I spent the day just cleaning up this patch series and testing. I
>> think it's ready for others to use and review. I've been running it on
>> two machines for a couple of days now and it's been solid.
>
> Patches 2, 4 are:
>
> Reviewed-by: Eric Anholt <eric@anholt.net>
>
> Patch 5 is:
>
> Acked-by: Eric Anholt <eric@anholt.net>

I've pushed a new version of the tree with your review marked and a few
changes:

 * Split the GetScratchPixmapHeader change into two pieces; the first
   just removes the redundant calls to drm_intel_bo_disable_reuse and
   the second contains the scratch pixmap changes and the other misc
   stuff. Yes, I could split the misc changes out into another cleanup
   patch if you want.

 * Removed the tiling check from intel_present when flipping. The kernel
   doesn't appear to ever require matching tiling.

 * Removed call to dixPrivateKeyRegistered in the 'Add glamor back' patch.

What I didn't do is clean up the 'remove glamor' patch so that it would
compile even with --enable-glamor. Fixing that seems like noise to me;
all of the changes needed to make it work would be immediately un-done
when adding glamor back.

-- 
keith.packard@intel.com

[-- Attachment #1.2: Type: application/pgp-signature, Size: 810 bytes --]

[-- Attachment #2: Type: text/plain, Size: 159 bytes --]

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH 09/12] Do more checks for proposed flip pixmaps
  2014-07-31  6:01       ` Keith Packard
@ 2014-07-31 14:43         ` Ville Syrjälä
  2014-07-31 15:20           ` Keith Packard
  0 siblings, 1 reply; 35+ messages in thread
From: Ville Syrjälä @ 2014-07-31 14:43 UTC (permalink / raw)
  To: Keith Packard; +Cc: xorg-devel, Eric Anholt, intel-gfx

On Wed, Jul 30, 2014 at 11:01:48PM -0700, Keith Packard wrote:
> Eric Anholt <eric@anholt.net> writes:
> 
> > Keith Packard <keithp@keithp.com> writes:
> >
> >> Make sure the pitch and tiling are correct.
> >> Make sure there's a BO we can get at.
> >
> > I thought we couldn't change these parameters, but now I can't find what
> > prevents them from changing.  Can you cite sources?
> 
> Looks like we *can* change tiling format. That actually makes me kinda
> happy as that explains why we were able to allocate a linear frame
> buffer for the X front buffer (due to a bug) and page flip to DRI3
> buffers which are always tiled.
> 
> However, we can't change the pitch. From the kernel driver:
> 
> 	/*
> 	 * TILEOFF/LINOFF registers can't be changed via MI display flips.
> 	 * Note that pitch changes could also affect these register.
> 	 */
> 	if (INTEL_INFO(dev)->gen > 3 &&
> 	    (fb->offsets[0] != crtc->primary->fb->offsets[0] ||
> 	     fb->pitches[0] != crtc->primary->fb->pitches[0]))
> 		return -EINVAL;
> 
> I'll remove the tiling check.

Now that we have mmio flips in the kernel we can start to relax that
restriction. That still needs a bit more work in the mmio flip code
but I believe some people working on just that.

We could even change the pixel format, except a check was added to
drm_mode_page_flip_ioctl() to prevent that, so I guess it was
deemed that the API isn't meant to allow that.

-- 
Ville Syrjälä
Intel OTC

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH 09/12] Do more checks for proposed flip pixmaps
  2014-07-31 14:43         ` Ville Syrjälä
@ 2014-07-31 15:20           ` Keith Packard
       [not found]             ` <86a97pd07f.fsf-6d7jPg3SX/+z9DMzp4kqnw@public.gmane.org>
  0 siblings, 1 reply; 35+ messages in thread
From: Keith Packard @ 2014-07-31 15:20 UTC (permalink / raw)
  To: Ville Syrjälä; +Cc: xorg-devel, Eric Anholt, intel-gfx


[-- Attachment #1.1: Type: text/plain, Size: 660 bytes --]

Ville Syrjälä <ville.syrjala@linux.intel.com> writes:

> Now that we have mmio flips in the kernel we can start to relax that
> restriction. That still needs a bit more work in the mmio flip code
> but I believe some people working on just that.

I couldn't find any tiling restrictions in the current (ring-based) flip
code; did I just miss them?

> We could even change the pixel format, except a check was added to
> drm_mode_page_flip_ioctl() to prevent that, so I guess it was
> deemed that the API isn't meant to allow that.

Yeah, not sure I care about this; 32bpp is pretty much the only format I
want.

-- 
keith.packard@intel.com

[-- Attachment #1.2: Type: application/pgp-signature, Size: 810 bytes --]

[-- Attachment #2: Type: text/plain, Size: 159 bytes --]

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [Intel-gfx] [PATCH 09/12] Do more checks for proposed flip pixmaps
       [not found]             ` <86a97pd07f.fsf-6d7jPg3SX/+z9DMzp4kqnw@public.gmane.org>
@ 2014-07-31 16:06               ` Ville Syrjälä
  0 siblings, 0 replies; 35+ messages in thread
From: Ville Syrjälä @ 2014-07-31 16:06 UTC (permalink / raw)
  To: Keith Packard
  Cc: xorg-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	intel-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

On Thu, Jul 31, 2014 at 08:20:20AM -0700, Keith Packard wrote:
> Ville Syrjälä <ville.syrjala-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> writes:
> 
> > Now that we have mmio flips in the kernel we can start to relax that
> > restriction. That still needs a bit more work in the mmio flip code
> > but I believe some people working on just that.
> 
> I couldn't find any tiling restrictions in the current (ring-based) flip
> code; did I just miss them?

No, changing tiling is supposed to work via cs flips. Except it
doesn't actually work on VLV for some reason. We now fall back to
mmio flip on VLV for that, so given a recent enough kernel it should
just work (tm) on all platforms.

I was referring to the relaxing the restrictions on stride changes.

> 
> > We could even change the pixel format, except a check was added to
> > drm_mode_page_flip_ioctl() to prevent that, so I guess it was
> > deemed that the API isn't meant to allow that.
> 
> Yeah, not sure I care about this; 32bpp is pretty much the only format I
> want.

You just need to be careful with the X vs. A because the kernel
considers those distinct pixel formats. I now regret adding that
distinciton to the pixel formats, but sadly I don't own a time
machine so I can't undo it.

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
xorg-devel-go0+a7rfsptAfugRpC6u6w@public.gmane.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH 01/12] Stop trying to out-guess mesa for BO allocation
  2014-07-31  5:45       ` Keith Packard
@ 2014-08-04 16:58         ` Eric Anholt
  2014-08-05  5:01           ` Keith Packard
  0 siblings, 1 reply; 35+ messages in thread
From: Eric Anholt @ 2014-08-04 16:58 UTC (permalink / raw)
  To: Keith Packard, xorg-devel, intel-gfx


[-- Attachment #1.1: Type: text/plain, Size: 587 bytes --]

Keith Packard <keithp@keithp.com> writes:

> Eric Anholt <eric@anholt.net> writes:
>
>> Keith Packard <keithp@keithp.com> writes:
>>
>> I don't see anything indicating that this code path is only used by
>> glamor.
>
> True. It's a fix for DRI3 for either UXA or "none". Mesa allocates a
> single page for a 1x1 texture, but this code thinks that should take two
> pages causing a texture-to-pixmap operation to fail.

OK, but isn't the problem with the code you're #if 0ing (which, really?
#if 0 in a patch being submitted for review?) that it's aligning to
2*height instead of height?

[-- Attachment #1.2: Type: application/pgp-signature, Size: 818 bytes --]

[-- Attachment #2: Type: text/plain, Size: 159 bytes --]

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH 03/12] Don't use GetScratchPixmapHeader for shadow pixmaps
  2014-07-31  5:49       ` Keith Packard
@ 2014-08-04 16:58         ` Eric Anholt
  0 siblings, 0 replies; 35+ messages in thread
From: Eric Anholt @ 2014-08-04 16:58 UTC (permalink / raw)
  To: Keith Packard, xorg-devel, intel-gfx


[-- Attachment #1.1: Type: text/plain, Size: 762 bytes --]

Keith Packard <keithp@keithp.com> writes:

> Eric Anholt <eric@anholt.net> writes:
>
>> This change appears to be unrelated, and possibly harmful (if X has
>> dropped the last ref to the BO, but it's still the scanout buffer, a new
>> allocation would now reuse the BO and scribble on scanout until the next
>> modeset happens).
>
> Yeah, it's unrelated. intel_allocate_framebuffer calls disable_reuse, so
> there's no need to call it from these two other places. I'll split that
> change out into a separate patch with separate comment.
>
>> Unrelated whitespace.
>
> There are a bunch of whitespace fixups; should I pull those into a
> separate patch or just leave them scattered in the first patch to change
> a file?

One patch at the front is fine with me.

[-- Attachment #1.2: Type: application/pgp-signature, Size: 818 bytes --]

[-- Attachment #2: Type: text/plain, Size: 159 bytes --]

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH 01/12] Stop trying to out-guess mesa for BO allocation
  2014-08-04 16:58         ` Eric Anholt
@ 2014-08-05  5:01           ` Keith Packard
  0 siblings, 0 replies; 35+ messages in thread
From: Keith Packard @ 2014-08-05  5:01 UTC (permalink / raw)
  To: Eric Anholt, xorg-devel, intel-gfx


[-- Attachment #1.1: Type: text/plain, Size: 2707 bytes --]

Eric Anholt <eric@anholt.net> writes:

> OK, but isn't the problem with the code you're #if 0ing (which, really?
> #if 0 in a patch being submitted for review?) that it's aligning to
> 2*height instead of height?

I went and did a bit of archaeology to figure out why it's using
2*height instead of just height. The initial change to pixmap
allocation, which was then copied to the BO validation logic, was here:

	commit 736b89504a32239a0c7dfb5961c1b8292dd744bd
	Author: Chris Wilson <chris@chris-wilson.co.uk>
	Date:   Sun Dec 30 10:32:18 2012 +0000
	
	    uxa: Align surface allocations to even tile rows
	    
	    Align surface sizes to an even number of tile rows to cater for sampler
	    prefetch. If we read beyond the last page we may catch the PTE in a
	    state of flux and trigger a GPU hang. Also detected by enabling invalid
	    PTE access checking.
	    
	    References: https://bugs.freedesktop.org/show_bug.cgi?id=56916
	    References: https://bugs.freedesktop.org/show_bug.cgi?id=55984
	    Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
	
	diff --git a/src/intel_uxa.c b/src/intel_uxa.c
	index f5ac0a6..2f14173 100644
	--- a/src/intel_uxa.c
	+++ b/src/intel_uxa.c
	@@ -209,7 +209,7 @@ intel_uxa_pixmap_compute_size(PixmapPtr pixmap,
	                        tile_height = 8;
	                else
	                        tile_height = 32;
	-               aligned_h = ALIGN(h, tile_height);
	+               aligned_h = ALIGN(h, 2*tile_height);
	 
	                *stride = intel_get_fence_pitch(intel,
	                                                ALIGN(pitch, 512),

Look at the referenced bugs, what I found was a long list of random GPU
hangs on ILK and SNB hardware that appear to have been caused by a
kernel change. Daniel and Chris created a number of scatter shot fixes
across the kernel, and this patch to the 2D driver. However, this patch
doesn't appear to have actually solved anything; Norbert Preining was
still crashing with this patch applied:

        https://bugs.freedesktop.org/show_bug.cgi?id=55984#c129

Furthermore, SNA has some similar code, but it applies it conditionally
for hardware which doesn't have 'relaxed fencing', which is only
hardware older than i965 when running on a older kernel that doesn't
recognize the HAS_RELAXED_FENCING parameter (the current kernel always
returns 'true').

So, as near as I can tell, this fix should never be necessary as the
reported bug wasn't fixed by it, and SNA does not apply this rule to any
hardware on which either bug was reproduced.

If this fix is actually useful, wouldn't we want it in Mesa as well?

-- 
keith.packard@intel.com

[-- Attachment #1.2: Type: application/pgp-signature, Size: 810 bytes --]

[-- Attachment #2: Type: text/plain, Size: 159 bytes --]

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 35+ messages in thread

end of thread, other threads:[~2014-08-05  5:01 UTC | newest]

Thread overview: 35+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-24 23:18 [PATCH 00/12] Rework intel 2D driver glamor support Keith Packard
2014-07-24 23:18 ` [PATCH 01/12] Stop trying to out-guess mesa for BO allocation Keith Packard
     [not found]   ` <1406243908-1123-2-git-send-email-keithp-aN4HjG94KOLQT0dZR+AlfA@public.gmane.org>
2014-07-31  1:28     ` Eric Anholt
2014-07-31  5:45       ` Keith Packard
2014-08-04 16:58         ` Eric Anholt
2014-08-05  5:01           ` Keith Packard
2014-07-24 23:18 ` [PATCH 03/12] Don't use GetScratchPixmapHeader for shadow pixmaps Keith Packard
     [not found]   ` <1406243908-1123-4-git-send-email-keithp-aN4HjG94KOLQT0dZR+AlfA@public.gmane.org>
2014-07-31  1:33     ` Eric Anholt
2014-07-31  5:49       ` Keith Packard
2014-08-04 16:58         ` Eric Anholt
2014-07-24 23:18 ` [PATCH 04/12] Move intel_alloc_framebuffer to intel_memory.c Keith Packard
2014-07-24 23:18 ` [PATCH 05/12] Rename uxa-specific functions and structs Keith Packard
2014-07-24 23:18 ` [PATCH 06/12] Remove glamor support from UXA acceleration Keith Packard
     [not found]   ` <1406243908-1123-7-git-send-email-keithp-aN4HjG94KOLQT0dZR+AlfA@public.gmane.org>
2014-07-31  1:42     ` Eric Anholt
2014-07-31  5:52       ` Keith Packard
2014-07-24 23:18 ` [PATCH 09/12] Do more checks for proposed flip pixmaps Keith Packard
     [not found]   ` <1406243908-1123-10-git-send-email-keithp-aN4HjG94KOLQT0dZR+AlfA@public.gmane.org>
2014-07-31  1:54     ` Eric Anholt
2014-07-31  6:01       ` Keith Packard
2014-07-31 14:43         ` Ville Syrjälä
2014-07-31 15:20           ` Keith Packard
     [not found]             ` <86a97pd07f.fsf-6d7jPg3SX/+z9DMzp4kqnw@public.gmane.org>
2014-07-31 16:06               ` [Intel-gfx] " Ville Syrjälä
     [not found] ` <1406243908-1123-1-git-send-email-keithp-aN4HjG94KOLQT0dZR+AlfA@public.gmane.org>
2014-07-24 23:18   ` [PATCH 02/12] Fix present debug output Keith Packard
2014-07-24 23:18   ` [PATCH 07/12] Add intel_flush to abstract flushing pending acceleration operations Keith Packard
     [not found]     ` <1406243908-1123-8-git-send-email-keithp-aN4HjG94KOLQT0dZR+AlfA@public.gmane.org>
2014-07-31  1:44       ` Eric Anholt
2014-07-24 23:18   ` [PATCH 08/12] Get rid of glamor stubs in intel_glamor.h Keith Packard
     [not found]     ` <1406243908-1123-9-git-send-email-keithp-aN4HjG94KOLQT0dZR+AlfA@public.gmane.org>
2014-07-31  1:47       ` Eric Anholt
2014-07-31  5:53         ` Keith Packard
2014-07-24 23:18   ` [PATCH 10/12] Add glamor back into the driver Keith Packard
     [not found]     ` <1406243908-1123-11-git-send-email-keithp-aN4HjG94KOLQT0dZR+AlfA@public.gmane.org>
2014-07-31  2:28       ` Eric Anholt
     [not found]         ` <8761iedzxh.fsf-omZaPlIz5HhaEpDpdNBo/KxOck334EZe@public.gmane.org>
2014-07-31  6:23           ` Keith Packard
2014-07-24 23:18   ` [PATCH 11/12] Add "none" acceleration option Keith Packard
2014-07-24 23:18   ` [PATCH 12/12] Delay initial modeset until root window contents are prepared Keith Packard
2014-07-31  2:29   ` [PATCH 00/12] Rework intel 2D driver glamor support Eric Anholt
2014-07-31  6:25     ` Keith Packard
2014-07-31  6:56     ` Keith Packard

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.