xf86-video-intel: configure.ac src/intel_device.c src/intel_module.c src/legacy/i810 src/sna/fb src/sna/gen3_render.c src/sna/gen4_render.c src/sna/gen5_render.c src/sna/gen6_render.c src/sna/gen7_render.c src/sna/sna_accel.c src/sna/sna_blt.c src/sna/sna_display.c src/sna/sna_dri.c src/sna/sna_driver.c src/sna/sna.h src/sna/sna_render.c src/sna/sna_stream.c src/sna/sna_threads.c src/sna/sna_vertex.c src/uxa/i830_3d.c src/uxa/i830_render.c src/uxa/i915_3d.c src/uxa/i915_render.c src/uxa/i915_video.c src/uxa/i965_render.c src/uxa/i965_video.c src/uxa/intel_batchbuffer.c src/uxa/intel_display.c src/uxa/intel_dri.c src/uxa/intel_driver.c src/uxa/intel_glamor.c src/uxa/intel.h src/uxa/intel_memory.c src/uxa/intel_uxa.c src/uxa/intel_video.c tools/virtual.c

Chris Wilson ickle at kemper.freedesktop.org
Wed Sep 18 04:53:32 PDT 2013


 configure.ac                  |   86 ++++++++++++++++------
 src/intel_device.c            |    2 
 src/intel_module.c            |    4 -
 src/legacy/i810/i810_accel.c  |    1 
 src/legacy/i810/i810_cursor.c |    1 
 src/legacy/i810/i810_dga.c    |    1 
 src/legacy/i810/i810_dri.c    |    1 
 src/legacy/i810/i810_driver.c |    1 
 src/legacy/i810/i810_hwmc.c   |    1 
 src/legacy/i810/i810_memory.c |    1 
 src/legacy/i810/i810_video.c  |    1 
 src/legacy/i810/i810_wmark.c  |    1 
 src/legacy/i810/i810_xaa.c    |    1 
 src/sna/fb/fbpict.h           |    1 
 src/sna/gen3_render.c         |   12 +++
 src/sna/gen4_render.c         |    4 +
 src/sna/gen5_render.c         |    4 +
 src/sna/gen6_render.c         |    4 +
 src/sna/gen7_render.c         |    4 +
 src/sna/sna.h                 |   10 --
 src/sna/sna_accel.c           |    3 
 src/sna/sna_blt.c             |    4 +
 src/sna/sna_display.c         |  145 ++++++++++++++++++++++++-------------
 src/sna/sna_dri.c             |  163 +++++++++++++++++++++++++++++++-----------
 src/sna/sna_driver.c          |   80 ++++++++++++++++++--
 src/sna/sna_render.c          |    6 +
 src/sna/sna_stream.c          |    4 +
 src/sna/sna_threads.c         |    4 +
 src/sna/sna_vertex.c          |    4 +
 src/uxa/i830_3d.c             |    1 
 src/uxa/i830_render.c         |    1 
 src/uxa/i915_3d.c             |    1 
 src/uxa/i915_render.c         |    1 
 src/uxa/i915_video.c          |    1 
 src/uxa/i965_render.c         |    1 
 src/uxa/i965_video.c          |    1 
 src/uxa/intel.h               |    2 
 src/uxa/intel_batchbuffer.c   |    1 
 src/uxa/intel_display.c       |    8 +-
 src/uxa/intel_dri.c           |   10 ++
 src/uxa/intel_driver.c        |    6 +
 src/uxa/intel_glamor.c        |    1 
 src/uxa/intel_memory.c        |    1 
 src/uxa/intel_uxa.c           |    1 
 src/uxa/intel_video.c         |    1 
 tools/virtual.c               |   26 ++++--
 46 files changed, 480 insertions(+), 138 deletions(-)

New commits:
commit dcf9b5ae1889926007cf8a0efd127e9df3c909de
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Sep 17 22:27:45 2013 +0100

    intel: Compile fixes for base install of SLED11.sp3
    
    Highlights of that distribution include xorg-xserver-1.6.5, kernel
    3.0.76 and gcc-4.3.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/configure.ac b/configure.ac
index 04ae1fd..7f4ba46 100644
--- a/configure.ac
+++ b/configure.ac
@@ -169,7 +169,43 @@ 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")
 
