xf86-video-intel: 6 commits - configure.ac NEWS src/intel_device.c src/intel_driver.h src/intel_module.c src/intel_xmir.h src/legacy/Makefile.am src/Makefile.am src/sna/kgem.c src/sna/Makefile.am src/sna/sna_accel.c src/sna/sna_dri.c src/sna/sna_driver.c src/sna/sna.h src/sna/sna_xmir.c

Chris Wilson ickle at kemper.freedesktop.org
Wed Sep 4 08:18:10 PDT 2013


 NEWS                   |   21 +++
 configure.ac           |  309 ++++++++++++++++++++++++++-----------------------
 src/Makefile.am        |    1 
 src/intel_device.c     |   24 +++
 src/intel_driver.h     |    4 
 src/intel_module.c     |   21 +--
 src/intel_xmir.h       |   15 ++
 src/legacy/Makefile.am |    2 
 src/sna/Makefile.am    |    1 
 src/sna/kgem.c         |    4 
 src/sna/sna.h          |   37 ++++-
 src/sna/sna_accel.c    |   77 +++++++-----
 src/sna/sna_dri.c      |   14 ++
 src/sna/sna_driver.c   |   19 ++-
 src/sna/sna_xmir.c     |  179 ++++++++++++++++++++++++++++
 15 files changed, 531 insertions(+), 197 deletions(-)

New commits:
commit 94bc69d5b9a0380cdd9941183b3b1c8e9beb8da5
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Sep 4 13:49:56 2013 +0100

    2.99.901 snapshot

diff --git a/NEWS b/NEWS
index c23da5e..83a7c82 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,24 @@
+Snapshot 2.99.901 (2013-08-04)
+==============================
+What's this? A pre-release snapshot of an upcoming 3.0 major release?
+What could be the big new feature about to land? SNA by default!
+Not only that, we also have a preview of the XMir integration patches.
+
+Whilst we consider the SNA acceleration method to be ready to take over
+from UXA (the current acceleration method), it still remains possible to
+switch over to the old method with the following xorg.conf snippet:
+  Section "Device"
+    Identifier "Device0"
+    Driver "intel"
+    Option "AccelMethod" "UXA"
+  EndSection
+
+The promise of SNA is that it improves the user experience by providing a
+faster, more fluid, desktop, that is both more power efficient and less
+prone to crashes than UXA. If it still fails to meet your expections,
+please file bugs!
+
+
 Release 2.21.15 (2013-08-21)
 ============================
 Some build fixes for the BSDs and alternate compiler, and conflicting
diff --git a/configure.ac b/configure.ac
index 4e0c3cf..8500e43 100644
--- a/configure.ac
+++ b/configure.ac
@@ -23,7 +23,7 @@
 # Initialize Autoconf
 AC_PREREQ([2.60])
 AC_INIT([xf86-video-intel],
-        [2.21.15],
+        [2.99.901],
         [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
         [xf86-video-intel])
 AC_CONFIG_SRCDIR([Makefile.am])
commit 4dfd7674d88a267d0d89c31422f2e6c333ccf176
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Fri Feb 1 19:48:38 2013 +0000

    intel: Select SNA as the default acceleration method
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/configure.ac b/configure.ac
index 29c5c0b..4e0c3cf 100644
--- a/configure.ac
+++ b/configure.ac
@@ -328,7 +328,7 @@ AM_CONDITIONAL(XAA, test "x$XAA" = "xyes")
 
 AC_ARG_WITH(default-accel,
 	    AS_HELP_STRING([--with-default-accel],
-			   [Select the default acceleration method [default=uxa if enabled, otherwise sna]]),
+			   [Select the default acceleration method [default=sna if enabled, otherwise uxa]]),
 			   [accel="$withval"],
 			   [accel="auto"])
 if test "x$accel" = "xyes"; then
@@ -338,11 +338,11 @@ fi
 
 AC_MSG_CHECKING([which acceleration method to use by default])
 if test "x$accel" = "xauto"; then
-	if test "x$UXA" != "xno"; then
-		accel="uxa"
+	if test "x$SNA" != "xno"; then
+		accel="sna"
 	else
-		if test "x$SNA" != "xno"; then
-			accel="sna"
+		if test "x$UXA" != "xno"; then
+			accel="uxa"
 		fi
 	fi
 	if test "x$accel" = "xauto" -a "x$KMS" = "xyes"; then
commit 42d94356f65972eb7fb8991234a4e9388c4c2031
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Jul 24 01:44:30 2013 +0100

    sna: Add XMir support
    
    With lots of updates by Christopher James Halse Rogers as he updated the
    XMir API - but now supposedly frozen!
    
    "<RAOF> ickle: I think the xmir api should be pretty much stable now,
    barring people coming up with more awesome ways of doing things."
    
    Signed-off-by: Christopher James Halse Rogers <raof at ubuntu.com>
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/Makefile.am b/src/Makefile.am
index b0781ca..126bde2 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -59,6 +59,7 @@ intel_drv_la_SOURCES = \
 	intel_driver.h \
 	intel_options.c \
 	intel_module.c \
+	intel_xmir.h \
 	compat-api.h \
 	$(NULL)
 
diff --git a/src/intel_device.c b/src/intel_device.c
index b3926df..710348e 100644
--- a/src/intel_device.c
+++ b/src/intel_device.c
@@ -144,10 +144,34 @@ static int fd_set_nonblock(int fd)
 	return fd;
 }
 
