[Xquartz-changes] xserver: Branch 'server-1.17-apple' - 51 commits

Jeremy Huddleston jeremyhu at freedesktop.org
Sat Feb 7 15:27:20 PST 2015


Rebased ref, commits from common ancestor:
commit 299f24e5dca1cb094ce015763f58e7791613958e
Author: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
Date:   Sat May 31 13:14:20 2014 -0700

    fb: Revert fb changes that broke XQuartz
    
        http://bugs.freedesktop.org/show_bug.cgi?id=26124
    
    Revert "Use new pixman_glyph_cache_t API that will be in pixman 0.28.0"
    Revert "fb: Fix origin of source picture in fbGlyphs"
    Revert "fb: Publish fbGlyphs and fbUnrealizeGlyph"
    
    This reverts commit 9cbcb5bd6a5360a128d15b77a02d8d3351f74366.
    This reverts commit 983e30361f49a67252d0b5d82630e70724d69dbf.
    This reverts commit 3c2c59eed3c68c0e5a93c38cf01eedad015e3157.

diff --git a/fb/fb.h b/fb/fb.h
index 59eaac3..046b948 100644
--- a/fb/fb.h
+++ b/fb/fb.h
@@ -1116,9 +1116,6 @@ extern _X_EXPORT void
 extern _X_EXPORT Bool
  fbPictureInit(ScreenPtr pScreen, PictFormatPtr formats, int nformats);
 
-extern _X_EXPORT void
-fbDestroyGlyphCache(void);
-
 /*
  * fbpixmap.c
  */
diff --git a/fb/fbpict.c b/fb/fbpict.c
index 219eae0..9c4cc42 100644
--- a/fb/fbpict.c
+++ b/fb/fbpict.c
@@ -65,152 +65,6 @@ fbComposite(CARD8 op,
     free_pixman_pict(pDst, dest);
 }
 
-static pixman_glyph_cache_t *glyphCache;
-
-void
-fbDestroyGlyphCache(void)
-{
-    if (glyphCache)
-    {
-	pixman_glyph_cache_destroy (glyphCache);
-	glyphCache = NULL;
-    }
-}
-
-static void
-fbUnrealizeGlyph(ScreenPtr pScreen,
-		 GlyphPtr pGlyph)
-{
-    if (glyphCache)
-	pixman_glyph_cache_remove (glyphCache, pGlyph, NULL);
-}
-
-void
-fbGlyphs(CARD8 op,
-	 PicturePtr pSrc,
-	 PicturePtr pDst,
-	 PictFormatPtr maskFormat,
-	 INT16 xSrc,
-	 INT16 ySrc, int nlist,
-	 GlyphListPtr list,
-	 GlyphPtr *glyphs)
-{
-#define N_STACK_GLYPHS 512
-    ScreenPtr pScreen = pDst->pDrawable->pScreen;
-    pixman_glyph_t stack_glyphs[N_STACK_GLYPHS];
-    pixman_glyph_t *pglyphs = stack_glyphs;
-    pixman_image_t *srcImage, *dstImage;
-    int srcXoff, srcYoff, dstXoff, dstYoff;
-    GlyphPtr glyph;
-    int n_glyphs;
-    int x, y;
-    int i, n;
-    int xDst = list->xOff, yDst = list->yOff;
-
-    miCompositeSourceValidate(pSrc);
-    
-    n_glyphs = 0;
-    for (i = 0; i < nlist; ++i)
-	n_glyphs += list[i].len;
-
-    if (!glyphCache)
-	glyphCache = pixman_glyph_cache_create();
-
-    pixman_glyph_cache_freeze (glyphCache);
-    
-    if (n_glyphs > N_STACK_GLYPHS) {
-	if (!(pglyphs = malloc (n_glyphs * sizeof (pixman_glyph_t))))
-	    goto out;
-    }
-    
-    i = 0;
-    x = y = 0;
-    while (nlist--) {
-        x += list->xOff;
-        y += list->yOff;
-        n = list->len;
-        while (n--) {
-	    const void *g;
-
-            glyph = *glyphs++;
-
-	    if (!(g = pixman_glyph_cache_lookup (glyphCache, glyph, NULL))) {
-		pixman_image_t *glyphImage;
-		PicturePtr pPicture;
-		int xoff, yoff;
-
-		pPicture = GetGlyphPicture(glyph, pScreen);
-		if (!pPicture) {
-		    n_glyphs--;
-		    goto next;
-		}
-
-		if (!(glyphImage = image_from_pict(pPicture, FALSE, &xoff, &yoff)))
-		    goto out;
-
-		g = pixman_glyph_cache_insert(glyphCache, glyph, NULL,
-					      glyph->info.x,
-					      glyph->info.y,
-					      glyphImage);
-
-		free_pixman_pict(pPicture, glyphImage);
-
-		if (!g)
-		    goto out;
-	    }
-
-	    pglyphs[i].x = x;
-	    pglyphs[i].y = y;
-	    pglyphs[i].glyph = g;
-	    i++;
-
-	next:
-            x += glyph->info.xOff;
-            y += glyph->info.yOff;
-	}
-	list++;
-    }
-
-    if (!(srcImage = image_from_pict(pSrc, FALSE, &srcXoff, &srcYoff)))
-	goto out;
-
-    if (!(dstImage = image_from_pict(pDst, TRUE, &dstXoff, &dstYoff)))
-	goto out_free_src;
-
-    if (maskFormat) {
-	pixman_format_code_t format;
-	pixman_box32_t extents;
-
-	format = maskFormat->format | (maskFormat->depth << 24);
-
-	pixman_glyph_get_extents(glyphCache, n_glyphs, pglyphs, &extents);
-
-	pixman_composite_glyphs(op, srcImage, dstImage, format,
-				xSrc + srcXoff + extents.x1 - xDst, ySrc + srcYoff + extents.y1 - yDst,
-				extents.x1, extents.y1,
-				extents.x1 + dstXoff, extents.y1 + dstYoff,
-				extents.x2 - extents.x1,
-				extents.y2 - extents.y1,
-				glyphCache, n_glyphs, pglyphs);
-    }
-    else {
-	pixman_composite_glyphs_no_mask(op, srcImage, dstImage,
-					xSrc + srcXoff - xDst, ySrc + srcYoff - yDst,
-					dstXoff, dstYoff,
-					glyphCache, n_glyphs, pglyphs);
-    }
-
-    free_pixman_pict(pDst, dstImage);
-
-out_free_src:
-    free_pixman_pict(pSrc, srcImage);
-
-out:
-    pixman_glyph_cache_thaw(glyphCache);
-    if (pglyphs != stack_glyphs)
-	free(pglyphs);
-}
-
 static pixman_image_t *
 create_solid_fill_image(PicturePtr pict)
 {
@@ -461,8 +315,7 @@ fbPictureInit(ScreenPtr pScreen, PictFormatPtr formats, int nformats)
         return FALSE;
     ps = GetPictureScreen(pScreen);
     ps->Composite = fbComposite;
-    ps->Glyphs = fbGlyphs;
-    ps->UnrealizeGlyph = fbUnrealizeGlyph;
+    ps->Glyphs = miGlyphs;
     ps->CompositeRects = miCompositeRects;
     ps->RasterizeTrapezoid = fbRasterizeTrapezoid;
     ps->AddTraps = fbAddTraps;
diff --git a/fb/fbpict.h b/fb/fbpict.h
index 5cb8663..110f32d 100644
--- a/fb/fbpict.h
+++ b/fb/fbpict.h
@@ -65,20 +65,11 @@ fbTrapezoids(CARD8 op,
              INT16 xSrc, INT16 ySrc, int ntrap, xTrapezoid * traps);
 
 extern _X_EXPORT void
+
 fbTriangles(CARD8 op,
             PicturePtr pSrc,
             PicturePtr pDst,
             PictFormatPtr maskFormat,
             INT16 xSrc, INT16 ySrc, int ntris, xTriangle * tris);
 
-extern _X_EXPORT void
-fbGlyphs(CARD8 op,
-	 PicturePtr pSrc,
-	 PicturePtr pDst,
-	 PictFormatPtr maskFormat,
-	 INT16 xSrc,
-	 INT16 ySrc, int nlist,
-	 GlyphListPtr list,
-	 GlyphPtr *glyphs);
-
 #endif                          /* _FBPICT_H_ */
diff --git a/fb/fbscreen.c b/fb/fbscreen.c
index 71bcc5d..55330fc 100644
--- a/fb/fbscreen.c
+++ b/fb/fbscreen.c
@@ -32,7 +32,6 @@ fbCloseScreen(ScreenPtr pScreen)
     int d;
     DepthPtr depths = pScreen->allowedDepths;
 
-    fbDestroyGlyphCache();
     for (d = 0; d < pScreen->numDepths; d++)
         free(depths[d].vids);
     free(depths);
commit c0fbd4545720941a89fdf2191e09d83a004a3f96
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Fri Feb 12 19:48:52 2010 -0800

    fb: Revert fb changes that broke XQuartz
    
    http://bugs.freedesktop.org/show_bug.cgi?id=26124
    
    Revert "Fix source pictures getting random transforms after 2d6a8f668342a5190cdf43b5."
    Revert "fb: Adjust transform or composite coordinates for pixman operations"
    
    http://bugs.freedesktop.org/26124
    
    This reverts commit a72c65e9176c51de95db2fdbf4c5d946a4911695.
    This reverts commit a6bd5d2e482a5aa84acb3d4932e2a166d8670ef1.
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/fb/fb.h b/fb/fb.h
index ab110f3..59eaac3 100644
--- a/fb/fb.h
+++ b/fb/fb.h
@@ -1326,8 +1326,7 @@ fbFillRegionSolid(DrawablePtr pDrawable,
                   RegionPtr pRegion, FbBits and, FbBits xor);
 
 extern _X_EXPORT pixman_image_t *image_from_pict(PicturePtr pict,
-                                                 Bool has_clip,
-                                                 int *xoff, int *yoff);
+                                                 Bool has_clip);
 
 extern _X_EXPORT void free_pixman_pict(PicturePtr, pixman_image_t *);
 
diff --git a/fb/fbpict.c b/fb/fbpict.c
index f6deae7..219eae0 100644
--- a/fb/fbpict.c
+++ b/fb/fbpict.c
@@ -46,23 +46,18 @@ fbComposite(CARD8 op,
             INT16 yMask, INT16 xDst, INT16 yDst, CARD16 width, CARD16 height)
 {
     pixman_image_t *src, *mask, *dest;
-    int src_xoff, src_yoff;
-    int msk_xoff, msk_yoff;
-    int dst_xoff, dst_yoff;
-
     miCompositeSourceValidate(pSrc);
     if (pMask)
         miCompositeSourceValidate(pMask);
 
-    src = image_from_pict(pSrc, FALSE, &src_xoff, &src_yoff);
-    mask = image_from_pict(pMask, FALSE, &msk_xoff, &msk_yoff);
-    dest = image_from_pict(pDst, TRUE, &dst_xoff, &dst_yoff);
+    src = image_from_pict(pSrc, TRUE);
+    mask = image_from_pict(pMask, TRUE);
+    dest = image_from_pict(pDst, TRUE);
 
     if (src && dest && !(pMask && !mask)) {
         pixman_image_composite(op, src, mask, dest,
-                               xSrc + src_xoff, ySrc + src_yoff,
-                               xMask + msk_xoff, yMask + msk_yoff,
-                               xDst + dst_xoff, yDst + dst_yoff, width, height);
+                               xSrc, ySrc, xMask, yMask, xDst, yDst,
+                               width, height);
     }
 
     free_pixman_pict(pSrc, src);
@@ -289,20 +284,22 @@ create_conical_gradient_image(PictGradient * gradient)
 }
 
 static pixman_image_t *
-create_bits_picture(PicturePtr pict, Bool has_clip, int *xoff, int *yoff)
+create_bits_picture(PicturePtr pict, Bool has_clip)
 {
-    PixmapPtr pixmap;
     FbBits *bits;
     FbStride stride;
-    int bpp;
+    int bpp, xoff, yoff;
     pixman_image_t *image;
 
-    fbGetDrawablePixmap(pict->pDrawable, pixmap, *xoff, *yoff);
-    fbGetPixmapBitsData(pixmap, bits, stride, bpp);
+    fbGetDrawable (pict->pDrawable, bits, stride, bpp, xoff, yoff);
+
+    bits = (FbBits*)((CARD8*)bits +
+                     (pict->pDrawable->y + yoff) * stride * sizeof(FbBits) +
+                     (pict->pDrawable->x + xoff) * (bpp / 8));
 
     image = pixman_image_create_bits((pixman_format_code_t) pict->format,
-                                     pixmap->drawable.width,
-                                     pixmap->drawable.height, (uint32_t *) bits,
+                                     pict->pDrawable->width,
+                                     pict->pDrawable->height, (uint32_t *) bits,
                                      stride * sizeof(FbStride));
 
     if (!image)
@@ -321,57 +318,31 @@ create_bits_picture(PicturePtr pict, Bool has_clip, int *xoff, int *yoff)
         if (pict->clientClip)
             pixman_image_set_has_client_clip(image, TRUE);
 
-        if (*xoff || *yoff)
-            pixman_region_translate(pict->pCompositeClip, *xoff, *yoff);
+        pixman_region_translate (pict->pCompositeClip, - pict->pDrawable->x, - pict->pDrawable->y);
 
         pixman_image_set_clip_region(image, pict->pCompositeClip);
 
-        if (*xoff || *yoff)
-            pixman_region_translate(pict->pCompositeClip, -*xoff, -*yoff);
+        pixman_region_translate (pict->pCompositeClip, pict->pDrawable->x, pict->pDrawable->y);
     }
 
     /* Indexed table */
     if (pict->pFormat->index.devPrivate)
         pixman_image_set_indexed(image, pict->pFormat->index.devPrivate);
 
-    /* Add in drawable origin to position within the image */
-    *xoff += pict->pDrawable->x;
-    *yoff += pict->pDrawable->y;
-
     return image;
 }
 
 static pixman_image_t *image_from_pict_internal(PicturePtr pict, Bool has_clip,
-                                                int *xoff, int *yoff,
                                                 Bool is_alpha_map);
 
 static void