-AH_TOP([#include "xorg-server.h"])
+if test "x$tools" = "xyes"; then
+  AC_CHECK_HEADER(sys/ipc.h)
+  AC_CHECK_HEADER(sys/shm.h)
+
+  if test "$ac_cv_header_sys_ipc_h" = "yes" -a "$ac_cv_header_sys_shm_h" = "yes"; then
+      AC_MSG_CHECKING(whether shmctl IPC_RMID allowes subsequent attaches)
+      AC_TRY_RUN([
+		  #include <sys/types.h>
+		  #include <sys/ipc.h>
+		  #include <sys/shm.h>
+		  int main()
+		  {
+		      char *shmaddr;
+		      int id = shmget (IPC_PRIVATE, 4, IPC_CREAT | 0600);
+		      if (id == -1) return 2;
+		      shmaddr = shmat (id, 0, 0);
+		      shmctl (id, IPC_RMID, 0);
+		      if ((char*) shmat (id, 0, 0) == (char*) -1) {
+			  shmdt (shmaddr);
+			  return 1;
+		      }
+		      shmdt (shmaddr);
+		      shmdt (shmaddr);
+		      return 0;
+		  }
+		  ],
+		  AC_DEFINE(IPC_RMID_DEFERRED_RELEASE, 1,
+			    [Define to 1 if shared memory segments are released deferred.])
+		  AC_MSG_RESULT(yes),
+		  AC_MSG_RESULT(no),
+		  AC_MSG_RESULT(assuming no))
+      fi
+
+      AC_CHECK_HEADERS([X11/extensions/XShm.h X11/extensions/shmproto.h X11/extensions/shmstr.h], [], [],
+		       [#include <X11/Xlibint.h>
+			#include <X11/Xproto.h>])
+fi
 
 # Define a configure option for an alternate module directory
 AC_ARG_WITH(xorg-module-dir,
@@ -221,6 +257,16 @@ if pkg-config --exists 'pixman-1 >= 0.24.0'; then
 	AC_DEFINE([HAS_PIXMAN_TRIANGLES], 1, [Enable pixman triangle rasterisation])
 fi
 
+# Store the list of server defined optional extensions in REQUIRED_MODULES
+XORG_DRIVER_CHECK_EXT(RANDR, randrproto)
+XORG_DRIVER_CHECK_EXT(RENDER, renderproto)
+XORG_DRIVER_CHECK_EXT(XF86DRI, xextproto x11)
+XORG_DRIVER_CHECK_EXT(DPMSExtension, xextproto)
+
+# Obtain compiler/linker options for the driver dependencies
+PKG_CHECK_MODULES(DRM, [libdrm >= 2.4.20]) # libdrm_intel is checked separately
+PKG_CHECK_MODULES(PCIACCESS, [pciaccess >= 0.10])
+
 AC_ARG_ENABLE(sna,
 	      AS_HELP_STRING([--enable-sna],
 			     [Enable SandyBridge's New Acceleration (SNA) [default=auto]]),
@@ -231,9 +277,6 @@ if test "x$SNA" != "xno"; then
 	AC_DEFINE(USE_SNA, 1, [Enable SNA support])
 	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")
-AC_MSG_RESULT([$SNA])
 
 AC_ARG_ENABLE(uxa,
 	      AS_HELP_STRING([--enable-uxa],
@@ -254,18 +297,12 @@ 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")
 
-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"])
-AC_MSG_RESULT([$GLAMOR])
-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])
@@ -387,7 +424,10 @@ 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>
+#include <drm.h>
+])
 		CFLAGS=$save_CFLAGS
 	fi
 fi
@@ -406,6 +446,20 @@ else
 	UXA=no
 fi
 
+AC_CHECK_HEADERS([X11/extensions/dpmsconst.h])
+
+AC_MSG_CHECKING([whether to include UXA support])
+AC_MSG_RESULT([$UXA])
+AM_CONDITIONAL(UXA, test "x$UXA" != "xno")
+
+AC_MSG_CHECKING([whether to include GLAMOR support])
+AC_MSG_RESULT([$GLAMOR])
+AM_CONDITIONAL(GLAMOR, test "x$GLAMOR" != "xno")
+
+AC_MSG_CHECKING([whether to include SNA support])
+AM_CONDITIONAL(SNA, test "x$SNA" != "xno")
+AC_MSG_RESULT([$SNA])
+
 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"])
@@ -525,16 +579,6 @@ AC_ARG_ENABLE(valgrind,
               [VG="$enableval"],
               [VG="no"])
 
-# Store the list of server defined optional extensions in REQUIRED_MODULES
-XORG_DRIVER_CHECK_EXT(RANDR, randrproto)
-XORG_DRIVER_CHECK_EXT(RENDER, renderproto)
-XORG_DRIVER_CHECK_EXT(XF86DRI, xextproto x11)
-XORG_DRIVER_CHECK_EXT(DPMSExtension, xextproto)
-
-# Obtain compiler/linker options for the driver dependencies
-PKG_CHECK_MODULES(DRM, [libdrm >= 2.4.20]) # libdrm_intel is checked separately
-PKG_CHECK_MODULES(PCIACCESS, [pciaccess >= 0.10])
-
 LIBS=""
 AC_SEARCH_LIBS(clock_gettime, rt, [CLOCK_GETTIME_LIBS=$LIBS])
 AC_SUBST(CLOCK_GETTIME_LIBS)
diff --git a/src/intel_device.c b/src/intel_device.c
index b3926df..92472c5 100644
--- a/src/intel_device.c
+++ b/src/intel_device.c
@@ -40,6 +40,8 @@
 #include <sys/ioctl.h>
 
 #include <pciaccess.h>
+
+#include <xorg-server.h>
 #include <xf86.h>
 #include <xf86drm.h>
 #include <xf86drmMode.h>
diff --git a/src/intel_module.c b/src/intel_module.c
index f61b688..ca8eacd 100644
--- a/src/intel_module.c
+++ b/src/intel_module.c
@@ -28,9 +28,11 @@
 #include "config.h"
 #endif
 
+#include <xorg-server.h>
+#include <xorgVersion.h>
+
 #include <xf86.h>
 #include <xf86Parser.h>
-#include <xorgVersion.h>
 
 #if XORG_VERSION_CURRENT < XORG_VERSION_NUMERIC(1,6,99,0,0)
 #include <xf86Resources.h>
diff --git a/src/legacy/i810/i810_accel.c b/src/legacy/i810/i810_accel.c
index aa2c4df..caf68d9 100644
--- a/src/legacy/i810/i810_accel.c
+++ b/src/legacy/i810/i810_accel.c
@@ -36,6 +36,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  *
  */
 
+#include "xorg-server.h"
 #include "xf86.h"
 #include "xaarop.h"
 #include "i810.h"
diff --git a/src/legacy/i810/i810_cursor.c b/src/legacy/i810/i810_cursor.c
index 580fe4b..2ac03e9 100644
--- a/src/legacy/i810/i810_cursor.c
+++ b/src/legacy/i810/i810_cursor.c
@@ -39,6 +39,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  *
  */
 
+#include "xorg-server.h"
 #include "xf86.h"
 #include "xf86_OSproc.h"
 #include "compiler.h"
diff --git a/src/legacy/i810/i810_dga.c b/src/legacy/i810/i810_dga.c
index 81e1767..bbdf7b3 100644
--- a/src/legacy/i810/i810_dga.c
+++ b/src/legacy/i810/i810_dga.c
@@ -26,6 +26,7 @@
 #include "config.h"
 #endif
 
+#include "xorg-server.h"
 #include "xf86.h"
 #include "xf86_OSproc.h"
 #include "xf86Pci.h"
diff --git a/src/legacy/i810/i810_dri.c b/src/legacy/i810/i810_dri.c
index 26ad855..cca35d6 100644
--- a/src/legacy/i810/i810_dri.c
+++ b/src/legacy/i810/i810_dri.c
@@ -7,6 +7,7 @@
 #include <string.h>
 #include <assert.h>
 
+#include "xorg-server.h"
 #include "xf86.h"
 #include "xf86_OSproc.h"
 
diff --git a/src/legacy/i810/i810_driver.c b/src/legacy/i810/i810_driver.c
index 9f684d2..d647cb3 100644
--- a/src/legacy/i810/i810_driver.c
+++ b/src/legacy/i810/i810_driver.c
@@ -53,6 +53,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 /*
  * These are X and server generic header files.
  */
+#include "xorg-server.h"
 #include "xf86.h"
 #include "xf86_OSproc.h"
 #include "xf86cmap.h"
diff --git a/src/legacy/i810/i810_hwmc.c b/src/legacy/i810/i810_hwmc.c
index 4d3bd1a..7cb9c1a 100644
--- a/src/legacy/i810/i810_hwmc.c
+++ b/src/legacy/i810/i810_hwmc.c
@@ -39,6 +39,7 @@ THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #include <string.h>
 
+#include "xorg-server.h"
 #include "xf86.h"
 #include "xf86_OSproc.h"
 #include "compiler.h"
diff --git a/src/legacy/i810/i810_memory.c b/src/legacy/i810/i810_memory.c
index f57ddbe..bd7c8db 100644
--- a/src/legacy/i810/i810_memory.c
+++ b/src/legacy/i810/i810_memory.c
@@ -35,6 +35,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  *
  */
 
+#include "xorg-server.h"
 #include "xf86.h"
 #include "xf86_OSproc.h"
 
diff --git a/src/legacy/i810/i810_video.c b/src/legacy/i810/i810_video.c
index bbaa3ce..be49b91 100644
--- a/src/legacy/i810/i810_video.c
+++ b/src/legacy/i810/i810_video.c
@@ -39,6 +39,7 @@ THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #include <string.h>
 
+#include "xorg-server.h"
 #include "xf86.h"
 #include "xf86_OSproc.h"
 #include "compiler.h"
diff --git a/src/legacy/i810/i810_wmark.c b/src/legacy/i810/i810_wmark.c
index 71b2a82..de4365b 100644
--- a/src/legacy/i810/i810_wmark.c
+++ b/src/legacy/i810/i810_wmark.c
@@ -34,6 +34,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "config.h"
 #endif
 
+#include "xorg-server.h"
 #include "xf86.h"
 #include "i810.h"
 
diff --git a/src/legacy/i810/i810_xaa.c b/src/legacy/i810/i810_xaa.c
index 13f0dc2..ea03441 100644
--- a/src/legacy/i810/i810_xaa.c
+++ b/src/legacy/i810/i810_xaa.c
@@ -36,6 +36,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  *
  */
 
+#include "xorg-server.h"
 #include "xf86.h"
 #include "xaarop.h"
 #include "i810.h"
diff --git a/src/sna/fb/fbpict.h b/src/sna/fb/fbpict.h
index 5601385..932032f 100644
--- a/src/sna/fb/fbpict.h
+++ b/src/sna/fb/fbpict.h
@@ -28,6 +28,7 @@
 #include "config.h"
 #endif
 
+#include <xorg-server.h>
 #include <picturestr.h>
 
 #include "sfb.h"
diff --git a/src/sna/gen3_render.c b/src/sna/gen3_render.c
index c7f9512..63dd5cc 100644
--- a/src/sna/gen3_render.c
+++ b/src/sna/gen3_render.c
@@ -108,8 +108,10 @@ static const struct formatinfo {
 	{PICT_x8r8g8b8, 0, MAPSURF_32BIT | MT_32BIT_XRGB8888, false},
 	{PICT_a8b8g8r8, 0, MAPSURF_32BIT | MT_32BIT_ABGR8888, false},
 	{PICT_x8b8g8r8, 0, MAPSURF_32BIT | MT_32BIT_XBGR8888, false},
+#ifdef PICT_a2r10g10b10
 	{PICT_a2r10g10b10, PICT_x2r10g10b10, MAPSURF_32BIT | MT_32BIT_ARGB2101010, false},
 	{PICT_a2b10g10r10, PICT_x2b10g10r10, MAPSURF_32BIT | MT_32BIT_ABGR2101010, false},
+#endif
 	{PICT_r5g6b5, 0, MAPSURF_16BIT | MT_16BIT_RGB565, false},
 	{PICT_b5g6r5, 0, MAPSURF_16BIT | MT_16BIT_RGB565, true},
 	{PICT_a1r5g5b5, PICT_x1r5g5b5, MAPSURF_16BIT | MT_16BIT_ARGB1555, false},
@@ -206,10 +208,12 @@ static bool gen3_check_dst_format(uint32_t format)
 	case PICT_x1r5g5b5:
 	case PICT_a1b5g5r5:
 	case PICT_x1b5g5r5:
+#ifdef PICT_a2r10g10b10
 	case PICT_a2r10g10b10:
 	case PICT_x2r10g10b10:
 	case PICT_a2b10g10r10:
 	case PICT_x2b10g10r10:
+#endif
 	case PICT_a8:
 	case PICT_a4r4g4b4:
 	case PICT_x4r4g4b4:
@@ -229,8 +233,10 @@ static bool gen3_dst_rb_reversed(uint32_t format)
 	case PICT_r5g6b5:
 	case PICT_a1r5g5b5:
 	case PICT_x1r5g5b5:
+#ifdef PICT_a2r10g10b10
 	case PICT_a2r10g10b10:
 	case PICT_x2r10g10b10:
+#endif
 	case PICT_a8:
 	case PICT_a4r4g4b4:
 	case PICT_x4r4g4b4:
@@ -261,11 +267,13 @@ static uint32_t gen3_get_dst_format(uint32_t format)
 	case PICT_a1b5g5r5:
 	case PICT_x1b5g5r5:
 		return BIAS | COLR_BUF_ARGB1555;
+#ifdef PICT_a2r10g10b10
 	case PICT_a2r10g10b10:
 	case PICT_x2r10g10b10:
 	case PICT_a2b10g10r10:
 	case PICT_x2b10g10r10:
 		return BIAS | COLR_BUF_ARGB2AAA;
+#endif
 	case PICT_a8:
 		return BIAS | COLR_BUF_8BIT;
 	case PICT_a4r4g4b4:
@@ -285,8 +293,10 @@ static bool gen3_check_format(PicturePtr p)
 	case PICT_x8r8g8b8:
 	case PICT_a8b8g8r8:
 	case PICT_x8b8g8r8:
+#ifdef PICT_a2r10g10b10
 	case PICT_a2r10g10b10:
 	case PICT_a2b10g10r10:
+#endif
 	case PICT_r5g6b5:
 	case PICT_b5g6r5:
 	case PICT_a1r5g5b5:
@@ -312,10 +322,12 @@ static bool gen3_check_xformat(PicturePtr p)
 	case PICT_x1r5g5b5:
 	case PICT_a1b5g5r5:
 	case PICT_x1b5g5r5:
+#ifdef PICT_a2r10g10b10
 	case PICT_a2r10g10b10:
 	case PICT_x2r10g10b10:
 	case PICT_a2b10g10r10:
 	case PICT_x2b10g10r10:
+#endif
 	case PICT_a8:
 	case PICT_a4r4g4b4:
 	case PICT_x4r4g4b4:
diff --git a/src/sna/gen4_render.c b/src/sna/gen4_render.c
index 3158b58..973d606 100644
--- a/src/sna/gen4_render.c
+++ b/src/sna/gen4_render.c
@@ -293,10 +293,12 @@ static uint32_t gen4_get_card_format(PictFormat format)
 		return GEN4_SURFACEFORMAT_R8G8B8A8_UNORM;
 	case PICT_x8b8g8r8:
 		return GEN4_SURFACEFORMAT_R8G8B8X8_UNORM;
+#ifdef PICT_a2r10g10b10
 	case PICT_a2r10g10b10:
 		return GEN4_SURFACEFORMAT_B10G10R10A2_UNORM;
 	case PICT_x2r10g10b10:
 		return GEN4_SURFACEFORMAT_B10G10R10X2_UNORM;
+#endif
 	case PICT_r8g8b8:
 		return GEN4_SURFACEFORMAT_R8G8B8_UNORM;
 	case PICT_r5g6b5:
@@ -321,9 +323,11 @@ static uint32_t gen4_get_dest_format(PictFormat format)
 	case PICT_a8b8g8r8:
 	case PICT_x8b8g8r8:
 		return GEN4_SURFACEFORMAT_R8G8B8A8_UNORM;
+#ifdef PICT_a2r10g10b10
 	case PICT_a2r10g10b10:
 	case PICT_x2r10g10b10:
 		return GEN4_SURFACEFORMAT_B10G10R10A2_UNORM;
+#endif
 	case PICT_r5g6b5:
 		return GEN4_SURFACEFORMAT_B5G6R5_UNORM;
 	case PICT_x1r5g5b5:
diff --git a/src/sna/gen5_render.c b/src/sna/gen5_render.c
index 9b469f3..7e336f0 100644
--- a/src/sna/gen5_render.c
+++ b/src/sna/gen5_render.c
@@ -282,10 +282,12 @@ static uint32_t gen5_get_card_format(PictFormat format)
 		return GEN5_SURFACEFORMAT_R8G8B8A8_UNORM;
 	case PICT_x8b8g8r8:
 		return GEN5_SURFACEFORMAT_R8G8B8X8_UNORM;
+#ifdef PICT_a2r10g10b10
 	case PICT_a2r10g10b10:
 		return GEN5_SURFACEFORMAT_B10G10R10A2_UNORM;
 	case PICT_x2r10g10b10:
 		return GEN5_SURFACEFORMAT_B10G10R10X2_UNORM;
+#endif
 	case PICT_r8g8b8:
 		return GEN5_SURFACEFORMAT_R8G8B8_UNORM;
 	case PICT_r5g6b5:
@@ -310,9 +312,11 @@ static uint32_t gen5_get_dest_format(PictFormat format)
 	case PICT_a8b8g8r8:
 	case PICT_x8b8g8r8:
 		return GEN5_SURFACEFORMAT_R8G8B8A8_UNORM;
+#ifdef PICT_a2r10g10b10
 	case PICT_a2r10g10b10:
 	case PICT_x2r10g10b10:
 		return GEN5_SURFACEFORMAT_B10G10R10A2_UNORM;
+#endif
 	case PICT_r5g6b5:
 		return GEN5_SURFACEFORMAT_B5G6R5_UNORM;
 	case PICT_x1r5g5b5:
diff --git a/src/sna/gen6_render.c b/src/sna/gen6_render.c
index 70821f7..1f15091 100644
--- a/src/sna/gen6_render.c
+++ b/src/sna/gen6_render.c
@@ -258,10 +258,12 @@ static uint32_t gen6_get_card_format(PictFormat format)
 		return GEN6_SURFACEFORMAT_R8G8B8A8_UNORM;
 	case PICT_x8b8g8r8:
 		return GEN6_SURFACEFORMAT_R8G8B8X8_UNORM;
+#ifdef PICT_a2r10g10b10
 	case PICT_a2r10g10b10:
 		return GEN6_SURFACEFORMAT_B10G10R10A2_UNORM;
 	case PICT_x2r10g10b10:
 		return GEN6_SURFACEFORMAT_B10G10R10X2_UNORM;
+#endif
 	case PICT_r8g8b8:
 		return GEN6_SURFACEFORMAT_R8G8B8_UNORM;
 	case PICT_r5g6b5:
@@ -286,9 +288,11 @@ static uint32_t gen6_get_dest_format(PictFormat format)
 	case PICT_a8b8g8r8:
 	case PICT_x8b8g8r8:
 		return GEN6_SURFACEFORMAT_R8G8B8A8_UNORM;
+#ifdef PICT_a2r10g10b10
 	case PICT_a2r10g10b10:
 	case PICT_x2r10g10b10:
 		return GEN6_SURFACEFORMAT_B10G10R10A2_UNORM;
+#endif
 	case PICT_r5g6b5:
 		return GEN6_SURFACEFORMAT_B5G6R5_UNORM;
 	case PICT_x1r5g5b5:
diff --git a/src/sna/gen7_render.c b/src/sna/gen7_render.c
index 53d3688..6f2e3ab 100644
--- a/src/sna/gen7_render.c
+++ b/src/sna/gen7_render.c
@@ -347,10 +347,12 @@ static uint32_t gen7_get_card_format(PictFormat format)
 		return GEN7_SURFACEFORMAT_R8G8B8A8_UNORM;
 	case PICT_x8b8g8r8:
 		return GEN7_SURFACEFORMAT_R8G8B8X8_UNORM;
+#ifdef PICT_a2r10g10b10
 	case PICT_a2r10g10b10:
 		return GEN7_SURFACEFORMAT_B10G10R10A2_UNORM;
 	case PICT_x2r10g10b10:
 		return GEN7_SURFACEFORMAT_B10G10R10X2_UNORM;
+#endif
 	case PICT_r8g8b8:
 		return GEN7_SURFACEFORMAT_R8G8B8_UNORM;
 	case PICT_r5g6b5:
@@ -375,9 +377,11 @@ static uint32_t gen7_get_dest_format(PictFormat format)
 	case PICT_a8b8g8r8:
 	case PICT_x8b8g8r8:
 		return GEN7_SURFACEFORMAT_R8G8B8A8_UNORM;
+#ifdef PICT_a2r10g10b10
 	case PICT_a2r10g10b10:
 	case PICT_x2r10g10b10:
 		return GEN7_SURFACEFORMAT_B10G10R10A2_UNORM;
+#endif
 	case PICT_r5g6b5:
 		return GEN7_SURFACEFORMAT_B5G6R5_UNORM;
 	case PICT_x1r5g5b5:
diff --git a/src/sna/sna.h b/src/sna/sna.h
index 32d9ef3..d29ee1d 100644
--- a/src/sna/sna.h
+++ b/src/sna/sna.h
@@ -37,22 +37,16 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #ifndef _SNA_H_
 #define _SNA_H_
 
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
 #include <stdint.h>
 
-#include "compiler.h"
-
 #include <xorg-server.h>
+#include <xf86str.h>
 
 #include <xf86Crtc.h>
 #if XF86_CRTC_VERSION >= 5
 #define HAS_PIXMAP_SHARING 1
 #endif
 
-#include <xf86str.h>
 #include <windowstr.h>
 #include <glyphstr.h>
 #include <picturestr.h>
@@ -75,6 +69,8 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include <libudev.h>
 #endif
 
+#include "compiler.h"
+
 #if HAS_DEBUG_FULL
 #define DBG(x) ErrorF x
 #else
diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c
index 713f98d..bf7cb9c 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -29,12 +29,13 @@
 #include "config.h"
 #endif
 
-#include "intel_options.h"
 #include "sna.h"
 #include "sna_reg.h"
 #include "sna_video.h"
 #include "rop.h"
 
+#include "intel_options.h"
+
 #include <X11/fonts/font.h>
 #include <X11/fonts/fontstruct.h>
 
diff --git a/src/sna/sna_blt.c b/src/sna/sna_blt.c
index 94d8458..1f173da 100644
--- a/src/sna/sna_blt.c
+++ b/src/sna/sna_blt.c
@@ -44,6 +44,10 @@
 #define NO_BLT_FILL 0
 #define NO_BLT_FILL_BOXES 0
 
+#ifndef PICT_TYPE_BGRA
+#define PICT_TYPE_BGRA 8
+#endif
+
 static const uint8_t copy_ROP[] = {
 	ROP_0,                  /* GXclear */
 	ROP_DSa,                /* GXand */
diff --git a/src/sna/sna_display.c b/src/sna/sna_display.c
index 7b1684f..bfb95a0 100644
--- a/src/sna/sna_display.c
+++ b/src/sna/sna_display.c
@@ -39,21 +39,37 @@
 #include <poll.h>
 #include <ctype.h>
 
-#include <xorgVersion.h>
+#include "sna.h"
+#include "sna_reg.h"
+#include "fb/fbpict.h"
+
+#include <xf86Crtc.h>
+
+#if XF86_CRTC_VERSION >= 3
+#define HAS_GAMMA 1
+#else
+#define HAS_GAMMA 0
+#endif
+
 #include <X11/Xatom.h>
+#if defined(HAVE_X11_EXTENSIONS_DPMSCONST_H)
 #include <X11/extensions/dpmsconst.h>
+#else
+#define DPMSModeOn 0
+#define DPMSModeOff 3
+#endif
 #include <xf86drm.h>
 #include <xf86DDC.h> /* for xf86InterpretEDID */
 #include <xf86Opt.h> /* for xf86OptionPtr */
 
-#include "sna.h"
-#include "sna_reg.h"
-#include "fb/fbpict.h"
-
 #include "intel_options.h"
 
 #define KNOWN_MODE_FLAGS ((1<<14)-1)
 
+#ifndef MONITOR_EDID_COMPLETE_RAWDATA
+#define MONITOR_EDID_COMPLETE_RAWDATA 1
+#endif
+
 #ifndef DEFAULT_DPI
 #define DEFAULT_DPI 96
 #endif
@@ -1426,11 +1442,13 @@ sna_crtc_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode,
 	assert(mode->HDisplay <= sna->mode.kmode->max_width &&
 	       mode->VDisplay <= sna->mode.kmode->max_height);
 
+#if HAS_GAMMA
 	drmModeCrtcSetGamma(sna->kgem.fd, sna_crtc->id,
 			    crtc->gamma_size,
 			    crtc->gamma_red,
 			    crtc->gamma_green,
 			    crtc->gamma_blue);
+#endif
 
 	saved_kmode = sna_crtc->kmode;
 	saved_bo = sna_crtc->bo;
@@ -1634,7 +1652,9 @@ sna_crtc_set_scanout_pixmap(xf86CrtcPtr crtc, PixmapPtr pixmap)
 #endif
 
 static const xf86CrtcFuncsRec sna_crtc_funcs = {
+#if XF86_CRTC_VERSION >= 1
 	.dpms = sna_crtc_dpms,
+#endif
 	.set_mode_major = sna_crtc_set_mode_major,
 	.set_cursor_colors = sna_crtc_set_cursor_colors,
 	.set_cursor_position = sna_crtc_set_cursor_position,
@@ -1945,6 +1965,16 @@ done:
 }
 
 static DisplayModePtr
+default_modes(void)
+{
+#if XORG_VERSION_CURRENT >= XORG_VERSION_NUMERIC(1,6,99,900,0)
+	return xf86GetDefaultModes();
+#else
+	return xf86GetDefaultModes(0, 0);
+#endif
+}
+
+static DisplayModePtr
 sna_output_panel_edid(xf86OutputPtr output, DisplayModePtr modes)
 {
 	xf86MonPtr mon = output->MonInfo;
@@ -1966,7 +1996,7 @@ sna_output_panel_edid(xf86OutputPtr output, DisplayModePtr modes)
 	max_vrefresh = max(max_vrefresh, 60.0);
 	max_vrefresh *= (1 + SYNC_TOLERANCE);
 
-	m = xf86GetDefaultModes();
+	m = default_modes();
 	xf86ValidateModesSize(output->scrn, m, max_x, max_y, 0);
 
 	for (i = m; i; i = i->next) {
@@ -2945,6 +2975,7 @@ enum { /* XXX copied from hw/xfree86/modes/xf86Crtc.c */
 	OPTION_DEFAULT_MODES,
 };
 
+#if HAS_GAMMA
 static void set_gamma(uint16_t *curve, int size, double value)
 {
 	int i;
@@ -2954,7 +2985,7 @@ static void set_gamma(uint16_t *curve, int size, double value)
 		curve[i] = 256*(size-1)*pow(i/(double)(size-1), value);
 }
 
-static void set_initial_gamma(xf86OutputPtr output, xf86CrtcPtr crtc)
+static void output_set_gamma(xf86OutputPtr output, xf86CrtcPtr crtc)
 {
 	XF86ConfMonitorPtr mon = output->conf_monitor;
 
@@ -2983,6 +3014,60 @@ static void set_initial_gamma(xf86OutputPtr output, xf86CrtcPtr crtc)
 			  mon->mon_gamma_blue);
 }
 
+static void crtc_init_gamma(xf86CrtcPtr crtc)
+{
+	uint16_t *gamma;
+
+	/* Initialize the gamma ramps */
+	gamma = NULL;
+	if (crtc->gamma_size == 256)
+		gamma = crtc->gamma_red;
+	if (gamma == NULL)
+		gamma = malloc(3 * 256 * sizeof(uint16_t));
+	if (gamma) {
+		struct sna *sna = to_sna(crtc->scrn);
+		struct sna_crtc *sna_crtc = to_sna_crtc(crtc);
+		struct drm_mode_crtc_lut lut;
+		bool gamma_set = false;
+
+		lut.crtc_id = sna_crtc->id;
+		lut.gamma_size = 256;
+		lut.red = (uintptr_t)(gamma);
+		lut.green = (uintptr_t)(gamma + 256);
+		lut.blue = (uintptr_t)(gamma + 2 * 256);
+		if (drmIoctl(sna->kgem.fd, DRM_IOCTL_MODE_GETGAMMA, &lut) == 0) {
+			gamma_set =
+				gamma[256 - 1] &&
+				gamma[2*256 - 1] &&
+				gamma[3*256 - 1];
+		}
+
+		DBG(("%s: CRTC:%d, pipe=%d: gamma set?=%d\n",
+		     __FUNCTION__, sna_crtc->id, sna_crtc->pipe,
+		     gamma_set));
+		if (!gamma_set) {
+			int i;
+
+			for (i = 0; i < 256; i++) {
+				gamma[i] = i << 8;
+				gamma[256 + i] = i << 8;
+				gamma[2*256 + i] = i << 8;
+			}
+		}
+
+		if (gamma != crtc->gamma_red) {
+			free(crtc->gamma_red);
+			crtc->gamma_red = gamma;
+			crtc->gamma_green = gamma + 256;
+			crtc->gamma_blue = gamma + 2*256;
+		}
+	}
+}
+#else
+static void output_set_gamma(xf86OutputPtr output, xf86CrtcPtr crtc) { }
+static void crtc_init_gamma(xf86CrtcPtr crtc) { }
+#endif
+
 static bool sna_probe_initial_configuration(struct sna *sna)
 {
 	ScrnInfoPtr scrn = sna->scrn;
@@ -3036,7 +3121,6 @@ static bool sna_probe_initial_configuration(struct sna *sna)
 		xf86CrtcPtr crtc = config->crtc[i];
 		struct sna_crtc *sna_crtc = to_sna_crtc(crtc);
 		struct drm_mode_crtc mode;
-		uint16_t *gamma;
 
 		if (sna_crtc == NULL)
 			continue;
@@ -3044,46 +3128,7 @@ static bool sna_probe_initial_configuration(struct sna *sna)
 		crtc->enabled = FALSE;
 		crtc->desiredMode.status = MODE_NOMODE;
 
-		/* Initialize the gamma ramps */
-		gamma = NULL;
-		if (crtc->gamma_size == 256)
-			gamma = crtc->gamma_red;
-		if (gamma == NULL)
-			gamma = malloc(3 * 256 * sizeof(uint16_t));
-		if (gamma) {
-			struct drm_mode_crtc_lut lut;
-			bool gamma_set = false;
-
-			lut.crtc_id = sna_crtc->id;
-			lut.gamma_size = 256;
-			lut.red = (uintptr_t)(gamma);
-			lut.green = (uintptr_t)(gamma + 256);
-			lut.blue = (uintptr_t)(gamma + 2 * 256);
-			if (drmIoctl(sna->kgem.fd, DRM_IOCTL_MODE_GETGAMMA, &lut) == 0) {
-				gamma_set =
-					gamma[256 - 1] &&
-					gamma[2*256 - 1] &&
-					gamma[3*256 - 1];
-			}
-
-			DBG(("%s: CRTC:%d, pipe=%d: gamma set?=%d\n",
-			     __FUNCTION__, sna_crtc->id, sna_crtc->pipe,
-			     gamma_set));
-			if (!gamma_set) {
-				for (j = 0; j < 256; j++) {
-					gamma[j] = j << 8;
-					gamma[256 + j] = j << 8;
-					gamma[2*256 + j] = j << 8;
-				}
-			}
-
-			if (gamma != crtc->gamma_red) {
-				free(crtc->gamma_red);
-				crtc->gamma_red = gamma;
-				crtc->gamma_green = gamma + 256;
-				crtc->gamma_blue = gamma + 2*256;
-			}
-		}
+		crtc_init_gamma(crtc);
 
 		/* Retrieve the current mode */
 		VG_CLEAR(mode);
@@ -3145,7 +3190,7 @@ static bool sna_probe_initial_configuration(struct sna *sna)
 					output->mm_width = (crtc->desiredMode.HDisplay * 254) / (10*DEFAULT_DPI);
 				}
 
-				set_initial_gamma(output, crtc);
+				output_set_gamma(output, crtc);
 
 				M = calloc(1, sizeof(DisplayModeRec));
 				if (M) {
@@ -3700,7 +3745,9 @@ void sna_mode_update(struct sna *sna)
 		if (sna_crtc == NULL)
 			continue;
 
+#if XF86_CRTC_VERSION >= 3
 		assert(sna_crtc->bo == NULL || crtc->active);
+#endif
 		expected = sna_crtc->bo ? fb_id(sna_crtc->bo) : 0;
 
 		VG_CLEAR(mode);
diff --git a/src/sna/sna_dri.c b/src/sna/sna_dri.c
index 4c5476e..6584e66 100644
--- a/src/sna/sna_dri.c
+++ b/src/sna/sna_dri.c
@@ -48,9 +48,11 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include <xf86drm.h>
 #include <i915_drm.h>
 #include <dri2.h>
+#if XORG_VERSION_CURRENT >= XORG_VERSION_NUMERIC(1,12,99,901,0)
 #include <compositeext.h>
+#endif
 
-#if DRI2INFOREC_VERSION <= 2
+#if DRI2INFOREC_VERSION < 2
 #error DRI2 version supported by the Xserver is too old
 #endif
 
@@ -70,34 +72,6 @@ enum frame_event_type {
 	DRI2_FLIP_THROTTLE,
 };
 
-struct sna_dri_frame_event {
-	DrawablePtr draw;
-	ClientPtr client;
-	enum frame_event_type type;
-	int pipe;
-	int count;
-
-	/* for swaps & flips only */
-	DRI2SwapEventPtr event_complete;
-	void *event_data;
-	DRI2BufferPtr front;
-	DRI2BufferPtr back;
-	struct kgem_bo *bo;
-
-	struct sna_dri_frame_event *chain;
-
-	unsigned int fe_frame;
-	unsigned int fe_tv_sec;
-	unsigned int fe_tv_usec;
-
-	struct dri_bo {
-		struct kgem_bo *bo;
-		uint32_t name;
-	} scanout[2], cache;
-
-	int mode;
-};
-
 struct sna_dri_private {
 	PixmapPtr pixmap;
 	struct kgem_bo *bo;
@@ -106,16 +80,10 @@ struct sna_dri_private {
 	int refcnt;
 };
 
-static inline struct sna_dri_frame_event *
-to_frame_event(uintptr_t  data)
-{
-	 return (struct sna_dri_frame_event *)(data & ~1);
-}
-
 static inline struct sna_dri_private *
-get_private(DRI2Buffer2Ptr buffer)
+get_private(void *buffer)
 {
-	return (struct sna_dri_private *)(buffer+1);
+	return (struct sna_dri_private *)((DRI2Buffer2Ptr)buffer+1);
 }
 
 static inline struct kgem_bo *ref(struct kgem_bo *bo)
@@ -208,7 +176,7 @@ static inline void sna_pixmap_set_buffer(PixmapPtr pixmap, void *ptr)
 void
 sna_dri_pixmap_update_bo(struct sna *sna, PixmapPtr pixmap)
 {
-	DRI2Buffer2Ptr buffer;
+	DRI2BufferPtr buffer;
 	struct sna_dri_private *private;
 	struct kgem_bo *bo;
 
@@ -481,7 +449,7 @@ static void sna_dri_destroy_buffer(DrawablePtr draw, DRI2Buffer2Ptr buffer)
 	_sna_dri_destroy_buffer(to_sna_from_drawable(draw), buffer);
 }
 
-static void sna_dri_reference_buffer(DRI2Buffer2Ptr buffer)
+static void sna_dri_reference_buffer(DRI2BufferPtr buffer)
 {
 	get_private(buffer)->refcnt++;
 }
@@ -647,7 +615,7 @@ sna_dri_copy_fallback(struct sna *sna, int bpp,
 
 static struct kgem_bo *
 __sna_dri_copy_region(struct sna *sna, DrawablePtr draw, RegionPtr region,
-		      DRI2Buffer2Ptr src, DRI2Buffer2Ptr dst,
+		      DRI2BufferPtr src, DRI2BufferPtr dst,
 		      bool sync)
 {
 	PixmapPtr pixmap = get_drawable_pixmap(draw);
@@ -886,6 +854,41 @@ static inline int sna_wait_vblank(struct sna *sna, drmVBlank *vbl)
 
 #if DRI2INFOREC_VERSION >= 4
 
+struct sna_dri_frame_event {
+	DrawablePtr draw;
+	ClientPtr client;
+	enum frame_event_type type;
+	int pipe;
+	int count;
+
+	/* for swaps & flips only */
+	DRI2SwapEventPtr event_complete;
+	void *event_data;
+	DRI2BufferPtr front;
+	DRI2BufferPtr back;
+	struct kgem_bo *bo;
+
+	struct sna_dri_frame_event *chain;
+
+	unsigned int fe_frame;
+	unsigned int fe_tv_sec;
+	unsigned int fe_tv_usec;
+
+	struct dri_bo {
+		struct kgem_bo *bo;
+		uint32_t name;
+	} scanout[2], cache;
+
+	int mode;
+};
+
+
+static inline struct sna_dri_frame_event *
+to_frame_event(uintptr_t  data)
+{
+	 return (struct sna_dri_frame_event *)(data & ~1);
+}
+
 static int
 sna_dri_get_pipe(DrawablePtr draw)
 {
@@ -2253,6 +2256,8 @@ out_complete:
 	DRI2WaitMSCComplete(client, draw, target_msc, 0, 0);
 	return TRUE;
 }
+#else
+void sna_dri_destroy_window(WindowPtr win) { }
 #endif
 
 static bool has_i830_dri(void)
@@ -2260,12 +2265,79 @@ static bool has_i830_dri(void)
 	return access(DRI_DRIVER_PATH "/i830_dri.so", R_OK) == 0;
 }
 
+static int
+namecmp(const char *s1, const char *s2)
+{
+	char c1, c2;
+
+	if (!s1 || *s1 == 0) {
+		if (!s2 || *s2 == 0)
+			return 0;
+		else
+			return 1;
+	}
+
+	while (*s1 == '_' || *s1 == ' ' || *s1 == '\t')
+		s1++;
+
+	while (*s2 == '_' || *s2 == ' ' || *s2 == '\t')
+		s2++;
+
+	c1 = isupper(*s1) ? tolower(*s1) : *s1;
+	c2 = isupper(*s2) ? tolower(*s2) : *s2;
+	while (c1 == c2) {
+		if (c1 == '\0')
+			return 0;
+
+		s1++;
+		while (*s1 == '_' || *s1 == ' ' || *s1 == '\t')
+			s1++;
+
+		s2++;
+		while (*s2 == '_' || *s2 == ' ' || *s2 == '\t')
+			s2++;
+
+		c1 = isupper(*s1) ? tolower(*s1) : *s1;
+		c2 = isupper(*s2) ? tolower(*s2) : *s2;
+	}
+
+	return c1 - c2;
+}
+
+static bool is_bool(const char *str)
+{
+	if (str == NULL)
+		return true;
+
+	if (*str == '\0')
+		return true;
+
+	if (namecmp(str, "1") == 0)
+		return true;
+	if (namecmp(str, "on") == 0)
+		return true;
+	if (namecmp(str, "true") == 0)
+		return true;
+	if (namecmp(str, "yes") == 0)
+		return true;
+
+	if (namecmp(str, "0") == 0)
+		return true;
+	if (namecmp(str, "off") == 0)
+		return true;
+	if (namecmp(str, "false") == 0)
+		return true;
+	if (namecmp(str, "no") == 0)
+		return true;
+
+	return false;
+}
+
 static const char *dri_driver_name(struct sna *sna)
 {
 	const char *s = xf86GetOptValString(sna->Options, OPTION_DRI);
-	Bool dummy;
 
-	if (s == NULL || xf86getBoolValue(&dummy, s)) {
+	if (is_bool(s)) {
 		if (sna->kgem.gen < 030)
 			return has_i830_dri() ? "i830" : "i915";
 		else if (sna->kgem.gen < 040)
@@ -2309,7 +2381,14 @@ bool sna_dri_open(struct sna *sna, ScreenPtr screen)
 	DBG(("%s: loading dri driver '%s' [gen=%d] for device '%s'\n",
 	     __FUNCTION__, info.driverName, sna->kgem.gen, info.deviceName));
 
+#if DRI2INFOREC_VERSION == 2
+	/* The ABI between 2 and 3 was broken so we could get rid of
+	 * the multi-buffer alloc functions.  Make sure we indicate the
+	 * right version so DRI2 can reject us if it's version 3 or above. */
+	info.version = 2;
+#else
 	info.version = 3;
+#endif
 	info.CreateBuffer = sna_dri_create_buffer;
 	info.DestroyBuffer = sna_dri_destroy_buffer;
 
diff --git a/src/sna/sna_driver.c b/src/sna/sna_driver.c
index da5740a..dcfcd67 100644
--- a/src/sna/sna_driver.c
+++ b/src/sna/sna_driver.c
@@ -45,6 +45,13 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include <stdio.h>
 #include <errno.h>
 
+#include "sna.h"
+#include "sna_module.h"
+#include "sna_video.h"
+
+#include "intel_driver.h"
+#include "intel_options.h"
+
 #include <xf86cmap.h>
 #include <xf86drm.h>
 #include <xf86RandR12.h>
@@ -52,13 +59,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include <micmap.h>
 #include <mipict.h>
 
-#include "compiler.h"
-#include "sna.h"
-#include "sna_module.h"
-#include "sna_video.h"
-
-#include "intel_driver.h"
-#include "intel_options.h"
 
 #include <sys/ioctl.h>
 #include <sys/fcntl.h>
@@ -338,9 +338,73 @@ static void sna_setup_capabilities(ScrnInfoPtr scrn, int fd)
 #endif
 }
 
+static int
+namecmp(const char *s1, const char *s2)
+{
+	char c1, c2;
+
+	if (!s1 || *s1 == 0) {
+		if (!s2 || *s2 == 0)
+			return 0;
+		else
+			return 1;
+	}
+
+	while (*s1 == '_' || *s1 == ' ' || *s1 == '\t')
+		s1++;
+
+	while (*s2 == '_' || *s2 == ' ' || *s2 == '\t')
+		s2++;
+
+	c1 = isupper(*s1) ? tolower(*s1) : *s1;
+	c2 = isupper(*s2) ? tolower(*s2) : *s2;
+	while (c1 == c2) {
+		if (c1 == '\0')
+			return 0;
+
+		s1++;
+		while (*s1 == '_' || *s1 == ' ' || *s1 == '\t')
+			s1++;
+
+		s2++;
+		while (*s2 == '_' || *s2 == ' ' || *s2 == '\t')
+			s2++;
+
+		c1 = isupper(*s1) ? tolower(*s1) : *s1;
+		c2 = isupper(*s2) ? tolower(*s2) : *s2;
+	}
+
+	return c1 - c2;
+}
+
 static Bool sna_option_cast_to_bool(struct sna *sna, int id, Bool val)
 {
-	xf86getBoolValue(&val, xf86GetOptValString(sna->Options, id));
+	const char *str = xf86GetOptValString(sna->Options, id);
+
+	if (str == NULL)
+		return val;
+
+	if (*str == '\0')
+		return TRUE;
+
+	if (namecmp(str, "1") == 0)
+		return TRUE;
+	if (namecmp(str, "on") == 0)
+		return TRUE;
+	if (namecmp(str, "true") == 0)
+		return TRUE;
+	if (namecmp(str, "yes") == 0)
+		return TRUE;
+
+	if (namecmp(str, "0") == 0)
+		return FALSE;
+	if (namecmp(str, "off") == 0)
+		return FALSE;
+	if (namecmp(str, "false") == 0)
+		return FALSE;
+	if (namecmp(str, "no") == 0)
+		return FALSE;
+
 	return val;
 }
 
diff --git a/src/sna/sna_render.c b/src/sna/sna_render.c
index 6b883dd..738cca4 100644
--- a/src/sna/sna_render.c
+++ b/src/sna/sna_render.c
@@ -25,6 +25,10 @@
  *
  */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include "sna.h"
 #include "sna_render.h"
 #include "sna_render_inline.h"
@@ -56,7 +60,9 @@ sna_format_for_depth(int depth)
 	case 16: return PICT_r5g6b5;
 	default: assert(0);
 	case 24: return PICT_x8r8g8b8;
+#ifdef PICT_x2r10g10b10
 	case 30: return PICT_x2r10g10b10;
+#endif
 	case 32: return PICT_a8r8g8b8;
 	}
 }
diff --git a/src/sna/sna_stream.c b/src/sna/sna_stream.c
index 1a0a86b..378825e 100644
--- a/src/sna/sna_stream.c
+++ b/src/sna/sna_stream.c
@@ -25,6 +25,10 @@
  *
  */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include "sna.h"
 #include "sna_render.h"
 #include "brw/brw.h"
diff --git a/src/sna/sna_threads.c b/src/sna/sna_threads.c
index 21fd94c..b771bda 100644
--- a/src/sna/sna_threads.c
+++ b/src/sna/sna_threads.c
@@ -25,6 +25,10 @@
  *
  */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include "sna.h"
 
 #include <unistd.h>
diff --git a/src/sna/sna_vertex.c b/src/sna/sna_vertex.c
index 6755d9a..86ad2c5 100644
--- a/src/sna/sna_vertex.c
+++ b/src/sna/sna_vertex.c
@@ -25,6 +25,10 @@
  *
  */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include "sna.h"
 
 #include <unistd.h>
diff --git a/src/uxa/i830_3d.c b/src/uxa/i830_3d.c
index 1043201..e03aaa0 100644
--- a/src/uxa/i830_3d.c
+++ b/src/uxa/i830_3d.c
@@ -29,6 +29,7 @@
 #include "config.h"
 #endif
 
+#include "xorg-server.h"
 #include "xf86.h"
 #include "intel.h"
 
diff --git a/src/uxa/i830_render.c b/src/uxa/i830_render.c
index e169cc1..ee68ec3 100644
--- a/src/uxa/i830_render.c
+++ b/src/uxa/i830_render.c
@@ -30,6 +30,7 @@
 #include "config.h"
 #endif
 
+#include "xorg-server.h"
 #include "xf86.h"
 #include "intel.h"
 #include "i830_reg.h"
diff --git a/src/uxa/i915_3d.c b/src/uxa/i915_3d.c
index 77db568..24f6081 100644
--- a/src/uxa/i915_3d.c
+++ b/src/uxa/i915_3d.c
@@ -29,6 +29,7 @@
 #include "config.h"
 #endif
 
+#include "xorg-server.h"
 #include "xf86.h"
 #include "intel.h"
 
diff --git a/src/uxa/i915_render.c b/src/uxa/i915_render.c
index 6d3400e..577abac 100644
--- a/src/uxa/i915_render.c
+++ b/src/uxa/i915_render.c
@@ -30,6 +30,7 @@
 #include "config.h"
 #endif
 
+#include "xorg-server.h"
 #include "xf86.h"
 #include "intel.h"
 #include "i915_reg.h"
diff --git a/src/uxa/i915_video.c b/src/uxa/i915_video.c
index ae2e6bb..f6a1c6e 100644
--- a/src/uxa/i915_video.c
+++ b/src/uxa/i915_video.c
@@ -29,6 +29,7 @@
 #include "config.h"
 #endif
 
+#include "xorg-server.h"
 #include "xf86.h"
 #include "xf86_OSproc.h"
 #include "xf86xv.h"
diff --git a/src/uxa/i965_render.c b/src/uxa/i965_render.c
index 39698b0..3586967 100644
--- a/src/uxa/i965_render.c
+++ b/src/uxa/i965_render.c
@@ -34,6 +34,7 @@
 #endif
 
 #include <assert.h>
+#include "xorg-server.h"
 #include "xf86.h"
 #include "intel.h"
 #include "i830_reg.h"
diff --git a/src/uxa/i965_video.c b/src/uxa/i965_video.c
index 5706b20..54f5fa7 100644
--- a/src/uxa/i965_video.c
+++ b/src/uxa/i965_video.c
@@ -30,6 +30,7 @@
 #include "config.h"
 #endif
 
+#include "xorg-server.h"
 #include "xf86.h"
 #include "xf86_OSproc.h"
 #include "xf86xv.h"
diff --git a/src/uxa/intel.h b/src/uxa/intel.h
index 9b696cd..131f18c 100644
--- a/src/uxa/intel.h
+++ b/src/uxa/intel.h
@@ -51,6 +51,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #ifndef _I830_H_
 #define _I830_H_
 
+#include "xorg-server.h"
 #include "xf86_OSproc.h"
 #include "compiler.h"
 #include "xf86Pci.h"
@@ -63,6 +64,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include <pciaccess.h>
 
 #define _XF86DRI_SERVER_
+#include "drm.h"
 #include "dri2.h"
 #include "intel_bufmgr.h"
 #include "i915_drm.h"
diff --git a/src/uxa/intel_batchbuffer.c b/src/uxa/intel_batchbuffer.c
index a44a156..579a63a 100644
--- a/src/uxa/intel_batchbuffer.c
+++ b/src/uxa/intel_batchbuffer.c
@@ -34,6 +34,7 @@
 #include <stdlib.h>
 #include <errno.h>
 
+#include "xorg-server.h"
 #include "xf86.h"
 #include "intel.h"
 #include "i830_reg.h"
diff --git a/src/uxa/intel_display.c b/src/uxa/intel_display.c
index b4f7e87..7dc0f68 100644
--- a/src/uxa/intel_display.c
+++ b/src/uxa/intel_display.c
@@ -38,6 +38,7 @@
 #include <poll.h>
 #include <sys/ioctl.h>
 
+#include "xorg-server.h"
 #include "xorgVersion.h"
 
 #include "intel.h"
@@ -46,7 +47,12 @@
 #include "xf86drm.h"
 #include "xf86drmMode.h"
 #include "X11/Xatom.h"
-#include "X11/extensions/dpmsconst.h"
+#if defined(HAVE_X11_EXTENSIONS_DPMSCONST_H)
+#include <X11/extensions/dpmsconst.h>
+#else
+#define DPMSModeOn 0
+#define DPMSModeOff 3
+#endif
 #include "xf86DDC.h"
 #include "fb.h"
 #include "uxa.h"
diff --git a/src/uxa/intel_dri.c b/src/uxa/intel_dri.c
index 0370034..acedd0b 100644
--- a/src/uxa/intel_dri.c
+++ b/src/uxa/intel_dri.c
@@ -48,6 +48,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include <time.h>
 #include <errno.h>
 
+#include "xorg-server.h"
 #include "xf86.h"
 #include "xf86_OSproc.h"
 
@@ -1530,6 +1531,7 @@ static int has_i830_dri(void)
 
 static const char *dri_driver_name(intel_screen_private *intel)
 {
+#if XORG_VERSION_CURRENT >= XORG_VERSION_NUMERIC(1,7,99,901,0)
 	const char *s = xf86GetOptValString(intel->Options, OPTION_DRI);
 	Bool dummy;
 
@@ -1543,6 +1545,14 @@ static const char *dri_driver_name(intel_screen_private *intel)
 	}
 
 	return s;
+#else
+	if (INTEL_INFO(intel)->gen < 030)
+		return has_i830_dri() ? "i830" : "i915";
+	else if (INTEL_INFO(intel)->gen < 040)
+		return "i915";
+	else
+		return "i965";
+#endif
 }
 
 Bool I830DRI2ScreenInit(ScreenPtr screen)
diff --git a/src/uxa/intel_driver.c b/src/uxa/intel_driver.c
index 675408d..7d716eb 100644
--- a/src/uxa/intel_driver.c
+++ b/src/uxa/intel_driver.c
@@ -45,6 +45,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include <stdio.h>
 #include <errno.h>
 
+#include "xorg-server.h"
 #include "xf86.h"
 #include "xf86_OSproc.h"
 #include "xf86cmap.h"
@@ -54,7 +55,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "micmap.h"
 #include "shadowfb.h"
 #include <X11/extensions/randr.h>
-#include <X11/extensions/dpmsconst.h>
 #include "fb.h"
 #include "miscstruct.h"
 #include "dixstruct.h"
@@ -225,8 +225,12 @@ static Bool I830GetEarlyOptions(ScrnInfoPtr scrn)
 static Bool intel_option_cast_string_to_bool(intel_screen_private *intel,
 					     int id, Bool val)
 {
+#if XORG_VERSION_CURRENT >= XORG_VERSION_NUMERIC(1,7,99,901,0)
 	xf86getBoolValue(&val, xf86GetOptValString(intel->Options, id));
 	return val;
+#else
+	return val;
+#endif
 }
 
 static void intel_check_dri_option(ScrnInfoPtr scrn)
diff --git a/src/uxa/intel_glamor.c b/src/uxa/intel_glamor.c
index 0c4e3a7..fa60300 100644
--- a/src/uxa/intel_glamor.c
+++ b/src/uxa/intel_glamor.c
@@ -31,6 +31,7 @@
 #include "config.h"
 #endif
 
+#include "xorg-server.h"
 #include <xf86.h>
 #define GLAMOR_FOR_XORG  1
 #include <glamor.h>
diff --git a/src/uxa/intel_memory.c b/src/uxa/intel_memory.c
index e51fa33..7db1a04 100644
--- a/src/uxa/intel_memory.c
+++ b/src/uxa/intel_memory.c
@@ -80,6 +80,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include <sys/types.h>
 #include <sys/ioctl.h>
 
+#include "xorg-server.h"
 #include "xf86.h"
 #include "xf86_OSproc.h"
 
diff --git a/src/uxa/intel_uxa.c b/src/uxa/intel_uxa.c
index 2f14173..0b6591a 100644
--- a/src/uxa/intel_uxa.c
+++ b/src/uxa/intel_uxa.c
@@ -31,6 +31,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "config.h"
 #endif
 
+#include "xorg-server.h"
 #include <xf86.h>
 #include <xf86drm.h>
 #include <xaarop.h>
diff --git a/src/uxa/intel_video.c b/src/uxa/intel_video.c
index d6906bf..238cd47 100644
--- a/src/uxa/intel_video.c
+++ b/src/uxa/intel_video.c
@@ -55,6 +55,7 @@
 #include <assert.h>
 #include <errno.h>
 
+#include "xorg-server.h"
 #include "xf86.h"
 #include "xf86_OSproc.h"
 #include "compiler.h"
diff --git a/tools/virtual.c b/tools/virtual.c
index c363a3e..3147943 100644
--- a/tools/virtual.c
+++ b/tools/virtual.c
@@ -22,17 +22,25 @@
  *
  */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include <X11/Xlib.h>
 #include <X11/Xatom.h>
 
 #include <X11/Xlibint.h>
 #include <X11/extensions/record.h>
+#include <X11/extensions/XShm.h>
+#if HAVE_X11_EXTENSIONS_SHMPROTO_H
 #include <X11/extensions/shmproto.h>
+#elif HAVE_X11_EXTENSIONS_SHMSTR_H
+#include <X11/extensions/shmstr.h>
+#endif
 #include <X11/extensions/Xdamage.h>
 #include <X11/extensions/Xinerama.h>
 #include <X11/extensions/Xrandr.h>
 #include <X11/extensions/Xrender.h>
-#include <X11/extensions/XShm.h>
 #include <X11/Xcursor/Xcursor.h>
 #include <pixman.h>
 
@@ -282,7 +290,10 @@ static int timerfd(int hz)
 	struct itimerspec it;
 	int fd;
 
+	fd = -1;
+#ifdef CLOCK_MONOTONIC_COARSE
 	fd = timerfd_create(CLOCK_MONOTONIC_COARSE, TFD_NONBLOCK);
+#endif
 	if (fd < 0)
 		fd = timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK);
 	if (fd < 0)
@@ -399,8 +410,8 @@ static XRRModeInfo *lookup_mode(XRRScreenResources *res, int id)
 
 static int clone_update_modes__randr(struct clone *clone)
 {
-	XRRScreenResources *from_res, *to_res;
-	XRROutputInfo *from_info, *to_info;
+	XRRScreenResources *from_res = NULL, *to_res = NULL;
+	XRROutputInfo *from_info = NULL, *to_info = NULL;
 	int i, j, ret = ENOENT;
 
 	assert(clone->src.rr_output);
@@ -499,8 +510,8 @@ err:
 static int clone_update_modes__fixed(struct clone *clone)
 {
 	char mode_name[80];
-	XRRScreenResources *res;
-	XRROutputInfo *info;
+	XRRScreenResources *res = NULL;
+	XRROutputInfo *info = NULL;
 	XRRModeInfo mode;
 	RRMode id;
 	int i, j, ret = ENOENT;
@@ -1604,6 +1615,7 @@ static int clone_init_depth(struct clone *clone)
 	DBG(("%s-%s wants depth %d\n",
 	     DisplayString(clone->dst.dpy), clone->dst.name, clone->depth));
 
+	ret = -1;
 	for (depth = clone->depth; depth <= 24; depth += 8) {
 		ret = display_init_render(clone->src.display, depth, &clone->src.use_render);
 		if (ret)
@@ -1986,7 +1998,7 @@ static int last_display_add_clones__display(struct context *ctx)
 	Display *dpy = display->dpy;
 	Screen *scr;
 	char buf[80];
-	int n, ret;
+	int ret;
 	RROutput id;
 
 	DBG(("%s(%s)\n", __func__, DisplayString(display->dpy)));
@@ -2007,7 +2019,7 @@ static int last_display_add_clones__display(struct context *ctx)
 		return ret;
 	}
 
-	sprintf(buf, "WHOLE%d", n);
+	sprintf(buf, "WHOLE");
 	ret = clone_output_init(clone, &clone->dst, display, buf, 0);
 	if (ret) {
 		fprintf(stderr, "Failed to add display \"%s\"\n",


More information about the xorg-commit mailing list