+static int __intel_open_xmir(const struct pci_device *pci,
+			     char **path)
+{
+	char id[20];
+	int fd;
+
+	snprintf(id, sizeof(id),
+		 "pci:%04x:%02x:%02x.%d",
+		 pci->domain, pci->bus, pci->dev, pci->func);
+	fd = xmir_get_drm_fd(id);
+	if (fd == -1)
+		return -1;
+
+	if (*path == NULL) /* XXX Fix Xmir - it knows both the fd and path */
+		*path = drmGetDeviceNameFromFd(fd);
+	if (*path == NULL)
+		fd = -1;
+
+	return fd;
+}
+
 static int __intel_open_device(const struct pci_device *pci, char **path)
 {
 	int fd;
 
+	if (xorgMir)
+		return __intel_open_xmir(pci, path);
+
 	if (*path == NULL) {
 		char id[20];
 		int ret;
diff --git a/src/intel_driver.h b/src/intel_driver.h
index e54054f..0c5e4ae 100644
--- a/src/intel_driver.h
+++ b/src/intel_driver.h
@@ -1,6 +1,8 @@
 #ifndef INTEL_DRIVER_H
 #define INTEL_DRIVER_H
 
+#include "intel_xmir.h"
+
 #define INTEL_VERSION 4000
 #define INTEL_NAME "intel"
 #define INTEL_DRIVER_NAME "intel"
@@ -129,6 +131,6 @@ void intel_put_device(ScrnInfoPtr scrn);
 
 void __intel_uxa_release_device(ScrnInfoPtr scrn);
 
-#define hosted() (0)
+#define hosted() (xorgMir)
 
 #endif /* INTEL_DRIVER_H */
diff --git a/src/intel_xmir.h b/src/intel_xmir.h
new file mode 100644
index 0000000..2e3c85a
--- /dev/null
+++ b/src/intel_xmir.h
@@ -0,0 +1,15 @@
+#ifndef INTEL_XMIR_H
+#define INTEL_XMIR_H
+
+#include <xorg-server.h>
+
+#if XMIR
+#include <xf86Priv.h>
+#include <xmir.h>
+#else
+typedef struct xmir_screen xmir_screen;
+#define xorgMir 0
+#define xmir_get_drm_fd(id) -1
+#endif
+
+#endif /* INTEL_XMIR_H */
diff --git a/src/sna/Makefile.am b/src/sna/Makefile.am
index 5d5417e..1c5dda0 100644
--- a/src/sna/Makefile.am
+++ b/src/sna/Makefile.am
@@ -75,6 +75,7 @@ libsna_la_SOURCES = \
 	sna_video_overlay.c \
 	sna_video_sprite.c \
 	sna_video_textured.c \
+	sna_xmir.c \
 	gen2_render.c \
 	gen2_render.h \
 	gen3_render.c \
diff --git a/src/sna/sna.h b/src/sna/sna.h
index e2d1ef8..5889c5f 100644
--- a/src/sna/sna.h
+++ b/src/sna/sna.h
@@ -288,6 +288,7 @@ struct sna {
 	EntityInfoPtr pEnt;
 	struct pci_device *PciInfo;
 	const struct intel_device_info *info;
+	xmir_screen *xmir;
 
 	ScreenBlockHandlerProcPtr BlockHandler;
 	ScreenWakeupHandlerProcPtr WakeupHandler;
@@ -426,14 +427,24 @@ CARD32 sna_render_format_for_depth(int depth);
 void sna_debug_flush(struct sna *sna);
 
 static inline bool
+get_window_deltas(PixmapPtr pixmap, int16_t *x, int16_t *y)
+{
+#ifdef COMPOSITE
+	*x = -pixmap->screen_x;
+	*y = -pixmap->screen_y;
+	return pixmap->screen_x | pixmap->screen_y;
+#else
+	*x = *y = 0;
+	return false;
+#endif
+}
+
+static inline bool
 get_drawable_deltas(DrawablePtr drawable, PixmapPtr pixmap, int16_t *x, int16_t *y)
 {
 #ifdef COMPOSITE
-	if (drawable->type == DRAWABLE_WINDOW) {
-		*x = -pixmap->screen_x;
-		*y = -pixmap->screen_y;
-		return pixmap->screen_x | pixmap->screen_y;
-	}
+	if (drawable->type == DRAWABLE_WINDOW)
+		return get_window_deltas(pixmap, x, y);
 #endif
 	*x = *y = 0;
 	return false;
@@ -946,4 +957,18 @@ void sna_image_composite(pixman_op_t        op,
 			 uint16_t           width,
 			 uint16_t           height);
 
+/* sna_xmir.c */
+
+#if XMIR
+bool sna_xmir_create(struct sna *sna);
+bool sna_xmir_pre_init(struct sna *sna);
+void sna_xmir_init(struct sna *sna, ScreenPtr screen);
+void sna_xmir_post_damage(struct sna *sna);
+#else
+inline static bool sna_xmir_create(struct sna *sna) { return true; }
+inline static bool sna_xmir_pre_init(struct sna *sna) { return true; }
+inline static void sna_xmir_init(struct sna *sna, ScreenPtr screen) { }
+inline static void sna_xmir_post_damage(struct sna *sna) { }
+#endif
+
 #endif /* _SNA_H */
diff --git a/src/sna/sna_dri.c b/src/sna/sna_dri.c
index 2527884..e0a1fc0 100644
--- a/src/sna/sna_dri.c
+++ b/src/sna/sna_dri.c
@@ -2249,6 +2249,13 @@ out_complete:
 }
 #endif
 
+#if DRI2INFOREC_VERSION >= 8 && XMIR
+static int sna_dri_auth_magic2(ScreenPtr screen, uint32_t magic)
+{
+	return xmir_auth_drm_magic(to_sna_from_screen(screen)->xmir, magic);
+}
+#endif
+
 static bool has_i830_dri(void)
 {
 	return access(DRI_DRIVER_PATH "/i830_dri.so", R_OK) == 0;
@@ -2324,6 +2331,13 @@ bool sna_dri_open(struct sna *sna, ScreenPtr screen)
 	info.ReuseBufferNotify = NULL;
 #endif
 
+#if DRI2INFOREC_VERSION >= 8 && XMIR
+	if (sna->xmir) {
+		info.version = 8;
+		info.AuthMagic2 = sna_dri_auth_magic2;
+	}
+#endif
+
 #if USE_ASYNC_SWAP
 	info.version = 10;
 	info.scheduleSwap0 = 1;
diff --git a/src/sna/sna_driver.c b/src/sna/sna_driver.c
index 2a4a830..44eea33 100644
--- a/src/sna/sna_driver.c
+++ b/src/sna/sna_driver.c
@@ -442,6 +442,9 @@ static Bool sna_pre_init(ScrnInfoPtr scrn, int flags)
 		goto cleanup;
 	}
 
+	if (!sna_xmir_create(sna))
+		goto cleanup;
+
 	/* Sanity check */
 	if (hosted() && (sna->flags & SNA_IS_HOSTED) == 0) {
 		xf86DrvMsg(scrn->scrnIndex, X_ERROR,
@@ -449,9 +452,14 @@ static Bool sna_pre_init(ScrnInfoPtr scrn, int flags)
 		goto cleanup;
 	}
 
-	preferred_depth = sna->info->gen < 030 ? 15 : 24;
-	if (!fb_supports_depth(fd, preferred_depth))
+	if (sna->xmir) {
+		/* XXX query depth from xmir */
 		preferred_depth = 24;
+	} else {
+		preferred_depth = sna->info->gen < 030 ? 15 : 24;
+		if (!fb_supports_depth(fd, preferred_depth))
+			preferred_depth = 24;
+	}
 
 	if (!xf86SetDepthBpp(scrn, preferred_depth, 0, 0,
 			     Support32bppFb |
@@ -488,6 +496,9 @@ static Bool sna_pre_init(ScrnInfoPtr scrn, int flags)
 
 	intel_detect_chipset(scrn, sna->pEnt, sna->PciInfo);
 
+	if (!sna_xmir_pre_init(sna))
+		goto cleanup;
+
 	kgem_init(&sna->kgem, fd, sna->PciInfo, sna->info->gen);
 	if (xf86ReturnOptValBool(sna->Options, OPTION_ACCEL_DISABLE, FALSE) ||
 	    !sna_option_cast_to_bool(sna, OPTION_ACCEL_METHOD, TRUE)) {
@@ -571,6 +582,8 @@ sna_block_handler(BLOCKHANDLER_ARGS_DECL)
 
 	if (*tv == NULL || ((*tv)->tv_usec | (*tv)->tv_sec))
 		sna_accel_block_handler(sna, tv);
+
+	sna_xmir_post_damage(sna);
 }
 
 static void
@@ -918,6 +931,8 @@ sna_screen_init(SCREEN_INIT_ARGS_DECL)
 	if (!miDCInitialize(screen, xf86GetPointerScreenFuncs()))
 		return FALSE;
 
+	sna_xmir_init(sna, screen); /* after DirectCursor is initialised */
+
 	if ((sna->flags & SNA_IS_HOSTED) == 0 &&
 	    xf86_cursors_init(screen, SNA_CURSOR_X, SNA_CURSOR_Y,
 			       HARDWARE_CURSOR_TRUECOLOR_AT_8BPP |
diff --git a/src/sna/sna_xmir.c b/src/sna/sna_xmir.c
new file mode 100644
index 0000000..ddce984
--- /dev/null
+++ b/src/sna/sna_xmir.c
@@ -0,0 +1,179 @@
+/***************************************************************************
+
+ Copyright 2013 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.
+
+ **************************************************************************/
+
+#include <assert.h>
+
+#include "sna.h"
+
+#if XMIR
+
+/* Theory of Operation
+ * -------------------
+ *
+ *  1. Clients render to their pixmaps and Windows aggregating damage.
+ *  2. Before blocking, we walk the list of dirty Windows and submit
+ *     any damage to Mir. This consumes the xfer buffer.
+ *  3. Clients continue to render and we accumulate damage. However,
+ *     as there is now no xfer buffer free, damage accumulates.
+ *  4. Mir reports that its exchange has complete and gives us a new
+ *     transport buffer.
+ *  5. Before going to sleep, we iterate over dirty Windows and copy
+ *     their damage into the xfer buffer and send back to Mir.
+ *
+ *  Clients render uninterrupted, but we only send damage to Mir once
+ *  every frame.
+ */
+
+#define FORCE_FULL_REDRAW 0
+
+static void
+sna_xmir_copy_to_mir(xmir_window *xmir_win, RegionPtr region)
+{
+	PixmapPtr src = get_window_pixmap(xmir_window_to_windowptr(xmir_win));
+	struct sna *sna = to_sna_from_pixmap(src);
+	const BoxRec *dst_box = xmir_window_get_drawable_region(xmir_win);
+	struct sna_pixmap *priv;
+	struct kgem_bo *bo;
+	BoxRec *box;
+	const int pitch = xmir_window_get_stride(xmir_win);
+	int16_t sx, sy, dx, dy;
+	int n;
+
+#if FORCE_FULL_REDRAW
+	RegionRec whole = { { 0, 0, src->drawable.width, src->drawable.height } };
+	region = &whole;
+#endif
+
+	assert(region);
+
+	DBG(("%s: copying region (%d, %d), (%d, %d) x %d, dst box=(%d, %d), (%d, %d), pitch=%d, fd=%d\n",
+	     __FUNCTION__,
+	     region->extents.x1, region->extents.y1,
+	     region->extents.x2, region->extents.y2,
+	     REGION_NUM_RECTS(region),
+	     dst_box->x1, dst_box->y1,
+	     dst_box->x2, dst_box->y2,
+	     pitch, xmir_window_get_fd(xmir_win)));
+
+	box = REGION_RECTS(region);
+	n = REGION_NUM_RECTS(region);
+	if (n == 0)
+		return;
+
+	/* XXX size is bogus, but only used for sanity checks */
+	bo = kgem_create_for_prime(&sna->kgem,
+				   xmir_window_get_fd(xmir_win),
+				   pitch * (dst_box->y2 - dst_box->y1));
+	if (bo == NULL)
+		return;
+
+	bo->pitch = pitch;
+	bo->scanout = true; /* presume the worst (almost always true) */
+
+	if (get_window_deltas(src, &sx, &sy))
+		RegionTranslate(region, sx, sy);
+
+	dx = sx + dst_box->x1;
+	dy = sy + dst_box->y1;
+
+	priv = sna_pixmap_move_area_to_gpu(src, &region->extents, MOVE_READ);
+	if (priv && sna->render.copy_boxes(sna, GXcopy,
+					   src, priv->gpu_bo, 0, 0,
+					   src, bo, -dx, -dy,
+					   box, n, COPY_LAST)) {
+		kgem_submit(&sna->kgem);
+		n = 0;
+	} else {
+		void *dst = kgem_bo_map__gtt(&sna->kgem, bo);
+		if (dst && sna_drawable_move_region_to_cpu(&src->drawable,
+							   region, MOVE_READ)) {
+			kgem_bo_sync__gtt(&sna->kgem, bo);
+			do {
+				memcpy_blt(src->devPrivate.ptr, dst,
+					   src->drawable.bitsPerPixel,
+					   src->devKind, bo->pitch,
+					   box->x1, box->y1,
+					   box->x1 - dx, box->y1 - dy,
+					   box->x2 - box->x1,
+					   box->y2 - box->y1);
+			} while (--n);
+		}
+	}
+
+	if (sx | sy)
+		RegionTranslate(region, -sx, -sy);
+
+	if (n == 0)
+		xmir_submit_rendering_for_window(xmir_win, region);
+
+	bo->scanout = false; /* but don't confuse our caching! */
+	kgem_bo_destroy(&sna->kgem, bo);
+}
+
+static xmir_driver sna_xmir_driver = {
+	XMIR_DRIVER_VERSION,
+	sna_xmir_copy_to_mir
+};
+
+bool sna_xmir_create(struct sna *sna)
+{
+	if (!xorgMir)
+		return true;
+
+	sna->xmir = xmir_screen_create(sna->scrn);
+	if (sna->xmir == NULL)
+		return false;
+
+	sna->flags |= SNA_IS_HOSTED;
+	return true;
+}
+
+bool sna_xmir_pre_init(struct sna *sna)
+{
+	if (sna->xmir == NULL)
+		return true;
+
+	return xmir_screen_pre_init(sna->scrn, sna->xmir, &sna_xmir_driver);
+}
+
+void sna_xmir_init(struct sna *sna, ScreenPtr screen)
+{
+	if (sna->xmir == NULL)
+		return;
+
+	xmir_screen_init(screen, sna->xmir);
+}
+
+void sna_xmir_post_damage(struct sna *sna)
+{
+	if (sna->xmir == NULL)
+		return;
+
+	xmir_screen_for_each_damaged_window(sna->xmir,
+					    sna_xmir_copy_to_mir);
+}
+
+#endif
commit f906a4de62856df5b2536ce9704750c3530636fa
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Sep 4 15:08:56 2013 +0100

    sna: WriteThrough support is now upstream
    
    Now that the WriteThrough ABI is upstream, we can rely on runtime
    detection of the current interface.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/configure.ac b/configure.ac
index 592605a..29c5c0b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -419,17 +419,6 @@ if test "x$ASYNC_SWAP" = "xyes"; then
 	xp_msg="$xp_msg async-swap"
 fi
 
-AC_ARG_ENABLE(wt,
-	      AS_HELP_STRING([--enable-wt],
-			     [Enable use of WT caching (experimental) [default=no]]),
-	      [WT="$enableval"],
-	      [WT="no"])
-AM_CONDITIONAL(USE_WT, test "x$WT" = "xyes")
-if test "x$WT" = "xyes"; then
-	AC_DEFINE(USE_WT,1,[Assume WriteThrough caching support])
-	xp_msg="$xp_msg wt-cache"
-fi
-
 AC_ARG_ENABLE(debug,
 	      AS_HELP_STRING([--enable-debug],
 			     [Enables internal debugging [default=no]]),
diff --git a/src/sna/kgem.c b/src/sna/kgem.c
index e001b01..8143170 100644
--- a/src/sna/kgem.c
+++ b/src/sna/kgem.c
@@ -829,14 +829,10 @@ static bool test_has_handle_lut(struct kgem *kgem)
 
 static bool test_has_wt(struct kgem *kgem)
 {
-#if defined(USE_WT)
 	if (DBG_NO_WT)
 		return false;
 
 	return gem_param(kgem, LOCAL_I915_PARAM_HAS_WT) > 0;
-#else
-	return false;
-#endif
 }
 
 static bool test_has_semaphores_enabled(struct kgem *kgem)
commit 6f49a413aa812e6f41826d6d1099927e1164353b
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Sep 4 14:33:15 2013 +0100

    configure: Check for required UMS headers before enabling
    
    Prevents the build failing with i810 if we can not find vgaHW.h
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/configure.ac b/configure.ac
index bde0833..592605a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -68,7 +68,7 @@ if test -e .git; then
 	AC_DEFINE(HAVE_DOT_GIT, 1, [Are we in a git checkout?])
 	dot_git=yes
 fi
-AM_CONDITIONAL(HAVE_DOT_GIT, test x$dot_git = xyes)
+AM_CONDITIONAL(HAVE_DOT_GIT, test "x$dot_git" = "xyes")
 
 # If so, we include the git description in our logs for sanity checking.
 #
@@ -81,10 +81,10 @@ AC_ARG_WITH(builderstring,
 	    [BUILDERSTRING="$withval"],
 	    [BUILDERSTRING="x-magic-git-describe"])
 
-if test "x$BUILDERSTRING" = xx-magic-git-describe -a x$dot_git = xyes; then
+if test "x$BUILDERSTRING" = "xx-magic-git-describe" -a "x$dot_git" = "xyes"; then
 	AC_DEFINE(USE_GIT_DESCRIBE, 1, [Use automagic builder description])
 else
-  if test "x$BUILDERSTRING" != x -a "x$BUILDERSTRING" != xno -a "x$BUILDERSTRING" != xx-magic-git-describe; then
+  if test "x$BUILDERSTRING" != x -a "x$BUILDERSTRING" != "xno" -a "x$BUILDERSTRING" != xx-magic-git-describe; then
 	  AC_DEFINE_UNQUOTED(BUILDER_DESCRIPTION, ["$BUILDERSTRING"], [Builder description])
   fi
 fi
@@ -93,15 +93,15 @@ AC_ARG_ENABLE(gen4asm,
               AS_HELP_STRING([--enable-gen4asm],
 			     [Enable rebuilding the gen4 assembly files [default=no]]),
               [ASM="$enableval"],
-              [ASM=no])
+              [ASM="no"])
 
 gen4asm=no
-if test x$ASM != "xno"; then
+if test "x$ASM" != "xno"; then
 	PKG_CHECK_MODULES(GEN4ASM, [intel-gen4asm >= 1.2], [gen4asm=yes], [gen4asm=no])
-	if test x$ASM = "xyes" -a x$gen4asm != "xyes"; then
+	if test "x$ASM" = "xyes" -a "x$gen4asm" != "xyes"; then
 		AC_MSG_ERROR([intel-gen4asm support requested but not found])
 	fi
-	if test x$gen4asm = "xyes"; then
+	if test "x$gen4asm" = "xyes"; then
 		AC_MSG_CHECKING([path to use for intel-gen4asm])
 		INTEL_GEN4ASM="`pkg-config intel-gen4asm --variable=exec_prefix`/bin/intel-gen4asm"
 		if ! test -e "$INTEL_GEN4ASM"; then
@@ -111,7 +111,7 @@ if test x$ASM != "xno"; then
 		AC_SUBST([INTEL_GEN4ASM])
 	fi
 fi
-AM_CONDITIONAL(HAVE_GEN4ASM, test x$gen4asm = xyes)
+AM_CONDITIONAL(HAVE_GEN4ASM, test "x$gen4asm" = "xyes")
 
 # Check for atomic intrinsics
 AC_CACHE_CHECK([for native atomic primitives], intel_cv_atomic_primitives,
@@ -135,7 +135,7 @@ int atomic_cmpxchg(int i, int j, int k) { return __sync_val_compare_and_swap (&i
     fi
 
 ])
-if test "x$intel_cv_atomic_primitives" = xIntel; then
+if test "x$intel_cv_atomic_primitives" = "xIntel"; then
     AC_DEFINE(HAVE_ATOMIC_PRIMITIVES, 1,
 	      [Enable if your compiler supports the Intel __sync_* atomic primitives])
 fi
@@ -153,21 +153,21 @@ AC_ARG_ENABLE(udev,
               [UDEV="$enableval"],
               [UDEV=auto])
 
-if test x$UDEV != "xno"; then
-	PKG_CHECK_MODULES(UDEV, [libudev], [udev=yes], [udev=no])
-	if test x$UDEV = xyes -a x$udev != xyes; then
+if test "x$UDEV" != "xno"; then
+	PKG_CHECK_MODULES(UDEV, [libudev], [udev="yes"], [udev="no"])
+	if test "x$UDEV" = "xyes" -a "x$udev" != "xyes"; then
 		AC_MSG_ERROR([udev support requested but not found (libudev)])
 	fi
-	if test x$udev = xyes; then
+	if test "x$udev" = "xyes"; then
 		AC_DEFINE(HAVE_UDEV,1,[Enable udev-based monitor hotplug detection])
 	fi
 fi
 
-PKG_CHECK_MODULES(X11, [x11 xrender xext pixman-1], [x11=yes], [x11=no])
-AM_CONDITIONAL(HAVE_X11, test x$x11 = xyes)
+PKG_CHECK_MODULES(X11, [x11 xrender xext pixman-1], [x11="yes"], [x11="no"])
+AM_CONDITIONAL(HAVE_X11, test "x$x11" = "xyes")
 
-PKG_CHECK_MODULES(TOOL, [xinerama xrandr xdamage xfixes xcursor xtst xrender xext x11 pixman-1], [tools=yes], [tools=no])
-AM_CONDITIONAL(BUILD_TOOLS, test x$tools = xyes)
+PKG_CHECK_MODULES(TOOL, [xinerama xrandr xdamage xfixes xcursor xtst xrender xext x11 pixman-1], [tools="yes"], [tools="no"])
+AM_CONDITIONAL(BUILD_TOOLS, test "x$tools" = "xyes")
 
 AH_TOP([#include "xorg-server.h"])
 
@@ -184,16 +184,30 @@ AC_ARG_ENABLE(dri, AS_HELP_STRING([--disable-dri],
 AC_ARG_ENABLE(xvmc, AS_HELP_STRING([--disable-xvmc],
                                   [Disable XvMC support [[default=yes]]]),
               [XVMC="$enableval"],
-              [XVMC=yes])
-
-AC_ARG_ENABLE(kms-only, AS_HELP_STRING([--enable-kms-only],
-                                  [Assume KMS support [[default=no]]]),
-              [KMS_ONLY="$enableval"],
-              [KMS_ONLY=no])
-AC_ARG_ENABLE(ums-only, AS_HELP_STRING([--enable-ums-only],
-                                  [Assume only UMS (no KMS) support [[default=no]]]),
-              [UMS_ONLY="$enableval"],
-              [UMS_ONLY=no])
+              [XVMC="yes"])
+
+AC_ARG_ENABLE(kms,
+	      AS_HELP_STRING([--enable-kms],
+			     [Assume KMS support [[default=yes]]]),
+              [KMS="$enableval"],
+              [KMS="yes"])
+AC_ARG_ENABLE(ums,
+	      AS_HELP_STRING([--enable-ums],
+			     [Assume UMS support [[default=auto]]]),
+              [UMS="$enableval"],
+              [UMS="auto"])
+
+AC_ARG_ENABLE(kms-only,
+	      AS_HELP_STRING([--enable-kms-only],
+			     [Only assume KMS support (no UMS) [[default=no]]]),
+              [ONLY_KMS="$enableval"],
+              [ONLY_KMS="no"])
+
+AC_ARG_ENABLE(ums-only,
+	      AS_HELP_STRING([--enable-ums-only],
+			     [Only assume UMS support (no KMS) [[default=no]]]),
+              [ONLY_UMS="$enableval"],
+              [ONLY_UMS="no"])
 
 required_xorg_server_version=1.6
 required_pixman_version=0.16
@@ -217,7 +231,7 @@ if test "x$SNA" != "xno"; then
 	AC_CHECK_HEADERS([sys/sysinfo.h], AC_CHECK_MEMBERS([struct sysinfo.totalram], [], [], [[#include <sys/sysinfo.h>]]))
 fi
 AC_MSG_CHECKING([whether to include SNA support])
-AM_CONDITIONAL(SNA, test x$SNA != xno)
+AM_CONDITIONAL(SNA, test "x$SNA" != "xno")
 AC_MSG_RESULT([$SNA])
 
 AC_ARG_ENABLE(uxa,
@@ -225,7 +239,6 @@ AC_ARG_ENABLE(uxa,
 			     [Enable Unified Acceleration Architecture (UXA) [default=yes]]),
 	      [UXA="$enableval"],
 	      [UXA=auto])
-AC_MSG_CHECKING([whether to include UXA support])
 if test "x$UXA" = "xauto"; then
 	if ! pkg-config --exists 'libdrm_intel >= 2.4.29'; then
 		UXA=no
@@ -240,100 +253,123 @@ if test "x$UXA" != "xno"; then
 	required_pixman_version=0.24
 	UXA=yes
 fi
+AC_MSG_CHECKING([whether to include UXA support])
 AC_MSG_RESULT([$UXA])
-AM_CONDITIONAL(UXA, test x$UXA != xno)
+AM_CONDITIONAL(UXA, test "x$UXA" != "xno")
 
 AC_MSG_CHECKING([whether to include GLAMOR support])
 AC_ARG_ENABLE(glamor,
 	      AS_HELP_STRING([--enable-glamor],
 			     [Enable glamor, a new GL-based acceleration [default=no]]),
 	      [GLAMOR="$enableval"],
-	      [GLAMOR=no])
+	      [GLAMOR="no"])
 AC_MSG_RESULT([$GLAMOR])
-AM_CONDITIONAL(GLAMOR, test x$GLAMOR != xno)
+AM_CONDITIONAL(GLAMOR, test "x$GLAMOR" != "xno")
 if test "x$GLAMOR" != "xno"; then
 	PKG_CHECK_MODULES(LIBGLAMOR, [glamor >= 0.3.1])
 	PKG_CHECK_MODULES(LIBGLAMOR_EGL, [glamor-egl])
 	AC_DEFINE(USE_GLAMOR, 1, [Enable glamor acceleration])
 fi
 
-
 PKG_CHECK_MODULES(XORG, [xorg-server >= $required_xorg_server_version xproto fontsproto pixman-1 >= $required_pixman_version $REQUIRED_MODULES])
 
-AC_ARG_ENABLE(xaa,
-	      AS_HELP_STRING([--enable-xaa],
-			     [Enable legacy X Acceleration Architecture (XAA) for i810 chipsets [default=auto]]),
-	      [XAA="$enableval"],
-	      [XAA=auto])
-if test "x$XAA" != xno; then
-        save_CPPFLAGS=$CPPFLAGS
-        CPPFLAGS=$XORG_CFLAGS
-	AC_CHECK_HEADERS([xaa.h], XAA=yes, XAA=no)
-        CPPFLAGS=$save_CPPFLAGS
-fi
-AC_MSG_CHECKING([whether to include XAA support])
-AM_CONDITIONAL(XAA, test "x$XAA" = xyes)
-AC_MSG_RESULT([$XAA])
-
-AC_ARG_ENABLE(dga,
-	      AS_HELP_STRING([--enable-dga],
-			     [Enable legacy Direct Graphics Access (DGA) for i810 chipsets [default=auto]]),
-	      [DGA="$enableval"],
-	      [DGA=auto])
-if test "x$DGA" != xno; then
-        save_CFLAGS=$CFLAGS
-        CFLAGS=$XORG_CFLAGS
-	AC_CHECK_HEADERS([dgaproc.h], DGA=yes, DGA=no, [#include <dixstruct.h>])
-        CFLAGS=$save_CFLAGS
-fi
-AC_MSG_CHECKING([whether to include DGA support])
-AM_CONDITIONAL(DGA, test "x$DGA" = xyes)
-AC_MSG_RESULT([$DGA])
+if test "x$ONLY_UMS" = "xyes"; then
+	UMS="yes"
+	KMS="no"
+fi
+
+if test "x$ONLY_KMS" = "xyes"; then
+	UMS="no"
+	KMS="yes"
+fi
+
+save_CPPFLAGS=$CPPFLAGS
+CPPFLAGS=$XORG_CFLAGS
+AC_CHECK_HEADERS([vgaHW.h], legacy="yes", legacy="no")
+CPPFLAGS=$save_CPPFLAGS
+if test "x$UMS" = "xauto"; then
+	UMS="$legacy"
+fi
+if test "x$UMS" = "xyes" -a "x$legacy" = "xno"; then
+	AC_MSG_ERROR([vgaHW support required for UMS (i810) driver])
+fi
+
+if test "x$UMS" = "xyes"; then
+	AC_ARG_ENABLE(xaa,
+		      AS_HELP_STRING([--enable-xaa],
+				     [Enable legacy X Acceleration Architecture (XAA) for i810 chipsets [default=auto]]),
+		      [XAA="$enableval"],
+		      [XAA="auto"])
+	if test "x$XAA" != "xno"; then
+		save_CPPFLAGS=$CPPFLAGS
+		CPPFLAGS=$XORG_CFLAGS
+		AC_CHECK_HEADERS([xaa.h], XAA="yes", XAA="no")
+		CPPFLAGS=$save_CPPFLAGS
+	fi
+	AC_MSG_CHECKING([whether to include XAA support])
+	AC_MSG_RESULT([$XAA])
+
+	AC_ARG_ENABLE(dga,
+		      AS_HELP_STRING([--enable-dga],
+				     [Enable legacy Direct Graphics Access (DGA) for i810 chipsets [default=auto]]),
+		      [DGA="$enableval"],
+		      [DGA="auto"])
+	if test "x$DGA" != "xno"; then
+		save_CFLAGS=$CFLAGS
+		CFLAGS=$XORG_CFLAGS
+		AC_CHECK_HEADERS([dgaproc.h], DGA="yes", DGA="no", [#include <dixstruct.h>])
+		CFLAGS=$save_CFLAGS
+	fi
+	AC_MSG_CHECKING([whether to include DGA support])
+	AC_MSG_RESULT([$DGA])
+fi
+AM_CONDITIONAL(DGA, test "x$DGA" = "xyes")
+AM_CONDITIONAL(XAA, test "x$XAA" = "xyes")
 
 AC_ARG_WITH(default-accel,
 	    AS_HELP_STRING([--with-default-accel],
 			   [Select the default acceleration method [default=uxa if enabled, otherwise sna]]),
 			   [accel="$withval"],
-			   [accel=auto])
-if test "x$accel" = xyes; then
+			   [accel="auto"])
+if test "x$accel" = "xyes"; then
 	AC_MSG_WARN([No default acceleration specified, choosing automatic selection])
 	accel="auto"
 fi
 
 AC_MSG_CHECKING([which acceleration method to use by default])
-if test "x$accel" = xauto; then
+if test "x$accel" = "xauto"; then
 	if test "x$UXA" != "xno"; then
-		accel=uxa
+		accel="uxa"
 	else
 		if test "x$SNA" != "xno"; then
-			accel=sna
+			accel="sna"
 		fi
 	fi
-	if test "x$accel" = xauto -a "x$UMS_ONLY" != "xyes"; then
+	if test "x$accel" = "xauto" -a "x$KMS" = "xyes"; then
 		AC_MSG_ERROR([No default acceleration option])
 	fi
 fi
 
-have_accel=none
-if test "x$accel" = xsna; then
+have_accel="none"
+if test "x$accel" = "xsna"; then
 	if test "x$SNA" != "xno"; then
 		AC_DEFINE(DEFAULT_ACCEL_METHOD, SNA, [Default acceleration method])
-		have_accel=yes
+		have_accel="yes"
 	else
 		AC_MSG_ERROR([SNA requested as default, but is not enabled])
 	fi
 fi
 
-if test "x$accel" = xuxa; then
+if test "x$accel" = "xuxa"; then
 	if test "x$UXA" != "xno"; then
 		AC_DEFINE(DEFAULT_ACCEL_METHOD, UXA, [Default acceleration method])
-		have_accel=yes
+		have_accel="yes"
 	else
 		AC_MSG_ERROR([UXA requested as default, but is not enabled])
 	fi
 fi
 AC_MSG_RESULT($accel)
-if test "x$accel" = xnone -a "x$UMS_ONLY" != "xyes"; then
+if test "x$accel" = "xnone" -a "x$KMS" = "xyes"; then
 	AC_MSG_ERROR([No default acceleration option])
 fi
 
@@ -343,9 +379,9 @@ AC_ARG_ENABLE(rendernode,
 	      AS_HELP_STRING([--enable-rendernode],
 			     [Enable use of render nodes (experimental) [default=no]]),
 	      [RENDERNODE="$enableval"],
-	      [RENDERNODE=no])
-AM_CONDITIONAL(USE_RENDERNODE, test x$RENDERNODE = xyes)
-if test "x$RENDERNODE" = xyes; then
+	      [RENDERNODE="no"])
+AM_CONDITIONAL(USE_RENDERNODE, test "x$RENDERNODE" = "xyes")
+if test "x$RENDERNODE" = "xyes"; then
 	AC_DEFINE(USE_RENDERNODE,1,[Assume "rendernode" support])
 	xp_msg="$xp_msg rendernode"
 fi
@@ -354,9 +390,9 @@ AC_ARG_ENABLE(create2,
 	      AS_HELP_STRING([--enable-create2],
 			     [Enable use of create2 ioctl (experimental) [default=no]]),
 	      [CREATE2="$enableval"],
-	      [CREATE2=no])
-AM_CONDITIONAL(USE_CREATE2, test x$CREATE2 = xyes)
-if test "x$CREATE2" = xyes; then
+	      [CREATE2="no"])
+AM_CONDITIONAL(USE_CREATE2, test "x$CREATE2" = "xyes")
+if test "x$CREATE2" = "xyes"; then
 	AC_DEFINE(USE_CREATE2,1,[Assume "create2" support])
 	xp_msg="$xp_msg create2"
 fi
@@ -365,9 +401,9 @@ AC_ARG_ENABLE(userptr,
 	      AS_HELP_STRING([--enable-userptr],
 			     [Enable use of userptr (experimental) [default=no]]),
 	      [USERPTR="$enableval"],
-	      [USERPTR=no])
-AM_CONDITIONAL(USE_USERPTR, test x$USERPTR = xyes)
-if test "x$USERPTR" = xyes; then
+	      [USERPTR="no"])
+AM_CONDITIONAL(USE_USERPTR, test "x$USERPTR" = "xyes")
+if test "x$USERPTR" = "xyes"; then
 	AC_DEFINE(USE_USERPTR,1,[Assume "userptr" support])
 	xp_msg="$xp_msg userptr"
 fi
@@ -376,9 +412,9 @@ AC_ARG_ENABLE(async-swap,
 	      AS_HELP_STRING([--enable-async-swap],
 			     [Enable use of asynchronous swaps (experimental) [default=no]]),
 	      [ASYNC_SWAP="$enableval"],
-	      [ASYNC_SWAP=no])
-AM_CONDITIONAL(USE_ASYNC_SWAP, test x$ASYNC_SWAP = xyes)
-if test "x$ASYNC_SWAP" = xyes; then
+	      [ASYNC_SWAP="no"])
+AM_CONDITIONAL(USE_ASYNC_SWAP, test "x$ASYNC_SWAP" = "xyes")
+if test "x$ASYNC_SWAP" = "xyes"; then
 	AC_DEFINE(USE_ASYNC_SWAP,1,[Assume asynchronous swap support])
 	xp_msg="$xp_msg async-swap"
 fi
@@ -387,9 +423,9 @@ AC_ARG_ENABLE(wt,
 	      AS_HELP_STRING([--enable-wt],
 			     [Enable use of WT caching (experimental) [default=no]]),
 	      [WT="$enableval"],
-	      [WT=no])
-AM_CONDITIONAL(USE_WT, test x$WT = xyes)
-if test "x$WT" = xyes; then
+	      [WT="no"])
+AM_CONDITIONAL(USE_WT, test "x$WT" = "xyes")
+if test "x$WT" = "xyes"; then
 	AC_DEFINE(USE_WT,1,[Assume WriteThrough caching support])
 	xp_msg="$xp_msg wt-cache"
 fi
@@ -398,12 +434,12 @@ AC_ARG_ENABLE(debug,
 	      AS_HELP_STRING([--enable-debug],
 			     [Enables internal debugging [default=no]]),
               [DEBUG="$enableval"],
-              [DEBUG=no])
+              [DEBUG="no"])
 AC_ARG_ENABLE(valgrind,
 	      AS_HELP_STRING([--enable-valgrind],
 			     [Enables valgrindified ioctls for debugging [default=no]]),
               [VG="$enableval"],
-              [VG=no])
+              [VG="no"])
 
 # Store the list of server defined optional extensions in REQUIRED_MODULES
 XORG_DRIVER_CHECK_EXT(RANDR, randrproto)
@@ -422,13 +458,13 @@ AC_SUBST(CLOCK_GETTIME_LIBS)
 sdkdir=`$PKG_CONFIG --variable=sdkdir xorg-server`
 
 DRI1=no
-if test "x$enable_dri" != "xno" -a "x$KMS_ONLY" != "xyes"; then
-	PKG_CHECK_MODULES(DRI1, [xf86driproto], [DRI1=yes], [DRI1=no])
+if test "x$enable_dri" != "xno" -a "x$UMS" = "xyes"; then
+	PKG_CHECK_MODULES(DRI1, [xf86driproto], [DRI1="yes"], [DRI1="no"])
         save_CFLAGS="$CFLAGS"
         save_CPPFLAGS="$CPPFLAGS"
         CFLAGS="$CFLAGS $XORG_CFLAGS $DRI_CFLAGS $DRM_CFLAGS"
         CPPFLAGS="$CPPFLAGS $XORG_CFLAGS $DRI_CFLAGS $DRM_CFLAGS"
-        AC_CHECK_HEADERS([dri.h sarea.h dristruct.h], [DRI1=yes], [DRI1=no],
+        AC_CHECK_HEADERS([dri.h sarea.h dristruct.h], [DRI1="yes"], [DRI1="no"],
                 [/* for dri.h */
                  #include <xf86str.h>
                  /* for dristruct.h */
@@ -447,7 +483,7 @@ fi
 AC_MSG_CHECKING([whether to include DRI1 support])
 AC_MSG_RESULT([$DRI1])
 
-AM_CONDITIONAL(DRI1, test x$DRI1 != xno)
+AM_CONDITIONAL(DRI1, test "x$DRI1" != "xno")
 if test "x$DRI1" != "xno"; then
         AC_DEFINE(HAVE_DRI1,1,[Enable DRI1 driver support])
 	dri_msg="$dri_msg DRI1"
@@ -455,14 +491,14 @@ else
         DRI1_CFLAGS=""
         DRI1_LIBS=""
 
-        if test "x$enable_dri" = "xyes" -a "x$KMS_ONLY" != "xyes"; then
+        if test "x$enable_dri" = "xyes" -a "x$UMS" = "xyes"; then
                 AC_MSG_ERROR([DRI1 requested but prerequisites not found])
         fi
 fi
 
 DRI2=no
 if test "x$enable_dri" != "xno"; then
-	PKG_CHECK_MODULES(DRI2, [dri2proto >= 2.6], DRI2=yes, DRI2=no)
+	PKG_CHECK_MODULES(DRI2, [dri2proto >= 2.6], DRI2="yes", DRI2="no")
 	dridriverdir=`$PKG_CONFIG --variable=dridriverdir dri`
 	if test "x$dridriverdir" = "x"; then
 		dridriverdir="$libdir/dri"
@@ -471,92 +507,92 @@ if test "x$enable_dri" != "xno"; then
 	if test "x$DRI2" != "xno"; then
 		save_CFLAGS=$CFLAGS
 		CFLAGS="$XORG_CFLAGS $DRM_CFLAGS $DRI_CFLAGS $DRI2_CFLAGS"
-		AC_CHECK_HEADERS([dri2.h], DRI2=yes, DRI2=no, [#include <dixstruct.h>])
+		AC_CHECK_HEADERS([dri2.h], DRI2="yes", DRI2="no", [#include <dixstruct.h>])
 		CFLAGS=$save_CFLAGS
 	fi
 fi
 AC_MSG_CHECKING([whether to include DRI2 support])
-AM_CONDITIONAL(DRI2, test "x$DRI2" = xyes)
+AM_CONDITIONAL(DRI2, test "x$DRI2" = "xyes")
 AC_MSG_RESULT([$DRI2])
 if test "x$DRI2" != "xno"; then
         AC_DEFINE(HAVE_DRI2,1,[Enable DRI2 driver support])
 	dri_msg="$dri_msg DRI2"
 fi
 
-if test "$XVMC" = yes; then
-	PKG_CHECK_MODULES(XVMCLIB, [xvmc dri2proto x11], [], [XVMC=no])
-	PKG_CHECK_MODULES(XCB, [x11-xcb xcb-dri2 xcb-aux], [], [XVMC=no])
+if test "$XVMC" = "yes"; then
+	PKG_CHECK_MODULES(XVMCLIB, [xvmc dri2proto x11], [], [XVMC="no"])
+	PKG_CHECK_MODULES(XCB, [x11-xcb xcb-dri2 xcb-aux], [], [XVMC="no"])
 fi
 AC_MSG_CHECKING([whether to include XvMC support])
 AC_MSG_RESULT([$XVMC])
-AM_CONDITIONAL(XVMC, test x$XVMC = xyes)
-if test "x$XVMC" = xyes; then
+AM_CONDITIONAL(XVMC, test "x$XVMC" = "xyes")
+if test "x$XVMC" = "xyes"; then
 	AC_DEFINE(ENABLE_XVMC,1,[Enable XvMC support])
 	xvmc_msg=" yes"
 else
 	xvmc_msg=" no"
 fi
 
-AM_CONDITIONAL(KMS_ONLY, test x$KMS_ONLY = xyes)
-if test "x$KMS_ONLY" = xyes; then
-	AC_DEFINE(KMS_ONLY,1,[Assume KMS support])
+AM_CONDITIONAL(KMS, test "x$KMS" = "xyes")
+if test "x$KMS" = "xyes"; then
+	AC_DEFINE(KMS,1,[Assume KMS support])
 fi
-AM_CONDITIONAL(UMS_ONLY, test x$UMS_ONLY = xyes)
-if test "x$UMS_ONLY" = xyes; then
-	AC_DEFINE(UMS_ONLY,1,[Assume only UMS (no KMS) support])
+AM_CONDITIONAL(UMS, test "x$UMS" = "xyes")
+if test "x$UMS" = "xyes"; then
+	AC_DEFINE(UMS,1,[Assume UMS support])
 fi
 
-AM_CONDITIONAL(DEBUG, test x$DEBUG != xno)
-AM_CONDITIONAL(FULL_DEBUG, test x$DEBUG = xfull)
-if test "x$DEBUG" = xno; then
+AM_CONDITIONAL(DEBUG, test "x$DEBUG" != "xno")
+AM_CONDITIONAL(FULL_DEBUG, test "x$DEBUG" = "xfull")
+if test "x$DEBUG" = "xno"; then
 	AC_DEFINE(NDEBUG,1,[Disable internal debugging])
 else
-	if test "x$VG" != xyes; then
+	if test "x$VG" != "xyes"; then
 		VG=auto
 	fi
 fi
 debug_msg=""
-have_valgrind=no
-if test "x$VG" != xno; then
-	PKG_CHECK_MODULES(VALGRIND, [valgrind], have_valgrind=yes, have_valgrind=no)
+have_valgrind="no"
+if test "x$VG" != "xno"; then
+	PKG_CHECK_MODULES(VALGRIND, [valgrind], have_valgrind="yes", have_valgrind="no")
 	AC_MSG_CHECKING([whether to include valgrind support])
-	if test x$have_valgrind = xyes; then
+	if test "x$have_valgrind" = "xyes"; then
 		AC_DEFINE([HAVE_VALGRIND], 1, [Use valgrind intrinsics to suppress false warnings])
 	else
-		if test "x$VG" = xyes; then
+		if test "x$VG" = "xyes"; then
 			AC_MSG_ERROR([valgrind support requested, but valgrind-dev headers not found])
 		fi
 	fi
 	AC_MSG_RESULT([$have_valgrind ($VG)])
 fi
-AM_CONDITIONAL(VALGRIND, test x$have_valgrind = xyes)
-if test "x$have_valgrind" = xyes; then
+AM_CONDITIONAL(VALGRIND, test "x$have_valgrind" = "xyes")
+if test "x$have_valgrind" = "xyes"; then
 	debug_msg="$debug_msg valgrind"
 fi
-if test "x$DEBUG" = xsync; then
+if test "x$DEBUG" = "xsync"; then
 	AC_DEFINE(DEBUG_SYNC,1,[Enable synchronous rendering for debugging])
 	debug_msg="$debug_msg sync"
 fi
-if test "x$DEBUG" = xmemory; then
+if test "x$DEBUG" = "xmemory"; then
 	AC_DEFINE(DEBUG_MEMORY,1,[Enable memory debugging])
 	debug_msg="$debug_msg memory"
 fi
-if test "x$DEBUG" = xpixmap; then
+if test "x$DEBUG" = "xpixmap"; then
 	AC_DEFINE(DEBUG_PIXMAP,1,[Enable pixmap debugging])
 	debug_msg="$debug_msg pixmaps"
 fi
-if test "x$DEBUG" = xfull; then
+if test "x$DEBUG" = "xfull"; then
 	AC_DEFINE(DEBUG_MEMORY,1,[Enable memory debugging])
 	AC_DEFINE(DEBUG_PIXMAP,1,[Enable pixmap debugging])
 	AC_DEFINE(HAS_DEBUG_FULL,1,[Enable all debugging])
         CFLAGS="$CFLAGS -O0 -ggdb3"
 	debug_msg=" full"
 fi
-if test "x$debug_msg" = x; then
+if test "x$debug_msg" = "x"; then
 	debug_msg=" none"
 fi
 
-DRIVER_NAME=intel
+DRIVER_NAME="intel"
 AC_SUBST([DRIVER_NAME])
 AC_SUBST([moduledir])
 
@@ -604,11 +640,11 @@ if test "x$GLAMOR" != "xno"; then
 	fi
 fi
 
-if test "x$dri_msg" = x; then
+if test "x$dri_msg" = "x"; then
 	dri_msg=" none"
 fi
 
-if test "x$tools" = xyes; then
+if test "x$tools" = "xyes"; then
 	tools_msg=" intel-virtual-output"
 else
 	tools_msg=" none"
@@ -618,6 +654,8 @@ echo ""
 echo "AC_PACKAGE_STRING will be compiled with:"
 echo "  Acceleration backends:$accel_msg"
 echo "  Additional debugging support?$debug_msg"
+echo "  Support for Kernel Mode Setting? $KMS"
+echo "  Support for legacy User Mode Setting (for i810)? $UMS"
 echo "  Support for Direct Rendering Infrastructure:$dri_msg"
 echo "  Support for Xv motion compensation (XvMC and libXvMC):$xvmc_msg"
 echo "  Build additional tools and utilities?$tools_msg"
diff --git a/src/intel_module.c b/src/intel_module.c
index b91152e..f61b688 100644
--- a/src/intel_module.c
+++ b/src/intel_module.c
@@ -207,14 +207,14 @@ static const SymTabRec intel_chipsets[] = {
 #define NUM_CHIPSETS (sizeof(intel_chipsets) / sizeof(intel_chipsets[0]))
 
 static const struct pci_id_match intel_device_match[] = {
-#if !KMS_ONLY
+#if UMS
 	INTEL_VGA_DEVICE(PCI_CHIP_I810, &intel_i81x_info),
 	INTEL_VGA_DEVICE(PCI_CHIP_I810_DC100, &intel_i81x_info),
 	INTEL_VGA_DEVICE(PCI_CHIP_I810_E, &intel_i81x_info),
 	INTEL_VGA_DEVICE(PCI_CHIP_I815, &intel_i81x_info),
 #endif
 
-#if !UMS_ONLY
+#if KMS
 	INTEL_I830_IDS(&intel_i830_info),
 	INTEL_I845G_IDS(&intel_i830_info),
 	INTEL_I85X_IDS(&intel_i855_info),
@@ -377,9 +377,8 @@ static Bool intel_driver_func(ScrnInfoPtr pScrn,
 	switch (op) {
 	case GET_REQUIRED_HW_INTERFACES:
 		flag = (CARD32*)ptr;
-#ifdef KMS_ONLY
 		(*flag) = 0;
-#else
+#if UMS
 		(*flag) = HW_IO | HW_MMIO;
 #endif
 #ifdef HW_SKIP_CONSOLE
@@ -394,7 +393,7 @@ static Bool intel_driver_func(ScrnInfoPtr pScrn,
 	}
 }
 
-#if !UMS_ONLY
+#if KMS
 extern XF86ConfigPtr xf86configptr;
 
 static XF86ConfDevicePtr
@@ -459,12 +458,12 @@ intel_scrn_create(DriverPtr		driver,
 		xf86SetEntityShared(entity_num);
 	xf86AddEntityToScreen(scrn, entity_num);
 
-#if !KMS_ONLY
+#if UMS
 	if ((unsigned)((struct intel_device_info *)match_data)->gen < 020)
 		return lg_i810_init(scrn);
 #endif
 
-#if !UMS_ONLY
+#if KMS
 	switch (get_accel_method()) {
 #if USE_SNA
 	case SNA: return sna_init_scrn(scrn, entity_num);
@@ -493,9 +492,7 @@ static Bool intel_pci_probe(DriverPtr		driver,
 			    intptr_t		match_data)
 {
 	if (intel_open_device(entity_num, pci, NULL) == -1) {
-#if KMS_ONLY
-		return FALSE;
-#else
+#if UMS
 		switch (pci->device_id) {
 		case PCI_CHIP_I810:
 		case PCI_CHIP_I810_DC100:
@@ -506,6 +503,8 @@ static Bool intel_pci_probe(DriverPtr		driver,
 		default:
 			return FALSE;
 		}
+#else
+		return FALSE;
 #endif
 	}
 
@@ -563,7 +562,7 @@ static const OptionInfoRec *
 intel_available_options(int chipid, int busid)
 {
 	switch (chipid) {
-#if !KMS_ONLY
+#if UMS
 	case PCI_CHIP_I810:
 	case PCI_CHIP_I810_DC100:
 	case PCI_CHIP_I810_E:
diff --git a/src/legacy/Makefile.am b/src/legacy/Makefile.am
index 206ac9c..8c5bac5 100644
--- a/src/legacy/Makefile.am
+++ b/src/legacy/Makefile.am
@@ -6,7 +6,7 @@ NULL:=#
 liblegacy_la_SOURCES = legacy.h
 liblegacy_la_LIBADD =
 
-if ! KMS_ONLY
+if UMS
 SUBDIRS += i810
 liblegacy_la_SOURCES +=
 liblegacy_la_LIBADD += \
commit ecb3c303f8f62f5232f3e49c8df4193ea478be13
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Sep 4 12:09:25 2013 +0100

    sna: Fix sna_pixmap_move_area_to_gpu() to return the sna_pixmap
    
    Like it's sibling sna_pixmap_move_to_gpu(), it helps to know the private
    sna_pixmap after the operation rather than just a boolean success/fail
    result, and make it more robust in the process.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/sna.h b/src/sna/sna.h
index c47a8ab..e2d1ef8 100644
--- a/src/sna/sna.h
+++ b/src/sna/sna.h
@@ -486,7 +486,7 @@ sna_pixmap_undo_cow(struct sna *sna, struct sna_pixmap *priv, unsigned flags);
 #define __MOVE_FORCE 0x40
 #define __MOVE_DRI 0x80
 
-bool
+struct sna_pixmap *
 sna_pixmap_move_area_to_gpu(PixmapPtr pixmap, const BoxRec *box, unsigned int flags);
 
 struct sna_pixmap *sna_pixmap_move_to_gpu(PixmapPtr pixmap, unsigned flags);
diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c
index c92d4c6..e3adc60 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -2831,21 +2831,55 @@ sna_pixmap_mark_active(struct sna *sna, struct sna_pixmap *priv)
 	return priv;
 }
 
-bool
+inline static struct sna_pixmap *
+__sna_pixmap_for_gpu(struct sna *sna, PixmapPtr pixmap, unsigned flags)
+{
+	struct sna_pixmap *priv;
+
+	if ((flags & __MOVE_FORCE) == 0 && wedged(sna))
+		return NULL;
+
+	priv = sna_pixmap(pixmap);
+	if (priv == NULL) {
+		DBG(("%s: not attached\n", __FUNCTION__));
+		if ((flags & __MOVE_DRI) == 0)
+			return NULL;
+
+		DBG(("%s: forcing the creation on the GPU\n", __FUNCTION__));
+
+		priv = sna_pixmap_attach(pixmap);
+		if (priv == NULL)
+			return NULL;
+
+		sna_damage_all(&priv->cpu_damage,
+			       pixmap->drawable.width,
+			       pixmap->drawable.height);
+
+		assert(priv->gpu_bo == NULL);
+		assert(priv->gpu_damage == NULL);
+	}
+
+	return priv;
+}
+
+struct sna_pixmap *
 sna_pixmap_move_area_to_gpu(PixmapPtr pixmap, const BoxRec *box, unsigned int flags)
 {
 	struct sna *sna = to_sna_from_pixmap(pixmap);
-	struct sna_pixmap *priv = sna_pixmap(pixmap);
+	struct sna_pixmap *priv;
 	RegionRec i, r;
 
 	DBG(("%s: pixmap=%ld box=(%d, %d), (%d, %d), flags=%x\n",
 	     __FUNCTION__, pixmap->drawable.serialNumber,
 	     box->x1, box->y1, box->x2, box->y2, flags));
 
+	priv = __sna_pixmap_for_gpu(sna, pixmap, flags);
+	if (priv == NULL)
+		return NULL;
+
 	assert(box->x2 > box->x1 && box->y2 > box->y1);
 	assert_pixmap_damage(pixmap);
 	assert_pixmap_contains_box(pixmap, box);
-	assert(!wedged(sna));
 	assert(priv->gpu_damage == NULL || priv->gpu_bo);
 
 	if (priv->cow && (flags & MOVE_WRITE || priv->cpu_damage)) {
@@ -2863,7 +2897,7 @@ sna_pixmap_move_area_to_gpu(PixmapPtr pixmap, const BoxRec *box, unsigned int fl
 		}
 
 		if (!sna_pixmap_undo_cow(sna, priv, cow))
-			return false;
+			return NULL;
 
 		if (priv->gpu_bo == NULL)
 			sna_damage_destroy(&priv->gpu_damage);
@@ -2921,7 +2955,7 @@ sna_pixmap_move_area_to_gpu(PixmapPtr pixmap, const BoxRec *box, unsigned int fl
 		}
 
 		if (priv->gpu_bo == NULL)
-			return false;
+			return NULL;
 
 		DBG(("%s: created gpu bo\n", __FUNCTION__));
 	}
@@ -2978,7 +3012,7 @@ sna_pixmap_move_area_to_gpu(PixmapPtr pixmap, const BoxRec *box, unsigned int fl
 							     box, n);
 				}
 				if (!ok)
-					return false;
+					return NULL;
 			}
 		}
 
@@ -3012,7 +3046,7 @@ sna_pixmap_move_area_to_gpu(PixmapPtr pixmap, const BoxRec *box, unsigned int fl
 					     box, 1);
 		}
 		if (!ok)
-			return false;
+			return NULL;
 
 		sna_damage_subtract(&priv->cpu_damage, &r);
 	} else if (sna_damage_intersect(priv->cpu_damage, &r, &i)) {
@@ -3043,7 +3077,7 @@ sna_pixmap_move_area_to_gpu(PixmapPtr pixmap, const BoxRec *box, unsigned int fl
 					     box, n);
 		}
 		if (!ok)
-			return false;
+			return NULL;
 
 		sna_damage_subtract(&priv->cpu_damage, &r);
 		RegionUninit(&i);
@@ -3071,7 +3105,7 @@ done:
 	}
 
 	assert(!priv->gpu_bo->proxy || (flags & MOVE_WRITE) == 0);
-	return sna_pixmap_mark_active(sna, priv) != NULL;
+	return sna_pixmap_mark_active(sna, priv);
 }
 
 struct kgem_bo *
@@ -3549,29 +3583,10 @@ sna_pixmap_move_to_gpu(PixmapPtr pixmap, unsigned flags)
 	     pixmap->usage_hint,
 	     flags));
 
-	if ((flags & __MOVE_FORCE) == 0 && wedged(sna))
+	priv = __sna_pixmap_for_gpu(sna, pixmap, flags);
+	if (priv == NULL)
 		return NULL;
 
-	priv = sna_pixmap(pixmap);
-	if (priv == NULL) {
-		DBG(("%s: not attached\n", __FUNCTION__));
-		if ((flags & __MOVE_DRI) == 0)
-			return NULL;
-
-		DBG(("%s: forcing the creation on the GPU\n", __FUNCTION__));
-
-		priv = sna_pixmap_attach(pixmap);
-		if (priv == NULL)
-			return NULL;
-
-		sna_damage_all(&priv->cpu_damage,
-			       pixmap->drawable.width,
-			       pixmap->drawable.height);
-
-		assert(priv->gpu_bo == NULL);
-		assert(priv->gpu_damage == NULL);
-	}
-
 	assert(priv->gpu_damage == NULL || priv->gpu_bo);
 
 	if ((flags & MOVE_READ) == 0 && UNDO) {
@@ -3583,7 +3598,7 @@ sna_pixmap_move_to_gpu(PixmapPtr pixmap, unsigned flags)
 
 	if (priv->cow && (flags & MOVE_WRITE || priv->cpu_damage)) {
 		if (!sna_pixmap_undo_cow(sna, priv, flags & MOVE_READ))
-			return false;
+			return NULL;
 
 		if (priv->gpu_bo == NULL)
 			sna_damage_destroy(&priv->gpu_damage);


More information about the xorg-commit mailing list