-set_image_properties(pixman_image_t * image, PicturePtr pict, Bool has_clip,
-                     int *xoff, int *yoff, Bool is_alpha_map)
+set_image_properties(pixman_image_t * image, PicturePtr pict, Bool is_alpha_map)
 {
     pixman_repeat_t repeat;
     pixman_filter_t filter;
 
     if (pict->transform) {
-        /* For source images, adjust the transform to account
-         * for the drawable offset within the pixman image,
-         * then set the offset to 0 as it will be used
-         * to compute positions within the transformed image.
-         */
-        if (!has_clip) {
-            struct pixman_transform adjusted;
-
-            adjusted = *pict->transform;
-            pixman_transform_translate(&adjusted,
-                                       NULL,
-                                       pixman_int_to_fixed(*xoff),
-                                       pixman_int_to_fixed(*yoff));
-            pixman_image_set_transform(image, &adjusted);
-            *xoff = 0;
-            *yoff = 0;
-        }
-        else
-            pixman_image_set_transform(image, pict->transform);
+        pixman_image_set_transform(image, pict->transform);
     }
 
     switch (pict->repeatType) {
@@ -399,10 +370,8 @@ set_image_properties(pixman_image_t * image, PicturePtr pict, Bool has_clip,
      * as the alpha map for this operation
      */
     if (pict->alphaMap && !is_alpha_map) {
-        int alpha_xoff, alpha_yoff;
         pixman_image_t *alpha_map =
-            image_from_pict_internal(pict->alphaMap, FALSE, &alpha_xoff,
-                                     &alpha_yoff, TRUE);
+            image_from_pict_internal(pict->alphaMap, TRUE, TRUE);
 
         pixman_image_set_alpha_map(image, alpha_map, pict->alphaOrigin.x,
                                    pict->alphaOrigin.y);
@@ -436,8 +405,7 @@ set_image_properties(pixman_image_t * image, PicturePtr pict, Bool has_clip,
 }
 
 static pixman_image_t *
-image_from_pict_internal(PicturePtr pict, Bool has_clip, int *xoff, int *yoff,
-                         Bool is_alpha_map)
+image_from_pict_internal(PicturePtr pict, Bool has_clip, Bool is_alpha_map)
 {
     pixman_image_t *image = NULL;
 
@@ -445,7 +413,7 @@ image_from_pict_internal(PicturePtr pict, Bool has_clip, int *xoff, int *yoff,
         return NULL;
 
     if (pict->pDrawable) {
-        image = create_bits_picture(pict, has_clip, xoff, yoff);
+        image = create_bits_picture(pict, has_clip);
     }
     else if (pict->pSourcePict) {
         SourcePict *sp = pict->pSourcePict;
@@ -463,19 +431,17 @@ image_from_pict_internal(PicturePtr pict, Bool has_clip, int *xoff, int *yoff,
             else if (sp->type == SourcePictTypeConical)
                 image = create_conical_gradient_image(gradient);
         }
-        *xoff = *yoff = 0;
     }
 
     if (image)
-        set_image_properties(image, pict, has_clip, xoff, yoff, is_alpha_map);
-
+        set_image_properties (image, pict, is_alpha_map);
     return image;
 }
 
 pixman_image_t *
-image_from_pict(PicturePtr pict, Bool has_clip, int *xoff, int *yoff)
+image_from_pict (PicturePtr pict, Bool has_clip)
 {
-    return image_from_pict_internal(pict, has_clip, xoff, yoff, FALSE);
+    return image_from_pict_internal (pict, has_clip, FALSE);
 }
 
 void
diff --git a/fb/fbtrap.c b/fb/fbtrap.c
index bf82f8f..0145ce9 100644
--- a/fb/fbtrap.c
+++ b/fb/fbtrap.c
@@ -36,13 +36,12 @@ fbAddTraps(PicturePtr pPicture,
            INT16 x_off, INT16 y_off, int ntrap, xTrap * traps)
 {
     pixman_image_t *image;
-    int dst_xoff, dst_yoff;
 
-    if (!(image = image_from_pict(pPicture, FALSE, &dst_xoff, &dst_yoff)))
-        return;
-
-    pixman_add_traps(image, x_off + dst_xoff, y_off + dst_yoff,
-                     ntrap, (pixman_trap_t *) traps);
+    if (!(image = image_from_pict (pPicture, FALSE)))
+	return;
+    
+    pixman_add_traps(image, x_off, y_off,
+                     ntrap, (pixman_trap_t *)traps);
 
     free_pixman_pict(pPicture, image);
 }
@@ -52,13 +51,12 @@ fbRasterizeTrapezoid(PicturePtr pPicture,
                      xTrapezoid * trap, int x_off, int y_off)
 {
     pixman_image_t *image;
-    int dst_xoff, dst_yoff;
 
-    if (!(image = image_from_pict(pPicture, FALSE, &dst_xoff, &dst_yoff)))
+    if (!(image = image_from_pict (pPicture, FALSE)))
         return;
 
-    pixman_rasterize_trapezoid(image, (pixman_trapezoid_t *) trap,
-                               x_off + dst_xoff, y_off + dst_yoff);
+    pixman_rasterize_trapezoid(image, (pixman_trapezoid_t *)trap,
+                               x_off, y_off);
 
     free_pixman_pict(pPicture, image);
 }
@@ -68,14 +66,12 @@ fbAddTriangles(PicturePtr pPicture,
                INT16 x_off, INT16 y_off, int ntri, xTriangle * tris)
 {
     pixman_image_t *image;
-    int dst_xoff, dst_yoff;
 
-    if (!(image = image_from_pict(pPicture, FALSE, &dst_xoff, &dst_yoff)))
+    if (!(image = image_from_pict (pPicture, FALSE)))
         return;
-
-    pixman_add_triangles(image,
-                         dst_xoff + x_off, dst_yoff + y_off,
-                         ntri, (pixman_triangle_t *) tris);
+    
+    pixman_add_triangles(image, x_off, y_off, ntri,
+                         (pixman_triangle_t *)tris);
 
     free_pixman_pict(pPicture, image);
 }
@@ -98,13 +94,11 @@ fbShapes(CompositeShapesFunc composite,
          int16_t ySrc, int nshapes, int shape_size, const uint8_t * shapes)
 {
     pixman_image_t *src, *dst;
-    int src_xoff, src_yoff;
-    int dst_xoff, dst_yoff;
 
     miCompositeSourceValidate(pSrc);
 
-    src = image_from_pict(pSrc, FALSE, &src_xoff, &src_yoff);
-    dst = image_from_pict(pDst, TRUE, &dst_xoff, &dst_yoff);
+    src = image_from_pict(pSrc, FALSE);
+    dst = image_from_pict(pDst, TRUE);
 
     if (src && dst) {
         pixman_format_code_t format;
@@ -121,9 +115,8 @@ fbShapes(CompositeShapesFunc composite,
 
             for (i = 0; i < nshapes; ++i) {
                 composite(op, src, dst, format,
-                          xSrc + src_xoff,
-                          ySrc + src_yoff,
-                          dst_xoff, dst_yoff, 1, shapes + i * shape_size);
+                          xSrc, ySrc, 0, 0, 
+                          1, shapes + i * shape_size);
             }
         }
         else {
@@ -143,8 +136,8 @@ fbShapes(CompositeShapesFunc composite,
             }
 
             composite(op, src, dst, format,
-                      xSrc + src_xoff,
-                      ySrc + src_yoff, dst_xoff, dst_yoff, nshapes, shapes);
+                      xSrc, ySrc, 0, 0,
+                      nshapes, shapes);
         }
 
         DamageRegionProcessPending(pDst->pDrawable);
commit e09892ca4ddd83205fc265c653b6fde2dc22619a
Author: Jeremy Huddleston Sequoia <jeremyhu at apple.com>
Date:   Sat Nov 2 11:00:23 2013 -0700

    Use old miTrapezoids and miTriangles routines
    
    Reverts commits:
        788ccb9a8bcf6a4fb4054c507111eec3338fb969
        566f1931ee2916269e164e114bffaf2da1d039d1
    
    http://xquartz.macosforge.org/trac/ticket/525
    
    Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu at apple.com>

diff --git a/fb/fbpict.c b/fb/fbpict.c
index e726691..f6deae7 100644
--- a/fb/fbpict.c
+++ b/fb/fbpict.c
@@ -499,10 +499,8 @@ fbPictureInit(ScreenPtr pScreen, PictFormatPtr formats, int nformats)
     ps->UnrealizeGlyph = fbUnrealizeGlyph;
     ps->CompositeRects = miCompositeRects;
     ps->RasterizeTrapezoid = fbRasterizeTrapezoid;
-    ps->Trapezoids = fbTrapezoids;
     ps->AddTraps = fbAddTraps;
     ps->AddTriangles = fbAddTriangles;
-    ps->Triangles = fbTriangles;
 
     return TRUE;
 }
diff --git a/render/mipict.c b/render/mipict.c
index a725104..e14293a 100644
--- a/render/mipict.c
+++ b/render/mipict.c
@@ -575,8 +575,8 @@ miPictureInit(ScreenPtr pScreen, PictFormatPtr formats, int nformats)
     ps->Composite = 0;          /* requires DDX support */
     ps->Glyphs = miGlyphs;
     ps->CompositeRects = miCompositeRects;
-    ps->Trapezoids = 0;
-    ps->Triangles = 0;
+    ps->Trapezoids = miTrapezoids;
+    ps->Triangles = miTriangles;
 
     ps->RasterizeTrapezoid = 0; /* requires DDX support */
     ps->AddTraps = 0;           /* requires DDX support */
diff --git a/render/mipict.h b/render/mipict.h
index a16dd31..ee90b58 100644
--- a/render/mipict.h
+++ b/render/mipict.h
@@ -122,6 +122,16 @@ miCompositeRects(CARD8 op,
                  xRenderColor * color, int nRect, xRectangle *rects);
 
 extern _X_EXPORT void
+miTriangles (CARD8	    op,
+	     PicturePtr	    pSrc,
+	     PicturePtr	    pDst,
+	     PictFormatPtr  maskFormat,
+	     INT16	    xSrc,
+	     INT16	    ySrc,
+	     int	    ntri,
+	     xTriangle	    *tris);
+
+extern _X_EXPORT void
 
 miTriStrip(CARD8 op,
            PicturePtr pSrc,
@@ -137,10 +147,27 @@ miTriFan(CARD8 op,
          PictFormatPtr maskFormat,
          INT16 xSrc, INT16 ySrc, int npoints, xPointFixed * points);
 
+extern _X_EXPORT PicturePtr
+miCreateAlphaPicture (ScreenPtr	    pScreen, 
+		      PicturePtr    pDst,
+		      PictFormatPtr pPictFormat,
+		      CARD16	    width,
+		      CARD16	    height);
+
 extern _X_EXPORT void
  miTrapezoidBounds(int ntrap, xTrapezoid * traps, BoxPtr box);
 
 extern _X_EXPORT void
+miTrapezoids (CARD8        op,
+             PicturePtr    pSrc,
+             PicturePtr    pDst,
+             PictFormatPtr maskFormat,
+             INT16         xSrc,
+             INT16         ySrc,
+             int           ntrap,
+             xTrapezoid    *traps);
+
+extern _X_EXPORT void
  miPointFixedBounds(int npoint, xPointFixed * points, BoxPtr bounds);
 
 extern _X_EXPORT void
diff --git a/render/mitrap.c b/render/mitrap.c
index 17b6dcd..71c1857 100644
--- a/render/mitrap.c
+++ b/render/mitrap.c
@@ -34,6 +34,55 @@
 #include "picturestr.h"
 #include "mipict.h"
 
+PicturePtr
+miCreateAlphaPicture (ScreenPtr	    pScreen, 
+		      PicturePtr    pDst,
+		      PictFormatPtr pPictFormat,
+		      CARD16	    width,
+		      CARD16	    height)
+{
+    PixmapPtr	    pPixmap;
+    PicturePtr	    pPicture;
+    GCPtr	    pGC;
+    int		    error;
+    xRectangle	    rect;
+
+    if (width > 32767 || height > 32767)
+	return 0;
+
+    if (!pPictFormat)
+    {
+	if (pDst->polyEdge == PolyEdgeSharp)
+	    pPictFormat = PictureMatchFormat (pScreen, 1, PICT_a1);
+	else
+	    pPictFormat = PictureMatchFormat (pScreen, 8, PICT_a8);
+	if (!pPictFormat)
+	    return 0;
+    }
+
+    pPixmap = (*pScreen->CreatePixmap) (pScreen, width, height, 
+					pPictFormat->depth, 0);
+    if (!pPixmap)
+	return 0;
+    pGC = GetScratchGC (pPixmap->drawable.depth, pScreen);
+    if (!pGC)
+    {
+	(*pScreen->DestroyPixmap) (pPixmap);
+	return 0;
+    }
+    ValidateGC (&pPixmap->drawable, pGC);
+    rect.x = 0;
+    rect.y = 0;
+    rect.width = width;
+    rect.height = height;
+    (*pGC->ops->PolyFillRect)(&pPixmap->drawable, pGC, 1, &rect);
+    FreeScratchGC (pGC);
+    pPicture = CreatePicture (0, &pPixmap->drawable, pPictFormat,
+			      0, 0, serverClient, &error);
+    (*pScreen->DestroyPixmap) (pPixmap);
+    return pPicture;
+}
+
 static xFixed
 miLineFixedX(xLineFixed * l, xFixed y, Bool ceil)
 {
@@ -79,3 +128,65 @@ miTrapezoidBounds(int ntrap, xTrapezoid * traps, BoxPtr box)
             box->x2 = x2;
     }
 }
+
+
+void
+miTrapezoids (CARD8        op,
+             PicturePtr    pSrc,
+             PicturePtr    pDst,
+             PictFormatPtr maskFormat,
+             INT16         xSrc,
+             INT16         ySrc,
+             int           ntrap,
+             xTrapezoid    *traps)
+{
+    ScreenPtr          pScreen = pDst->pDrawable->pScreen;
+    PictureScreenPtr    ps = GetPictureScreen(pScreen);
+
+    /*
+     * Check for solid alpha add
+     */
+    if (op == PictOpAdd && miIsSolidAlpha (pSrc))
+    {
+       for (; ntrap; ntrap--, traps++)
+           (*ps->RasterizeTrapezoid) (pDst, traps, 0, 0);
+    } 
+    else if (maskFormat)
+    {
+       PicturePtr      pPicture;
+       BoxRec          bounds;
+       INT16           xDst, yDst;
+       INT16           xRel, yRel;
+       
+       xDst = traps[0].left.p1.x >> 16;
+       yDst = traps[0].left.p1.y >> 16;
+
+       miTrapezoidBounds (ntrap, traps, &bounds);
+       if (bounds.y1 >= bounds.y2 || bounds.x1 >= bounds.x2)
+           return;
+       pPicture = miCreateAlphaPicture (pScreen, pDst, maskFormat,
+                                        bounds.x2 - bounds.x1,
+                                        bounds.y2 - bounds.y1);
+       if (!pPicture)
+           return;
+       for (; ntrap; ntrap--, traps++)
+           (*ps->RasterizeTrapezoid) (pPicture, traps, 
+                                      -bounds.x1, -bounds.y1);
+       xRel = bounds.x1 + xSrc - xDst;
+       yRel = bounds.y1 + ySrc - yDst;
+       CompositePicture (op, pSrc, pPicture, pDst,
+                         xRel, yRel, 0, 0, bounds.x1, bounds.y1,
+                         bounds.x2 - bounds.x1,
+                         bounds.y2 - bounds.y1);
+       FreePicture (pPicture, 0);
+    }
+    else
+    {
+       if (pDst->polyEdge == PolyEdgeSharp)
+           maskFormat = PictureMatchFormat (pScreen, 1, PICT_a1);
+       else
+           maskFormat = PictureMatchFormat (pScreen, 8, PICT_a8);
+       for (; ntrap; ntrap--, traps++)
+           miTrapezoids (op, pSrc, pDst, maskFormat, xSrc, ySrc, 1, traps);
+    }
+}
diff --git a/render/mitri.c b/render/mitri.c
index 922f22a..bdca9ca 100644
--- a/render/mitri.c
+++ b/render/mitri.c
@@ -65,3 +65,64 @@ miTriangleBounds(int ntri, xTriangle * tris, BoxPtr bounds)
 {
     miPointFixedBounds(ntri * 3, (xPointFixed *) tris, bounds);
 }
+
+
+void
+miTriangles (CARD8	    op,
+	     PicturePtr	    pSrc,
+	     PicturePtr	    pDst,
+	     PictFormatPtr  maskFormat,
+	     INT16	    xSrc,
+	     INT16	    ySrc,
+	     int	    ntri,
+	     xTriangle	    *tris)
+{
+    ScreenPtr		pScreen = pDst->pDrawable->pScreen;
+    PictureScreenPtr    ps = GetPictureScreen(pScreen);
+    
+    /*
+     * Check for solid alpha add
+     */
+    if (op == PictOpAdd && miIsSolidAlpha (pSrc))
+    {
+	(*ps->AddTriangles) (pDst, 0, 0, ntri, tris);
+    }
+    else if (maskFormat)
+    {
+	BoxRec		bounds;
+	PicturePtr	pPicture;
+	INT16		xDst, yDst;
+	INT16		xRel, yRel;
+	
+	xDst = tris[0].p1.x >> 16;
+	yDst = tris[0].p1.y >> 16;
+
+	miTriangleBounds (ntri, tris, &bounds);
+	if (bounds.x2 <= bounds.x1 || bounds.y2 <= bounds.y1)
+	    return;
+	pPicture = miCreateAlphaPicture (pScreen, pDst, maskFormat,
+					 bounds.x2 - bounds.x1,
+					 bounds.y2 - bounds.y1);
+	if (!pPicture)
+	    return;
+	(*ps->AddTriangles) (pPicture, -bounds.x1, -bounds.y1, ntri, tris);
+	
+	xRel = bounds.x1 + xSrc - xDst;
+	yRel = bounds.y1 + ySrc - yDst;
+	CompositePicture (op, pSrc, pPicture, pDst,
+			  xRel, yRel, 0, 0, bounds.x1, bounds.y1,
+			  bounds.x2 - bounds.x1, bounds.y2 - bounds.y1);
+	FreePicture (pPicture, 0);
+    }
+    else
+    {
+	if (pDst->polyEdge == PolyEdgeSharp)
+	    maskFormat = PictureMatchFormat (pScreen, 1, PICT_a1);
+	else
+	    maskFormat = PictureMatchFormat (pScreen, 8, PICT_a8);
+	
+	for (; ntri; ntri--, tris++)
+	    miTriangles (op, pSrc, pDst, maskFormat, xSrc, ySrc, 1, tris);
+    }
+}
+
commit 672a4c1b34ad27581f39334f6706745c45626cc0
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Fri Apr 30 13:08:25 2010 -0700

    Workaround the GC clipping problem in miPaintWindow and add some debugging output.
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/mi/miexpose.c b/mi/miexpose.c
index e74b9c3..5360b73 100644
--- a/mi/miexpose.c
+++ b/mi/miexpose.c
@@ -408,7 +408,8 @@ void RootlessSetPixmapOfAncestors(WindowPtr pWin);
 void RootlessStartDrawing(WindowPtr pWin);
 void RootlessDamageRegion(WindowPtr pWin, RegionPtr prgn);
 Bool IsFramedWindow(WindowPtr pWin);
-#endif
+#include "../fb/fb.h"
+#endif 
 
 void
 miPaintWindow(WindowPtr pWin, RegionPtr prgn, int what)
@@ -437,23 +438,37 @@ miPaintWindow(WindowPtr pWin, RegionPtr prgn, int what)
     Bool solid = TRUE;
     DrawablePtr drawable = &pWin->drawable;
 
+#ifdef XQUARTZ_CLIP_DEBUG
+    ErrorF("START %d BS %d (pR = %ld)\n", what, pWin->backgroundState, ParentRelative);
+    ErrorF("      Rgn: %d %d %d %d\n", prgn->extents.x1, prgn->extents.y1,
+	                               prgn->extents.x2 - prgn->extents.x1,
+	                               prgn->extents.y2 - prgn->extents.y1);
+    ErrorF("      Win: %d %d (%d %d) %d %d\n", pWin->origin.x, pWin->origin.y,
+	                                       pWin->winSize.extents.x1, pWin->winSize.extents.y1,
+	                                       pWin->winSize.extents.x2 - pWin->winSize.extents.x1,
+					       pWin->winSize.extents.y2 - pWin->winSize.extents.y1);
+    ErrorF("     Draw: %d %d %d %d\n", pWin->drawable.x, pWin->drawable.y,
+				       pWin->drawable.width, pWin->drawable.height);
+#endif
+
 #ifdef ROOTLESS
     if (!drawable || drawable->type == UNDRAWABLE_WINDOW)
         return;
+#endif
+    
+    if (what == PW_BACKGROUND)
+    {
+#ifdef ROOTLESS
+        if(IsFramedWindow(pWin)) {
+            RootlessStartDrawing(pWin);
+            RootlessDamageRegion(pWin, prgn);
 
-    if (IsFramedWindow(pWin)) {
-        RootlessStartDrawing(pWin);
-        RootlessDamageRegion(pWin, prgn);
-
-        if (pWin->backgroundState == ParentRelative) {
-            if ((what == PW_BACKGROUND) ||
-                (what == PW_BORDER && !pWin->borderIsPixel))
+            if(pWin->backgroundState == ParentRelative) {
                 RootlessSetPixmapOfAncestors(pWin);
+            }
         }
-    }
 #endif
 
-    if (what == PW_BACKGROUND) {
         while (pWin->backgroundState == ParentRelative)
             pWin = pWin->parent;
 
@@ -478,6 +493,18 @@ miPaintWindow(WindowPtr pWin, RegionPtr prgn, int what)
     else {
         PixmapPtr pixmap;
 
+#ifdef ROOTLESS
+	if(IsFramedWindow(pWin)) {
+	    RootlessStartDrawing(pWin);
+	    RootlessDamageRegion(pWin, prgn);
+	    
+	    if(!pWin->borderIsPixel &&
+		pWin->backgroundState == ParentRelative) {
+		RootlessSetPixmapOfAncestors(pWin);
+	    }
+	}
+#endif
+
         tile_x_off = drawable->x;
         tile_y_off = drawable->y;
 
@@ -486,6 +513,12 @@ miPaintWindow(WindowPtr pWin, RegionPtr prgn, int what)
             return;
         pixmap = (*pScreen->GetWindowPixmap) ((WindowPtr) drawable);
         drawable = &pixmap->drawable;
+
+#ifdef XQUARTZ_CLIP_DEBUG
+        ErrorF("     Draw: %d %d %d %d\n",
+               drawable->x, drawable->y, drawable->width, drawable->height);    
+#endif
+	
 #ifdef COMPOSITE
         draw_x_off = pixmap->screen_x;
         draw_y_off = pixmap->screen_y;
@@ -548,6 +581,57 @@ miPaintWindow(WindowPtr pWin, RegionPtr prgn, int what)
     ChangeGC(NullClient, pGC, gcmask, gcval);
     ValidateGC(drawable, pGC);
 
+#ifdef XQUARTZ_CLIP_DEBUG
+    ErrorF("       GC: %d %d %d %d\n",
+	   pGC->pCompositeClip->extents.x1, pGC->pCompositeClip->extents.y1,
+	   pGC->pCompositeClip->extents.x2 - pGC->pCompositeClip->extents.x1,
+	   pGC->pCompositeClip->extents.y2 - pGC->pCompositeClip->extents.y1);
+#endif
+    
+#ifdef XQUARTZ
+    /* Looks like our clipping isn't set right for some reason:
+     * http://xquartz.macosforge.org/trac/ticket/290
+     */
+    if(what == PW_BORDER) {
+
+#if 0
+	if(solid) {
+#if 1
+	    fbFillRegionSolid(&pWin->drawable,
+			      prgn,
+			      0,
+			      fbReplicatePixel(fill.pixel,
+					       pWin->drawable.bitsPerPixel));
+#else
+	    fbFillRegionSolid(drawable,
+			      prgn,
+			      0,
+			      fbReplicatePixel(fill.pixel,
+					       drawable->bitsPerPixel));
+#endif
+	    return;
+	}
+#endif
+    
+	pGC->pCompositeClip->extents.x1 += prgn->extents.x1;
+	pGC->pCompositeClip->extents.y1 += prgn->extents.y1;
+	pGC->pCompositeClip->extents.x2 += prgn->extents.x1;
+	pGC->pCompositeClip->extents.y2 += prgn->extents.y1;
+	
+	if(pGC->pCompositeClip->extents.x2 > drawable->pScreen->width)
+	    pGC->pCompositeClip->extents.x2 = drawable->pScreen->width;
+	if(pGC->pCompositeClip->extents.y2 > drawable->pScreen->height)
+	    pGC->pCompositeClip->extents.y2 = drawable->pScreen->height;
+    }
+#endif
+
+#ifdef XQUARTZ_CLIP_DEBUG
+    ErrorF("       GC: %d %d %d %d\n",
+	   pGC->pCompositeClip->extents.x1, pGC->pCompositeClip->extents.y1,
+	   pGC->pCompositeClip->extents.x2 - pGC->pCompositeClip->extents.x1,
+	   pGC->pCompositeClip->extents.y2 - pGC->pCompositeClip->extents.y1);    
+#endif
+
     numRects = RegionNumRects(prgn);
     pbox = RegionRects(prgn);
     for (i = numRects; --i >= 0; pbox++, prect++) {
commit a7a7bc03d092d0224c5241dfd203f65763bb853c
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Fri Jan 13 12:00:57 2012 -0800

    sdksyms.sh: Use CPPFLAGS, not CFLAGS
    
    CFLAGS can include flags which are not useful to the preprocessor
    or can even cause it to fail.  This fixes a build issue on darwin
    when building for more than one architecture.
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>
    Reviewed-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/xfree86/Makefile.am b/hw/xfree86/Makefile.am
index d46bf0a..de86285 100644
--- a/hw/xfree86/Makefile.am
+++ b/hw/xfree86/Makefile.am
@@ -48,8 +48,7 @@ DIST_SUBDIRS = common ddc i2c x86emu int10 fbdevhw os-support \
 bin_PROGRAMS = Xorg
 nodist_Xorg_SOURCES = sdksyms.c
 
-AM_CFLAGS = $(DIX_CFLAGS) @XORG_CFLAGS@
-AM_CPPFLAGS = $(XORG_INCS) -I$(srcdir)/parser -I$(top_srcdir)/miext/cw \
+AM_CPPFLAGS = $(DIX_CFLAGS) @XORG_CFLAGS@ $(XORG_INCS) -I$(srcdir)/parser -I$(top_srcdir)/miext/cw \
 	-I$(srcdir)/ddc -I$(srcdir)/i2c -I$(srcdir)/modes -I$(srcdir)/ramdac \
 	-I$(srcdir)/dri -I$(srcdir)/dri2 -I$(top_srcdir)/dri3
 
@@ -135,7 +134,7 @@ CLEANFILES = sdksyms.c sdksyms.dep Xorg.sh
 EXTRA_DIST += sdksyms.sh
 
 sdksyms.dep sdksyms.c: sdksyms.sh
-	$(AM_V_GEN)CPP='$(CPP)' AWK='$(AWK)' $(SHELL) $(srcdir)/sdksyms.sh $(top_srcdir) $(CFLAGS) $(AM_CFLAGS) $(AM_CPPFLAGS)
+	$(AM_V_GEN)CPP='$(CPP)' AWK='$(AWK)' $(SHELL) $(srcdir)/sdksyms.sh $(top_srcdir) $(CPPFLAGS) $(AM_CPPFLAGS)
 
 SDKSYMS_DEP = sdksyms.dep
 -include $(SDKSYMS_DEP)
commit 96143d6dc35c98cb6b4e409dd89687e4ced3c1f0
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Fri Oct 31 09:32:35 2014 +1000

    dix: silence compiler warning comparing CARD32 to -1
    
    window.c:3246:36: warning: comparison of constant -1 with expression of type
    'CARD32' (aka 'unsigned int') is always true
    [-Wtautological-constant-out-of-range-compare]
        if (optional->backingBitPlanes != ~0L)
                ~~~~~~~~~~~~~~~~~~~~~~~~~~ ^  ~~~
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Michel Dänzer <michel at daenzer.net>

diff --git a/dix/window.c b/dix/window.c
index d43ef03..9019852 100644
--- a/dix/window.c
+++ b/dix/window.c
@@ -3243,7 +3243,7 @@ CheckWindowOptionalNeed(WindowPtr w)
         return;
     if (optional->userProps != NULL)
         return;
-    if (optional->backingBitPlanes != ~0L)
+    if (optional->backingBitPlanes != (CARD32)~0L)
         return;
     if (optional->backingPixel != 0)
         return;
commit 04ca16997994c7561ed8948b89fc1c922233da13
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Fri Oct 31 09:29:33 2014 +1000

    dix: silence compiler warning
    
    inpututils.c:243:26: warning: comparison of constant 256 with expression of
    type 'KeyCode' (aka 'unsigned char') is always false
    [-Wtautological-constant-out-of-range-compare]
            if (modkeymap[i] >= MAP_LENGTH)
                        ~~~~~~~~~~~~ ^  ~~~~~~~~~~
    
    MAP_LENGTH depends on MAX_BUTTONS which is somewhat arbitrarily chosen. We
    don't expect this to ever change, but just in case leave the condition there
    so the code is correct if we drop the number down.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/dix/inpututils.c b/dix/inpututils.c
index e5bcc31..5c2a32d 100644
--- a/dix/inpututils.c
+++ b/dix/inpututils.c
@@ -239,8 +239,10 @@ build_modmap_from_modkeymap(CARD8 *modmap, KeyCode *modkeymap,
         if (!modkeymap[i])
             continue;
 
+#if MAP_LENGTH < 256
         if (modkeymap[i] >= MAP_LENGTH)
             return BadValue;
+#endif
 
         if (modmap[modkeymap[i]])
             return BadValue;
commit 79b9d33545034f2952ebc7e444c201693b45f44b
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Fri Oct 31 09:26:28 2014 +1000

    xwayland: declare fatal log handler as noreturn
    
    xwayland.c:661:1: warning: function 'xwl_log_handler' could be declared with
    attribute 'noreturn' [-Wmissing-noreturn]
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/hw/xwayland/xwayland.c b/hw/xwayland/xwayland.c
index 9132969..37d6d82 100644
--- a/hw/xwayland/xwayland.c
+++ b/hw/xwayland/xwayland.c
@@ -656,6 +656,7 @@ xwl_screen_init(ScreenPtr pScreen, int argc, char **argv)
     return ret;
 }
 
+_X_NORETURN
 static void _X_ATTRIBUTE_PRINTF(1, 0)
 xwl_log_handler(const char *format, va_list args)
 {
commit adee4f239b5074d318dfc48beb0ec4e91973b449
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Fri Oct 31 09:24:50 2014 +1000

    xfree86: drop double-typedef of DBusConnection
    
    Just include dbus.h, it's been typedef'd there since 2003.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/hw/xfree86/common/Makefile.am b/hw/xfree86/common/Makefile.am
index 7a2b4bc..54e7f4d 100644
--- a/hw/xfree86/common/Makefile.am
+++ b/hw/xfree86/common/Makefile.am
@@ -103,4 +103,8 @@ if LNXACPI
 XORG_CFLAGS += -DHAVE_ACPI
 endif
 
+if NEED_DBUS
+XORG_CFLAGS += $(DBUS_CFLAGS)
+endif
+
 AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS)
diff --git a/include/dbus-core.h b/include/dbus-core.h
index b2d6d1b..d6260dc 100644
--- a/include/dbus-core.h
+++ b/include/dbus-core.h
@@ -27,7 +27,7 @@
 #define DBUS_CORE_H
 
 #ifdef NEED_DBUS
-typedef struct DBusConnection DBusConnection;
+#include <dbus/dbus.h>
 
 typedef void (*dbus_core_connect_hook) (DBusConnection * connection,
                                                void *data);
commit 25315ee555dfeb96d9ed83064b1022ed852b612e
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Fri Oct 31 09:16:28 2014 +1000

    Xext: fix clang compiler warning
    
    shm.c:1150:24: warning: equality comparison with extraneous parentheses
    [-Wparentheses-equality]
        if ((shmdesc->addr == ((char *) -1))) {
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/Xext/shm.c b/Xext/shm.c
index b787918..30f688a 100644
--- a/Xext/shm.c
+++ b/Xext/shm.c
@@ -1147,7 +1147,7 @@ ProcShmAttachFd(ClientPtr client)
                          fd, 0);
 
     close(fd);
-    if ((shmdesc->addr == ((char *) -1))) {
+    if (shmdesc->addr == ((char *) -1)) {
         free(shmdesc);
         return BadAccess;
     }
@@ -1237,7 +1237,7 @@ ProcShmCreateSegment(ClientPtr client)
                          MAP_SHARED,
                          fd, 0);
 
-    if ((shmdesc->addr == ((char *) -1))) {
+    if (shmdesc->addr == ((char *) -1)) {
         close(fd);
         free(shmdesc);
         return BadAccess;
commit 995ecfb51d4ab8197e4591d5c0957e08a0bd6a59
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Thu Oct 30 09:00:21 2014 +1000

    include: change RegionSize() to take a size_t
    
    /usr/include/xorg/regionstr.h:130:36: warning: implicit conversion changes
    signedness: 'int' to 'unsigned long' [-Wsign-conversion]
        return (sizeof(RegDataRec) + ((n) * sizeof(BoxRec)));
                                       ^  ~
    
    Really only just pushes the problem to the caller, but maybe that motivates
    someone to fix it.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/include/regionstr.h b/include/regionstr.h
index 4a0725d..515e93f 100644
--- a/include/regionstr.h
+++ b/include/regionstr.h
@@ -125,7 +125,7 @@ RegionEnd(RegionPtr reg)
 }
 
 static inline size_t
-RegionSizeof(int n)
+RegionSizeof(size_t n)
 {
     return (sizeof(RegDataRec) + ((n) * sizeof(BoxRec)));
 }
commit 3ccec1b5ba6a26a30f82ba3aa9c5218dfa336869
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Thu Oct 30 08:56:55 2014 +1000

    include: fix documentation for list.h
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com>

diff --git a/include/list.h b/include/list.h
index 455c670..39f1985 100644
--- a/include/list.h
+++ b/include/list.h
@@ -117,7 +117,7 @@ struct xorg_list {
  * Example:
  * xorg_list_init(&bar->list_of_foos);
  *
- * @param The list to initialized.
+ * @param list The list to initialize
  */
 static inline void
 xorg_list_init(struct xorg_list *list)
commit b227d974569b4c315a72b85fe839c5f455396678
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Thu Oct 30 08:54:11 2014 +1000

    include: fix compiler warning about casting int to uint16_t
    
    /usr/include/xorg/misc.h:141:30: warning: implicit conversion loses integer
    precision: 'int' to 'uint16_t' (aka 'unsigned short') [-Wconversion]
        return ((x & 0xff) << 8) | ((x >> 8) & 0xff);
            ~~~~~~ ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
    
    Function sig is a uint16_t, so just force the cast.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/include/misc.h b/include/misc.h
index 9c2f573..f5b85ee 100644
--- a/include/misc.h
+++ b/include/misc.h
@@ -138,7 +138,7 @@ lswapl(uint32_t x)
 static inline uint16_t
 lswaps(uint16_t x)
 {
-    return ((x & 0xff) << 8) | ((x >> 8) & 0xff);
+    return (uint16_t)((x & 0xff) << 8) | ((x >> 8) & 0xff);
 }
 
 #undef min
commit e9db7682028bb0464c211c1f7bb6983fcfb6f37b
Author: Keith Packard <keithp at keithp.com>
Date:   Tue Oct 28 21:32:24 2014 -0700

    Update to version 1.16.99.901
    
    1.17 RC1
    
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/configure.ac b/configure.ac
index bf385b3..140e33e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -26,9 +26,9 @@ dnl
 dnl Process this file with autoconf to create configure.
 
 AC_PREREQ(2.60)
-AC_INIT([xorg-server], 1.16.99.1, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server)
-RELEASE_DATE="2014-07-17"
-RELEASE_NAME="Baba Ghanouj"
+AC_INIT([xorg-server], 1.16.99.901, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server)
+RELEASE_DATE="2014-10-28"
+RELEASE_NAME="Chanterelle"
 AC_CONFIG_SRCDIR([Makefile.am])
 AC_CONFIG_MACRO_DIR([m4])
 AM_INIT_AUTOMAKE([foreign dist-bzip2])
commit 5ff74d68b0cce85e041251efdc76595eac3c89e4
Author: Keith Packard <keithp at keithp.com>
Date:   Tue Oct 28 21:31:40 2014 -0700

    xfree86: Include 'drivers' directory with distribution
    
    Even if we don't build it locally, make sure it gets included with the release.
    
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/xfree86/Makefile.am b/hw/xfree86/Makefile.am
index 30f7c8f..d46bf0a 100644
--- a/hw/xfree86/Makefile.am
+++ b/hw/xfree86/Makefile.am
@@ -43,7 +43,7 @@ SUBDIRS = common ddc x86emu $(INT10_SUBDIR) os-support parser \
 DIST_SUBDIRS = common ddc i2c x86emu int10 fbdevhw os-support \
                parser ramdac shadowfb vbe vgahw \
                loader dixmods dri dri2 exa modes \
-	       utils doc man glamor_egl
+	       utils doc man glamor_egl drivers
 
 bin_PROGRAMS = Xorg
 nodist_Xorg_SOURCES = sdksyms.c
commit f36f16f0551aa091c1ff154875aebe3d29cf51e7
Author: Keith Packard <keithp at keithp.com>
Date:   Tue Oct 28 21:30:23 2014 -0700

    dri2: Distribute new pci_ids headers
    
    Create hw/xfree86/dri2/pci_ids/Makefile.am which includes all of the new
    pci id files in the tarballs. Build that from configure.ac, and run it
    from dri2/Makefile.am
    
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/configure.ac b/configure.ac
index fee048e..bf385b3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2556,6 +2556,7 @@ hw/xfree86/dixmods/Makefile
 hw/xfree86/doc/Makefile
 hw/xfree86/dri/Makefile
 hw/xfree86/dri2/Makefile
+hw/xfree86/dri2/pci_ids/Makefile
 hw/xfree86/drivers/Makefile
 hw/xfree86/drivers/modesetting/Makefile
 hw/xfree86/exa/Makefile
diff --git a/hw/xfree86/dri2/Makefile.am b/hw/xfree86/dri2/Makefile.am
index 502a2ee..78e507b 100644
--- a/hw/xfree86/dri2/Makefile.am
+++ b/hw/xfree86/dri2/Makefile.am
@@ -1,3 +1,5 @@
+SUBDIRS=pci_ids
+
 noinst_LTLIBRARIES = libdri2.la
 AM_CFLAGS = \
 	-DHAVE_XORG_CONFIG_H \
diff --git a/hw/xfree86/dri2/pci_ids/Makefile.am b/hw/xfree86/dri2/pci_ids/Makefile.am
new file mode 100644
index 0000000..c511108
--- /dev/null
+++ b/hw/xfree86/dri2/pci_ids/Makefile.am
@@ -0,0 +1,11 @@
+EXTRA_DIST = \
+	pci_id_driver_map.h \
+	i810_pci_ids.h \
+	i915_pci_ids.h \
+	i965_pci_ids.h \
+	r200_pci_ids.h \
+	r300_pci_ids.h \
+	r600_pci_ids.h \
+	radeon_pci_ids.h \
+	radeonsi_pci_ids.h \
+	vmwgfx_pci_ids.h
commit 65dd1ba7b3e00243a76ec691e566ef7c8dd94855
Author: Keith Packard <keithp at keithp.com>
Date:   Wed Oct 22 14:48:10 2014 -0700

    dix: Untwist transformAbsolute logic, eliminate uninitialized value warnings
    
    tranformAbsolute has a pretty simple job, that of running the X/Y
    values from a device through the transformation matrix. The tricky bit
    comes when the current device state doesn't include one of the
    values. In that case, the last delivered value is back-converted to
    device space and used instead.
    
    The logic was twisted though, confusing GCC's uninitialized value
    detection logic and emitting warnings.
    
    This has been fixed by changing the code to:
    
     1) Detect whether the ValuatorMask includes X/Y values
     2) If either are missing, back-convert the current values into ox/oy
     3) When X/Y are present, set ox/oy to the current value
     4) Transform
     5) Store X/Y values if changed or if they were set before.
    
    Signed-off-by: Keith Packard <keithp at keithp.com>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/dix/getevents.c b/dix/getevents.c
index ffa89fa..dd96265 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -1248,8 +1248,8 @@ transformAbsolute(DeviceIntPtr dev, ValuatorMask *mask)
     double x, y, ox, oy;
     int has_x, has_y;
 
-    has_x = valuator_mask_fetch_double(mask, 0, &ox);
-    has_y = valuator_mask_fetch_double(mask, 1, &oy);
+    has_x = valuator_mask_isset(mask, 0);
+    has_y = valuator_mask_isset(mask, 1);
 
     if (!has_x && !has_y)
         return;
@@ -1263,23 +1263,23 @@ transformAbsolute(DeviceIntPtr dev, ValuatorMask *mask)
 
         pixman_f_transform_invert(&invert, &dev->scale_and_transform);
         transform(&invert, &ox, &oy);
-
-        x = ox;
-        y = oy;
     }
 
-    if (valuator_mask_isset(mask, 0))
-        ox = x = valuator_mask_get_double(mask, 0);
+    if (has_x)
+        ox = valuator_mask_get_double(mask, 0);
 
-    if (valuator_mask_isset(mask, 1))
-        oy = y = valuator_mask_get_double(mask, 1);
+    if (has_y)
+        oy = valuator_mask_get_double(mask, 1);
+
+    x = ox;
+    y = oy;
 
     transform(&dev->scale_and_transform, &x, &y);
 
-    if (valuator_mask_isset(mask, 0) || ox != x)
+    if (has_x || ox != x)
         valuator_mask_set_double(mask, 0, x);
 
-    if (valuator_mask_isset(mask, 1) || oy != y)
+    if (has_y || oy != y)
         valuator_mask_set_double(mask, 1, y);
 }
 
commit 0fbbdb37c87b5824729f65c7fbac05223024fd27
Author: Adam Jackson <ajax at redhat.com>
Date:   Wed Oct 22 13:19:18 2014 -0400

    composite: Wrap GetSpans
    
    GetSpans should flush composition from children to parent, just like
    GetImage and SourceValidate.  Fortunately no one is likely to have
    noticed, since to hit this you're already deep into failure town.
    
    Signed-off-by: Adam Jackson <ajax at redhat.com>
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/composite/compinit.c b/composite/compinit.c
index 111c16e..10433a1 100644
--- a/composite/compinit.c
+++ b/composite/compinit.c
@@ -78,6 +78,7 @@ compCloseScreen(ScreenPtr pScreen)
     pScreen->PositionWindow = cs->PositionWindow;
 
     pScreen->GetImage = cs->GetImage;
+    pScreen->GetSpans = cs->GetSpans;
     pScreen->SourceValidate = cs->SourceValidate;
 
     free(cs);
@@ -151,6 +152,21 @@ compGetImage(DrawablePtr pDrawable,
 }
 
 static void
+compGetSpans(DrawablePtr pDrawable, int wMax, DDXPointPtr ppt, int *pwidth,
+             int nspans, char *pdstStart)
+{
+    ScreenPtr pScreen = pDrawable->pScreen;
+    CompScreenPtr cs = GetCompScreen(pScreen);
+
+    pScreen->GetSpans = cs->GetSpans;
+    if (pDrawable->type == DRAWABLE_WINDOW)
+        compPaintChildrenToWindow((WindowPtr) pDrawable);
+    (*pScreen->GetSpans) (pDrawable, wMax, ppt, pwidth, nspans, pdstStart);
+    cs->GetSpans = pScreen->GetSpans;
+    pScreen->GetSpans = compGetSpans;
+}
+
+static void
 compSourceValidate(DrawablePtr pDrawable,
                    int x, int y,
                    int width, int height, unsigned int subWindowMode)
@@ -432,6 +448,9 @@ compScreenInit(ScreenPtr pScreen)
     cs->GetImage = pScreen->GetImage;
     pScreen->GetImage = compGetImage;
 
+    cs->GetSpans = pScreen->GetSpans;
+    pScreen->GetSpans = compGetSpans;
+
     cs->SourceValidate = pScreen->SourceValidate;
     pScreen->SourceValidate = compSourceValidate;
 
diff --git a/composite/compint.h b/composite/compint.h
index 56b76c5..f06b846 100644
--- a/composite/compint.h
+++ b/composite/compint.h
@@ -168,6 +168,7 @@ typedef struct _CompScreen {
     CompOverlayClientPtr pOverlayClients;
 
     GetImageProcPtr GetImage;
+    GetSpansProcPtr GetSpans;
     SourceValidateProcPtr SourceValidate;
 } CompScreenRec, *CompScreenPtr;
 
commit da70c7d556bbf21ad495c26e982e2e0f2d7de6c1
Author: Keith Packard <keithp at keithp.com>
Date:   Wed Oct 22 14:27:26 2014 -0700

    xkb: Initialize 'bad' Atom in _XkbSetNamesCheck
    
    When _XkbCheckAtoms returns NULL for an error, it always sets the
    error return code, but GCC can't figure that out, so just initialize
    the local variable, 'bad', in _XkbSetNamesCheck to eliminate the warning.
    
    Signed-off-by: Keith Packard <keithp at keithp.com>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/xkb/xkb.c b/xkb/xkb.c
index dc570f0..fdc5923 100644
--- a/xkb/xkb.c
+++ b/xkb/xkb.c
@@ -3986,7 +3986,7 @@ _XkbSetNamesCheck(ClientPtr client, DeviceIntPtr dev,
 {
     XkbDescRec *xkb;
     CARD32 *tmp;
-    Atom bad;
+    Atom bad = None;
 
     tmp = data;
     xkb = dev->key->xkbInfo->desc;
commit 2566835b4374edb3e5a8353d4f7c9e7ec4851c57
Author: Keith Packard <keithp at keithp.com>
Date:   Wed Oct 22 14:24:55 2014 -0700

    os: Eliminate uninitialized value warnings from access.c
    
    The ConvertAddr function doesn't reliably set the 'addr' return value,
    and so callers are getting flagged for using potentially uninitialized
    values. Initialize the value in the callers to NULL and then go ahead
    and check for NULL values before using them.
    
    Signed-off-by: Keith Packard <keithp at keithp.com>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/os/access.c b/os/access.c
index 125f35f..fe01420 100644
--- a/os/access.c
+++ b/os/access.c
@@ -835,7 +835,7 @@ ResetHosts(const char *display)
     } saddr;
 #endif
     int family = 0;
-    void *addr;
+    void *addr = NULL;
     int len;
 
     siTypesInitialize();
@@ -928,8 +928,8 @@ ResetHosts(const char *display)
                             len = a->ai_addrlen;
                             f = ConvertAddr(a->ai_addr, &len,
                                             (void **) &addr);
-                            if ((family == f) ||
-                                ((family == FamilyWild) && (f != -1))) {
+                            if (addr && ((family == f) ||
+                                         ((family == FamilyWild) && (f != -1)))) {
                                 NewHost(f, addr, len, FALSE);
                             }
                         }
@@ -1359,7 +1359,7 @@ int
 InvalidHost(register struct sockaddr *saddr, int len, ClientPtr client)
 {
     int family;
-    void *addr;
+    void *addr = NULL;
     register HOST *selfhost, *host;
 
     if (!AccessEnabled)         /* just let them in */
@@ -1386,12 +1386,12 @@ InvalidHost(register struct sockaddr *saddr, int len, ClientPtr client)
     }
     for (host = validhosts; host; host = host->next) {
         if (host->family == FamilyServerInterpreted) {
-            if (siAddrMatch(family, addr, len, host, client)) {
+            if (addr && siAddrMatch(family, addr, len, host, client)) {
                 return 0;
             }
         }
         else {
-            if (addrEqual(family, addr, len, host))
+            if (addr && addrEqual(family, addr, len, host))
                 return 0;
         }
 
@@ -1648,7 +1648,7 @@ siHostnameAddrMatch(int family, void *addr, int len,
         struct addrinfo *addresses;
         struct addrinfo *a;
         int f, hostaddrlen;
-        void *hostaddr;
+        void *hostaddr = NULL;
 
         if (siAddrLen >= sizeof(hostname))
             return FALSE;
@@ -1659,7 +1659,7 @@ siHostnameAddrMatch(int family, void *addr, int len,
             for (a = addresses; a != NULL; a = a->ai_next) {
                 hostaddrlen = a->ai_addrlen;
                 f = ConvertAddr(a->ai_addr, &hostaddrlen, &hostaddr);
-                if ((f == family) && (len == hostaddrlen) &&
+                if ((f == family) && (len == hostaddrlen) && hostaddr &&
                     (memcmp(addr, hostaddr, len) == 0)) {
                     res = TRUE;
                     break;
commit 1b94fd77792310c80b0a2bcf4bf6d4e4c4c23bca
Author: Alex Orange <crazycasta at gmail.com>
Date:   Fri Oct 3 15:41:38 2014 -0600

    fb: Fix Bresenham algorithms for commonly used small segments.
    
    Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=54168
    
    Fix errors introducted in 863d528a9f76d0e8f122aebf19f8564a4c67a938. Said
    patch does indeed remove the problematic writes to bad memory, however
    it also introduces errors in the algoritm. This patch has the effect of
    reverting said patch and adding an if in the proper location to catch
    the out of bounds memory write without causing problems to the overall
    algorithm.
    
    Signed-off-by: Alex Orange <crazycasta at gmail.com>
    Reviewed-by: Peter Harris <pharris at opentext.com>
    Tested-by: Peter Harris <pharris at opentext.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/fb/fbseg.c b/fb/fbseg.c
index 36b17e3..c3c196a 100644
--- a/fb/fbseg.c
+++ b/fb/fbseg.c
@@ -65,12 +65,6 @@ fbBresSolid(DrawablePtr pDrawable,
     if (axis == X_AXIS) {
         bits = 0;
         while (len--) {
-            if (e >= 0) {
-                WRITE(dst, FbDoMaskRRop (READ(dst), and, xor, bits));
-                bits = 0;
-                dst += dstStride;
-                e += e3;
-            }
             bits |= mask;
             mask = fbBresShiftMask(mask, signdx, dstBpp);
             if (!mask) {
@@ -80,12 +74,23 @@ fbBresSolid(DrawablePtr pDrawable,
                 mask = mask0;
             }
             e += e1;
+            if (e >= 0) {
+                if (bits) {
+                    WRITE(dst, FbDoMaskRRop (READ(dst), and, xor, bits));
+                    bits = 0;
+                }
+                dst += dstStride;
+                e += e3;
+            }
         }
         if (bits)
             WRITE(dst, FbDoMaskRRop(READ(dst), and, xor, bits));
     }
     else {
         while (len--) {
+            WRITE(dst, FbDoMaskRRop(READ(dst), and, xor, mask));
+            dst += dstStride;
+            e += e1;
             if (e >= 0) {
                 e += e3;
                 mask = fbBresShiftMask(mask, signdx, dstBpp);
@@ -94,9 +99,6 @@ fbBresSolid(DrawablePtr pDrawable,
                     mask = mask0;
                 }
             }
-            WRITE(dst, FbDoMaskRRop(READ(dst), and, xor, mask));
-            dst += dstStride;
-            e += e1;
         }
     }
 
commit ea5b2b0a2e2143ad1414fcbdc081b5d584588346
Author: Jon TURNEY <jon.turney at dronecode.org.uk>
Date:   Tue Oct 21 15:03:55 2014 +0100

    os: -displayfd should check ports up to 65535
    
    -displayfd should check ports up to 65535
    
    Noticed during https://cygwin.com/ml/cygwin-xfree/2014-07/msg00024.html
    
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Reviewed-by: Adam Jackson <ajax at redhat.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/os/connection.c b/os/connection.c
index f915e12..d53bd34 100644
--- a/os/connection.c
+++ b/os/connection.c
@@ -421,7 +421,7 @@ CreateWellKnownSockets(void)
     }
     else { /* -displayfd and no explicit display number */
         Bool found = 0;
-        for (i = 0; i < 65535 - X_TCP_PORT; i++) {
+        for (i = 0; i < 65536 - X_TCP_PORT; i++) {
             if (TryCreateSocket(i, &partial) && !partial) {
                 found = 1;
                 break;
commit 3a123fbdda56b24dc01a2308137144dc960e0d61
Merge: 9b29fa9 7ea4a21
Author: Keith Packard <keithp at keithp.com>
Date:   Mon Oct 27 15:39:26 2014 -0700

    Merge remote-tracking branch 'jturney/master'
    
    Conflicts:
    	hw/xwin/winpixmap.c
    
    Adam removed a pile of windows code, including this file.

commit 9b29fa957a397664463c7c78fbcc2f34d1993271
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Oct 16 14:09:08 2014 +0100

    Xext/shm: Detach SHM segment after Pixmap is released
    
    The GPU may still have a reference to the SHM segment which would only
    be finally released when the Pixmap is destroy. So we can only detach
    the SHM segment (and thereby making the memory unaccessible) after the
    backend has had a chance to flush any remaining references.
    
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=85058
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
    Reported-and-tested-by: gedgon at gmail.com
    Reviewed-by: Adam Jackson <ajax at redhat.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/Xext/shm.c b/Xext/shm.c
index 4dad8b6..b787918 100644
--- a/Xext/shm.c
+++ b/Xext/shm.c
@@ -248,21 +248,20 @@ ShmDestroyPixmap(PixmapPtr pPixmap)
 {
     ScreenPtr pScreen = pPixmap->drawable.pScreen;
     ShmScrPrivateRec *screen_priv = ShmGetScreenPriv(pScreen);
+    void *shmdesc = NULL;
     Bool ret;
 
-    if (pPixmap->refcnt == 1) {
-        ShmDescPtr shmdesc;
-
-        shmdesc = (ShmDescPtr) dixLookupPrivate(&pPixmap->devPrivates,
-                                                shmPixmapPrivateKey);
-        if (shmdesc)
-            ShmDetachSegment((void *) shmdesc, pPixmap->drawable.id);
-    }
+    if (pPixmap->refcnt == 1)
+        shmdesc = dixLookupPrivate(&pPixmap->devPrivates, shmPixmapPrivateKey);
 
     pScreen->DestroyPixmap = screen_priv->destroyPixmap;
     ret = (*pScreen->DestroyPixmap) (pPixmap);
     screen_priv->destroyPixmap = pScreen->DestroyPixmap;
     pScreen->DestroyPixmap = ShmDestroyPixmap;
+
+    if (shmdesc)
+	ShmDetachSegment(shmdesc, pPixmap->drawable.id);
+
     return ret;
 }
 
commit 5adc20179e9818d51e1cd79bfc8a8271786c3949
Author: Keith Packard <keithp at keithp.com>
Date:   Mon Oct 27 15:28:14 2014 -0700

    modesetting: Skip kernel work-around on error in crtc to kernel msc
    
    ms_crtc_msc_to_kernel_msc attempts to work around kernel
    inconsistencies in reporting msc values by comparing the expected
    value with the reported value. If the kernel fails to
    actually provide its current values, then just skip the work around
    steps as there's really nothing better we can do.
    
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/xfree86/drivers/modesetting/vblank.c b/hw/xfree86/drivers/modesetting/vblank.c
index 35cadb2..5031ef8 100644
--- a/hw/xfree86/drivers/modesetting/vblank.c
+++ b/hw/xfree86/drivers/modesetting/vblank.c
@@ -228,17 +228,18 @@ ms_crtc_msc_to_kernel_msc(xf86CrtcPtr crtc, uint64_t expect)
     uint64_t ust;
     int64_t diff;
 
-    ms_get_crtc_ust_msc(crtc, &ust, &msc);
-    diff = expect - msc;
-
-    /* We're way off here, assume that the kernel has lost its mind
-     * and smack the vblank back to something sensible
-     */
-    if (diff < -MAX_VBLANK_OFFSET || MAX_VBLANK_OFFSET < diff) {
-        drmmode_crtc->vblank_offset += (int32_t) diff;
-        if (drmmode_crtc->vblank_offset > -MAX_VBLANK_OFFSET &&
-            drmmode_crtc->vblank_offset < MAX_VBLANK_OFFSET)
-            drmmode_crtc->vblank_offset = 0;
+    if (ms_get_crtc_ust_msc(crtc, &ust, &msc) == Success) {
+        diff = expect - msc;
+
+        /* We're way off here, assume that the kernel has lost its mind
+         * and smack the vblank back to something sensible
+         */
+        if (diff < -MAX_VBLANK_OFFSET || MAX_VBLANK_OFFSET < diff) {
+            drmmode_crtc->vblank_offset += (int32_t) diff;
+            if (drmmode_crtc->vblank_offset > -MAX_VBLANK_OFFSET &&
+                drmmode_crtc->vblank_offset < MAX_VBLANK_OFFSET)
+                drmmode_crtc->vblank_offset = 0;
+        }
     }
     return (uint32_t) (expect - drmmode_crtc->vblank_offset);
 }
commit 59b12c454d9c4b5a26c6ad87c53abc671b15ce37
Merge: 5574a0a cac4b06
Author: Keith Packard <keithp at keithp.com>
Date:   Mon Oct 27 14:48:55 2014 -0700

    Merge remote-tracking branch 'anholt/modesetting-dri2-no-pageflip'

commit 5574a0a07e83ff989c074c44d3ea9db0a819f472
Author: Keith Packard <keithp at keithp.com>
Date:   Mon Oct 27 13:38:21 2014 -0700

    composite: Skip SetWindowPixmap when pixmap isn't changing
    
    Check the current window pixmap to see if it matches the new pixmap
    and avoid calling SetWindowPixmap in that case.
    
    x11perf -ucreate highlights an instance where compCreateWindow reassigns
    the same Pixmap to the Window. Currently this triggers an expensive
    invalidation of the entire window hierachy, making sure that DRI2
    clients are kept informed of the handle changes. However, as the backing
    Pixmap for the Window is actually unchanged, there is no need to
    do anything in this case.
    
    Signed-off-by: Keith Packard <keithp at keithp.com>
    Reviewed-by: Chris Wilson <chris at chris-wilson.co.uk>
    Tested-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/composite/compwindow.c b/composite/compwindow.c
index 9a6b2da..77bdfa2 100644
--- a/composite/compwindow.c
+++ b/composite/compwindow.c
@@ -567,10 +567,11 @@ compCreateWindow(WindowPtr pWin)
     if (pWin->parent && ret) {
         CompSubwindowsPtr csw = GetCompSubwindows(pWin->parent);
         CompClientWindowPtr ccw;
+        PixmapPtr parent_pixmap = (*pScreen->GetWindowPixmap)(pWin->parent);
+        PixmapPtr window_pixmap = (*pScreen->GetWindowPixmap)(pWin);
 
-        (*pScreen->SetWindowPixmap) (pWin,
-                                     (*pScreen->GetWindowPixmap) (pWin->
-                                                                  parent));
+        if (window_pixmap != parent_pixmap)
+            (*pScreen->SetWindowPixmap) (pWin, parent_pixmap);
         if (csw)
             for (ccw = csw->clients; ccw; ccw = ccw->next)
                 compRedirectWindow(clients[CLIENT_ID(ccw->id)],
commit df6a3a07f60c40bab2b59b9b3ba0c20c8fb7e95d
Author: Yogish Kulkarni <yogishk at nvidia.com>
Date:   Wed Oct 22 12:55:28 2014 +0530

    Skip SetCursor when vtSema is FALSE.
    
    Consider below sequence -
    1) Cursor is removed : isUp will be FALSE if HW cursor is set.
    2) VT switched away from X : vtSema becomes FALSE.
    3) xf86CursorSetCursor is called with non-null CursorPtr :
    Saves the passed in CursorPtr, fallbacks to SW cursor and invokes
    spriteFuncs->SetCursor which saves the area under cursor and restores
    the cursor. This sets isUp to TRUE and as vtSema is FALSE saved data
    is garbage.
    4) VT switched to X : vtSema becomes TRUE. xf86Cursor enable fb access
    is called which will remove the SW cursor, i.e copies saved data in #3
    to screen.
    
    This results to momentary garbage data on screen. Hence when !vtSema
    skip spriteFuncs->SetCursor.
    
    X.Org Bug 85313 <https://bugs.freedesktop.org/show_bug.cgi?id=85313>
    
    Signed-off-by: Yogish Kulkarni <yogishk at nvidia.com>
    Reviewed-by: Adam Jackson <ajax at redhat.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/xfree86/ramdac/xf86Cursor.c b/hw/xfree86/ramdac/xf86Cursor.c
index fac6822..4ff1b59 100644
--- a/hw/xfree86/ramdac/xf86Cursor.c
+++ b/hw/xfree86/ramdac/xf86Cursor.c
@@ -332,8 +332,10 @@ xf86CursorSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCurs,
         ScreenPriv->HotX = cursor->bits->xhot;
         ScreenPriv->HotY = cursor->bits->yhot;
 
-        if (!infoPtr->pScrn->vtSema)
+        if (!infoPtr->pScrn->vtSema) {
             ScreenPriv->SavedCursor = cursor;
+            return;
+        }
 
         if (infoPtr->pScrn->vtSema && xorg_list_is_empty(&pScreen->pixmap_dirty_list) &&
             (ScreenPriv->ForceHWCursorCount ||
commit cac4b064f9f66435430f61568c6a516c54bf3c40
Author: Eric Anholt <eric at anholt.net>
Date:   Mon Dec 30 17:23:38 2013 -0800

    modesetting: Add support for DRI2 with glamor.
    
    This is derived from the intel driver DRI2 code, with swapchain and
    pageflipping dropped, functions renamed, and vblank event management
    shared code moved to a vblank.c for reuse by Present.
    
    This allows AIGLX to load, which means that you get appropriate
    visuals exposed in GL, along with many extensions under
    direct-rendering that require presence in GLX (which aren't supported
    in glxdriswrast.c).
    
    v2: Drop unused header includes in pageflip.c, wrap in #ifdef GLAMOR.
        Drop triple-buffering, which was totally broken in practice (I'll
        try to fix this later).  Fix up some style nits.  Document the
        general flow of pageflipping and why, rename the DRI2 frame event
        type enums to reflect what they're for, and handle them in a
        single switch statement so you can understand the state machine
        more easily.
    v3: Drop pageflipping entirely -- it's unstable on my Intel laptop
        (not that the normal 2D driver is stable with pageflipping for
        me), and I won't get it fixed before the merge window.  It now
        passes all of the OML_sync_control tests from Jamey and Theo
        (except for occasional warns in timing -fullscreen -divisor 2).
    v4: Fix doxygen at the top of vblank.c
    
    Signed-off-by: Eric Anholt <eric at anholt.net>
    Reviewed-by: Adam Jackson <ajax at redhat.com>

diff --git a/hw/xfree86/drivers/modesetting/Makefile.am b/hw/xfree86/drivers/modesetting/Makefile.am
index e6834e2..5b08600 100644
--- a/hw/xfree86/drivers/modesetting/Makefile.am
+++ b/hw/xfree86/drivers/modesetting/Makefile.am
@@ -30,6 +30,7 @@ AM_CPPFLAGS = \
 	$(XORG_INCS) \
 	-I$(top_srcdir)/glamor \
 	-I$(srcdir)/../../ddc \
+	-I$(srcdir)/../../dri2 \
 	-I$(srcdir)/../../i2c \
 	-I$(srcdir)/../../modes \
 	-I$(srcdir)/../../parser \
@@ -42,10 +43,13 @@ modesetting_drv_la_LIBADD = $(UDEV_LIBS) $(DRM_LIBS)
 modesetting_drv_ladir = @moduledir@/drivers
 
 modesetting_drv_la_SOURCES = \
+	 dri2.c \
 	 driver.c \
 	 driver.h \
 	 drmmode_display.c \
-	 drmmode_display.h
+	 drmmode_display.h \
+	 vblank.c \
+	 $(NULL)
 
 drivermandir = $(DRIVER_MAN_DIR)
 driverman_PRE = modesetting.man
diff --git a/hw/xfree86/drivers/modesetting/dri2.c b/hw/xfree86/drivers/modesetting/dri2.c
new file mode 100644
index 0000000..6c88060
--- /dev/null
+++ b/hw/xfree86/drivers/modesetting/dri2.c
@@ -0,0 +1,863 @@
+/*
+ * Copyright © 2013 Intel Corporation
+ * Copyright © 2014 Broadcom
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+/**
+ * @file dri2.c
+ *
+ * Implements generic support for DRI2 on KMS, using glamor pixmaps
+ * for color buffer management (no support for other aux buffers), and
+ * the DRM vblank ioctls.
+ *
+ * This doesn't implement pageflipping yet.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include "dix-config.h"
+#endif
+
+#include <time.h>
+#include "list.h"
+#include "xf86.h"
+#include "driver.h"
+#include "dri2.h"
+
+#ifdef GLAMOR
+#define GLAMOR_FOR_XORG 1
+#include "glamor.h"
+
+enum ms_dri2_frame_event_type {
+    MS_DRI2_QUEUE_SWAP,
+    MS_DRI2_WAIT_MSC,
+};
+
+typedef struct ms_dri2_frame_event {
+    ScreenPtr screen;
+
+    DrawablePtr drawable;
+    ClientPtr client;
+    enum ms_dri2_frame_event_type type;
+    int frame;
+    xf86CrtcPtr crtc;
+
+    struct xorg_list drawable_resource, client_resource;
+
+    /* for swaps & flips only */
+    DRI2SwapEventPtr event_complete;
+    void *event_data;
+    DRI2BufferPtr front;
+    DRI2BufferPtr back;
+} ms_dri2_frame_event_rec, *ms_dri2_frame_event_ptr;
+
+typedef struct {
+    int refcnt;
+    PixmapPtr pixmap;
+} ms_dri2_buffer_private_rec, *ms_dri2_buffer_private_ptr;
+
+static DevPrivateKeyRec ms_dri2_client_key;
+static RESTYPE frame_event_client_type, frame_event_drawable_type;
+static int ms_dri2_server_generation;
+
+struct ms_dri2_resource {
+    XID id;
+    RESTYPE type;
+    struct xorg_list list;
+};
+
+static struct ms_dri2_resource *
+ms_get_resource(XID id, RESTYPE type)
+{
+    struct ms_dri2_resource *resource;
+    void *ptr;
+
+    ptr = NULL;
+    dixLookupResourceByType(&ptr, id, type, NULL, DixWriteAccess);
+    if (ptr)
+        return ptr;
+
+    resource = malloc(sizeof(*resource));
+    if (resource == NULL)
+        return NULL;
+
+    if (!AddResource(id, type, resource)) {
+        free(resource);
+        return NULL;
+    }
+
+    resource->id = id;
+    resource->type = type;
+    xorg_list_init(&resource->list);
+    return resource;
+}
+
+static inline PixmapPtr
+get_drawable_pixmap(DrawablePtr drawable)
+{
+    ScreenPtr screen = drawable->pScreen;
+
+    if (drawable->type == DRAWABLE_PIXMAP)
+        return (PixmapPtr) drawable;
+    else
+        return screen->GetWindowPixmap((WindowPtr) drawable);
+}
+
+static PixmapPtr
+get_front_buffer(DrawablePtr drawable)
+{
+    PixmapPtr pixmap;
+
+    pixmap = get_drawable_pixmap(drawable);
+    pixmap->refcnt++;
+
+    return pixmap;
+}
+
+static DRI2Buffer2Ptr
+ms_dri2_create_buffer(DrawablePtr drawable, unsigned int attachment,
+                      unsigned int format)
+{
+    ScreenPtr screen = drawable->pScreen;
+    ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
+    DRI2Buffer2Ptr buffer;
+    PixmapPtr pixmap;
+    uint32_t size;
+    uint16_t pitch;
+    ms_dri2_buffer_private_ptr private;
+
+    buffer = calloc(1, sizeof *buffer);
+    if (buffer == NULL)
+        return NULL;
+
+    private = calloc(1, sizeof(*private));
+    if (private == NULL) {
+        free(buffer);
+        return NULL;
+    }
+
+    pixmap = NULL;
+    if (attachment == DRI2BufferFrontLeft)
+        pixmap = get_front_buffer(drawable);
+
+    if (pixmap == NULL) {
+        int pixmap_width = drawable->width;
+        int pixmap_height = drawable->height;
+        int pixmap_cpp = (format != 0) ? format : drawable->depth;
+
+        /* Assume that non-color-buffers require special
+         * device-specific handling.  Mesa currently makes no requests
+         * for non-color aux buffers.
+         */
+        switch (attachment) {
+        case DRI2BufferAccum:
+        case DRI2BufferBackLeft:
+        case DRI2BufferBackRight:
+        case DRI2BufferFakeFrontLeft:
+        case DRI2BufferFakeFrontRight:
+        case DRI2BufferFrontLeft:
+        case DRI2BufferFrontRight:
+            break;
+
+        case DRI2BufferStencil:
+        case DRI2BufferDepth:
+        case DRI2BufferDepthStencil:
+        case DRI2BufferHiz:
+        default:
+            xf86DrvMsg(scrn->scrnIndex, X_WARNING,
+                       "Request for DRI2 buffer attachment %d unsupported\n",
+                       attachment);
+            free(private);
+            free(buffer);
+            return NULL;
+        }
+
+        pixmap = screen->CreatePixmap(screen,
+                                      pixmap_width,
+                                      pixmap_height,
+                                      pixmap_cpp,
+                                      0);
+        if (pixmap == NULL) {
+            if (pixmap)
+                screen->DestroyPixmap(pixmap);
+            free(private);
+            free(buffer);
+            return NULL;
+        }
+    }
+
+    buffer->attachment = attachment;
+    buffer->cpp = pixmap->drawable.bitsPerPixel / 8;
+    buffer->format = format;
+    /* The buffer's flags field is unused by the client drivers in
+     * Mesa currently.
+     */
+    buffer->flags = 0;
+
+    buffer->name = glamor_name_from_pixmap(pixmap, &pitch, &size);
+    buffer->pitch = pitch;
+    if (buffer->name == -1) {
+        xf86DrvMsg(scrn->scrnIndex, X_ERROR,
+                   "Failed to get DRI2 name for pixmap\n");
+        screen->DestroyPixmap(pixmap);
+        free(private);
+        free(buffer);
+        return NULL;
+    }
+
+    buffer->driverPrivate = private;
+    private->refcnt = 1;
+    private->pixmap = pixmap;
+
+    return buffer;
+}
+
+static void
+ms_dri2_reference_buffer(DRI2Buffer2Ptr buffer)
+{
+    if (buffer) {
+        ms_dri2_buffer_private_ptr private = buffer->driverPrivate;
+        private->refcnt++;
+    }
+}
+
+static void ms_dri2_destroy_buffer(DrawablePtr drawable, DRI2Buffer2Ptr buffer)
+{
+    if (!buffer)
+        return;
+
+    if (buffer->driverPrivate) {
+        ms_dri2_buffer_private_ptr private = buffer->driverPrivate;
+        if (--private->refcnt == 0) {
+            ScreenPtr screen = private->pixmap->drawable.pScreen;
+            screen->DestroyPixmap(private->pixmap);
+            free(private);
+            free(buffer);
+        }
+    } else {
+        free(buffer);
+    }
+}
+
+static void
+ms_dri2_copy_region(DrawablePtr drawable, RegionPtr pRegion,
+                    DRI2BufferPtr destBuffer, DRI2BufferPtr sourceBuffer)
+{
+    ms_dri2_buffer_private_ptr src_priv = sourceBuffer->driverPrivate;
+    ms_dri2_buffer_private_ptr dst_priv = destBuffer->driverPrivate;
+    PixmapPtr src_pixmap = src_priv->pixmap;
+    PixmapPtr dst_pixmap = dst_priv->pixmap;
+    ScreenPtr screen = drawable->pScreen;
+    DrawablePtr src = (sourceBuffer->attachment == DRI2BufferFrontLeft)
+        ? drawable : &src_pixmap->drawable;
+    DrawablePtr dst = (destBuffer->attachment == DRI2BufferFrontLeft)
+        ? drawable : &dst_pixmap->drawable;
+    RegionPtr pCopyClip;
+    GCPtr gc;
+
+    gc = GetScratchGC(dst->depth, screen);
+    if (!gc)
+        return;
+
+    pCopyClip = REGION_CREATE(screen, NULL, 0);
+    REGION_COPY(screen, pCopyClip, pRegion);
+    (*gc->funcs->ChangeClip) (gc, CT_REGION, pCopyClip, 0);
+    ValidateGC(dst, gc);
+
+    /* It's important that this copy gets submitted before the direct
+     * rendering client submits rendering for the next frame, but we
+     * don't actually need to submit right now.  The client will wait
+     * for the DRI2CopyRegion reply or the swap buffer event before
+     * rendering, and we'll hit the flush callback chain before those
+     * messages are sent.  We submit our batch buffers from the flush
+     * callback chain so we know that will happen before the client
+     * tries to render again.
+     */
+    gc->ops->CopyArea(src, dst, gc,
+                      0, 0,
+                      drawable->width, drawable->height,
+                      0, 0);
+
+    FreeScratchGC(gc);
+}
+
+static uint64_t
+gettime_us(void)
+{
+    struct timespec tv;
+
+    if (clock_gettime(CLOCK_MONOTONIC, &tv))
+        return 0;
+
+    return (uint64_t)tv.tv_sec * 1000000 + tv.tv_nsec / 1000;
+}
+
+/**
+ * Get current frame count and frame count timestamp, based on drawable's
+ * crtc.
+ */
+static int
+ms_dri2_get_msc(DrawablePtr draw, CARD64 *ust, CARD64 *msc)
+{
+    int ret;
+    xf86CrtcPtr crtc = ms_dri2_crtc_covering_drawable(draw);
+
+    /* Drawable not displayed, make up a *monotonic* value */
+    if (crtc == NULL) {
+        *ust = gettime_us();
+        *msc = 0;
+        return TRUE;
+    }
+
+    ret = ms_get_crtc_ust_msc(crtc, ust, msc);
+
+    if (ret)
+        return FALSE;
+
+    return TRUE;
+}
+
+static XID
+get_client_id(ClientPtr client)
+{
+    XID *ptr = dixGetPrivateAddr(&client->devPrivates, &ms_dri2_client_key);
+    if (*ptr == 0)
+        *ptr = FakeClientID(client->index);
+    return *ptr;
+}
+
+/*
+ * Hook this frame event into the server resource
+ * database so we can clean it up if the drawable or
+ * client exits while the swap is pending
+ */
+static Bool
+ms_dri2_add_frame_event(ms_dri2_frame_event_ptr info)
+{
+    struct ms_dri2_resource *resource;
+
+    resource = ms_get_resource(get_client_id(info->client),
+                               frame_event_client_type);
+    if (resource == NULL)
+        return FALSE;
+
+    xorg_list_add(&info->client_resource, &resource->list);
+
+    resource = ms_get_resource(info->drawable->id, frame_event_drawable_type);
+    if (resource == NULL) {
+        xorg_list_del(&info->client_resource);
+        return FALSE;
+    }
+
+    xorg_list_add(&info->drawable_resource, &resource->list);
+
+    return TRUE;
+}
+
+static void
+ms_dri2_del_frame_event(ms_dri2_frame_event_rec *info)
+{
+    xorg_list_del(&info->client_resource);
+    xorg_list_del(&info->drawable_resource);
+
+    if (info->front)
+        ms_dri2_destroy_buffer(NULL, info->front);
+    if (info->back)
+        ms_dri2_destroy_buffer(NULL, info->back);
+
+    free(info);
+}
+
+static void
+ms_dri2_blit_swap(DrawablePtr drawable,
+                  DRI2BufferPtr dst,
+                  DRI2BufferPtr src)
+{
+    BoxRec box;
+    RegionRec region;
+
+    box.x1 = 0;
+    box.y1 = 0;
+    box.x2 = drawable->width;
+    box.y2 = drawable->height;
+    REGION_INIT(pScreen, &region, &box, 0);
+
+    ms_dri2_copy_region(drawable, &region, dst, src);
+}
+
+static void
+ms_dri2_frame_event_handler(uint64_t msc,
+                            uint64_t usec,
+                            void *data)
+{
+    ms_dri2_frame_event_ptr frame_info = data;
+    DrawablePtr drawable = frame_info->drawable;
+    ScreenPtr screen = frame_info->screen;
+    ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
+    uint32_t tv_sec = usec / 1000000;
+    uint32_t tv_usec = usec % 1000000;
+
+    if (!drawable) {
+        ms_dri2_del_frame_event(frame_info);
+        return;
+    }
+
+    switch (frame_info->type) {
+    case MS_DRI2_QUEUE_SWAP:
+        ms_dri2_blit_swap(drawable, frame_info->front, frame_info->back);
+        DRI2SwapComplete(frame_info->client, drawable, msc, tv_sec, tv_usec,
+                         DRI2_BLIT_COMPLETE,
+                         frame_info->client ? frame_info->event_complete : NULL,
+                         frame_info->event_data);
+        break;
+
+    case MS_DRI2_WAIT_MSC:
+        if (frame_info->client)
+            DRI2WaitMSCComplete(frame_info->client, drawable,
+                                msc, tv_sec, tv_usec);
+        break;
+
+    default:
+        xf86DrvMsg(scrn->scrnIndex, X_WARNING,
+                   "%s: unknown vblank event (type %d) received\n", __func__,
+                   frame_info->type);
+        break;
+    }
+
+    ms_dri2_del_frame_event(frame_info);
+}
+
+static void
+ms_dri2_frame_event_abort(void *data)
+{
+    ms_dri2_frame_event_ptr frame_info = data;
+
+    ms_dri2_del_frame_event(frame_info);
+}
+
+/**
+ * Request a DRM event when the requested conditions will be satisfied.
+ *
+ * We need to handle the event and ask the server to wake up the client when
+ * we receive it.
+ */
+static int
+ms_dri2_schedule_wait_msc(ClientPtr client, DrawablePtr draw, CARD64 target_msc,
+                          CARD64 divisor, CARD64 remainder)
+{
+    ScreenPtr screen = draw->pScreen;
+    ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
+    modesettingPtr ms = modesettingPTR(scrn);
+    ms_dri2_frame_event_ptr wait_info;
+    drmVBlank vbl;
+    int ret;
+    xf86CrtcPtr crtc = ms_dri2_crtc_covering_drawable(draw);
+    drmmode_crtc_private_ptr drmmode_crtc;
+    CARD64 current_msc, current_ust, request_msc;
+    uint32_t seq;
+
+    /* Drawable not visible, return immediately */
+    if (!crtc)
+        goto out_complete;
+    drmmode_crtc = crtc->driver_private;
+
+    wait_info = calloc(1, sizeof(*wait_info));
+    if (!wait_info)
+        goto out_complete;
+
+    wait_info->screen = screen;
+    wait_info->drawable = draw;
+    wait_info->client = client;
+    wait_info->type = MS_DRI2_WAIT_MSC;
+
+    if (!ms_dri2_add_frame_event(wait_info)) {
+        free(wait_info);
+        wait_info = NULL;
+        goto out_complete;
+    }
+
+    /* Get current count */
+    ret = ms_get_crtc_ust_msc(crtc, &current_ust, &current_msc);
+
+    /*
+     * If divisor is zero, or current_msc is smaller than target_msc,
+     * we just need to make sure target_msc passes  before waking up the
+     * client.
+     */
+    if (divisor == 0 || current_msc < target_msc) {
+        /* If target_msc already reached or passed, set it to
+         * current_msc to ensure we return a reasonable value back
+         * to the caller. This keeps the client from continually
+         * sending us MSC targets from the past by forcibly updating
+         * their count on this call.
+         */
+        seq = ms_drm_queue_alloc(crtc, wait_info,
+                                 ms_dri2_frame_event_handler,
+                                 ms_dri2_frame_event_abort);
+        if (!seq)
+            goto out_free;
+
+        if (current_msc >= target_msc)
+            target_msc = current_msc;
+        vbl.request.type = (DRM_VBLANK_ABSOLUTE |
+                            DRM_VBLANK_EVENT |
+                            drmmode_crtc->vblank_pipe);
+        vbl.request.sequence = ms_crtc_msc_to_kernel_msc(crtc, target_msc);
+        vbl.request.signal = (unsigned long)seq;
+
+        ret = drmWaitVBlank(ms->fd, &vbl);
+        if (ret) {
+            static int limit = 5;
+            if (limit) {
+                xf86DrvMsg(scrn->scrnIndex, X_WARNING,
+                           "%s:%d get vblank counter failed: %s\n",
+                           __FUNCTION__, __LINE__,
+                           strerror(errno));
+                limit--;
+            }
+            goto out_free;
+        }
+
+        wait_info->frame = ms_kernel_msc_to_crtc_msc(crtc, vbl.reply.sequence);
+        DRI2BlockClient(client, draw);
+        return TRUE;
+    }
+
+    /*
+     * If we get here, target_msc has already passed or we don't have one,
+     * so we queue an event that will satisfy the divisor/remainder equation.
+     */
+    vbl.request.type =
+        DRM_VBLANK_ABSOLUTE | DRM_VBLANK_EVENT | drmmode_crtc->vblank_pipe;
+
+    request_msc = current_msc - (current_msc % divisor) +
+        remainder;
+    /*
+     * If calculated remainder is larger than requested remainder,
+     * it means we've passed the last point where
+     * seq % divisor == remainder, so we need to wait for the next time
+     * that will happen.
+     */
+    if ((current_msc % divisor) >= remainder)
+        request_msc += divisor;
+
+    seq = ms_drm_queue_alloc(crtc, wait_info,
+                             ms_dri2_frame_event_handler,
+                             ms_dri2_frame_event_abort);
+    if (!seq)
+        goto out_free;
+
+    vbl.request.sequence = ms_crtc_msc_to_kernel_msc(crtc, request_msc);
+    vbl.request.signal = (unsigned long)seq;
+
+    ret = drmWaitVBlank(ms->fd, &vbl);
+    if (ret) {
+        static int limit = 5;
+        if (limit) {
+            xf86DrvMsg(scrn->scrnIndex, X_WARNING,
+                       "%s:%d get vblank counter failed: %s\n",
+                       __FUNCTION__, __LINE__,
+                       strerror(errno));
+            limit--;
+        }
+        goto out_free;
+    }
+
+    wait_info->frame = ms_kernel_msc_to_crtc_msc(crtc, vbl.reply.sequence);
+    DRI2BlockClient(client, draw);
+
+    return TRUE;
+
+ out_free:
+    ms_dri2_del_frame_event(wait_info);
+ out_complete:
+    DRI2WaitMSCComplete(client, draw, target_msc, 0, 0);
+    return TRUE;
+}
+
+/**
+ * ScheduleSwap is responsible for requesting a DRM vblank event for
+ * the appropriate frame, or executing the swap immediately if it
+ * doesn't need to wait.
+ *
+ * When the swap is complete, the driver should call into the server so it
+ * can send any swap complete events that have been requested.
+ */
+static int
+ms_dri2_schedule_swap(ClientPtr client, DrawablePtr draw,
+                      DRI2BufferPtr front, DRI2BufferPtr back,
+                      CARD64 *target_msc, CARD64 divisor,
+                      CARD64 remainder, DRI2SwapEventPtr func, void *data)
+{
+    ScreenPtr screen = draw->pScreen;
+    ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
+    modesettingPtr ms = modesettingPTR(scrn);
+    drmVBlank vbl;
+    int ret;
+    xf86CrtcPtr crtc = ms_dri2_crtc_covering_drawable(draw);
+    drmmode_crtc_private_ptr drmmode_crtc;
+    ms_dri2_frame_event_ptr frame_info = NULL;
+    uint64_t current_msc, current_ust;
+    uint64_t request_msc;
+    uint32_t seq;
+
+    /* Drawable not displayed... just complete the swap */
+    if (!crtc)
+        goto blit_fallback;
+    drmmode_crtc = crtc->driver_private;
+
+    frame_info = calloc(1, sizeof(*frame_info));
+    if (!frame_info)
+        goto blit_fallback;
+
+    frame_info->screen = screen;
+    frame_info->drawable = draw;
+    frame_info->client = client;
+    frame_info->event_complete = func;
+    frame_info->event_data = data;
+    frame_info->front = front;
+    frame_info->back = back;
+    frame_info->crtc = crtc;
+    frame_info->type = MS_DRI2_QUEUE_SWAP;
+
+    if (!ms_dri2_add_frame_event(frame_info)) {
+        free(frame_info);
+        frame_info = NULL;
+        goto blit_fallback;
+    }
+
+    ms_dri2_reference_buffer(front);
+    ms_dri2_reference_buffer(back);
+
+    ret = ms_get_crtc_ust_msc(crtc, &current_ust, &current_msc);
+
+    /*
+     * If divisor is zero, or current_msc is smaller than target_msc
+     * we just need to make sure target_msc passes before initiating
+     * the swap.
+     */
+    if (divisor == 0 || current_msc < *target_msc) {
+        /* We need to use DRM_VBLANK_NEXTONMISS to avoid unreliable
+         * timestamping later on.
+         */
+        vbl.request.type = (DRM_VBLANK_ABSOLUTE |
+                            DRM_VBLANK_NEXTONMISS |
+                            DRM_VBLANK_EVENT |
+                            drmmode_crtc->vblank_pipe);
+
+        /* If target_msc already reached or passed, set it to
+         * current_msc to ensure we return a reasonable value back
+         * to the caller. This makes swap_interval logic more robust.
+         */
+        if (current_msc >= *target_msc)
+            *target_msc = current_msc;
+
+        seq = ms_drm_queue_alloc(crtc, frame_info,
+                                 ms_dri2_frame_event_handler,
+                                 ms_dri2_frame_event_abort);
+        if (!seq)
+            goto blit_fallback;
+
+        vbl.request.sequence = ms_crtc_msc_to_kernel_msc(crtc, *target_msc);
+        vbl.request.signal = (unsigned long)seq;
+
+        ret = drmWaitVBlank(ms->fd, &vbl);
+        if (ret) {
+            xf86DrvMsg(scrn->scrnIndex, X_WARNING,
+                       "divisor 0 get vblank counter failed: %s\n",
+                       strerror(errno));
+            goto blit_fallback;
+        }
+
+        *target_msc = ms_kernel_msc_to_crtc_msc(crtc, vbl.reply.sequence);
+        frame_info->frame = *target_msc;
+
+        return TRUE;
+    }
+
+    /*
+     * If we get here, target_msc has already passed or we don't have one,
+     * and we need to queue an event that will satisfy the divisor/remainder
+     * equation.
+     */
+    vbl.request.type = (DRM_VBLANK_ABSOLUTE |
+                        DRM_VBLANK_NEXTONMISS |
+                        DRM_VBLANK_EVENT |
+                        drmmode_crtc->vblank_pipe);
+
+    request_msc = current_msc - (current_msc % divisor) +
+        remainder;
+
+    /*
+     * If the calculated deadline vbl.request.sequence is smaller than
+     * or equal to current_msc, it means we've passed the last point
+     * when effective onset frame seq could satisfy
+     * seq % divisor == remainder, so we need to wait for the next time
+     * this will happen.
+
+     * This comparison takes the DRM_VBLANK_NEXTONMISS delay into account.
+     */
+    if (request_msc <= current_msc)
+        request_msc += divisor;
+
+
+    seq = ms_drm_queue_alloc(crtc, frame_info,
+                             ms_dri2_frame_event_handler,
+                             ms_dri2_frame_event_abort);
+    if (!seq)
+        goto blit_fallback;
+
+    vbl.request.sequence = ms_crtc_msc_to_kernel_msc(crtc, request_msc);
+    vbl.request.signal = (unsigned long)seq;
+
+    ret = drmWaitVBlank(ms->fd, &vbl);
+    if (ret) {
+        xf86DrvMsg(scrn->scrnIndex, X_WARNING,
+                   "final get vblank counter failed: %s\n",
+                   strerror(errno));
+        goto blit_fallback;
+    }
+
+    *target_msc = ms_kernel_msc_to_crtc_msc(crtc, vbl.reply.sequence);
+    frame_info->frame = *target_msc;
+
+    return TRUE;
+
+ blit_fallback:
+    ms_dri2_blit_swap(draw, front, back);
+    DRI2SwapComplete(client, draw, 0, 0, 0, DRI2_BLIT_COMPLETE, func, data);
+    if (frame_info)
+        ms_dri2_del_frame_event(frame_info);
+    *target_msc = 0; /* offscreen, so zero out target vblank count */
+    return TRUE;
+}
+
+static int
+ms_dri2_frame_event_client_gone(void *data, XID id)
+{
+    struct ms_dri2_resource *resource = data;
+
+    while (!xorg_list_is_empty(&resource->list)) {
+        ms_dri2_frame_event_ptr info =
+            xorg_list_first_entry(&resource->list,
+                                  ms_dri2_frame_event_rec,
+                                  client_resource);
+
+        xorg_list_del(&info->client_resource);
+        info->client = NULL;
+    }
+    free(resource);
+
+    return Success;
+}
+
+static int
+ms_dri2_frame_event_drawable_gone(void *data, XID id)
+{
+    struct ms_dri2_resource *resource = data;
+
+    while (!xorg_list_is_empty(&resource->list)) {
+        ms_dri2_frame_event_ptr info =
+            xorg_list_first_entry(&resource->list,
+                                  ms_dri2_frame_event_rec,
+                                  drawable_resource);
+
+        xorg_list_del(&info->drawable_resource);
+        info->drawable = NULL;
+    }
+    free(resource);
+
+    return Success;
+}
+
+static Bool
+ms_dri2_register_frame_event_resource_types(void)
+{
+    frame_event_client_type =
+        CreateNewResourceType(ms_dri2_frame_event_client_gone,
+                              "Frame Event Client");
+    if (!frame_event_client_type)
+        return FALSE;
+
+    frame_event_drawable_type =
+        CreateNewResourceType(ms_dri2_frame_event_drawable_gone,
+                              "Frame Event Drawable");
+    if (!frame_event_drawable_type)
+        return FALSE;
+
+    return TRUE;
+}
+
+Bool
+ms_dri2_screen_init(ScreenPtr screen)
+{
+    ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
+    modesettingPtr ms = modesettingPTR(scrn);
+    DRI2InfoRec info;
+
+    if (!glamor_supports_pixmap_import_export(screen)) {
+        xf86DrvMsg(scrn->scrnIndex, X_WARNING,
+                   "DRI2: glamor lacks support for pixmap import/export\n");
+    }
+
+    if (!xf86LoaderCheckSymbol("DRI2Version"))
+        return FALSE;
+
+    if (!dixRegisterPrivateKey(&ms_dri2_client_key,
+                               PRIVATE_CLIENT, sizeof(XID)))
+        return FALSE;
+
+    if (serverGeneration != ms_dri2_server_generation) {
+        ms_dri2_server_generation = serverGeneration;
+        if (!ms_dri2_register_frame_event_resource_types()) {
+            xf86DrvMsg(scrn->scrnIndex, X_WARNING,
+                       "Cannot register DRI2 frame event resources\n");
+            return FALSE;
+        }
+    }
+
+    memset(&info, '\0', sizeof(info));
+    info.fd = ms->fd;
+    info.driverName = NULL; /* Compat field, unused. */
+    info.deviceName = drmGetDeviceNameFromFd(ms->fd);
+
+    info.version = 4;
+    info.CreateBuffer = ms_dri2_create_buffer;
+    info.DestroyBuffer = ms_dri2_destroy_buffer;
+    info.CopyRegion = ms_dri2_copy_region;
+    info.ScheduleSwap = ms_dri2_schedule_swap;
+    info.GetMSC = ms_dri2_get_msc;
+    info.ScheduleWaitMSC = ms_dri2_schedule_wait_msc;
+
+    /* These two will be filled in by dri2.c */
+    info.numDrivers = 0;
+    info.driverNames = NULL;
+
+    return DRI2ScreenInit(screen, &info);
+}
+
+void
+ms_dri2_close_screen(ScreenPtr screen)
+{
+    DRI2CloseScreen(screen);
+}
+
+#endif /* GLAMOR */
diff --git a/hw/xfree86/drivers/modesetting/driver.c b/hw/xfree86/drivers/modesetting/driver.c
index c62147a..e0391db 100644
--- a/hw/xfree86/drivers/modesetting/driver.c
+++ b/hw/xfree86/drivers/modesetting/driver.c
@@ -788,7 +788,9 @@ PreInit(ScrnInfoPtr pScrn, int flags)
 
     try_enable_glamor(pScrn);
 
-    if (!ms->glamor) {
+    if (ms->glamor) {
+        xf86LoadSubModule(pScrn, "dri2");
+    } else {
         Bool prefer_shadow = TRUE;
 
         ret = drmGetCap(ms->fd, DRM_CAP_DUMB_PREFER_SHADOW, &value);
@@ -1107,6 +1109,21 @@ ScreenInit(ScreenPtr pScreen, int argc, char **argv)
     if (serverGeneration == 1)
         xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options);
 
+    if (!ms_vblank_screen_init(pScreen)) {
+        xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+                   "Failed to initialize vblank support.\n");
+        return FALSE;
+    }
+
+#ifdef GLAMOR
+    if (ms->glamor) {
+        if (!ms_dri2_screen_init(pScreen)) {
+            xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+                       "Failed to initialize the DRI2 extension.\n");
+        }
+    }
+#endif
+
     return EnterVT(pScrn);
 }
 
@@ -1172,6 +1189,14 @@ CloseScreen(ScreenPtr pScreen)
     ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     modesettingPtr ms = modesettingPTR(pScrn);
 
+#ifdef GLAMOR
+    if (ms->glamor) {
+        ms_dri2_close_screen(pScreen);
+    }
+#endif
+
+    ms_vblank_close_screen(pScreen);
+
     if (ms->damage) {
         DamageUnregister(ms->damage);
         DamageDestroy(ms->damage);
diff --git a/hw/xfree86/drivers/modesetting/driver.h b/hw/xfree86/drivers/modesetting/driver.h
index 35f2419..9eda1c4 100644
--- a/hw/xfree86/drivers/modesetting/driver.h
+++ b/hw/xfree86/drivers/modesetting/driver.h
@@ -30,6 +30,7 @@
 #include <errno.h>
 #include <drm.h>
 #include <xf86drm.h>
+#include <xf86Crtc.h>
 #include <damage.h>
 
 #include "drmmode_display.h"
@@ -42,6 +43,26 @@ typedef struct {
     ScrnInfoPtr pScrn_2;
 } EntRec, *EntPtr;
 
+typedef void (*ms_drm_handler_proc)(uint64_t frame,
+                                    uint64_t usec,
+                                    void *data);
+
+typedef void (*ms_drm_abort_proc)(void *data);
+
+/**
+ * A tracked handler for an event that will hopefully be generated by
+ * the kernel, and what to do when it is encountered.
+ */
+struct ms_drm_queue {
+    struct xorg_list list;
+    xf86CrtcPtr crtc;
+    uint32_t seq;
+    void *data;
+    ScrnInfoPtr scrn;
+    ms_drm_handler_proc handler;
+    ms_drm_abort_proc abort;
+};
+
 typedef struct _modesettingRec {
     int fd;
 
@@ -70,6 +91,8 @@ typedef struct _modesettingRec {
 
     drmmode_rec drmmode;
 
+    drmEventContext event_context;
+
     DamagePtr damage;
     Bool dirty_enabled;
 
@@ -78,3 +101,24 @@ typedef struct _modesettingRec {
 } modesettingRec, *modesettingPtr;
 
 #define modesettingPTR(p) ((modesettingPtr)((p)->driverPrivate))
+
+uint32_t ms_drm_queue_alloc(xf86CrtcPtr crtc,
+                            void *data,
+                            ms_drm_handler_proc handler,
+                            ms_drm_abort_proc abort);
+
+xf86CrtcPtr ms_dri2_crtc_covering_drawable(DrawablePtr pDraw);
+xf86CrtcPtr ms_covering_crtc(ScrnInfoPtr scrn, BoxPtr box,
+                             xf86CrtcPtr desired, BoxPtr crtc_box_ret);
+
+int ms_get_crtc_ust_msc(xf86CrtcPtr crtc, CARD64 *ust, CARD64 *msc);
+
+uint32_t ms_crtc_msc_to_kernel_msc(xf86CrtcPtr crtc, uint64_t expect);
+uint64_t ms_kernel_msc_to_crtc_msc(xf86CrtcPtr crtc, uint32_t sequence);
+
+
+Bool ms_dri2_screen_init(ScreenPtr screen);
+void ms_dri2_close_screen(ScreenPtr screen);
+
+Bool ms_vblank_screen_init(ScreenPtr screen);
+void ms_vblank_close_screen(ScreenPtr screen);
diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c b/hw/xfree86/drivers/modesetting/drmmode_display.c
index d8d1b44..ef9009e 100644
--- a/hw/xfree86/drivers/modesetting/drmmode_display.c
+++ b/hw/xfree86/drivers/modesetting/drmmode_display.c
@@ -582,6 +582,17 @@ static const xf86CrtcFuncsRec drmmode_crtc_funcs = {
     .shadow_create = drmmode_shadow_create,
 };
 
+static uint32_t
+drmmode_crtc_vblank_pipe(int crtc_id)
+{
+    if (crtc_id > 1)
+        return crtc_id << DRM_VBLANK_HIGH_CRTC_SHIFT;
+    else if (crtc_id > 0)
+        return DRM_VBLANK_SECONDARY;
+    else
+        return 0;
+}
+
 static void
 drmmode_crtc_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int num)
 {
@@ -596,6 +607,7 @@ drmmode_crtc_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int num)
     drmmode_crtc->mode_crtc =
         drmModeGetCrtc(drmmode->fd, drmmode->mode_res->crtcs[num]);
     drmmode_crtc->drmmode = drmmode;
+    drmmode_crtc->vblank_pipe = drmmode_crtc_vblank_pipe(num);
     crtc->driver_private = drmmode_crtc;
 }
 
@@ -1183,6 +1195,11 @@ drmmode_xf86crtc_resize(ScrnInfoPtr scrn, int width, int height)
     xf86DrvMsg(scrn->scrnIndex, X_INFO,
                "Allocate new frame buffer %dx%d stride\n", width, height);
 
+    if (drmmode->triple_buffer_pixmap) {
+        screen->DestroyPixmap(drmmode->triple_buffer_pixmap);
+        drmmode->triple_buffer_pixmap = NULL;
+    }
+
     old_width = scrn->virtualX;
     old_height = scrn->virtualY;
     old_pitch = drmmode->front_bo->pitch;
diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.h b/hw/xfree86/drivers/modesetting/drmmode_display.h
index c7e7ef0..987608c 100644
--- a/hw/xfree86/drivers/modesetting/drmmode_display.h
+++ b/hw/xfree86/drivers/modesetting/drmmode_display.h
@@ -43,6 +43,7 @@ struct dumb_bo {
 typedef struct {
     int fd;
     unsigned fb_id;
+    unsigned old_fb_id;
     drmModeResPtr mode_res;
     drmModeFBPtr mode_fb;
     int cpp;
@@ -58,17 +59,42 @@ typedef struct {
     Bool shadow_enable;
     void *shadow_fb;
 
+    /**
+     * A screen-sized pixmap when we're doing triple-buffered DRI2
+     * pageflipping.
+     *
+     * One is shared between all drawables that flip to the front
+     * buffer, and it only gets reallocated when root pixmap size
+     * changes.
+     */
+    PixmapPtr triple_buffer_pixmap;
+
+    /** The GEM name for triple_buffer_pixmap */
+    uint32_t triple_buffer_name;
+
     DevPrivateKeyRec pixmapPrivateKeyRec;
 } drmmode_rec, *drmmode_ptr;
 
 typedef struct {
     drmmode_ptr drmmode;
     drmModeCrtcPtr mode_crtc;
-    int hw_id;
+    uint32_t vblank_pipe;
     struct dumb_bo *cursor_bo;
     unsigned rotate_fb_id;
     uint16_t lut_r[256], lut_g[256], lut_b[256];
     DamagePtr slave_damage;
+
+    /**
+     * @{ MSC (vblank count) handling for the PRESENT extension.
+     *
+     * The kernel's vblank counters are 32 bits and apparently full of
+     * lies, and we need to give a reliable 64-bit msc for GL, so we
+     * have to track and convert to a userland-tracked 64-bit msc.
+     */
+    int32_t vblank_offset;
+    uint32_t msc_prev;
+    uint64_t msc_high;
+    /** @} */
 } drmmode_crtc_private_rec, *drmmode_crtc_private_ptr;
 
 typedef struct {
diff --git a/hw/xfree86/drivers/modesetting/vblank.c b/hw/xfree86/drivers/modesetting/vblank.c
new file mode 100644
index 0000000..35cadb2
--- /dev/null
+++ b/hw/xfree86/drivers/modesetting/vblank.c
@@ -0,0 +1,382 @@
+/*
+ * Copyright © 2013 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * that the name of the copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission.  The copyright holders make no representations
+ * about the suitability of this software for any purpose.  It is provided "as
+ * is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+/** @file vblank.c
+ *
+ * Support for tracking the DRM's vblank events.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include "dix-config.h"
+#endif
+
+#include <unistd.h>
+#include <xf86.h>
+#include <xf86Crtc.h>
+#include <poll.h>
+#include "driver.h"
+#include "drmmode_display.h"
+
+/**
+ * Tracking for outstanding events queued to the kernel.
+ *
+ * Each list entry is a struct ms_drm_queue, which has a uint32_t
+ * value generated from drm_seq that identifies the event and a
+ * reference back to the crtc/screen associated with the event.  It's
+ * done this way rather than in the screen because we want to be able
+ * to drain the list of event handlers that should be called at server
+ * regen time, even though we don't close the drm fd and have no way
+ * to actually drain the kernel events.
+ */
+static struct xorg_list ms_drm_queue;
+static uint32_t ms_drm_seq;
+
+struct ms_pageflip {
+    ScreenPtr screen;
+    Bool crtc_for_msc_ust;
+};
+
+static void ms_box_intersect(BoxPtr dest, BoxPtr a, BoxPtr b)
+{
+    dest->x1 = a->x1 > b->x1 ? a->x1 : b->x1;
+    dest->x2 = a->x2 < b->x2 ? a->x2 : b->x2;
+    if (dest->x1 >= dest->x2) {
+        dest->x1 = dest->x2 = dest->y1 = dest->y2 = 0;
+        return;
+    }
+
+    dest->y1 = a->y1 > b->y1 ? a->y1 : b->y1;
+    dest->y2 = a->y2 < b->y2 ? a->y2 : b->y2;
+    if (dest->y1 >= dest->y2)
+        dest->x1 = dest->x2 = dest->y1 = dest->y2 = 0;
+}
+
+static void ms_crtc_box(xf86CrtcPtr crtc, BoxPtr crtc_box)
+{
+    if (crtc->enabled) {
+        crtc_box->x1 = crtc->x;
+        crtc_box->x2 =
+            crtc->x + xf86ModeWidth(&crtc->mode, crtc->rotation);
+        crtc_box->y1 = crtc->y;
+        crtc_box->y2 =
+            crtc->y + xf86ModeHeight(&crtc->mode, crtc->rotation);
+    } else
+        crtc_box->x1 = crtc_box->x2 = crtc_box->y1 = crtc_box->y2 = 0;
+}
+
+static int ms_box_area(BoxPtr box)
+{
+    return (int)(box->x2 - box->x1) * (int)(box->y2 - box->y1);
+}
+
+/*
+ * Return the crtc covering 'box'. If two crtcs cover a portion of
+ * 'box', then prefer 'desired'. If 'desired' is NULL, then prefer the crtc
+ * with greater coverage
+ */
+
+xf86CrtcPtr
+ms_covering_crtc(ScrnInfoPtr scrn,
+                 BoxPtr box, xf86CrtcPtr desired, BoxPtr crtc_box_ret)
+{
+    xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
+    xf86CrtcPtr crtc, best_crtc;
+    int coverage, best_coverage;
+    int c;
+    BoxRec crtc_box, cover_box;
+
+    best_crtc = NULL;
+    best_coverage = 0;
+    crtc_box_ret->x1 = 0;
+    crtc_box_ret->x2 = 0;
+    crtc_box_ret->y1 = 0;
+    crtc_box_ret->y2 = 0;
+    for (c = 0; c < xf86_config->num_crtc; c++) {
+        crtc = xf86_config->crtc[c];
+
+        /* If the CRTC is off, treat it as not covering */
+        if (!crtc->enabled)
+            continue;
+
+        ms_crtc_box(crtc, &crtc_box);
+        ms_box_intersect(&cover_box, &crtc_box, box);
+        coverage = ms_box_area(&cover_box);
+        if (coverage && crtc == desired) {
+            *crtc_box_ret = crtc_box;
+            return crtc;
+        }
+        if (coverage > best_coverage) {
+            *crtc_box_ret = crtc_box;
+            best_crtc = crtc;
+            best_coverage = coverage;
+        }
+    }
+    return best_crtc;
+}
+
+xf86CrtcPtr
+ms_dri2_crtc_covering_drawable(DrawablePtr pDraw)
+{
+    ScreenPtr pScreen = pDraw->pScreen;
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
+    BoxRec box, crtcbox;
+    xf86CrtcPtr crtc;
+
+    box.x1 = pDraw->x;
+    box.y1 = pDraw->y;
+    box.x2 = box.x1 + pDraw->width;
+    box.y2 = box.y1 + pDraw->height;
+
+    crtc = ms_covering_crtc(pScrn, &box, NULL, &crtcbox);
+
+    /* Make sure the CRTC is valid and this is the real front buffer */
+    if (crtc != NULL && !crtc->rotatedData)
+        return crtc;
+
+    return NULL;
+}
+
+static Bool
+ms_get_kernel_ust_msc(xf86CrtcPtr crtc,
+                      uint32_t *msc, uint64_t *ust)
+{
+    ScreenPtr screen = crtc->randr_crtc->pScreen;
+    ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
+    modesettingPtr ms = modesettingPTR(scrn);
+    drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+    drmVBlank vbl;
+    int ret;
+
+    /* Get current count */
+    vbl.request.type = DRM_VBLANK_RELATIVE | drmmode_crtc->vblank_pipe;
+    vbl.request.sequence = 0;
+    vbl.request.signal = 0;
+    ret = drmWaitVBlank(ms->fd, &vbl);
+    if (ret) {
+        *msc = 0;
+        *ust = 0;
+        return FALSE;
+    } else {
+        *msc = vbl.reply.sequence;
+        *ust = (CARD64) vbl.reply.tval_sec * 1000000 + vbl.reply.tval_usec;
+        return TRUE;
+    }
+}
+
+/**
+ * Convert a 32-bit kernel MSC sequence number to a 64-bit local sequence
+ * number, adding in the vblank_offset and high 32 bits, and dealing
+ * with 64-bit wrapping
+ */
+uint64_t
+ms_kernel_msc_to_crtc_msc(xf86CrtcPtr crtc, uint32_t sequence)
+{
+    drmmode_crtc_private_rec *drmmode_crtc = crtc->driver_private;
+    sequence += drmmode_crtc->vblank_offset;
+
+    if ((int32_t) (sequence - drmmode_crtc->msc_prev) < -0x40000000)
+        drmmode_crtc->msc_high += 0x100000000L;
+    drmmode_crtc->msc_prev = sequence;
+    return drmmode_crtc->msc_high + sequence;
+}
+
+int
+ms_get_crtc_ust_msc(xf86CrtcPtr crtc, CARD64 *ust, CARD64 *msc)
+{
+    uint32_t kernel_msc;
+
+    if (!ms_get_kernel_ust_msc(crtc, &kernel_msc, ust))
+        return BadMatch;
+    *msc = ms_kernel_msc_to_crtc_msc(crtc, kernel_msc);
+
+    return Success;
+}
+
+#define MAX_VBLANK_OFFSET       1000
+
+/**
+ * Convert a 64-bit adjusted MSC value into a 32-bit kernel sequence number,
+ * removing the high 32 bits and subtracting out the vblank_offset term.
+ *
+ * This also updates the vblank_offset when it notices that the value should
+ * change.
+ */
+uint32_t
+ms_crtc_msc_to_kernel_msc(xf86CrtcPtr crtc, uint64_t expect)
+{
+    drmmode_crtc_private_rec *drmmode_crtc = crtc->driver_private;
+    uint64_t msc;
+    uint64_t ust;
+    int64_t diff;
+
+    ms_get_crtc_ust_msc(crtc, &ust, &msc);
+    diff = expect - msc;
+
+    /* We're way off here, assume that the kernel has lost its mind
+     * and smack the vblank back to something sensible
+     */
+    if (diff < -MAX_VBLANK_OFFSET || MAX_VBLANK_OFFSET < diff) {
+        drmmode_crtc->vblank_offset += (int32_t) diff;
+        if (drmmode_crtc->vblank_offset > -MAX_VBLANK_OFFSET &&
+            drmmode_crtc->vblank_offset < MAX_VBLANK_OFFSET)
+            drmmode_crtc->vblank_offset = 0;
+    }
+    return (uint32_t) (expect - drmmode_crtc->vblank_offset);
+}
+
+/**
+ * Check for pending DRM events and process them.
+ */
+static void
+ms_drm_wakeup_handler(void *data, int err, void *mask)
+{
+    ScreenPtr screen = data;
+    ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
+    modesettingPtr ms = modesettingPTR(scrn);
+    fd_set *read_mask = mask;
+
+    if (data == NULL || err < 0)
+        return;
+
+    if (FD_ISSET(ms->fd, read_mask))
+        drmHandleEvent(ms->fd, &ms->event_context);
+}
+
+/*
+ * Enqueue a potential drm response; when the associated response
+ * appears, we've got data to pass to the handler from here
+ */
+uint32_t
+ms_drm_queue_alloc(xf86CrtcPtr crtc,
+                   void *data,
+                   ms_drm_handler_proc handler,
+                   ms_drm_abort_proc abort)
+{
+    ScreenPtr screen = crtc->randr_crtc->pScreen;
+    ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
+    struct ms_drm_queue *q;
+
+    q = calloc(1, sizeof(struct ms_drm_queue));
+
+    if (!q)
+        return 0;
+    if (!ms_drm_seq)
+        ++ms_drm_seq;
+    q->seq = ms_drm_seq++;
+    q->scrn = scrn;
+    q->crtc = crtc;
+    q->data = data;
+    q->handler = handler;
+    q->abort = abort;
+
+    xorg_list_add(&q->list, &ms_drm_queue);
+
+    return q->seq;
+}
+
+/**
+ * Abort one queued DRM entry, removing it
+ * from the list, calling the abort function and
+ * freeing the memory
+ */
+static void
+ms_drm_abort_one(struct ms_drm_queue *q)
+{
+        xorg_list_del(&q->list);
+        q->abort(q->data);
+        free(q);
+}
+
+/**
+ * Abort all queued entries on a specific scrn, used
+ * when resetting the X server
+ */
+static void
+ms_drm_abort_scrn(ScrnInfoPtr scrn)
+{
+    struct ms_drm_queue *q, *tmp;
+
+    xorg_list_for_each_entry_safe(q, tmp, &ms_drm_queue, list) {
+        if (q->scrn == scrn)
+            ms_drm_abort_one(q);
+    }
+}
+
+/*
+ * General DRM kernel handler. Looks for the matching sequence number in the
+ * drm event queue and calls the handler for it.
+ */
+static void
+ms_drm_handler(int fd, uint32_t frame, uint32_t sec, uint32_t usec,
+               void *user_ptr)
+{
+    struct ms_drm_queue *q, *tmp;
+    uint32_t user_data = (uint32_t) (intptr_t) user_ptr;
+
+    xorg_list_for_each_entry_safe(q, tmp, &ms_drm_queue, list) {
+        if (q->seq == user_data) {
+            uint64_t msc;
+
+            msc = ms_kernel_msc_to_crtc_msc(q->crtc, frame);
+            xorg_list_del(&q->list);
+            q->handler(msc, (uint64_t) sec * 1000000 + usec, q->data);
+            free(q);
+            break;
+        }
+    }
+}
+
+Bool
+ms_vblank_screen_init(ScreenPtr screen)
+{
+    ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
+    modesettingPtr ms = modesettingPTR(scrn);
+
+    xorg_list_init(&ms_drm_queue);
+
+    ms->event_context.version = DRM_EVENT_CONTEXT_VERSION;
+    ms->event_context.vblank_handler = ms_drm_handler;
+    ms->event_context.page_flip_handler = ms_drm_handler;
+
+    /* We need to re-register the DRM fd for the synchronisation
+     * feedback on every server generation, so perform the
+     * registration within ScreenInit and not PreInit.
+     */
+    AddGeneralSocket(ms->fd);
+    RegisterBlockAndWakeupHandlers((BlockHandlerProcPtr)NoopDDA,
+                                   ms_drm_wakeup_handler, screen);
+
+    return TRUE;
+}
+
+void
+ms_vblank_close_screen(ScreenPtr screen)
+{
+    ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
+    modesettingPtr ms = modesettingPTR(scrn);
+
+    ms_drm_abort_scrn(scrn);
+
+    RemoveBlockAndWakeupHandlers((BlockHandlerProcPtr)NoopDDA,
+                                 ms_drm_wakeup_handler, screen);
+    RemoveGeneralSocket(ms->fd);
+}
commit 7064b00d478646cb428e427df2d3f91d7022c582
Author: Eric Anholt <eric at anholt.net>
Date:   Mon Dec 30 00:25:37 2013 -0800

    modesetting: Export two functions I want to reuse from DRI2/Present.
    
    This renames dumb_get_bo_from_handle(), since it wasn't using a handle
    (GEM terminology) but a dmabuf fd.
    
    Signed-off-by: Eric Anholt <eric at anholt.net>
    Reviewed-by: Adam Jackson <ajax at redhat.com>
    Reviewed-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c b/hw/xfree86/drivers/modesetting/drmmode_display.c
index d959837..d8d1b44 100644
--- a/hw/xfree86/drivers/modesetting/drmmode_display.c
+++ b/hw/xfree86/drivers/modesetting/drmmode_display.c
@@ -116,7 +116,7 @@ dumb_bo_unmap(int fd, struct dumb_bo *bo)
 }
 #endif
 
-static int
+int
 dumb_bo_destroy(int fd, struct dumb_bo *bo)
 {
     struct drm_mode_destroy_dumb arg;
@@ -137,8 +137,8 @@ dumb_bo_destroy(int fd, struct dumb_bo *bo)
     return 0;
 }
 
-static struct dumb_bo *
-dumb_get_bo_from_handle(int fd, int handle, int pitch, int size)
+struct dumb_bo *
+dumb_get_bo_from_fd(int fd, int handle, int pitch, int size)
 {
     struct dumb_bo *bo;
     int ret;
@@ -164,7 +164,7 @@ drmmode_SetSlaveBO(PixmapPtr ppix,
     msPixmapPrivPtr ppriv = msGetPixmapPriv(drmmode, ppix);
 
     ppriv->backing_bo =
-        dumb_get_bo_from_handle(drmmode->fd, fd_handle, pitch, size);
+        dumb_get_bo_from_fd(drmmode->fd, fd_handle, pitch, size);
     if (!ppriv->backing_bo)
         return FALSE;
 
diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.h b/hw/xfree86/drivers/modesetting/drmmode_display.h
index 438743b..c7e7ef0 100644
--- a/hw/xfree86/drivers/modesetting/drmmode_display.h
+++ b/hw/xfree86/drivers/modesetting/drmmode_display.h
@@ -121,6 +121,9 @@ Bool drmmode_map_cursor_bos(ScrnInfoPtr pScrn, drmmode_ptr drmmode);
 void drmmode_free_bos(ScrnInfoPtr pScrn, drmmode_ptr drmmode);
 void drmmode_get_default_bpp(ScrnInfoPtr pScrn, drmmode_ptr drmmmode,
                              int *depth, int *bpp);
+struct dumb_bo *dumb_get_bo_from_fd(int drm_fd, int fd, int pitch, int size);
+int dumb_bo_destroy(int fd, struct dumb_bo *bo);
+
 
 #ifndef DRM_CAP_DUMB_PREFERRED_DEPTH
 #define DRM_CAP_DUMB_PREFERRED_DEPTH 3
commit 34a98c8103a6f725283d0d1ee4084bf387b93019
Author: Eric Anholt <eric at anholt.net>
Date:   Wed Oct 8 04:12:49 2014 -0700

    dri2: Automatically fill in the driver name if the DDX doesn't provide it.
    
    This will be used by the modesetting driver to support DRI2 across all
    hardware that can support glamor, and could potentially be used by
    other drivers that have to support DRI2 on sets of hardware with
    multiple Mesa drivers.
    
    This logic is the same as what's present in the Mesa driver loader,
    except for the lack of nouveau_vieux support (which requires a
    predicate on the device).
    
    v2: Fix duplicated assignment of info->driverName.
    
    Signed-off-by: Eric Anholt <eric at anholt.net>
    Reviewed-by: Adam Jackson <ajax at redhat.com>

diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
index 6459f11..c8fcd62 100644
--- a/hw/xfree86/dri2/dri2.c
+++ b/hw/xfree86/dri2/dri2.c
@@ -1410,6 +1410,59 @@ get_prime_id(void)
     return -1;
 }
 
+#include "pci_ids/pci_id_driver_map.h"
+
+static char *
+dri2_probe_driver_name(ScreenPtr pScreen, DRI2InfoPtr info)
+{
+    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
+    EntityInfoPtr pEnt = xf86GetEntityInfo(pScrn->entityList[0]);
+    struct pci_device *pdev = NULL;
+    int i, j;
+
+    if (pEnt)
+        pdev = xf86GetPciInfoForEntity(pEnt->index);
+
+    /* For non-PCI devices, just assume that the 3D driver is named
+     * the same as the kernel driver.  This is currently true for vc4
+     * and msm (freedreno).
+     */
+    if (!pdev) {
+        drmVersionPtr version = drmGetVersion(info->fd);
+        char *kernel_driver;
+
+        if (!version) {
+            xf86DrvMsg(pScreen->myNum, X_ERROR,
+                       "[DRI2] Couldn't drmGetVersion() on non-PCI device, "
+                       "no driver name found.\n");
+            return NULL;
+        }
+
+        kernel_driver = strndup(version->name, version->name_len);
+        drmFreeVersion(version);
+        return kernel_driver;
+    }
+
+    for (i = 0; driver_map[i].driver; i++) {
+        if (pdev->vendor_id != driver_map[i].vendor_id)
+            continue;
+
+        if (driver_map[i].num_chips_ids == -1)
+            return strdup(driver_map[i].driver);
+
+        for (j = 0; j < driver_map[i].num_chips_ids; j++) {
+            if (driver_map[i].chip_ids[j] == pdev->device_id)
+                return strdup(driver_map[i].driver);
+        }
+    }
+
+    xf86DrvMsg(pScreen->myNum, X_ERROR,
+               "[DRI2] No driver mapping found for PCI device "
+               "0x%04x / 0x%04x\n",
+               pdev->vendor_id, pdev->device_id);
+    return NULL;
+}
+
 Bool
 DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info)
 {
@@ -1524,7 +1577,14 @@ DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info)
         ds->driverNames = malloc(sizeof(*ds->driverNames));
         if (!ds->driverNames)
             goto err_out;
-        ds->driverNames[0] = info->driverName;
+
+        if (info->driverName) {
+            ds->driverNames[0] = info->driverName;
+        } else {
+            ds->driverNames[0] = dri2_probe_driver_name(pScreen, info);
+            if (!ds->driverNames[0])
+                return FALSE;
+        }
     }
     else {
         ds->numDrivers = info->numDrivers;
commit 470d97e1d176981dbd8087c621e54caab0d6c73c
Author: Eric Anholt <eric at anholt.net>
Date:   Tue Dec 31 13:52:49 2013 -0800

    dri2: Import a copy of Mesa's PCI ID -> driver name mappings.
    
    This comes from Mesa commit acdcef6788beaa2a1532e13ff84c3e246b8025ed
    
    Previously, each driver had to tell DRI2 what GL driver object should
    be loaded.  Originally for a 2D driver that was a matter of giving the
    constant string for the vendor name, same as the driver's name.  For a
    driver that's trying to handle multiple generations of hardware with
    different Mesa driver filenames, the driver had to bake in a mapping
    from PCI ID to the appropriate driver name in Mesa, which seems like a
    pretty awful layering violation (and one that was fixed with DRI3)
    
    As of January, Mesa now handles the mapping from a DRI fd to the
    driver name on its own, but the AIGLX loader still relies on DRI2 for
    choosing the filename.  Instead of propagating the PCI ID list from
    each 2D driver to the modesetting driver, import a central copy of the
    PCI ID list so that drivers can stop handling this themselves.  (Some
    day, when AIGLX transitions to EGL, we can drop the DRI2 filename
    setup entirely).
    
    Signed-off-by: Eric Anholt <eric at anholt.net>
    Reviewed-by: Adam Jackson <ajax at redhat.com>

diff --git a/hw/xfree86/dri2/pci_ids/i810_pci_ids.h b/hw/xfree86/dri2/pci_ids/i810_pci_ids.h
new file mode 100644
index 0000000..7f68192
--- /dev/null
+++ b/hw/xfree86/dri2/pci_ids/i810_pci_ids.h
@@ -0,0 +1,4 @@
+CHIPSET(0x7121, I810, i8xx)
+CHIPSET(0x7123, I810_DC100, i8xx)
+CHIPSET(0x7125, I810_E, i8xx)
+CHIPSET(0x1132, I815, i8xx)
diff --git a/hw/xfree86/dri2/pci_ids/i915_pci_ids.h b/hw/xfree86/dri2/pci_ids/i915_pci_ids.h
new file mode 100644
index 0000000..7d51975
--- /dev/null
+++ b/hw/xfree86/dri2/pci_ids/i915_pci_ids.h
@@ -0,0 +1,15 @@
+CHIPSET(0x3577, I830_M,   "Intel(R) 830M")
+CHIPSET(0x2562, 845_G,    "Intel(R) 845G")
+CHIPSET(0x3582, I855_GM,  "Intel(R) 852GM/855GM")
+CHIPSET(0x2572, I865_G,   "Intel(R) 865G")
+CHIPSET(0x2582, I915_G,   "Intel(R) 915G")
+CHIPSET(0x258A, E7221_G,  "Intel(R) E7221G (i915)")
+CHIPSET(0x2592, I915_GM,  "Intel(R) 915GM")
+CHIPSET(0x2772, I945_G,   "Intel(R) 945G")
+CHIPSET(0x27A2, I945_GM,  "Intel(R) 945GM")
+CHIPSET(0x27AE, I945_GME, "Intel(R) 945GME")
+CHIPSET(0x29B2, Q35_G,    "Intel(R) Q35")
+CHIPSET(0x29C2, G33_G,    "Intel(R) G33")
+CHIPSET(0x29D2, Q33_G,    "Intel(R) Q33")
+CHIPSET(0xA011, IGD_GM,   "Intel(R) IGD")
+CHIPSET(0xA001, IGD_G,    "Intel(R) IGD")
diff --git a/hw/xfree86/dri2/pci_ids/i965_pci_ids.h b/hw/xfree86/dri2/pci_ids/i965_pci_ids.h
new file mode 100644
index 0000000..2e04301
--- /dev/null
+++ b/hw/xfree86/dri2/pci_ids/i965_pci_ids.h
@@ -0,0 +1,115 @@
+CHIPSET(0x29A2, i965,    "Intel(R) 965G")
+CHIPSET(0x2992, i965,    "Intel(R) 965Q")
+CHIPSET(0x2982, i965,    "Intel(R) 965G")
+CHIPSET(0x2972, i965,    "Intel(R) 946GZ")
+CHIPSET(0x2A02, i965,    "Intel(R) 965GM")
+CHIPSET(0x2A12, i965,    "Intel(R) 965GME/GLE")
+CHIPSET(0x2A42, g4x,     "Mobile Intel® GM45 Express Chipset")
+CHIPSET(0x2E02, g4x,     "Intel(R) Integrated Graphics Device")
+CHIPSET(0x2E12, g4x,     "Intel(R) Q45/Q43")
+CHIPSET(0x2E22, g4x,     "Intel(R) G45/G43")
+CHIPSET(0x2E32, g4x,     "Intel(R) G41")
+CHIPSET(0x2E42, g4x,     "Intel(R) B43")
+CHIPSET(0x2E92, g4x,     "Intel(R) B43")
+CHIPSET(0x0042, ilk,     "Intel(R) Ironlake Desktop")
+CHIPSET(0x0046, ilk,     "Intel(R) Ironlake Mobile")
+CHIPSET(0x0102, snb_gt1, "Intel(R) Sandybridge Desktop")
+CHIPSET(0x0112, snb_gt2, "Intel(R) Sandybridge Desktop")
+CHIPSET(0x0122, snb_gt2, "Intel(R) Sandybridge Desktop")
+CHIPSET(0x0106, snb_gt1, "Intel(R) Sandybridge Mobile")
+CHIPSET(0x0116, snb_gt2, "Intel(R) Sandybridge Mobile")
+CHIPSET(0x0126, snb_gt2, "Intel(R) Sandybridge Mobile")
+CHIPSET(0x010A, snb_gt1, "Intel(R) Sandybridge Server")
+CHIPSET(0x0152, ivb_gt1, "Intel(R) Ivybridge Desktop")
+CHIPSET(0x0162, ivb_gt2, "Intel(R) Ivybridge Desktop")
+CHIPSET(0x0156, ivb_gt1, "Intel(R) Ivybridge Mobile")
+CHIPSET(0x0166, ivb_gt2, "Intel(R) Ivybridge Mobile")
+CHIPSET(0x015a, ivb_gt1, "Intel(R) Ivybridge Server")
+CHIPSET(0x016a, ivb_gt2, "Intel(R) Ivybridge Server")
+CHIPSET(0x0402, hsw_gt1, "Intel(R) Haswell Desktop")
+CHIPSET(0x0412, hsw_gt2, "Intel(R) Haswell Desktop")
+CHIPSET(0x0422, hsw_gt3, "Intel(R) Haswell Desktop")
+CHIPSET(0x0406, hsw_gt1, "Intel(R) Haswell Mobile")
+CHIPSET(0x0416, hsw_gt2, "Intel(R) Haswell Mobile")
+CHIPSET(0x0426, hsw_gt3, "Intel(R) Haswell Mobile")
+CHIPSET(0x040A, hsw_gt1, "Intel(R) Haswell Server")
+CHIPSET(0x041A, hsw_gt2, "Intel(R) Haswell Server")
+CHIPSET(0x042A, hsw_gt3, "Intel(R) Haswell Server")
+CHIPSET(0x040B, hsw_gt1, "Intel(R) Haswell")
+CHIPSET(0x041B, hsw_gt2, "Intel(R) Haswell")
+CHIPSET(0x042B, hsw_gt3, "Intel(R) Haswell")
+CHIPSET(0x040E, hsw_gt1, "Intel(R) Haswell")
+CHIPSET(0x041E, hsw_gt2, "Intel(R) Haswell")
+CHIPSET(0x042E, hsw_gt3, "Intel(R) Haswell")
+CHIPSET(0x0C02, hsw_gt1, "Intel(R) Haswell Desktop")
+CHIPSET(0x0C12, hsw_gt2, "Intel(R) Haswell Desktop")
+CHIPSET(0x0C22, hsw_gt3, "Intel(R) Haswell Desktop")
+CHIPSET(0x0C06, hsw_gt1, "Intel(R) Haswell Mobile")
+CHIPSET(0x0C16, hsw_gt2, "Intel(R) Haswell Mobile")
+CHIPSET(0x0C26, hsw_gt3, "Intel(R) Haswell Mobile")
+CHIPSET(0x0C0A, hsw_gt1, "Intel(R) Haswell Server")
+CHIPSET(0x0C1A, hsw_gt2, "Intel(R) Haswell Server")
+CHIPSET(0x0C2A, hsw_gt3, "Intel(R) Haswell Server")
+CHIPSET(0x0C0B, hsw_gt1, "Intel(R) Haswell")
+CHIPSET(0x0C1B, hsw_gt2, "Intel(R) Haswell")
+CHIPSET(0x0C2B, hsw_gt3, "Intel(R) Haswell")
+CHIPSET(0x0C0E, hsw_gt1, "Intel(R) Haswell")
+CHIPSET(0x0C1E, hsw_gt2, "Intel(R) Haswell")
+CHIPSET(0x0C2E, hsw_gt3, "Intel(R) Haswell")
+CHIPSET(0x0A02, hsw_gt1, "Intel(R) Haswell Desktop")
+CHIPSET(0x0A12, hsw_gt2, "Intel(R) Haswell Desktop")
+CHIPSET(0x0A22, hsw_gt3, "Intel(R) Haswell Desktop")
+CHIPSET(0x0A06, hsw_gt1, "Intel(R) Haswell Mobile")
+CHIPSET(0x0A16, hsw_gt2, "Intel(R) Haswell Mobile")
+CHIPSET(0x0A26, hsw_gt3, "Intel(R) Haswell Mobile")
+CHIPSET(0x0A0A, hsw_gt1, "Intel(R) Haswell Server")
+CHIPSET(0x0A1A, hsw_gt2, "Intel(R) Haswell Server")
+CHIPSET(0x0A2A, hsw_gt3, "Intel(R) Haswell Server")
+CHIPSET(0x0A0B, hsw_gt1, "Intel(R) Haswell")
+CHIPSET(0x0A1B, hsw_gt2, "Intel(R) Haswell")
+CHIPSET(0x0A2B, hsw_gt3, "Intel(R) Haswell")
+CHIPSET(0x0A0E, hsw_gt1, "Intel(R) Haswell")
+CHIPSET(0x0A1E, hsw_gt2, "Intel(R) Haswell")
+CHIPSET(0x0A2E, hsw_gt3, "Intel(R) Haswell")
+CHIPSET(0x0D02, hsw_gt1, "Intel(R) Haswell Desktop")
+CHIPSET(0x0D12, hsw_gt2, "Intel(R) Haswell Desktop")
+CHIPSET(0x0D22, hsw_gt3, "Intel(R) Haswell Desktop")
+CHIPSET(0x0D06, hsw_gt1, "Intel(R) Haswell Mobile")
+CHIPSET(0x0D16, hsw_gt2, "Intel(R) Haswell Mobile")
+CHIPSET(0x0D26, hsw_gt3, "Intel(R) Haswell Mobile")
+CHIPSET(0x0D0A, hsw_gt1, "Intel(R) Haswell Server")
+CHIPSET(0x0D1A, hsw_gt2, "Intel(R) Haswell Server")
+CHIPSET(0x0D2A, hsw_gt3, "Intel(R) Haswell")
+CHIPSET(0x0D0B, hsw_gt1, "Intel(R) Haswell")
+CHIPSET(0x0D1B, hsw_gt2, "Intel(R) Haswell")
+CHIPSET(0x0D2B, hsw_gt3, "Intel(R) Haswell")
+CHIPSET(0x0D0E, hsw_gt1, "Intel(R) Haswell")
+CHIPSET(0x0D1E, hsw_gt2, "Intel(R) Haswell")
+CHIPSET(0x0D2E, hsw_gt3, "Intel(R) Haswell")
+CHIPSET(0x0F31, byt,     "Intel(R) Bay Trail")
+CHIPSET(0x0F32, byt,     "Intel(R) Bay Trail")
+CHIPSET(0x0F33, byt,     "Intel(R) Bay Trail")
+CHIPSET(0x0157, byt,     "Intel(R) Bay Trail")
+CHIPSET(0x0155, byt,     "Intel(R) Bay Trail")
+CHIPSET(0x1602, bdw_gt1, "Intel(R) Broadwell GT1")
+CHIPSET(0x1606, bdw_gt1, "Intel(R) Broadwell GT1")
+CHIPSET(0x160A, bdw_gt1, "Intel(R) Broadwell GT1")
+CHIPSET(0x160B, bdw_gt1, "Intel(R) Broadwell GT1")
+CHIPSET(0x160D, bdw_gt1, "Intel(R) Broadwell GT1")
+CHIPSET(0x160E, bdw_gt1, "Intel(R) Broadwell GT1")
+CHIPSET(0x1612, bdw_gt2, "Intel(R) HD Graphics 5600 (Broadwell GT2)")
+CHIPSET(0x1616, bdw_gt2, "Intel(R) HD Graphics 5500 (Broadwell GT2)")
+CHIPSET(0x161A, bdw_gt2, "Intel(R) Broadwell GT2")
+CHIPSET(0x161B, bdw_gt2, "Intel(R) Broadwell GT2")
+CHIPSET(0x161D, bdw_gt2, "Intel(R) Broadwell GT2")
+CHIPSET(0x161E, bdw_gt2, "Intel(R) HD Graphics 5300 (Broadwell GT2)")
+CHIPSET(0x1622, bdw_gt3, "Intel(R) Iris Pro 6200 (Broadwell GT3e)")
+CHIPSET(0x1626, bdw_gt3, "Intel(R) HD Graphics 6000 (Broadwell GT3)")
+CHIPSET(0x162A, bdw_gt3, "Intel(R) Iris Pro P6300 (Broadwell GT3e)")
+CHIPSET(0x162B, bdw_gt3, "Intel(R) Iris 6100 (Broadwell GT3)")
+CHIPSET(0x162D, bdw_gt3, "Intel(R) Broadwell GT3")
+CHIPSET(0x162E, bdw_gt3, "Intel(R) Broadwell GT3")
+CHIPSET(0x22B0, chv,     "Intel(R) Cherryview")
+CHIPSET(0x22B1, chv,     "Intel(R) Cherryview")
+CHIPSET(0x22B2, chv,     "Intel(R) Cherryview")
+CHIPSET(0x22B3, chv,     "Intel(R) Cherryview")
diff --git a/hw/xfree86/dri2/pci_ids/pci_id_driver_map.h b/hw/xfree86/dri2/pci_ids/pci_id_driver_map.h
new file mode 100644
index 0000000..8a97c6f
--- /dev/null
+++ b/hw/xfree86/dri2/pci_ids/pci_id_driver_map.h
@@ -0,0 +1,80 @@
+#ifndef _PCI_ID_DRIVER_MAP_H_
+#define _PCI_ID_DRIVER_MAP_H_
+
+#include <stddef.h>
+
+#ifndef ARRAY_SIZE
+#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
+#endif
+
+static const int i915_chip_ids[] = {
+#define CHIPSET(chip, desc, name) chip,
+#include "pci_ids/i915_pci_ids.h"
+#undef CHIPSET
+};
+
+static const int i965_chip_ids[] = {
+#define CHIPSET(chip, family, name) chip,
+#include "pci_ids/i965_pci_ids.h"
+#undef CHIPSET
+};
+
+#ifndef DRIVER_MAP_GALLIUM_ONLY
+static const int r100_chip_ids[] = {
+#define CHIPSET(chip, name, family) chip,
+#include "pci_ids/radeon_pci_ids.h"
+#undef CHIPSET
+};
+
+static const int r200_chip_ids[] = {
+#define CHIPSET(chip, name, family) chip,
+#include "pci_ids/r200_pci_ids.h"
+#undef CHIPSET
+};
+#endif
+
+static const int r300_chip_ids[] = {
+#define CHIPSET(chip, name, family) chip,
+#include "pci_ids/r300_pci_ids.h"
+#undef CHIPSET
+};
+
+static const int r600_chip_ids[] = {
+#define CHIPSET(chip, name, family) chip,
+#include "pci_ids/r600_pci_ids.h"
+#undef CHIPSET
+};
+
+static const int radeonsi_chip_ids[] = {
+#define CHIPSET(chip, name, family) chip,
+#include "pci_ids/radeonsi_pci_ids.h"
+#undef CHIPSET
+};
+
+static const int vmwgfx_chip_ids[] = {
+#define CHIPSET(chip, name, family) chip,
+#include "pci_ids/vmwgfx_pci_ids.h"
+#undef CHIPSET
+};
+
+static const struct {
+   int vendor_id;
+   const char *driver;
+   const int *chip_ids;
+   int num_chips_ids;
+} driver_map[] = {
+   { 0x8086, "i915", i915_chip_ids, ARRAY_SIZE(i915_chip_ids) },
+   { 0x8086, "i965", i965_chip_ids, ARRAY_SIZE(i965_chip_ids) },
+#ifndef DRIVER_MAP_GALLIUM_ONLY
+   { 0x1002, "radeon", r100_chip_ids, ARRAY_SIZE(r100_chip_ids) },
+   { 0x1002, "r200", r200_chip_ids, ARRAY_SIZE(r200_chip_ids) },
+#endif
+   { 0x1002, "r300", r300_chip_ids, ARRAY_SIZE(r300_chip_ids) },
+   { 0x1002, "r600", r600_chip_ids, ARRAY_SIZE(r600_chip_ids) },
+   { 0x1002, "radeonsi", radeonsi_chip_ids, ARRAY_SIZE(radeonsi_chip_ids) },
+   { 0x10de, "nouveau", NULL, -1 },
+   { 0x15ad, "vmwgfx", vmwgfx_chip_ids, ARRAY_SIZE(vmwgfx_chip_ids) },
+   { 0x0000, NULL, NULL, 0 },
+};
+
+#endif /* _PCI_ID_DRIVER_MAP_H_ */
diff --git a/hw/xfree86/dri2/pci_ids/r200_pci_ids.h b/hw/xfree86/dri2/pci_ids/r200_pci_ids.h
new file mode 100644
index 0000000..f857ca7
--- /dev/null
+++ b/hw/xfree86/dri2/pci_ids/r200_pci_ids.h
@@ -0,0 +1,24 @@
+CHIPSET(0x5148, R200_QH, R200)
+CHIPSET(0x514C, R200_QL, R200)
+CHIPSET(0x514D, R200_QM, R200)
+CHIPSET(0x4242, R200_BB, R200)
+
+CHIPSET(0x4966, RV250_If, RV250)
+CHIPSET(0x4967, RV250_Ig, RV250)
+CHIPSET(0x4C64, RV250_Ld, RV250)
+CHIPSET(0x4C66, RV250_Lf, RV250)
+CHIPSET(0x4C67, RV250_Lg, RV250)
+
+CHIPSET(0x4C6E, RV280_4C6E, RV280)
+CHIPSET(0x5960, RV280_5960, RV280)
+CHIPSET(0x5961, RV280_5961, RV280)
+CHIPSET(0x5962, RV280_5962, RV280)
+CHIPSET(0x5964, RV280_5964, RV280)
+CHIPSET(0x5965, RV280_5965, RV280)
+CHIPSET(0x5C61, RV280_5C61, RV280)
+CHIPSET(0x5C63, RV280_5C63, RV280)
+
+CHIPSET(0x5834, RS300_5834, RS300)
+CHIPSET(0x5835, RS300_5835, RS300)
+CHIPSET(0x7834, RS350_7834, RS300)
+CHIPSET(0x7835, RS350_7835, RS300)
diff --git a/hw/xfree86/dri2/pci_ids/r300_pci_ids.h b/hw/xfree86/dri2/pci_ids/r300_pci_ids.h
new file mode 100644
index 0000000..791026a
--- /dev/null
+++ b/hw/xfree86/dri2/pci_ids/r300_pci_ids.h
@@ -0,0 +1,227 @@
+CHIPSET(0x4144, R300_AD, R300)
+CHIPSET(0x4145, R300_AE, R300)
+CHIPSET(0x4146, R300_AF, R300)
+CHIPSET(0x4147, R300_AG, R300)
+CHIPSET(0x4E44, R300_ND, R300)
+CHIPSET(0x4E45, R300_NE, R300)
+CHIPSET(0x4E46, R300_NF, R300)
+CHIPSET(0x4E47, R300_NG, R300)
+
+CHIPSET(0x4E48, R350_NH, R350)
+CHIPSET(0x4E49, R350_NI, R350)
+CHIPSET(0x4E4B, R350_NK, R350)
+CHIPSET(0x4148, R350_AH, R350)
+CHIPSET(0x4149, R350_AI, R350)
+CHIPSET(0x414A, R350_AJ, R350)
+CHIPSET(0x414B, R350_AK, R350)
+CHIPSET(0x4E4A, R360_NJ, R350)
+
+CHIPSET(0x4150, RV350_AP, RV350)
+CHIPSET(0x4151, RV350_AQ, RV350)
+CHIPSET(0x4152, RV350_AR, RV350)
+CHIPSET(0x4153, RV350_AS, RV350)
+CHIPSET(0x4154, RV350_AT, RV350)
+CHIPSET(0x4155, RV350_AU, RV350)
+CHIPSET(0x4156, RV350_AV, RV350)
+CHIPSET(0x4E50, RV350_NP, RV350)
+CHIPSET(0x4E51, RV350_NQ, RV350)
+CHIPSET(0x4E52, RV350_NR, RV350)
+CHIPSET(0x4E53, RV350_NS, RV350)
+CHIPSET(0x4E54, RV350_NT, RV350)
+CHIPSET(0x4E56, RV350_NV, RV350)
+
+CHIPSET(0x5460, RV370_5460, RV370)
+CHIPSET(0x5462, RV370_5462, RV370)
+CHIPSET(0x5464, RV370_5464, RV370)
+CHIPSET(0x5B60, RV370_5B60, RV370)
+CHIPSET(0x5B62, RV370_5B62, RV370)
+CHIPSET(0x5B63, RV370_5B63, RV370)
+CHIPSET(0x5B64, RV370_5B64, RV370)
+CHIPSET(0x5B65, RV370_5B65, RV370)
+
+CHIPSET(0x3150, RV380_3150, RV380)
+CHIPSET(0x3151, RV380_3151, RV380)
+CHIPSET(0x3152, RV380_3152, RV380)
+CHIPSET(0x3154, RV380_3154, RV380)
+CHIPSET(0x3155, RV380_3155, RV380)
+CHIPSET(0x3E50, RV380_3E50, RV380)
+CHIPSET(0x3E54, RV380_3E54, RV380)
+
+CHIPSET(0x4A48, R420_JH, R420)
+CHIPSET(0x4A49, R420_JI, R420)
+CHIPSET(0x4A4A, R420_JJ, R420)
+CHIPSET(0x4A4B, R420_JK, R420)
+CHIPSET(0x4A4C, R420_JL, R420)
+CHIPSET(0x4A4D, R420_JM, R420)
+CHIPSET(0x4A4E, R420_JN, R420)
+CHIPSET(0x4A4F, R420_JO, R420)
+CHIPSET(0x4A50, R420_JP, R420)
+CHIPSET(0x4A54, R420_JT, R420)
+
+CHIPSET(0x5548, R423_UH, R423)
+CHIPSET(0x5549, R423_UI, R423)
+CHIPSET(0x554A, R423_UJ, R423)
+CHIPSET(0x554B, R423_UK, R423)
+CHIPSET(0x5550, R423_5550, R423)
+CHIPSET(0x5551, R423_UQ, R423)
+CHIPSET(0x5552, R423_UR, R423)
+CHIPSET(0x5554, R423_UT, R423)
+CHIPSET(0x5D57, R423_5D57, R423)
+
+CHIPSET(0x554C, R430_554C, R430)
+CHIPSET(0x554D, R430_554D, R430)
+CHIPSET(0x554E, R430_554E, R430)
+CHIPSET(0x554F, R430_554F, R430)
+CHIPSET(0x5D48, R430_5D48, R430)
+CHIPSET(0x5D49, R430_5D49, R430)
+CHIPSET(0x5D4A, R430_5D4A, R430)
+
+CHIPSET(0x5D4C, R480_5D4C, R480)
+CHIPSET(0x5D4D, R480_5D4D, R480)
+CHIPSET(0x5D4E, R480_5D4E, R480)
+CHIPSET(0x5D4F, R480_5D4F, R480)
+CHIPSET(0x5D50, R480_5D50, R480)
+CHIPSET(0x5D52, R480_5D52, R480)
+
+CHIPSET(0x4B48, R481_4B48, R481)
+CHIPSET(0x4B49, R481_4B49, R481)
+CHIPSET(0x4B4A, R481_4B4A, R481)
+CHIPSET(0x4B4B, R481_4B4B, R481)
+CHIPSET(0x4B4C, R481_4B4C, R481)
+
+CHIPSET(0x564A, RV410_564A, RV410)
+CHIPSET(0x564B, RV410_564B, RV410)
+CHIPSET(0x564F, RV410_564F, RV410)
+CHIPSET(0x5652, RV410_5652, RV410)
+CHIPSET(0x5653, RV410_5653, RV410)
+CHIPSET(0x5657, RV410_5657, RV410)
+CHIPSET(0x5E48, RV410_5E48, RV410)
+CHIPSET(0x5E4A, RV410_5E4A, RV410)
+CHIPSET(0x5E4B, RV410_5E4B, RV410)
+CHIPSET(0x5E4C, RV410_5E4C, RV410)
+CHIPSET(0x5E4D, RV410_5E4D, RV410)
+CHIPSET(0x5E4F, RV410_5E4F, RV410)
+
+CHIPSET(0x5A41, RS400_5A41, RS400)
+CHIPSET(0x5A42, RS400_5A42, RS400)
+
+CHIPSET(0x5A61, RC410_5A61, RC410)
+CHIPSET(0x5A62, RC410_5A62, RC410)
+
+CHIPSET(0x5954, RS480_5954, RS480)
+CHIPSET(0x5955, RS480_5955, RS480)
+CHIPSET(0x5974, RS482_5974, RS480)
+CHIPSET(0x5975, RS482_5975, RS480)
+
+CHIPSET(0x7100, R520_7100, R520)
+CHIPSET(0x7101, R520_7101, R520)
+CHIPSET(0x7102, R520_7102, R520)
+CHIPSET(0x7103, R520_7103, R520)
+CHIPSET(0x7104, R520_7104, R520)
+CHIPSET(0x7105, R520_7105, R520)
+CHIPSET(0x7106, R520_7106, R520)
+CHIPSET(0x7108, R520_7108, R520)
+CHIPSET(0x7109, R520_7109, R520)
+CHIPSET(0x710A, R520_710A, R520)
+CHIPSET(0x710B, R520_710B, R520)
+CHIPSET(0x710C, R520_710C, R520)
+CHIPSET(0x710E, R520_710E, R520)
+CHIPSET(0x710F, R520_710F, R520)
+
+CHIPSET(0x7140, RV515_7140, RV515)
+CHIPSET(0x7141, RV515_7141, RV515)
+CHIPSET(0x7142, RV515_7142, RV515)
+CHIPSET(0x7143, RV515_7143, RV515)
+CHIPSET(0x7144, RV515_7144, RV515)
+CHIPSET(0x7145, RV515_7145, RV515)
+CHIPSET(0x7146, RV515_7146, RV515)
+CHIPSET(0x7147, RV515_7147, RV515)
+CHIPSET(0x7149, RV515_7149, RV515)
+CHIPSET(0x714A, RV515_714A, RV515)
+CHIPSET(0x714B, RV515_714B, RV515)
+CHIPSET(0x714C, RV515_714C, RV515)
+CHIPSET(0x714D, RV515_714D, RV515)
+CHIPSET(0x714E, RV515_714E, RV515)
+CHIPSET(0x714F, RV515_714F, RV515)
+CHIPSET(0x7151, RV515_7151, RV515)
+CHIPSET(0x7152, RV515_7152, RV515)
+CHIPSET(0x7153, RV515_7153, RV515)
+CHIPSET(0x715E, RV515_715E, RV515)
+CHIPSET(0x715F, RV515_715F, RV515)
+CHIPSET(0x7180, RV515_7180, RV515)
+CHIPSET(0x7181, RV515_7181, RV515)
+CHIPSET(0x7183, RV515_7183, RV515)
+CHIPSET(0x7186, RV515_7186, RV515)
+CHIPSET(0x7187, RV515_7187, RV515)
+CHIPSET(0x7188, RV515_7188, RV515)
+CHIPSET(0x718A, RV515_718A, RV515)
+CHIPSET(0x718B, RV515_718B, RV515)
+CHIPSET(0x718C, RV515_718C, RV515)
+CHIPSET(0x718D, RV515_718D, RV515)
+CHIPSET(0x718F, RV515_718F, RV515)
+CHIPSET(0x7193, RV515_7193, RV515)
+CHIPSET(0x7196, RV515_7196, RV515)
+CHIPSET(0x719B, RV515_719B, RV515)
+CHIPSET(0x719F, RV515_719F, RV515)
+CHIPSET(0x7200, RV515_7200, RV515)
+CHIPSET(0x7210, RV515_7210, RV515)
+CHIPSET(0x7211, RV515_7211, RV515)
+
+CHIPSET(0x71C0, RV530_71C0, RV530)
+CHIPSET(0x71C1, RV530_71C1, RV530)
+CHIPSET(0x71C2, RV530_71C2, RV530)
+CHIPSET(0x71C3, RV530_71C3, RV530)
+CHIPSET(0x71C4, RV530_71C4, RV530)
+CHIPSET(0x71C5, RV530_71C5, RV530)
+CHIPSET(0x71C6, RV530_71C6, RV530)
+CHIPSET(0x71C7, RV530_71C7, RV530)
+CHIPSET(0x71CD, RV530_71CD, RV530)
+CHIPSET(0x71CE, RV530_71CE, RV530)
+CHIPSET(0x71D2, RV530_71D2, RV530)
+CHIPSET(0x71D4, RV530_71D4, RV530)
+CHIPSET(0x71D5, RV530_71D5, RV530)
+CHIPSET(0x71D6, RV530_71D6, RV530)
+CHIPSET(0x71DA, RV530_71DA, RV530)
+CHIPSET(0x71DE, RV530_71DE, RV530)
+
+CHIPSET(0x7281, RV560_7281, RV560)
+CHIPSET(0x7283, RV560_7283, RV560)
+CHIPSET(0x7287, RV560_7287, RV560)
+CHIPSET(0x7290, RV560_7290, RV560)
+CHIPSET(0x7291, RV560_7291, RV560)
+CHIPSET(0x7293, RV560_7293, RV560)
+CHIPSET(0x7297, RV560_7297, RV560)
+
+CHIPSET(0x7280, RV570_7280, RV570)
+CHIPSET(0x7288, RV570_7288, RV570)
+CHIPSET(0x7289, RV570_7289, RV570)
+CHIPSET(0x728B, RV570_728B, RV570)
+CHIPSET(0x728C, RV570_728C, RV570)
+
+CHIPSET(0x7240, R580_7240, R580)
+CHIPSET(0x7243, R580_7243, R580)
+CHIPSET(0x7244, R580_7244, R580)
+CHIPSET(0x7245, R580_7245, R580)
+CHIPSET(0x7246, R580_7246, R580)
+CHIPSET(0x7247, R580_7247, R580)
+CHIPSET(0x7248, R580_7248, R580)
+CHIPSET(0x7249, R580_7249, R580)
+CHIPSET(0x724A, R580_724A, R580)
+CHIPSET(0x724B, R580_724B, R580)
+CHIPSET(0x724C, R580_724C, R580)
+CHIPSET(0x724D, R580_724D, R580)
+CHIPSET(0x724E, R580_724E, R580)
+CHIPSET(0x724F, R580_724F, R580)
+CHIPSET(0x7284, R580_7284, R580)
+
+CHIPSET(0x793F, RS600_793F, RS600)
+CHIPSET(0x7941, RS600_7941, RS600)
+CHIPSET(0x7942, RS600_7942, RS600)
+
+CHIPSET(0x791E, RS690_791E, RS690)
+CHIPSET(0x791F, RS690_791F, RS690)
+
+CHIPSET(0x796C, RS740_796C, RS740)
+CHIPSET(0x796D, RS740_796D, RS740)
+CHIPSET(0x796E, RS740_796E, RS740)
+CHIPSET(0x796F, RS740_796F, RS740)
diff --git a/hw/xfree86/dri2/pci_ids/r600_pci_ids.h b/hw/xfree86/dri2/pci_ids/r600_pci_ids.h
new file mode 100644
index 0000000..533c9f3
--- /dev/null
+++ b/hw/xfree86/dri2/pci_ids/r600_pci_ids.h
@@ -0,0 +1,327 @@
+CHIPSET(0x9400, R600_9400, R600)
+CHIPSET(0x9401, R600_9401, R600)
+CHIPSET(0x9402, R600_9402, R600)
+CHIPSET(0x9403, R600_9403, R600)
+CHIPSET(0x9405, R600_9405, R600)
+CHIPSET(0x940A, R600_940A, R600)
+CHIPSET(0x940B, R600_940B, R600)
+CHIPSET(0x940F, R600_940F, R600)
+
+CHIPSET(0x94C0, RV610_94C0, RV610)
+CHIPSET(0x94C1, RV610_94C1, RV610)
+CHIPSET(0x94C3, RV610_94C3, RV610)
+CHIPSET(0x94C4, RV610_94C4, RV610)
+CHIPSET(0x94C5, RV610_94C5, RV610)
+CHIPSET(0x94C6, RV610_94C6, RV610)
+CHIPSET(0x94C7, RV610_94C7, RV610)
+CHIPSET(0x94C8, RV610_94C8, RV610)
+CHIPSET(0x94C9, RV610_94C9, RV610)
+CHIPSET(0x94CB, RV610_94CB, RV610)
+CHIPSET(0x94CC, RV610_94CC, RV610)
+CHIPSET(0x94CD, RV610_94CD, RV610)
+
+CHIPSET(0x9580, RV630_9580, RV630)
+CHIPSET(0x9581, RV630_9581, RV630)
+CHIPSET(0x9583, RV630_9583, RV630)
+CHIPSET(0x9586, RV630_9586, RV630)
+CHIPSET(0x9587, RV630_9587, RV630)
+CHIPSET(0x9588, RV630_9588, RV630)
+CHIPSET(0x9589, RV630_9589, RV630)
+CHIPSET(0x958A, RV630_958A, RV630)
+CHIPSET(0x958B, RV630_958B, RV630)
+CHIPSET(0x958C, RV630_958C, RV630)
+CHIPSET(0x958D, RV630_958D, RV630)
+CHIPSET(0x958E, RV630_958E, RV630)
+CHIPSET(0x958F, RV630_958F, RV630)
+
+CHIPSET(0x9500, RV670_9500, RV670)
+CHIPSET(0x9501, RV670_9501, RV670)
+CHIPSET(0x9504, RV670_9504, RV670)
+CHIPSET(0x9505, RV670_9505, RV670)
+CHIPSET(0x9506, RV670_9506, RV670)
+CHIPSET(0x9507, RV670_9507, RV670)
+CHIPSET(0x9508, RV670_9508, RV670)
+CHIPSET(0x9509, RV670_9509, RV670)
+CHIPSET(0x950F, RV670_950F, RV670)
+CHIPSET(0x9511, RV670_9511, RV670)
+CHIPSET(0x9515, RV670_9515, RV670)
+CHIPSET(0x9517, RV670_9517, RV670)
+CHIPSET(0x9519, RV670_9519, RV670)
+
+CHIPSET(0x95C0, RV620_95C0, RV620)
+CHIPSET(0x95C2, RV620_95C2, RV620)
+CHIPSET(0x95C4, RV620_95C4, RV620)
+CHIPSET(0x95C5, RV620_95C5, RV620)
+CHIPSET(0x95C6, RV620_95C6, RV620)
+CHIPSET(0x95C7, RV620_95C7, RV620)
+CHIPSET(0x95C9, RV620_95C9, RV620)
+CHIPSET(0x95CC, RV620_95CC, RV620)
+CHIPSET(0x95CD, RV620_95CD, RV620)
+CHIPSET(0x95CE, RV620_95CE, RV620)
+CHIPSET(0x95CF, RV620_95CF, RV620)
+
+CHIPSET(0x9590, RV635_9590, RV635)
+CHIPSET(0x9591, RV635_9591, RV635)
+CHIPSET(0x9593, RV635_9593, RV635)
+CHIPSET(0x9595, RV635_9595, RV635)
+CHIPSET(0x9596, RV635_9596, RV635)
+CHIPSET(0x9597, RV635_9597, RV635)
+CHIPSET(0x9598, RV635_9598, RV635)
+CHIPSET(0x9599, RV635_9599, RV635)
+CHIPSET(0x959B, RV635_959B, RV635)
+
+CHIPSET(0x9610, RS780_9610, RS780)
+CHIPSET(0x9611, RS780_9611, RS780)
+CHIPSET(0x9612, RS780_9612, RS780)
+CHIPSET(0x9613, RS780_9613, RS780)
+CHIPSET(0x9614, RS780_9614, RS780)
+CHIPSET(0x9615, RS780_9615, RS780)
+CHIPSET(0x9616, RS780_9616, RS780)
+
+CHIPSET(0x9710, RS880_9710, RS880)
+CHIPSET(0x9711, RS880_9711, RS880)
+CHIPSET(0x9712, RS880_9712, RS880)
+CHIPSET(0x9713, RS880_9713, RS880)
+CHIPSET(0x9714, RS880_9714, RS880)
+CHIPSET(0x9715, RS880_9715, RS880)
+
+CHIPSET(0x9440, RV770_9440, RV770)
+CHIPSET(0x9441, RV770_9441, RV770)
+CHIPSET(0x9442, RV770_9442, RV770)
+CHIPSET(0x9443, RV770_9443, RV770)
+CHIPSET(0x9444, RV770_9444, RV770)
+CHIPSET(0x9446, RV770_9446, RV770)
+CHIPSET(0x944A, RV770_944A, RV770)
+CHIPSET(0x944B, RV770_944B, RV770)
+CHIPSET(0x944C, RV770_944C, RV770)
+CHIPSET(0x944E, RV770_944E, RV770)
+CHIPSET(0x9450, RV770_9450, RV770)
+CHIPSET(0x9452, RV770_9452, RV770)
+CHIPSET(0x9456, RV770_9456, RV770)
+CHIPSET(0x945A, RV770_945A, RV770)
+CHIPSET(0x945B, RV770_945B, RV770)
+CHIPSET(0x945E, RV770_945E, RV770)
+CHIPSET(0x9460, RV790_9460, RV770)
+CHIPSET(0x9462, RV790_9462, RV770)
+CHIPSET(0x946A, RV770_946A, RV770)
+CHIPSET(0x946B, RV770_946B, RV770)
+CHIPSET(0x947A, RV770_947A, RV770)
+CHIPSET(0x947B, RV770_947B, RV770)
+
+CHIPSET(0x9480, RV730_9480, RV730)
+CHIPSET(0x9487, RV730_9487, RV730)
+CHIPSET(0x9488, RV730_9488, RV730)
+CHIPSET(0x9489, RV730_9489, RV730)
+CHIPSET(0x948A, RV730_948A, RV730)
+CHIPSET(0x948F, RV730_948F, RV730)
+CHIPSET(0x9490, RV730_9490, RV730)
+CHIPSET(0x9491, RV730_9491, RV730)
+CHIPSET(0x9495, RV730_9495, RV730)
+CHIPSET(0x9498, RV730_9498, RV730)
+CHIPSET(0x949C, RV730_949C, RV730)
+CHIPSET(0x949E, RV730_949E, RV730)
+CHIPSET(0x949F, RV730_949F, RV730)
+
+CHIPSET(0x9540, RV710_9540, RV710)
+CHIPSET(0x9541, RV710_9541, RV710)
+CHIPSET(0x9542, RV710_9542, RV710)
+CHIPSET(0x954E, RV710_954E, RV710)
+CHIPSET(0x954F, RV710_954F, RV710)
+CHIPSET(0x9552, RV710_9552, RV710)
+CHIPSET(0x9553, RV710_9553, RV710)
+CHIPSET(0x9555, RV710_9555, RV710)
+CHIPSET(0x9557, RV710_9557, RV710)
+CHIPSET(0x955F, RV710_955F, RV710)
+
+CHIPSET(0x94A0, RV740_94A0, RV740)
+CHIPSET(0x94A1, RV740_94A1, RV740)
+CHIPSET(0x94A3, RV740_94A3, RV740)
+CHIPSET(0x94B1, RV740_94B1, RV740)
+CHIPSET(0x94B3, RV740_94B3, RV740)
+CHIPSET(0x94B4, RV740_94B4, RV740)
+CHIPSET(0x94B5, RV740_94B5, RV740)
+CHIPSET(0x94B9, RV740_94B9, RV740)
+
+CHIPSET(0x68E0, CEDAR_68E0, CEDAR)
+CHIPSET(0x68E1, CEDAR_68E1, CEDAR)
+CHIPSET(0x68E4, CEDAR_68E4, CEDAR)
+CHIPSET(0x68E5, CEDAR_68E5, CEDAR)
+CHIPSET(0x68E8, CEDAR_68E8, CEDAR)
+CHIPSET(0x68E9, CEDAR_68E9, CEDAR)
+CHIPSET(0x68F1, CEDAR_68F1, CEDAR)
+CHIPSET(0x68F2, CEDAR_68F2, CEDAR)
+CHIPSET(0x68F8, CEDAR_68F8, CEDAR)
+CHIPSET(0x68F9, CEDAR_68F9, CEDAR)
+CHIPSET(0x68FA, CEDAR_68FA, CEDAR)
+CHIPSET(0x68FE, CEDAR_68FE, CEDAR)
+
+CHIPSET(0x68C0, REDWOOD_68C0, REDWOOD)
+CHIPSET(0x68C1, REDWOOD_68C1, REDWOOD)
+CHIPSET(0x68C7, REDWOOD_68C7, REDWOOD)
+CHIPSET(0x68C8, REDWOOD_68C8, REDWOOD)
+CHIPSET(0x68C9, REDWOOD_68C9, REDWOOD)
+CHIPSET(0x68D8, REDWOOD_68D8, REDWOOD)
+CHIPSET(0x68D9, REDWOOD_68D9, REDWOOD)
+CHIPSET(0x68DA, REDWOOD_68DA, REDWOOD)
+CHIPSET(0x68DE, REDWOOD_68DE, REDWOOD)
+
+CHIPSET(0x68A0, JUNIPER_68A0, JUNIPER)
+CHIPSET(0x68A1, JUNIPER_68A1, JUNIPER)
+CHIPSET(0x68A8, JUNIPER_68A8, JUNIPER)
+CHIPSET(0x68A9, JUNIPER_68A9, JUNIPER)
+CHIPSET(0x68B0, JUNIPER_68B0, JUNIPER)
+CHIPSET(0x68B8, JUNIPER_68B8, JUNIPER)
+CHIPSET(0x68B9, JUNIPER_68B9, JUNIPER)
+CHIPSET(0x68BA, JUNIPER_68BA, JUNIPER)
+CHIPSET(0x68BE, JUNIPER_68BE, JUNIPER)
+CHIPSET(0x68BF, JUNIPER_68BF, JUNIPER)
+
+CHIPSET(0x6880, CYPRESS_6880, CYPRESS)
+CHIPSET(0x6888, CYPRESS_6888, CYPRESS)
+CHIPSET(0x6889, CYPRESS_6889, CYPRESS)
+CHIPSET(0x688A, CYPRESS_688A, CYPRESS)
+CHIPSET(0x688C, CYPRESS_688C, CYPRESS)
+CHIPSET(0x688D, CYPRESS_688D, CYPRESS)
+CHIPSET(0x6898, CYPRESS_6898, CYPRESS)
+CHIPSET(0x6899, CYPRESS_6899, CYPRESS)
+CHIPSET(0x689B, CYPRESS_689B, CYPRESS)
+CHIPSET(0x689E, CYPRESS_689E, CYPRESS)
+
+CHIPSET(0x689C, HEMLOCK_689C, HEMLOCK)
+CHIPSET(0x689D, HEMLOCK_689D, HEMLOCK)
+
+CHIPSET(0x9802, PALM_9802, PALM)
+CHIPSET(0x9803, PALM_9803, PALM)
+CHIPSET(0x9804, PALM_9804, PALM)
+CHIPSET(0x9805, PALM_9805, PALM)
+CHIPSET(0x9806, PALM_9806, PALM)
+CHIPSET(0x9807, PALM_9807, PALM)
+CHIPSET(0x9808, PALM_9808, PALM)
+CHIPSET(0x9809, PALM_9809, PALM)
+CHIPSET(0x980A, PALM_980A, PALM)
+
+CHIPSET(0x9640, SUMO_9640,  SUMO)
+CHIPSET(0x9641, SUMO_9641,  SUMO)
+CHIPSET(0x9642, SUMO2_9642, SUMO2)
+CHIPSET(0x9643, SUMO2_9643, SUMO2)
+CHIPSET(0x9644, SUMO2_9644, SUMO2)
+CHIPSET(0x9645, SUMO2_9645, SUMO2)
+CHIPSET(0x9647, SUMO_9647,  SUMO)
+CHIPSET(0x9648, SUMO_9648,  SUMO)
+CHIPSET(0x9649, SUMO2_9649, SUMO2)
+CHIPSET(0x964a, SUMO_964A,  SUMO)
+CHIPSET(0x964b, SUMO_964B,  SUMO)
+CHIPSET(0x964c, SUMO_964C,  SUMO)
+CHIPSET(0x964e, SUMO_964E,  SUMO)
+CHIPSET(0x964f, SUMO_964F,  SUMO)
+
+CHIPSET(0x6700, CAYMAN_6700, CAYMAN)
+CHIPSET(0x6701, CAYMAN_6701, CAYMAN)
+CHIPSET(0x6702, CAYMAN_6702, CAYMAN)
+CHIPSET(0x6703, CAYMAN_6703, CAYMAN)
+CHIPSET(0x6704, CAYMAN_6704, CAYMAN)
+CHIPSET(0x6705, CAYMAN_6705, CAYMAN)
+CHIPSET(0x6706, CAYMAN_6706, CAYMAN)
+CHIPSET(0x6707, CAYMAN_6707, CAYMAN)
+CHIPSET(0x6708, CAYMAN_6708, CAYMAN)
+CHIPSET(0x6709, CAYMAN_6709, CAYMAN)
+CHIPSET(0x6718, CAYMAN_6718, CAYMAN)
+CHIPSET(0x6719, CAYMAN_6719, CAYMAN)
+CHIPSET(0x671C, CAYMAN_671C, CAYMAN)
+CHIPSET(0x671D, CAYMAN_671D, CAYMAN)
+CHIPSET(0x671F, CAYMAN_671F, CAYMAN)
+
+CHIPSET(0x6720, BARTS_6720, BARTS)
+CHIPSET(0x6721, BARTS_6721, BARTS)
+CHIPSET(0x6722, BARTS_6722, BARTS)
+CHIPSET(0x6723, BARTS_6723, BARTS)
+CHIPSET(0x6724, BARTS_6724, BARTS)
+CHIPSET(0x6725, BARTS_6725, BARTS)
+CHIPSET(0x6726, BARTS_6726, BARTS)
+CHIPSET(0x6727, BARTS_6727, BARTS)
+CHIPSET(0x6728, BARTS_6728, BARTS)
+CHIPSET(0x6729, BARTS_6729, BARTS)
+CHIPSET(0x6738, BARTS_6738, BARTS)
+CHIPSET(0x6739, BARTS_6739, BARTS)
+CHIPSET(0x673E, BARTS_673E, BARTS)
+
+CHIPSET(0x6740, TURKS_6740, TURKS)
+CHIPSET(0x6741, TURKS_6741, TURKS)
+CHIPSET(0x6742, TURKS_6742, TURKS)
+CHIPSET(0x6743, TURKS_6743, TURKS)
+CHIPSET(0x6744, TURKS_6744, TURKS)
+CHIPSET(0x6745, TURKS_6745, TURKS)
+CHIPSET(0x6746, TURKS_6746, TURKS)
+CHIPSET(0x6747, TURKS_6747, TURKS)
+CHIPSET(0x6748, TURKS_6748, TURKS)
+CHIPSET(0x6749, TURKS_6749, TURKS)
+CHIPSET(0x674A, TURKS_674A, TURKS)
+CHIPSET(0x6750, TURKS_6750, TURKS)
+CHIPSET(0x6751, TURKS_6751, TURKS)
+CHIPSET(0x6758, TURKS_6758, TURKS)
+CHIPSET(0x6759, TURKS_6759, TURKS)
+CHIPSET(0x675B, TURKS_675B, TURKS)
+CHIPSET(0x675D, TURKS_675D, TURKS)
+CHIPSET(0x675F, TURKS_675F, TURKS)
+CHIPSET(0x6840, TURKS_6840, TURKS)
+CHIPSET(0x6841, TURKS_6841, TURKS)
+CHIPSET(0x6842, TURKS_6842, TURKS)
+CHIPSET(0x6843, TURKS_6843, TURKS)
+CHIPSET(0x6849, TURKS_6849, TURKS)
+CHIPSET(0x6850, TURKS_6850, TURKS)
+CHIPSET(0x6858, TURKS_6858, TURKS)
+CHIPSET(0x6859, TURKS_6859, TURKS)
+
+CHIPSET(0x6760, CAICOS_6760, CAICOS)
+CHIPSET(0x6761, CAICOS_6761, CAICOS)
+CHIPSET(0x6762, CAICOS_6762, CAICOS)
+CHIPSET(0x6763, CAICOS_6763, CAICOS)
+CHIPSET(0x6764, CAICOS_6764, CAICOS)
+CHIPSET(0x6765, CAICOS_6765, CAICOS)
+CHIPSET(0x6766, CAICOS_6766, CAICOS)
+CHIPSET(0x6767, CAICOS_6767, CAICOS)
+CHIPSET(0x6768, CAICOS_6768, CAICOS)
+CHIPSET(0x6770, CAICOS_6770, CAICOS)
+CHIPSET(0x6771, CAICOS_6771, CAICOS)
+CHIPSET(0x6772, CAICOS_6772, CAICOS)
+CHIPSET(0x6778, CAICOS_6778, CAICOS)
+CHIPSET(0x6779, CAICOS_6779, CAICOS)
+CHIPSET(0x677B, CAICOS_677B, CAICOS)
+
+CHIPSET(0x9900, ARUBA_9900, ARUBA)
+CHIPSET(0x9901, ARUBA_9901, ARUBA)
+CHIPSET(0x9903, ARUBA_9903, ARUBA)
+CHIPSET(0x9904, ARUBA_9904, ARUBA)
+CHIPSET(0x9905, ARUBA_9905, ARUBA)
+CHIPSET(0x9906, ARUBA_9906, ARUBA)
+CHIPSET(0x9907, ARUBA_9907, ARUBA)
+CHIPSET(0x9908, ARUBA_9908, ARUBA)
+CHIPSET(0x9909, ARUBA_9909, ARUBA)
+CHIPSET(0x990A, ARUBA_990A, ARUBA)
+CHIPSET(0x990B, ARUBA_990B, ARUBA)
+CHIPSET(0x990C, ARUBA_990C, ARUBA)
+CHIPSET(0x990D, ARUBA_990D, ARUBA)
+CHIPSET(0x990E, ARUBA_990E, ARUBA)
+CHIPSET(0x990F, ARUBA_990F, ARUBA)
+CHIPSET(0x9910, ARUBA_9910, ARUBA)
+CHIPSET(0x9913, ARUBA_9913, ARUBA)
+CHIPSET(0x9917, ARUBA_9917, ARUBA)
+CHIPSET(0x9918, ARUBA_9918, ARUBA)
+CHIPSET(0x9919, ARUBA_9919, ARUBA)
+CHIPSET(0x9990, ARUBA_9990, ARUBA)
+CHIPSET(0x9991, ARUBA_9991, ARUBA)
+CHIPSET(0x9992, ARUBA_9992, ARUBA)
+CHIPSET(0x9993, ARUBA_9993, ARUBA)
+CHIPSET(0x9994, ARUBA_9994, ARUBA)
+CHIPSET(0x9995, ARUBA_9995, ARUBA)
+CHIPSET(0x9996, ARUBA_9996, ARUBA)
+CHIPSET(0x9997, ARUBA_9997, ARUBA)
+CHIPSET(0x9998, ARUBA_9998, ARUBA)
+CHIPSET(0x9999, ARUBA_9999, ARUBA)
+CHIPSET(0x999A, ARUBA_999A, ARUBA)
+CHIPSET(0x999B, ARUBA_999B, ARUBA)
+CHIPSET(0x999C, ARUBA_999C, ARUBA)
+CHIPSET(0x999D, ARUBA_999D, ARUBA)
+CHIPSET(0x99A0, ARUBA_99A0, ARUBA)
+CHIPSET(0x99A2, ARUBA_99A2, ARUBA)
+CHIPSET(0x99A4, ARUBA_99A4, ARUBA)
diff --git a/hw/xfree86/dri2/pci_ids/radeon_pci_ids.h b/hw/xfree86/dri2/pci_ids/radeon_pci_ids.h
new file mode 100644
index 0000000..a9efc76
--- /dev/null
+++ b/hw/xfree86/dri2/pci_ids/radeon_pci_ids.h
@@ -0,0 +1,23 @@
+CHIPSET(0x4C57, RADEON_LW, RV200)
+CHIPSET(0x4C58, RADEON_LX, RV200)
+CHIPSET(0x4C59, RADEON_LY, RV100)
+CHIPSET(0x4C5A, RADEON_LZ, RV100)
+CHIPSET(0x5144, RADEON_QD, R100)
+CHIPSET(0x5145, RADEON_QE, R100)
+CHIPSET(0x5146, RADEON_QF, R100)
+CHIPSET(0x5147, RADEON_QG, R100)
+CHIPSET(0x5159, RADEON_QY, RV100)
+CHIPSET(0x515A, RADEON_QZ, RV100)
+
+CHIPSET(0x5157, RV200_QW, RV200)
+CHIPSET(0x5158, RV200_QX, RV200)
+
+CHIPSET(0x515E, RN50_515E, UNKNOWN)
+CHIPSET(0x5969, RN50_5969, UNKNOWN)
+
+CHIPSET(0x4136, RS100_4136, RS100)
+CHIPSET(0x4336, RS100_4336, RS100)
+CHIPSET(0x4137, RS200_4137, RS200)
+CHIPSET(0x4337, RS200_4337, RS200)
+CHIPSET(0x4237, RS250_4237, RS200)
+CHIPSET(0x4437, RS250_4437, RS200)
diff --git a/hw/xfree86/dri2/pci_ids/radeonsi_pci_ids.h b/hw/xfree86/dri2/pci_ids/radeonsi_pci_ids.h
new file mode 100644
index 0000000..571e863
--- /dev/null
+++ b/hw/xfree86/dri2/pci_ids/radeonsi_pci_ids.h
@@ -0,0 +1,157 @@
+CHIPSET(0x6780, TAHITI_6780, TAHITI)
+CHIPSET(0x6784, TAHITI_6784, TAHITI)
+CHIPSET(0x6788, TAHITI_6788, TAHITI)
+CHIPSET(0x678A, TAHITI_678A, TAHITI)
+CHIPSET(0x6790, TAHITI_6790, TAHITI)
+CHIPSET(0x6791, TAHITI_6791, TAHITI)
+CHIPSET(0x6792, TAHITI_6792, TAHITI)
+CHIPSET(0x6798, TAHITI_6798, TAHITI)
+CHIPSET(0x6799, TAHITI_6799, TAHITI)
+CHIPSET(0x679A, TAHITI_679A, TAHITI)
+CHIPSET(0x679B, TAHITI_679B, TAHITI)
+CHIPSET(0x679E, TAHITI_679E, TAHITI)
+CHIPSET(0x679F, TAHITI_679F, TAHITI)
+
+CHIPSET(0x6800, PITCAIRN_6800, PITCAIRN)
+CHIPSET(0x6801, PITCAIRN_6801, PITCAIRN)
+CHIPSET(0x6802, PITCAIRN_6802, PITCAIRN)
+CHIPSET(0x6806, PITCAIRN_6806, PITCAIRN)
+CHIPSET(0x6808, PITCAIRN_6808, PITCAIRN)
+CHIPSET(0x6809, PITCAIRN_6809, PITCAIRN)
+CHIPSET(0x6810, PITCAIRN_6810, PITCAIRN)
+CHIPSET(0x6811, PITCAIRN_6811, PITCAIRN)
+CHIPSET(0x6816, PITCAIRN_6816, PITCAIRN)
+CHIPSET(0x6817, PITCAIRN_6817, PITCAIRN)
+CHIPSET(0x6818, PITCAIRN_6818, PITCAIRN)
+CHIPSET(0x6819, PITCAIRN_6819, PITCAIRN)
+CHIPSET(0x684C, PITCAIRN_684C, PITCAIRN)
+
+CHIPSET(0x6820, VERDE_6820, VERDE)
+CHIPSET(0x6821, VERDE_6821, VERDE)
+CHIPSET(0x6822, VERDE_6822, VERDE)
+CHIPSET(0x6823, VERDE_6823, VERDE)
+CHIPSET(0x6824, VERDE_6824, VERDE)
+CHIPSET(0x6825, VERDE_6825, VERDE)
+CHIPSET(0x6826, VERDE_6826, VERDE)
+CHIPSET(0x6827, VERDE_6827, VERDE)
+CHIPSET(0x6828, VERDE_6828, VERDE)
+CHIPSET(0x6829, VERDE_6829, VERDE)
+CHIPSET(0x682A, VERDE_682A, VERDE)
+CHIPSET(0x682B, VERDE_682B, VERDE)
+CHIPSET(0x682C, VERDE_682C, VERDE)
+CHIPSET(0x682D, VERDE_682D, VERDE)
+CHIPSET(0x682F, VERDE_682F, VERDE)
+CHIPSET(0x6830, VERDE_6830, VERDE)
+CHIPSET(0x6831, VERDE_6831, VERDE)
+CHIPSET(0x6835, VERDE_6835, VERDE)
+CHIPSET(0x6837, VERDE_6837, VERDE)
+CHIPSET(0x6838, VERDE_6838, VERDE)
+CHIPSET(0x6839, VERDE_6839, VERDE)
+CHIPSET(0x683B, VERDE_683B, VERDE)
+CHIPSET(0x683D, VERDE_683D, VERDE)
+CHIPSET(0x683F, VERDE_683F, VERDE)
+
+CHIPSET(0x6600, OLAND_6600, OLAND)
+CHIPSET(0x6601, OLAND_6601, OLAND)
+CHIPSET(0x6602, OLAND_6602, OLAND)
+CHIPSET(0x6603, OLAND_6603, OLAND)
+CHIPSET(0x6604, OLAND_6604, OLAND)
+CHIPSET(0x6605, OLAND_6605, OLAND)
+CHIPSET(0x6606, OLAND_6606, OLAND)
+CHIPSET(0x6607, OLAND_6607, OLAND)
+CHIPSET(0x6608, OLAND_6608, OLAND)
+CHIPSET(0x6610, OLAND_6610, OLAND)
+CHIPSET(0x6611, OLAND_6611, OLAND)
+CHIPSET(0x6613, OLAND_6613, OLAND)
+CHIPSET(0x6620, OLAND_6620, OLAND)
+CHIPSET(0x6621, OLAND_6621, OLAND)
+CHIPSET(0x6623, OLAND_6623, OLAND)
+CHIPSET(0x6631, OLAND_6631, OLAND)
+
+CHIPSET(0x6660, HAINAN_6660, HAINAN)
+CHIPSET(0x6663, HAINAN_6663, HAINAN)
+CHIPSET(0x6664, HAINAN_6664, HAINAN)
+CHIPSET(0x6665, HAINAN_6665, HAINAN)
+CHIPSET(0x6667, HAINAN_6667, HAINAN)
+CHIPSET(0x666F, HAINAN_666F, HAINAN)
+
+CHIPSET(0x6640, BONAIRE_6640, BONAIRE)
+CHIPSET(0x6641, BONAIRE_6641, BONAIRE)
+CHIPSET(0x6646, BONAIRE_6646, BONAIRE)
+CHIPSET(0x6647, BONAIRE_6647, BONAIRE)
+CHIPSET(0x6649, BONAIRE_6649, BONAIRE)
+CHIPSET(0x6650, BONAIRE_6650, BONAIRE)
+CHIPSET(0x6651, BONAIRE_6651, BONAIRE)
+CHIPSET(0x6658, BONAIRE_6658, BONAIRE)
+CHIPSET(0x665C, BONAIRE_665C, BONAIRE)
+CHIPSET(0x665D, BONAIRE_665D, BONAIRE)
+
+CHIPSET(0x9830, KABINI_9830, KABINI)
+CHIPSET(0x9831, KABINI_9831, KABINI)
+CHIPSET(0x9832, KABINI_9832, KABINI)
+CHIPSET(0x9833, KABINI_9833, KABINI)
+CHIPSET(0x9834, KABINI_9834, KABINI)
+CHIPSET(0x9835, KABINI_9835, KABINI)
+CHIPSET(0x9836, KABINI_9836, KABINI)
+CHIPSET(0x9837, KABINI_9837, KABINI)
+CHIPSET(0x9838, KABINI_9838, KABINI)
+CHIPSET(0x9839, KABINI_9839, KABINI)
+CHIPSET(0x983A, KABINI_983A, KABINI)
+CHIPSET(0x983B, KABINI_983B, KABINI)
+CHIPSET(0x983C, KABINI_983C, KABINI)
+CHIPSET(0x983D, KABINI_983D, KABINI)
+CHIPSET(0x983E, KABINI_983E, KABINI)
+CHIPSET(0x983F, KABINI_983F, KABINI)
+
+CHIPSET(0x9850, MULLINS_9850, MULLINS)
+CHIPSET(0x9851, MULLINS_9851, MULLINS)
+CHIPSET(0x9852, MULLINS_9852, MULLINS)
+CHIPSET(0x9853, MULLINS_9853, MULLINS)
+CHIPSET(0x9854, MULLINS_9854, MULLINS)
+CHIPSET(0x9855, MULLINS_9855, MULLINS)
+CHIPSET(0x9856, MULLINS_9856, MULLINS)
+CHIPSET(0x9857, MULLINS_9857, MULLINS)
+CHIPSET(0x9858, MULLINS_9858, MULLINS)
+CHIPSET(0x9859, MULLINS_9859, MULLINS)
+CHIPSET(0x985A, MULLINS_985A, MULLINS)
+CHIPSET(0x985B, MULLINS_985B, MULLINS)
+CHIPSET(0x985C, MULLINS_985C, MULLINS)
+CHIPSET(0x985D, MULLINS_985D, MULLINS)
+CHIPSET(0x985E, MULLINS_985E, MULLINS)
+CHIPSET(0x985F, MULLINS_985F, MULLINS)
+
+CHIPSET(0x1304, KAVERI_1304, KAVERI)
+CHIPSET(0x1305, KAVERI_1305, KAVERI)
+CHIPSET(0x1306, KAVERI_1306, KAVERI)
+CHIPSET(0x1307, KAVERI_1307, KAVERI)
+CHIPSET(0x1309, KAVERI_1309, KAVERI)
+CHIPSET(0x130A, KAVERI_130A, KAVERI)
+CHIPSET(0x130B, KAVERI_130B, KAVERI)
+CHIPSET(0x130C, KAVERI_130C, KAVERI)
+CHIPSET(0x130D, KAVERI_130D, KAVERI)
+CHIPSET(0x130E, KAVERI_130E, KAVERI)
+CHIPSET(0x130F, KAVERI_130F, KAVERI)
+CHIPSET(0x1310, KAVERI_1310, KAVERI)
+CHIPSET(0x1311, KAVERI_1311, KAVERI)
+CHIPSET(0x1312, KAVERI_1312, KAVERI)
+CHIPSET(0x1313, KAVERI_1313, KAVERI)
+CHIPSET(0x1315, KAVERI_1315, KAVERI)
+CHIPSET(0x1316, KAVERI_1316, KAVERI)
+CHIPSET(0x1317, KAVERI_1317, KAVERI)
+CHIPSET(0x1318, KAVERI_1318, KAVERI)
+CHIPSET(0x131B, KAVERI_131B, KAVERI)
+CHIPSET(0x131C, KAVERI_131C, KAVERI)
+CHIPSET(0x131D, KAVERI_131D, KAVERI)
+
+CHIPSET(0x67A0, HAWAII_67A0, HAWAII)
+CHIPSET(0x67A1, HAWAII_67A1, HAWAII)
+CHIPSET(0x67A2, HAWAII_67A2, HAWAII)
+CHIPSET(0x67A8, HAWAII_67A8, HAWAII)
+CHIPSET(0x67A9, HAWAII_67A9, HAWAII)
+CHIPSET(0x67AA, HAWAII_67AA, HAWAII)
+CHIPSET(0x67B0, HAWAII_67B0, HAWAII)
+CHIPSET(0x67B1, HAWAII_67B1, HAWAII)
+CHIPSET(0x67B8, HAWAII_67B8, HAWAII)
+CHIPSET(0x67B9, HAWAII_67B9, HAWAII)
+CHIPSET(0x67BA, HAWAII_67BA, HAWAII)
+CHIPSET(0x67BE, HAWAII_67BE, HAWAII)
diff --git a/hw/xfree86/dri2/pci_ids/vmwgfx_pci_ids.h b/hw/xfree86/dri2/pci_ids/vmwgfx_pci_ids.h
new file mode 100644
index 0000000..124d75b
--- /dev/null
+++ b/hw/xfree86/dri2/pci_ids/vmwgfx_pci_ids.h
@@ -0,0 +1 @@
+CHIPSET(0x0405, SVGAII, SVGAII)
commit 839f05329ddb6f9b5b988edf3a2c3a1f856727f7
Author: Adam Jackson <ajax at redhat.com>
Date:   Fri Feb 28 16:35:10 2014 -0500

    dix: Retype and repack GC
    
    LP64: 160 bytes before, 128 after.
    
    Signed-off-by: Adam Jackson <ajax at redhat.com>
    Reviewed-by: Keith Packard <keithp at keithp.com>

diff --git a/include/gcstruct.h b/include/gcstruct.h
index 32e89a1..aa2064c 100644
--- a/include/gcstruct.h
+++ b/include/gcstruct.h
@@ -260,9 +260,9 @@ typedef struct _GC {
     unsigned int freeCompClip:1;        /* Free composite clip */
     unsigned int scratch_inuse:1;       /* is this GC in a pool for reuse? */
     unsigned int unused:15;     /* see comment above */
-    unsigned long planemask;
-    unsigned long fgPixel;
-    unsigned long bgPixel;
+    unsigned int planemask;
+    unsigned int fgPixel;
+    unsigned int bgPixel;
     /*
      * alas -- both tile and stipple must be here as they
      * are independently specifiable
@@ -270,11 +270,11 @@ typedef struct _GC {
     PixUnion tile;
     PixmapPtr stipple;
     DDXPointRec patOrg;         /* origin for (tile, stipple) */
-    struct _Font *font;
     DDXPointRec clipOrg;
+    struct _Font *font;
     RegionPtr clientClip;
-    unsigned long stateChanges; /* masked with GC_<kind> */
-    unsigned long serialNumber;
+    unsigned int stateChanges; /* masked with GC_<kind> */
+    unsigned int serialNumber;
     const GCFuncs *funcs;
     const GCOps *ops;
     PrivateRec *devPrivates;
commit 73e2383b7350723256894c5076d0c731aec5cd1f
Author: Adam Jackson <ajax at redhat.com>
Date:   Fri Jun 20 13:31:20 2014 -0400

    dix: Always store GC client clip as a region (v2)
    
    Again, this changes FixesCreateRegionFromGC to throw BadMatch when fed a
    GC with no client clip.
    
    v2: Fix Xnest and some variable names (Keith)
    
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/dix/gc.c b/dix/gc.c
index 88d6501..d10b7d6 100644
--- a/dix/gc.c
+++ b/dix/gc.c
@@ -495,7 +495,6 @@ NewGCObject(ScreenPtr pScreen, int depth)
     pGC->graphicsExposures = TRUE;
     pGC->clipOrg.x = 0;
     pGC->clipOrg.y = 0;
-    pGC->clientClipType = CT_NONE;
     pGC->clientClip = (void *) NULL;
     pGC->numInDashList = 2;
     pGC->dash = DefaultDash;
@@ -1067,7 +1066,7 @@ GetScratchGC(unsigned depth, ScreenPtr pScreen)
             pGC->graphicsExposures = FALSE;
             pGC->clipOrg.x = 0;
             pGC->clipOrg.y = 0;
-            if (pGC->clientClipType != CT_NONE)
+            if (pGC->clientClip)
                 (*pGC->funcs->ChangeClip) (pGC, CT_NONE, NULL, 0);
             pGC->stateChanges = GCAllBits;
             return pGC;
diff --git a/exa/exa_accel.c b/exa/exa_accel.c
index 9c742bd..5aa7d10 100644
--- a/exa/exa_accel.c
+++ b/exa/exa_accel.c
@@ -413,7 +413,7 @@ exaHWCopyNtoN(DrawablePtr pSrcDrawable,
 
         if (!pGC || !exaGCReadsDestination(pDstDrawable, pGC->planemask,
                                            pGC->fillStyle, pGC->alu,
-                                           pGC->clientClipType)) {
+                                           pGC->clientClip != NULL)) {
             dstregion = RegionCreate(NullBox, 0);
             RegionCopy(dstregion, srcregion);
             RegionTranslate(dstregion, dst_off_x - dx - src_off_x,
@@ -771,7 +771,7 @@ exaPolySegment(DrawablePtr pDrawable, GCPtr pGC, int nseg, xSegment * pSeg)
 
 static Bool exaFillRegionSolid(DrawablePtr pDrawable, RegionPtr pRegion,
                                Pixel pixel, CARD32 planemask, CARD32 alu,
-                               unsigned int clientClipType);
+                               Bool hasClientClip);
 
 static void
 exaPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, int nrect, xRectangle *prect)
@@ -816,11 +816,11 @@ exaPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, int nrect, xRectangle *prect)
         if (((pGC->fillStyle == FillSolid || pGC->tileIsPixel) &&
              exaFillRegionSolid(pDrawable, pReg, pGC->fillStyle == FillSolid ?
                                 pGC->fgPixel : pGC->tile.pixel, pGC->planemask,
-                                pGC->alu, pGC->clientClipType)) ||
+                                pGC->alu, pGC->clientClip != NULL)) ||
             (pGC->fillStyle == FillTiled && !pGC->tileIsPixel &&
              exaFillRegionTiled(pDrawable, pReg, pGC->tile.pixmap, &pGC->patOrg,
                                 pGC->planemask, pGC->alu,
-                                pGC->clientClipType))) {
+                                pGC->clientClip != NULL))) {
             goto out;
         }
     }
@@ -990,7 +990,7 @@ exaCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
 
 static Bool
 exaFillRegionSolid(DrawablePtr pDrawable, RegionPtr pRegion, Pixel pixel,
-                   CARD32 planemask, CARD32 alu, unsigned int clientClipType)
+                   CARD32 planemask, CARD32 alu, Bool hasClientClip)
 {
     ExaScreenPriv(pDrawable->pScreen);
     PixmapPtr pPixmap = exaGetDrawablePixmap(pDrawable);
@@ -1013,8 +1013,7 @@ exaFillRegionSolid(DrawablePtr pDrawable, RegionPtr pRegion, Pixel pixel,
         pixmaps[0].pPix = pPixmap;
         pixmaps[0].pReg = exaGCReadsDestination(pDrawable, planemask, FillSolid,
                                                 alu,
-                                                clientClipType) ? NULL :
-            pRegion;
+                                                hasClientClip) ? NULL : pRegion;
 
         exaDoMigration(pixmaps, 1, TRUE);
     }
@@ -1074,7 +1073,7 @@ exaFillRegionSolid(DrawablePtr pDrawable, RegionPtr pRegion, Pixel pixel,
 Bool
 exaFillRegionTiled(DrawablePtr pDrawable, RegionPtr pRegion, PixmapPtr pTile,
                    DDXPointPtr pPatOrg, CARD32 planemask, CARD32 alu,
-                   unsigned int clientClipType)
+                   Bool hasClientClip)
 {
     ExaScreenPriv(pDrawable->pScreen);
     PixmapPtr pPixmap;
@@ -1096,7 +1095,7 @@ exaFillRegionTiled(DrawablePtr pDrawable, RegionPtr pRegion, PixmapPtr pTile,
     if (tileWidth == 1 && tileHeight == 1)
         return exaFillRegionSolid(pDrawable, pRegion,
                                   exaGetPixmapFirstPixel(pTile), planemask,
-                                  alu, clientClipType);
+                                  alu, hasClientClip);
 
     pPixmap = exaGetDrawablePixmap(pDrawable);
     pExaPixmap = ExaGetPixmapPriv(pPixmap);
@@ -1113,8 +1112,7 @@ exaFillRegionTiled(DrawablePtr pDrawable, RegionPtr pRegion, PixmapPtr pTile,
         pixmaps[0].pPix = pPixmap;
         pixmaps[0].pReg = exaGCReadsDestination(pDrawable, planemask, FillTiled,
                                                 alu,
-                                                clientClipType) ? NULL :
-            pRegion;
+                                                hasClientClip) ? NULL : pRegion;
         pixmaps[1].as_dst = FALSE;
         pixmaps[1].as_src = TRUE;
         pixmaps[1].pPix = pTile;
diff --git a/exa/exa_priv.h b/exa/exa_priv.h
index 88bfd37..ca4db72 100644
--- a/exa/exa_priv.h
+++ b/exa/exa_priv.h
@@ -455,12 +455,11 @@ ExaCheckAddTraps(PicturePtr pPicture,
 static _X_INLINE Bool
 exaGCReadsDestination(DrawablePtr pDrawable, unsigned long planemask,
                       unsigned int fillStyle, unsigned char alu,
-                      unsigned int clientClipType)
+                      Bool clientClip)
 {
     return ((alu != GXcopy && alu != GXclear && alu != GXset &&
              alu != GXcopyInverted) || fillStyle == FillStippled ||
-            clientClipType != CT_NONE ||
-            !EXA_PM_IS_SOLID(pDrawable, planemask));
+            clientClip != FALSE || !EXA_PM_IS_SOLID(pDrawable, planemask));
 }
 
 void
@@ -470,7 +469,7 @@ Bool
 
 exaFillRegionTiled(DrawablePtr pDrawable, RegionPtr pRegion, PixmapPtr pTile,
                    DDXPointPtr pPatOrg, CARD32 planemask, CARD32 alu,
-                   unsigned int clientClipType);
+                   Bool clientClip);
 
 void
 
diff --git a/exa/exa_unaccel.c b/exa/exa_unaccel.c
index b0c6344..73eada9 100644
--- a/exa/exa_unaccel.c
+++ b/exa/exa_unaccel.c
@@ -107,7 +107,7 @@ ExaCheckPutImage(DrawablePtr pDrawable, GCPtr pGC, int depth,
     EXA_FALLBACK(("to %p (%c)\n", pDrawable, exaDrawableLocation(pDrawable)));
     if (!pExaScr->prepare_access_reg || !pExaPixmap->pDamage ||
         exaGCReadsDestination(pDrawable, pGC->planemask, pGC->fillStyle,
-                              pGC->alu, pGC->clientClipType))
+                              pGC->alu, pGC->clientClip != NULL))
         exaPrepareAccess(pDrawable, EXA_PREPARE_DEST);
     else
         pExaScr->prepare_access_reg(pPixmap, EXA_PREPARE_DEST,
@@ -143,7 +143,7 @@ ExaCheckCopyNtoN(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
 
     if (pExaScr->prepare_access_reg &&
         !exaGCReadsDestination(pDst, pGC->planemask, pGC->fillStyle,
-                               pGC->alu, pGC->clientClipType) &&
+                               pGC->alu, pGC->clientClip != NULL) &&
         RegionInitBoxes(&reg, pbox, nbox)) {
         PixmapPtr pPixmap = exaGetDrawablePixmap(pDst);
 
@@ -179,10 +179,9 @@ ExaFallbackPrepareReg(DrawablePtr pDrawable,
     ExaScreenPriv(pScreen);
 
     if (pExaScr->prepare_access_reg &&
-        !(checkReads && exaGCReadsDestination(pDrawable,
-                                              pGC->planemask,
-                                              pGC->fillStyle,
-                                              pGC->alu, pGC->clientClipType))) {
+        !(checkReads && exaGCReadsDestination(pDrawable, pGC->planemask,
+                                              pGC->fillStyle, pGC->alu,
+                                              pGC->clientClip != NULL))) {
         BoxRec box;
         RegionRec reg;
         int xoff, yoff;
diff --git a/hw/dmx/dmxgc.c b/hw/dmx/dmxgc.c
index 2d61ea2..2343167 100644
--- a/hw/dmx/dmxgc.c
+++ b/hw/dmx/dmxgc.c
@@ -391,13 +391,10 @@ dmxChangeClip(GCPtr pGC, int type, void *pvalue, int nrects)
     pGC->funcs->ChangeClip(pGC, type, pvalue, nrects);
 
     /* Set the client clip on the back-end server */
-    switch (pGC->clientClipType) {
-    case CT_NONE:
+    if (!pGC->clientClip) {
         if (dmxScreen->beDisplay)
             XSetClipMask(dmxScreen->beDisplay, pGCPriv->gc, None);
-        break;
-
-    case CT_REGION:
+    } else {
         if (dmxScreen->beDisplay) {
             nRects = RegionNumRects((RegionPtr) pGC->clientClip);
             pRects = malloc(nRects * sizeof(*pRects));
@@ -416,11 +413,6 @@ dmxChangeClip(GCPtr pGC, int type, void *pvalue, int nrects)
 
             free(pRects);
         }
-        break;
-
-    case CT_PIXMAP:
-        /* Condensed down to REGION in the mi code */
-        break;
     }
 
     DMX_GC_FUNC_EPILOGUE(pGC);
diff --git a/hw/kdrive/src/kxv.c b/hw/kdrive/src/kxv.c
index 163d5c1..369db33 100644
--- a/hw/kdrive/src/kxv.c
+++ b/hw/kdrive/src/kxv.c
@@ -492,7 +492,7 @@ static void
 KdXVCopyClip(XvPortRecPrivatePtr portPriv, GCPtr pGC)
 {
     /* copy the new clip if it exists */
-    if ((pGC->clientClipType == CT_REGION) && pGC->clientClip) {
+    if (pGC->clientClip) {
         if (!portPriv->clientClip)
             portPriv->clientClip = RegionCreate(NullBox, 1);
         /* Note: this is in window coordinates */
diff --git a/hw/xfree86/common/xf86xv.c b/hw/xfree86/common/xf86xv.c
index 5ef5de1..b974cd2 100644
--- a/hw/xfree86/common/xf86xv.c
+++ b/hw/xfree86/common/xf86xv.c
@@ -599,7 +599,7 @@ static void
 xf86XVCopyClip(XvPortRecPrivatePtr portPriv, GCPtr pGC)
 {
     /* copy the new clip if it exists */
-    if ((pGC->clientClipType == CT_REGION) && pGC->clientClip) {
+    if (pGC->clientClip) {
         if (!portPriv->clientClip)
             portPriv->clientClip = RegionCreate(NullBox, 1);
         /* Note: this is in window coordinates */
diff --git a/hw/xnest/GC.c b/hw/xnest/GC.c
index 0ec60fc..96af6eb 100644
--- a/hw/xnest/GC.c
+++ b/hw/xnest/GC.c
@@ -194,11 +194,12 @@ xnestChangeClip(GCPtr pGC, int type, void *pValue, int nRects)
     BoxPtr pBox;
     XRectangle *pRects;
 
-    xnestDestroyClipHelper(pGC);
+    xnestDestroyClip(pGC);
 
     switch (type) {
     case CT_NONE:
         XSetClipMask(xnestDisplay, xnestGC(pGC), None);
+        pValue = NULL;
         break;
 
     case CT_REGION:
@@ -224,11 +225,9 @@ xnestChangeClip(GCPtr pGC, int type, void *pValue, int nRects)
          * Need to change into region, so subsequent uses are with
          * current pixmap contents.
          */
-        pGC->clientClip =
-            (void *) (*pGC->pScreen->BitmapToRegion) ((PixmapPtr) pValue);
+        pGC->clientClip = (*pGC->pScreen->BitmapToRegion) ((PixmapPtr) pValue);
         (*pGC->pScreen->DestroyPixmap) ((PixmapPtr) pValue);
         pValue = pGC->clientClip;
-        type = CT_REGION;
         break;
 
     case CT_UNSORTED:
@@ -264,65 +263,34 @@ xnestChangeClip(GCPtr pGC, int type, void *pValue, int nRects)
     case CT_YSORTED:
     case CT_YXSORTED:
     case CT_YXBANDED:
-
-        /*
-         * other parts of server can only deal with CT_NONE,
-         * CT_PIXMAP and CT_REGION client clips.
-         */
-        pGC->clientClip = (void *) RegionFromRects(nRects,
-                                                    (xRectangle *) pValue,
-                                                    type);
+        /* server clip representation is a region */
+        pGC->clientClip = RegionFromRects(nRects, (xRectangle *) pValue, type);
         free(pValue);
         pValue = pGC->clientClip;
-        type = CT_REGION;
-
         break;
     }
 
-    pGC->clientClipType = type;
     pGC->clientClip = pValue;
 }
 
 void
 xnestDestroyClip(GCPtr pGC)
 {
-    xnestDestroyClipHelper(pGC);
-
-    XSetClipMask(xnestDisplay, xnestGC(pGC), None);
-
-    pGC->clientClipType = CT_NONE;
-    pGC->clientClip = NULL;
-}
-
-void
-xnestDestroyClipHelper(GCPtr pGC)
-{
-    switch (pGC->clientClipType) {
-    default:
-    case CT_NONE:
-        break;
-
-    case CT_REGION:
+    if (pGC->clientClip) {
         RegionDestroy(pGC->clientClip);
-        break;
+        XSetClipMask(xnestDisplay, xnestGC(pGC), None);
+        pGC->clientClip = NULL;
     }
 }
 
 void
 xnestCopyClip(GCPtr pGCDst, GCPtr pGCSrc)
 {
-    RegionPtr pRgn;
-
-    switch (pGCSrc->clientClipType) {
-    default:
-    case CT_NONE:
-        xnestDestroyClip(pGCDst);
-        break;
-
-    case CT_REGION:
-        pRgn = RegionCreate(NULL, 1);
+    if (pGCSrc->clientClip) {
+        RegionPtr pRgn = RegionCreate(NULL, 1);
         RegionCopy(pRgn, pGCSrc->clientClip);
         xnestChangeClip(pGCDst, CT_REGION, pRgn, 0);
-        break;
+    } else {
+        xnestDestroyClip(pGCDst);
     }
 }
diff --git a/hw/xnest/XNGC.h b/hw/xnest/XNGC.h
index e2f10fb..974173e 100644
--- a/hw/xnest/XNGC.h
+++ b/hw/xnest/XNGC.h
@@ -37,7 +37,6 @@ void xnestCopyGC(GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst);
 void xnestDestroyGC(GCPtr pGC);
 void xnestChangeClip(GCPtr pGC, int type, void *pValue, int nRects);
 void xnestDestroyClip(GCPtr pGC);
-void xnestDestroyClipHelper(GCPtr pGC);
 void xnestCopyClip(GCPtr pGCDst, GCPtr pGCSrc);
 
 #endif                          /* XNESTGC_H */
diff --git a/include/gcstruct.h b/include/gcstruct.h
index 6358b8c..32e89a1 100644
--- a/include/gcstruct.h
+++ b/include/gcstruct.h
@@ -254,13 +254,12 @@ typedef struct _GC {
     unsigned int arcMode:1;
     unsigned int subWindowMode:1;
     unsigned int graphicsExposures:1;
-    unsigned int clientClipType:2;      /* CT_<kind> */
     unsigned int miTranslate:1; /* should mi things translate? */
     unsigned int tileIsPixel:1; /* tile is solid pixel */
     unsigned int fExpose:1;     /* Call exposure handling */
     unsigned int freeCompClip:1;        /* Free composite clip */
     unsigned int scratch_inuse:1;       /* is this GC in a pool for reuse? */
-    unsigned int unused:13;     /* see comment above */
+    unsigned int unused:15;     /* see comment above */
     unsigned long planemask;
     unsigned long fgPixel;
     unsigned long bgPixel;
@@ -273,7 +272,7 @@ typedef struct _GC {
     DDXPointRec patOrg;         /* origin for (tile, stipple) */
     struct _Font *font;
     DDXPointRec clipOrg;
-    void *clientClip;
+    RegionPtr clientClip;
     unsigned long stateChanges; /* masked with GC_<kind> */
     unsigned long serialNumber;
     const GCFuncs *funcs;
diff --git a/mi/micopy.c b/mi/micopy.c
index a52b0a7..2409c78 100644
--- a/mi/micopy.c
+++ b/mi/micopy.c
@@ -167,7 +167,7 @@ miDoCopy(DrawablePtr pSrcDrawable,
 
     /* Compute source clip region */
     if (pSrcDrawable->type == DRAWABLE_PIXMAP) {
-        if ((pSrcDrawable == pDstDrawable) && (pGC->clientClipType == CT_NONE))
+        if ((pSrcDrawable == pDstDrawable) && (!pGC->clientClip))
             prgnSrcClip = miGetCompositeClip(pGC);
         else
             fastSrc = TRUE;
@@ -186,8 +186,7 @@ miDoCopy(DrawablePtr pSrcDrawable,
                  */
                 fastSrc = TRUE;
             }
-            else if ((pSrcDrawable == pDstDrawable) &&
-                     (pGC->clientClipType == CT_NONE)) {
+            else if ((pSrcDrawable == pDstDrawable) && (!pGC->clientClip)) {
                 prgnSrcClip = miGetCompositeClip(pGC);
             }
             else {
diff --git a/mi/miexpose.c b/mi/miexpose.c
index de8ee6c..e74b9c3 100644
--- a/mi/miexpose.c
+++ b/mi/miexpose.c
@@ -230,7 +230,7 @@ miHandleExposures(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable,
     RegionIntersect(&rgnExposed, &rgnExposed, prgnDstClip);
 
     /* intersect with client clip region. */
-    if (pGC->clientClipType == CT_REGION)
+    if (pGC->clientClip)
         RegionIntersect(&rgnExposed, &rgnExposed, pGC->clientClip);
 
     /*
diff --git a/mi/migc.c b/mi/migc.c
index 9bbe884..8fdd481 100644
--- a/mi/migc.c
+++ b/mi/migc.c
@@ -55,20 +55,9 @@ miDestroyGC(GCPtr pGC)
 void
 miDestroyClip(GCPtr pGC)
 {
-    if (pGC->clientClipType == CT_NONE)
-        return;
-    else if (pGC->clientClipType == CT_PIXMAP) {
-        (*pGC->pScreen->DestroyPixmap) ((PixmapPtr) (pGC->clientClip));
-    }
-    else {
-        /*
-         * we know we'll never have a list of rectangles, since ChangeClip
-         * immediately turns them into a region
-         */
+    if (pGC->clientClip)
         RegionDestroy(pGC->clientClip);
-    }
     pGC->clientClip = NULL;
-    pGC->clientClipType = CT_NONE;
 }
 
 void
@@ -77,8 +66,7 @@ miChangeClip(GCPtr pGC, int type, void *pvalue, int nrects)
     (*pGC->funcs->DestroyClip) (pGC);
     if (type == CT_PIXMAP) {
         /* convert the pixmap to a region */
-        pGC->clientClip = (void *) BitmapToRegion(pGC->pScreen,
-                                                   (PixmapPtr) pvalue);
+        pGC->clientClip = BitmapToRegion(pGC->pScreen, (PixmapPtr) pvalue);
         (*pGC->pScreen->DestroyPixmap) (pvalue);
     }
     else if (type == CT_REGION) {
@@ -86,34 +74,21 @@ miChangeClip(GCPtr pGC, int type, void *pvalue, int nrects)
         pGC->clientClip = pvalue;
     }
     else if (type != CT_NONE) {
-        pGC->clientClip = (void *) RegionFromRects(nrects,
-                                                    (xRectangle *) pvalue,
-                                                    type);
+        pGC->clientClip = RegionFromRects(nrects, (xRectangle *) pvalue, type);
         free(pvalue);
     }
-    pGC->clientClipType = (type != CT_NONE &&
-                           pGC->clientClip) ? CT_REGION : CT_NONE;
     pGC->stateChanges |= GCClipMask;
 }
 
 void
 miCopyClip(GCPtr pgcDst, GCPtr pgcSrc)
 {
-    RegionPtr prgnNew;
-
-    switch (pgcSrc->clientClipType) {
-    case CT_PIXMAP:
-        ((PixmapPtr) pgcSrc->clientClip)->refcnt++;
-        /* Fall through !! */
-    case CT_NONE:
-        (*pgcDst->funcs->ChangeClip) (pgcDst, (int) pgcSrc->clientClipType,
-                                      pgcSrc->clientClip, 0);
-        break;
-    case CT_REGION:
-        prgnNew = RegionCreate(NULL, 1);
+    if (pgcSrc->clientClip) {
+        RegionPtr prgnNew = RegionCreate(NULL, 1);
         RegionCopy(prgnNew, (RegionPtr) (pgcSrc->clientClip));
-        (*pgcDst->funcs->ChangeClip) (pgcDst, CT_REGION, (void *) prgnNew, 0);
-        break;
+        (*pgcDst->funcs->ChangeClip) (pgcDst, CT_REGION, prgnNew, 0);
+    } else {
+        (*pgcDst->funcs->ChangeClip) (pgcDst, CT_NONE, NULL, 0);
     }
 }
 
@@ -149,7 +124,7 @@ miComputeCompositeClip(GCPtr pGC, DrawablePtr pDrawable)
          * regions.  (this wins especially if many clients clip by children
          * and have no client clip.)
          */
-        if (pGC->clientClipType == CT_NONE) {
+        if (!pGC->clientClip) {
             if (freeCompClip)
                 RegionDestroy(pGC->pCompositeClip);
             pGC->pCompositeClip = pregWin;
@@ -206,7 +181,7 @@ miComputeCompositeClip(GCPtr pGC, DrawablePtr pDrawable)
             pGC->pCompositeClip = RegionCreate(&pixbounds, 1);
         }
 
-        if (pGC->clientClipType == CT_REGION) {
+        if (pGC->clientClip) {
             if (pDrawable->x || pDrawable->y) {
                 RegionTranslate(pGC->clientClip,
                                 pDrawable->x + pGC->clipOrg.x,
diff --git a/mi/mioverlay.c b/mi/mioverlay.c
index eb8dda1..2b20fd7 100644
--- a/mi/mioverlay.c
+++ b/mi/mioverlay.c
@@ -1667,7 +1667,7 @@ miOverlayComputeCompositeClip(GCPtr pGC, WindowPtr pWin)
         freeTmpClip = FALSE;
     }
     freeCompClip = pGC->freeCompClip;
-    if (pGC->clientClipType == CT_NONE) {
+    if (!pGC->clientClip) {
         if (freeCompClip)
             RegionDestroy(pGC->pCompositeClip);
         pGC->pCompositeClip = pregWin;
diff --git a/xfixes/region.c b/xfixes/region.c
index 4cfeee1..4492f12 100644
--- a/xfixes/region.c
+++ b/xfixes/region.c
@@ -222,20 +222,13 @@ ProcXFixesCreateRegionFromGC(ClientPtr client)
     if (rc != Success)
         return rc;
 
-    switch (pGC->clientClipType) {
-    case CT_PIXMAP:
-        pRegion = BitmapToRegion(pGC->pScreen, (PixmapPtr) pGC->clientClip);
-        if (!pRegion)
-            return BadAlloc;
-        break;
-    case CT_REGION:
+    if (pGC->clientClip) {
         pClip = (RegionPtr) pGC->clientClip;
         pRegion = XFixesRegionCopy(pClip);
         if (!pRegion)
             return BadAlloc;
-        break;
-    default:
-        return BadImplementation;       /* assume sane server bits */
+    } else {
+        return BadMatch;
     }
 
     if (!AddResource(stuff->region, RegionResType, (void *) pRegion))
commit e7b9295551d55b42b416ba70cce11dae79ece5e7
Author: Adam Jackson <ajax at redhat.com>
Date:   Fri Sep 26 13:41:59 2014 -0400

    fb: Hide fbPush{Pattern,Fill}
    
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/fb/fb.h b/fb/fb.h
index f6bceea..ab110f3 100644
--- a/fb/fb.h
+++ b/fb/fb.h
@@ -1151,20 +1151,6 @@ fbPolyPoint(DrawablePtr pDrawable,
 /*
  * fbpush.c
  */
-extern _X_EXPORT void
-
-fbPushPattern(DrawablePtr pDrawable,
-              GCPtr pGC,
-              FbStip * src,
-              FbStride srcStride,
-              int srcX, int x, int y, int width, int height);
-
-extern _X_EXPORT void
-
-fbPushFill(DrawablePtr pDrawable,
-           GCPtr pGC,
-           FbStip * src,
-           FbStride srcStride, int srcX, int x, int y, int width, int height);
 
 extern _X_EXPORT void
 
diff --git a/fb/fbpush.c b/fb/fbpush.c
index f0a861c..1d1bcfd 100644
--- a/fb/fbpush.c
+++ b/fb/fbpush.c
@@ -26,7 +26,7 @@
 
 #include "fb.h"
 
-void
+static void
 fbPushPattern(DrawablePtr pDrawable,
               GCPtr pGC,
               FbStip * src,
@@ -84,7 +84,7 @@ fbPushPattern(DrawablePtr pDrawable,
     }
 }
 
-void
+static void
 fbPushFill(DrawablePtr pDrawable,
            GCPtr pGC,
            FbStip * src,
commit e31d16a82d83738740f67743b759c006d9845e79
Author: Adam Jackson <ajax at redhat.com>
Date:   Fri Sep 26 13:32:37 2014 -0400

    fb: Hide fbDots
    
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/fb/fb.h b/fb/fb.h
index a3d5185..f6bceea 100644
--- a/fb/fb.h
+++ b/fb/fb.h
@@ -1145,16 +1145,6 @@ extern _X_EXPORT RegionPtr
 
 extern _X_EXPORT void
 
-fbDots(FbBits * dstOrig,
-       FbStride dstStride,
-       int dstBpp,
-       BoxPtr pBox,
-       xPoint * pts,
-       int npt,
-       int xorg, int yorg, int xoff, int yoff, FbBits andOrig, FbBits xorOrig);
-
-extern _X_EXPORT void
-
 fbPolyPoint(DrawablePtr pDrawable,
             GCPtr pGC, int mode, int npt, xPoint * pptInit);
 
diff --git a/fb/fbpoint.c b/fb/fbpoint.c
index d5129d7..be7c801 100644
--- a/fb/fbpoint.c
+++ b/fb/fbpoint.c
@@ -35,7 +35,7 @@ typedef void (*FbDots) (FbBits * dst,
                         int xorg,
                         int yorg, int xoff, int yoff, FbBits and, FbBits xor);
 
-void
+static void
 fbDots(FbBits * dstOrig,
        FbStride dstStride,
        int dstBpp,
commit 5db0f067ed4ff24c48cdb7998e4a52ad80037cb7
Author: Adam Jackson <ajax at redhat.com>
Date:   Fri Sep 26 13:30:06 2014 -0400

    fb: Hide Bresenham line details
    
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/fb/fb.h b/fb/fb.h
index 23e4c8d..a3d5185 100644
--- a/fb/fb.h
+++ b/fb/fb.h
@@ -1268,34 +1268,20 @@ typedef void FbBres(DrawablePtr pDrawable,
                     int signdy,
                     int axis, int x, int y, int e, int e1, int e3, int len);
 
-extern _X_EXPORT FbBres fbBresSolid, fbBresDash, fbBresFill, fbBresFillDash;
+extern _X_EXPORT void
+fbSegment(DrawablePtr pDrawable,
+          GCPtr pGC,
+          int xa, int ya, int xb, int yb, Bool drawLast, int *dashOffset);
 
 /*
  * fbsetsp.c
  */
 
 extern _X_EXPORT void
-
 fbSetSpans(DrawablePtr pDrawable,
            GCPtr pGC,
            char *src, DDXPointPtr ppt, int *pwidth, int nspans, int fSorted);
 
-extern _X_EXPORT FbBres *fbSelectBres(DrawablePtr pDrawable, GCPtr pGC);
-
-extern _X_EXPORT void
-
-fbBres(DrawablePtr pDrawable,
-       GCPtr pGC,
-       int dashOffset,
-       int signdx,
-       int signdy, int axis, int x, int y, int e, int e1, int e3, int len);
-
-extern _X_EXPORT void
-
-fbSegment(DrawablePtr pDrawable,
-          GCPtr pGC,
-          int xa, int ya, int xb, int yb, Bool drawLast, int *dashOffset);
-
 /*
  * fbsolid.c
  */
diff --git a/fb/fbseg.c b/fb/fbseg.c
index 1848387..36b17e3 100644
--- a/fb/fbseg.c
+++ b/fb/fbseg.c
@@ -33,7 +33,7 @@
 					((dir < 0) ? FbStipLeft(mask,bpp) : \
 					 FbStipRight(mask,bpp)))
 
-void
+static void
 fbBresSolid(DrawablePtr pDrawable,
             GCPtr pGC,
             int dashOffset,
@@ -103,7 +103,7 @@ fbBresSolid(DrawablePtr pDrawable,
     fbFinishAccess(pDrawable);
 }
 
-void
+static void
 fbBresDash(DrawablePtr pDrawable,
            GCPtr pGC,
            int dashOffset,
@@ -176,7 +176,7 @@ fbBresDash(DrawablePtr pDrawable,
     fbFinishAccess(pDrawable);
 }
 
-void
+static void
 fbBresFill(DrawablePtr pDrawable,
            GCPtr pGC,
            int dashOffset,
@@ -216,7 +216,7 @@ fbSetFg(DrawablePtr pDrawable, GCPtr pGC, Pixel fg)
     }
 }
 
-void
+static void
 fbBresFillDash(DrawablePtr pDrawable,
                GCPtr pGC,
                int dashOffset,
@@ -434,7 +434,7 @@ fbBresDash24RRop(DrawablePtr pDrawable,
  * based on the contents of the specified GC.
  */
 
-FbBres *
+static FbBres *
 fbSelectBres(DrawablePtr pDrawable, GCPtr pGC)
 {
     FbGCPrivPtr pPriv = fbGetGCPrivate(pGC);
@@ -494,18 +494,6 @@ fbSelectBres(DrawablePtr pDrawable, GCPtr pGC)
 }
 
 void
-fbBres(DrawablePtr pDrawable,
-       GCPtr pGC,
-       int dashOffset,
-       int signdx,
-       int signdy, int axis, int x1, int y1, int e, int e1, int e3, int len)
-{
-    (*fbSelectBres(pDrawable, pGC)) (pDrawable, pGC, dashOffset,
-                                     signdx, signdy, axis, x1, y1,
-                                     e, e1, e3, len);
-}
-
-void
 fbSegment(DrawablePtr pDrawable,
           GCPtr pGC,
           int x1, int y1, int x2, int y2, Bool drawLast, int *dashOffset)
commit b184a863c111834e28564d963c0733a30833f128
Author: Adam Jackson <ajax at redhat.com>
Date:   Tue Jul 8 12:23:48 2014 -0400

    fb: Hide some zero-width line details
    
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/fb/fb.h b/fb/fb.h
index e567332..23e4c8d 100644
--- a/fb/fb.h
+++ b/fb/fb.h
@@ -1098,15 +1098,6 @@ fbGetImage(DrawablePtr pDrawable,
  */
 
 extern _X_EXPORT void
-
-fbZeroLine(DrawablePtr pDrawable,
-           GCPtr pGC, int mode, int npt, DDXPointPtr ppt);
-
-extern _X_EXPORT void
- fbZeroSegment(DrawablePtr pDrawable, GCPtr pGC, int nseg, xSegment * pSegs);
-
-extern _X_EXPORT void
-
 fbPolyLine(DrawablePtr pDrawable,
            GCPtr pGC, int mode, int npt, DDXPointPtr ppt);
 
diff --git a/fb/fbline.c b/fb/fbline.c
index 80dc89d..3e582e6 100644
--- a/fb/fbline.c
+++ b/fb/fbline.c
@@ -26,7 +26,7 @@
 
 #include "fb.h"
 
-void
+static void
 fbZeroLine(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt, DDXPointPtr ppt)
 {
     int x1, y1, x2, y2;
@@ -54,7 +54,7 @@ fbZeroLine(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt, DDXPointPtr ppt)
     }
 }
 
-void
+static void
 fbZeroSegment(DrawablePtr pDrawable, GCPtr pGC, int nseg, xSegment * pSegs)
 {
     int dashOffset;
diff --git a/fb/wfbrename.h b/fb/wfbrename.h
index adac64a..baa80f8 100644
--- a/fb/wfbrename.h
+++ b/fb/wfbrename.h
@@ -143,7 +143,5 @@
 #define fbUnrealizeFont wfbUnrealizeFont
 #define fbValidateGC wfbValidateGC
 #define fbWinPrivateKeyRec wfbWinPrivateKeyRec
-#define fbZeroLine wfbZeroLine
-#define fbZeroSegment wfbZeroSegment
 #define free_pixman_pict wfb_free_pixman_pict
 #define image_from_pict wfb_image_from_pict
commit 7ea4a21feed5ac5e71cc6d8141c97d6362402c5d
Author: Jon TURNEY <jon.turney at dronecode.org.uk>
Date:   Fri Sep 19 13:37:50 2014 +0100

    configure.ac: Force --disable-libdrm on Cygwin
    
    This is now needed to avoid trying to build the modesetting driver by default
    when building the Xorg DDX on Cygwin.
    
    http://tinderbox.x.org/builds/2014-09-18-0011/logs/xserver/#build
    
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Reviewed-by: Adam Jackson <ajax at redhat.com>

diff --git a/configure.ac b/configure.ac
index 8105763..fcf5c03 100644
--- a/configure.ac
+++ b/configure.ac
@@ -698,6 +698,7 @@ case $host_os in
 		CONFIG_UDEV=no
 		CONFIG_UDEV_KMS=no
 		DGA=no
+		DRM=no
 		DRI2=no
 		DRI3=no
 		INT10MODULE=no
commit 883927d2e8733f4070b2a8bcc5ec8cc2d7a661b3
Author: Jon TURNEY <jon.turney at dronecode.org.uk>
Date:   Tue Sep 30 13:55:59 2014 +0100

    configure.ac: Avoid "Your OS is unknown" warning when configuring for Cygwin
    
    Don't emit "Your OS is unknown" warning when configuring with --enable-xorg to
    build the XOrg DDX for Cygwin.
    
    The list of supported OSes is getting a bit unwieldy, so just remove it.
    
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Reviewed-by: Adam Jackson <ajax at redhat.com>

diff --git a/configure.ac b/configure.ac
index c697188..8105763 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1993,11 +1993,13 @@ if test "x$XORG" = xyes; then
 	  gnu*)
 		XORG_OS_SUBDIR="hurd"
 		;;
+	  cygwin*)
+		XORG_OS_SUBDIR="stub"
+		;;
 	  *)
 		XORG_OS_SUBDIR="stub"
 		AC_MSG_NOTICE([m4_text_wrap(m4_join([ ],
-		[Your OS is unknown. Xorg currently only supports Linux,],
-		[Free/Open/Net/DragonFlyBSD, Solaris/OpenSolaris, & GNU Hurd.],
+		[Your OS is unknown.],
 		[If you are interested in porting Xorg to your platform,],
 		[please email xorg at lists.freedesktop.org.]))])
 		;;
commit 549b3175afc46cee6e1b61841f854a5272eaf1f7
Author: Jon TURNEY <jon.turney at dronecode.org.uk>
Date:   Thu Oct 2 15:37:50 2014 +0100

    hw/xwin: Fix unused variable warning in winCreateMsgWindow()
    
    winmsgwindow.c:99:11: warning: variable ‘winClass’ set but not used [-Wunused-but-set-variable]
    
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Reviewed-by: Colin Harrison <colin.harrison at virgin.net>

diff --git a/hw/xwin/winmsgwindow.c b/hw/xwin/winmsgwindow.c
index 0f26cea..f5649b7 100644
--- a/hw/xwin/winmsgwindow.c
+++ b/hw/xwin/winmsgwindow.c
@@ -96,7 +96,6 @@ static HWND
 winCreateMsgWindow(void)
 {
     HWND hwndMsg;
-    wATOM winClass;
 
     // register window class
     {
@@ -114,7 +113,7 @@ winCreateMsgWindow(void)
         wcx.lpszMenuName = NULL;
         wcx.lpszClassName = WINDOW_CLASS_X_MSG;
         wcx.hIconSm = NULL;
-        winClass = RegisterClassEx(&wcx);
+        RegisterClassEx(&wcx);
     }
 
     // Create the msg window.
commit 5adfb566fe05bcf5f40b4adc1457862936d6d038
Author: Jon TURNEY <jon.turney at dronecode.org.uk>
Date:   Fri Oct 3 14:22:30 2014 +0100

    hw/xwin: Fix redundant declaration warning in winprefslex.l
    
    winprefslex.l:40:12: warning: redundant redeclaration of ‘yyparse’ [-Wredundant-decls]
    winprefsyacc.h:130:5: note: previous declaration of ‘yyparse’ was here
    
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Reviewed-by: Colin Harrison <colin.harrison at virgin.net>

diff --git a/hw/xwin/winprefslex.l b/hw/xwin/winprefslex.l
index fd13edc..9e6f0d6 100644
--- a/hw/xwin/winprefslex.l
+++ b/hw/xwin/winprefslex.l
@@ -37,8 +37,6 @@
 #include <string.h>
 #include "winprefsyacc.h"
 
-extern int yyparse(void);
-
 extern void ErrorF (const char* /*f*/, ...);
 
 /* Copy the parsed string, must be free()d in yacc parser */
commit 8f062f73805765f5769dfd7b738c8dd10062fba6
Author: Jon TURNEY <jon.turney at dronecode.org.uk>
Date:   Fri Oct 3 14:12:57 2014 +0100

    hw/xwin: Fix warning in yyerror()
    
    winprefsyacc.y:257:3: warning: nested extern declaration of ‘yylineno’ [-Wnested-externs]
    
    Promote yylineno declaration to file scope
    
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Reviewed-by: Colin Harrison <colin.harrison at virgin.net>

diff --git a/hw/xwin/winprefsyacc.y b/hw/xwin/winprefsyacc.y
index 92f222d..9bb28ae 100644
--- a/hw/xwin/winprefsyacc.y
+++ b/hw/xwin/winprefsyacc.y
@@ -82,6 +82,7 @@ static void CloseSysMenu(void);
 static int yyerror (const char *s);
 
 extern char *yytext;
+extern int yylineno;
 extern int yylex(void);
 
 %}
@@ -254,8 +255,6 @@ debug: 	DEBUGOUTPUT STRING NEWLINE { ErrorF("LoadPreferences: %s\n", $2); free($
 static int
 yyerror (const char *s)
 {
-  extern int yylineno; /* Handled by flex internally */
-
   ErrorF("LoadPreferences: %s line %d\n", s, yylineno);
   return 1;
 }
commit f0f0c92a08f0ccf5a7ac447d117eb0341fe136d6
Author: Jon TURNEY <jon.turney at dronecode.org.uk>
Date:   Fri Oct 3 14:00:06 2014 +0100

    hw/xwin: Fix const warning in winPrefsLoadPreferences()
    
    winprefs.c:643:14: warning: assignment discards ‘const’ qualifier from pointer target type [enabled by default]
    
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Reviewed-by: Colin Harrison <colin.harrison at virgin.net>

diff --git a/hw/xwin/winprefs.c b/hw/xwin/winprefs.c
index 53abc16..5052927 100644
--- a/hw/xwin/winprefs.c
+++ b/hw/xwin/winprefs.c
@@ -625,7 +625,7 @@ winIconIsOverride(HICON hicon)
  * If @path is NULL, use the built-in default.
  */
 static int
-winPrefsLoadPreferences(char *path)
+winPrefsLoadPreferences(const char *path)
 {
     FILE *prefFile = NULL;
 
commit 593c6b19349538ec3b89bc48eb3f0bb4c0cebb23
Author: Jon TURNEY <jon.turney at dronecode.org.uk>
Date:   Thu Oct 2 15:35:54 2014 +0100

    hw/xwin: Fix const warnings in winprefsyacc.y
    
    winprefsyacc.y:174:5: warning: passing argument 1 of ‘AddMenuLine’ discards ‘const’ qualifier from pointer target type [enabled by default]
    winprefsyacc.y:67:13: note: expected ‘char *’ but argument is of type ‘const char *’
    winprefsyacc.y:174:5: warning: passing argument 3 of ‘AddMenuLine’ discards ‘const’ qualifier from pointer target type [enabled by default]
    winprefsyacc.y:67:13: note: expected ‘char *’ but argument is of type ‘const char *’
    winprefsyacc.y:175:5: warning: passing argument 3 of ‘AddMenuLine’ discards ‘const’ qualifier from pointer target type [enabled by default]
    winprefsyacc.y:67:13: note: expected ‘char *’ but argument is of type ‘const char *’
    winprefsyacc.y:178:5: warning: passing argument 3 of ‘AddMenuLine’ discards ‘const’ qualifier from pointer target type [enabled by default]
    winprefsyacc.y:67:13: note: expected ‘char *’ but argument is of type ‘const char *’
    winprefsyacc.c:1737:9: warning: passing argument 1 of ‘yyerror’ discards ‘const’ qualifier from pointer target type [enabled by default]
    winprefsyacc.y:82:12: note: expected ‘char *’ but argument is of type ‘const char *’
    winprefsyacc.c:1854:3: warning: passing argument 1 of ‘yyerror’ discards ‘const’ qualifier from pointer target type [enabled by default]
    
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Reviewed-by: Colin Harrison <colin.harrison at virgin.net>

diff --git a/hw/xwin/winprefsyacc.y b/hw/xwin/winprefsyacc.y
index 683fc44..92f222d 100644
--- a/hw/xwin/winprefsyacc.y
+++ b/hw/xwin/winprefsyacc.y
@@ -64,7 +64,7 @@ static void SetDefaultSysMenu (char *menu, int pos);
 static void SetTrayIcon (char *fname);
 
 static void OpenMenu(char *menuname);
-static void AddMenuLine(char *name, MENUCOMMANDTYPE cmd, char *param);
+static void AddMenuLine(const char *name, MENUCOMMANDTYPE cmd, const char *param);
 static void CloseMenu(void);
 
 static void OpenIcons(void);
@@ -79,7 +79,7 @@ static void OpenSysMenu(void);
 static void AddSysMenuLine(char *matchstr, char *menuname, int pos);
 static void CloseSysMenu(void);
 
-static int yyerror (char *s);
+static int yyerror (const char *s);
 
 extern char *yytext;
 extern int yylex(void);
@@ -252,7 +252,7 @@ debug: 	DEBUGOUTPUT STRING NEWLINE { ErrorF("LoadPreferences: %s\n", $2); free($
  * Errors in parsing abort and print log messages
  */
 static int
-yyerror (char *s) 
+yyerror (const char *s)
 {
   extern int yylineno; /* Handled by flex internally */
 
@@ -308,7 +308,7 @@ OpenMenu (char *menuname)
 }
 
 static void
-AddMenuLine (char *text, MENUCOMMANDTYPE cmd, char *param)
+AddMenuLine (const char *text, MENUCOMMANDTYPE cmd, const char *param)
 {
   if (menu.menuItem==NULL)
     menu.menuItem = malloc(sizeof(MENUITEM));
commit 394ad259596801860d32d531408a07b63e469427
Author: Jon TURNEY <jon.turney at dronecode.org.uk>
Date:   Thu Oct 2 14:31:35 2014 +0100

    hw/xwin: Fix const warning in winCheckDisplayNumber()
    
    InitOutput.c:1032:19: warning: assignment discards ‘const’ qualifier from pointer target type [enabled by default]
    
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Reviewed-by: Colin Harrison <colin.harrison at virgin.net>

diff --git a/hw/xwin/InitOutput.c b/hw/xwin/InitOutput.c
index 88bc85a..ae02c17 100644
--- a/hw/xwin/InitOutput.c
+++ b/hw/xwin/InitOutput.c
@@ -1010,7 +1010,7 @@ winCheckDisplayNumber(void)
     int nDisp;
     HANDLE mutex;
     char name[MAX_PATH];
-    char *pszPrefix = '\0';
+    const char *pszPrefix = '\0';
     OSVERSIONINFO osvi = { 0 };
 
     /* Check display range */
commit 701492e5d9487545afeb5ebfcebccc0408ca7bc4
Author: Jon TURNEY <jon.turney at dronecode.org.uk>
Date:   Thu Oct 2 14:30:56 2014 +0100

    hw/xwin: Fix warning in winXIconToHICON()
    
    winmultiwindowicons.c:403:29: warning: passing argument 8 of ‘XGetWindowProperty’ from incompatible pointer type [enabled by default]
    /usr/include/X11/Xlib.h:2688:12: note: expected ‘Atom *’ but argument is of type ‘long unsigned int *’
    
    Looks like this has been wrong since I added it in 527cf131 :-(
    
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Reviewed-by: Colin Harrison <colin.harrison at virgin.net>

diff --git a/hw/xwin/winmultiwindowicons.c b/hw/xwin/winmultiwindowicons.c
index 81ab494..c22e688 100644
--- a/hw/xwin/winmultiwindowicons.c
+++ b/hw/xwin/winmultiwindowicons.c
@@ -382,7 +382,7 @@ winXIconToHICON(Display * pDisplay, Window id, int iconSize)
     static int generation;
     uint32_t *icon, *icon_data = NULL;
     unsigned long int size;
-    unsigned long int type;
+    Atom type;
     int format;
     unsigned long int left;
 
commit a14f1d94d5bb87055f7e4812e9ef75771ea65bc5
Author: Jon TURNEY <jon.turney at dronecode.org.uk>
Date:   Thu Oct 2 14:09:40 2014 +0100

    hw/xwin: Fix format warnings with debug printing of pointers on 64-bit
    
    Fix various pieces of debug output, mainly under --enable-debug, which use a
    "%08x" printf format for a pointer type. Use "%p" format for 64-bit portability.
    
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Reviewed-by: Colin Harrison <colin.harrison at virgin.net>

diff --git a/hw/xwin/winSetAppUserModelID.c b/hw/xwin/winSetAppUserModelID.c
index 41615e1..f9cb92c 100644
--- a/hw/xwin/winSetAppUserModelID.c
+++ b/hw/xwin/winSetAppUserModelID.c
@@ -90,7 +90,7 @@ winSetAppUserModelID(HWND hWnd, const char *AppID)
         return;
     }
 
-    winDebug("winSetAppUserMOdelID - hwnd 0x%08x appid '%s'\n", hWnd, AppID);
+    winDebug("winSetAppUserMOdelID - hwnd 0x%p appid '%s'\n", hWnd, AppID);
 
     hr = g_pSHGetPropertyStoreForWindow(hWnd, &IID_IPropertyStore,
                                         (void **) &pps);
diff --git a/hw/xwin/windialogs.c b/hw/xwin/windialogs.c
index 61f7fe0..07fd409 100644
--- a/hw/xwin/windialogs.c
+++ b/hw/xwin/windialogs.c
@@ -437,8 +437,8 @@ winChangeDepthDlgProc(HWND hwndDialog, UINT message,
         s_pScreenInfo = s_pScreenPriv->pScreenInfo;
 
 #if CYGDEBUG
-        winDebug("winChangeDepthDlgProc - WM_INITDIALOG - s_pScreenPriv: %08x, "
-                 "s_pScreenInfo: %08x\n",
+        winDebug("winChangeDepthDlgProc - WM_INITDIALOG - s_pScreenPriv: %p, "
+                 "s_pScreenInfo: %p\n",
                  s_pScreenPriv, s_pScreenInfo);
 #endif
 
diff --git a/hw/xwin/winmsgwindow.c b/hw/xwin/winmsgwindow.c
index 59f1da5..0f26cea 100644
--- a/hw/xwin/winmsgwindow.c
+++ b/hw/xwin/winmsgwindow.c
@@ -136,7 +136,7 @@ winCreateMsgWindow(void)
         return NULL;
     }
 
-    winDebug("winCreateMsgWindow - Created msg window hwnd 0x%x\n", hwndMsg);
+    winDebug("winCreateMsgWindow - Created msg window hwnd 0x%p\n", hwndMsg);
 
     return hwndMsg;
 }
diff --git a/hw/xwin/winmultiwindowicons.c b/hw/xwin/winmultiwindowicons.c
index 93d389d..81ab494 100644
--- a/hw/xwin/winmultiwindowicons.c
+++ b/hw/xwin/winmultiwindowicons.c
@@ -465,7 +465,7 @@ winXIconToHICON(Display * pDisplay, Window id, int iconSize)
                 xImageIcon =
                     XGetImage(pDisplay, hints->icon_pixmap, 0, 0, width, height,
                               0xFFFFFFFF, ZPixmap);
-                winDebug("winXIconToHICON: id 0x%x icon Ximage 0x%x\n", id,
+                winDebug("winXIconToHICON: id 0x%x icon Ximage 0x%p\n", id,
                          xImageIcon);
 
                 if (hints->icon_mask)
diff --git a/hw/xwin/winmultiwindowshape.c b/hw/xwin/winmultiwindowshape.c
index cb0f389..73afaea 100644
--- a/hw/xwin/winmultiwindowshape.c
+++ b/hw/xwin/winmultiwindowshape.c
@@ -47,7 +47,7 @@ winSetShapeMultiWindow(WindowPtr pWin, int kind)
     winScreenPriv(pScreen);
 
 #if CYGMULTIWINDOW_DEBUG
-    ErrorF("winSetShapeMultiWindow - pWin: %08x kind: %i\n", pWin, kind);
+    ErrorF("winSetShapeMultiWindow - pWin: %p kind: %i\n", pWin, kind);
 #endif
 
     WIN_UNWRAP(SetShape);
diff --git a/hw/xwin/winmultiwindowwindow.c b/hw/xwin/winmultiwindowwindow.c
index f2e7907..421223a 100644
--- a/hw/xwin/winmultiwindowwindow.c
+++ b/hw/xwin/winmultiwindowwindow.c
@@ -286,7 +286,7 @@ winChangeWindowAttributesMultiWindow(WindowPtr pWin, unsigned long mask)
     winScreenPriv(pScreen);
 
 #if CYGMULTIWINDOW_DEBUG
-    ErrorF("winChangeWindowAttributesMultiWindow - pWin: %08x\n", pWin);
+    ErrorF("winChangeWindowAttributesMultiWindow - pWin: %p\n", pWin);
 #endif
 
     WIN_UNWRAP(ChangeWindowAttributes);
@@ -315,7 +315,7 @@ winUnmapWindowMultiWindow(WindowPtr pWin)
     winScreenPriv(pScreen);
 
 #if CYGMULTIWINDOW_DEBUG
-    ErrorF("winUnmapWindowMultiWindow - pWin: %08x\n", pWin);
+    ErrorF("winUnmapWindowMultiWindow - pWin: %p\n", pWin);
 #endif
 
     WIN_UNWRAP(UnrealizeWindow);
@@ -346,7 +346,7 @@ winMapWindowMultiWindow(WindowPtr pWin)
     winScreenPriv(pScreen);
 
 #if CYGMULTIWINDOW_DEBUG
-    ErrorF("winMapWindowMultiWindow - pWin: %08x\n", pWin);
+    ErrorF("winMapWindowMultiWindow - pWin: %p\n", pWin);
 #endif
 
     WIN_UNWRAP(RealizeWindow);
@@ -378,7 +378,7 @@ winReparentWindowMultiWindow(WindowPtr pWin, WindowPtr pPriorParent)
     winScreenPriv(pScreen);
 
     winDebug
-        ("winReparentMultiWindow - pWin:%08x XID:0x%x, reparent from pWin:%08x XID:0x%x to pWin:%08x XID:0x%x\n",
+        ("winReparentMultiWindow - pWin:%p XID:0x%x, reparent from pWin:%p XID:0x%x to pWin:%p XID:0x%x\n",
          pWin, pWin->drawable.id, pPriorParent, pPriorParent->drawable.id,
          pWin->parent, pWin->parent->drawable.id);
 
@@ -409,7 +409,7 @@ winRestackWindowMultiWindow(WindowPtr pWin, WindowPtr pOldNextSib)
     winScreenPriv(pScreen);
 
 #if CYGMULTIWINDOW_DEBUG || CYGWINDOWING_DEBUG
-    winTrace("winRestackMultiWindow - %08x\n", pWin);
+    winTrace("winRestackMultiWindow - %p\n", pWin);
 #endif
 
     WIN_UNWRAP(RestackWindow);
@@ -492,7 +492,7 @@ winCreateWindowsWindow(WindowPtr pWin)
 
     winInitMultiWindowClass();
 
-    winDebug("winCreateWindowsTopLevelWindow - pWin:%08x XID:0x%x \n", pWin,
+    winDebug("winCreateWindowsTopLevelWindow - pWin:%p XID:0x%x \n", pWin,
              pWin->drawable.id);
 
     iX = pWin->drawable.x + GetSystemMetrics(SM_XVIRTUALSCREEN);
@@ -618,7 +618,7 @@ winDestroyWindowsWindow(WindowPtr pWin)
     HICON hIcon;
     HICON hIconSm;
 
-    winDebug("winDestroyWindowsWindow - pWin:%08x XID:0x%x \n", pWin,
+    winDebug("winDestroyWindowsWindow - pWin:%p XID:0x%x \n", pWin,
              pWin->drawable.id);
 
     /* Bail out if the Windows window handle is invalid */
diff --git a/hw/xwin/winpixmap.c b/hw/xwin/winpixmap.c
index ef158c8..ef50fa3 100644
--- a/hw/xwin/winpixmap.c
+++ b/hw/xwin/winpixmap.c
@@ -113,8 +113,8 @@ winCreatePixmapNativeGDI(ScreenPtr pScreen,
                                                  pbmih);
 
 #if CYGDEBUG
-    winDebug("winCreatePixmap () - Created a pixmap %08x, %dx%dx%d, for "
-             "screen: %08x\n",
+    winDebug("winCreatePixmap () - Created a pixmap %p, %dx%dx%d, for "
+             "screen: %p\n",
              pPixmapPriv->hBitmap, iWidth, iHeight, iDepth, pScreen);
 #endif
 
@@ -146,7 +146,7 @@ winDestroyPixmapNativeGDI(PixmapPtr pPixmap)
     pPixmapPriv = winGetPixmapPriv(pPixmap);
 
 #if CYGDEBUG
-    winDebug("winDestroyPixmapNativeGDI - pPixmapPriv->hBitmap: %08x\n",
+    winDebug("winDestroyPixmapNativeGDI - pPixmapPriv->hBitmap: %p\n",
              pPixmapPriv->hBitmap);
 #endif
 
diff --git a/hw/xwin/winwndproc.c b/hw/xwin/winwndproc.c
index e3adb56..6b1efdd 100644
--- a/hw/xwin/winwndproc.c
+++ b/hw/xwin/winwndproc.c
@@ -629,7 +629,7 @@ winWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
         int iBorderHeight, iBorderWidth;
 
 #if CYGDEBUG
-        winDebug("winWindowProc - WM_GETMINMAXINFO - pScreenInfo: %08x\n",
+        winDebug("winWindowProc - WM_GETMINMAXINFO - pScreenInfo: %p\n",
                  s_pScreenInfo);
 #endif
 
commit 03d462ddd2cacce92dc9e6bad00710d899509387
Author: Jon TURNEY <jon.turney at dronecode.org.uk>
Date:   Thu Oct 2 12:04:20 2014 +0100

    hw/xwin: Fix warnings in glx/glshim.c
    
    glext.h currently requires GL_GLEXT_PROTOTYPES in order to prototype
    glCompressedTexImmage* functions
    
    generated_gl_shim.c:2859:6: warning: no previous prototype for 'glCompressedTexImage3DARB' [-Wmissing-prototypes]
    generated_gl_shim.c:2866:6: warning: no previous prototype for 'glCompressedTexImage2DARB' [-Wmissing-prototypes]
    generated_gl_shim.c:2873:6: warning: no previous prototype for 'glCompressedTexImage1DARB' [-Wmissing-prototypes]
    generated_gl_shim.c:2880:6: warning: no previous prototype for 'glCompressedTexSubImage3DARB' [-Wmissing-prototypes]
    generated_gl_shim.c:2887:6: warning: no previous prototype for 'glCompressedTexSubImage2DARB' [-Wmissing-prototypes]
    generated_gl_shim.c:2894:6: warning: no previous prototype for 'glCompressedTexSubImage1DARB' [-Wmissing-prototypes]
    generated_gl_shim.c:2901:6: warning: no previous prototype for 'glGetCompressedTexImageARB' [-Wmissing-prototypes]
    
    Also, explicitly prototype glXGetProcAddressARB(), as glx/glxdri*.c does, as
    it's not practical to include glx.h here...
    
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Reviewed-by: Colin Harrison <colin.harrison at virgin.net>

diff --git a/hw/xwin/glx/glshim.c b/hw/xwin/glx/glshim.c
index 7109196..df5a932 100644
--- a/hw/xwin/glx/glshim.c
+++ b/hw/xwin/glx/glshim.c
@@ -36,6 +36,7 @@
 #endif
 
 #define GL_GLEXT_LEGACY
+#define GL_GLEXT_PROTOTYPES
 #include <GL/gl.h>
 #undef GL_ARB_imaging
 #undef GL_VERSION_1_3
@@ -46,6 +47,8 @@
 #include "glwindows.h"
 #include <glx/glxserver.h>
 
+extern void *glXGetProcAddressARB(const char *);
+
 static HMODULE hMod = NULL;
 
 /*
commit 329e8125aa3b4c83121f8290a5436c2cb4c1cf96
Author: Jon TURNEY <jon.turney at dronecode.org.uk>
Date:   Wed Oct 1 12:14:43 2014 +0100

    hw/xwin: Fix compilation with -Werror=declaration-after-statement
    
    xevents.c: In function 'winClipboardInitMonitoredSelections':
    xevents.c:129:5: error: 'for' loop initial declarations are only allowed in C99 mode
         for (int i = 0; i < CLIP_NUM_SELECTIONS; ++i)
    
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Reviewed-by: Colin Harrison <colin.harrison at virgin.net>

diff --git a/hw/xwin/winclipboard/xevents.c b/hw/xwin/winclipboard/xevents.c
index d0077b8..33d52aa 100644
--- a/hw/xwin/winclipboard/xevents.c
+++ b/hw/xwin/winclipboard/xevents.c
@@ -126,7 +126,8 @@ void
 winClipboardInitMonitoredSelections(void)
 {
     /* Initialize static variables */
-    for (int i = 0; i < CLIP_NUM_SELECTIONS; ++i)
+    int i;
+    for (i = 0; i < CLIP_NUM_SELECTIONS; ++i)
       s_iOwners[i] = None;
 
     lastOwnedSelectionIndex = CLIP_OWN_NONE;
commit 97c3298caab7c5a5396fcbde02d862e5380d7d2e
Author: Jon TURNEY <jon.turney at dronecode.org.uk>
Date:   Wed Oct 1 12:02:04 2014 +0100

    hw/xwin: Fix compilation with -Werror=return-type
    
    winshadddnl.c: In function ‘winRedrawScreenShadowDDNL’:
    winshadddnl.c:991:9: error: ‘return’ with no value, in function returning non-void [-Werror=return-type]
    
    Just wrong in 1c34e774
    
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Reviewed-by: Colin Harrison <colin.harrison at virgin.net>

diff --git a/hw/xwin/winshadddnl.c b/hw/xwin/winshadddnl.c
index cb326dc..896fd53 100644
--- a/hw/xwin/winshadddnl.c
+++ b/hw/xwin/winshadddnl.c
@@ -988,7 +988,7 @@ winRedrawScreenShadowDDNL(ScreenPtr pScreen)
 
     /* Return immediately if we didn't get needed surfaces */
     if (!pScreenPriv->pddsPrimary4 || !pScreenPriv->pddsShadow4)
-        return;
+        return FALSE;
 
     /* Get the origin of the window in the screen coords */
     ptOrigin.x = pScreenInfo->dwXOffset;


More information about the Xquartz-changes mailing list