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

Jeremy Huddleston jeremyhu at freedesktop.org
Sat Feb 7 14:51:49 PST 2015


Rebased ref, commits from common ancestor:
commit 1298d92e044632b04d5693db7ac695ff709d2183
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 dd91cae..0b3bc95 100644
--- a/fb/fb.h
+++ b/fb/fb.h
@@ -1135,9 +1135,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 2ff9ae2..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;
-    }
-}
-
-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 8b0f59f..110f32d 100644
--- a/fb/fbpict.h
+++ b/fb/fbpict.h
@@ -65,24 +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
-fbUnrealizeGlyph(ScreenPtr pScreen,
-		 GlyphPtr pGlyph);
-
-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 e21b429acf631776d3ebe14c3d5db9fa7f3656d7
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 5099b0f..dd91cae 100644
--- a/fb/fb.h
+++ b/fb/fb.h
@@ -1383,8 +1383,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 8e99cbe..2ff9ae2 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 07c2bb05052b9084055ed27e9c3637bfddabea41
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 7a9e46a..8e99cbe 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 21b64fe49a2a26d0d57ce135a72a12c9736f5866
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 de8ee6c..a6678a5 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 19ba0d4ad155a66fcdbda925a1509273263db805
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 30f7c8f..22156d4 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 e572bcc7f4236b7e0f23ab762f225b3bce37db59
Author: Adam Jackson <ajax at redhat.com>
Date:   Mon Jun 23 15:24:35 2014 -0400

    fb: Remove even/odd tile slow-pathing
    
    Again, clearly meant to be a fast path, but this turns out not to be the
    case.
    
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/fb/Makefile.am b/fb/Makefile.am
index ff6dc3a..65b5d94 100644
--- a/fb/Makefile.am
+++ b/fb/Makefile.am
@@ -44,7 +44,6 @@ libfb_la_SOURCES = 	\
 	fbseg.c		\
 	fbsetsp.c	\
 	fbsolid.c	\
-	fbtile.c	\
 	fbtrap.c	\
 	fbutil.c	\
 	fbwindow.c
diff --git a/fb/fb.h b/fb/fb.h
index 9a67b9d..5099b0f 100644
--- a/fb/fb.h
+++ b/fb/fb.h
@@ -1332,45 +1332,6 @@ fbSolid24(FbBits * dst,
           int dstX, int width, int height, FbBits and, FbBits xor);
 
 /*
- * fbtile.c
- */
-
-extern _X_EXPORT void
-
-fbEvenTile(FbBits * dst,
-           FbStride dstStride,
-           int dstX,
-           int width,
-           int height,
-           FbBits * tile,
-           FbStride tileStride,
-           int tileHeight, int alu, FbBits pm, int xRot, int yRot);
-
-extern _X_EXPORT void
-
-fbOddTile(FbBits * dst,
-          FbStride dstStride,
-          int dstX,
-          int width,
-          int height,
-          FbBits * tile,
-          FbStride tileStride,
-          int tileWidth,
-          int tileHeight, int alu, FbBits pm, int bpp, int xRot, int yRot);
-
-extern _X_EXPORT void
-
-fbTile(FbBits * dst,
-       FbStride dstStride,
-       int dstX,
-       int width,
-       int height,
-       FbBits * tile,
-       FbStride tileStride,
-       int tileWidth,
-       int tileHeight, int alu, FbBits pm, int bpp, int xRot, int yRot);
-
-/*
  * fbutil.c
  */
 extern _X_EXPORT FbBits fbReplicatePixel(Pixel p, int bpp);
diff --git a/fb/fbfill.c b/fb/fbfill.c
index ad09671..05d81ab 100644
--- a/fb/fbfill.c
+++ b/fb/fbfill.c
@@ -27,6 +27,44 @@
 #include "fb.h"
 
 static void
+fbTile(FbBits * dst, FbStride dstStride, int dstX, int width, int height,
+       FbBits * tile, FbStride tileStride, int tileWidth, int tileHeight,
+       int alu, FbBits pm, int bpp, int xRot, int yRot)
+{
+    int tileX, tileY;
+    int widthTmp;
+    int h, w;
+    int x, y;
+
+    modulus(-yRot, tileHeight, tileY);
+    y = 0;
+    while (height) {
+        h = tileHeight - tileY;
+        if (h > height)
+            h = height;
+        height -= h;
+        widthTmp = width;
+        x = dstX;
+        modulus(dstX - xRot, tileWidth, tileX);
+        while (widthTmp) {
+            w = tileWidth - tileX;
+            if (w > widthTmp)
+                w = widthTmp;
+            widthTmp -= w;
+            fbBlt(tile + tileY * tileStride,
+                  tileStride,
+                  tileX,
+                  dst + y * dstStride,
+                  dstStride, x, w, h, alu, pm, bpp, FALSE, FALSE);
+            x += w;
+            tileX = 0;
+        }
+        y += h;
+        tileY = 0;
+    }
+}
+
+static void
 fbStipple(FbBits * dst, FbStride dstStride,
           int dstX, int dstBpp,
           int width, int height,
diff --git a/fb/fbtile.c b/fb/fbtile.c
deleted file mode 100644
index 785c5f0..0000000
--- a/fb/fbtile.c
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * Copyright © 1998 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 Keith Packard not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  Keith Packard makes no
- * representations about the suitability of this software for any purpose.  It
- * is provided "as is" without express or implied warranty.
- *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "fb.h"
-
-/*
- * Accelerated tile fill -- tile width is a power of two not greater
- * than FB_UNIT
- */
-
-void
-fbEvenTile(FbBits * dst,
-           FbStride dstStride,
-           int dstX,
-           int width,
-           int height,
-           FbBits * tile,
-           FbStride tileStride,
-           int tileHeight, int alu, FbBits pm, int xRot, int yRot)
-{
-    FbBits *t, *tileEnd, bits;
-    FbBits startmask, endmask;
-    FbBits and, xor;
-    int n, nmiddle;
-    int tileX, tileY;
-    int rot;
-    int startbyte, endbyte;
-
-    dst += dstX >> FB_SHIFT;
-    dstX &= FB_MASK;
-    FbMaskBitsBytes(dstX, width, FbDestInvarientRop(alu, pm),
-                    startmask, startbyte, nmiddle, endmask, endbyte);
-    if (startmask)
-        dstStride--;
-    dstStride -= nmiddle;
-
-    /*
-     * Compute tile start scanline and rotation parameters
-     */
-    tileEnd = tile + tileHeight * tileStride;
-    modulus(-yRot, tileHeight, tileY);
-    t = tile + tileY * tileStride;
-    modulus(-xRot, FB_UNIT, tileX);
-    rot = tileX;
-
-    while (height--) {
-
-        /*
-         * Pick up bits for this scanline
-         */
-        bits = READ(t);
-        t += tileStride;
-        if (t >= tileEnd)
-            t = tile;
-        bits = FbRotLeft(bits, rot);
-        and = fbAnd(alu, bits, pm);
-        xor = fbXor(alu, bits, pm);
-
-        if (startmask) {
-            FbDoLeftMaskByteRRop(dst, startbyte, startmask, and, xor);
-            dst++;
-        }
-        n = nmiddle;
-        if (!and)
-            while (n--)
-                WRITE(dst++, xor);
-        else
-            while (n--) {
-                WRITE(dst, FbDoRRop(READ(dst), and, xor));
-                dst++;
-            }
-        if (endmask)
-            FbDoRightMaskByteRRop(dst, endbyte, endmask, and, xor);
-        dst += dstStride;
-    }
-}
-
-void
-fbOddTile(FbBits * dst,
-          FbStride dstStride,
-          int dstX,
-          int width,
-          int height,
-          FbBits * tile,
-          FbStride tileStride,
-          int tileWidth,
-          int tileHeight, int alu, FbBits pm, int bpp, int xRot, int yRot)
-{
-    int tileX, tileY;
-    int widthTmp;
-    int h, w;
-    int x, y;
-
-    modulus(-yRot, tileHeight, tileY);
-    y = 0;
-    while (height) {
-        h = tileHeight - tileY;
-        if (h > height)
-            h = height;
-        height -= h;
-        widthTmp = width;
-        x = dstX;
-        modulus(dstX - xRot, tileWidth, tileX);
-        while (widthTmp) {
-            w = tileWidth - tileX;
-            if (w > widthTmp)
-                w = widthTmp;
-            widthTmp -= w;
-            fbBlt(tile + tileY * tileStride,
-                  tileStride,
-                  tileX,
-                  dst + y * dstStride,
-                  dstStride, x, w, h, alu, pm, bpp, FALSE, FALSE);
-            x += w;
-            tileX = 0;
-        }
-        y += h;
-        tileY = 0;
-    }
-}
-
-void
-fbTile(FbBits * dst,
-       FbStride dstStride,
-       int dstX,
-       int width,
-       int height,
-       FbBits * tile,
-       FbStride tileStride,
-       int tileWidth,
-       int tileHeight, int alu, FbBits pm, int bpp, int xRot, int yRot)
-{
-    if (FbEvenTile(tileWidth))
-        fbEvenTile(dst, dstStride, dstX, width, height,
-                   tile, tileStride, tileHeight, alu, pm, xRot, yRot);
-    else
-        fbOddTile(dst, dstStride, dstX, width, height,
-                  tile, tileStride, tileWidth, tileHeight,
-                  alu, pm, bpp, xRot, yRot);
-}
diff --git a/fb/wfbrename.h b/fb/wfbrename.h
index d32c7a4..30221c5 100644
--- a/fb/wfbrename.h
+++ b/fb/wfbrename.h
@@ -58,7 +58,6 @@
 #define fbDots24 wfbDots24
 #define fbDots32 wfbDots32
 #define fbDots8 wfbDots8
-#define fbEvenTile wfbEvenTile
 #define fbExpandDirectColors wfbExpandDirectColors
 #define fbFill wfbFill
 #define fbFillRegionSolid wfbFillRegionSolid
@@ -83,7 +82,6 @@
 #define fbInitVisuals wfbInitVisuals
 #define fbListInstalledColormaps wfbListInstalledColormaps
 #define FbMergeRopBits wFbMergeRopBits
-#define fbOddTile wfbOddTile
 #define fbOver wfbOver
 #define fbOver24 wfbOver24
 #define fbOverlayCloseScreen wfbOverlayCloseScreen
@@ -139,7 +137,6 @@
 #define fbSolid wfbSolid
 #define fbSolid24 wfbSolid24
 #define fbSolidBoxClipped wfbSolidBoxClipped
-#define fbTile wfbTile
 #define fbTrapezoids wfbTrapezoids
 #define fbTriangles wfbTriangles
 #define fbUninstallColormap wfbUninstallColormap
commit 836bb27726441e048bb300664343a136bc596a5b
Author: Adam Jackson <ajax at redhat.com>
Date:   Tue Jun 17 12:25:42 2014 -0400

    fb: Remove unused fbReduceRasterOp
    
    Appears to have been cargo-culted in from cfb and then never used.
    
    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 f7cbaf9..9a67b9d 100644
--- a/fb/fb.h
+++ b/fb/fb.h
@@ -1375,9 +1375,6 @@ fbTile(FbBits * dst,
  */
 extern _X_EXPORT FbBits fbReplicatePixel(Pixel p, int bpp);
 
-extern _X_EXPORT void
- fbReduceRasterOp(int rop, FbBits fg, FbBits pm, FbBits * andp, FbBits * xorp);
-
 #ifdef FB_ACCESS_WRAPPER
 extern _X_EXPORT ReadMemoryProcPtr wfbReadMemory;
 extern _X_EXPORT WriteMemoryProcPtr wfbWriteMemory;
diff --git a/fb/fbutil.c b/fb/fbutil.c
index 078fc42..c1d5923 100644
--- a/fb/fbutil.c
+++ b/fb/fbutil.c
@@ -39,84 +39,6 @@ fbReplicatePixel(Pixel p, int bpp)
     return b;
 }
 
-void
-fbReduceRasterOp(int rop, FbBits fg, FbBits pm, FbBits * andp, FbBits * xorp)
-{
-    FbBits and, xor;
-
-    switch (rop) {
-    default:
-    case GXclear:              /* 0 0 0 0 */
-        and = 0;
-        xor = 0;
-        break;
-    case GXand:                /* 0 0 0 1 */
-        and = fg;
-        xor = 0;
-        break;
-    case GXandReverse:         /* 0 0 1 0 */
-        and = fg;
-        xor = fg;
-        break;
-    case GXcopy:               /* 0 0 1 1 */
-        and = 0;
-        xor = fg;
-        break;
-    case GXandInverted:        /* 0 1 0 0 */
-        and = ~fg;
-        xor = 0;
-        break;
-    case GXnoop:               /* 0 1 0 1 */
-        and = FB_ALLONES;
-        xor = 0;
-        break;
-    case GXxor:                /* 0 1 1 0 */
-        and = FB_ALLONES;
-        xor = fg;
-        break;
-    case GXor:                 /* 0 1 1 1 */
-        and = ~fg;
-        xor = fg;
-        break;
-    case GXnor:                /* 1 0 0 0 */
-        and = ~fg;
-        xor = ~fg;
-        break;
-    case GXequiv:              /* 1 0 0 1 */
-        and = FB_ALLONES;
-        xor = ~fg;
-        break;
-    case GXinvert:             /* 1 0 1 0 */
-        and = FB_ALLONES;
-        xor = FB_ALLONES;
-        break;
-    case GXorReverse:          /* 1 0 1 1 */
-        and = ~fg;
-        xor = FB_ALLONES;
-        break;
-    case GXcopyInverted:       /* 1 1 0 0 */
-        and = 0;
-        xor = ~fg;
-        break;
-    case GXorInverted:         /* 1 1 0 1 */
-        and = fg;
-        xor = ~fg;
-        break;
-    case GXnand:               /* 1 1 1 0 */
-        and = fg;
-        xor = FB_ALLONES;
-        break;
-    case GXset:                /* 1 1 1 1 */
-        and = 0;
-        xor = FB_ALLONES;
-        break;
-    }
-    and |= ~pm;
-    xor &= pm;
-    *andp = and;
-    *xorp = xor;
-}
-
 #define O 0
 #define I FB_ALLONES
 
diff --git a/fb/wfbrename.h b/fb/wfbrename.h
index c8be10f..d32c7a4 100644
--- a/fb/wfbrename.h
+++ b/fb/wfbrename.h
@@ -126,8 +126,6 @@
 #define fbQueryBestSize wfbQueryBestSize
 #define fbRasterizeTrapezoid wfbRasterizeTrapezoid
 #define fbRealizeFont wfbRealizeFont
-#define fbRealizeWindow wfbRealizeWindow
-#define fbReduceRasterOp wfbReduceRasterOp
 #define fbReplicatePixel wfbReplicatePixel
 #define fbResolveColor wfbResolveColor
 #define fbScreenPrivateKeyRec wfbScreenPrivateKeyRec
commit 167ccd33e0d2c4bd68aebcdba5a512d24c5eb49a
Author: Adam Jackson <ajax at redhat.com>
Date:   Tue Jun 17 12:21:19 2014 -0400

    fb: Move fbStipple*Bits near their only consumer
    
    And remove fbStippleTable since gcc can't figure that out itself.
    
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/fb/fbbltone.c b/fb/fbbltone.c
index bd3229a..d5806e5 100644
--- a/fb/fbbltone.c
+++ b/fb/fbbltone.c
@@ -26,6 +26,101 @@
 
 #include "fb.h"
 
+/*
+ * Stipple masks are independent of bit/byte order as long
+ * as bitorder == byteorder.  FB doesn't handle the case
+ * where these differ
+ */
+#define BitsMask(x,w)	((FB_ALLONES << ((x) & FB_MASK)) & \
+			 (FB_ALLONES >> ((FB_UNIT - ((x) + (w))) & FB_MASK)))
+
+#define Mask(x,w)	BitsMask((x)*(w),(w))
+
+#define SelMask(b,n,w)	((((b) >> n) & 1) * Mask(n,w))
+
+#define C1(b,w) \
+    (SelMask(b,0,w))
+
+#define C2(b,w) \
+    (SelMask(b,0,w) | \
+     SelMask(b,1,w))
+
+#define C4(b,w) \
+    (SelMask(b,0,w) | \
+     SelMask(b,1,w) | \
+     SelMask(b,2,w) | \
+     SelMask(b,3,w))
+
+#define C8(b,w) \
+    (SelMask(b,0,w) | \
+     SelMask(b,1,w) | \
+     SelMask(b,2,w) | \
+     SelMask(b,3,w) | \
+     SelMask(b,4,w) | \
+     SelMask(b,5,w) | \
+     SelMask(b,6,w) | \
+     SelMask(b,7,w))
+
+static const FbBits fbStipple8Bits[256] = {
+    C8(0, 4), C8(1, 4), C8(2, 4), C8(3, 4), C8(4, 4), C8(5, 4),
+    C8(6, 4), C8(7, 4), C8(8, 4), C8(9, 4), C8(10, 4), C8(11, 4),
+    C8(12, 4), C8(13, 4), C8(14, 4), C8(15, 4), C8(16, 4), C8(17, 4),
+    C8(18, 4), C8(19, 4), C8(20, 4), C8(21, 4), C8(22, 4), C8(23, 4),
+    C8(24, 4), C8(25, 4), C8(26, 4), C8(27, 4), C8(28, 4), C8(29, 4),
+    C8(30, 4), C8(31, 4), C8(32, 4), C8(33, 4), C8(34, 4), C8(35, 4),
+    C8(36, 4), C8(37, 4), C8(38, 4), C8(39, 4), C8(40, 4), C8(41, 4),
+    C8(42, 4), C8(43, 4), C8(44, 4), C8(45, 4), C8(46, 4), C8(47, 4),
+    C8(48, 4), C8(49, 4), C8(50, 4), C8(51, 4), C8(52, 4), C8(53, 4),
+    C8(54, 4), C8(55, 4), C8(56, 4), C8(57, 4), C8(58, 4), C8(59, 4),
+    C8(60, 4), C8(61, 4), C8(62, 4), C8(63, 4), C8(64, 4), C8(65, 4),
+    C8(66, 4), C8(67, 4), C8(68, 4), C8(69, 4), C8(70, 4), C8(71, 4),
+    C8(72, 4), C8(73, 4), C8(74, 4), C8(75, 4), C8(76, 4), C8(77, 4),
+    C8(78, 4), C8(79, 4), C8(80, 4), C8(81, 4), C8(82, 4), C8(83, 4),
+    C8(84, 4), C8(85, 4), C8(86, 4), C8(87, 4), C8(88, 4), C8(89, 4),
+    C8(90, 4), C8(91, 4), C8(92, 4), C8(93, 4), C8(94, 4), C8(95, 4),
+    C8(96, 4), C8(97, 4), C8(98, 4), C8(99, 4), C8(100, 4), C8(101, 4),
+    C8(102, 4), C8(103, 4), C8(104, 4), C8(105, 4), C8(106, 4), C8(107, 4),
+    C8(108, 4), C8(109, 4), C8(110, 4), C8(111, 4), C8(112, 4), C8(113, 4),
+    C8(114, 4), C8(115, 4), C8(116, 4), C8(117, 4), C8(118, 4), C8(119, 4),
+    C8(120, 4), C8(121, 4), C8(122, 4), C8(123, 4), C8(124, 4), C8(125, 4),
+    C8(126, 4), C8(127, 4), C8(128, 4), C8(129, 4), C8(130, 4), C8(131, 4),
+    C8(132, 4), C8(133, 4), C8(134, 4), C8(135, 4), C8(136, 4), C8(137, 4),
+    C8(138, 4), C8(139, 4), C8(140, 4), C8(141, 4), C8(142, 4), C8(143, 4),
+    C8(144, 4), C8(145, 4), C8(146, 4), C8(147, 4), C8(148, 4), C8(149, 4),
+    C8(150, 4), C8(151, 4), C8(152, 4), C8(153, 4), C8(154, 4), C8(155, 4),
+    C8(156, 4), C8(157, 4), C8(158, 4), C8(159, 4), C8(160, 4), C8(161, 4),
+    C8(162, 4), C8(163, 4), C8(164, 4), C8(165, 4), C8(166, 4), C8(167, 4),
+    C8(168, 4), C8(169, 4), C8(170, 4), C8(171, 4), C8(172, 4), C8(173, 4),
+    C8(174, 4), C8(175, 4), C8(176, 4), C8(177, 4), C8(178, 4), C8(179, 4),
+    C8(180, 4), C8(181, 4), C8(182, 4), C8(183, 4), C8(184, 4), C8(185, 4),
+    C8(186, 4), C8(187, 4), C8(188, 4), C8(189, 4), C8(190, 4), C8(191, 4),
+    C8(192, 4), C8(193, 4), C8(194, 4), C8(195, 4), C8(196, 4), C8(197, 4),
+    C8(198, 4), C8(199, 4), C8(200, 4), C8(201, 4), C8(202, 4), C8(203, 4),
+    C8(204, 4), C8(205, 4), C8(206, 4), C8(207, 4), C8(208, 4), C8(209, 4),
+    C8(210, 4), C8(211, 4), C8(212, 4), C8(213, 4), C8(214, 4), C8(215, 4),
+    C8(216, 4), C8(217, 4), C8(218, 4), C8(219, 4), C8(220, 4), C8(221, 4),
+    C8(222, 4), C8(223, 4), C8(224, 4), C8(225, 4), C8(226, 4), C8(227, 4),
+    C8(228, 4), C8(229, 4), C8(230, 4), C8(231, 4), C8(232, 4), C8(233, 4),
+    C8(234, 4), C8(235, 4), C8(236, 4), C8(237, 4), C8(238, 4), C8(239, 4),
+    C8(240, 4), C8(241, 4), C8(242, 4), C8(243, 4), C8(244, 4), C8(245, 4),
+    C8(246, 4), C8(247, 4), C8(248, 4), C8(249, 4), C8(250, 4), C8(251, 4),
+    C8(252, 4), C8(253, 4), C8(254, 4), C8(255, 4),
+};
+
+static const FbBits fbStipple4Bits[16] = {
+    C4(0, 8), C4(1, 8), C4(2, 8), C4(3, 8), C4(4, 8), C4(5, 8),
+    C4(6, 8), C4(7, 8), C4(8, 8), C4(9, 8), C4(10, 8), C4(11, 8),
+    C4(12, 8), C4(13, 8), C4(14, 8), C4(15, 8),
+};
+
+static const FbBits fbStipple2Bits[4] = {
+    C2(0, 16), C2(1, 16), C2(2, 16), C2(3, 16),
+};
+
+static const FbBits fbStipple1Bits[2] = {
+    C1(0, 32), C1(1, 32),
+};
+
 #ifdef __clang__
 /* shift overflow is intentional */
 #pragma clang diagnostic ignored "-Wshift-overflow"
@@ -153,8 +248,22 @@ fbBltOne(FbStip * src, FbStride srcStride,      /* FbStip units per scanline */
      * Get pointer to stipple mask array for this depth
      */
     fbBits = 0;                 /* unused */
-    if (pixelsPerDst <= 8)
-        fbBits = fbStippleTable[pixelsPerDst];
+    switch (pixelsPerDst) {
+    case 8:
+        fbBits = fbStipple8Bits;
+        break;
+    case 4:
+        fbBits = fbStipple4Bits;
+        break;
+    case 2:
+        fbBits = fbStipple2Bits;
+        break;
+    case 1:
+        fbBits = fbStipple1Bits;
+        break;
+    default:
+        return;
+    }
 
     /*
      * Compute total number of destination words written, but 
diff --git a/fb/fbrop.h b/fb/fbrop.h
index b995f23..872ae52 100644
--- a/fb/fbrop.h
+++ b/fb/fbrop.h
@@ -95,12 +95,6 @@ extern _X_EXPORT const FbMergeRopRec FbMergeRopBits[16];
  * Stippling operations; 
  */
 
-extern _X_EXPORT const FbBits fbStipple8Bits[256];
-extern _X_EXPORT const FbBits fbStipple4Bits[16];
-extern _X_EXPORT const FbBits fbStipple2Bits[4];
-extern _X_EXPORT const FbBits fbStipple1Bits[2];
-extern _X_EXPORT const FbBits *const fbStippleTable[];
-
 #define FbStippleRRop(dst, b, fa, fx, ba, bx) \
     (FbDoRRop(dst, fa, fx) & b) | (FbDoRRop(dst, ba, bx) & ~b)
 
diff --git a/fb/fbutil.c b/fb/fbutil.c
index 9d66c2a..078fc42 100644
--- a/fb/fbutil.c
+++ b/fb/fbutil.c
@@ -139,110 +139,3 @@ const FbMergeRopRec FbMergeRopBits[16] = {
     {O, O, O, I},               /* set           0xf         1 */
 };
 
-/*
- * Stipple masks are independent of bit/byte order as long
- * as bitorder == byteorder.  FB doesn't handle the case
- * where these differ
- */
-#define BitsMask(x,w)	((FB_ALLONES << ((x) & FB_MASK)) & \
-			 (FB_ALLONES >> ((FB_UNIT - ((x) + (w))) & FB_MASK)))
-
-#define Mask(x,w)	BitsMask((x)*(w),(w))
-
-#define SelMask(b,n,w)	((((b) >> n) & 1) * Mask(n,w))
-
-#define C1(b,w) \
-    (SelMask(b,0,w))
-
-#define C2(b,w) \
-    (SelMask(b,0,w) | \
-     SelMask(b,1,w))
-
-#define C4(b,w) \
-    (SelMask(b,0,w) | \
-     SelMask(b,1,w) | \
-     SelMask(b,2,w) | \
-     SelMask(b,3,w))
-
-#define C8(b,w) \
-    (SelMask(b,0,w) | \
-     SelMask(b,1,w) | \
-     SelMask(b,2,w) | \
-     SelMask(b,3,w) | \
-     SelMask(b,4,w) | \
-     SelMask(b,5,w) | \
-     SelMask(b,6,w) | \
-     SelMask(b,7,w))
-
-#define fbStipple16Bits 0
-const FbBits fbStipple8Bits[256] = {
-    C8(0, 4), C8(1, 4), C8(2, 4), C8(3, 4), C8(4, 4), C8(5, 4),
-    C8(6, 4), C8(7, 4), C8(8, 4), C8(9, 4), C8(10, 4), C8(11, 4),
-    C8(12, 4), C8(13, 4), C8(14, 4), C8(15, 4), C8(16, 4), C8(17, 4),
-    C8(18, 4), C8(19, 4), C8(20, 4), C8(21, 4), C8(22, 4), C8(23, 4),
-    C8(24, 4), C8(25, 4), C8(26, 4), C8(27, 4), C8(28, 4), C8(29, 4),
-    C8(30, 4), C8(31, 4), C8(32, 4), C8(33, 4), C8(34, 4), C8(35, 4),
-    C8(36, 4), C8(37, 4), C8(38, 4), C8(39, 4), C8(40, 4), C8(41, 4),
-    C8(42, 4), C8(43, 4), C8(44, 4), C8(45, 4), C8(46, 4), C8(47, 4),
-    C8(48, 4), C8(49, 4), C8(50, 4), C8(51, 4), C8(52, 4), C8(53, 4),
-    C8(54, 4), C8(55, 4), C8(56, 4), C8(57, 4), C8(58, 4), C8(59, 4),
-    C8(60, 4), C8(61, 4), C8(62, 4), C8(63, 4), C8(64, 4), C8(65, 4),
-    C8(66, 4), C8(67, 4), C8(68, 4), C8(69, 4), C8(70, 4), C8(71, 4),
-    C8(72, 4), C8(73, 4), C8(74, 4), C8(75, 4), C8(76, 4), C8(77, 4),
-    C8(78, 4), C8(79, 4), C8(80, 4), C8(81, 4), C8(82, 4), C8(83, 4),
-    C8(84, 4), C8(85, 4), C8(86, 4), C8(87, 4), C8(88, 4), C8(89, 4),
-    C8(90, 4), C8(91, 4), C8(92, 4), C8(93, 4), C8(94, 4), C8(95, 4),
-    C8(96, 4), C8(97, 4), C8(98, 4), C8(99, 4), C8(100, 4), C8(101, 4),
-    C8(102, 4), C8(103, 4), C8(104, 4), C8(105, 4), C8(106, 4), C8(107, 4),
-    C8(108, 4), C8(109, 4), C8(110, 4), C8(111, 4), C8(112, 4), C8(113, 4),
-    C8(114, 4), C8(115, 4), C8(116, 4), C8(117, 4), C8(118, 4), C8(119, 4),
-    C8(120, 4), C8(121, 4), C8(122, 4), C8(123, 4), C8(124, 4), C8(125, 4),
-    C8(126, 4), C8(127, 4), C8(128, 4), C8(129, 4), C8(130, 4), C8(131, 4),
-    C8(132, 4), C8(133, 4), C8(134, 4), C8(135, 4), C8(136, 4), C8(137, 4),
-    C8(138, 4), C8(139, 4), C8(140, 4), C8(141, 4), C8(142, 4), C8(143, 4),
-    C8(144, 4), C8(145, 4), C8(146, 4), C8(147, 4), C8(148, 4), C8(149, 4),
-    C8(150, 4), C8(151, 4), C8(152, 4), C8(153, 4), C8(154, 4), C8(155, 4),
-    C8(156, 4), C8(157, 4), C8(158, 4), C8(159, 4), C8(160, 4), C8(161, 4),
-    C8(162, 4), C8(163, 4), C8(164, 4), C8(165, 4), C8(166, 4), C8(167, 4),
-    C8(168, 4), C8(169, 4), C8(170, 4), C8(171, 4), C8(172, 4), C8(173, 4),
-    C8(174, 4), C8(175, 4), C8(176, 4), C8(177, 4), C8(178, 4), C8(179, 4),
-    C8(180, 4), C8(181, 4), C8(182, 4), C8(183, 4), C8(184, 4), C8(185, 4),
-    C8(186, 4), C8(187, 4), C8(188, 4), C8(189, 4), C8(190, 4), C8(191, 4),
-    C8(192, 4), C8(193, 4), C8(194, 4), C8(195, 4), C8(196, 4), C8(197, 4),
-    C8(198, 4), C8(199, 4), C8(200, 4), C8(201, 4), C8(202, 4), C8(203, 4),
-    C8(204, 4), C8(205, 4), C8(206, 4), C8(207, 4), C8(208, 4), C8(209, 4),
-    C8(210, 4), C8(211, 4), C8(212, 4), C8(213, 4), C8(214, 4), C8(215, 4),
-    C8(216, 4), C8(217, 4), C8(218, 4), C8(219, 4), C8(220, 4), C8(221, 4),
-    C8(222, 4), C8(223, 4), C8(224, 4), C8(225, 4), C8(226, 4), C8(227, 4),
-    C8(228, 4), C8(229, 4), C8(230, 4), C8(231, 4), C8(232, 4), C8(233, 4),
-    C8(234, 4), C8(235, 4), C8(236, 4), C8(237, 4), C8(238, 4), C8(239, 4),
-    C8(240, 4), C8(241, 4), C8(242, 4), C8(243, 4), C8(244, 4), C8(245, 4),
-    C8(246, 4), C8(247, 4), C8(248, 4), C8(249, 4), C8(250, 4), C8(251, 4),
-    C8(252, 4), C8(253, 4), C8(254, 4), C8(255, 4),
-};
-
-const FbBits fbStipple4Bits[16] = {
-    C4(0, 8), C4(1, 8), C4(2, 8), C4(3, 8), C4(4, 8), C4(5, 8),
-    C4(6, 8), C4(7, 8), C4(8, 8), C4(9, 8), C4(10, 8), C4(11, 8),
-    C4(12, 8), C4(13, 8), C4(14, 8), C4(15, 8),
-};
-
-const FbBits fbStipple2Bits[4] = {
-    C2(0, 16), C2(1, 16), C2(2, 16), C2(3, 16),
-};
-
-const FbBits fbStipple1Bits[2] = {
-    C1(0, 32), C1(1, 32),
-};
-
-const FbBits *const fbStippleTable[] = {
-    0,
-    fbStipple1Bits,
-    fbStipple2Bits,
-    0,
-    fbStipple4Bits,
-    0,
-    0,
-    0,
-    fbStipple8Bits,
-};
diff --git a/fb/wfbrename.h b/fb/wfbrename.h
index 0bd233e..c8be10f 100644
--- a/fb/wfbrename.h
+++ b/fb/wfbrename.h
@@ -141,12 +141,6 @@
 #define fbSolid wfbSolid
 #define fbSolid24 wfbSolid24
 #define fbSolidBoxClipped wfbSolidBoxClipped
-#define fbStipple1Bits wfbStipple1Bits
-#define fbStipple24Bits wfbStipple24Bits
-#define fbStipple2Bits wfbStipple2Bits
-#define fbStipple4Bits wfbStipple4Bits
-#define fbStipple8Bits wfbStipple8Bits
-#define fbStippleTable wfbStippleTable
 #define fbTile wfbTile
 #define fbTrapezoids wfbTrapezoids
 #define fbTriangles wfbTriangles
commit 7430fdb689678b98ac63f5a8dad13719bac777e0
Author: Adam Jackson <ajax at redhat.com>
Date:   Tue Dec 17 14:46:38 2013 -0500

    fb: Remove even/odd stipple slow-pathing
    
    This is clearly meant to be a fast path, but it appears to be a net
    loss at this point.
    
    If you really wanted to ricer-tune here, note that the inner loop of
    fbBltOne is a bit too complicated for gcc (at least 4.8.2), it doesn't
    specialize the loop for the handful of legal values of bitsPerDst, which
    means computing at runtime what could have been const-propped.
    
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/fb/Makefile.am b/fb/Makefile.am
index 752eabe..ff6dc3a 100644
--- a/fb/Makefile.am
+++ b/fb/Makefile.am
@@ -44,7 +44,6 @@ libfb_la_SOURCES = 	\
 	fbseg.c		\
 	fbsetsp.c	\
 	fbsolid.c	\
-	fbstipple.c	\
 	fbtile.c	\
 	fbtrap.c	\
 	fbutil.c	\
diff --git a/fb/fb.h b/fb/fb.h
index 6db5803..f7cbaf9 100644
--- a/fb/fb.h
+++ b/fb/fb.h
@@ -452,7 +452,6 @@ typedef struct {
     FbBits bgand, bgxor;        /* for stipples */
     FbBits fg, bg, pm;          /* expanded and filled */
     unsigned int dashLength;    /* total of all dash elements */
-    unsigned char evenStipple;  /* stipple is even */
     unsigned char bpp;          /* current drawable bpp */
 } FbGCPrivRec, *FbGCPrivPtr;
 
@@ -545,11 +544,6 @@ typedef struct {
  * Accelerated tiles are power of 2 width <= FB_UNIT
  */
 #define FbEvenTile(w)	    ((w) <= FB_UNIT && FbPowerOfTwo(w))
-/*
- * Accelerated stipples are power of 2 width and <= FB_UNIT/dstBpp
- * with dstBpp a power of 2 as well
- */
-#define FbEvenStip(w,bpp)   ((w) * (bpp) <= FB_UNIT && FbPowerOfTwo(w) && FbPowerOfTwo(bpp))
 
 /*
  * fb24_32.c
@@ -1338,58 +1332,6 @@ fbSolid24(FbBits * dst,
           int dstX, int width, int height, FbBits and, FbBits xor);
 
 /*
- * fbstipple.c
- */
-
-extern _X_EXPORT void
- fbTransparentSpan(FbBits * dst, FbBits stip, FbBits fgxor, int n);
-
-extern _X_EXPORT void
-
-fbEvenStipple(FbBits * dst,
-              FbStride dstStride,
-              int dstX,
-              int dstBpp,
-              int width,
-              int height,
-              FbStip * stip,
-              FbStride stipStride,
-              int stipHeight,
-              FbBits fgand,
-              FbBits fgxor, FbBits bgand, FbBits bgxor, int xRot, int yRot);
-
-extern _X_EXPORT void
-
-fbOddStipple(FbBits * dst,
-             FbStride dstStride,
-             int dstX,
-             int dstBpp,
-             int width,
-             int height,
-             FbStip * stip,
-             FbStride stipStride,
-             int stipWidth,
-             int stipHeight,
-             FbBits fgand,
-             FbBits fgxor, FbBits bgand, FbBits bgxor, int xRot, int yRot);
-
-extern _X_EXPORT void
-
-fbStipple(FbBits * dst,
-          FbStride dstStride,
-          int dstX,
-          int dstBpp,
-          int width,
-          int height,
-          FbStip * stip,
-          FbStride stipStride,
-          int stipWidth,
-          int stipHeight,
-          Bool even,
-          FbBits fgand,
-          FbBits fgxor, FbBits bgand, FbBits bgxor, int xRot, int yRot);
-
-/*
  * fbtile.c
  */
 
diff --git a/fb/fbbltone.c b/fb/fbbltone.c
index 3042c4b..bd3229a 100644
--- a/fb/fbbltone.c
+++ b/fb/fbbltone.c
@@ -62,26 +62,6 @@
 	bits = (src < srcEnd ? READ(src++) : 0); \
 }
 
-#define LaneCases1(n,a)	    case n: FbLaneCase(n,a); break
-#define LaneCases2(n,a)	    LaneCases1(n,a); LaneCases1(n+1,a)
-#define LaneCases4(n,a)	    LaneCases2(n,a); LaneCases2(n+2,a)
-#define LaneCases8(n,a)	    LaneCases4(n,a); LaneCases4(n+4,a)
-#define LaneCases16(n,a)    LaneCases8(n,a); LaneCases8(n+8,a)
-
-#define LaneCases(a)	    LaneCases16(0,a)
-
-static const CARD8 fb8Lane[16] = {
-    0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
-};
-
-static const CARD8 fb16Lane[16] = {
-    0, 3, 12, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-};
-
-static const CARD8 fb32Lane[16] = {
-    0, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-};
-
 void
 fbBltOne(FbStip * src, FbStride srcStride,      /* FbStip units per scanline */
          int srcX,              /* bit position of source */
@@ -110,7 +90,6 @@ fbBltOne(FbStip * src, FbStride srcStride,      /* FbStip units per scanline */
     Bool transparent;           /* accelerate 0 nop */
     int srcinc;                 /* source units consumed */
     Bool endNeedsLoad = FALSE;  /* need load for endmask */
-    const CARD8 *fbLane;
     int startbyte, endbyte;
 
     if (dstBpp == 24) {
@@ -176,15 +155,6 @@ fbBltOne(FbStip * src, FbStride srcStride,      /* FbStip units per scanline */
     fbBits = 0;                 /* unused */
     if (pixelsPerDst <= 8)
         fbBits = fbStippleTable[pixelsPerDst];
-    fbLane = 0;
-    if (transparent && fgand == 0) {
-        if (dstBpp == 8)
-            fbLane = fb8Lane;
-        if (dstBpp == 16)
-            fbLane = fb16Lane;
-        if (dstBpp == 32)
-            fbLane = fb32Lane;
-    }
 
     /*
      * Compute total number of destination words written, but 
@@ -235,15 +205,10 @@ fbBltOne(FbStip * src, FbStride srcStride,      /* FbStip units per scanline */
              */
             if (startmask) {
                 mask = fbBits[FbLeftStipBits(bits, pixelsPerDst)];
-                if (fbLane) {
-                    fbTransparentSpan(dst, mask & startmask, fgxor, 1);
-                }
-                else {
-                    if (mask || !transparent)
-                        FbDoLeftMaskByteStippleRRop(dst, mask,
-                                                    fgand, fgxor, bgand, bgxor,
-                                                    startbyte, startmask);
-                }
+                if (mask || !transparent)
+                    FbDoLeftMaskByteStippleRRop(dst, mask,
+                                                fgand, fgxor, bgand, bgxor,
+                                                startbyte, startmask);
                 bits = FbStipLeft(bits, pixelsPerDst);
                 dst++;
                 n--;
@@ -263,29 +228,15 @@ fbBltOne(FbStip * src, FbStride srcStride,      /* FbStip units per scanline */
                     }
                 }
                 else {
-                    if (fbLane) {
-                        while (bits && n) {
-                            switch (fbLane[FbLeftStipBits(bits, pixelsPerDst)]) {
-                                LaneCases((CARD8 *) dst);
-                            }
-                            bits = FbStipLeft(bits, pixelsPerDst);
-                            dst++;
-                            n--;
-                        }
-                        dst += n;
-                    }
-                    else {
-                        while (n--) {
-                            left = FbLeftStipBits(bits, pixelsPerDst);
-                            if (left || !transparent) {
-                                mask = fbBits[left];
-                                WRITE(dst, FbStippleRRop(READ(dst), mask,
-                                                         fgand, fgxor, bgand,
-                                                         bgxor));
-                            }
-                            dst++;
-                            bits = FbStipLeft(bits, pixelsPerDst);
+                    while (n--) {
+                        left = FbLeftStipBits(bits, pixelsPerDst);
+                        if (left || !transparent) {
+                            mask = fbBits[left];
+                            WRITE(dst, FbStippleRRop(READ(dst), mask, fgand,
+                                                     fgxor, bgand, bgxor));
                         }
+                        dst++;
+                        bits = FbStipLeft(bits, pixelsPerDst);
                     }
                 }
                 if (!w)
@@ -307,15 +258,9 @@ fbBltOne(FbStip * src, FbStride srcStride,      /* FbStip units per scanline */
                 LoadBits;
             }
             mask = fbBits[FbLeftStipBits(bits, pixelsPerDst)];
-            if (fbLane) {
-                fbTransparentSpan(dst, mask & endmask, fgxor, 1);
-            }
-            else {
-                if (mask || !transparent)
-                    FbDoRightMaskByteStippleRRop(dst, mask,
-                                                 fgand, fgxor, bgand, bgxor,
-                                                 endbyte, endmask);
-            }
+            if (mask || !transparent)
+                FbDoRightMaskByteStippleRRop(dst, mask, fgand, fgxor,
+                                             bgand, bgxor, endbyte, endmask);
         }
         dst += dstStride;
         src += srcStride;
diff --git a/fb/fbfill.c b/fb/fbfill.c
index de9d6b3..ad09671 100644
--- a/fb/fbfill.c
+++ b/fb/fbfill.c
@@ -26,6 +26,50 @@
 
 #include "fb.h"
 
+static void
+fbStipple(FbBits * dst, FbStride dstStride,
+          int dstX, int dstBpp,
+          int width, int height,
+          FbStip * stip, FbStride stipStride,
+          int stipWidth, int stipHeight,
+          FbBits fgand, FbBits fgxor,
+          FbBits bgand, FbBits bgxor,
+          int xRot, int yRot)
+{
+    int stipX, stipY, sx;
+    int widthTmp;
+    int h, w;
+    int x, y;
+
+    modulus(-yRot, stipHeight, stipY);
+    modulus(dstX / dstBpp - xRot, stipWidth, stipX);
+    y = 0;
+    while (height) {
+        h = stipHeight - stipY;
+        if (h > height)
+            h = height;
+        height -= h;
+        widthTmp = width;
+        x = dstX;
+        sx = stipX;
+        while (widthTmp) {
+            w = (stipWidth - sx) * dstBpp;
+            if (w > widthTmp)
+                w = widthTmp;
+            widthTmp -= w;
+            fbBltOne(stip + stipY * stipStride,
+                     stipStride,
+                     sx,
+                     dst + y * dstStride,
+                     dstStride, x, dstBpp, w, h, fgand, fgxor, bgand, bgxor);
+            x += w;
+            sx = 0;
+        }
+        y += h;
+        stipY = 0;
+    }
+}
+
 void
 fbFill(DrawablePtr pDrawable, GCPtr pGC, int x, int y, int width, int height)
 {
@@ -97,7 +141,7 @@ fbFill(DrawablePtr pDrawable, GCPtr pGC, int x, int y, int width, int height)
             fbStipple(dst + (y + dstYoff) * dstStride, dstStride,
                       (x + dstXoff) * dstBpp, dstBpp, width * dstBpp, height,
                       stip, stipStride, stipWidth, stipHeight,
-                      pPriv->evenStipple, fgand, fgxor, bgand, bgxor,
+                      fgand, fgxor, bgand, bgxor,
                       pGC->patOrg.x + pDrawable->x + dstXoff,
                       pGC->patOrg.y + pDrawable->y - y);
             fbFinishAccess(&pStip->drawable);
diff --git a/fb/fbgc.c b/fb/fbgc.c
index f4d7f3a..21c9b03 100644
--- a/fb/fbgc.c
+++ b/fb/fbgc.c
@@ -110,80 +110,6 @@ fbPadPixmap(PixmapPtr pPixmap)
     fbFinishAccess(&pPixmap->drawable);
 }
 
-/*
- * Verify that 'bits' repeats every 'len' bits
- */
-static Bool
-fbBitsRepeat(FbBits bits, int len, int width)
-{
-    FbBits mask = FbBitsMask(0, len);
-    FbBits orig = bits & mask;
-    int i;
-
-    if (width > FB_UNIT)
-        width = FB_UNIT;
-    for (i = 0; i < width / len; i++) {
-        if ((bits & mask) != orig)
-            return FALSE;
-        bits = FbScrLeft(bits, len);
-    }
-    return TRUE;
-}
-
-/*
- * Check whether an entire bitmap line is a repetition of
- * the first 'len' bits
- */
-static Bool
-fbLineRepeat(FbBits * bits, int len, int width)
-{
-    FbBits first = bits[0];
-
-    if (!fbBitsRepeat(first, len, width))
-        return FALSE;
-    width = (width + FB_UNIT - 1) >> FB_SHIFT;
-    bits++;
-    while (--width)
-        if (READ(bits) != first)
-            return FALSE;
-    return TRUE;
-}
-
-/*
- * The even stipple code wants the first FB_UNIT/bpp bits on
- * each scanline to represent the entire stipple
- */
-static Bool
-fbCanEvenStipple(PixmapPtr pStipple, int bpp)
-{
-    int len = FB_UNIT / bpp;
-    FbBits *bits;
-    int stride;
-    int stip_bpp;
-    _X_UNUSED int stipXoff, stipYoff;
-    int h;
-
-    /* can't even stipple 24bpp drawables */
-    if ((bpp & (bpp - 1)) != 0)
-        return FALSE;
-    /* make sure the stipple width is a multiple of the even stipple width */
-    if (pStipple->drawable.width % len != 0)
-        return FALSE;
-    fbGetDrawable(&pStipple->drawable, bits, stride, stip_bpp, stipXoff,
-                  stipYoff);
-    h = pStipple->drawable.height;
-    /* check to see that the stipple repeats horizontally */
-    while (h--) {
-        if (!fbLineRepeat(bits, len, pStipple->drawable.width)) {
-            fbFinishAccess(&pStipple->drawable);
-            return FALSE;
-        }
-        bits += stride;
-    }
-    fbFinishAccess(&pStipple->drawable);
-    return TRUE;
-}
-
 void
 fbValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDrawable)
 {
@@ -239,16 +165,7 @@ fbValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDrawable)
             fbPadPixmap(pGC->tile.pixmap);
     }
     if (changes & GCStipple) {
-        pPriv->evenStipple = FALSE;
-
         if (pGC->stipple) {
-
-            /* can we do an even stipple ?? */
-            if (FbEvenStip(pGC->stipple->drawable.width,
-                           pDrawable->bitsPerPixel) &&
-                (fbCanEvenStipple(pGC->stipple, pDrawable->bitsPerPixel)))
-                pPriv->evenStipple = TRUE;
-
             if (pGC->stipple->drawable.width * pDrawable->bitsPerPixel <
                 FB_UNIT)
                 fbPadPixmap(pGC->stipple);
diff --git a/fb/fbstipple.c b/fb/fbstipple.c
deleted file mode 100644
index 9a877c1..0000000
--- a/fb/fbstipple.c
+++ /dev/null
@@ -1,243 +0,0 @@
-/*
- * Copyright © 1998 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 Keith Packard not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  Keith Packard makes no
- * representations about the suitability of this software for any purpose.  It
- * is provided "as is" without express or implied warranty.
- *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "fb.h"
-
-/*
- * This is a slight abuse of the preprocessor to generate repetitive
- * code, the idea is to generate code for each case of a copy-mode
- * transparent stipple
- */
-#define LaneCases1(c,a)	    case c: \
-				while (n--) { FbLaneCase(c,a); a++; } \
-				break
-#define LaneCases2(c,a)	    LaneCases1(c,a); LaneCases1(c+1,a)
-#define LaneCases4(c,a)	    LaneCases2(c,a); LaneCases2(c+2,a)
-#define LaneCases8(c,a)	    LaneCases4(c,a); LaneCases4(c+4,a)
-#define LaneCases16(c,a)    LaneCases8(c,a); LaneCases8(c+8,a)
-
-#define LaneCases(a)	    LaneCases16(0,a)
-
-/*
- * Repeat a transparent stipple across a scanline n times
- */
-
-void
-fbTransparentSpan(FbBits * dst, FbBits stip, FbBits fgxor, int n)
-{
-    FbStip s;
-
-    s = ((FbStip) (stip) & 0x01);
-    s |= ((FbStip) (stip >> 8) & 0x02);
-    s |= ((FbStip) (stip >> 16) & 0x04);
-    s |= ((FbStip) (stip >> 24) & 0x08);
-    switch (s) {
-        LaneCases(dst);
-    }
-}
-
-void
-fbEvenStipple(FbBits * dst,
-              FbStride dstStride,
-              int dstX,
-              int dstBpp,
-              int width,
-              int height,
-              FbStip * stip,
-              FbStride stipStride,
-              int stipHeight,
-              FbBits fgand,
-              FbBits fgxor, FbBits bgand, FbBits bgxor, int xRot, int yRot)
-{
-    FbBits startmask, endmask;
-    FbBits mask, and, xor;
-    int nmiddle, n;
-    FbStip *s, *stipEnd, bits;
-    int rot, stipX, stipY;
-    int pixelsPerDst;
-    const FbBits *fbBits;
-    Bool transparent;
-    int startbyte, endbyte;
-
-    /*
-     * Check for a transparent stipple (stencil)
-     */
-    transparent = FALSE;
-    if (dstBpp >= 8 && fgand == 0 && bgand == FB_ALLONES && bgxor == 0)
-        transparent = TRUE;
-
-    pixelsPerDst = FB_UNIT / dstBpp;
-    /*
-     * Adjust dest pointers
-     */
-    dst += dstX >> FB_SHIFT;
-    dstX &= FB_MASK;
-    FbMaskBitsBytes(dstX, width, fgand == 0 && bgand == 0,
-                    startmask, startbyte, nmiddle, endmask, endbyte);
-
-    if (startmask)
-        dstStride--;
-    dstStride -= nmiddle;
-
-    xRot *= dstBpp;
-    /*
-     * Compute stip start scanline and rotation parameters
-     */
-    stipEnd = stip + stipStride * stipHeight;
-    modulus(-yRot, stipHeight, stipY);
-    s = stip + stipStride * stipY;
-    modulus(-xRot, FB_UNIT, stipX);
-    rot = stipX;
-
-    /*
-     * Get pointer to stipple mask array for this depth
-     */
-    /* fbStippleTable covers all valid bpp (4,8,16,32) */
-    fbBits = fbStippleTable[pixelsPerDst];
-
-    while (height--) {
-        /*
-         * Extract stipple bits for this scanline;
-         */
-        bits = READ(s);
-        s += stipStride;
-        if (s == stipEnd)
-            s = stip;
-        mask = fbBits[FbLeftStipBits(bits, pixelsPerDst)];
-        /*
-         * Rotate into position and compute reduced rop values
-         */
-        mask = FbRotLeft(mask, rot);
-        and = (fgand & mask) | (bgand & ~mask);
-        xor = (fgxor & mask) | (bgxor & ~mask);
-
-        if (transparent) {
-            if (startmask) {
-                fbTransparentSpan(dst, mask & startmask, fgxor, 1);
-                dst++;
-            }
-            fbTransparentSpan(dst, mask, fgxor, nmiddle);
-            dst += nmiddle;
-            if (endmask)
-                fbTransparentSpan(dst, mask & endmask, fgxor, 1);
-        }
-        else {
-            /*
-             * Fill scanline
-             */
-            if (startmask) {
-                FbDoLeftMaskByteRRop(dst, startbyte, startmask, and, xor);
-                dst++;
-            }
-            n = nmiddle;
-            if (!and)
-                while (n--)
-                    WRITE(dst++, xor);
-            else {
-                while (n--) {
-                    WRITE(dst, FbDoRRop(READ(dst), and, xor));
-                    dst++;
-                }
-            }
-            if (endmask)
-                FbDoRightMaskByteRRop(dst, endbyte, endmask, and, xor);
-        }
-        dst += dstStride;
-    }
-}
-
-void
-fbOddStipple(FbBits * dst,
-             FbStride dstStride,
-             int dstX,
-             int dstBpp,
-             int width,
-             int height,
-             FbStip * stip,
-             FbStride stipStride,
-             int stipWidth,
-             int stipHeight,
-             FbBits fgand,
-             FbBits fgxor, FbBits bgand, FbBits bgxor, int xRot, int yRot)
-{
-    int stipX, stipY, sx;
-    int widthTmp;
-    int h, w;
-    int x, y;
-
-    modulus(-yRot, stipHeight, stipY);
-    modulus(dstX / dstBpp - xRot, stipWidth, stipX);
-    y = 0;
-    while (height) {
-        h = stipHeight - stipY;
-        if (h > height)
-            h = height;
-        height -= h;
-        widthTmp = width;
-        x = dstX;
-        sx = stipX;
-        while (widthTmp) {
-            w = (stipWidth - sx) * dstBpp;
-            if (w > widthTmp)
-                w = widthTmp;
-            widthTmp -= w;
-            fbBltOne(stip + stipY * stipStride,
-                     stipStride,
-                     sx,
-                     dst + y * dstStride,
-                     dstStride, x, dstBpp, w, h, fgand, fgxor, bgand, bgxor);
-            x += w;
-            sx = 0;
-        }
-        y += h;
-        stipY = 0;
-    }
-}
-
-void
-fbStipple(FbBits * dst,
-          FbStride dstStride,
-          int dstX,
-          int dstBpp,
-          int width,
-          int height,
-          FbStip * stip,
-          FbStride stipStride,
-          int stipWidth,
-          int stipHeight,
-          Bool even,
-          FbBits fgand,
-          FbBits fgxor, FbBits bgand, FbBits bgxor, int xRot, int yRot)
-{
-    if (even)
-        fbEvenStipple(dst, dstStride, dstX, dstBpp, width, height,
-                      stip, stipStride, stipHeight,
-                      fgand, fgxor, bgand, bgxor, xRot, yRot);
-    else
-        fbOddStipple(dst, dstStride, dstX, dstBpp, width, height,
-                     stip, stipStride, stipWidth, stipHeight,
-                     fgand, fgxor, bgand, bgxor, xRot, yRot);
-}
diff --git a/fb/wfbrename.h b/fb/wfbrename.h
index a80858a..0bd233e 100644
--- a/fb/wfbrename.h
+++ b/fb/wfbrename.h
@@ -58,7 +58,6 @@
 #define fbDots24 wfbDots24
 #define fbDots32 wfbDots32
 #define fbDots8 wfbDots8
-#define fbEvenStipple wfbEvenStipple
 #define fbEvenTile wfbEvenTile
 #define fbExpandDirectColors wfbExpandDirectColors
 #define fbFill wfbFill
@@ -84,7 +83,6 @@
 #define fbInitVisuals wfbInitVisuals
 #define fbListInstalledColormaps wfbListInstalledColormaps
 #define FbMergeRopBits wFbMergeRopBits
-#define fbOddStipple wfbOddStipple
 #define fbOddTile wfbOddTile
 #define fbOver wfbOver
 #define fbOver24 wfbOver24
@@ -143,7 +141,6 @@
 #define fbSolid wfbSolid
 #define fbSolid24 wfbSolid24
 #define fbSolidBoxClipped wfbSolidBoxClipped
-#define fbStipple wfbStipple
 #define fbStipple1Bits wfbStipple1Bits
 #define fbStipple24Bits wfbStipple24Bits
 #define fbStipple2Bits wfbStipple2Bits
@@ -151,7 +148,6 @@
 #define fbStipple8Bits wfbStipple8Bits
 #define fbStippleTable wfbStippleTable
 #define fbTile wfbTile
-#define fbTransparentSpan wfbTransparentSpan
 #define fbTrapezoids wfbTrapezoids
 #define fbTriangles wfbTriangles
 #define fbUninstallColormap wfbUninstallColormap
commit a1983736853814d34450c0a0de1c4f6ee308423d
Author: Adam Jackson <ajax at redhat.com>
Date:   Tue Jun 17 11:24:06 2014 -0400

    fb: FB_SHIFT is 5 (and FB_UNIT is 32)
    
    The other paths don't build or work, PCI and other buses are almost
    always 32 bit data paths, and X doesn't really support pixels bigger
    than that anyway.
    
    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 d176bb3..6db5803 100644
--- a/fb/fb.h
+++ b/fb/fb.h
@@ -83,11 +83,7 @@
 #define FB_SHIFT    LOG2_BITMAP_PAD
 #endif
 
-#if FB_SHIFT < LOG2_BITMAP_PAD
-error FB_SHIFT must be >= LOG2_BITMAP_PAD
-#endif
 #define FB_UNIT	    (1 << FB_SHIFT)
-#define FB_HALFUNIT (1 << (FB_SHIFT-1))
 #define FB_MASK	    (FB_UNIT - 1)
 #define FB_ALLONES  ((FbBits) -1)
 #if GLYPHPADBYTES != 4
@@ -105,37 +101,15 @@ error FB_SHIFT must be >= LOG2_BITMAP_PAD
 #define FbStipStrideToBitsStride(s) (((s) >> (FB_SHIFT - FB_STIP_SHIFT)))
 #define FbBitsStrideToStipStride(s) (((s) << (FB_SHIFT - FB_STIP_SHIFT)))
 #define FbFullMask(n)   ((n) == FB_UNIT ? FB_ALLONES : ((((FbBits) 1) << n) - 1))
-#if FB_SHIFT == 6
-#ifdef WIN32
-typedef unsigned __int64 FbBits;
-#else
-#if defined(__alpha__) || defined(__alpha) || \
-      defined(ia64) || defined(__ia64__) || \
-      defined(__sparc64__) || defined(_LP64) || \
-      defined(__s390x__) || \
-      defined(amd64) || defined (__amd64__) || \
-      defined (__powerpc64__)
-typedef unsigned long FbBits;
-#else
-typedef unsigned long long FbBits;
-#endif
-#endif
-#endif
 
 #if FB_SHIFT == 5
 typedef CARD32 FbBits;
-#endif
-
-#if FB_SHIFT == 4
-typedef CARD16 FbBits;
+#else
+#error "Unsupported FB_SHIFT"
 #endif
 
 #if LOG2_BITMAP_PAD == FB_SHIFT
 typedef FbBits FbStip;
-#else
-#if LOG2_BITMAP_PAD == 5
-typedef CARD32 FbStip;
-#endif
 #endif
 
 typedef int FbStride;
@@ -264,122 +238,8 @@ extern _X_EXPORT void fbSetBits(FbStip * bits, int stride, FbStip data);
     n >>= FB_SHIFT; \
 }
 
-#if FB_SHIFT == 6
-#define FbDoLeftMaskByteRRop6Cases(dst,xor) \
-    case (sizeof (FbBits) - 7) | (1 << (FB_SHIFT - 3)): \
-	FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \
-	break; \
-    case (sizeof (FbBits) - 7) | (2 << (FB_SHIFT - 3)): \
-	FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \
-	FbStorePart(dst,sizeof (FbBits) - 6,CARD8,xor); \
-	break; \
-    case (sizeof (FbBits) - 7) | (3 << (FB_SHIFT - 3)): \
-	FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \
-	FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
-	break; \
-    case (sizeof (FbBits) - 7) | (4 << (FB_SHIFT - 3)): \
-	FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \
-	FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
-	FbStorePart(dst,sizeof (FbBits) - 4,CARD8,xor); \
-	break; \
-    case (sizeof (FbBits) - 7) | (5 << (FB_SHIFT - 3)): \
-	FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \
-	FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
-	FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
-	break; \
-    case (sizeof (FbBits) - 7) | (6 << (FB_SHIFT - 3)): \
-	FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \
-	FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
-	FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
-	FbStorePart(dst,sizeof (FbBits) - 2,CARD8,xor); \
-	break; \
-    case (sizeof (FbBits) - 7): \
-	FbStorePart(dst,sizeof (FbBits) - 7,CARD8,xor); \
-	FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
-	FbStorePart(dst,sizeof (FbBits) - 4,CARD32,xor); \
-	break; \
-    case (sizeof (FbBits) - 6) | (1 << (FB_SHIFT - 3)): \
-	FbStorePart(dst,sizeof (FbBits) - 6,CARD8,xor); \
-	break; \
-    case (sizeof (FbBits) - 6) | (2 << (FB_SHIFT - 3)): \
-	FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
-	break; \
-    case (sizeof (FbBits) - 6) | (3 << (FB_SHIFT - 3)): \
-	FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
-	FbStorePart(dst,sizeof (FbBits) - 4,CARD8,xor); \
-	break; \
-    case (sizeof (FbBits) - 6) | (4 << (FB_SHIFT - 3)): \
-	FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
-	FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
-	break; \
-    case (sizeof (FbBits) - 6) | (5 << (FB_SHIFT - 3)): \
-	FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
-	FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
-	FbStorePart(dst,sizeof (FbBits) - 2,CARD8,xor); \
-	break; \
-    case (sizeof (FbBits) - 6): \
-	FbStorePart(dst,sizeof (FbBits) - 6,CARD16,xor); \
-	FbStorePart(dst,sizeof (FbBits) - 4,CARD32,xor); \
-	break; \
-    case (sizeof (FbBits) - 5) | (1 << (FB_SHIFT - 3)): \
-	FbStorePart(dst,sizeof (FbBits) - 5,CARD8,xor); \
-	break; \
-    case (sizeof (FbBits) - 5) | (2 << (FB_SHIFT - 3)): \
-	FbStorePart(dst,sizeof (FbBits) - 5,CARD8,xor); \
-	FbStorePart(dst,sizeof (FbBits) - 4,CARD8,xor); \
-	break; \
-    case (sizeof (FbBits) - 5) | (3 << (FB_SHIFT - 3)): \
-	FbStorePart(dst,sizeof (FbBits) - 5,CARD8,xor); \
-	FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
-	break; \
-    case (sizeof (FbBits) - 5) | (4 << (FB_SHIFT - 3)): \
-	FbStorePart(dst,sizeof (FbBits) - 5,CARD8,xor); \
-	FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
-	FbStorePart(dst,sizeof (FbBits) - 2,CARD8,xor); \
-	break; \
-    case (sizeof (FbBits) - 5): \
-	FbStorePart(dst,sizeof (FbBits) - 5,CARD8,xor); \
-	FbStorePart(dst,sizeof (FbBits) - 4,CARD32,xor); \
-	break; \
-    case (sizeof (FbBits) - 4) | (1 << (FB_SHIFT - 3)): \
-	FbStorePart(dst,sizeof (FbBits) - 4,CARD8,xor); \
-	break; \
-    case (sizeof (FbBits) - 4) | (2 << (FB_SHIFT - 3)): \
-	FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
-	break; \
-    case (sizeof (FbBits) - 4) | (3 << (FB_SHIFT - 3)): \
-	FbStorePart(dst,sizeof (FbBits) - 4,CARD16,xor); \
-	FbStorePart(dst,sizeof (FbBits) - 2,CARD8,xor); \
-	break; \
-    case (sizeof (FbBits) - 4): \
-	FbStorePart(dst,sizeof (FbBits) - 4,CARD32,xor); \
-	break;
-
-#define FbDoRightMaskByteRRop6Cases(dst,xor) \
-    case 4: \
-	FbStorePart(dst,0,CARD32,xor); \
-	break; \
-    case 5: \
-	FbStorePart(dst,0,CARD32,xor); \
-	FbStorePart(dst,4,CARD8,xor); \
-	break; \
-    case 6: \
-	FbStorePart(dst,0,CARD32,xor); \
-	FbStorePart(dst,4,CARD16,xor); \
-	break; \
-    case 7: \
-	FbStorePart(dst,0,CARD32,xor); \
-	FbStorePart(dst,4,CARD16,xor); \
-	FbStorePart(dst,6,CARD8,xor); \
-	break;
-#else
-#define FbDoLeftMaskByteRRop6Cases(dst,xor)
-#define FbDoRightMaskByteRRop6Cases(dst,xor)
-#endif
-
 #define FbDoLeftMaskByteRRop(dst,lb,l,and,xor) { \
     switch (lb) { \
-    FbDoLeftMaskByteRRop6Cases(dst,xor) \
     case (sizeof (FbBits) - 3) | (1 << (FB_SHIFT - 3)): \
 	FbStorePart(dst,sizeof (FbBits) - 3,CARD8,xor); \
 	break; \
@@ -416,7 +276,6 @@ extern _X_EXPORT void fbSetBits(FbStip * bits, int stride, FbStip data);
 	FbStorePart(dst,0,CARD16,xor); \
 	FbStorePart(dst,2,CARD8,xor); \
 	break; \
-    FbDoRightMaskByteRRop6Cases(dst,xor) \
     default: \
 	WRITE(dst, FbDoMaskRRop (READ(dst), and, xor, r)); \
     } \
@@ -470,21 +329,7 @@ extern _X_EXPORT void fbSetBits(FbStip * bits, int stride, FbStip data);
 	FbLaneCase2((n)>>2,a,(o)+2)					\
     }
 
-#define FbLaneCase8(n,a,o)						\
-    if ((n) == 0x0ff) {							\
-	*(FbBits *) ((a)+(o)) = fgxor;					\
-    } else {								\
-	FbLaneCase4((n)&15,a,o)						\
-	FbLaneCase4((n)>>4,a,(o)+4)					\
-    }
-
-#if FB_SHIFT == 6
-#define FbLaneCase(n,a)   FbLaneCase8(n,(CARD8 *) (a),0)
-#endif
-
-#if FB_SHIFT == 5
 #define FbLaneCase(n,a)   FbLaneCase4(n,(CARD8 *) (a),0)
-#endif
 
 /* Rotate a filled pixel value to the specified alignement */
 #define FbRot24(p,b)	    (FbScrRight(p,b) | FbScrLeft(p,24-(b)))
@@ -497,19 +342,6 @@ extern _X_EXPORT void fbSetBits(FbStip * bits, int stride, FbStip data);
 #define FbPrev24Stip(p)	(FbRot24(p,FB_STIP_UNIT%24))
 
 /* step a rotation value to the next/previous rotation value */
-#if FB_UNIT == 64
-#define FbNext24Rot(r)        ((r) == 16 ? 0 : (r) + 8)
-#define FbPrev24Rot(r)        ((r) == 0 ? 16 : (r) - 8)
-
-#if IMAGE_BYTE_ORDER == MSBFirst
-#define FbFirst24Rot(x)		(((x) + 8) % 24)
-#else
-#define FbFirst24Rot(x)		((x) % 24)
-#endif
-
-#endif
-
-#if FB_UNIT == 32
 #define FbNext24Rot(r)        ((r) == 0 ? 16 : (r) - 8)
 #define FbPrev24Rot(r)        ((r) == 16 ? 0 : (r) + 8)
 
@@ -518,7 +350,6 @@ extern _X_EXPORT void fbSetBits(FbStip * bits, int stride, FbStip data);
 #else
 #define FbFirst24Rot(x)		((x) % 24)
 #endif
-#endif
 
 #define FbNext24RotStip(r)        ((r) == 0 ? 16 : (r) - 8)
 #define FbPrev24RotStip(r)        ((r) == 16 ? 0 : (r) + 8)
diff --git a/fb/fbbits.c b/fb/fbbits.c
index ac44f3e..d7d089c 100644
--- a/fb/fbbits.c
+++ b/fb/fbbits.c
@@ -70,9 +70,6 @@
 #define POLYSEGMENT fbPolySegment16
 #define BITS	    CARD16
 #define BITS2	    CARD32
-#if FB_SHIFT == 6
-#define BITS4	    FbBits
-#endif
 
 #include "fbbits.h"
 
@@ -85,9 +82,6 @@
 #undef POLYSEGMENT
 #undef BITS
 #undef BITS2
-#if FB_SHIFT == 6
-#undef BITS4
-#endif
 
 #define BRESSOLID   fbBresSolid24
 #define BRESDASH    fbBresDash24
@@ -155,9 +149,6 @@
 #define POLYLINE    fbPolyline32
 #define POLYSEGMENT fbPolySegment32
 #define BITS	    CARD32
-#if FB_SHIFT == 6
-#define BITS2	    FbBits
-#endif
 
 #include "fbbits.h"
 
@@ -169,6 +160,3 @@
 #undef POLYLINE
 #undef POLYSEGMENT
 #undef BITS
-#if FB_SHIFT == 6
-#undef BITS2
-#endif
diff --git a/fb/fbblt.c b/fb/fbblt.c
index c615106..b412365 100644
--- a/fb/fbblt.c
+++ b/fb/fbblt.c
@@ -520,277 +520,12 @@ fbBlt24(FbBits * srcLine,
 #endif
 }
 
-#if FB_SHIFT == FB_STIP_SHIFT + 1
-
-/*
- * Could be generalized to FB_SHIFT > FB_STIP_SHIFT + 1 by
- * creating an ring of values stepped through for each line
- */
-
-void
-fbBltOdd(FbBits * srcLine,
-         FbStride srcStrideEven,
-         FbStride srcStrideOdd,
-         int srcXEven,
-         int srcXOdd,
-         FbBits * dstLine,
-         FbStride dstStrideEven,
-         FbStride dstStrideOdd,
-         int dstXEven,
-         int dstXOdd, int width, int height, int alu, FbBits pm, int bpp)
-{
-    FbBits *src;
-    int leftShiftEven, rightShiftEven;
-    FbBits startmaskEven, endmaskEven;
-    int nmiddleEven;
-
-    FbBits *dst;
-    int leftShiftOdd, rightShiftOdd;
-    FbBits startmaskOdd, endmaskOdd;
-    int nmiddleOdd;
-
-    int leftShift, rightShift;
-    FbBits startmask, endmask;
-    int nmiddle;
-
-    int srcX, dstX;
-
-    FbBits bits, bits1;
-    int n;
-
-    Bool destInvarient;
-    Bool even;
-
-    FbDeclareMergeRop();
-
-    FbInitializeMergeRop(alu, pm);
-    destInvarient = FbDestInvarientMergeRop();
-
-    srcLine += srcXEven >> FB_SHIFT;
-    dstLine += dstXEven >> FB_SHIFT;
-    srcXEven &= FB_MASK;
-    dstXEven &= FB_MASK;
-    srcXOdd &= FB_MASK;
-    dstXOdd &= FB_MASK;
-
-    FbMaskBits(dstXEven, width, startmaskEven, nmiddleEven, endmaskEven);
-    FbMaskBits(dstXOdd, width, startmaskOdd, nmiddleOdd, endmaskOdd);
-
-    even = TRUE;
-    InitializeShifts(srcXEven, dstXEven, leftShiftEven, rightShiftEven);
-    InitializeShifts(srcXOdd, dstXOdd, leftShiftOdd, rightShiftOdd);
-    while (height--) {
-        src = srcLine;
-        dst = dstLine;
-        if (even) {
-            srcX = srcXEven;
-            dstX = dstXEven;
-            startmask = startmaskEven;
-            endmask = endmaskEven;
-            nmiddle = nmiddleEven;
-            leftShift = leftShiftEven;
-            rightShift = rightShiftEven;
-            srcLine += srcStrideEven;
-            dstLine += dstStrideEven;
-            even = FALSE;
-        }
-        else {
-            srcX = srcXOdd;
-            dstX = dstXOdd;
-            startmask = startmaskOdd;
-            endmask = endmaskOdd;
-            nmiddle = nmiddleOdd;
-            leftShift = leftShiftOdd;
-            rightShift = rightShiftOdd;
-            srcLine += srcStrideOdd;
-            dstLine += dstStrideOdd;
-            even = TRUE;
-        }
-        if (srcX == dstX) {
-            if (startmask) {
-                bits = READ(src++);
-                WRITE(dst, FbDoMaskMergeRop(bits, READ(dst), startmask));
-                dst++;
-            }
-            n = nmiddle;
-            if (destInvarient) {
-                while (n--) {
-                    bits = READ(src++);
-                    WRITE(dst, FbDoDestInvarientMergeRop(bits));
-                    dst++;
-                }
-            }
-            else {
-                while (n--) {
-                    bits = READ(src++);
-                    WRITE(dst, FbDoMergeRop(bits, READ(dst)));
-                    dst++;
-                }
-            }
-            if (endmask) {
-                bits = READ(src);
-                WRITE(dst, FbDoMaskMergeRop(bits, READ(dst), endmask));
-            }
-        }
-        else {
-            bits = 0;
-            if (srcX > dstX)
-                bits = READ(src++);
-            if (startmask) {
-                bits1 = FbScrLeft(bits, leftShift);
-                bits = READ(src++);
-                bits1 |= FbScrRight(bits, rightShift);
-                WRITE(dst, FbDoMaskMergeRop(bits1, READ(dst), startmask));
-                dst++;
-            }
-            n = nmiddle;
-            if (destInvarient) {
-                while (n--) {
-                    bits1 = FbScrLeft(bits, leftShift);
-                    bits = READ(src++);
-                    bits1 |= FbScrRight(bits, rightShift);
-                    WRITE(dst, FbDoDestInvarientMergeRop(bits1));
-                    dst++;
-                }
-            }
-            else {
-                while (n--) {
-                    bits1 = FbScrLeft(bits, leftShift);
-                    bits = READ(src++);
-                    bits1 |= FbScrRight(bits, rightShift);
-                    WRITE(dst, FbDoMergeRop(bits1, READ(dst)));
-                    dst++;
-                }
-            }
-            if (endmask) {
-                bits1 = FbScrLeft(bits, leftShift);
-                if (FbScrLeft(endmask, rightShift)) {
-                    bits = READ(src);
-                    bits1 |= FbScrRight(bits, rightShift);
-                }
-                WRITE(dst, FbDoMaskMergeRop(bits1, READ(dst), endmask));
-            }
-        }
-    }
-}
-
-void
-fbBltOdd24(FbBits * srcLine,
-           FbStride srcStrideEven,
-           FbStride srcStrideOdd,
-           int srcXEven,
-           int srcXOdd,
-           FbBits * dstLine,
-           FbStride dstStrideEven,
-           FbStride dstStrideOdd,
-           int dstXEven, int dstXOdd, int width, int height, int alu, FbBits pm)
-{
-    Bool even = TRUE;
-
-    while (height--) {
-        if (even) {
-            fbBlt24Line(srcLine, srcXEven, dstLine, dstXEven,
-                        width, alu, pm, FALSE);
-            srcLine += srcStrideEven;
-            dstLine += dstStrideEven;
-            even = FALSE;
-        }
-        else {
-            fbBlt24Line(srcLine, srcXOdd, dstLine, dstXOdd,
-                        width, alu, pm, FALSE);
-            srcLine += srcStrideOdd;
-            dstLine += dstStrideOdd;
-            even = TRUE;
-        }
-    }
-}
-
-#endif
-
-#if FB_STIP_SHIFT != FB_SHIFT
-void
-fbSetBltOdd(FbStip * stip,
-            FbStride stipStride,
-            int srcX,
-            FbBits ** bits,
-            FbStride * strideEven,
-            FbStride * strideOdd, int *srcXEven, int *srcXOdd)
-{
-    int srcAdjust;
-    int strideAdjust;
-
-    /*
-     * bytes needed to align source
-     */
-    srcAdjust = (((int) stip) & (FB_MASK >> 3));
-    /*
-     * FbStip units needed to align stride
-     */
-    strideAdjust = stipStride & (FB_MASK >> FB_STIP_SHIFT);
-
-    *bits = (FbBits *) ((char *) stip - srcAdjust);
-    if (srcAdjust) {
-        *strideEven = FbStipStrideToBitsStride(stipStride + 1);
-        *strideOdd = FbStipStrideToBitsStride(stipStride);
-
-        *srcXEven = srcX + (srcAdjust << 3);
-        *srcXOdd = srcX + (srcAdjust << 3) - (strideAdjust << FB_STIP_SHIFT);
-    }
-    else {
-        *strideEven = FbStipStrideToBitsStride(stipStride);
-        *strideOdd = FbStipStrideToBitsStride(stipStride + 1);
-
-        *srcXEven = srcX;
-        *srcXOdd = srcX + (strideAdjust << FB_STIP_SHIFT);
-    }
-}
-#endif
-
 void
 fbBltStip(FbStip * src, FbStride srcStride,     /* in FbStip units, not FbBits units */
           int srcX, FbStip * dst, FbStride dstStride,   /* in FbStip units, not FbBits units */
           int dstX, int width, int height, int alu, FbBits pm, int bpp)
 {
-#if FB_STIP_SHIFT != FB_SHIFT
-    if (FB_STIP_ODDSTRIDE(srcStride) || FB_STIP_ODDPTR(src) ||
-        FB_STIP_ODDSTRIDE(dstStride) || FB_STIP_ODDPTR(dst)) {
-        FbStride srcStrideEven, srcStrideOdd;
-        FbStride dstStrideEven, dstStrideOdd;
-        int srcXEven, srcXOdd;
-        int dstXEven, dstXOdd;
-        FbBits *s, *d;
-        int sx, dx;
-
-        src += srcX >> FB_STIP_SHIFT;
-        srcX &= FB_STIP_MASK;
-        dst += dstX >> FB_STIP_SHIFT;
-        dstX &= FB_STIP_MASK;
-
-        fbSetBltOdd(src, srcStride, srcX,
-                    &s, &srcStrideEven, &srcStrideOdd, &srcXEven, &srcXOdd);
-
-        fbSetBltOdd(dst, dstStride, dstX,
-                    &d, &dstStrideEven, &dstStrideOdd, &dstXEven, &dstXOdd);
-
-        if (bpp == 24 && !FbCheck24Pix(pm)) {
-            fbBltOdd24(s, srcStrideEven, srcStrideOdd,
-                       srcXEven, srcXOdd,
-                       d, dstStrideEven, dstStrideOdd,
-                       dstXEven, dstXOdd, width, height, alu, pm);
-        }
-        else {
-            fbBltOdd(s, srcStrideEven, srcStrideOdd,
-                     srcXEven, srcXOdd,
-                     d, dstStrideEven, dstStrideOdd,
-                     dstXEven, dstXOdd, width, height, alu, pm, bpp);
-        }
-    }
-    else
-#endif
-    {
-        fbBlt((FbBits *) src, FbStipStrideToBitsStride(srcStride),
-              srcX,
-              (FbBits *) dst, FbStipStrideToBitsStride(dstStride),
-              dstX, width, height, alu, pm, bpp, FALSE, FALSE);
-    }
+    fbBlt((FbBits *) src, FbStipStrideToBitsStride(srcStride), srcX,
+          (FbBits *) dst, FbStipStrideToBitsStride(dstStride), dstX,
+          width, height, alu, pm, bpp, FALSE, FALSE);
 }
diff --git a/fb/fbbltone.c b/fb/fbbltone.c
index d2f0416..3042c4b 100644
--- a/fb/fbbltone.c
+++ b/fb/fbbltone.c
@@ -67,59 +67,9 @@
 #define LaneCases4(n,a)	    LaneCases2(n,a); LaneCases2(n+2,a)
 #define LaneCases8(n,a)	    LaneCases4(n,a); LaneCases4(n+4,a)
 #define LaneCases16(n,a)    LaneCases8(n,a); LaneCases8(n+8,a)
-#define LaneCases32(n,a)    LaneCases16(n,a); LaneCases16(n+16,a)
-#define LaneCases64(n,a)    LaneCases32(n,a); LaneCases32(n+32,a)
-#define LaneCases128(n,a)   LaneCases64(n,a); LaneCases64(n+64,a)
-#define LaneCases256(n,a)   LaneCases128(n,a); LaneCases128(n+128,a)
 
-#if FB_SHIFT == 6
-#define LaneCases(a)	    LaneCases256(0,a)
-#endif
-
-#if FB_SHIFT == 5
 #define LaneCases(a)	    LaneCases16(0,a)
-#endif
-
-#if FB_SHIFT == 6
-static const CARD8 fb8Lane[256] = {
-    0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
-        21,
-    22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
-    41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
-    60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
-    79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97,
-    98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112,
-        113, 114, 115,
-    116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130,
-        131, 132, 133,
-    134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148,
-        149, 150, 151,
-    152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166,
-        167, 168, 169,
-    170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184,
-        185, 186, 187,
-    188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202,
-        203, 204, 205,
-    206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220,
-        221, 222, 223,
-    224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238,
-        239, 240, 241,
-    242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255,
-};
-
-static const CARD8 fb16Lane[256] = {
-    0x00, 0x03, 0x0c, 0x0f,
-    0x30, 0x33, 0x3c, 0x3f,
-    0xc0, 0xc3, 0xcc, 0xcf,
-    0xf0, 0xf3, 0xfc, 0xff,
-};
-
-static const CARD8 fb32Lane[16] = {
-    0x00, 0x0f, 0xf0, 0xff,
-};
-#endif
 
-#if FB_SHIFT == 5
 static const CARD8 fb8Lane[16] = {
     0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
 };
@@ -131,7 +81,6 @@ static const CARD8 fb16Lane[16] = {
 static const CARD8 fb32Lane[16] = {
     0, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 };
-#endif
 
 void
 fbBltOne(FbStip * src, FbStride srcStride,      /* FbStip units per scanline */
@@ -285,12 +234,7 @@ fbBltOne(FbStip * src, FbStride srcStride,      /* FbStip units per scanline */
              * Consume stipple bits for startmask
              */
             if (startmask) {
-#if FB_UNIT > 32
-                if (pixelsPerDst == 16)
-                    mask = FbStipple16Bits(FbLeftStipBits(bits, 16));
-                else
-#endif
-                    mask = fbBits[FbLeftStipBits(bits, pixelsPerDst)];
+                mask = fbBits[FbLeftStipBits(bits, pixelsPerDst)];
                 if (fbLane) {
                     fbTransparentSpan(dst, mask & startmask, fgxor, 1);
                 }
@@ -312,12 +256,7 @@ fbBltOne(FbStip * src, FbStride srcStride,      /* FbStip units per scanline */
                 w -= n;
                 if (copy) {
                     while (n--) {
-#if FB_UNIT > 32
-                        if (pixelsPerDst == 16)
-                            mask = FbStipple16Bits(FbLeftStipBits(bits, 16));
-                        else
-#endif
-                            mask = fbBits[FbLeftStipBits(bits, pixelsPerDst)];
+                        mask = fbBits[FbLeftStipBits(bits, pixelsPerDst)];
                         WRITE(dst, FbOpaqueStipple(mask, fgxor, bgxor));
                         dst++;
                         bits = FbStipLeft(bits, pixelsPerDst);
@@ -367,12 +306,7 @@ fbBltOne(FbStip * src, FbStride srcStride,      /* FbStip units per scanline */
             if (endNeedsLoad) {
                 LoadBits;
             }
-#if FB_UNIT > 32
-            if (pixelsPerDst == 16)
-                mask = FbStipple16Bits(FbLeftStipBits(bits, 16));
-            else
-#endif
-                mask = fbBits[FbLeftStipBits(bits, pixelsPerDst)];
+            mask = fbBits[FbLeftStipBits(bits, pixelsPerDst)];
             if (fbLane) {
                 fbTransparentSpan(dst, mask & endmask, fgxor, 1);
             }
@@ -410,47 +344,6 @@ fbBltOne(FbStip * src, FbStride srcStride,      /* FbStip units per scanline */
 
 #define SelMask24(b,n,r)	((((b) >> n) & 1) * Mask24(n,r))
 
-/*
- * Untested for MSBFirst or FB_UNIT == 32
- */
-
-#if FB_UNIT == 64
-#define C4_24(b,r) \
-    (SelMask24(b,0,r) | \
-     SelMask24(b,1,r) | \
-     SelMask24(b,2,r) | \
-     SelMask24(b,3,r))
-
-#define FbStip24New(rot)    (2 + (rot != 0))
-#define FbStip24Len	    4
-
-const FbBits fbStipple24Bits[3][1 << FbStip24Len] = {
-    /* rotate 0 */
-    {
-     C4_24(0, 0), C4_24(1, 0), C4_24(2, 0), C4_24(3, 0),
-     C4_24(4, 0), C4_24(5, 0), C4_24(6, 0), C4_24(7, 0),
-     C4_24(8, 0), C4_24(9, 0), C4_24(10, 0), C4_24(11, 0),
-     C4_24(12, 0), C4_24(13, 0), C4_24(14, 0), C4_24(15, 0),
-     },
-    /* rotate 8 */
-    {
-     C4_24(0, 8), C4_24(1, 8), C4_24(2, 8), C4_24(3, 8),
-     C4_24(4, 8), C4_24(5, 8), C4_24(6, 8), C4_24(7, 8),
-     C4_24(8, 8), C4_24(9, 8), C4_24(10, 8), C4_24(11, 8),
-     C4_24(12, 8), C4_24(13, 8), C4_24(14, 8), C4_24(15, 8),
-     },
-    /* rotate 16 */
-    {
-     C4_24(0, 16), C4_24(1, 16), C4_24(2, 16), C4_24(3, 16),
-     C4_24(4, 16), C4_24(5, 16), C4_24(6, 16), C4_24(7, 16),
-     C4_24(8, 16), C4_24(9, 16), C4_24(10, 16), C4_24(11, 16),
-     C4_24(12, 16), C4_24(13, 16), C4_24(14, 16), C4_24(15, 16),
-     }
-};
-
-#endif
-
-#if FB_UNIT == 32
 #define C2_24(b,r)  \
     (SelMask24(b,0,r) | \
      SelMask24(b,1,r))
@@ -476,7 +369,6 @@ const FbBits fbStipple24Bits[3][1 << FbStip24Len] = {
      C2_24(0, 16), C2_24(1, 16), C2_24(2, 16), C2_24(3, 16),
      }
 };
-#endif
 
 #if BITMAP_BIT_ORDER == LSBFirst
 
diff --git a/fb/fbglyph.c b/fb/fbglyph.c
index 4f2904c..8484782 100644
--- a/fb/fbglyph.c
+++ b/fb/fbglyph.c
@@ -56,11 +56,7 @@ fbGlyphIn(RegionPtr pRegion, int x, int y, int width, int height)
 #define WRITE1(d,n,fg)	WRITE((d) + (n), (CARD8) fg)
 #define WRITE2(d,n,fg)	WRITE((CARD16 *) &(d[n]), (CARD16) fg)
 #define WRITE4(d,n,fg)	WRITE((CARD32 *) &(d[n]), (CARD32) fg)
-#if FB_UNIT == 6 && IMAGE_BYTE_ORDER == LSBFirst
-#define WRITE8(d)	WRITE((FbBits *) &(d[0]), fg)
-#else
 #define WRITE8(d)	WRITE4(d,0,_ABCA), WRITE4(d,4,_BCAB)
-#endif
 
 /*
  * This is a bit tricky, but it's brief.  Write 12 bytes worth
diff --git a/fb/fbpict.c b/fb/fbpict.c
index f9c9917..7a9e46a 100644
--- a/fb/fbpict.c
+++ b/fb/fbpict.c
@@ -309,17 +309,9 @@ create_bits_picture(PicturePtr pict, Bool has_clip, int *xoff, int *yoff)
         return NULL;
 
 #ifdef FB_ACCESS_WRAPPER
-#if FB_SHIFT==5
-
     pixman_image_set_accessors(image,
                                (pixman_read_memory_func_t) wfbReadMemory,
                                (pixman_write_memory_func_t) wfbWriteMemory);
-
-#else
-
-#error The pixman library only works when FbBits is 32 bits wide
-
-#endif
 #endif
 
     /* pCompositeClip is undefined for source pictures, so
diff --git a/fb/fbrop.h b/fb/fbrop.h
index 4362adb..b995f23 100644
--- a/fb/fbrop.h
+++ b/fb/fbrop.h
@@ -95,10 +95,6 @@ extern _X_EXPORT const FbMergeRopRec FbMergeRopBits[16];
  * Stippling operations; 
  */
 
-extern _X_EXPORT const FbBits fbStipple16Bits[256];     /* half of table */
-
-#define FbStipple16Bits(b) \
-    (fbStipple16Bits[(b)&0xff] | fbStipple16Bits[(b) >> 8] << FB_HALFUNIT)
 extern _X_EXPORT const FbBits fbStipple8Bits[256];
 extern _X_EXPORT const FbBits fbStipple4Bits[16];
 extern _X_EXPORT const FbBits fbStipple2Bits[4];
diff --git a/fb/fbstipple.c b/fb/fbstipple.c
index f6c84a2..9a877c1 100644
--- a/fb/fbstipple.c
+++ b/fb/fbstipple.c
@@ -38,18 +38,8 @@
 #define LaneCases4(c,a)	    LaneCases2(c,a); LaneCases2(c+2,a)
 #define LaneCases8(c,a)	    LaneCases4(c,a); LaneCases4(c+4,a)
 #define LaneCases16(c,a)    LaneCases8(c,a); LaneCases8(c+8,a)
-#define LaneCases32(c,a)    LaneCases16(c,a); LaneCases16(c+16,a)
-#define LaneCases64(c,a)    LaneCases32(c,a); LaneCases32(c+32,a)
-#define LaneCases128(c,a)   LaneCases64(c,a); LaneCases64(c+64,a)
-#define LaneCases256(c,a)   LaneCases128(c,a); LaneCases128(c+128,a)
 
-#if FB_SHIFT == 6
-#define LaneCases(a)	    LaneCases256(0,a)
-#endif
-
-#if FB_SHIFT == 5
 #define LaneCases(a)	    LaneCases16(0,a)
-#endif
 
 /*
  * Repeat a transparent stipple across a scanline n times
@@ -64,12 +54,6 @@ fbTransparentSpan(FbBits * dst, FbBits stip, FbBits fgxor, int n)
     s |= ((FbStip) (stip >> 8) & 0x02);
     s |= ((FbStip) (stip >> 16) & 0x04);
     s |= ((FbStip) (stip >> 24) & 0x08);
-#if FB_SHIFT > 5
-    s |= ((FbStip) (stip >> 32) & 0x10);
-    s |= ((FbStip) (stip >> 40) & 0x20);
-    s |= ((FbStip) (stip >> 48) & 0x40);
-    s |= ((FbStip) (stip >> 56) & 0x80);
-#endif
     switch (s) {
         LaneCases(dst);
     }
@@ -142,12 +126,7 @@ fbEvenStipple(FbBits * dst,
         s += stipStride;
         if (s == stipEnd)
             s = stip;
-#if FB_UNIT > 32
-        if (pixelsPerDst == 16)
-            mask = FbStipple16Bits(FbLeftStipBits(bits, 16));
-        else
-#endif
-            mask = fbBits[FbLeftStipBits(bits, pixelsPerDst)];
+        mask = fbBits[FbLeftStipBits(bits, pixelsPerDst)];
         /*
          * Rotate into position and compute reduced rop values
          */
diff --git a/fb/fbutil.c b/fb/fbutil.c
index 2ca80d1..9d66c2a 100644
--- a/fb/fbutil.c
+++ b/fb/fbutil.c
@@ -174,24 +174,6 @@ const FbMergeRopRec FbMergeRopBits[16] = {
      SelMask(b,6,w) | \
      SelMask(b,7,w))
 
-#if FB_UNIT == 16
-#define fbStipple16Bits 0
-#define fbStipple8Bits 0
-const FbBits fbStipple4Bits[16] = {
-    C4(0, 4), C4(1, 4), C4(2, 4), C4(3, 4), C4(4, 4), C4(5, 4),
-    C4(6, 4), C4(7, 4), C4(8, 4), C4(9, 4), C4(10, 4), C4(11, 4),
-    C4(12, 4), C4(13, 4), C4(14, 4), C4(15, 4),
-};
-
-const FbBits fbStipple2Bits[4] = {
-    C2(0, 8), C2(1, 8), C2(2, 8), C2(3, 8),
-};
-
-const FbBits fbStipple1Bits[2] = {
-    C1(0, 16), C1(1, 16),
-};
-#endif
-#if FB_UNIT == 32
 #define fbStipple16Bits 0
 const FbBits fbStipple8Bits[256] = {
     C8(0, 4), C8(1, 4), C8(2, 4), C8(3, 4), C8(4, 4), C8(5, 4),
@@ -252,112 +234,7 @@ const FbBits fbStipple2Bits[4] = {
 const FbBits fbStipple1Bits[2] = {
     C1(0, 32), C1(1, 32),
 };
-#endif
-#if FB_UNIT == 64
-const FbBits fbStipple16Bits[256] = {
-    C8(0, 4), C8(1, 4), C8(2, 4), C8(3, 4), C8(4, 4), C8(5, 4),
-    C8(6, 4), C8(7, 4), C8(8, 4), C8(9, 4), C8(10, 4), C8(11, 4),
-    C8(12, 4), C8(13, 4), C8(14, 4), C8(15, 4), C8(16, 4), C8(17, 4),
-    C8(18, 4), C8(19, 4), C8(20, 4), C8(21, 4), C8(22, 4), C8(23, 4),
-    C8(24, 4), C8(25, 4), C8(26, 4), C8(27, 4), C8(28, 4), C8(29, 4),
-    C8(30, 4), C8(31, 4), C8(32, 4), C8(33, 4), C8(34, 4), C8(35, 4),
-    C8(36, 4), C8(37, 4), C8(38, 4), C8(39, 4), C8(40, 4), C8(41, 4),
-    C8(42, 4), C8(43, 4), C8(44, 4), C8(45, 4), C8(46, 4), C8(47, 4),
-    C8(48, 4), C8(49, 4), C8(50, 4), C8(51, 4), C8(52, 4), C8(53, 4),
-    C8(54, 4), C8(55, 4), C8(56, 4), C8(57, 4), C8(58, 4), C8(59, 4),
-    C8(60, 4), C8(61, 4), C8(62, 4), C8(63, 4), C8(64, 4), C8(65, 4),
-    C8(66, 4), C8(67, 4), C8(68, 4), C8(69, 4), C8(70, 4), C8(71, 4),
-    C8(72, 4), C8(73, 4), C8(74, 4), C8(75, 4), C8(76, 4), C8(77, 4),
-    C8(78, 4), C8(79, 4), C8(80, 4), C8(81, 4), C8(82, 4), C8(83, 4),
-    C8(84, 4), C8(85, 4), C8(86, 4), C8(87, 4), C8(88, 4), C8(89, 4),
-    C8(90, 4), C8(91, 4), C8(92, 4), C8(93, 4), C8(94, 4), C8(95, 4),
-    C8(96, 4), C8(97, 4), C8(98, 4), C8(99, 4), C8(100, 4), C8(101, 4),
-    C8(102, 4), C8(103, 4), C8(104, 4), C8(105, 4), C8(106, 4), C8(107, 4),
-    C8(108, 4), C8(109, 4), C8(110, 4), C8(111, 4), C8(112, 4), C8(113, 4),
-    C8(114, 4), C8(115, 4), C8(116, 4), C8(117, 4), C8(118, 4), C8(119, 4),
-    C8(120, 4), C8(121, 4), C8(122, 4), C8(123, 4), C8(124, 4), C8(125, 4),
-    C8(126, 4), C8(127, 4), C8(128, 4), C8(129, 4), C8(130, 4), C8(131, 4),
-    C8(132, 4), C8(133, 4), C8(134, 4), C8(135, 4), C8(136, 4), C8(137, 4),
-    C8(138, 4), C8(139, 4), C8(140, 4), C8(141, 4), C8(142, 4), C8(143, 4),
-    C8(144, 4), C8(145, 4), C8(146, 4), C8(147, 4), C8(148, 4), C8(149, 4),
-    C8(150, 4), C8(151, 4), C8(152, 4), C8(153, 4), C8(154, 4), C8(155, 4),
-    C8(156, 4), C8(157, 4), C8(158, 4), C8(159, 4), C8(160, 4), C8(161, 4),
-    C8(162, 4), C8(163, 4), C8(164, 4), C8(165, 4), C8(166, 4), C8(167, 4),
-    C8(168, 4), C8(169, 4), C8(170, 4), C8(171, 4), C8(172, 4), C8(173, 4),
-    C8(174, 4), C8(175, 4), C8(176, 4), C8(177, 4), C8(178, 4), C8(179, 4),
-    C8(180, 4), C8(181, 4), C8(182, 4), C8(183, 4), C8(184, 4), C8(185, 4),
-    C8(186, 4), C8(187, 4), C8(188, 4), C8(189, 4), C8(190, 4), C8(191, 4),
-    C8(192, 4), C8(193, 4), C8(194, 4), C8(195, 4), C8(196, 4), C8(197, 4),
-    C8(198, 4), C8(199, 4), C8(200, 4), C8(201, 4), C8(202, 4), C8(203, 4),
-    C8(204, 4), C8(205, 4), C8(206, 4), C8(207, 4), C8(208, 4), C8(209, 4),
-    C8(210, 4), C8(211, 4), C8(212, 4), C8(213, 4), C8(214, 4), C8(215, 4),
-    C8(216, 4), C8(217, 4), C8(218, 4), C8(219, 4), C8(220, 4), C8(221, 4),
-    C8(222, 4), C8(223, 4), C8(224, 4), C8(225, 4), C8(226, 4), C8(227, 4),
-    C8(228, 4), C8(229, 4), C8(230, 4), C8(231, 4), C8(232, 4), C8(233, 4),
-    C8(234, 4), C8(235, 4), C8(236, 4), C8(237, 4), C8(238, 4), C8(239, 4),
-    C8(240, 4), C8(241, 4), C8(242, 4), C8(243, 4), C8(244, 4), C8(245, 4),
-    C8(246, 4), C8(247, 4), C8(248, 4), C8(249, 4), C8(250, 4), C8(251, 4),
-    C8(252, 4), C8(253, 4), C8(254, 4), C8(255, 4),
-};
-
-const FbBits fbStipple8Bits[256] = {
-    C8(0, 8), C8(1, 8), C8(2, 8), C8(3, 8), C8(4, 8), C8(5, 8),
-    C8(6, 8), C8(7, 8), C8(8, 8), C8(9, 8), C8(10, 8), C8(11, 8),
-    C8(12, 8), C8(13, 8), C8(14, 8), C8(15, 8), C8(16, 8), C8(17, 8),
-    C8(18, 8), C8(19, 8), C8(20, 8), C8(21, 8), C8(22, 8), C8(23, 8),
-    C8(24, 8), C8(25, 8), C8(26, 8), C8(27, 8), C8(28, 8), C8(29, 8),
-    C8(30, 8), C8(31, 8), C8(32, 8), C8(33, 8), C8(34, 8), C8(35, 8),
-    C8(36, 8), C8(37, 8), C8(38, 8), C8(39, 8), C8(40, 8), C8(41, 8),
-    C8(42, 8), C8(43, 8), C8(44, 8), C8(45, 8), C8(46, 8), C8(47, 8),
-    C8(48, 8), C8(49, 8), C8(50, 8), C8(51, 8), C8(52, 8), C8(53, 8),
-    C8(54, 8), C8(55, 8), C8(56, 8), C8(57, 8), C8(58, 8), C8(59, 8),
-    C8(60, 8), C8(61, 8), C8(62, 8), C8(63, 8), C8(64, 8), C8(65, 8),
-    C8(66, 8), C8(67, 8), C8(68, 8), C8(69, 8), C8(70, 8), C8(71, 8),
-    C8(72, 8), C8(73, 8), C8(74, 8), C8(75, 8), C8(76, 8), C8(77, 8),
-    C8(78, 8), C8(79, 8), C8(80, 8), C8(81, 8), C8(82, 8), C8(83, 8),
-    C8(84, 8), C8(85, 8), C8(86, 8), C8(87, 8), C8(88, 8), C8(89, 8),
-    C8(90, 8), C8(91, 8), C8(92, 8), C8(93, 8), C8(94, 8), C8(95, 8),
-    C8(96, 8), C8(97, 8), C8(98, 8), C8(99, 8), C8(100, 8), C8(101, 8),
-    C8(102, 8), C8(103, 8), C8(104, 8), C8(105, 8), C8(106, 8), C8(107, 8),
-    C8(108, 8), C8(109, 8), C8(110, 8), C8(111, 8), C8(112, 8), C8(113, 8),
-    C8(114, 8), C8(115, 8), C8(116, 8), C8(117, 8), C8(118, 8), C8(119, 8),
-    C8(120, 8), C8(121, 8), C8(122, 8), C8(123, 8), C8(124, 8), C8(125, 8),
-    C8(126, 8), C8(127, 8), C8(128, 8), C8(129, 8), C8(130, 8), C8(131, 8),
-    C8(132, 8), C8(133, 8), C8(134, 8), C8(135, 8), C8(136, 8), C8(137, 8),
-    C8(138, 8), C8(139, 8), C8(140, 8), C8(141, 8), C8(142, 8), C8(143, 8),
-    C8(144, 8), C8(145, 8), C8(146, 8), C8(147, 8), C8(148, 8), C8(149, 8),
-    C8(150, 8), C8(151, 8), C8(152, 8), C8(153, 8), C8(154, 8), C8(155, 8),
-    C8(156, 8), C8(157, 8), C8(158, 8), C8(159, 8), C8(160, 8), C8(161, 8),
-    C8(162, 8), C8(163, 8), C8(164, 8), C8(165, 8), C8(166, 8), C8(167, 8),
-    C8(168, 8), C8(169, 8), C8(170, 8), C8(171, 8), C8(172, 8), C8(173, 8),
-    C8(174, 8), C8(175, 8), C8(176, 8), C8(177, 8), C8(178, 8), C8(179, 8),
-    C8(180, 8), C8(181, 8), C8(182, 8), C8(183, 8), C8(184, 8), C8(185, 8),
-    C8(186, 8), C8(187, 8), C8(188, 8), C8(189, 8), C8(190, 8), C8(191, 8),
-    C8(192, 8), C8(193, 8), C8(194, 8), C8(195, 8), C8(196, 8), C8(197, 8),
-    C8(198, 8), C8(199, 8), C8(200, 8), C8(201, 8), C8(202, 8), C8(203, 8),
-    C8(204, 8), C8(205, 8), C8(206, 8), C8(207, 8), C8(208, 8), C8(209, 8),
-    C8(210, 8), C8(211, 8), C8(212, 8), C8(213, 8), C8(214, 8), C8(215, 8),
-    C8(216, 8), C8(217, 8), C8(218, 8), C8(219, 8), C8(220, 8), C8(221, 8),
-    C8(222, 8), C8(223, 8), C8(224, 8), C8(225, 8), C8(226, 8), C8(227, 8),
-    C8(228, 8), C8(229, 8), C8(230, 8), C8(231, 8), C8(232, 8), C8(233, 8),
-    C8(234, 8), C8(235, 8), C8(236, 8), C8(237, 8), C8(238, 8), C8(239, 8),
-    C8(240, 8), C8(241, 8), C8(242, 8), C8(243, 8), C8(244, 8), C8(245, 8),
-    C8(246, 8), C8(247, 8), C8(248, 8), C8(249, 8), C8(250, 8), C8(251, 8),
-    C8(252, 8), C8(253, 8), C8(254, 8), C8(255, 8),
-};
-
-const FbBits fbStipple4Bits[16] = {
-    C4(0, 16), C4(1, 16), C4(2, 16), C4(3, 16), C4(4, 16), C4(5, 16),
-    C4(6, 16), C4(7, 16), C4(8, 16), C4(9, 16), C4(10, 16), C4(11, 16),
-    C4(12, 16), C4(13, 16), C4(14, 16), C4(15, 16),
-};
 
-const FbBits fbStipple2Bits[4] = {
-    C2(0, 32), C2(1, 32), C2(2, 32), C2(3, 32),
-};
-
-#define fbStipple1Bits 0
-#endif
 const FbBits *const fbStippleTable[] = {
     0,
     fbStipple1Bits,
commit 3d35bd6b79957a3441abd87a377f0beb058997ed
Author: Adam Jackson <ajax at redhat.com>
Date:   Mon Mar 24 12:01:54 2014 -0400

    fb: Eliminate fbLaneTable, staticize fb{8,16,32}Lane
    
    gcc doesn't appear to be smart enough to fold away the indirection here,
    even if you make fbLaneTable const.
    
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/fb/fbbltone.c b/fb/fbbltone.c
index bfcb5a2..d2f0416 100644
--- a/fb/fbbltone.c
+++ b/fb/fbbltone.c
@@ -81,7 +81,7 @@
 #endif
 
 #if FB_SHIFT == 6
-CARD8 fb8Lane[256] = {
+static const CARD8 fb8Lane[256] = {
     0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
         21,
     22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
@@ -107,40 +107,32 @@ CARD8 fb8Lane[256] = {
     242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255,
 };
 
-CARD8 fb16Lane[256] = {
+static const CARD8 fb16Lane[256] = {
     0x00, 0x03, 0x0c, 0x0f,
     0x30, 0x33, 0x3c, 0x3f,
     0xc0, 0xc3, 0xcc, 0xcf,
     0xf0, 0xf3, 0xfc, 0xff,
 };
 
-CARD8 fb32Lane[16] = {
+static const CARD8 fb32Lane[16] = {
     0x00, 0x0f, 0xf0, 0xff,
 };
 #endif
 
 #if FB_SHIFT == 5
-CARD8 fb8Lane[16] = {
+static const CARD8 fb8Lane[16] = {
     0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
 };
 
-CARD8 fb16Lane[16] = {
+static const CARD8 fb16Lane[16] = {
     0, 3, 12, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 };
 
-CARD8 fb32Lane[16] = {
+static const CARD8 fb32Lane[16] = {
     0, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 };
 #endif
 
-CARD8 *fbLaneTable[33] = {
-    0, 0, 0, 0, 0, 0, 0, 0,
-    fb8Lane, 0, 0, 0, 0, 0, 0, 0,
-    fb16Lane, 0, 0, 0, 0, 0, 0, 0,
-    0, 0, 0, 0, 0, 0, 0, 0,
-    fb32Lane
-};
-
 void
 fbBltOne(FbStip * src, FbStride srcStride,      /* FbStip units per scanline */
          int srcX,              /* bit position of source */
@@ -169,7 +161,7 @@ fbBltOne(FbStip * src, FbStride srcStride,      /* FbStip units per scanline */
     Bool transparent;           /* accelerate 0 nop */
     int srcinc;                 /* source units consumed */
     Bool endNeedsLoad = FALSE;  /* need load for endmask */
-    CARD8 *fbLane;
+    const CARD8 *fbLane;
     int startbyte, endbyte;
 
     if (dstBpp == 24) {
@@ -236,8 +228,14 @@ fbBltOne(FbStip * src, FbStride srcStride,      /* FbStip units per scanline */
     if (pixelsPerDst <= 8)
         fbBits = fbStippleTable[pixelsPerDst];
     fbLane = 0;
-    if (transparent && fgand == 0 && dstBpp >= 8)
-        fbLane = fbLaneTable[dstBpp];
+    if (transparent && fgand == 0) {
+        if (dstBpp == 8)
+            fbLane = fb8Lane;
+        if (dstBpp == 16)
+            fbLane = fb16Lane;
+        if (dstBpp == 32)
+            fbLane = fb32Lane;
+    }
 
     /*
      * Compute total number of destination words written, but 
diff --git a/fb/wfbrename.h b/fb/wfbrename.h
index 749c6d0..a80858a 100644
--- a/fb/wfbrename.h
+++ b/fb/wfbrename.h
@@ -1,4 +1,3 @@
-#define fb16Lane wfb16Lane
 #define fb24_32CopyMtoN wfb24_32CopyMtoN
 #define fb24_32CreateScreenResources wfb24_32CreateScreenResources
 #define fb24_32GetImage wfb24_32GetImage
@@ -7,8 +6,6 @@
 #define fb24_32PutZImage wfb24_32PutZImage
 #define fb24_32ReformatTile wfb24_32ReformatTile
 #define fb24_32SetSpans wfb24_32SetSpans
-#define fb32Lane wfb32Lane
-#define fb8Lane wfb8Lane
 #define fbAddTraps wfbAddTraps
 #define fbAddTriangles wfbAddTriangles
 #define fbAllocatePrivates wfbAllocatePrivates
@@ -85,8 +82,6 @@
 #define fbIn wfbIn
 #define fbInitializeColormap wfbInitializeColormap
 #define fbInitVisuals wfbInitVisuals
-#define fbInstallColormap wfbInstallColormap
-#define fbLaneTable wfbLaneTable
 #define fbListInstalledColormaps wfbListInstalledColormaps
 #define FbMergeRopBits wFbMergeRopBits
 #define fbOddStipple wfbOddStipple
commit 86ce6262975a7d53d9331723beb49cbe7bd02b48
Author: Adam Jackson <ajax at redhat.com>
Date:   Fri Sep 26 12:39:38 2014 -0400

    mi: Fold micursor.c into mipointer.c
    
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/mi/Makefile.am b/mi/Makefile.am
index ce416c4..110c3f5 100644
--- a/mi/Makefile.am
+++ b/mi/Makefile.am
@@ -16,7 +16,6 @@ libmi_la_SOURCES = 	\
 	micmap.h	\
 	micoord.h	\
 	micopy.c	\
-	micursor.c	\
 	midash.c	\
 	midispcur.c	\
 	mieq.c		\
diff --git a/mi/micursor.c b/mi/micursor.c
deleted file mode 100644
index 13ce776..0000000
--- a/mi/micursor.c
+++ /dev/null
@@ -1,68 +0,0 @@
-/***********************************************************
-
-Copyright 1987, 1998  The Open Group
-
-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.
-
-The above copyright notice and this permission notice 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
-OPEN GROUP 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.
-
-Except as contained in this notice, the name of The Open Group shall not be
-used in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization from The Open Group.
-
-Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
-
-                        All Rights Reserved
-
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
-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 Digital not be
-used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
-
-DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
-ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
-DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
-ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
-WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
-ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
-SOFTWARE.
-
-******************************************************************/
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "scrnintstr.h"
-#include "cursor.h"
-#include "misc.h"
-#include "mi.h"
-#include "inputstr.h"
-
-void
-miRecolorCursor(DeviceIntPtr pDev, ScreenPtr pScr,
-                CursorPtr pCurs, Bool displayed)
-{
-    /*
-     * This is guaranteed to correct any color-dependent state which may have
-     * been bound up in private state created by RealizeCursor
-     */
-    pScr->UnrealizeCursor(pDev, pScr, pCurs);
-    pScr->RealizeCursor(pDev, pScr, pCurs);
-    if (displayed)
-        pScr->DisplayCursor(pDev, pScr, pCurs);
-}
diff --git a/mi/mipointer.c b/mi/mipointer.c
index 6fa416d..9805425 100644
--- a/mi/mipointer.c
+++ b/mi/mipointer.c
@@ -273,6 +273,20 @@ miPointerSetCursorPosition(DeviceIntPtr pDev, ScreenPtr pScreen,
     return TRUE;
 }
 
+void
+miRecolorCursor(DeviceIntPtr pDev, ScreenPtr pScr,
+                CursorPtr pCurs, Bool displayed)
+{
+    /*
+     * This is guaranteed to correct any color-dependent state which may have
+     * been bound up in private state created by RealizeCursor
+     */
+    pScr->UnrealizeCursor(pDev, pScr, pCurs);
+    pScr->RealizeCursor(pDev, pScr, pCurs);
+    if (displayed)
+        pScr->DisplayCursor(pDev, pScr, pCurs);
+}
+
 /**
  * Set up sprite information for the device.
  * This function will be called once for each device after it is initialized
commit 3b63900e90f44cf85a4d3391d23407b3bb6db52b
Author: Adam Jackson <ajax at redhat.com>
Date:   Fri Sep 26 12:34:15 2014 -0400

    mi: Fold mipolyutil.c into mipoly.c
    
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/mi/Makefile.am b/mi/Makefile.am
index 44e4f20..ce416c4 100644
--- a/mi/Makefile.am
+++ b/mi/Makefile.am
@@ -40,7 +40,6 @@ libmi_la_SOURCES = 	\
 	mipolyrect.c	\
 	mipolyseg.c	\
 	mipolytext.c	\
-	mipolyutil.c	\
 	mipushpxl.c	\
 	miscanfill.h	\
 	miscrinit.c	\
diff --git a/mi/mipoly.c b/mi/mipoly.c
index 3d49789..0ed2edb 100644
--- a/mi/mipoly.c
+++ b/mi/mipoly.c
@@ -61,6 +61,291 @@ SOFTWARE.
 #include "mipoly.h"
 #include "regionstr.h"
 
+/*
+ * Insert the given edge into the edge table.  First we must find the correct
+ * bucket in the Edge table, then find the right slot in the bucket.  Finally,
+ * we can insert it.
+ */
+static Bool
+miInsertEdgeInET(EdgeTable * ET, EdgeTableEntry * ETE, int scanline,
+                 ScanLineListBlock ** SLLBlock, int *iSLLBlock)
+{
+    EdgeTableEntry *start, *prev;
+    ScanLineList *pSLL, *pPrevSLL;
+    ScanLineListBlock *tmpSLLBlock;
+
+    /*
+     * find the right bucket to put the edge into
+     */
+    pPrevSLL = &ET->scanlines;
+    pSLL = pPrevSLL->next;
+    while (pSLL && (pSLL->scanline < scanline)) {
+        pPrevSLL = pSLL;
+        pSLL = pSLL->next;
+    }
+
+    /*
+     * reassign pSLL (pointer to ScanLineList) if necessary
+     */
+    if ((!pSLL) || (pSLL->scanline > scanline)) {
+        if (*iSLLBlock > SLLSPERBLOCK - 1) {
+            tmpSLLBlock = malloc(sizeof(ScanLineListBlock));
+            if (!tmpSLLBlock)
+                return FALSE;
+            (*SLLBlock)->next = tmpSLLBlock;
+            tmpSLLBlock->next = NULL;
+            *SLLBlock = tmpSLLBlock;
+            *iSLLBlock = 0;
+        }
+        pSLL = &((*SLLBlock)->SLLs[(*iSLLBlock)++]);
+
+        pSLL->next = pPrevSLL->next;
+        pSLL->edgelist = NULL;
+        pPrevSLL->next = pSLL;
+    }
+    pSLL->scanline = scanline;
+
+    /*
+     * now insert the edge in the right bucket
+     */
+    prev = NULL;
+    start = pSLL->edgelist;
+    while (start && (start->bres.minor < ETE->bres.minor)) {
+        prev = start;
+        start = start->next;
+    }
+    ETE->next = start;
+
+    if (prev)
+        prev->next = ETE;
+    else
+        pSLL->edgelist = ETE;
+    return TRUE;
+}
+
+static void
+miFreeStorage(ScanLineListBlock * pSLLBlock)
+{
+    ScanLineListBlock *tmpSLLBlock;
+
+    while (pSLLBlock) {
+        tmpSLLBlock = pSLLBlock->next;
+        free(pSLLBlock);
+        pSLLBlock = tmpSLLBlock;
+    }
+}
+
+/*
+ * CreateEdgeTable
+ *
+ * This routine creates the edge table for scan converting polygons.
+ * The Edge Table (ET) looks like:
+ *
+ * EdgeTable
+ *  --------
+ * |  ymax  |        ScanLineLists
+ * |scanline|-->------------>-------------->...
+ *  --------   |scanline|   |scanline|
+ *             |edgelist|   |edgelist|
+ *             ---------    ---------
+ *                 |             |
+ *                 |             |
+ *                 V             V
+ *           list of ETEs   list of ETEs
+ *
+ * where ETE is an EdgeTableEntry data structure, and there is one ScanLineList
+ * per scanline at which an edge is initially entered.
+ */
+
+static Bool
+miCreateETandAET(int count, DDXPointPtr pts, EdgeTable * ET,
+                 EdgeTableEntry * AET, EdgeTableEntry * pETEs,
+                 ScanLineListBlock * pSLLBlock)
+{
+    DDXPointPtr top, bottom;
+    DDXPointPtr PrevPt, CurrPt;
+    int iSLLBlock = 0;
+
+    int dy;
+
+    if (count < 2)
+        return TRUE;
+
+    /*
+     *  initialize the Active Edge Table
+     */
+    AET->next = NULL;
+    AET->back = NULL;
+    AET->nextWETE = NULL;
+    AET->bres.minor = MININT;
+
+    /*
+     *  initialize the Edge Table.
+     */
+    ET->scanlines.next = NULL;
+    ET->ymax = MININT;
+    ET->ymin = MAXINT;
+    pSLLBlock->next = NULL;
+
+    PrevPt = &pts[count - 1];
+
+    /*
+     *  for each vertex in the array of points.
+     *  In this loop we are dealing with two vertices at
+     *  a time -- these make up one edge of the polygon.
+     */
+    while (count--) {
+        CurrPt = pts++;
+
+        /*
+         *  find out which point is above and which is below.
+         */
+        if (PrevPt->y > CurrPt->y) {
+            bottom = PrevPt, top = CurrPt;
+            pETEs->ClockWise = 0;
+        }
+        else {
+            bottom = CurrPt, top = PrevPt;
+            pETEs->ClockWise = 1;
+        }
+
+        /*
+         * don't add horizontal edges to the Edge table.
+         */
+        if (bottom->y != top->y) {
+            pETEs->ymax = bottom->y - 1; /* -1 so we don't get last scanline */
+
+            /*
+             *  initialize integer edge algorithm
+             */
+            dy = bottom->y - top->y;
+            BRESINITPGONSTRUCT(dy, top->x, bottom->x, pETEs->bres);
+
+            if (!miInsertEdgeInET(ET, pETEs, top->y, &pSLLBlock, &iSLLBlock)) {
+                miFreeStorage(pSLLBlock->next);
+                return FALSE;
+            }
+
+            ET->ymax = max(ET->ymax, PrevPt->y);
+            ET->ymin = min(ET->ymin, PrevPt->y);
+            pETEs++;
+        }
+
+        PrevPt = CurrPt;
+    }
+    return TRUE;
+}
+
+/*
+ * This routine moves EdgeTableEntries from the EdgeTable into the Active Edge
+ * Table, leaving them sorted by smaller x coordinate.
+ */
+
+static void
+miloadAET(EdgeTableEntry * AET, EdgeTableEntry * ETEs)
+{
+    EdgeTableEntry *pPrevAET;
+    EdgeTableEntry *tmp;
+
+    pPrevAET = AET;
+    AET = AET->next;
+    while (ETEs) {
+        while (AET && (AET->bres.minor < ETEs->bres.minor)) {
+            pPrevAET = AET;
+            AET = AET->next;
+        }
+        tmp = ETEs->next;
+        ETEs->next = AET;
+        if (AET)
+            AET->back = ETEs;
+        ETEs->back = pPrevAET;
+        pPrevAET->next = ETEs;
+        pPrevAET = ETEs;
+
+        ETEs = tmp;
+    }
+}
+
+/*
+ * computeWAET
+ *
+ * This routine links the AET by the nextWETE (winding EdgeTableEntry) link for
+ * use by the winding number rule.  The final Active Edge Table (AET) might
+ * look something like:
+ *
+ * AET
+ * ----------  ---------   ---------
+ * |ymax    |  |ymax    |  |ymax    |
+ * | ...    |  |...     |  |...     |
+ * |next    |->|next    |->|next    |->...
+ * |nextWETE|  |nextWETE|  |nextWETE|
+ * ---------   ---------   ^--------
+ *     |                   |       |
+ *     V------------------->       V---> ...
+ *
+ */
+static void
+micomputeWAET(EdgeTableEntry * AET)
+{
+    EdgeTableEntry *pWETE;
+    int inside = 1;
+    int isInside = 0;
+
+    AET->nextWETE = NULL;
+    pWETE = AET;
+    AET = AET->next;
+    while (AET) {
+        if (AET->ClockWise)
+            isInside++;
+        else
+            isInside--;
+
+        if ((!inside && !isInside) || (inside && isInside)) {
+            pWETE->nextWETE = AET;
+            pWETE = AET;
+            inside = !inside;
+        }
+        AET = AET->next;
+    }
+    pWETE->nextWETE = NULL;
+}
+
+/*
+ * Just a simple insertion sort using pointers and back pointers to sort the
+ * Active Edge Table.
+ */
+
+static int
+miInsertionSort(EdgeTableEntry * AET)
+{
+    EdgeTableEntry *pETEchase;
+    EdgeTableEntry *pETEinsert;
+    EdgeTableEntry *pETEchaseBackTMP;
+    int changed = 0;
+
+    AET = AET->next;
+    while (AET) {
+        pETEinsert = AET;
+        pETEchase = AET;
+        while (pETEchase->back->bres.minor > AET->bres.minor)
+            pETEchase = pETEchase->back;
+
+        AET = AET->next;
+        if (pETEchase != pETEinsert) {
+            pETEchaseBackTMP = pETEchase->back;
+            pETEinsert->back->next = AET;
+            if (AET)
+                AET->back = pETEinsert->back;
+            pETEinsert->next = pETEchase;
+            pETEchase->back->next = pETEinsert;
+            pETEchase->back = pETEinsert;
+            pETEinsert->back = pETEchaseBackTMP;
+            changed = 1;
+        }
+    }
+    return changed;
+}
+
 /* Find the index of the point with the smallest y */
 static int
 getPolyYBounds(DDXPointPtr pts, int n, int *by, int *ty)
diff --git a/mi/mipoly.h b/mi/mipoly.h
index 02fcfc8..fc5a5cf 100644
--- a/mi/mipoly.h
+++ b/mi/mipoly.h
@@ -171,20 +171,3 @@ typedef struct _ScanLineListBlock {
       pAET = pAET->next; \
    } \
 }
-
-/* mipolyutil.c */
-
-extern Bool miCreateETandAET(int /*count */ ,
-                             DDXPointPtr /*pts */ ,
-                             EdgeTable * /*ET*/,
-                             EdgeTableEntry * /*AET*/,
-                             EdgeTableEntry * /*pETEs */ ,
-                             ScanLineListBlock *      /*pSLLBlock */);
-
-extern void miloadAET(EdgeTableEntry * /*AET*/, EdgeTableEntry * /*ETEs */);
-
-extern void micomputeWAET(EdgeTableEntry * /*AET*/);
-
-extern int miInsertionSort(EdgeTableEntry * /*AET*/);
-
-extern void miFreeStorage(ScanLineListBlock * /*pSLLBlock */);
diff --git a/mi/mipolyutil.c b/mi/mipolyutil.c
deleted file mode 100644
index 5e6301d..0000000
--- a/mi/mipolyutil.c
+++ /dev/null
@@ -1,369 +0,0 @@
-/***********************************************************
-
-Copyright 1987, 1998  The Open Group
-
-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.
-
-The above copyright notice and this permission notice 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
-OPEN GROUP 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.
-
-Except as contained in this notice, the name of The Open Group shall not be
-used in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization from The Open Group.
-
-Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
-
-                        All Rights Reserved
-
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
-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 Digital not be
-used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
-
-DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
-ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
-DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
-ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
-WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
-ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
-SOFTWARE.
-
-******************************************************************/
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "regionstr.h"
-#include "gc.h"
-#include "miscanfill.h"
-#include "mipoly.h"
-#include "misc.h"               /* MAXINT */
-
-/*
- *     fillUtils.c
- *
- *     Written by Brian Kelleher;  Oct. 1985
- *
- *     This module contains all of the utility functions
- *     needed to scan convert a polygon.
- *
- */
-
-/*
- *     InsertEdgeInET
- *
- *     Insert the given edge into the edge table.
- *     First we must find the correct bucket in the
- *     Edge table, then find the right slot in the
- *     bucket.  Finally, we can insert it.
- *
- */
-static Bool
-miInsertEdgeInET(EdgeTable * ET, EdgeTableEntry * ETE, int scanline,
-                 ScanLineListBlock ** SLLBlock, int *iSLLBlock)
-{
-    EdgeTableEntry *start, *prev;
-    ScanLineList *pSLL, *pPrevSLL;
-    ScanLineListBlock *tmpSLLBlock;
-
-    /*
-     * find the right bucket to put the edge into
-     */
-    pPrevSLL = &ET->scanlines;
-    pSLL = pPrevSLL->next;
-    while (pSLL && (pSLL->scanline < scanline)) {
-        pPrevSLL = pSLL;
-        pSLL = pSLL->next;
-    }
-
-    /*
-     * reassign pSLL (pointer to ScanLineList) if necessary
-     */
-    if ((!pSLL) || (pSLL->scanline > scanline)) {
-        if (*iSLLBlock > SLLSPERBLOCK - 1) {
-            tmpSLLBlock = malloc(sizeof(ScanLineListBlock));
-            if (!tmpSLLBlock)
-                return FALSE;
-            (*SLLBlock)->next = tmpSLLBlock;
-            tmpSLLBlock->next = NULL;
-            *SLLBlock = tmpSLLBlock;
-            *iSLLBlock = 0;
-        }
-        pSLL = &((*SLLBlock)->SLLs[(*iSLLBlock)++]);
-
-        pSLL->next = pPrevSLL->next;
-        pSLL->edgelist = NULL;
-        pPrevSLL->next = pSLL;
-    }
-    pSLL->scanline = scanline;
-
-    /*
-     * now insert the edge in the right bucket
-     */
-    prev = NULL;
-    start = pSLL->edgelist;
-    while (start && (start->bres.minor < ETE->bres.minor)) {
-        prev = start;
-        start = start->next;
-    }
-    ETE->next = start;
-
-    if (prev)
-        prev->next = ETE;
-    else
-        pSLL->edgelist = ETE;
-    return TRUE;
-}
-
-/*
- *     CreateEdgeTable
- *
- *     This routine creates the edge table for
- *     scan converting polygons. 
- *     The Edge Table (ET) looks like:
- *
- *    EdgeTable
- *     --------
- *    |  ymax  |        ScanLineLists
- *    |scanline|-->------------>-------------->...
- *     --------   |scanline|   |scanline|
- *                |edgelist|   |edgelist|
- *                ---------    ---------
- *                    |             |
- *                    |             |
- *                    V             V
- *              list of ETEs   list of ETEs
- *
- *     where ETE is an EdgeTableEntry data structure,
- *     and there is one ScanLineList per scanline at
- *     which an edge is initially entered.
- *
- */
-
-Bool
-miCreateETandAET(int count, DDXPointPtr pts, EdgeTable * ET,
-                 EdgeTableEntry * AET, EdgeTableEntry * pETEs,
-                 ScanLineListBlock * pSLLBlock)
-{
-    DDXPointPtr top, bottom;
-    DDXPointPtr PrevPt, CurrPt;
-    int iSLLBlock = 0;
-
-    int dy;
-
-    if (count < 2)
-        return TRUE;
-
-    /*
-     *  initialize the Active Edge Table
-     */
-    AET->next = NULL;
-    AET->back = NULL;
-    AET->nextWETE = NULL;
-    AET->bres.minor = MININT;
-
-    /*
-     *  initialize the Edge Table.
-     */
-    ET->scanlines.next = NULL;
-    ET->ymax = MININT;
-    ET->ymin = MAXINT;
-    pSLLBlock->next = NULL;
-
-    PrevPt = &pts[count - 1];
-
-    /*
-     *  for each vertex in the array of points.
-     *  In this loop we are dealing with two vertices at
-     *  a time -- these make up one edge of the polygon.
-     */
-    while (count--) {
-        CurrPt = pts++;
-
-        /*
-         *  find out which point is above and which is below.
-         */
-        if (PrevPt->y > CurrPt->y) {
-            bottom = PrevPt, top = CurrPt;
-            pETEs->ClockWise = 0;
-        }
-        else {
-            bottom = CurrPt, top = PrevPt;
-            pETEs->ClockWise = 1;
-        }
-
-        /*
-         * don't add horizontal edges to the Edge table.
-         */
-        if (bottom->y != top->y) {
-            pETEs->ymax = bottom->y - 1;        /* -1 so we don't get last scanline */
-
-            /*
-             *  initialize integer edge algorithm
-             */
-            dy = bottom->y - top->y;
-            BRESINITPGONSTRUCT(dy, top->x, bottom->x, pETEs->bres);
-
-            if (!miInsertEdgeInET(ET, pETEs, top->y, &pSLLBlock, &iSLLBlock)) {
-                miFreeStorage(pSLLBlock->next);
-                return FALSE;
-            }
-
-            ET->ymax = max(ET->ymax, PrevPt->y);
-            ET->ymin = min(ET->ymin, PrevPt->y);
-            pETEs++;
-        }
-
-        PrevPt = CurrPt;
-    }
-    return TRUE;
-}
-
-/*
- *     loadAET
- *
- *     This routine moves EdgeTableEntries from the
- *     EdgeTable into the Active Edge Table,
- *     leaving them sorted by smaller x coordinate.
- *
- */
-
-void
-miloadAET(EdgeTableEntry * AET, EdgeTableEntry * ETEs)
-{
-    EdgeTableEntry *pPrevAET;
-    EdgeTableEntry *tmp;
-
-    pPrevAET = AET;
-    AET = AET->next;
-    while (ETEs) {
-        while (AET && (AET->bres.minor < ETEs->bres.minor)) {
-            pPrevAET = AET;
-            AET = AET->next;
-        }
-        tmp = ETEs->next;
-        ETEs->next = AET;
-        if (AET)
-            AET->back = ETEs;
-        ETEs->back = pPrevAET;
-        pPrevAET->next = ETEs;
-        pPrevAET = ETEs;
-
-        ETEs = tmp;
-    }
-}
-
-/*
- *     computeWAET
- *
- *     This routine links the AET by the
- *     nextWETE (winding EdgeTableEntry) link for
- *     use by the winding number rule.  The final 
- *     Active Edge Table (AET) might look something
- *     like:
- *
- *     AET
- *     ----------  ---------   ---------
- *     |ymax    |  |ymax    |  |ymax    | 
- *     | ...    |  |...     |  |...     |
- *     |next    |->|next    |->|next    |->...
- *     |nextWETE|  |nextWETE|  |nextWETE|
- *     ---------   ---------   ^--------
- *         |                   |       |
- *         V------------------->       V---> ...
- *
- */
-void
-micomputeWAET(EdgeTableEntry * AET)
-{
-    EdgeTableEntry *pWETE;
-    int inside = 1;
-    int isInside = 0;
-
-    AET->nextWETE = NULL;
-    pWETE = AET;
-    AET = AET->next;
-    while (AET) {
-        if (AET->ClockWise)
-            isInside++;
-        else
-            isInside--;
-
-        if ((!inside && !isInside) || (inside && isInside)) {
-            pWETE->nextWETE = AET;
-            pWETE = AET;
-            inside = !inside;
-        }
-        AET = AET->next;
-    }
-    pWETE->nextWETE = NULL;
-}
-
-/*
- *     InsertionSort
- *
- *     Just a simple insertion sort using
- *     pointers and back pointers to sort the Active
- *     Edge Table.
- *
- */
-
-int
-miInsertionSort(EdgeTableEntry * AET)
-{
-    EdgeTableEntry *pETEchase;
-    EdgeTableEntry *pETEinsert;
-    EdgeTableEntry *pETEchaseBackTMP;
-    int changed = 0;
-
-    AET = AET->next;
-    while (AET) {
-        pETEinsert = AET;
-        pETEchase = AET;
-        while (pETEchase->back->bres.minor > AET->bres.minor)
-            pETEchase = pETEchase->back;
-
-        AET = AET->next;
-        if (pETEchase != pETEinsert) {
-            pETEchaseBackTMP = pETEchase->back;
-            pETEinsert->back->next = AET;
-            if (AET)
-                AET->back = pETEinsert->back;
-            pETEinsert->next = pETEchase;
-            pETEchase->back->next = pETEinsert;
-            pETEchase->back = pETEinsert;
-            pETEinsert->back = pETEchaseBackTMP;
-            changed = 1;
-        }
-    }
-    return changed;
-}
-
-/*
- *     Clean up our act.
- */
-void
-miFreeStorage(ScanLineListBlock * pSLLBlock)
-{
-    ScanLineListBlock *tmpSLLBlock;
-
-    while (pSLLBlock) {
-        tmpSLLBlock = pSLLBlock->next;
-        free(pSLLBlock);
-        pSLLBlock = tmpSLLBlock;
-    }
-}
commit 21b041ef48c49ff6fc06f6e4482ffe54cb763493
Author: Adam Jackson <ajax at redhat.com>
Date:   Fri Sep 26 12:27:22 2014 -0400

    mi: Fold mipoly{con,gen}.c into mipoly.c
    
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/mi/Makefile.am b/mi/Makefile.am
index d9139a3..44e4f20 100644
--- a/mi/Makefile.am
+++ b/mi/Makefile.am
@@ -36,8 +36,6 @@ libmi_la_SOURCES = 	\
 	mipointrst.h	\
 	mipoly.c	\
 	mipoly.h	\
-	mipolycon.c	\
-	mipolygen.c	\
 	mipolypnt.c	\
 	mipolyrect.c	\
 	mipolyseg.c	\
diff --git a/mi/mi.h b/mi/mi.h
index 5a455c9..3269d9b 100644
--- a/mi/mi.h
+++ b/mi/mi.h
@@ -288,22 +288,6 @@ extern _X_EXPORT void miFillPolygon(DrawablePtr /*dst */ ,
                                     DDXPointPtr /*pPts */
     );
 
-/* mipolycon.c */
-
-extern _X_EXPORT Bool miFillConvexPoly(DrawablePtr /*dst */ ,
-                                       GCPtr /*pgc */ ,
-                                       int /*count */ ,
-                                       DDXPointPtr      /*ptsIn */
-    );
-
-/* mipolygen.c */
-
-extern _X_EXPORT Bool miFillGeneralPoly(DrawablePtr /*dst */ ,
-                                        GCPtr /*pgc */ ,
-                                        int /*count */ ,
-                                        DDXPointPtr     /*ptsIn */
-    );
-
 /* mipolypnt.c */
 
 extern _X_EXPORT void miPolyPoint(DrawablePtr /*pDrawable */ ,
diff --git a/mi/mipoly.c b/mi/mipoly.c
index 07d9818..3d49789 100644
--- a/mi/mipoly.c
+++ b/mi/mipoly.c
@@ -47,11 +47,6 @@ SOFTWARE.
  *  mipoly.c
  *
  *  Written by Brian Kelleher; June 1986
- *
- *  Draw polygons.  This routine translates the point by the
- *  origin if pGC->miTranslate is non-zero, and calls
- *  to the appropriate routine to actually scan convert the
- *  polygon.
  */
 #ifdef HAVE_DIX_CONFIG_H
 #include <dix-config.h>
@@ -62,8 +57,337 @@ SOFTWARE.
 #include "gcstruct.h"
 #include "pixmapstr.h"
 #include "mi.h"
+#include "miscanfill.h"
+#include "mipoly.h"
 #include "regionstr.h"
 
+/* Find the index of the point with the smallest y */
+static int
+getPolyYBounds(DDXPointPtr pts, int n, int *by, int *ty)
+{
+    DDXPointPtr ptMin;
+    int ymin, ymax;
+    DDXPointPtr ptsStart = pts;
+
+    ptMin = pts;
+    ymin = ymax = (pts++)->y;
+
+    while (--n > 0) {
+        if (pts->y < ymin) {
+            ptMin = pts;
+            ymin = pts->y;
+        }
+        if (pts->y > ymax)
+            ymax = pts->y;
+
+        pts++;
+    }
+
+    *by = ymin;
+    *ty = ymax;
+    return ptMin - ptsStart;
+}
+
+/*
+ * Written by Brian Kelleher; Dec. 1985.
+ *
+ * Fill a convex polygon.  If the given polygon is not convex, then the result
+ * is undefined.  The algorithm is to order the edges from smallest y to
+ * largest by partitioning the array into a left edge list and a right edge
+ * list.  The algorithm used to traverse each edge is an extension of
+ * Bresenham's line algorithm with y as the major axis.  For a derivation of
+ * the algorithm, see the author of this code.
+ */
+static Bool
+miFillConvexPoly(DrawablePtr dst, GCPtr pgc, int count, DDXPointPtr ptsIn)
+{
+    int xl = 0, xr = 0;         /* x vals of left and right edges */
+    int dl = 0, dr = 0;         /* decision variables             */
+    int ml = 0, m1l = 0;        /* left edge slope and slope+1    */
+    int mr = 0, m1r = 0;        /* right edge slope and slope+1   */
+    int incr1l = 0, incr2l = 0; /* left edge error increments     */
+    int incr1r = 0, incr2r = 0; /* right edge error increments    */
+    int dy;                     /* delta y                        */
+    int y;                      /* current scanline               */
+    int left, right;            /* indices to first endpoints     */
+    int i;                      /* loop counter                   */
+    int nextleft, nextright;    /* indices to second endpoints    */
+    DDXPointPtr ptsOut, FirstPoint;     /* output buffer               */
+    int *width, *FirstWidth;    /* output buffer                  */
+    int imin;                   /* index of smallest vertex (in y) */
+    int ymin;                   /* y-extents of polygon            */
+    int ymax;
+
+    /*
+     *  find leftx, bottomy, rightx, topy, and the index
+     *  of bottomy. Also translate the points.
+     */
+    imin = getPolyYBounds(ptsIn, count, &ymin, &ymax);
+
+    dy = ymax - ymin + 1;
+    if ((count < 3) || (dy < 0))
+        return TRUE;
+    ptsOut = FirstPoint = malloc(sizeof(DDXPointRec) * dy);
+    width = FirstWidth = malloc(sizeof(int) * dy);
+    if (!FirstPoint || !FirstWidth) {
+        free(FirstWidth);
+        free(FirstPoint);
+        return FALSE;
+    }
+
+    nextleft = nextright = imin;
+    y = ptsIn[nextleft].y;
+
+    /*
+     *  loop through all edges of the polygon
+     */
+    do {
+        /*
+         *  add a left edge if we need to
+         */
+        if (ptsIn[nextleft].y == y) {
+            left = nextleft;
+
+            /*
+             *  find the next edge, considering the end
+             *  conditions of the array.
+             */
+            nextleft++;
+            if (nextleft >= count)
+                nextleft = 0;
+
+            /*
+             *  now compute all of the random information
+             *  needed to run the iterative algorithm.
+             */
+            BRESINITPGON(ptsIn[nextleft].y - ptsIn[left].y,
+                         ptsIn[left].x, ptsIn[nextleft].x,
+                         xl, dl, ml, m1l, incr1l, incr2l);
+        }
+
+        /*
+         *  add a right edge if we need to
+         */
+        if (ptsIn[nextright].y == y) {
+            right = nextright;
+
+            /*
+             *  find the next edge, considering the end
+             *  conditions of the array.
+             */
+            nextright--;
+            if (nextright < 0)
+                nextright = count - 1;
+
+            /*
+             *  now compute all of the random information
+             *  needed to run the iterative algorithm.
+             */
+            BRESINITPGON(ptsIn[nextright].y - ptsIn[right].y,
+                         ptsIn[right].x, ptsIn[nextright].x,
+                         xr, dr, mr, m1r, incr1r, incr2r);
+        }
+
+        /*
+         *  generate scans to fill while we still have
+         *  a right edge as well as a left edge.
+         */
+        i = min(ptsIn[nextleft].y, ptsIn[nextright].y) - y;
+        /* in case we're called with non-convex polygon */
+        if (i < 0) {
+            free(FirstWidth);
+            free(FirstPoint);
+            return TRUE;
+        }
+        while (i-- > 0) {
+            ptsOut->y = y;
+
+            /*
+             *  reverse the edges if necessary
+             */
+            if (xl < xr) {
+                *(width++) = xr - xl;
+                (ptsOut++)->x = xl;
+            }
+            else {
+                *(width++) = xl - xr;
+                (ptsOut++)->x = xr;
+            }
+            y++;
+
+            /* increment down the edges */
+            BRESINCRPGON(dl, xl, ml, m1l, incr1l, incr2l);
+            BRESINCRPGON(dr, xr, mr, m1r, incr1r, incr2r);
+        }
+    } while (y != ymax);
+
+    /*
+     * Finally, fill the <remaining> spans
+     */
+    (*pgc->ops->FillSpans) (dst, pgc,
+                            ptsOut - FirstPoint, FirstPoint, FirstWidth, 1);
+    free(FirstWidth);
+    free(FirstPoint);
+    return TRUE;
+}
+
+/*
+ * Written by Brian Kelleher;  Oct. 1985
+ *
+ * Routine to fill a polygon.  Two fill rules are supported: frWINDING and
+ * frEVENODD.
+ */
+static Bool
+miFillGeneralPoly(DrawablePtr dst, GCPtr pgc, int count, DDXPointPtr ptsIn)
+{
+    EdgeTableEntry *pAET;       /* the Active Edge Table   */
+    int y;                      /* the current scanline    */
+    int nPts = 0;               /* number of pts in buffer */
+    EdgeTableEntry *pWETE;      /* Winding Edge Table      */
+    ScanLineList *pSLL;         /* Current ScanLineList    */
+    DDXPointPtr ptsOut;         /* ptr to output buffers   */
+    int *width;
+    DDXPointRec FirstPoint[NUMPTSTOBUFFER];     /* the output buffers */
+    int FirstWidth[NUMPTSTOBUFFER];
+    EdgeTableEntry *pPrevAET;   /* previous AET entry      */
+    EdgeTable ET;               /* Edge Table header node  */
+    EdgeTableEntry AET;         /* Active ET header node   */
+    EdgeTableEntry *pETEs;      /* Edge Table Entries buff */
+    ScanLineListBlock SLLBlock; /* header for ScanLineList */
+    int fixWAET = 0;
+
+    if (count < 3)
+        return TRUE;
+
+    if (!(pETEs = malloc(sizeof(EdgeTableEntry) * count)))
+        return FALSE;
+    ptsOut = FirstPoint;
+    width = FirstWidth;
+    if (!miCreateETandAET(count, ptsIn, &ET, &AET, pETEs, &SLLBlock)) {
+        free(pETEs);
+        return FALSE;
+    }
+    pSLL = ET.scanlines.next;
+
+    if (pgc->fillRule == EvenOddRule) {
+        /*
+         *  for each scanline
+         */
+        for (y = ET.ymin; y < ET.ymax; y++) {
+            /*
+             *  Add a new edge to the active edge table when we
+             *  get to the next edge.
+             */
+            if (pSLL && y == pSLL->scanline) {
+                miloadAET(&AET, pSLL->edgelist);
+                pSLL = pSLL->next;
+            }
+            pPrevAET = &AET;
+            pAET = AET.next;
+
+            /*
+             *  for each active edge
+             */
+            while (pAET) {
+                ptsOut->x = pAET->bres.minor;
+                ptsOut++->y = y;
+                *width++ = pAET->next->bres.minor - pAET->bres.minor;
+                nPts++;
+
+                /*
+                 *  send out the buffer when its full
+                 */
+                if (nPts == NUMPTSTOBUFFER) {
+                    (*pgc->ops->FillSpans) (dst, pgc,
+                                            nPts, FirstPoint, FirstWidth, 1);
+                    ptsOut = FirstPoint;
+                    width = FirstWidth;
+                    nPts = 0;
+                }
+                EVALUATEEDGEEVENODD(pAET, pPrevAET, y);
+                EVALUATEEDGEEVENODD(pAET, pPrevAET, y);
+            }
+            miInsertionSort(&AET);
+        }
+    }
+    else {                      /* default to WindingNumber */
+
+        /*
+         *  for each scanline
+         */
+        for (y = ET.ymin; y < ET.ymax; y++) {
+            /*
+             *  Add a new edge to the active edge table when we
+             *  get to the next edge.
+             */
+            if (pSLL && y == pSLL->scanline) {
+                miloadAET(&AET, pSLL->edgelist);
+                micomputeWAET(&AET);
+                pSLL = pSLL->next;
+            }
+            pPrevAET = &AET;
+            pAET = AET.next;
+            pWETE = pAET;
+
+            /*
+             *  for each active edge
+             */
+            while (pAET) {
+                /*
+                 *  if the next edge in the active edge table is
+                 *  also the next edge in the winding active edge
+                 *  table.
+                 */
+                if (pWETE == pAET) {
+                    ptsOut->x = pAET->bres.minor;
+                    ptsOut++->y = y;
+                    *width++ = pAET->nextWETE->bres.minor - pAET->bres.minor;
+                    nPts++;
+
+                    /*
+                     *  send out the buffer
+                     */
+                    if (nPts == NUMPTSTOBUFFER) {
+                        (*pgc->ops->FillSpans) (dst, pgc, nPts, FirstPoint,
+                                                FirstWidth, 1);
+                        ptsOut = FirstPoint;
+                        width = FirstWidth;
+                        nPts = 0;
+                    }
+
+                    pWETE = pWETE->nextWETE;
+                    while (pWETE != pAET)
+                        EVALUATEEDGEWINDING(pAET, pPrevAET, y, fixWAET);
+                    pWETE = pWETE->nextWETE;
+                }
+                EVALUATEEDGEWINDING(pAET, pPrevAET, y, fixWAET);
+            }
+
+            /*
+             *  reevaluate the Winding active edge table if we
+             *  just had to resort it or if we just exited an edge.
+             */
+            if (miInsertionSort(&AET) || fixWAET) {
+                micomputeWAET(&AET);
+                fixWAET = 0;
+            }
+        }
+    }
+
+    /*
+     *     Get any spans that we missed by buffering
+     */
+    (*pgc->ops->FillSpans) (dst, pgc, nPts, FirstPoint, FirstWidth, 1);
+    free(pETEs);
+    miFreeStorage(SLLBlock.next);
+    return TRUE;
+}
+
+/*
+ *  Draw polygons.  This routine translates the point by the origin if
+ *  pGC->miTranslate is non-zero, and calls to the appropriate routine to
+ *  actually scan convert the polygon.
+ */
 void
 miFillPolygon(DrawablePtr dst, GCPtr pgc,
               int shape, int mode, int count, DDXPointPtr pPts)
diff --git a/mi/mipolycon.c b/mi/mipolycon.c
deleted file mode 100644
index e831633..0000000
--- a/mi/mipolycon.c
+++ /dev/null
@@ -1,235 +0,0 @@
-/***********************************************************
-
-Copyright 1987, 1998  The Open Group
-
-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.
-
-The above copyright notice and this permission notice 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
-OPEN GROUP 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.
-
-Except as contained in this notice, the name of The Open Group shall not be
-used in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization from The Open Group.
-
-Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
-
-                        All Rights Reserved
-
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
-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 Digital not be
-used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
-
-DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
-ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
-DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
-ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
-WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
-ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
-SOFTWARE.
-
-******************************************************************/
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "gcstruct.h"
-#include "pixmap.h"
-#include "mi.h"
-#include "miscanfill.h"
-
-static int getPolyYBounds(DDXPointPtr pts, int n, int *by, int *ty);
-
-/*
- *     convexpoly.c
- *
- *     Written by Brian Kelleher; Dec. 1985.
- *
- *     Fill a convex polygon.  If the given polygon
- *     is not convex, then the result is undefined.
- *     The algorithm is to order the edges from smallest
- *     y to largest by partitioning the array into a left
- *     edge list and a right edge list.  The algorithm used
- *     to traverse each edge is an extension of Bresenham's
- *     line algorithm with y as the major axis.
- *     For a derivation of the algorithm, see the author of
- *     this code.
- */
-Bool
-miFillConvexPoly(DrawablePtr dst, GCPtr pgc, int count, /* number of points        */
-                 DDXPointPtr ptsIn      /* the points              */
-    )
-{
-    int xl = 0, xr = 0;         /* x vals of left and right edges */
-    int dl = 0, dr = 0;         /* decision variables             */
-    int ml = 0, m1l = 0;        /* left edge slope and slope+1    */
-    int mr = 0, m1r = 0;        /* right edge slope and slope+1   */
-    int incr1l = 0, incr2l = 0; /* left edge error increments     */
-    int incr1r = 0, incr2r = 0; /* right edge error increments    */
-    int dy;                     /* delta y                        */
-    int y;                      /* current scanline               */
-    int left, right;            /* indices to first endpoints     */
-    int i;                      /* loop counter                   */
-    int nextleft, nextright;    /* indices to second endpoints    */
-    DDXPointPtr ptsOut, FirstPoint;     /* output buffer               */
-    int *width, *FirstWidth;    /* output buffer                  */
-    int imin;                   /* index of smallest vertex (in y) */
-    int ymin;                   /* y-extents of polygon            */
-    int ymax;
-
-    /*
-     *  find leftx, bottomy, rightx, topy, and the index
-     *  of bottomy. Also translate the points.
-     */
-    imin = getPolyYBounds(ptsIn, count, &ymin, &ymax);
-
-    dy = ymax - ymin + 1;
-    if ((count < 3) || (dy < 0))
-        return TRUE;
-    ptsOut = FirstPoint = malloc(sizeof(DDXPointRec) * dy);
-    width = FirstWidth = malloc(sizeof(int) * dy);
-    if (!FirstPoint || !FirstWidth) {
-        free(FirstWidth);
-        free(FirstPoint);
-        return FALSE;
-    }
-
-    nextleft = nextright = imin;
-    y = ptsIn[nextleft].y;
-
-    /*
-     *  loop through all edges of the polygon
-     */
-    do {
-        /*
-         *  add a left edge if we need to
-         */
-        if (ptsIn[nextleft].y == y) {
-            left = nextleft;
-
-            /*
-             *  find the next edge, considering the end
-             *  conditions of the array.
-             */
-            nextleft++;
-            if (nextleft >= count)
-                nextleft = 0;
-
-            /*
-             *  now compute all of the random information
-             *  needed to run the iterative algorithm.
-             */
-            BRESINITPGON(ptsIn[nextleft].y - ptsIn[left].y,
-                         ptsIn[left].x, ptsIn[nextleft].x,
-                         xl, dl, ml, m1l, incr1l, incr2l);
-        }
-
-        /*
-         *  add a right edge if we need to
-         */
-        if (ptsIn[nextright].y == y) {
-            right = nextright;
-
-            /*
-             *  find the next edge, considering the end
-             *  conditions of the array.
-             */
-            nextright--;
-            if (nextright < 0)
-                nextright = count - 1;
-
-            /*
-             *  now compute all of the random information
-             *  needed to run the iterative algorithm.
-             */
-            BRESINITPGON(ptsIn[nextright].y - ptsIn[right].y,
-                         ptsIn[right].x, ptsIn[nextright].x,
-                         xr, dr, mr, m1r, incr1r, incr2r);
-        }
-
-        /*
-         *  generate scans to fill while we still have
-         *  a right edge as well as a left edge.
-         */
-        i = min(ptsIn[nextleft].y, ptsIn[nextright].y) - y;
-        /* in case we're called with non-convex polygon */
-        if (i < 0) {
-            free(FirstWidth);
-            free(FirstPoint);
-            return TRUE;
-        }
-        while (i-- > 0) {
-            ptsOut->y = y;
-
-            /*
-             *  reverse the edges if necessary
-             */
-            if (xl < xr) {
-                *(width++) = xr - xl;
-                (ptsOut++)->x = xl;
-            }
-            else {
-                *(width++) = xl - xr;
-                (ptsOut++)->x = xr;
-            }
-            y++;
-
-            /* increment down the edges */
-            BRESINCRPGON(dl, xl, ml, m1l, incr1l, incr2l);
-            BRESINCRPGON(dr, xr, mr, m1r, incr1r, incr2r);
-        }
-    } while (y != ymax);
-
-    /*
-     * Finally, fill the <remaining> spans
-     */
-    (*pgc->ops->FillSpans) (dst, pgc,
-                            ptsOut - FirstPoint, FirstPoint, FirstWidth, 1);
-    free(FirstWidth);
-    free(FirstPoint);
-    return TRUE;
-}
-
-/*
- *     Find the index of the point with the smallest y.
- */
-static int
-getPolyYBounds(DDXPointPtr pts, int n, int *by, int *ty)
-{
-    DDXPointPtr ptMin;
-    int ymin, ymax;
-    DDXPointPtr ptsStart = pts;
-
-    ptMin = pts;
-    ymin = ymax = (pts++)->y;
-
-    while (--n > 0) {
-        if (pts->y < ymin) {
-            ptMin = pts;
-            ymin = pts->y;
-        }
-        if (pts->y > ymax)
-            ymax = pts->y;
-
-        pts++;
-    }
-
-    *by = ymin;
-    *ty = ymax;
-    return ptMin - ptsStart;
-}
diff --git a/mi/mipolygen.c b/mi/mipolygen.c
deleted file mode 100644
index 2031b42..0000000
--- a/mi/mipolygen.c
+++ /dev/null
@@ -1,213 +0,0 @@
-/***********************************************************
-
-Copyright 1987, 1998  The Open Group
-
-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.
-
-The above copyright notice and this permission notice 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
-OPEN GROUP 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.
-
-Except as contained in this notice, the name of The Open Group shall not be
-used in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization from The Open Group.
-
-Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
-
-                        All Rights Reserved
-
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
-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 Digital not be
-used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
-
-DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
-ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
-DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
-ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
-WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
-ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
-SOFTWARE.
-
-******************************************************************/
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include <X11/X.h>
-#include "gcstruct.h"
-#include "miscanfill.h"
-#include "mipoly.h"
-#include "pixmap.h"
-#include "mi.h"
-
-/*
- *
- *     Written by Brian Kelleher;  Oct. 1985
- *
- *     Routine to fill a polygon.  Two fill rules are
- *     supported: frWINDING and frEVENODD.
- *
- *     See fillpoly.h for a complete description of the algorithm.
- */
-
-Bool
-miFillGeneralPoly(DrawablePtr dst, GCPtr pgc, int count,        /* number of points        */
-                  DDXPointPtr ptsIn     /* the points              */
-    )
-{
-    EdgeTableEntry *pAET;       /* the Active Edge Table   */
-    int y;                      /* the current scanline    */
-    int nPts = 0;               /* number of pts in buffer */
-    EdgeTableEntry *pWETE;      /* Winding Edge Table      */
-    ScanLineList *pSLL;         /* Current ScanLineList    */
-    DDXPointPtr ptsOut;         /* ptr to output buffers   */
-    int *width;
-    DDXPointRec FirstPoint[NUMPTSTOBUFFER];     /* the output buffers */
-    int FirstWidth[NUMPTSTOBUFFER];
-    EdgeTableEntry *pPrevAET;   /* previous AET entry      */
-    EdgeTable ET;               /* Edge Table header node  */
-    EdgeTableEntry AET;         /* Active ET header node   */
-    EdgeTableEntry *pETEs;      /* Edge Table Entries buff */
-    ScanLineListBlock SLLBlock; /* header for ScanLineList */
-    int fixWAET = 0;
-
-    if (count < 3)
-        return TRUE;
-
-    if (!(pETEs = malloc(sizeof(EdgeTableEntry) * count)))
-        return FALSE;
-    ptsOut = FirstPoint;
-    width = FirstWidth;
-    if (!miCreateETandAET(count, ptsIn, &ET, &AET, pETEs, &SLLBlock)) {
-        free(pETEs);
-        return FALSE;
-    }
-    pSLL = ET.scanlines.next;
-
-    if (pgc->fillRule == EvenOddRule) {
-        /*
-         *  for each scanline
-         */
-        for (y = ET.ymin; y < ET.ymax; y++) {
-            /*
-             *  Add a new edge to the active edge table when we
-             *  get to the next edge.
-             */
-            if (pSLL && y == pSLL->scanline) {
-                miloadAET(&AET, pSLL->edgelist);
-                pSLL = pSLL->next;
-            }
-            pPrevAET = &AET;
-            pAET = AET.next;
-
-            /*
-             *  for each active edge
-             */
-            while (pAET) {
-                ptsOut->x = pAET->bres.minor;
-                ptsOut++->y = y;
-                *width++ = pAET->next->bres.minor - pAET->bres.minor;
-                nPts++;
-
-                /*
-                 *  send out the buffer when its full
-                 */
-                if (nPts == NUMPTSTOBUFFER) {
-                    (*pgc->ops->FillSpans) (dst, pgc,
-                                            nPts, FirstPoint, FirstWidth, 1);
-                    ptsOut = FirstPoint;
-                    width = FirstWidth;
-                    nPts = 0;
-                }
-                EVALUATEEDGEEVENODD(pAET, pPrevAET, y)
-                    EVALUATEEDGEEVENODD(pAET, pPrevAET, y);
-            }
-            miInsertionSort(&AET);
-        }
-    }
-    else {                      /* default to WindingNumber */
-
-        /*
-         *  for each scanline
-         */
-        for (y = ET.ymin; y < ET.ymax; y++) {
-            /*
-             *  Add a new edge to the active edge table when we
-             *  get to the next edge.
-             */
-            if (pSLL && y == pSLL->scanline) {
-                miloadAET(&AET, pSLL->edgelist);
-                micomputeWAET(&AET);
-                pSLL = pSLL->next;
-            }
-            pPrevAET = &AET;
-            pAET = AET.next;
-            pWETE = pAET;
-
-            /*
-             *  for each active edge
-             */
-            while (pAET) {
-                /*
-                 *  if the next edge in the active edge table is
-                 *  also the next edge in the winding active edge
-                 *  table.
-                 */
-                if (pWETE == pAET) {
-                    ptsOut->x = pAET->bres.minor;
-                    ptsOut++->y = y;
-                    *width++ = pAET->nextWETE->bres.minor - pAET->bres.minor;
-                    nPts++;
-
-                    /*
-                     *  send out the buffer
-                     */
-                    if (nPts == NUMPTSTOBUFFER) {
-                        (*pgc->ops->FillSpans) (dst, pgc, nPts, FirstPoint,
-                                                FirstWidth, 1);
-                        ptsOut = FirstPoint;
-                        width = FirstWidth;
-                        nPts = 0;
-                    }
-
-                    pWETE = pWETE->nextWETE;
-                    while (pWETE != pAET)
-                        EVALUATEEDGEWINDING(pAET, pPrevAET, y, fixWAET);
-                    pWETE = pWETE->nextWETE;
-                }
-                EVALUATEEDGEWINDING(pAET, pPrevAET, y, fixWAET);
-            }
-
-            /*
-             *  reevaluate the Winding active edge table if we
-             *  just had to resort it or if we just exited an edge.
-             */
-            if (miInsertionSort(&AET) || fixWAET) {
-                micomputeWAET(&AET);
-                fixWAET = 0;
-            }
-        }
-    }
-
-    /*
-     *     Get any spans that we missed by buffering
-     */
-    (*pgc->ops->FillSpans) (dst, pgc, nPts, FirstPoint, FirstWidth, 1);
-    free(pETEs);
-    miFreeStorage(SLLBlock.next);
-    return TRUE;
-}
commit 7679afd4da8b86aed27e5916ba723116a3c8bb4a
Author: Adam Jackson <ajax at redhat.com>
Date:   Fri Sep 26 12:01:37 2014 -0400

    mi: Fold mifpolycon.c into miarc.c
    
    Also put mifpoly.h on a diet, and stop including it from places that
    don't need it.
    
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/hw/xfree86/sdksyms.sh b/hw/xfree86/sdksyms.sh
index 9c3c02f..2305073 100755
--- a/hw/xfree86/sdksyms.sh
+++ b/hw/xfree86/sdksyms.sh
@@ -217,7 +217,6 @@ cat > sdksyms.c << EOF
 #include "micoord.h"
 #include "mifillarc.h"
 #include "mistruct.h"
-#include "mifpoly.h"
 #include "mioverlay.h"
 
 
diff --git a/mi/Makefile.am b/mi/Makefile.am
index 149dc06..d9139a3 100644
--- a/mi/Makefile.am
+++ b/mi/Makefile.am
@@ -24,7 +24,6 @@ libmi_la_SOURCES = 	\
 	mifillarc.c	\
 	mifillarc.h	\
 	mifillrct.c	\
-	mifpolycon.c	\
 	mifpoly.h	\
 	migc.c		\
 	migc.h		\
diff --git a/mi/miarc.c b/mi/miarc.c
index e55108a..7bbe5b3 100644
--- a/mi/miarc.c
+++ b/mi/miarc.c
@@ -63,6 +63,22 @@ SOFTWARE.
 #include "mifillarc.h"
 #include <X11/Xfuncproto.h>
 
+#define EPSILON	0.000001
+#define ISEQUAL(a,b) (fabs((a) - (b)) <= EPSILON)
+#define UNEQUAL(a,b) (fabs((a) - (b)) > EPSILON)
+#define PTISEQUAL(a,b) (ISEQUAL(a.x,b.x) && ISEQUAL(a.y,b.y))
+#define SQSECANT 108.856472512142   /* 1/sin^2(11/2) - for 11o miter cutoff */
+
+/* Point with sub-pixel positioning. */
+typedef struct _SppPoint {
+    double x, y;
+} SppPointRec, *SppPointPtr;
+
+typedef struct _SppArc {
+    double x, y, width, height;
+    double angle1, angle2;
+} SppArcRec, *SppArcPtr;
+
 static double miDsin(double a);
 static double miDcos(double a);
 static double miDasin(double v);
@@ -1110,6 +1126,195 @@ miWideArc(DrawablePtr pDraw, GCPtr pGC, int narcs, xArc * parcs)
     }
 }
 
+/* Find the index of the point with the smallest y.also return the
+ * smallest and largest y */
+static int
+GetFPolyYBounds(SppPointPtr pts, int n, double yFtrans, int *by, int *ty)
+{
+    SppPointPtr ptMin;
+    double ymin, ymax;
+    SppPointPtr ptsStart = pts;
+
+    ptMin = pts;
+    ymin = ymax = (pts++)->y;
+
+    while (--n > 0) {
+        if (pts->y < ymin) {
+            ptMin = pts;
+            ymin = pts->y;
+        }
+        if (pts->y > ymax)
+            ymax = pts->y;
+
+        pts++;
+    }
+
+    *by = ICEIL(ymin + yFtrans);
+    *ty = ICEIL(ymax + yFtrans - 1);
+    return ptMin - ptsStart;
+}
+
+/*
+ *	miFillSppPoly written by Todd Newman; April. 1987.
+ *
+ *	Fill a convex polygon.  If the given polygon
+ *	is not convex, then the result is undefined.
+ *	The algorithm is to order the edges from smallest
+ *	y to largest by partitioning the array into a left
+ *	edge list and a right edge list.  The algorithm used
+ *	to traverse each edge is digital differencing analyzer
+ *	line algorithm with y as the major axis. There's some funny linear
+ *	interpolation involved because of the subpixel postioning.
+ */
+static void
+miFillSppPoly(DrawablePtr dst, GCPtr pgc, int count,    /* number of points */
+              SppPointPtr ptsIn,        /* the points */
+              int xTrans, int yTrans,   /* Translate each point by this */
+              double xFtrans, double yFtrans    /* translate before conversion
+                                                   by this amount.  This provides
+                                                   a mechanism to match rounding
+                                                   errors with any shape that must
+                                                   meet the polygon exactly.
+                                                 */
+    )
+{
+    double xl = 0.0, xr = 0.0,  /* x vals of left and right edges */
+        ml = 0.0,               /* left edge slope */
+        mr = 0.0,               /* right edge slope */
+        dy,                     /* delta y */
+        i;                      /* loop counter */
+    int y,                      /* current scanline */
+     j, imin,                   /* index of vertex with smallest y */
+     ymin,                      /* y-extents of polygon */
+     ymax, *width, *FirstWidth, /* output buffer */
+    *Marked;                    /* set if this vertex has been used */
+    int left, right,            /* indices to first endpoints */
+     nextleft, nextright;       /* indices to second endpoints */
+    DDXPointPtr ptsOut, FirstPoint;     /* output buffer */
+
+    if (pgc->miTranslate) {
+        xTrans += dst->x;
+        yTrans += dst->y;
+    }
+
+    imin = GetFPolyYBounds(ptsIn, count, yFtrans, &ymin, &ymax);
+
+    y = ymax - ymin + 1;
+    if ((count < 3) || (y <= 0))
+        return;
+    ptsOut = FirstPoint = malloc(sizeof(DDXPointRec) * y);
+    width = FirstWidth = malloc(sizeof(int) * y);
+    Marked = malloc(sizeof(int) * count);
+
+    if (!ptsOut || !width || !Marked) {
+        free(Marked);
+        free(width);
+        free(ptsOut);
+        return;
+    }
+
+    for (j = 0; j < count; j++)
+        Marked[j] = 0;
+    nextleft = nextright = imin;
+    Marked[imin] = -1;
+    y = ICEIL(ptsIn[nextleft].y + yFtrans);
+
+    /*
+     *  loop through all edges of the polygon
+     */
+    do {
+        /* add a left edge if we need to */
+        if ((y > (ptsIn[nextleft].y + yFtrans) ||
+             ISEQUAL(y, ptsIn[nextleft].y + yFtrans)) &&
+            Marked[nextleft] != 1) {
+            Marked[nextleft]++;
+            left = nextleft++;
+
+            /* find the next edge, considering the end conditions */
+            if (nextleft >= count)
+                nextleft = 0;
+
+            /* now compute the starting point and slope */
+            dy = ptsIn[nextleft].y - ptsIn[left].y;
+            if (dy != 0.0) {
+                ml = (ptsIn[nextleft].x - ptsIn[left].x) / dy;
+                dy = y - (ptsIn[left].y + yFtrans);
+                xl = (ptsIn[left].x + xFtrans) + ml * max(dy, 0);
+            }
+        }
+
+        /* add a right edge if we need to */
+        if ((y > ptsIn[nextright].y + yFtrans) ||
+            (ISEQUAL(y, ptsIn[nextright].y + yFtrans)
+             && Marked[nextright] != 1)) {
+            Marked[nextright]++;
+            right = nextright--;
+
+            /* find the next edge, considering the end conditions */
+            if (nextright < 0)
+                nextright = count - 1;
+
+            /* now compute the starting point and slope */
+            dy = ptsIn[nextright].y - ptsIn[right].y;
+            if (dy != 0.0) {
+                mr = (ptsIn[nextright].x - ptsIn[right].x) / dy;
+                dy = y - (ptsIn[right].y + yFtrans);
+                xr = (ptsIn[right].x + xFtrans) + mr * max(dy, 0);
+            }
+        }
+
+        /*
+         *  generate scans to fill while we still have
+         *  a right edge as well as a left edge.
+         */
+        i = (min(ptsIn[nextleft].y, ptsIn[nextright].y) + yFtrans) - y;
+
+        if (i < EPSILON) {
+            if (Marked[nextleft] && Marked[nextright]) {
+                /* Arrgh, we're trapped! (no more points)
+                 * Out, we've got to get out of here before this decadence saps
+                 * our will completely! */
+                break;
+            }
+            continue;
+        }
+        else {
+            j = (int) i;
+            if (!j)
+                j++;
+        }
+        while (j > 0) {
+            int cxl, cxr;
+
+            ptsOut->y = (y) + yTrans;
+
+            cxl = ICEIL(xl);
+            cxr = ICEIL(xr);
+            /* reverse the edges if necessary */
+            if (xl < xr) {
+                *(width++) = cxr - cxl;
+                (ptsOut++)->x = cxl + xTrans;
+            }
+            else {
+                *(width++) = cxl - cxr;
+                (ptsOut++)->x = cxr + xTrans;
+            }
+            y++;
+
+            /* increment down the edges */
+            xl += ml;
+            xr += mr;
+            j--;
+        }
+    } while (y <= ymax);
+
+    /* Finally, fill the spans we've collected */
+    (*pgc->ops->FillSpans) (dst, pgc,
+                            ptsOut - FirstPoint, FirstPoint, FirstWidth, 1);
+    free(Marked);
+    free(FirstWidth);
+    free(FirstPoint);
+}
 static double
 angleBetween(SppPointRec center, SppPointRec point1, SppPointRec point2)
 {
diff --git a/mi/midash.c b/mi/midash.c
index 78cbaf2..50b0fbe 100644
--- a/mi/midash.c
+++ b/mi/midash.c
@@ -49,7 +49,6 @@ SOFTWARE.
 
 #include "regionstr.h"
 #include "mistruct.h"
-#include "mifpoly.h"
 
 void
 miStepDash(int dist,            /* distance to step */
diff --git a/mi/mifillarc.c b/mi/mifillarc.c
index 9a5e785..246d70f 100644
--- a/mi/mifillarc.c
+++ b/mi/mifillarc.c
@@ -36,7 +36,6 @@ Author:  Bob Scheifler, MIT X Consortium
 #include "regionstr.h"
 #include "gcstruct.h"
 #include "pixmapstr.h"
-#include "mifpoly.h"
 #include "mi.h"
 #include "mifillarc.h"
 
diff --git a/mi/mifpoly.h b/mi/mifpoly.h
index 4b27d1c..9304c6f 100644
--- a/mi/mifpoly.h
+++ b/mi/mifpoly.h
@@ -49,24 +49,6 @@ SOFTWARE.
 
 #include <X11/Xfuncproto.h>
 
-#define EPSILON	0.000001
-#define ISEQUAL(a,b) (fabs((a) - (b)) <= EPSILON)
-#define UNEQUAL(a,b) (fabs((a) - (b)) > EPSILON)
-#define WITHINHALF(a, b) (((a) - (b) > 0.0) ? (a) - (b) < 0.5 : \
-					     (b) - (a) <= 0.5)
-#define ROUNDTOINT(x)   ((int) (((x) > 0.0) ? ((x) + 0.5) : ((x) - 0.5)))
-#define ISZERO(x) 	(fabs((x)) <= EPSILON)
-#define PTISEQUAL(a,b) (ISEQUAL(a.x,b.x) && ISEQUAL(a.y,b.y))
-#define PTUNEQUAL(a,b) (UNEQUAL(a.x,b.x) || UNEQUAL(a.y,b.y))
-#define PtEqual(a, b) (((a).x == (b).x) && ((a).y == (b).y))
-
-#define NotEnd		0
-#define FirstEnd	1
-#define SecondEnd	2
-
-#define SQSECANT 108.856472512142       /* 1/sin^2(11/2) - for 11o miter cutoff */
-#define D2SECANT 5.21671526231167       /* 1/2*sin(11/2) - max extension per width */
-
 static _X_INLINE int
 ICEIL(double x)
 {
@@ -75,27 +57,4 @@ ICEIL(double x)
     return ((x == _cTmp) || (x < 0.0)) ? _cTmp : _cTmp + 1;
 }
 
-/* Point with sub-pixel positioning.  In this case we use doubles, but
- * see mifpolycon.c for other suggestions 
- */
-typedef struct _SppPoint {
-    double x, y;
-} SppPointRec, *SppPointPtr;
-
-typedef struct _SppArc {
-    double x, y, width, height;
-    double angle1, angle2;
-} SppArcRec, *SppArcPtr;
-
-/* mifpolycon.c */
-
-extern void miFillSppPoly(DrawablePtr /*dst */ ,
-                          GCPtr /*pgc */ ,
-                          int /*count */ ,
-                          SppPointPtr /*ptsIn */ ,
-                          int /*xTrans */ ,
-                          int /*yTrans */ ,
-                          double /*xFtrans */ ,
-                          double      /*yFtrans */);
-
 #endif                          /* __MIFPOLY_H__ */
diff --git a/mi/mifpolycon.c b/mi/mifpolycon.c
deleted file mode 100644
index b133731..0000000
--- a/mi/mifpolycon.c
+++ /dev/null
@@ -1,249 +0,0 @@
-/***********************************************************
-
-Copyright 1987, 1998  The Open Group
-
-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.
-
-The above copyright notice and this permission notice 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
-OPEN GROUP 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.
-
-Except as contained in this notice, the name of The Open Group shall not be
-used in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization from The Open Group.
-
-Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
-
-                        All Rights Reserved
-
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
-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 Digital not be
-used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
-
-DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
-ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
-DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
-ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
-WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
-ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
-SOFTWARE.
-
-******************************************************************/
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include <math.h>
-#include <X11/X.h>
-#include "gcstruct.h"
-#include "windowstr.h"
-#include "pixmapstr.h"
-#include "mifpoly.h"
-
-static int GetFPolyYBounds(SppPointPtr pts, int n, double yFtrans,
-                           int *by, int *ty);
-
-/*
- *	Written by Todd Newman; April. 1987.
- *
- *	Fill a convex polygon.  If the given polygon
- *	is not convex, then the result is undefined.
- *	The algorithm is to order the edges from smallest
- *	y to largest by partitioning the array into a left
- *	edge list and a right edge list.  The algorithm used
- *	to traverse each edge is digital differencing analyzer
- *	line algorithm with y as the major axis. There's some funny linear
- *	interpolation involved because of the subpixel postioning.
- */
-void
-miFillSppPoly(DrawablePtr dst, GCPtr pgc, int count,    /* number of points */
-              SppPointPtr ptsIn,        /* the points */
-              int xTrans, int yTrans,   /* Translate each point by this */
-              double xFtrans, double yFtrans    /* translate before conversion
-                                                   by this amount.  This provides
-                                                   a mechanism to match rounding
-                                                   errors with any shape that must
-                                                   meet the polygon exactly.
-                                                 */
-    )
-{
-    double xl = 0.0, xr = 0.0,  /* x vals of left and right edges */
-        ml = 0.0,               /* left edge slope */
-        mr = 0.0,               /* right edge slope */
-        dy,                     /* delta y */
-        i;                      /* loop counter */
-    int y,                      /* current scanline */
-     j, imin,                   /* index of vertex with smallest y */
-     ymin,                      /* y-extents of polygon */
-     ymax, *width, *FirstWidth, /* output buffer */
-    *Marked;                    /* set if this vertex has been used */
-    int left, right,            /* indices to first endpoints */
-     nextleft, nextright;       /* indices to second endpoints */
-    DDXPointPtr ptsOut, FirstPoint;     /* output buffer */
-
-    if (pgc->miTranslate) {
-        xTrans += dst->x;
-        yTrans += dst->y;
-    }
-
-    imin = GetFPolyYBounds(ptsIn, count, yFtrans, &ymin, &ymax);
-
-    y = ymax - ymin + 1;
-    if ((count < 3) || (y <= 0))
-        return;
-    ptsOut = FirstPoint = malloc(sizeof(DDXPointRec) * y);
-    width = FirstWidth = malloc(sizeof(int) * y);
-    Marked = malloc(sizeof(int) * count);
-
-    if (!ptsOut || !width || !Marked) {
-        free(Marked);
-        free(width);
-        free(ptsOut);
-        return;
-    }
-
-    for (j = 0; j < count; j++)
-        Marked[j] = 0;
-    nextleft = nextright = imin;
-    Marked[imin] = -1;
-    y = ICEIL(ptsIn[nextleft].y + yFtrans);
-
-    /*
-     *  loop through all edges of the polygon
-     */
-    do {
-        /* add a left edge if we need to */
-        if ((y > (ptsIn[nextleft].y + yFtrans) ||
-             ISEQUAL(y, ptsIn[nextleft].y + yFtrans)) &&
-            Marked[nextleft] != 1) {
-            Marked[nextleft]++;
-            left = nextleft++;
-
-            /* find the next edge, considering the end conditions */
-            if (nextleft >= count)
-                nextleft = 0;
-
-            /* now compute the starting point and slope */
-            dy = ptsIn[nextleft].y - ptsIn[left].y;
-            if (dy != 0.0) {
-                ml = (ptsIn[nextleft].x - ptsIn[left].x) / dy;
-                dy = y - (ptsIn[left].y + yFtrans);
-                xl = (ptsIn[left].x + xFtrans) + ml * max(dy, 0);
-            }
-        }
-
-        /* add a right edge if we need to */
-        if ((y > ptsIn[nextright].y + yFtrans) ||
-            (ISEQUAL(y, ptsIn[nextright].y + yFtrans)
-             && Marked[nextright] != 1)) {
-            Marked[nextright]++;
-            right = nextright--;
-
-            /* find the next edge, considering the end conditions */
-            if (nextright < 0)
-                nextright = count - 1;
-
-            /* now compute the starting point and slope */
-            dy = ptsIn[nextright].y - ptsIn[right].y;
-            if (dy != 0.0) {
-                mr = (ptsIn[nextright].x - ptsIn[right].x) / dy;
-                dy = y - (ptsIn[right].y + yFtrans);
-                xr = (ptsIn[right].x + xFtrans) + mr * max(dy, 0);
-            }
-        }
-
-        /*
-         *  generate scans to fill while we still have
-         *  a right edge as well as a left edge.
-         */
-        i = (min(ptsIn[nextleft].y, ptsIn[nextright].y) + yFtrans) - y;
-
-        if (i < EPSILON) {
-            if (Marked[nextleft] && Marked[nextright]) {
-                /* Arrgh, we're trapped! (no more points) 
-                 * Out, we've got to get out of here before this decadence saps
-                 * our will completely! */
-                break;
-            }
-            continue;
-        }
-        else {
-            j = (int) i;
-            if (!j)
-                j++;
-        }
-        while (j > 0) {
-            int cxl, cxr;
-
-            ptsOut->y = (y) + yTrans;
-
-            cxl = ICEIL(xl);
-            cxr = ICEIL(xr);
-            /* reverse the edges if necessary */
-            if (xl < xr) {
-                *(width++) = cxr - cxl;
-                (ptsOut++)->x = cxl + xTrans;
-            }
-            else {
-                *(width++) = cxl - cxr;
-                (ptsOut++)->x = cxr + xTrans;
-            }
-            y++;
-
-            /* increment down the edges */
-            xl += ml;
-            xr += mr;
-            j--;
-        }
-    } while (y <= ymax);
-
-    /* Finally, fill the spans we've collected */
-    (*pgc->ops->FillSpans) (dst, pgc,
-                            ptsOut - FirstPoint, FirstPoint, FirstWidth, 1);
-    free(Marked);
-    free(FirstWidth);
-    free(FirstPoint);
-}
-
-/* Find the index of the point with the smallest y.also return the
- * smallest and largest y */
-static
-    int
-GetFPolyYBounds(SppPointPtr pts, int n, double yFtrans, int *by, int *ty)
-{
-    SppPointPtr ptMin;
-    double ymin, ymax;
-    SppPointPtr ptsStart = pts;
-
-    ptMin = pts;
-    ymin = ymax = (pts++)->y;
-
-    while (--n > 0) {
-        if (pts->y < ymin) {
-            ptMin = pts;
-            ymin = pts->y;
-        }
-        if (pts->y > ymax)
-            ymax = pts->y;
-
-        pts++;
-    }
-
-    *by = ICEIL(ymin + yFtrans);
-    *ty = ICEIL(ymax + yFtrans - 1);
-    return ptMin - ptsStart;
-}
commit f307ef10f4c33da4b5ae59800931741b0a431d75
Author: Adam Jackson <ajax at redhat.com>
Date:   Mon Jul 21 17:22:07 2014 -0400

    mi: Fold mispans.c into miwideline.c
    
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/hw/xfree86/sdksyms.sh b/hw/xfree86/sdksyms.sh
index c2a1942..9c3c02f 100755
--- a/hw/xfree86/sdksyms.sh
+++ b/hw/xfree86/sdksyms.sh
@@ -216,7 +216,6 @@ cat > sdksyms.c << EOF
 #include "mizerarc.h"
 #include "micoord.h"
 #include "mifillarc.h"
-#include "mispans.h"
 #include "mistruct.h"
 #include "mifpoly.h"
 #include "mioverlay.h"
diff --git a/mi/Makefile.am b/mi/Makefile.am
index 4466f69..149dc06 100644
--- a/mi/Makefile.am
+++ b/mi/Makefile.am
@@ -47,8 +47,6 @@ libmi_la_SOURCES = 	\
 	mipushpxl.c	\
 	miscanfill.h	\
 	miscrinit.c	\
-	mispans.c	\
-	mispans.h	\
 	misprite.c	\
 	misprite.h	\
 	mistruct.h	\
diff --git a/mi/mispans.c b/mi/mispans.c
deleted file mode 100644
index 11c8a43..0000000
--- a/mi/mispans.c
+++ /dev/null
@@ -1,526 +0,0 @@
-/***********************************************************
-
-Copyright 1989, 1998  The Open Group
-
-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.
-
-The above copyright notice and this permission notice 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
-OPEN GROUP 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.
-
-Except as contained in this notice, the name of The Open Group shall not be
-used in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization from The Open Group.
-
-Copyright 1989 by Digital Equipment Corporation, Maynard, Massachusetts.
-
-                        All Rights Reserved
-
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
-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 Digital not be
-used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
-
-DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
-ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
-DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
-ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
-WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
-ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
-SOFTWARE.
-
-******************************************************************/
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "misc.h"
-#include "pixmapstr.h"
-#include "gcstruct.h"
-#include "mispans.h"
-
-/*
-
-These routines maintain lists of Spans, in order to implement the
-``touch-each-pixel-once'' rules of wide lines and arcs.
-
-Written by Joel McCormack, Summer 1989.
-
-*/
-
-void
-miInitSpanGroup(SpanGroup * spanGroup)
-{
-    spanGroup->size = 0;
-    spanGroup->count = 0;
-    spanGroup->group = NULL;
-    spanGroup->ymin = MAXSHORT;
-    spanGroup->ymax = MINSHORT;
-}                               /* InitSpanGroup */
-
-#define YMIN(spans) (spans->points[0].y)
-#define YMAX(spans)  (spans->points[spans->count-1].y)
-
-static void
-miSubtractSpans(SpanGroup * spanGroup, Spans * sub)
-{
-    int i, subCount, spansCount;
-    int ymin, ymax, xmin, xmax;
-    Spans *spans;
-    DDXPointPtr subPt, spansPt;
-    int *subWid, *spansWid;
-    int extra;
-
-    ymin = YMIN(sub);
-    ymax = YMAX(sub);
-    spans = spanGroup->group;
-    for (i = spanGroup->count; i; i--, spans++) {
-        if (YMIN(spans) <= ymax && ymin <= YMAX(spans)) {
-            subCount = sub->count;
-            subPt = sub->points;
-            subWid = sub->widths;
-            spansCount = spans->count;
-            spansPt = spans->points;
-            spansWid = spans->widths;
-            extra = 0;
-            for (;;) {
-                while (spansCount && spansPt->y < subPt->y) {
-                    spansPt++;
-                    spansWid++;
-                    spansCount--;
-                }
-                if (!spansCount)
-                    break;
-                while (subCount && subPt->y < spansPt->y) {
-                    subPt++;
-                    subWid++;
-                    subCount--;
-                }
-                if (!subCount)
-                    break;
-                if (subPt->y == spansPt->y) {
-                    xmin = subPt->x;
-                    xmax = xmin + *subWid;
-                    if (xmin >= spansPt->x + *spansWid || spansPt->x >= xmax) {
-                        ;
-                    }
-                    else if (xmin <= spansPt->x) {
-                        if (xmax >= spansPt->x + *spansWid) {
-                            memmove(spansPt, spansPt + 1,
-                                    sizeof *spansPt * (spansCount - 1));
-                            memmove(spansWid, spansWid + 1,
-                                    sizeof *spansWid * (spansCount - 1));
-                            spansPt--;
-                            spansWid--;
-                            spans->count--;
-                            extra++;
-                        }
-                        else {
-                            *spansWid = *spansWid - (xmax - spansPt->x);
-                            spansPt->x = xmax;
-                        }
-                    }
-                    else {
-                        if (xmax >= spansPt->x + *spansWid) {
-                            *spansWid = xmin - spansPt->x;
-                        }
-                        else {
-                            if (!extra) {
-                                DDXPointPtr newPt;
-                                int *newwid;
-
-#define EXTRA 8
-                                newPt =
-                                    (DDXPointPtr) realloc(spans->points,
-                                                          (spans->count +
-                                                           EXTRA) *
-                                                          sizeof(DDXPointRec));
-                                if (!newPt)
-                                    break;
-                                spansPt = newPt + (spansPt - spans->points);
-                                spans->points = newPt;
-                                newwid =
-                                    (int *) realloc(spans->widths,
-                                                    (spans->count +
-                                                     EXTRA) * sizeof(int));
-                                if (!newwid)
-                                    break;
-                                spansWid = newwid + (spansWid - spans->widths);
-                                spans->widths = newwid;
-                                extra = EXTRA;
-                            }
-                            memmove(spansPt + 1, spansPt,
-                                    sizeof *spansPt * (spansCount));
-                            memmove(spansWid + 1, spansWid,
-                                    sizeof *spansWid * (spansCount));
-                            spans->count++;
-                            extra--;
-                            *spansWid = xmin - spansPt->x;
-                            spansWid++;
-                            spansPt++;
-                            *spansWid = *spansWid - (xmax - spansPt->x);
-                            spansPt->x = xmax;
-                        }
-                    }
-                }
-                spansPt++;
-                spansWid++;
-                spansCount--;
-            }
-        }
-    }
-}
-
-void
-miAppendSpans(SpanGroup * spanGroup, SpanGroup * otherGroup, Spans * spans)
-{
-    int ymin, ymax;
-    int spansCount;
-
-    spansCount = spans->count;
-    if (spansCount > 0) {
-        if (spanGroup->size == spanGroup->count) {
-            spanGroup->size = (spanGroup->size + 8) * 2;
-            spanGroup->group = (Spans *)
-                realloc(spanGroup->group, sizeof(Spans) * spanGroup->size);
-        }
-
-        spanGroup->group[spanGroup->count] = *spans;
-        (spanGroup->count)++;
-        ymin = spans->points[0].y;
-        if (ymin < spanGroup->ymin)
-            spanGroup->ymin = ymin;
-        ymax = spans->points[spansCount - 1].y;
-        if (ymax > spanGroup->ymax)
-            spanGroup->ymax = ymax;
-        if (otherGroup && otherGroup->ymin < ymax && ymin < otherGroup->ymax) {
-            miSubtractSpans(otherGroup, spans);
-        }
-    }
-    else {
-        free(spans->points);
-        free(spans->widths);
-    }
-}                               /* AppendSpans */
-
-void
-miFreeSpanGroup(SpanGroup * spanGroup)
-{
-    free(spanGroup->group);
-}
-
-static void
-QuickSortSpansX(DDXPointRec points[], int widths[], int numSpans)
-{
-    int x;
-    int i, j, m;
-    DDXPointPtr r;
-
-/* Always called with numSpans > 1 */
-/* Sorts only by x, as all y should be the same */
-
-#define ExchangeSpans(a, b)				    \
-{							    \
-    DDXPointRec 	tpt;				    \
-    int    		tw;				    \
-							    \
-    tpt = points[a]; points[a] = points[b]; points[b] = tpt;    \
-    tw = widths[a]; widths[a] = widths[b]; widths[b] = tw;  \
-}
-
-    do {
-        if (numSpans < 9) {
-            /* Do insertion sort */
-            int xprev;
-
-            xprev = points[0].x;
-            i = 1;
-            do {                /* while i != numSpans */
-                x = points[i].x;
-                if (xprev > x) {
-                    /* points[i] is out of order.  Move into proper location. */
-                    DDXPointRec tpt;
-                    int tw, k;
-
-                    for (j = 0; x >= points[j].x; j++) {
-                    }
-                    tpt = points[i];
-                    tw = widths[i];
-                    for (k = i; k != j; k--) {
-                        points[k] = points[k - 1];
-                        widths[k] = widths[k - 1];
-                    }
-                    points[j] = tpt;
-                    widths[j] = tw;
-                    x = points[i].x;
-                }               /* if out of order */
-                xprev = x;
-                i++;
-            } while (i != numSpans);
-            return;
-        }
-
-        /* Choose partition element, stick in location 0 */
-        m = numSpans / 2;
-        if (points[m].x > points[0].x)
-            ExchangeSpans(m, 0);
-        if (points[m].x > points[numSpans - 1].x)
-            ExchangeSpans(m, numSpans - 1);
-        if (points[m].x > points[0].x)
-            ExchangeSpans(m, 0);
-        x = points[0].x;
-
-        /* Partition array */
-        i = 0;
-        j = numSpans;
-        do {
-            r = &(points[i]);
-            do {
-                r++;
-                i++;
-            } while (i != numSpans && r->x < x);
-            r = &(points[j]);
-            do {
-                r--;
-                j--;
-            } while (x < r->x);
-            if (i < j)
-                ExchangeSpans(i, j);
-        } while (i < j);
-
-        /* Move partition element back to middle */
-        ExchangeSpans(0, j);
-
-        /* Recurse */
-        if (numSpans - j - 1 > 1)
-            QuickSortSpansX(&points[j + 1], &widths[j + 1], numSpans - j - 1);
-        numSpans = j;
-    } while (numSpans > 1);
-}                               /* QuickSortSpans */
-
-static int
-UniquifySpansX(Spans * spans, DDXPointRec * newPoints, int *newWidths)
-{
-    int newx1, newx2, oldpt, i, y;
-    DDXPointRec *oldPoints;
-    int *oldWidths;
-    int *startNewWidths;
-
-/* Always called with numSpans > 1 */
-/* Uniquify the spans, and stash them into newPoints and newWidths.  Return the
-   number of unique spans. */
-
-    startNewWidths = newWidths;
-
-    oldPoints = spans->points;
-    oldWidths = spans->widths;
-
-    y = oldPoints->y;
-    newx1 = oldPoints->x;
-    newx2 = newx1 + *oldWidths;
-
-    for (i = spans->count - 1; i != 0; i--) {
-        oldPoints++;
-        oldWidths++;
-        oldpt = oldPoints->x;
-        if (oldpt > newx2) {
-            /* Write current span, start a new one */
-            newPoints->x = newx1;
-            newPoints->y = y;
-            *newWidths = newx2 - newx1;
-            newPoints++;
-            newWidths++;
-            newx1 = oldpt;
-            newx2 = oldpt + *oldWidths;
-        }
-        else {
-            /* extend current span, if old extends beyond new */
-            oldpt = oldpt + *oldWidths;
-            if (oldpt > newx2)
-                newx2 = oldpt;
-        }
-    }                           /* for */
-
-    /* Write final span */
-    newPoints->x = newx1;
-    *newWidths = newx2 - newx1;
-    newPoints->y = y;
-
-    return (newWidths - startNewWidths) + 1;
-}                               /* UniquifySpansX */
-
-static void
-miDisposeSpanGroup(SpanGroup * spanGroup)
-{
-    int i;
-    Spans *spans;
-
-    for (i = 0; i < spanGroup->count; i++) {
-        spans = spanGroup->group + i;
-        free(spans->points);
-        free(spans->widths);
-    }
-}
-
-void
-miFillUniqueSpanGroup(DrawablePtr pDraw, GCPtr pGC, SpanGroup * spanGroup)
-{
-    int i;
-    Spans *spans;
-    Spans *yspans;
-    int *ysizes;
-    int ymin, ylength;
-
-    /* Outgoing spans for one big call to FillSpans */
-    DDXPointPtr points;
-    int *widths;
-    int count;
-
-    if (spanGroup->count == 0)
-        return;
-
-    if (spanGroup->count == 1) {
-        /* Already should be sorted, unique */
-        spans = spanGroup->group;
-        (*pGC->ops->FillSpans)
-            (pDraw, pGC, spans->count, spans->points, spans->widths, TRUE);
-        free(spans->points);
-        free(spans->widths);
-    }
-    else {
-        /* Yuck.  Gross.  Radix sort into y buckets, then sort x and uniquify */
-        /* This seems to be the fastest thing to do.  I've tried sorting on
-           both x and y at the same time rather than creating into all those
-           y buckets, but it was somewhat slower. */
-
-        ymin = spanGroup->ymin;
-        ylength = spanGroup->ymax - ymin + 1;
-
-        /* Allocate Spans for y buckets */
-        yspans = malloc(ylength * sizeof(Spans));
-        ysizes = malloc(ylength * sizeof(int));
-
-        if (!yspans || !ysizes) {
-            free(yspans);
-            free(ysizes);
-            miDisposeSpanGroup(spanGroup);
-            return;
-        }
-
-        for (i = 0; i != ylength; i++) {
-            ysizes[i] = 0;
-            yspans[i].count = 0;
-            yspans[i].points = NULL;
-            yspans[i].widths = NULL;
-        }
-
-        /* Go through every single span and put it into the correct bucket */
-        count = 0;
-        for (i = 0, spans = spanGroup->group;
-             i != spanGroup->count; i++, spans++) {
-            int index;
-            int j;
-
-            for (j = 0, points = spans->points, widths = spans->widths;
-                 j != spans->count; j++, points++, widths++) {
-                index = points->y - ymin;
-                if (index >= 0 && index < ylength) {
-                    Spans *newspans = &(yspans[index]);
-
-                    if (newspans->count == ysizes[index]) {
-                        DDXPointPtr newpoints;
-                        int *newwidths;
-
-                        ysizes[index] = (ysizes[index] + 8) * 2;
-                        newpoints = (DDXPointPtr) realloc(newspans->points,
-                                                          ysizes[index] *
-                                                          sizeof(DDXPointRec));
-                        newwidths =
-                            (int *) realloc(newspans->widths,
-                                            ysizes[index] * sizeof(int));
-                        if (!newpoints || !newwidths) {
-                            for (i = 0; i < ylength; i++) {
-                                free(yspans[i].points);
-                                free(yspans[i].widths);
-                            }
-                            free(yspans);
-                            free(ysizes);
-                            free(newpoints);
-                            free(newwidths);
-                            miDisposeSpanGroup(spanGroup);
-                            return;
-                        }
-                        newspans->points = newpoints;
-                        newspans->widths = newwidths;
-                    }
-                    newspans->points[newspans->count] = *points;
-                    newspans->widths[newspans->count] = *widths;
-                    (newspans->count)++;
-                }               /* if y value of span in range */
-            }                   /* for j through spans */
-            count += spans->count;
-            free(spans->points);
-            spans->points = NULL;
-            free(spans->widths);
-            spans->widths = NULL;
-        }                       /* for i thorough Spans */
-
-        /* Now sort by x and uniquify each bucket into the final array */
-        points = malloc(count * sizeof(DDXPointRec));
-        widths = malloc(count * sizeof(int));
-        if (!points || !widths) {
-            for (i = 0; i < ylength; i++) {
-                free(yspans[i].points);
-                free(yspans[i].widths);
-            }
-            free(yspans);
-            free(ysizes);
-            free(points);
-            free(widths);
-            return;
-        }
-        count = 0;
-        for (i = 0; i != ylength; i++) {
-            int ycount = yspans[i].count;
-
-            if (ycount > 0) {
-                if (ycount > 1) {
-                    QuickSortSpansX(yspans[i].points, yspans[i].widths, ycount);
-                    count += UniquifySpansX
-                        (&(yspans[i]), &(points[count]), &(widths[count]));
-                }
-                else {
-                    points[count] = yspans[i].points[0];
-                    widths[count] = yspans[i].widths[0];
-                    count++;
-                }
-                free(yspans[i].points);
-                free(yspans[i].widths);
-            }
-        }
-
-        (*pGC->ops->FillSpans) (pDraw, pGC, count, points, widths, TRUE);
-        free(points);
-        free(widths);
-        free(yspans);
-        free(ysizes);           /* use (DE)xalloc for these? */
-    }
-
-    spanGroup->count = 0;
-    spanGroup->ymin = MAXSHORT;
-    spanGroup->ymax = MINSHORT;
-}
diff --git a/mi/mispans.h b/mi/mispans.h
deleted file mode 100644
index 7c3fcef..0000000
--- a/mi/mispans.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/***********************************************************
-
-Copyright 1989, 1998  The Open Group
-
-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.
-
-The above copyright notice and this permission notice 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
-OPEN GROUP 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.
-
-Except as contained in this notice, the name of The Open Group shall not be
-used in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization from The Open Group.
-
-Copyright 1989 by Digital Equipment Corporation, Maynard, Massachusetts.
-
-                        All Rights Reserved
-
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
-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 Digital not be
-used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.  
-
-DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
-ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
-DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
-ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
-WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
-ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
-SOFTWARE.
-
-******************************************************************/
-
-#ifndef MISPANS_H
-#define MISPANS_H
-
-typedef struct {
-    int count;                  /* number of spans                  */
-    DDXPointPtr points;         /* pointer to list of start points  */
-    int *widths;                /* pointer to list of widths        */
-} Spans;
-
-typedef struct {
-    int size;                   /* Total number of *Spans allocated     */
-    int count;                  /* Number of *Spans actually in group   */
-    Spans *group;               /* List of Spans                        */
-    int ymin, ymax;             /* Min, max y values encountered        */
-} SpanGroup;
-
-/* Initialize SpanGroup.  MUST BE DONE before use. */
-extern void miInitSpanGroup(SpanGroup *       /*spanGroup */);
-
-/* Add a Spans to a SpanGroup. The spans MUST BE in y-sorted order */
-extern void miAppendSpans(SpanGroup * /*spanGroup */ ,
-                          SpanGroup * /*otherGroup */ ,
-                          Spans *     /*spans */);
-
-/* Paint a span group, insuring that each pixel is painted at most once */
-extern void miFillUniqueSpanGroup(DrawablePtr /*pDraw */ ,
-                                  GCPtr /*pGC */ ,
-                                  SpanGroup * /*spanGroup */);
-
-/* Free up data in a span group.  MUST BE DONE or you'll suffer memory leaks */
-extern void miFreeSpanGroup(SpanGroup *       /*spanGroup */);
-
-/* Rops which must use span groups */
-#define miSpansCarefulRop(rop)	(((rop) & 0xc) == 0x8 || ((rop) & 0x3) == 0x2)
-#define miSpansEasyRop(rop)	(!miSpansCarefulRop(rop))
-
-#endif                          /* MISPANS_H */
diff --git a/mi/miwideline.c b/mi/miwideline.c
index 295a05a..452d74f 100644
--- a/mi/miwideline.c
+++ b/mi/miwideline.c
@@ -24,6 +24,25 @@ not be used in advertising or otherwise to promote the sale, use or
 other dealings in this Software without prior written authorization
 from The Open Group.
 
+Copyright 1989 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+                        All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted,
+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 Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL 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.
 */
 
 /* Author:  Keith Packard, MIT X Consortium */
@@ -52,6 +71,505 @@ from The Open Group.
 #include "miwideline.h"
 #include "mi.h"
 
+#if 0
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "misc.h"
+#include "pixmapstr.h"
+#include "gcstruct.h"
+#endif
+
+typedef struct {
+    int count;                  /* number of spans                  */
+    DDXPointPtr points;         /* pointer to list of start points  */
+    int *widths;                /* pointer to list of widths        */
+} Spans;
+
+typedef struct {
+    int size;                   /* Total number of *Spans allocated     */
+    int count;                  /* Number of *Spans actually in group   */
+    Spans *group;               /* List of Spans                        */
+    int ymin, ymax;             /* Min, max y values encountered        */
+} SpanGroup;
+
+/* Rops which must use span groups */
+#define miSpansCarefulRop(rop)	(((rop) & 0xc) == 0x8 || ((rop) & 0x3) == 0x2)
+#define miSpansEasyRop(rop)	(!miSpansCarefulRop(rop))
+
+/*
+
+These routines maintain lists of Spans, in order to implement the
+``touch-each-pixel-once'' rules of wide lines and arcs.
+
+Written by Joel McCormack, Summer 1989.
+
+*/
+
+static void
+miInitSpanGroup(SpanGroup * spanGroup)
+{
+    spanGroup->size = 0;
+    spanGroup->count = 0;
+    spanGroup->group = NULL;
+    spanGroup->ymin = MAXSHORT;
+    spanGroup->ymax = MINSHORT;
+}                               /* InitSpanGroup */
+
+#define YMIN(spans) (spans->points[0].y)
+#define YMAX(spans)  (spans->points[spans->count-1].y)
+
+static void
+miSubtractSpans(SpanGroup * spanGroup, Spans * sub)
+{
+    int i, subCount, spansCount;
+    int ymin, ymax, xmin, xmax;
+    Spans *spans;
+    DDXPointPtr subPt, spansPt;
+    int *subWid, *spansWid;
+    int extra;
+
+    ymin = YMIN(sub);
+    ymax = YMAX(sub);
+    spans = spanGroup->group;
+    for (i = spanGroup->count; i; i--, spans++) {
+        if (YMIN(spans) <= ymax && ymin <= YMAX(spans)) {
+            subCount = sub->count;
+            subPt = sub->points;
+            subWid = sub->widths;
+            spansCount = spans->count;
+            spansPt = spans->points;
+            spansWid = spans->widths;
+            extra = 0;
+            for (;;) {
+                while (spansCount && spansPt->y < subPt->y) {
+                    spansPt++;
+                    spansWid++;
+                    spansCount--;
+                }
+                if (!spansCount)
+                    break;
+                while (subCount && subPt->y < spansPt->y) {
+                    subPt++;
+                    subWid++;
+                    subCount--;
+                }
+                if (!subCount)
+                    break;
+                if (subPt->y == spansPt->y) {
+                    xmin = subPt->x;
+                    xmax = xmin + *subWid;
+                    if (xmin >= spansPt->x + *spansWid || spansPt->x >= xmax) {
+                        ;
+                    }
+                    else if (xmin <= spansPt->x) {
+                        if (xmax >= spansPt->x + *spansWid) {
+                            memmove(spansPt, spansPt + 1,
+                                    sizeof *spansPt * (spansCount - 1));
+                            memmove(spansWid, spansWid + 1,
+                                    sizeof *spansWid * (spansCount - 1));
+                            spansPt--;
+                            spansWid--;
+                            spans->count--;
+                            extra++;
+                        }
+                        else {
+                            *spansWid = *spansWid - (xmax - spansPt->x);
+                            spansPt->x = xmax;
+                        }
+                    }
+                    else {
+                        if (xmax >= spansPt->x + *spansWid) {
+                            *spansWid = xmin - spansPt->x;
+                        }
+                        else {
+                            if (!extra) {
+                                DDXPointPtr newPt;
+                                int *newwid;
+
+#define EXTRA 8
+                                newPt =
+                                    (DDXPointPtr) realloc(spans->points,
+                                                          (spans->count +
+                                                           EXTRA) *
+                                                          sizeof(DDXPointRec));
+                                if (!newPt)
+                                    break;
+                                spansPt = newPt + (spansPt - spans->points);
+                                spans->points = newPt;
+                                newwid =
+                                    (int *) realloc(spans->widths,
+                                                    (spans->count +
+                                                     EXTRA) * sizeof(int));
+                                if (!newwid)
+                                    break;
+                                spansWid = newwid + (spansWid - spans->widths);
+                                spans->widths = newwid;
+                                extra = EXTRA;
+                            }
+                            memmove(spansPt + 1, spansPt,
+                                    sizeof *spansPt * (spansCount));
+                            memmove(spansWid + 1, spansWid,
+                                    sizeof *spansWid * (spansCount));
+                            spans->count++;
+                            extra--;
+                            *spansWid = xmin - spansPt->x;
+                            spansWid++;
+                            spansPt++;
+                            *spansWid = *spansWid - (xmax - spansPt->x);
+                            spansPt->x = xmax;
+                        }
+                    }
+                }
+                spansPt++;
+                spansWid++;
+                spansCount--;
+            }
+        }
+    }
+}
+
+static void
+miAppendSpans(SpanGroup * spanGroup, SpanGroup * otherGroup, Spans * spans)
+{
+    int ymin, ymax;
+    int spansCount;
+
+    spansCount = spans->count;
+    if (spansCount > 0) {
+        if (spanGroup->size == spanGroup->count) {
+            spanGroup->size = (spanGroup->size + 8) * 2;
+            spanGroup->group = (Spans *)
+                realloc(spanGroup->group, sizeof(Spans) * spanGroup->size);
+        }
+
+        spanGroup->group[spanGroup->count] = *spans;
+        (spanGroup->count)++;
+        ymin = spans->points[0].y;
+        if (ymin < spanGroup->ymin)
+            spanGroup->ymin = ymin;
+        ymax = spans->points[spansCount - 1].y;
+        if (ymax > spanGroup->ymax)
+            spanGroup->ymax = ymax;
+        if (otherGroup && otherGroup->ymin < ymax && ymin < otherGroup->ymax) {
+            miSubtractSpans(otherGroup, spans);
+        }
+    }
+    else {
+        free(spans->points);
+        free(spans->widths);
+    }
+}                               /* AppendSpans */
+
+static void
+miFreeSpanGroup(SpanGroup * spanGroup)
+{
+    free(spanGroup->group);
+}
+
+static void
+QuickSortSpansX(DDXPointRec points[], int widths[], int numSpans)
+{
+    int x;
+    int i, j, m;
+    DDXPointPtr r;
+
+/* Always called with numSpans > 1 */
+/* Sorts only by x, as all y should be the same */
+
+#define ExchangeSpans(a, b)				    \
+{							    \
+    DDXPointRec 	tpt;				    \
+    int    		tw;				    \
+							    \
+    tpt = points[a]; points[a] = points[b]; points[b] = tpt;    \
+    tw = widths[a]; widths[a] = widths[b]; widths[b] = tw;  \
+}
+
+    do {
+        if (numSpans < 9) {
+            /* Do insertion sort */
+            int xprev;
+
+            xprev = points[0].x;
+            i = 1;
+            do {                /* while i != numSpans */
+                x = points[i].x;
+                if (xprev > x) {
+                    /* points[i] is out of order.  Move into proper location. */
+                    DDXPointRec tpt;
+                    int tw, k;
+
+                    for (j = 0; x >= points[j].x; j++) {
+                    }
+                    tpt = points[i];
+                    tw = widths[i];
+                    for (k = i; k != j; k--) {
+                        points[k] = points[k - 1];
+                        widths[k] = widths[k - 1];
+                    }
+                    points[j] = tpt;
+                    widths[j] = tw;
+                    x = points[i].x;
+                }               /* if out of order */
+                xprev = x;
+                i++;
+            } while (i != numSpans);
+            return;
+        }
+
+        /* Choose partition element, stick in location 0 */
+        m = numSpans / 2;
+        if (points[m].x > points[0].x)
+            ExchangeSpans(m, 0);
+        if (points[m].x > points[numSpans - 1].x)
+            ExchangeSpans(m, numSpans - 1);
+        if (points[m].x > points[0].x)
+            ExchangeSpans(m, 0);
+        x = points[0].x;
+
+        /* Partition array */
+        i = 0;
+        j = numSpans;
+        do {
+            r = &(points[i]);
+            do {
+                r++;
+                i++;
+            } while (i != numSpans && r->x < x);
+            r = &(points[j]);
+            do {
+                r--;
+                j--;
+            } while (x < r->x);
+            if (i < j)
+                ExchangeSpans(i, j);
+        } while (i < j);
+
+        /* Move partition element back to middle */
+        ExchangeSpans(0, j);
+
+        /* Recurse */
+        if (numSpans - j - 1 > 1)
+            QuickSortSpansX(&points[j + 1], &widths[j + 1], numSpans - j - 1);
+        numSpans = j;
+    } while (numSpans > 1);
+}                               /* QuickSortSpans */
+
+static int
+UniquifySpansX(Spans * spans, DDXPointRec * newPoints, int *newWidths)
+{
+    int newx1, newx2, oldpt, i, y;
+    DDXPointRec *oldPoints;
+    int *oldWidths;
+    int *startNewWidths;
+
+/* Always called with numSpans > 1 */
+/* Uniquify the spans, and stash them into newPoints and newWidths.  Return the
+   number of unique spans. */
+
+    startNewWidths = newWidths;
+
+    oldPoints = spans->points;
+    oldWidths = spans->widths;
+
+    y = oldPoints->y;
+    newx1 = oldPoints->x;
+    newx2 = newx1 + *oldWidths;
+
+    for (i = spans->count - 1; i != 0; i--) {
+        oldPoints++;
+        oldWidths++;
+        oldpt = oldPoints->x;
+        if (oldpt > newx2) {
+            /* Write current span, start a new one */
+            newPoints->x = newx1;
+            newPoints->y = y;
+            *newWidths = newx2 - newx1;
+            newPoints++;
+            newWidths++;
+            newx1 = oldpt;
+            newx2 = oldpt + *oldWidths;
+        }
+        else {
+            /* extend current span, if old extends beyond new */
+            oldpt = oldpt + *oldWidths;
+            if (oldpt > newx2)
+                newx2 = oldpt;
+        }
+    }                           /* for */
+
+    /* Write final span */
+    newPoints->x = newx1;
+    *newWidths = newx2 - newx1;
+    newPoints->y = y;
+
+    return (newWidths - startNewWidths) + 1;
+}                               /* UniquifySpansX */
+
+static void
+miDisposeSpanGroup(SpanGroup * spanGroup)
+{
+    int i;
+    Spans *spans;
+
+    for (i = 0; i < spanGroup->count; i++) {
+        spans = spanGroup->group + i;
+        free(spans->points);
+        free(spans->widths);
+    }
+}
+
+static void
+miFillUniqueSpanGroup(DrawablePtr pDraw, GCPtr pGC, SpanGroup * spanGroup)
+{
+    int i;
+    Spans *spans;
+    Spans *yspans;
+    int *ysizes;
+    int ymin, ylength;
+
+    /* Outgoing spans for one big call to FillSpans */
+    DDXPointPtr points;
+    int *widths;
+    int count;
+
+    if (spanGroup->count == 0)
+        return;
+
+    if (spanGroup->count == 1) {
+        /* Already should be sorted, unique */
+        spans = spanGroup->group;
+        (*pGC->ops->FillSpans)
+            (pDraw, pGC, spans->count, spans->points, spans->widths, TRUE);
+        free(spans->points);
+        free(spans->widths);
+    }
+    else {
+        /* Yuck.  Gross.  Radix sort into y buckets, then sort x and uniquify */
+        /* This seems to be the fastest thing to do.  I've tried sorting on
+           both x and y at the same time rather than creating into all those
+           y buckets, but it was somewhat slower. */
+
+        ymin = spanGroup->ymin;
+        ylength = spanGroup->ymax - ymin + 1;
+
+        /* Allocate Spans for y buckets */
+        yspans = malloc(ylength * sizeof(Spans));
+        ysizes = malloc(ylength * sizeof(int));
+
+        if (!yspans || !ysizes) {
+            free(yspans);
+            free(ysizes);
+            miDisposeSpanGroup(spanGroup);
+            return;
+        }
+
+        for (i = 0; i != ylength; i++) {
+            ysizes[i] = 0;
+            yspans[i].count = 0;
+            yspans[i].points = NULL;
+            yspans[i].widths = NULL;
+        }
+
+        /* Go through every single span and put it into the correct bucket */
+        count = 0;
+        for (i = 0, spans = spanGroup->group;
+             i != spanGroup->count; i++, spans++) {
+            int index;
+            int j;
+
+            for (j = 0, points = spans->points, widths = spans->widths;
+                 j != spans->count; j++, points++, widths++) {
+                index = points->y - ymin;
+                if (index >= 0 && index < ylength) {
+                    Spans *newspans = &(yspans[index]);
+
+                    if (newspans->count == ysizes[index]) {
+                        DDXPointPtr newpoints;
+                        int *newwidths;
+
+                        ysizes[index] = (ysizes[index] + 8) * 2;
+                        newpoints = (DDXPointPtr) realloc(newspans->points,
+                                                          ysizes[index] *
+                                                          sizeof(DDXPointRec));
+                        newwidths =
+                            (int *) realloc(newspans->widths,
+                                            ysizes[index] * sizeof(int));
+                        if (!newpoints || !newwidths) {
+                            for (i = 0; i < ylength; i++) {
+                                free(yspans[i].points);
+                                free(yspans[i].widths);
+                            }
+                            free(yspans);
+                            free(ysizes);
+                            free(newpoints);
+                            free(newwidths);
+                            miDisposeSpanGroup(spanGroup);
+                            return;
+                        }
+                        newspans->points = newpoints;
+                        newspans->widths = newwidths;
+                    }
+                    newspans->points[newspans->count] = *points;
+                    newspans->widths[newspans->count] = *widths;
+                    (newspans->count)++;
+                }               /* if y value of span in range */
+            }                   /* for j through spans */
+            count += spans->count;
+            free(spans->points);
+            spans->points = NULL;
+            free(spans->widths);
+            spans->widths = NULL;
+        }                       /* for i thorough Spans */
+
+        /* Now sort by x and uniquify each bucket into the final array */
+        points = malloc(count * sizeof(DDXPointRec));
+        widths = malloc(count * sizeof(int));
+        if (!points || !widths) {
+            for (i = 0; i < ylength; i++) {
+                free(yspans[i].points);
+                free(yspans[i].widths);
+            }
+            free(yspans);
+            free(ysizes);
+            free(points);
+            free(widths);
+            return;
+        }
+        count = 0;
+        for (i = 0; i != ylength; i++) {
+            int ycount = yspans[i].count;
+
+            if (ycount > 0) {
+                if (ycount > 1) {
+                    QuickSortSpansX(yspans[i].points, yspans[i].widths, ycount);
+                    count += UniquifySpansX
+                        (&(yspans[i]), &(points[count]), &(widths[count]));
+                }
+                else {
+                    points[count] = yspans[i].points[0];
+                    widths[count] = yspans[i].widths[0];
+                    count++;
+                }
+                free(yspans[i].points);
+                free(yspans[i].widths);
+            }
+        }
+
+        (*pGC->ops->FillSpans) (pDraw, pGC, count, points, widths, TRUE);
+        free(points);
+        free(widths);
+        free(yspans);
+        free(ysizes);           /* use (DE)xalloc for these? */
+    }
+
+    spanGroup->count = 0;
+    spanGroup->ymin = MAXSHORT;
+    spanGroup->ymax = MINSHORT;
+}
+
 static Bool
 InitSpans(Spans * spans, size_t nspans)
 {
diff --git a/mi/miwideline.h b/mi/miwideline.h
index a9f2740..88bc3d6 100644
--- a/mi/miwideline.h
+++ b/mi/miwideline.h
@@ -28,7 +28,6 @@ from The Open Group.
 
 /* Author:  Keith Packard, MIT X Consortium */
 
-#include "mispans.h"
 #include "mifpoly.h"            /* for ICEIL */
 
 /*
commit 707965407a3c907058b89610e73e02989fd0b552
Author: Adam Jackson <ajax at redhat.com>
Date:   Fri May 23 12:10:29 2014 -0400

    mi: Unexport arc fill implementation details
    
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/mi/Makefile.am b/mi/Makefile.am
index b243029..4466f69 100644
--- a/mi/Makefile.am
+++ b/mi/Makefile.am
@@ -2,7 +2,7 @@ noinst_LTLIBRARIES = libmi.la
 
 if XORG
 sdk_HEADERS = micmap.h miline.h mipointer.h mi.h \
-              migc.h mipointrst.h mizerarc.h micoord.h mifillarc.h \
+              migc.h mipointrst.h mizerarc.h micoord.h \
               mistruct.h mioverlay.h
 endif
 
diff --git a/mi/mifillarc.c b/mi/mifillarc.c
index 08484d7..9a5e785 100644
--- a/mi/mifillarc.c
+++ b/mi/mifillarc.c
@@ -51,7 +51,7 @@ Author:  Bob Scheifler, MIT X Consortium
 #define Dsin(d)	sin((double)d*(M_PI/11520.0))
 #define Dcos(d)	cos((double)d*(M_PI/11520.0))
 
-void
+static void
 miFillArcSetup(xArc * arc, miFillArcRec * info)
 {
     info->y = arc->height >> 1;
@@ -277,7 +277,7 @@ miGetPieEdge(xArc * arc, int angle, miSliceEdgePtr edge, Bool top, Bool left)
     miGetArcEdge(arc, edge, k, top, left);
 }
 
-void
+static void
 miFillArcSliceSetup(xArc * arc, miArcSliceRec * slice, GCPtr pGC)
 {
     int angle1, angle2;
diff --git a/mi/mifillarc.h b/mi/mifillarc.h
index 1478d18..61ab253 100644
--- a/mi/mifillarc.h
+++ b/mi/mifillarc.h
@@ -175,13 +175,4 @@ typedef struct _miArcSlice {
 #define miFillInArcLower(slw) (((iny + dy) != 0) && \
 			       ((slw > 1) || (ine != inxk)))
 
-extern _X_EXPORT void miFillArcSetup(xArc * /*arc */ ,
-                                     miFillArcRec *     /*info */
-    );
-
-extern _X_EXPORT void miFillArcSliceSetup(xArc * /*arc */ ,
-                                          miArcSliceRec * /*slice */ ,
-                                          GCPtr /*pGC */
-    );
-
 #endif                          /* __MIFILLARC_H__ */
commit ce8fff5cd681523088c14b97ce4fb6e4fb658321
Author: Adam Jackson <ajax at redhat.com>
Date:   Fri May 23 12:06:03 2014 -0400

    mi: Unexport subpixel polygon implementation details
    
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/mi/Makefile.am b/mi/Makefile.am
index b93a8f9..b243029 100644
--- a/mi/Makefile.am
+++ b/mi/Makefile.am
@@ -3,7 +3,7 @@ noinst_LTLIBRARIES = libmi.la
 if XORG
 sdk_HEADERS = micmap.h miline.h mipointer.h mi.h \
               migc.h mipointrst.h mizerarc.h micoord.h mifillarc.h \
-              mistruct.h mifpoly.h mioverlay.h
+              mistruct.h mioverlay.h
 endif
 
 AM_CFLAGS = $(DIX_CFLAGS)
diff --git a/mi/mifpoly.h b/mi/mifpoly.h
index f853fb4..4b27d1c 100644
--- a/mi/mifpoly.h
+++ b/mi/mifpoly.h
@@ -89,14 +89,13 @@ typedef struct _SppArc {
 
 /* mifpolycon.c */
 
-extern _X_EXPORT void miFillSppPoly(DrawablePtr /*dst */ ,
-                                    GCPtr /*pgc */ ,
-                                    int /*count */ ,
-                                    SppPointPtr /*ptsIn */ ,
-                                    int /*xTrans */ ,
-                                    int /*yTrans */ ,
-                                    double /*xFtrans */ ,
-                                    double      /*yFtrans */
-    );
+extern void miFillSppPoly(DrawablePtr /*dst */ ,
+                          GCPtr /*pgc */ ,
+                          int /*count */ ,
+                          SppPointPtr /*ptsIn */ ,
+                          int /*xTrans */ ,
+                          int /*yTrans */ ,
+                          double /*xFtrans */ ,
+                          double      /*yFtrans */);
 
 #endif                          /* __MIFPOLY_H__ */
commit a085ba82bde375b5c884a40b410b563815c58a9e
Author: Adam Jackson <ajax at redhat.com>
Date:   Fri May 23 11:55:05 2014 -0400

    mi: Unexport span group implementation details
    
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/mi/Makefile.am b/mi/Makefile.am
index 526f4bb..b93a8f9 100644
--- a/mi/Makefile.am
+++ b/mi/Makefile.am
@@ -3,7 +3,7 @@ noinst_LTLIBRARIES = libmi.la
 if XORG
 sdk_HEADERS = micmap.h miline.h mipointer.h mi.h \
               migc.h mipointrst.h mizerarc.h micoord.h mifillarc.h \
-              mispans.h mistruct.h mifpoly.h mioverlay.h
+              mistruct.h mifpoly.h mioverlay.h
 endif
 
 AM_CFLAGS = $(DIX_CFLAGS)
diff --git a/mi/mispans.h b/mi/mispans.h
index f3148ff..7c3fcef 100644
--- a/mi/mispans.h
+++ b/mi/mispans.h
@@ -61,24 +61,20 @@ typedef struct {
 } SpanGroup;
 
 /* Initialize SpanGroup.  MUST BE DONE before use. */
-extern _X_EXPORT void miInitSpanGroup(SpanGroup *       /*spanGroup */
-    );
+extern void miInitSpanGroup(SpanGroup *       /*spanGroup */);
 
 /* Add a Spans to a SpanGroup. The spans MUST BE in y-sorted order */
-extern _X_EXPORT void miAppendSpans(SpanGroup * /*spanGroup */ ,
-                                    SpanGroup * /*otherGroup */ ,
-                                    Spans *     /*spans */
-    );
+extern void miAppendSpans(SpanGroup * /*spanGroup */ ,
+                          SpanGroup * /*otherGroup */ ,
+                          Spans *     /*spans */);
 
 /* Paint a span group, insuring that each pixel is painted at most once */
-extern _X_EXPORT void miFillUniqueSpanGroup(DrawablePtr /*pDraw */ ,
-                                            GCPtr /*pGC */ ,
-                                            SpanGroup * /*spanGroup */
-    );
+extern void miFillUniqueSpanGroup(DrawablePtr /*pDraw */ ,
+                                  GCPtr /*pGC */ ,
+                                  SpanGroup * /*spanGroup */);
 
 /* Free up data in a span group.  MUST BE DONE or you'll suffer memory leaks */
-extern _X_EXPORT void miFreeSpanGroup(SpanGroup *       /*spanGroup */
-    );
+extern void miFreeSpanGroup(SpanGroup *       /*spanGroup */);
 
 /* Rops which must use span groups */
 #define miSpansCarefulRop(rop)	(((rop) & 0xc) == 0x8 || ((rop) & 0x3) == 0x2)
commit c15c886ee70f9144bc4603b918310f229312aadc
Author: Adam Jackson <ajax at redhat.com>
Date:   Fri May 23 11:50:07 2014 -0400

    mi: Unexport polygon edge table implementation details
    
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/mi/mipoly.h b/mi/mipoly.h
index e37fb48..02fcfc8 100644
--- a/mi/mipoly.h
+++ b/mi/mipoly.h
@@ -174,20 +174,17 @@ typedef struct _ScanLineListBlock {
 
 /* mipolyutil.c */
 
-extern _X_EXPORT Bool miCreateETandAET(int /*count */ ,
-                                       DDXPointPtr /*pts */ ,
-                                       EdgeTable * /*ET*/,
-                                       EdgeTableEntry * /*AET*/,
-                                       EdgeTableEntry * /*pETEs */ ,
-                                       ScanLineListBlock *      /*pSLLBlock */
-    );
+extern Bool miCreateETandAET(int /*count */ ,
+                             DDXPointPtr /*pts */ ,
+                             EdgeTable * /*ET*/,
+                             EdgeTableEntry * /*AET*/,
+                             EdgeTableEntry * /*pETEs */ ,
+                             ScanLineListBlock *      /*pSLLBlock */);
 
-extern _X_EXPORT void miloadAET(EdgeTableEntry * /*AET*/, EdgeTableEntry *      /*ETEs */
-    );
+extern void miloadAET(EdgeTableEntry * /*AET*/, EdgeTableEntry * /*ETEs */);
 
-extern _X_EXPORT void micomputeWAET(EdgeTableEntry * /*AET*/);
+extern void micomputeWAET(EdgeTableEntry * /*AET*/);
 
-extern _X_EXPORT int miInsertionSort(EdgeTableEntry * /*AET*/);
+extern int miInsertionSort(EdgeTableEntry * /*AET*/);
 
-extern _X_EXPORT void miFreeStorage(ScanLineListBlock * /*pSLLBlock */
-    );
+extern void miFreeStorage(ScanLineListBlock * /*pSLLBlock */);
commit 9bdc9b0113915de3d536b2b3f025915379c2126f
Author: Adam Jackson <ajax at redhat.com>
Date:   Fri May 23 11:21:28 2014 -0400

    mi: Unexport wide line details
    
    XAA wanted these, once upon a time, but that's gone now.
    
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/hw/xfree86/sdksyms.sh b/hw/xfree86/sdksyms.sh
index d9a4478..c2a1942 100755
--- a/hw/xfree86/sdksyms.sh
+++ b/hw/xfree86/sdksyms.sh
@@ -217,7 +217,6 @@ cat > sdksyms.c << EOF
 #include "micoord.h"
 #include "mifillarc.h"
 #include "mispans.h"
-#include "miwideline.h"
 #include "mistruct.h"
 #include "mifpoly.h"
 #include "mioverlay.h"
diff --git a/mi/Makefile.am b/mi/Makefile.am
index 0cef779..526f4bb 100644
--- a/mi/Makefile.am
+++ b/mi/Makefile.am
@@ -3,7 +3,7 @@ noinst_LTLIBRARIES = libmi.la
 if XORG
 sdk_HEADERS = micmap.h miline.h mipointer.h mi.h \
               migc.h mipointrst.h mizerarc.h micoord.h mifillarc.h \
-              mispans.h miwideline.h mistruct.h mifpoly.h mioverlay.h
+              mispans.h mistruct.h mifpoly.h mioverlay.h
 endif
 
 AM_CFLAGS = $(DIX_CFLAGS)
diff --git a/mi/miwideline.c b/mi/miwideline.c
index 29ba12c..295a05a 100644
--- a/mi/miwideline.c
+++ b/mi/miwideline.c
@@ -273,7 +273,7 @@ miFillRectPolyHelper(DrawablePtr pDrawable,
     }
 }
 
-/* static */ int
+static int
 miPolyBuildEdge(double x0, double y0, double k, /* x0 * dy - y0 * dx */
                 int dx, int dy, int xi, int yi, int left, PolyEdgePtr edge)
 {
@@ -325,7 +325,7 @@ miPolyBuildEdge(double x0, double y0, double k, /* x0 * dy - y0 * dx */
 
 #define StepAround(v, incr, max) (((v) + (incr) < 0) ? (max - 1) : ((v) + (incr) == max) ? 0 : ((v) + (incr)))
 
-/* static */ int
+static int
 miPolyBuildPoly(PolyVertexPtr vertices,
                 PolySlopePtr slopes,
                 int count,
@@ -865,7 +865,7 @@ miRoundJoinFace(LineFacePtr face, PolyEdgePtr edge, Bool *leftEdge)
     return y;
 }
 
-void
+static void
 miRoundJoinClip(LineFacePtr pLeft, LineFacePtr pRight,
                 PolyEdgePtr edge1, PolyEdgePtr edge2,
                 int *y1, int *y2, Bool *left1, Bool *left2)
@@ -886,7 +886,7 @@ miRoundJoinClip(LineFacePtr pLeft, LineFacePtr pRight,
     *y2 = miRoundJoinFace(pRight, edge2, left2);
 }
 
-int
+static int
 miRoundCapClip(LineFacePtr face, Bool isInt, PolyEdgePtr edge, Bool *leftEdge)
 {
     int y;
diff --git a/mi/miwideline.h b/mi/miwideline.h
index 1105411..a9f2740 100644
--- a/mi/miwideline.h
+++ b/mi/miwideline.h
@@ -92,28 +92,3 @@ typedef struct _LineFace {
 	ValidateGC (pDrawable, pGC); \
     } \
 }
-
-extern _X_EXPORT void miRoundJoinClip(LineFacePtr /*pLeft */ ,
-                                      LineFacePtr /*pRight */ ,
-                                      PolyEdgePtr /*edge1 */ ,
-                                      PolyEdgePtr /*edge2 */ ,
-                                      int * /*y1 */ ,
-                                      int * /*y2 */ ,
-                                      Bool * /*left1 */ ,
-                                      Bool *    /*left2 */
-    );
-
-extern _X_EXPORT int miRoundCapClip(LineFacePtr /*face */ ,
-                                    Bool /*isInt */ ,
-                                    PolyEdgePtr /*edge */ ,
-                                    Bool *      /*leftEdge */
-    );
-
-extern _X_EXPORT int miPolyBuildEdge(double x0, double y0, double k, int dx,
-                                     int dy, int xi, int yi, int left,
-                                     PolyEdgePtr edge);
-extern _X_EXPORT int miPolyBuildPoly(PolyVertexPtr vertices,
-                                     PolySlopePtr slopes, int count, int xi,
-                                     int yi, PolyEdgePtr left,
-                                     PolyEdgePtr right, int *pnleft,
-                                     int *pnright, int *h);
commit d181e52ceb9ae44e1faa8d5af8805f43328da6c2
Author: Keith Packard <keithp at keithp.com>
Date:   Fri Oct 24 11:56:23 2014 -0700

    glamor: Free converted bits in _glamor_upload_bits_to_pixmap_texture fast path
    
    When uploading bits to a texture which need reformatting to match a
    supported GL format, a temporary buffer is allocated to hold the
    reformatted bits. This gets freed in the general path, but is not
    freed in the fast path because that includes an early return before
    the call to free.
    
    This patch removes the early return and places the general case under
    an 'else' block, so that both paths reach the call to free.
    
    Signed-off-by: Keith Packard <keithp at keithp.com>
    Reviewed-by: Alex Deucher <alexander.deucher at amd.com>

diff --git a/glamor/glamor_pixmap.c b/glamor/glamor_pixmap.c
index 7c9bf26..947113e 100644
--- a/glamor/glamor_pixmap.c
+++ b/glamor/glamor_pixmap.c
@@ -808,45 +808,44 @@ _glamor_upload_bits_to_pixmap_texture(PixmapPtr pixmap, GLenum format,
                                           format, type,
                                           x + fbo_x_off, y + fbo_y_off, w, h,
                                           bits, pbo);
-        return TRUE;
+    } else {
+        ptexcoords = texcoords_inv;
+
+        pixmap_priv_get_dest_scale(pixmap_priv, &dst_xscale, &dst_yscale);
+        glamor_set_normalize_vcoords(pixmap_priv, dst_xscale,
+                                     dst_yscale,
+                                     x, y,
+                                     x + w, y + h,
+                                     vertices);
+        /* Slow path, we need to flip y or wire alpha to 1. */
+        glamor_make_current(glamor_priv);
+        glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
+                              GL_FALSE, 2 * sizeof(float), vertices);
+        glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
+        glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2, GL_FLOAT,
+                              GL_FALSE, 2 * sizeof(float), ptexcoords);
+        glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
+
+        glamor_set_destination_pixmap_priv_nc(pixmap_priv);
+        __glamor_upload_pixmap_to_texture(pixmap, &tex,
+                                          format, type, 0, 0, w, h, bits, pbo);
+        glActiveTexture(GL_TEXTURE0);
+        glBindTexture(GL_TEXTURE_2D, tex);
+
+        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+        glUseProgram(glamor_priv->finish_access_prog[no_alpha]);
+        glUniform1i(glamor_priv->finish_access_revert[no_alpha], revert);
+        glUniform1i(glamor_priv->finish_access_swap_rb[no_alpha], swap_rb);
+
+        glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
+
+        glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
+        glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
+        glDeleteTextures(1, &tex);
+        glBindFramebuffer(GL_FRAMEBUFFER, 0);
     }
 
-    ptexcoords = texcoords_inv;
-
-    pixmap_priv_get_dest_scale(pixmap_priv, &dst_xscale, &dst_yscale);
-    glamor_set_normalize_vcoords(pixmap_priv, dst_xscale,
-                                 dst_yscale,
-                                 x, y,
-                                 x + w, y + h,
-                                 vertices);
-    /* Slow path, we need to flip y or wire alpha to 1. */
-    glamor_make_current(glamor_priv);
-    glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
-                          GL_FALSE, 2 * sizeof(float), vertices);
-    glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
-    glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2, GL_FLOAT,
-                          GL_FALSE, 2 * sizeof(float), ptexcoords);
-    glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
-
-    glamor_set_destination_pixmap_priv_nc(pixmap_priv);
-    __glamor_upload_pixmap_to_texture(pixmap, &tex,
-                                      format, type, 0, 0, w, h, bits, pbo);
-    glActiveTexture(GL_TEXTURE0);
-    glBindTexture(GL_TEXTURE_2D, tex);
-
-    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
-    glUseProgram(glamor_priv->finish_access_prog[no_alpha]);
-    glUniform1i(glamor_priv->finish_access_revert[no_alpha], revert);
-    glUniform1i(glamor_priv->finish_access_swap_rb[no_alpha], swap_rb);
-
-    glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
-
-    glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
-    glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
-    glDeleteTextures(1, &tex);
-    glBindFramebuffer(GL_FRAMEBUFFER, 0);
-
     if (need_free_bits)
         free(bits);
     return TRUE;
commit 55b27ed70cf9dfa9b9dffe46e9a3191bfda38f7c
Author: Andreas Hartmetz <ahartmetz at gmail.com>
Date:   Sat Oct 4 18:13:04 2014 +0200

    glamor: Don't free memory we are going to use.
    
    glamor_color_convert_to_bits() returns its second argument on
    success, NULL on error, and need_free_bits already makes sure that
    "bits" aliasing converted_bits is freed in the success case.
    Looks like the memory leak that was supposed to be fixed in
    6e50bfa706cd3ab884c933bf1f17c221a6208aa4 only occurred in the error
    case.
    
    Reviewed-by: Michel Dänzer <michel.daenzer at amd.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/glamor/glamor_pixmap.c b/glamor/glamor_pixmap.c
index 355fe4b..7c9bf26 100644
--- a/glamor/glamor_pixmap.c
+++ b/glamor/glamor_pixmap.c
@@ -774,8 +774,8 @@ _glamor_upload_bits_to_pixmap_texture(PixmapPtr pixmap, GLenum format,
             return FALSE;
         bits = glamor_color_convert_to_bits(bits, converted_bits, w, h,
                                             stride, no_alpha, revert, swap_rb);
-        free(converted_bits);
         if (bits == NULL) {
+            free(converted_bits);
             ErrorF("Failed to convert pixmap no_alpha %d,"
                    "revert mode %d, swap mode %d\n", no_alpha, revert, swap_rb);
             return FALSE;
commit 16a32c53f6e9ad1f3284d4596edfa33e9efb740e
Author: Alan Coopersmith <alan.coopersmith at oracle.com>
Date:   Thu Oct 9 05:42:09 2014 -0700

    If fork fails in System(), don't fallthrough to exec()
    
    In the unlikely event of a failure in creating processes, signal
    masks will fall from the panels above you.  Secure your mask before
    telling your child what to do, since it won't exist, and you will
    instead cause the server itself to be replaced by a shell running
    the target program.
    
    Found by Coverity #53397: Missing break in switch
    Execution falls through to the next case statement or default;
     this might indicate a common typo.
    In System: Missing break statement between cases in switch statement (CWE-484)
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
    Reviewed-by: Matthieu Herrb <matthieu at herrb.eu>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/os/utils.c b/os/utils.c
index 80415c4..75769f1 100644
--- a/os/utils.c
+++ b/os/utils.c
@@ -1373,6 +1373,7 @@ System(const char *command)
     switch (pid = fork()) {
     case -1:                   /* error */
         p = -1;
+        break;
     case 0:                    /* child */
         if (setgid(getgid()) == -1)
             _exit(127);
commit 7e5bc49d1ed2c78c321da79bdbc99b90c5f95b38
Author: Alan Coopersmith <alan.coopersmith at oracle.com>
Date:   Thu Oct 9 05:42:08 2014 -0700

    Allocate enough room for both reset & flags attributes
    
    ctx_attribs had room for 3 pairs of attributes, but if both flags & reset
    attributes were being returned it was storing 4 pairs in the array.
    
    Found by Coverity #53442:  Out-of-bounds write
    This could cause an immediate crash or incorrect computations.
    In create_driver_context: Out-of-bounds write to a buffer (CWE-119)
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
    Reviewed-by: Adam Jackson <ajax at redhat.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/glx/glxdri2.c b/glx/glxdri2.c
index c756bf5..5a8966f 100644
--- a/glx/glxdri2.c
+++ b/glx/glxdri2.c
@@ -475,7 +475,7 @@ create_driver_context(__GLXDRIcontext * context,
     context->driContext = NULL;
 
     if (screen->dri2->base.version >= 3) {
-        uint32_t ctx_attribs[3 * 2];
+        uint32_t ctx_attribs[4 * 2];
         unsigned num_ctx_attribs = 0;
         unsigned dri_err = 0;
         unsigned major_ver;
@@ -510,6 +510,8 @@ create_driver_context(__GLXDRIcontext * context,
                     __DRI_CTX_ATTRIB_RESET_STRATEGY;
                 ctx_attribs[num_ctx_attribs++] = reset;
             }
+
+            assert(num_ctx_attribs <= ARRAY_SIZE(ctx_attribs));
         }
 
         context->driContext =
commit cffd4e4a4ee615d8583eae78b35017e0d1bfa4f0
Author: Adam Jackson <ajax at redhat.com>
Date:   Thu Oct 9 09:58:06 2014 +0200

    mi: Mark the span blit routines as _X_COLD
    
    On gcc, __attribute__((cold)) means:
    
    - consider calls to the function to be unlikely for branch prediction
    - optimize the function for size
    - emit the function in a dedicated cold text section
    
    It's not worth deleting these routines even though there are no longer
    in-tree consumers, but we can at least keep them out of i$ at runtime.
    
    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/mi/mibitblt.c b/mi/mibitblt.c
index 08bd1c5..114f72d 100644
--- a/mi/mibitblt.c
+++ b/mi/mibitblt.c
@@ -72,7 +72,7 @@ extern int ffs(int);
  *     set them in the destination with SetSpans
  * We let SetSpans worry about clipping to the destination.
  */
-RegionPtr
+_X_COLD RegionPtr
 miCopyArea(DrawablePtr pSrcDrawable,
            DrawablePtr pDstDrawable,
            GCPtr pGC,
@@ -261,8 +261,7 @@ miCopyArea(DrawablePtr pSrcDrawable,
  * This should be replaced with something more general.  mi shouldn't have to
  * care about such things as scanline padding et alia.
  */
-static
-MiBits *
+_X_COLD static MiBits *
 miGetPlane(DrawablePtr pDraw, int planeNum,     /* number of the bitPlane */
            int sx, int sy, int w, int h, MiBits * result)
 {
@@ -368,7 +367,7 @@ miGetPlane(DrawablePtr pDraw, int planeNum,     /* number of the bitPlane */
  * Note how the clipped out bits of the bitmap are always the background
  * color so that the stipple never causes FillRect to draw them.
  */
-static void
+_X_COLD static void
 miOpqStipDrawable(DrawablePtr pDraw, GCPtr pGC, RegionPtr prgnSrc,
                   MiBits * pbits, int srcx, int w, int h, int dstx, int dsty)
 {
@@ -510,7 +509,7 @@ miOpqStipDrawable(DrawablePtr pDraw, GCPtr pGC, RegionPtr prgnSrc,
  * build a source clip
  * Use the bitmap we've built up as a Stipple for the destination 
  */
-RegionPtr
+_X_COLD RegionPtr
 miCopyPlane(DrawablePtr pSrcDrawable,
             DrawablePtr pDstDrawable,
             GCPtr pGC,
@@ -599,7 +598,7 @@ miCopyPlane(DrawablePtr pSrcDrawable,
  * XY format:
  * get the single plane specified in planemask
  */
-void
+_X_COLD void
 miGetImage(DrawablePtr pDraw, int sx, int sy, int w, int h,
            unsigned int format, unsigned long planeMask, char *pDst)
 {
@@ -689,7 +688,7 @@ miGetImage(DrawablePtr pDraw, int sx, int sy, int w, int h,
  * ZPixmap format:
  *	This part is simple, just call SetSpans
  */
-void
+_X_COLD void
 miPutImage(DrawablePtr pDraw, GCPtr pGC, int depth,
            int x, int y, int w, int h, int leftPad, int format, char *pImage)
 {
diff --git a/mi/mifillrct.c b/mi/mifillrct.c
index 79c4057..faf6049 100644
--- a/mi/mifillrct.c
+++ b/mi/mifillrct.c
@@ -65,7 +65,7 @@ SOFTWARE.
  * then call FillSpans to fill each rectangle.  We let FillSpans worry about
  * clipping to the destination
  */
-void
+_X_COLD void
 miPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, int nrectFill, /* number of rectangles to fill */
                xRectangle *prectInit    /* Pointer to first rectangle to fill */
     )
commit de55aafa8f6a9e0dec364bec920d6f91ef2b39f0
Merge: 462bf87 c79f824
Author: Keith Packard <keithp at keithp.com>
Date:   Thu Oct 23 17:28:24 2014 -0700

    Merge remote-tracking branch 'ajax/xwin'

commit 462bf87c4d1c2211dd49a5ce62d01ff84ff33970
Author: Adam Jackson <ajax at redhat.com>
Date:   Wed Oct 8 17:20:33 2014 +0200

    render: Always store client clip as a region
    
    This does have one semantic change.  FixesCreateRegionFromPicture used to
    throw BadImplementation if you tried to create a region from a picture
    with no client clip.  I changed that to BadMatch here since that more
    honestly describes what's going on.
    
    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/fb/fbpict.c b/fb/fbpict.c
index 21baf89..f9c9917 100644
--- a/fb/fbpict.c
+++ b/fb/fbpict.c
@@ -326,7 +326,7 @@ create_bits_picture(PicturePtr pict, Bool has_clip, int *xoff, int *yoff)
      * only set the clip region for pictures with drawables
      */
     if (has_clip) {
-        if (pict->clientClipType != CT_NONE)
+        if (pict->clientClip)
             pixman_image_set_has_client_clip(image, TRUE);
 
         if (*xoff || *yoff)
diff --git a/render/mipict.c b/render/mipict.c
index 3959fc4..a725104 100644
--- a/render/mipict.c
+++ b/render/mipict.c
@@ -49,23 +49,9 @@ miDestroyPicture(PicturePtr pPicture)
 void
 miDestroyPictureClip(PicturePtr pPicture)
 {
-    switch (pPicture->clientClipType) {
-    case CT_NONE:
-        return;
-    case CT_PIXMAP:
-        (*pPicture->pDrawable->pScreen->
-         DestroyPixmap) ((PixmapPtr) (pPicture->clientClip));
-        break;
-    default:
-        /*
-         * we know we'll never have a list of rectangles, since ChangeClip
-         * immediately turns them into a region
-         */
+    if (pPicture->clientClip)
         RegionDestroy(pPicture->clientClip);
-        break;
-    }
     pPicture->clientClip = NULL;
-    pPicture->clientClipType = CT_NONE;
 }
 
 int
@@ -73,37 +59,31 @@ miChangePictureClip(PicturePtr pPicture, int type, void *value, int n)
 {
     ScreenPtr pScreen = pPicture->pDrawable->pScreen;
     PictureScreenPtr ps = GetPictureScreen(pScreen);
-    void *clientClip;
-    int clientClipType;
+    RegionPtr clientClip;
 
     switch (type) {
     case CT_PIXMAP:
         /* convert the pixmap to a region */
-        clientClip = (void *) BitmapToRegion(pScreen, (PixmapPtr) value);
+        clientClip = BitmapToRegion(pScreen, (PixmapPtr) value);
         if (!clientClip)
             return BadAlloc;
-        clientClipType = CT_REGION;
         (*pScreen->DestroyPixmap) ((PixmapPtr) value);
         break;
     case CT_REGION:
         clientClip = value;
-        clientClipType = CT_REGION;
         break;
     case CT_NONE:
         clientClip = 0;
-        clientClipType = CT_NONE;
         break;
     default:
-        clientClip = (void *) RegionFromRects(n, (xRectangle *) value, type);
+        clientClip = RegionFromRects(n, (xRectangle *) value, type);
         if (!clientClip)
             return BadAlloc;
-        clientClipType = CT_REGION;
         free(value);
         break;
     }
     (*ps->DestroyPictureClip) (pPicture);
     pPicture->clientClip = clientClip;
-    pPicture->clientClipType = clientClipType;
     pPicture->stateChanges |= CPClipMask;
     return Success;
 }
@@ -144,7 +124,7 @@ miValidatePicture(PicturePtr pPicture, Mask mask)
              * copying of regions.  (this wins especially if many clients clip
              * by children and have no client clip.)
              */
-            if (pPicture->clientClipType == CT_NONE) {
+            if (!pPicture->clientClip) {
                 if (freeCompClip)
                     RegionDestroy(pPicture->pCompositeClip);
                 pPicture->pCompositeClip = pregWin;
@@ -203,7 +183,7 @@ miValidatePicture(PicturePtr pPicture, Mask mask)
                 pPicture->pCompositeClip = RegionCreate(&pixbounds, 1);
             }
 
-            if (pPicture->clientClipType == CT_REGION) {
+            if (pPicture->clientClip) {
                 if (pDrawable->x || pDrawable->y) {
                     RegionTranslate(pPicture->clientClip,
                                     pDrawable->x + pPicture->clipOrigin.x,
@@ -284,7 +264,7 @@ miClipPictureReg(pixman_region16_t * pRegion,
 static inline Bool
 miClipPictureSrc(RegionPtr pRegion, PicturePtr pPicture, int dx, int dy)
 {
-    if (pPicture->clientClipType != CT_NONE) {
+    if (pPicture->clientClip) {
         Bool result;
 
         pixman_region_translate(pPicture->clientClip,
diff --git a/render/mirect.c b/render/mirect.c
index 4e76972..a36d1d6 100644
--- a/render/mirect.c
+++ b/render/mirect.c
@@ -54,7 +54,7 @@ miColorRects(PicturePtr pDst,
     tmpval[1].val = pixel;
     tmpval[2].val = pDst->subWindowMode;
     mask = GCFunction | GCForeground | GCSubwindowMode;
-    if (pClipPict->clientClipType == CT_REGION) {
+    if (pClipPict->clientClip) {
         tmpval[3].val = pDst->clipOrigin.x - xoff;
         tmpval[4].val = pDst->clipOrigin.y - yoff;
         mask |= GCClipXOrigin | GCClipYOrigin;
diff --git a/render/picture.c b/render/picture.c
index 58535d4..cd9bc74 100644
--- a/render/picture.c
+++ b/render/picture.c
@@ -731,7 +731,6 @@ SetPictureToDefaults(PicturePtr pPicture)
     pPicture->polyEdge = PolyEdgeSharp;
     pPicture->polyMode = PolyModePrecise;
     pPicture->freeCompClip = FALSE;
-    pPicture->clientClipType = CT_NONE;
     pPicture->componentAlpha = FALSE;
     pPicture->repeatType = RepeatNone;
 
diff --git a/render/picturestr.h b/render/picturestr.h
index 1278f62..177f87b 100644
--- a/render/picturestr.h
+++ b/render/picturestr.h
@@ -132,7 +132,6 @@ typedef struct _Picture {
     unsigned int polyEdge:1;
     unsigned int polyMode:1;
     unsigned int freeCompClip:1;
-    unsigned int clientClipType:2;
     unsigned int componentAlpha:1;
     unsigned int repeatType:2;
     unsigned int filter:3;
@@ -145,7 +144,7 @@ typedef struct _Picture {
     DDXPointRec alphaOrigin;
 
     DDXPointRec clipOrigin;
-    void *clientClip;
+    RegionPtr clientClip;
 
     unsigned long serialNumber;
 
diff --git a/xfixes/region.c b/xfixes/region.c
index f9de525..4cfeee1 100644
--- a/xfixes/region.c
+++ b/xfixes/region.c
@@ -272,20 +272,12 @@ ProcXFixesCreateRegionFromPicture(ClientPtr client)
     if (!pPicture->pDrawable)
         return RenderErrBase + BadPicture;
 
-    switch (pPicture->clientClipType) {
-    case CT_PIXMAP:
-        pRegion = BitmapToRegion(pPicture->pDrawable->pScreen,
-                                 (PixmapPtr) pPicture->clientClip);
-        if (!pRegion)
-            return BadAlloc;
-        break;
-    case CT_REGION:
+    if (pPicture->clientClip) {
         pRegion = XFixesRegionCopy((RegionPtr) pPicture->clientClip);
         if (!pRegion)
             return BadAlloc;
-        break;
-    default:
-        return BadImplementation;       /* assume sane server bits */
+    } else {
+        return BadMatch;
     }
 
     if (!AddResource(stuff->region, RegionResType, (void *) pRegion))
commit 3f4edd2e3ff84c38df563b09c2e8c32404db38f7
Author: Adam Jackson <ajax at redhat.com>
Date:   Wed Oct 8 17:18:32 2014 +0200

    xinerama: Fix access mode in GetImage's drawable lookup
    
    Signed-off-by: Adam Jackson <ajax at redhat.com>
    Reviewed-by: Julien Cristau <jcristau at debian.org>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/Xext/panoramiXprocs.c b/Xext/panoramiXprocs.c
index aa3859f..0122ff3 100644
--- a/Xext/panoramiXprocs.c
+++ b/Xext/panoramiXprocs.c
@@ -1908,7 +1908,7 @@ PanoramiXGetImage(ClientPtr client)
     }
 
     rc = dixLookupResourceByClass((void **) &draw, stuff->drawable,
-                                  XRC_DRAWABLE, client, DixWriteAccess);
+                                  XRC_DRAWABLE, client, DixReadAccess);
     if (rc != Success)
         return (rc == BadValue) ? BadDrawable : rc;
 
commit 942e18e17e334d7a25f8c1dcc6f5c3711eeb6a7d
Author: William ML Leslie <william.leslie.ttg at gmail.com>
Date:   Wed May 21 10:28:52 2014 +1000

    Xephyr: option to disable grabbing the host
    
    This patch makes it possible to use C-S key combinations
    within Xephyr without losing access to the host window manager's
    commands.
    
    Signed-off-by: Keith Packard <keithp at keithp.com>
    Reviewed-by: Eric Anholt <eric at anholt.net>

diff --git a/hw/kdrive/ephyr/ephyr.c b/hw/kdrive/ephyr/ephyr.c
index 8b88f3e..5761710 100644
--- a/hw/kdrive/ephyr/ephyr.c
+++ b/hw/kdrive/ephyr/ephyr.c
@@ -68,6 +68,7 @@ typedef struct _EphyrInputPrivate {
 
 Bool EphyrWantGrayScale = 0;
 Bool EphyrWantResize = 0;
+Bool EphyrWantNoHostGrab = 0;
 
 Bool
 host_has_extension(xcb_extension_t *extension)
@@ -649,7 +650,11 @@ ephyrInitScreen(ScreenPtr pScreen)
 
     EPHYR_LOG("pScreen->myNum:%d\n", pScreen->myNum);
     hostx_set_screen_number(screen, pScreen->myNum);
-    hostx_set_win_title(screen, "(ctrl+shift grabs mouse and keyboard)");
+    if (EphyrWantNoHostGrab) {
+        hostx_set_win_title(screen, "xephyr");
+    } else {
+        hostx_set_win_title(screen, "(ctrl+shift grabs mouse and keyboard)");
+    }
     pScreen->CreateColormap = ephyrCreateColormap;
 
 #ifdef XV
@@ -1092,12 +1097,13 @@ ephyrProcessKeyRelease(xcb_generic_event_t *xev)
     if (!keysyms)
         keysyms = xcb_key_symbols_alloc(conn);
 
-    if (((xcb_key_symbols_get_keysym(keysyms, key->detail, 0) == XK_Shift_L
+    if (!EphyrWantNoHostGrab &&
+        (((xcb_key_symbols_get_keysym(keysyms, key->detail, 0) == XK_Shift_L
           || xcb_key_symbols_get_keysym(keysyms, key->detail, 0) == XK_Shift_R)
          && (key->state & XCB_MOD_MASK_CONTROL)) ||
         ((xcb_key_symbols_get_keysym(keysyms, key->detail, 0) == XK_Control_L
           || xcb_key_symbols_get_keysym(keysyms, key->detail, 0) == XK_Control_R)
-         && (key->state & XCB_MOD_MASK_SHIFT))) {
+         && (key->state & XCB_MOD_MASK_SHIFT)))) {
         KdScreenInfo *screen = screen_from_window(key->event);
         EphyrScrPriv *scrpriv = screen->driver;
 
diff --git a/hw/kdrive/ephyr/ephyrinit.c b/hw/kdrive/ephyr/ephyrinit.c
index 3693531..bcfb750 100644
--- a/hw/kdrive/ephyr/ephyrinit.c
+++ b/hw/kdrive/ephyr/ephyrinit.c
@@ -33,6 +33,7 @@
 extern Window EphyrPreExistingHostWin;
 extern Bool EphyrWantGrayScale;
 extern Bool EphyrWantResize;
+extern Bool EphyrWantNoHostGrab;
 extern Bool kdHasPointer;
 extern Bool kdHasKbd;
 extern Bool ephyr_glamor, ephyr_glamor_gles2;
@@ -153,6 +154,7 @@ ddxUseMsg(void)
     ErrorF("-name [name]         define the name in the WM_CLASS property\n");
     ErrorF
         ("-title [title]       set the window title in the WM_NAME property\n");
+    ErrorF("-no-host-grab        Disable grabbing the keyboard and mouse.\n");
     ErrorF("\n");
 }
 
@@ -360,6 +362,10 @@ ddxProcessArgument(int argc, char **argv, int i)
         return 2;
     }
     /* end Xnest compat */
+    else if (!strcmp(argv[i], "-no-host-grab")) {
+        EphyrWantNoHostGrab = 1;
+        return 2;
+    }
 
     return KdProcessArgument(argc, argv, i);
 }
diff --git a/hw/kdrive/ephyr/man/Xephyr.man b/hw/kdrive/ephyr/man/Xephyr.man
index f14f6c8..c043790 100644
--- a/hw/kdrive/ephyr/man/Xephyr.man
+++ b/hw/kdrive/ephyr/man/Xephyr.man
@@ -63,6 +63,9 @@ improvement is negligible.
 .B -resizeable
 Allow the Xephyr window to be resized, even if not embedded into a parent
 window. By default, the Xephyr window has a fixed size.
+.TP 8
+.B -no-host-grab
+Disable grabbing the keyboard and mouse.
 .SH "SIGNALS"
 Send a SIGUSR1 to the server (e.g. pkill -USR1 Xephyr) to
 toggle the debugging mode.
commit 61a292adf45405641de1c522a04c148e0a152acd
Author: Keith Packard <keithp at keithp.com>
Date:   Thu Oct 9 15:17:17 2014 +0200

    glx: check return from __glXGetAnswerBuffer
    
    This function can return NULL; make sure every caller tests for that.
    
    Reviewed-by: Adam Jackson <ajax at redhat.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/glx/indirect_dispatch.c b/glx/indirect_dispatch.c
index 329b2e6..f6cabef 100644
--- a/glx/indirect_dispatch.c
+++ b/glx/indirect_dispatch.c
@@ -2464,6 +2464,9 @@ __glXDisp_AreTexturesResident(__GLXclientState * cl, GLbyte * pc)
         GLboolean answerBuffer[200];
         GLboolean *residences =
             __glXGetAnswerBuffer(cl, n, answerBuffer, sizeof(answerBuffer), 1);
+
+        if (residences == NULL)
+            return BadAlloc;
         retval =
             glAreTexturesResident(n, (const GLuint *) (pc + 4), residences);
         __glXSendReply(cl->client, residences, n, 1, GL_TRUE, retval);
@@ -2488,6 +2491,9 @@ __glXDisp_AreTexturesResidentEXT(__GLXclientState * cl, GLbyte * pc)
         GLboolean answerBuffer[200];
         GLboolean *residences =
             __glXGetAnswerBuffer(cl, n, answerBuffer, sizeof(answerBuffer), 1);
+
+        if (residences == NULL)
+            return BadAlloc;
         retval =
             glAreTexturesResident(n, (const GLuint *) (pc + 4), residences);
         __glXSendReply(cl->client, residences, n, 1, GL_TRUE, retval);
@@ -2593,6 +2599,9 @@ __glXDisp_GenTextures(__GLXclientState * cl, GLbyte * pc)
         GLuint *textures =
             __glXGetAnswerBuffer(cl, n * 4, answerBuffer, sizeof(answerBuffer),
                                  4);
+
+        if (textures == NULL)
+            return BadAlloc;
         glGenTextures(n, textures);
         __glXSendReply(cl->client, textures, n, 4, GL_TRUE, 0);
         error = Success;
@@ -2616,6 +2625,9 @@ __glXDisp_GenTexturesEXT(__GLXclientState * cl, GLbyte * pc)
         GLuint *textures =
             __glXGetAnswerBuffer(cl, n * 4, answerBuffer, sizeof(answerBuffer),
                                  4);
+
+        if (textures == NULL)
+            return BadAlloc;
         glGenTextures(n, textures);
         __glXSendReply(cl->client, textures, n, 4, GL_TRUE, 0);
         error = Success;
@@ -3883,6 +3895,9 @@ __glXDisp_GenQueries(__GLXclientState * cl, GLbyte * pc)
         GLuint *ids =
             __glXGetAnswerBuffer(cl, n * 4, answerBuffer, sizeof(answerBuffer),
                                  4);
+
+        if (ids == NULL)
+            return BadAlloc;
         GenQueries(n, ids);
         __glXSendReply(cl->client, ids, n, 4, GL_TRUE, 0);
         error = Success;
@@ -4253,6 +4268,9 @@ __glXDisp_GenProgramsARB(__GLXclientState * cl, GLbyte * pc)
         GLuint *programs =
             __glXGetAnswerBuffer(cl, n * 4, answerBuffer, sizeof(answerBuffer),
                                  4);
+
+        if (programs == NULL)
+            return BadAlloc;
         GenProgramsARB(n, programs);
         __glXSendReply(cl->client, programs, n, 4, GL_TRUE, 0);
         error = Success;
@@ -4630,6 +4648,10 @@ __glXDisp_GenFramebuffers(__GLXclientState * cl, GLbyte * pc)
         GLuint *framebuffers =
             __glXGetAnswerBuffer(cl, n * 4, answerBuffer, sizeof(answerBuffer),
                                  4);
+
+        if (framebuffers == NULL)
+            return BadAlloc;
+
         GenFramebuffers(n, framebuffers);
         __glXSendReply(cl->client, framebuffers, n, 4, GL_TRUE, 0);
         error = Success;
@@ -4655,6 +4677,9 @@ __glXDisp_GenRenderbuffers(__GLXclientState * cl, GLbyte * pc)
         GLuint *renderbuffers =
             __glXGetAnswerBuffer(cl, n * 4, answerBuffer, sizeof(answerBuffer),
                                  4);
+
+        if (renderbuffers == NULL)
+            return BadAlloc;
         GenRenderbuffers(n, renderbuffers);
         __glXSendReply(cl->client, renderbuffers, n, 4, GL_TRUE, 0);
         error = Success;
diff --git a/glx/indirect_dispatch_swap.c b/glx/indirect_dispatch_swap.c
index 647d0c9..c0bb64d 100644
--- a/glx/indirect_dispatch_swap.c
+++ b/glx/indirect_dispatch_swap.c
@@ -2731,6 +2731,9 @@ __glXDispSwap_AreTexturesResident(__GLXclientState * cl, GLbyte * pc)
         GLboolean answerBuffer[200];
         GLboolean *residences =
             __glXGetAnswerBuffer(cl, n, answerBuffer, sizeof(answerBuffer), 1);
+
+        if (residences == NULL)
+            return BadAlloc;
         retval =
             glAreTexturesResident(n,
                                   (const GLuint *)
@@ -2759,6 +2762,9 @@ __glXDispSwap_AreTexturesResidentEXT(__GLXclientState * cl, GLbyte * pc)
         GLboolean answerBuffer[200];
         GLboolean *residences =
             __glXGetAnswerBuffer(cl, n, answerBuffer, sizeof(answerBuffer), 1);
+
+        if (residences == NULL)
+            return BadAlloc;
         retval =
             glAreTexturesResident(n,
                                   (const GLuint *)
@@ -2878,6 +2884,9 @@ __glXDispSwap_GenTextures(__GLXclientState * cl, GLbyte * pc)
         GLuint *textures =
             __glXGetAnswerBuffer(cl, n * 4, answerBuffer, sizeof(answerBuffer),
                                  4);
+
+        if (textures == NULL)
+            return BadAlloc;
         glGenTextures(n, textures);
         (void) bswap_32_array((uint32_t *) textures, n);
         __glXSendReplySwap(cl->client, textures, n, 4, GL_TRUE, 0);
@@ -2903,6 +2912,9 @@ __glXDispSwap_GenTexturesEXT(__GLXclientState * cl, GLbyte * pc)
         GLuint *textures =
             __glXGetAnswerBuffer(cl, n * 4, answerBuffer, sizeof(answerBuffer),
                                  4);
+
+        if (textures == NULL)
+            return BadAlloc;
         glGenTextures(n, textures);
         (void) bswap_32_array((uint32_t *) textures, n);
         __glXSendReplySwap(cl->client, textures, n, 4, GL_TRUE, 0);
@@ -4290,6 +4302,9 @@ __glXDispSwap_GenQueries(__GLXclientState * cl, GLbyte * pc)
         GLuint *ids =
             __glXGetAnswerBuffer(cl, n * 4, answerBuffer, sizeof(answerBuffer),
                                  4);
+        if (ids == NULL)
+            return BadAlloc;
+
         GenQueries(n, ids);
         (void) bswap_32_array((uint32_t *) ids, n);
         __glXSendReplySwap(cl->client, ids, n, 4, GL_TRUE, 0);
@@ -4697,6 +4712,9 @@ __glXDispSwap_GenProgramsARB(__GLXclientState * cl, GLbyte * pc)
         GLuint *programs =
             __glXGetAnswerBuffer(cl, n * 4, answerBuffer, sizeof(answerBuffer),
                                  4);
+        if (programs == NULL)
+            return BadAlloc;
+
         GenProgramsARB(n, programs);
         (void) bswap_32_array((uint32_t *) programs, n);
         __glXSendReplySwap(cl->client, programs, n, 4, GL_TRUE, 0);
@@ -5122,6 +5140,10 @@ __glXDispSwap_GenFramebuffers(__GLXclientState * cl, GLbyte * pc)
         GLuint *framebuffers =
             __glXGetAnswerBuffer(cl, n * 4, answerBuffer, sizeof(answerBuffer),
                                  4);
+
+        if (framebuffers == NULL)
+            return BadAlloc;
+
         GenFramebuffers(n, framebuffers);
         (void) bswap_32_array((uint32_t *) framebuffers, n);
         __glXSendReplySwap(cl->client, framebuffers, n, 4, GL_TRUE, 0);
@@ -5149,6 +5171,10 @@ __glXDispSwap_GenRenderbuffers(__GLXclientState * cl, GLbyte * pc)
         GLuint *renderbuffers =
             __glXGetAnswerBuffer(cl, n * 4, answerBuffer, sizeof(answerBuffer),
                                  4);
+
+        if (renderbuffers == NULL)
+            return BadAlloc;
+
         GenRenderbuffers(n, renderbuffers);
         (void) bswap_32_array((uint32_t *) renderbuffers, n);
         __glXSendReplySwap(cl->client, renderbuffers, n, 4, GL_TRUE, 0);
commit d634ecdf82f244ff8ce75d351fc175792d254e5c
Merge: 6622f0c 7ebf480
Author: Keith Packard <keithp at keithp.com>
Date:   Thu Oct 9 15:08:31 2014 +0200

    Merge remote-tracking branch 'ajax/dead-code'

commit 6622f0cb1761501f3287ffa8d3cbca3fd30f9f0c
Merge: f12e7f4 5ecd786
Author: Keith Packard <keithp at keithp.com>
Date:   Thu Oct 9 15:05:26 2014 +0200

    Merge remote-tracking branch 'ajax/mi-cleanup'

commit f12e7f4980416b74988052a04d0f2487b2c4a7e9
Merge: da88772 aaf5e2d
Author: Keith Packard <keithp at keithp.com>
Date:   Thu Oct 9 14:21:19 2014 +0200

    Merge remote-tracking branch 'anholt/modesetting-glamor'

commit da887726eeaece0396962dd3912578d3372881b1
Author: Alan Coopersmith <alan.coopersmith at oracle.com>
Date:   Sun Sep 21 09:49:06 2014 -0700

    Use unique display name for each xi2 test program [v3]
    
    make -j 8 check was sporadically failing in different xi2 tests.
    After adding the asserts in the previous commit to catch xkb failure
    it became easier to catch the failures and see that multiple tests
    were running at once trying to write to /tmp/server-(null).xkm and
    then delete it, and interfering with each other.
    
    Putting a unique string into the display variable let them each write
    to their own file and not interfere with others.
    
    v2: Fix Linux bits:
    
      Add #include <errno.h> to get a declaration of
      program_invocation_name on Linux.
    
      Use only the last portion of the pathname so that the resulting
      display name doesn't contain any slashes.
    
    v3: use program_invocation_short_name on Linux
    
      This is the same as program_invocation_name, except is has
      stripped off any path prefix.
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Adam Jackson <ajax at redhat.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/configure.ac b/configure.ac
index 30c0c5c..c697188 100644
--- a/configure.ac
+++ b/configure.ac
@@ -217,10 +217,12 @@ AC_SUBST(DLOPEN_LIBS)
 
 dnl Checks for library functions.
 AC_CHECK_FUNCS([backtrace ffs geteuid getuid issetugid getresuid \
-	getdtablesize getifaddrs getpeereid getpeerucred getzoneid \
+	getdtablesize getifaddrs getpeereid getpeerucred getprogname getzoneid \
 	mmap seteuid shmctl64 strncasecmp vasprintf vsnprintf walkcontext])
 AC_REPLACE_FUNCS([strcasecmp strcasestr strlcat strlcpy strndup])
 
+AC_CHECK_DECLS([program_invocation_short_name], [], [], [[#include <errno.h>]])
+
 dnl Find the math libary, then check for cbrt function in it.
 AC_CHECK_LIB(m, sqrt)
 AC_CHECK_FUNCS([cbrt])
diff --git a/include/dix-config.h.in b/include/dix-config.h.in
index f170c1c..1aa77a5 100644
--- a/include/dix-config.h.in
+++ b/include/dix-config.h.in
@@ -72,6 +72,10 @@
 /* Define to 1 if you have the <dbm.h> header file. */
 #undef HAVE_DBM_H
 
+/* Define to 1 if you have the declaration of `program_invocation_short_name', and
+   to 0 if you don't. */
+#undef HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME
+
 /* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
    */
 #undef HAVE_DIRENT_H
@@ -100,6 +104,9 @@
 /* Define to 1 if you have the `getpeerucred' function. */
 #undef HAVE_GETPEERUCRED
 
+/* Define to 1 if you have the `getprogname' function. */
+#undef HAVE_GETPROGNAME
+
 /* Define to 1 if you have the `getzoneid' function. */
 #undef HAVE_GETZONEID
 
diff --git a/test/xi2/protocol-common.c b/test/xi2/protocol-common.c
index 64a5777..9265ba3 100644
--- a/test/xi2/protocol-common.c
+++ b/test/xi2/protocol-common.c
@@ -25,6 +25,7 @@
 #include <dix-config.h>
 #endif
 
+#include <errno.h>
 #include <stdint.h>
 #include "extinit.h"            /* for XInputExtensionInit */
 #include "exglobals.h"
@@ -139,6 +140,17 @@ init_devices(void)
     struct devices local_devices;
     int ret;
 
+    /*
+     * Put a unique name in display pointer so that when tests are run in
+     * parallel, their xkbcomp outputs to /tmp/server-<display>.xkm don't
+     * stomp on each other.
+     */
+#ifdef HAVE_GETPROGNAME
+    display = getprogname();
+#elif HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME
+    display = program_invocation_short_name;
+#endif
+
     client = init_client(0, NULL);
 
     AllocDevicePair(&client, "Virtual core", &local_devices.vcp, &local_devices.vck,
commit 5ecd7866f7587d620f000e802a262c7cd4b9df33
Author: Adam Jackson <ajax at redhat.com>
Date:   Thu Sep 11 10:11:39 2014 -0400

    misc: Fold together some redundant conditionals
    
    Reviewed-by: Julien Cristau <jcristau at debian.org>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/dix/window.c b/dix/window.c
index 7a2866a..d43ef03 100644
--- a/dix/window.c
+++ b/dix/window.c
@@ -2059,10 +2059,10 @@ ReflectStackChange(WindowPtr pWin, WindowPtr pSib, VTKind kind)
         if (anyMarked) {
             (*pScreen->ValidateTree) (pLayerWin->parent, pFirstChange, kind);
             (*pScreen->HandleExposures) (pLayerWin->parent);
+            if (pWin->drawable.pScreen->PostValidateTree)
+                (*pScreen->PostValidateTree) (pLayerWin->parent, pFirstChange,
+                                              kind);
         }
-        if (anyMarked && pWin->drawable.pScreen->PostValidateTree)
-            (*pScreen->PostValidateTree) (pLayerWin->parent, pFirstChange,
-                                          kind);
     }
     if (pWin->realized)
         WindowsRestructured();
@@ -2576,10 +2576,10 @@ MapWindow(WindowPtr pWin, ClientPtr client)
             if (anyMarked) {
                 (*pScreen->ValidateTree) (pLayerWin->parent, pLayerWin, VTMap);
                 (*pScreen->HandleExposures) (pLayerWin->parent);
+                if (pScreen->PostValidateTree)
+                    (*pScreen->PostValidateTree) (pLayerWin->parent, pLayerWin,
+                                                  VTMap);
             }
-            if (anyMarked && pScreen->PostValidateTree)
-                (*pScreen->PostValidateTree) (pLayerWin->parent, pLayerWin,
-                                              VTMap);
         }
         WindowsRestructured();
     }
@@ -2657,10 +2657,10 @@ MapSubwindows(WindowPtr pParent, ClientPtr client)
         if (anyMarked) {
             (*pScreen->ValidateTree) (pLayerWin->parent, pFirstMapped, VTMap);
             (*pScreen->HandleExposures) (pLayerWin->parent);
+            if (pScreen->PostValidateTree)
+                (*pScreen->PostValidateTree) (pLayerWin->parent, pFirstMapped,
+                                              VTMap);
         }
-        if (anyMarked && pScreen->PostValidateTree)
-            (*pScreen->PostValidateTree) (pLayerWin->parent, pFirstMapped,
-                                          VTMap);
         WindowsRestructured();
     }
 }
@@ -2754,9 +2754,9 @@ UnmapWindow(WindowPtr pWin, Bool fromConfigure)
         if (!fromConfigure) {
             (*pScreen->ValidateTree) (pLayerWin->parent, pWin, VTUnmap);
             (*pScreen->HandleExposures) (pLayerWin->parent);
+            if (pScreen->PostValidateTree)
+                (*pScreen->PostValidateTree) (pLayerWin->parent, pWin, VTUnmap);
         }
-        if (!fromConfigure && pScreen->PostValidateTree)
-            (*pScreen->PostValidateTree) (pLayerWin->parent, pWin, VTUnmap);
     }
     if (wasRealized && !fromConfigure) {
         WindowsRestructured();
@@ -2824,9 +2824,10 @@ UnmapSubwindows(WindowPtr pWin)
             }
             (*pScreen->ValidateTree) (pLayerWin->parent, pHead, VTUnmap);
             (*pScreen->HandleExposures) (pLayerWin->parent);
+            if (pScreen->PostValidateTree)
+                (*pScreen->PostValidateTree) (pLayerWin->parent, pHead,
+                                              VTUnmap);
         }
-        if (anyMarked && pScreen->PostValidateTree)
-            (*pScreen->PostValidateTree) (pLayerWin->parent, pHead, VTUnmap);
     }
     if (wasRealized) {
         WindowsRestructured();
@@ -3592,15 +3593,12 @@ SetRootClip(ScreenPtr pScreen, Bool enable)
             anyMarked = TRUE;
         }
 
-        if (anyMarked)
+        if (anyMarked) {
             (*pScreen->ValidateTree) (pWin, NullWindow, VTOther);
-    }
-
-    if (WasViewable) {
-        if (anyMarked)
             (*pScreen->HandleExposures) (pWin);
-        if (anyMarked && pScreen->PostValidateTree)
-            (*pScreen->PostValidateTree) (pWin, NullWindow, VTOther);
+            if (pScreen->PostValidateTree)
+                (*pScreen->PostValidateTree) (pWin, NullWindow, VTOther);
+        }
     }
     if (pWin->realized)
         WindowsRestructured();
diff --git a/mi/mioverlay.c b/mi/mioverlay.c
index 2ad6bc0..eb8dda1 100644
--- a/mi/mioverlay.c
+++ b/mi/mioverlay.c
@@ -1464,11 +1464,7 @@ miOverlaySetShape(WindowPtr pWin, int kind)
 
         if (WasViewable) {
             (*pScreen->MarkOverlappedWindows) (pWin, pWin, NULL);
-
             (*pScreen->ValidateTree) (pWin->parent, NullWindow, VTOther);
-        }
-
-        if (WasViewable) {
             (*pScreen->HandleExposures) (pWin->parent);
             if (pScreen->PostValidateTree)
                 (*pScreen->PostValidateTree) (pWin->parent, NullWindow,
diff --git a/mi/miwindow.c b/mi/miwindow.c
index cfe085a..0cf5046 100644
--- a/mi/miwindow.c
+++ b/mi/miwindow.c
@@ -292,9 +292,9 @@ miMoveWindow(WindowPtr pWin, int x, int y, WindowPtr pNextSib, VTKind kind)
             RegionDestroy(oldRegion);
             /* XXX need to retile border if ParentRelative origin */
             (*pScreen->HandleExposures) (pLayerWin->parent);
+            if (pScreen->PostValidateTree)
+                (*pScreen->PostValidateTree) (pLayerWin->parent, NULL, kind);
         }
-        if (anyMarked && pScreen->PostValidateTree)
-            (*pScreen->PostValidateTree) (pLayerWin->parent, NullWindow, kind);
     }
     if (pWin->realized)
         WindowsRestructured();
@@ -607,11 +607,12 @@ miResizeWindow(WindowPtr pWin, int x, int y, unsigned int w, unsigned int h,
         RegionDestroy(pRegion);
         if (destClip)
             RegionDestroy(destClip);
-        if (anyMarked)
+        if (anyMarked) {
             (*pScreen->HandleExposures) (pLayerWin->parent);
-        if (anyMarked && pScreen->PostValidateTree)
-            (*pScreen->PostValidateTree) (pLayerWin->parent, pFirstChange,
-                                          VTOther);
+            if (pScreen->PostValidateTree)
+                (*pScreen->PostValidateTree) (pLayerWin->parent, pFirstChange,
+                                              VTOther);
+        }
     }
     if (pWin->realized)
         WindowsRestructured();
@@ -663,17 +664,14 @@ miSetShape(WindowPtr pWin, int kind)
         if (WasViewable) {
             anyMarked |= (*pScreen->MarkOverlappedWindows) (pWin, pWin, NULL);
 
-            if (anyMarked)
+            if (anyMarked) {
                 (*pScreen->ValidateTree) (pLayerWin->parent, NullWindow,
                                           VTOther);
-        }
-
-        if (WasViewable) {
-            if (anyMarked)
                 (*pScreen->HandleExposures) (pLayerWin->parent);
-            if (anyMarked && pScreen->PostValidateTree)
-                (*pScreen->PostValidateTree) (pLayerWin->parent, NullWindow,
-                                              VTOther);
+                if (pScreen->PostValidateTree)
+                    (*pScreen->PostValidateTree) (pLayerWin->parent, NULL,
+                                                  VTOther);
+            }
         }
     }
     if (pWin->realized)
@@ -725,10 +723,10 @@ miChangeBorderWidth(WindowPtr pWin, unsigned int width)
         if (anyMarked) {
             (*pScreen->ValidateTree) (pLayerWin->parent, pLayerWin, VTOther);
             (*pScreen->HandleExposures) (pLayerWin->parent);
+            if (pScreen->PostValidateTree)
+                (*pScreen->PostValidateTree) (pLayerWin->parent, pLayerWin,
+                                              VTOther);
         }
-        if (anyMarked && pScreen->PostValidateTree)
-            (*pScreen->PostValidateTree) (pLayerWin->parent, pLayerWin,
-                                          VTOther);
     }
     if (pWin->realized)
         WindowsRestructured();
commit 5b07f1db6de9f08f757206454da03ee0ae872bfc
Author: Adam Jackson <ajax at redhat.com>
Date:   Thu Sep 18 16:05:40 2014 -0400

    fb: fb{Map,Unmap}Window -> fb{Realize,Unrealize}Window
    
    Make the function names match the screen slot name.
    
    Reviewed-by: Julien Cristau <jcristau at debian.org>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/fb/fb.h b/fb/fb.h
index 9057767..d176bb3 100644
--- a/fb/fb.h
+++ b/fb/fb.h
@@ -1621,13 +1621,13 @@ extern _X_EXPORT Bool
  fbDestroyWindow(WindowPtr pWin);
 
 extern _X_EXPORT Bool
- fbMapWindow(WindowPtr pWindow);
+ fbRealizeWindow(WindowPtr pWindow);
 
 extern _X_EXPORT Bool
  fbPositionWindow(WindowPtr pWin, int x, int y);
 
 extern _X_EXPORT Bool
- fbUnmapWindow(WindowPtr pWindow);
+ fbUnrealizeWindow(WindowPtr pWindow);
 
 extern _X_EXPORT void
 
diff --git a/fb/fbscreen.c b/fb/fbscreen.c
index 0d4d87f..71bcc5d 100644
--- a/fb/fbscreen.c
+++ b/fb/fbscreen.c
@@ -110,8 +110,8 @@ fbSetupScreen(ScreenPtr pScreen, void *pbits, /* pointer to screen bitmap */
     pScreen->DestroyWindow = fbDestroyWindow;
     pScreen->PositionWindow = fbPositionWindow;
     pScreen->ChangeWindowAttributes = fbChangeWindowAttributes;
-    pScreen->RealizeWindow = fbMapWindow;
-    pScreen->UnrealizeWindow = fbUnmapWindow;
+    pScreen->RealizeWindow = fbRealizeWindow;
+    pScreen->UnrealizeWindow = fbUnrealizeWindow;
     pScreen->CopyWindow = fbCopyWindow;
     pScreen->CreatePixmap = fbCreatePixmap;
     pScreen->DestroyPixmap = fbDestroyPixmap;
diff --git a/fb/fbwindow.c b/fb/fbwindow.c
index c90175f..7a5fac8 100644
--- a/fb/fbwindow.c
+++ b/fb/fbwindow.c
@@ -46,7 +46,7 @@ fbDestroyWindow(WindowPtr pWin)
 }
 
 Bool
-fbMapWindow(WindowPtr pWindow)
+fbRealizeWindow(WindowPtr pWindow)
 {
     return TRUE;
 }
@@ -58,7 +58,7 @@ fbPositionWindow(WindowPtr pWin, int x, int y)
 }
 
 Bool
-fbUnmapWindow(WindowPtr pWindow)
+fbUnrealizeWindow(WindowPtr pWindow)
 {
     return TRUE;
 }
diff --git a/fb/wfbrename.h b/fb/wfbrename.h
index 54d00d0..749c6d0 100644
--- a/fb/wfbrename.h
+++ b/fb/wfbrename.h
@@ -88,7 +88,6 @@
 #define fbInstallColormap wfbInstallColormap
 #define fbLaneTable wfbLaneTable
 #define fbListInstalledColormaps wfbListInstalledColormaps
-#define fbMapWindow wfbMapWindow
 #define FbMergeRopBits wFbMergeRopBits
 #define fbOddStipple wfbOddStipple
 #define fbOddTile wfbOddTile
@@ -134,6 +133,7 @@
 #define fbQueryBestSize wfbQueryBestSize
 #define fbRasterizeTrapezoid wfbRasterizeTrapezoid
 #define fbRealizeFont wfbRealizeFont
+#define fbRealizeWindow wfbRealizeWindow
 #define fbReduceRasterOp wfbReduceRasterOp
 #define fbReplicatePixel wfbReplicatePixel
 #define fbResolveColor wfbResolveColor
@@ -160,7 +160,7 @@
 #define fbTrapezoids wfbTrapezoids
 #define fbTriangles wfbTriangles
 #define fbUninstallColormap wfbUninstallColormap
-#define fbUnmapWindow wfbUnmapWindow
+#define fbUnrealizeWindow wfbUnrealizeWindow
 #define fbUnrealizeFont wfbUnrealizeFont
 #define fbValidateGC wfbValidateGC
 #define fbWinPrivateKeyRec wfbWinPrivateKeyRec
commit 9ed83a694b6492c9db226b115ed282cb127e798e
Author: Adam Jackson <ajax at redhat.com>
Date:   Thu Sep 18 15:36:57 2014 -0400

    mi: miSlideAndSizeWindow -> miResizeWindow
    
    Make the function name match the screen slot name.
    
    Reviewed-by: Julien Cristau <jcristau at debian.org>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/mi/mi.h b/mi/mi.h
index 8cb3ce7..5a455c9 100644
--- a/mi/mi.h
+++ b/mi/mi.h
@@ -470,12 +470,12 @@ extern _X_EXPORT void miMoveWindow(WindowPtr /*pWin */ ,
                                    VTKind       /*kind */
     );
 
-extern _X_EXPORT void miSlideAndSizeWindow(WindowPtr /*pWin */ ,
-                                           int /*x */ ,
-                                           int /*y */ ,
-                                           unsigned int /*w */ ,
-                                           unsigned int /*h */ ,
-                                           WindowPtr    /*pSib */
+extern _X_EXPORT void miResizeWindow(WindowPtr /*pWin */ ,
+                                     int /*x */ ,
+                                     int /*y */ ,
+                                     unsigned int /*w */ ,
+                                     unsigned int /*h */ ,
+                                     WindowPtr    /*pSib */
     );
 
 extern _X_EXPORT WindowPtr miGetLayerWindow(WindowPtr   /*pWin */
diff --git a/mi/miscrinit.c b/mi/miscrinit.c
index ec4d108..327bd15 100644
--- a/mi/miscrinit.c
+++ b/mi/miscrinit.c
@@ -264,7 +264,7 @@ miScreenInit(ScreenPtr pScreen, void *pbits,  /* pointer to screen bits */
     pScreen->MarkWindow = miMarkWindow;
     pScreen->MarkOverlappedWindows = miMarkOverlappedWindows;
     pScreen->MoveWindow = miMoveWindow;
-    pScreen->ResizeWindow = miSlideAndSizeWindow;
+    pScreen->ResizeWindow = miResizeWindow;
     pScreen->GetLayerWindow = miGetLayerWindow;
     pScreen->HandleExposures = miHandleValidateExposures;
     pScreen->ReparentWindow = (ReparentWindowProcPtr) 0;
diff --git a/mi/miwindow.c b/mi/miwindow.c
index ba4c9ed..cfe085a 100644
--- a/mi/miwindow.c
+++ b/mi/miwindow.c
@@ -337,9 +337,8 @@ miRecomputeExposures(WindowPtr pWin, void *value)
 }
 
 void
-miSlideAndSizeWindow(WindowPtr pWin,
-                     int x, int y,
-                     unsigned int w, unsigned int h, WindowPtr pSib)
+miResizeWindow(WindowPtr pWin, int x, int y, unsigned int w, unsigned int h,
+               WindowPtr pSib)
 {
     WindowPtr pParent;
     Bool WasViewable = (Bool) (pWin->viewable);
commit 939ca767c7603923a91fd37901175a42e802d40e
Author: Adam Jackson <ajax at redhat.com>
Date:   Thu Sep 18 14:50:28 2014 -0400

    dix: Remove an obfuscatory macro
    
    Reviewed-by: Julien Cristau <jcristau at debian.org>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/dix/window.c b/dix/window.c
index 295038a..7a2866a 100644
--- a/dix/window.c
+++ b/dix/window.c
@@ -1812,8 +1812,6 @@ ResizeChildrenWinSize(WindowPtr pWin, int dx, int dy, int dw, int dh)
 
 #define ChangeMask ((Mask)(CWX | CWY | CWWidth | CWHeight))
 
-#define IllegalInputOnlyConfigureMask (CWBorderWidth)
-
 /*
  * IsSiblingAboveMe
  *     returns Above if pSib above pMe in stack or Below otherwise 
@@ -2091,8 +2089,7 @@ ConfigureWindow(WindowPtr pWin, Mask mask, XID *vlist, ClientPtr client)
         h = pWin->drawable.height, bw = pWin->borderWidth;
     int rc, action, smode = Above;
 
-    if ((pWin->drawable.class == InputOnly) &&
-        (mask & IllegalInputOnlyConfigureMask))
+    if ((pWin->drawable.class == InputOnly) && (mask & CWBorderWidth))
         return BadMatch;
 
     if ((mask & CWSibling) && !(mask & CWStackMode))
commit d138d9ccc62a9472925574089f346bf9aa3dab1f
Author: Adam Jackson <ajax at redhat.com>
Date:   Mon Sep 15 13:05:24 2014 -0400

    dix: Remove some pointless casting of NULL
    
    Reviewed-by: Julien Cristau <jcristau at debian.org>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/dix/window.c b/dix/window.c
index e49670a..295038a 100644
--- a/dix/window.c
+++ b/dix/window.c
@@ -357,8 +357,8 @@ SetWindowToDefaults(WindowPtr pWin)
     pWin->firstChild = NullWindow;
     pWin->lastChild = NullWindow;
 
-    pWin->valdata = (ValidatePtr) NULL;
-    pWin->optional = (WindowOptPtr) NULL;
+    pWin->valdata = NULL;
+    pWin->optional = NULL;
     pWin->cursorIsNone = TRUE;
 
     pWin->backingStore = NotUseful;
@@ -1550,7 +1550,7 @@ MoveWindowInStack(WindowPtr pWin, WindowPtr pNextSib)
             if (pWin->prevSib)
                 pWin->prevSib->nextSib = pWin->nextSib;
             pWin->nextSib = pParent->firstChild;
-            pWin->prevSib = (WindowPtr) NULL;
+            pWin->prevSib = NULL;
             pNextSib->prevSib = pWin;
             pParent->firstChild = pWin;
         }
@@ -1847,7 +1847,7 @@ WindowExtents(WindowPtr pWin, BoxPtr pBox)
     return pBox;
 }
 
-#define IS_SHAPED(pWin)	(wBoundingShape (pWin) != (RegionPtr) NULL)
+#define IS_SHAPED(pWin)	(wBoundingShape (pWin) != NULL)
 
 static RegionPtr
 MakeBoundingRegion(WindowPtr pWin, BoxPtr pBox)
@@ -1953,7 +1953,7 @@ WhereDoIGoInTheStack(WindowPtr pWin,
     WindowPtr pHead, pFirst;
 
     if ((pWin == pWin->parent->firstChild) && (pWin == pWin->parent->lastChild))
-        return ((WindowPtr) NULL);
+        return NULL;
     pHead = RealChildHead(pWin->parent);
     pFirst = pHead ? pHead->nextSib : pWin->parent->firstChild;
     box.x1 = x;
@@ -2644,8 +2644,7 @@ MapSubwindows(WindowPtr pParent, ClientPtr client)
                 RealizeTree(pWin);
                 if (pWin->viewable) {
                     anyMarked |= (*pScreen->MarkOverlappedWindows) (pWin, pWin,
-                                                                    (WindowPtr
-                                                                     *) NULL);
+                                                                    NULL);
                 }
             }
         }
@@ -2655,8 +2654,7 @@ MapSubwindows(WindowPtr pParent, ClientPtr client)
         pLayerWin = (*pScreen->GetLayerWindow) (pParent);
         if (pLayerWin->parent != pParent) {
             anyMarked |= (*pScreen->MarkOverlappedWindows) (pLayerWin,
-                                                            pLayerWin,
-                                                            (WindowPtr *) NULL);
+                                                            pLayerWin, NULL);
             pFirstMapped = pLayerWin;
         }
         if (anyMarked) {
@@ -2815,8 +2813,7 @@ UnmapSubwindows(WindowPtr pWin)
             else {
                 WindowPtr ptmp;
 
-                (*pScreen->MarkOverlappedWindows) (pWin, pLayerWin,
-                                                   (WindowPtr *) NULL);
+                (*pScreen->MarkOverlappedWindows) (pWin, pLayerWin, NULL);
                 (*pScreen->MarkWindow) (pLayerWin->parent);
 
                 /* Windows between pWin and pLayerWin may not have been marked */
@@ -2875,7 +2872,7 @@ HandleSaveSet(ClientPtr client)
     }
     free(client->saveSet);
     client->numSaved = 0;
-    client->saveSet = (SaveSetElt *) NULL;
+    client->saveSet = NULL;
 }
 
 /**
@@ -3591,7 +3588,7 @@ SetRootClip(ScreenPtr pScreen, Bool enable)
         if (pWin->firstChild) {
             anyMarked |= (*pScreen->MarkOverlappedWindows) (pWin->firstChild,
                                                             pWin->firstChild,
-                                                            (WindowPtr *) NULL);
+                                                            NULL);
         }
         else {
             (*pScreen->MarkWindow) (pWin);
commit 277330075bfbd4343c4efdd136e0be716e1a491f
Author: Adam Jackson <ajax at redhat.com>
Date:   Mon Sep 15 12:30:44 2014 -0400

    dix: Remove an empty if
    
    Reviewed-by: Julien Cristau <jcristau at debian.org>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/dix/window.c b/dix/window.c
index e1645c3..e49670a 100644
--- a/dix/window.c
+++ b/dix/window.c
@@ -2806,8 +2806,6 @@ UnmapSubwindows(WindowPtr pWin)
             pChild->mapped = FALSE;
             if (pChild->realized)
                 UnrealizeTree(pChild, FALSE);
-            if (wasViewable) {
-            }
         }
     }
     if (wasViewable) {
commit 81d76a835b2f647e3051b1d93606e59db7998d76
Author: Adam Jackson <ajax at redhat.com>
Date:   Mon Sep 15 12:10:55 2014 -0400

    dix: Lower backStorage to a bit instead of a pointer
    
    Reviewed-by: Julien Cristau <jcristau at debian.org>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/composite/compinit.c b/composite/compinit.c
index 48e938f..111c16e 100644
--- a/composite/compinit.c
+++ b/composite/compinit.c
@@ -119,12 +119,12 @@ compChangeWindowAttributes(WindowPtr pWin, unsigned long mask)
         pScreen->backingStoreSupport != NotUseful) {
         if (pWin->backingStore != NotUseful && !pWin->backStorage) {
             compRedirectWindow(serverClient, pWin, CompositeRedirectAutomatic);
-            pWin->backStorage = (void *) (intptr_t) 1;
+            pWin->backStorage = TRUE;
         }
         else if (pWin->backingStore == NotUseful && pWin->backStorage) {
             compUnredirectWindow(serverClient, pWin,
                                  CompositeRedirectAutomatic);
-            pWin->backStorage = NULL;
+            pWin->backStorage = FALSE;
         }
     }
 
diff --git a/dix/window.c b/dix/window.c
index f227e4c..e1645c3 100644
--- a/dix/window.c
+++ b/dix/window.c
@@ -362,7 +362,7 @@ SetWindowToDefaults(WindowPtr pWin)
     pWin->cursorIsNone = TRUE;
 
     pWin->backingStore = NotUseful;
-    pWin->backStorage = (void *) NULL;
+    pWin->backStorage = 0;
 
     pWin->mapped = FALSE;       /* off */
     pWin->realized = FALSE;     /* off */
diff --git a/include/windowstr.h b/include/windowstr.h
index 81f5f8c..740f4a6 100644
--- a/include/windowstr.h
+++ b/include/windowstr.h
@@ -144,12 +144,12 @@ typedef struct _Window {
     Mask eventMask;             /* mask from the creating client */
     PixUnion background;
     PixUnion border;
-    void *backStorage;          /* null when BS disabled */
     WindowOptPtr optional;
     unsigned backgroundState:2; /* None, Relative, Pixel, Pixmap */
     unsigned borderIsPixel:1;
     unsigned cursorIsNone:1;    /* else real cursor (might inherit) */
     unsigned backingStore:2;
+    unsigned backStorage:1;     /* if bs is allocated */
     unsigned saveUnder:1;
     unsigned bitGravity:4;
     unsigned winGravity:4;
diff --git a/mi/miexpose.c b/mi/miexpose.c
index 555f3b2..de8ee6c 100644
--- a/mi/miexpose.c
+++ b/mi/miexpose.c
@@ -143,7 +143,7 @@ miHandleExposures(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable,
     if (!pGC->graphicsExposures &&
         (pDstDrawable->type == DRAWABLE_PIXMAP) &&
         ((pSrcDrawable->type == DRAWABLE_PIXMAP) ||
-         (((WindowPtr) pSrcDrawable)->backStorage == NULL)))
+         (((WindowPtr) pSrcDrawable)->backStorage == 0)))
         return NULL;
 
     srcBox.x1 = srcx;
commit 322ba42c23a3a107f7a62fb1c449792b616e5eba
Author: Adam Jackson <ajax at redhat.com>
Date:   Mon Sep 15 12:05:26 2014 -0400

    dix: Remove DIXsaveUnder bit from the Window
    
    Reviewed-by: Julien Cristau <jcristau at debian.org>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/dix/window.c b/dix/window.c
index 52e69ef..f227e4c 100644
--- a/dix/window.c
+++ b/dix/window.c
@@ -362,7 +362,6 @@ SetWindowToDefaults(WindowPtr pWin)
     pWin->cursorIsNone = TRUE;
 
     pWin->backingStore = NotUseful;
-    pWin->DIXsaveUnder = FALSE;
     pWin->backStorage = (void *) NULL;
 
     pWin->mapped = FALSE;       /* off */
diff --git a/include/windowstr.h b/include/windowstr.h
index 6b79bbd..81f5f8c 100644
--- a/include/windowstr.h
+++ b/include/windowstr.h
@@ -151,7 +151,6 @@ typedef struct _Window {
     unsigned cursorIsNone:1;    /* else real cursor (might inherit) */
     unsigned backingStore:2;
     unsigned saveUnder:1;
-    unsigned DIXsaveUnder:1;
     unsigned bitGravity:4;
     unsigned winGravity:4;
     unsigned overrideRedirect:1;
commit 1e56b2dfc6377234ffdcdf206528d476b04d13af
Author: Adam Jackson <ajax at redhat.com>
Date:   Fri Sep 12 12:51:13 2014 -0400

    mi: Move pScreen->SendGraphicsExpose up to dix
    
    No DDX is overriding this and it's fairly absurd to expose it as a
    screen operation anyway.
    
    Reviewed-by: Julien Cristau <jcristau at debian.org>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/Xext/panoramiXprocs.c b/Xext/panoramiXprocs.c
index 83a2e08..aa3859f 100644
--- a/Xext/panoramiXprocs.c
+++ b/Xext/panoramiXprocs.c
@@ -1193,9 +1193,8 @@ PanoramiXCopyArea(ClientPtr client)
             Bool overlap;
 
             RegionValidate(&totalReg, &overlap);
-            (*pDst->pScreen->SendGraphicsExpose) (client, &totalReg,
-                                                  stuff->dstDrawable,
-                                                  X_CopyArea, 0);
+            SendGraphicsExpose(client, &totalReg, stuff->dstDrawable,
+                               X_CopyArea, 0);
             RegionUninit(&totalReg);
         }
     }
@@ -1306,9 +1305,8 @@ PanoramiXCopyPlane(ClientPtr client)
         Bool overlap;
 
         RegionValidate(&totalReg, &overlap);
-        (*pdstDraw->pScreen->SendGraphicsExpose) (client, &totalReg,
-                                                  stuff->dstDrawable,
-                                                  X_CopyPlane, 0);
+        SendGraphicsExpose(client, &totalReg, stuff->dstDrawable,
+                           X_CopyPlane, 0);
         RegionUninit(&totalReg);
     }
 
diff --git a/dix/dispatch.c b/dix/dispatch.c
index f7a08f8..74abecd 100644
--- a/dix/dispatch.c
+++ b/dix/dispatch.c
@@ -1597,6 +1597,52 @@ ProcClearToBackground(ClientPtr client)
     return Success;
 }
 
+/* send GraphicsExpose events, or a NoExpose event, based on the region */
+void
+SendGraphicsExpose(ClientPtr client, RegionPtr pRgn, XID drawable,
+                     int major, int minor)
+{
+    if (pRgn && !RegionNil(pRgn)) {
+        xEvent *pEvent;
+        xEvent *pe;
+        BoxPtr pBox;
+        int i;
+        int numRects;
+
+        numRects = RegionNumRects(pRgn);
+        pBox = RegionRects(pRgn);
+        if (!(pEvent = calloc(numRects, sizeof(xEvent))))
+            return;
+        pe = pEvent;
+
+        for (i = 1; i <= numRects; i++, pe++, pBox++) {
+            pe->u.u.type = GraphicsExpose;
+            pe->u.graphicsExposure.drawable = drawable;
+            pe->u.graphicsExposure.x = pBox->x1;
+            pe->u.graphicsExposure.y = pBox->y1;
+            pe->u.graphicsExposure.width = pBox->x2 - pBox->x1;
+            pe->u.graphicsExposure.height = pBox->y2 - pBox->y1;
+            pe->u.graphicsExposure.count = numRects - i;
+            pe->u.graphicsExposure.majorEvent = major;
+            pe->u.graphicsExposure.minorEvent = minor;
+        }
+        /* GraphicsExpose is a "critical event", which TryClientEvents
+         * handles specially. */
+        TryClientEvents(client, NULL, pEvent, numRects,
+                        (Mask) 0, NoEventMask, NullGrab);
+        free(pEvent);
+    }
+    else {
+        xEvent event = {
+            .u.noExposure.drawable = drawable,
+            .u.noExposure.majorEvent = major,
+            .u.noExposure.minorEvent = minor
+        };
+        event.u.u.type = NoExpose;
+        WriteEventsToClient(client, 1, &event);
+    }
+}
+
 int
 ProcCopyArea(ClientPtr client)
 {
@@ -1628,8 +1674,7 @@ ProcCopyArea(ClientPtr client)
                                   stuff->width, stuff->height,
                                   stuff->dstX, stuff->dstY);
     if (pGC->graphicsExposures) {
-        (*pDst->pScreen->SendGraphicsExpose)
-            (client, pRgn, stuff->dstDrawable, X_CopyArea, 0);
+        SendGraphicsExpose(client, pRgn, stuff->dstDrawable, X_CopyArea, 0);
         if (pRgn)
             RegionDestroy(pRgn);
     }
@@ -1676,8 +1721,7 @@ ProcCopyPlane(ClientPtr client)
                                 stuff->srcY, stuff->width, stuff->height,
                                 stuff->dstX, stuff->dstY, stuff->bitPlane);
     if (pGC->graphicsExposures) {
-        (*pdstDraw->pScreen->SendGraphicsExpose)
-            (client, pRgn, stuff->dstDrawable, X_CopyPlane, 0);
+        SendGraphicsExpose(client, pRgn, stuff->dstDrawable, X_CopyPlane, 0);
         if (pRgn)
             RegionDestroy(pRgn);
     }
diff --git a/include/dix.h b/include/dix.h
index 61ecc8d..116da2e 100644
--- a/include/dix.h
+++ b/include/dix.h
@@ -254,6 +254,12 @@ extern _X_EXPORT void ClientWakeup(ClientPtr /*client */ );
 
 extern _X_EXPORT Bool ClientIsAsleep(ClientPtr /*client */ );
 
+extern _X_EXPORT void SendGraphicsExpose(ClientPtr /*client */ ,
+                                         RegionPtr /*pRgn */ ,
+                                         XID /*drawable */ ,
+                                         int /*major */ ,
+                                         int  /*minor */);
+
 /* atom.c */
 
 extern _X_EXPORT Atom MakeAtom(const char * /*string */ ,
diff --git a/include/scrnintstr.h b/include/scrnintstr.h
index 7331ec1..269ff5a 100644
--- a/include/scrnintstr.h
+++ b/include/scrnintstr.h
@@ -252,12 +252,6 @@ typedef void (*ResolveColorProcPtr) (unsigned short * /*pred */ ,
 
 typedef RegionPtr (*BitmapToRegionProcPtr) (PixmapPtr /*pPix */ );
 
-typedef void (*SendGraphicsExposeProcPtr) (ClientPtr /*client */ ,
-                                           RegionPtr /*pRgn */ ,
-                                           XID /*drawable */ ,
-                                           int /*major */ ,
-                                           int /*minor */ );
-
 typedef void (*ScreenBlockHandlerProcPtr) (ScreenPtr pScreen,
                                            void *pTimeout,
                                            void *pReadmask);
@@ -540,7 +534,6 @@ typedef struct _Screen {
     /* Region procedures */
 
     BitmapToRegionProcPtr BitmapToRegion;
-    SendGraphicsExposeProcPtr SendGraphicsExpose;
 
     /* os layer procedures */
 
diff --git a/mi/mi.h b/mi/mi.h
index 700bb11..8cb3ce7 100644
--- a/mi/mi.h
+++ b/mi/mi.h
@@ -232,13 +232,6 @@ extern _X_EXPORT RegionPtr miHandleExposures(DrawablePtr /*pSrcDrawable */ ,
                                              int /*dsty */
     );
 
-extern _X_EXPORT void miSendGraphicsExpose(ClientPtr /*client */ ,
-                                           RegionPtr /*pRgn */ ,
-                                           XID /*drawable */ ,
-                                           int /*major */ ,
-                                           int  /*minor */
-    );
-
 extern _X_EXPORT void miSendExposures(WindowPtr /*pWin */ ,
                                       RegionPtr /*pRgn */ ,
                                       int /*dx */ ,
diff --git a/mi/miexpose.c b/mi/miexpose.c
index 7a1c172..555f3b2 100644
--- a/mi/miexpose.c
+++ b/mi/miexpose.c
@@ -306,53 +306,6 @@ miHandleExposures(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable,
     }
 }
 
-/* send GraphicsExpose events, or a NoExpose event, based on the region */
-
-void
-miSendGraphicsExpose(ClientPtr client, RegionPtr pRgn, XID drawable,
-                     int major, int minor)
-{
-    if (pRgn && !RegionNil(pRgn)) {
-        xEvent *pEvent;
-        xEvent *pe;
-        BoxPtr pBox;
-        int i;
-        int numRects;
-
-        numRects = RegionNumRects(pRgn);
-        pBox = RegionRects(pRgn);
-        if (!(pEvent = calloc(numRects, sizeof(xEvent))))
-            return;
-        pe = pEvent;
-
-        for (i = 1; i <= numRects; i++, pe++, pBox++) {
-            pe->u.u.type = GraphicsExpose;
-            pe->u.graphicsExposure.drawable = drawable;
-            pe->u.graphicsExposure.x = pBox->x1;
-            pe->u.graphicsExposure.y = pBox->y1;
-            pe->u.graphicsExposure.width = pBox->x2 - pBox->x1;
-            pe->u.graphicsExposure.height = pBox->y2 - pBox->y1;
-            pe->u.graphicsExposure.count = numRects - i;
-            pe->u.graphicsExposure.majorEvent = major;
-            pe->u.graphicsExposure.minorEvent = minor;
-        }
-        /* GraphicsExpose is a "critical event", which TryClientEvents
-         * handles specially. */
-        TryClientEvents(client, NULL, pEvent, numRects,
-                        (Mask) 0, NoEventMask, NullGrab);
-        free(pEvent);
-    }
-    else {
-        xEvent event = {
-            .u.noExposure.drawable = drawable,
-            .u.noExposure.majorEvent = major,
-            .u.noExposure.minorEvent = minor
-        };
-        event.u.u.type = NoExpose;
-        WriteEventsToClient(client, 1, &event);
-    }
-}
-
 void
 miSendExposures(WindowPtr pWin, RegionPtr pRgn, int dx, int dy)
 {
diff --git a/mi/miscrinit.c b/mi/miscrinit.c
index 00c15f7..ec4d108 100644
--- a/mi/miscrinit.c
+++ b/mi/miscrinit.c
@@ -259,7 +259,6 @@ miScreenInit(ScreenPtr pScreen, void *pbits,  /* pointer to screen bits */
     /* CreateColormap, DestroyColormap, InstallColormap, UninstallColormap */
     /* ListInstalledColormaps, StoreColors, ResolveColor */
     /* BitmapToRegion */
-    pScreen->SendGraphicsExpose = miSendGraphicsExpose;
     pScreen->BlockHandler = (ScreenBlockHandlerProcPtr) NoopDDA;
     pScreen->WakeupHandler = (ScreenWakeupHandlerProcPtr) NoopDDA;
     pScreen->MarkWindow = miMarkWindow;
commit 5d3bd8a3dc6456ea1ccf7b5f71b972379d7565ec
Author: Adam Jackson <ajax at redhat.com>
Date:   Fri Sep 12 11:56:28 2014 -0400

    mi: Drop plane argument from miHandleExposures
    
    This existed to be passed to the bs recovery routine; since we back all
    planes, we don't care.
    
    Reviewed-by: Julien Cristau <jcristau at debian.org>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/fb/fbcopy.c b/fb/fbcopy.c
index 541ef71..5bbabc3 100644
--- a/fb/fbcopy.c
+++ b/fb/fbcopy.c
@@ -271,5 +271,5 @@ fbCopyPlane(DrawablePtr pSrcDrawable,
     else
         return miHandleExposures(pSrcDrawable, pDstDrawable, pGC,
                                  xIn, yIn,
-                                 widthSrc, heightSrc, xOut, yOut, bitplane);
+                                 widthSrc, heightSrc, xOut, yOut);
 }
diff --git a/glamor/glamor_copy.c b/glamor/glamor_copy.c
index 6f422d4..3320935 100644
--- a/glamor/glamor_copy.c
+++ b/glamor/glamor_copy.c
@@ -677,8 +677,7 @@ glamor_copy_plane(DrawablePtr src, DrawablePtr dst, GCPtr gc,
 {
     if ((bitplane & FbFullMask(src->depth)) == 0)
         return miHandleExposures(src, dst, gc,
-                                 srcx, srcy, width, height, dstx, dsty,
-                                 bitplane);
+                                 srcx, srcy, width, height, dstx, dsty);
     return miDoCopy(src, dst, gc,
                     srcx, srcy, width, height,
                     dstx, dsty, glamor_copy, bitplane, NULL);
diff --git a/hw/dmx/dmxgcops.c b/hw/dmx/dmxgcops.c
index aa7c8eb..0ebd69a 100644
--- a/hw/dmx/dmxgcops.c
+++ b/hw/dmx/dmxgcops.c
@@ -179,7 +179,7 @@ dmxCopyArea(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
 
     if (DMX_GCOPS_OFFSCREEN(pSrc) || DMX_GCOPS_OFFSCREEN(pDst))
         return miHandleExposures(pSrc, pDst, pGC, srcx, srcy, w, h,
-                                 dstx, dsty, 0L);
+                                 dstx, dsty);
 
     DMX_GCOPS_SET_DRAWABLE(pSrc, srcDraw);
     DMX_GCOPS_SET_DRAWABLE(pDst, dstDraw);
@@ -188,7 +188,7 @@ dmxCopyArea(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
               srcx, srcy, w, h, dstx, dsty);
     dmxSync(dmxScreen, FALSE);
 
-    return miHandleExposures(pSrc, pDst, pGC, srcx, srcy, w, h, dstx, dsty, 0L);
+    return miHandleExposures(pSrc, pDst, pGC, srcx, srcy, w, h, dstx, dsty);
 }
 
 /** Copy plane number \a bitPlane from \a pSrc drawable to \a pDst
@@ -206,7 +206,7 @@ dmxCopyPlane(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
 
     if (DMX_GCOPS_OFFSCREEN(pSrc) || DMX_GCOPS_OFFSCREEN(pDst))
         return miHandleExposures(pSrc, pDst, pGC, srcx, srcy, width, height,
-                                 dstx, dsty, bitPlane);
+                                 dstx, dsty);
 
     DMX_GCOPS_SET_DRAWABLE(pSrc, srcDraw);
     DMX_GCOPS_SET_DRAWABLE(pDst, dstDraw);
@@ -216,7 +216,7 @@ dmxCopyPlane(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
     dmxSync(dmxScreen, FALSE);
 
     return miHandleExposures(pSrc, pDst, pGC, srcx, srcy, width, height,
-                             dstx, dsty, bitPlane);
+                             dstx, dsty);
 }
 
 /** Render list of points, \a pptInit in \a pDrawable on the back-end
diff --git a/mi/mi.h b/mi/mi.h
index a4a01b8..700bb11 100644
--- a/mi/mi.h
+++ b/mi/mi.h
@@ -229,8 +229,7 @@ extern _X_EXPORT RegionPtr miHandleExposures(DrawablePtr /*pSrcDrawable */ ,
                                              int /*width */ ,
                                              int /*height */ ,
                                              int /*dstx */ ,
-                                             int /*dsty */ ,
-                                             unsigned long      /*plane */
+                                             int /*dsty */
     );
 
 extern _X_EXPORT void miSendGraphicsExpose(ClientPtr /*client */ ,
diff --git a/mi/mibitblt.c b/mi/mibitblt.c
index 3ed4ed1..08bd1c5 100644
--- a/mi/mibitblt.c
+++ b/mi/mibitblt.c
@@ -242,8 +242,7 @@ miCopyArea(DrawablePtr pSrcDrawable,
         }
     }
     prgnExposed = miHandleExposures(pSrcDrawable, pDstDrawable, pGC, xIn, yIn,
-                                    widthSrc, heightSrc, xOut, yOut,
-                                    (unsigned long) 0);
+                                    widthSrc, heightSrc, xOut, yOut);
     if (realSrcClip)
         RegionDestroy(prgnSrcClip);
 
@@ -579,7 +578,7 @@ miCopyPlane(DrawablePtr pSrcDrawable,
         }
     }
     prgnExposed = miHandleExposures(pSrcDrawable, pDstDrawable, pGC, srcx, srcy,
-                                    width, height, dstx, dsty, bitPlane);
+                                    width, height, dstx, dsty);
     RegionDestroy(prgnSrc);
     return prgnExposed;
 }
diff --git a/mi/micopy.c b/mi/micopy.c
index 3079511..a52b0a7 100644
--- a/mi/micopy.c
+++ b/mi/micopy.c
@@ -304,8 +304,7 @@ miDoCopy(DrawablePtr pSrcDrawable,
                                         yIn - pSrcDrawable->y,
                                         widthSrc, heightSrc,
                                         xOut - pDstDrawable->x,
-                                        yOut - pDstDrawable->y,
-                                        (unsigned long) bitPlane);
+                                        yOut - pDstDrawable->y);
     RegionUninit(&rgnDst);
     if (freeSrcClip)
         RegionDestroy(prgnSrcClip);
diff --git a/mi/miexpose.c b/mi/miexpose.c
index de0e148..7a1c172 100644
--- a/mi/miexpose.c
+++ b/mi/miexpose.c
@@ -116,18 +116,12 @@ NOTE:
      this should generally be called, even if graphicsExposures is false,
 because this is where bits get recovered from backing store.
 
-NOTE:
-     added argument 'plane' is used to indicate how exposures from backing
-store should be accomplished. If plane is 0 (i.e. no bit plane), CopyArea
-should be used, else a CopyPlane of the indicated plane will be used. The
-exposing is done by the backing store's GraphicsExpose function, of course.
-
 */
 
 RegionPtr
 miHandleExposures(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable,
                   GCPtr pGC, int srcx, int srcy, int width, int height,
-                  int dstx, int dsty, unsigned long plane)
+                  int dstx, int dsty)
 {
     RegionPtr prgnSrcClip;      /* drawable-relative source clip */
     RegionRec rgnSrcRec;
commit 7eddc80bc4a6c1902746a9fbe79ab553f9fd5821
Author: Adam Jackson <ajax at redhat.com>
Date:   Tue Aug 5 14:07:17 2014 -0400

    mi: Simplify composite border clip redirection interface
    
    There's not really a good reason for mi to not just call the composite
    code directly.
    
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/composite/compext.c b/composite/compext.c
index cadedbd..fcfc349 100644
--- a/composite/compext.c
+++ b/composite/compext.c
@@ -594,9 +594,6 @@ CompositeExtensionInit(void)
         return;
     CompositeReqCode = (CARD8) extEntry->base;
 
-    miRegisterRedirectBorderClipProc(compSetRedirectBorderClip,
-                                     compGetRedirectBorderClip);
-
     /* Initialization succeeded */
     noCompositeExtension = FALSE;
 }
diff --git a/mi/mi.h b/mi/mi.h
index 4b5e862..a4a01b8 100644
--- a/mi/mi.h
+++ b/mi/mi.h
@@ -425,17 +425,6 @@ extern _X_EXPORT int miShapedWindowIn(RegionPtr /*universe */ ,
                                       int       /*y */
     );
 
-typedef void
- (*SetRedirectBorderClipProcPtr) (WindowPtr pWindow, RegionPtr pRegion);
-
-typedef RegionPtr
- (*GetRedirectBorderClipProcPtr) (WindowPtr pWindow);
-
-extern _X_EXPORT void
-
-miRegisterRedirectBorderClipProc(SetRedirectBorderClipProcPtr setBorderClip,
-                                 GetRedirectBorderClipProcPtr getBorderClip);
-
 extern _X_EXPORT int miValidateTree(WindowPtr /*pParent */ ,
                                     WindowPtr /*pChild */ ,
                                     VTKind      /*kind */
diff --git a/mi/mivaltree.c b/mi/mivaltree.c
index c1cc431..8e4e9a9 100644
--- a/mi/mivaltree.c
+++ b/mi/mivaltree.c
@@ -99,8 +99,10 @@ Equipment Corporation.
 #include    "mi.h"
 #include    "regionstr.h"
 #include    "mivalidate.h"
-
 #include    "globals.h"
+#ifdef COMPOSITE
+#include    "compint.h"
+#endif
 
 /*
  * Compute the visibility of a shaped window
@@ -160,17 +162,6 @@ miShapedWindowIn(RegionPtr universe, RegionPtr bounding,
     return rgnOUT;
 }
 
-static GetRedirectBorderClipProcPtr miGetRedirectBorderClipProc;
-static SetRedirectBorderClipProcPtr miSetRedirectBorderClipProc;
-
-void
-miRegisterRedirectBorderClipProc(SetRedirectBorderClipProcPtr setBorderClip,
-                                 GetRedirectBorderClipProcPtr getBorderClip)
-{
-    miSetRedirectBorderClipProc = setBorderClip;
-    miGetRedirectBorderClipProc = getBorderClip;
-}
-
 /*
  * Manual redirected windows are treated as transparent; they do not obscure
  * siblings or parent windows
@@ -242,11 +233,9 @@ miComputeClips(WindowPtr pParent,
      * In redirected drawing case, reset universe to borderSize
      */
     if (pParent->redirectDraw != RedirectDrawNone) {
-        if (miSetRedirectBorderClipProc) {
-            if (TreatAsTransparent(pParent))
-                RegionEmpty(universe);
-            (*miSetRedirectBorderClipProc) (pParent, universe);
-        }
+        if (TreatAsTransparent(pParent))
+            RegionEmpty(universe);
+        compSetRedirectBorderClip (pParent, universe);
         RegionCopy(universe, &pParent->borderSize);
     }
 #endif
@@ -516,6 +505,17 @@ miTreeObscured(WindowPtr pParent)
     }
 }
 
+static RegionPtr
+getBorderClip(WindowPtr pWin)
+{
+#ifdef COMPOSITE
+    if (pWin->redirectDraw != RedirectDrawNone)
+        return compGetRedirectBorderClip(pWin);
+    else
+#endif
+        return &pWin->borderClip;
+}
+
 /*
  *-----------------------------------------------------------------------
  * miValidateTree --
@@ -609,14 +609,7 @@ miValidateTree(WindowPtr pParent,       /* Parent to validate */
             forward = TRUE;
             for (pWin = pChild; pWin; pWin = pWin->nextSib) {
                 if (pWin->valdata) {
-                    RegionPtr pBorderClip = &pWin->borderClip;
-
-#ifdef COMPOSITE
-                    if (pWin->redirectDraw != RedirectDrawNone &&
-                        miGetRedirectBorderClipProc)
-                        pBorderClip = (*miGetRedirectBorderClipProc) (pWin);
-#endif
-                    RegionAppend(&totalClip, pBorderClip);
+                    RegionAppend(&totalClip, getBorderClip(pWin));
                     if (pWin->viewable)
                         viewvals++;
                 }
@@ -627,14 +620,7 @@ miValidateTree(WindowPtr pParent,       /* Parent to validate */
             pWin = pParent->lastChild;
             while (1) {
                 if (pWin->valdata) {
-                    RegionPtr pBorderClip = &pWin->borderClip;
-
-#ifdef COMPOSITE
-                    if (pWin->redirectDraw != RedirectDrawNone &&
-                        miGetRedirectBorderClipProc)
-                        pBorderClip = (*miGetRedirectBorderClipProc) (pWin);
-#endif
-                    RegionAppend(&totalClip, pBorderClip);
+                    RegionAppend(&totalClip, getBorderClip(pWin));
                     if (pWin->viewable)
                         viewvals++;
                 }
commit 7b35dc9b1533d4b99a3f84f460ac66354a6fe347
Author: Adam Jackson <ajax at redhat.com>
Date:   Tue Sep 23 10:35:37 2014 -0400

    mi: Deobfuscate miOverlayWindowExposures
    
    Reviewed-by: Julien Cristau <jcristau at debian.org>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/mi/mioverlay.c b/mi/mioverlay.c
index f894e2b..2ad6bc0 100644
--- a/mi/mioverlay.c
+++ b/mi/mioverlay.c
@@ -983,28 +983,19 @@ miOverlayWindowExposures(WindowPtr pWin, RegionPtr prgn)
 {
     RegionPtr exposures = prgn;
 
-    if ((prgn && !RegionNil(prgn)) || (exposures && !RegionNil(exposures))) {
+    if (prgn && !RegionNil(prgn)) {
         RegionRec expRec;
-        int clientInterested;
-
-        clientInterested = (pWin->eventMask | wOtherEventMasks(pWin)) &
-            ExposureMask;
-        if (clientInterested && exposures &&
-            (RegionNumRects(exposures) > RECTLIMIT)) {
+        int clientInterested =
+            (pWin->eventMask | wOtherEventMasks(pWin)) & ExposureMask;
+        if (clientInterested && (RegionNumRects(prgn) > RECTLIMIT)) {
             ScreenPtr pScreen = pWin->drawable.pScreen;
             miOverlayScreenPtr pPriv = MIOVERLAY_GET_SCREEN_PRIVATE(pScreen);
             BoxRec box;
 
-            box = *RegionExtents(exposures);
-            if (exposures == prgn) {
-                exposures = &expRec;
-                RegionInit(exposures, &box, 1);
-                RegionReset(prgn, &box);
-            }
-            else {
-                RegionReset(exposures, &box);
-                RegionUnion(prgn, prgn, exposures);
-            }
+            box = *RegionExtents(prgn);
+            exposures = &expRec;
+            RegionInit(exposures, &box, 1);
+            RegionReset(prgn, &box);
             /* This is the only reason why we are replacing mi's version
                of this file */
 
@@ -1016,21 +1007,14 @@ miOverlayWindowExposures(WindowPtr pWin, RegionPtr prgn)
             else
                 RegionIntersect(prgn, prgn, &pWin->clipList);
         }
-        if (prgn && !RegionNil(prgn))
-            miPaintWindow(pWin, prgn, PW_BACKGROUND);
-        if (clientInterested && exposures && !RegionNil(exposures))
+        miPaintWindow(pWin, prgn, PW_BACKGROUND);
+        if (clientInterested)
             miSendExposures(pWin, exposures,
                             pWin->drawable.x, pWin->drawable.y);
-        if (exposures == &expRec) {
+        if (exposures == &expRec)
             RegionUninit(exposures);
-        }
-        else if (exposures && exposures != prgn)
-            RegionDestroy(exposures);
-        if (prgn)
-            RegionEmpty(prgn);
+        RegionEmpty(prgn);
     }
-    else if (exposures && exposures != prgn)
-        RegionDestroy(exposures);
 }
 
 typedef struct {
commit fb34f273481b90a90a988f0f5c5a2d642a5661b8
Author: Adam Jackson <ajax at redhat.com>
Date:   Tue Sep 23 10:30:56 2014 -0400

    mi: Deobfuscate miWindowExposures
    
    Reviewed-by: Julien Cristau <jcristau at debian.org>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/mi/miexpose.c b/mi/miexpose.c
index 23987fa..de0e148 100644
--- a/mi/miexpose.c
+++ b/mi/miexpose.c
@@ -425,17 +425,11 @@ miWindowExposures(WindowPtr pWin, RegionPtr prgn)
 {
     RegionPtr exposures = prgn;
 
-    if ((prgn && !RegionNil(prgn)) || (exposures && !RegionNil(exposures))) {
+    if (prgn && !RegionNil(prgn)) {
         RegionRec expRec;
-        int clientInterested;
-
-        /*
-         * Restore from backing-store FIRST.
-         */
-        clientInterested =
+        int clientInterested =
             (pWin->eventMask | wOtherEventMasks(pWin)) & ExposureMask;
-        if (clientInterested && exposures &&
-            (RegionNumRects(exposures) > RECTLIMIT)) {
+        if (clientInterested && (RegionNumRects(prgn) > RECTLIMIT)) {
             /*
              * If we have LOTS of rectangles, we decide to take the extents
              * and force an exposure on that.  This should require much less
@@ -444,34 +438,21 @@ miWindowExposures(WindowPtr pWin, RegionPtr prgn)
              */
             BoxRec box;
 
-            box = *RegionExtents(exposures);
-            if (exposures == prgn) {
-                exposures = &expRec;
-                RegionInit(exposures, &box, 1);
-                RegionReset(prgn, &box);
-            }
-            else {
-                RegionReset(exposures, &box);
-                RegionUnion(prgn, prgn, exposures);
-            }
+            box = *RegionExtents(prgn);
+            exposures = &expRec;
+            RegionInit(exposures, &box, 1);
+            RegionReset(prgn, &box);
             /* miPaintWindow doesn't clip, so we have to */
             RegionIntersect(prgn, prgn, &pWin->clipList);
         }
-        if (prgn && !RegionNil(prgn))
-            miPaintWindow(pWin, prgn, PW_BACKGROUND);
-        if (clientInterested && exposures && !RegionNil(exposures))
+        miPaintWindow(pWin, prgn, PW_BACKGROUND);
+        if (clientInterested)
             miSendExposures(pWin, exposures,
                             pWin->drawable.x, pWin->drawable.y);
-        if (exposures == &expRec) {
+        if (exposures == &expRec)
             RegionUninit(exposures);
-        }
-        else if (exposures && exposures != prgn)
-            RegionDestroy(exposures);
-        if (prgn)
-            RegionEmpty(prgn);
+        RegionEmpty(prgn);
     }
-    else if (exposures && exposures != prgn)
-        RegionDestroy(exposures);
 }
 
 #ifdef ROOTLESS
commit 0d30d44a8cdacfbc99d8193f76c133b803464622
Author: Adam Jackson <ajax at redhat.com>
Date:   Thu Sep 11 12:44:54 2014 -0400

    dix: Drop the third argument from WindowExposuresProcPtr
    
    A careful read shows that it was always NULL.  It hasn't always been; as
    the DDX spec indicates, it was the "occluded region that has backing
    store", but since that backing store code is long gone, we can nuke it.
    
    mi{,Overlay}WindowExposures get slightly simpler here, and will get even
    simpler in just a moment.
    
    Reviewed-by: Julien Cristau <jcristau at debian.org>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/dix/window.c b/dix/window.c
index f4acdc8..52e69ef 100644
--- a/dix/window.c
+++ b/dix/window.c
@@ -2601,7 +2601,7 @@ MapWindow(WindowPtr pWin, ClientPtr client)
             (*pScreen->PostValidateTree) (NullWindow, pWin, VTMap);
         RegionNull(&temp);
         RegionCopy(&temp, &pWin->clipList);
-        (*pScreen->WindowExposures) (pWin, &temp, NullRegion);
+        (*pScreen->WindowExposures) (pWin, &temp);
         RegionUninit(&temp);
     }
 
diff --git a/fb/fboverlay.c b/fb/fboverlay.c
index 935bf1b..6a5f0f8 100644
--- a/fb/fboverlay.c
+++ b/fb/fboverlay.c
@@ -240,12 +240,11 @@ fbOverlayCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
 }
 
 void
-fbOverlayWindowExposures(WindowPtr pWin,
-                         RegionPtr prgn, RegionPtr other_exposed)
+fbOverlayWindowExposures(WindowPtr pWin, RegionPtr prgn)
 {
     fbOverlayUpdateLayerRegion(pWin->drawable.pScreen,
                                fbOverlayWindowLayer(pWin), prgn);
-    miWindowExposures(pWin, prgn, other_exposed);
+    miWindowExposures(pWin, prgn);
 }
 
 Bool
diff --git a/fb/fboverlay.h b/fb/fboverlay.h
index 57c9873..47727e4 100644
--- a/fb/fboverlay.h
+++ b/fb/fboverlay.h
@@ -82,9 +82,7 @@ extern _X_EXPORT void
  fbOverlayCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc);
 
 extern _X_EXPORT void
-
-fbOverlayWindowExposures(WindowPtr pWin,
-                         RegionPtr prgn, RegionPtr other_exposed);
+fbOverlayWindowExposures(WindowPtr pWin, RegionPtr prgn);
 
 extern _X_EXPORT Bool
 
diff --git a/hw/dmx/dmxwindow.c b/hw/dmx/dmxwindow.c
index 1c23527..c753735 100644
--- a/hw/dmx/dmxwindow.c
+++ b/hw/dmx/dmxwindow.c
@@ -772,7 +772,7 @@ dmxWindowExposurePredicate(Display * dpy, XEvent * ev, XPointer ptr)
  *  in DMX, the events that are generated by the back-end server are
  *  redundant, so we eat them here. */
 void
-dmxWindowExposures(WindowPtr pWindow, RegionPtr prgn, RegionPtr other_exposed)
+dmxWindowExposures(WindowPtr pWindow, RegionPtr prgn)
 {
     ScreenPtr pScreen = pWindow->drawable.pScreen;
     DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum];
@@ -799,7 +799,7 @@ dmxWindowExposures(WindowPtr pWindow, RegionPtr prgn, RegionPtr other_exposed)
 
 #if 1
     if (pScreen->WindowExposures)
-        pScreen->WindowExposures(pWindow, prgn, other_exposed);
+        pScreen->WindowExposures(pWindow, prgn);
 #endif
     DMX_WRAP(WindowExposures, dmxWindowExposures, dmxScreen, pScreen);
 }
diff --git a/hw/dmx/dmxwindow.h b/hw/dmx/dmxwindow.h
index c6b2efe..dda6538 100644
--- a/hw/dmx/dmxwindow.h
+++ b/hw/dmx/dmxwindow.h
@@ -73,8 +73,7 @@ extern Bool dmxChangeWindowAttributes(WindowPtr pWindow, unsigned long mask);
 extern Bool dmxRealizeWindow(WindowPtr pWindow);
 extern Bool dmxUnrealizeWindow(WindowPtr pWindow);
 extern void dmxRestackWindow(WindowPtr pWindow, WindowPtr pOldNextSib);
-extern void dmxWindowExposures(WindowPtr pWindow, RegionPtr prgn,
-                               RegionPtr other_exposed);
+extern void dmxWindowExposures(WindowPtr pWindow, RegionPtr prgn);
 extern void dmxCopyWindow(WindowPtr pWindow, DDXPointRec ptOldOrg,
                           RegionPtr prgnSrc);
 
diff --git a/hw/kdrive/ephyr/ephyr.c b/hw/kdrive/ephyr/ephyr.c
index 85d4193..8b88f3e 100644
--- a/hw/kdrive/ephyr/ephyr.c
+++ b/hw/kdrive/ephyr/ephyr.c
@@ -878,7 +878,7 @@ ephyrExposePairedWindow(int a_remote)
     screen = pair->local->drawable.pScreen;
     RegionNull(&reg);
     RegionCopy(&reg, &pair->local->clipList);
-    screen->WindowExposures(pair->local, &reg, NullRegion);
+    screen->WindowExposures(pair->local, &reg);
     RegionUninit(&reg);
 }
 #endif                          /* XF86DRI */
diff --git a/hw/kdrive/src/kxv.c b/hw/kdrive/src/kxv.c
index f979e1f..163d5c1 100644
--- a/hw/kdrive/src/kxv.c
+++ b/hw/kdrive/src/kxv.c
@@ -86,7 +86,7 @@ static int KdXVQueryImageAttributes(XvPortPtr, XvImagePtr,
 /* ScreenRec fields */
 
 static Bool KdXVDestroyWindow(WindowPtr pWin);
-static void KdXVWindowExposures(WindowPtr pWin, RegionPtr r1, RegionPtr r2);
+static void KdXVWindowExposures(WindowPtr pWin, RegionPtr r1);
 static void KdXVClipNotify(WindowPtr pWin, int dx, int dy);
 static Bool KdXVCloseScreen(ScreenPtr);
 
@@ -822,7 +822,7 @@ KdXVDestroyWindow(WindowPtr pWin)
 }
 
 static void
-KdXVWindowExposures(WindowPtr pWin, RegionPtr reg1, RegionPtr reg2)
+KdXVWindowExposures(WindowPtr pWin, RegionPtr reg1)
 {
     ScreenPtr pScreen = pWin->drawable.pScreen;
     KdXVScreenPtr ScreenPriv = GET_KDXV_SCREEN(pScreen);
@@ -834,7 +834,7 @@ KdXVWindowExposures(WindowPtr pWin, RegionPtr reg1, RegionPtr reg2)
     AreasExposed = (WinPriv && reg1 && RegionNotEmpty(reg1));
 
     pScreen->WindowExposures = ScreenPriv->WindowExposures;
-    (*pScreen->WindowExposures) (pWin, reg1, reg2);
+    (*pScreen->WindowExposures) (pWin, reg1);
     pScreen->WindowExposures = KdXVWindowExposures;
 
     /* filter out XClearWindow/Area */
diff --git a/hw/xfree86/common/xf86xv.c b/hw/xfree86/common/xf86xv.c
index 0e67690..5ef5de1 100644
--- a/hw/xfree86/common/xf86xv.c
+++ b/hw/xfree86/common/xf86xv.c
@@ -84,7 +84,7 @@ static int xf86XVQueryImageAttributes(XvPortPtr, XvImagePtr,
 /* ScreenRec fields */
 
 static Bool xf86XVDestroyWindow(WindowPtr pWin);
-static void xf86XVWindowExposures(WindowPtr pWin, RegionPtr r1, RegionPtr r2);
+static void xf86XVWindowExposures(WindowPtr pWin, RegionPtr r1);
 static void xf86XVPostValidateTree(WindowPtr pWin, WindowPtr pLayerWin,
                                    VTKind kind);
 static void xf86XVClipNotify(WindowPtr pWin, int dx, int dy);
@@ -1048,7 +1048,7 @@ xf86XVPostValidateTree(WindowPtr pWin, WindowPtr pLayerWin, VTKind kind)
 }
 
 static void
-xf86XVWindowExposures(WindowPtr pWin, RegionPtr reg1, RegionPtr reg2)
+xf86XVWindowExposures(WindowPtr pWin, RegionPtr reg1)
 {
     ScreenPtr pScreen = pWin->drawable.pScreen;
     XF86XVScreenPtr ScreenPriv = GET_XF86XV_SCREEN(pScreen);
@@ -1059,7 +1059,7 @@ xf86XVWindowExposures(WindowPtr pWin, RegionPtr reg1, RegionPtr reg2)
     AreasExposed = (WinPriv && reg1 && RegionNotEmpty(reg1));
 
     pScreen->WindowExposures = ScreenPriv->WindowExposures;
-    (*pScreen->WindowExposures) (pWin, reg1, reg2);
+    (*pScreen->WindowExposures) (pWin, reg1);
     pScreen->WindowExposures = xf86XVWindowExposures;
 
     /* filter out XClearWindow/Area */
diff --git a/hw/xfree86/dri/dri.c b/hw/xfree86/dri/dri.c
index 3f2f6a9..5077c7c 100644
--- a/hw/xfree86/dri/dri.c
+++ b/hw/xfree86/dri/dri.c
@@ -1828,7 +1828,7 @@ DRIGetContextStore(DRIContextPrivPtr context)
 }
 
 void
-DRIWindowExposures(WindowPtr pWin, RegionPtr prgn, RegionPtr bsreg)
+DRIWindowExposures(WindowPtr pWin, RegionPtr prgn)
 {
     ScreenPtr pScreen = pWin->drawable.pScreen;
     DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
@@ -1846,7 +1846,7 @@ DRIWindowExposures(WindowPtr pWin, RegionPtr prgn, RegionPtr bsreg)
         pScreen->WindowExposures = pDRIPriv->wrap.WindowExposures;
 
         /* call lower layers */
-        (*pScreen->WindowExposures) (pWin, prgn, bsreg);
+        (*pScreen->WindowExposures) (pWin, prgn);
 
         /* rewrap */
         pDRIPriv->wrap.WindowExposures = pScreen->WindowExposures;
diff --git a/hw/xfree86/dri/dri.h b/hw/xfree86/dri/dri.h
index dec6885..1ce0970 100644
--- a/hw/xfree86/dri/dri.h
+++ b/hw/xfree86/dri/dri.h
@@ -280,8 +280,7 @@ extern _X_EXPORT void DRISwapContext(int drmFD, void *oldctx, void *newctx);
 
 extern _X_EXPORT void *DRIGetContextStore(DRIContextPrivPtr context);
 
-extern _X_EXPORT void DRIWindowExposures(WindowPtr pWin,
-                                         RegionPtr prgn, RegionPtr bsreg);
+extern _X_EXPORT void DRIWindowExposures(WindowPtr pWin, RegionPtr prgn);
 
 extern _X_EXPORT Bool DRIDestroyWindow(WindowPtr pWin);
 
diff --git a/hw/xnest/Window.c b/hw/xnest/Window.c
index fc87e82..8d9c672 100644
--- a/hw/xnest/Window.c
+++ b/hw/xnest/Window.c
@@ -386,7 +386,7 @@ xnestWindowExposurePredicate(Display * dpy, XEvent * event, XPointer ptr)
 }
 
 void
-xnestWindowExposures(WindowPtr pWin, RegionPtr pRgn, RegionPtr other_exposed)
+xnestWindowExposures(WindowPtr pWin, RegionPtr pRgn)
 {
     XEvent event;
     Window window;
@@ -410,7 +410,7 @@ xnestWindowExposures(WindowPtr pWin, RegionPtr pRgn, RegionPtr other_exposed)
             XPutBackEvent(xnestDisplay, &event);
     }
 
-    miWindowExposures(pWin, pRgn, other_exposed);
+    miWindowExposures(pWin, pRgn);
 }
 
 void
diff --git a/hw/xnest/XNWindow.h b/hw/xnest/XNWindow.h
index 02b0f3f..6320ede 100644
--- a/hw/xnest/XNWindow.h
+++ b/hw/xnest/XNWindow.h
@@ -66,8 +66,7 @@ Bool xnestRealizeWindow(WindowPtr pWin);
 Bool xnestUnrealizeWindow(WindowPtr pWin);
 void xnestCopyWindow(WindowPtr pWin, xPoint oldOrigin, RegionPtr oldRegion);
 void xnestClipNotify(WindowPtr pWin, int dx, int dy);
-void xnestWindowExposures(WindowPtr pWin, RegionPtr pRgn,
-                          RegionPtr other_exposed);
+void xnestWindowExposures(WindowPtr pWin, RegionPtr pRgn);
 void xnestSetShape(WindowPtr pWin, int kind);
 void xnestShapeWindow(WindowPtr pWin);
 
diff --git a/include/scrnintstr.h b/include/scrnintstr.h
index 6955e77..7331ec1 100644
--- a/include/scrnintstr.h
+++ b/include/scrnintstr.h
@@ -155,8 +155,7 @@ typedef void (*PostValidateTreeProcPtr) (WindowPtr /*pParent */ ,
                                          VTKind /*kind */ );
 
 typedef void (*WindowExposuresProcPtr) (WindowPtr /*pWindow */ ,
-                                        RegionPtr /*prgn */ ,
-                                        RegionPtr /*other_exposed */ );
+                                        RegionPtr /*prgn */);
 
 typedef void (*CopyWindowProcPtr) (WindowPtr /*pWindow */ ,
                                    DDXPointRec /*ptOldOrg */ ,
diff --git a/mi/mi.h b/mi/mi.h
index d5a5ba3..4b5e862 100644
--- a/mi/mi.h
+++ b/mi/mi.h
@@ -247,9 +247,7 @@ extern _X_EXPORT void miSendExposures(WindowPtr /*pWin */ ,
     );
 
 extern _X_EXPORT void miWindowExposures(WindowPtr /*pWin */ ,
-                                        RegionPtr /*prgn */ ,
-                                        RegionPtr       /*other_exposed */
-    );
+                                        RegionPtr /*prgn */);
 
 extern _X_EXPORT void miPaintWindow(WindowPtr /*pWin */ ,
                                     RegionPtr /*prgn */ ,
diff --git a/mi/miexpose.c b/mi/miexpose.c
index 198c433..23987fa 100644
--- a/mi/miexpose.c
+++ b/mi/miexpose.c
@@ -421,12 +421,11 @@ miSendExposures(WindowPtr pWin, RegionPtr pRgn, int dx, int dy)
 }
 
 void
-miWindowExposures(WindowPtr pWin, RegionPtr prgn, RegionPtr other_exposed)
+miWindowExposures(WindowPtr pWin, RegionPtr prgn)
 {
     RegionPtr exposures = prgn;
 
-    if ((prgn && !RegionNil(prgn)) ||
-        (exposures && !RegionNil(exposures)) || other_exposed) {
+    if ((prgn && !RegionNil(prgn)) || (exposures && !RegionNil(exposures))) {
         RegionRec expRec;
         int clientInterested;
 
@@ -435,14 +434,6 @@ miWindowExposures(WindowPtr pWin, RegionPtr prgn, RegionPtr other_exposed)
          */
         clientInterested =
             (pWin->eventMask | wOtherEventMasks(pWin)) & ExposureMask;
-        if (other_exposed) {
-            if (exposures) {
-                RegionUnion(other_exposed, exposures, other_exposed);
-                if (exposures != prgn)
-                    RegionDestroy(exposures);
-            }
-            exposures = other_exposed;
-        }
         if (clientInterested && exposures &&
             (RegionNumRects(exposures) > RECTLIMIT)) {
             /*
@@ -474,7 +465,7 @@ miWindowExposures(WindowPtr pWin, RegionPtr prgn, RegionPtr other_exposed)
         if (exposures == &expRec) {
             RegionUninit(exposures);
         }
-        else if (exposures && exposures != prgn && exposures != other_exposed)
+        else if (exposures && exposures != prgn)
             RegionDestroy(exposures);
         if (prgn)
             RegionEmpty(prgn);
diff --git a/mi/mioverlay.c b/mi/mioverlay.c
index 7f502fa..f894e2b 100644
--- a/mi/mioverlay.c
+++ b/mi/mioverlay.c
@@ -79,7 +79,7 @@ static void miOverlayMarkUnrealizedWindow(WindowPtr, WindowPtr, Bool);
 static int miOverlayValidateTree(WindowPtr, WindowPtr, VTKind);
 static void miOverlayHandleExposures(WindowPtr);
 static void miOverlayMoveWindow(WindowPtr, int, int, WindowPtr, VTKind);
-static void miOverlayWindowExposures(WindowPtr, RegionPtr, RegionPtr);
+static void miOverlayWindowExposures(WindowPtr, RegionPtr);
 static void miOverlayResizeWindow(WindowPtr, int, int, unsigned int,
                                   unsigned int, WindowPtr);
 static void miOverlayClearToBackground(WindowPtr, int, int, int, int, Bool);
@@ -827,7 +827,7 @@ miOverlayHandleExposures(WindowPtr pWin)
     miOverlayScreenPtr pPriv = MIOVERLAY_GET_SCREEN_PRIVATE(pScreen);
     WindowPtr pChild;
     ValidatePtr val;
-    void (*WindowExposures) (WindowPtr, RegionPtr, RegionPtr);
+    WindowExposuresProcPtr WindowExposures;
 
     WindowExposures = pWin->drawable.pScreen->WindowExposures;
     if (pPriv->underlayMarked) {
@@ -849,8 +849,7 @@ miOverlayHandleExposures(WindowPtr pWin)
                     }
                     RegionUninit(&mival->borderExposed);
 
-                    (*WindowExposures) (pTree->pWin, &mival->exposed,
-                                        NullRegion);
+                    (*WindowExposures) (pTree->pWin, &mival->exposed);
                     RegionUninit(&mival->exposed);
                 }
                 free(mival);
@@ -886,7 +885,7 @@ miOverlayHandleExposures(WindowPtr pWin)
                 if (RegionNotEmpty(&val->after.borderExposed)) {
                     miPaintWindow(pChild, &val->after.borderExposed, PW_BORDER);
                 }
-                (*WindowExposures) (pChild, &val->after.exposed, NullRegion);
+                (*WindowExposures) (pChild, &val->after.exposed);
             }
             RegionUninit(&val->after.borderExposed);
             RegionUninit(&val->after.exposed);
@@ -980,26 +979,16 @@ miOverlayMoveWindow(WindowPtr pWin,
 #endif
 
 static void
-miOverlayWindowExposures(WindowPtr pWin,
-                         RegionPtr prgn, RegionPtr other_exposed)
+miOverlayWindowExposures(WindowPtr pWin, RegionPtr prgn)
 {
     RegionPtr exposures = prgn;
 
-    if ((prgn && !RegionNil(prgn)) ||
-        (exposures && !RegionNil(exposures)) || other_exposed) {
+    if ((prgn && !RegionNil(prgn)) || (exposures && !RegionNil(exposures))) {
         RegionRec expRec;
         int clientInterested;
 
         clientInterested = (pWin->eventMask | wOtherEventMasks(pWin)) &
             ExposureMask;
-        if (other_exposed) {
-            if (exposures) {
-                RegionUnion(other_exposed, exposures, other_exposed);
-                if (exposures != prgn)
-                    RegionDestroy(exposures);
-            }
-            exposures = other_exposed;
-        }
         if (clientInterested && exposures &&
             (RegionNumRects(exposures) > RECTLIMIT)) {
             ScreenPtr pScreen = pWin->drawable.pScreen;
@@ -1035,7 +1024,7 @@ miOverlayWindowExposures(WindowPtr pWin,
         if (exposures == &expRec) {
             RegionUninit(exposures);
         }
-        else if (exposures && exposures != prgn && exposures != other_exposed)
+        else if (exposures && exposures != prgn)
             RegionDestroy(exposures);
         if (prgn)
             RegionEmpty(prgn);
@@ -1592,7 +1581,6 @@ miOverlayClearToBackground(WindowPtr pWin,
     miOverlayTreePtr pTree = MIOVERLAY_GET_WINDOW_TREE(pWin);
     BoxRec box;
     RegionRec reg;
-    RegionPtr pBSReg = NullRegion;
     ScreenPtr pScreen = pWin->drawable.pScreen;
     miOverlayScreenPtr pScreenPriv = MIOVERLAY_GET_SCREEN_PRIVATE(pScreen);
     RegionPtr clipList;
@@ -1636,12 +1624,10 @@ miOverlayClearToBackground(WindowPtr pWin,
 
     RegionIntersect(&reg, &reg, clipList);
     if (generateExposures)
-        (*pScreen->WindowExposures) (pWin, &reg, pBSReg);
+        (*pScreen->WindowExposures) (pWin, &reg);
     else if (pWin->backgroundState != None)
         miPaintWindow(pWin, &reg, PW_BACKGROUND);
     RegionUninit(&reg);
-    if (pBSReg)
-        RegionDestroy(pBSReg);
 }
 
 /****************************************************************/
diff --git a/mi/miwindow.c b/mi/miwindow.c
index 82c3513..ba4c9ed 100644
--- a/mi/miwindow.c
+++ b/mi/miwindow.c
@@ -111,7 +111,7 @@ miClearToBackground(WindowPtr pWin,
 
     RegionIntersect(&reg, &reg, &pWin->clipList);
     if (generateExposures)
-        (*pWin->drawable.pScreen->WindowExposures) (pWin, &reg, NULL);
+        (*pWin->drawable.pScreen->WindowExposures) (pWin, &reg);
     else if (pWin->backgroundState != None)
         miPaintWindow(pWin, &reg, PW_BACKGROUND);
     RegionUninit(&reg);
@@ -221,7 +221,7 @@ miHandleValidateExposures(WindowPtr pWin)
             if (RegionNotEmpty(&val->after.borderExposed))
                 miPaintWindow(pChild, &val->after.borderExposed, PW_BORDER);
             RegionUninit(&val->after.borderExposed);
-            (*WindowExposures) (pChild, &val->after.exposed, NullRegion);
+            (*WindowExposures) (pChild, &val->after.exposed);
             RegionUninit(&val->after.exposed);
             free(val);
             pChild->valdata = NULL;
commit aaf5e2d643af590366b2d02ad1c2db05d1fc4131
Author: Eric Anholt <eric at anholt.net>
Date:   Sat Dec 28 11:32:10 2013 -0800

    modesetting: Add support for rendering using glamor.
    
    By default modesetting now tries to enable X acceleration using
    glamor, but falls back to normal shadowfb if GL fails to initialize.
    
    Signed-off-by: Eric Anholt <eric at anholt.net>
    Reviewed-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/xfree86/drivers/modesetting/Makefile.am b/hw/xfree86/drivers/modesetting/Makefile.am
index ca3279e..e6834e2 100644
--- a/hw/xfree86/drivers/modesetting/Makefile.am
+++ b/hw/xfree86/drivers/modesetting/Makefile.am
@@ -28,6 +28,7 @@ AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) $(LIBDRM_CFLAGS) $(UDEV_CFLAGS) $(CWARN
 
 AM_CPPFLAGS = \
 	$(XORG_INCS) \
+	-I$(top_srcdir)/glamor \
 	-I$(srcdir)/../../ddc \
 	-I$(srcdir)/../../i2c \
 	-I$(srcdir)/../../modes \
diff --git a/hw/xfree86/drivers/modesetting/driver.c b/hw/xfree86/drivers/modesetting/driver.c
index c713746..c62147a 100644
--- a/hw/xfree86/drivers/modesetting/driver.c
+++ b/hw/xfree86/drivers/modesetting/driver.c
@@ -61,6 +61,11 @@
 
 #include "driver.h"
 
+#ifdef GLAMOR
+#define GLAMOR_FOR_XORG 1
+#include "glamor.h"
+#endif
+
 static void AdjustFrame(ScrnInfoPtr pScrn, int x, int y);
 static Bool CloseScreen(ScreenPtr pScreen);
 static Bool EnterVT(ScrnInfoPtr pScrn);
@@ -122,12 +127,14 @@ typedef enum {
     OPTION_SW_CURSOR,
     OPTION_DEVICE_PATH,
     OPTION_SHADOW_FB,
+    OPTION_ACCEL_METHOD,
 } modesettingOpts;
 
 static const OptionInfoRec Options[] = {
     {OPTION_SW_CURSOR, "SWcursor", OPTV_BOOLEAN, {0}, FALSE},
     {OPTION_DEVICE_PATH, "kmsdev", OPTV_STRING, {0}, FALSE},
     {OPTION_SHADOW_FB, "ShadowFB", OPTV_BOOLEAN, {0}, FALSE},
+    {OPTION_ACCEL_METHOD, "AccelMethod", OPTV_STRING, {0}, FALSE},
     {-1, NULL, OPTV_NONE, {0}, FALSE}
 };
 
@@ -577,6 +584,43 @@ FreeRec(ScrnInfoPtr pScrn)
 
 }
 
+static void
+try_enable_glamor(ScrnInfoPtr pScrn)
+{
+    modesettingPtr ms = modesettingPTR(pScrn);
+    const char *accel_method_str = xf86GetOptValString(ms->Options,
+                                                       OPTION_ACCEL_METHOD);
+    Bool do_glamor = (!accel_method_str ||
+                      strcmp(accel_method_str, "glamor") == 0);
+
+    ms->glamor = FALSE;
+
+#ifdef GLAMOR
+    if (!do_glamor) {
+        xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "glamor disabled\n");
+        return;
+    }
+
+    if (xf86LoadSubModule(pScrn, GLAMOR_EGL_MODULE_NAME)) {
+        if (glamor_egl_init(pScrn, ms->fd)) {
+            xf86DrvMsg(pScrn->scrnIndex, X_INFO, "glamor initialized\n");
+            ms->glamor = TRUE;
+        } else {
+            xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+                       "glamor initialization failed\n");
+        }
+    } else {
+        xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+                   "Failed to load glamor module.\n");
+    }
+#else
+    if (do_glamor) {
+        xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+                   "No glamor support in the X Server\n");
+    }
+#endif
+}
+
 #ifndef DRM_CAP_CURSOR_WIDTH
 #define DRM_CAP_CURSOR_WIDTH 0x8
 #endif
@@ -594,7 +638,6 @@ PreInit(ScrnInfoPtr pScrn, int flags)
     EntPtr msEnt = NULL;
     char *BusID = NULL;
     const char *devicename;
-    Bool prefer_shadow = TRUE;
     uint64_t value = 0;
     int ret;
     int bppflags;
@@ -732,11 +775,6 @@ PreInit(ScrnInfoPtr pScrn, int flags)
         ms->drmmode.sw_cursor = TRUE;
     }
 
-    ret = drmGetCap(ms->fd, DRM_CAP_DUMB_PREFER_SHADOW, &value);
-    if (!ret) {
-        prefer_shadow = ! !value;
-    }
-
     ms->cursor_width = 64;
     ms->cursor_height = 64;
     ret = drmGetCap(ms->fd, DRM_CAP_CURSOR_WIDTH, &value);
@@ -748,12 +786,26 @@ PreInit(ScrnInfoPtr pScrn, int flags)
         ms->cursor_height = value;
     }
 
-    ms->drmmode.shadow_enable =
-        xf86ReturnOptValBool(ms->Options, OPTION_SHADOW_FB, prefer_shadow);
+    try_enable_glamor(pScrn);
+
+    if (!ms->glamor) {
+        Bool prefer_shadow = TRUE;
+
+        ret = drmGetCap(ms->fd, DRM_CAP_DUMB_PREFER_SHADOW, &value);
+        if (!ret) {
+            prefer_shadow = !!value;
+        }
+
+        ms->drmmode.shadow_enable = xf86ReturnOptValBool(ms->Options,
+                                                         OPTION_SHADOW_FB,
+                                                         prefer_shadow);
+
+        xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+                   "ShadowFB: preferred %s, enabled %s\n",
+                   prefer_shadow ? "YES" : "NO",
+                   ms->drmmode.shadow_enable ? "YES" : "NO");
+    }
 
-    xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ShadowFB: preferred %s, enabled %s\n",
-               prefer_shadow ? "YES" : "NO",
-               ms->drmmode.shadow_enable ? "YES" : "NO");
     if (drmmode_pre_init(pScrn, &ms->drmmode, pScrn->bitsPerPixel / 8) == FALSE) {
         xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "KMS setup failed\n");
         goto fail;
@@ -832,6 +884,20 @@ CreateScreenResources(ScreenPtr pScreen)
     if (!drmmode_set_desired_modes(pScrn, &ms->drmmode))
         return FALSE;
 
+#ifdef GLAMOR
+    if (ms->glamor) {
+        if (!glamor_egl_create_textured_screen_ext(pScreen,
+                                                   ms->drmmode.front_bo->handle,
+                                                   pScrn->displayWidth *
+                                                   pScrn->bitsPerPixel / 8,
+                                                   NULL)) {
+            xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+                       "glamor_egl_create_textured_screen_ext() failed\n");
+            return FALSE;
+        }
+    }
+#endif
+
     drmmode_uevent_init(pScrn, &ms->drmmode);
 
     if (!ms->drmmode.sw_cursor)
@@ -984,6 +1050,19 @@ ScreenInit(ScreenPtr pScreen, int argc, char **argv)
 
     fbPictureInit(pScreen, NULL, 0);
 
+#ifdef GLAMOR
+    if (ms->glamor) {
+        if (!glamor_init(pScreen,
+                         GLAMOR_USE_EGL_SCREEN |
+                         GLAMOR_USE_SCREEN |
+                         GLAMOR_USE_PICTURE_SCREEN)) {
+            xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+                       "Failed to initialize glamor at ScreenInit() time.\n");
+            return FALSE;
+        }
+    }
+#endif
+
     if (ms->drmmode.shadow_enable && !msShadowInit(pScreen)) {
         xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "shadow fb init failed\n");
         return FALSE;
diff --git a/hw/xfree86/drivers/modesetting/driver.h b/hw/xfree86/drivers/modesetting/driver.h
index 8a920b9..35f2419 100644
--- a/hw/xfree86/drivers/modesetting/driver.h
+++ b/hw/xfree86/drivers/modesetting/driver.h
@@ -74,6 +74,7 @@ typedef struct _modesettingRec {
     Bool dirty_enabled;
 
     uint32_t cursor_width, cursor_height;
+    Bool glamor;
 } modesettingRec, *modesettingPtr;
 
 #define modesettingPTR(p) ((modesettingPtr)((p)->driverPrivate))
diff --git a/hw/xfree86/drivers/modesetting/modesetting.man b/hw/xfree86/drivers/modesetting/modesetting.man
index 34baa9c..9cb27d7 100644
--- a/hw/xfree86/drivers/modesetting/modesetting.man
+++ b/hw/xfree86/drivers/modesetting/modesetting.man
@@ -47,6 +47,9 @@ The framebuffer device to use. Default: /dev/dri/card0.
 .BI "Option \*qShadowFB\*q \*q" boolean \*q
 Enable or disable use of the shadow framebuffer layer.  Default: on.
 .TP
+.BI "Option \*qAccelMethod\*q \*q" string \*q
+One of \*qglamor\*q or \*qnone\*q.  Default: glamor
+.TP
 .SH "SEE ALSO"
 __xservername__(__appmansuffix__), __xconfigfile__(__filemansuffix__), Xserver(__appmansuffix__),
 X(__miscmansuffix__)
commit 6d41bdb23ca92803e3a51dc317d2b80cdb92f43a
Author: Eric Anholt <eric at anholt.net>
Date:   Tue Aug 26 16:59:37 2014 -0700

    modesetting: Deduplicate some scrn setup.
    
    Signed-off-by: Eric Anholt <eric at anholt.net>
    Reviewed-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/xfree86/drivers/modesetting/driver.c b/hw/xfree86/drivers/modesetting/driver.c
index f509a19..c713746 100644
--- a/hw/xfree86/drivers/modesetting/driver.c
+++ b/hw/xfree86/drivers/modesetting/driver.c
@@ -306,6 +306,24 @@ ms_driver_func(ScrnInfoPtr scrn, xorgDriverFuncOp op, void *data)
     }
 }
 
+static void
+ms_setup_scrn_hooks(ScrnInfoPtr scrn)
+{
+    scrn->driverVersion = 1;
+    scrn->driverName = "modesetting";
+    scrn->name = "modeset";
+
+    scrn->Probe = NULL;
+    scrn->PreInit = PreInit;
+    scrn->ScreenInit = ScreenInit;
+    scrn->SwitchMode = SwitchMode;
+    scrn->AdjustFrame = AdjustFrame;
+    scrn->EnterVT = EnterVT;
+    scrn->LeaveVT = LeaveVT;
+    scrn->FreeScreen = FreeScreen;
+    scrn->ValidMode = ValidMode;
+}
+
 #if XSERVER_LIBPCIACCESS
 static Bool
 ms_pci_probe(DriverPtr driver,
@@ -322,18 +340,7 @@ ms_pci_probe(DriverPtr driver,
 
         devpath = xf86FindOptionValue(devSection->options, "kmsdev");
         if (probe_hw_pci(devpath, dev)) {
-            scrn->driverVersion = 1;
-            scrn->driverName = "modesetting";
-            scrn->name = "modeset";
-            scrn->Probe = NULL;
-            scrn->PreInit = PreInit;
-            scrn->ScreenInit = ScreenInit;
-            scrn->SwitchMode = SwitchMode;
-            scrn->AdjustFrame = AdjustFrame;
-            scrn->EnterVT = EnterVT;
-            scrn->LeaveVT = LeaveVT;
-            scrn->FreeScreen = FreeScreen;
-            scrn->ValidMode = ValidMode;
+            ms_setup_scrn_hooks(scrn);
 
             xf86DrvMsg(scrn->scrnIndex, X_CONFIG,
                        "claimed PCI slot %d@%d:%d:%d\n",
@@ -365,16 +372,8 @@ ms_platform_probe(DriverPtr driver,
         scrn = xf86AllocateScreen(driver, scr_flags);
         xf86AddEntityToScreen(scrn, entity_num);
 
-        scrn->driverName = "modesetting";
-        scrn->name = "modesetting";
-        scrn->PreInit = PreInit;
-        scrn->ScreenInit = ScreenInit;
-        scrn->SwitchMode = SwitchMode;
-        scrn->AdjustFrame = AdjustFrame;
-        scrn->EnterVT = EnterVT;
-        scrn->LeaveVT = LeaveVT;
-        scrn->FreeScreen = FreeScreen;
-        scrn->ValidMode = ValidMode;
+        ms_setup_scrn_hooks(scrn);
+
         xf86DrvMsg(scrn->scrnIndex, X_INFO,
                    "using drv %s\n", path ? path : "default device");
     }
@@ -416,18 +415,8 @@ Probe(DriverPtr drv, int flags)
 
         if (scrn) {
             foundScreen = TRUE;
-            scrn->driverVersion = 1;
-            scrn->driverName = "modesetting";
-            scrn->name = "modesetting";
+            ms_setup_scrn_hooks(scrn);
             scrn->Probe = Probe;
-            scrn->PreInit = PreInit;
-            scrn->ScreenInit = ScreenInit;
-            scrn->SwitchMode = SwitchMode;
-            scrn->AdjustFrame = AdjustFrame;
-            scrn->EnterVT = EnterVT;
-            scrn->LeaveVT = LeaveVT;
-            scrn->FreeScreen = FreeScreen;
-            scrn->ValidMode = ValidMode;
 
             xf86DrvMsg(scrn->scrnIndex, X_INFO,
                        "using %s\n", dev ? dev : "default device");
commit 20a3b482191711bc15be0410ccc3651924271349
Author: Eric Anholt <eric at anholt.net>
Date:   Wed Oct 8 00:41:13 2014 -0700

    modesetting: Fix some weird formatting after x-indent-all.sh.
    
    Signed-off-by: Eric Anholt <eric at anholt.net>
    Reviewed-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c b/hw/xfree86/drivers/modesetting/drmmode_display.c
index ca02a4d..d959837 100644
--- a/hw/xfree86/drivers/modesetting/drmmode_display.c
+++ b/hw/xfree86/drivers/modesetting/drmmode_display.c
@@ -976,7 +976,9 @@ static const xf86OutputFuncsRec drmmode_output_funcs = {
     .destroy = drmmode_output_destroy
 };
 
-static int subpixel_conv_table[7] = { 0, SubPixelUnknown,
+static int subpixel_conv_table[7] = {
+    0,
+    SubPixelUnknown,
     SubPixelHorizontalRGB,
     SubPixelHorizontalBGR,
     SubPixelVerticalRGB,
@@ -984,7 +986,8 @@ static int subpixel_conv_table[7] = { 0, SubPixelUnknown,
     SubPixelNone
 };
 
-static const char *const output_names[] = { "None",
+static const char *const output_names[] = {
+    "None",
     "VGA",
     "DVI",
     "DVI",
commit 3119acdab9eecff90b8fd9a265e2a456e7bc8779
Author: Eric Anholt <eric at anholt.net>
Date:   Wed Oct 8 00:39:15 2014 -0700

    modesetting: Run x-indent-all.sh.
    
    As I was editing code, the top-level .dir-locals.el was making my new
    stuff conflict with the existing style.  Make it consistently use the
    xorg style, instead.
    
    Signed-off-by: Eric Anholt <eric at anholt.net>
    Reviewed-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/xfree86/drivers/modesetting/driver.c b/hw/xfree86/drivers/modesetting/driver.c
index adfb69c..f509a19 100644
--- a/hw/xfree86/drivers/modesetting/driver.c
+++ b/hw/xfree86/drivers/modesetting/driver.c
@@ -66,8 +66,8 @@ static Bool CloseScreen(ScreenPtr pScreen);
 static Bool EnterVT(ScrnInfoPtr pScrn);
 static void Identify(int flags);
 static const OptionInfoRec *AvailableOptions(int chipid, int busid);
-static ModeStatus ValidMode(ScrnInfoPtr pScrn, DisplayModePtr mode, Bool verbose,
-			    int flags);
+static ModeStatus ValidMode(ScrnInfoPtr pScrn, DisplayModePtr mode,
+                            Bool verbose, int flags);
 static void FreeScreen(ScrnInfoPtr pScrn);
 static void LeaveVT(ScrnInfoPtr pScrn);
 static Bool SwitchMode(ScrnInfoPtr pScrn, DisplayModePtr mode);
@@ -76,26 +76,25 @@ static Bool PreInit(ScrnInfoPtr pScrn, int flags);
 
 static Bool Probe(DriverPtr drv, int flags);
 static Bool ms_pci_probe(DriverPtr driver,
-			 int entity_num, struct pci_device *device,
-			 intptr_t match_data);
-static Bool ms_driver_func(ScrnInfoPtr scrn, xorgDriverFuncOp op,
-			   void *data);
+                         int entity_num, struct pci_device *device,
+                         intptr_t match_data);
+static Bool ms_driver_func(ScrnInfoPtr scrn, xorgDriverFuncOp op, void *data);
 
 #ifdef XSERVER_LIBPCIACCESS
 static const struct pci_id_match ms_device_match[] = {
     {
-	PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY,
-	0x00030000, 0x00ff0000, 0
-    },
+     PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY,
+     0x00030000, 0x00ff0000, 0},
 
-    { 0, 0, 0 },
+    {0, 0, 0},
 };
 #endif
 
 #ifdef XSERVER_PLATFORM_BUS
 static Bool ms_platform_probe(DriverPtr driver,
-                          int entity_num, int flags, struct xf86_platform_device *device,
-			  intptr_t match_data);
+                              int entity_num, int flags,
+                              struct xf86_platform_device *device,
+                              intptr_t match_data);
 #endif
 
 _X_EXPORT DriverRec modesetting = {
@@ -115,12 +114,11 @@ _X_EXPORT DriverRec modesetting = {
 };
 
 static SymTabRec Chipsets[] = {
-    {0, "kms" },
+    {0, "kms"},
     {-1, NULL}
 };
 
-typedef enum
-{
+typedef enum {
     OPTION_SW_CURSOR,
     OPTION_DEVICE_PATH,
     OPTION_SHADOW_FB,
@@ -128,8 +126,8 @@ typedef enum
 
 static const OptionInfoRec Options[] = {
     {OPTION_SW_CURSOR, "SWcursor", OPTV_BOOLEAN, {0}, FALSE},
-    {OPTION_DEVICE_PATH, "kmsdev", OPTV_STRING, {0}, FALSE },
-    {OPTION_SHADOW_FB, "ShadowFB", OPTV_BOOLEAN, {0}, FALSE },
+    {OPTION_DEVICE_PATH, "kmsdev", OPTV_STRING, {0}, FALSE},
+    {OPTION_SHADOW_FB, "ShadowFB", OPTV_BOOLEAN, {0}, FALSE},
     {-1, NULL, OPTV_NONE, {0}, FALSE}
 };
 
@@ -155,25 +153,26 @@ static XF86ModuleVersionInfo VersRec = {
 _X_EXPORT XF86ModuleData modesettingModuleData = { &VersRec, Setup, NULL };
 
 static void *
-Setup(void * module, void * opts, int *errmaj, int *errmin)
+Setup(void *module, void *opts, int *errmaj, int *errmin)
 {
     static Bool setupDone = 0;
 
     /* This module should be loaded only once, but check to be sure.
      */
     if (!setupDone) {
-	setupDone = 1;
-	xf86AddDriver(&modesetting, module, HaveDriverFuncs);
-
-	/*
-	 * The return value must be non-NULL on success even though there
-	 * is no TearDownProc.
-	 */
-	return (void *) 1;
-    } else {
-	if (errmaj)
-	    *errmaj = LDR_ONCEONLY;
-	return NULL;
+        setupDone = 1;
+        xf86AddDriver(&modesetting, module, HaveDriverFuncs);
+
+        /*
+         * The return value must be non-NULL on success even though there
+         * is no TearDownProc.
+         */
+        return (void *) 1;
+    }
+    else {
+        if (errmaj)
+            *errmaj = LDR_ONCEONLY;
+        return NULL;
     }
 }
 
@@ -181,28 +180,31 @@ static void
 Identify(int flags)
 {
     xf86PrintChipsets("modesetting", "Driver for Modesetting Kernel Drivers",
-		      Chipsets);
+                      Chipsets);
 }
 
-static int open_hw(const char *dev)
+static int
+open_hw(const char *dev)
 {
     int fd;
+
     if (dev)
-	fd = open(dev, O_RDWR, 0);
+        fd = open(dev, O_RDWR, 0);
     else {
-	dev = getenv("KMSDEVICE");
-	if ((NULL == dev) || ((fd = open(dev, O_RDWR, 0)) == -1)) {
-	    dev = "/dev/dri/card0";
-	    fd = open(dev,O_RDWR, 0);
-	}
+        dev = getenv("KMSDEVICE");
+        if ((NULL == dev) || ((fd = open(dev, O_RDWR, 0)) == -1)) {
+            dev = "/dev/dri/card0";
+            fd = open(dev, O_RDWR, 0);
+        }
     }
     if (fd == -1)
-	xf86DrvMsg(-1, X_ERROR,"open %s: %s\n", dev, strerror(errno));
+        xf86DrvMsg(-1, X_ERROR, "open %s: %s\n", dev, strerror(errno));
 
     return fd;
 }
 
-static int check_outputs(int fd)
+static int
+check_outputs(int fd)
 {
     drmModeResPtr res = drmModeGetResources(fd);
     int ret;
@@ -214,7 +216,8 @@ static int check_outputs(int fd)
     return ret;
 }
 
-static Bool probe_hw(const char *dev, struct xf86_platform_device *platform_dev)
+static Bool
+probe_hw(const char *dev, struct xf86_platform_device *platform_dev)
 {
     int fd;
 
@@ -230,6 +233,7 @@ static Bool probe_hw(const char *dev, struct xf86_platform_device *platform_dev)
     fd = open_hw(dev);
     if (fd != -1) {
         int ret = check_outputs(fd);
+
         close(fd);
         return ret;
     }
@@ -248,15 +252,15 @@ ms_DRICreatePCIBusID(const struct pci_device *dev)
     return busID;
 }
 
-
-static Bool probe_hw_pci(const char *dev, struct pci_device *pdev)
+static Bool
+probe_hw_pci(const char *dev, struct pci_device *pdev)
 {
     int ret = FALSE, fd = open_hw(dev);
     char *id, *devid;
     drmSetVersion sv;
 
     if (fd == -1)
-	return FALSE;
+        return FALSE;
 
     sv.drm_di_major = 1;
     sv.drm_di_minor = 4;
@@ -267,7 +271,6 @@ static Bool probe_hw_pci(const char *dev, struct pci_device *pdev)
         return FALSE;
     }
 
-
     id = drmGetBusid(fd);
     devid = ms_DRICreatePCIBusID(pdev);
 
@@ -279,6 +282,7 @@ static Bool probe_hw_pci(const char *dev, struct pci_device *pdev)
     free(devid);
     return ret;
 }
+
 static const OptionInfoRec *
 AvailableOptions(int chipid, int busid)
 {
@@ -289,55 +293,56 @@ static Bool
 ms_driver_func(ScrnInfoPtr scrn, xorgDriverFuncOp op, void *data)
 {
     xorgHWFlags *flag;
-    
+
     switch (op) {
-	case GET_REQUIRED_HW_INTERFACES:
-	    flag = (CARD32 *)data;
-	    (*flag) = 0;
-	    return TRUE;
-        case SUPPORTS_SERVER_FDS:
-            return TRUE;
-	default:
-	    return FALSE;
+    case GET_REQUIRED_HW_INTERFACES:
+        flag = (CARD32 *) data;
+        (*flag) = 0;
+        return TRUE;
+    case SUPPORTS_SERVER_FDS:
+        return TRUE;
+    default:
+        return FALSE;
     }
 }
 
 #if XSERVER_LIBPCIACCESS
 static Bool
 ms_pci_probe(DriverPtr driver,
-	     int entity_num, struct pci_device *dev, intptr_t match_data)
+             int entity_num, struct pci_device *dev, intptr_t match_data)
 {
     ScrnInfoPtr scrn = NULL;
 
     scrn = xf86ConfigPciEntity(scrn, 0, entity_num, NULL,
-			       NULL, NULL, NULL, NULL, NULL);
+                               NULL, NULL, NULL, NULL, NULL);
     if (scrn) {
-	const char *devpath;
-	GDevPtr devSection = xf86GetDevFromEntity(scrn->entityList[0],
-						  scrn->entityInstanceList[0]);
-
-	devpath = xf86FindOptionValue(devSection->options, "kmsdev");
-	if (probe_hw_pci(devpath, dev)) {
-	    scrn->driverVersion = 1;
-	    scrn->driverName = "modesetting";
-	    scrn->name = "modeset";
-	    scrn->Probe = NULL;
-	    scrn->PreInit = PreInit;
-	    scrn->ScreenInit = ScreenInit;
-	    scrn->SwitchMode = SwitchMode;
-	    scrn->AdjustFrame = AdjustFrame;
-	    scrn->EnterVT = EnterVT;
-	    scrn->LeaveVT = LeaveVT;
-	    scrn->FreeScreen = FreeScreen;
-	    scrn->ValidMode = ValidMode;
-
-	    xf86DrvMsg(scrn->scrnIndex, X_CONFIG,
-		       "claimed PCI slot %d@%d:%d:%d\n", 
-		       dev->bus, dev->domain, dev->dev, dev->func);
-	    xf86DrvMsg(scrn->scrnIndex, X_INFO,
-		       "using %s\n", devpath ? devpath : "default device");
-	} else
-	    scrn = NULL;
+        const char *devpath;
+        GDevPtr devSection = xf86GetDevFromEntity(scrn->entityList[0],
+                                                  scrn->entityInstanceList[0]);
+
+        devpath = xf86FindOptionValue(devSection->options, "kmsdev");
+        if (probe_hw_pci(devpath, dev)) {
+            scrn->driverVersion = 1;
+            scrn->driverName = "modesetting";
+            scrn->name = "modeset";
+            scrn->Probe = NULL;
+            scrn->PreInit = PreInit;
+            scrn->ScreenInit = ScreenInit;
+            scrn->SwitchMode = SwitchMode;
+            scrn->AdjustFrame = AdjustFrame;
+            scrn->EnterVT = EnterVT;
+            scrn->LeaveVT = LeaveVT;
+            scrn->FreeScreen = FreeScreen;
+            scrn->ValidMode = ValidMode;
+
+            xf86DrvMsg(scrn->scrnIndex, X_CONFIG,
+                       "claimed PCI slot %d@%d:%d:%d\n",
+                       dev->bus, dev->domain, dev->dev, dev->func);
+            xf86DrvMsg(scrn->scrnIndex, X_INFO,
+                       "using %s\n", devpath ? devpath : "default device");
+        }
+        else
+            scrn = NULL;
     }
     return scrn != NULL;
 }
@@ -346,14 +351,15 @@ ms_pci_probe(DriverPtr driver,
 #ifdef XSERVER_PLATFORM_BUS
 static Bool
 ms_platform_probe(DriverPtr driver,
-              int entity_num, int flags, struct xf86_platform_device *dev, intptr_t match_data)
+                  int entity_num, int flags, struct xf86_platform_device *dev,
+                  intptr_t match_data)
 {
     ScrnInfoPtr scrn = NULL;
     const char *path = xf86_platform_device_odev_attributes(dev)->path;
     int scr_flags = 0;
 
     if (flags & PLATFORM_PROBE_GPU_SCREEN)
-            scr_flags = XF86_ALLOCATE_GPU_SCREEN;
+        scr_flags = XF86_ALLOCATE_GPU_SCREEN;
 
     if (probe_hw(path, dev)) {
         scrn = xf86AllocateScreen(driver, scr_flags);
@@ -388,44 +394,44 @@ Probe(DriverPtr drv, int flags)
 
     /* For now, just bail out for PROBE_DETECT. */
     if (flags & PROBE_DETECT)
-	return FALSE;
+        return FALSE;
 
     /*
      * Find the config file Device sections that match this
      * driver, and return if there are none.
      */
     if ((numDevSections = xf86MatchDevice("modesetting", &devSections)) <= 0) {
-	return FALSE;
+        return FALSE;
     }
 
     for (i = 0; i < numDevSections; i++) {
 
-	dev = xf86FindOptionValue(devSections[i]->options,"kmsdev");
-	if (probe_hw(dev, NULL)) {
-	    int entity;
-	    entity = xf86ClaimFbSlot(drv, 0, devSections[i], TRUE);
-	    scrn = xf86ConfigFbEntity(scrn, 0, entity,
-				  NULL, NULL, NULL, NULL);
-	}
-
-	if (scrn) {
-	    foundScreen = TRUE;
-	    scrn->driverVersion = 1;
-	    scrn->driverName = "modesetting";
-	    scrn->name = "modesetting";
-	    scrn->Probe = Probe;
-	    scrn->PreInit = PreInit;
-	    scrn->ScreenInit = ScreenInit;
-	    scrn->SwitchMode = SwitchMode;
-	    scrn->AdjustFrame = AdjustFrame;
-	    scrn->EnterVT = EnterVT;
-	    scrn->LeaveVT = LeaveVT;
-	    scrn->FreeScreen = FreeScreen;
-	    scrn->ValidMode = ValidMode;
-
-	    xf86DrvMsg(scrn->scrnIndex, X_INFO,
-			   "using %s\n", dev ? dev : "default device");
-	}
+        dev = xf86FindOptionValue(devSections[i]->options, "kmsdev");
+        if (probe_hw(dev, NULL)) {
+            int entity;
+
+            entity = xf86ClaimFbSlot(drv, 0, devSections[i], TRUE);
+            scrn = xf86ConfigFbEntity(scrn, 0, entity, NULL, NULL, NULL, NULL);
+        }
+
+        if (scrn) {
+            foundScreen = TRUE;
+            scrn->driverVersion = 1;
+            scrn->driverName = "modesetting";
+            scrn->name = "modesetting";
+            scrn->Probe = Probe;
+            scrn->PreInit = PreInit;
+            scrn->ScreenInit = ScreenInit;
+            scrn->SwitchMode = SwitchMode;
+            scrn->AdjustFrame = AdjustFrame;
+            scrn->EnterVT = EnterVT;
+            scrn->LeaveVT = LeaveVT;
+            scrn->FreeScreen = FreeScreen;
+            scrn->ValidMode = ValidMode;
+
+            xf86DrvMsg(scrn->scrnIndex, X_INFO,
+                       "using %s\n", dev ? dev : "default device");
+        }
     }
 
     free(devSections);
@@ -437,51 +443,51 @@ static Bool
 GetRec(ScrnInfoPtr pScrn)
 {
     if (pScrn->driverPrivate)
-	return TRUE;
+        return TRUE;
 
     pScrn->driverPrivate = xnfcalloc(sizeof(modesettingRec), 1);
 
     return TRUE;
 }
 
-static int dispatch_dirty_region(ScrnInfoPtr scrn,
-				 PixmapPtr pixmap,
-				 DamagePtr damage,
-				 int fb_id)
+static int
+dispatch_dirty_region(ScrnInfoPtr scrn,
+                      PixmapPtr pixmap, DamagePtr damage, int fb_id)
 {
     modesettingPtr ms = modesettingPTR(scrn);
     RegionPtr dirty = DamageRegion(damage);
     unsigned num_cliprects = REGION_NUM_RECTS(dirty);
 
     if (num_cliprects) {
-	drmModeClip *clip = malloc(num_cliprects * sizeof(drmModeClip));
-	BoxPtr rect = REGION_RECTS(dirty);
-	int i, ret;
-	    
-	if (!clip)
-	    return -ENOMEM;
-
-	/* XXX no need for copy? */
-	for (i = 0; i < num_cliprects; i++, rect++) {
-	    clip[i].x1 = rect->x1;
-	    clip[i].y1 = rect->y1;
-	    clip[i].x2 = rect->x2;
-	    clip[i].y2 = rect->y2;
-	}
-
-	/* TODO query connector property to see if this is needed */
-	ret = drmModeDirtyFB(ms->fd, fb_id, clip, num_cliprects);
-	free(clip);
-	DamageEmpty(damage);
-	if (ret) {
-	    if (ret == -EINVAL)
-		return ret;
-	}
+        drmModeClip *clip = malloc(num_cliprects * sizeof(drmModeClip));
+        BoxPtr rect = REGION_RECTS(dirty);
+        int i, ret;
+
+        if (!clip)
+            return -ENOMEM;
+
+        /* XXX no need for copy? */
+        for (i = 0; i < num_cliprects; i++, rect++) {
+            clip[i].x1 = rect->x1;
+            clip[i].y1 = rect->y1;
+            clip[i].x2 = rect->x2;
+            clip[i].y2 = rect->y2;
+        }
+
+        /* TODO query connector property to see if this is needed */
+        ret = drmModeDirtyFB(ms->fd, fb_id, clip, num_cliprects);
+        free(clip);
+        DamageEmpty(damage);
+        if (ret) {
+            if (ret == -EINVAL)
+                return ret;
+        }
     }
     return 0;
 }
 
-static void dispatch_dirty(ScreenPtr pScreen)
+static void
+dispatch_dirty(ScreenPtr pScreen)
 {
     ScrnInfoPtr scrn = xf86ScreenToScrn(pScreen);
     modesettingPtr ms = modesettingPTR(scrn);
@@ -491,16 +497,18 @@ static void dispatch_dirty(ScreenPtr pScreen)
 
     ret = dispatch_dirty_region(scrn, pixmap, ms->damage, fb_id);
     if (ret == -EINVAL || ret == -ENOSYS) {
-	ms->dirty_enabled = FALSE;
-	DamageUnregister(ms->damage);
-	DamageDestroy(ms->damage);
-	ms->damage = NULL;
-	xf86DrvMsg(scrn->scrnIndex, X_INFO, "Disabling kernel dirty updates, not required.\n");
-	return;
+        ms->dirty_enabled = FALSE;
+        DamageUnregister(ms->damage);
+        DamageDestroy(ms->damage);
+        ms->damage = NULL;
+        xf86DrvMsg(scrn->scrnIndex, X_INFO,
+                   "Disabling kernel dirty updates, not required.\n");
+        return;
     }
 }
 
-static void dispatch_dirty_crtc(ScrnInfoPtr scrn, xf86CrtcPtr crtc)
+static void
+dispatch_dirty_crtc(ScrnInfoPtr scrn, xf86CrtcPtr crtc)
 {
     modesettingPtr ms = modesettingPTR(scrn);
     PixmapPtr pixmap = crtc->randr_crtc->scanout_pixmap;
@@ -516,25 +524,27 @@ static void dispatch_dirty_crtc(ScrnInfoPtr scrn, xf86CrtcPtr crtc)
     }
 }
 
-static void dispatch_slave_dirty(ScreenPtr pScreen)
+static void
+dispatch_slave_dirty(ScreenPtr pScreen)
 {
     ScrnInfoPtr scrn = xf86ScreenToScrn(pScreen);
     xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
     int c;
 
     for (c = 0; c < xf86_config->num_crtc; c++) {
-	xf86CrtcPtr crtc = xf86_config->crtc[c];
+        xf86CrtcPtr crtc = xf86_config->crtc[c];
 
-	if (!crtc->randr_crtc)
-	    continue;
-	if (!crtc->randr_crtc->scanout_pixmap)
-	    continue;
+        if (!crtc->randr_crtc)
+            continue;
+        if (!crtc->randr_crtc->scanout_pixmap)
+            continue;
 
-	dispatch_dirty_crtc(scrn, crtc);
+        dispatch_dirty_crtc(scrn, crtc);
     }
 }
 
-static void msBlockHandler(ScreenPtr pScreen, void *pTimeout, void *pReadmask)
+static void
+msBlockHandler(ScreenPtr pScreen, void *pTimeout, void *pReadmask)
 {
     modesettingPtr ms = modesettingPTR(xf86ScreenToScrn(pScreen));
 
@@ -568,7 +578,7 @@ FreeRec(ScrnInfoPtr pScrn)
         else
 #ifdef XF86_PDEV_SERVER_FD
         if (!(ms->pEnt->location.type == BUS_PLATFORM &&
-              (ms->pEnt->location.id.plat->flags & XF86_PDEV_SERVER_FD)))
+                  (ms->pEnt->location.id.plat->flags & XF86_PDEV_SERVER_FD)))
 #endif
             ret = close(ms->fd);
         (void) ret;
@@ -602,38 +612,40 @@ PreInit(ScrnInfoPtr pScrn, int flags)
     int defaultdepth, defaultbpp;
 
     if (pScrn->numEntities != 1)
-	return FALSE;
+        return FALSE;
 
     pEnt = xf86GetEntityInfo(pScrn->entityList[0]);
 
     if (flags & PROBE_DETECT) {
-	return FALSE;
+        return FALSE;
     }
 
     /* Allocate driverPrivate */
     if (!GetRec(pScrn))
-	return FALSE;
+        return FALSE;
 
     ms = modesettingPTR(pScrn);
     ms->SaveGeneration = -1;
     ms->pEnt = pEnt;
 
-    pScrn->displayWidth = 640;	       /* default it */
+    pScrn->displayWidth = 640;  /* default it */
 
     /* Allocate an entity private if necessary */
     if (xf86IsEntityShared(pScrn->entityList[0])) {
-	msEnt = xf86GetEntityPrivate(pScrn->entityList[0],
-				     modesettingEntityIndex)->ptr;
-	ms->entityPrivate = msEnt;
-    } else
-	ms->entityPrivate = NULL;
+        msEnt = xf86GetEntityPrivate(pScrn->entityList[0],
+                                     modesettingEntityIndex)->ptr;
+        ms->entityPrivate = msEnt;
+    }
+    else
+        ms->entityPrivate = NULL;
 
     if (xf86IsEntityShared(pScrn->entityList[0])) {
-	if (xf86IsPrimInitDone(pScrn->entityList[0])) {
-	    /* do something */
-	} else {
-	    xf86SetPrimInitDone(pScrn->entityList[0]);
-	}
+        if (xf86IsPrimInitDone(pScrn->entityList[0])) {
+            /* do something */
+        }
+        else {
+            xf86SetPrimInitDone(pScrn->entityList[0]);
+        }
     }
 
     pScrn->monitor = pScrn->confScreen->monitor;
@@ -644,15 +656,19 @@ PreInit(ScrnInfoPtr pScrn, int flags)
     if (pEnt->location.type == BUS_PLATFORM) {
 #ifdef XF86_PDEV_SERVER_FD
         if (pEnt->location.id.plat->flags & XF86_PDEV_SERVER_FD)
-            ms->fd = xf86_platform_device_odev_attributes(pEnt->location.id.plat)->fd;
+            ms->fd =
+                xf86_platform_device_odev_attributes(pEnt->location.id.plat)->
+                fd;
         else
 #endif
         {
-            char *path = xf86_platform_device_odev_attributes(pEnt->location.id.plat)->path;
+            char *path =
+                xf86_platform_device_odev_attributes(pEnt->location.id.plat)->
+                path;
             ms->fd = open_hw(path);
         }
     }
-    else 
+    else
 #endif
     if (pEnt->location.type == BUS_PCI) {
         ms->PciInfo = xf86GetPciInfoForEntity(ms->pEnt->index);
@@ -670,12 +686,13 @@ PreInit(ScrnInfoPtr pScrn, int flags)
                 );
         }
         ms->fd = drmOpen(NULL, BusID);
-    } else {
+    }
+    else {
         devicename = xf86FindOptionValue(ms->pEnt->device->options, "kmsdev");
         ms->fd = open_hw(devicename);
     }
     if (ms->fd < 0)
-	return FALSE;
+        return FALSE;
 
     ms->drmmode.fd = ms->fd;
 
@@ -689,81 +706,84 @@ PreInit(ScrnInfoPtr pScrn, int flags)
 #endif
     drmmode_get_default_bpp(pScrn, &ms->drmmode, &defaultdepth, &defaultbpp);
     if (defaultdepth == 24 && defaultbpp == 24)
-	    bppflags = SupportConvert32to24 | Support24bppFb;
+        bppflags = SupportConvert32to24 | Support24bppFb;
     else
-	    bppflags = PreferConvert24to32 | SupportConvert24to32 | Support32bppFb;
-    
+        bppflags = PreferConvert24to32 | SupportConvert24to32 | Support32bppFb;
+
     if (!xf86SetDepthBpp
-	(pScrn, defaultdepth, defaultdepth, defaultbpp, bppflags))
-	return FALSE;
+        (pScrn, defaultdepth, defaultdepth, defaultbpp, bppflags))
+        return FALSE;
 
     switch (pScrn->depth) {
     case 15:
     case 16:
     case 24:
-	break;
+        break;
     default:
-	xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
-		   "Given depth (%d) is not supported by the driver\n",
-		   pScrn->depth);
-	return FALSE;
+        xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+                   "Given depth (%d) is not supported by the driver\n",
+                   pScrn->depth);
+        return FALSE;
     }
     xf86PrintDepthBpp(pScrn);
 
     /* Process the options */
     xf86CollectOptions(pScrn, NULL);
     if (!(ms->Options = malloc(sizeof(Options))))
-	return FALSE;
+        return FALSE;
     memcpy(ms->Options, Options, sizeof(Options));
     xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, ms->Options);
 
     if (!xf86SetWeight(pScrn, defaultWeight, defaultWeight))
-	return FALSE;
+        return FALSE;
     if (!xf86SetDefaultVisual(pScrn, -1))
-	return FALSE;
+        return FALSE;
 
     if (xf86ReturnOptValBool(ms->Options, OPTION_SW_CURSOR, FALSE)) {
-	ms->drmmode.sw_cursor = TRUE;
+        ms->drmmode.sw_cursor = TRUE;
     }
 
     ret = drmGetCap(ms->fd, DRM_CAP_DUMB_PREFER_SHADOW, &value);
     if (!ret) {
-	prefer_shadow = !!value;
+        prefer_shadow = ! !value;
     }
 
     ms->cursor_width = 64;
     ms->cursor_height = 64;
     ret = drmGetCap(ms->fd, DRM_CAP_CURSOR_WIDTH, &value);
     if (!ret) {
-	ms->cursor_width = value;
+        ms->cursor_width = value;
     }
     ret = drmGetCap(ms->fd, DRM_CAP_CURSOR_HEIGHT, &value);
     if (!ret) {
-	ms->cursor_height = value;
+        ms->cursor_height = value;
     }
 
-    ms->drmmode.shadow_enable = xf86ReturnOptValBool(ms->Options, OPTION_SHADOW_FB, prefer_shadow);
+    ms->drmmode.shadow_enable =
+        xf86ReturnOptValBool(ms->Options, OPTION_SHADOW_FB, prefer_shadow);
 
-    xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ShadowFB: preferred %s, enabled %s\n", prefer_shadow ? "YES" : "NO", ms->drmmode.shadow_enable ? "YES" : "NO");
+    xf86DrvMsg(pScrn->scrnIndex, X_INFO, "ShadowFB: preferred %s, enabled %s\n",
+               prefer_shadow ? "YES" : "NO",
+               ms->drmmode.shadow_enable ? "YES" : "NO");
     if (drmmode_pre_init(pScrn, &ms->drmmode, pScrn->bitsPerPixel / 8) == FALSE) {
-	xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "KMS setup failed\n");
-	goto fail;
+        xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "KMS setup failed\n");
+        goto fail;
     }
 
     /*
      * If the driver can do gamma correction, it should call xf86SetGamma() here.
      */
     {
-	Gamma zeros = { 0.0, 0.0, 0.0 };
+        Gamma zeros = { 0.0, 0.0, 0.0 };
 
-	if (!xf86SetGamma(pScrn, zeros)) {
-	    return FALSE;
-	}
+        if (!xf86SetGamma(pScrn, zeros)) {
+            return FALSE;
+        }
     }
 
     if (pScrn->modes == NULL) {
-	xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No modes.\n");
-	return FALSE;
+        xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No modes.\n");
+        return FALSE;
     }
 
     pScrn->currentMode = pScrn->modes;
@@ -773,23 +793,23 @@ PreInit(ScrnInfoPtr pScrn, int flags)
 
     /* Load the required sub modules */
     if (!xf86LoadSubModule(pScrn, "fb")) {
-	return FALSE;
+        return FALSE;
     }
 
     if (ms->drmmode.shadow_enable) {
-	if (!xf86LoadSubModule(pScrn, "shadow")) {
-	    return FALSE;
-	}
+        if (!xf86LoadSubModule(pScrn, "shadow")) {
+            return FALSE;
+        }
     }
 
     return TRUE;
-    fail:
+ fail:
     return FALSE;
 }
 
 static void *
 msShadowWindow(ScreenPtr screen, CARD32 row, CARD32 offset, int mode,
-	       CARD32 *size, void *closure)
+               CARD32 *size, void *closure)
 {
     ScrnInfoPtr pScrn = xf86ScreenToScrn(screen);
     modesettingPtr ms = modesettingPTR(pScrn);
@@ -798,7 +818,7 @@ msShadowWindow(ScreenPtr screen, CARD32 row, CARD32 offset, int mode,
     stride = (pScrn->displayWidth * pScrn->bitsPerPixel) / 8;
     *size = stride;
 
-    return ((uint8_t *)ms->drmmode.front_bo->ptr + row * stride + offset);
+    return ((uint8_t *) ms->drmmode.front_bo->ptr + row * stride + offset);
 }
 
 static void
@@ -815,12 +835,13 @@ CreateScreenResources(ScreenPtr pScreen)
     PixmapPtr rootPixmap;
     Bool ret;
     void *pixels;
+
     pScreen->CreateScreenResources = ms->createScreenResources;
     ret = pScreen->CreateScreenResources(pScreen);
     pScreen->CreateScreenResources = CreateScreenResources;
 
     if (!drmmode_set_desired_modes(pScrn, &ms->drmmode))
-      return FALSE;
+        return FALSE;
 
     drmmode_uevent_init(pScrn, &ms->drmmode);
 
@@ -828,33 +849,34 @@ CreateScreenResources(ScreenPtr pScreen)
         drmmode_map_cursor_bos(pScrn, &ms->drmmode);
     pixels = drmmode_map_front_bo(&ms->drmmode);
     if (!pixels)
-	return FALSE;
+        return FALSE;
 
     rootPixmap = pScreen->GetScreenPixmap(pScreen);
 
     if (ms->drmmode.shadow_enable)
-	pixels = ms->drmmode.shadow_fb;
-    
+        pixels = ms->drmmode.shadow_fb;
+
     if (!pScreen->ModifyPixmapHeader(rootPixmap, -1, -1, -1, -1, -1, pixels))
-	FatalError("Couldn't adjust screen pixmap\n");
+        FatalError("Couldn't adjust screen pixmap\n");
 
     if (ms->drmmode.shadow_enable) {
-	if (!shadowAdd(pScreen, rootPixmap, msUpdatePacked,
-		       msShadowWindow, 0, 0))
-	    return FALSE;
+        if (!shadowAdd(pScreen, rootPixmap, msUpdatePacked,
+                       msShadowWindow, 0, 0))
+            return FALSE;
     }
 
     ms->damage = DamageCreate(NULL, NULL, DamageReportNone, TRUE,
                               pScreen, rootPixmap);
 
     if (ms->damage) {
-	DamageRegister(&rootPixmap->drawable, ms->damage);
-	ms->dirty_enabled = TRUE;
-	xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Damage tracking initialized\n");
-    } else {
-	xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
-		   "Failed to create screen damage record\n");
-	return FALSE;
+        DamageRegister(&rootPixmap->drawable, ms->damage);
+        ms->dirty_enabled = TRUE;
+        xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Damage tracking initialized\n");
+    }
+    else {
+        xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+                   "Failed to create screen damage record\n");
+        return FALSE;
     }
     return ret;
 }
@@ -863,7 +885,7 @@ static Bool
 msShadowInit(ScreenPtr pScreen)
 {
     if (!shadowSetup(pScreen)) {
-	return FALSE;
+        return FALSE;
     }
     return TRUE;
 }
@@ -876,11 +898,11 @@ msSetSharedPixmapBacking(PixmapPtr ppix, void *fd_handle)
     modesettingPtr ms = modesettingPTR(scrn);
     Bool ret;
     int size = ppix->devKind * ppix->drawable.height;
-    int ihandle = (int)(long)fd_handle;
+    int ihandle = (int) (long) fd_handle;
 
     ret = drmmode_SetSlaveBO(ppix, &ms->drmmode, ihandle, ppix->devKind, size);
     if (ret == FALSE)
-	    return ret;
+        return ret;
 
     return TRUE;
 }
@@ -893,7 +915,7 @@ SetMaster(ScrnInfoPtr pScrn)
 
 #ifdef XF86_PDEV_SERVER_FD
     if (ms->pEnt->location.type == BUS_PLATFORM &&
-            (ms->pEnt->location.id.plat->flags & XF86_PDEV_SERVER_FD))
+        (ms->pEnt->location.id.plat->flags & XF86_PDEV_SERVER_FD))
         return TRUE;
 #endif
 
@@ -920,62 +942,64 @@ ScreenInit(ScreenPtr pScreen, int argc, char **argv)
     /* HW dependent - FIXME */
     pScrn->displayWidth = pScrn->virtualX;
     if (!drmmode_create_initial_bos(pScrn, &ms->drmmode))
-	return FALSE;
+        return FALSE;
 
     if (ms->drmmode.shadow_enable) {
-	ms->drmmode.shadow_fb = calloc(1, pScrn->displayWidth * pScrn->virtualY *
-			       ((pScrn->bitsPerPixel + 7) >> 3));
-	if (!ms->drmmode.shadow_fb)
-	    ms->drmmode.shadow_enable = FALSE;
-    }	
-    
+        ms->drmmode.shadow_fb =
+            calloc(1,
+                   pScrn->displayWidth * pScrn->virtualY *
+                   ((pScrn->bitsPerPixel + 7) >> 3));
+        if (!ms->drmmode.shadow_fb)
+            ms->drmmode.shadow_enable = FALSE;
+    }
+
     miClearVisualTypes();
 
     if (!miSetVisualTypes(pScrn->depth,
-			  miGetDefaultVisualMask(pScrn->depth),
-			  pScrn->rgbBits, pScrn->defaultVisual))
-	return FALSE;
+                          miGetDefaultVisualMask(pScrn->depth),
+                          pScrn->rgbBits, pScrn->defaultVisual))
+        return FALSE;
 
     if (!miSetPixmapDepths())
-	return FALSE;
+        return FALSE;
 
-    if (!dixRegisterScreenSpecificPrivateKey(pScreen, &ms->drmmode.pixmapPrivateKeyRec,
-        PRIVATE_PIXMAP, sizeof(msPixmapPrivRec))) { 
-	return FALSE;
+    if (!dixRegisterScreenSpecificPrivateKey
+        (pScreen, &ms->drmmode.pixmapPrivateKeyRec, PRIVATE_PIXMAP,
+         sizeof(msPixmapPrivRec))) {
+        return FALSE;
     }
 
     pScrn->memPhysBase = 0;
     pScrn->fbOffset = 0;
 
     if (!fbScreenInit(pScreen, NULL,
-		      pScrn->virtualX, pScrn->virtualY,
-		      pScrn->xDpi, pScrn->yDpi,
-		      pScrn->displayWidth, pScrn->bitsPerPixel))
-	return FALSE;
+                      pScrn->virtualX, pScrn->virtualY,
+                      pScrn->xDpi, pScrn->yDpi,
+                      pScrn->displayWidth, pScrn->bitsPerPixel))
+        return FALSE;
 
     if (pScrn->bitsPerPixel > 8) {
-	/* Fixup RGB ordering */
-	visual = pScreen->visuals + pScreen->numVisuals;
-	while (--visual >= pScreen->visuals) {
-	    if ((visual->class | DynamicClass) == DirectColor) {
-		visual->offsetRed = pScrn->offset.red;
-		visual->offsetGreen = pScrn->offset.green;
-		visual->offsetBlue = pScrn->offset.blue;
-		visual->redMask = pScrn->mask.red;
-		visual->greenMask = pScrn->mask.green;
-		visual->blueMask = pScrn->mask.blue;
-	    }
-	}
+        /* Fixup RGB ordering */
+        visual = pScreen->visuals + pScreen->numVisuals;
+        while (--visual >= pScreen->visuals) {
+            if ((visual->class | DynamicClass) == DirectColor) {
+                visual->offsetRed = pScrn->offset.red;
+                visual->offsetGreen = pScrn->offset.green;
+                visual->offsetBlue = pScrn->offset.blue;
+                visual->redMask = pScrn->mask.red;
+                visual->greenMask = pScrn->mask.green;
+                visual->blueMask = pScrn->mask.blue;
+            }
+        }
     }
 
     fbPictureInit(pScreen, NULL, 0);
 
     if (ms->drmmode.shadow_enable && !msShadowInit(pScreen)) {
-	xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
-		   "shadow fb init failed\n");
-	return FALSE;
+        xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "shadow fb init failed\n");
+        return FALSE;
     }
-  
+
     ms->createScreenResources = pScreen->CreateScreenResources;
     pScreen->CreateScreenResources = CreateScreenResources;
 
@@ -987,9 +1011,9 @@ ScreenInit(ScreenPtr pScreen, int argc, char **argv)
 
     /* Need to extend HWcursor support to handle mask interleave */
     if (!ms->drmmode.sw_cursor)
-	xf86_cursors_init(pScreen, ms->cursor_width, ms->cursor_height,
-			  HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_64 |
-			  HARDWARE_CURSOR_ARGB);
+        xf86_cursors_init(pScreen, ms->cursor_width, ms->cursor_height,
+                          HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_64 |
+                          HARDWARE_CURSOR_ARGB);
 
     /* Must force it before EnterVT, so we are in control of VT and
      * later memory should be bound when allocating, e.g rotate_mem */
@@ -1005,15 +1029,15 @@ ScreenInit(ScreenPtr pScreen, int argc, char **argv)
     pScreen->SetSharedPixmapBacking = msSetSharedPixmapBacking;
 
     if (!xf86CrtcScreenInit(pScreen))
-	return FALSE;
+        return FALSE;
 
     if (!miCreateDefColormap(pScreen))
-	return FALSE;
+        return FALSE;
 
     xf86DPMSInit(pScreen, xf86DPMSSet, 0);
 
     if (serverGeneration == 1)
-	xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options);
+        xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options);
 
     return EnterVT(pScrn);
 }
@@ -1036,13 +1060,14 @@ static void
 LeaveVT(ScrnInfoPtr pScrn)
 {
     modesettingPtr ms = modesettingPTR(pScrn);
+
     xf86_hide_cursors(pScrn);
 
     pScrn->vtSema = FALSE;
 
 #ifdef XF86_PDEV_SERVER_FD
     if (ms->pEnt->location.type == BUS_PLATFORM &&
-            (ms->pEnt->location.id.plat->flags & XF86_PDEV_SERVER_FD))
+        (ms->pEnt->location.id.plat->flags & XF86_PDEV_SERVER_FD))
         return;
 #endif
 
@@ -1062,7 +1087,7 @@ EnterVT(ScrnInfoPtr pScrn)
     SetMaster(pScrn);
 
     if (!drmmode_set_desired_modes(pScrn, &ms->drmmode))
-	return FALSE;
+        return FALSE;
 
     return TRUE;
 }
@@ -1080,15 +1105,15 @@ CloseScreen(ScreenPtr pScreen)
     modesettingPtr ms = modesettingPTR(pScrn);
 
     if (ms->damage) {
-	DamageUnregister(ms->damage);
-	DamageDestroy(ms->damage);
-	ms->damage = NULL;
+        DamageUnregister(ms->damage);
+        DamageDestroy(ms->damage);
+        ms->damage = NULL;
     }
 
     if (ms->drmmode.shadow_enable) {
-	shadowRemove(pScreen, pScreen->GetScreenPixmap(pScreen));
-	free(ms->drmmode.shadow_fb);
-	ms->drmmode.shadow_fb = NULL;
+        shadowRemove(pScreen, pScreen->GetScreenPixmap(pScreen));
+        free(ms->drmmode.shadow_fb);
+        ms->drmmode.shadow_fb = NULL;
     }
     drmmode_uevent_fini(pScrn, &ms->drmmode);
 
diff --git a/hw/xfree86/drivers/modesetting/driver.h b/hw/xfree86/drivers/modesetting/driver.h
index 450b29c..8a920b9 100644
--- a/hw/xfree86/drivers/modesetting/driver.h
+++ b/hw/xfree86/drivers/modesetting/driver.h
@@ -35,16 +35,14 @@
 #include "drmmode_display.h"
 #define DRV_ERROR(msg)	xf86DrvMsg(pScrn->scrnIndex, X_ERROR, msg);
 
-typedef struct
-{
+typedef struct {
     int lastInstance;
     int refCount;
     ScrnInfoPtr pScrn_1;
     ScrnInfoPtr pScrn_2;
 } EntRec, *EntPtr;
 
-typedef struct _modesettingRec
-{
+typedef struct _modesettingRec {
     int fd;
 
     EntPtr entityPrivate;
diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c b/hw/xfree86/drivers/modesetting/drmmode_display.c
index 9723ccd..ca02a4d 100644
--- a/hw/xfree86/drivers/modesetting/drmmode_display.c
+++ b/hw/xfree86/drivers/modesetting/drmmode_display.c
@@ -49,181 +49,183 @@
 
 #include "driver.h"
 
-static struct dumb_bo *dumb_bo_create(int fd,
-			  const unsigned width, const unsigned height,
-			  const unsigned bpp)
+static struct dumb_bo *
+dumb_bo_create(int fd,
+               const unsigned width, const unsigned height, const unsigned bpp)
 {
-	struct drm_mode_create_dumb arg;
-	struct dumb_bo *bo;
-	int ret;
-
-	bo = calloc(1, sizeof(*bo));
-	if (!bo)
-		return NULL;
-
-	memset(&arg, 0, sizeof(arg));
-	arg.width = width;
-	arg.height = height;
-	arg.bpp = bpp;
-	
-	ret = drmIoctl(fd, DRM_IOCTL_MODE_CREATE_DUMB, &arg);
-	if (ret)
-		goto err_free;
-
-	bo->handle = arg.handle;
-	bo->size = arg.size;
-	bo->pitch = arg.pitch;
-
-	return bo;
+    struct drm_mode_create_dumb arg;
+    struct dumb_bo *bo;
+    int ret;
+
+    bo = calloc(1, sizeof(*bo));
+    if (!bo)
+        return NULL;
+
+    memset(&arg, 0, sizeof(arg));
+    arg.width = width;
+    arg.height = height;
+    arg.bpp = bpp;
+
+    ret = drmIoctl(fd, DRM_IOCTL_MODE_CREATE_DUMB, &arg);
+    if (ret)
+        goto err_free;
+
+    bo->handle = arg.handle;
+    bo->size = arg.size;
+    bo->pitch = arg.pitch;
+
+    return bo;
  err_free:
-	free(bo);
-	return NULL;
+    free(bo);
+    return NULL;
 }
 
-static int dumb_bo_map(int fd, struct dumb_bo *bo)
+static int
+dumb_bo_map(int fd, struct dumb_bo *bo)
 {
-	struct drm_mode_map_dumb arg;
-	int ret;
-	void *map;
+    struct drm_mode_map_dumb arg;
+    int ret;
+    void *map;
 
-	if (bo->ptr) {
-		bo->map_count++;
-		return 0;
-	}
+    if (bo->ptr) {
+        bo->map_count++;
+        return 0;
+    }
 
-	memset(&arg, 0, sizeof(arg));
-	arg.handle = bo->handle;
+    memset(&arg, 0, sizeof(arg));
+    arg.handle = bo->handle;
 
-	ret = drmIoctl(fd, DRM_IOCTL_MODE_MAP_DUMB, &arg);
-	if (ret)
-		return ret;
+    ret = drmIoctl(fd, DRM_IOCTL_MODE_MAP_DUMB, &arg);
+    if (ret)
+        return ret;
 
-	map = mmap(0, bo->size, PROT_READ | PROT_WRITE, MAP_SHARED,
-		   fd, arg.offset);
-	if (map == MAP_FAILED)
-		return -errno;
+    map = mmap(0, bo->size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, arg.offset);
+    if (map == MAP_FAILED)
+        return -errno;
 
-	bo->ptr = map;
-	return 0;
+    bo->ptr = map;
+    return 0;
 }
 
 #if 0
-static int dumb_bo_unmap(int fd, struct dumb_bo *bo)
+static int
+dumb_bo_unmap(int fd, struct dumb_bo *bo)
 {
-	bo->map_count--;
-	return 0;
+    bo->map_count--;
+    return 0;
 }
 #endif
 
-static int dumb_bo_destroy(int fd, struct dumb_bo *bo)
+static int
+dumb_bo_destroy(int fd, struct dumb_bo *bo)
 {
-	struct drm_mode_destroy_dumb arg;
-	int ret;
-	
-	if (bo->ptr) {
-		munmap(bo->ptr, bo->size);
-		bo->ptr = NULL;
-	}
-
-	memset(&arg, 0, sizeof(arg));
-	arg.handle = bo->handle;
-	ret = drmIoctl(fd, DRM_IOCTL_MODE_DESTROY_DUMB, &arg);
-	if (ret)
-		return -errno;
-
-	free(bo);
-	return 0;
+    struct drm_mode_destroy_dumb arg;
+    int ret;
+
+    if (bo->ptr) {
+        munmap(bo->ptr, bo->size);
+        bo->ptr = NULL;
+    }
+
+    memset(&arg, 0, sizeof(arg));
+    arg.handle = bo->handle;
+    ret = drmIoctl(fd, DRM_IOCTL_MODE_DESTROY_DUMB, &arg);
+    if (ret)
+        return -errno;
+
+    free(bo);
+    return 0;
 }
 
-static struct dumb_bo *dumb_get_bo_from_handle(int fd, int handle, int pitch, int size)
+static struct dumb_bo *
+dumb_get_bo_from_handle(int fd, int handle, int pitch, int size)
 {
-  	struct dumb_bo *bo;
-	int ret;
-
-	bo = calloc(1, sizeof(*bo));
-	if (!bo)
-		return NULL;
-
-	ret = drmPrimeFDToHandle(fd, handle, &bo->handle);
-	if (ret) {
-		free(bo);
-		return NULL;
-	}
-	bo->pitch = pitch;
-	bo->size = size;
-	return bo;
+    struct dumb_bo *bo;
+    int ret;
+
+    bo = calloc(1, sizeof(*bo));
+    if (!bo)
+        return NULL;
+
+    ret = drmPrimeFDToHandle(fd, handle, &bo->handle);
+    if (ret) {
+        free(bo);
+        return NULL;
+    }
+    bo->pitch = pitch;
+    bo->size = size;
+    return bo;
 }
 
-Bool drmmode_SetSlaveBO(PixmapPtr ppix,
-			drmmode_ptr drmmode, 
-			int fd_handle, int pitch, int size)
+Bool
+drmmode_SetSlaveBO(PixmapPtr ppix,
+                   drmmode_ptr drmmode, int fd_handle, int pitch, int size)
 {
-    	msPixmapPrivPtr ppriv = msGetPixmapPriv(drmmode, ppix);
+    msPixmapPrivPtr ppriv = msGetPixmapPriv(drmmode, ppix);
 
-	ppriv->backing_bo = dumb_get_bo_from_handle(drmmode->fd, fd_handle, pitch, size);
-	if (!ppriv->backing_bo)
-		return FALSE;
+    ppriv->backing_bo =
+        dumb_get_bo_from_handle(drmmode->fd, fd_handle, pitch, size);
+    if (!ppriv->backing_bo)
+        return FALSE;
 
-	close(fd_handle);
-	return TRUE;
+    close(fd_handle);
+    return TRUE;
 }
 
 static void
-drmmode_ConvertFromKMode(ScrnInfoPtr	scrn,
-		     drmModeModeInfo *kmode,
-		     DisplayModePtr	mode)
+drmmode_ConvertFromKMode(ScrnInfoPtr scrn,
+                         drmModeModeInfo * kmode, DisplayModePtr mode)
 {
-	memset(mode, 0, sizeof(DisplayModeRec));
-	mode->status = MODE_OK;
-
-	mode->Clock = kmode->clock;
-
-	mode->HDisplay = kmode->hdisplay;
-	mode->HSyncStart = kmode->hsync_start;
-	mode->HSyncEnd = kmode->hsync_end;
-	mode->HTotal = kmode->htotal;
-	mode->HSkew = kmode->hskew;
-
-	mode->VDisplay = kmode->vdisplay;
-	mode->VSyncStart = kmode->vsync_start;
-	mode->VSyncEnd = kmode->vsync_end;
-	mode->VTotal = kmode->vtotal;
-	mode->VScan = kmode->vscan;
-
-	mode->Flags = kmode->flags; //& FLAG_BITS;
-	mode->name = strdup(kmode->name);
-
-	if (kmode->type & DRM_MODE_TYPE_DRIVER)
-		mode->type = M_T_DRIVER;
-	if (kmode->type & DRM_MODE_TYPE_PREFERRED)
-		mode->type |= M_T_PREFERRED;
-	xf86SetModeCrtc (mode, scrn->adjustFlags);
+    memset(mode, 0, sizeof(DisplayModeRec));
+    mode->status = MODE_OK;
+
+    mode->Clock = kmode->clock;
+
+    mode->HDisplay = kmode->hdisplay;
+    mode->HSyncStart = kmode->hsync_start;
+    mode->HSyncEnd = kmode->hsync_end;
+    mode->HTotal = kmode->htotal;
+    mode->HSkew = kmode->hskew;
+
+    mode->VDisplay = kmode->vdisplay;
+    mode->VSyncStart = kmode->vsync_start;
+    mode->VSyncEnd = kmode->vsync_end;
+    mode->VTotal = kmode->vtotal;
+    mode->VScan = kmode->vscan;
+
+    mode->Flags = kmode->flags; //& FLAG_BITS;
+    mode->name = strdup(kmode->name);
+
+    if (kmode->type & DRM_MODE_TYPE_DRIVER)
+        mode->type = M_T_DRIVER;
+    if (kmode->type & DRM_MODE_TYPE_PREFERRED)
+        mode->type |= M_T_PREFERRED;
+    xf86SetModeCrtc(mode, scrn->adjustFlags);
 }
 
 static void
-drmmode_ConvertToKMode(ScrnInfoPtr	scrn,
-		     drmModeModeInfo *kmode,
-		     DisplayModePtr	mode)
+drmmode_ConvertToKMode(ScrnInfoPtr scrn,
+                       drmModeModeInfo * kmode, DisplayModePtr mode)
 {
-	memset(kmode, 0, sizeof(*kmode));
-
-	kmode->clock = mode->Clock;
-	kmode->hdisplay = mode->HDisplay;
-	kmode->hsync_start = mode->HSyncStart;
-	kmode->hsync_end = mode->HSyncEnd;
-	kmode->htotal = mode->HTotal;
-	kmode->hskew = mode->HSkew;
-
-	kmode->vdisplay = mode->VDisplay;
-	kmode->vsync_start = mode->VSyncStart;
-	kmode->vsync_end = mode->VSyncEnd;
-	kmode->vtotal = mode->VTotal;
-	kmode->vscan = mode->VScan;
-
-	kmode->flags = mode->Flags; //& FLAG_BITS;
-	if (mode->name)
-		strncpy(kmode->name, mode->name, DRM_DISPLAY_MODE_LEN);
-	kmode->name[DRM_DISPLAY_MODE_LEN-1] = 0;
+    memset(kmode, 0, sizeof(*kmode));
+
+    kmode->clock = mode->Clock;
+    kmode->hdisplay = mode->HDisplay;
+    kmode->hsync_start = mode->HSyncStart;
+    kmode->hsync_end = mode->HSyncEnd;
+    kmode->htotal = mode->HTotal;
+    kmode->hskew = mode->HSkew;
+
+    kmode->vdisplay = mode->VDisplay;
+    kmode->vsync_start = mode->VSyncStart;
+    kmode->vsync_end = mode->VSyncEnd;
+    kmode->vtotal = mode->VTotal;
+    kmode->vscan = mode->VScan;
+
+    kmode->flags = mode->Flags; //& FLAG_BITS;
+    if (mode->name)
+        strncpy(kmode->name, mode->name, DRM_DISPLAY_MODE_LEN);
+    kmode->name[DRM_DISPLAY_MODE_LEN - 1] = 0;
 
 }
 
@@ -231,331 +233,337 @@ static void
 drmmode_crtc_dpms(xf86CrtcPtr crtc, int mode)
 {
 #if 0
-	xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(crtc->scrn);
-//	drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
-//	drmmode_ptr drmmode = drmmode_crtc->drmmode;
-
-	/* bonghits in the randr 1.2 - uses dpms to disable crtc - bad buzz */
-	if (mode == DPMSModeOff) {
-//		drmModeSetCrtc(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id,
-//			       0, 0, 0, NULL, 0, NULL);
-	}
+    xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(crtc->scrn);
+
+//      drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+//      drmmode_ptr drmmode = drmmode_crtc->drmmode;
+
+    /* bonghits in the randr 1.2 - uses dpms to disable crtc - bad buzz */
+    if (mode == DPMSModeOff) {
+//              drmModeSetCrtc(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id,
+//                             0, 0, 0, NULL, 0, NULL);
+    }
 #endif
 }
 
 #if 0
 static PixmapPtr
-create_pixmap_for_fbcon(drmmode_ptr drmmode,
-			ScrnInfoPtr pScrn, int crtc_id)
+create_pixmap_for_fbcon(drmmode_ptr drmmode, ScrnInfoPtr pScrn, int crtc_id)
 {
-	xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
-	drmmode_crtc_private_ptr drmmode_crtc;
-	ScreenPtr pScreen = pScrn->pScreen;
-	PixmapPtr pixmap;
-	struct radeon_bo *bo;
-	drmModeFBPtr fbcon;
-	struct drm_gem_flink flink;
-
-	drmmode_crtc = xf86_config->crtc[crtc_id]->driver_private;
-
-	fbcon = drmModeGetFB(drmmode->fd, drmmode_crtc->mode_crtc->buffer_id);
-	if (fbcon == NULL)
-		return NULL;
-
-	flink.handle = fbcon->handle;
-	if (ioctl(drmmode->fd, DRM_IOCTL_GEM_FLINK, &flink) < 0) {
-		xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
-			   "Couldn't flink fbcon handle\n");
-		return NULL;
-	}
-
-	bo = radeon_bo_open(drmmode->bufmgr, flink.name, 0, 0, 0, 0);
-	if (bo == NULL) {
-		xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
-			   "Couldn't allocate bo for fbcon handle\n");
-		return NULL;
-	}
-
-	pixmap = drmmode_create_bo_pixmap(pScreen, fbcon->width, fbcon->height,
-					  fbcon->depth, fbcon->bpp,
-					  fbcon->pitch, bo);
-	if (!pixmap) 
-		return NULL;
-
-	radeon_bo_unref(bo);
-	drmModeFreeFB(fbcon);
-	return pixmap;
+    xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
+    drmmode_crtc_private_ptr drmmode_crtc;
+    ScreenPtr pScreen = pScrn->pScreen;
+    PixmapPtr pixmap;
+    struct radeon_bo *bo;
+    drmModeFBPtr fbcon;
+    struct drm_gem_flink flink;
+
+    drmmode_crtc = xf86_config->crtc[crtc_id]->driver_private;
+
+    fbcon = drmModeGetFB(drmmode->fd, drmmode_crtc->mode_crtc->buffer_id);
+    if (fbcon == NULL)
+        return NULL;
+
+    flink.handle = fbcon->handle;
+    if (ioctl(drmmode->fd, DRM_IOCTL_GEM_FLINK, &flink) < 0) {
+        xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Couldn't flink fbcon handle\n");
+        return NULL;
+    }
+
+    bo = radeon_bo_open(drmmode->bufmgr, flink.name, 0, 0, 0, 0);
+    if (bo == NULL) {
+        xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+                   "Couldn't allocate bo for fbcon handle\n");
+        return NULL;
+    }
+
+    pixmap = drmmode_create_bo_pixmap(pScreen, fbcon->width, fbcon->height,
+                                      fbcon->depth, fbcon->bpp,
+                                      fbcon->pitch, bo);
+    if (!pixmap)
+        return NULL;
+
+    radeon_bo_unref(bo);
+    drmModeFreeFB(fbcon);
+    return pixmap;
 }
 
 #endif
 
 static Bool
 drmmode_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode,
-		     Rotation rotation, int x, int y)
+                       Rotation rotation, int x, int y)
 {
-	ScrnInfoPtr pScrn = crtc->scrn;
-	xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(crtc->scrn);
-	drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
-	drmmode_ptr drmmode = drmmode_crtc->drmmode;
-	int saved_x, saved_y;
-	Rotation saved_rotation;
-	DisplayModeRec saved_mode;
-	uint32_t *output_ids;
-	int output_count = 0;
-	Bool ret = TRUE;
-	int i;
-	uint32_t fb_id;
-	drmModeModeInfo kmode;
-	int height;
-
-	height = pScrn->virtualY;
-
-	if (drmmode->fb_id == 0) {
-		ret = drmModeAddFB(drmmode->fd,
-				   pScrn->virtualX, height,
-                                   pScrn->depth, pScrn->bitsPerPixel,
-				   drmmode->front_bo->pitch,
-				   drmmode->front_bo->handle,
-                                   &drmmode->fb_id);
-                if (ret < 0) {
-                        ErrorF("failed to add fb %d\n", ret);
-                        return FALSE;
-                }
+    ScrnInfoPtr pScrn = crtc->scrn;
+    xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(crtc->scrn);
+    drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+    drmmode_ptr drmmode = drmmode_crtc->drmmode;
+    int saved_x, saved_y;
+    Rotation saved_rotation;
+    DisplayModeRec saved_mode;
+    uint32_t *output_ids;
+    int output_count = 0;
+    Bool ret = TRUE;
+    int i;
+    uint32_t fb_id;
+    drmModeModeInfo kmode;
+    int height;
+
+    height = pScrn->virtualY;
+
+    if (drmmode->fb_id == 0) {
+        ret = drmModeAddFB(drmmode->fd,
+                           pScrn->virtualX, height,
+                           pScrn->depth, pScrn->bitsPerPixel,
+                           drmmode->front_bo->pitch,
+                           drmmode->front_bo->handle, &drmmode->fb_id);
+        if (ret < 0) {
+            ErrorF("failed to add fb %d\n", ret);
+            return FALSE;
+        }
+    }
+
+    saved_mode = crtc->mode;
+    saved_x = crtc->x;
+    saved_y = crtc->y;
+    saved_rotation = crtc->rotation;
+
+    if (mode) {
+        crtc->mode = *mode;
+        crtc->x = x;
+        crtc->y = y;
+        crtc->rotation = rotation;
+        crtc->transformPresent = FALSE;
+    }
+
+    output_ids = calloc(sizeof(uint32_t), xf86_config->num_output);
+    if (!output_ids) {
+        ret = FALSE;
+        goto done;
+    }
+
+    if (mode) {
+        for (i = 0; i < xf86_config->num_output; i++) {
+            xf86OutputPtr output = xf86_config->output[i];
+            drmmode_output_private_ptr drmmode_output;
+
+            if (output->crtc != crtc)
+                continue;
+
+            drmmode_output = output->driver_private;
+            output_ids[output_count] =
+                drmmode_output->mode_output->connector_id;
+            output_count++;
         }
 
-	saved_mode = crtc->mode;
-	saved_x = crtc->x;
-	saved_y = crtc->y;
-	saved_rotation = crtc->rotation;
-
-	if (mode) {
-		crtc->mode = *mode;
-		crtc->x = x;
-		crtc->y = y;
-		crtc->rotation = rotation;
-		crtc->transformPresent = FALSE;
-	}
-
-	output_ids = calloc(sizeof(uint32_t), xf86_config->num_output);
-	if (!output_ids) {
-		ret = FALSE;
-		goto done;
-	}
-
-	if (mode) {
-		for (i = 0; i < xf86_config->num_output; i++) {
-			xf86OutputPtr output = xf86_config->output[i];
-			drmmode_output_private_ptr drmmode_output;
-
-			if (output->crtc != crtc)
-				continue;
-
-			drmmode_output = output->driver_private;
-			output_ids[output_count] = drmmode_output->mode_output->connector_id;
-			output_count++;
-		}
-
-		if (!xf86CrtcRotate(crtc)) {
-			goto done;
-		}
-		crtc->funcs->gamma_set(crtc, crtc->gamma_red, crtc->gamma_green,
-				       crtc->gamma_blue, crtc->gamma_size);
-		
-		drmmode_ConvertToKMode(crtc->scrn, &kmode, mode);
-
-		fb_id = drmmode->fb_id;
-		if (crtc->randr_crtc->scanout_pixmap) {
-    			msPixmapPrivPtr ppriv = msGetPixmapPriv(drmmode, crtc->randr_crtc->scanout_pixmap);
-			fb_id = ppriv->fb_id;
-			x = y = 0;
-		} else if (drmmode_crtc->rotate_fb_id) {
-			fb_id = drmmode_crtc->rotate_fb_id;
-			x = y = 0;
-		}
-		ret = drmModeSetCrtc(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id,
-				     fb_id, x, y, output_ids, output_count, &kmode);
-		if (ret)
-			xf86DrvMsg(crtc->scrn->scrnIndex, X_ERROR,
-				   "failed to set mode: %s", strerror(-ret));
-		else
-			ret = TRUE;
-
-		if (crtc->scrn->pScreen)
-			xf86CrtcSetScreenSubpixelOrder(crtc->scrn->pScreen);
-		/* go through all the outputs and force DPMS them back on? */
-		for (i = 0; i < xf86_config->num_output; i++) {
-			xf86OutputPtr output = xf86_config->output[i];
-
-			if (output->crtc != crtc)
-				continue;
-
-			output->funcs->dpms(output, DPMSModeOn);
-		}
-	}
+        if (!xf86CrtcRotate(crtc)) {
+            goto done;
+        }
+        crtc->funcs->gamma_set(crtc, crtc->gamma_red, crtc->gamma_green,
+                               crtc->gamma_blue, crtc->gamma_size);
+
+        drmmode_ConvertToKMode(crtc->scrn, &kmode, mode);
+
+        fb_id = drmmode->fb_id;
+        if (crtc->randr_crtc->scanout_pixmap) {
+            msPixmapPrivPtr ppriv =
+                msGetPixmapPriv(drmmode, crtc->randr_crtc->scanout_pixmap);
+            fb_id = ppriv->fb_id;
+            x = y = 0;
+        }
+        else if (drmmode_crtc->rotate_fb_id) {
+            fb_id = drmmode_crtc->rotate_fb_id;
+            x = y = 0;
+        }
+        ret = drmModeSetCrtc(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id,
+                             fb_id, x, y, output_ids, output_count, &kmode);
+        if (ret)
+            xf86DrvMsg(crtc->scrn->scrnIndex, X_ERROR,
+                       "failed to set mode: %s", strerror(-ret));
+        else
+            ret = TRUE;
+
+        if (crtc->scrn->pScreen)
+            xf86CrtcSetScreenSubpixelOrder(crtc->scrn->pScreen);
+        /* go through all the outputs and force DPMS them back on? */
+        for (i = 0; i < xf86_config->num_output; i++) {
+            xf86OutputPtr output = xf86_config->output[i];
+
+            if (output->crtc != crtc)
+                continue;
+
+            output->funcs->dpms(output, DPMSModeOn);
+        }
+    }
 
 #if 0
-	if (pScrn->pScreen &&
-		!xf86ReturnOptValBool(info->Options, OPTION_SW_CURSOR, FALSE))
-		xf86_reload_cursors(pScrn->pScreen);
+    if (pScrn->pScreen &&
+        !xf86ReturnOptValBool(info->Options, OPTION_SW_CURSOR, FALSE))
+        xf86_reload_cursors(pScrn->pScreen);
 #endif
-done:
-	if (!ret) {
-		crtc->x = saved_x;
-		crtc->y = saved_y;
-		crtc->rotation = saved_rotation;
-		crtc->mode = saved_mode;
-	}
+ done:
+    if (!ret) {
+        crtc->x = saved_x;
+        crtc->y = saved_y;
+        crtc->rotation = saved_rotation;
+        crtc->mode = saved_mode;
+    }
 #if defined(XF86_CRTC_VERSION) && XF86_CRTC_VERSION >= 3
-	else
-		crtc->active = TRUE;
+    else
+        crtc->active = TRUE;
 #endif
 
-	return ret;
+    return ret;
 }
 
 static void
-drmmode_set_cursor_colors (xf86CrtcPtr crtc, int bg, int fg)
+drmmode_set_cursor_colors(xf86CrtcPtr crtc, int bg, int fg)
 {
 
 }
 
 static void
-drmmode_set_cursor_position (xf86CrtcPtr crtc, int x, int y)
+drmmode_set_cursor_position(xf86CrtcPtr crtc, int x, int y)
 {
-	drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
-	drmmode_ptr drmmode = drmmode_crtc->drmmode;
+    drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+    drmmode_ptr drmmode = drmmode_crtc->drmmode;
 
-	drmModeMoveCursor(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id, x, y);
+    drmModeMoveCursor(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id, x, y);
 }
 
 static void
-drmmode_load_cursor_argb (xf86CrtcPtr crtc, CARD32 *image)
+drmmode_load_cursor_argb(xf86CrtcPtr crtc, CARD32 *image)
 {
-	modesettingPtr ms = modesettingPTR(crtc->scrn);
-	drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
-	int i;
-	uint32_t *ptr;
-	uint32_t handle = drmmode_crtc->cursor_bo->handle;
-	int ret;
-	/* cursor should be mapped already */
-	ptr = (uint32_t *)(drmmode_crtc->cursor_bo->ptr);
-
-	for (i = 0; i < ms->cursor_width * ms->cursor_height; i++)
-		ptr[i] = image[i];// cpu_to_le32(image[i]);
-
-	ret = drmModeSetCursor(drmmode_crtc->drmmode->fd, drmmode_crtc->mode_crtc->crtc_id, handle,
-			       ms->cursor_width, ms->cursor_height);
-	if (ret) {
-		xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(crtc->scrn);
-		xf86CursorInfoPtr	cursor_info = xf86_config->cursor_info;
-		
-		cursor_info->MaxWidth = cursor_info->MaxHeight = 0;
-		drmmode_crtc->drmmode->sw_cursor = TRUE;
-		/* fallback to swcursor */
-	}
+    modesettingPtr ms = modesettingPTR(crtc->scrn);
+    drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+    int i;
+    uint32_t *ptr;
+    uint32_t handle = drmmode_crtc->cursor_bo->handle;
+    int ret;
+
+    /* cursor should be mapped already */
+    ptr = (uint32_t *) (drmmode_crtc->cursor_bo->ptr);
+
+    for (i = 0; i < ms->cursor_width * ms->cursor_height; i++)
+        ptr[i] = image[i];      // cpu_to_le32(image[i]);
+
+    ret =
+        drmModeSetCursor(drmmode_crtc->drmmode->fd,
+                         drmmode_crtc->mode_crtc->crtc_id, handle,
+                         ms->cursor_width, ms->cursor_height);
+    if (ret) {
+        xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(crtc->scrn);
+        xf86CursorInfoPtr cursor_info = xf86_config->cursor_info;
+
+        cursor_info->MaxWidth = cursor_info->MaxHeight = 0;
+        drmmode_crtc->drmmode->sw_cursor = TRUE;
+        /* fallback to swcursor */
+    }
 }
 
-
 static void
-drmmode_hide_cursor (xf86CrtcPtr crtc)
+drmmode_hide_cursor(xf86CrtcPtr crtc)
 {
-	modesettingPtr ms = modesettingPTR(crtc->scrn);
-	drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
-	drmmode_ptr drmmode = drmmode_crtc->drmmode;
+    modesettingPtr ms = modesettingPTR(crtc->scrn);
+    drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+    drmmode_ptr drmmode = drmmode_crtc->drmmode;
 
-	drmModeSetCursor(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id, 0,
-			 ms->cursor_width, ms->cursor_height);
+    drmModeSetCursor(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id, 0,
+                     ms->cursor_width, ms->cursor_height);
 
 }
 
 static void
-drmmode_show_cursor (xf86CrtcPtr crtc)
+drmmode_show_cursor(xf86CrtcPtr crtc)
 {
-	modesettingPtr ms = modesettingPTR(crtc->scrn);
-	drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
-	drmmode_ptr drmmode = drmmode_crtc->drmmode;
-	uint32_t handle = drmmode_crtc->cursor_bo->handle;
-       static Bool use_set_cursor2 = TRUE;
-
-       if (use_set_cursor2) {
-               xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(crtc->scrn);
-               CursorPtr cursor = xf86_config->cursor;
-               int ret;
-               ret = drmModeSetCursor2(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id, handle, ms->cursor_width, ms->cursor_height, cursor->bits->xhot, cursor->bits->yhot);
-               if (ret == -EINVAL)
-                       use_set_cursor2 = FALSE;
-               else
-                       return;
-       }
-
-	drmModeSetCursor(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id, handle,
-			 ms->cursor_width, ms->cursor_height);
+    modesettingPtr ms = modesettingPTR(crtc->scrn);
+    drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+    drmmode_ptr drmmode = drmmode_crtc->drmmode;
+    uint32_t handle = drmmode_crtc->cursor_bo->handle;
+    static Bool use_set_cursor2 = TRUE;
+
+    if (use_set_cursor2) {
+        xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(crtc->scrn);
+        CursorPtr cursor = xf86_config->cursor;
+        int ret;
+
+        ret =
+            drmModeSetCursor2(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id,
+                              handle, ms->cursor_width, ms->cursor_height,
+                              cursor->bits->xhot, cursor->bits->yhot);
+        if (ret == -EINVAL)
+            use_set_cursor2 = FALSE;
+        else
+            return;
+    }
+
+    drmModeSetCursor(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id, handle,
+                     ms->cursor_width, ms->cursor_height);
 }
 
 static void
-drmmode_crtc_gamma_set(xf86CrtcPtr crtc, uint16_t *red, uint16_t *green,
-                      uint16_t *blue, int size)
+drmmode_crtc_gamma_set(xf86CrtcPtr crtc, uint16_t * red, uint16_t * green,
+                       uint16_t * blue, int size)
 {
-	drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
-	drmmode_ptr drmmode = drmmode_crtc->drmmode;
+    drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+    drmmode_ptr drmmode = drmmode_crtc->drmmode;
 
-	drmModeCrtcSetGamma(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id,
-			    size, red, green, blue);
+    drmModeCrtcSetGamma(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id,
+                        size, red, green, blue);
 }
 
 static Bool
 drmmode_set_scanout_pixmap(xf86CrtcPtr crtc, PixmapPtr ppix)
 {
-	drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
-	drmmode_ptr drmmode = drmmode_crtc->drmmode;
-	msPixmapPrivPtr ppriv;
-	void *ptr;
-
-	if (!ppix) {
-		if (crtc->randr_crtc->scanout_pixmap) {
-    			ppriv = msGetPixmapPriv(drmmode, crtc->randr_crtc->scanout_pixmap);
-			drmModeRmFB(drmmode->fd, ppriv->fb_id);
-		}
-		if (drmmode_crtc->slave_damage) {
-			DamageUnregister(drmmode_crtc->slave_damage);
-			drmmode_crtc->slave_damage = NULL;
-		}
-		return TRUE;
-	}
-
-	ppriv = msGetPixmapPriv(drmmode, ppix);
-	if (!drmmode_crtc->slave_damage) {
-		drmmode_crtc->slave_damage = DamageCreate(NULL, NULL,
-							  DamageReportNone,
-							  TRUE,
-							  crtc->randr_crtc->pScreen,
-							  NULL);
-	}
-	ptr = drmmode_map_slave_bo(drmmode, ppriv);
-	ppix->devPrivate.ptr = ptr;
-	DamageRegister(&ppix->drawable, drmmode_crtc->slave_damage);
-
-	if (ppriv->fb_id == 0) {
-                drmModeAddFB(drmmode->fd, ppix->drawable.width,
-                             ppix->drawable.height,
-                             ppix->drawable.depth,
-                             ppix->drawable.bitsPerPixel,
-                             ppix->devKind,
-                             ppriv->backing_bo->handle,
-                             &ppriv->fb_id);
-	}
-	return TRUE;
+    drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+    drmmode_ptr drmmode = drmmode_crtc->drmmode;
+    msPixmapPrivPtr ppriv;
+    void *ptr;
+
+    if (!ppix) {
+        if (crtc->randr_crtc->scanout_pixmap) {
+            ppriv = msGetPixmapPriv(drmmode, crtc->randr_crtc->scanout_pixmap);
+            drmModeRmFB(drmmode->fd, ppriv->fb_id);
+        }
+        if (drmmode_crtc->slave_damage) {
+            DamageUnregister(drmmode_crtc->slave_damage);
+            drmmode_crtc->slave_damage = NULL;
+        }
+        return TRUE;
+    }
+
+    ppriv = msGetPixmapPriv(drmmode, ppix);
+    if (!drmmode_crtc->slave_damage) {
+        drmmode_crtc->slave_damage = DamageCreate(NULL, NULL,
+                                                  DamageReportNone,
+                                                  TRUE,
+                                                  crtc->randr_crtc->pScreen,
+                                                  NULL);
+    }
+    ptr = drmmode_map_slave_bo(drmmode, ppriv);
+    ppix->devPrivate.ptr = ptr;
+    DamageRegister(&ppix->drawable, drmmode_crtc->slave_damage);
+
+    if (ppriv->fb_id == 0) {
+        drmModeAddFB(drmmode->fd, ppix->drawable.width,
+                     ppix->drawable.height,
+                     ppix->drawable.depth,
+                     ppix->drawable.bitsPerPixel,
+                     ppix->devKind, ppriv->backing_bo->handle, &ppriv->fb_id);
+    }
+    return TRUE;
 }
 
-static void *drmmode_shadow_allocate(xf86CrtcPtr crtc, int width, int height)
+static void *
+drmmode_shadow_allocate(xf86CrtcPtr crtc, int width, int height)
 {
-	return NULL;
+    return NULL;
 }
 
-static PixmapPtr drmmode_shadow_create(xf86CrtcPtr crtc, void *data, int width,
-				       int height)
+static PixmapPtr
+drmmode_shadow_create(xf86CrtcPtr crtc, void *data, int width, int height)
 {
-	return NULL;
+    return NULL;
 }
 
 static const xf86CrtcFuncsRec drmmode_crtc_funcs = {
@@ -568,7 +576,7 @@ static const xf86CrtcFuncsRec drmmode_crtc_funcs = {
     .load_cursor_argb = drmmode_load_cursor_argb,
 
     .gamma_set = drmmode_crtc_gamma_set,
-    .destroy = NULL, /* XXX */
+    .destroy = NULL,            /* XXX */
     .set_scanout_pixmap = drmmode_set_scanout_pixmap,
     .shadow_allocate = drmmode_shadow_allocate,
     .shadow_create = drmmode_shadow_create,
@@ -577,222 +585,224 @@ static const xf86CrtcFuncsRec drmmode_crtc_funcs = {
 static void
 drmmode_crtc_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int num)
 {
-	xf86CrtcPtr crtc;
-	drmmode_crtc_private_ptr drmmode_crtc;
-
-	crtc = xf86CrtcCreate(pScrn, &drmmode_crtc_funcs);
-	if (crtc == NULL)
-		return;
-
-	drmmode_crtc = xnfcalloc(sizeof(drmmode_crtc_private_rec), 1);
-	drmmode_crtc->mode_crtc = drmModeGetCrtc(drmmode->fd, drmmode->mode_res->crtcs[num]);
-	drmmode_crtc->drmmode = drmmode;
-	crtc->driver_private = drmmode_crtc;
+    xf86CrtcPtr crtc;
+    drmmode_crtc_private_ptr drmmode_crtc;
+
+    crtc = xf86CrtcCreate(pScrn, &drmmode_crtc_funcs);
+    if (crtc == NULL)
+        return;
+
+    drmmode_crtc = xnfcalloc(sizeof(drmmode_crtc_private_rec), 1);
+    drmmode_crtc->mode_crtc =
+        drmModeGetCrtc(drmmode->fd, drmmode->mode_res->crtcs[num]);
+    drmmode_crtc->drmmode = drmmode;
+    crtc->driver_private = drmmode_crtc;
 }
 
 static xf86OutputStatus
 drmmode_output_detect(xf86OutputPtr output)
 {
-	/* go to the hw and retrieve a new output struct */
-	drmmode_output_private_ptr drmmode_output = output->driver_private;
-	drmmode_ptr drmmode = drmmode_output->drmmode;
-	xf86OutputStatus status;
-	drmModeFreeConnector(drmmode_output->mode_output);
-
-	drmmode_output->mode_output = drmModeGetConnector(drmmode->fd, drmmode_output->output_id);
-	if (!drmmode_output->mode_output)
-		return XF86OutputStatusDisconnected;
-
-	switch (drmmode_output->mode_output->connection) {
-	case DRM_MODE_CONNECTED:
-		status = XF86OutputStatusConnected;
-		break;
-	case DRM_MODE_DISCONNECTED:
-		status = XF86OutputStatusDisconnected;
-		break;
-	default:
-	case DRM_MODE_UNKNOWNCONNECTION:
-		status = XF86OutputStatusUnknown;
-		break;
-	}
-	return status;
+    /* go to the hw and retrieve a new output struct */
+    drmmode_output_private_ptr drmmode_output = output->driver_private;
+    drmmode_ptr drmmode = drmmode_output->drmmode;
+    xf86OutputStatus status;
+
+    drmModeFreeConnector(drmmode_output->mode_output);
+
+    drmmode_output->mode_output =
+        drmModeGetConnector(drmmode->fd, drmmode_output->output_id);
+    if (!drmmode_output->mode_output)
+        return XF86OutputStatusDisconnected;
+
+    switch (drmmode_output->mode_output->connection) {
+    case DRM_MODE_CONNECTED:
+        status = XF86OutputStatusConnected;
+        break;
+    case DRM_MODE_DISCONNECTED:
+        status = XF86OutputStatusDisconnected;
+        break;
+    default:
+    case DRM_MODE_UNKNOWNCONNECTION:
+        status = XF86OutputStatusUnknown;
+        break;
+    }
+    return status;
 }
 
 static Bool
 drmmode_output_mode_valid(xf86OutputPtr output, DisplayModePtr pModes)
 {
-	return MODE_OK;
+    return MODE_OK;
 }
 
 static Bool
 has_panel_fitter(xf86OutputPtr output)
 {
-	drmmode_output_private_ptr drmmode_output = output->driver_private;
-	drmModeConnectorPtr koutput = drmmode_output->mode_output;
-	drmmode_ptr drmmode = drmmode_output->drmmode;
-	int i;
-
-	/* Presume that if the output supports scaling, then we have a
-	 * panel fitter capable of adjust any mode to suit.
-	 */
-	for (i = 0; i < koutput->count_props; i++) {
-		drmModePropertyPtr props;
-		Bool found = FALSE;
-
-		props = drmModeGetProperty(drmmode->fd, koutput->props[i]);
-		if (props) {
-			found = strcmp(props->name, "scaling mode") == 0;
-			drmModeFreeProperty(props);
-		}
-
-		if (found)
-			return TRUE;
-	}
-
-	return FALSE;
+    drmmode_output_private_ptr drmmode_output = output->driver_private;
+    drmModeConnectorPtr koutput = drmmode_output->mode_output;
+    drmmode_ptr drmmode = drmmode_output->drmmode;
+    int i;
+
+    /* Presume that if the output supports scaling, then we have a
+     * panel fitter capable of adjust any mode to suit.
+     */
+    for (i = 0; i < koutput->count_props; i++) {
+        drmModePropertyPtr props;
+        Bool found = FALSE;
+
+        props = drmModeGetProperty(drmmode->fd, koutput->props[i]);
+        if (props) {
+            found = strcmp(props->name, "scaling mode") == 0;
+            drmModeFreeProperty(props);
+        }
+
+        if (found)
+            return TRUE;
+    }
+
+    return FALSE;
 }
 
 static DisplayModePtr
-drmmode_output_add_gtf_modes(xf86OutputPtr output,
-			     DisplayModePtr Modes)
+drmmode_output_add_gtf_modes(xf86OutputPtr output, DisplayModePtr Modes)
 {
-	xf86MonPtr mon = output->MonInfo;
-	DisplayModePtr i, m, preferred = NULL;
-	int max_x = 0, max_y = 0;
-	float max_vrefresh = 0.0;
-
-	if (mon && GTF_SUPPORTED(mon->features.msc))
-		return Modes;
-
-	if (!has_panel_fitter(output))
-		return Modes;
-
-	for (m = Modes; m; m = m->next) {
-		if (m->type & M_T_PREFERRED)
-			preferred = m;
-		max_x = max(max_x, m->HDisplay);
-		max_y = max(max_y, m->VDisplay);
-		max_vrefresh = max(max_vrefresh, xf86ModeVRefresh(m));
-	}
-
-	max_vrefresh = max(max_vrefresh, 60.0);
-	max_vrefresh *= (1 + SYNC_TOLERANCE);
-
-	m = xf86GetDefaultModes();
-	xf86ValidateModesSize(output->scrn, m, max_x, max_y, 0);
-
-	for (i = m; i; i = i->next) {
-		if (xf86ModeVRefresh(i) > max_vrefresh)
-			i->status = MODE_VSYNC;
-		if (preferred &&
-		    i->HDisplay >= preferred->HDisplay &&
-		    i->VDisplay >= preferred->VDisplay &&
-		    xf86ModeVRefresh(i) >= xf86ModeVRefresh(preferred))
-			i->status = MODE_VSYNC;
-	}
-
-	xf86PruneInvalidModes(output->scrn, &m, FALSE);
-
-	return xf86ModesAdd(Modes, m);
+    xf86MonPtr mon = output->MonInfo;
+    DisplayModePtr i, m, preferred = NULL;
+    int max_x = 0, max_y = 0;
+    float max_vrefresh = 0.0;
+
+    if (mon && GTF_SUPPORTED(mon->features.msc))
+        return Modes;
+
+    if (!has_panel_fitter(output))
+        return Modes;
+
+    for (m = Modes; m; m = m->next) {
+        if (m->type & M_T_PREFERRED)
+            preferred = m;
+        max_x = max(max_x, m->HDisplay);
+        max_y = max(max_y, m->VDisplay);
+        max_vrefresh = max(max_vrefresh, xf86ModeVRefresh(m));
+    }
+
+    max_vrefresh = max(max_vrefresh, 60.0);
+    max_vrefresh *= (1 + SYNC_TOLERANCE);
+
+    m = xf86GetDefaultModes();
+    xf86ValidateModesSize(output->scrn, m, max_x, max_y, 0);
+
+    for (i = m; i; i = i->next) {
+        if (xf86ModeVRefresh(i) > max_vrefresh)
+            i->status = MODE_VSYNC;
+        if (preferred &&
+            i->HDisplay >= preferred->HDisplay &&
+            i->VDisplay >= preferred->VDisplay &&
+            xf86ModeVRefresh(i) >= xf86ModeVRefresh(preferred))
+            i->status = MODE_VSYNC;
+    }
+
+    xf86PruneInvalidModes(output->scrn, &m, FALSE);
+
+    return xf86ModesAdd(Modes, m);
 }
 
 static DisplayModePtr
 drmmode_output_get_modes(xf86OutputPtr output)
 {
-	drmmode_output_private_ptr drmmode_output = output->driver_private;
-	drmModeConnectorPtr koutput = drmmode_output->mode_output;
-	drmmode_ptr drmmode = drmmode_output->drmmode;
-	int i;
-	DisplayModePtr Modes = NULL, Mode;
-	drmModePropertyPtr props;
-	xf86MonPtr mon = NULL;
-
-	if (!koutput)
-		return NULL;
-
-	/* look for an EDID property */
-	for (i = 0; i < koutput->count_props; i++) {
-		props = drmModeGetProperty(drmmode->fd, koutput->props[i]);
-		if (props && (props->flags & DRM_MODE_PROP_BLOB)) {
-			if (!strcmp(props->name, "EDID")) {
-				if (drmmode_output->edid_blob)
-					drmModeFreePropertyBlob(drmmode_output->edid_blob);
-				drmmode_output->edid_blob = drmModeGetPropertyBlob(drmmode->fd, koutput->prop_values[i]);
-			}
-			drmModeFreeProperty(props);
-		}
-	}
-
-	if (drmmode_output->edid_blob) {
-		mon = xf86InterpretEDID(output->scrn->scrnIndex,
-					drmmode_output->edid_blob->data);
-		if (mon && drmmode_output->edid_blob->length > 128)
-			mon->flags |= MONITOR_EDID_COMPLETE_RAWDATA;
-	}
-	xf86OutputSetEDID(output, mon);
-
-	/* modes should already be available */
-	for (i = 0; i < koutput->count_modes; i++) {
-		Mode = xnfalloc(sizeof(DisplayModeRec));
-
-		drmmode_ConvertFromKMode(output->scrn, &koutput->modes[i], Mode);
-		Modes = xf86ModesAdd(Modes, Mode);
-
-	}
-
-	return drmmode_output_add_gtf_modes(output, Modes);
+    drmmode_output_private_ptr drmmode_output = output->driver_private;
+    drmModeConnectorPtr koutput = drmmode_output->mode_output;
+    drmmode_ptr drmmode = drmmode_output->drmmode;
+    int i;
+    DisplayModePtr Modes = NULL, Mode;
+    drmModePropertyPtr props;
+    xf86MonPtr mon = NULL;
+
+    if (!koutput)
+        return NULL;
+
+    /* look for an EDID property */
+    for (i = 0; i < koutput->count_props; i++) {
+        props = drmModeGetProperty(drmmode->fd, koutput->props[i]);
+        if (props && (props->flags & DRM_MODE_PROP_BLOB)) {
+            if (!strcmp(props->name, "EDID")) {
+                if (drmmode_output->edid_blob)
+                    drmModeFreePropertyBlob(drmmode_output->edid_blob);
+                drmmode_output->edid_blob =
+                    drmModeGetPropertyBlob(drmmode->fd,
+                                           koutput->prop_values[i]);
+            }
+            drmModeFreeProperty(props);
+        }
+    }
+
+    if (drmmode_output->edid_blob) {
+        mon = xf86InterpretEDID(output->scrn->scrnIndex,
+                                drmmode_output->edid_blob->data);
+        if (mon && drmmode_output->edid_blob->length > 128)
+            mon->flags |= MONITOR_EDID_COMPLETE_RAWDATA;
+    }
+    xf86OutputSetEDID(output, mon);
+
+    /* modes should already be available */
+    for (i = 0; i < koutput->count_modes; i++) {
+        Mode = xnfalloc(sizeof(DisplayModeRec));
+
+        drmmode_ConvertFromKMode(output->scrn, &koutput->modes[i], Mode);
+        Modes = xf86ModesAdd(Modes, Mode);
+
+    }
+
+    return drmmode_output_add_gtf_modes(output, Modes);
 }
 
 static void
 drmmode_output_destroy(xf86OutputPtr output)
 {
-	drmmode_output_private_ptr drmmode_output = output->driver_private;
-	int i;
-
-	if (drmmode_output->edid_blob)
-		drmModeFreePropertyBlob(drmmode_output->edid_blob);
-	for (i = 0; i < drmmode_output->num_props; i++) {
-		drmModeFreeProperty(drmmode_output->props[i].mode_prop);
-		free(drmmode_output->props[i].atoms);
-	}
-	free(drmmode_output->props);
-	for (i = 0; i < drmmode_output->mode_output->count_encoders; i++) {
-		drmModeFreeEncoder(drmmode_output->mode_encoders[i]);
-	}
-	free(drmmode_output->mode_encoders);
-	drmModeFreeConnector(drmmode_output->mode_output);
-	free(drmmode_output);
-	output->driver_private = NULL;
+    drmmode_output_private_ptr drmmode_output = output->driver_private;
+    int i;
+
+    if (drmmode_output->edid_blob)
+        drmModeFreePropertyBlob(drmmode_output->edid_blob);
+    for (i = 0; i < drmmode_output->num_props; i++) {
+        drmModeFreeProperty(drmmode_output->props[i].mode_prop);
+        free(drmmode_output->props[i].atoms);
+    }
+    free(drmmode_output->props);
+    for (i = 0; i < drmmode_output->mode_output->count_encoders; i++) {
+        drmModeFreeEncoder(drmmode_output->mode_encoders[i]);
+    }
+    free(drmmode_output->mode_encoders);
+    drmModeFreeConnector(drmmode_output->mode_output);
+    free(drmmode_output);
+    output->driver_private = NULL;
 }
 
 static void
 drmmode_output_dpms(xf86OutputPtr output, int mode)
 {
-	drmmode_output_private_ptr drmmode_output = output->driver_private;
-	drmModeConnectorPtr koutput = drmmode_output->mode_output;
-	drmmode_ptr drmmode = drmmode_output->drmmode;
+    drmmode_output_private_ptr drmmode_output = output->driver_private;
+    drmModeConnectorPtr koutput = drmmode_output->mode_output;
+    drmmode_ptr drmmode = drmmode_output->drmmode;
 
-	if (!koutput)
-		return;
+    if (!koutput)
+        return;
 
-	drmModeConnectorSetProperty(drmmode->fd, koutput->connector_id,
-				    drmmode_output->dpms_enum_id, mode);
-	return;
+    drmModeConnectorSetProperty(drmmode->fd, koutput->connector_id,
+                                drmmode_output->dpms_enum_id, mode);
+    return;
 }
 
-
 static Bool
 drmmode_property_ignore(drmModePropertyPtr prop)
 {
     if (!prop)
-	return TRUE;
+        return TRUE;
     /* ignore blob prop */
     if (prop->flags & DRM_MODE_PROP_BLOB)
-	return TRUE;
+        return TRUE;
     /* ignore standard property */
-    if (!strcmp(prop->name, "EDID") ||
-	    !strcmp(prop->name, "DPMS"))
-	return TRUE;
+    if (!strcmp(prop->name, "EDID") || !strcmp(prop->name, "DPMS"))
+        return TRUE;
 
     return FALSE;
 }
@@ -806,128 +816,143 @@ drmmode_output_create_resources(xf86OutputPtr output)
     drmModePropertyPtr drmmode_prop;
     int i, j, err;
 
-    drmmode_output->props = calloc(mode_output->count_props, sizeof(drmmode_prop_rec));
+    drmmode_output->props =
+        calloc(mode_output->count_props, sizeof(drmmode_prop_rec));
     if (!drmmode_output->props)
-	return;
-    
+        return;
+
     drmmode_output->num_props = 0;
     for (i = 0, j = 0; i < mode_output->count_props; i++) {
-	drmmode_prop = drmModeGetProperty(drmmode->fd, mode_output->props[i]);
-	if (drmmode_property_ignore(drmmode_prop)) {
-	    drmModeFreeProperty(drmmode_prop);
-	    continue;
-	}
-	drmmode_output->props[j].mode_prop = drmmode_prop;
-	drmmode_output->props[j].value = mode_output->prop_values[i];
-	drmmode_output->num_props++;
-	j++;
+        drmmode_prop = drmModeGetProperty(drmmode->fd, mode_output->props[i]);
+        if (drmmode_property_ignore(drmmode_prop)) {
+            drmModeFreeProperty(drmmode_prop);
+            continue;
+        }
+        drmmode_output->props[j].mode_prop = drmmode_prop;
+        drmmode_output->props[j].value = mode_output->prop_values[i];
+        drmmode_output->num_props++;
+        j++;
     }
 
     for (i = 0; i < drmmode_output->num_props; i++) {
-	drmmode_prop_ptr p = &drmmode_output->props[i];
-	drmmode_prop = p->mode_prop;
-
-	if (drmmode_prop->flags & DRM_MODE_PROP_RANGE) {
-	    INT32 prop_range[2];
-	    INT32 value = p->value;
-
-	    p->num_atoms = 1;
-	    p->atoms = calloc(p->num_atoms, sizeof(Atom));
-	    if (!p->atoms)
-		continue;
-	    p->atoms[0] = MakeAtom(drmmode_prop->name, strlen(drmmode_prop->name), TRUE);
-	    prop_range[0] = drmmode_prop->values[0];
-	    prop_range[1] = drmmode_prop->values[1];
-	    err = RRConfigureOutputProperty(output->randr_output, p->atoms[0],
-		    FALSE, TRUE,
-		    drmmode_prop->flags & DRM_MODE_PROP_IMMUTABLE ? TRUE : FALSE,
-		    2, prop_range);
-	    if (err != 0) {
-		xf86DrvMsg(output->scrn->scrnIndex, X_ERROR,
-			"RRConfigureOutputProperty error, %d\n", err);
-	    }
-	    err = RRChangeOutputProperty(output->randr_output, p->atoms[0],
-		    XA_INTEGER, 32, PropModeReplace, 1, &value, FALSE, TRUE);
-	    if (err != 0) {
-		xf86DrvMsg(output->scrn->scrnIndex, X_ERROR,
-			"RRChangeOutputProperty error, %d\n", err);
-	    }
-	} else if (drmmode_prop->flags & DRM_MODE_PROP_ENUM) {
-	    p->num_atoms = drmmode_prop->count_enums + 1;
-	    p->atoms = calloc(p->num_atoms, sizeof(Atom));
-	    if (!p->atoms)
-		continue;
-	    p->atoms[0] = MakeAtom(drmmode_prop->name, strlen(drmmode_prop->name), TRUE);
-	    for (j = 1; j <= drmmode_prop->count_enums; j++) {
-		struct drm_mode_property_enum *e = &drmmode_prop->enums[j-1];
-		p->atoms[j] = MakeAtom(e->name, strlen(e->name), TRUE);
-	    }
-	    err = RRConfigureOutputProperty(output->randr_output, p->atoms[0],
-		    FALSE, FALSE,
-		    drmmode_prop->flags & DRM_MODE_PROP_IMMUTABLE ? TRUE : FALSE,
-		    p->num_atoms - 1, (INT32 *)&p->atoms[1]);
-	    if (err != 0) {
-		xf86DrvMsg(output->scrn->scrnIndex, X_ERROR,
-			"RRConfigureOutputProperty error, %d\n", err);
-	    }
-	    for (j = 0; j < drmmode_prop->count_enums; j++)
-		if (drmmode_prop->enums[j].value == p->value)
-		    break;
-	    /* there's always a matching value */
-	    err = RRChangeOutputProperty(output->randr_output, p->atoms[0],
-		    XA_ATOM, 32, PropModeReplace, 1, &p->atoms[j+1], FALSE, TRUE);
-	    if (err != 0) {
-		xf86DrvMsg(output->scrn->scrnIndex, X_ERROR,
-			"RRChangeOutputProperty error, %d\n", err);
-	    }
-	}
+        drmmode_prop_ptr p = &drmmode_output->props[i];
+
+        drmmode_prop = p->mode_prop;
+
+        if (drmmode_prop->flags & DRM_MODE_PROP_RANGE) {
+            INT32 prop_range[2];
+            INT32 value = p->value;
+
+            p->num_atoms = 1;
+            p->atoms = calloc(p->num_atoms, sizeof(Atom));
+            if (!p->atoms)
+                continue;
+            p->atoms[0] =
+                MakeAtom(drmmode_prop->name, strlen(drmmode_prop->name), TRUE);
+            prop_range[0] = drmmode_prop->values[0];
+            prop_range[1] = drmmode_prop->values[1];
+            err = RRConfigureOutputProperty(output->randr_output, p->atoms[0],
+                                            FALSE, TRUE,
+                                            drmmode_prop->
+                                            flags & DRM_MODE_PROP_IMMUTABLE ?
+                                            TRUE : FALSE, 2, prop_range);
+            if (err != 0) {
+                xf86DrvMsg(output->scrn->scrnIndex, X_ERROR,
+                           "RRConfigureOutputProperty error, %d\n", err);
+            }
+            err = RRChangeOutputProperty(output->randr_output, p->atoms[0],
+                                         XA_INTEGER, 32, PropModeReplace, 1,
+                                         &value, FALSE, TRUE);
+            if (err != 0) {
+                xf86DrvMsg(output->scrn->scrnIndex, X_ERROR,
+                           "RRChangeOutputProperty error, %d\n", err);
+            }
+        }
+        else if (drmmode_prop->flags & DRM_MODE_PROP_ENUM) {
+            p->num_atoms = drmmode_prop->count_enums + 1;
+            p->atoms = calloc(p->num_atoms, sizeof(Atom));
+            if (!p->atoms)
+                continue;
+            p->atoms[0] =
+                MakeAtom(drmmode_prop->name, strlen(drmmode_prop->name), TRUE);
+            for (j = 1; j <= drmmode_prop->count_enums; j++) {
+                struct drm_mode_property_enum *e = &drmmode_prop->enums[j - 1];
+
+                p->atoms[j] = MakeAtom(e->name, strlen(e->name), TRUE);
+            }
+            err = RRConfigureOutputProperty(output->randr_output, p->atoms[0],
+                                            FALSE, FALSE,
+                                            drmmode_prop->
+                                            flags & DRM_MODE_PROP_IMMUTABLE ?
+                                            TRUE : FALSE, p->num_atoms - 1,
+                                            (INT32 *) &p->atoms[1]);
+            if (err != 0) {
+                xf86DrvMsg(output->scrn->scrnIndex, X_ERROR,
+                           "RRConfigureOutputProperty error, %d\n", err);
+            }
+            for (j = 0; j < drmmode_prop->count_enums; j++)
+                if (drmmode_prop->enums[j].value == p->value)
+                    break;
+            /* there's always a matching value */
+            err = RRChangeOutputProperty(output->randr_output, p->atoms[0],
+                                         XA_ATOM, 32, PropModeReplace, 1,
+                                         &p->atoms[j + 1], FALSE, TRUE);
+            if (err != 0) {
+                xf86DrvMsg(output->scrn->scrnIndex, X_ERROR,
+                           "RRChangeOutputProperty error, %d\n", err);
+            }
+        }
     }
 }
 
 static Bool
 drmmode_output_set_property(xf86OutputPtr output, Atom property,
-		RRPropertyValuePtr value)
+                            RRPropertyValuePtr value)
 {
     drmmode_output_private_ptr drmmode_output = output->driver_private;
     drmmode_ptr drmmode = drmmode_output->drmmode;
     int i;
 
     for (i = 0; i < drmmode_output->num_props; i++) {
-	drmmode_prop_ptr p = &drmmode_output->props[i];
-
-	if (p->atoms[0] != property)
-	    continue;
-
-	if (p->mode_prop->flags & DRM_MODE_PROP_RANGE) {
-	    uint32_t val;
-
-	    if (value->type != XA_INTEGER || value->format != 32 ||
-		    value->size != 1)
-		return FALSE;
-	    val = *(uint32_t *)value->data;
-
-	    drmModeConnectorSetProperty(drmmode->fd, drmmode_output->output_id,
-		    p->mode_prop->prop_id, (uint64_t)val);
-	    return TRUE;
-	} else if (p->mode_prop->flags & DRM_MODE_PROP_ENUM) {
-	    Atom	atom;
-	    const char	*name;
-	    int		j;
-
-	    if (value->type != XA_ATOM || value->format != 32 || value->size != 1)
-		return FALSE;
-	    memcpy(&atom, value->data, 4);
-	    name = NameForAtom(atom);
-
-	    /* search for matching name string, then set its value down */
-	    for (j = 0; j < p->mode_prop->count_enums; j++) {
-		if (!strcmp(p->mode_prop->enums[j].name, name)) {
-		    drmModeConnectorSetProperty(drmmode->fd, drmmode_output->output_id,
-			    p->mode_prop->prop_id, p->mode_prop->enums[j].value);
-		    return TRUE;
-		}
-	    }
-	}
+        drmmode_prop_ptr p = &drmmode_output->props[i];
+
+        if (p->atoms[0] != property)
+            continue;
+
+        if (p->mode_prop->flags & DRM_MODE_PROP_RANGE) {
+            uint32_t val;
+
+            if (value->type != XA_INTEGER || value->format != 32 ||
+                value->size != 1)
+                return FALSE;
+            val = *(uint32_t *) value->data;
+
+            drmModeConnectorSetProperty(drmmode->fd, drmmode_output->output_id,
+                                        p->mode_prop->prop_id, (uint64_t) val);
+            return TRUE;
+        }
+        else if (p->mode_prop->flags & DRM_MODE_PROP_ENUM) {
+            Atom atom;
+            const char *name;
+            int j;
+
+            if (value->type != XA_ATOM || value->format != 32 ||
+                value->size != 1)
+                return FALSE;
+            memcpy(&atom, value->data, 4);
+            name = NameForAtom(atom);
+
+            /* search for matching name string, then set its value down */
+            for (j = 0; j < p->mode_prop->count_enums; j++) {
+                if (!strcmp(p->mode_prop->enums[j].name, name)) {
+                    drmModeConnectorSetProperty(drmmode->fd,
+                                                drmmode_output->output_id,
+                                                p->mode_prop->prop_id,
+                                                p->mode_prop->enums[j].value);
+                    return TRUE;
+                }
+            }
+        }
     }
 
     return TRUE;
@@ -952,401 +977,416 @@ static const xf86OutputFuncsRec drmmode_output_funcs = {
 };
 
 static int subpixel_conv_table[7] = { 0, SubPixelUnknown,
-				      SubPixelHorizontalRGB,
-				      SubPixelHorizontalBGR,
-				      SubPixelVerticalRGB,
-				      SubPixelVerticalBGR,
-				      SubPixelNone };
-
-static const char * const output_names[] = { "None",
-					     "VGA",
-					     "DVI",
-					     "DVI",
-					     "DVI",
-					     "Composite",
-					     "S-video",
-					     "LVDS",
-					     "CTV",
-					     "DIN",
-					     "DisplayPort",
-					     "HDMI",
-					     "HDMI",
-					     "TV",
-					     "eDP",
-					     "Virtual",
-					     "DSI",
+    SubPixelHorizontalRGB,
+    SubPixelHorizontalBGR,
+    SubPixelVerticalRGB,
+    SubPixelVerticalBGR,
+    SubPixelNone
+};
+
+static const char *const output_names[] = { "None",
+    "VGA",
+    "DVI",
+    "DVI",
+    "DVI",
+    "Composite",
+    "S-video",
+    "LVDS",
+    "CTV",
+    "DIN",
+    "DisplayPort",
+    "HDMI",
+    "HDMI",
+    "TV",
+    "eDP",
+    "Virtual",
+    "DSI",
 };
 
 static void
-drmmode_output_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int num, int *num_dvi, int *num_hdmi)
+drmmode_output_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int num,
+                    int *num_dvi, int *num_hdmi)
 {
-	xf86OutputPtr output;
-	drmModeConnectorPtr koutput;
-	drmModeEncoderPtr *kencoders = NULL;
-	drmmode_output_private_ptr drmmode_output;
-	drmModePropertyPtr props;
-	char name[32];
-	int i;
-
-	koutput = drmModeGetConnector(drmmode->fd, drmmode->mode_res->connectors[num]);
-	if (!koutput)
-		return;
-
-	kencoders = calloc(sizeof(drmModeEncoderPtr), koutput->count_encoders);
-	if (!kencoders) {
-		goto out_free_encoders;
-	}
-
-	for (i = 0; i < koutput->count_encoders; i++) {
-		kencoders[i] = drmModeGetEncoder(drmmode->fd, koutput->encoders[i]);
-		if (!kencoders[i]) {
-			goto out_free_encoders;
-		}
-	}
-
-	/* need to do smart conversion here for compat with non-kms ATI driver */
-	if (koutput->connector_type >= MS_ARRAY_SIZE(output_names))
-		snprintf(name, 32, "Unknown-%d", koutput->connector_type_id - 1);
-	else if (pScrn->is_gpu)
-		snprintf(name, 32, "%s-%d-%d", output_names[koutput->connector_type], pScrn->scrnIndex - GPU_SCREEN_OFFSET + 1, koutput->connector_type_id - 1);
-	else
-		snprintf(name, 32, "%s-%d", output_names[koutput->connector_type], koutput->connector_type_id - 1);
-
-	output = xf86OutputCreate (pScrn, &drmmode_output_funcs, name);
-	if (!output) {
-		goto out_free_encoders;
-	}
-
-	drmmode_output = calloc(sizeof(drmmode_output_private_rec), 1);
-	if (!drmmode_output) {
-		xf86OutputDestroy(output);
-		goto out_free_encoders;
-	}
-
-	drmmode_output->output_id = drmmode->mode_res->connectors[num];
-	drmmode_output->mode_output = koutput;
-	drmmode_output->mode_encoders = kencoders;
-	drmmode_output->drmmode = drmmode;
-	output->mm_width = koutput->mmWidth;
-	output->mm_height = koutput->mmHeight;
-
-	output->subpixel_order = subpixel_conv_table[koutput->subpixel];
-	output->interlaceAllowed = TRUE;
-	output->doubleScanAllowed = TRUE;
-	output->driver_private = drmmode_output;
-	
-	output->possible_crtcs = 0x7f;
-	for (i = 0; i < koutput->count_encoders; i++) {
-		output->possible_crtcs &= kencoders[i]->possible_crtcs;
-	}
-	/* work out the possible clones later */
-	output->possible_clones = 0;
-
-	for (i = 0; i < koutput->count_props; i++) {
-		props = drmModeGetProperty(drmmode->fd, koutput->props[i]);
-		if (props && (props->flags & DRM_MODE_PROP_ENUM)) {
-			if (!strcmp(props->name, "DPMS")) {
-				drmmode_output->dpms_enum_id = koutput->props[i];
-				drmModeFreeProperty(props);
-				break;
-			}
-			drmModeFreeProperty(props);
-		}
-	}
-
-	return;
-out_free_encoders:
-	if (kencoders){
-		for (i = 0; i < koutput->count_encoders; i++)
-			drmModeFreeEncoder(kencoders[i]);
-		free(kencoders);
-	}
-	drmModeFreeConnector(koutput);
-	
+    xf86OutputPtr output;
+    drmModeConnectorPtr koutput;
+    drmModeEncoderPtr *kencoders = NULL;
+    drmmode_output_private_ptr drmmode_output;
+    drmModePropertyPtr props;
+    char name[32];
+    int i;
+
+    koutput =
+        drmModeGetConnector(drmmode->fd, drmmode->mode_res->connectors[num]);
+    if (!koutput)
+        return;
+
+    kencoders = calloc(sizeof(drmModeEncoderPtr), koutput->count_encoders);
+    if (!kencoders) {
+        goto out_free_encoders;
+    }
+
+    for (i = 0; i < koutput->count_encoders; i++) {
+        kencoders[i] = drmModeGetEncoder(drmmode->fd, koutput->encoders[i]);
+        if (!kencoders[i]) {
+            goto out_free_encoders;
+        }
+    }
+
+    /* need to do smart conversion here for compat with non-kms ATI driver */
+    if (koutput->connector_type >= MS_ARRAY_SIZE(output_names))
+        snprintf(name, 32, "Unknown-%d", koutput->connector_type_id - 1);
+    else if (pScrn->is_gpu)
+        snprintf(name, 32, "%s-%d-%d", output_names[koutput->connector_type],
+                 pScrn->scrnIndex - GPU_SCREEN_OFFSET + 1,
+                 koutput->connector_type_id - 1);
+    else
+        snprintf(name, 32, "%s-%d", output_names[koutput->connector_type],
+                 koutput->connector_type_id - 1);
+
+    output = xf86OutputCreate(pScrn, &drmmode_output_funcs, name);
+    if (!output) {
+        goto out_free_encoders;
+    }
+
+    drmmode_output = calloc(sizeof(drmmode_output_private_rec), 1);
+    if (!drmmode_output) {
+        xf86OutputDestroy(output);
+        goto out_free_encoders;
+    }
+
+    drmmode_output->output_id = drmmode->mode_res->connectors[num];
+    drmmode_output->mode_output = koutput;
+    drmmode_output->mode_encoders = kencoders;
+    drmmode_output->drmmode = drmmode;
+    output->mm_width = koutput->mmWidth;
+    output->mm_height = koutput->mmHeight;
+
+    output->subpixel_order = subpixel_conv_table[koutput->subpixel];
+    output->interlaceAllowed = TRUE;
+    output->doubleScanAllowed = TRUE;
+    output->driver_private = drmmode_output;
+
+    output->possible_crtcs = 0x7f;
+    for (i = 0; i < koutput->count_encoders; i++) {
+        output->possible_crtcs &= kencoders[i]->possible_crtcs;
+    }
+    /* work out the possible clones later */
+    output->possible_clones = 0;
+
+    for (i = 0; i < koutput->count_props; i++) {
+        props = drmModeGetProperty(drmmode->fd, koutput->props[i]);
+        if (props && (props->flags & DRM_MODE_PROP_ENUM)) {
+            if (!strcmp(props->name, "DPMS")) {
+                drmmode_output->dpms_enum_id = koutput->props[i];
+                drmModeFreeProperty(props);
+                break;
+            }
+            drmModeFreeProperty(props);
+        }
+    }
+
+    return;
+ out_free_encoders:
+    if (kencoders) {
+        for (i = 0; i < koutput->count_encoders; i++)
+            drmModeFreeEncoder(kencoders[i]);
+        free(kencoders);
+    }
+    drmModeFreeConnector(koutput);
+
 }
 
-static uint32_t find_clones(ScrnInfoPtr scrn, xf86OutputPtr output)
+static uint32_t
+find_clones(ScrnInfoPtr scrn, xf86OutputPtr output)
 {
-	drmmode_output_private_ptr drmmode_output = output->driver_private, clone_drmout;
-	int i;
-	xf86OutputPtr clone_output;
-	xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
-	int index_mask = 0;
-
-	if (drmmode_output->enc_clone_mask == 0)
-		return index_mask;
-
-	for (i = 0; i < xf86_config->num_output; i++) {
-		clone_output = xf86_config->output[i];
-		clone_drmout = clone_output->driver_private;
-		if (output == clone_output)
-			continue;
-		
-		if (clone_drmout->enc_mask == 0)
-			continue;
-		if (drmmode_output->enc_clone_mask == clone_drmout->enc_mask)
-			index_mask |= (1 << i);
-	}
-	return index_mask;
+    drmmode_output_private_ptr drmmode_output =
+        output->driver_private, clone_drmout;
+    int i;
+    xf86OutputPtr clone_output;
+    xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
+    int index_mask = 0;
+
+    if (drmmode_output->enc_clone_mask == 0)
+        return index_mask;
+
+    for (i = 0; i < xf86_config->num_output; i++) {
+        clone_output = xf86_config->output[i];
+        clone_drmout = clone_output->driver_private;
+        if (output == clone_output)
+            continue;
+
+        if (clone_drmout->enc_mask == 0)
+            continue;
+        if (drmmode_output->enc_clone_mask == clone_drmout->enc_mask)
+            index_mask |= (1 << i);
+    }
+    return index_mask;
 }
 
-
 static void
 drmmode_clones_init(ScrnInfoPtr scrn, drmmode_ptr drmmode)
 {
-	int i, j;
-	xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
-
-	for (i = 0; i < xf86_config->num_output; i++) {
-		xf86OutputPtr output = xf86_config->output[i];
-		drmmode_output_private_ptr drmmode_output;
-
-		drmmode_output = output->driver_private;
-		drmmode_output->enc_clone_mask = 0xff;
-		/* and all the possible encoder clones for this output together */
-		for (j = 0; j < drmmode_output->mode_output->count_encoders; j++)
-		{
-			int k;
-			for (k = 0; k < drmmode->mode_res->count_encoders; k++) {
-				if (drmmode->mode_res->encoders[k] == drmmode_output->mode_encoders[j]->encoder_id)
-					drmmode_output->enc_mask |= (1 << k);
-			}
-
-			drmmode_output->enc_clone_mask &= drmmode_output->mode_encoders[j]->possible_clones;
-		}
-	}
-
-	for (i = 0; i < xf86_config->num_output; i++) {
-		xf86OutputPtr output = xf86_config->output[i];
-		output->possible_clones = find_clones(scrn, output);
-	}
+    int i, j;
+    xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
+
+    for (i = 0; i < xf86_config->num_output; i++) {
+        xf86OutputPtr output = xf86_config->output[i];
+        drmmode_output_private_ptr drmmode_output;
+
+        drmmode_output = output->driver_private;
+        drmmode_output->enc_clone_mask = 0xff;
+        /* and all the possible encoder clones for this output together */
+        for (j = 0; j < drmmode_output->mode_output->count_encoders; j++) {
+            int k;
+
+            for (k = 0; k < drmmode->mode_res->count_encoders; k++) {
+                if (drmmode->mode_res->encoders[k] ==
+                    drmmode_output->mode_encoders[j]->encoder_id)
+                    drmmode_output->enc_mask |= (1 << k);
+            }
+
+            drmmode_output->enc_clone_mask &=
+                drmmode_output->mode_encoders[j]->possible_clones;
+        }
+    }
+
+    for (i = 0; i < xf86_config->num_output; i++) {
+        xf86OutputPtr output = xf86_config->output[i];
+
+        output->possible_clones = find_clones(scrn, output);
+    }
 }
 
 static Bool
-drmmode_xf86crtc_resize (ScrnInfoPtr scrn, int width, int height)
+drmmode_xf86crtc_resize(ScrnInfoPtr scrn, int width, int height)
 {
-	xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
-	drmmode_crtc_private_ptr
-		    drmmode_crtc = xf86_config->crtc[0]->driver_private;
-	drmmode_ptr drmmode = drmmode_crtc->drmmode;
-	struct dumb_bo *old_front = NULL;
-	Bool	    ret;
-	ScreenPtr   screen = xf86ScrnToScreen(scrn);
-	uint32_t    old_fb_id;
-	int	    i, pitch, old_width, old_height, old_pitch;
-	int cpp = (scrn->bitsPerPixel + 7) / 8;
-	PixmapPtr ppix = screen->GetScreenPixmap(screen);
-	void *new_pixels;
-
-	if (scrn->virtualX == width && scrn->virtualY == height)
-		return TRUE;
-
-	xf86DrvMsg(scrn->scrnIndex, X_INFO,
-		   "Allocate new frame buffer %dx%d stride\n",
-		   width, height);
-
-	old_width = scrn->virtualX;
-	old_height = scrn->virtualY;
-	old_pitch = drmmode->front_bo->pitch;
-	old_fb_id = drmmode->fb_id;
-	old_front = drmmode->front_bo;
-
-	drmmode->front_bo = dumb_bo_create(drmmode->fd, width, height, scrn->bitsPerPixel);
-	if (!drmmode->front_bo)
-		goto fail;
-
-	pitch = drmmode->front_bo->pitch;
-
-	scrn->virtualX = width;
-	scrn->virtualY = height;
-	scrn->displayWidth = pitch / cpp;
-
-	ret = drmModeAddFB(drmmode->fd, width, height, scrn->depth,
-			   scrn->bitsPerPixel, pitch,
-			   drmmode->front_bo->handle,
-			   &drmmode->fb_id);
-	if (ret)
-		goto fail;
-	
-	new_pixels  = drmmode_map_front_bo(drmmode);
-	if (!new_pixels)
-		goto fail;
-
-	if (!drmmode->shadow_enable)
-		screen->ModifyPixmapHeader(ppix, width, height, -1, -1,
-					   pitch, new_pixels);
-	else {
-		void *new_shadow;
-		uint32_t size = scrn->displayWidth * scrn->virtualY *
-			((scrn->bitsPerPixel + 7) >> 3);
-		new_shadow = calloc(1, size);
-		if (new_shadow == NULL)
-			goto fail;
-		free(drmmode->shadow_fb);
-		drmmode->shadow_fb = new_shadow;
-		screen->ModifyPixmapHeader(ppix, width, height, -1, -1,
-					   pitch, drmmode->shadow_fb);
-	}
-
-	for (i = 0; i < xf86_config->num_crtc; i++) {
-		xf86CrtcPtr crtc = xf86_config->crtc[i];
-
-		if (!crtc->enabled)
-			continue;
-
-		drmmode_set_mode_major(crtc, &crtc->mode,
-				       crtc->rotation, crtc->x, crtc->y);
-	}
-
-	if (old_fb_id) {
-		drmModeRmFB(drmmode->fd, old_fb_id);
-		dumb_bo_destroy(drmmode->fd, old_front);
-	}
-
-	return TRUE;
+    xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
+
+    drmmode_crtc_private_ptr
+        drmmode_crtc = xf86_config->crtc[0]->driver_private;
+    drmmode_ptr drmmode = drmmode_crtc->drmmode;
+    struct dumb_bo *old_front = NULL;
+    Bool ret;
+    ScreenPtr screen = xf86ScrnToScreen(scrn);
+    uint32_t old_fb_id;
+    int i, pitch, old_width, old_height, old_pitch;
+    int cpp = (scrn->bitsPerPixel + 7) / 8;
+    PixmapPtr ppix = screen->GetScreenPixmap(screen);
+    void *new_pixels;
+
+    if (scrn->virtualX == width && scrn->virtualY == height)
+        return TRUE;
+
+    xf86DrvMsg(scrn->scrnIndex, X_INFO,
+               "Allocate new frame buffer %dx%d stride\n", width, height);
+
+    old_width = scrn->virtualX;
+    old_height = scrn->virtualY;
+    old_pitch = drmmode->front_bo->pitch;
+    old_fb_id = drmmode->fb_id;
+    old_front = drmmode->front_bo;
+
+    drmmode->front_bo =
+        dumb_bo_create(drmmode->fd, width, height, scrn->bitsPerPixel);
+    if (!drmmode->front_bo)
+        goto fail;
+
+    pitch = drmmode->front_bo->pitch;
+
+    scrn->virtualX = width;
+    scrn->virtualY = height;
+    scrn->displayWidth = pitch / cpp;
+
+    ret = drmModeAddFB(drmmode->fd, width, height, scrn->depth,
+                       scrn->bitsPerPixel, pitch,
+                       drmmode->front_bo->handle, &drmmode->fb_id);
+    if (ret)
+        goto fail;
+
+    new_pixels = drmmode_map_front_bo(drmmode);
+    if (!new_pixels)
+        goto fail;
+
+    if (!drmmode->shadow_enable)
+        screen->ModifyPixmapHeader(ppix, width, height, -1, -1,
+                                   pitch, new_pixels);
+    else {
+        void *new_shadow;
+        uint32_t size = scrn->displayWidth * scrn->virtualY *
+            ((scrn->bitsPerPixel + 7) >> 3);
+        new_shadow = calloc(1, size);
+        if (new_shadow == NULL)
+            goto fail;
+        free(drmmode->shadow_fb);
+        drmmode->shadow_fb = new_shadow;
+        screen->ModifyPixmapHeader(ppix, width, height, -1, -1,
+                                   pitch, drmmode->shadow_fb);
+    }
+
+    for (i = 0; i < xf86_config->num_crtc; i++) {
+        xf86CrtcPtr crtc = xf86_config->crtc[i];
+
+        if (!crtc->enabled)
+            continue;
+
+        drmmode_set_mode_major(crtc, &crtc->mode,
+                               crtc->rotation, crtc->x, crtc->y);
+    }
+
+    if (old_fb_id) {
+        drmModeRmFB(drmmode->fd, old_fb_id);
+        dumb_bo_destroy(drmmode->fd, old_front);
+    }
+
+    return TRUE;
 
  fail:
-	if (drmmode->front_bo)
-		dumb_bo_destroy(drmmode->fd, drmmode->front_bo);
-	drmmode->front_bo = old_front;
-	scrn->virtualX = old_width;
-	scrn->virtualY = old_height;
-	scrn->displayWidth = old_pitch / cpp;
-	drmmode->fb_id = old_fb_id;
-
-	return FALSE;
+    if (drmmode->front_bo)
+        dumb_bo_destroy(drmmode->fd, drmmode->front_bo);
+    drmmode->front_bo = old_front;
+    scrn->virtualX = old_width;
+    scrn->virtualY = old_height;
+    scrn->displayWidth = old_pitch / cpp;
+    drmmode->fb_id = old_fb_id;
+
+    return FALSE;
 }
 
 static const xf86CrtcConfigFuncsRec drmmode_xf86crtc_config_funcs = {
-	drmmode_xf86crtc_resize
+    drmmode_xf86crtc_resize
 };
 
-Bool drmmode_pre_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int cpp)
+Bool
+drmmode_pre_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int cpp)
 {
-	int i, num_dvi = 0, num_hdmi = 0;
-	int ret;
-	uint64_t value = 0;
-
-	/* check for dumb capability */
-	ret = drmGetCap(drmmode->fd, DRM_CAP_DUMB_BUFFER, &value);
-	if (ret > 0 || value != 1) {
-		xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "KMS doesn't support dumb interface\n");
-		return FALSE;
-	}
+    int i, num_dvi = 0, num_hdmi = 0;
+    int ret;
+    uint64_t value = 0;
+
+    /* check for dumb capability */
+    ret = drmGetCap(drmmode->fd, DRM_CAP_DUMB_BUFFER, &value);
+    if (ret > 0 || value != 1) {
+        xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+                   "KMS doesn't support dumb interface\n");
+        return FALSE;
+    }
 
-	xf86CrtcConfigInit(pScrn, &drmmode_xf86crtc_config_funcs);
+    xf86CrtcConfigInit(pScrn, &drmmode_xf86crtc_config_funcs);
 
-	drmmode->scrn = pScrn;
-	drmmode->cpp = cpp;
-	drmmode->mode_res = drmModeGetResources(drmmode->fd);
-	if (!drmmode->mode_res)
-		return FALSE;
+    drmmode->scrn = pScrn;
+    drmmode->cpp = cpp;
+    drmmode->mode_res = drmModeGetResources(drmmode->fd);
+    if (!drmmode->mode_res)
+        return FALSE;
 
-	xf86CrtcSetSizeRange(pScrn, 320, 200, drmmode->mode_res->max_width, drmmode->mode_res->max_height);
-	for (i = 0; i < drmmode->mode_res->count_crtcs; i++)
-		if (!xf86IsEntityShared(pScrn->entityList[0]) || pScrn->confScreen->device->screen == i)
-			drmmode_crtc_init(pScrn, drmmode, i);
+    xf86CrtcSetSizeRange(pScrn, 320, 200, drmmode->mode_res->max_width,
+                         drmmode->mode_res->max_height);
+    for (i = 0; i < drmmode->mode_res->count_crtcs; i++)
+        if (!xf86IsEntityShared(pScrn->entityList[0]) ||
+            pScrn->confScreen->device->screen == i)
+            drmmode_crtc_init(pScrn, drmmode, i);
 
-	for (i = 0; i < drmmode->mode_res->count_connectors; i++)
-		drmmode_output_init(pScrn, drmmode, i, &num_dvi, &num_hdmi);
+    for (i = 0; i < drmmode->mode_res->count_connectors; i++)
+        drmmode_output_init(pScrn, drmmode, i, &num_dvi, &num_hdmi);
 
-	/* workout clones */
-	drmmode_clones_init(pScrn, drmmode);
+    /* workout clones */
+    drmmode_clones_init(pScrn, drmmode);
 
 #if XF86_CRTC_VERSION >= 5
-	xf86ProviderSetup(pScrn, NULL, "modesetting");
+    xf86ProviderSetup(pScrn, NULL, "modesetting");
 #endif
 
-	xf86InitialConfiguration(pScrn, TRUE);
+    xf86InitialConfiguration(pScrn, TRUE);
 
-	return TRUE;
+    return TRUE;
 }
 
-void drmmode_adjust_frame(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int x, int y)
+void
+drmmode_adjust_frame(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int x, int y)
 {
-	xf86CrtcConfigPtr	config = XF86_CRTC_CONFIG_PTR(pScrn);
-	xf86OutputPtr  output = config->output[config->compat_output];
-	xf86CrtcPtr	crtc = output->crtc;
-
-	if (crtc && crtc->enabled) {
-		drmmode_set_mode_major(crtc, &crtc->mode, crtc->rotation,
-				       x, y);
-	}
+    xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
+    xf86OutputPtr output = config->output[config->compat_output];
+    xf86CrtcPtr crtc = output->crtc;
+
+    if (crtc && crtc->enabled) {
+        drmmode_set_mode_major(crtc, &crtc->mode, crtc->rotation, x, y);
+    }
 }
 
-Bool drmmode_set_desired_modes(ScrnInfoPtr pScrn, drmmode_ptr drmmode)
+Bool
+drmmode_set_desired_modes(ScrnInfoPtr pScrn, drmmode_ptr drmmode)
 {
-	xf86CrtcConfigPtr   config = XF86_CRTC_CONFIG_PTR(pScrn);
-	int c;
-
-	for (c = 0; c < config->num_crtc; c++) {
-		xf86CrtcPtr	crtc = config->crtc[c];
-		drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
-		xf86OutputPtr	output = NULL;
-		int		o;
-
-		/* Skip disabled CRTCs */
-		if (!crtc->enabled) {
-			drmModeSetCrtc(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id,
-				       0, 0, 0, NULL, 0, NULL);
-			continue;
-		}
-
-		if (config->output[config->compat_output]->crtc == crtc)
-			output = config->output[config->compat_output];
-		else
-		{
-			for (o = 0; o < config->num_output; o++)
-				if (config->output[o]->crtc == crtc)
-				{
-					output = config->output[o];
-					break;
-				}
-		}
-		/* paranoia */
-		if (!output)
-			continue;
-
-		/* Mark that we'll need to re-set the mode for sure */
-		memset(&crtc->mode, 0, sizeof(crtc->mode));
-		if (!crtc->desiredMode.CrtcHDisplay)
-		{
-			DisplayModePtr  mode = xf86OutputFindClosestMode (output, pScrn->currentMode);
-
-			if (!mode)
-				return FALSE;
-			crtc->desiredMode = *mode;
-			crtc->desiredRotation = RR_Rotate_0;
-			crtc->desiredX = 0;
-			crtc->desiredY = 0;
-		}
-
-		if (!crtc->funcs->set_mode_major(crtc, &crtc->desiredMode, crtc->desiredRotation,
-						 crtc->desiredX, crtc->desiredY))
-			return FALSE;
-	}
-	return TRUE;
+    xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
+    int c;
+
+    for (c = 0; c < config->num_crtc; c++) {
+        xf86CrtcPtr crtc = config->crtc[c];
+        drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+        xf86OutputPtr output = NULL;
+        int o;
+
+        /* Skip disabled CRTCs */
+        if (!crtc->enabled) {
+            drmModeSetCrtc(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id,
+                           0, 0, 0, NULL, 0, NULL);
+            continue;
+        }
+
+        if (config->output[config->compat_output]->crtc == crtc)
+            output = config->output[config->compat_output];
+        else {
+            for (o = 0; o < config->num_output; o++)
+                if (config->output[o]->crtc == crtc) {
+                    output = config->output[o];
+                    break;
+                }
+        }
+        /* paranoia */
+        if (!output)
+            continue;
+
+        /* Mark that we'll need to re-set the mode for sure */
+        memset(&crtc->mode, 0, sizeof(crtc->mode));
+        if (!crtc->desiredMode.CrtcHDisplay) {
+            DisplayModePtr mode =
+                xf86OutputFindClosestMode(output, pScrn->currentMode);
+
+            if (!mode)
+                return FALSE;
+            crtc->desiredMode = *mode;
+            crtc->desiredRotation = RR_Rotate_0;
+            crtc->desiredX = 0;
+            crtc->desiredY = 0;
+        }
+
+        if (!crtc->funcs->
+            set_mode_major(crtc, &crtc->desiredMode, crtc->desiredRotation,
+                           crtc->desiredX, crtc->desiredY))
+            return FALSE;
+    }
+    return TRUE;
 }
 
-static void drmmode_load_palette(ScrnInfoPtr pScrn, int numColors,
-                                 int *indices, LOCO *colors, VisualPtr pVisual)
+static void
+drmmode_load_palette(ScrnInfoPtr pScrn, int numColors,
+                     int *indices, LOCO * colors, VisualPtr pVisual)
 {
-    xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
-    uint16_t       lut_r[256], lut_g[256], lut_b[256];
+    xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
+    uint16_t lut_r[256], lut_g[256], lut_b[256];
     int index, j, i;
     int c;
 
     for (c = 0; c < xf86_config->num_crtc; c++) {
         xf86CrtcPtr crtc = xf86_config->crtc[c];
-	drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+        drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
 
-        for (i = 0 ; i < 256; i++) {
+        for (i = 0; i < 256; i++) {
             lut_r[i] = drmmode_crtc->lut_r[i] << 6;
             lut_g[i] = drmmode_crtc->lut_g[i] << 6;
             lut_b[i] = drmmode_crtc->lut_b[i] << 6;
         }
 
-        switch(pScrn->depth) {
+        switch (pScrn->depth) {
         case 15:
             for (i = 0; i < numColors; i++) {
                 index = indices[i];
@@ -1356,56 +1396,55 @@ static void drmmode_load_palette(ScrnInfoPtr pScrn, int numColors,
                     lut_b[index * 8 + j] = colors[index].blue << 6;
                 }
             }
-         break;
-         case 16:
-             for (i = 0; i < numColors; i++) {
-                 index = indices[i];
-
-                  if (i <= 31) {
-                      for (j = 0; j < 8; j++) {
-                          lut_r[index * 8 + j] = colors[index].red << 6;
-                          lut_b[index * 8 + j] = colors[index].blue << 6;
-                      }
-                  }
-
-                  for (j = 0; j < 4; j++) {
-                      lut_g[index * 4 + j] = colors[index].green << 6;
-                  }
-              }
-	  break;
-          default:
-              for (i = 0; i < numColors; i++) {
-                  index = indices[i];
-                  lut_r[index] = colors[index].red << 6;
-                  lut_g[index] = colors[index].green << 6;
-                  lut_b[index] = colors[index].blue << 6;
-              }
-              break;
-          }
-
-    /* Make the change through RandR */
+            break;
+        case 16:
+            for (i = 0; i < numColors; i++) {
+                index = indices[i];
+
+                if (i <= 31) {
+                    for (j = 0; j < 8; j++) {
+                        lut_r[index * 8 + j] = colors[index].red << 6;
+                        lut_b[index * 8 + j] = colors[index].blue << 6;
+                    }
+                }
+
+                for (j = 0; j < 4; j++) {
+                    lut_g[index * 4 + j] = colors[index].green << 6;
+                }
+            }
+            break;
+        default:
+            for (i = 0; i < numColors; i++) {
+                index = indices[i];
+                lut_r[index] = colors[index].red << 6;
+                lut_g[index] = colors[index].green << 6;
+                lut_b[index] = colors[index].blue << 6;
+            }
+            break;
+        }
+
+        /* Make the change through RandR */
         if (crtc->randr_crtc)
             RRCrtcGammaSet(crtc->randr_crtc, lut_r, lut_g, lut_b);
         else
             crtc->funcs->gamma_set(crtc, lut_r, lut_g, lut_b, 256);
-     }
+    }
 }
 
-Bool drmmode_setup_colormap(ScreenPtr pScreen, ScrnInfoPtr pScrn)
+Bool
+drmmode_setup_colormap(ScreenPtr pScreen, ScrnInfoPtr pScrn)
 {
-    xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 0,
-                  "Initializing kms color map\n");
+    xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 0, "Initializing kms color map\n");
     if (!miCreateDefColormap(pScreen))
         return FALSE;
     /* all radeons support 10 bit CLUTs */
     if (!xf86HandleColormaps(pScreen, 256, 10,
-                             drmmode_load_palette, NULL,
-                             CMAP_PALETTED_TRUECOLOR
-#if 0 /* This option messes up text mode! (eich at suse.de) */
+                             drmmode_load_palette, NULL, CMAP_PALETTED_TRUECOLOR
+#if 0                           /* This option messes up text mode! (eich at suse.de) */
                              | CMAP_LOAD_EVEN_IF_OFFSCREEN
 #endif
                              | CMAP_RELOAD_ON_MODE_SWITCH))
-         return FALSE;
+        return FALSE;
     return TRUE;
 }
 
@@ -1413,204 +1452,220 @@ Bool drmmode_setup_colormap(ScreenPtr pScreen, ScrnInfoPtr pScrn)
 static void
 drmmode_handle_uevents(int fd, void *closure)
 {
-	drmmode_ptr drmmode = closure;
-	ScrnInfoPtr scrn = drmmode->scrn;
-	struct udev_device *dev;
-	dev = udev_monitor_receive_device(drmmode->uevent_monitor);
-	if (!dev)
-		return;
-
-	RRGetInfo(xf86ScrnToScreen(scrn), TRUE);
-	udev_device_unref(dev);
+    drmmode_ptr drmmode = closure;
+    ScrnInfoPtr scrn = drmmode->scrn;
+    struct udev_device *dev;
+
+    dev = udev_monitor_receive_device(drmmode->uevent_monitor);
+    if (!dev)
+        return;
+
+    RRGetInfo(xf86ScrnToScreen(scrn), TRUE);
+    udev_device_unref(dev);
 }
 #endif
 
-void drmmode_uevent_init(ScrnInfoPtr scrn, drmmode_ptr drmmode)
+void
+drmmode_uevent_init(ScrnInfoPtr scrn, drmmode_ptr drmmode)
 {
 #ifdef HAVE_UDEV
-	struct udev *u;
-	struct udev_monitor *mon;
-
-	u = udev_new();
-	if (!u)
-		return;
-	mon = udev_monitor_new_from_netlink(u, "udev");
-	if (!mon) {
-		udev_unref(u);
-		return;
-	}
-
-	if (udev_monitor_filter_add_match_subsystem_devtype(mon,
-							    "drm",
-							    "drm_minor") < 0 ||
-	    udev_monitor_enable_receiving(mon) < 0) {
-		udev_monitor_unref(mon);
-		udev_unref(u);
-		return;
-	}
-
-	drmmode->uevent_handler =
-		xf86AddGeneralHandler(udev_monitor_get_fd(mon),
-				      drmmode_handle_uevents,
-				      drmmode);
-
-	drmmode->uevent_monitor = mon;
+    struct udev *u;
+    struct udev_monitor *mon;
+
+    u = udev_new();
+    if (!u)
+        return;
+    mon = udev_monitor_new_from_netlink(u, "udev");
+    if (!mon) {
+        udev_unref(u);
+        return;
+    }
+
+    if (udev_monitor_filter_add_match_subsystem_devtype(mon,
+                                                        "drm",
+                                                        "drm_minor") < 0 ||
+        udev_monitor_enable_receiving(mon) < 0) {
+        udev_monitor_unref(mon);
+        udev_unref(u);
+        return;
+    }
+
+    drmmode->uevent_handler =
+        xf86AddGeneralHandler(udev_monitor_get_fd(mon),
+                              drmmode_handle_uevents, drmmode);
+
+    drmmode->uevent_monitor = mon;
 #endif
 }
 
-void drmmode_uevent_fini(ScrnInfoPtr scrn, drmmode_ptr drmmode)
+void
+drmmode_uevent_fini(ScrnInfoPtr scrn, drmmode_ptr drmmode)
 {
 #ifdef HAVE_UDEV
-	if (drmmode->uevent_handler) {
-		struct udev *u = udev_monitor_get_udev(drmmode->uevent_monitor);
-		xf86RemoveGeneralHandler(drmmode->uevent_handler);
+    if (drmmode->uevent_handler) {
+        struct udev *u = udev_monitor_get_udev(drmmode->uevent_monitor);
+
+        xf86RemoveGeneralHandler(drmmode->uevent_handler);
 
-		udev_monitor_unref(drmmode->uevent_monitor);
-		udev_unref(u);
-	}
+        udev_monitor_unref(drmmode->uevent_monitor);
+        udev_unref(u);
+    }
 #endif
 }
 
 /* create front and cursor BOs */
-Bool drmmode_create_initial_bos(ScrnInfoPtr pScrn, drmmode_ptr drmmode)
+Bool
+drmmode_create_initial_bos(ScrnInfoPtr pScrn, drmmode_ptr drmmode)
 {
-	modesettingPtr ms = modesettingPTR(pScrn);
-	xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
-	int width;
-	int height;
-	int bpp = pScrn->bitsPerPixel;
-	int i;
-	int cpp = (bpp + 7) / 8;
-
-	width = pScrn->virtualX;
-	height = pScrn->virtualY;
-
-	drmmode->front_bo = dumb_bo_create(drmmode->fd, width, height, bpp);
-	if (!drmmode->front_bo)
-		return FALSE;
-	pScrn->displayWidth = drmmode->front_bo->pitch / cpp;
-
-	width = ms->cursor_width;
-	height = ms->cursor_height;
-	bpp = 32;
-	for (i = 0; i < xf86_config->num_crtc; i++) {
-		xf86CrtcPtr crtc = xf86_config->crtc[i];
-		drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
-		drmmode_crtc->cursor_bo = dumb_bo_create(drmmode->fd, width, height, bpp);
-	}
-	return TRUE;
+    modesettingPtr ms = modesettingPTR(pScrn);
+    xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
+    int width;
+    int height;
+    int bpp = pScrn->bitsPerPixel;
+    int i;
+    int cpp = (bpp + 7) / 8;
+
+    width = pScrn->virtualX;
+    height = pScrn->virtualY;
+
+    drmmode->front_bo = dumb_bo_create(drmmode->fd, width, height, bpp);
+    if (!drmmode->front_bo)
+        return FALSE;
+    pScrn->displayWidth = drmmode->front_bo->pitch / cpp;
+
+    width = ms->cursor_width;
+    height = ms->cursor_height;
+    bpp = 32;
+    for (i = 0; i < xf86_config->num_crtc; i++) {
+        xf86CrtcPtr crtc = xf86_config->crtc[i];
+        drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+
+        drmmode_crtc->cursor_bo =
+            dumb_bo_create(drmmode->fd, width, height, bpp);
+    }
+    return TRUE;
 }
 
-void *drmmode_map_front_bo(drmmode_ptr drmmode)
+void *
+drmmode_map_front_bo(drmmode_ptr drmmode)
 {
-	int ret;
+    int ret;
 
-	if (drmmode->front_bo->ptr)
-		return drmmode->front_bo->ptr;
+    if (drmmode->front_bo->ptr)
+        return drmmode->front_bo->ptr;
 
-	ret = dumb_bo_map(drmmode->fd, drmmode->front_bo);
-	if (ret)
-		return NULL;
+    ret = dumb_bo_map(drmmode->fd, drmmode->front_bo);
+    if (ret)
+        return NULL;
+
+    return drmmode->front_bo->ptr;
 
-	return drmmode->front_bo->ptr;
-	
 }
 
-void *drmmode_map_slave_bo(drmmode_ptr drmmode, msPixmapPrivPtr ppriv)
+void *
+drmmode_map_slave_bo(drmmode_ptr drmmode, msPixmapPrivPtr ppriv)
 {
-        int ret;
+    int ret;
 
-        if (ppriv->backing_bo->ptr)
-                return ppriv->backing_bo->ptr;
+    if (ppriv->backing_bo->ptr)
+        return ppriv->backing_bo->ptr;
 
-        ret = dumb_bo_map(drmmode->fd, ppriv->backing_bo);
-        if (ret)
-                return NULL;
+    ret = dumb_bo_map(drmmode->fd, ppriv->backing_bo);
+    if (ret)
+        return NULL;
 
-        return ppriv->backing_bo->ptr;  
+    return ppriv->backing_bo->ptr;
 }
 
-Bool drmmode_map_cursor_bos(ScrnInfoPtr pScrn, drmmode_ptr drmmode)
+Bool
+drmmode_map_cursor_bos(ScrnInfoPtr pScrn, drmmode_ptr drmmode)
 {
-	xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
-	int i, ret;
-	for (i = 0; i < xf86_config->num_crtc; i++) {
-		xf86CrtcPtr crtc = xf86_config->crtc[i];
-		drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
-		ret = dumb_bo_map(drmmode->fd, drmmode_crtc->cursor_bo);
-		if (ret)
-			return FALSE;
-	}
-	return TRUE;
+    xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
+    int i, ret;
+
+    for (i = 0; i < xf86_config->num_crtc; i++) {
+        xf86CrtcPtr crtc = xf86_config->crtc[i];
+        drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+
+        ret = dumb_bo_map(drmmode->fd, drmmode_crtc->cursor_bo);
+        if (ret)
+            return FALSE;
+    }
+    return TRUE;
 }
 
-void drmmode_free_bos(ScrnInfoPtr pScrn, drmmode_ptr drmmode)
+void
+drmmode_free_bos(ScrnInfoPtr pScrn, drmmode_ptr drmmode)
 {
-	xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
-	int i;
-
-	if (drmmode->fb_id) {
-		drmModeRmFB(drmmode->fd, drmmode->fb_id);
-		drmmode->fb_id = 0;
-	}
-
-	dumb_bo_destroy(drmmode->fd, drmmode->front_bo);
-	drmmode->front_bo = NULL;
-
-	for (i = 0; i < xf86_config->num_crtc; i++) {
-		xf86CrtcPtr crtc = xf86_config->crtc[i];
-		drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
-		dumb_bo_destroy(drmmode->fd, drmmode_crtc->cursor_bo);
-	}
+    xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
+    int i;
+
+    if (drmmode->fb_id) {
+        drmModeRmFB(drmmode->fd, drmmode->fb_id);
+        drmmode->fb_id = 0;
+    }
+
+    dumb_bo_destroy(drmmode->fd, drmmode->front_bo);
+    drmmode->front_bo = NULL;
+
+    for (i = 0; i < xf86_config->num_crtc; i++) {
+        xf86CrtcPtr crtc = xf86_config->crtc[i];
+        drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private;
+
+        dumb_bo_destroy(drmmode->fd, drmmode_crtc->cursor_bo);
+    }
 }
 
 /* ugly workaround to see if we can create 32bpp */
-void drmmode_get_default_bpp(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int *depth, int *bpp)
+void
+drmmode_get_default_bpp(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int *depth,
+                        int *bpp)
 {
-	drmModeResPtr mode_res;
-	uint64_t value;
-	struct dumb_bo *bo;
-	uint32_t fb_id;
-	int ret;
-
-	/* 16 is fine */
-	ret = drmGetCap(drmmode->fd, DRM_CAP_DUMB_PREFERRED_DEPTH, &value);
-	if (!ret && (value == 16 || value == 8)) {
-		*depth = value;
-		*bpp = value;
-		return;
-	}
-
-	*depth = 24;
-	mode_res = drmModeGetResources(drmmode->fd);
-	if (!mode_res)
-		return;
-
-	if (mode_res->min_width == 0)
-		mode_res->min_width = 1;
-	if (mode_res->min_height == 0)
-		mode_res->min_height = 1;
-	/*create a bo */
-	bo = dumb_bo_create(drmmode->fd, mode_res->min_width, mode_res->min_height, 32);
-	if (!bo) {
-		*bpp = 24;
-		goto out;
-	}
-
-	ret = drmModeAddFB(drmmode->fd, mode_res->min_width, mode_res->min_height,
-			    24, 32, bo->pitch, bo->handle, &fb_id);
-
-	if (ret) {
-		*bpp = 24;
-		dumb_bo_destroy(drmmode->fd, bo);
-		goto out;
-	}
-
-	drmModeRmFB(drmmode->fd, fb_id);
-	*bpp = 32;
-
-	dumb_bo_destroy(drmmode->fd, bo);
-out:	
-	drmModeFreeResources(mode_res);
-	return;
+    drmModeResPtr mode_res;
+    uint64_t value;
+    struct dumb_bo *bo;
+    uint32_t fb_id;
+    int ret;
+
+    /* 16 is fine */
+    ret = drmGetCap(drmmode->fd, DRM_CAP_DUMB_PREFERRED_DEPTH, &value);
+    if (!ret && (value == 16 || value == 8)) {
+        *depth = value;
+        *bpp = value;
+        return;
+    }
+
+    *depth = 24;
+    mode_res = drmModeGetResources(drmmode->fd);
+    if (!mode_res)
+        return;
+
+    if (mode_res->min_width == 0)
+        mode_res->min_width = 1;
+    if (mode_res->min_height == 0)
+        mode_res->min_height = 1;
+    /*create a bo */
+    bo = dumb_bo_create(drmmode->fd, mode_res->min_width, mode_res->min_height,
+                        32);
+    if (!bo) {
+        *bpp = 24;
+        goto out;
+    }
+
+    ret = drmModeAddFB(drmmode->fd, mode_res->min_width, mode_res->min_height,
+                       24, 32, bo->pitch, bo->handle, &fb_id);
+
+    if (ret) {
+        *bpp = 24;
+        dumb_bo_destroy(drmmode->fd, bo);
+        goto out;
+    }
+
+    drmModeRmFB(drmmode->fd, fb_id);
+    *bpp = 32;
+
+    dumb_bo_destroy(drmmode->fd, bo);
+ out:
+    drmModeFreeResources(mode_res);
+    return;
 }
diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.h b/hw/xfree86/drivers/modesetting/drmmode_display.h
index 7bfe885..438743b 100644
--- a/hw/xfree86/drivers/modesetting/drmmode_display.h
+++ b/hw/xfree86/drivers/modesetting/drmmode_display.h
@@ -74,11 +74,10 @@ typedef struct {
 typedef struct {
     drmModePropertyPtr mode_prop;
     uint64_t value;
-    int num_atoms; /* if range prop, num_atoms == 1; if enum prop, num_atoms == num_enums + 1 */
+    int num_atoms;              /* if range prop, num_atoms == 1; if enum prop, num_atoms == num_enums + 1 */
     Atom *atoms;
 } drmmode_prop_rec, *drmmode_prop_ptr;
 
-
 typedef struct {
     drmmode_ptr drmmode;
     int output_id;
@@ -97,16 +96,16 @@ typedef struct _msPixmapPriv {
     struct dumb_bo *backing_bo; /* if this pixmap is backed by a dumb bo */
 } msPixmapPrivRec, *msPixmapPrivPtr;
 
-
 extern DevPrivateKeyRec msPixmapPrivateKeyRec;
+
 #define msPixmapPrivateKey (&msPixmapPrivateKeyRec)
 
 #define msGetPixmapPriv(drmmode, p) ((msPixmapPrivPtr)dixGetPrivateAddr(&(p)->devPrivates, &(drmmode)->pixmapPrivateKeyRec))
 
 void *drmmode_map_slave_bo(drmmode_ptr drmmode, msPixmapPrivPtr ppriv);
 Bool drmmode_SetSlaveBO(PixmapPtr ppix,
-			drmmode_ptr drmmode,
-			int fd_handle, int pitch, int size);
+                        drmmode_ptr drmmode,
+                        int fd_handle, int pitch, int size);
 
 extern Bool drmmode_pre_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int cpp);
 void drmmode_adjust_frame(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int x, int y);
@@ -120,8 +119,8 @@ Bool drmmode_create_initial_bos(ScrnInfoPtr pScrn, drmmode_ptr drmmode);
 void *drmmode_map_front_bo(drmmode_ptr drmmode);
 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);
-
+void drmmode_get_default_bpp(ScrnInfoPtr pScrn, drmmode_ptr drmmmode,
+                             int *depth, int *bpp);
 
 #ifndef DRM_CAP_DUMB_PREFERRED_DEPTH
 #define DRM_CAP_DUMB_PREFERRED_DEPTH 3
@@ -132,5 +131,4 @@ void drmmode_get_default_bpp(ScrnInfoPtr pScrn, drmmode_ptr drmmmode, int *depth
 
 #define MS_ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
 
-
 #endif
commit c79f824bf6617816aaf10393beec8dddfa591f7b
Author: Adam Jackson <ajax at redhat.com>
Date:   Thu Sep 25 15:49:26 2014 -0400

    xwin: Remove primary DirectDraw engine
    
    Again, as the documentation says, "unsupported, obsolete".
    
    Reviewed-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/configure.ac b/configure.ac
index a12e9e2..3a72947 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2206,7 +2206,6 @@ AM_CONDITIONAL(XWIN_MULTIWINDOW, [test "x$XWIN" = xyes])
 AM_CONDITIONAL(XWIN_MULTIWINDOWEXTWM, [test "x$XWIN" = xyes && test "x$WINDOWSWM" = xyes])
 AM_CONDITIONAL(XWIN_CLIPBOARD, [test "x$XWIN" = xyes])
 AM_CONDITIONAL(XWIN_GLX_WINDOWS, [test "x$XWIN" = xyes && test "x$AIGLX" = xyes])
-AM_CONDITIONAL(XWIN_PRIMARYFB, [test "x$XWIN" = xyes])
 AM_CONDITIONAL(XWIN_RANDR, [test "x$XWIN" = xyes])
 AM_CONDITIONAL(XWIN_XV, [test "x$XWIN" = xyes && test "x$XV" = xyes])
 
diff --git a/hw/xwin/InitOutput.c b/hw/xwin/InitOutput.c
index 96e1006..e867119 100644
--- a/hw/xwin/InitOutput.c
+++ b/hw/xwin/InitOutput.c
@@ -735,9 +735,6 @@ winUseMsg(void)
            "\t\t1 - Shadow GDI\n"
            "\t\t2 - Shadow DirectDraw\n"
            "\t\t4 - Shadow DirectDraw4 Non-Locking\n"
-#ifdef XWIN_PRIMARYFB
-           "\t\t8 - Primary DirectDraw - obsolete\n"
-#endif
         );
 
     ErrorF("-fullscreen\n" "\tRun the server in fullscreen mode.\n");
diff --git a/hw/xwin/Makefile.am b/hw/xwin/Makefile.am
index dea55b4..0ea8ba7 100644
--- a/hw/xwin/Makefile.am
+++ b/hw/xwin/Makefile.am
@@ -37,12 +37,6 @@ DEFS_MULTIWINDOWEXTWM = -DXWIN_MULTIWINDOWEXTWM
 MULTIWINDOWEXTWM_LIBS = $(top_builddir)/miext/rootless/librootless.la
 endif
 
-if XWIN_PRIMARYFB
-SRCS_PRIMARYFB = \
-	winpfbdd.c
-DEFS_PRIMARYFB = -DXWIN_PRIMARYFB
-endif
-
 if XWIN_RANDR
 SRCS_RANDR = \
 	winrandr.c
diff --git a/hw/xwin/man/XWin.man b/hw/xwin/man/XWin.man
index f3eca1e..a043ac2 100644
--- a/hw/xwin/man/XWin.man
+++ b/hw/xwin/man/XWin.man
@@ -261,8 +261,6 @@ Shadow GDI
 Shadow DirectDraw
 .IP 4 4
 Shadow DirectDraw Non-Locking
-.IP 8 4
-Primary DirectDraw (unsupported, obsolete)
 .RE
 
 .SH FULLSCREEN OPTIONS
diff --git a/hw/xwin/win.h b/hw/xwin/win.h
index 6b3e42a..ed1ad01 100644
--- a/hw/xwin/win.h
+++ b/hw/xwin/win.h
@@ -103,9 +103,6 @@
 #define WIN_SERVER_SHADOW_GDI	0x1L    /* 1 */
 #define WIN_SERVER_SHADOW_DD	0x2L    /* 2 */
 #define WIN_SERVER_SHADOW_DDNL	0x4L    /* 4 */
-#ifdef XWIN_PRIMARYFB
-#define WIN_SERVER_PRIMARY_DD	0x8L    /* 8 */
-#endif
 
 #define AltMapIndex		Mod1MapIndex
 #define NumLockMapIndex		Mod2MapIndex
@@ -913,15 +910,6 @@ winMouseButtonsHandle(ScreenPtr pScreen,
 void
  winEnqueueMotion(int x, int y);
 
-#ifdef XWIN_PRIMARYFB
-/*
- * winpfbddd.c
- */
-
-Bool
- winSetEngineFunctionsPrimaryDD(ScreenPtr pScreen);
-#endif
-
 /*
  * winscrinit.c
  */
diff --git a/hw/xwin/winengine.c b/hw/xwin/winengine.c
index 8aa9051..b473b3a 100644
--- a/hw/xwin/winengine.c
+++ b/hw/xwin/winengine.c
@@ -90,15 +90,6 @@ winDetectSupportedEngines(void)
             winErrorFVerb(2,
                           "winDetectSupportedEngines - DirectDraw installed, allowing ShadowDD\n");
             g_dwEnginesSupported |= WIN_SERVER_SHADOW_DD;
-
-#ifdef XWIN_PRIMARYFB
-            /* Allow PrimaryDD engine if NT */
-            if (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT) {
-                g_dwEnginesSupported |= WIN_SERVER_PRIMARY_DD;
-                winErrorFVerb(2,
-                              "winDetectSupportedEngines - Windows NT, allowing PrimaryDD\n");
-            }
-#endif
         }
 
         /* Try to query for DirectDraw4 interface */
@@ -202,11 +193,6 @@ winSetEngine(ScreenPtr pScreen)
         case WIN_SERVER_SHADOW_DDNL:
             winSetEngineFunctionsShadowDDNL(pScreen);
             break;
-#ifdef XWIN_PRIMARYFB
-        case WIN_SERVER_PRIMARY_DD:
-            winSetEngineFunctionsPrimaryDD(pScreen);
-            break;
-#endif
         default:
             FatalError("winSetEngine - Invalid engine type\n");
         }
diff --git a/hw/xwin/winpfbdd.c b/hw/xwin/winpfbdd.c
deleted file mode 100644
index 0106161..0000000
--- a/hw/xwin/winpfbdd.c
+++ /dev/null
@@ -1,620 +0,0 @@
-/*
- *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
- *
- *Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- *"Software"), to deal in the Software without restriction, including
- *without limitation the rights to use, copy, modify, merge, publish,
- *distribute, 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 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 XFREE86 PROJECT 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.
- *
- *Except as contained in this notice, the name of the XFree86 Project
- *shall not be used in advertising or otherwise to promote the sale, use
- *or other dealings in this Software without prior written authorization
- *from the XFree86 Project.
- *
- * Authors:	Dakshinamurthy Karra
- *		Suhaib M Siddiqi
- *		Peter Busch
- *		Harold L Hunt II
- */
-
-#ifdef HAVE_XWIN_CONFIG_H
-#include <xwin-config.h>
-#endif
-#include "win.h"
-
-/*
- * Local function prototypes
- */
-
-static Bool
- winAllocateFBPrimaryDD(ScreenPtr pScreen);
-
-static Bool
- winCloseScreenPrimaryDD(ScreenPtr pScreen);
-
-static Bool
- winInitVisualsPrimaryDD(ScreenPtr pScreen);
-
-static Bool
- winAdjustVideoModePrimaryDD(ScreenPtr pScreen);
-
-static Bool
- winActivateAppPrimaryDD(ScreenPtr pScreen);
-
-static Bool
- winHotKeyAltTabPrimaryDD(ScreenPtr pScreen);
-
-/*
- * Create a DirectDraw primary surface 
- */
-
-static Bool
-winAllocateFBPrimaryDD(ScreenPtr pScreen)
-{
-    winScreenPriv(pScreen);
-    winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
-    HRESULT ddrval = DD_OK;
-    DDSURFACEDESC ddsd;
-    DDSURFACEDESC *pddsdPrimary = NULL;
-    DDSURFACEDESC *pddsdOffscreen = NULL;
-    RECT rcClient;
-
-    ErrorF("winAllocateFBPrimaryDD\n");
-
-    /* Get client area location in screen coords */
-    GetClientRect(pScreenPriv->hwndScreen, &rcClient);
-    MapWindowPoints(pScreenPriv->hwndScreen,
-                    HWND_DESKTOP, (LPPOINT) &rcClient, 2);
-
-    /* Create a DirectDraw object, store the address at lpdd */
-    ddrval = (*g_fpDirectDrawCreate) (NULL, &pScreenPriv->pdd, NULL);
-    if (ddrval != DD_OK)
-        FatalError("winAllocateFBPrimaryDD - Could not start DirectDraw\n");
-
-    /* Get a DirectDraw2 interface pointer */
-    ddrval = IDirectDraw_QueryInterface(pScreenPriv->pdd,
-                                        &IID_IDirectDraw2,
-                                        (LPVOID *) &pScreenPriv->pdd2);
-    if (FAILED(ddrval)) {
-        ErrorF("winAllocateFBShadowDD - Failed DD2 query: %08x\n",
-               (unsigned int) ddrval);
-        return FALSE;
-    }
-
-    ErrorF("winAllocateFBPrimaryDD - Created and initialized DD\n");
-
-    /* Are we windowed or fullscreen? */
-    if (pScreenInfo->fFullScreen) {
-        /* Full screen mode */
-        ddrval = IDirectDraw2_SetCooperativeLevel(pScreenPriv->pdd2,
-                                                  pScreenPriv->hwndScreen,
-                                                  DDSCL_FULLSCREEN
-                                                  | DDSCL_EXCLUSIVE);
-        if (FAILED(ddrval))
-            FatalError("winAllocateFBPrimaryDD - Could not set "
-                       "cooperative level\n");
-
-        /* Change the video mode to the mode requested */
-        ddrval = IDirectDraw2_SetDisplayMode(pScreenPriv->pdd2,
-                                             pScreenInfo->dwWidth,
-                                             pScreenInfo->dwHeight,
-                                             pScreenInfo->dwBPP,
-                                             pScreenInfo->dwRefreshRate, 0);
-        if (FAILED(ddrval))
-            FatalError("winAllocateFBPrimaryDD - Could not set "
-                       "full screen display mode\n");
-    }
-    else {
-        /* Windowed mode */
-        ddrval = IDirectDraw2_SetCooperativeLevel(pScreenPriv->pdd2,
-                                                  pScreenPriv->hwndScreen,
-                                                  DDSCL_NORMAL);
-        if (FAILED(ddrval))
-            FatalError("winAllocateFBPrimaryDD - Could not set "
-                       "cooperative level\n");
-    }
-
-    /* Describe the primary surface */
-    ZeroMemory(&ddsd, sizeof(ddsd));
-    ddsd.dwSize = sizeof(ddsd);
-    ddsd.dwFlags = DDSD_CAPS;
-    ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
-
-    /* Create the primary surface */
-    ddrval = IDirectDraw2_CreateSurface(pScreenPriv->pdd2,
-                                        &ddsd, &pScreenPriv->pddsPrimary, NULL);
-    if (FAILED(ddrval))
-        FatalError("winAllocateFBPrimaryDD - Could not create primary "
-                   "surface %08x\n", (unsigned int) ddrval);
-
-    ErrorF("winAllocateFBPrimaryDD - Created primary\n");
-
-    /* Allocate a DD surface description for our screen privates */
-    pddsdPrimary = pScreenPriv->pddsdPrimary = malloc(sizeof(DDSURFACEDESC));
-    if (pddsdPrimary == NULL)
-        FatalError("winAllocateFBPrimaryDD - Could not allocate surface "
-                   "description memory\n");
-    ZeroMemory(pddsdPrimary, sizeof(*pddsdPrimary));
-    pddsdPrimary->dwSize = sizeof(*pddsdPrimary);
-
-    /* Describe the offscreen surface to be created */
-    /*
-     * NOTE: Do not use a DDSCAPS_VIDEOMEMORY surface,
-     * as drawing, locking, and unlocking take forever
-     * with video memory surfaces.  In addition,
-     * video memory is a somewhat scarce resource,
-     * so you shouldn't be allocating video memory when
-     * you have the option of using system memory instead.
-     */
-    ZeroMemory(&ddsd, sizeof(ddsd));
-    ddsd.dwSize = sizeof(ddsd);
-    ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
-    ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY;
-    ddsd.dwHeight = pScreenInfo->dwHeight;
-    ddsd.dwWidth = pScreenInfo->dwWidth;
-
-    /* Create the shadow surface */
-    ddrval = IDirectDraw2_CreateSurface(pScreenPriv->pdd2,
-                                        &ddsd,
-                                        &pScreenPriv->pddsOffscreen, NULL);
-    if (ddrval != DD_OK)
-        FatalError("winAllocateFBPrimaryDD - Could not create shadow "
-                   "surface\n");
-
-    ErrorF("winAllocateFBPrimaryDD - Created offscreen\n");
-
-    /* Allocate a DD surface description for our screen privates */
-    pddsdOffscreen = pScreenPriv->pddsdOffscreen
-        = malloc(sizeof(DDSURFACEDESC));
-    if (pddsdOffscreen == NULL)
-        FatalError("winAllocateFBPrimaryDD - Could not allocate surface "
-                   "description memory\n");
-    ZeroMemory(pddsdOffscreen, sizeof(*pddsdOffscreen));
-    pddsdOffscreen->dwSize = sizeof(*pddsdOffscreen);
-
-    ErrorF("winAllocateFBPrimaryDD - Locking primary\n");
-
-    /* Lock the primary surface */
-    ddrval = IDirectDrawSurface2_Lock(pScreenPriv->pddsPrimary,
-                                      pScreenInfo->
-                                      fFullScreen ? NULL : &rcClient,
-                                      pddsdPrimary, DDLOCK_WAIT, NULL);
-    if (ddrval != DD_OK || pddsdPrimary->lpSurface == NULL)
-        FatalError("winAllocateFBPrimaryDD - Could not lock "
-                   "primary surface\n");
-
-    ErrorF("winAllocateFBPrimaryDD - Locked primary\n");
-
-    /* We don't know how to deal with anything other than RGB */
-    if (!(pddsdPrimary->ddpfPixelFormat.dwFlags & DDPF_RGB))
-        FatalError("winAllocateFBPrimaryDD - Color format other than RGB\n");
-
-    /* Grab the pitch from the surface desc */
-    pScreenInfo->dwStride = (pddsdPrimary->u1.lPitch * 8)
-        / pScreenInfo->dwBPP;
-
-    /* Save the pointer to our surface memory */
-    pScreenInfo->pfb = pddsdPrimary->lpSurface;
-
-    /* Grab the color depth and masks from the surface description */
-    pScreenPriv->dwRedMask = pddsdPrimary->ddpfPixelFormat.u2.dwRBitMask;
-    pScreenPriv->dwGreenMask = pddsdPrimary->ddpfPixelFormat.u3.dwGBitMask;
-    pScreenPriv->dwBlueMask = pddsdPrimary->ddpfPixelFormat.u4.dwBBitMask;
-
-    ErrorF("winAllocateFBPrimaryDD - Returning\n");
-
-    return TRUE;
-}
-
-static void
-winFreeFBPrimaryDD(ScreenPtr pScreen)
-{
-    winScreenPriv(pScreen);
-    winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
-
-    /* Free the offscreen surface, if there is one */
-    if (pScreenPriv->pddsOffscreen) {
-        IDirectDrawSurface2_Unlock(pScreenPriv->pddsOffscreen, NULL);
-        IDirectDrawSurface2_Release(pScreenPriv->pddsOffscreen);
-        pScreenPriv->pddsOffscreen = NULL;
-    }
-
-    /* Release the primary surface, if there is one */
-    if (pScreenPriv->pddsPrimary) {
-        IDirectDrawSurface2_Unlock(pScreenPriv->pddsPrimary, NULL);
-        IDirectDrawSurface2_Release(pScreenPriv->pddsPrimary);
-        pScreenPriv->pddsPrimary = NULL;
-    }
-
-    /* Free the DirectDraw object, if there is one */
-    if (pScreenPriv->pdd) {
-        IDirectDraw2_RestoreDisplayMode(pScreenPriv->pdd);
-        IDirectDraw2_Release(pScreenPriv->pdd);
-        pScreenPriv->pdd = NULL;
-    }
-
-    /* Invalidate the ScreenInfo's fb pointer */
-    pScreenInfo->pfb = NULL;
-}
-
-static Bool
-winInitScreenPrimaryDD(ScreenPtr pScreen)
-{
-    return winAllocateFBPrimaryDD(pScreen);
-}
-
-/*
- * Call the wrapped CloseScreen function.
- * 
- * Free our resources and private structures.
- */
-
-static Bool
-winCloseScreenPrimaryDD(ScreenPtr pScreen)
-{
-    winScreenPriv(pScreen);
-    winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
-    Bool fReturn;
-
-    ErrorF("winCloseScreenPrimaryDD - Freeing screen resources\n");
-
-    /* Flag that the screen is closed */
-    pScreenPriv->fClosed = TRUE;
-    pScreenPriv->fActive = FALSE;
-
-    /* Call the wrapped CloseScreen procedure */
-    WIN_UNWRAP(CloseScreen);
-    if (pScreen->CloseScreen)
-        fReturn = (*pScreen->CloseScreen) (pScreen);
-
-    /* Delete the window property */
-    RemoveProp(pScreenPriv->hwndScreen, WIN_SCR_PROP);
-
-    winFreeFBPrimaryDD(pScreen);
-
-    /* Delete tray icon, if we have one */
-    if (!pScreenInfo->fNoTrayIcon)
-        winDeleteNotifyIcon(pScreenPriv);
-
-    /* Free the exit confirmation dialog box, if it exists */
-    if (g_hDlgExit != NULL) {
-        DestroyWindow(g_hDlgExit);
-        g_hDlgExit = NULL;
-    }
-
-    /* Kill our window */
-    if (pScreenPriv->hwndScreen) {
-        DestroyWindow(pScreenPriv->hwndScreen);
-        pScreenPriv->hwndScreen = NULL;
-    }
-
-    /* Kill our screeninfo's pointer to the screen */
-    pScreenInfo->pScreen = NULL;
-
-    /* Free the screen privates for this screen */
-    free((void *) pScreenPriv);
-
-    return fReturn;
-}
-
-/*
- * Tell mi what sort of visuals we need.
- * 
- * Generally we only need one visual, as our screen can only
- * handle one format at a time, I believe.  You may want
- * to verify that last sentence.
- */
-
-static Bool
-winInitVisualsPrimaryDD(ScreenPtr pScreen)
-{
-    winScreenPriv(pScreen);
-    winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
-    DWORD dwRedBits, dwGreenBits, dwBlueBits;
-
-    /* Count the number of ones in each color mask */
-    dwRedBits = winCountBits(pScreenPriv->dwRedMask);
-    dwGreenBits = winCountBits(pScreenPriv->dwGreenMask);
-    dwBlueBits = winCountBits(pScreenPriv->dwBlueMask);
-
-    /* Store the maximum number of ones in a color mask as the bitsPerRGB */
-    if (dwRedBits > dwGreenBits && dwRedBits > dwBlueBits)
-        pScreenPriv->dwBitsPerRGB = dwRedBits;
-    else if (dwGreenBits > dwRedBits && dwGreenBits > dwBlueBits)
-        pScreenPriv->dwBitsPerRGB = dwGreenBits;
-    else
-        pScreenPriv->dwBitsPerRGB = dwBlueBits;
-
-    ErrorF("winInitVisualsPrimaryDD - Masks: %08x %08x %08x bpRGB: %d\n",
-           (unsigned int) pScreenPriv->dwRedMask,
-           (unsigned int) pScreenPriv->dwGreenMask,
-           (unsigned int) pScreenPriv->dwBlueMask,
-           (int) pScreenPriv->dwBitsPerRGB);
-
-    /* Create a single visual according to the Windows screen depth */
-    switch (pScreenInfo->dwDepth) {
-    case 24:
-    case 16:
-    case 15:
-        if (!miSetVisualTypesAndMasks(pScreenInfo->dwDepth,
-                                      TrueColorMask,
-                                      pScreenPriv->dwBitsPerRGB,
-                                      TrueColor,
-                                      pScreenPriv->dwRedMask,
-                                      pScreenPriv->dwGreenMask,
-                                      pScreenPriv->dwBlueMask)) {
-            ErrorF("winInitVisualsPrimaryDD - "
-                   "miSetVisualTypesAndMasks failed\n");
-            return FALSE;
-        }
-        break;
-
-    case 8:
-#if CYGDEBUG
-        winDebug("winInitVisuals - Calling miSetVisualTypesAndMasks\n");
-#endif                          /* CYGDEBUG */
-        if (!miSetVisualTypesAndMasks(pScreenInfo->dwDepth,
-                                      PseudoColorMask,
-                                      pScreenPriv->dwBitsPerRGB,
-                                      PseudoColor,
-                                      pScreenPriv->dwRedMask,
-                                      pScreenPriv->dwGreenMask,
-                                      pScreenPriv->dwBlueMask)) {
-            ErrorF("winInitVisualsPrimaryDD - "
-                   "miSetVisualTypesAndMasks failed\n");
-            return FALSE;
-        }
-#if CYGDEBUG
-        winDebug("winInitVisualsPrimaryDD - Returned from "
-                 "miSetVisualTypesAndMasks\n");
-#endif                          /* CYGDEBUG */
-        break;
-
-    default:
-        ErrorF("winInitVisualsPrimaryDD - Unknown screen depth\n");
-        return FALSE;
-    }
-
-    ErrorF("winInitVisualsPrimaryDD - Returning\n");
-
-    return TRUE;
-}
-
-static Bool
-winAdjustVideoModePrimaryDD(ScreenPtr pScreen)
-{
-    winScreenPriv(pScreen);
-    winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
-    HDC hdc = NULL;
-    DWORD dwBPP;
-
-    /* We're in serious trouble if we can't get a DC */
-    hdc = GetDC(NULL);
-    if (hdc == NULL) {
-        ErrorF("winAdjustVideoModePrimaryDD - GetDC failed\n");
-        return FALSE;
-    }
-
-    /* Query GDI for current display depth */
-    dwBPP = GetDeviceCaps(hdc, BITSPIXEL);
-
-    /* DirectDraw can only change the depth in fullscreen mode */
-    if (!(pScreenInfo->fFullScreen && (pScreenInfo->dwBPP != WIN_DEFAULT_BPP))) {
-        /* Otherwise, We'll use GDI's depth */
-        pScreenInfo->dwBPP = dwBPP;
-    }
-
-    /* Release our DC */
-    ReleaseDC(NULL, hdc);
-
-    return TRUE;
-}
-
-/*
- * We need to blit our offscreen fb to
- * the screen when we are activated, and we need to point
- * the fb code back to the primary surface memory.
- */
-
-static Bool
-winActivateAppPrimaryDD(ScreenPtr pScreen)
-{
-    winScreenPriv(pScreen);
-    RECT rcSrc, rcClient;
-    HRESULT ddrval = DD_OK;
-
-    /* Check for errors */
-    if (pScreenPriv == NULL
-        || pScreenPriv->pScreenInfo == NULL
-        || pScreenPriv->pddsPrimary == NULL
-        || pScreenPriv->pddsOffscreen == NULL)
-        return FALSE;
-
-    /* Check for do-nothing */
-    if (!pScreenPriv->fActive)
-        return TRUE;
-
-    /* We are activating */
-    ddrval = IDirectDrawSurface2_IsLost(pScreenPriv->pddsOffscreen);
-    if (ddrval == DD_OK) {
-        IDirectDrawSurface2_Unlock(pScreenPriv->pddsOffscreen, NULL);
-        /*
-         * We don't check for an error from Unlock, because it
-         * doesn't matter if the Unlock failed.
-         */
-    }
-
-    /* Restore both surfaces, just cause I like it that way */
-    IDirectDrawSurface2_Restore(pScreenPriv->pddsOffscreen);
-    IDirectDrawSurface2_Restore(pScreenPriv->pddsPrimary);
-
-    /* Get client area in screen coords */
-    GetClientRect(pScreenPriv->hwndScreen, &rcClient);
-    MapWindowPoints(pScreenPriv->hwndScreen,
-                    HWND_DESKTOP, (LPPOINT) &rcClient, 2);
-
-    /* Setup a source rectangle */
-    rcSrc.left = 0;
-    rcSrc.top = 0;
-    rcSrc.right = pScreenPriv->pScreenInfo->dwWidth;
-    rcSrc.bottom = pScreenPriv->pScreenInfo->dwHeight;
-
-    ddrval = IDirectDrawSurface2_Blt(pScreenPriv->pddsPrimary,
-                                     &rcClient,
-                                     pScreenPriv->pddsOffscreen,
-                                     &rcSrc, DDBLT_WAIT, NULL);
-    if (ddrval != DD_OK)
-        FatalError("winActivateAppPrimaryDD () - Failed blitting offscreen "
-                   "surface to primary surface %08x\n", (unsigned int) ddrval);
-
-    /* Lock the primary surface */
-    ddrval = IDirectDrawSurface2_Lock(pScreenPriv->pddsPrimary,
-                                      &rcClient,
-                                      pScreenPriv->pddsdPrimary,
-                                      DDLOCK_WAIT, NULL);
-    if (ddrval != DD_OK || pScreenPriv->pddsdPrimary->lpSurface == NULL)
-        FatalError("winActivateAppPrimaryDD () - Could not lock "
-                   "primary surface\n");
-
-    /* Notify FB of the new memory pointer */
-    winUpdateFBPointer(pScreen, pScreenPriv->pddsdPrimary->lpSurface);
-
-    /*
-     * Register the Alt-Tab combo as a hotkey so we can copy
-     * the primary framebuffer before the display mode changes
-     */
-    RegisterHotKey(pScreenPriv->hwndScreen, 1, MOD_ALT, 9);
-
-    return TRUE;
-}
-
-/*
- * Handle the Alt+Tab hotkey.
- *
- * We need to save the primary fb to an offscreen fb when
- * we get deactivated, and point the fb code at the offscreen
- * fb for the duration of the deactivation.
- */
-
-static Bool
-winHotKeyAltTabPrimaryDD(ScreenPtr pScreen)
-{
-    winScreenPriv(pScreen);
-    HRESULT ddrval = DD_OK;
-
-    ErrorF("\nwinHotKeyAltTabPrimaryDD\n\n");
-
-    /* Alt+Tab was pressed, we will lose focus very soon */
-    pScreenPriv->fActive = FALSE;
-
-    /* Check for error conditions */
-    if (pScreenPriv->pddsPrimary == NULL || pScreenPriv->pddsOffscreen == NULL)
-        return FALSE;
-
-    /* Did we loose the primary surface? */
-    ddrval = IDirectDrawSurface2_IsLost(pScreenPriv->pddsPrimary);
-    if (ddrval == DD_OK) {
-        ddrval = IDirectDrawSurface2_Unlock(pScreenPriv->pddsPrimary, NULL);
-        if (FAILED(ddrval))
-            FatalError("winHotKeyAltTabPrimaryDD - Failed unlocking primary "
-                       "surface\n");
-    }
-
-    /* Blit the primary surface to the offscreen surface */
-    ddrval = IDirectDrawSurface2_Blt(pScreenPriv->pddsOffscreen, NULL,  /* should be rcDest */
-                                     pScreenPriv->pddsPrimary,
-                                     NULL, DDBLT_WAIT, NULL);
-    if (ddrval == DDERR_SURFACELOST) {
-        IDirectDrawSurface2_Restore(pScreenPriv->pddsOffscreen);
-        IDirectDrawSurface2_Restore(pScreenPriv->pddsPrimary);
-
-        /* Blit the primary surface to the offscreen surface */
-        ddrval = IDirectDrawSurface2_Blt(pScreenPriv->pddsOffscreen,
-                                         NULL,
-                                         pScreenPriv->pddsPrimary,
-                                         NULL, DDBLT_WAIT, NULL);
-        if (FAILED(ddrval))
-            FatalError("winHotKeyAltTabPrimaryDD - Failed blitting primary "
-                       "surface to offscreen surface: %08x\n",
-                       (unsigned int) ddrval);
-    }
-    else {
-        FatalError("winHotKeyAltTabPrimaryDD - Unknown error from "
-                   "Blt: %08dx\n", (unsigned int) ddrval);
-    }
-
-    /* Lock the offscreen surface */
-    ddrval = IDirectDrawSurface2_Lock(pScreenPriv->pddsOffscreen,
-                                      NULL,
-                                      pScreenPriv->pddsdOffscreen,
-                                      DDLOCK_WAIT, NULL);
-    if (ddrval != DD_OK || pScreenPriv->pddsdPrimary->lpSurface == NULL)
-        FatalError("winHotKeyAltTabPrimaryDD - Could not lock "
-                   "offscreen surface\n");
-
-    /* Notify FB of the new memory pointer */
-    winUpdateFBPointer(pScreen, pScreenPriv->pddsdOffscreen->lpSurface);
-
-    /* Unregister our hotkey */
-    UnregisterHotKey(pScreenPriv->hwndScreen, 1);
-
-    return TRUE;
-}
-
-/* Set engine specific functions */
-Bool
-winSetEngineFunctionsPrimaryDD(ScreenPtr pScreen)
-{
-    winScreenPriv(pScreen);
-    winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
-
-    /* Set our pointers */
-    pScreenPriv->pwinAllocateFB = winAllocateFBPrimaryDD;
-    pScreenPriv->pwinFreeFB = winFreeFBPrimaryDD;
-    pScreenPriv->pwinShadowUpdate =
-        (winShadowUpdateProcPtr) (void (*)(void)) NoopDDA;
-    pScreenPriv->pwinInitScreen = winInitScreenPrimaryDD;
-    pScreenPriv->pwinCloseScreen = winCloseScreenPrimaryDD;
-    pScreenPriv->pwinInitVisuals = winInitVisualsPrimaryDD;
-    pScreenPriv->pwinAdjustVideoMode = winAdjustVideoModePrimaryDD;
-    if (pScreenInfo->fFullScreen)
-        pScreenPriv->pwinCreateBoundingWindow =
-            winCreateBoundingWindowFullScreen;
-    else
-        pScreenPriv->pwinCreateBoundingWindow = winCreateBoundingWindowWindowed;
-    pScreenPriv->pwinFinishScreenInit = winFinishScreenInitFB;
-    pScreenPriv->pwinBltExposedRegions =
-        (winBltExposedRegionsProcPtr) (void (*)(void)) NoopDDA;
-    pScreenPriv->pwinActivateApp = winActivateAppPrimaryDD;
-    pScreenPriv->pwinRedrawScreen = NULL;
-    pScreenPriv->pwinRealizeInstalledPalette = NULL;
-    pScreenPriv->pwinInstallColormap = NULL;
-    pScreenPriv->pwinStoreColors = NULL;
-    pScreenPriv->pwinCreateColormap = NULL;
-    pScreenPriv->pwinDestroyColormap = NULL;
-    pScreenPriv->pwinHotKeyAltTab = winHotKeyAltTabPrimaryDD;
-    pScreenPriv->pwinCreatePrimarySurface =
-        (winCreatePrimarySurfaceProcPtr) (void (*)(void)) NoopDDA;
-    pScreenPriv->pwinReleasePrimarySurface =
-        (winReleasePrimarySurfaceProcPtr) (void (*)(void)) NoopDDA;
-#ifdef XWIN_MULTIWINDOW
-    pScreenPriv->pwinFinishCreateWindowsWindow =
-        (winFinishCreateWindowsWindowProcPtr) (void (*)(void)) NoopDDA;
-#endif
-
-    return TRUE;
-}
diff --git a/hw/xwin/winwndproc.c b/hw/xwin/winwndproc.c
index e3adb56..1b09921 100644
--- a/hw/xwin/winwndproc.c
+++ b/hw/xwin/winwndproc.c
@@ -163,11 +163,7 @@ winWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
          */
         if (s_pScreenInfo->fFullScreen
             && (s_pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DD
-                || s_pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DDNL
-#ifdef XWIN_PRIMARYFB
-                || s_pScreenInfo->dwEngine == WIN_SERVER_PRIMARY_DD
-#endif
-            )) {
+                || s_pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DDNL)) {
             break;
         }
 
@@ -191,11 +187,7 @@ winWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
         if (s_pScreenInfo->dwBPP !=
             GetDeviceCaps(s_pScreenPriv->hdcScreen, BITSPIXEL)) {
             if ((s_pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DD ||
-                 s_pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DDNL
-#ifdef XWIN_PRIMARYFB
-                 || s_pScreenInfo->dwEngine == WIN_SERVER_PRIMARY_DD
-#endif
-                )) {
+                 s_pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DDNL)) {
                 /* Cannot display the visual until the depth is restored */
                 ErrorF("winWindowProc - Disruptive change in depth\n");
 
commit 8465ee788fd541fa37681aa0a44103c7f944d437
Author: Adam Jackson <ajax at redhat.com>
Date:   Thu Sep 25 15:37:33 2014 -0400

    xwin: Remove native GDI engine (v2)
    
    As the man page says, "unsupported, experimental, and barely
    functional".  The last even minor updates to any of this were back in
    2004, presumably it's not getting better any time soon.
    
    This is also the only GC ops implementation in the tree that actually
    falls all the way down to the spans routines for everything, so that's
    pretty nice to be rid of.
    
    v2: Fix stray break statement (Jon)
    
    Reviewed-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/configure.ac b/configure.ac
index 30c0c5c..a12e9e2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2206,7 +2206,6 @@ AM_CONDITIONAL(XWIN_MULTIWINDOW, [test "x$XWIN" = xyes])
 AM_CONDITIONAL(XWIN_MULTIWINDOWEXTWM, [test "x$XWIN" = xyes && test "x$WINDOWSWM" = xyes])
 AM_CONDITIONAL(XWIN_CLIPBOARD, [test "x$XWIN" = xyes])
 AM_CONDITIONAL(XWIN_GLX_WINDOWS, [test "x$XWIN" = xyes && test "x$AIGLX" = xyes])
-AM_CONDITIONAL(XWIN_NATIVEGDI, [test "x$XWIN" = xyes])
 AM_CONDITIONAL(XWIN_PRIMARYFB, [test "x$XWIN" = xyes])
 AM_CONDITIONAL(XWIN_RANDR, [test "x$XWIN" = xyes])
 AM_CONDITIONAL(XWIN_XV, [test "x$XWIN" = xyes && test "x$XV" = xyes])
diff --git a/hw/xwin/InitOutput.c b/hw/xwin/InitOutput.c
index 88bc85a..96e1006 100644
--- a/hw/xwin/InitOutput.c
+++ b/hw/xwin/InitOutput.c
@@ -738,9 +738,6 @@ winUseMsg(void)
 #ifdef XWIN_PRIMARYFB
            "\t\t8 - Primary DirectDraw - obsolete\n"
 #endif
-#ifdef XWIN_NATIVEGDI
-           "\t\t16 - Native GDI - experimental\n"
-#endif
         );
 
     ErrorF("-fullscreen\n" "\tRun the server in fullscreen mode.\n");
diff --git a/hw/xwin/Makefile.am b/hw/xwin/Makefile.am
index 2c7fde3..dea55b4 100644
--- a/hw/xwin/Makefile.am
+++ b/hw/xwin/Makefile.am
@@ -37,21 +37,6 @@ DEFS_MULTIWINDOWEXTWM = -DXWIN_MULTIWINDOWEXTWM
 MULTIWINDOWEXTWM_LIBS = $(top_builddir)/miext/rootless/librootless.la
 endif
 
-if XWIN_NATIVEGDI
-SRCS_NATIVEGDI = \
-	winclip.c \
-	winfillsp.c \
-	winfont.c \
-	wingc.c \
-	wingetsp.c \
-	winnativegdi.c \
-	winpixmap.c \
-	winpolyline.c \
-	winrop.c \
-	winsetsp.c
-DEFS_NATIVEGDI = -DXWIN_NATIVEGDI
-endif
-
 if XWIN_PRIMARYFB
 SRCS_PRIMARYFB = \
 	winpfbdd.c
diff --git a/hw/xwin/man/XWin.man b/hw/xwin/man/XWin.man
index c71f6a1..f3eca1e 100644
--- a/hw/xwin/man/XWin.man
+++ b/hw/xwin/man/XWin.man
@@ -263,8 +263,6 @@ Shadow DirectDraw
 Shadow DirectDraw Non-Locking
 .IP 8 4
 Primary DirectDraw (unsupported, obsolete)
-.IP 16 4
-Native GDI (unsupported, experimental and barely functional)
 .RE
 
 .SH FULLSCREEN OPTIONS
diff --git a/hw/xwin/win.h b/hw/xwin/win.h
index 7af35e7..6b3e42a 100644
--- a/hw/xwin/win.h
+++ b/hw/xwin/win.h
@@ -106,9 +106,6 @@
 #ifdef XWIN_PRIMARYFB
 #define WIN_SERVER_PRIMARY_DD	0x8L    /* 8 */
 #endif
-#ifdef XWIN_NATIVEGDI
-#define WIN_SERVER_NATIVE_GDI	0x10L   /* 16 */
-#endif
 
 #define AltMapIndex		Mod1MapIndex
 #define NumLockMapIndex		Mod2MapIndex
@@ -304,12 +301,6 @@ typedef Bool (*winFinishCreateWindowsWindowProcPtr) (WindowPtr pWin);
 
 typedef Bool (*winCreateScreenResourcesProc) (ScreenPtr);
 
-#ifdef XWIN_NATIVEGDI
-/* Typedefs for native GDI wrappers */
-typedef Bool (*RealizeFontPtr) (ScreenPtr pScreen, FontPtr pFont);
-typedef Bool (*UnrealizeFontPtr) (ScreenPtr pScreen, FontPtr pFont);
-#endif
-
 /*
  * GC (graphics context) privates
  */
@@ -582,12 +573,6 @@ typedef struct _winPrivScreenRec {
     SetShapeProcPtr SetShape;
 
     winCursorRec cursor;
-
-#ifdef XWIN_NATIVEGDI
-    RealizeFontPtr RealizeFont;
-    UnrealizeFontPtr UnrealizeFont;
-#endif
-
 } winPrivScreenRec;
 
 #ifdef XWIN_MULTIWINDOWEXTWM
@@ -775,15 +760,6 @@ void
 winBlockHandler(ScreenPtr pScreen,
                 void *pTimeout, void *pReadMask);
 
-#ifdef XWIN_NATIVEGDI
-/*
- * winclip.c
- */
-
-RegionPtr
- winPixmapToRegionNativeGDI(PixmapPtr pPix);
-#endif
-
 #ifdef XWIN_CLIPBOARD
 /*
  * winclipboardinit.c
@@ -859,52 +835,6 @@ void
 winMessageBoxF(const char *pszError, UINT uType, ...)
 _X_ATTRIBUTE_PRINTF(1, 3);
 
-#ifdef XWIN_NATIVEGDI
-/*
- * winfillsp.c
- */
-
-void
-
-winFillSpansNativeGDI(DrawablePtr pDrawable,
-                      GCPtr pGC,
-                      int nSpans,
-                      DDXPointPtr pPoints, int *pWidths, int fSorted);
-#endif
-
-#ifdef XWIN_NATIVEGDI
-/*
- * winfont.c
- */
-
-Bool
- winRealizeFontNativeGDI(ScreenPtr pScreen, FontPtr pFont);
-
-Bool
- winUnrealizeFontNativeGDI(ScreenPtr pScreen, FontPtr pFont);
-#endif
-
-#ifdef XWIN_NATIVEGDI
-/*
- * wingc.c
- */
-
-Bool
- winCreateGCNativeGDI(GCPtr pGC);
-#endif
-
-#ifdef XWIN_NATIVEGDI
-/*
- * wingetsp.c
- */
-
-void
-
-winGetSpansNativeGDI(DrawablePtr pDrawable,
-                     int wMax,
-                     DDXPointPtr pPoints, int *pWidths, int nSpans, char *pDst);
-#endif
-
 /*
  * winglobals.c
  */
@@ -956,23 +886,12 @@ void
  * winmisc.c
  */
 
-#ifdef XWIN_NATIVEGDI
-void
-
-winQueryBestSizeNativeGDI(int class, unsigned short *pWidth,
-                          unsigned short *pHeight, ScreenPtr pScreen);
-#endif
-
 CARD8
  winCountBits(DWORD dw);
 
 Bool
  winUpdateFBPointer(ScreenPtr pScreen, void *pbits);
 
-#ifdef XWIN_NATIVEGDI
-BOOL winPaintBackground(HWND hwnd, COLORREF colorref);
-#endif
-
 /*
  * winmouse.c
  */
@@ -994,19 +913,6 @@ winMouseButtonsHandle(ScreenPtr pScreen,
 void
  winEnqueueMotion(int x, int y);
 
-#ifdef XWIN_NATIVEGDI
-/*
- * winnativegdi.c
- */
-
-HBITMAP
-winCreateDIBNativeGDI(int iWidth, int iHeight, int iDepth,
-                      BYTE ** ppbBits, BITMAPINFO ** ppbmi);
-
-Bool
- winSetEngineFunctionsNativeGDI(ScreenPtr pScreen);
-#endif
-
 #ifdef XWIN_PRIMARYFB
 /*
  * winpfbddd.c
@@ -1016,38 +922,6 @@ Bool
  winSetEngineFunctionsPrimaryDD(ScreenPtr pScreen);
 #endif
 
-#ifdef XWIN_NATIVEGDI
-/*
- * winpixmap.c
- */
-
-PixmapPtr
-
-winCreatePixmapNativeGDI(ScreenPtr pScreen, int width, int height, int depth,
-                         unsigned usage_hint);
-
-Bool
- winDestroyPixmapNativeGDI(PixmapPtr pPixmap);
-
-Bool
-
-winModifyPixmapHeaderNativeGDI(PixmapPtr pPixmap,
-                               int iWidth, int iHeight,
-                               int iDepth,
-                               int iBitsPerPixel,
-                               int devKind, void *pPixData);
-#endif
-
-#ifdef XWIN_NATIVEGDI
-/*
- * winpolyline.c
- */
-
-void
-
-winPolyLineNativeGDI(DrawablePtr pDrawable,
-                     GCPtr pGC, int mode, int npt, DDXPointPtr ppt);
-#endif
 /*
  * winscrinit.c
  */
@@ -1058,26 +932,6 @@ Bool
 Bool
  winFinishScreenInitFB(int i, ScreenPtr pScreen, int argc, char **argv);
 
-#if defined(XWIN_NATIVEGDI)
-Bool
-
-winFinishScreenInitNativeGDI(int i,
-                             ScreenPtr pScreen, int argc, char **argv);
-#endif
-
-#ifdef XWIN_NATIVEGDI
-/*
- * winsetsp.c
- */
-
-void
-
-winSetSpansNativeGDI(DrawablePtr pDrawable,
-                     GCPtr pGC,
-                     char *pSrc,
-                     DDXPointPtr pPoints, int *pWidth, int nSpans, int fSorted);
-#endif
-
 /*
  * winshaddd.c
  */
@@ -1112,30 +966,6 @@ winWakeupHandler(ScreenPtr pScreen,
  * winwindow.c
  */
 
-#ifdef XWIN_NATIVEGDI
-Bool
- winCreateWindowNativeGDI(WindowPtr pWin);
-
-Bool
- winDestroyWindowNativeGDI(WindowPtr pWin);
-
-Bool
- winPositionWindowNativeGDI(WindowPtr pWin, int x, int y);
-
-void
-
-winCopyWindowNativeGDI(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc);
-
-Bool
- winChangeWindowAttributesNativeGDI(WindowPtr pWin, unsigned long mask);
-
-Bool
- winUnmapWindowNativeGDI(WindowPtr pWindow);
-
-Bool
- winMapWindowNativeGDI(WindowPtr pWindow);
-#endif
-
 Bool
  winCreateWindowRootless(WindowPtr pWindow);
 
diff --git a/hw/xwin/winclip.c b/hw/xwin/winclip.c
deleted file mode 100644
index 941e948..0000000
--- a/hw/xwin/winclip.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- *Copyright (C) 2001-2004 Harold L Hunt II All Rights Reserved.
- *
- *Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- *"Software"), to deal in the Software without restriction, including
- *without limitation the rights to use, copy, modify, merge, publish,
- *distribute, 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 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 HAROLD L HUNT II 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.
- *
- *Except as contained in this notice, the name of Harold L Hunt II
- *shall not be used in advertising or otherwise to promote the sale, use
- *or other dealings in this Software without prior written authorization
- *from Harold L Hunt II.
- *
- * Authors:	Harold L Hunt II
- */
-
-#ifdef HAVE_XWIN_CONFIG_H
-#include <xwin-config.h>
-#endif
-#include "win.h"
-
-/* Look at mfb/mfbclip.c for sample implementation */
-RegionPtr
-winPixmapToRegionNativeGDI(PixmapPtr pPix)
-{
-    ErrorF("winPixmapToRegion()\n");
-    return NULL;
-}
diff --git a/hw/xwin/wincreatewnd.c b/hw/xwin/wincreatewnd.c
index 6732dcb..9f72016 100644
--- a/hw/xwin/wincreatewnd.c
+++ b/hw/xwin/wincreatewnd.c
@@ -110,20 +110,8 @@ winCreateBoundingWindowFullScreen(ScreenPtr pScreen)
                              GetModuleHandle(NULL),     /* Instance handle */
                              pScreenPriv);      /* ScreenPrivates */
 
-    /* Branch on the server engine */
-    switch (pScreenInfo->dwEngine) {
-#ifdef XWIN_NATIVEGDI
-    case WIN_SERVER_SHADOW_GDI:
-        /* Show the window */
-        ShowWindow(*phwnd, SW_SHOWMAXIMIZED);
-        break;
-#endif
-
-    default:
-        /* Hide the window */
-        ShowWindow(*phwnd, SW_SHOWNORMAL);
-        break;
-    }
+    /* Hide the window */
+    ShowWindow(*phwnd, SW_SHOWNORMAL);
 
     /* Send first paint message */
     UpdateWindow(*phwnd);
@@ -474,12 +462,6 @@ winCreateBoundingWindowWindowed(ScreenPtr pScreen)
         }
     }
 
-#ifdef XWIN_NATIVEGDI
-    /* Paint window background blue */
-    if (pScreenInfo->dwEngine == WIN_SERVER_NATIVE_GDI)
-        winPaintBackground(*phwnd, RGB(0x00, 0x00, 0xFF));
-#endif
-
     winDebug("winCreateBoundingWindowWindowed -  Returning\n");
 
     return TRUE;
diff --git a/hw/xwin/winengine.c b/hw/xwin/winengine.c
index 1f55ada..8aa9051 100644
--- a/hw/xwin/winengine.c
+++ b/hw/xwin/winengine.c
@@ -59,10 +59,6 @@ winDetectSupportedEngines(void)
     /* Initialize the engine support flags */
     g_dwEnginesSupported = WIN_SERVER_SHADOW_GDI;
 
-#ifdef XWIN_NATIVEGDI
-    g_dwEnginesSupported |= WIN_SERVER_NATIVE_GDI;
-#endif
-
     /* Get operating system version information */
     ZeroMemory(&osvi, sizeof(osvi));
     osvi.dwOSVersionInfoSize = sizeof(osvi);
@@ -211,11 +207,6 @@ winSetEngine(ScreenPtr pScreen)
             winSetEngineFunctionsPrimaryDD(pScreen);
             break;
 #endif
-#ifdef XWIN_NATIVEGDI
-        case WIN_SERVER_NATIVE_GDI:
-            winSetEngineFunctionsNativeGDI(pScreen);
-            break;
-#endif
         default:
             FatalError("winSetEngine - Invalid engine type\n");
         }
diff --git a/hw/xwin/winfillsp.c b/hw/xwin/winfillsp.c
deleted file mode 100644
index bd0a15e..0000000
--- a/hw/xwin/winfillsp.c
+++ /dev/null
@@ -1,842 +0,0 @@
-/*
- *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
- *
- *Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- *"Software"), to deal in the Software without restriction, including
- *without limitation the rights to use, copy, modify, merge, publish,
- *distribute, 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 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 XFREE86 PROJECT 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.
- *
- *Except as contained in this notice, the name of the XFree86 Project
- *shall not be used in advertising or otherwise to promote the sale, use
- *or other dealings in this Software without prior written authorization
- *from the XFree86 Project.
- *
- * Authors:	Harold L Hunt II
- * 		Alan Hourihane <alanh at fairlite.demon.co.uk>
- */
-
-#ifdef HAVE_XWIN_CONFIG_H
-#include <xwin-config.h>
-#endif
-#include "win.h"
-
-extern void ROP16(HDC hdc, int rop);
-
-#define TRANSLATE_COLOR(color)						\
-{									\
-  if (pDrawable->depth == 15)						\
-    color = ((color & 0x1F) << 19) | ((color & 0x03E0) << 6) |		\
-      ((color & 0xF800) >> 8);						\
-  else if (pDrawable->depth == 16)					\
-    color = ((color & 0x1F) << 19) | ((color & 0x07E0) << 5) |		\
-      ((color & 0xF800) >> 8);						\
-  else if (pDrawable->depth == 24 || pDrawable->depth == 32)		\
-    color = ((color & 0xFF) << 16) | (color & 0xFF00) |			\
-      ((color & 0xFF0000) >> 16);					\
-}
-
-/* See Porting Layer Definition - p. 54 */
-void
-winFillSpansNativeGDI(DrawablePtr pDrawable,
-                      GCPtr pGC,
-                      int iSpans,
-                      DDXPointPtr pPoints, int *piWidths, int fSorted)
-{
-    winGCPriv(pGC);
-    HBITMAP hbmpOrig = NULL, hbmpOrigStipple = NULL;
-    HBITMAP hPenOrig = NULL;
-    HBITMAP hBitmap = NULL;
-    PixmapPtr pPixmap = NULL;
-    winPrivPixmapPtr pPixmapPriv = NULL;
-    PixmapPtr pStipple = NULL;
-    winPrivPixmapPtr pStipplePriv = NULL;
-    PixmapPtr pTile = NULL;
-    winPrivPixmapPtr pTilePriv = NULL;
-    HDC hdcStipple = NULL, hdcTile = NULL;
-    HPEN hPen = NULL;
-    int iX;
-    int fg, bg;
-    RegionPtr pClip = pGC->pCompositeClip;
-    BoxPtr pextent, pbox;
-    int nbox;
-    int extentX1, extentX2, extentY1, extentY2;
-    int fullX1, fullX2, fullY1;
-    HRGN hrgn = NULL, combined = NULL;
-
-    nbox = RegionNumRects(pClip);
-    pbox = RegionRects(pClip);
-
-    if (!nbox)
-        return;
-
-    combined = CreateRectRgn(pbox->x1, pbox->y1, pbox->x2, pbox->y2);
-    nbox--;
-    pbox++;
-
-    while (nbox--) {
-        hrgn = CreateRectRgn(pbox->x1, pbox->y1, pbox->x2, pbox->y2);
-        CombineRgn(combined, combined, hrgn, RGN_OR);
-        DeleteObject(hrgn);
-        hrgn = NULL;
-        pbox++;
-    }
-
-    pextent = RegionExtents(pClip);
-    extentX1 = pextent->x1;
-    extentY1 = pextent->y1;
-    extentX2 = pextent->x2;
-    extentY2 = pextent->y2;
-
-    /* Branch on the type of drawable we have */
-    switch (pDrawable->type) {
-    case DRAWABLE_PIXMAP:
-
-        SelectClipRgn(pGCPriv->hdcMem, combined);
-        DeleteObject(combined);
-        combined = NULL;
-
-        /* Get a pixmap pointer from the drawable pointer, and fetch privates  */
-        pPixmap = (PixmapPtr) pDrawable;
-        pPixmapPriv = winGetPixmapPriv(pPixmap);
-
-        /* Select the drawable pixmap into memory hdc */
-        hbmpOrig = SelectObject(pGCPriv->hdcMem, pPixmapPriv->hBitmap);
-        if (hbmpOrig == NULL)
-            FatalError("winFillSpans - DRAWABLE_PIXMAP - "
-                       "SelectObject () failed on\n\tpPixmapPriv->hBitmap: "
-                       "%p\n", pPixmapPriv->hBitmap);
-
-        /* Branch on the fill type */
-        switch (pGC->fillStyle) {
-        case FillSolid:
-
-            ROP16(pGCPriv->hdcMem, pGC->alu);
-
-            if (pDrawable->depth == 1) {
-                if (pGC->fgPixel == 0)
-                    hPenOrig = SelectObject(pGCPriv->hdcMem,
-                                            GetStockObject(BLACK_PEN));
-                else
-                    hPenOrig = SelectObject(pGCPriv->hdcMem,
-                                            GetStockObject(WHITE_PEN));
-            }
-            else {
-                fg = pGC->fgPixel;
-                TRANSLATE_COLOR(fg);
-                hPen = CreatePen(PS_SOLID, 0, fg);
-                hPenOrig = SelectObject(pGCPriv->hdcMem, hPen);
-            }
-
-            while (iSpans--) {
-                fullX1 = pPoints->x;
-                fullY1 = pPoints->y;
-                fullX2 = fullX1 + (int) *piWidths;
-                pPoints++;
-                piWidths++;
-
-                if (fullY1 < extentY1 || extentY2 <= fullY1)
-                    continue;
-
-                if (fullX1 < extentX1)
-                    fullX1 = extentX1;
-                if (fullX2 > extentX2)
-                    fullX2 = extentX2;
-
-                if (fullX1 >= fullX2)
-                    continue;
-
-                MoveToEx(pGCPriv->hdcMem, fullX1, fullY1, NULL);
-                LineTo(pGCPriv->hdcMem, fullX2, fullY1);
-            }
-
-            SetROP2(pGCPriv->hdcMem, R2_COPYPEN);
-
-            /* Give back the Pen */
-            SelectObject(pGCPriv->hdcMem, hPenOrig);
-
-            if (pDrawable->depth != 1)
-                DeleteObject(hPen);
-            break;
-
-        case FillOpaqueStippled:
-
-            pStipple = pGC->stipple;
-            pStipplePriv = winGetPixmapPriv(pStipple);
-
-            /* Create a device-dependent bitmap for the stipple */
-            hBitmap = CreateDIBitmap(pGCPriv->hdcMem,
-                                     (BITMAPINFOHEADER *) pStipplePriv->pbmih,
-                                     CBM_INIT,
-                                     pStipplePriv->pbBits,
-                                     (BITMAPINFO *) pStipplePriv->pbmih,
-                                     DIB_RGB_COLORS);
-
-            /* Create a memory DC to hold the stipple */
-            hdcStipple = CreateCompatibleDC(pGCPriv->hdcMem);
-
-            /* Select the stipple bitmap into the stipple DC */
-            hbmpOrigStipple = SelectObject(hdcStipple, hBitmap);
-            if (hbmpOrigStipple == NULL)
-                FatalError("winFillSpans () - DRAWABLE_PIXMAP - FillStippled - "
-                           "SelectObject () failed on hbmpOrigStipple\n");
-
-            /* Make a temporary copy of the foreground and background colors */
-            bg = pGC->bgPixel;
-            fg = pGC->fgPixel;
-
-            /* Translate the depth-dependent colors to Win32 COLORREFs */
-            TRANSLATE_COLOR(fg);
-            TRANSLATE_COLOR(bg);
-            SetTextColor(pGCPriv->hdcMem, fg);
-            SetBkColor(pGCPriv->hdcMem, bg);
-
-            while (iSpans--) {
-                int width = pStipple->drawable.width;
-
-                fullX1 = pPoints->x;
-                fullY1 = pPoints->y;
-                fullX2 = fullX1 + (int) *piWidths;
-                pPoints++;
-                piWidths++;
-
-                if (fullY1 < extentY1 || extentY2 <= fullY1)
-                    continue;
-
-                if (fullX1 < extentX1)
-                    fullX1 = extentX1;
-                if (fullX2 > extentX2)
-                    fullX2 = extentX2;
-
-                if (fullX1 >= fullX2)
-                    continue;
-
-                for (iX = fullX1; iX < fullX2; iX += width) {
-                    int xoffset;
-
-                    if ((iX + pStipple->drawable.width) > fullX2)
-                        width = fullX2 - iX;
-                    else
-                        width = pStipple->drawable.width;
-
-                    if (iX == fullX1)
-                        xoffset =
-                            (fullX1 -
-                             (pDrawable->x +
-                              (pGC->patOrg.x % pStipple->drawable.width) -
-                              pStipple->drawable.width)) %
-                            pStipple->drawable.width;
-                    else
-                        xoffset = 0;
-
-                    if (xoffset + width > pStipple->drawable.width)
-                        width = pStipple->drawable.width - xoffset;
-
-                    BitBlt(pGCPriv->hdcMem,
-                           iX, fullY1,
-                           width, 1,
-                           hdcStipple,
-                           xoffset,
-                           (fullY1 -
-                            (pDrawable->y +
-                             (pGC->patOrg.y % pStipple->drawable.height) -
-                             pStipple->drawable.height)) %
-                           pStipple->drawable.height, g_copyROP[pGC->alu]);
-                }
-            }
-
-            /* Clear the stipple HDC */
-            SelectObject(hdcStipple, hbmpOrigStipple);
-            DeleteDC(hdcStipple);
-
-            /* Delete the device dependent stipple bitmap */
-            DeleteObject(hBitmap);
-
-            break;
-        case FillStippled:
-
-            pStipple = pGC->stipple;
-            pStipplePriv = winGetPixmapPriv(pStipple);
-
-            /* Create a device-dependent bitmap for the stipple */
-            hBitmap = CreateDIBitmap(pGCPriv->hdcMem,
-                                     (BITMAPINFOHEADER *) pStipplePriv->pbmih,
-                                     CBM_INIT,
-                                     pStipplePriv->pbBits,
-                                     (BITMAPINFO *) pStipplePriv->pbmih,
-                                     DIB_RGB_COLORS);
-
-            /* Create a memory DC to hold the stipple */
-            hdcStipple = CreateCompatibleDC(pGCPriv->hdcMem);
-
-            /* Select the stipple bitmap into the stipple DC */
-            hbmpOrigStipple = SelectObject(hdcStipple, hBitmap);
-            if (hbmpOrigStipple == NULL)
-                FatalError("winFillSpans () - DRAWABLE_PIXMAP - FillStippled - "
-                           "SelectObject () failed on hbmpOrigStipple\n");
-
-            /* Make a temporary copy of the foreground and background colors */
-            bg = pGC->bgPixel;
-            fg = pGC->fgPixel;
-
-            /* Translate the depth-dependent colors to Win32 COLORREFs */
-            TRANSLATE_COLOR(fg);
-            TRANSLATE_COLOR(bg);
-
-            /* this is fudgy, we should only invert on the last one
-             * We need to get the black/white pixels right in the
-             * colormap. But yeah ! it's working.. 
-             */
-            if (pGC->bgPixel != -1 && pGC->fgPixel != -1) {
-                SetTextColor(pGCPriv->hdcMem, fg);
-                SetBkColor(pGCPriv->hdcMem, bg);
-                BitBlt(hdcStipple,
-                       0, 0,
-                       pStipple->drawable.width, pStipple->drawable.height,
-                       hdcStipple, 0, 0, 0x330008);
-            }
-            else if (pGC->bgPixel == -1) {
-                SetTextColor(pGCPriv->hdcMem, fg);
-                SetBkMode(pGCPriv->hdcMem, TRANSPARENT);
-                BitBlt(hdcStipple,
-                       0, 0,
-                       pStipple->drawable.width, pStipple->drawable.height,
-                       hdcStipple, 0, 0, 0x330008);
-            }
-            else if (pGC->fgPixel == -1) {
-                SetTextColor(pGCPriv->hdcMem, bg);
-                SetBkMode(pGCPriv->hdcMem, TRANSPARENT);
-#if 0
-                BitBlt(hdcStipple,
-                       0, 0,
-                       pStipple->drawable.width, pStipple->drawable.height,
-                       hdcStipple, 0, 0, 0x330008);
-#endif
-            }
-
-            while (iSpans--) {
-                int width = pStipple->drawable.width;
-
-                fullX1 = pPoints->x;
-                fullY1 = pPoints->y;
-                fullX2 = fullX1 + (int) *piWidths;
-                pPoints++;
-                piWidths++;
-
-                if (fullY1 < extentY1 || extentY2 <= fullY1)
-                    continue;
-
-                if (fullX1 < extentX1)
-                    fullX1 = extentX1;
-                if (fullX2 > extentX2)
-                    fullX2 = extentX2;
-
-                if (fullX1 >= fullX2)
-                    continue;
-
-                for (iX = fullX1; iX < fullX2; iX += width) {
-                    int xoffset;
-
-                    if ((iX + pStipple->drawable.width) > fullX2)
-                        width = fullX2 - iX;
-                    else
-                        width = pStipple->drawable.width;
-
-                    if (iX == fullX1)
-                        xoffset =
-                            (fullX1 -
-                             (pDrawable->x +
-                              (pGC->patOrg.x % pStipple->drawable.width) -
-                              pStipple->drawable.width)) %
-                            pStipple->drawable.width;
-                    else
-                        xoffset = 0;
-
-                    if (xoffset + width > pStipple->drawable.width)
-                        width = pStipple->drawable.width - xoffset;
-
-                    BitBlt(pGCPriv->hdcMem,
-                           iX, fullY1,
-                           width, 1,
-                           hdcStipple,
-                           xoffset,
-                           (fullY1 -
-                            (pDrawable->y +
-                             (pGC->patOrg.y % pStipple->drawable.height) -
-                             pStipple->drawable.height)) %
-                           pStipple->drawable.height, g_copyROP[pGC->alu]);
-                }
-            }
-
-            /* Clear the stipple HDC */
-            SelectObject(hdcStipple, hbmpOrigStipple);
-            DeleteDC(hdcStipple);
-
-            /* Delete the device dependent stipple bitmap */
-            DeleteObject(hBitmap);
-
-            /* Restore the background mode */
-            SetBkMode(pGCPriv->hdcMem, OPAQUE);
-            break;
-
-        case FillTiled:
-
-            /* Get a pixmap pointer from the tile pointer, and fetch privates  */
-            pTile = (PixmapPtr) pGC->tile.pixmap;
-            pTilePriv = winGetPixmapPriv(pTile);
-
-            /* Create a memory DC to hold the tile */
-            hdcTile = CreateCompatibleDC(pGCPriv->hdcMem);
-
-            /* Select the tile into a DC */
-            hbmpOrig = SelectObject(hdcTile, pTilePriv->hBitmap);
-            if (hbmpOrig == NULL)
-                FatalError("winFillSpans - DRAWABLE_PIXMAP - FillTiled - "
-                           "SelectObject () failed on pTilePriv->hBitmap\n");
-
-            while (iSpans--) {
-                int width = pTile->drawable.width;
-
-                fullX1 = pPoints->x;
-                fullY1 = pPoints->y;
-                fullX2 = fullX1 + (int) *piWidths;
-                pPoints++;
-                piWidths++;
-
-                if (fullY1 < extentY1 || extentY2 <= fullY1)
-                    continue;
-
-                if (fullX1 < extentX1)
-                    fullX1 = extentX1;
-                if (fullX2 > extentX2)
-                    fullX2 = extentX2;
-
-                if (fullX1 >= fullX2)
-                    continue;
-
-                for (iX = fullX1; iX < fullX2; iX += width) {
-                    int xoffset;
-
-                    if ((iX + pTile->drawable.width) > fullX2)
-                        width = fullX2 - iX;
-                    else
-                        width = pTile->drawable.width;
-
-                    if (iX == fullX1)
-                        xoffset =
-                            (fullX1 -
-                             (pDrawable->x +
-                              (pGC->patOrg.x % pTile->drawable.width) -
-                              pTile->drawable.width)) % pTile->drawable.width;
-                    else
-                        xoffset = 0;
-
-                    if (xoffset + width > pTile->drawable.width)
-                        width = pTile->drawable.width - xoffset;
-
-                    BitBlt(pGCPriv->hdcMem,
-                           iX, fullY1,
-                           width, 1,
-                           hdcTile,
-                           xoffset,
-                           (fullY1 -
-                            (pDrawable->y +
-                             (pGC->patOrg.y % pTile->drawable.height) -
-                             pTile->drawable.height)) % pTile->drawable.height,
-                           g_copyROP[pGC->alu]);
-                }
-            }
-
-            /* Push the tile pixmap out of the memory HDC */
-            SelectObject(hdcTile, hbmpOrig);
-
-            /* Delete the tile */
-            DeleteDC(hdcTile);
-            break;
-
-        default:
-            ErrorF("winFillSpans - DRAWABLE_PIXMAP - Unknown fillStyle\n");
-            break;
-        }
-
-        /* Reset clip region */
-        SelectClipRgn(pGCPriv->hdcMem, NULL);
-
-        /* Push the drawable pixmap out of the GC HDC */
-        SelectObject(pGCPriv->hdcMem, hbmpOrig);
-        break;
-
-    case DRAWABLE_WINDOW:
-
-        SelectClipRgn(pGCPriv->hdc, combined);
-        DeleteObject(combined);
-        combined = NULL;
-
-        /* Branch on fill style */
-        switch (pGC->fillStyle) {
-        case FillSolid:
-
-            ROP16(pGCPriv->hdc, pGC->alu);
-
-            if (pDrawable->depth == 1) {
-                if (pGC->fgPixel == 0)
-                    hPenOrig = SelectObject(pGCPriv->hdc,
-                                            GetStockObject(BLACK_PEN));
-                else
-                    hPenOrig = SelectObject(pGCPriv->hdc,
-                                            GetStockObject(WHITE_PEN));
-            }
-            else {
-                fg = pGC->fgPixel;
-                TRANSLATE_COLOR(fg);
-                hPen = CreatePen(PS_SOLID, 0, fg);
-                hPenOrig = SelectObject(pGCPriv->hdc, hPen);
-            }
-
-            while (iSpans--) {
-                fullX1 = pPoints->x;
-                fullY1 = pPoints->y;
-                fullX2 = fullX1 + (int) *piWidths;
-                pPoints++;
-                piWidths++;
-
-                if (fullY1 < extentY1 || extentY2 <= fullY1)
-                    continue;
-
-                if (fullX1 < extentX1)
-                    fullX1 = extentX1;
-                if (fullX2 > extentX2)
-                    fullX2 = extentX2;
-
-                if (fullX1 >= fullX2)
-                    continue;
-
-                MoveToEx(pGCPriv->hdc, fullX1, fullY1, NULL);
-                LineTo(pGCPriv->hdc, fullX2, fullY1);
-            }
-
-            SetROP2(pGCPriv->hdc, R2_COPYPEN);
-
-            /* Give back the Brush */
-            SelectObject(pGCPriv->hdc, hPenOrig);
-
-            if (pDrawable->depth != 1)
-                DeleteObject(hPen);
-            break;
-
-        case FillOpaqueStippled:
-
-            pStipple = pGC->stipple;
-            pStipplePriv = winGetPixmapPriv(pStipple);
-
-            /* Create a device-dependent bitmap for the stipple */
-            hBitmap = CreateDIBitmap(pGCPriv->hdc,
-                                     (BITMAPINFOHEADER *) pStipplePriv->pbmih,
-                                     CBM_INIT,
-                                     pStipplePriv->pbBits,
-                                     (BITMAPINFO *) pStipplePriv->pbmih,
-                                     DIB_RGB_COLORS);
-
-            /* Create a memory DC to hold the stipple */
-            hdcStipple = CreateCompatibleDC(pGCPriv->hdc);
-
-            /* Select the stipple bitmap into the stipple DC */
-            hbmpOrigStipple = SelectObject(hdcStipple, hBitmap);
-            if (hbmpOrigStipple == NULL)
-                FatalError("winFillSpans () - DRAWABLE_PIXMAP - FillStippled - "
-                           "SelectObject () failed on hbmpOrigStipple\n");
-
-            /* Make a temporary copy of the foreground and background colors */
-            bg = pGC->bgPixel;
-            fg = pGC->fgPixel;
-
-            /* Translate the depth-dependent colors to Win32 COLORREFs */
-            TRANSLATE_COLOR(fg);
-            TRANSLATE_COLOR(bg);
-            SetTextColor(pGCPriv->hdc, fg);
-            SetBkColor(pGCPriv->hdc, bg);
-
-            while (iSpans--) {
-                int width = pStipple->drawable.width;
-
-                fullX1 = pPoints->x;
-                fullY1 = pPoints->y;
-                fullX2 = fullX1 + (int) *piWidths;
-                pPoints++;
-                piWidths++;
-
-                if (fullY1 < extentY1 || extentY2 <= fullY1)
-                    continue;
-
-                if (fullX1 < extentX1)
-                    fullX1 = extentX1;
-                if (fullX2 > extentX2)
-                    fullX2 = extentX2;
-
-                if (fullX1 >= fullX2)
-                    continue;
-
-                for (iX = fullX1; iX < fullX2; iX += width) {
-                    int xoffset;
-
-                    if ((iX + pStipple->drawable.width) > fullX2)
-                        width = fullX2 - iX;
-                    else
-                        width = pStipple->drawable.width;
-
-                    if (iX == fullX1)
-                        xoffset =
-                            (fullX1 -
-                             (pDrawable->x +
-                              (pGC->patOrg.x % pStipple->drawable.width) -
-                              pStipple->drawable.width)) %
-                            pStipple->drawable.width;
-                    else
-                        xoffset = 0;
-
-                    if (xoffset + width > pStipple->drawable.width)
-                        width = pStipple->drawable.width - xoffset;
-
-                    BitBlt(pGCPriv->hdc,
-                           iX, fullY1,
-                           width, 1,
-                           hdcStipple,
-                           xoffset,
-                           (fullY1 -
-                            (pDrawable->y +
-                             (pGC->patOrg.y % pStipple->drawable.height) -
-                             pStipple->drawable.height)) %
-                           pStipple->drawable.height, g_copyROP[pGC->alu]);
-                }
-            }
-
-            /* Clear the stipple HDC */
-            SelectObject(hdcStipple, hbmpOrigStipple);
-            DeleteDC(hdcStipple);
-
-            /* Delete the device dependent stipple bitmap */
-            DeleteObject(hBitmap);
-
-            break;
-
-        case FillStippled:
-            pStipple = pGC->stipple;
-            pStipplePriv = winGetPixmapPriv(pStipple);
-
-            /* Create a device-dependent bitmap for the stipple */
-            hBitmap = CreateDIBitmap(pGCPriv->hdcMem,
-                                     (BITMAPINFOHEADER *) pStipplePriv->pbmih,
-                                     CBM_INIT,
-                                     pStipplePriv->pbBits,
-                                     (BITMAPINFO *) pStipplePriv->pbmih,
-                                     DIB_RGB_COLORS);
-
-            /* Create a memory DC to hold the stipple */
-            hdcStipple = CreateCompatibleDC(pGCPriv->hdc);
-
-            /* Select the stipple bitmap into the stipple DC */
-            hbmpOrigStipple = SelectObject(hdcStipple, hBitmap);
-            if (hbmpOrigStipple == NULL)
-                FatalError("winFillSpans () - DRAWABLE_PIXMAP - FillStippled - "
-                           "SelectObject () failed on hbmpOrigStipple\n");
-
-            /* Make a temporary copy of the foreground and background colors */
-            bg = pGC->bgPixel;
-            fg = pGC->fgPixel;
-
-            /* Translate the depth-dependent colors to Win32 COLORREFs */
-            TRANSLATE_COLOR(fg);
-            TRANSLATE_COLOR(bg);
-
-            /* this is fudgy, we should only invert on the last one
-             * We need to get the black/white pixels right in the
-             * colormap. But yeah ! it's working.. 
-             */
-            if (pGC->bgPixel != -1 && pGC->fgPixel != -1) {
-                SetTextColor(pGCPriv->hdc, fg);
-                SetBkColor(pGCPriv->hdc, bg);
-                BitBlt(hdcStipple,
-                       0, 0,
-                       pStipple->drawable.width, pStipple->drawable.height,
-                       hdcStipple, 0, 0, 0x330008);
-            }
-            else if (pGC->bgPixel == -1) {
-                SetTextColor(pGCPriv->hdc, fg);
-                SetBkMode(pGCPriv->hdc, TRANSPARENT);
-                BitBlt(hdcStipple,
-                       0, 0,
-                       pStipple->drawable.width, pStipple->drawable.height,
-                       hdcStipple, 0, 0, 0x330008);
-            }
-            else if (pGC->fgPixel == -1) {
-                SetTextColor(pGCPriv->hdc, bg);
-                SetBkMode(pGCPriv->hdc, TRANSPARENT);
-#if 0
-                BitBlt(hdcStipple,
-                       0, 0,
-                       pStipple->drawable.width, pStipple->drawable.height,
-                       hdcStipple, 0, 0, 0x330008);
-#endif
-            }
-
-            while (iSpans--) {
-                int width = pStipple->drawable.width;
-
-                fullX1 = pPoints->x;
-                fullY1 = pPoints->y;
-                fullX2 = fullX1 + (int) *piWidths;
-                pPoints++;
-                piWidths++;
-
-                if (fullY1 < extentY1 || extentY2 <= fullY1)
-                    continue;
-
-                if (fullX1 < extentX1)
-                    fullX1 = extentX1;
-                if (fullX2 > extentX2)
-                    fullX2 = extentX2;
-
-                if (fullX1 >= fullX2)
-                    continue;
-
-                for (iX = fullX1; iX < fullX2; iX += width) {
-                    int xoffset;
-
-                    if ((iX + pStipple->drawable.width) > fullX2)
-                        width = fullX2 - iX;
-                    else
-                        width = pStipple->drawable.width;
-
-                    if (iX == fullX1)
-                        xoffset =
-                            (fullX1 -
-                             (pDrawable->x +
-                              (pGC->patOrg.x % pStipple->drawable.width) -
-                              pStipple->drawable.width)) %
-                            pStipple->drawable.width;
-                    else
-                        xoffset = 0;
-
-                    if (xoffset + width > pStipple->drawable.width)
-                        width = pStipple->drawable.width - xoffset;
-
-                    BitBlt(pGCPriv->hdc,
-                           iX, fullY1,
-                           width, 1,
-                           hdcStipple,
-                           xoffset,
-                           (fullY1 -
-                            (pDrawable->y +
-                             (pGC->patOrg.y % pStipple->drawable.height) -
-                             pStipple->drawable.height)) %
-                           pStipple->drawable.height, g_copyROP[pGC->alu]);
-                }
-            }
-
-            /* Clear the stipple HDC */
-            SelectObject(hdcStipple, hbmpOrigStipple);
-            DeleteDC(hdcStipple);
-
-            /* Delete the device dependent stipple bitmap */
-            DeleteObject(hBitmap);
-
-            /* Restore the background mode */
-            SetBkMode(pGCPriv->hdc, OPAQUE);
-            break;
-
-        case FillTiled:
-
-            /* Get a pixmap pointer from the tile pointer, and fetch privates  */
-            pTile = (PixmapPtr) pGC->tile.pixmap;
-            pTilePriv = winGetPixmapPriv(pTile);
-
-            /* Select the tile into a DC */
-            hbmpOrig = SelectObject(pGCPriv->hdcMem, pTilePriv->hBitmap);
-            if (hbmpOrig == NULL)
-                FatalError("winFillSpans - DRAWABLE_WINDOW - FillTiled - "
-                           "SelectObject () failed on pTilePriv->hBitmap\n");
-
-            while (iSpans--) {
-                int width = pTile->drawable.width;
-
-                fullX1 = pPoints->x;
-                fullY1 = pPoints->y;
-                fullX2 = fullX1 + (int) *piWidths;
-                pPoints++;
-                piWidths++;
-
-                if (fullY1 < extentY1 || extentY2 <= fullY1)
-                    continue;
-
-                if (fullX1 < extentX1)
-                    fullX1 = extentX1;
-                if (fullX2 > extentX2)
-                    fullX2 = extentX2;
-
-                if (fullX1 >= fullX2)
-                    continue;
-
-                for (iX = fullX1; iX < fullX2; iX += width) {
-                    int xoffset;
-
-                    if ((iX + pTile->drawable.width) > fullX2)
-                        width = fullX2 - iX;
-                    else
-                        width = pTile->drawable.width;
-
-                    if (iX == fullX1)
-                        xoffset =
-                            (fullX1 -
-                             (pDrawable->x +
-                              (pGC->patOrg.x % pTile->drawable.width) -
-                              pTile->drawable.width)) % pTile->drawable.width;
-                    else
-                        xoffset = 0;
-
-                    if (xoffset + width > pTile->drawable.width)
-                        width = pTile->drawable.width - xoffset;
-
-                    BitBlt(pGCPriv->hdc,
-                           iX, fullY1,
-                           width, 1,
-                           pGCPriv->hdcMem,
-                           xoffset,
-                           (fullY1 -
-                            (pDrawable->y +
-                             (pGC->patOrg.y % pTile->drawable.height) -
-                             pTile->drawable.height)) % pTile->drawable.height,
-                           g_copyROP[pGC->alu]);
-                }
-            }
-
-            /* Push the tile pixmap out of the memory HDC */
-            SelectObject(pGCPriv->hdcMem, hbmpOrig);
-            break;
-
-        default:
-            ErrorF("winFillSpans - DRAWABLE_WINDOW - Unknown fillStyle\n");
-            break;
-        }
-
-        /* Reset clip region */
-        SelectClipRgn(pGCPriv->hdc, NULL);
-        break;
-
-    default:
-        ErrorF("winFillSpans - Unknown drawable type\n");
-        break;
-    }
-}
diff --git a/hw/xwin/winfont.c b/hw/xwin/winfont.c
deleted file mode 100644
index 7bcbce1..0000000
--- a/hw/xwin/winfont.c
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- *Copyright (C) 2001-2004 Harold L Hunt II All Rights Reserved.
- *
- *Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- *"Software"), to deal in the Software without restriction, including
- *without limitation the rights to use, copy, modify, merge, publish,
- *distribute, 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 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 HAROLD L HUNT II 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.
- *
- *Except as contained in this notice, the name of Harold L Hunt II
- *shall not be used in advertising or otherwise to promote the sale, use
- *or other dealings in this Software without prior written authorization
- *from Harold L Hunt II.
- *
- * Authors:	Harold L Hunt II
- */
-
-#ifdef HAVE_XWIN_CONFIG_H
-#include <xwin-config.h>
-#endif
-#include "win.h"
-
-#ifdef XWIN_NATIVEGDI
-/* See Porting Layer Definition - p. 32 */
-/* See mfb/mfbfont.c - mfbRealizeFont() - which is empty :) */
-Bool
-winRealizeFontNativeGDI(ScreenPtr pScreen, FontPtr pFont)
-{
-    BOOL fResult = TRUE;
-
-    winScreenPriv(pScreen);
-
-#if CYGDEBUG
-    winTrace("winRealizeFont (%p, %p)\n", pScreen, pFont);
-#endif
-
-    WIN_UNWRAP(RealizeFont);
-    if (pScreen->RealizeFont)
-        fResult = (*pScreen->RealizeFont) (pScreen, pFont);
-    WIN_WRAP(RealizeFont, winRealizeFontNativeGDI);
-
-    return fResult;
-}
-
-/* See Porting Layer Definition - p. 32 */
-/* See mfb/mfbfont.c - mfbUnrealizeFont() - which is empty :) */
-Bool
-winUnrealizeFontNativeGDI(ScreenPtr pScreen, FontPtr pFont)
-{
-    BOOL fResult = TRUE;
-
-    winScreenPriv(pScreen);
-
-#if CYGDEBUG
-    winTrace("winUnrealizeFont (%p, %p)\n", pScreen, pFont);
-#endif
-
-    WIN_UNWRAP(UnrealizeFont);
-    if (pScreen->UnrealizeFont)
-        fResult = (*pScreen->UnrealizeFont) (pScreen, pFont);
-    WIN_WRAP(UnrealizeFont, winUnrealizeFontNativeGDI);
-
-    return fResult;
-#if CYGDEBUG
-    winDebug("winUnrealizeFont()\n");
-#endif
-    return TRUE;
-}
-#endif
diff --git a/hw/xwin/wingc.c b/hw/xwin/wingc.c
deleted file mode 100644
index 5986e0a..0000000
--- a/hw/xwin/wingc.c
+++ /dev/null
@@ -1,235 +0,0 @@
-/*
- *Copyright (C) 2001-2004 Harold L Hunt II All Rights Reserved.
- *
- *Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- *"Software"), to deal in the Software without restriction, including
- *without limitation the rights to use, copy, modify, merge, publish,
- *distribute, 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 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 HAROLD L HUNT II 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.
- *
- *Except as contained in this notice, the name of Harold L Hunt II
- *shall not be used in advertising or otherwise to promote the sale, use
- *or other dealings in this Software without prior written authorization
- *from Harold L Hunt II.
- *
- * Authors:	Harold L Hunt II
- */
-
-#ifdef HAVE_XWIN_CONFIG_H
-#include <xwin-config.h>
-#endif
-#include "win.h"
-
-/*
- * Local prototypes
- */
-
-#if 0
-static void
- winChangeGCNativeGDI(GCPtr pGC, unsigned long ulChanges);
-#endif
-
-static void
-
-winValidateGCNativeGDI(GCPtr pGC, unsigned long changes, DrawablePtr pDrawable);
-
-#if 0
-static void
- winCopyGCNativeGDI(GCPtr pGCsrc, unsigned long ulMask, GCPtr pGCdst);
-#endif
-
-static void
- winDestroyGCNativeGDI(GCPtr pGC);
-
-#if 0
-static void
- winChangeClipNativeGDI(GCPtr pGC, int nType, void *pValue, int nRects);
-
-static void
- winDestroyClipNativeGDI(GCPtr pGC);
-
-static void
- winCopyClipNativeGDI(GCPtr pGCdst, GCPtr pGCsrc);
-#endif
-
-#if 0
-/* GC Handling Routines */
-const GCFuncs winGCFuncs = {
-    winValidateGCNativeGDI,
-    winChangeGCNativeGDI,
-    winCopyGCNativeGDI,
-    winDestroyGCNativeGDI,
-    winChangeClipNativeGDI,
-    winDestroyClipNativeGDI,
-    winCopyClipNativeGDI,
-};
-#else
-const GCFuncs winGCFuncs = {
-    winValidateGCNativeGDI,
-    miChangeGC,
-    miCopyGC,
-    winDestroyGCNativeGDI,
-    miChangeClip,
-    miDestroyClip,
-    miCopyClip,
-};
-#endif
-
-/* Drawing Primitives */
-const GCOps winGCOps = {
-    winFillSpansNativeGDI,
-    winSetSpansNativeGDI,
-    miPutImage,
-    miCopyArea,
-    miCopyPlane,
-    miPolyPoint,
-    winPolyLineNativeGDI,
-    miPolySegment,
-    miPolyRectangle,
-    miPolyArc,
-    miFillPolygon,
-    miPolyFillRect,
-    miPolyFillArc,
-    miPolyText8,
-    miPolyText16,
-    miImageText8,
-    miImageText16,
-#if 0
-    winImageGlyphBltNativeGDI,
-    winPolyGlyphBltNativeGDI,
-#else
-    miImageGlyphBlt,
-    miPolyGlyphBlt,
-#endif
-    miPushPixels,
-};
-
-/* See Porting Layer Definition - p. 45 */
-/* See mfb/mfbgc.c - mfbCreateGC() */
-/* See Strategies for Porting - pp. 15, 16 */
-Bool
-winCreateGCNativeGDI(GCPtr pGC)
-{
-    winPrivGCPtr pGCPriv = NULL;
-    winPrivScreenPtr pScreenPriv = NULL;
-
-#if 0
-    ErrorF("winCreateGCNativeGDI - depth: %d\n", pGC->depth);
-#endif
-
-    pGC->ops = (GCOps *) &winGCOps;
-    pGC->funcs = (GCFuncs *) &winGCFuncs;
-
-    /* We want all coordinates passed to spans functions to be screen relative */
-    pGC->miTranslate = TRUE;
-
-    /* Allocate privates for this GC */
-    pGCPriv = winGetGCPriv(pGC);
-    if (pGCPriv == NULL) {
-        ErrorF("winCreateGCNativeGDI () - Privates pointer was NULL\n");
-        return FALSE;
-    }
-
-    /* Create a new screen DC for the display window */
-    pScreenPriv = winGetScreenPriv(pGC->pScreen);
-    pGCPriv->hdc = GetDC(pScreenPriv->hwndScreen);
-
-    /* Allocate a memory DC for the GC */
-    pGCPriv->hdcMem = CreateCompatibleDC(pGCPriv->hdc);
-
-    return TRUE;
-}
-
-#if 0
-/* See Porting Layer Definition - p. 45 */
-static void
-winChangeGCNativeGDI(GCPtr pGC, unsigned long ulChanges)
-{
-#if 0
-    ErrorF("winChangeGCNativeGDI () - Doing nothing\n");
-#endif
-}
-#endif
-
-static void
-winValidateGCNativeGDI(GCPtr pGC,
-                       unsigned long ulChanges, DrawablePtr pDrawable)
-{
-    if ((ulChanges &
-         (GCClipXOrigin | GCClipYOrigin | GCClipMask | GCSubwindowMode))
-        || (pDrawable->serialNumber !=
-            (pGC->serialNumber & DRAWABLE_SERIAL_BITS))) {
-        miComputeCompositeClip(pGC, pDrawable);
-    }
-}
-
-#if 0
-/* See Porting Layer Definition - p. 46 */
-static void
-winCopyGCNativeGDI(GCPtr pGCsrc, unsigned long ulMask, GCPtr pGCdst)
-{
-
-}
-#endif
-
-/* See Porting Layer Definition - p. 46 */
-static void
-winDestroyGCNativeGDI(GCPtr pGC)
-{
-    winGCPriv(pGC);
-    winScreenPriv(pGC->pScreen);
-
-    if (pGC->freeCompClip)
-        RegionDestroy(pGC->pCompositeClip);
-
-    /* Free the memory DC */
-    if (pGCPriv->hdcMem != NULL) {
-        DeleteDC(pGCPriv->hdcMem);
-        pGCPriv->hdcMem = NULL;
-    }
-
-    /* Release the screen DC for the display window */
-    if (pGCPriv->hdc != NULL) {
-        ReleaseDC(pScreenPriv->hwndScreen, pGCPriv->hdc);
-        pGCPriv->hdc = NULL;
-    }
-
-    /* Invalidate the GC privates pointer */
-    winSetGCPriv(pGC, NULL);
-}
-
-#if 0
-/* See Porting Layer Definition - p. 46 */
-static void
-winChangeClipNativeGDI(GCPtr pGC, int nType, void *pValue, int nRects)
-{
-
-}
-
-/* See Porting Layer Definition - p. 47 */
-static void
-winDestroyClipNativeGDI(GCPtr pGC)
-{
-
-}
-
-/* See Porting Layer Definition - p. 47 */
-static void
-winCopyClipNativeGDI(GCPtr pGCdst, GCPtr pGCsrc)
-{
-
-}
-#endif
diff --git a/hw/xwin/wingetsp.c b/hw/xwin/wingetsp.c
deleted file mode 100644
index 049e2c9..0000000
--- a/hw/xwin/wingetsp.c
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
- *
- *Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- *"Software"), to deal in the Software without restriction, including
- *without limitation the rights to use, copy, modify, merge, publish,
- *distribute, 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 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 XFREE86 PROJECT 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.
- *
- *Except as contained in this notice, the name of the XFree86 Project
- *shall not be used in advertising or otherwise to promote the sale, use
- *or other dealings in this Software without prior written authorization
- *from the XFree86 Project.
- *
- * Authors:	Harold L Hunt II
- * 		Alan Hourihane <alanh at fairlite.demon.co.uk>
- */
-
-#ifdef HAVE_XWIN_CONFIG_H
-#include <xwin-config.h>
-#endif
-#include "win.h"
-
-/* See Porting Layer Definition - p. 55 */
-void
-winGetSpansNativeGDI(DrawablePtr pDrawable,
-                     int nMax,
-                     DDXPointPtr pPoints,
-                     int *piWidths, int iSpans, char *pDsts)
-{
-    PixmapPtr pPixmap = NULL;
-    winPrivPixmapPtr pPixmapPriv = NULL;
-    int iSpan;
-    DDXPointPtr pPoint = NULL;
-    int *piWidth = NULL;
-    char *pDst = pDsts;
-    HBITMAP hbmpWindow, hbmpOrig, hbmpOrig1;
-    BYTE *pbWindow = NULL;
-    HDC hdcMem, hdcMem1;
-    ScreenPtr pScreen = pDrawable->pScreen;
-
-    winScreenPriv(pScreen);
-
-    /* Branch on the drawable type */
-    switch (pDrawable->type) {
-    case DRAWABLE_PIXMAP:
-#if 0
-        ErrorF("winGetSpans - DRAWABLE_PIXMAP %08x\n", pDrawable);
-#endif
-
-        pPixmap = (PixmapPtr) pDrawable;
-        pPixmapPriv = winGetPixmapPriv(pPixmap);
-
-        /* Open a memory HDC */
-        hdcMem1 = CreateCompatibleDC(NULL);
-        hdcMem = CreateCompatibleDC(NULL);
-
-        /* Select the drawable pixmap into a DC */
-        hbmpOrig1 = SelectObject(hdcMem1, pPixmapPriv->hBitmap);
-
-        if (hbmpOrig1 == NULL)
-            FatalError("winGetSpans - DRAWABLE_PIXMAP - SelectObject () "
-                       "failed on pPixmapPriv->hBitmap\n");
-
-        /* Loop through spans */
-        for (iSpan = 0; iSpan < iSpans; ++iSpan) {
-            pPoint = pPoints + iSpan;
-            piWidth = piWidths + iSpan;
-
-            hbmpWindow = winCreateDIBNativeGDI(*piWidth, 1,
-                                               pDrawable->depth,
-                                               &pbWindow, NULL);
-
-            hbmpOrig = SelectObject(hdcMem, hbmpWindow);
-
-            /* Transfer the window bits to the window bitmap */
-            BitBlt(hdcMem,
-                   0, 0, *piWidth, 1, hdcMem1, pPoint->x, pPoint->y, SRCCOPY);
-
-            memcpy(pDst,
-                   (char *) pbWindow,
-                   PixmapBytePad(*piWidth, pDrawable->depth));
-
-            /* Pop the window bitmap out of the HDC and delete the bitmap */
-            SelectObject(hdcMem, hbmpOrig);
-            DeleteObject(hbmpWindow);
-
-#if 0
-            ErrorF("(%dx%dx%d) (%d,%d) w: %d\n",
-                   pDrawable->width, pDrawable->height, pDrawable->depth,
-                   pPoint->x, pPoint->y, *piWidth);
-#endif
-
-            /* Calculate offset of next bit destination */
-            pDst += PixmapBytePad(*piWidth, pDrawable->depth);
-        }
-
-        /* Pop the pixmap's bitmap out of the HDC */
-        SelectObject(hdcMem1, hbmpOrig1);
-
-        /* Delete the HDCs */
-        DeleteDC(hdcMem1);
-        DeleteDC(hdcMem);
-        break;
-
-    case DRAWABLE_WINDOW:
-#if 0
-        ErrorF("winGetSpans - DRAWABLE_WINDOW\n");
-#endif
-
-        /* Open a memory HDC */
-        hdcMem = CreateCompatibleDC(NULL);
-
-        /* Loop through spans */
-        for (iSpan = 0; iSpan < iSpans; ++iSpan) {
-            pPoint = pPoints + iSpan;
-            piWidth = piWidths + iSpan;
-
-            hbmpWindow = winCreateDIBNativeGDI(*piWidth, 1,
-                                               pDrawable->depth,
-                                               &pbWindow, NULL);
-
-            hbmpOrig = SelectObject(hdcMem, hbmpWindow);
-
-            /* Transfer the window bits to the window bitmap */
-            BitBlt(hdcMem,
-                   0, 0,
-                   *piWidth, 1,
-                   pScreenPriv->hdcScreen, pPoint->x, pPoint->y, SRCCOPY);
-
-            memcpy(pDst,
-                   (char *) pbWindow,
-                   PixmapBytePad(*piWidth, pDrawable->depth));
-
-            /* Pop the window bitmap out of the HDC */
-            SelectObject(hdcMem, hbmpOrig);
-
-            DeleteObject(hbmpWindow);
-
-#if 0
-            ErrorF("(%dx%dx%d) (%d,%d) w: %d\n",
-                   pDrawable->width, pDrawable->height, pDrawable->depth,
-                   pPoint->x, pPoint->y, *piWidth);
-#endif
-
-            /* Calculate offset of next bit destination */
-            pDst += PixmapBytePad(*piWidth, pDrawable->depth);
-        }
-
-        /* Delete the window bitmap */
-        DeleteDC(hdcMem);
-        break;
-
-    default:
-        FatalError("winGetSpans - Unknown drawable type\n");
-        break;
-    }
-}
diff --git a/hw/xwin/winmisc.c b/hw/xwin/winmisc.c
index 10f9732..bea6290 100644
--- a/hw/xwin/winmisc.c
+++ b/hw/xwin/winmisc.c
@@ -33,21 +33,6 @@
 #endif
 #include "win.h"
 
-#ifdef XWIN_NATIVEGDI
-/* See Porting Layer Definition - p. 33 */
-/*
- * Called by clients, returns the best size for a cursor, tile, or
- * stipple, specified by class (sometimes called kind)
- */
-
-void
-winQueryBestSizeNativeGDI(int class, unsigned short *pWidth,
-                          unsigned short *pHeight, ScreenPtr pScreen)
-{
-    ErrorF("winQueryBestSizeNativeGDI\n");
-}
-#endif
-
 /*
  * Count the number of one bits in a color mask.
  */
@@ -93,51 +78,3 @@ winUpdateFBPointer(ScreenPtr pScreen, void *pbits)
 
     return TRUE;
 }
-
-#ifdef XWIN_NATIVEGDI
-/*
- * Paint the window background with the specified color
- */
-
-BOOL
-winPaintBackground(HWND hwnd, COLORREF colorref)
-{
-    HDC hdc;
-    HBRUSH hbrush;
-    RECT rect;
-
-    /* Create an hdc */
-    hdc = GetDC(hwnd);
-    if (hdc == NULL) {
-        printf("gdiWindowProc - GetDC failed\n");
-        exit(1);
-    }
-
-    /* Create and select blue brush */
-    hbrush = CreateSolidBrush(colorref);
-    if (hbrush == NULL) {
-        printf("gdiWindowProc - CreateSolidBrush failed\n");
-        exit(1);
-    }
-
-    /* Get window extents */
-    if (GetClientRect(hwnd, &rect) == FALSE) {
-        printf("gdiWindowProc - GetClientRect failed\n");
-        exit(1);
-    }
-
-    /* Fill window with blue brush */
-    if (FillRect(hdc, &rect, hbrush) == 0) {
-        printf("gdiWindowProc - FillRect failed\n");
-        exit(1);
-    }
-
-    /* Delete blue brush */
-    DeleteObject(hbrush);
-
-    /* Release the hdc */
-    ReleaseDC(hwnd, hdc);
-
-    return TRUE;
-}
-#endif
diff --git a/hw/xwin/winnativegdi.c b/hw/xwin/winnativegdi.c
deleted file mode 100644
index 1859698..0000000
--- a/hw/xwin/winnativegdi.c
+++ /dev/null
@@ -1,491 +0,0 @@
-/*
- *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
- *
- *Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- *"Software"), to deal in the Software without restriction, including
- *without limitation the rights to use, copy, modify, merge, publish,
- *distribute, 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 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 XFREE86 PROJECT 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.
- *
- *Except as contained in this notice, the name of the XFree86 Project
- *shall not be used in advertising or otherwise to promote the sale, use
- *or other dealings in this Software without prior written authorization
- *from the XFree86 Project.
- *
- * Authors:	Harold L Hunt II
- */
-
-#ifdef HAVE_XWIN_CONFIG_H
-#include <xwin-config.h>
-#endif
-#include "win.h"
-
-/*
- * Local function prototypes
- */
-
-static Bool
- winAllocateFBNativeGDI(ScreenPtr pScreen);
-
-static void
- winShadowUpdateNativeGDI(ScreenPtr pScreen, shadowBufPtr pBuf);
-
-static Bool
- winCloseScreenNativeGDI(ScreenPtr pScreen);
-
-static Bool
- winInitVisualsNativeGDI(ScreenPtr pScreen);
-
-static Bool
- winAdjustVideoModeNativeGDI(ScreenPtr pScreen);
-
-#if 0
-static Bool
- winBltExposedRegionsNativeGDI(ScreenPtr pScreen);
-#endif
-
-static Bool
- winActivateAppNativeGDI(ScreenPtr pScreen);
-
-static Bool
- winRedrawScreenNativeGDI(ScreenPtr pScreen);
-
-static Bool
- winRealizeInstalledPaletteNativeGDI(ScreenPtr pScreen);
-
-static Bool
- winInstallColormapNativeGDI(ColormapPtr pColormap);
-
-static Bool
- winStoreColorsNativeGDI(ColormapPtr pmap, int ndef, xColorItem * pdefs);
-
-static Bool
- winCreateColormapNativeGDI(ColormapPtr pColormap);
-
-static Bool
- winDestroyColormapNativeGDI(ColormapPtr pColormap);
-
-static Bool
-winAllocateFBNativeGDI(ScreenPtr pScreen)
-{
-    FatalError("winAllocateFBNativeGDI\n");
-
-    return TRUE;
-}
-
-static void
-winFreeFBNativeGDI(ScreenPtr pScreen)
-{
-    FatalError("winFreeFBNativeGDI\n");
-}
-
-static Bool
-winInitScreenNativeGDI(ScreenPtr pScreen)
-{
-    FatalError("winInitScreenNativeGDI\n");
-}
-
-/*
- * We wrap whatever CloseScreen procedure was specified by fb;
- * a pointer to said procedure is stored in our privates.
- */
-
-static Bool
-winCloseScreenNativeGDI(ScreenPtr pScreen)
-{
-    winScreenPriv(pScreen);
-    winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
-
-    ErrorF("winCloseScreenNativeGDI - Freeing screen resources\n");
-
-    /* Flag that the screen is closed */
-    pScreenPriv->fClosed = TRUE;
-    pScreenPriv->fActive = FALSE;
-
-    /* 
-     * NOTE: mi doesn't use a CloseScreen procedure, so we do not
-     * need to call a wrapped procedure here.
-     */
-
-    /* Delete the window property */
-    RemoveProp(pScreenPriv->hwndScreen, WIN_SCR_PROP);
-
-    ErrorF("winCloseScreenNativeGDI - Destroying window\n");
-
-    /* Delete tray icon, if we have one */
-    if (!pScreenInfo->fNoTrayIcon)
-        winDeleteNotifyIcon(pScreenPriv);
-
-    /* Free the exit confirmation dialog box, if it exists */
-    if (g_hDlgExit != NULL) {
-        DestroyWindow(g_hDlgExit);
-        g_hDlgExit = NULL;
-    }
-
-    /* Kill our window */
-    if (pScreenPriv->hwndScreen) {
-        DestroyWindow(pScreenPriv->hwndScreen);
-        pScreenPriv->hwndScreen = NULL;
-    }
-
-    /* Invalidate our screeninfo's pointer to the screen */
-    pScreenInfo->pScreen = NULL;
-
-    /* Free the screen privates for this screen */
-    free(pScreenPriv);
-
-    ErrorF("winCloseScreenNativeGDI - Returning\n");
-
-    return TRUE;
-}
-
-static void
-winShadowUpdateNativeGDI(ScreenPtr pScreen, shadowBufPtr pBuf)
-{
-    FatalError("winShadowUpdateNativeGDI\n");
-    return;
-}
-
-static Bool
-winInitVisualsNativeGDI(ScreenPtr pScreen)
-{
-    winScreenPriv(pScreen);
-    winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
-
-    /* Set the bitsPerRGB and bit masks */
-    switch (pScreenInfo->dwDepth) {
-    case 24:
-        pScreenPriv->dwBitsPerRGB = 8;
-        pScreenPriv->dwRedMask = 0x00FF0000;
-        pScreenPriv->dwGreenMask = 0x0000FF00;
-        pScreenPriv->dwBlueMask = 0x000000FF;
-        break;
-
-    case 16:
-        pScreenPriv->dwBitsPerRGB = 6;
-        pScreenPriv->dwRedMask = 0xF800;
-        pScreenPriv->dwGreenMask = 0x07E0;
-        pScreenPriv->dwBlueMask = 0x001F;
-        break;
-
-    case 15:
-        pScreenPriv->dwBitsPerRGB = 5;
-        pScreenPriv->dwRedMask = 0x7C00;
-        pScreenPriv->dwGreenMask = 0x03E0;
-        pScreenPriv->dwBlueMask = 0x001F;
-        break;
-
-    case 8:
-        pScreenPriv->dwBitsPerRGB = 8;
-        pScreenPriv->dwRedMask = 0;
-        pScreenPriv->dwGreenMask = 0;
-        pScreenPriv->dwBlueMask = 0;
-        break;
-
-    default:
-        ErrorF("winInitVisualsNativeGDI - Unknown screen depth\n");
-        return FALSE;
-        break;
-    }
-
-    /* Tell the user how many bits per RGB we are using */
-    ErrorF("winInitVisualsNativeGDI - Using dwBitsPerRGB: %d\n",
-           (int) pScreenPriv->dwBitsPerRGB);
-
-    /* Create a single visual according to the Windows screen depth */
-    switch (pScreenInfo->dwDepth) {
-    case 24:
-    case 16:
-    case 15:
-        if (!miSetVisualTypesAndMasks(pScreenInfo->dwDepth,
-                                      TrueColorMask,
-                                      pScreenPriv->dwBitsPerRGB,
-                                      TrueColor,
-                                      pScreenPriv->dwRedMask,
-                                      pScreenPriv->dwGreenMask,
-                                      pScreenPriv->dwBlueMask)) {
-            ErrorF("winInitVisuals - miSetVisualTypesAndMasks failed\n");
-            return FALSE;
-        }
-        break;
-
-    case 8:
-        ErrorF("winInitVisuals - Calling miSetVisualTypesAndMasks\n");
-        if (!miSetVisualTypesAndMasks(pScreenInfo->dwDepth,
-                                      StaticColorMask,
-                                      pScreenPriv->dwBitsPerRGB,
-                                      StaticColor,
-                                      pScreenPriv->dwRedMask,
-                                      pScreenPriv->dwGreenMask,
-                                      pScreenPriv->dwBlueMask)) {
-            ErrorF("winInitVisuals - miSetVisualTypesAndMasks failed\n");
-            return FALSE;
-        }
-        break;
-
-    default:
-        ErrorF("winInitVisualsNativeGDI - Unknown screen depth\n");
-        return FALSE;
-    }
-
-#if 1
-    ErrorF("winInitVisualsNativeGDI - Returning\n");
-#endif
-
-    return TRUE;
-}
-
-/* Adjust the video mode */
-static Bool
-winAdjustVideoModeNativeGDI(ScreenPtr pScreen)
-{
-    winScreenPriv(pScreen);
-    winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
-    HDC hdc = NULL;
-    DWORD dwBPP;
-
-    hdc = GetDC(NULL);
-
-    /* We're in serious trouble if we can't get a DC */
-    if (hdc == NULL) {
-        ErrorF("winAdjustVideoModeNativeGDI - GetDC () failed\n");
-        return FALSE;
-    }
-
-    /* Query GDI for current display depth */
-    dwBPP = GetDeviceCaps(hdc, BITSPIXEL);
-    pScreenInfo->dwDepth = GetDeviceCaps(hdc, PLANES);
-
-    switch (pScreenInfo->dwDepth) {
-    case 24:
-    case 16:
-    case 15:
-    case 8:
-        break;
-    default:
-        if (dwBPP == 32)
-            pScreenInfo->dwDepth = 24;
-        else
-            pScreenInfo->dwDepth = dwBPP;
-        break;
-    }
-
-    /* GDI cannot change the screen depth, so we'll use GDI's depth */
-    pScreenInfo->dwBPP = dwBPP;
-
-    /* Release our DC */
-    ReleaseDC(NULL, hdc);
-
-    return TRUE;
-}
-
-static Bool
-winActivateAppNativeGDI(ScreenPtr pScreen)
-{
-    winScreenPriv(pScreen);
-
-    /*
-     * Are we active?
-     * Are we fullscreen?
-     */
-    if (pScreenPriv != NULL
-        && pScreenPriv->fActive
-        && pScreenPriv->pScreenInfo && pScreenPriv->pScreenInfo->fFullScreen) {
-        /*
-         * Activating, attempt to bring our window 
-         * to the top of the display
-         */
-        ShowWindow(pScreenPriv->hwndScreen, SW_RESTORE);
-    }
-
-    /*
-     * Are we inactive?
-     * Are we fullscreen?
-     */
-    if (pScreenPriv != NULL
-        && !pScreenPriv->fActive
-        && pScreenPriv->pScreenInfo && pScreenPriv->pScreenInfo->fFullScreen) {
-        /*
-         * Deactivating, stuff our window onto the
-         * task bar.
-         */
-        ShowWindow(pScreenPriv->hwndScreen, SW_MINIMIZE);
-    }
-
-    return TRUE;
-}
-
-HBITMAP
-winCreateDIBNativeGDI(int iWidth, int iHeight, int iDepth,
-                      BYTE ** ppbBits, BITMAPINFO ** ppbmi)
-{
-    BITMAPINFOHEADER *pbmih = NULL;
-    HBITMAP hBitmap = NULL;
-    BITMAPINFO *pbmi = NULL;
-
-    /* Don't create an invalid bitmap */
-    if (iWidth == 0 || iHeight == 0 || iDepth == 0) {
-        ErrorF("\nwinCreateDIBNativeGDI - Invalid specs w %d h %d d %d\n\n",
-               iWidth, iHeight, iDepth);
-        return NULL;
-    }
-
-    /* Allocate bitmap info header */
-    pbmih = malloc(sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD));
-    if (pbmih == NULL) {
-        ErrorF("winCreateDIBNativeGDI - malloc () failed\n");
-        return FALSE;
-    }
-    ZeroMemory(pbmih, sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD));
-
-    /* Describe bitmap to be created */
-    pbmih->biSize = sizeof(BITMAPINFOHEADER);
-    pbmih->biWidth = iWidth;
-    pbmih->biHeight = -iHeight;
-    pbmih->biPlanes = 1;
-    pbmih->biBitCount = iDepth;
-    pbmih->biCompression = BI_RGB;
-    pbmih->biSizeImage = 0;
-    pbmih->biXPelsPerMeter = 0;
-    pbmih->biYPelsPerMeter = 0;
-    pbmih->biClrUsed = 0;
-    pbmih->biClrImportant = 0;
-
-    /* Setup color table for mono DIBs */
-    if (iDepth == 1) {
-        pbmi = (BITMAPINFO *) pbmih;
-        pbmi->bmiColors[1].rgbBlue = 255;
-        pbmi->bmiColors[1].rgbGreen = 255;
-        pbmi->bmiColors[1].rgbRed = 255;
-    }
-
-    /* Create a DIB with a bit pointer */
-    hBitmap = CreateDIBSection(NULL,
-                               (BITMAPINFO *) pbmih,
-                               DIB_RGB_COLORS, (void **) ppbBits, NULL, 0);
-    if (hBitmap == NULL) {
-        ErrorF("winCreateDIBNativeGDI - CreateDIBSection () failed\n");
-        return NULL;
-    }
-
-    /* Free the bitmap info header memory */
-    if (ppbmi != NULL) {
-        /* Store the address of the BMIH in the ppbmih parameter */
-        *ppbmi = (BITMAPINFO *) pbmih;
-    }
-    else {
-        free(pbmih);
-        pbmih = NULL;
-    }
-
-    return hBitmap;
-}
-
-#if 0
-static Bool
-winBltExposedRegionsNativeGDI(ScreenPtr pScreen)
-{
-
-    return TRUE;
-}
-#endif
-
-static Bool
-winRedrawScreenNativeGDI(ScreenPtr pScreen)
-{
-    FatalError("winRedrawScreenNativeGDI\n");
-    return TRUE;
-}
-
-static Bool
-winRealizeInstalledPaletteNativeGDI(ScreenPtr pScreen)
-{
-    FatalError("winRealizeInstalledPaletteNativeGDI\n");
-    return TRUE;
-}
-
-static Bool
-winInstallColormapNativeGDI(ColormapPtr pColormap)
-{
-    FatalError("winInstallColormapNativeGDI\n");
-    return TRUE;
-}
-
-static Bool
-winStoreColorsNativeGDI(ColormapPtr pmap, int ndef, xColorItem * pdefs)
-{
-    FatalError("winStoreColorsNativeGDI\n");
-    return TRUE;
-}
-
-static Bool
-winCreateColormapNativeGDI(ColormapPtr pColormap)
-{
-    FatalError("winCreateColormapNativeGDI\n");
-    return TRUE;
-}
-
-static Bool
-winDestroyColormapNativeGDI(ColormapPtr pColormap)
-{
-    FatalError("winDestroyColormapNativeGDI\n");
-    return TRUE;
-}
-
-/* Set engine specific funtions */
-Bool
-winSetEngineFunctionsNativeGDI(ScreenPtr pScreen)
-{
-    winScreenPriv(pScreen);
-    winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo;
-
-    /* Set our pointers */
-    pScreenPriv->pwinAllocateFB = winAllocateFBNativeGDI;
-    pScreenPriv->pwinFreeFB = winFreeFBNativeGDI;
-    pScreenPriv->pwinShadowUpdate = winShadowUpdateNativeGDI;
-    pScreenPriv->pwinInitScreen = winInitScreenNativeGDI;
-    pScreenPriv->pwinCloseScreen = winCloseScreenNativeGDI;
-    pScreenPriv->pwinInitVisuals = winInitVisualsNativeGDI;
-    pScreenPriv->pwinAdjustVideoMode = winAdjustVideoModeNativeGDI;
-    if (pScreenInfo->fFullScreen)
-        pScreenPriv->pwinCreateBoundingWindow =
-            winCreateBoundingWindowFullScreen;
-    else
-        pScreenPriv->pwinCreateBoundingWindow = winCreateBoundingWindowWindowed;
-    pScreenPriv->pwinFinishScreenInit = winFinishScreenInitNativeGDI;
-    /*
-     * WARNING: Do not set the BltExposedRegions procedure pointer to anything
-     * other than NULL until a working painting procedure is in place.
-     * Else, winWindowProc will get stuck in an infinite loop because
-     * Windows expects the BeginPaint and EndPaint functions to be called
-     * before a WM_PAINT message can be removed from the queue.  We are
-     * using NULL here as a signal for winWindowProc that it should
-     * not signal that the WM_PAINT message has been processed.
-     */
-    pScreenPriv->pwinBltExposedRegions = NULL;
-    pScreenPriv->pwinActivateApp = winActivateAppNativeGDI;
-    pScreenPriv->pwinRedrawScreen = winRedrawScreenNativeGDI;
-    pScreenPriv->pwinRealizeInstalledPalette =
-        winRealizeInstalledPaletteNativeGDI;
-    pScreenPriv->pwinInstallColormap = winInstallColormapNativeGDI;
-    pScreenPriv->pwinStoreColors = winStoreColorsNativeGDI;
-    pScreenPriv->pwinCreateColormap = winCreateColormapNativeGDI;
-    pScreenPriv->pwinDestroyColormap = winDestroyColormapNativeGDI;
-    pScreenPriv->pwinHotKeyAltTab =
-        (winHotKeyAltTabProcPtr) (void (*)(void)) NoopDDA;
-
-    return TRUE;
-}
diff --git a/hw/xwin/winpixmap.c b/hw/xwin/winpixmap.c
deleted file mode 100644
index ef158c8..0000000
--- a/hw/xwin/winpixmap.c
+++ /dev/null
@@ -1,223 +0,0 @@
-/*
- *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
- *
- *Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- *"Software"), to deal in the Software without restriction, including
- *without limitation the rights to use, copy, modify, merge, publish,
- *distribute, 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 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 XFREE86 PROJECT 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.
- *
- *Except as contained in this notice, the name of the XFree86 Project
- *shall not be used in advertising or otherwise to promote the sale, use
- *or other dealings in this Software without prior written authorization
- *from the XFree86 Project.
- *
- * Authors:	drewry, september 1986
- *		Harold L Hunt II
- */
-
-#ifdef HAVE_XWIN_CONFIG_H
-#include <xwin-config.h>
-#endif
-#include "win.h"
-
-/*
- * Local prototypes
- */
-
-#if 0
-static void
- winXRotatePixmapNativeGDI(PixmapPtr pPix, int rw);
-
-static void
- winYRotatePixmapNativeGDI(PixmapPtr pPix, int rh);
-
-static void
-
-winCopyRotatePixmapNativeGDI(PixmapPtr psrcPix, PixmapPtr *ppdstPix,
-                             int xrot, int yrot);
-#endif
-
-/* See Porting Layer Definition - p. 34 */
-/* See mfb/mfbpixmap.c - mfbCreatePixmap() */
-PixmapPtr
-winCreatePixmapNativeGDI(ScreenPtr pScreen,
-                         int iWidth, int iHeight,
-                         int iDepth, unsigned usage_hint)
-{
-    winPrivPixmapPtr pPixmapPriv = NULL;
-    PixmapPtr pPixmap = NULL;
-
-    /* Allocate pixmap memory */
-    pPixmap = AllocatePixmap(pScreen, 0);
-    if (!pPixmap) {
-        ErrorF("winCreatePixmapNativeGDI () - Couldn't allocate a pixmap\n");
-        return NullPixmap;
-    }
-
-#if CYGDEBUG
-    winDebug("winCreatePixmap () - w %d h %d d %d uh %d bw %d\n",
-             iWidth, iHeight, iDepth, usage_hint,
-             PixmapBytePad(iWidth, iDepth));
-#endif
-
-    /* Setup pixmap values */
-    pPixmap->drawable.type = DRAWABLE_PIXMAP;
-    pPixmap->drawable.class = 0;
-    pPixmap->drawable.pScreen = pScreen;
-    pPixmap->drawable.depth = iDepth;
-    pPixmap->drawable.bitsPerPixel = BitsPerPixel(iDepth);
-    pPixmap->drawable.id = 0;
-    pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
-    pPixmap->drawable.x = 0;
-    pPixmap->drawable.y = 0;
-    pPixmap->drawable.width = iWidth;
-    pPixmap->drawable.height = iHeight;
-    pPixmap->devKind = 0;
-    pPixmap->refcnt = 1;
-    pPixmap->devPrivate.ptr = NULL;
-    pPixmap->usage_hint = usage_hint;
-
-    /* Pixmap privates are allocated by AllocatePixmap */
-    pPixmapPriv = winGetPixmapPriv(pPixmap);
-
-    /* Initialize pixmap privates */
-    pPixmapPriv->hBitmap = NULL;
-    pPixmapPriv->hdcSelected = NULL;
-    pPixmapPriv->pbBits = NULL;
-    pPixmapPriv->dwScanlineBytes = PixmapBytePad(iWidth, iDepth);
-
-    /* Check for zero width or height pixmaps */
-    if (iWidth == 0 || iHeight == 0) {
-        /* Don't allocate a real pixmap, just set fields and return */
-        return pPixmap;
-    }
-
-    /* Create a DIB for the pixmap */
-    pPixmapPriv->hBitmap = winCreateDIBNativeGDI(iWidth, iHeight, iDepth,
-                                                 &pPixmapPriv->pbBits,
-                                                 (BITMAPINFO **) &pPixmapPriv->
-                                                 pbmih);
-
-#if CYGDEBUG
-    winDebug("winCreatePixmap () - Created a pixmap %08x, %dx%dx%d, for "
-             "screen: %08x\n",
-             pPixmapPriv->hBitmap, iWidth, iHeight, iDepth, pScreen);
-#endif
-
-    return pPixmap;
-}
-
-/* 
- * See Porting Layer Definition - p. 35
- *
- * See mfb/mfbpixmap.c - mfbDestroyPixmap()
- */
-
-Bool
-winDestroyPixmapNativeGDI(PixmapPtr pPixmap)
-{
-    winPrivPixmapPtr pPixmapPriv = NULL;
-
-#if CYGDEBUG
-    winDebug("winDestroyPixmapNativeGDI ()\n");
-#endif
-
-    /* Bail early if there is not a pixmap to destroy */
-    if (pPixmap == NULL) {
-        ErrorF("winDestroyPixmapNativeGDI () - No pixmap to destroy\n");
-        return TRUE;
-    }
-
-    /* Get a handle to the pixmap privates */
-    pPixmapPriv = winGetPixmapPriv(pPixmap);
-
-#if CYGDEBUG
-    winDebug("winDestroyPixmapNativeGDI - pPixmapPriv->hBitmap: %08x\n",
-             pPixmapPriv->hBitmap);
-#endif
-
-    /* Decrement reference count, return if nonzero */
-    --pPixmap->refcnt;
-    if (pPixmap->refcnt != 0)
-        return TRUE;
-
-    /* Free GDI bitmap */
-    if (pPixmapPriv->hBitmap)
-        DeleteObject(pPixmapPriv->hBitmap);
-
-    /* Free the bitmap info header memory */
-    free(pPixmapPriv->pbmih);
-    pPixmapPriv->pbmih = NULL;
-
-    /* Free the pixmap memory */
-    free(pPixmap);
-    pPixmap = NULL;
-
-    return TRUE;
-}
-
-/* 
- * Not used yet
- */
-
-Bool
-winModifyPixmapHeaderNativeGDI(PixmapPtr pPixmap,
-                               int iWidth, int iHeight,
-                               int iDepth,
-                               int iBitsPerPixel, int devKind, void *pPixData)
-{
-    FatalError("winModifyPixmapHeaderNativeGDI ()\n");
-    return TRUE;
-}
-
-#if 0
-/* 
- * Not used yet.
- * See cfb/cfbpixmap.c
- */
-
-static void
-winXRotatePixmapNativeGDI(PixmapPtr pPix, int rw)
-{
-    ErrorF("winXRotatePixmap()\n");
-    /* fill in this function, look at CFB */
-}
-
-/*
- * Not used yet.
- * See cfb/cfbpixmap.c
- */
-static void
-winYRotatePixmapNativeGDI(PixmapPtr pPix, int rh)
-{
-    ErrorF("winYRotatePixmap()\n");
-    /* fill in this function, look at CFB */
-}
-
-/* 
- * Not used yet.
- * See cfb/cfbpixmap.c
- */
-
-static void
-winCopyRotatePixmapNativeGDI(PixmapPtr psrcPix, PixmapPtr *ppdstPix,
-                             int xrot, int yrot)
-{
-    ErrorF("winCopyRotatePixmap()\n");
-    /* fill in this function, look at CFB */
-}
-#endif
diff --git a/hw/xwin/winpolyline.c b/hw/xwin/winpolyline.c
deleted file mode 100644
index 8b7e106..0000000
--- a/hw/xwin/winpolyline.c
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- *Copyright (C) 2001-2004 Harold L Hunt II All Rights Reserved.
- *
- *Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- *"Software"), to deal in the Software without restriction, including
- *without limitation the rights to use, copy, modify, merge, publish,
- *distribute, 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 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 HAROLD L HUNT II 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.
- *
- *Except as contained in this notice, the name of Harold L Hunt II
- *shall not be used in advertising or otherwise to promote the sale, use
- *or other dealings in this Software without prior written authorization
- *from Harold L Hunt II.
- *
- * Authors:	Harold L Hunt II
- */
-
-#ifdef HAVE_XWIN_CONFIG_H
-#include <xwin-config.h>
-#endif
-#include "win.h"
-
-/* See Porting Layer Definition - p. 50 */
-void
-winPolyLineNativeGDI(DrawablePtr pDrawable,
-                     GCPtr pGC, int mode, int npt, DDXPointPtr ppt)
-{
-    switch (pGC->lineStyle) {
-    case LineSolid:
-        if (pGC->lineWidth == 0)
-            return miZeroLine(pDrawable, pGC, mode, npt, ppt);
-        else
-            miWideLine(pDrawable, pGC, mode, npt, ppt);
-        break;
-    case LineOnOffDash:
-    case LineDoubleDash:
-        miWideDash(pDrawable, pGC, mode, npt, ppt);
-        break;
-    }
-}
diff --git a/hw/xwin/winrop.c b/hw/xwin/winrop.c
deleted file mode 100644
index 1f9ff73..0000000
--- a/hw/xwin/winrop.c
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- *Copyright (C) 1994-2002 The XFree86 Project, Inc. All Rights Reserved.
- *
- *Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- *"Software"), to deal in the Software without restriction, including
- *without limitation the rights to use, copy, modify, merge, publish,
- *distribute, 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 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 XFREE86 PROJECT 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.
- *
- *Except as contained in this notice, the name of the XFree86 Project
- *shall not be used in advertising or otherwise to promote the sale, use
- *or other dealings in this Software without prior written authorization
- *from the XFree86 Project.
- *
- * 	Authors:	Alan Hourihane <alanh at fairlite.demon.co.uk>
- */
-
-/*
- * Raster operations used by Windows translated to X's 16 rop codes...
- */
-#ifdef HAVE_XWIN_CONFIG_H
-#include <xwin-config.h>
-#endif
-#include "win.h"
-
-void
- ROP16(HDC hdc, int rop);
-
-int g_copyROP[16] = { 0xFF0062, /* GXclear            - 0 */
-    0x8800C6,                   /* GXand              - S & D */
-    0x440328,                   /* GXandReverse       - S & !D */
-    0xCC0020,                   /* GXcopy             - S */
-    0x220326,                   /* GXandInverted      - !S & D */
-    0xAA0029,                   /* GXnoop             - D */
-    0x660046,                   /* GXxor              - S ^ D */
-    0xEE0086,                   /* GXor               - S | D */
-    0x1100A6,                   /* GXnor              - !S & !D */
-    0x990126,                   /* GXequiv            - !S ^ D */
-    0x550009,                   /* GXinvert           - !D */
-    0xDD0228,                   /* GXorReverse        - S | !D */
-    0x330008,                   /* GXcopyInverted     - !S */
-    0xBB0226,                   /* GXorInverted       - !S | D */
-    0x7700C6,                   /* GXnand             - !S | !D */
-    0x000042                    /* GXset              - 1 */
-};
-
-int g_patternROP[16] = { 0xFF0062,      /* GXclear            - 0 */
-    0xA000C9,                   /* GXand              - P & D */
-    0xF50225,                   /* GXandReverse       - P & !D */
-    0xF00021,                   /* GXcopy             - P */
-    0x5F00E9,                   /* GXandInverted      - !P & D */
-    0xAA0029,                   /* GXnoop             - D */
-    0xA50065,                   /* GXxor              - P ^ D */
-    0xA000C9,                   /* GXor               - P | D */
-    0x5F00E9,                   /* GXnor              - !P & !D */
-    0x5A0049,                   /* GXequiv            - !P ^ D */
-    0x550009,                   /* GXinvert           - !D */
-    0x500325,                   /* GXorReverse        - P | !D */
-    0x0F0001,                   /* GXcopyInverted     - !P */
-    0x0A0329,                   /* GXorInverted       - !P | D */
-    0x0500A9,                   /* GXnand             - !P | !D */
-    0x000042                    /* GXset              - 1 */
-};
-
-void
-ROP16(HDC hdc, int rop)
-{
-    switch (rop) {
-    case GXclear:
-        SetROP2(hdc, R2_BLACK);
-        break;
-
-    case GXand:
-        SetROP2(hdc, R2_MASKPEN);
-        break;
-
-    case GXandReverse:
-        SetROP2(hdc, R2_MASKPENNOT);
-        break;
-
-    case GXcopy:
-        SetROP2(hdc, R2_COPYPEN);
-        break;
-
-    case GXnoop:
-        SetROP2(hdc, R2_NOP);
-        break;
-
-    case GXxor:
-        SetROP2(hdc, R2_XORPEN);
-        break;
-
-    case GXor:
-        SetROP2(hdc, R2_MERGEPEN);
-        break;
-
-    case GXnor:
-        SetROP2(hdc, R2_NOTMERGEPEN);
-        break;
-
-    case GXequiv:
-        SetROP2(hdc, R2_NOTXORPEN);
-        break;
-
-    case GXinvert:
-        SetROP2(hdc, R2_NOT);
-        break;
-
-    case GXorReverse:
-        SetROP2(hdc, R2_MERGEPENNOT);
-        break;
-
-    case GXcopyInverted:
-        SetROP2(hdc, R2_NOTCOPYPEN);
-        break;
-
-    case GXorInverted:
-        SetROP2(hdc, R2_MERGENOTPEN);
-        break;
-
-    case GXnand:
-        SetROP2(hdc, R2_NOTMASKPEN);
-        break;
-
-    case GXset:
-        SetROP2(hdc, R2_WHITE);
-        break;
-    }
-}
diff --git a/hw/xwin/winscrinit.c b/hw/xwin/winscrinit.c
index 23152cb..ed1773c 100644
--- a/hw/xwin/winscrinit.c
+++ b/hw/xwin/winscrinit.c
@@ -570,145 +570,6 @@ winFinishScreenInitFB(int i, ScreenPtr pScreen, int argc, char **argv)
     return TRUE;
 }
 
-#ifdef XWIN_NATIVEGDI
-/* See Porting Layer Definition - p. 20 */
-
-Bool
-winFinishScreenInitNativeGDI(int i,
-                             ScreenPtr pScreen, int argc, char **argv)
-{
-    winScreenPriv(pScreen);
-    winScreenInfoPtr pScreenInfo = &g_ScreenInfo[i];
-    VisualPtr pVisuals = NULL;
-    DepthPtr pDepths = NULL;
-    VisualID rootVisual = 0;
-    int nVisuals = 0, nDepths = 0, nRootDepth = 0;
-
-    /* Ignore user input (mouse, keyboard) */
-    pScreenInfo->fIgnoreInput = FALSE;
-
-    /* Get device contexts for the screen and shadow bitmap */
-    pScreenPriv->hdcScreen = GetDC(pScreenPriv->hwndScreen);
-    if (pScreenPriv->hdcScreen == NULL)
-        FatalError("winFinishScreenInitNativeGDI - Couldn't get a DC\n");
-
-    /* Init visuals */
-    if (!(*pScreenPriv->pwinInitVisuals) (pScreen)) {
-        ErrorF("winFinishScreenInitNativeGDI - pwinInitVisuals failed\n");
-        return FALSE;
-    }
-
-    /* Initialize the mi visuals */
-    if (!miInitVisuals(&pVisuals, &pDepths, &nVisuals, &nDepths, &nRootDepth,
-                       &rootVisual,
-                       ((unsigned long) 1 << (pScreenInfo->dwDepth - 1)), 8,
-                       TrueColor)) {
-        ErrorF("winFinishScreenInitNativeGDI - miInitVisuals () failed\n");
-        return FALSE;
-    }
-
-    /* Initialize the CloseScreen procedure pointer */
-    pScreen->CloseScreen = NULL;
-
-    /* Initialize the mi code */
-    if (!miScreenInit(pScreen, NULL,    /* No framebuffer */
-                      pScreenInfo->dwWidth, pScreenInfo->dwHeight,
-                      monitorResolution, monitorResolution,
-                      pScreenInfo->dwStride,
-                      nRootDepth, nDepths, pDepths, rootVisual,
-                      nVisuals, pVisuals)) {
-        ErrorF("winFinishScreenInitNativeGDI - miScreenInit failed\n");
-        return FALSE;
-    }
-
-    pScreen->defColormap = FakeClientID(0);
-
-    /*
-     * Register our block and wakeup handlers; these procedures
-     * process messages in our Windows message queue; specifically,
-     * they process mouse and keyboard input.
-     */
-    pScreen->BlockHandler = winBlockHandler;
-    pScreen->WakeupHandler = winWakeupHandler;
-
-    /* Place our save screen function */
-    pScreen->SaveScreen = winSaveScreen;
-
-    /* Pixmaps */
-    pScreen->CreatePixmap = winCreatePixmapNativeGDI;
-    pScreen->DestroyPixmap = winDestroyPixmapNativeGDI;
-
-    /* Other Screen Routines */
-    pScreen->QueryBestSize = winQueryBestSizeNativeGDI;
-    pScreen->SaveScreen = winSaveScreen;
-    pScreen->GetImage = miGetImage;
-    pScreen->GetSpans = winGetSpansNativeGDI;
-
-    /* Window Procedures */
-    pScreen->CreateWindow = winCreateWindowNativeGDI;
-    pScreen->DestroyWindow = winDestroyWindowNativeGDI;
-    pScreen->PositionWindow = winPositionWindowNativeGDI;
-    /*pScreen->ChangeWindowAttributes = winChangeWindowAttributesNativeGDI; */
-    pScreen->RealizeWindow = winMapWindowNativeGDI;
-    pScreen->UnrealizeWindow = winUnmapWindowNativeGDI;
-
-    /* Paint window */
-    pScreen->CopyWindow = winCopyWindowNativeGDI;
-
-    /* Fonts */
-    pScreen->RealizeFont = winRealizeFontNativeGDI;
-    pScreen->UnrealizeFont = winUnrealizeFontNativeGDI;
-
-    /* GC */
-    pScreen->CreateGC = winCreateGCNativeGDI;
-
-    /* Colormap Routines */
-    pScreen->CreateColormap = miInitializeColormap;
-    pScreen->DestroyColormap =
-        (DestroyColormapProcPtr) (void (*)(void)) NoopDDA;
-    pScreen->InstallColormap = miInstallColormap;
-    pScreen->UninstallColormap = miUninstallColormap;
-    pScreen->ListInstalledColormaps = miListInstalledColormaps;
-    pScreen->StoreColors = (StoreColorsProcPtr) (void (*)(void)) NoopDDA;
-    pScreen->ResolveColor = miResolveColor;
-
-    /* Bitmap */
-    pScreen->BitmapToRegion = winPixmapToRegionNativeGDI;
-
-    ErrorF("winFinishScreenInitNativeGDI - calling miDCInitialize\n");
-
-    /* Set the default white and black pixel positions */
-    pScreen->whitePixel = pScreen->blackPixel = (Pixel) 0;
-
-    /* Initialize the cursor */
-    if (!miDCInitialize(pScreen, &g_winPointerCursorFuncs)) {
-        ErrorF("winFinishScreenInitNativeGDI - miDCInitialize failed\n");
-        return FALSE;
-    }
-
-    /* Create a default colormap */
-    if (!miCreateDefColormap(pScreen)) {
-        ErrorF("winFinishScreenInitNativeGDI - miCreateDefColormap () "
-               "failed\n");
-        return FALSE;
-    }
-
-    ErrorF("winFinishScreenInitNativeGDI - miCreateDefColormap () "
-           "returned\n");
-
-    /* mi doesn't use a CloseScreen procedure, so no need to wrap */
-    pScreen->CloseScreen = pScreenPriv->pwinCloseScreen;
-
-    /* Tell the server that we are enabled */
-    pScreenPriv->fEnabled = TRUE;
-
-    ErrorF("winFinishScreenInitNativeGDI - Successful addition of "
-           "screen %p\n", pScreen);
-
-    return TRUE;
-}
-#endif
-
 /* See Porting Layer Definition - p. 33 */
 static Bool
 winSaveScreen(ScreenPtr pScreen, int on)
diff --git a/hw/xwin/winsetsp.c b/hw/xwin/winsetsp.c
deleted file mode 100644
index 11108cb..0000000
--- a/hw/xwin/winsetsp.c
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
- *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
- *
- *Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- *"Software"), to deal in the Software without restriction, including
- *without limitation the rights to use, copy, modify, merge, publish,
- *distribute, 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 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 XFREE86 PROJECT 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.
- *
- *Except as contained in this notice, the name of the XFree86 Project
- *shall not be used in advertising or otherwise to promote the sale, use
- *or other dealings in this Software without prior written authorization
- *from the XFree86 Project.
- *
- * Authors:	Harold L Hunt II
- * 		Alan Hourihane <alanh at fairlite.demon.co.uk>
- */
-
-#ifdef HAVE_XWIN_CONFIG_H
-#include <xwin-config.h>
-#endif
-#include "win.h"
-
-/* See Porting Layer Definition - p. 55 */
-void
-winSetSpansNativeGDI(DrawablePtr pDrawable,
-                     GCPtr pGC,
-                     char *pSrcs,
-                     DDXPointPtr pPoints,
-                     int *piWidths, int iSpans, int fSorted)
-{
-    winGCPriv(pGC);
-    PixmapPtr pPixmap = NULL;
-    winPrivPixmapPtr pPixmapPriv = NULL;
-    HBITMAP hbmpOrig = NULL;
-    BITMAPINFO *pbmi;
-    HRGN hrgn = NULL, combined = NULL;
-    int nbox;
-    BoxPtr pbox;
-
-    nbox = RegionNumRects(pGC->pCompositeClip);
-    pbox = RegionRects(pGC->pCompositeClip);
-
-    if (!nbox)
-        return;
-
-    pbmi = malloc(sizeof(BITMAPINFO) + sizeof(RGBQUAD));
-
-    combined = CreateRectRgn(pbox->x1, pbox->y1, pbox->x2, pbox->y2);
-    nbox--;
-    pbox++;
-    while (nbox--) {
-        hrgn = CreateRectRgn(pbox->x1, pbox->y1, pbox->x2, pbox->y2);
-        CombineRgn(combined, combined, hrgn, RGN_OR);
-        DeleteObject(hrgn);
-        hrgn = NULL;
-        pbox++;
-    }
-
-    /* Branch on the drawable type */
-    switch (pDrawable->type) {
-    case DRAWABLE_PIXMAP:
-
-        SelectClipRgn(pGCPriv->hdcMem, combined);
-        DeleteObject(combined);
-        combined = NULL;
-
-        pPixmap = (PixmapPtr) pDrawable;
-        pPixmapPriv = winGetPixmapPriv(pPixmap);
-
-        /* Select the drawable pixmap into a DC */
-        hbmpOrig = SelectObject(pGCPriv->hdcMem, pPixmapPriv->hBitmap);
-        if (hbmpOrig == NULL)
-            FatalError("winSetSpans - DRAWABLE_PIXMAP - SelectObject () "
-                       "failed on pPixmapPriv->hBitmap\n");
-
-        while (iSpans--) {
-            ZeroMemory(pbmi, sizeof(BITMAPINFO));
-            pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
-            pbmi->bmiHeader.biWidth = *piWidths;
-            pbmi->bmiHeader.biHeight = 1;
-            pbmi->bmiHeader.biPlanes = 1;
-            pbmi->bmiHeader.biBitCount = pDrawable->depth;
-            pbmi->bmiHeader.biCompression = BI_RGB;
-
-            /* Setup color table for mono DIBs */
-            if (pDrawable->depth == 1) {
-                RGBQUAD *bmiColors = &(pbmi->bmiColors[0]);
-                bmiColors[1].rgbBlue = 255;
-                bmiColors[1].rgbGreen = 255;
-                bmiColors[1].rgbRed = 255;
-            }
-
-            StretchDIBits(pGCPriv->hdcMem,
-                          pPoints->x, pPoints->y,
-                          *piWidths, 1,
-                          0, 0,
-                          *piWidths, 1,
-                          pSrcs,
-                          (BITMAPINFO *) pbmi,
-                          DIB_RGB_COLORS, g_copyROP[pGC->alu]);
-
-            pSrcs += PixmapBytePad(*piWidths, pDrawable->depth);
-            pPoints++;
-            piWidths++;
-        }
-
-        /* Reset the clip region */
-        SelectClipRgn(pGCPriv->hdcMem, NULL);
-
-        /* Push the drawable pixmap out of the GC HDC */
-        SelectObject(pGCPriv->hdcMem, hbmpOrig);
-        break;
-
-    case DRAWABLE_WINDOW:
-
-        SelectClipRgn(pGCPriv->hdc, combined);
-        DeleteObject(combined);
-        combined = NULL;
-
-        while (iSpans--) {
-            ZeroMemory(pbmi, sizeof(BITMAPINFO));
-            pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
-            pbmi->bmiHeader.biWidth = *piWidths;
-            pbmi->bmiHeader.biHeight = 1;
-            pbmi->bmiHeader.biPlanes = 1;
-            pbmi->bmiHeader.biBitCount = pDrawable->depth;
-            pbmi->bmiHeader.biCompression = BI_RGB;
-
-            /* Setup color table for mono DIBs */
-            if (pDrawable->depth == 1) {
-                RGBQUAD *bmiColors = &(pbmi->bmiColors[0]);
-                bmiColors[1].rgbBlue = 255;
-                bmiColors[1].rgbGreen = 255;
-                bmiColors[1].rgbRed = 255;
-            }
-
-            StretchDIBits(pGCPriv->hdc,
-                          pPoints->x, pPoints->y,
-                          *piWidths, 1,
-                          0, 0,
-                          *piWidths, 1,
-                          pSrcs,
-                          (BITMAPINFO *) pbmi,
-                          DIB_RGB_COLORS, g_copyROP[pGC->alu]);
-
-            pSrcs += PixmapBytePad(*piWidths, pDrawable->depth);
-            pPoints++;
-            piWidths++;
-        }
-
-        /* Reset the clip region */
-        SelectClipRgn(pGCPriv->hdc, NULL);
-        break;
-
-    default:
-        FatalError("\nwinSetSpansNativeGDI - Unknown drawable type\n\n");
-        break;
-    }
-
-    free(pbmi);
-}
diff --git a/hw/xwin/winwindow.c b/hw/xwin/winwindow.c
index 8c1c28f..934f6d8 100644
--- a/hw/xwin/winwindow.c
+++ b/hw/xwin/winwindow.c
@@ -49,225 +49,6 @@ static
     void
  winReshapeRootless(WindowPtr pWin);
 
-#ifdef XWIN_NATIVEGDI
-/* See Porting Layer Definition - p. 37 */
-/* See mfb/mfbwindow.c - mfbCreateWindow() */
-
-Bool
-winCreateWindowNativeGDI(WindowPtr pWin)
-{
-    Bool fResult = TRUE;
-    ScreenPtr pScreen = pWin->drawable.pScreen;
-
-    winScreenPriv(pScreen);
-
-#if CYGDEBUG
-    winTrace("winCreateWindowNativeGDI (%p)\n", pWin);
-#endif
-
-    WIN_UNWRAP(CreateWindow);
-    fResult = (*pScreen->CreateWindow) (pWin);
-    WIN_WRAP(CreateWindow, winCreateWindowNativeGDI);
-
-    return fResult;
-}
-
-/* See Porting Layer Definition - p. 37 */
-/* See mfb/mfbwindow.c - mfbDestroyWindow() */
-
-Bool
-winDestroyWindowNativeGDI(WindowPtr pWin)
-{
-    Bool fResult = TRUE;
-    ScreenPtr pScreen = pWin->drawable.pScreen;
-
-    winScreenPriv(pScreen);
-
-#if CYGDEBUG
-    winTrace("winDestroyWindowNativeGDI (%p)\n", pWin);
-#endif
-
-    WIN_UNWRAP(DestroyWindow);
-    fResult = (*pScreen->DestroyWindow) (pWin);
-    WIN_WRAP(DestroyWindow, winDestroyWindowNativeGDI);
-
-    return fResult;
-}
-
-/* See Porting Layer Definition - p. 37 */
-/* See mfb/mfbwindow.c - mfbPositionWindow() */
-
-Bool
-winPositionWindowNativeGDI(WindowPtr pWin, int x, int y)
-{
-    Bool fResult = TRUE;
-    ScreenPtr pScreen = pWin->drawable.pScreen;
-
-    winScreenPriv(pScreen);
-
-#if CYGDEBUG
-    winTrace("winPositionWindowNativeGDI (%p)\n", pWin);
-#endif
-
-    WIN_UNWRAP(PositionWindow);
-    fResult = (*pScreen->PositionWindow) (pWin, x, y);
-    WIN_WRAP(PositionWindow, winPositionWindowNativeGDI);
-
-    return fResult;
-}
-
-/* See Porting Layer Definition - p. 39 */
-/* See mfb/mfbwindow.c - mfbCopyWindow() */
-
-void
-winCopyWindowNativeGDI(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
-{
-    DDXPointPtr pptSrc;
-    DDXPointPtr ppt;
-    RegionPtr prgnDst;
-    BoxPtr pBox;
-    int dx, dy;
-    int i, nbox;
-    BoxPtr pBoxDst;
-    ScreenPtr pScreen = pWin->drawable.pScreen;
-
-    winScreenPriv(pScreen);
-
-#if 0
-    ErrorF("winCopyWindow\n");
-#endif
-
-    /* Create a region for the destination */
-    prgnDst = RegionCreate(NULL, 1);
-
-    /* Calculate the shift from the source to the destination */
-    dx = ptOldOrg.x - pWin->drawable.x;
-    dy = ptOldOrg.y - pWin->drawable.y;
-
-    /* Translate the region from the destination to the source? */
-    RegionTranslate(prgnSrc, -dx, -dy);
-    RegionIntersect(prgnDst, &pWin->borderClip, prgnSrc);
-
-    /* Get a pointer to the first box in the region to be copied */
-    pBox = RegionRects(prgnDst);
-
-    /* Get the number of boxes in the region */
-    nbox = RegionNumRects(prgnDst);
-
-    /* Allocate source points for each box */
-    if (!(pptSrc = malloc(nbox * sizeof(DDXPointRec))))
-        return;
-
-    /* Set an iterator pointer */
-    ppt = pptSrc;
-
-    /* Calculate the source point of each box? */
-    for (i = nbox; --i >= 0; ppt++, pBox++) {
-        ppt->x = pBox->x1 + dx;
-        ppt->y = pBox->y1 + dy;
-    }
-
-    /* Setup loop pointers again */
-    pBoxDst = RegionRects(prgnDst);
-    ppt = pptSrc;
-
-#if 0
-    ErrorF("winCopyWindow - x1\tx2\ty1\ty2\tx\ty\n");
-#endif
-
-    /* BitBlt each source to the destination point */
-    for (i = nbox; --i >= 0; pBoxDst++, ppt++) {
-#if 0
-        ErrorF("winCopyWindow - %d\t%d\t%d\t%d\t%d\t%d\n",
-               pBoxDst->x1, pBoxDst->x2, pBoxDst->y1, pBoxDst->y2,
-               ppt->x, ppt->y);
-#endif
-
-        BitBlt(pScreenPriv->hdcScreen,
-               pBoxDst->x1, pBoxDst->y1,
-               pBoxDst->x2 - pBoxDst->x1, pBoxDst->y2 - pBoxDst->y1,
-               pScreenPriv->hdcScreen, ppt->x, ppt->y, SRCCOPY);
-    }
-
-    /* Cleanup the regions, etc. */
-    free(pptSrc);
-    RegionDestroy(prgnDst);
-}
-
-/* See Porting Layer Definition - p. 37 */
-/* See mfb/mfbwindow.c - mfbChangeWindowAttributes() */
-
-Bool
-winChangeWindowAttributesNativeGDI(WindowPtr pWin, unsigned long mask)
-{
-    Bool fResult = TRUE;
-    ScreenPtr pScreen = pWin->drawable.pScreen;
-
-    winScreenPriv(pScreen);
-
-#if CYGDEBUG
-    winTrace("winChangeWindowAttributesNativeGDI (%p)\n", pWin);
-#endif
-
-    WIN_UNWRAP(ChangeWindowAttributes);
-    fResult = (*pScreen->ChangeWindowAttributes) (pWin, mask);
-    WIN_WRAP(ChangeWindowAttributes, winChangeWindowAttributesNativeGDI);
-
-    /*
-     * NOTE: We do not currently need to do anything here.
-     */
-
-    return fResult;
-}
-
-/* See Porting Layer Definition - p. 37
- * Also referred to as UnrealizeWindow
- */
-
-Bool
-winUnmapWindowNativeGDI(WindowPtr pWin)
-{
-    Bool fResult = TRUE;
-    ScreenPtr pScreen = pWin->drawable.pScreen;
-
-    winScreenPriv(pScreen);
-
-#if CYGDEBUG
-    winTrace("winUnmapWindowNativeGDI (%p)\n", pWin);
-#endif
-
-    WIN_UNWRAP(UnrealizeWindow);
-    fResult = (*pScreen->UnrealizeWindow) (pWin);
-    WIN_WRAP(UnrealizeWindow, winUnmapWindowNativeGDI);
-
-    return fResult;
-}
-
-/* See Porting Layer Definition - p. 37
- * Also referred to as RealizeWindow
- */
-
-Bool
-winMapWindowNativeGDI(WindowPtr pWin)
-{
-    Bool fResult = TRUE;
-    ScreenPtr pScreen = pWin->drawable.pScreen;
-
-    winScreenPriv(pScreen);
-
-#if CYGDEBUG
-    winTrace("winMapWindowNativeGDI (%p)\n", pWin);
-#endif
-
-    WIN_UNWRAP(RealizeWindow);
-    fResult = (*pScreen->RealizeWindow) (pWin);
-    WIN_WRAP(RealizeWindow, winMapWindowMultiWindow);
-
-    return fResult;
-
-}
-#endif
-
 /* See Porting Layer Definition - p. 37 */
 /* See mfb/mfbwindow.c - mfbCreateWindow() */
 
commit e2a3e91a56cb598f2c8257614d92ccd46b7fc094
Author: Adam Jackson <ajax at redhat.com>
Date:   Fri Jul 25 11:01:22 2014 -0400

    rootless: remove redundant RootlessShapedWindowIn
    
    miShapedWindowIn is identical.  Which you would expect, since neither
    one takes an actual WindowPtr argument, so they couldn't possibly make
    reference to rootlessness.
    
    Reviewed-by: Julien Cristau <jcristau at debian.org>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/miext/rootless/rootlessValTree.c b/miext/rootless/rootlessValTree.c
index 730d291..c7c2c99 100644
--- a/miext/rootless/rootlessValTree.c
+++ b/miext/rootless/rootlessValTree.c
@@ -106,64 +106,6 @@ Equipment Corporation.
 
 int RootlessMiValidateTree(WindowPtr pRoot, WindowPtr pChild, VTKind kind);
 
-/*
- * Compute the visibility of a shaped window
- */
-static int
-RootlessShapedWindowIn(RegionPtr universe,
-                       RegionPtr bounding, BoxPtr rect, int x, int y)
-{
-    BoxRec box;
-    register BoxPtr boundBox;
-    int nbox;
-    Bool someIn, someOut;
-    register int t, x1, y1, x2, y2;
-
-    nbox = RegionNumRects(bounding);
-    boundBox = RegionRects(bounding);
-    someIn = someOut = FALSE;
-    x1 = rect->x1;
-    y1 = rect->y1;
-    x2 = rect->x2;
-    y2 = rect->y2;
-    while (nbox--) {
-        if ((t = boundBox->x1 + x) < x1)
-            t = x1;
-        box.x1 = t;
-        if ((t = boundBox->y1 + y) < y1)
-            t = y1;
-        box.y1 = t;
-        if ((t = boundBox->x2 + x) > x2)
-            t = x2;
-        box.x2 = t;
-        if ((t = boundBox->y2 + y) > y2)
-            t = y2;
-        box.y2 = t;
-        if (box.x1 > box.x2)
-            box.x2 = box.x1;
-        if (box.y1 > box.y2)
-            box.y2 = box.y1;
-        switch (RegionContainsRect(universe, &box)) {
-        case rgnIN:
-            if (someOut)
-                return rgnPART;
-            someIn = TRUE;
-            break;
-        case rgnOUT:
-            if (someIn)
-                return rgnPART;
-            someOut = TRUE;
-            break;
-        default:
-            return rgnPART;
-        }
-        boundBox++;
-    }
-    if (someIn)
-        return rgnIN;
-    return rgnOUT;
-}
-
 #define HasParentRelativeBorder(w) (!(w)->borderIsPixel && \
 				    HasBorder(w) && \
 				    (w)->backgroundState == ParentRelative)
@@ -229,10 +171,9 @@ RootlessComputeClips(WindowPtr pParent, ScreenPtr pScreen,
             RegionPtr pBounding;
 
             if ((pBounding = wBoundingShape(pParent))) {
-                switch (RootlessShapedWindowIn(universe,
-                                               pBounding, &borderSize,
-                                               pParent->drawable.x,
-                                               pParent->drawable.y)) {
+                switch (miShapedWindowIn(universe, pBounding, &borderSize,
+                                         pParent->drawable.x,
+                                         pParent->drawable.y)) {
                 case rgnIN:
                     newVis = VisibilityUnobscured;
                     break;
commit 7e8ac6dcd24d56e384ad09c7c23259cb3f4f8dc6
Author: Adam Jackson <ajax at redhat.com>
Date:   Thu Sep 11 12:30:15 2014 -0400

    xquartz: Remove useless DRIWindowExposures
    
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/hw/xquartz/xpr/dri.c b/hw/xquartz/xpr/dri.c
index 0f19047..565d94f 100644
--- a/hw/xquartz/xpr/dri.c
+++ b/hw/xquartz/xpr/dri.c
@@ -138,9 +138,6 @@ DRIFinishScreenInit(ScreenPtr pScreen)
     DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
 
     /* Wrap DRI support */
-    pDRIPriv->wrap.WindowExposures = pScreen->WindowExposures;
-    pScreen->WindowExposures = DRIWindowExposures;
-
     pDRIPriv->wrap.CopyWindow = pScreen->CopyWindow;
     pScreen->CopyWindow = DRICopyWindow;
 
@@ -577,24 +574,6 @@ DRIDrawablePrivDelete(void *pResource, XID id)
 }
 
 void
-DRIWindowExposures(WindowPtr pWin, RegionPtr prgn, RegionPtr bsreg)
-{
-    ScreenPtr pScreen = pWin->drawable.pScreen;
-    DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
-    DRIDrawablePrivPtr pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin);
-
-    if (pDRIDrawablePriv) {
-        /* FIXME: something? */
-    }
-
-    pScreen->WindowExposures = pDRIPriv->wrap.WindowExposures;
-
-    (*pScreen->WindowExposures)(pWin, prgn, bsreg);
-
-    pScreen->WindowExposures = DRIWindowExposures;
-}
-
-void
 DRICopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
 {
     ScreenPtr pScreen = pWin->drawable.pScreen;
diff --git a/hw/xquartz/xpr/dri.h b/hw/xquartz/xpr/dri.h
index 4476b06..a4400a2 100644
--- a/hw/xquartz/xpr/dri.h
+++ b/hw/xquartz/xpr/dri.h
@@ -51,7 +51,6 @@ typedef void (*ClipNotifyPtr)(WindowPtr, int, int);
  * overridden by the driver in its [driver]DRIScreenInit function.
  */
 typedef struct {
-    WindowExposuresProcPtr WindowExposures;
     CopyWindowProcPtr CopyWindow;
     ClipNotifyProcPtr ClipNotify;
 } DRIWrappedFuncsRec, *DRIWrappedFuncsPtr;
@@ -109,9 +108,6 @@ extern void
 DRIClipNotify(WindowPtr pWin, int dx, int dy);
 
 extern void
-DRIWindowExposures(WindowPtr pWin, RegionPtr prgn, RegionPtr bsreg);
-
-extern void
 DRISurfaceNotify(xp_surface_id id, int kind);
 
 extern void
commit a8c6fc46c088bedb36c6441b78c98ca4cb9761b4
Author: Adam Jackson <ajax at redhat.com>
Date:   Thu Sep 11 10:24:27 2014 -0400

    kdrive: Remove vestigial reference to fbInitValidateTree
    
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/hw/kdrive/src/kdrive.c b/hw/kdrive/src/kdrive.c
index 5dbff3f..dddbe6e 100644
--- a/hw/kdrive/src/kdrive.c
+++ b/hw/kdrive/src/kdrive.c
@@ -909,10 +909,6 @@ KdScreenInit(ScreenPtr pScreen, int argc, char **argv)
         if (!(*card->cfuncs->finishInitScreen) (pScreen))
             return FALSE;
 
-#if 0
-    fbInitValidateTree(pScreen);
-#endif
-
     /*
      * Wrap CloseScreen, the order now is:
      *  KdCloseScreen
commit 7ebf480f5eb75e06271ec924769e51bdcbbdc69c
Author: Adam Jackson <ajax at redhat.com>
Date:   Fri Feb 28 12:34:49 2014 -0500

    xfree86: Remove some can't-happen printf from xf86CreateRootWindow
    
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
index 7686294..017dcb6 100644
--- a/hw/xfree86/common/xf86Init.c
+++ b/hw/xfree86/common/xf86Init.c
@@ -308,14 +308,6 @@ xf86CreateRootWindow(WindowPtr pWin)
 
     DebugF("xf86CreateRootWindow(%p)\n", pWin);
 
-    if (pScreen->CreateWindow != xf86CreateRootWindow) {
-        /* Can't find hook we are hung on */
-        xf86DrvMsg(pScreen->myNum, X_WARNING /* X_ERROR */ ,
-                   "xf86CreateRootWindow %p called when not in pScreen->CreateWindow %p n",
-                   (void *) xf86CreateRootWindow,
-                   (void *) pScreen->CreateWindow);
-    }
-
     /* Unhook this function ... */
     pScreen->CreateWindow = create_window;
     dixSetPrivate(&pScreen->devPrivates, xf86CreateRootWindowKey, NULL);
@@ -343,15 +335,8 @@ xf86CreateRootWindow(WindowPtr pWin)
             ret &= (err == Success);
 
         }
-        else {
-            xf86Msg(X_ERROR, "xf86CreateRootWindow unexpectedly called with "
-                    "non-root window %p (parent %p)\n",
-                    (void *) pWin, (void *) pWin->parent);
-            ret = FALSE;
-        }
     }
 
-    DebugF("xf86CreateRootWindow() returns %d\n", ret);
     return ret;
 }
 
commit 3689be96ac125c9bfca9d37de4878f05f4e2f584
Author: Adam Jackson <ajax at redhat.com>
Date:   Tue Jun 10 12:54:41 2014 -0400

    vfb: Don't reimplement micmap so much
    
    We know we're atop fb which is atop micmap, the only thing we need to
    hook is InstallColormap to handle the xwd colormap change.
    
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/hw/vfb/InitOutput.c b/hw/vfb/InitOutput.c
index 9c49264..bcaaa85 100644
--- a/hw/vfb/InitOutput.c
+++ b/hw/vfb/InitOutput.c
@@ -380,26 +380,10 @@ ddxProcessArgument(int argc, char *argv[], int i)
     return 0;
 }
 
-static DevPrivateKeyRec cmapScrPrivateKeyRec;
-
-#define cmapScrPrivateKey (&cmapScrPrivateKeyRec)
-
-#define GetInstalledColormap(s) ((ColormapPtr) dixLookupPrivate(&(s)->devPrivates, cmapScrPrivateKey))
-#define SetInstalledColormap(s,c) (dixSetPrivate(&(s)->devPrivates, cmapScrPrivateKey, c))
-
-static int
-vfbListInstalledColormaps(ScreenPtr pScreen, Colormap * pmaps)
-{
-    /* By the time we are processing requests, we can guarantee that there
-     * is always a colormap installed */
-    *pmaps = GetInstalledColormap(pScreen)->mid;
-    return 1;
-}
-
 static void
 vfbInstallColormap(ColormapPtr pmap)
 {
-    ColormapPtr oldpmap = GetInstalledColormap(pmap->pScreen);
+    ColormapPtr oldpmap = GetInstalledmiColormap(pmap->pScreen);
 
     if (pmap != oldpmap) {
         int entries;
@@ -410,11 +394,7 @@ vfbInstallColormap(ColormapPtr pmap)
         xColorItem *defs;
         int i;
 
-        if (oldpmap != (ColormapPtr) None)
-            WalkTree(pmap->pScreen, TellLostMap, (char *) &oldpmap->mid);
-        /* Install pmap */
-        SetInstalledColormap(pmap->pScreen, pmap);
-        WalkTree(pmap->pScreen, TellGainedMap, (char *) &pmap->mid);
+        miInstallColormap(pmap);
 
         entries = pmap->pVisual->ColormapEntries;
         pXWDHeader = vfbScreens[pmap->pScreen->myNum].pXWDHeader;
@@ -452,28 +432,12 @@ vfbInstallColormap(ColormapPtr pmap)
 }
 
 static void
-vfbUninstallColormap(ColormapPtr pmap)
-{
-    ColormapPtr curpmap = GetInstalledColormap(pmap->pScreen);
-
-    if (pmap == curpmap) {
-        if (pmap->mid != pmap->pScreen->defColormap) {
-            dixLookupResourceByType((void **) &curpmap,
-                                    pmap->pScreen->defColormap,
-                                    RT_COLORMAP, serverClient,
-                                    DixInstallAccess);
-            (*pmap->pScreen->InstallColormap) (curpmap);
-        }
-    }
-}
-
-static void
 vfbStoreColors(ColormapPtr pmap, int ndef, xColorItem * pdefs)
 {
     XWDColor *pXWDCmap;
     int i;
 
-    if (pmap != GetInstalledColormap(pmap->pScreen)) {
+    if (pmap != GetInstalledmiColormap(pmap->pScreen)) {
         return;
     }
 
@@ -761,18 +725,10 @@ static Bool
 vfbCloseScreen(ScreenPtr pScreen)
 {
     vfbScreenInfoPtr pvfb = &vfbScreens[pScreen->myNum];
-    int i;
 
     pScreen->CloseScreen = pvfb->closeScreen;
 
     /*
-     * XXX probably lots of stuff to clean.  For now,
-     * clear installed colormaps so that server reset works correctly.
-     */
-    for (i = 0; i < screenInfo.numScreens; i++)
-        SetInstalledColormap(screenInfo.screens[i], NULL);
-
-    /*
      * fb overwrites miCloseScreen, so do this here
      */
     if (pScreen->devPrivate)
@@ -790,9 +746,6 @@ vfbScreenInit(ScreenPtr pScreen, int argc, char **argv)
     int ret;
     char *pbits;
 
-    if (!dixRegisterPrivateKey(&cmapScrPrivateKeyRec, PRIVATE_SCREEN, 0))
-        return FALSE;
-
     if (dpix == 0)
         dpix = 100;
 
@@ -859,8 +812,6 @@ vfbScreenInit(ScreenPtr pScreen, int argc, char **argv)
         return FALSE;
 
     pScreen->InstallColormap = vfbInstallColormap;
-    pScreen->UninstallColormap = vfbUninstallColormap;
-    pScreen->ListInstalledColormaps = vfbListInstalledColormaps;
 
     pScreen->SaveScreen = vfbSaveScreen;
     pScreen->StoreColors = vfbStoreColors;
commit 692676debbc2227054d67078c6442f1ab1811192
Author: Adam Jackson <ajax at redhat.com>
Date:   Mon Jun 16 12:35:28 2014 -0400

    loader: Remove some baklava code
    
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/hw/xfree86/loader/loadmod.c b/hw/xfree86/loader/loadmod.c
index 21ccb1b..7021bdd 100644
--- a/hw/xfree86/loader/loadmod.c
+++ b/hw/xfree86/loader/loadmod.c
@@ -77,12 +77,8 @@ typedef struct _pattern {
 static char *FindModule(const char *, const char *, const char **, PatternPtr);
 static Bool CheckVersion(const char *, XF86ModuleVersionInfo *,
                          const XF86ModReqInfo *);
-static void UnloadModuleOrDriver(ModuleDescPtr mod);
 static char *LoaderGetCanonicalName(const char *, PatternPtr);
 static void RemoveChild(ModuleDescPtr);
-static ModuleDescPtr doLoadModule(const char *, const char *, const char **,
-                                  const char **, void *,
-                                  const XF86ModReqInfo *, int *, int *);
 
 const ModuleVersions LoaderVersionInfo = {
     XORG_VERSION_CURRENT,
@@ -754,8 +750,8 @@ LoadSubModule(void *_parent, const char *module,
         return NULL;
     }
 
-    submod = doLoadModule(module, NULL, subdirlist, patternlist, options,
-                          modreq, errmaj, errmin);
+    submod = LoadModule(module, NULL, subdirlist, patternlist, options,
+                        modreq, errmaj, errmin);
     if (submod && submod != (ModuleDescPtr) 1) {
         parent->child = AddSibling(parent->child, submod);
         submod->parent = parent;
@@ -818,10 +814,47 @@ static const char *compiled_in_modules[] = {
     NULL
 };
 
-static ModuleDescPtr
-doLoadModule(const char *module, const char *path, const char **subdirlist,
-             const char **patternlist, void *options,
-             const XF86ModReqInfo * modreq, int *errmaj, int *errmin)
+/*
+ * LoadModule: load a module
+ *
+ * module       The module name.  Normally this is not a filename but the
+ *              module's "canonical name.  A full pathname is, however,
+ *              also accepted.
+ * path         A comma separated list of module directories.
+ * subdirlist   A NULL terminated list of subdirectories to search.  When
+ *              NULL, the default "stdSubdirs" list is used.  The default
+ *              list is also substituted for entries with value DEFAULT_LIST.
+ * patternlist  A NULL terminated list of regular expressions used to find
+ *              module filenames.  Each regex should contain exactly one
+ *              subexpression that corresponds to the canonical module name.
+ *              When NULL, the default "stdPatterns" list is used.  The
+ *              default list is also substituted for entries with value
+ *              DEFAULT_LIST.
+ * options      A NULL terminated list of Options that are passed to the
+ *              module's SetupProc function.
+ * modreq       An optional XF86ModReqInfo* containing
+ *              version/ABI/vendor-ABI requirements to check for when
+ *              loading the module.  The following fields of the
+ *              XF86ModReqInfo struct are checked:
+ *                majorversion - must match the module's majorversion exactly
+ *                minorversion - the module's minorversion must be >= this
+ *                patchlevel   - the module's minorversion.patchlevel must be
+ *                               >= this.  Patchlevel is ignored when
+ *                               minorversion is not set.
+ *                abiclass     - (string) must match the module's abiclass
+ *                abiversion   - must be consistent with the module's
+ *                               abiversion (major equal, minor no older)
+ *                moduleclass  - string must match the module's moduleclass
+ *                               string
+ *              "don't care" values are ~0 for numbers, and NULL for strings
+ * errmaj       Major error return.
+ * errmin       Minor error return.
+ *
+ */
+ModuleDescPtr
+LoadModule(const char *module, const char *path, const char **subdirlist,
+           const char **patternlist, void *options,
+           const XF86ModReqInfo * modreq, int *errmaj, int *errmin)
 {
     XF86ModuleData *initdata = NULL;
     char **pathlist = NULL;
@@ -1009,61 +1042,11 @@ doLoadModule(const char *module, const char *path, const char **subdirlist,
     return ret;
 }
 
-/*
- * LoadModule: load a module
- *
- * module       The module name.  Normally this is not a filename but the
- *              module's "canonical name.  A full pathname is, however,
- *              also accepted.
- * path         A comma separated list of module directories.
- * subdirlist   A NULL terminated list of subdirectories to search.  When
- *              NULL, the default "stdSubdirs" list is used.  The default
- *              list is also substituted for entries with value DEFAULT_LIST.
- * patternlist  A NULL terminated list of regular expressions used to find
- *              module filenames.  Each regex should contain exactly one
- *              subexpression that corresponds to the canonical module name.
- *              When NULL, the default "stdPatterns" list is used.  The
- *              default list is also substituted for entries with value
- *              DEFAULT_LIST.
- * options      A NULL terminated list of Options that are passed to the
- *              module's SetupProc function.
- * modreq       An optional XF86ModReqInfo* containing
- *              version/ABI/vendor-ABI requirements to check for when
- *              loading the module.  The following fields of the
- *              XF86ModReqInfo struct are checked:
- *                majorversion - must match the module's majorversion exactly
- *                minorversion - the module's minorversion must be >= this
- *                patchlevel   - the module's minorversion.patchlevel must be
- *                               >= this.  Patchlevel is ignored when
- *                               minorversion is not set.
- *                abiclass     - (string) must match the module's abiclass
- *                abiversion   - must be consistent with the module's
- *                               abiversion (major equal, minor no older)
- *                moduleclass  - string must match the module's moduleclass
- *                               string
- *              "don't care" values are ~0 for numbers, and NULL for strings
- * errmaj       Major error return.
- * errmin       Minor error return.
- *
- */
-ModuleDescPtr
-LoadModule(const char *module, const char *path, const char **subdirlist,
-           const char **patternlist, void *options,
-           const XF86ModReqInfo * modreq, int *errmaj, int *errmin)
-{
-    return doLoadModule(module, path, subdirlist, patternlist, options,
-                        modreq, errmaj, errmin);
-}
-
 void
-UnloadModule(void *mod)
+UnloadModule(void *_mod)
 {
-    UnloadModuleOrDriver((ModuleDescPtr) mod);
-}
+    ModuleDescPtr mod = _mod;
 
-static void
-UnloadModuleOrDriver(ModuleDescPtr mod)
-{
     if (mod == (ModuleDescPtr) 1)
         return;
 
@@ -1083,9 +1066,9 @@ UnloadModuleOrDriver(ModuleDescPtr mod)
     }
 
     if (mod->child)
-        UnloadModuleOrDriver(mod->child);
+        UnloadModule(mod->child);
     if (mod->sib)
-        UnloadModuleOrDriver(mod->sib);
+        UnloadModule(mod->sib);
     free(mod->path);
     free(mod->name);
     free(mod);
@@ -1100,7 +1083,7 @@ UnloadSubModule(void *_mod)
     if (mod == (ModuleDescPtr) 1)
         return;
     RemoveChild(mod);
-    UnloadModuleOrDriver(mod);
+    UnloadModule(mod);
 }
 
 static void
commit c695a1430b80bac0b95e4d7f559e1bd223ecb1ef
Author: Adam Jackson <ajax at redhat.com>
Date:   Tue Jul 8 14:38:34 2014 -0400

    input: Remove unused SetKeySymsMap
    
    Reviewed-by: Daniel Stone <daniels at collabora.com>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/dix/devices.c b/dix/devices.c
index f17a3ac..3fb7ca0 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -1214,63 +1214,6 @@ QueryMinMaxKeyCodes(KeyCode *minCode, KeyCode *maxCode)
     }
 }
 
-/* Notably, this function does not expand the destination's keycode range, or
- * notify clients. */
-Bool
-SetKeySymsMap(KeySymsPtr dst, KeySymsPtr src)
-{
-    int i, j;
-    KeySym *tmp;
-    int rowDif = src->minKeyCode - dst->minKeyCode;
-
-    /* if keysym map size changes, grow map first */
-    if (src->mapWidth < dst->mapWidth) {
-        for (i = src->minKeyCode; i <= src->maxKeyCode; i++) {
-#define SI(r, c) (((r - src->minKeyCode) * src->mapWidth) + (c))
-#define DI(r, c) (((r - dst->minKeyCode) * dst->mapWidth) + (c))
-            for (j = 0; j < src->mapWidth; j++)
-                dst->map[DI(i, j)] = src->map[SI(i, j)];
-            for (j = src->mapWidth; j < dst->mapWidth; j++)
-                dst->map[DI(i, j)] = NoSymbol;
-#undef SI
-#undef DI
-        }
-        return TRUE;
-    }
-    else if (src->mapWidth > dst->mapWidth) {
-        i = sizeof(KeySym) * src->mapWidth *
-            (dst->maxKeyCode - dst->minKeyCode + 1);
-        tmp = calloc(sizeof(KeySym), i);
-        if (!tmp)
-            return FALSE;
-
-        if (dst->map) {
-            for (i = 0; i <= dst->maxKeyCode - dst->minKeyCode; i++)
-                memmove(&tmp[i * src->mapWidth], &dst->map[i * dst->mapWidth],
-                        dst->mapWidth * sizeof(KeySym));
-            free(dst->map);
-        }
-        dst->mapWidth = src->mapWidth;
-        dst->map = tmp;
-    }
-    else if (!dst->map) {
-        i = sizeof(KeySym) * src->mapWidth *
-            (dst->maxKeyCode - dst->minKeyCode + 1);
-        tmp = calloc(sizeof(KeySym), i);
-        if (!tmp)
-            return FALSE;
-
-        dst->map = tmp;
-        dst->mapWidth = src->mapWidth;
-    }
-
-    memmove(&dst->map[rowDif * dst->mapWidth], src->map,
-            (src->maxKeyCode - src->minKeyCode + 1) *
-            dst->mapWidth * sizeof(KeySym));
-
-    return TRUE;
-}
-
 Bool
 InitButtonClassDeviceStruct(DeviceIntPtr dev, int numButtons, Atom *labels,
                             CARD8 *map)
diff --git a/include/input.h b/include/input.h
index 1b2102f..35ceafa 100644
--- a/include/input.h
+++ b/include/input.h
@@ -287,9 +287,6 @@ extern _X_EXPORT int dixLookupDevice(DeviceIntPtr * /* dev */ ,
 extern _X_EXPORT void QueryMinMaxKeyCodes(KeyCode * /*minCode */ ,
                                           KeyCode * /*maxCode */ );
 
-extern _X_EXPORT Bool SetKeySymsMap(KeySymsPtr /*dst */ ,
-                                    KeySymsPtr /*src */ );
-
 extern _X_EXPORT Bool InitButtonClassDeviceStruct(DeviceIntPtr /*device */ ,
                                                   int /*numButtons */ ,
                                                   Atom * /* labels */ ,
commit 645063cd9384a26353775e92a79ed8710c6ca66c
Author: Adam Jackson <ajax at redhat.com>
Date:   Tue Mar 4 12:51:49 2014 -0500

    exa, kdrive: Remove redundant BitsPerPixel macros
    
    We already get this from servermd.h
    
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/exa/exa_priv.h b/exa/exa_priv.h
index 61a1f4c..88bfd37 100644
--- a/exa/exa_priv.h
+++ b/exa/exa_priv.h
@@ -214,18 +214,6 @@ typedef struct {
     DevPrivateKeyRec gcPrivateKeyRec;
 } ExaScreenPrivRec, *ExaScreenPrivPtr;
 
-/*
- * This is the only completely portable way to
- * compute this info.
- */
-#ifndef BitsPerPixel
-#define BitsPerPixel(d) (\
-    PixmapWidthPaddingInfo[d].notPower2 ? \
-    (PixmapWidthPaddingInfo[d].bytesPerPixel * 8) : \
-    ((1 << PixmapWidthPaddingInfo[d].padBytesLog2) * 8 / \
-    (PixmapWidthPaddingInfo[d].padRoundUp+1)))
-#endif
-
 extern DevPrivateKeyRec exaScreenPrivateKeyRec;
 
 #define exaScreenPrivateKey (&exaScreenPrivateKeyRec)
diff --git a/hw/kdrive/src/kdrive.h b/hw/kdrive/src/kdrive.h
index 066a134..e1d2b59 100644
--- a/hw/kdrive/src/kdrive.h
+++ b/hw/kdrive/src/kdrive.h
@@ -330,19 +330,6 @@ typedef struct _KdPointerMatrix {
     int matrix[2][3];
 } KdPointerMatrix;
 
-/*
- * This is the only completely portable way to
- * compute this info.
- */
-
-#ifndef BitsPerPixel
-#define BitsPerPixel(d) (\
-    PixmapWidthPaddingInfo[d].notPower2 ? \
-    (PixmapWidthPaddingInfo[d].bytesPerPixel * 8) : \
-    ((1 << PixmapWidthPaddingInfo[d].padBytesLog2) * 8 / \
-    (PixmapWidthPaddingInfo[d].padRoundUp+1)))
-#endif
-
 extern DevPrivateKeyRec kdScreenPrivateKeyRec;
 
 #define kdScreenPrivateKey (&kdScreenPrivateKeyRec)
commit cccba52d152a7d233c0b762a54844ecef831483e
Author: Alan Coopersmith <alan.coopersmith at oracle.com>
Date:   Sun Sep 21 09:49:05 2014 -0700

    Abort xi2 tests if ActivateDevice() fails
    
    I was getting segfaults in xi2 tests from trying to copy XKB keyboard
    state to NULL pointers with a stack of:
        key=key at entry=0) at xkbActions.c:1189
        sendevent=sendevent at entry=0 '\000') at devices.c:420
        at protocol-xiquerydevice.c:338
    
    which turned out to be due to xkbcomp failure, which was logged in the
    test logs as:
    XKB: Failed to compile keymap
    Keyboard initialization failed. This could be a missing or incorrect setup of xkeyboard-config.
    
    but which was overlooked because the ActivateDevice() return code wasn't
    checked and the tests went forward assuming the structures were all
    correctly initialized.   This catches the failure closer to the point of
    failure, to save debugging time.
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/test/xi2/protocol-common.c b/test/xi2/protocol-common.c
index 9a429e4..64a5777 100644
--- a/test/xi2/protocol-common.c
+++ b/test/xi2/protocol-common.c
@@ -137,6 +137,7 @@ init_devices(void)
 {
     ClientRec client;
     struct devices local_devices;
+    int ret;
 
     client = init_client(0, NULL);
 
@@ -145,15 +146,20 @@ init_devices(void)
     inputInfo.pointer = local_devices.vcp;
 
     inputInfo.keyboard = local_devices.vck;
-    ActivateDevice(local_devices.vcp, FALSE);
-    ActivateDevice(local_devices.vck, FALSE);
+    ret = ActivateDevice(local_devices.vcp, FALSE);
+    assert(ret == Success);
+    /* This may fail if xkbcomp fails or xkb-config is not found. */
+    ret = ActivateDevice(local_devices.vck, FALSE);
+    assert(ret == Success);
     EnableDevice(local_devices.vcp, FALSE);
     EnableDevice(local_devices.vck, FALSE);
 
     AllocDevicePair(&client, "", &local_devices.mouse, &local_devices.kbd,
                     TestPointerProc, CoreKeyboardProc, FALSE);
-    ActivateDevice(local_devices.mouse, FALSE);
-    ActivateDevice(local_devices.kbd, FALSE);
+    ret = ActivateDevice(local_devices.mouse, FALSE);
+    assert(ret == Success);
+    ret = ActivateDevice(local_devices.kbd, FALSE);
+    assert(ret == Success);
     EnableDevice(local_devices.mouse, FALSE);
     EnableDevice(local_devices.kbd, FALSE);
 
commit 95a5b92e37f73f497d547fd91c543c16d2cc73de
Author: Keith Packard <keithp at keithp.com>
Date:   Thu Oct 2 10:26:53 2014 -0700

    xfree86: Remove remaining return FALSE from configServerFlags
    
    Remove the error return path from the FLAG_PIXMAP path and leave the
    default value in place. There's no point skipping the rest of this
    function.
    
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c
index bca5b45..5b254ba 100644
--- a/hw/xfree86/common/xf86Config.c
+++ b/hw/xfree86/common/xf86Config.c
@@ -1011,7 +1011,7 @@ configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts)
         break;
     default:
         ErrorF("Pixmap option's value (%d) must be 24 or 32\n", i);
-        return FALSE;
+        break;
     }
     if (xf86Pix24 != Pix24DontCare) {
         xf86Info.pixmap24 = xf86Pix24;
commit e9651e3dbc32650fcaf90888b4cbef81da77cfcd
Merge: 9bc01df 4433bc6
Author: Keith Packard <keithp at keithp.com>
Date:   Thu Oct 2 10:24:33 2014 -0700

    Merge remote-tracking branch 'ajax/dead-code'

commit 9bc01dfc7070a40f5948588895b3a11dd1636d0e
Author: Axel Davy <axel.davy at ens.fr>
Date:   Sat Sep 27 23:17:13 2014 +0200

    Fix present_pixmap when using present_notify_msc
    
    Calling present_notify_msc could cancel a pending pixmap presentation.
    
    Signed-off-by: Axel Davy <axel.davy at ens.fr>
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/present/present.c b/present/present.c
index e838da7..47566c7 100644
--- a/present/present.c
+++ b/present/present.c
@@ -767,7 +767,7 @@ present_pixmap(WindowPtr window,
      * in the same frame
      */
 
-    if (!update) {
+    if (!update && pixmap) {
         xorg_list_for_each_entry_safe(vblank, tmp, &window_priv->vblank, window_list) {
 
             if (!vblank->pixmap)
commit b3e9791fd375eb71b6150a77b8009b046b213004
Author: Daniel Martin <consume.noise at gmail.com>
Date:   Sat Sep 20 09:07:41 2014 +0200

    xfree86: Delete file modinit.h
    
    All references to modinit.h have been remove with:
    
        a1d41e3 Move extension initialisation prototypes into extinit.h
    
    Signed-off-by: Daniel Martin <consume.noise at gmail.com>
    Reviewed-by: Eric Anholt <eric at anholt.net>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/xfree86/dixmods/extmod/modinit.h b/hw/xfree86/dixmods/extmod/modinit.h
deleted file mode 100644
index 4c9b6e3..0000000
--- a/hw/xfree86/dixmods/extmod/modinit.h
+++ /dev/null
@@ -1,80 +0,0 @@
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include <X11/extensions/shapeproto.h>
-
-#ifdef XTEST
-extern void XTestExtensionInit(void);
-#include <X11/extensions/xtestproto.h>
-#endif
-
-#if 1
-extern void XTestExtension1Init(void);
-#endif
-
-#if 1
-extern void XCMiscExtensionInit(void);
-#endif
-
-#ifdef SCREENSAVER
-extern void ScreenSaverExtensionInit(void);
-#include <X11/extensions/saver.h>
-#endif
-
-#ifdef XF86VIDMODE
-extern void XFree86VidModeExtensionInit(void);
-#include <X11/extensions/xf86vmproto.h>
-#endif
-
-#ifdef XFreeXDGA
-extern void XFree86DGAExtensionInit(void);
-extern void XFree86DGARegister(void);
-#include <X11/extensions/xf86dgaproto.h>
-#endif
-
-#ifdef DPMSExtension
-extern void DPMSExtensionInit(void);
-#include <X11/extensions/dpmsconst.h>
-#endif
-
-#ifdef XV
-extern void XvExtensionInit(void);
-extern void XvMCExtensionInit(void);
-extern void XvRegister(void);
-#include <X11/extensions/Xv.h>
-#include <X11/extensions/XvMC.h>
-#endif
-
-#ifdef RES
-extern void ResExtensionInit(void);
-#include <X11/extensions/XResproto.h>
-#endif
-
-#ifdef SHM
-#include <X11/extensions/shmproto.h>
-extern void ShmExtensionInit(void);
-extern void ShmRegisterFuncs(ScreenPtr pScreen, ShmFuncsPtr funcs);
-#endif
-
-#ifdef XSELINUX
-extern void SELinuxExtensionInit(void);
-#include "xselinux.h"
-#endif
-
-#ifdef XEVIE
-extern void XevieExtensionInit(void);
-#endif
-
-#if 1
-extern void SecurityExtensionInit(void);
-#endif
-
-#if 1
-extern void PanoramiXExtensionInit(void);
-#endif
-
-#if 1
-extern void XkbExtensionInit(void);
-#endif
commit 2aeb9d8f8b22ceb1de883c231a0a75d4c75d3f4a
Author: Daniel Martin <consume.noise at gmail.com>
Date:   Sat Sep 20 09:07:40 2014 +0200

    security: Remove XpExtension from SecurityTrustedExtensions
    
    There's no XPrint extension (anymore).
    
    Signed-off-by: Daniel Martin <consume.noise at gmail.com>
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/Xext/security.c b/Xext/security.c
index 421b252..bf2ab2e 100644
--- a/Xext/security.c
+++ b/Xext/security.c
@@ -67,7 +67,6 @@ typedef struct {
 static const char *SecurityTrustedExtensions[] = {
     "XC-MISC",
     "BIG-REQUESTS",
-    "XpExtension",
     NULL
 };
 
commit 12c19bbff4b7b2d0b350a7b93b38ebbf69748534
Author: Daniel Martin <consume.noise at gmail.com>
Date:   Sat Sep 20 09:07:39 2014 +0200

    dix: Remove XpExtension leftovers from protocol.txt
    
    There's no XPrint extension (anymore).
    
    Signed-off-by: Daniel Martin <consume.noise at gmail.com>
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/dix/protocol.txt b/dix/protocol.txt
index f83f38c..c223795 100644
--- a/dix/protocol.txt
+++ b/dix/protocol.txt
@@ -1082,33 +1082,3 @@ R009 XVideo-MotionCompensation:GetDRInfo
 E000 XVideo-MotionCompensation:BadContext
 E001 XVideo-MotionCompensation:BadSurface
 E002 XVideo-MotionCompensation:BadSubpicture
-R000 XpExtension:QueryVersion
-R001 XpExtension:GetPrinterList
-R002 XpExtension:CreateContext
-R003 XpExtension:SetContext
-R004 XpExtension:GetContext
-R005 XpExtension:DestroyContext
-R006 XpExtension:GetContextScreen
-R007 XpExtension:StartJob
-R008 XpExtension:EndJob
-R009 XpExtension:StartDoc
-R010 XpExtension:EndDoc
-R011 XpExtension:PutDocumentData
-R012 XpExtension:GetDocumentData
-R013 XpExtension:StartPage
-R014 XpExtension:EndPage
-R015 XpExtension:SelectInput
-R016 XpExtension:InputSelected
-R017 XpExtension:GetAttributes
-R018 XpExtension:SetAttributes
-R019 XpExtension:GetOneAttribute
-R020 XpExtension:RehashPrinterList
-R021 XpExtension:GetPageDimensions
-R022 XpExtension:QueryScreens
-R023 XpExtension:SetImageResolution
-R024 XpExtension:GetImageResolution
-V000 XpExtension:PrintNotify
-V001 XpExtension:AttributeNotify
-E000 XpExtension:BadContext
-E001 XpExtension:BadSequence
-E002 XpExtension:BadResourceID
commit d3d845ca9e92f0a2ccde93f4242d7769cfe14164
Author: Michel Dänzer <michel.daenzer at amd.com>
Date:   Thu Sep 25 15:27:22 2014 +0900

    glamor: Use GL_STREAM_READ also for read/write access to a PBO
    
    Otherwise the CPU may end up reading from non-cacheable memory, which is
    very slow.
    
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=84178
    Signed-off-by: Michel Dänzer <michel.daenzer at amd.com>
    Reviewed-by: Markus Wick <markus at selfnet.de>
    Reviewed-by: Eric Anholt <eric at anholt.net>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/glamor/glamor_prepare.c b/glamor/glamor_prepare.c
index 561c55d..fb85d90 100644
--- a/glamor/glamor_prepare.c
+++ b/glamor/glamor_prepare.c
@@ -84,10 +84,7 @@ glamor_prep_pixmap_box(PixmapPtr pixmap, glamor_access_t access, BoxPtr box)
             if (priv->base.pbo == 0)
                 glGenBuffers(1, &priv->base.pbo);
 
-            if (access == GLAMOR_ACCESS_RW)
-                gl_usage = GL_DYNAMIC_DRAW;
-            else
-                gl_usage = GL_STREAM_READ;
+            gl_usage = GL_STREAM_READ;
 
             glBindBuffer(GL_PIXEL_PACK_BUFFER, priv->base.pbo);
             glBufferData(GL_PIXEL_PACK_BUFFER,
commit 78c27d12e1f4857bfcfc92afbb69d5dd989232b9
Merge: 6e50bfa 1d6334d
Author: Keith Packard <keithp at keithp.com>
Date:   Mon Sep 29 13:04:49 2014 -0700

    Merge remote-tracking branch 'jturney/xwin-clipboard-refactoring'

commit 6e50bfa706cd3ab884c933bf1f17c221a6208aa4
Author: Michel Dänzer <michel.daenzer at amd.com>
Date:   Wed Sep 24 16:48:10 2014 +0900

    glamor: Fix leak of converted_bits in _glamor_upload_bits_to_pixmap_texture
    
    ==9530== 808,575,600 bytes in 5,904 blocks are definitely lost in loss record 4,602 of 4,602
    ==9530==    at 0x4C28C20: malloc (vg_replace_malloc.c:296)
    ==9530==    by 0xAD29C98: _glamor_upload_bits_to_pixmap_texture (glamor_pixmap.c:771)
    ==9530==    by 0xAD2AE95: glamor_upload_sub_pixmap_to_texture (glamor_pixmap.c:1031)
    ==9530==    by 0xAD2BD55: glamor_upload_pixmap_to_texture (glamor_pixmap.c:1057)
    ==9530==    by 0xAD1C2E6: glamor_composite_choose_shader (glamor_render.c:1025)
    ==9530==    by 0xAD1C629: glamor_composite_with_shader (glamor_render.c:1174)
    ==9530==    by 0xAD1DA77: glamor_composite_clipped_region (glamor_render.c:1542)
    ==9530==    by 0xAD1E849: _glamor_composite (glamor_render.c:1689)
    ==9530==    by 0xAD1ED90: glamor_composite (glamor_render.c:1758)
    ==9530==    by 0x519FD6: damageComposite (damage.c:502)
    ==9530==    by 0xAD27AA3: glamor_trapezoids (glamor_trapezoid.c:147)
    ==9530==    by 0xAD27B51: glamor_trapezoids (glamor_trapezoid.c:101)
    
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=84176
    Signed-off-by: Michel Dänzer <michel.daenzer at amd.com>
    Reviewed-by: Eric Anholt <eric at anholt.net>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/glamor/glamor_pixmap.c b/glamor/glamor_pixmap.c
index 11e9ebb..355fe4b 100644
--- a/glamor/glamor_pixmap.c
+++ b/glamor/glamor_pixmap.c
@@ -774,6 +774,7 @@ _glamor_upload_bits_to_pixmap_texture(PixmapPtr pixmap, GLenum format,
             return FALSE;
         bits = glamor_color_convert_to_bits(bits, converted_bits, w, h,
                                             stride, no_alpha, revert, swap_rb);
+        free(converted_bits);
         if (bits == NULL) {
             ErrorF("Failed to convert pixmap no_alpha %d,"
                    "revert mode %d, swap mode %d\n", no_alpha, revert, swap_rb);
commit 4433bc6d53e651b3dc4112099a153c2574f30797
Author: Adam Jackson <ajax at redhat.com>
Date:   Thu May 1 12:48:15 2014 -0400

    x86emu: Undefine _NO_INLINE
    
    Never defined by the server.
    
    Reviewed-by: Eric Anholt <eric at anholt.net>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/hw/xfree86/x86emu/x86emu/x86emui.h b/hw/xfree86/x86emu/x86emu/x86emui.h
index 5e20d97..01bd92a 100644
--- a/hw/xfree86/x86emu/x86emu/x86emui.h
+++ b/hw/xfree86/x86emu/x86emu/x86emui.h
@@ -46,7 +46,7 @@
  * dramatically in this case).
  */
 
-#if	defined(__cplusplus) && !defined(_NO_INLINE)
+#if defined(__cplusplus)
 #define	_INLINE	inline
 #else
 #define	_INLINE static
commit 1c3cb68d0cd15d29fd3aaa9eedbfa772ec8e3a47
Author: Adam Jackson <ajax at redhat.com>
Date:   Tue Jul 29 14:15:24 2014 -0400

    xfree86: Remove pointless xf86PrintMarkers
    
    Reviewed-by: Eric Anholt <eric at anholt.net>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
index b197c1c..7686294 100644
--- a/hw/xfree86/common/xf86Init.c
+++ b/hw/xfree86/common/xf86Init.c
@@ -233,12 +233,6 @@ xf86PrintBanner(void)
                    "\tto make sure that you have the latest version.\n");
 }
 
-static void
-xf86PrintMarkers(void)
-{
-    LogPrintMarkers();
-}
-
 Bool
 xf86PrivsElevated(void)
 {
@@ -421,7 +415,7 @@ InitOutput(ScreenInfo * pScreenInfo, int argc, char **argv)
             xf86ServerName = argv[0];
 
         xf86PrintBanner();
-        xf86PrintMarkers();
+        LogPrintMarkers();
         if (xf86LogFile) {
             time_t t;
             const char *ct;
commit 30fa6da6f140d713041942a81f5d6da6736e4f7f
Author: Adam Jackson <ajax at redhat.com>
Date:   Tue Jul 29 14:07:39 2014 -0400

    xfree86: configServerFlags never fails, make it return void
    
    Reviewed-by: Eric Anholt <eric at anholt.net>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c
index 3eb7a0f..bca5b45 100644
--- a/hw/xfree86/common/xf86Config.c
+++ b/hw/xfree86/common/xf86Config.c
@@ -760,7 +760,7 @@ static OptionInfoRec FlagOptions[] = {
      {0}, FALSE},
 };
 
-static Bool
+static void
 configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts)
 {
     XF86OptionPtr optp, tmp;
@@ -1046,8 +1046,6 @@ configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts)
         xf86Info.dri2From = X_CONFIG;
     }
 #endif
-
-    return TRUE;
 }
 
 Bool
@@ -2474,11 +2472,7 @@ xf86HandleConfigFile(Bool autoconfig)
     }
 #endif
     /* Now process everything else */
-    if (!configServerFlags(xf86configptr->conf_flags, xf86ConfigLayout.options)) {
-        ErrorF("Problem when converting the config data structures\n");
-        return CONFIG_PARSE_ERROR;
-    }
-
+    configServerFlags(xf86configptr->conf_flags, xf86ConfigLayout.options);
     configFiles(xf86configptr->conf_files);
     configExtensions(xf86configptr->conf_extensions);
 #ifdef XF86DRI
commit 2bf9db1930528255a37f9787aeb82e2851f814c2
Author: Adam Jackson <ajax at redhat.com>
Date:   Tue Jul 29 14:02:01 2014 -0400

    xfree86: Remove unused xf86Info.useDefaultFontPathFrom
    
    Reviewed-by: Eric Anholt <eric at anholt.net>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c
index 8f16be3..3eb7a0f 100644
--- a/hw/xfree86/common/xf86Config.c
+++ b/hw/xfree86/common/xf86Config.c
@@ -959,10 +959,8 @@ configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts)
     XkbFreeRMLVOSet(&set, FALSE);
 
     xf86Info.useDefaultFontPath = TRUE;
-    xf86Info.useDefaultFontPathFrom = X_DEFAULT;
     if (xf86GetOptValBool(FlagOptions, FLAG_USE_DEFAULT_FONT_PATH, &value)) {
         xf86Info.useDefaultFontPath = value;
-        xf86Info.useDefaultFontPathFrom = X_CONFIG;
     }
 
 /* Make sure that timers don't overflow CARD32's after multiplying */
diff --git a/hw/xfree86/common/xf86Privstr.h b/hw/xfree86/common/xf86Privstr.h
index 7bb8889..cffa14d 100644
--- a/hw/xfree86/common/xf86Privstr.h
+++ b/hw/xfree86/common/xf86Privstr.h
@@ -93,7 +93,6 @@ typedef struct {
     MessageType glxVisualsFrom;
 
     Bool useDefaultFontPath;
-    MessageType useDefaultFontPathFrom;
     Bool ignoreABI;
 
     Bool forceInputDevices;     /* force xorg.conf or built-in input devices */
commit fffea07b4cb0992fed2cca33be08440ea94090d9
Author: Adam Jackson <ajax at redhat.com>
Date:   Tue Jul 29 13:48:10 2014 -0400

    xfree86: Remove xf86Info.log (v2)
    
    SUBCLASS ALL THE THINGS
    
    v2: Remove the enum too (anholt)
    
    Reviewed-by: Eric Anholt <eric at anholt.net>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c
index 546055d..8f16be3 100644
--- a/hw/xfree86/common/xf86Config.c
+++ b/hw/xfree86/common/xf86Config.c
@@ -874,12 +874,10 @@ configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts)
         if ((s = xf86GetOptValString(FlagOptions, FLAG_LOG))) {
             if (!xf86NameCmp(s, "flush")) {
                 xf86Msg(X_CONFIG, "Flushing logfile enabled\n");
-                xf86Info.log = LogFlush;
                 LogSetParameter(XLOG_FLUSH, TRUE);
             }
             else if (!xf86NameCmp(s, "sync")) {
                 xf86Msg(X_CONFIG, "Syncing logfile enabled\n");
-                xf86Info.log = LogSync;
                 LogSetParameter(XLOG_FLUSH, TRUE);
                 LogSetParameter(XLOG_SYNC, TRUE);
             }
diff --git a/hw/xfree86/common/xf86Globals.c b/hw/xfree86/common/xf86Globals.c
index 984c39b..93a35b8 100644
--- a/hw/xfree86/common/xf86Globals.c
+++ b/hw/xfree86/common/xf86Globals.c
@@ -120,7 +120,6 @@ xf86InfoRec xf86Info = {
     .pixmap24 = Pix24DontCare,
     .pix24From = X_DEFAULT,
     .pmFlag = TRUE,
-    .log = LogNone,
     .disableRandR = FALSE,
     .randRFrom = X_DEFAULT,
 #if defined(CONFIG_HAL) || defined(CONFIG_UDEV) || defined(CONFIG_WSCONS)
diff --git a/hw/xfree86/common/xf86Privstr.h b/hw/xfree86/common/xf86Privstr.h
index 410ef17..7bb8889 100644
--- a/hw/xfree86/common/xf86Privstr.h
+++ b/hw/xfree86/common/xf86Privstr.h
@@ -37,12 +37,6 @@
 #include "xf86str.h"
 
 typedef enum {
-    LogNone,
-    LogFlush,
-    LogSync
-} Log;
-
-typedef enum {
     XF86_GlxVisualsMinimal,
     XF86_GlxVisualsTypical,
     XF86_GlxVisualsAll,
@@ -91,7 +85,6 @@ typedef struct {
     Pix24Flags pixmap24;
     MessageType pix24From;
     Bool pmFlag;
-    Log log;
     Bool disableRandR;
     MessageType randRFrom;
     Bool aiglx;
commit 2f5cfbee5409b088156d4cd84a3376499e291631
Author: Adam Jackson <ajax at redhat.com>
Date:   Tue Jul 8 14:50:22 2014 -0400

    xfree86: Remove DisplayID support
    
    Not actually wired up so it's fairly useless.
    
    Reviewed-by: Eric Anholt <eric at anholt.net>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/hw/xfree86/ddc/ddc.c b/hw/xfree86/ddc/ddc.c
index 04d1a09..15e4beb 100644
--- a/hw/xfree86/ddc/ddc.c
+++ b/hw/xfree86/ddc/ddc.c
@@ -468,61 +468,3 @@ xf86DoEDID_DDC2(ScrnInfoPtr pScrn, I2CBusPtr pBus)
 {
     return xf86DoEEDID(pScrn, pBus, FALSE);
 }
-
-/* XXX write me */
-static void *
-DDC2ReadDisplayID(void)
-{
-    return FALSE;
-}
-
-/**
- * Attempts to probe the monitor for DisplayID information, if NoDDC and
- * NoDDC2 are unset.  DisplayID blocks are interpreted and the results
- * returned in an xf86MonPtr.
- *
- * This function does not affect the list of modes used by drivers -- it is up
- * to the driver to decide policy on what to do with DisplayID information.
- *
- * @return pointer to a new xf86MonPtr containing the DisplayID information.
- * @return NULL if no monitor attached or failure to interpret the DisplayID.
- */
-xf86MonPtr
-xf86DoDisplayID(ScrnInfoPtr pScrn, I2CBusPtr pBus)
-{
-    unsigned char *did = NULL;
-    xf86MonPtr tmp = NULL;
-    I2CDevPtr dev = NULL;
-
-    /* Default DDC and DDC2 to enabled. */
-    Bool noddc = FALSE, noddc2 = FALSE;
-    OptionInfoPtr options;
-
-    options = malloc(sizeof(DDCOptions));
-    if (!options)
-        return NULL;
-    memcpy(options, DDCOptions, sizeof(DDCOptions));
-    xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, options);
-
-    xf86GetOptValBool(options, DDCOPT_NODDC, &noddc);
-    xf86GetOptValBool(options, DDCOPT_NODDC2, &noddc2);
-    free(options);
-
-    if (noddc || noddc2)
-        return NULL;
-
-    if (!(dev = DDC2Init(pBus)))
-        return NULL;
-
-    if ((did = DDC2ReadDisplayID())) {
-        tmp = calloc(1, sizeof(*tmp));
-        if (!tmp)
-            return NULL;
-
-        tmp->scrnIndex = pScrn->scrnIndex;
-        tmp->flags |= MONITOR_DISPLAYID;
-        tmp->rawData = did;
-    }
-
-    return tmp;
-}
diff --git a/hw/xfree86/ddc/xf86DDC.h b/hw/xfree86/ddc/xf86DDC.h
index de8e718..727813f 100644
--- a/hw/xfree86/ddc/xf86DDC.h
+++ b/hw/xfree86/ddc/xf86DDC.h
@@ -48,11 +48,6 @@ extern _X_EXPORT Bool xf86SetDDCproperties(ScrnInfoPtr pScreen, xf86MonPtr DDC);
 extern _X_EXPORT Bool
  xf86MonitorIsHDMI(xf86MonPtr mon);
 
-extern _X_EXPORT xf86MonPtr xf86DoDisplayID(ScrnInfoPtr pScrn, I2CBusPtr pBus);
-
-extern _X_EXPORT void
- xf86DisplayIDMonitorSet(int scrnIndex, MonPtr mon, xf86MonPtr DDC);
-
 extern _X_EXPORT DisplayModePtr
 FindDMTMode(int hsize, int vsize, int refresh, Bool rb);
 
diff --git a/hw/xfree86/modes/Makefile.am b/hw/xfree86/modes/Makefile.am
index 220643f..6eb162a 100644
--- a/hw/xfree86/modes/Makefile.am
+++ b/hw/xfree86/modes/Makefile.am
@@ -10,7 +10,6 @@ libxf86modes_la_SOURCES = \
 	xf86Cursors.c \
 	xf86cvt.c \
 	xf86gtf.c \
-	xf86DisplayIDModes.c \
 	xf86EdidModes.c \
 	xf86Modes.c \
 	xf86Modes.h \
diff --git a/hw/xfree86/modes/xf86DisplayIDModes.c b/hw/xfree86/modes/xf86DisplayIDModes.c
deleted file mode 100644
index c2e7718..0000000
--- a/hw/xfree86/modes/xf86DisplayIDModes.c
+++ /dev/null
@@ -1,444 +0,0 @@
-/*
- * Copyright 2009 Red Hat, Inc.
- *
- * 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
- * on the rights to use, copy, modify, merge, publish, distribute, sub
- * license, and/or sell copies of the Software, and to permit persons to whom
- * them 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 MERCHANTIBILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
- * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY, WHETHER
- * IN AN ACTION OF CONTRACT, TORT, OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- *	Adam Jackson <ajax at redhat.com>
- */
-
-#include "xorg-config.h"
-#include "xf86.h"
-#include "xf86Modes.h"
-#include "xf86str.h"
-#include "edid.h"
-#include "xf86DDC.h"
-
-typedef void (*did_proc) (int scrnIndex, unsigned char *data, void *closure);
-
-#define DID_PRODUCT_ID		    0x00
-#define DID_DISPLAY_PARAMETERS	    0x01
-#define DID_COLOR_INFO		    0x02
-#define DID_TIMING_1_DETAILED	    0x03
-#define DID_TIMING_2_DETAILED	    0x04
-#define DID_TIMING_3_SHORT	    0x05
-#define DID_TIMING_4_DMT	    0x06
-#define DID_TIMING_VESA		    0x07
-#define DID_TIMING_CEA		    0x08
-#define DID_TIMING_RANGE_LIMITS	    0x09
-#define DID_PRODUCT_SERIAL	    0x0A
-#define DID_ASCII_STRING	    0x0B
-#define DID_DISPLAY_DEVICE	    0x0C
-#define DID_POWER_SEQUENCING	    0x0D
-#define DID_TRANSFER_INFO	    0x0E
-#define DID_DISPLAY_INTERFACE	    0x0F
-#define DID_STEREO		    0x10
-#define DID_VENDOR		    0x7F
-
-#define extract_le16(x, i) ((x[i+1] << 8) + (x[i]))
-#define extract_le24(x, i) ((x[i+2] << 16) + (x[i+1] << 8) + (x[i]))
-
-static DisplayModePtr
-modeCalloc(void)
-{
-    return calloc(1, sizeof(DisplayModeRec));
-}
-
-/*
- * How awesome is it to have two detailed timing formats, neither of which
- * are compatible with the format in EDID?  So awesome.
- */
-
-static void
-didDetailedTiming1(int i, unsigned char *x, MonPtr mon)
-{
-    DisplayModePtr m = modeCalloc();
-
-    if (!m)
-        return;
-
-    m->Clock = extract_le24(x, 0);
-
-    m->HDisplay = extract_le16(x, 4);
-    m->HSyncStart = m->HDisplay + (extract_le16(x, 8) & 0x7f);
-    m->HSyncEnd = m->HSyncStart + extract_le16(x, 10);
-    m->HTotal = m->HDisplay + extract_le16(x, 6);
-    m->Flags |= (x[9] & 0x80) ? V_PHSYNC : V_NHSYNC;
-
-    m->VDisplay = extract_le16(x, 12);
-    m->VSyncStart = m->VDisplay + (extract_le16(x, 16) & 0x7f);
-    m->VSyncEnd = m->VSyncStart + extract_le16(x, 18);
-    m->VTotal = m->VDisplay + extract_le16(x, 14);
-    m->Flags |= (x[17] & 0x80) ? V_PVSYNC : V_NVSYNC;
-
-    m->type = M_T_DRIVER;
-    if (x[3] & 0x80)
-        m->type |= M_T_PREFERRED;
-
-    /* XXX double check handling of this */
-    if (x[3] & 0x10)
-        m->Flags |= V_INTERLACE;
-
-    mon->Modes = xf86ModesAdd(mon->Modes, m);
-}
-
-/* XXX no sync bits.  what to do? */
-static void
-didDetailedTiming2(int i, unsigned char *x, MonPtr mon)
-{
-    DisplayModePtr mode = modeCalloc();
-
-    if (!mode)
-        return;
-
-    mode->Clock = extract_le24(x, 0);
-
-    /* horiz sizes are in character cells, not pixels, hence * 8 */
-    mode->HDisplay = ((extract_le16(x, 4) & 0x01ff) + 1) * 8;
-    mode->HSyncStart = mode->HDisplay + (((x[6] & 0xf0) >> 4) + 1) * 8;
-    mode->HSyncEnd = mode->HSyncStart + ((x[6] & 0x0f) + 1) * 8;
-    mode->HTotal = mode->HDisplay + ((x[5] >> 1) + 1) * 8;
-
-    mode->VDisplay = extract_le16(x, 7) & 0x07ff;
-    mode->VSyncStart = mode->VDisplay + (x[10] >> 4) + 1;
-    mode->VSyncEnd = mode->VSyncStart + (x[10] & 0x0f) + 1;
-    mode->VTotal = mode->VDisplay + x[9];
-
-    mode->status = M_T_DRIVER;
-    if (x[3] & 0x80)
-        mode->status |= M_T_PREFERRED;
-
-    /* XXX double check handling of this */
-    if (x[3] & 0x10)
-        mode->Flags |= V_INTERLACE;
-
-    mon->Modes = xf86ModesAdd(mon->Modes, mode);
-}
-
-static void
-didShortTiming(int i, unsigned char *x, MonPtr mon)
-{
-    DisplayModePtr m;
-    int w, h, r;
-
-    w = (x[1] + 1) * 8;
-    switch (x[0] & 0x0f) {
-    case 0:
-        h = w;
-        break;
-    case 1:
-        h = (w * 4) / 5;
-        break;
-    case 2:
-        h = (w * 3) / 4;
-        break;
-    case 3:
-        h = (w * 9) / 15;
-        break;
-    case 4:
-        h = (w * 9) / 16;
-        break;
-    case 5:
-        h = (w * 10) / 16;
-        break;
-    default:
-        return;
-    }
-    r = (x[2] & 0x7f) + 1;
-
-    m = xf86CVTMode(w, h, r, ! !(x[0] & 0x10), ! !(x[2] & 0x80));
-
-    m->type = M_T_DRIVER;
-    if (x[0] & 0x80)
-        m->type |= M_T_PREFERRED;
-
-    mon->Modes = xf86ModesAdd(mon->Modes, m);
-}
-
-static void
-didDMTTiming(int i, unsigned char *x, void *closure)
-{
-    MonPtr mon = closure;
-
-    mon->Modes = xf86ModesAdd(mon->Modes, xf86DuplicateMode(DMTModes + *x));
-}
-
-#define RB 1
-#define INT 2
-static const struct did_dmt {
-    short w, h, r, f;
-} did_dmt[] = {
-    /* byte 3 */
-    {640, 350, 85, 0},
-    {640, 400, 85, 0},
-    {720, 400, 85, 0},
-    {640, 480, 60, 0},
-    {640, 480, 72, 0},
-    {640, 480, 75, 0},
-    {640, 480, 85, 0},
-    {800, 600, 56, 0},
-        /* byte 4 */
-    {800, 600, 60, 0},
-    {800, 600, 72, 0},
-    {800, 600, 75, 0},
-    {800, 600, 85, 0},
-    {800, 600, 120, RB},
-    {848, 480, 60, 0},
-    {1024, 768, 43, INT},
-    {1024, 768, 60, 0},
-        /* byte 5 */
-    {1024, 768, 70, 0},
-    {1024, 768, 75, 0},
-    {1024, 768, 85, 0},
-    {1024, 768, 120, RB},
-    {1152, 864, 75, 0},
-    {1280, 768, 60, RB},
-    {1280, 768, 60, 0},
-    {1280, 768, 75, 0},
-        /* byte 6 */
-    {1280, 768, 85, 0},
-    {1280, 768, 120, RB},
-    {1280, 800, 60, RB},
-    {1280, 800, 60, 0},
-    {1280, 800, 75, 0},
-    {1280, 800, 85, 0},
-    {1280, 800, 120, RB},
-    {1280, 960, 60, 0},
-        /* byte 7 */
-    {1280, 960, 85, 0},
-    {1280, 960, 120, RB},
-    {1280, 1024, 60, 0},
-    {1280, 1024, 75, 0},
-    {1280, 1024, 85, 0},
-    {1280, 1024, 120, RB},
-    {1360, 768, 60, 0},
-    {1360, 768, 120, RB},
-        /* byte 8 */
-    {1400, 1050, 60, RB},
-    {1400, 1050, 60, 0},
-    {1400, 1050, 75, 0},
-    {1400, 1050, 85, 0},
-    {1400, 1050, 120, RB},
-    {1440, 900, 60, RB},
-    {1440, 900, 60, 0},
-    {1440, 900, 75, 0},
-        /* byte 9 */
-    {1440, 900, 85, 0},
-    {1440, 900, 120, RB},
-    {1600, 1200, 60, 0},
-    {1600, 1200, 65, 0},
-    {1600, 1200, 70, 0},
-    {1600, 1200, 75, 0},
-    {1600, 1200, 85, 0},
-    {1600, 1200, 120, RB},
-        /* byte a */
-    {1680, 1050, 60, RB},
-    {1680, 1050, 60, 0},
-    {1680, 1050, 75, 0},
-    {1680, 1050, 85, 0},
-    {1680, 1050, 120, RB},
-    {1792, 1344, 60, 0},
-    {1792, 1344, 75, 0},
-    {1792, 1344, 120, RB},
-        /* byte b */
-    {1856, 1392, 60, 0},
-    {1856, 1392, 75, 0},
-    {1856, 1392, 120, RB},
-    {1920, 1200, 60, RB},
-    {1920, 1200, 60, 0},
-    {1920, 1200, 75, 0},
-    {1920, 1200, 85, 0},
-    {1920, 1200, 120, RB},
-        /* byte c */
-    {1920, 1440, 60, 0},
-    {1920, 1440, 75, 0},
-    {1920, 1440, 120, RB},
-    {2560, 1600, 60, RB},
-    {2560, 1600, 60, 0},
-    {2560, 1600, 75, 0},
-    {2560, 1600, 85, 0},
-    {2560, 1600, 120, RB},
-};
-
-static void
-didVesaTiming(int scrn, unsigned char *x, MonPtr mon)
-{
-    int i, j;
-
-    x += 3;
-
-    for (i = 0; i < 10; i++)
-        for (j = 0; j < 8; j++)
-            if (x[i] & (1 << j)) {
-                const struct did_dmt *d = &(did_dmt[i * 8 + j]);
-
-                if (d->f == INT)
-                    continue;
-                mon->Modes = xf86ModesAdd(mon->Modes,
-                                          FindDMTMode(d->w, d->h, d->r,
-                                                      d->f == RB));
-            }
-
-}
-
-static void
-handleDisplayIDBlock(int scrnIndex, unsigned char *x, void *closure)
-{
-    MonPtr mon = closure;
-
-    switch (x[0]) {
-    case DID_DISPLAY_PARAMETERS:
-        /* w/h are in decimillimeters */
-        mon->widthmm = (extract_le16(x, 3) + 5) / 10;
-        mon->heightmm = (extract_le16(x, 5) + 5) / 10;
-        /* XXX pixel count, feature flags, gamma, aspect, color depth */
-        break;
-
-    case DID_TIMING_RANGE_LIMITS:
-    {
-        int n;
-
-        mon->maxPixClock = max(mon->maxPixClock, extract_le24(x, 6) * 10);
-
-        n = mon->nHsync++;
-        if (n < MAX_HSYNC) {
-            mon->hsync[n].lo = x[9];
-            mon->hsync[n].hi = x[10];
-        }
-        else {
-            n = MAX_HSYNC;
-        }
-        n = mon->nVrefresh++;
-        if (n < MAX_VREFRESH) {
-            mon->vrefresh[n].lo = x[13];
-            mon->vrefresh[n].hi = x[14];
-        }
-        else {
-            n = MAX_VREFRESH;
-        }
-        break;
-    }
-
-    case DID_TIMING_1_DETAILED:
-    {
-        int i;
-
-        for (i = 0; i < x[2]; i += 20)
-            didDetailedTiming1(scrnIndex, x + i + 3, mon);
-        break;
-    }
-
-    case DID_TIMING_2_DETAILED:
-    {
-        int i;
-
-        for (i = 0; i < x[2]; i += 11)
-            didDetailedTiming2(scrnIndex, x + i + 3, mon);
-        break;
-    }
-
-    case DID_TIMING_3_SHORT:
-    {
-        int i;
-
-        for (i = 0; i < x[2]; i += 3)
-            didShortTiming(scrnIndex, x + i + 3, mon);
-        break;
-    }
-
-    case DID_TIMING_4_DMT:
-    {
-        int i;
-
-        for (i = 0; i < x[2]; i++)
-            didDMTTiming(scrnIndex, x + i + 3, mon);
-        break;
-    }
-
-    case DID_TIMING_VESA:
-        didVesaTiming(scrnIndex, x, mon);
-        break;
-
-        /* XXX pixel format, ar, orientation, subpixel, dot pitch, bit depth */
-    case DID_DISPLAY_DEVICE:
-
-        /* XXX interface, links, color encoding, ss, drm */
-    case DID_DISPLAY_INTERFACE:
-
-        /* XXX stereo */
-    case DID_STEREO:
-
-        /* nothing interesting in these */
-    case DID_COLOR_INFO:
-    case DID_PRODUCT_SERIAL:
-    case DID_ASCII_STRING:
-    case DID_POWER_SEQUENCING:
-    case DID_TRANSFER_INFO:
-    case DID_VENDOR:
-        break;
-
-        /* warn about anything else */
-    default:
-        xf86DrvMsg(scrnIndex, X_WARNING,
-                   "Unknown DisplayID block type %hx\n", x[0]);
-        break;
-    }
-}
-
-static void
-forEachDisplayIDBlock(int scrnIndex, unsigned char *did, did_proc proc,
-                      void *closure)
-{
-    int num_extensions = did[3];
-    int section_size = did[1];
-    unsigned char *block;
-
-    do {
-        if ((did[0] & 0xf0) != 0x10)    /* not 1.x, abort */
-            return;
-        /* XXX also, checksum */
-
-        block = did + 4;
-
-        while (section_size > 0) {
-            int block_size = (block[2] + 2);
-
-            proc(scrnIndex, block, closure);
-
-            section_size -= block_size;
-            block += block_size;
-        }
-
-        did += (did[1] + 5);
-    } while (num_extensions--);
-}
-
-/*
- * Fill out MonPtr with xf86MonPtr information.
- */
-void
-xf86DisplayIDMonitorSet(int scrnIndex, MonPtr mon, xf86MonPtr DDC)
-{
-    if (!mon || !DDC)
-        return;
-
-    mon->DDC = DDC;
-
-    forEachDisplayIDBlock(scrnIndex, DDC->rawData, handleDisplayIDBlock, mon);
-}
commit b56fcce761534d3e28b7ea19e2a13213c3157a1f
Author: Adam Jackson <ajax at redhat.com>
Date:   Tue Jun 17 10:36:44 2014 -0400

    xfree86: Remove useless back-pointer to pScrn from colormap code
    
    Reviewed-by: Eric Anholt <eric at anholt.net>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/hw/xfree86/common/xf86cmap.c b/hw/xfree86/common/xf86cmap.c
index 3f9c880..c4bae56 100644
--- a/hw/xfree86/common/xf86cmap.c
+++ b/hw/xfree86/common/xf86cmap.c
@@ -74,7 +74,6 @@ typedef struct _CMapLink {
 } CMapLink, *CMapLinkPtr;
 
 typedef struct {
-    ScrnInfoPtr pScrn;
     CloseScreenProcPtr CloseScreen;
     CreateColormapProcPtr CreateColormap;
     DestroyColormapProcPtr DestroyColormap;
@@ -123,7 +122,7 @@ static int CMapSetDGAMode(ScrnInfoPtr, int, DGADevicePtr);
 #endif
 static int CMapChangeGamma(ScrnInfoPtr, Gamma);
 
-static void ComputeGamma(CMapScreenPtr);
+static void ComputeGamma(ScrnInfoPtr, CMapScreenPtr);
 static Bool CMapAllocateColormapPrivate(ColormapPtr);
 static void CMapRefreshColors(ColormapPtr, int, int *);
 static void CMapSetOverscan(ColormapPtr, int, int *);
@@ -194,7 +193,6 @@ xf86HandleColormaps(ScreenPtr pScreen,
     pScreen->InstallColormap = CMapInstallColormap;
     pScreen->StoreColors = CMapStoreColors;
 
-    pScreenPriv->pScrn = pScrn;
     pScrn->LoadPalette = loadPalette;
     pScrn->SetOverscan = setOverscan;
     pScreenPriv->maxColors = maxColors;
@@ -221,7 +219,7 @@ xf86HandleColormaps(ScreenPtr pScreen,
 #endif
     pScrn->ChangeGamma = CMapChangeGamma;
 
-    ComputeGamma(pScreenPriv);
+    ComputeGamma(pScrn, pScreenPriv);
 
     /* get the default map */
     dixLookupResourceByType((void **) &pDefMap, pScreen->defColormap,
@@ -660,8 +658,7 @@ CMapRefreshColors(ColormapPtr pmap, int defs, int *indices)
     }
 
     if (LOAD_PALETTE(pmap))
-        (*pScrn->LoadPalette) (pScreenPriv->pScrn, defs, indices,
-                               colors, pmap->pVisual);
+        (*pScrn->LoadPalette) (pScrn, defs, indices, colors, pmap->pVisual);
 
     if (pScrn->SetOverscan)
         CMapSetOverscan(pmap, defs, indices);
@@ -822,7 +819,7 @@ CMapSetOverscan(ColormapPtr pmap, int defs, int *indices)
 #ifdef DEBUGOVERSCAN
             ErrorF("SetOverscan() called from CmapSetOverscan\n");
 #endif
-            pScrn->SetOverscan(pScreenPriv->pScrn, overscan);
+            pScrn->SetOverscan(pScrn, overscan);
         }
     }
 }
@@ -851,7 +848,7 @@ CMapUnwrapScreen(ScreenPtr pScreen)
 }
 
 static void
-ComputeGamma(CMapScreenPtr priv)
+ComputeGamma(ScrnInfoPtr pScrn, CMapScreenPtr priv)
 {
     int elements = priv->gammaElements - 1;
     double RedGamma, GreenGamma, BlueGamma;
@@ -859,28 +856,25 @@ ComputeGamma(CMapScreenPtr priv)
 
 #ifndef DONT_CHECK_GAMMA
     /* This check is to catch drivers that are not initialising pScrn->gamma */
-    if (priv->pScrn->gamma.red < GAMMA_MIN ||
-        priv->pScrn->gamma.red > GAMMA_MAX ||
-        priv->pScrn->gamma.green < GAMMA_MIN ||
-        priv->pScrn->gamma.green > GAMMA_MAX ||
-        priv->pScrn->gamma.blue < GAMMA_MIN ||
-        priv->pScrn->gamma.blue > GAMMA_MAX) {
-
-        xf86DrvMsgVerb(priv->pScrn->scrnIndex, X_WARNING, 0,
+    if (pScrn->gamma.red < GAMMA_MIN || pScrn->gamma.red > GAMMA_MAX ||
+        pScrn->gamma.green < GAMMA_MIN || pScrn->gamma.green > GAMMA_MAX ||
+        pScrn->gamma.blue < GAMMA_MIN || pScrn->gamma.blue > GAMMA_MAX) {
+
+        xf86DrvMsgVerb(pScrn->scrnIndex, X_WARNING, 0,
                        "The %s driver didn't call xf86SetGamma() to initialise\n"
-                       "\tthe gamma values.\n", priv->pScrn->driverName);
-        xf86DrvMsgVerb(priv->pScrn->scrnIndex, X_WARNING, 0,
+                       "\tthe gamma values.\n", pScrn->driverName);
+        xf86DrvMsgVerb(pScrn->scrnIndex, X_WARNING, 0,
                        "PLEASE FIX THE `%s' DRIVER!\n",
-                       priv->pScrn->driverName);
-        priv->pScrn->gamma.red = 1.0;
-        priv->pScrn->gamma.green = 1.0;
-        priv->pScrn->gamma.blue = 1.0;
+                       pScrn->driverName);
+        pScrn->gamma.red = 1.0;
+        pScrn->gamma.green = 1.0;
+        pScrn->gamma.blue = 1.0;
     }
 #endif
 
-    RedGamma = 1.0 / (double) priv->pScrn->gamma.red;
-    GreenGamma = 1.0 / (double) priv->pScrn->gamma.green;
-    BlueGamma = 1.0 / (double) priv->pScrn->gamma.blue;
+    RedGamma = 1.0 / (double) pScrn->gamma.red;
+    GreenGamma = 1.0 / (double) pScrn->gamma.green;
+    BlueGamma = 1.0 / (double) pScrn->gamma.blue;
 
     for (i = 0; i <= elements; i++) {
         if (RedGamma == 1.0)
@@ -933,7 +927,7 @@ CMapChangeGamma(ScrnInfoPtr pScrn, Gamma gamma)
     pScrn->gamma.green = gamma.green;
     pScrn->gamma.blue = gamma.blue;
 
-    ComputeGamma(pScreenPriv);
+    ComputeGamma(pScrn, pScreenPriv);
 
     /* mark all colormaps on this screen */
     pLink = pScreenPriv->maps;
commit ef22655311efa0d5a5395ba2f19aa20d71a05a4f
Author: Adam Jackson <ajax at redhat.com>
Date:   Fri May 2 13:36:13 2014 -0400

    xfree86: Remove spurious xf86ConfigError
    
    READABLE.
    
    Reviewed-by: Eric Anholt <eric at anholt.net>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c
index 53e61a0..546055d 100644
--- a/hw/xfree86/common/xf86Config.c
+++ b/hw/xfree86/common/xf86Config.c
@@ -571,25 +571,6 @@ xf86DriverlistFromCompile(void)
     return driverlist;
 }
 
-/*
- * xf86ConfigError --
- *      Print a READABLE ErrorMessage!!!  All information that is 
- *      available is printed.
- */
-static void
-_X_ATTRIBUTE_PRINTF(1, 2)
-xf86ConfigError(const char *msg, ...)
-{
-    va_list ap;
-
-    ErrorF("\nConfig Error:\n");
-    va_start(ap, msg);
-    VErrorF(msg, ap);
-    va_end(ap);
-    ErrorF("\n");
-    return;
-}
-
 static void
 configFiles(XF86ConfFilesPtr fileconf)
 {
@@ -994,9 +975,8 @@ configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts)
     if ((i >= 0) && (i < MAX_TIME_IN_MIN))
         ScreenSaverTime = defaultScreenSaverTime = i * MILLI_PER_MIN;
     else if (i != -1)
-        xf86ConfigError
-            ("BlankTime value %d outside legal range of 0 - %d minutes", i,
-             MAX_TIME_IN_MIN);
+        ErrorF("BlankTime value %d outside legal range of 0 - %d minutes\n",
+               i, MAX_TIME_IN_MIN);
 
 #ifdef DPMSExtension
     i = -1;
@@ -1004,25 +984,22 @@ configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts)
     if ((i >= 0) && (i < MAX_TIME_IN_MIN))
         DPMSStandbyTime = i * MILLI_PER_MIN;
     else if (i != -1)
-        xf86ConfigError
-            ("StandbyTime value %d outside legal range of 0 - %d minutes", i,
-             MAX_TIME_IN_MIN);
+        ErrorF("StandbyTime value %d outside legal range of 0 - %d minutes\n",
+               i, MAX_TIME_IN_MIN);
     i = -1;
     xf86GetOptValInteger(FlagOptions, FLAG_DPMS_SUSPENDTIME, &i);
     if ((i >= 0) && (i < MAX_TIME_IN_MIN))
         DPMSSuspendTime = i * MILLI_PER_MIN;
     else if (i != -1)
-        xf86ConfigError
-            ("SuspendTime value %d outside legal range of 0 - %d minutes", i,
-             MAX_TIME_IN_MIN);
+        ErrorF("SuspendTime value %d outside legal range of 0 - %d minutes\n",
+               i, MAX_TIME_IN_MIN);
     i = -1;
     xf86GetOptValInteger(FlagOptions, FLAG_DPMS_OFFTIME, &i);
     if ((i >= 0) && (i < MAX_TIME_IN_MIN))
         DPMSOffTime = i * MILLI_PER_MIN;
     else if (i != -1)
-        xf86ConfigError
-            ("OffTime value %d outside legal range of 0 - %d minutes", i,
-             MAX_TIME_IN_MIN);
+        ErrorF("OffTime value %d outside legal range of 0 - %d minutes\n",
+               i, MAX_TIME_IN_MIN);
 #endif
 
     i = -1;
@@ -1037,7 +1014,7 @@ configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts)
     case -1:
         break;
     default:
-        xf86ConfigError("Pixmap option's value (%d) must be 24 or 32\n", i);
+        ErrorF("Pixmap option's value (%d) must be 24 or 32\n", i);
         return FALSE;
     }
     if (xf86Pix24 != Pix24DontCare) {
@@ -2049,8 +2026,8 @@ configMonitor(MonPtr monitorp, XF86ConfMonitorPtr conf_monitor)
         badgamma = monitorp->gamma.blue;
     }
     if (badgamma > GAMMA_ZERO) {
-        xf86ConfigError("Gamma value %.f is out of range (%.2f - %.1f)\n",
-                        badgamma, GAMMA_MIN, GAMMA_MAX);
+        ErrorF("Gamma value %.f is out of range (%.2f - %.1f)\n", badgamma,
+               GAMMA_MIN, GAMMA_MAX);
         return FALSE;
     }
 
@@ -2109,8 +2086,7 @@ configDisplay(DispPtr displayp, XF86ConfDisplayPtr conf_display)
     if (conf_display->disp_visual) {
         displayp->defaultVisual = lookupVisual(conf_display->disp_visual);
         if (displayp->defaultVisual == -1) {
-            xf86ConfigError("Invalid visual name: \"%s\"",
-                            conf_display->disp_visual);
+            ErrorF("Invalid visual name: \"%s\"\n", conf_display->disp_visual);
             return FALSE;
         }
     }
commit 35f0257360fa6e11b9ecc08e467163718e012bb1
Author: Adam Jackson <ajax at redhat.com>
Date:   Tue Mar 4 11:12:16 2014 -0500

    xfree86: Remove Option "TextClockFreq"
    
    No modern driver pays attention to this.  Presumably there existed
    hardware once where you couldn't just read the right values out of the
    CRTC.
    
    Reviewed-by: Eric Anholt <eric at anholt.net>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c
index 779ba6f..53e61a0 100644
--- a/hw/xfree86/common/xf86Config.c
+++ b/hw/xfree86/common/xf86Config.c
@@ -2168,7 +2168,6 @@ configDevice(GDevPtr devicep, XF86ConfDevicePtr conf_device, Bool active)
     devicep->IOBase = conf_device->dev_io_base;
     devicep->clockchip = conf_device->dev_clockchip;
     devicep->busID = conf_device->dev_busid;
-    devicep->textClockFreq = conf_device->dev_textclockfreq;
     devicep->chipID = conf_device->dev_chipid;
     devicep->chipRev = conf_device->dev_chiprev;
     devicep->options = conf_device->dev_option_lst;
diff --git a/hw/xfree86/common/xf86Configure.c b/hw/xfree86/common/xf86Configure.c
index 967bfbc..8dbca3a 100644
--- a/hw/xfree86/common/xf86Configure.c
+++ b/hw/xfree86/common/xf86Configure.c
@@ -267,7 +267,6 @@ configureDeviceSection(int screennum)
     for (i = 0; (i < MAXDACSPEEDS) && (i < CONF_MAXDACSPEEDS); i++)
         ptr->dev_dacSpeeds[i] = DevToConfig[screennum].GDev.dacSpeeds[i];
     ptr->dev_videoram = DevToConfig[screennum].GDev.videoRam;
-    ptr->dev_textclockfreq = DevToConfig[screennum].GDev.textClockFreq;
     ptr->dev_bios_base = DevToConfig[screennum].GDev.BiosBase;
     ptr->dev_mem_base = DevToConfig[screennum].GDev.MemBase;
     ptr->dev_io_base = DevToConfig[screennum].GDev.IOBase;
diff --git a/hw/xfree86/common/xf86str.h b/hw/xfree86/common/xf86str.h
index a81e886..9ad1b90 100644
--- a/hw/xfree86/common/xf86str.h
+++ b/hw/xfree86/common/xf86str.h
@@ -403,7 +403,6 @@ typedef struct {
     Bool active;
     Bool inUse;
     int videoRam;
-    int textClockFreq;
     unsigned long BiosBase;     /* Base address of video BIOS */
     unsigned long MemBase;      /* Frame buffer base address */
     unsigned long IOBase;
@@ -753,7 +752,6 @@ typedef struct _ScrnInfoRec {
     unsigned long memPhysBase;  /* Physical address of FB */
     unsigned long fbOffset;     /* Offset of FB in the above */
     int memClk;                 /* memory clock */
-    int textClockFreq;          /* clock of text mode */
     Bool flipPixels;            /* swap default black/white */
     void *options;
 
diff --git a/hw/xfree86/man/xorg.conf.man b/hw/xfree86/man/xorg.conf.man
index 378f26b..d26c3cc 100644
--- a/hw/xfree86/man/xorg.conf.man
+++ b/hw/xfree86/man/xorg.conf.man
@@ -1449,12 +1449,6 @@ This optional entry specifies the chip revision number.
 This can be used to override the auto-detection, but that should only be done
 when the driver-specific documentation recommends it.
 .TP 7
-.BI "TextClockFreq  " "freq"
-This optional entry specifies the pixel clock frequency that is used
-for the regular text mode.
-The frequency is specified in MHz.
-This is rarely used.
-.TP 7
 .BI "MatchSeat  " "seat\-id"
 Only apply this
 .B Device
diff --git a/hw/xfree86/parser/Device.c b/hw/xfree86/parser/Device.c
index d3ac293..28c274d 100644
--- a/hw/xfree86/parser/Device.c
+++ b/hw/xfree86/parser/Device.c
@@ -83,7 +83,6 @@ xf86ConfigSymTabRec DeviceTab[] = {
     {CARD, "card"},
     {DRIVER, "driver"},
     {BUSID, "busid"},
-    {TEXTCLOCKFRQ, "textclockfreq"},
     {IRQ, "irq"},
     {SCREEN, "screen"},
     {-1, ""},
@@ -212,11 +211,6 @@ xf86parseDeviceSection(void)
             ptr->dev_clocks = i;
             xf86unGetToken(token);
             break;
-        case TEXTCLOCKFRQ:
-            if ((token = xf86getSubToken(&(ptr->dev_comment))) != NUMBER)
-                Error(NUMBER_MSG, "TextClockFreq");
-            ptr->dev_textclockfreq = (int) (xf86_lex_val.realnum * 1000.0 + 0.5);
-            break;
         case MATCHSEAT:
             if (xf86getSubToken(&(ptr->dev_comment)) != STRING)
                 Error(QUOTE_MSG, "MatchSeat");
@@ -312,10 +306,6 @@ xf86printDeviceSection(FILE * cf, XF86ConfDevicePtr ptr)
                 fprintf(cf, "%.1f ", (double) ptr->dev_clock[i] / 1000.0);
             fprintf(cf, "\n");
         }
-        if (ptr->dev_textclockfreq) {
-            fprintf(cf, "\tTextClockFreq %.1f\n",
-                    (double) ptr->dev_textclockfreq / 1000.0);
-        }
         if (ptr->dev_busid)
             fprintf(cf, "\tBusID       \"%s\"\n", ptr->dev_busid);
         if (ptr->dev_screen > 0)
diff --git a/hw/xfree86/parser/xf86Parser.h b/hw/xfree86/parser/xf86Parser.h
index 3fa5b71..73187f3 100644
--- a/hw/xfree86/parser/xf86Parser.h
+++ b/hw/xfree86/parser/xf86Parser.h
@@ -211,7 +211,6 @@ typedef struct {
     const char *dev_ramdac;
     int dev_dacSpeeds[CONF_MAXDACSPEEDS];
     int dev_videoram;
-    int dev_textclockfreq;
     unsigned long dev_bios_base;
     unsigned long dev_mem_base;
     unsigned long dev_io_base;
diff --git a/hw/xfree86/parser/xf86tokens.h b/hw/xfree86/parser/xf86tokens.h
index 5c01ce7..8e15f12 100644
--- a/hw/xfree86/parser/xf86tokens.h
+++ b/hw/xfree86/parser/xf86tokens.h
@@ -187,7 +187,6 @@ typedef enum {
     CHIPREV,
     CARD,
     BUSID,
-    TEXTCLOCKFRQ,
     IRQ,
 
     /* Keyboard tokens */
diff --git a/hw/xwin/winconfig.h b/hw/xwin/winconfig.h
index 798c779..f079368 100644
--- a/hw/xwin/winconfig.h
+++ b/hw/xwin/winconfig.h
@@ -57,7 +57,6 @@ typedef struct {
     Bool active;
     Bool inUse;
     int videoRam;
-    int textClockFreq;
     void *options;
     int screen;                 /* For multi-CRTC cards */
 } GDevRec, *GDevPtr;
commit 6755aa2c1244fee11846c1e0b274bd34900e3299
Author: Adam Jackson <ajax at redhat.com>
Date:   Fri Jul 25 12:31:54 2014 -0400

    xfree86: Remove xv clip notify driver hook
    
    Nothing's using it.
    
    Reviewed-by: Eric Anholt <eric at anholt.net>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/hw/xfree86/common/xf86xv.c b/hw/xfree86/common/xf86xv.c
index d342bde..0e67690 100644
--- a/hw/xfree86/common/xf86xv.c
+++ b/hw/xfree86/common/xf86xv.c
@@ -1117,10 +1117,6 @@ xf86XVClipNotify(WindowPtr pWin, int dx, int dy)
 
         pPriv->pCompositeClip = NULL;
 
-        if (pPriv->AdaptorRec->ClipNotify)
-            (*pPriv->AdaptorRec->ClipNotify) (pPriv->pScrn, pPriv->DevPriv.ptr,
-                                              pWin, dx, dy);
-
         pPriv->clipChanged = TRUE;
 
         if (ScreenPriv->PostValidateTree == PostValidateTreeUndefined) {
diff --git a/hw/xfree86/common/xf86xv.h b/hw/xfree86/common/xf86xv.h
index c6455d7..6f8662c 100644
--- a/hw/xfree86/common/xf86xv.h
+++ b/hw/xfree86/common/xf86xv.h
@@ -95,8 +95,6 @@ typedef int (*QueryImageAttributesFuncPtr) (ScrnInfoPtr pScrn, int image,
                                             unsigned short *width,
                                             unsigned short *height,
                                             int *pitches, int *offsets);
-typedef void (*ClipNotifyFuncPtr) (ScrnInfoPtr pScrn, void *data,
-                                   WindowPtr window, int dx, int dy);
 
 typedef enum {
     XV_OFF,
@@ -145,7 +143,6 @@ typedef struct {
     PutImageFuncPtr PutImage;
     ReputImageFuncPtr ReputImage;       /* image/still */
     QueryImageAttributesFuncPtr QueryImageAttributes;
-    ClipNotifyFuncPtr ClipNotify;
 } XF86VideoAdaptorRec, *XF86VideoAdaptorPtr;
 
 typedef struct {
diff --git a/hw/xfree86/common/xf86xvpriv.h b/hw/xfree86/common/xf86xvpriv.h
index c0dff16..8fb22e6 100644
--- a/hw/xfree86/common/xf86xvpriv.h
+++ b/hw/xfree86/common/xf86xvpriv.h
@@ -61,7 +61,6 @@ typedef struct {
     PutImageFuncPtr PutImage;
     ReputImageFuncPtr ReputImage;
     QueryImageAttributesFuncPtr QueryImageAttributes;
-    ClipNotifyFuncPtr ClipNotify;
 } XvAdaptorRecPrivate, *XvAdaptorRecPrivatePtr;
 
 typedef struct {
commit e89ccacea9a1e4bc3693bb78e717343addd517e5
Author: Adam Jackson <ajax at redhat.com>
Date:   Thu Jan 23 10:27:58 2014 -0500

    mi: Remove Windows 8-bpp colormap compatibility
    
    Nice, but not something our Windows servers build, and not something
    that belongs in mi anyway.
    
    Reviewed-by: Eric Anholt <eric at anholt.net>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/mi/micmap.c b/mi/micmap.c
index 4648b9a..1aeb359 100644
--- a/mi/micmap.c
+++ b/mi/micmap.c
@@ -235,42 +235,7 @@ miExpandDirectColors(ColormapPtr pmap, int ndef, xColorItem * indefs,
 Bool
 miCreateDefColormap(ScreenPtr pScreen)
 {
-/* 
- * In the following sources PC X server vendors may want to delete 
- * "_not_tog" from "#ifdef WIN32_not_tog"
- */
-#ifdef WIN32_not_tog
-    /*  
-     * these are the MS-Windows desktop colors, adjusted for X's 16-bit 
-     * color specifications.
-     */
-    static xColorItem citems[] = {
-        {0, 0, 0, 0, 0, 0},
-        {1, 0x8000, 0, 0, 0, 0},
-        {2, 0, 0x8000, 0, 0, 0},
-        {3, 0x8000, 0x8000, 0, 0, 0},
-        {4, 0, 0, 0x8000, 0, 0},
-        {5, 0x8000, 0, 0x8000, 0, 0},
-        {6, 0, 0x8000, 0x8000, 0, 0},
-        {7, 0xc000, 0xc000, 0xc000, 0, 0},
-        {8, 0xc000, 0xdc00, 0xc000, 0, 0},
-        {9, 0xa600, 0xca00, 0xf000, 0, 0},
-        {246, 0xff00, 0xfb00, 0xf000, 0, 0},
-        {247, 0xa000, 0xa000, 0xa400, 0, 0},
-        {248, 0x8000, 0x8000, 0x8000, 0, 0},
-        {249, 0xff00, 0, 0, 0, 0},
-        {250, 0, 0xff00, 0, 0, 0},
-        {251, 0xff00, 0xff00, 0, 0, 0},
-        {252, 0, 0, 0xff00, 0, 0},
-        {253, 0xff00, 0, 0xff00, 0, 0},
-        {254, 0, 0xff00, 0xff00, 0, 0},
-        {255, 0xff00, 0xff00, 0xff00, 0, 0}
-    };
-#define NUM_DESKTOP_COLORS sizeof citems / sizeof citems[0]
-    int i;
-#else
     unsigned short zero = 0, ones = 0xFFFF;
-#endif
     Pixel wp, bp;
     VisualPtr pVisual;
     ColormapPtr cmap;
@@ -294,21 +259,12 @@ miCreateDefColormap(ScreenPtr pScreen)
     if (pScreen->rootDepth > 1) {
         wp = pScreen->whitePixel;
         bp = pScreen->blackPixel;
-#ifdef WIN32_not_tog
-        for (i = 0; i < NUM_DESKTOP_COLORS; i++) {
-            if (AllocColor(cmap,
-                           &citems[i].red, &citems[i].green, &citems[i].blue,
-                           &citems[i].pixel, 0) != Success)
-                return FALSE;
-        }
-#else
         if ((AllocColor(cmap, &ones, &ones, &ones, &wp, 0) !=
              Success) ||
             (AllocColor(cmap, &zero, &zero, &zero, &bp, 0) != Success))
             return FALSE;
         pScreen->whitePixel = wp;
         pScreen->blackPixel = bp;
-#endif
     }
 
     (*pScreen->InstallColormap) (cmap);
commit 7cd192edc195c089c6df32e9f22e57da7467b6fd
Author: Adam Jackson <ajax at redhat.com>
Date:   Mon Jun 16 11:55:30 2014 -0400

    loader: Deobfuscate RTLD_* macro stuff
    
    POSIX requires that these be named correctly, no need to be clever.
    
    Reviewed-by: Mark Kettenis <kettenis at openbsd.org>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/hw/xfree86/loader/loader.c b/hw/xfree86/loader/loader.c
index cc41dcb..3132984 100644
--- a/hw/xfree86/loader/loader.c
+++ b/hw/xfree86/loader/loader.c
@@ -71,24 +71,6 @@
 #include <dlfcn.h>
 #include <X11/Xos.h>
 
-#if defined(DL_LAZY)
-#define DLOPEN_LAZY DL_LAZY
-#elif defined(RTLD_LAZY)
-#define DLOPEN_LAZY RTLD_LAZY
-#elif defined(__FreeBSD__)
-#define DLOPEN_LAZY 1
-#else
-#define DLOPEN_LAZY 0
-#endif
-
-#if defined(LD_GLOBAL)
-#define DLOPEN_GLOBAL LD_GLOBAL
-#elif defined(RTLD_GLOBAL)
-#define DLOPEN_GLOBAL RTLD_GLOBAL
-#else
-#define DLOPEN_GLOBAL 0
-#endif
-
 #else
 #error i have no dynamic linker and i must scream
 #endif
@@ -128,7 +110,7 @@ LoaderOpen(const char *module, int *errmaj, int *errmin)
 
     xf86Msg(X_INFO, "Loading %s\n", module);
 
-    if (!(ret = dlopen(module, DLOPEN_LAZY | DLOPEN_GLOBAL))) {
+    if (!(ret = dlopen(module, RTLD_LAZY | RTLD_GLOBAL))) {
         xf86Msg(X_ERROR, "Failed to load %s: %s\n", module, dlerror());
         if (errmaj)
             *errmaj = LDR_NOLOAD;
@@ -151,7 +133,7 @@ LoaderSymbol(const char *name)
         return p;
 
     if (!global_scope)
-        global_scope = dlopen(NULL, DLOPEN_LAZY | DLOPEN_GLOBAL);
+        global_scope = dlopen(NULL, RTLD_LAZY | RTLD_GLOBAL);
 
     if (global_scope)
         return dlsym(global_scope, name);
commit cc59be38b7eff52a1d003b390f2994c73ee0b3e9
Author: Keith Packard <keithp at keithp.com>
Date:   Fri Sep 12 11:33:48 2014 -0700

    os: Don't listen to 'tcp' by default. Add '-listen' option. [v2]
    
    This disables the tcp listen socket by default. Then, it
    uses a new xtrans interface, TRANS(Listen), to provide a command line
    option to re-enable those if desired.
    
    v2: Leave unix socket enabled by default. Add configure options.
    
    Signed-off-by: Keith Packard <keithp at keithp.com>
    Reviewed-by: Hans de Goede <hdegoede at redhat.com>

diff --git a/configure.ac b/configure.ac
index 9066a6f..51e0f1f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -461,6 +461,16 @@ AC_ARG_WITH(os-vendor,       AS_HELP_STRING([--with-os-vendor=OSVENDOR], [Name o
 AC_ARG_WITH(builderstring,   AS_HELP_STRING([--with-builderstring=BUILDERSTRING], [Additional builder string]),
 				[ BUILDERSTRING="$withval" ]
 				[ ])
+AC_ARG_ENABLE(listen-tcp,    AS_HELP_STRING([--enable-listen-tcp],
+                                            [Listen on TCP by default (default:disabled)]),
+                                [LISTEN_TCP=$enableval], [LISTEN_TCP=no])
+AC_ARG_ENABLE(listen-unix,   AS_HELP_STRING([--disable-listen-unix],
+                                            [Listen on Unix by default (default:enabled)]),
+                                [LISTEN_UNIX=$enableval], [LISTEN_UNIX=yes])
+
+AC_ARG_ENABLE(listen-local,  AS_HELP_STRING([--disable-listen-local],
+                                            [Listen on local by default (default:enabled)]),
+                                [LISTEN_LOCAL=$enableval], [LISTEN_LOCAL=yes])
 
 dnl Determine font path
 XORG_FONTROOTDIR
@@ -1053,6 +1063,16 @@ if test "x$RES" = xyes; then
 	SDK_REQUIRED_MODULES="$SDK_REQUIRED_MODULES $RESOURCEPROTO"
 fi
 
+if test "x$LISTEN_TCP" = xyes; then
+	AC_DEFINE(LISTEN_TCP, 1, [Listen on TCP socket])
+fi
+if test "x$LISTEN_UNIX" = xyes; then
+	AC_DEFINE(LISTEN_UNIX, 1, [Listen on Unix socket])
+fi
+if test "x$LISTEN_LOCAL" = xyes; then
+	AC_DEFINE(LISTEN_LOCAL, 1, [Listen on local socket])
+fi
+
 # The XRes extension may support client ID tracking only if it has
 # been specifically enabled. Client ID tracking is implicitly not
 # supported if XRes extension is disabled.
diff --git a/include/dix-config.h.in b/include/dix-config.h.in
index 4268b8f..f170c1c 100644
--- a/include/dix-config.h.in
+++ b/include/dix-config.h.in
@@ -493,4 +493,13 @@
 /* byte order */
 #undef X_BYTE_ORDER
 
+/* Listen on TCP socket */
+#undef LISTEN_TCP
+
+/* Listen on Unix socket */
+#undef LISTEN_UNIX
+
+/* Listen on local socket */
+#undef LISTEN_LOCAL
+
 #endif /* _DIX_CONFIG_H_ */
diff --git a/man/Xserver.man b/man/Xserver.man
index 7a74e85..c03830c 100644
--- a/man/Xserver.man
+++ b/man/Xserver.man
@@ -196,6 +196,13 @@ with
 This option may be issued multiple times to disable listening to different
 transport types.
 .TP 8
+.B \-listen \fItrans-type\fP
+enables a transport type.  For example, TCP/IP connections can be enabled
+with
+.BR "\-listen tcp" .
+This option may be issued multiple times to enable listening to different
+transport types.
+.TP 8
 .B \-noreset
 prevents a server reset when the last client connection is closed.  This
 overrides a previous
diff --git a/os/utils.c b/os/utils.c
index 2d02f92..80415c4 100644
--- a/os/utils.c
+++ b/os/utils.c
@@ -557,6 +557,7 @@ UseMsg(void)
     ErrorF("-nolock                disable the locking mechanism\n");
 #endif
     ErrorF("-nolisten string       don't listen on protocol\n");
+    ErrorF("-listen string         listen on protocol\n");
     ErrorF("-noreset               don't reset after last client exists\n");
     ErrorF("-background [none]     create root window with no background\n");
     ErrorF("-reset                 reset after last client exists\n");
@@ -646,6 +647,19 @@ VerifyDisplayName(const char *d)
     return 1;
 }
 
+static const char *defaultNoListenList[] = {
+#ifndef LISTEN_TCP
+    "tcp",
+#endif
+#ifndef LISTEN_UNIX
+    "unix",
+#endif
+#ifndef LISTEN_LOCAL
+    "local",
+#endif
+    NULL
+};
+
 /*
  * This function parses the command line. Handles device-independent fields
  * and allows ddx to handle additional fields.  It is not allowed to modify
@@ -664,6 +678,12 @@ ProcessCommandLine(int argc, char *argv[])
     PartialNetwork = TRUE;
 #endif
 
+    for (i = 0; defaultNoListenList[i] != NULL; i++) {
+        if (_XSERVTransNoListen(defaultNoListenList[i]))
+                    ErrorF("Failed to disable listen for %s transport",
+                           defaultNoListenList[i]);
+    }
+
     for (i = 1; i < argc; i++) {
         /* call ddx first, so it can peek/override if it wants */
         if ((skip = ddxProcessArgument(argc, argv, i))) {
@@ -849,6 +869,15 @@ ProcessCommandLine(int argc, char *argv[])
             else
                 UseMsg();
         }
+        else if (strcmp(argv[i], "-listen") == 0) {
+            if (++i < argc) {
+                if (_XSERVTransListen(argv[i]))
+                    ErrorF("Failed to enable listen for %s transport",
+                           argv[i]);
+            }
+            else
+                UseMsg();
+        }
         else if (strcmp(argv[i], "-noreset") == 0) {
             dispatchExceptionAtReset = 0;
         }
commit 8ada3fb32cd7dd8948eb55620de18ba03df6131d
Author: Keith Packard <keithp at keithp.com>
Date:   Sat Sep 20 10:04:11 2014 -0700

    Require xtrans 1.3.5 or newer
    
    This version of xtrans offers the TRANS(Listen) function.
    
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/configure.ac b/configure.ac
index be8bff6..9066a6f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -779,7 +779,7 @@ FIXESPROTO="fixesproto >= 5.0"
 DAMAGEPROTO="damageproto >= 1.1"
 XCMISCPROTO="xcmiscproto >= 1.2.0"
 BIGREQSPROTO="bigreqsproto >= 1.1.0"
-XTRANS="xtrans >= 1.3.3"
+XTRANS="xtrans >= 1.3.5"
 PRESENTPROTO="presentproto >= 1.0"
 
 dnl List of libraries that require a specific version
commit 18935b41e13b34571ffda84bde5257b8e84e6d1f
Author: Keith Packard <keithp at keithp.com>
Date:   Sat Sep 20 04:04:43 2014 -0700

    XSERVER_DTRACE needs request names from registry too
    
    The dtrace code in the server wants to log the name of each executed
    request, which it gets from the registry. Use that as an additional
    indication of when that portion of the registry should be included in
    the server build.
    
    See:
    
    http://tinderbox.x.org/builds/2014-09-19-0003/logs/xserver/#build
    
    Signed-off-by: Keith Packard <keithp at keithp.com>
    Reviewed-by: Dave Airlie <airlied at gmail.com>

diff --git a/include/registry.h b/include/registry.h
index 43c3db3..f50fa76 100644
--- a/include/registry.h
+++ b/include/registry.h
@@ -24,7 +24,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #define X_REGISTRY_RESOURCE       1
 #endif
 
-#if defined(XSELINUX) || defined(XCSECURITY)
+#if defined(XSELINUX) || defined(XCSECURITY) || defined(XSERVER_DTRACE)
 #define X_REGISTRY_REQUEST        1
 #endif
 
commit 28337cb14e4347e1dd7936c5393a22e042866687
Author: Jon TURNEY <jon.turney at dronecode.org.uk>
Date:   Fri Sep 19 14:22:13 2014 +1000

    xserver: Move 'pragma GCC diagnostic' outside functions
    
    $ gcc --version
    gcc (Gentoo 4.4.3-r2 p1.2) 4.4.3
    
    /jhbuild/checkout/xorg/xserver/os/log.c: In function ‘LogInit’:
    /jhbuild/checkout/xorg/xserver/os/log.c:199: error: #pragma GCC diagnostic not allowed inside functions
    /jhbuild/checkout/xorg/xserver/os/log.c:201: warning: format not a string literal, argument types not checked
    /jhbuild/checkout/xorg/xserver/os/log.c:212: error: #pragma GCC diagnostic not allowed inside functions
    /jhbuild/checkout/xorg/xserver/os/log.c:214: warning: format not a string literal, argument types not checked
    
    etc.
    
    Reviewed-by: Dave Airlie <airlied at redhat.com>
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Signed-off-by: Dave Airlie <airlied at redhat.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/xfree86/os-support/linux/lnx_init.c b/hw/xfree86/os-support/linux/lnx_init.c
index 85709c6..9485307 100644
--- a/hw/xfree86/os-support/linux/lnx_init.c
+++ b/hw/xfree86/os-support/linux/lnx_init.c
@@ -76,6 +76,9 @@ switch_to(int vt, const char *from)
         FatalError("%s: VT_WAITACTIVE failed: %s\n", from, strerror(errno));
 }
 
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
+
 void
 xf86OpenConsole(void)
 {
@@ -166,7 +169,6 @@ xf86OpenConsole(void)
 
         i = 0;
         while (vcs[i] != NULL) {
-#pragma GCC diagnostic ignored "-Wformat-nonliteral"
             snprintf(vtname, sizeof(vtname), vcs[i], xf86Info.vtno);    /* /dev/tty1-64 */
             if ((xf86Info.consoleFd = open(vtname, O_RDWR | O_NDELAY, 0)) >= 0)
                 break;
@@ -272,6 +274,8 @@ xf86OpenConsole(void)
     }
 }
 
+#pragma GCC diagnostic pop
+
 void
 xf86CloseConsole(void)
 {
diff --git a/os/log.c b/os/log.c
index 629021e..7348ad4 100644
--- a/os/log.c
+++ b/os/log.c
@@ -189,15 +189,15 @@ strlen_sigsafe(const char *s)
  * string.
  */
 
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
+
 const char *
 LogInit(const char *fname, const char *backup)
 {
     char *logFileName = NULL;
 
     if (fname && *fname) {
-#if __GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ > 5
-#pragma GCC diagnostic ignored "-Wformat-nonliteral"
-#endif
         if (asprintf(&logFileName, fname, display) == -1)
             FatalError("Cannot allocate space for the log file name\n");
 
@@ -208,9 +208,6 @@ LogInit(const char *fname, const char *backup)
                 char *suffix;
                 char *oldLog;
 
-#if __GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ > 5
-#pragma GCC diagnostic ignored "-Wformat-nonliteral"
-#endif
                 if ((asprintf(&suffix, backup, display) == -1) ||
                     (asprintf(&oldLog, "%s%s", logFileName, suffix) == -1))
                     FatalError("Cannot allocate space for the log file name\n");
@@ -254,6 +251,7 @@ LogInit(const char *fname, const char *backup)
 
     return logFileName;
 }
+#pragma GCC diagnostic pop
 
 void
 LogClose(enum ExitCode error)
diff --git a/test/signal-logging.c b/test/signal-logging.c
index 4320121..3d2d048 100644
--- a/test/signal-logging.c
+++ b/test/signal-logging.c
@@ -113,12 +113,13 @@ double float_tests[] = { 0, 5, 0.1, 0.01, 5.2342, 10.2301,
                          -1, -2.00, -0.6023, -1203.30
                         };
 
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Woverflow"
+
 static void
 number_formatting(void)
 {
     int i;
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Woverflow"
     long unsigned int unsigned_tests[] = { 0,/* Zero */
                                            5, /* Single digit number */
                                            12, /* Two digit decimal number */
@@ -141,7 +142,6 @@ number_formatting(void)
                                 -0x15D027BF211B37A, /* Large > 32 bit number */
                                 -0x7FFFFFFFFFFFFFFF, /* Maximum 64-bit signed number */
     } ;
-#pragma GCC diagnostic pop
 
     for (i = 0; i < sizeof(unsigned_tests) / sizeof(unsigned_tests[0]); i++)
         assert(check_number_format_test(unsigned_tests[i]));
@@ -152,6 +152,7 @@ number_formatting(void)
     for (i = 0; i < sizeof(float_tests) / sizeof(float_tests[0]); i++)
         assert(check_float_format_test(float_tests[i]));
 }
+#pragma GCC diagnostic pop
 
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wformat-security"
commit 7e6bd546846964fd9b8c2a06dea4782a552b62d7
Author: Keith Packard <keithp at keithp.com>
Date:   Wed Aug 6 12:58:38 2014 -0700

    glamor: Remove shader-based trapezoid implementation. Fixes Bug 76213.
    
    I can't find any performance benefit to using the GL path and the code
    renders this trapezoid incorrectly:
    
      		                 top: FIXED   29.50
    		              bottom: FIXED   30.00
    		            left top: POINT    0.00,   29.50
    		         left bottom: POINT    0.00,   30.50
    		           right top: POINT -127.50,   29.50
    		        right bottom: POINT   52.50,   30.00
    
    This should render a solid line from 0,30 to 52,30 but draws nothing.
    
    The code also uses an area computation for trapezoid coverage which
    does not conform to the Render specification which requires a specific
    point sampling technique.
    
    Signed-off-by: Keith Packard <keithp at keithp.com>
    Reviewed-by: Adam Jackson <ajax at redhat.com>

diff --git a/glamor/glamor.c b/glamor/glamor.c
index e582e50..fc24b1b 100644
--- a/glamor/glamor.c
+++ b/glamor/glamor.c
@@ -515,9 +515,6 @@ glamor_init(ScreenPtr screen, unsigned int flags)
 
     glamor_init_vbo(screen);
     glamor_init_pixmap_fbo(screen);
-#ifdef GLAMOR_TRAPEZOID_SHADER
-    glamor_init_trapezoid_shader(screen);
-#endif
     glamor_init_finish_access_shaders(screen);
 #ifdef GLAMOR_GRADIENT_SHADER
     glamor_init_gradient_shader(screen);
@@ -546,9 +543,6 @@ glamor_release_screen_priv(ScreenPtr screen)
 #endif
     glamor_fini_vbo(screen);
     glamor_fini_pixmap_fbo(screen);
-#ifdef GLAMOR_TRAPEZOID_SHADER
-    glamor_fini_trapezoid_shader(screen);
-#endif
     glamor_fini_finish_access_shaders(screen);
 #ifdef GLAMOR_GRADIENT_SHADER
     glamor_fini_gradient_shader(screen);
diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h
index 51adeef..c089db8 100644
--- a/glamor/glamor_priv.h
+++ b/glamor/glamor_priv.h
@@ -306,9 +306,6 @@ typedef struct glamor_screen_private {
     int linear_max_nstops;
     int radial_max_nstops;
 
-    /* glamor trapezoid shader. */
-    GLint trapezoid_prog;
-
     PixmapPtr *back_pixmap;
     int screen_fbo;
     struct glamor_saved_procs saved_procs;
@@ -745,8 +742,6 @@ void glamor_composite_glyph_rects(CARD8 op,
 void glamor_composite_rects(CARD8 op,
                             PicturePtr pDst,
                             xRenderColor *color, int nRect, xRectangle *rects);
-void glamor_init_trapezoid_shader(ScreenPtr screen);
-void glamor_fini_trapezoid_shader(ScreenPtr screen);
 PicturePtr glamor_convert_gradient_picture(ScreenPtr screen,
                                            PicturePtr source,
                                            int x_source,
@@ -1089,7 +1084,6 @@ void glamor_xv_render(glamor_port_private *port_priv);
 
 #define GLAMOR_PIXMAP_DYNAMIC_UPLOAD
 #define GLAMOR_GRADIENT_SHADER
-#define GLAMOR_TRAPEZOID_SHADER
 #define GLAMOR_TEXTURED_LARGE_PIXMAP 1
 #define WALKAROUND_LARGE_TEXTURE_MAP
 #if 0
diff --git a/glamor/glamor_trapezoid.c b/glamor/glamor_trapezoid.c
index d61d11f..f8bf6c9 100644
--- a/glamor/glamor_trapezoid.c
+++ b/glamor/glamor_trapezoid.c
@@ -36,1522 +36,6 @@
 #include "mipict.h"
 #include "fbpict.h"
 
-static xFixed
-_glamor_linefixedX(xLineFixed *l, xFixed y, Bool ceil)
-{
-    xFixed dx = l->p2.x - l->p1.x;
-    xFixed_32_32 ex = (xFixed_32_32) (y - l->p1.y) * dx;
-    xFixed dy = l->p2.y - l->p1.y;
-
-    if (ceil)
-        ex += (dy - 1);
-    return l->p1.x + (xFixed) (ex / dy);
-}
-
-static xFixed
-_glamor_linefixedY(xLineFixed *l, xFixed x, Bool ceil)
-{
-    xFixed dy = l->p2.y - l->p1.y;
-    xFixed_32_32 ey = (xFixed_32_32) (x - l->p1.x) * dy;
-    xFixed dx = l->p2.x - l->p1.x;
-
-    if (ceil)
-        ey += (dx - 1);
-    return l->p1.y + (xFixed) (ey / dx);
-}
-
-#ifdef GLAMOR_TRAPEZOID_SHADER
-
-#define GLAMOR_VERTEX_TOP_BOTTOM  (GLAMOR_VERTEX_SOURCE + 1)
-#define GLAMOR_VERTEX_LEFT_PARAM  (GLAMOR_VERTEX_SOURCE + 2)
-#define GLAMOR_VERTEX_RIGHT_PARAM (GLAMOR_VERTEX_SOURCE + 3)
-
-#define DEBUG_CLIP_VTX 0
-
-#define POINT_INSIDE_CLIP_RECT(point, rect)	\
-    (point[0] >= IntToxFixed(rect->x1)		\
-     && point[0] <= IntToxFixed(rect->x2) 	\
-     && point[1] >= IntToxFixed(rect->y1)	\
-     && point[1] <= IntToxFixed(rect->y2))
-
-static xFixed
-_glamor_lines_crossfixedY(xLineFixed *l, xLineFixed *r)
-{
-    xFixed dx1 = l->p2.x - l->p1.x;
-    xFixed dx2 = r->p2.x - r->p1.x;
-    xFixed dy1 = l->p2.y - l->p1.y;
-    xFixed dy2 = r->p2.y - r->p1.y;
-    xFixed_32_32 tmp = (xFixed_32_32) dy2 * dy1;
-    xFixed_32_32 dividend1 = (tmp >> 32) * (l->p1.x - r->p1.x);
-    xFixed_32_32 dividend2;
-    xFixed_32_32 dividend3;
-    xFixed_32_32 divisor;
-
-    tmp = (xFixed_32_32) dx1 *dy2;
-
-    dividend2 = (tmp >> 32) * l->p1.y;
-    tmp = (xFixed_32_32) dy1 *dx2;
-
-    dividend3 = (tmp >> 32) * r->p1.y;
-    divisor = ((xFixed_32_32) dx1 * (xFixed_32_32) dy2
-               - (xFixed_32_32) dy1 * (xFixed_32_32) dx2) >> 32;
-
-    if (divisor)
-        return (xFixed) ((dividend2 - dividend1 - dividend3) / divisor);
-
-    return 0xFFFFFFFF;
-}
-
-static Bool
-point_inside_trapezoid(int point[2], xTrapezoid *trap, xFixed cut_y)
-{
-    int ret = TRUE;
-    int tmp;
-
-    if (point[1] > trap->bottom) {
-        ret = FALSE;
-        if (DEBUG_CLIP_VTX) {
-            ErrorF("Out of Trap bottom, point[1] = %d(0x%x)), "
-                   "bottom = %d(0x%x)\n",
-                   (unsigned int) xFixedToInt(point[1]), point[1],
-                   (unsigned int) xFixedToInt(trap->bottom),
-                   (unsigned int) trap->bottom);
-        }
-
-        return ret;
-    }
-
-    if (point[1] < trap->top) {
-        ret = FALSE;
-        if (DEBUG_CLIP_VTX) {
-            ErrorF("Out of Trap top, point[1] = %d(0x%x)), "
-                   "top = %d(0x%x)\n",
-                   (unsigned int) xFixedToInt(point[1]), point[1],
-                   (unsigned int) xFixedToInt(trap->top),
-                   (unsigned int) trap->top);
-        }
-
-        return ret;
-    }
-
-    tmp = _glamor_linefixedX(&trap->left, point[1], FALSE);
-    if (point[0] < tmp) {
-        ret = FALSE;
-
-        if (abs(cut_y - trap->top) < pixman_fixed_1_minus_e &&
-            abs(point[1] - trap->top) < pixman_fixed_1_minus_e &&
-            tmp - point[0] < pixman_fixed_1_minus_e) {
-            ret = TRUE;
-        }
-        else if (abs(cut_y - trap->bottom) < pixman_fixed_1_minus_e &&
-                 point[1] - trap->bottom < pixman_fixed_1_minus_e &&
-                 tmp - point[0] < pixman_fixed_1_minus_e) {
-            ret = TRUE;
-        }
-
-        if (DEBUG_CLIP_VTX && !ret) {
-            ErrorF("Out of Trap left, point[0] = %d(0x%x)), "
-                   "left = %d(0x%x)\n",
-                   (unsigned int) xFixedToInt(point[0]), point[0],
-                   (unsigned int) xFixedToInt(tmp), (unsigned int) tmp);
-        }
-
-        if (!ret)
-            return ret;
-    }
-
-    tmp = _glamor_linefixedX(&trap->right, point[1], TRUE);
-    if (point[0] > tmp) {
-        ret = FALSE;
-
-        if (abs(cut_y - trap->top) < pixman_fixed_1_minus_e &&
-            abs(point[1] - trap->top) < pixman_fixed_1_minus_e &&
-            point[0] - tmp < pixman_fixed_1_minus_e) {
-            ret = TRUE;
-        }
-        else if (abs(cut_y - trap->bottom) < pixman_fixed_1_minus_e &&
-                 abs(point[1] - trap->bottom) < pixman_fixed_1_minus_e &&
-                 point[0] - tmp < pixman_fixed_1_minus_e) {
-            ret = TRUE;
-        }
-
-        if (DEBUG_CLIP_VTX && !ret) {
-            ErrorF("Out of Trap right, point[0] = %d(0x%x)), "
-                   "right = %d(0x%x)\n",
-                   (unsigned int) xFixedToInt(point[0]), point[0],
-                   (unsigned int) xFixedToInt(tmp), (unsigned int) tmp);
-        }
-
-        if (!ret)
-            return ret;
-    }
-
-    return ret;
-}
-
-static void
-glamor_emit_composite_vert(ScreenPtr screen,
-                           float *vb,
-                           const float *src_coords,
-                           const float *mask_coords,
-                           const float *dst_coords, int i)
-{
-    glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
-    int j = 0;
-
-    vb += i * glamor_priv->vb_stride / sizeof(float);
-
-    vb[j++] = dst_coords[i * 2 + 0];
-    vb[j++] = dst_coords[i * 2 + 1];
-    if (glamor_priv->has_source_coords) {
-        vb[j++] = src_coords[i * 2 + 0];
-        vb[j++] = src_coords[i * 2 + 1];
-    }
-    if (glamor_priv->has_mask_coords) {
-        vb[j++] = mask_coords[i * 2 + 0];
-        vb[j++] = mask_coords[i * 2 + 1];
-    }
-
-    glamor_priv->render_nr_verts++;
-}
-
-static void
-glamor_emit_composite_triangle(ScreenPtr screen,
-                               float *vb,
-                               const float *src_coords,
-                               const float *mask_coords,
-                               const float *dst_coords)
-{
-    glamor_emit_composite_vert(screen, vb,
-                               src_coords, mask_coords, dst_coords, 0);
-    glamor_emit_composite_vert(screen, vb,
-                               src_coords, mask_coords, dst_coords, 1);
-    glamor_emit_composite_vert(screen, vb,
-                               src_coords, mask_coords, dst_coords, 2);
-}
-
-static void
-glamor_flush_composite_triangles(ScreenPtr screen)
-{
-    glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
-
-    glamor_make_current(glamor_priv);
-    glamor_put_vbo_space(screen);
-
-    if (!glamor_priv->render_nr_verts)
-        return;
-
-    glDrawArrays(GL_TRIANGLES, 0, glamor_priv->render_nr_verts);
-}
-
-static Bool
-_glamor_clip_trapezoid_vertex(xTrapezoid *trap, BoxPtr pbox,
-                              int vertex[6], int *num)
-{
-    xFixed edge_cross_y = 0xFFFFFFFF;
-    int tl[2];
-    int bl[2];
-    int tr[2];
-    int br[2];
-    int left_cut_top[2];
-    int left_cut_left[2];
-    int left_cut_right[2];
-    int left_cut_bottom[2];
-    int right_cut_top[2];
-    int right_cut_left[2];
-    int right_cut_right[2];
-    int right_cut_bottom[2];
-    int tmp[2];
-    int tmp_vtx[20 * 2];
-    float tmp_vtx_slope[20];
-    BoxRec trap_bound;
-    int i = 0;
-    int vertex_num = 0;
-
-    if (DEBUG_CLIP_VTX) {
-        ErrorF
-            ("The parameter of xTrapezoid is:\ntop: %d  0x%x\tbottom: %d  0x%x\n"
-             "left:  p1 (%d   0x%x, %d   0x%x)\tp2 (%d   0x%x, %d   0x%x)\n"
-             "right: p1 (%d   0x%x, %d   0x%x)\tp2 (%d   0x%x, %d   0x%x)\n",
-             xFixedToInt(trap->top), (unsigned int) trap->top,
-             xFixedToInt(trap->bottom), (unsigned int) trap->bottom,
-             xFixedToInt(trap->left.p1.x), (unsigned int) trap->left.p1.x,
-             xFixedToInt(trap->left.p1.y), (unsigned int) trap->left.p1.y,
-             xFixedToInt(trap->left.p2.x), (unsigned int) trap->left.p2.x,
-             xFixedToInt(trap->left.p2.y), (unsigned int) trap->left.p2.y,
-             xFixedToInt(trap->right.p1.x), (unsigned int) trap->right.p1.x,
-             xFixedToInt(trap->right.p1.y), (unsigned int) trap->right.p1.y,
-             xFixedToInt(trap->right.p2.x), (unsigned int) trap->right.p2.x,
-             xFixedToInt(trap->right.p2.y), (unsigned int) trap->right.p2.y);
-    }
-
-    miTrapezoidBounds(1, trap, &trap_bound);
-    if (DEBUG_CLIP_VTX)
-        ErrorF("The bounds for this traps is: bounds.x1 = %d, bounds.x2 = %d, "
-               "bounds.y1 = %d, bounds.y2 = %d\n", trap_bound.x1, trap_bound.x2,
-               trap_bound.y1, trap_bound.y2);
-
-    if (trap_bound.x1 > pbox->x2 || trap_bound.x2 < pbox->x1)
-        return FALSE;
-    if (trap_bound.y1 > pbox->y2 || trap_bound.y2 < pbox->y1)
-        return FALSE;
-
-#define IS_TRAP_EDGE_VERTICAL(edge)		\
-	(edge->p1.x == edge->p2.x)
-
-#define CACULATE_CUT_VERTEX(vtx, cal_x, ceil, vh_edge, edge)		\
-	do {								\
-	    if(cal_x) {							\
-		vtx[1] = (vh_edge);					\
-		vtx[0] = (_glamor_linefixedX(				\
-			      edge, vh_edge, ceil));			\
-		if(DEBUG_CLIP_VTX)					\
-		    ErrorF("The intersection point of line y=%d and "	\
-			   "line of p1:(%d,%d) -- p2 (%d,%d) "		\
-			   "is (%d, %d)\n",				\
-			   xFixedToInt(vh_edge),			\
-			   xFixedToInt(edge->p1.x),			\
-			   xFixedToInt(edge->p1.y),			\
-			   xFixedToInt(edge->p2.x),			\
-			   xFixedToInt(edge->p2.y),			\
-			   xFixedToInt(vtx[0]),				\
-			   xFixedToInt(vtx[1]));			\
-	    } else {							\
-		vtx[0] = (vh_edge);					\
-		vtx[1] = (_glamor_linefixedY(				\
-			      edge, vh_edge, ceil));			\
-		if(DEBUG_CLIP_VTX)					\
-		    ErrorF("The intersection point of line x=%d and "	\
-			   "line of p1:(%d,%d) -- p2 (%d,%d) "		\
-			   "is (%d, %d)\n",				\
-			   xFixedToInt(vh_edge),			\
-			   xFixedToInt(edge->p1.x),			\
-			   xFixedToInt(edge->p1.y),			\
-			   xFixedToInt(edge->p2.x),			\
-			   xFixedToInt(edge->p2.y),			\
-			   xFixedToInt(vtx[0]),				\
-			   xFixedToInt(vtx[1]));			\
-	    }								\
-	} while(0)
-
-#define ADD_VERTEX_IF_INSIDE(vtx)				\
-	if(POINT_INSIDE_CLIP_RECT(vtx, pbox)			\
-	   && point_inside_trapezoid(vtx, trap, edge_cross_y)){	\
-	    tmp_vtx[vertex_num] = xFixedToInt(vtx[0]);		\
-	    tmp_vtx[vertex_num + 1] = xFixedToInt(vtx[1]);	\
-	    vertex_num += 2;					\
-	    if(DEBUG_CLIP_VTX)					\
-		ErrorF("@ Point: (%d, %d) is inside "		\
-		       "the Rect and Trapezoid\n",		\
-		       xFixedToInt(vtx[0]),			\
-		       xFixedToInt(vtx[1]));			\
-	} else if(DEBUG_CLIP_VTX){				\
-	    ErrorF("X Point: (%d, %d) is outside "		\
-		   "the Rect and Trapezoid\t",			\
-		   xFixedToInt(vtx[0]),				\
-		   xFixedToInt(vtx[1]));			\
-	    if(POINT_INSIDE_CLIP_RECT(vtx, pbox))		\
-		ErrorF("The Point is outside "			\
-		       "the Trapezoid\n");			\
-	    else						\
-		ErrorF("The Point is outside "			\
-		       "the Rect\n");				\
-	}
-
-    /*Trap's right edge cut right edge. */
-    if ((!IS_TRAP_EDGE_VERTICAL((&trap->left))) ||
-        (!IS_TRAP_EDGE_VERTICAL((&trap->right)))) {
-        edge_cross_y = _glamor_lines_crossfixedY((&trap->left), (&trap->right));
-        if (DEBUG_CLIP_VTX) {
-            ErrorF("Trap's left edge cut right edge at %d(0x%x), "
-                   "trap_top = %x, trap_bottom = %x\n",
-                   xFixedToInt(edge_cross_y), edge_cross_y,
-                   (unsigned int) trap->top, (unsigned int) trap->bottom);
-        }
-    }
-
-    /*Trap's TopLeft, BottomLeft, TopRight and BottomRight. */
-    CACULATE_CUT_VERTEX(tl, 1, FALSE, trap->top, (&trap->left));
-    CACULATE_CUT_VERTEX(bl, 1, FALSE, trap->bottom, (&trap->left));
-    CACULATE_CUT_VERTEX(tr, 1, TRUE, trap->top, (&trap->right));
-    CACULATE_CUT_VERTEX(br, 1, TRUE, trap->bottom, (&trap->right));
-
-    if (DEBUG_CLIP_VTX)
-        ErrorF("Trap's TopLeft, BottomLeft, TopRight and BottomRight\n");
-    if (DEBUG_CLIP_VTX)
-        ErrorF("Caculate the vertex of trapezoid:\n"
-               "      (%3d, %3d)-------------------------(%3d, %3d)\n"
-               "              /                           \\       \n"
-               "             /                             \\      \n"
-               "            /                               \\     \n"
-               "  (%3d, %3d)---------------------------------(%3d, %3d)\n"
-               "Clip with rect:\n"
-               "  (%3d, %3d)------------------------(%3d, %3d)    \n"
-               "           |                        |             \n"
-               "           |                        |             \n"
-               "           |                        |             \n"
-               "  (%3d, %3d)------------------------(%3d, %3d)    \n",
-               xFixedToInt(tl[0]), xFixedToInt(tl[1]), xFixedToInt(tr[0]),
-               xFixedToInt(tr[1]), xFixedToInt(bl[0]), xFixedToInt(bl[1]),
-               xFixedToInt(br[0]), xFixedToInt(br[1]),
-               pbox->x1, pbox->y1, pbox->x2, pbox->y1, pbox->x1, pbox->y2,
-               pbox->x2, pbox->y2);
-
-    ADD_VERTEX_IF_INSIDE(tl);
-    ADD_VERTEX_IF_INSIDE(bl);
-    ADD_VERTEX_IF_INSIDE(tr);
-    ADD_VERTEX_IF_INSIDE(br);
-
-    /*Trap's left edge cut Rect. */
-    if (DEBUG_CLIP_VTX)
-        ErrorF("Trap's left edge cut Rect\n");
-    CACULATE_CUT_VERTEX(left_cut_top, 1, FALSE, IntToxFixed(pbox->y1),
-                        (&trap->left));
-    ADD_VERTEX_IF_INSIDE(left_cut_top);
-    if (!IS_TRAP_EDGE_VERTICAL((&trap->left))) {
-        CACULATE_CUT_VERTEX(left_cut_left, 0, FALSE, IntToxFixed(pbox->x1),
-                            (&trap->left));
-        ADD_VERTEX_IF_INSIDE(left_cut_left);
-    }
-    CACULATE_CUT_VERTEX(left_cut_bottom, 1, FALSE, IntToxFixed(pbox->y2),
-                        (&trap->left));
-    ADD_VERTEX_IF_INSIDE(left_cut_bottom);
-    if (!IS_TRAP_EDGE_VERTICAL((&trap->left))) {
-        CACULATE_CUT_VERTEX(left_cut_right, 0, FALSE, IntToxFixed(pbox->x2),
-                            (&trap->left));
-        ADD_VERTEX_IF_INSIDE(left_cut_right);
-    }
-
-    /*Trap's right edge cut Rect. */
-    if (DEBUG_CLIP_VTX)
-        ErrorF("Trap's right edge cut Rect\n");
-    CACULATE_CUT_VERTEX(right_cut_top, 1, TRUE, IntToxFixed(pbox->y1),
-                        (&trap->right));
-    ADD_VERTEX_IF_INSIDE(right_cut_top);
-    if (!IS_TRAP_EDGE_VERTICAL((&trap->right))) {
-        CACULATE_CUT_VERTEX(right_cut_left, 0, TRUE, IntToxFixed(pbox->x1),
-                            (&trap->right));
-        ADD_VERTEX_IF_INSIDE(right_cut_left);
-    }
-    CACULATE_CUT_VERTEX(right_cut_bottom, 1, TRUE, IntToxFixed(pbox->y2),
-                        (&trap->right));
-    ADD_VERTEX_IF_INSIDE(right_cut_bottom);
-    if (!IS_TRAP_EDGE_VERTICAL((&trap->right))) {
-        CACULATE_CUT_VERTEX(right_cut_right, 0, TRUE, IntToxFixed(pbox->x2),
-                            (&trap->right));
-        ADD_VERTEX_IF_INSIDE(right_cut_right);
-    }
-
-    /* Trap's top cut Left and Right of rect. */
-    if (DEBUG_CLIP_VTX)
-        ErrorF("Trap's top cut Left and Right of rect\n");
-    tmp[0] = IntToxFixed(pbox->x1);
-    tmp[1] = trap->top;
-    ADD_VERTEX_IF_INSIDE(tmp);
-    tmp[0] = IntToxFixed(pbox->x2);
-    tmp[1] = trap->top;
-    ADD_VERTEX_IF_INSIDE(tmp);
-
-    /* Trap's bottom cut Left and Right of rect. */
-    if (DEBUG_CLIP_VTX)
-        ErrorF("Trap's bottom cut Left and Right of rect\n");
-    tmp[0] = IntToxFixed(pbox->x1);
-    tmp[1] = trap->bottom;
-    ADD_VERTEX_IF_INSIDE(tmp);
-    tmp[0] = IntToxFixed(pbox->x2);
-    tmp[1] = trap->bottom;
-    ADD_VERTEX_IF_INSIDE(tmp);
-
-    /* The orginal 4 vertex of rect. */
-    if (DEBUG_CLIP_VTX)
-        ErrorF("The orginal 4 vertex of rect\n");
-    tmp[0] = IntToxFixed(pbox->x1);
-    tmp[1] = IntToxFixed(pbox->y1);
-    ADD_VERTEX_IF_INSIDE(tmp);
-    tmp[0] = IntToxFixed(pbox->x1);
-    tmp[1] = IntToxFixed(pbox->y2);
-    ADD_VERTEX_IF_INSIDE(tmp);
-    tmp[0] = IntToxFixed(pbox->x2);
-    tmp[1] = IntToxFixed(pbox->y2);
-    ADD_VERTEX_IF_INSIDE(tmp);
-    tmp[0] = IntToxFixed(pbox->x2);
-    tmp[1] = IntToxFixed(pbox->y1);
-    ADD_VERTEX_IF_INSIDE(tmp);
-
-    if (DEBUG_CLIP_VTX) {
-        ErrorF("\nThe candidate vertex number is %d\n", vertex_num / 2);
-        for (i = 0; i < vertex_num / 2; i++) {
-            ErrorF("(%d, %d) ", tmp_vtx[2 * i], tmp_vtx[2 * i + 1]);
-        }
-        ErrorF("\n");
-    }
-
-    /* Sort the vertex by X and then Y. */
-    for (i = 0; i < vertex_num / 2; i++) {
-        int j;
-
-        for (j = 0; j < vertex_num / 2 - i - 1; j++) {
-            if (tmp_vtx[2 * j] > tmp_vtx[2 * (j + 1)]
-                || (tmp_vtx[2 * j] == tmp_vtx[2 * (j + 1)]
-                    && tmp_vtx[2 * j + 1] > tmp_vtx[2 * (j + 1) + 1])) {
-                tmp[0] = tmp_vtx[2 * j];
-                tmp[1] = tmp_vtx[2 * j + 1];
-                tmp_vtx[2 * j] = tmp_vtx[2 * (j + 1)];
-                tmp_vtx[2 * j + 1] = tmp_vtx[2 * (j + 1) + 1];
-                tmp_vtx[2 * (j + 1)] = tmp[0];
-                tmp_vtx[2 * (j + 1) + 1] = tmp[1];
-            }
-        }
-
-    }
-
-    if (DEBUG_CLIP_VTX) {
-        ErrorF("\nAfter sort vertex number is:\n");
-        for (i = 0; i < vertex_num / 2; i++) {
-            ErrorF("(%d, %d) ", tmp_vtx[2 * i], tmp_vtx[2 * i + 1]);
-        }
-        ErrorF("\n");
-    }
-
-    memset(vertex, -1, 2 * 6);
-    *num = 0;
-
-    for (i = 0; i < vertex_num / 2; i++) {
-        if (*num > 0 && vertex[2 * (*num - 1)] == tmp_vtx[2 * i]
-            && vertex[2 * (*num - 1) + 1] == tmp_vtx[2 * i + 1]) {
-            /*same vertex. */
-            if (DEBUG_CLIP_VTX)
-                ErrorF("X Point:(%d, %d) discard\n",
-                       tmp_vtx[2 * i], tmp_vtx[2 * i + 1]);
-            continue;
-        }
-
-        (*num)++;
-        if (*num > 6) {
-            if (DEBUG_CLIP_VTX)
-                FatalError("Trapezoid clip with Rect can never have vtx"
-                           "number bigger than 6\n");
-            else {
-                ErrorF("Trapezoid clip with Rect can never have vtx"
-                       "number bigger than 6\n");
-                *num = 6;
-                break;
-            }
-        }
-
-        vertex[2 * (*num - 1)] = tmp_vtx[2 * i];
-        vertex[2 * (*num - 1) + 1] = tmp_vtx[2 * i + 1];
-        if (DEBUG_CLIP_VTX)
-            ErrorF("@ Point:(%d, %d) select, num now is %d\n",
-                   tmp_vtx[2 * i], tmp_vtx[2 * i + 1], *num);
-    }
-
-    /* Now we need to arrange the vtx in the polygon's counter-clockwise
-       order. We first select the left and top point as the start point and
-       sort every vtx by the slope from vtx to the start vtx. */
-    for (i = 1; i < *num; i++) {
-        tmp_vtx_slope[i] = (vertex[2 * i] != vertex[0] ?
-                            (float) (vertex[2 * i + 1] -
-                                     vertex[1]) / (float) (vertex[2 * i] -
-                                                           vertex[0])
-                            : (float) INT_MAX);
-    }
-
-    if (DEBUG_CLIP_VTX) {
-        ErrorF("\nvtx number: %d, VTX and slope:\n", *num);
-        for (i = 0; i < *num; i++) {
-            ErrorF("(%d, %d):%f ",
-                   vertex[2 * i], vertex[2 * i + 1], tmp_vtx_slope[i]);
-        }
-        ErrorF("\n");
-    }
-
-    /* Sort the vertex by slope. */
-    for (i = 0; i < *num - 1; i++) {
-        int j;
-        float tmp_slope;
-
-        for (j = 1; j < *num - i - 1; j++) {
-            if (tmp_vtx_slope[j] < tmp_vtx_slope[j + 1]) {
-                tmp_slope = tmp_vtx_slope[j];
-                tmp_vtx_slope[j] = tmp_vtx_slope[j + 1];
-                tmp_vtx_slope[j + 1] = tmp_slope;
-                tmp[0] = vertex[2 * j];
-                tmp[1] = vertex[2 * j + 1];
-                vertex[2 * j] = vertex[2 * (j + 1)];
-                vertex[2 * j + 1] = vertex[2 * (j + 1) + 1];
-                vertex[2 * (j + 1)] = tmp[0];
-                vertex[2 * (j + 1) + 1] = tmp[1];
-            }
-        }
-    }
-
-    if (DEBUG_CLIP_VTX) {
-        ErrorF("\nBefore return, vtx number: %d, VTX and slope:\n", *num);
-        for (i = 0; i < *num; i++) {
-            ErrorF("(%d, %d):%f ",
-                   vertex[2 * i], vertex[2 * i + 1], tmp_vtx_slope[i]);
-        }
-        ErrorF("\n");
-    }
-
-    return TRUE;
-}
-
-static void *
-glamor_setup_composite_vbo_for_trapezoid(ScreenPtr screen, int n_verts)
-{
-    glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
-    int stride;
-    int vert_size;
-    char *vbo_offset;
-    void *vb;
-
-    glamor_priv->render_nr_verts = 0;
-
-    /* For GLAMOR_VERTEX_POS */
-    glamor_priv->vb_stride = 2 * sizeof(float);
-
-    /* For GLAMOR_GLAMOR_VERTEX_SOURCE */
-    glamor_priv->vb_stride += 2 * sizeof(float);
-
-    /* For GLAMOR_VERTEX_TOP_BOTTOM */
-    glamor_priv->vb_stride += 2 * sizeof(float);
-
-    /* For GLAMOR_VERTEX_LEFT_PARAM */
-    glamor_priv->vb_stride += 4 * sizeof(float);
-
-    /* For GLAMOR_VERTEX_RIGHT_PARAM */
-    glamor_priv->vb_stride += 4 * sizeof(float);
-
-    vert_size = n_verts * glamor_priv->vb_stride;
-
-    glamor_make_current(glamor_priv);
-
-    glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
-    glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
-    glDisableVertexAttribArray(GLAMOR_VERTEX_TOP_BOTTOM);
-    glDisableVertexAttribArray(GLAMOR_VERTEX_LEFT_PARAM);
-    glDisableVertexAttribArray(GLAMOR_VERTEX_RIGHT_PARAM);
-
-    vb = glamor_get_vbo_space(screen, vert_size, &vbo_offset);
-
-    /* Set the vertex pointer. */
-    glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
-                          GL_FALSE, glamor_priv->vb_stride,
-                          vbo_offset);
-    glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
-    stride = 2;
-
-    glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2, GL_FLOAT,
-                          GL_FALSE, glamor_priv->vb_stride,
-                          vbo_offset + stride * sizeof(float));
-    glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
-    stride += 2;
-
-    glVertexAttribPointer(GLAMOR_VERTEX_TOP_BOTTOM, 2, GL_FLOAT,
-                          GL_FALSE, glamor_priv->vb_stride,
-                          vbo_offset + stride * sizeof(float));
-    glEnableVertexAttribArray(GLAMOR_VERTEX_TOP_BOTTOM);
-    stride += 2;
-
-    glVertexAttribPointer(GLAMOR_VERTEX_LEFT_PARAM, 4, GL_FLOAT,
-                          GL_FALSE, glamor_priv->vb_stride,
-                          vbo_offset + stride * sizeof(float));
-    glEnableVertexAttribArray(GLAMOR_VERTEX_LEFT_PARAM);
-    stride += 4;
-
-    glVertexAttribPointer(GLAMOR_VERTEX_RIGHT_PARAM, 4, GL_FLOAT,
-                          GL_FALSE, glamor_priv->vb_stride,
-                          vbo_offset + stride * sizeof(float));
-    glEnableVertexAttribArray(GLAMOR_VERTEX_RIGHT_PARAM);
-
-    return vb;
-}
-
-static Bool
-_glamor_trapezoids_with_shader(CARD8 op,
-                               PicturePtr src, PicturePtr dst,
-                               PictFormatPtr mask_format, INT16 x_src,
-                               INT16 y_src, int ntrap, xTrapezoid * traps)
-{
-    ScreenPtr screen = dst->pDrawable->pScreen;
-    glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
-    struct shader_key key;
-    glamor_composite_shader *shader = NULL;
-    struct blendinfo op_info;
-    PictFormatShort saved_source_format = 0;
-    PixmapPtr source_pixmap = NULL;
-    PixmapPtr dest_pixmap = NULL;
-    glamor_pixmap_private *source_pixmap_priv = NULL;
-    glamor_pixmap_private *dest_pixmap_priv = NULL;
-    glamor_pixmap_private *temp_src_priv = NULL;
-    int x_temp_src, y_temp_src;
-    int src_width, src_height;
-    int source_x_off, source_y_off;
-    GLfloat src_xscale = 1, src_yscale = 1;
-    int x_dst, y_dst;
-    int dest_x_off, dest_y_off;
-    GLfloat dst_xscale, dst_yscale;
-    BoxRec bounds;
-    PicturePtr temp_src = src;
-    int vert_stride = 3;
-    int ntriangle_per_loop;
-    int nclip_rect;
-    int mclip_rect;
-    int clip_processed;
-    int clipped_vtx[6 * 2];
-    RegionRec region;
-    BoxPtr box = NULL;
-    BoxPtr pbox = NULL;
-    int traps_count = 0;
-    int traps_not_completed = 0;
-    xTrapezoid *ptrap = NULL;
-    int nbox;
-    float src_matrix[9];
-    Bool ret = FALSE;
-
-    /* If a mask format wasn't provided, we get to choose, but behavior should
-     * be as if there was no temporary mask the traps were accumulated into.
-     */
-    if (!mask_format) {
-        if (dst->polyEdge == PolyEdgeSharp)
-            mask_format = PictureMatchFormat(screen, 1, PICT_a1);
-        else
-            mask_format = PictureMatchFormat(screen, 8, PICT_a8);
-        for (; ntrap; ntrap--, traps++)
-            glamor_trapezoids(op, src, dst, mask_format, x_src,
-                              y_src, 1, traps);
-        return TRUE;
-    }
-
-    miTrapezoidBounds(ntrap, traps, &bounds);
-    DEBUGF("The bounds for all traps is: bounds.x1 = %d, bounds.x2 = %d, "
-           "bounds.y1 = %d, bounds.y2 = %d\n", bounds.x1, bounds.x2,
-           bounds.y1, bounds.y2);
-
-    /* No area need to render. */
-    if (bounds.y1 >= bounds.y2 || bounds.x1 >= bounds.x2)
-        return TRUE;
-
-    dest_pixmap = glamor_get_drawable_pixmap(dst->pDrawable);
-    dest_pixmap_priv = glamor_get_pixmap_private(dest_pixmap);
-
-    if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(dest_pixmap_priv)
-        || dest_pixmap_priv->type == GLAMOR_TEXTURE_LARGE) {
-        /* Currently. Always fallback to cpu if destination is in CPU memory. */
-        ret = FALSE;
-        DEBUGF("dst pixmap has no FBO.\n");
-        goto TRAPEZOID_OUT;
-    }
-
-    if (src->pDrawable) {
-        source_pixmap = glamor_get_drawable_pixmap(src->pDrawable);
-        source_pixmap_priv = glamor_get_pixmap_private(source_pixmap);
-        temp_src_priv = source_pixmap_priv;
-        if (source_pixmap_priv
-            && (source_pixmap_priv->type == GLAMOR_DRM_ONLY
-                || source_pixmap_priv->type == GLAMOR_TEXTURE_LARGE)) {
-            ret = FALSE;
-            goto TRAPEZOID_OUT;
-        }
-    }
-
-    x_dst = bounds.x1;
-    y_dst = bounds.y1;
-
-    src_width = bounds.x2 - bounds.x1;
-    src_height = bounds.y2 - bounds.y1;
-
-    x_temp_src = x_src + bounds.x1 - (traps[0].left.p1.x >> 16);
-    y_temp_src = y_src + bounds.y1 - (traps[0].left.p1.y >> 16);
-
-    if ((!src->pDrawable && (src->pSourcePict->type != SourcePictTypeSolidFill))        //1. The Gradient case.
-        /* 2. Has no fbo but can upload. */
-        || (src->pDrawable && !GLAMOR_PIXMAP_PRIV_HAS_FBO(source_pixmap_priv)
-            && ((src_width * src_height * 4 <
-                 source_pixmap->drawable.width * source_pixmap->drawable.height)
-                || !glamor_check_fbo_size(glamor_priv,
-                                          source_pixmap->drawable.width,
-                                          source_pixmap->drawable.height)))) {
-
-        if (!glamor_check_fbo_size(glamor_priv, src_width, src_height)) {
-            ret = FALSE;
-            goto TRAPEZOID_OUT;
-        }
-        temp_src = glamor_convert_gradient_picture(screen, src,
-                                                   x_src, y_src,
-                                                   src_width, src_height);
-        if (!temp_src) {
-            temp_src = src;
-            ret = FALSE;
-            DEBUGF("Convert gradient picture failed\n");
-            goto TRAPEZOID_OUT;
-        }
-        temp_src_priv =
-            glamor_get_pixmap_private((PixmapPtr) temp_src->pDrawable);
-        x_temp_src = y_temp_src = 0;
-    }
-
-    x_dst += dst->pDrawable->x;
-    y_dst += dst->pDrawable->y;
-    if (temp_src->pDrawable) {
-        x_temp_src += temp_src->pDrawable->x;
-        y_temp_src += temp_src->pDrawable->y;
-    }
-
-    if (!miComputeCompositeRegion(&region,
-                                  temp_src, NULL, dst,
-                                  x_temp_src, y_temp_src,
-                                  0, 0, x_dst, y_dst, src_width, src_height)) {
-        DEBUGF("All the regions are clipped out, do nothing\n");
-        goto TRAPEZOID_OUT;
-    }
-
-    glamor_make_current(glamor_priv);
-
-    box = REGION_RECTS(&region);
-    nbox = REGION_NUM_RECTS(&region);
-    pbox = box;
-
-    ret = glamor_composite_choose_shader(op, temp_src, NULL, dst,
-                                         temp_src_priv, NULL, dest_pixmap_priv,
-                                         &key, &shader, &op_info,
-                                         &saved_source_format);
-    if (ret == FALSE) {
-        DEBUGF("can not set the shader program for composite\n");
-        goto TRAPEZOID_RESET_GL;
-    }
-    glamor_set_destination_pixmap_priv_nc(dest_pixmap_priv);
-    glamor_composite_set_shader_blend(dest_pixmap_priv, &key, shader, &op_info);
-    glamor_priv->has_source_coords = key.source != SHADER_SOURCE_SOLID;
-    glamor_priv->has_mask_coords = (key.mask != SHADER_MASK_NONE &&
-                                    key.mask != SHADER_MASK_SOLID);
-
-    glamor_get_drawable_deltas(dst->pDrawable, dest_pixmap,
-                               &dest_x_off, &dest_y_off);
-
-    pixmap_priv_get_dest_scale(dest_pixmap_priv, &dst_xscale, &dst_yscale);
-
-    if (glamor_priv->has_source_coords) {
-        source_pixmap = glamor_get_drawable_pixmap(temp_src->pDrawable);
-        source_pixmap_priv = glamor_get_pixmap_private(source_pixmap);
-        glamor_get_drawable_deltas(temp_src->pDrawable,
-                                   source_pixmap, &source_x_off, &source_y_off);
-        pixmap_priv_get_scale(source_pixmap_priv, &src_xscale, &src_yscale);
-        glamor_picture_get_matrixf(temp_src, src_matrix);
-        vert_stride += 3;
-    }
-
-    if (glamor_priv->has_mask_coords) {
-        DEBUGF("Should never have mask coords here!\n");
-        ret = FALSE;
-        goto TRAPEZOID_RESET_GL;
-    }
-
-    /* A trapezoid clip with a rectangle will at most generate a hexagon,
-       which can be devided into 4 triangles to render. */
-    ntriangle_per_loop =
-        (vert_stride * nbox * ntrap * 4) >
-        GLAMOR_COMPOSITE_VBO_VERT_CNT ? (GLAMOR_COMPOSITE_VBO_VERT_CNT /
-                                         vert_stride) : nbox * ntrap * 4;
-    ntriangle_per_loop = (ntriangle_per_loop / 4) * 4;
-
-    nclip_rect = nbox;
-    while (nclip_rect) {
-        float *vb;
-
-        mclip_rect = (nclip_rect * ntrap * 4) > ntriangle_per_loop ?
-            (ntriangle_per_loop / (4 * ntrap)) : nclip_rect;
-
-        if (!mclip_rect) {      /* Maybe too many traps. */
-            mclip_rect = 1;
-            ptrap = traps;
-            traps_count = ntriangle_per_loop / 4;
-            traps_not_completed = ntrap - traps_count;
-        }
-        else {
-            traps_count = ntrap;
-            ptrap = traps;
-            traps_not_completed = 0;
-        }
-
- NTRAPS_LOOP_AGAIN:
-
-        vb = glamor_setup_composite_vbo(screen,
-                                        (mclip_rect * traps_count *
-                                         4 * vert_stride));
-        clip_processed = mclip_rect;
-
-        while (mclip_rect--) {
-            while (traps_count--) {
-                int vtx_num;
-                int i;
-                float vertices[3 * 2], source_texcoords[3 * 2];
-
-                DEBUGF
-                    ("In loop of render trapezoid, nclip_rect = %d, mclip_rect = %d, "
-                     "clip_processed = %d, traps_count = %d, traps_not_completed = %d\n",
-                     nclip_rect, mclip_rect, clip_processed, traps_count,
-                     traps_not_completed);
-
-                if (_glamor_clip_trapezoid_vertex
-                    (ptrap, pbox, clipped_vtx, &vtx_num)) {
-                    for (i = 0; i < vtx_num - 2; i++) {
-                        int clipped_vtx_tmp[3 * 2];
-
-                        clipped_vtx_tmp[0] = clipped_vtx[0];
-                        clipped_vtx_tmp[1] = clipped_vtx[1];
-                        clipped_vtx_tmp[2] = clipped_vtx[(i + 1) * 2];
-                        clipped_vtx_tmp[3] = clipped_vtx[(i + 1) * 2 + 1];
-                        clipped_vtx_tmp[4] = clipped_vtx[(i + 2) * 2];
-                        clipped_vtx_tmp[5] = clipped_vtx[(i + 2) * 2 + 1];
-                        glamor_set_normalize_tri_vcoords(dst_xscale, dst_yscale,
-                                                         clipped_vtx_tmp,
-                                                         vertices);
-                        DEBUGF("vertices of triangle: (%f X %f), (%f X %f), "
-                               "(%f X %f)\n", vertices[0], vertices[1],
-                               vertices[2], vertices[3], vertices[4],
-                               vertices[5]);
-
-                        if (key.source != SHADER_SOURCE_SOLID) {
-                            if (src->transform) {
-                                glamor_set_transformed_normalize_tri_tcoords
-                                    (source_pixmap_priv, src_matrix, src_xscale,
-                                     src_yscale, clipped_vtx_tmp,
-                                     source_texcoords);
-                            }
-                            else {
-                                glamor_set_normalize_tri_tcoords(src_xscale,
-                                                                 src_yscale,
-                                                                 clipped_vtx_tmp,
-                                                                 source_texcoords);
-                            }
-
-                            DEBUGF("source_texcoords of triangle: (%f X %f), "
-                                   "(%f X %f), (%f X %f)\n",
-                                   source_texcoords[0], source_texcoords[1],
-                                   source_texcoords[2], source_texcoords[3],
-                                   source_texcoords[4], source_texcoords[5]);
-                        }
-
-                        glamor_emit_composite_triangle(screen, vb,
-                                                       source_texcoords,
-                                                       NULL, vertices);
-                        vb += 3 * glamor_priv->vb_stride / sizeof(float);
-                    }
-                }
-
-                ptrap++;
-            }
-
-            if (traps_not_completed) {  /* one loop of ntraps not completed */
-                mclip_rect = 1;
-                traps_count = traps_not_completed > (ntriangle_per_loop / 4) ?
-                    (ntriangle_per_loop / 4) : traps_not_completed;
-                traps_not_completed -= traps_count;
-                glamor_flush_composite_triangles(screen);
-                goto NTRAPS_LOOP_AGAIN;
-            }
-            else {
-                ptrap = traps;
-                traps_count = ntrap;
-            }
-
-            pbox++;
-        }
-
-        glamor_flush_composite_triangles(screen);
-
-        nclip_rect -= clip_processed;
-    }
-
-    ret = TRUE;
-
- TRAPEZOID_RESET_GL:
-    glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
-    glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
-    glDisableVertexAttribArray(GLAMOR_VERTEX_MASK);
-    glDisable(GL_BLEND);
-
- TRAPEZOID_OUT:
-    if (box) {
-        REGION_UNINIT(dst->pDrawable->pScreen, &region);
-    }
-
-    if (temp_src != src) {
-        FreePicture(temp_src, 0);
-    }
-    else {
-        if (saved_source_format) {
-            src->format = saved_source_format;
-        }
-    }
-
-    return ret;
-}
-
-void
-glamor_init_trapezoid_shader(ScreenPtr screen)
-{
-    glamor_screen_private *glamor_priv;
-    GLint fs_prog, vs_prog;
-
-    const char *trapezoid_vs =
-        GLAMOR_DEFAULT_PRECISION
-        "attribute vec4 v_position;\n"
-        "attribute vec2 v_texcoord;\n"
-        /* v_top_bottom, v_left_param and v_right_param contain the
-           constant value for all the vertex of one rect. Using uniform
-           is more suitable but we need to reset the uniform variables
-           for every rect rendering and can not use the vbo, which causes
-           performance loss. So we set these attributes to same value
-           for every vertex of one rect and so it is also a constant in FS */
-        "attribute vec2 v_top_bottom;\n"
-        "attribute vec4 v_left_param;\n"
-        "attribute vec4 v_right_param;\n"
-        "\n"
-        "varying vec2 source_texture;\n"
-        "varying float trap_top;\n"
-        "varying float trap_bottom;\n"
-        "varying float trap_left_x;\n"
-        "varying float trap_left_y;\n"
-        "varying float trap_left_slope;\n"
-        "varying float trap_left_vertical_f;\n"
-        "varying float trap_right_x;\n"
-        "varying float trap_right_y;\n"
-        "varying float trap_right_slope;\n"
-        "varying float trap_right_vertical_f;\n"
-        "\n"
-        "void main()\n"
-        "{\n"
-        "    gl_Position = v_position;\n"
-        "    source_texture = v_texcoord.xy;\n"
-        "    trap_top = v_top_bottom.x;\n"
-        "    trap_bottom = v_top_bottom.y;\n"
-        "    \n"
-        "    trap_left_x = v_left_param.x;\n"
-        "    trap_left_y = v_left_param.y;\n"
-        "    trap_left_slope = v_left_param.z;\n"
-        "    trap_left_vertical_f = v_left_param.w;\n"
-        "    \n"
-        "    trap_right_x = v_right_param.x;\n"
-        "    trap_right_y = v_right_param.y;\n"
-        "    trap_right_slope = v_right_param.z;\n"
-        "    trap_right_vertical_f = v_right_param.w;\n"
-        "}\n";
-
-    /*
-     * Because some GL fill function do not support the MultSample
-     * anti-alias, we need to do the MSAA here. This manner like
-     * pixman, will caculate the value of area in trapezoid dividing
-     * the totol area for each pixel, as follow:
-     |
-     ----+------------------------------------------------------>
-     |
-     |              -------------
-     |             /             \
-     |            /               \
-     |           /                 \
-     |          /              +----------------+
-     |         /               |.....\          |
-     |        /                |......\         |
-     |       /                 |.......\        |
-     |      /                  |........\       |
-     |     /-------------------+---------\      |
-     |                         |                |
-     |                         |                |
-     |                         +----------------+
-     |
-     \|/
-
-     */
-    const char *trapezoid_fs =
-        GLAMOR_DEFAULT_PRECISION
-        "varying vec2 source_texture;  \n"
-        "varying float trap_top;  \n"
-        "varying float trap_bottom;  \n"
-        "varying float trap_left_x;  \n"
-        "varying float trap_left_y;  \n"
-        "varying float trap_left_slope;  \n"
-        "varying float trap_left_vertical_f;  \n"
-        "varying float trap_right_x;  \n"
-        "varying float trap_right_y;  \n"
-        "varying float trap_right_slope;  \n"
-        "varying float trap_right_vertical_f;  \n"
-        "float x_per_pix = 1.0;"
-        "float y_per_pix = 1.0;"
-        "\n"
-        "float get_alpha_val() \n"
-        "{  \n"
-        "    float x_up_cut_left;  \n"
-        "    float x_bottom_cut_left;  \n"
-        "    float x_up_cut_right;  \n"
-        "    float x_bottom_cut_right;  \n"
-        "    bool trap_left_vertical;\n"
-        "    bool trap_right_vertical;\n"
-        "	 if (abs(trap_left_vertical_f - 1.0) <= 0.0001)\n"
-        "		trap_left_vertical = true;\n"
-        "	 else\n"
-        "		trap_left_vertical = false;\n"
-        "	 if (abs(trap_right_vertical_f - 1.0) <= 0.0001)\n"
-        "		trap_right_vertical = true;\n"
-        "	 else\n"
-        "		trap_right_vertical = false;\n"
-        "    \n"
-        "    if(trap_left_vertical == true) {  \n"
-        "        x_up_cut_left = trap_left_x;  \n"
-        "        x_bottom_cut_left = trap_left_x;  \n"
-        "    } else {  \n"
-        "        x_up_cut_left = trap_left_x  \n"
-        "            + (source_texture.y - y_per_pix/2.0 - trap_left_y)  \n"
-        "              / trap_left_slope;  \n"
-        "        x_bottom_cut_left = trap_left_x  \n"
-        "            + (source_texture.y + y_per_pix/2.0 - trap_left_y)  \n"
-        "              / trap_left_slope;  \n"
-        "    }  \n"
-        "    \n"
-        "    if(trap_right_vertical == true) {  \n"
-        "        x_up_cut_right = trap_right_x;  \n"
-        "        x_bottom_cut_right = trap_right_x;  \n"
-        "    } else {  \n"
-        "        x_up_cut_right = trap_right_x  \n"
-        "            + (source_texture.y - y_per_pix/2.0 - trap_right_y)  \n"
-        "              / trap_right_slope;  \n"
-        "        x_bottom_cut_right = trap_right_x  \n"
-        "            + (source_texture.y + y_per_pix/2.0 - trap_right_y)  \n"
-        "              / trap_right_slope;  \n"
-        "    }  \n"
-        "    \n"
-        "    if((x_up_cut_left <= source_texture.x - x_per_pix/2.0) &&  \n"
-        "          (x_bottom_cut_left <= source_texture.x - x_per_pix/2.0) &&  \n"
-        "          (x_up_cut_right >= source_texture.x + x_per_pix/2.0) &&  \n"
-        "          (x_bottom_cut_right >= source_texture.x + x_per_pix/2.0) &&  \n"
-        "          (trap_top <= source_texture.y - y_per_pix/2.0) &&  \n"
-        "          (trap_bottom >= source_texture.y + y_per_pix/2.0)) {  \n"
-        //       The complete inside case.
-        "        return 1.0;  \n"
-        "    } else if((trap_top > source_texture.y + y_per_pix/2.0) ||  \n"
-        "                (trap_bottom < source_texture.y - y_per_pix/2.0)) {  \n"
-        //       The complete outside. Above the top or Below the bottom.
-        "        return 0.0;  \n"
-        "    } else {  \n"
-        "        if((x_up_cut_right < source_texture.x - x_per_pix/2.0 &&  \n"
-        "                   x_bottom_cut_right < source_texture.x - x_per_pix/2.0)  \n"
-        "            || (x_up_cut_left > source_texture.x + x_per_pix/2.0  &&  \n"
-        "                   x_bottom_cut_left > source_texture.x + x_per_pix/2.0)) {  \n"
-        //            The complete outside. At Left or Right of the trapezoide.
-        "             return 0.0;  \n"
-        "        }  \n"
-        "    }  \n"
-        //   Get here, the pix is partly inside the trapezoid.
-        "    {  \n"
-        "        float percent = 0.0;  \n"
-        "        float up = (source_texture.y - y_per_pix/2.0) >= trap_top ?  \n"
-        "                       (source_texture.y - y_per_pix/2.0) : trap_top;  \n"
-        "        float bottom = (source_texture.y + y_per_pix/2.0) <= trap_bottom ?  \n"
-        "                       (source_texture.y + y_per_pix/2.0) : trap_bottom;  \n"
-        "        float left = source_texture.x - x_per_pix/2.0;  \n"
-        "        float right = source_texture.x + x_per_pix/2.0;  \n"
-        "        \n"
-        "        percent = (bottom - up) / y_per_pix;  \n"
-        "        \n"
-        "	     if(trap_left_vertical == true) {  \n"
-        "            if(trap_left_x > source_texture.x - x_per_pix/2.0 &&  \n"
-        "                     trap_left_x < source_texture.x + x_per_pix/2.0)  \n"
-        "                left = trap_left_x;  \n"
-        "        }  \n"
-        "	     if(trap_right_vertical == true) {  \n"
-        "            if(trap_right_x > source_texture.x - x_per_pix/2.0 &&  \n"
-        "                     trap_right_x < source_texture.x + x_per_pix/2.0)  \n"
-        "                right = trap_right_x;  \n"
-        "        }  \n"
-        "        if((up >= bottom) || (left >= right))  \n"
-        "            return 0.0;  \n"
-        "        \n"
-        "        percent = percent * ((right - left)/x_per_pix);  \n"
-        "        if(trap_left_vertical == true && trap_right_vertical == true)  \n"
-        "            return percent;  \n"
-        "        \n"
-        "        if(trap_left_vertical != true) {  \n"
-        "            float area;  \n"
-        //           the slope should never be 0.0 here
-        "            float up_x = trap_left_x + (up - trap_left_y)/trap_left_slope;  \n"
-        "            float bottom_x = trap_left_x + (bottom - trap_left_y)/trap_left_slope;  \n"
-        "            if(trap_left_slope < 0.0 && up_x > left) {  \n"
-        /*   case 1
-           |
-           ----+------------------------------------->
-           |                 /
-           |                /
-           |           +---/--------+
-           |           |  /.........|
-           |           | /..........|
-           |           |/...........|
-           |           /............|
-           |          /|............|
-           |           +------------+
-           |
-           \|/
-         */
-        "                float left_y = trap_left_y + trap_left_slope*(left - trap_left_x);  \n"
-        "                if((up_x > left) && (left_y > up)) {  \n"
-        "                    area = 0.5 * (up_x - left) * (left_y - up);  \n"
-        "                    if(up_x > right) {  \n"
-        "                        float right_y = trap_left_y  \n"
-        "                                  + trap_left_slope*(right - trap_left_x);  \n"
-        "                        area = area - 0.5 * (up_x - right) * (right_y - up);  \n"
-        "                    }  \n"
-        "                    if(left_y > bottom) {  \n"
-        "                        area = area - 0.5 * (bottom_x - left) * (left_y - bottom);  \n"
-        "                    }  \n"
-        "                } else {  \n"
-        "                    area = 0.0;  \n"
-        "                }  \n"
-        "                percent = percent * (1.0 - (area/((right-left)*(bottom-up))));  \n"
-        "            } else if(trap_left_slope > 0.0 && bottom_x > left) {  \n"
-        /*   case 2
-           |
-           ----+------------------------------------->
-           |          \
-           |           \
-           |           +\-----------+
-           |           | \..........|
-           |           |  \.........|
-           |           |   \........|
-           |           |    \.......|
-           |           |     \......|
-           |           +------\-----+
-           |                   \
-           |                    \
-           \|/
-         */
-        "                float right_y = trap_left_y + trap_left_slope*(right - trap_left_x);  \n"
-        "                if((up_x < right) && (right_y > up)) {  \n"
-        "                    area = 0.5 * (right - up_x) * (right_y - up);  \n"
-        "                    if(up_x < left) {  \n"
-        "                        float left_y = trap_left_y  \n"
-        "                                  + trap_left_slope*(left - trap_left_x);  \n"
-        "                        area = area - 0.5 * (left - up_x) * (left_y - up);  \n"
-        "                    }  \n"
-        "                    if(right_y > bottom) {  \n"
-        "                        area = area - 0.5 * (right - bottom_x) * (right_y - bottom);  \n"
-        "                    }  \n"
-        "                } else {  \n"
-        "                    area = 0.0;  \n"
-        "                }  \n"
-        "                percent = percent * (area/((right-left)*(bottom-up)));  \n"
-        "            }  \n"
-        "        }  \n"
-        "        \n"
-        "        if(trap_right_vertical != true) {  \n"
-        "            float area;  \n"
-        //           the slope should never be 0.0 here
-        "            float up_x = trap_right_x + (up - trap_right_y)/trap_right_slope;  \n"
-        "            float bottom_x = trap_right_x + (bottom - trap_right_y)/trap_right_slope;  \n"
-        "            if(trap_right_slope < 0.0 && bottom_x < right) {  \n"
-        /*   case 3
-           |
-           ----+------------------------------------->
-           |                     /
-           |           +--------/---+
-           |           |......./    |
-           |           |....../     |
-           |           |...../      |
-           |           |..../       |
-           |           |.../        |
-           |           +--/---------+
-           |             /
-           |
-           \|/
-         */
-        "                float left_y = trap_right_y + trap_right_slope*(left - trap_right_x);  \n"
-        "                if((up_x > left) && (left_y > up)) {  \n"
-        "                    area = 0.5 * (up_x - left) * (left_y - up);  \n"
-        "                    if(up_x > right) {  \n"
-        "                        float right_y = trap_right_y  \n"
-        "                                  + trap_right_slope*(right - trap_right_x);  \n"
-        "                        area = area - 0.5 * (up_x - right) * (right_y - up);  \n"
-        "                    }  \n"
-        "                    if(left_y > bottom) {  \n"
-        "                        area = area - 0.5 * (bottom_x - left) * (left_y - bottom);  \n"
-        "                    }  \n"
-        "                } else {  \n"
-        "                    area = 0.0;  \n"
-        "                }  \n"
-        "                percent = percent * (area/((right-left)*(bottom-up)));  \n"
-        "            } else if(trap_right_slope > 0.0 && up_x < right) {  \n"
-        /*   case 4
-           |
-           ----+------------------------------------->
-           |                   \
-           |           +--------\---+
-           |           |.........\  |
-           |           |..........\ |
-           |           |...........\|
-           |           |............\
-           |           |............|\
-           |           +------------+ \
-           |                           \
-           |
-           \|/
-         */
-        "                float right_y = trap_right_y + trap_right_slope*(right - trap_right_x);  \n"
-        "                if((up_x < right) && (right_y > up)) {  \n"
-        "                    area = 0.5 * (right - up_x) * (right_y - up);  \n"
-        "                    if(up_x < left) {  \n"
-        "                        float left_y = trap_right_y  \n"
-        "                                  + trap_right_slope*(left - trap_right_x);  \n"
-        "                        area = area - 0.5 * (left - up_x) * (left_y - up);  \n"
-        "                    }  \n"
-        "                    if(right_y > bottom) {  \n"
-        "                        area = area - 0.5 * (right - bottom_x) * (right_y - bottom);  \n"
-        "                    }  \n"
-        "                } else {  \n"
-        "                    area = 0.0;  \n"
-        "                }  \n"
-        "                percent = percent * (1.0 - (area/((right-left)*(bottom-up))));  \n"
-        "            }  \n"
-        "        }  \n"
-        "        \n"
-        "        return percent;  \n"
-        "    }  \n"
-        "}  \n"
-        "\n"
-        "void main()  \n"
-        "{  \n"
-        "    float alpha_val = get_alpha_val();  \n"
-        "    gl_FragColor = vec4(0.0, 0.0, 0.0, alpha_val);  \n"
-        "}\n";
-
-    glamor_priv = glamor_get_screen_private(screen);
-    glamor_make_current(glamor_priv);
-
-    glamor_priv->trapezoid_prog = glCreateProgram();
-
-    vs_prog = glamor_compile_glsl_prog(GL_VERTEX_SHADER, trapezoid_vs);
-    fs_prog = glamor_compile_glsl_prog(GL_FRAGMENT_SHADER, trapezoid_fs);
-
-    glAttachShader(glamor_priv->trapezoid_prog, vs_prog);
-    glAttachShader(glamor_priv->trapezoid_prog, fs_prog);
-
-    glBindAttribLocation(glamor_priv->trapezoid_prog,
-                         GLAMOR_VERTEX_POS, "v_positionsition");
-    glBindAttribLocation(glamor_priv->trapezoid_prog,
-                         GLAMOR_VERTEX_SOURCE, "v_texcoord");
-    glBindAttribLocation(glamor_priv->trapezoid_prog,
-                         GLAMOR_VERTEX_TOP_BOTTOM, "v_top_bottom");
-    glBindAttribLocation(glamor_priv->trapezoid_prog,
-                         GLAMOR_VERTEX_LEFT_PARAM, "v_left_param");
-    glBindAttribLocation(glamor_priv->trapezoid_prog,
-                         GLAMOR_VERTEX_RIGHT_PARAM, "v_right_param");
-
-    glamor_link_glsl_prog(screen, glamor_priv->trapezoid_prog, "trapezoid");
-}
-
-void
-glamor_fini_trapezoid_shader(ScreenPtr screen)
-{
-    glamor_screen_private *glamor_priv;
-
-    glamor_priv = glamor_get_screen_private(screen);
-    glamor_make_current(glamor_priv);
-    glDeleteProgram(glamor_priv->trapezoid_prog);
-}
-
-static Bool
-_glamor_generate_trapezoid_with_shader(ScreenPtr screen, PicturePtr picture,
-                                       xTrapezoid *traps, int ntrap,
-                                       BoxRec *bounds)
-{
-    glamor_screen_private *glamor_priv;
-    glamor_pixmap_private *pixmap_priv;
-    PixmapPtr pixmap = NULL;
-    GLint trapezoid_prog;
-    GLfloat xscale, yscale;
-    float left_slope, right_slope;
-    xTrapezoid *ptrap;
-    BoxRec one_trap_bound;
-    int nrect_max;
-    int i, j;
-    float params[4];
-
-    glamor_priv = glamor_get_screen_private(screen);
-    trapezoid_prog = glamor_priv->trapezoid_prog;
-
-    pixmap = glamor_get_drawable_pixmap(picture->pDrawable);
-    pixmap_priv = glamor_get_pixmap_private(pixmap);
-
-    if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv)
-        || pixmap_priv->type == GLAMOR_TEXTURE_LARGE) { /* should always have here. */
-        DEBUGF("GLAMOR_PIXMAP_PRIV_HAS_FBO check failed, fallback\n");
-        return FALSE;
-    }
-
-    /* First, clear all to zero */
-    glamor_solid(pixmap, 0, 0, pixmap_priv->base.pixmap->drawable.width,
-                 pixmap_priv->base.pixmap->drawable.height, 0);
-
-    glamor_make_current(glamor_priv);
-
-    glamor_set_destination_pixmap_priv_nc(pixmap_priv);
-
-    pixmap_priv_get_dest_scale(pixmap_priv, (&xscale), (&yscale));
-
-    /* Now draw the Trapezoid mask. */
-    glUseProgram(trapezoid_prog);
-
-    glEnable(GL_BLEND);
-    glBlendFunc(GL_ONE, GL_ONE);
-
-    nrect_max = GLAMOR_COMPOSITE_VBO_VERT_CNT / (4 * GLAMOR_VERTEX_RIGHT_PARAM);
-
-    for (i = 0; i < ntrap;) {
-        float *vertices;
-        int mrect;
-        int stride;
-
-        mrect = (ntrap - i) > nrect_max ? nrect_max : (ntrap - i);
-        vertices = glamor_setup_composite_vbo_for_trapezoid(screen, 4 * mrect);
-        stride = glamor_priv->vb_stride / sizeof(float);
-
-        for (j = 0; j < mrect; j++) {
-            ptrap = traps + i + j;
-
-            DEBUGF
-                ("--- The parameter of xTrapezoid is:\ntop: %d  0x%x\tbottom: %d  0x%x\n"
-                 "left:  p1 (%d   0x%x, %d   0x%x)\tp2 (%d   0x%x, %d   0x%x)\n"
-                 "right: p1 (%d   0x%x, %d   0x%x)\tp2 (%d   0x%x, %d   0x%x)\n",
-                 xFixedToInt(ptrap->top), ptrap->top,
-                 xFixedToInt(ptrap->bottom), ptrap->bottom,
-                 xFixedToInt(ptrap->left.p1.x), ptrap->left.p1.x,
-                 xFixedToInt(ptrap->left.p1.y), ptrap->left.p1.y,
-                 xFixedToInt(ptrap->left.p2.x), ptrap->left.p2.x,
-                 xFixedToInt(ptrap->left.p2.y), ptrap->left.p2.y,
-                 xFixedToInt(ptrap->right.p1.x), ptrap->right.p1.x,
-                 xFixedToInt(ptrap->right.p1.y), ptrap->right.p1.y,
-                 xFixedToInt(ptrap->right.p2.x), ptrap->right.p2.x,
-                 xFixedToInt(ptrap->right.p2.y), ptrap->right.p2.y);
-
-            miTrapezoidBounds(1, ptrap, &one_trap_bound);
-
-            vertices += 2;
-            glamor_set_tcoords_ext((one_trap_bound.x1), (one_trap_bound.y1),
-                                   (one_trap_bound.x2), (one_trap_bound.y2),
-                                   vertices, stride);
-            DEBUGF("tex_vertices --> leftup : %f X %f, rightup: %f X %f,"
-                   "rightbottom: %f X %f, leftbottom : %f X %f\n", vertices[0],
-                   vertices[1], vertices[1 * stride], vertices[1 * stride + 1],
-                   vertices[2 * stride], vertices[2 * stride + 1],
-                   vertices[3 * stride], vertices[3 * stride + 1]);
-
-            /* Need to rebase. */
-            one_trap_bound.x1 -= bounds->x1;
-            one_trap_bound.x2 -= bounds->x1;
-            one_trap_bound.y1 -= bounds->y1;
-            one_trap_bound.y2 -= bounds->y1;
-
-            vertices -= 2;
-
-            glamor_set_normalize_vcoords_ext(pixmap_priv, xscale, yscale,
-                                             one_trap_bound.x1,
-                                             one_trap_bound.y1,
-                                             one_trap_bound.x2,
-                                             one_trap_bound.y2,
-                                             vertices, stride);
-            DEBUGF("vertices --> leftup : %f X %f, rightup: %f X %f,"
-                   "rightbottom: %f X %f, leftbottom : %f X %f\n", vertices[0],
-                   vertices[1], vertices[1 * stride], vertices[1 * stride + 1],
-                   vertices[2 * stride], vertices[2 * stride + 1],
-                   vertices[3 * stride], vertices[3 * stride + 1]);
-            vertices += 4;
-
-            /* Set the top and bottom. */
-            params[0] = ((float) ptrap->top) / 65536;
-            params[1] = ((float) ptrap->bottom) / 65536;
-            glamor_set_const_ext(params, 2, vertices, 4, stride);
-            vertices += 2;
-
-            /* Set the left params. */
-            params[0] = ((float) ptrap->left.p1.x) / 65536;
-            params[1] = ((float) ptrap->left.p1.y) / 65536;
-
-            if (ptrap->left.p1.x == ptrap->left.p2.x) {
-                left_slope = 0.0;
-                params[3] = 1.0;
-            }
-            else {
-                left_slope = ((float) (ptrap->left.p1.y - ptrap->left.p2.y))
-                    / ((float) (ptrap->left.p1.x - ptrap->left.p2.x));
-                params[3] = 0.0;
-            }
-            params[2] = left_slope;
-            glamor_set_const_ext(params, 4, vertices, 4, stride);
-            vertices += 4;
-
-            /* Set the left params. */
-            params[0] = ((float) ptrap->right.p1.x) / 65536;
-            params[1] = ((float) ptrap->right.p1.y) / 65536;
-
-            if (ptrap->right.p1.x == ptrap->right.p2.x) {
-                right_slope = 0.0;
-                params[3] = 1.0;
-            }
-            else {
-                right_slope = ((float) (ptrap->right.p1.y - ptrap->right.p2.y))
-                    / ((float) (ptrap->right.p1.x - ptrap->right.p2.x));
-                params[3] = 0.0;
-            }
-            params[2] = right_slope;
-            glamor_set_const_ext(params, 4, vertices, 4, stride);
-            vertices += 4;
-
-            DEBUGF("trap_top = %f, trap_bottom = %f, "
-                   "trap_left_x = %f, trap_left_y = %f, left_slope = %f, "
-                   "trap_right_x = %f, trap_right_y = %f, right_slope = %f\n",
-                   ((float) ptrap->top) / 65536,
-                   ((float) ptrap->bottom) / 65536,
-                   ((float) ptrap->left.p1.x) / 65536,
-                   ((float) ptrap->left.p1.y) / 65536, left_slope,
-                   ((float) ptrap->right.p1.x) / 65536,
-                   ((float) ptrap->right.p1.y) / 65536, right_slope);
-
-            glamor_priv->render_nr_verts += 4;
-            vertices += 3 * stride;
-        }
-
-        i += mrect;
-
-        glamor_put_vbo_space(screen);
-
-        /* Now rendering. */
-        if (!glamor_priv->render_nr_verts)
-            continue;
-
-        if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP) {
-            glDrawRangeElements(GL_TRIANGLES, 0,
-                                glamor_priv->render_nr_verts,
-                                (glamor_priv->render_nr_verts * 3) / 2,
-                                GL_UNSIGNED_SHORT, NULL);
-        } else {
-            glDrawElements(GL_TRIANGLES,
-                           (glamor_priv->render_nr_verts * 3) / 2,
-                           GL_UNSIGNED_SHORT, NULL);
-        }
-    }
-
-    glBlendFunc(GL_ONE, GL_ZERO);
-    glDisable(GL_BLEND);
-    glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
-    glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
-    glDisableVertexAttribArray(GLAMOR_VERTEX_TOP_BOTTOM);
-    glDisableVertexAttribArray(GLAMOR_VERTEX_LEFT_PARAM);
-    glDisableVertexAttribArray(GLAMOR_VERTEX_RIGHT_PARAM);
-    return TRUE;
-}
-
-#endif                          /*GLAMOR_TRAPEZOID_SHADER */
-
 /**
  * Creates an appropriate picture for temp mask use.
  */
@@ -1559,7 +43,7 @@ static PicturePtr
 glamor_create_mask_picture(ScreenPtr screen,
                            PicturePtr dst,
                            PictFormatPtr pict_format,
-                           CARD16 width, CARD16 height, int gpu)
+                           CARD16 width, CARD16 height)
 {
     PixmapPtr pixmap;
     PicturePtr picture;
@@ -1574,15 +58,9 @@ glamor_create_mask_picture(ScreenPtr screen,
             return 0;
     }
 
-    if (gpu) {
-        pixmap = glamor_create_pixmap(screen, width, height,
-                                      pict_format->depth, 0);
-    }
-    else {
-        pixmap = glamor_create_pixmap(screen, 0, 0,
-                                      pict_format->depth,
-                                      GLAMOR_CREATE_PIXMAP_CPU);
-    }
+    pixmap = glamor_create_pixmap(screen, 0, 0,
+                                  pict_format->depth,
+                                  GLAMOR_CREATE_PIXMAP_CPU);
 
     if (!pixmap)
         return 0;
@@ -1592,61 +70,15 @@ glamor_create_mask_picture(ScreenPtr screen,
     return picture;
 }
 
-static int
-_glamor_trapezoid_bounds(int ntrap, xTrapezoid *traps, BoxPtr box)
-{
-    int has_large_trapezoid = 0;
-
-    box->y1 = MAXSHORT;
-    box->y2 = MINSHORT;
-    box->x1 = MAXSHORT;
-    box->x2 = MINSHORT;
-
-    for (; ntrap; ntrap--, traps++) {
-        INT16 x1, y1, x2, y2;
-
-        if (!xTrapezoidValid(traps))
-            continue;
-        y1 = xFixedToInt(traps->top);
-        if (y1 < box->y1)
-            box->y1 = y1;
-
-        y2 = xFixedToInt(xFixedCeil(traps->bottom));
-        if (y2 > box->y2)
-            box->y2 = y2;
-
-        x1 = xFixedToInt(min
-                         (_glamor_linefixedX(&traps->left, traps->top, FALSE),
-                          _glamor_linefixedX(&traps->left, traps->bottom,
-                                             FALSE)));
-        if (x1 < box->x1)
-            box->x1 = x1;
-
-        x2 = xFixedToInt(xFixedCeil
-                         (max
-                          (_glamor_linefixedX(&traps->right, traps->top, TRUE),
-                           _glamor_linefixedX(&traps->right, traps->bottom,
-                                              TRUE))));
-        if (x2 > box->x2)
-            box->x2 = x2;
-
-        if (!has_large_trapezoid && (x2 - x1) > 256 && (y2 - y1) > 32)
-            has_large_trapezoid = 1;
-    }
-
-    return has_large_trapezoid;
-}
-
 /**
- * glamor_trapezoids will first try to create a trapezoid mask using shader,
- * if failed, miTrapezoids will generate trapezoid mask accumulating in
+ * glamor_trapezoids will generate trapezoid mask accumulating in
  * system memory.
  */
-static Bool
-_glamor_trapezoids(CARD8 op,
-                   PicturePtr src, PicturePtr dst,
-                   PictFormatPtr mask_format, INT16 x_src, INT16 y_src,
-                   int ntrap, xTrapezoid *traps, Bool fallback)
+void
+glamor_trapezoids(CARD8 op,
+                  PicturePtr src, PicturePtr dst,
+                  PictFormatPtr mask_format, INT16 x_src, INT16 y_src,
+                  int ntrap, xTrapezoid *traps)
 {
     ScreenPtr screen = dst->pDrawable->pScreen;
     BoxRec bounds;
@@ -1656,8 +88,6 @@ _glamor_trapezoids(CARD8 op,
     int width, height, stride;
     PixmapPtr pixmap;
     pixman_image_t *image = NULL;
-    int ret = 0;
-    int has_large_trapezoid;
 
     /* If a mask format wasn't provided, we get to choose, but behavior should
      * be as if there was no temporary mask the traps were accumulated into.
@@ -1670,16 +100,13 @@ _glamor_trapezoids(CARD8 op,
         for (; ntrap; ntrap--, traps++)
             glamor_trapezoids(op, src, dst, mask_format, x_src,
                               y_src, 1, traps);
-        return TRUE;
+        return;
     }
 
-    has_large_trapezoid = _glamor_trapezoid_bounds(ntrap, traps, &bounds);
-    DEBUGF("The bounds for all traps is: bounds.x1 = %d, bounds.x2 = %d, "
-           "bounds.y1 = %d, bounds.y2 = %d, ---- ntrap = %d\n", bounds.x1,
-           bounds.x2, bounds.y1, bounds.y2, ntrap);
+    miTrapezoidBounds(ntrap, traps, &bounds);
 
     if (bounds.y1 >= bounds.y2 || bounds.x1 >= bounds.x2)
-        return TRUE;
+        return;
 
     x_dst = traps[0].left.p1.x >> 16;
     y_dst = traps[0].left.p1.y >> 16;
@@ -1688,85 +115,34 @@ _glamor_trapezoids(CARD8 op,
     height = bounds.y2 - bounds.y1;
     stride = PixmapBytePad(width, mask_format->depth);
 
-#ifdef GLAMOR_TRAPEZOID_SHADER
-    /* We seperate the render to two paths.
-       Some GL implemetation do not implement the Anti-Alias for triangles
-       and polygen's filling. So when the edge is not vertical or horizontal,
-       sawtooth will be obvious. The trapezoid is widely used to render wide
-       lines and circles. In these case, the line or circle will be divided
-       into a large number of small trapezoids to approximate it, so the sawtooth
-       at the edge will cause the result not be acceptable.
-       When the depth of the mask is 1, there is no Anti-Alias needed, so we
-       use the clip logic to generate the result directly(fast path).
-       When the depth is not 1, AA is needed and we use a shader to generate
-       a temp mask pixmap.
-     */
-    if (mask_format->depth == 1) {
-        ret = _glamor_trapezoids_with_shader(op, src, dst, mask_format,
-                                             x_src, y_src, ntrap, traps);
-        if (ret)
-            return TRUE;
-    }
-    else {
-        if (has_large_trapezoid || ntrap > 256) {
-            /* The shader speed is relative slower than pixman when generating big chunk
-               trapezoid mask. We fallback to pixman to improve the performance. */
-            ;
-        }
-        else if (dst->polyMode == PolyModeImprecise) {
-            /*  The precise mode is that we sample the trapezoid on the centre points of
-               an (2*n+1)x(2*n-1) subpixel grid. It is computationally expensive in shader
-               and we use inside area ratio to replace it if the polymode == Imprecise. */
-            picture = glamor_create_mask_picture(screen, dst, mask_format,
-                                                 width, height, 1);
-            if (!picture)
-                return TRUE;
-
-            ret =
-                _glamor_generate_trapezoid_with_shader(screen, picture, traps,
-                                                       ntrap, &bounds);
+    picture = glamor_create_mask_picture(screen, dst, mask_format,
+                                         width, height);
+    if (!picture)
+        return;
 
-            if (!ret)
-                FreePicture(picture, 0);
-        }
+    image = pixman_image_create_bits(picture->format,
+                                     width, height, NULL, stride);
+    if (!image) {
+        FreePicture(picture, 0);
+        return;
     }
-#endif
 
-    if (!ret) {
-        DEBUGF("Fallback to sw rasterize of trapezoid\n");
+    for (; ntrap; ntrap--, traps++)
+        pixman_rasterize_trapezoid(image,
+                                   (pixman_trapezoid_t *) traps,
+                                   -bounds.x1, -bounds.y1);
 
-        picture = glamor_create_mask_picture(screen, dst, mask_format,
-                                             width, height, 0);
-        if (!picture)
-            return TRUE;
-
-        image = pixman_image_create_bits(picture->format,
-                                         width, height, NULL, stride);
-        if (!image) {
-            FreePicture(picture, 0);
-            return TRUE;
-        }
-
-        for (; ntrap; ntrap--, traps++)
-            pixman_rasterize_trapezoid(image,
-                                       (pixman_trapezoid_t *) traps,
-                                       -bounds.x1, -bounds.y1);
+    pixmap = glamor_get_drawable_pixmap(picture->pDrawable);
 
-        pixmap = glamor_get_drawable_pixmap(picture->pDrawable);
-
-        screen->ModifyPixmapHeader(pixmap, width, height,
-                                   mask_format->depth,
-                                   BitsPerPixel(mask_format->depth),
-                                   PixmapBytePad(width,
-                                                 mask_format->depth),
-                                   pixman_image_get_data(image));
-    }
+    screen->ModifyPixmapHeader(pixmap, width, height,
+                               mask_format->depth,
+                               BitsPerPixel(mask_format->depth),
+                               PixmapBytePad(width,
+                                             mask_format->depth),
+                               pixman_image_get_data(image));
 
     x_rel = bounds.x1 + x_src - x_dst;
     y_rel = bounds.y1 + y_src - y_dst;
-    DEBUGF("x_src = %d, y_src = %d, x_dst = %d, y_dst = %d, "
-           "x_rel = %d, y_rel = %d\n", x_src, y_src, x_dst,
-           y_dst, x_rel, y_rel);
 
     CompositePicture(op, src, picture, dst,
                      x_rel, y_rel,
@@ -1778,19 +154,6 @@ _glamor_trapezoids(CARD8 op,
         pixman_image_unref(image);
 
     FreePicture(picture, 0);
-    return TRUE;
-}
-
-void
-glamor_trapezoids(CARD8 op,
-                  PicturePtr src, PicturePtr dst,
-                  PictFormatPtr mask_format, INT16 x_src, INT16 y_src,
-                  int ntrap, xTrapezoid *traps)
-{
-    DEBUGF("x_src = %d, y_src = %d, ntrap = %d\n", x_src, y_src, ntrap);
-
-    _glamor_trapezoids(op, src, dst, mask_format, x_src,
-                       y_src, ntrap, traps, TRUE);
 }
 
 Bool
@@ -1801,8 +164,9 @@ glamor_trapezoids_nf(CARD8 op,
 {
     DEBUGF("x_src = %d, y_src = %d, ntrap = %d\n", x_src, y_src, ntrap);
 
-    return _glamor_trapezoids(op, src, dst, mask_format, x_src,
-                              y_src, ntrap, traps, FALSE);
+    glamor_trapezoids(op, src, dst, mask_format, x_src,
+                      y_src, ntrap, traps);
+    return TRUE;
 }
 
 #endif                          /* RENDER */
commit b2452311bd1d67b4d78612570d4a25c685c78a0c
Author: Keith Packard <keithp at keithp.com>
Date:   Tue Aug 19 12:52:05 2014 -0700

    glamor: Check large pixmap users in glamor_largepixmap.c
    
    This enables the assertion that all users of the large pixmap member
    are restricted to pixmaps which are actually large.
    
    Signed-off-by: Keith Packard <keithp at keithp.com>
    Reviewed-by: Adam Jackson <ajax at redhat.com>

diff --git a/glamor/glamor_largepixmap.c b/glamor/glamor_largepixmap.c
index ce38809..9b24584 100644
--- a/glamor/glamor_largepixmap.c
+++ b/glamor/glamor_largepixmap.c
@@ -4,9 +4,7 @@
 
 static inline glamor_pixmap_private_large_t *
 __glamor_large(glamor_pixmap_private *pixmap_priv) {
-#if 0
     assert(pixmap_priv->type == GLAMOR_TEXTURE_LARGE);
-#endif
     return &pixmap_priv->large;
 }
 
commit 5fc3e99f537b10dd9c2adfd37cf2c4ba5ed4bd44
Author: Keith Packard <keithp at keithp.com>
Date:   Tue Aug 19 12:44:41 2014 -0700

    glamor: Handle compositing from large to small pixmaps
    
    glamor_composite_largepixmap_region is given the job of dealing with
    compositing between a mixture of large and small pixmaps. However, it
    was assuming that the destination pixmap was large and fetching
    members of the large structure even for small pixmaps.
    
    This manifested with assertion failures when compositing from a large
    pixmap to a small pixmap.
    
    Fixed by using the pixmap size for the destination block size for
    small pixmaps.
    
    Signed-off-by: Keith Packard <keithp at keithp.com>
    Reviewed-by: Adam Jackson <ajax at redhat.com>

diff --git a/glamor/glamor_largepixmap.c b/glamor/glamor_largepixmap.c
index ad6a090..ce38809 100644
--- a/glamor/glamor_largepixmap.c
+++ b/glamor/glamor_largepixmap.c
@@ -1041,6 +1041,7 @@ glamor_composite_largepixmap_region(CARD8 op,
     int is_normal_source_fbo = 0;
     int is_normal_mask_fbo = 0;
     int fixed_block_width, fixed_block_height;
+    int dest_block_width, dest_block_height;
     int null_source, null_mask;
     glamor_pixmap_private *need_free_source_pixmap_priv = NULL;
     glamor_pixmap_private *need_free_mask_pixmap_priv = NULL;
@@ -1057,8 +1058,16 @@ glamor_composite_largepixmap_region(CARD8 op,
     else
         mask_repeat_type = RepeatNone;
 
-    fixed_block_width = dest_pixmap_priv->large.block_w;
-    fixed_block_height = dest_pixmap_priv->large.block_h;
+    if (dest_pixmap_priv->type == GLAMOR_TEXTURE_LARGE) {
+        dest_block_width = __glamor_large(dest_pixmap_priv)->block_w;
+        dest_block_height = __glamor_large(dest_pixmap_priv)->block_h;
+    } else {
+        dest_block_width = dest_pixmap_priv->base.pixmap->drawable.width;
+        dest_block_height = dest_pixmap_priv->base.pixmap->drawable.height;
+    }
+    fixed_block_width = dest_block_width;
+    fixed_block_height = dest_block_height;
+
     /* If we got an totally out-of-box region for a source or mask
      * region without repeat, we need to set it as null_source and
      * give it a solid color (0,0,0,0). */
@@ -1124,8 +1133,8 @@ glamor_composite_largepixmap_region(CARD8 op,
 
     /*compute the correct block width and height whose transformed source/mask
      *region can fit into one texture.*/
-    if (force_clip || fixed_block_width < dest_pixmap_priv->large.block_w
-        || fixed_block_height < dest_pixmap_priv->large.block_h)
+    if (force_clip || fixed_block_width < dest_block_width
+        || fixed_block_height < dest_block_height)
         clipped_dest_regions =
             glamor_compute_clipped_regions_ext(dest_pixmap_priv, region,
                                                &n_dest_regions,
commit 6e78d7f5e6edf56180e2ecfd25300bb2523876ab
Author: Keith Packard <keithp at keithp.com>
Date:   Tue Aug 19 12:41:45 2014 -0700

    glamor: Don't abuse large_pixmap members for regular pixmaps
    
    glamor_compute_clipped_regions_ext wants to treat small and large
    pixmaps uniformly and did that by writing into the large pixmap
    union member in small pixmaps to construct something that looks like a
    one texture large pixmap.
    
    Instead of doing that, simply allocate the necessary elements locally
    on the stack and use them from there.
    
    Signed-off-by: Keith Packard <keithp at keithp.com>
    Reviewed-by: Adam Jackson <ajax at redhat.com>

diff --git a/glamor/glamor_largepixmap.c b/glamor/glamor_largepixmap.c
index e3a1e82..ad6a090 100644
--- a/glamor/glamor_largepixmap.c
+++ b/glamor/glamor_largepixmap.c
@@ -162,9 +162,9 @@ glamor_compute_clipped_regions_ext(glamor_pixmap_private *pixmap_priv,
         *result_regions;
     int i, j, x, y, k, inner_n_regions;
     int width, height;
-    glamor_pixmap_private_large_t *priv;
-
-    priv = &pixmap_priv->large;
+    BoxPtr box_array;
+    BoxRec small_box;
+    int block_w, block_h;
 
     DEBUGF("ext called \n");
 
@@ -178,14 +178,16 @@ glamor_compute_clipped_regions_ext(glamor_pixmap_private *pixmap_priv,
         clipped_regions[0].block_idx = 0;
         RegionCopy(clipped_regions[0].region, region);
         *n_region = 1;
-        priv->block_w = priv->base.pixmap->drawable.width;
-        priv->block_h = priv->base.pixmap->drawable.height;
-        priv->box_array = &priv->box;
-        priv->box.x1 = priv->box.y1 = 0;
-        priv->box.x2 = priv->block_w;
-        priv->box.y2 = priv->block_h;
+        block_w = pixmap_priv->base.pixmap->drawable.width;
+        block_h = pixmap_priv->base.pixmap->drawable.height;
+        box_array = &small_box;
+        small_box.x1 = small_box.y1 = 0;
+        small_box.x2 = block_w;
+        small_box.y2 = block_h;
     }
     else {
+        glamor_pixmap_private_large_t *priv = __glamor_large(pixmap_priv);
+
         clipped_regions = __glamor_compute_clipped_regions(priv->block_w,
                                                            priv->block_h,
                                                            priv->block_wcnt,
@@ -201,20 +203,23 @@ glamor_compute_clipped_regions_ext(glamor_pixmap_private *pixmap_priv,
             *n_region = 0;
             return NULL;
         }
+        block_w = priv->block_w;
+        block_h = priv->block_h;
+        box_array = priv->box_array;
     }
-    if (inner_block_w >= priv->block_w && inner_block_h >= priv->block_h)
+    if (inner_block_w >= block_w && inner_block_h >= block_h)
         return clipped_regions;
     result_regions = calloc(*n_region
-                            * ((priv->block_w + inner_block_w - 1) /
+                            * ((block_w + inner_block_w - 1) /
                                inner_block_w)
-                            * ((priv->block_h + inner_block_h - 1) /
+                            * ((block_h + inner_block_h - 1) /
                                inner_block_h), sizeof(*result_regions));
     k = 0;
     for (i = 0; i < *n_region; i++) {
-        x = priv->box_array[clipped_regions[i].block_idx].x1;
-        y = priv->box_array[clipped_regions[i].block_idx].y1;
-        width = priv->box_array[clipped_regions[i].block_idx].x2 - x;
-        height = priv->box_array[clipped_regions[i].block_idx].y2 - y;
+        x = box_array[clipped_regions[i].block_idx].x1;
+        y = box_array[clipped_regions[i].block_idx].y1;
+        width = box_array[clipped_regions[i].block_idx].x2 - x;
+        height = box_array[clipped_regions[i].block_idx].y2 - y;
         inner_regions = __glamor_compute_clipped_regions(inner_block_w,
                                                          inner_block_h,
                                                          0, x, y,
commit bab319763c9734da3cff7b91a582f54989dc4cbe
Author: Keith Packard <keithp at keithp.com>
Date:   Tue Aug 19 12:39:07 2014 -0700

    glamor: Add macro __glamor_large in glamor_largepixmap.c
    
    For now, this simply fetches the large member of the pixmap private.
    It will be changed to assert that the pixmap is large once bugs
    related to that have been fixed.
    
    Signed-off-by: Keith Packard <keithp at keithp.com>
    Reviewed-by: Adam Jackson <ajax at redhat.com>

diff --git a/glamor/glamor_largepixmap.c b/glamor/glamor_largepixmap.c
index 4c82a8d..e3a1e82 100644
--- a/glamor/glamor_largepixmap.c
+++ b/glamor/glamor_largepixmap.c
@@ -2,6 +2,14 @@
 
 #include "glamor_priv.h"
 
+static inline glamor_pixmap_private_large_t *
+__glamor_large(glamor_pixmap_private *pixmap_priv) {
+#if 0
+    assert(pixmap_priv->type == GLAMOR_TEXTURE_LARGE);
+#endif
+    return &pixmap_priv->large;
+}
+
 /**
  * Clip the boxes regards to each pixmap's block array.
  *
@@ -343,8 +351,6 @@ _glamor_compute_clipped_regions(glamor_pixmap_private *pixmap_priv,
     int x_center_shift = 0, y_center_shift = 0;
     glamor_pixmap_private_large_t *priv;
 
-    priv = &pixmap_priv->large;
-
     DEBUGRegionPrint(region);
     if (pixmap_priv->type != GLAMOR_TEXTURE_LARGE) {
         clipped_regions = calloc(1, sizeof(*clipped_regions));
@@ -355,6 +361,8 @@ _glamor_compute_clipped_regions(glamor_pixmap_private *pixmap_priv,
         return clipped_regions;
     }
 
+    priv = __glamor_large(pixmap_priv);
+
     pixmap_width = priv->base.pixmap->drawable.width;
     pixmap_height = priv->base.pixmap->drawable.height;
     if (repeat_type == 0 || repeat_type == RepeatPad) {
@@ -751,7 +759,7 @@ glamor_merge_clipped_regions(glamor_pixmap_private *pixmap_priv,
     int pixmap_width, pixmap_height;
     glamor_pixmap_private_large_t *priv;
 
-    priv = &pixmap_priv->large;
+    priv = __glamor_large(pixmap_priv);
     pixmap_width = priv->base.pixmap->drawable.width;
     pixmap_height = priv->base.pixmap->drawable.height;
 
@@ -985,15 +993,15 @@ _glamor_process_transformed_clipped_region(glamor_pixmap_private *priv,
             shift_y = (temp_box->y1 - rem) / priv->base.pixmap->drawable.height;
 
             if (shift_x != 0) {
-                priv->large.box.x1 +=
+                __glamor_large(priv)->box.x1 +=
                     shift_x * priv->base.pixmap->drawable.width;
-                priv->large.box.x2 +=
+                __glamor_large(priv)->box.x2 +=
                     shift_x * priv->base.pixmap->drawable.width;
             }
             if (shift_y != 0) {
-                priv->large.box.y1 +=
+                __glamor_large(priv)->box.y1 +=
                     shift_y * priv->base.pixmap->drawable.height;
-                priv->large.box.y2 +=
+                __glamor_large(priv)->box.y2 +=
                     shift_y * priv->base.pixmap->drawable.height;
             }
         }
@@ -1071,8 +1079,8 @@ glamor_composite_largepixmap_region(CARD8 op,
         int source_transformed_block_width, source_transformed_block_height;
 
         if (!glamor_get_transform_block_size(source->transform,
-                                             source_pixmap_priv->large.block_w,
-                                             source_pixmap_priv->large.block_h,
+                                             __glamor_large(source_pixmap_priv)->block_w,
+                                             __glamor_large(source_pixmap_priv)->block_h,
                                              &source_transformed_block_width,
                                              &source_transformed_block_height))
         {
@@ -1093,8 +1101,8 @@ glamor_composite_largepixmap_region(CARD8 op,
         int mask_transformed_block_width, mask_transformed_block_height;
 
         if (!glamor_get_transform_block_size(mask->transform,
-                                             mask_pixmap_priv->large.block_w,
-                                             mask_pixmap_priv->large.block_h,
+                                             __glamor_large(mask_pixmap_priv)->block_w,
+                                             __glamor_large(mask_pixmap_priv)->block_h,
                                              &mask_transformed_block_width,
                                              &mask_transformed_block_height)) {
             DEBUGF("mask block size less than 1, fallback.\n");
@@ -1271,8 +1279,8 @@ glamor_composite_largepixmap_region(CARD8 op,
                                                    clipped_mask_regions[k].
                                                    block_idx);
                             DEBUGF("mask fbo off %d %d \n",
-                                   mask_pixmap_priv->large.box.x1,
-                                   mask_pixmap_priv->large.box.y1);
+                                   __glamor_large(mask_pixmap_priv)->box.x1,
+                                   __glamor_large(mask_pixmap_priv)->box.y1);
                             DEBUGF("start composite mask hasn't transform.\n");
                             RegionTranslate(clipped_mask_regions[k].region,
                                             x_dest - x_mask +
commit 16e429f1f96f984b1ff575875a7a4d7d29b482e2
Author: Keith Packard <keithp at keithp.com>
Date:   Tue Aug 19 12:34:41 2014 -0700

    glamor: Change SET_PIXMAP_FBO_CURRENT from macro to static inline
    
    This is the last function-like macro in glamor_priv.h; change to
    static inline like all of the other functions there.
    
    Signed-off-by: Keith Packard <keithp at keithp.com>
    Reviewed-by: Adam Jackson <ajax at redhat.com>

diff --git a/glamor/glamor_largepixmap.c b/glamor/glamor_largepixmap.c
index 5a4bec5..4c82a8d 100644
--- a/glamor/glamor_largepixmap.c
+++ b/glamor/glamor_largepixmap.c
@@ -970,7 +970,7 @@ _glamor_process_transformed_clipped_region(glamor_pixmap_private *priv,
                                      need_clean_fbo);
     }
     else {
-        SET_PIXMAP_FBO_CURRENT(priv, clipped_regions[0].block_idx);
+        glamor_set_pixmap_fbo_current(priv, clipped_regions[0].block_idx);
         if (repeat_type == RepeatReflect || repeat_type == RepeatNormal) {
             /* The required source areas are in one region,
              * we need to shift the corresponding box's coords to proper position,
@@ -1140,7 +1140,7 @@ glamor_composite_largepixmap_region(CARD8 op,
         DEBUGF("dest region %d  idx %d\n", i,
                clipped_dest_regions[i].block_idx);
         DEBUGRegionPrint(clipped_dest_regions[i].region);
-        SET_PIXMAP_FBO_CURRENT(dest_pixmap_priv,
+        glamor_set_pixmap_fbo_current(dest_pixmap_priv,
                                clipped_dest_regions[i].block_idx);
         if (source_pixmap_priv &&
             source_pixmap_priv->type == GLAMOR_TEXTURE_LARGE) {
@@ -1180,7 +1180,7 @@ glamor_composite_largepixmap_region(CARD8 op,
             DEBUGF("source clipped result %d region: \n", n_source_regions);
             for (j = 0; j < n_source_regions; j++) {
                 if (is_normal_source_fbo)
-                    SET_PIXMAP_FBO_CURRENT(source_pixmap_priv,
+                    glamor_set_pixmap_fbo_current(source_pixmap_priv,
                                            clipped_source_regions[j].block_idx);
 
                 if (mask_pixmap_priv &&
@@ -1267,7 +1267,7 @@ glamor_composite_largepixmap_region(CARD8 op,
                                clipped_mask_regions[k].block_idx);
                         DEBUGRegionPrint(clipped_mask_regions[k].region);
                         if (is_normal_mask_fbo) {
-                            SET_PIXMAP_FBO_CURRENT(mask_pixmap_priv,
+                            glamor_set_pixmap_fbo_current(mask_pixmap_priv,
                                                    clipped_mask_regions[k].
                                                    block_idx);
                             DEBUGF("mask fbo off %d %d \n",
@@ -1378,7 +1378,7 @@ glamor_composite_largepixmap_region(CARD8 op,
                            clipped_mask_regions[k].block_idx);
                     DEBUGRegionPrint(clipped_mask_regions[k].region);
                     if (is_normal_mask_fbo) {
-                        SET_PIXMAP_FBO_CURRENT(mask_pixmap_priv,
+                        glamor_set_pixmap_fbo_current(mask_pixmap_priv,
                                                clipped_mask_regions[k].
                                                block_idx);
                         RegionTranslate(clipped_mask_regions[k].region,
diff --git a/glamor/glamor_pixmap.c b/glamor/glamor_pixmap.c
index ccb49f3..11e9ebb 100644
--- a/glamor/glamor_pixmap.c
+++ b/glamor/glamor_pixmap.c
@@ -985,7 +985,7 @@ glamor_upload_sub_pixmap_to_texture(PixmapPtr pixmap, int x, int y, int w,
 
             assert(pbo == 0);
 
-            SET_PIXMAP_FBO_CURRENT(pixmap_priv, clipped_regions[i].block_idx);
+            glamor_set_pixmap_fbo_current(pixmap_priv, clipped_regions[i].block_idx);
 
             boxes = RegionRects(clipped_regions[i].region);
             nbox = RegionNumRects(clipped_regions[i].region);
diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h
index aa59e3b..51adeef 100644
--- a/glamor/glamor_priv.h
+++ b/glamor/glamor_priv.h
@@ -438,14 +438,6 @@ typedef struct glamor_pixmap_clipped_regions {
     RegionPtr region;
 } glamor_pixmap_clipped_regions;
 
-#define SET_PIXMAP_FBO_CURRENT(priv, idx) 				\
-  do {									\
-	if (priv->type == GLAMOR_TEXTURE_LARGE) {			\
-		(priv)->large.base.fbo = priv->large.fbo_array[idx]; 	\
-		(priv)->large.box = priv->large.box_array[idx]; 	\
-	}								\
-  } while(0)
-
 typedef struct glamor_pixmap_private_base {
     glamor_pixmap_type_t type;
     enum glamor_fbo_state gl_fbo;
@@ -518,6 +510,15 @@ typedef struct glamor_pixmap_private {
     };
 } glamor_pixmap_private;
 
+static inline void
+glamor_set_pixmap_fbo_current(glamor_pixmap_private *priv, int idx)
+{
+    if (priv->type == GLAMOR_TEXTURE_LARGE) {
+        priv->large.base.fbo = priv->large.fbo_array[idx];
+        priv->large.box = priv->large.box_array[idx];
+    }
+}
+
 static inline glamor_pixmap_fbo *
 glamor_pixmap_fbo_at(glamor_pixmap_private *priv, int x, int y)
 {
commit ea7357de90792cbceca6d8d9fdc144e7df8a0fba
Author: Keith Packard <keithp at keithp.com>
Date:   Wed Sep 10 14:01:59 2014 -0700

    present: Clear pending flip pixmaps at CloseScreen
    
    If a flip is active at server reset time, the associated window will
    get destroyed which will queue an unflip operation. If that isn't
    synchronous, then it won't have finished by the time CloseScreen is
    called.
    
    Calling present_flip_idle will signal the fence and remove the
    reference to the fence and pixmap, freeing these in the X server and
    allowing a DRM client to clean up as well.
    
    This also rewords other comments in present_flip_destroy, removing
    scary words about needing synchronous operation (everything in this
    function is synchronous now) and describing what effect we actually
    need from present_set_abort_flip.
    
    Signed-off-by: Keith Packard <keithp at keithp.com>
    Reviewed-by: Adam Jackson <ajax at redhat.com>

diff --git a/present/present.c b/present/present.c
index 9be690c..e838da7 100644
--- a/present/present.c
+++ b/present/present.c
@@ -938,11 +938,12 @@ present_flip_destroy(ScreenPtr screen)
 {
     present_screen_priv_ptr     screen_priv = present_screen_priv(screen);
 
-    /* XXX this needs to be synchronous for server reset */
-
-    /* Do the actual cleanup once the flip has been performed by the hardware */
+    /* Reset window pixmaps back to the screen pixmap */
     if (screen_priv->flip_pending)
         present_set_abort_flip(screen);
+
+    /* Drop reference to any pending flip or unflip pixmaps. */
+    present_flip_idle(screen);
 }
 
 void
commit 2051514652481a83bd7cf22e57cb0fcd40333f33
Author: Keith Packard <keithp at keithp.com>
Date:   Wed Sep 10 14:02:13 2014 -0700

    present: Support PresentOptionCopy
    
    We added this option to the present protocol before 1.0 but somehow
    never implemented it in the server. It's pretty simple; just don't
    ever do flips if the application specifies Copy.
    
    Signed-off-by: Keith Packard <keithp at keithp.com>
    Reviewed-by: Adam Jackson <ajax at redhat.com>

diff --git a/present/present.c b/present/present.c
index f488e21..9be690c 100644
--- a/present/present.c
+++ b/present/present.c
@@ -837,7 +837,10 @@ present_pixmap(WindowPtr window,
     if (!screen_priv->info || !(screen_priv->info->capabilities & PresentCapabilityAsync))
         vblank->sync_flip = TRUE;
 
-    if (pixmap && present_check_flip (target_crtc, window, pixmap, vblank->sync_flip, valid, x_off, y_off)) {
+    if (!(options & PresentOptionCopy) &&
+        pixmap != NULL &&
+        present_check_flip (target_crtc, window, pixmap, vblank->sync_flip, valid, x_off, y_off))
+    {
         vblank->flip = TRUE;
         if (vblank->sync_flip)
             target_msc--;
commit 69d8572ae4cd1bce17223ea8aff87916a974c861
Author: Keith Packard <keithp at keithp.com>
Date:   Wed Sep 10 15:21:32 2014 -0700

    Build required portions of registry.c automatically [v2]
    
    Instead of making the inclusion of the registry code a global
    conditional, split the registry into two pieces; the bits required by
    the X-Resource extension (the resource names) and the bits required by
    the XCSECURITY extension (the protocol names). Build each set of code
    if the related extension is being built.
    
    v2: Check for both XCSECURITY and XSELINUX.
    
    Signed-off-by: Keith Packard <keithp at keithp.com>
    Reviewed-by: Adam Jackson <ajax at redhat.com>

diff --git a/configure.ac b/configure.ac
index 140fb97..be8bff6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -564,7 +564,6 @@ AC_ARG_WITH(khronos-spec-dir, AS_HELP_STRING([--with-khronos-spec-dir=PATH], [Pa
 				[KHRONOS_SPEC_DIR=auto])
 
 dnl Extensions.
-AC_ARG_ENABLE(registry,       AS_HELP_STRING([--disable-registry], [Build string registry module (default: enabled)]), [XREGISTRY=$enableval], [XREGISTRY=yes])
 AC_ARG_ENABLE(composite,      AS_HELP_STRING([--disable-composite], [Build Composite extension (default: enabled)]), [COMPOSITE=$enableval], [COMPOSITE=yes])
 AC_ARG_ENABLE(mitshm,         AS_HELP_STRING([--disable-mitshm], [Build SHM extension (default: auto)]), [MITSHM=$enableval], [MITSHM=auto])
 AC_ARG_ENABLE(xres,           AS_HELP_STRING([--disable-xres], [Build XRes extension (default: enabled)]), [RES=$enableval], [RES=yes])
@@ -1016,11 +1015,6 @@ if test "x$XVMC" = xyes; then
 	AC_DEFINE(XvMCExtension, 1, [Build XvMC extension])
 fi
 
-AM_CONDITIONAL(XREGISTRY, [test "x$XREGISTRY" = xyes])
-if test "x$XREGISTRY" = xyes; then
-	AC_DEFINE(XREGISTRY, 1, [Build registry module])
-fi
-
 AM_CONDITIONAL(COMPOSITE, [test "x$COMPOSITE" = xyes])
 if test "x$COMPOSITE" = xyes; then
 	AC_DEFINE(COMPOSITE, 1, [Support Composite Extension])
diff --git a/dix/extension.c b/dix/extension.c
index ede4bf5..e43291e 100644
--- a/dix/extension.c
+++ b/dix/extension.c
@@ -139,7 +139,9 @@ AddExtension(const char *name, int NumEvents, int NumErrors,
         ext->errorLast = 0;
     }
 
+#ifdef X_REGISTRY_REQUEST
     RegisterExtensionNames(ext);
+#endif
     return ext;
 }
 
diff --git a/dix/registry.c b/dix/registry.c
index 8b76d56..84d48b4 100644
--- a/dix/registry.c
+++ b/dix/registry.c
@@ -21,8 +21,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include <dix-config.h>
 #endif
 
-#ifdef XREGISTRY
-
 #include <stdlib.h>
 #include <string.h>
 #include <X11/X.h>
@@ -31,6 +29,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "registry.h"
 
 #define BASE_SIZE 16
+
+#ifdef X_REGISTRY_REQUEST
 #define CORE "X11"
 #define FILENAME SERVER_MISC_CONFIG_PATH "/protocol.txt"
 
@@ -42,9 +42,15 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 static FILE *fh;
 
 static char ***requests, **events, **errors;
+static unsigned nmajor, *nminor, nevent, nerror;
+#endif
+
+#ifdef X_REGISTRY_RESOURCE
 static const char **resources;
-static unsigned nmajor, *nminor, nevent, nerror, nresource;
+static unsigned nresource;
+#endif
 
+#if defined(X_REGISTRY_RESOURCE) || defined(X_REGISTRY_REQUEST)
 /*
  * File parsing routines
  */
@@ -72,7 +78,12 @@ double_size(void *p, unsigned n, unsigned size)
     memset(*ptr + s, 0, f - s);
     return TRUE;
 }
+#endif
 
+#ifdef X_REGISTRY_REQUEST
+/*
+ * Request/event/error registry functions
+ */
 static void
 RegisterRequestName(unsigned major, unsigned minor, char *name)
 {
@@ -197,28 +208,6 @@ RegisterExtensionNames(ExtensionEntry * extEntry)
     }
 }
 
-/*
- * Registration functions
- */
-
-void
-RegisterResourceName(RESTYPE resource, const char *name)
-{
-    resource &= TypeMask;
-
-    while (resource >= nresource) {
-        if (!double_size(&resources, nresource, sizeof(char *)))
-            return;
-        nresource = nresource ? nresource * 2 : BASE_SIZE;
-    }
-
-    resources[resource] = name;
-}
-
-/*
- * Lookup functions
- */
-
 const char *
 LookupRequestName(int major, int minor)
 {
@@ -269,6 +258,26 @@ LookupErrorName(int error)
 
     return errors[error] ? errors[error] : XREGISTRY_UNKNOWN;
 }
+#endif /* X_REGISTRY_REQUEST */
+
+#ifdef X_REGISTRY_RESOURCE
+/*
+ * Resource registry functions
+ */
+
+void
+RegisterResourceName(RESTYPE resource, const char *name)
+{
+    resource &= TypeMask;
+
+    while (resource >= nresource) {
+        if (!double_size(&resources, nresource, sizeof(char *)))
+            return;
+        nresource = nresource ? nresource * 2 : BASE_SIZE;
+    }
+
+    resources[resource] = name;
+}
 
 const char *
 LookupResourceName(RESTYPE resource)
@@ -279,10 +288,12 @@ LookupResourceName(RESTYPE resource)
 
     return resources[resource] ? resources[resource] : XREGISTRY_UNKNOWN;
 }
+#endif /* X_REGISTRY_RESOURCE */
 
 void
 dixFreeRegistry(void)
 {
+#ifdef X_REGISTRY_REQUEST
     /* Free all memory */
     while (nmajor--) {
         while (nminor[nmajor])
@@ -299,25 +310,30 @@ dixFreeRegistry(void)
     while (nerror--)
         free(errors[nerror]);
     free(errors);
-
-    free(resources);
-
     requests = NULL;
     nminor = NULL;
     events = NULL;
     errors = NULL;
-    resources = NULL;
+    nmajor = nevent = nerror = 0;
+#endif
+
+#ifdef X_REGISTRY_RESOURCE
+    free(resources);
 
-    nmajor = nevent = nerror = nresource = 0;
+    resources = NULL;
+    nresource = 0;
+#endif
 }
 
 void
 dixCloseRegistry(void)
 {
+#ifdef X_REGISTRY_REQUEST
     if (fh) {
 	fclose(fh);
         fh = NULL;
     }
+#endif
 }
 
 /*
@@ -326,16 +342,24 @@ dixCloseRegistry(void)
 void
 dixResetRegistry(void)
 {
+#ifdef X_REGISTRY_REQUEST
     ExtensionEntry extEntry = { .name = CORE };
+#endif
 
     dixFreeRegistry();
 
+#ifdef X_REGISTRY_REQUEST
     /* Open the protocol file */
     fh = fopen(FILENAME, "r");
     if (!fh)
         LogMessage(X_WARNING,
                    "Failed to open protocol names file " FILENAME "\n");
 
+    /* Add the core protocol */
+    RegisterExtensionNames(&extEntry);
+#endif
+
+#ifdef X_REGISTRY_RESOURCE
     /* Add built-in resources */
     RegisterResourceName(RT_NONE, "NONE");
     RegisterResourceName(RT_WINDOW, "WINDOW");
@@ -347,9 +371,5 @@ dixResetRegistry(void)
     RegisterResourceName(RT_CMAPENTRY, "COLORMAP ENTRY");
     RegisterResourceName(RT_OTHERCLIENT, "OTHER CLIENT");
     RegisterResourceName(RT_PASSIVEGRAB, "PASSIVE GRAB");
-
-    /* Add the core protocol */
-    RegisterExtensionNames(&extEntry);
+#endif
 }
-
-#endif                          /* XREGISTRY */
diff --git a/dix/resource.c b/dix/resource.c
index 623d862..c254244 100644
--- a/dix/resource.c
+++ b/dix/resource.c
@@ -524,8 +524,10 @@ CreateNewResourceType(DeleteType deleteFunc, const char *name)
     resourceTypes[next].findSubResFunc = DefaultFindSubRes;
     resourceTypes[next].errorValue = BadValue;
 
+#if X_REGISTRY_RESOURCE
     /* Called even if name is NULL, to remove any previous entry */
     RegisterResourceName(next, name);
+#endif
 
     return next;
 }
diff --git a/include/registry.h b/include/registry.h
index 4e54bf6..43c3db3 100644
--- a/include/registry.h
+++ b/include/registry.h
@@ -17,18 +17,26 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
 #define XREGISTRY_UNKNOWN "<unknown>"
 
-#ifdef XREGISTRY
-
 #include "resource.h"
 #include "extnsionst.h"
 
+#if defined(XSELINUX) || defined(RES)
+#define X_REGISTRY_RESOURCE       1
+#endif
+
+#if defined(XSELINUX) || defined(XCSECURITY)
+#define X_REGISTRY_REQUEST        1
+#endif
+
 /* Internal string registry - for auditing, debugging, security, etc. */
 
-/*
- * Registration functions.  The name string is not copied, so it must
- * not be a stack variable.
- */
+#ifdef X_REGISTRY_RESOURCE
+/* Functions used by the X-Resource extension */
 extern _X_EXPORT void RegisterResourceName(RESTYPE type, const char *name);
+extern _X_EXPORT const char *LookupResourceName(RESTYPE rtype);
+#endif
+
+#ifdef X_REGISTRY_REQUEST
 extern _X_EXPORT void RegisterExtensionNames(ExtensionEntry * ext);
 
 /*
@@ -38,7 +46,7 @@ extern _X_EXPORT const char *LookupMajorName(int major);
 extern _X_EXPORT const char *LookupRequestName(int major, int minor);
 extern _X_EXPORT const char *LookupEventName(int event);
 extern _X_EXPORT const char *LookupErrorName(int error);
-extern _X_EXPORT const char *LookupResourceName(RESTYPE rtype);
+#endif
 
 /*
  * Setup and teardown
@@ -47,21 +55,4 @@ extern _X_EXPORT void dixResetRegistry(void);
 extern _X_EXPORT void dixFreeRegistry(void);
 extern _X_EXPORT void dixCloseRegistry(void);
 
-#else                           /* XREGISTRY */
-
-/* Define calls away when the registry is not being built. */
-
-#define RegisterResourceName(a, b) { ; }
-#define RegisterExtensionNames(a) { ; }
-
-#define LookupMajorName(a) XREGISTRY_UNKNOWN
-#define LookupRequestName(a, b) XREGISTRY_UNKNOWN
-#define LookupEventName(a) XREGISTRY_UNKNOWN
-#define LookupErrorName(a) XREGISTRY_UNKNOWN
-#define LookupResourceName(a) XREGISTRY_UNKNOWN
-
-#define dixResetRegistry() { ; }
-#define dixFreeRegistry() { ; }
-
-#endif                          /* XREGISTRY */
 #endif                          /* DIX_REGISTRY_H */
commit a11fc2493e85e4a532f4954805a7c6d1c601b08f
Author: Keith Packard <keithp at keithp.com>
Date:   Wed Sep 10 15:04:00 2014 -0700

    dix: Close protocol.txt after we're done loading extension names
    
    Don't leave this file open during the whole server execution process;
    close it once all of the extensions are initialized.
    
    Signed-off-by: Keith Packard <keithp at keithp.com>
    Reviewed-by: Adam Jackson <ajax at redhat.com>

diff --git a/dix/main.c b/dix/main.c
index 7427e08..930a85f 100644
--- a/dix/main.c
+++ b/dix/main.c
@@ -269,6 +269,8 @@ dix_main(int argc, char *argv[], char *envp[])
 
         dixSaveScreens(serverClient, SCREEN_SAVER_FORCER, ScreenSaverReset);
 
+        dixCloseRegistry();
+
 #ifdef PANORAMIX
         if (!noPanoramiXExtension) {
             if (!PanoramiXCreateConnectionBlock()) {
diff --git a/dix/registry.c b/dix/registry.c
index 82a3340..8b76d56 100644
--- a/dix/registry.c
+++ b/dix/registry.c
@@ -309,7 +309,11 @@ dixFreeRegistry(void)
     resources = NULL;
 
     nmajor = nevent = nerror = nresource = 0;
+}
 
+void
+dixCloseRegistry(void)
+{
     if (fh) {
 	fclose(fh);
         fh = NULL;
diff --git a/include/registry.h b/include/registry.h
index 96be87a..4e54bf6 100644
--- a/include/registry.h
+++ b/include/registry.h
@@ -45,6 +45,7 @@ extern _X_EXPORT const char *LookupResourceName(RESTYPE rtype);
  */
 extern _X_EXPORT void dixResetRegistry(void);
 extern _X_EXPORT void dixFreeRegistry(void);
+extern _X_EXPORT void dixCloseRegistry(void);
 
 #else                           /* XREGISTRY */
 
commit 9e07f3a3d28b01402beecb3280c94fc525bd8075
Author: Keith Packard <keithp at keithp.com>
Date:   Wed Sep 10 15:41:08 2014 -0700

    test: Only build hashtable tests if building X-Resource extension
    
    The hash table functions are only included in the server when the
    X-Resource extension is built, so don't try to build and test them
    unless the X-Resource extension is being built.
    
    Signed-off-by: Keith Packard <keithp at keithp.com>
    Reviewed-by: Adam Jackson <ajax at redhat.com>

diff --git a/test/Makefile.am b/test/Makefile.am
index 32edc7a..8344276 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -5,7 +5,10 @@ if XORG
 # Tests that require at least some DDX functions in order to fully link
 # For now, requires xf86 ddx, could be adjusted to use another
 SUBDIRS += xi2
-noinst_PROGRAMS += xkb input xtest misc fixes xfree86 hashtabletest os signal-logging touch
+noinst_PROGRAMS += xkb input xtest misc fixes xfree86 os signal-logging touch
+if RES
+noinst_PROGRAMS += hashtabletest
+endif
 endif
 check_LTLIBRARIES = libxservertest.la
 
commit 670ee0757febfb965d718fce2d5688717def667d
Author: Adam Jackson <ajax at redhat.com>
Date:   Tue Sep 16 11:10:58 2014 -0400

    ephyr: Properly implement hardware cursors (v3)
    
    When dix hands us a new cursor we proxy it through to the host server;
    since we keep the host XID on the cursor bits private we can switch
    among them with just ChangeWindowAttributes.
    
    v2:
    Use xcb-renderutil for argb format lookup (Uli, Keith)
    Fall back to core cursors for host RENDER < 0.5 (Keith)
    Drop useless ephyrEnableCursor
    Consistently create/destroy the cursor image GC on both paths
    Treat null cursor from dix as invisible
    
    v3:
    Initialize the invisible cursor's image (Keith)
    
    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/configure.ac b/configure.ac
index 0d6c232..140fb97 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2349,7 +2349,7 @@ if test "$KDRIVE" = yes; then
        AC_DEFINE(KDRIVE_MOUSE, 1, [Enable KDrive mouse driver])
     fi
 
-    XEPHYR_REQUIRED_LIBS="xau xdmcp xcb xcb-shape xcb-aux xcb-image xcb-icccm xcb-shm xcb-keysyms xcb-randr"
+    XEPHYR_REQUIRED_LIBS="xau xdmcp xcb xcb-shape xcb-render xcb-renderutil xcb-aux xcb-image xcb-icccm xcb-shm xcb-keysyms xcb-randr"
     if test "x$XV" = xyes; then
         XEPHYR_REQUIRED_LIBS="$XEPHYR_REQUIRED_LIBS xcb-xv"
     fi
diff --git a/hw/kdrive/ephyr/Makefile.am b/hw/kdrive/ephyr/Makefile.am
index 10c5917..155e11e 100644
--- a/hw/kdrive/ephyr/Makefile.am
+++ b/hw/kdrive/ephyr/Makefile.am
@@ -68,6 +68,7 @@ Xephyr_SOURCES = \
 	ephyr_draw.c \
 	os.c \
 	ephyrinit.c \
+	ephyrcursor.c \
 	hostx.c \
 	hostx.h \
 	$(XV_SRCS) \
diff --git a/hw/kdrive/ephyr/ephyr.h b/hw/kdrive/ephyr/ephyr.h
index 4e753f1..f3a3c8e 100644
--- a/hw/kdrive/ephyr/ephyr.h
+++ b/hw/kdrive/ephyr/ephyr.h
@@ -197,8 +197,6 @@ extern KdOsFuncs EphyrOsFuncs;
 
 extern Bool ephyrCursorInit(ScreenPtr pScreen);
 
-extern void ephyrCursorEnable(ScreenPtr pScreen);
-
 extern int ephyrBufferHeight(KdScreenInfo * screen);
 
 /* ephyr_draw.c */
diff --git a/hw/kdrive/ephyr/ephyrcursor.c b/hw/kdrive/ephyr/ephyrcursor.c
new file mode 100644
index 0000000..852be33
--- /dev/null
+++ b/hw/kdrive/ephyr/ephyrcursor.c
@@ -0,0 +1,262 @@
+/*
+ * Copyright © 2014 Red Hat, Inc.
+ *
+ * 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.
+ *
+ * Author:
+ *      Adam Jackson <ajax at redhat.com>
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <kdrive-config.h>
+#endif
+#include "ephyr.h"
+#include "ephyrlog.h"
+#include "hostx.h"
+#include "cursorstr.h"
+#include <xcb/render.h>
+#include <xcb/xcb_renderutil.h>
+
+static DevPrivateKeyRec ephyrCursorPrivateKey;
+
+typedef struct _ephyrCursor {
+    xcb_cursor_t cursor;
+} ephyrCursorRec, *ephyrCursorPtr;
+
+static ephyrCursorPtr
+ephyrGetCursor(CursorPtr cursor)
+{
+    return dixGetPrivateAddr(&cursor->devPrivates, &ephyrCursorPrivateKey);
+}
+
+static void
+ephyrRealizeCoreCursor(EphyrScrPriv *scr, CursorPtr cursor)
+{
+    ephyrCursorPtr hw = ephyrGetCursor(cursor);
+    xcb_connection_t *conn = hostx_get_xcbconn();
+    xcb_pixmap_t source, mask;
+    xcb_image_t *image;
+    xcb_gcontext_t gc;
+    int w = cursor->bits->width, h = cursor->bits->height;
+    uint32_t gcmask = XCB_GC_FUNCTION |
+                      XCB_GC_PLANE_MASK |
+                      XCB_GC_FOREGROUND |
+                      XCB_GC_BACKGROUND |
+                      XCB_GC_CLIP_MASK;
+    uint32_t val[] = {
+        XCB_GX_COPY,    /* function */
+        ~0,             /* planemask */
+        1L,             /* foreground */
+        0L,             /* background */
+        None,           /* clipmask */
+    };
+
+    source = xcb_generate_id(conn);
+    mask = xcb_generate_id(conn);
+    xcb_create_pixmap(conn, 1, source, scr->win, w, h);
+    xcb_create_pixmap(conn, 1, mask, scr->win, w, h);
+
+    gc = xcb_generate_id(conn);
+    xcb_create_gc(conn, gc, source, gcmask, val);
+
+    image = xcb_image_create_native(conn, w, h, XCB_IMAGE_FORMAT_XY_BITMAP,
+                                    1, NULL, ~0, NULL);
+    image->data = cursor->bits->source;
+    xcb_image_put(conn, source, gc, image, 0, 0, 0);
+    xcb_image_destroy(image);
+
+    image = xcb_image_create_native(conn, w, h, XCB_IMAGE_FORMAT_XY_BITMAP,
+                                    1, NULL, ~0, NULL);
+    image->data = cursor->bits->mask;
+    xcb_image_put(conn, mask, gc, image, 0, 0, 0);
+    xcb_image_destroy(image);
+
+    xcb_free_gc(conn, gc);
+
+    hw->cursor = xcb_generate_id(conn);
+    xcb_create_cursor(conn, hw->cursor, source, mask,
+                      cursor->foreRed, cursor->foreGreen, cursor->foreBlue,
+                      cursor->backRed, cursor->backGreen, cursor->backBlue,
+                      cursor->bits->xhot, cursor->bits->yhot);
+
+    xcb_free_pixmap(conn, source);
+    xcb_free_pixmap(conn, mask);
+}
+
+#ifdef ARGB_CURSOR
+static xcb_render_pictformat_t
+get_argb_format(void)
+{
+    static xcb_render_pictformat_t format;
+    if (format == None) {
+        xcb_connection_t *conn = hostx_get_xcbconn();
+        xcb_render_query_pict_formats_cookie_t cookie;
+        xcb_render_query_pict_formats_reply_t *formats;
+
+        cookie = xcb_render_query_pict_formats(conn);
+        formats =
+            xcb_render_query_pict_formats_reply(conn, cookie, NULL);
+
+        format =
+            xcb_render_util_find_standard_format(formats,
+                                                 XCB_PICT_STANDARD_ARGB_32)->id;
+
+        free(formats);
+    }
+
+    return format;
+}
+
+static void
+ephyrRealizeARGBCursor(EphyrScrPriv *scr, CursorPtr cursor)
+{
+    ephyrCursorPtr hw = ephyrGetCursor(cursor);
+    xcb_connection_t *conn = hostx_get_xcbconn();
+    xcb_gcontext_t gc;
+    xcb_pixmap_t source;
+    xcb_render_picture_t picture;
+    xcb_image_t *image;
+    int w = cursor->bits->width, h = cursor->bits->height;
+
+    /* dix' storage is PICT_a8r8g8b8 */
+    source = xcb_generate_id(conn);
+    xcb_create_pixmap(conn, 32, source, scr->win, w, h);
+
+    gc = xcb_generate_id(conn);
+    xcb_create_gc(conn, gc, source, 0, NULL);
+    image = xcb_image_create_native(conn, w, h, XCB_IMAGE_FORMAT_Z_PIXMAP,
+                                    32, NULL, ~0, NULL);
+    image->data = (void *)cursor->bits->argb;
+    xcb_image_put(conn, source, gc, image, 0, 0, 0);
+    xcb_free_gc(conn, gc);
+    xcb_image_destroy(image);
+
+    picture = xcb_generate_id(conn);
+    xcb_render_create_picture(conn, picture, source, get_argb_format(),
+                              0, NULL);
+    xcb_free_pixmap(conn, source);
+
+    hw->cursor = xcb_generate_id(conn);
+    xcb_render_create_cursor(conn, hw->cursor, picture,
+                             cursor->bits->xhot, cursor->bits->yhot);
+
+    xcb_render_free_picture(conn, picture);
+}
+
+static Bool
+can_argb_cursor(void)
+{
+    static const xcb_render_query_version_reply_t *v;
+
+    if (!v)
+        v = xcb_render_util_query_version(hostx_get_xcbconn());
+
+    return v->major_version == 0 && v->minor_version >= 5;
+}
+#endif
+
+static Bool
+ephyrRealizeCursor(DeviceIntPtr dev, ScreenPtr screen, CursorPtr cursor)
+{
+    KdScreenPriv(screen);
+    KdScreenInfo *kscr = pScreenPriv->screen;
+    EphyrScrPriv *scr = kscr->driver;
+
+#ifdef ARGB_CURSOR
+    if (cursor->bits->argb && can_argb_cursor())
+        ephyrRealizeARGBCursor(scr, cursor);
+    else
+#endif
+    {
+        ephyrRealizeCoreCursor(scr, cursor);
+    }
+    return TRUE;
+}
+
+static Bool
+ephyrUnrealizeCursor(DeviceIntPtr dev, ScreenPtr screen, CursorPtr cursor)
+{
+    ephyrCursorPtr hw = ephyrGetCursor(cursor);
+
+    if (hw->cursor) {
+        xcb_free_cursor(hostx_get_xcbconn(), hw->cursor);
+        hw->cursor = None;
+    }
+
+    return TRUE;
+}
+
+static void
+ephyrSetCursor(DeviceIntPtr dev, ScreenPtr screen, CursorPtr cursor, int x,
+               int y)
+{
+    KdScreenPriv(screen);
+    KdScreenInfo *kscr = pScreenPriv->screen;
+    EphyrScrPriv *scr = kscr->driver;
+    uint32_t attr = None;
+
+    if (cursor)
+        attr = ephyrGetCursor(cursor)->cursor;
+    else
+        attr = hostx_get_empty_cursor();
+
+    xcb_change_window_attributes(hostx_get_xcbconn(), scr->win,
+                                 XCB_CW_CURSOR, &attr);
+    xcb_flush(hostx_get_xcbconn());
+}
+
+static void
+ephyrMoveCursor(DeviceIntPtr dev, ScreenPtr screen, int x, int y)
+{
+}
+
+static Bool
+ephyrDeviceCursorInitialize(DeviceIntPtr dev, ScreenPtr screen)
+{
+    return TRUE;
+}
+
+static void
+ephyrDeviceCursorCleanup(DeviceIntPtr dev, ScreenPtr screen)
+{
+}
+
+miPointerSpriteFuncRec EphyrPointerSpriteFuncs = {
+    ephyrRealizeCursor,
+    ephyrUnrealizeCursor,
+    ephyrSetCursor,
+    ephyrMoveCursor,
+    ephyrDeviceCursorInitialize,
+    ephyrDeviceCursorCleanup
+};
+
+Bool
+ephyrCursorInit(ScreenPtr screen)
+{
+    if (!dixRegisterPrivateKey(&ephyrCursorPrivateKey, PRIVATE_CURSOR_BITS,
+                               sizeof(ephyrCursorRec)))
+        return FALSE;
+
+    miPointerInitialize(screen,
+                        &EphyrPointerSpriteFuncs,
+                        &ephyrPointerScreenFuncs, FALSE);
+
+    return TRUE;
+}
diff --git a/hw/kdrive/ephyr/ephyrinit.c b/hw/kdrive/ephyr/ephyrinit.c
index 38acc52..3693531 100644
--- a/hw/kdrive/ephyr/ephyrinit.c
+++ b/hw/kdrive/ephyr/ephyrinit.c
@@ -369,77 +369,12 @@ OsVendorInit(void)
 {
     EPHYR_DBG("mark");
 
-    if (hostx_want_host_cursor()) {
+    if (hostx_want_host_cursor())
         ephyrFuncs.initCursor = &ephyrCursorInit;
-        ephyrFuncs.enableCursor = &ephyrCursorEnable;
-    }
 
     KdOsInit(&EphyrOsFuncs);
 }
 
-/* 'Fake' cursor stuff, could be improved */
-
-static Bool
-ephyrRealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor)
-{
-    return TRUE;
-}
-
-static Bool
-ephyrUnrealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor)
-{
-    return TRUE;
-}
-
-static void
-ephyrSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor, int x,
-               int y)
-{
-    ;
-}
-
-static void
-ephyrMoveCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
-{
-    ;
-}
-
-static Bool
-ephyrDeviceCursorInitialize(DeviceIntPtr pDev, ScreenPtr pScreen)
-{
-    return TRUE;
-}
-
-static void
-ephyrDeviceCursorCleanup(DeviceIntPtr pDev, ScreenPtr pScreen)
-{
-}
-
-miPointerSpriteFuncRec EphyrPointerSpriteFuncs = {
-    ephyrRealizeCursor,
-    ephyrUnrealizeCursor,
-    ephyrSetCursor,
-    ephyrMoveCursor,
-    ephyrDeviceCursorInitialize,
-    ephyrDeviceCursorCleanup
-};
-
-Bool
-ephyrCursorInit(ScreenPtr pScreen)
-{
-    miPointerInitialize(pScreen,
-                        &EphyrPointerSpriteFuncs,
-                        &ephyrPointerScreenFuncs, FALSE);
-
-    return TRUE;
-}
-
-void
-ephyrCursorEnable(ScreenPtr pScreen)
-{
-    ;
-}
-
 KdCardFuncs ephyrFuncs = {
     ephyrCardInit,              /* cardinit */
     ephyrScreenInitialize,      /* scrinit */
diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c
index 2161ad5..0562625 100644
--- a/hw/kdrive/ephyr/hostx.c
+++ b/hw/kdrive/ephyr/hostx.c
@@ -71,6 +71,8 @@ struct EphyrHostXVars {
     xcb_visualtype_t *visual;
     Window winroot;
     xcb_gcontext_t  gc;
+    xcb_render_pictformat_t argb_format;
+    xcb_cursor_t empty_cursor;
     int depth;
     Bool use_sw_cursor;
     Bool use_fullscreen;
@@ -202,6 +204,12 @@ hostx_use_sw_cursor(void)
     HostX.use_sw_cursor = TRUE;
 }
 
+xcb_cursor_t
+hostx_get_empty_cursor(void)
+{
+    return HostX.empty_cursor;
+}
+
 int
 hostx_want_preexisting_window(KdScreenInfo *screen)
 {
@@ -408,8 +416,8 @@ hostx_init(void)
 {
     uint32_t attrs[2];
     uint32_t attr_mask = 0;
-    xcb_cursor_t empty_cursor;
     xcb_pixmap_t cursor_pxm;
+    xcb_gcontext_t cursor_gc;
     uint16_t red, green, blue;
     uint32_t pixel;
     int index;
@@ -418,6 +426,7 @@ hostx_init(void)
     size_t class_len;
     const xcb_query_extension_reply_t *shm_rep;
     xcb_screen_t *xscreen;
+    xcb_rectangle_t rect = { 0, 0, 1, 1 };
 
     attrs[0] =
         XCB_EVENT_MASK_BUTTON_PRESS
@@ -594,18 +603,25 @@ hostx_init(void)
 
     xcb_change_gc(HostX.conn, HostX.gc, XCB_GC_FOREGROUND, &pixel);
 
+    cursor_pxm = xcb_generate_id(HostX.conn);
+    xcb_create_pixmap(HostX.conn, 1, cursor_pxm, HostX.winroot, 1, 1);
+    cursor_gc = xcb_generate_id(HostX.conn);
+    pixel = 0;
+    xcb_create_gc(HostX.conn, cursor_gc, cursor_pxm,
+                  XCB_GC_FOREGROUND, &pixel);
+    xcb_poly_fill_rectangle(HostX.conn, cursor_pxm, cursor_gc, 1, &rect);
+    xcb_free_gc(HostX.conn, cursor_gc);
+    HostX.empty_cursor = xcb_generate_id(HostX.conn);
+    xcb_create_cursor(HostX.conn,
+                      HostX.empty_cursor,
+                      cursor_pxm, cursor_pxm,
+                      0,0,0,
+                      0,0,0,
+                      1,1);
+    xcb_free_pixmap(HostX.conn, cursor_pxm);
     if (!hostx_want_host_cursor ()) {
         CursorVisible = TRUE;
         /* Ditch the cursor, we provide our 'own' */
-        cursor_pxm = xcb_generate_id(HostX.conn);
-        xcb_create_pixmap(HostX.conn, 1, cursor_pxm, HostX.winroot, 1, 1);
-        empty_cursor = xcb_generate_id(HostX.conn);
-        xcb_create_cursor(HostX.conn,
-                          empty_cursor,
-                          cursor_pxm, cursor_pxm,
-                          0,0,0,
-                          0,0,0,
-                          1,1);
         for (index = 0; index < HostX.n_screens; index++) {
             KdScreenInfo *screen = HostX.screens[index];
             EphyrScrPriv *scrpriv = screen->driver;
@@ -613,9 +629,8 @@ hostx_init(void)
             xcb_change_window_attributes(HostX.conn,
                                          scrpriv->win,
                                          XCB_CW_CURSOR,
-                                         &empty_cursor);
+                                         &HostX.empty_cursor);
         }
-        xcb_free_pixmap(HostX.conn, cursor_pxm);
     }
 
     /* Try to get share memory ximages for a little bit more speed */
diff --git a/hw/kdrive/ephyr/hostx.h b/hw/kdrive/ephyr/hostx.h
index 80894c8..229961e 100644
--- a/hw/kdrive/ephyr/hostx.h
+++ b/hw/kdrive/ephyr/hostx.h
@@ -29,6 +29,7 @@
 #include <X11/X.h>
 #include <X11/Xmd.h>
 #include <xcb/xcb.h>
+#include <xcb/render.h>
 #include "ephyr.h"
 
 #define EPHYR_WANT_DEBUG 0
@@ -82,6 +83,9 @@ int
 void
  hostx_use_sw_cursor(void);
 
+xcb_cursor_t
+ hostx_get_empty_cursor(void);
+
 void
  hostx_get_output_geometry(const char *output,
                            int *x, int *y,
commit f839caadd4e567bf89f893aa7e5ba1327b712b4b
Author: Adam Jackson <ajax at redhat.com>
Date:   Wed Sep 17 11:07:22 2014 -0400

    loader: Remove compatibility with ancient XFree86 version numbering
    
    Pretty sure I'm guilty of adding this.  I think I was thinking of trying
    to be compatible with some really old binary-only driver that I had
    vague aspirations of reverse-engineering, but since I haven't gotten
    around to it in the intervening decade...
    
    Signed-off-by: Adam Jackson <ajax at redhat.com>
    Reviewed-by: Eric Anholt <eric at anholt.net>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/xfree86/loader/loadmod.c b/hw/xfree86/loader/loadmod.c
index f1f7c22..21ccb1b 100644
--- a/hw/xfree86/loader/loadmod.c
+++ b/hw/xfree86/loader/loadmod.c
@@ -584,7 +584,6 @@ CheckVersion(const char *module, XF86ModuleVersionInfo * data,
              const XF86ModReqInfo * req)
 {
     int vercode[4];
-    char verstr[4];
     long ver = data->xf86version;
     MessageType errtype;
 
@@ -592,42 +591,15 @@ CheckVersion(const char *module, XF86ModuleVersionInfo * data,
             data->modname ? data->modname : "UNKNOWN!",
             data->vendor ? data->vendor : "UNKNOWN!");
 
-    /* Check for the different scheme used in XFree86 4.0.x releases:
-     * ((((((((major << 7) | minor) << 7) | subminor) << 5) | beta) << 5) | alpha)
-     * Since it wasn't used in 4.1.0 or later, limit to versions in the 4.0.x
-     * range, which limits the overlap with the new version scheme to conflicts
-     * with 6.71.8.764 through 6.72.39.934.
-     */
-    if ((ver > (4 << 24)) && (ver < ((4 << 24) + (1 << 17)))) {
-        /* 4.0.x and earlier */
-        verstr[1] = verstr[3] = 0;
-        verstr[2] = (ver & 0x1f) ? (ver & 0x1f) + 'a' - 1 : 0;
-        ver >>= 5;
-        verstr[0] = (ver & 0x1f) ? (ver & 0x1f) + 'A' - 1 : 0;
-        ver >>= 5;
-        vercode[2] = ver & 0x7f;
-        ver >>= 7;
-        vercode[1] = ver & 0x7f;
-        ver >>= 7;
-        vercode[0] = ver;
-        xf86ErrorF("\tcompiled for %d.%d", vercode[0], vercode[1]);
-        if (vercode[2] != 0)
-            xf86ErrorF(".%d", vercode[2]);
-        xf86ErrorF("%s%s, module version = %d.%d.%d\n", verstr, verstr + 2,
-                   data->majorversion, data->minorversion, data->patchlevel);
-    }
-    else {
-        vercode[0] = ver / 10000000;
-        vercode[1] = (ver / 100000) % 100;
-        vercode[2] = (ver / 1000) % 100;
-        vercode[3] = ver % 1000;
-        xf86ErrorF("\tcompiled for %d.%d.%d", vercode[0], vercode[1],
-                   vercode[2]);
-        if (vercode[3] != 0)
-            xf86ErrorF(".%d", vercode[3]);
-        xf86ErrorF(", module version = %d.%d.%d\n", data->majorversion,
-                   data->minorversion, data->patchlevel);
-    }
+    vercode[0] = ver / 10000000;
+    vercode[1] = (ver / 100000) % 100;
+    vercode[2] = (ver / 1000) % 100;
+    vercode[3] = ver % 1000;
+    xf86ErrorF("\tcompiled for %d.%d.%d", vercode[0], vercode[1], vercode[2]);
+    if (vercode[3] != 0)
+        xf86ErrorF(".%d", vercode[3]);
+    xf86ErrorF(", module version = %d.%d.%d\n", data->majorversion,
+               data->minorversion, data->patchlevel);
 
     if (data->moduleclass)
         xf86ErrorFVerb(2, "\tModule class: %s\n", data->moduleclass);
commit af40913797e6595fb5466c2ff3110e9526a37b9f
Author: Julien Cristau <jcristau at debian.org>
Date:   Wed Sep 17 07:41:27 2014 +0200

    xwayland: always include drm.xml in tarballs
    
    Move drm.xml out of the automake conditional so make dist includes it
    even if glamor-egl is disabled.
    
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=83960
    
    Signed-off-by: Julien Cristau <jcristau at debian.org>
    Reviewed-by: Eric Anholt <eric at anholt.net>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/xwayland/Makefile.am b/hw/xwayland/Makefile.am
index dc16b8b..4e0e1bb 100644
--- a/hw/xwayland/Makefile.am
+++ b/hw/xwayland/Makefile.am
@@ -39,8 +39,6 @@ nodist_Xwayland_SOURCES =			\
 
 CLEANFILES = $(nodist_Xwayland_SOURCES)
 
-EXTRA_DIST = drm.xml
-
 xwayland-glamor.c : $(nodist_Xwayland_SOURCES)
 
 glamor_lib = $(top_builddir)/glamor/libglamor.la
@@ -48,6 +46,8 @@ glamor_lib = $(top_builddir)/glamor/libglamor.la
 Xwayland_LDADD += $(GLAMOR_LIBS) $(GBM_LIBS) -lEGL -lGL
 endif
 
+EXTRA_DIST = drm.xml
+
 
 relink:
 	$(AM_V_at)rm -f Xwayland$(EXEEXT) && $(MAKE) Xwayland$(EXEEXT)
commit eaee6572beefca240c42791f9a3a6e547bedd410
Merge: e3aa13b b84d25f
Author: Keith Packard <keithp at keithp.com>
Date:   Wed Sep 17 15:49:24 2014 -0700

    Merge remote-tracking branch 'anholt/modesetting-import'

commit e3aa13b8d63ea2fba6eb47ddd0a7dde5a6d2b661
Author: Jon TURNEY <jon.turney at dronecode.org.uk>
Date:   Wed Sep 17 15:38:39 2014 -0700

    Update help text since -iglx is now the default
    
    This should have been part of d0da0e9c3bb8fe0cd4879ecb24d21715bfaa209b
    
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Signed-off-by: Eric Anholt <eric at anholt.net>
    Reviewed-by: Eric Anholt <eric at anholt.net>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/os/utils.c b/os/utils.c
index c83f77d..2d02f92 100644
--- a/os/utils.c
+++ b/os/utils.c
@@ -541,8 +541,8 @@ UseMsg(void)
     ErrorF("-fn string             default font name\n");
     ErrorF("-fp string             default font path\n");
     ErrorF("-help                  prints message with these options\n");
-    ErrorF("+iglx                  Allow creating indirect GLX contexts (default)\n");
-    ErrorF("-iglx                  Prohibit creating indirect GLX contexts\n");
+    ErrorF("+iglx                  Allow creating indirect GLX contexts\n");
+    ErrorF("-iglx                  Prohibit creating indirect GLX contexts (default)\n");
     ErrorF("-I                     ignore all remaining arguments\n");
 #ifdef RLIMIT_DATA
     ErrorF("-ld int                limit data space to N Kb\n");
commit b84d25fd53e97105b99495af84abaacc4c901967
Author: Eric Anholt <eric at anholt.net>
Date:   Tue Aug 26 11:22:02 2014 -0700

    modesetting: Drop remaining old-xserver compatibility.
    
    Signed-off-by: Eric Anholt <eric at anholt.net>
    Reviewed-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/xfree86/drivers/modesetting/driver.c b/hw/xfree86/drivers/modesetting/driver.c
index 35e73a3..adfb69c 100644
--- a/hw/xfree86/drivers/modesetting/driver.c
+++ b/hw/xfree86/drivers/modesetting/driver.c
@@ -295,10 +295,8 @@ ms_driver_func(ScrnInfoPtr scrn, xorgDriverFuncOp op, void *data)
 	    flag = (CARD32 *)data;
 	    (*flag) = 0;
 	    return TRUE;
-#if XORG_VERSION_CURRENT >= XORG_VERSION_NUMERIC(1,15,99,902,0)
         case SUPPORTS_SERVER_FDS:
             return TRUE;
-#endif
 	default:
 	    return FALSE;
     }
@@ -494,7 +492,7 @@ static void dispatch_dirty(ScreenPtr pScreen)
     ret = dispatch_dirty_region(scrn, pixmap, ms->damage, fb_id);
     if (ret == -EINVAL || ret == -ENOSYS) {
 	ms->dirty_enabled = FALSE;
-	DamageUnregister(&pScreen->GetScreenPixmap(pScreen)->drawable, ms->damage);
+	DamageUnregister(ms->damage);
 	DamageDestroy(ms->damage);
 	ms->damage = NULL;
 	xf86DrvMsg(scrn->scrnIndex, X_INFO, "Disabling kernel dirty updates, not required.\n");
@@ -1082,7 +1080,7 @@ CloseScreen(ScreenPtr pScreen)
     modesettingPtr ms = modesettingPTR(pScrn);
 
     if (ms->damage) {
-	DamageUnregister(&pScreen->GetScreenPixmap(pScreen)->drawable, ms->damage);
+	DamageUnregister(ms->damage);
 	DamageDestroy(ms->damage);
 	ms->damage = NULL;
     }
diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c b/hw/xfree86/drivers/modesetting/drmmode_display.c
index 88de97c..9723ccd 100644
--- a/hw/xfree86/drivers/modesetting/drmmode_display.c
+++ b/hw/xfree86/drivers/modesetting/drmmode_display.c
@@ -333,9 +333,7 @@ drmmode_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode,
 		crtc->x = x;
 		crtc->y = y;
 		crtc->rotation = rotation;
-#if XORG_VERSION_CURRENT >= XORG_VERSION_NUMERIC(1,5,99,0,0)
 		crtc->transformPresent = FALSE;
-#endif
 	}
 
 	output_ids = calloc(sizeof(uint32_t), xf86_config->num_output);
@@ -360,10 +358,8 @@ drmmode_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode,
 		if (!xf86CrtcRotate(crtc)) {
 			goto done;
 		}
-#if XORG_VERSION_CURRENT >= XORG_VERSION_NUMERIC(1,7,0,0,0)
 		crtc->funcs->gamma_set(crtc, crtc->gamma_red, crtc->gamma_green,
 				       crtc->gamma_blue, crtc->gamma_size);
-#endif
 		
 		drmmode_ConvertToKMode(crtc->scrn, &kmode, mode);
 
@@ -521,8 +517,7 @@ drmmode_set_scanout_pixmap(xf86CrtcPtr crtc, PixmapPtr ppix)
 			drmModeRmFB(drmmode->fd, ppriv->fb_id);
 		}
 		if (drmmode_crtc->slave_damage) {
-			DamageUnregister(&crtc->randr_crtc->scanout_pixmap->drawable,
-					 drmmode_crtc->slave_damage);
+			DamageUnregister(drmmode_crtc->slave_damage);
 			drmmode_crtc->slave_damage = NULL;
 		}
 		return TRUE;
@@ -947,10 +942,8 @@ drmmode_output_get_property(xf86OutputPtr output, Atom property)
 static const xf86OutputFuncsRec drmmode_output_funcs = {
     .dpms = drmmode_output_dpms,
     .create_resources = drmmode_output_create_resources,
-#ifdef RANDR_12_INTERFACE
     .set_property = drmmode_output_set_property,
     .get_property = drmmode_output_get_property,
-#endif
     .detect = drmmode_output_detect,
     .mode_valid = drmmode_output_mode_valid,
 
@@ -1195,10 +1188,6 @@ drmmode_xf86crtc_resize (ScrnInfoPtr scrn, int width, int height)
 					   pitch, drmmode->shadow_fb);
 	}
 
-#if XORG_VERSION_CURRENT < XORG_VERSION_NUMERIC(1,9,99,1,0)
-	scrn->pixmapPrivate.ptr = ppix->devPrivate.ptr;
-#endif
-
 	for (i = 0; i < xf86_config->num_crtc; i++) {
 		xf86CrtcPtr crtc = xf86_config->crtc[i];
 
@@ -1395,11 +1384,9 @@ static void drmmode_load_palette(ScrnInfoPtr pScrn, int numColors,
           }
 
     /* Make the change through RandR */
-#ifdef RANDR_12_INTERFACE
         if (crtc->randr_crtc)
             RRCrtcGammaSet(crtc->randr_crtc, lut_r, lut_g, lut_b);
         else
-#endif
             crtc->funcs->gamma_set(crtc, lut_r, lut_g, lut_b, 256);
      }
 }
diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.h b/hw/xfree86/drivers/modesetting/drmmode_display.h
index 1954abf..7bfe885 100644
--- a/hw/xfree86/drivers/modesetting/drmmode_display.h
+++ b/hw/xfree86/drivers/modesetting/drmmode_display.h
@@ -32,10 +32,6 @@
 #include "libudev.h"
 #endif
 
-#if XORG_VERSION_CURRENT >= XORG_VERSION_NUMERIC(1,14,99,2,0)
-#define DamageUnregister(d, dd) DamageUnregister(dd)
-#endif
-
 struct dumb_bo {
     uint32_t handle;
     uint32_t size;
@@ -62,9 +58,7 @@ typedef struct {
     Bool shadow_enable;
     void *shadow_fb;
 
-#ifdef HAVE_SCREEN_SPECIFIC_PRIVATE_KEYS
     DevPrivateKeyRec pixmapPrivateKeyRec;
-#endif
 } drmmode_rec, *drmmode_ptr;
 
 typedef struct {
commit 7b0965a826612988dd721ddbd67cfbec392b67b5
Author: Eric Anholt <eric at anholt.net>
Date:   Tue Aug 26 11:37:46 2014 -0700

    modesetting: Drop use of compat-api.h
    
    Signed-off-by: Eric Anholt <eric at anholt.net>
    Reviewed-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/xfree86/drivers/modesetting/Makefile.am b/hw/xfree86/drivers/modesetting/Makefile.am
index f6c6041..ca3279e 100644
--- a/hw/xfree86/drivers/modesetting/Makefile.am
+++ b/hw/xfree86/drivers/modesetting/Makefile.am
@@ -41,7 +41,6 @@ modesetting_drv_la_LIBADD = $(UDEV_LIBS) $(DRM_LIBS)
 modesetting_drv_ladir = @moduledir@/drivers
 
 modesetting_drv_la_SOURCES = \
-	 compat-api.h \
 	 driver.c \
 	 driver.h \
 	 drmmode_display.c \
diff --git a/hw/xfree86/drivers/modesetting/compat-api.h b/hw/xfree86/drivers/modesetting/compat-api.h
deleted file mode 100644
index bd7decc..0000000
--- a/hw/xfree86/drivers/modesetting/compat-api.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright 2012 Red Hat, Inc.
- *
- * 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.
- *
- * Author: Dave Airlie <airlied at redhat.com>
- */
-
-/* this file provides API compat between server post 1.13 and pre it,
-   it should be reused inside as many drivers as possible */
-#ifndef COMPAT_API_H
-#define COMPAT_API_H
-
-#ifndef GLYPH_HAS_GLYPH_PICTURE_ACCESSOR
-#define GetGlyphPicture(g, s) GlyphPicture((g))[(s)->myNum]
-#define SetGlyphPicture(g, s, p) GlyphPicture((g))[(s)->myNum] = p
-#endif
-
-#ifndef XF86_HAS_SCRN_CONV
-#define xf86ScreenToScrn(s) xf86Screens[(s)->myNum]
-#define xf86ScrnToScreen(s) screenInfo.screens[(s)->scrnIndex]
-#endif
-
-#ifndef XF86_SCRN_INTERFACE
-
-#define SCRN_ARG_TYPE int
-#define SCRN_INFO_PTR(arg1) ScrnInfoPtr pScrn = xf86Screens[(arg1)]
-
-#define SCREEN_ARG_TYPE int
-#define SCREEN_PTR(arg1) ScreenPtr pScreen = screenInfo.screens[(arg1)]
-
-#define SCREEN_INIT_ARGS_DECL int i, ScreenPtr pScreen, int argc, char **argv
-
-#define BLOCKHANDLER_ARGS_DECL int arg, void * blockData, void * pTimeout, void * pReadmask
-#define BLOCKHANDLER_ARGS arg, blockData, pTimeout, pReadmask
-
-#define CLOSE_SCREEN_ARGS_DECL int scrnIndex, ScreenPtr pScreen
-#define CLOSE_SCREEN_ARGS scrnIndex, pScreen
-
-#define ADJUST_FRAME_ARGS_DECL int arg, int x, int y, int flags
-
-#define SWITCH_MODE_ARGS_DECL int arg, DisplayModePtr mode, int flags
-
-#define FREE_SCREEN_ARGS_DECL int arg, int flags
-
-#define VT_FUNC_ARGS_DECL int arg, int flags
-#define VT_FUNC_ARGS pScrn->scrnIndex, 0
-
-#define XF86_ENABLEDISABLEFB_ARG(x) ((x)->scrnIndex)
-#else
-#define SCRN_ARG_TYPE ScrnInfoPtr
-#define SCRN_INFO_PTR(arg1) ScrnInfoPtr pScrn = (arg1)
-
-#define SCREEN_ARG_TYPE ScreenPtr
-#define SCREEN_PTR(arg1) ScreenPtr pScreen = (arg1)
-
-#define SCREEN_INIT_ARGS_DECL ScreenPtr pScreen, int argc, char **argv
-
-#define BLOCKHANDLER_ARGS_DECL ScreenPtr arg, void * pTimeout, void * pReadmask
-#define BLOCKHANDLER_ARGS arg, pTimeout, pReadmask
-
-#define CLOSE_SCREEN_ARGS_DECL ScreenPtr pScreen
-#define CLOSE_SCREEN_ARGS pScreen
-
-#define ADJUST_FRAME_ARGS_DECL ScrnInfoPtr arg, int x, int y
-#define SWITCH_MODE_ARGS_DECL ScrnInfoPtr arg, DisplayModePtr mode
-
-#define FREE_SCREEN_ARGS_DECL ScrnInfoPtr arg
-
-#define VT_FUNC_ARGS_DECL ScrnInfoPtr arg
-#define VT_FUNC_ARGS pScrn
-
-#define XF86_ENABLEDISABLEFB_ARG(x) (x)
-
-#endif
-
-#endif
diff --git a/hw/xfree86/drivers/modesetting/driver.c b/hw/xfree86/drivers/modesetting/driver.c
index b30c32c..35e73a3 100644
--- a/hw/xfree86/drivers/modesetting/driver.c
+++ b/hw/xfree86/drivers/modesetting/driver.c
@@ -59,20 +59,19 @@
 #include <pciaccess.h>
 #endif
 
-#include "compat-api.h"
 #include "driver.h"
 
-static void AdjustFrame(ADJUST_FRAME_ARGS_DECL);
-static Bool CloseScreen(CLOSE_SCREEN_ARGS_DECL);
-static Bool EnterVT(VT_FUNC_ARGS_DECL);
+static void AdjustFrame(ScrnInfoPtr pScrn, int x, int y);
+static Bool CloseScreen(ScreenPtr pScreen);
+static Bool EnterVT(ScrnInfoPtr pScrn);
 static void Identify(int flags);
 static const OptionInfoRec *AvailableOptions(int chipid, int busid);
-static ModeStatus ValidMode(SCRN_ARG_TYPE arg, DisplayModePtr mode, Bool verbose,
+static ModeStatus ValidMode(ScrnInfoPtr pScrn, DisplayModePtr mode, Bool verbose,
 			    int flags);
-static void FreeScreen(FREE_SCREEN_ARGS_DECL);
-static void LeaveVT(VT_FUNC_ARGS_DECL);
-static Bool SwitchMode(SWITCH_MODE_ARGS_DECL);
-static Bool ScreenInit(SCREEN_INIT_ARGS_DECL);
+static void FreeScreen(ScrnInfoPtr pScrn);
+static void LeaveVT(ScrnInfoPtr pScrn);
+static Bool SwitchMode(ScrnInfoPtr pScrn, DisplayModePtr mode);
+static Bool ScreenInit(ScreenPtr pScreen, int argc, char **argv);
 static Bool PreInit(ScrnInfoPtr pScrn, int flags);
 
 static Bool Probe(DriverPtr drv, int flags);
@@ -537,13 +536,12 @@ static void dispatch_slave_dirty(ScreenPtr pScreen)
     }
 }
 
-static void msBlockHandler(BLOCKHANDLER_ARGS_DECL)
+static void msBlockHandler(ScreenPtr pScreen, void *pTimeout, void *pReadmask)
 {
-    SCREEN_PTR(arg);
     modesettingPtr ms = modesettingPTR(xf86ScreenToScrn(pScreen));
 
     pScreen->BlockHandler = ms->BlockHandler;
-    pScreen->BlockHandler(BLOCKHANDLER_ARGS);
+    pScreen->BlockHandler(pScreen, pTimeout, pReadmask);
     pScreen->BlockHandler = msBlockHandler;
     if (pScreen->isGPU)
         dispatch_slave_dirty(pScreen);
@@ -910,7 +908,7 @@ SetMaster(ScrnInfoPtr pScrn)
 }
 
 static Bool
-ScreenInit(SCREEN_INIT_ARGS_DECL)
+ScreenInit(ScreenPtr pScreen, int argc, char **argv)
 {
     ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     modesettingPtr ms = modesettingPTR(pScrn);
@@ -1019,29 +1017,26 @@ ScreenInit(SCREEN_INIT_ARGS_DECL)
     if (serverGeneration == 1)
 	xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options);
 
-    return EnterVT(VT_FUNC_ARGS);
+    return EnterVT(pScrn);
 }
 
 static void
-AdjustFrame(ADJUST_FRAME_ARGS_DECL)
+AdjustFrame(ScrnInfoPtr pScrn, int x, int y)
 {
-    SCRN_INFO_PTR(arg);
     modesettingPtr ms = modesettingPTR(pScrn);
 
     drmmode_adjust_frame(pScrn, &ms->drmmode, x, y);
 }
 
 static void
-FreeScreen(FREE_SCREEN_ARGS_DECL)
+FreeScreen(ScrnInfoPtr pScrn)
 {
-    SCRN_INFO_PTR(arg);
     FreeRec(pScrn);
 }
 
 static void
-LeaveVT(VT_FUNC_ARGS_DECL)
+LeaveVT(ScrnInfoPtr pScrn)
 {
-    SCRN_INFO_PTR(arg);
     modesettingPtr ms = modesettingPTR(pScrn);
     xf86_hide_cursors(pScrn);
 
@@ -1060,9 +1055,8 @@ LeaveVT(VT_FUNC_ARGS_DECL)
  * This gets called when gaining control of the VT, and from ScreenInit().
  */
 static Bool
-EnterVT(VT_FUNC_ARGS_DECL)
+EnterVT(ScrnInfoPtr pScrn)
 {
-    SCRN_INFO_PTR(arg);
     modesettingPtr ms = modesettingPTR(pScrn);
 
     pScrn->vtSema = TRUE;
@@ -1076,15 +1070,13 @@ EnterVT(VT_FUNC_ARGS_DECL)
 }
 
 static Bool
-SwitchMode(SWITCH_MODE_ARGS_DECL)
+SwitchMode(ScrnInfoPtr pScrn, DisplayModePtr mode)
 {
-    SCRN_INFO_PTR(arg);
-
     return xf86SetSingleMode(pScrn, mode, RR_Rotate_0);
 }
 
 static Bool
-CloseScreen(CLOSE_SCREEN_ARGS_DECL)
+CloseScreen(ScreenPtr pScreen)
 {
     ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
     modesettingPtr ms = modesettingPTR(pScrn);
@@ -1105,7 +1097,7 @@ CloseScreen(CLOSE_SCREEN_ARGS_DECL)
     drmmode_free_bos(pScrn, &ms->drmmode);
 
     if (pScrn->vtSema) {
-        LeaveVT(VT_FUNC_ARGS);
+        LeaveVT(pScrn);
     }
 
     pScreen->CreateScreenResources = ms->createScreenResources;
@@ -1113,11 +1105,11 @@ CloseScreen(CLOSE_SCREEN_ARGS_DECL)
 
     pScrn->vtSema = FALSE;
     pScreen->CloseScreen = ms->CloseScreen;
-    return (*pScreen->CloseScreen) (CLOSE_SCREEN_ARGS);
+    return (*pScreen->CloseScreen) (pScreen);
 }
 
 static ModeStatus
-ValidMode(SCRN_ARG_TYPE arg, DisplayModePtr mode, Bool verbose, int flags)
+ValidMode(ScrnInfoPtr arg, DisplayModePtr mode, Bool verbose, int flags)
 {
     return MODE_OK;
 }
diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c b/hw/xfree86/drivers/modesetting/drmmode_display.c
index d55157b..88de97c 100644
--- a/hw/xfree86/drivers/modesetting/drmmode_display.c
+++ b/hw/xfree86/drivers/modesetting/drmmode_display.c
@@ -46,7 +46,6 @@
 #include <cursorstr.h>
 
 #include <X11/extensions/dpmsconst.h>
-#include "compat-api.h"
 
 #include "driver.h"
 
commit 2feda3b6b58f46cef91ea41312aac9021a703777
Author: Eric Anholt <eric at anholt.net>
Date:   Tue Aug 26 11:06:23 2014 -0700

    modesetting: Connect the driver to the build.
    
    v2: Fix libdrm version check, and use XORG_VERSION_* instead of a
        static 1.0.0 version for the driver module.
    
    Signed-off-by: Eric Anholt <eric at anholt.net>
    Reviewed-by: Keith Packard <keithp at keithp.com>

diff --git a/configure.ac b/configure.ac
index cba7d24..ae3327d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -863,6 +863,7 @@ fi
 PKG_CHECK_MODULES(UDEV, $LIBUDEV, [HAVE_LIBUDEV=yes], [HAVE_LIBUDEV=no])
 if test "x$CONFIG_UDEV" = xauto; then
 	CONFIG_UDEV="$HAVE_LIBUDEV"
+	AC_DEFINE(HAVE_LIBUDEV, 1, [Define to 1 if libudev is available.])
 fi
 AM_CONDITIONAL(CONFIG_UDEV, [test "x$CONFIG_UDEV" = xyes])
 if test "x$CONFIG_UDEV" = xyes; then
@@ -2039,6 +2040,12 @@ if test "x$XORG" = xyes; then
 	        XORG_SYS_LIBS="$XORG_SYS_LIBS $XORG_MODULES_LIBS"
 	fi
 
+	if test "x$DRM" = xyes; then
+		dnl 2.4.46 is required for cursor hotspot support.
+		PKG_CHECK_EXISTS(libdrm >= 2.4.46)
+		XORG_DRIVER_MODESETTING=yes
+	fi
+
 	AC_SUBST([XORG_LIBS])
 	AC_SUBST([XORG_SYS_LIBS])
 	AC_SUBST([XORG_INCS])
@@ -2109,6 +2116,7 @@ AM_CONDITIONAL([SOLARIS_VT], [test "x$solaris_vt" = xyes])
 AM_CONDITIONAL([DGA], [test "x$DGA" = xyes])
 AM_CONDITIONAL([XF86VIDMODE], [test "x$XF86VIDMODE" = xyes])
 AM_CONDITIONAL([XORG_BUS_PLATFORM], [test "x$CONFIG_UDEV_KMS" = xyes])
+AM_CONDITIONAL([XORG_DRIVER_MODESETTING], [test "x$XORG_DRIVER_MODESETTING" = xyes])
 
 dnl glamor
 AM_CONDITIONAL([GLAMOR], [test "x$GLAMOR" = xyes])
@@ -2554,6 +2562,8 @@ hw/xfree86/dixmods/Makefile
 hw/xfree86/doc/Makefile
 hw/xfree86/dri/Makefile
 hw/xfree86/dri2/Makefile
+hw/xfree86/drivers/Makefile
+hw/xfree86/drivers/modesetting/Makefile
 hw/xfree86/exa/Makefile
 hw/xfree86/exa/man/Makefile
 hw/xfree86/fbdevhw/Makefile
diff --git a/hw/xfree86/Makefile.am b/hw/xfree86/Makefile.am
index c5992c3..30f7c8f 100644
--- a/hw/xfree86/Makefile.am
+++ b/hw/xfree86/Makefile.am
@@ -38,7 +38,7 @@ SUBDIRS = common ddc x86emu $(INT10_SUBDIR) os-support parser \
 	  ramdac $(VGAHW_SUBDIR) loader modes $(DRI_SUBDIR) \
 	  $(DRI2_SUBDIR) . $(VBE_SUBDIR) i2c dixmods \
 	  fbdevhw shadowfb exa $(XF86UTILS_SUBDIR) doc man \
-	  $(GLAMOR_EGL_SUBDIR)
+	  $(GLAMOR_EGL_SUBDIR) drivers
 
 DIST_SUBDIRS = common ddc i2c x86emu int10 fbdevhw os-support \
                parser ramdac shadowfb vbe vgahw \
diff --git a/hw/xfree86/drivers/Makefile.am b/hw/xfree86/drivers/Makefile.am
new file mode 100644
index 0000000..04d787f
--- /dev/null
+++ b/hw/xfree86/drivers/Makefile.am
@@ -0,0 +1,5 @@
+SUBDIRS =
+
+if XORG_DRIVER_MODESETTING
+SUBDIRS += modesetting
+endif
diff --git a/hw/xfree86/drivers/modesetting/Makefile.am b/hw/xfree86/drivers/modesetting/Makefile.am
index 3cc4624..f6c6041 100644
--- a/hw/xfree86/drivers/modesetting/Makefile.am
+++ b/hw/xfree86/drivers/modesetting/Makefile.am
@@ -24,11 +24,20 @@
 # _ladir passes a dummy rpath to libtool so the thing will actually link
 # TODO: -nostdlib/-Bstatic/-lgcc platform magic, not installing the .a, etc.
 
-AM_CFLAGS = $(XORG_CFLAGS) $(DRM_CFLAGS) $(UDEV_CFLAGS) $(CWARNFLAGS)
+AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) $(LIBDRM_CFLAGS) $(UDEV_CFLAGS) $(CWARNFLAGS)
+
+AM_CPPFLAGS = \
+	$(XORG_INCS) \
+	-I$(srcdir)/../../ddc \
+	-I$(srcdir)/../../i2c \
+	-I$(srcdir)/../../modes \
+	-I$(srcdir)/../../parser \
+	-I$(srcdir)/../../ramdac \
+	$(NULL)
 
 modesetting_drv_la_LTLIBRARIES = modesetting_drv.la
 modesetting_drv_la_LDFLAGS = -module -avoid-version
-modesetting_drv_la_LIBADD = @UDEV_LIBS@ @DRM_LIBS@
+modesetting_drv_la_LIBADD = $(UDEV_LIBS) $(DRM_LIBS)
 modesetting_drv_ladir = @moduledir@/drivers
 
 modesetting_drv_la_SOURCES = \
@@ -37,3 +46,17 @@ modesetting_drv_la_SOURCES = \
 	 driver.h \
 	 drmmode_display.c \
 	 drmmode_display.h
+
+drivermandir = $(DRIVER_MAN_DIR)
+driverman_PRE = modesetting.man
+driverman_DATA = $(driverman_PRE:man=@DRIVER_MAN_SUFFIX@)
+
+EXTRA_DIST = modesetting.man
+
+CLEANFILES = $(driverman_DATA)
+
+# String replacements in MAN_SUBSTS now come from xorg-macros.m4 via configure
+SUFFIXES = .$(DRIVER_MAN_SUFFIX) .man
+
+.man.$(DRIVER_MAN_SUFFIX):
+	$(AM_V_GEN)$(SED) $(MAN_SUBSTS) < $< > $@
diff --git a/hw/xfree86/drivers/modesetting/driver.c b/hw/xfree86/drivers/modesetting/driver.c
index eaa3a0f..b30c32c 100644
--- a/hw/xfree86/drivers/modesetting/driver.c
+++ b/hw/xfree86/drivers/modesetting/driver.c
@@ -29,8 +29,8 @@
  *
  */
 
-#ifdef HAVE_CONFIG_H
-#include "config.h"
+#ifdef HAVE_DIX_CONFIG_H
+#include "dix-config.h"
 #endif
 
 #include <unistd.h>
@@ -51,7 +51,7 @@
 #include "shadow.h"
 #include "xf86xv.h"
 #include <X11/extensions/Xv.h>
-#include <xorg-server.h>
+#include <xorg-config.h>
 #ifdef XSERVER_PLATFORM_BUS
 #include "xf86platformBus.h"
 #endif
@@ -144,7 +144,9 @@ static XF86ModuleVersionInfo VersRec = {
     MODINFOSTRING1,
     MODINFOSTRING2,
     XORG_VERSION_CURRENT,
-    PACKAGE_VERSION_MAJOR, PACKAGE_VERSION_MINOR, PACKAGE_VERSION_PATCHLEVEL,
+    XORG_VERSION_MAJOR,
+    XORG_VERSION_MINOR,
+    XORG_VERSION_PATCH,
     ABI_CLASS_VIDEODRV,
     ABI_VIDEODRV_VERSION,
     MOD_CLASS_VIDEODRV,
diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c b/hw/xfree86/drivers/modesetting/drmmode_display.c
index 31c39a2..d55157b 100644
--- a/hw/xfree86/drivers/modesetting/drmmode_display.c
+++ b/hw/xfree86/drivers/modesetting/drmmode_display.c
@@ -25,8 +25,8 @@
  *
  */
 
-#ifdef HAVE_CONFIG_H
-#include "config.h"
+#ifdef HAVE_DIX_CONFIG_H
+#include "dix-config.h"
 #endif
 
 #include <errno.h>
commit 30dcc10f6c9c4bacbc0e3652917c298ca9fb3898
Author: Adam Jackson <ajax at redhat.com>
Date:   Mon May 5 11:18:33 2014 -0400

    xfree86: Clean up some more alpha awareness
    
    Since the sparse stuff is gone none of these variables get used for
    anything, they're just dead side-effect-less execution.
    
    Reviewed-by: Eric Anholt <eric at anholt.net>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/hw/xfree86/os-support/bsd/Makefile.am b/hw/xfree86/os-support/bsd/Makefile.am
index 7133c0f..b01ea5b 100644
--- a/hw/xfree86/os-support/bsd/Makefile.am
+++ b/hw/xfree86/os-support/bsd/Makefile.am
@@ -27,9 +27,7 @@ if ALPHA_VIDEO
 # Cheat here and piggyback other alpha bits on ALPHA_VIDEO.
 ARCH_SOURCES = \
 	alpha_video.c \
-	bsd_ev56.c \
-	bsd_axp.c \
-	$(srcdir)/../shared/xf86Axp.c
+	bsd_ev56.c
 endif
 
 if ARM_VIDEO
diff --git a/hw/xfree86/os-support/bsd/alpha_video.c b/hw/xfree86/os-support/bsd/alpha_video.c
index b65b762..236def6 100644
--- a/hw/xfree86/os-support/bsd/alpha_video.c
+++ b/hw/xfree86/os-support/bsd/alpha_video.c
@@ -36,8 +36,6 @@
 #include <sys/sysctl.h>
 #endif
 
-#include "xf86Axp.h"
-
 #include "xf86_OSlib.h"
 #include "xf86OSpriv.h"
 
@@ -47,43 +45,9 @@
 #define MAP_FLAGS (MAP_FILE | MAP_SHARED)
 #endif
 
-axpDevice bsdGetAXP(void);
-
 #ifndef __NetBSD__
 extern unsigned long dense_base(void);
-
-static int axpSystem = -1;
-static unsigned long hae_thresh;
-static unsigned long hae_mask;
-
-static int
-has_bwx(void)
-{
-    static int bwx = 0;
-    size_t len = sizeof(bwx);
-    int error;
-
-#ifdef __OpenBSD__
-    int mib[3];
-
-    mib[0] = CTL_MACHDEP;
-    mib[1] = CPU_CHIPSET;
-    mib[2] = CPU_CHIPSET_BWX;
-
-    if ((error = sysctl(mib, 3, &bwx, &len, NULL, 0)) < 0)
-        return FALSE;
-    else
-        return bwx;
-#else
-    if ((error = sysctlbyname("hw.chipset.bwx", &bwx, &len, 0, 0)) < 0)
-        return FALSE;
-    else
-        return bwx;
-#endif
-}
 #else                           /* __NetBSD__ */
-static unsigned long hae_thresh = (1UL << 24);
-static unsigned long hae_mask = 0xf8000000UL;   /* XXX - should use xf86AXP.c */
 static struct alpha_bus_window *abw;
 static int abw_count = -1;
 
@@ -97,16 +61,6 @@ init_abw(void)
     }
 }
 
-static int
-has_bwx(void)
-{
-    if (abw_count < 0)
-        init_abw();
-
-    xf86Msg(X_INFO, "has_bwx = %d\n", abw[0].abw_abst.abst_flags & ABST_BWX ? 1 : 0);   /* XXXX */
-    return abw[0].abw_abst.abst_flags & ABST_BWX;
-}
-
 static unsigned long
 dense_base(void)
 {
@@ -216,18 +170,6 @@ xf86OSInitVidMem(VidMemInfoPtr pVidMem)
 {
     checkDevMem(TRUE);
 
-    if (has_bwx()) {
-        xf86Msg(X_PROBED, "Machine type has 8/16 bit access\n");
-    }
-    else {
-        xf86Msg(X_PROBED, "Machine needs sparse mapping\n");
-#ifndef __NetBSD__
-        if (axpSystem == -1)
-            axpSystem = bsdGetAXP();
-        hae_thresh = xf86AXPParams[axpSystem].hae_thresh;
-        hae_mask = xf86AXPParams[axpSystem].hae_mask;
-#endif                          /* __NetBSD__ */
-    }
     pVidMem->initialised = TRUE;
 }
 
diff --git a/hw/xfree86/os-support/bsd/bsd_axp.c b/hw/xfree86/os-support/bsd/bsd_axp.c
deleted file mode 100644
index e7a36f8..0000000
--- a/hw/xfree86/os-support/bsd/bsd_axp.c
+++ /dev/null
@@ -1,71 +0,0 @@
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <X11/X.h>
-#include "os.h"
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "shared/xf86Axp.h"
-#include <sys/param.h>
-#include "xf86_OSlib.h"
-#include <stdio.h>
-#include <sys/sysctl.h>
-
-axpDevice bsdGetAXP(void);
-
-/*
- * BSD does a very nice job providing system information to
- * user space programs. Unfortunately it doesn't provide all
- * the information required. Therefore we just obtain the
- * system type and look up the rest from a list we maintain
- * ourselves.
- */
-
-typedef struct {
-    char *name;
-    int type;
-} _AXP;
-
-static _AXP axpList[] = {
-    {"apecs", APECS},
-    {"pyxis", PYXIS},
-    {"cia", CIA},
-    {"irongate", IRONGATE},
-    {"lca", LCA},
-    {"t2", T2},
-    {"tsunami", TSUNAMI},
-    {NULL, SYS_NONE}
-};
-
-axpDevice
-bsdGetAXP(void)
-{
-    int i;
-    char sysname[64];
-    size_t len = sizeof(sysname);
-
-#ifdef __OpenBSD__
-    int mib[3];
-    int error;
-
-    mib[0] = CTL_MACHDEP;
-    mib[1] = CPU_CHIPSET;
-    mib[2] = CPU_CHIPSET_TYPE;
-
-    if ((error = sysctl(mib, 3, &sysname, &len, NULL, 0)) < 0)
-#else
-    if ((sysctlbyname("hw.chipset.type", &sysname, &len, 0, 0)) < 0)
-#endif
-        FatalError("bsdGetAXP: can't find machine type\n");
-#ifdef DEBUG
-    xf86Msg(X_INFO, "AXP is a: %s\n", sysname);
-#endif
-    for (i = 0;; i++) {
-        if (axpList[i].name == NULL)
-            return SYS_NONE;
-        if (!strcmp(sysname, axpList[i].name))
-            return axpList[i].type;
-    }
-}
diff --git a/hw/xfree86/os-support/linux/Makefile.am b/hw/xfree86/os-support/linux/Makefile.am
index 6fd317a..50fcd1f 100644
--- a/hw/xfree86/os-support/linux/Makefile.am
+++ b/hw/xfree86/os-support/linux/Makefile.am
@@ -2,9 +2,6 @@ noinst_LTLIBRARIES = liblinux.la
 
 if LINUX_ALPHA
 noinst_LTLIBRARIES += liblinuxev56.la
-PLATFORM_PCI_SUPPORT = \
-       $(srcdir)/lnx_axp.c \
-       $(srcdir)/../shared/xf86Axp.c
 
 liblinuxev56_la_CFLAGS = $(AM_CFLAGS) -mcpu=ev56
 
@@ -34,16 +31,12 @@ liblinux_la_SOURCES = lnx_init.c lnx_video.c \
 		     $(srcdir)/../shared/sigio.c \
                      $(ACPI_SRCS) \
                      $(APM_SRCS) \
-                     $(LOGIND_SRCS) \
-                     $(PLATFORM_PCI_SUPPORT)
+                     $(LOGIND_SRCS)
 
 AM_CFLAGS = -DUSESTDRES -DHAVE_SYSV_IPC $(DIX_CFLAGS) $(XORG_CFLAGS) $(PLATFORM_DEFINES)
 
 AM_CPPFLAGS = $(XORG_INCS) $(PLATFORM_INCLUDES) $(LIBDRM_CFLAGS)
 
-EXTRA_DIST = \
-	$(srcdir)/../shared/xf86Axp.h
-
 if LINUX_ALPHA
 liblinux_la_LIBADD = liblinuxev56.la
 endif
diff --git a/hw/xfree86/os-support/linux/lnx_axp.c b/hw/xfree86/os-support/linux/lnx_axp.c
deleted file mode 100644
index d65a3a4..0000000
--- a/hw/xfree86/os-support/linux/lnx_axp.c
+++ /dev/null
@@ -1,103 +0,0 @@
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <stdio.h>
-#include "xf86.h"
-#include "shared/xf86Axp.h"
-
-axpDevice lnxGetAXP(void);
-
-typedef struct {
-    char *sysName;
-    char *sysVari;
-    char *cpu;
-    axpDevice sys;
-} AXP;
-
-static AXP axpList[] = {
-    {"Tsunami", NULL, NULL, TSUNAMI},
-    {"Eiger", NULL, NULL, TSUNAMI},
-    {"Noname", NULL, NULL, LCA},
-    {"AlphaBook1", NULL, NULL, LCA},
-    {"EB66", NULL, NULL, LCA},
-    {"EB64+", NULL, NULL, APECS},
-    {"Noritake", NULL, "EV5", CIA},
-    {"Noritake", NULL, "EV56", CIA},
-    {"Noritake", NULL, NULL, APECS},
-    {"XL", NULL, NULL, APECS},
-    {"Avanti", NULL, NULL, APECS},
-    {"Mikasa", NULL, "EV5", CIA},
-    {"Mikasa", NULL, "EV56", CIA},
-    {"Mikasa", NULL, NULL, APECS},
-    {"EB164", "EB164", NULL, CIA},
-    {"EB164", "PC164", NULL, CIA},
-    {"EB164", "LX164", NULL, PYXIS},
-    {"EB164", "SX164", NULL, PYXIS},
-    {"EB164", "RX164", NULL, POLARIS},
-    {"Alcor", NULL, NULL, CIA},
-    {"Takara", NULL, NULL, CIA},
-    {"Sable", NULL, "EV5", T2_GAMMA},
-    {"Sable", NULL, "EV56", T2_GAMMA},
-    {"Sable", NULL, NULL, T2},
-    {"Rawhide", NULL, NULL, MCPCIA},
-    {"Jensen", NULL, NULL, JENSEN},
-    {"Miata", NULL, NULL, PYXIS_CIA},
-    {"Ruffian", NULL, NULL, PYXIS_CIA},
-    {"Nautilus", NULL, NULL, IRONGATE},
-    {NULL, NULL, NULL, SYS_NONE}
-};
-
-axpDevice
-lnxGetAXP(void)
-{
-    FILE *file;
-    int count = 0;
-    char res[256];
-    char cpu[255];
-    char systype[255];
-    char sysvari[255];
-
-    if (!(file = fopen("/proc/cpuinfo", "r")))
-        return SYS_NONE;
-    do {
-        if (!fgets(res, 0xff, file))
-            return SYS_NONE;
-        switch (count) {
-        case 1:
-            sscanf(res, "cpu model : %s", cpu);
-            DebugF("CPU %s\n", cpu);
-            break;
-        case 5:
-            sscanf(res, "system type : %s", systype);
-            DebugF("system type : %s\n", systype);
-            break;
-        case 6:
-            sscanf(res, "system variation : %s", sysvari);
-            DebugF("system variation: %s\n", sysvari);
-            break;
-        }
-        count++;
-    } while (count < 8);
-
-    fclose(file);
-
-    count = 0;
-
-    do {
-        if (!axpList[count].sysName || !strcmp(axpList[count].sysName, systype)) {
-            if (axpList[count].sysVari &&
-                strcmp(axpList[count].sysVari, sysvari)) {
-                count++;
-                continue;
-            };
-            if (axpList[count].cpu && strcmp(axpList[count].cpu, cpu)) {
-                count++;
-                continue;
-            }
-            return axpList[count].sys;
-        }
-        count++;
-    } while (1);
-}
diff --git a/hw/xfree86/os-support/linux/lnx_video.c b/hw/xfree86/os-support/linux/lnx_video.c
index 018d921..c09d719 100644
--- a/hw/xfree86/os-support/linux/lnx_video.c
+++ b/hw/xfree86/os-support/linux/lnx_video.c
@@ -38,9 +38,6 @@
 #include "xf86Priv.h"
 #include "xf86_OSlib.h"
 #include "xf86OSpriv.h"
-#ifdef __alpha__
-#include "shared/xf86Axp.h"
-#endif
 
 static Bool ExtendedEnabled = FALSE;
 
@@ -68,49 +65,13 @@ extern int iopl(int __level);
 
 #endif
 
-#ifdef __alpha__
-#define BUS_BASE bus_base
-#else
-#define BUS_BASE (0)
-#endif                          /*  __alpha__ */
-
 /***************************************************************************/
 /* Video Memory Mapping section                                            */
 /***************************************************************************/
 
-#if defined (__alpha__)
-extern void sethae(unsigned long hae);
-extern unsigned long _bus_base __P((void)) __attribute__ ((const));
-extern unsigned long _bus_base_sparse __P((void)) __attribute__ ((const));
-
-extern axpDevice lnxGetAXP(void);
-static axpDevice axpSystem = -1;
-static Bool needSparse;
-static unsigned long hae_thresh;
-static unsigned long hae_mask;
-static unsigned long bus_base;
-#endif
-
 void
 xf86OSInitVidMem(VidMemInfoPtr pVidMem)
 {
-#ifdef __alpha__
-    if (axpSystem == -1) {
-        axpSystem = lnxGetAXP();
-        if ((needSparse = (_bus_base_sparse() > 0))) {
-            hae_thresh = xf86AXPParams[axpSystem].hae_thresh;
-            hae_mask = xf86AXPParams[axpSystem].hae_mask;
-        }
-        bus_base = _bus_base();
-    }
-    if (needSparse) {
-        xf86Msg(X_INFO, "Machine needs sparse mapping\n");
-    }
-    else {
-        xf86Msg(X_INFO, "Machine type has 8/16 bit access\n");
-    }
-#endif                          /* __alpha__ */
-
     pVidMem->initialised = TRUE;
 }
 
diff --git a/hw/xfree86/os-support/shared/xf86Axp.c b/hw/xfree86/os-support/shared/xf86Axp.c
deleted file mode 100644
index 5f2f398..0000000
--- a/hw/xfree86/os-support/shared/xf86Axp.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (c) 2000 by The XFree86 Project, Inc.
- *
- * 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 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 COPYRIGHT HOLDER(S) OR AUTHOR(S) 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.
- *
- * Except as contained in this notice, the name of the copyright holder(s)
- * and author(s) shall not be used in advertising or otherwise to promote
- * the sale, use or other dealings in this Software without prior written
- * authorization from the copyright holder(s) and author(s).
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "xf86Axp.h"
-
-axpParams xf86AXPParams[] = {
-    {SYS_NONE, 0, 0, 0}
-    ,
-    {TSUNAMI, 0, 0, 0}
-    ,
-    {LCA, 1 << 24, 0xf8000000, 1UL << 32}
-    ,
-    {APECS, 1 << 24, 0xf8000000, 1UL << 32}
-    ,
-    {T2, 0, 0xFC000000, 1UL << 31}
-    ,
-    {T2_GAMMA, 0, 0xFC000000, 1UL << 31}
-    ,
-    {CIA, 0, 0xE0000000, 1UL << 34}
-    ,
-    {MCPCIA, 0, 0xf8000000, 1UL << 31}
-    ,
-    {JENSEN, 0, 0xE000000, 1UL << 32}
-    ,
-    {POLARIS, 0, 0, 0}
-    ,
-    {PYXIS, 0, 0, 0}
-    ,
-    {PYXIS_CIA, 0, 0xE0000000, 1UL << 34}
-    ,
-    {IRONGATE, 0, 0, 0}
-};
diff --git a/hw/xfree86/os-support/shared/xf86Axp.h b/hw/xfree86/os-support/shared/xf86Axp.h
deleted file mode 100644
index fded9d8..0000000
--- a/hw/xfree86/os-support/shared/xf86Axp.h
+++ /dev/null
@@ -1,33 +0,0 @@
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#ifndef _XF86_AXP_H_
-#define _XF86_AXP_H_
-
-typedef enum {
-    SYS_NONE,
-    TSUNAMI,
-    LCA,
-    APECS,
-    T2,
-    T2_GAMMA,
-    CIA,
-    MCPCIA,
-    JENSEN,
-    POLARIS,
-    PYXIS,
-    PYXIS_CIA,
-    IRONGATE
-} axpDevice;
-
-typedef struct {
-    axpDevice id;
-    unsigned long hae_thresh;
-    unsigned long hae_mask;
-    unsigned long size;
-} axpParams;
-
-extern axpParams xf86AXPParams[];
-
-#endif
commit 2e21c081d34d52ee49ac00a294d2e74caf529818
Author: Adam Jackson <ajax at redhat.com>
Date:   Fri May 2 13:00:21 2014 -0400

    xfree86: Remove the memory of MTRR awareness
    
    pciaccess does this for us, and none of our internal hooks really
    remain.  This does remove a cleanup pass from the BSD code, but the case
    it's covering (a previous server leaving MTRRs around) can't happen
    anymore.
    
    Reviewed-by: Eric Anholt <eric at anholt.net>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/configure.ac b/configure.ac
index cba7d24..b69caec 100644
--- a/configure.ac
+++ b/configure.ac
@@ -235,29 +235,6 @@ dnl fbdev header
 AC_CHECK_HEADERS([linux/fb.h], FBDEV=yes)
 AM_CONDITIONAL(FBDEVHW, [test "x$FBDEV" = xyes])
 
-dnl MTRR header
-AC_CHECK_HEADERS([asm/mtrr.h], ac_cv_asm_mtrr_h=yes)
-if test "x$ac_cv_asm_mtrr_h" = xyes; then
-	HAVE_MTRR=yes
-fi
-
-dnl BSD MTRR header
-AC_CHECK_HEADERS([sys/memrange.h], ac_cv_memrange_h=yes)
-if test "x$ac_cv_memrange_h" = xyes; then
-	HAVE_MTRR=yes
-fi
-
-if test "x$HAVE_MTRR" = xyes; then
-	AC_DEFINE(HAS_MTRR_SUPPORT, 1, [MTRR support available])
-fi
-
-dnl A NetBSD MTRR header
-AC_CHECK_HEADERS([machine/mtrr.h], ac_cv_machine_mtrr_h=yes)
-if test "x$ac_cv_machine_mtrr_h" = xyes; then
-	AC_DEFINE(HAS_MTRR_BUILTIN, 1, [Define to 1 if NetBSD built-in MTRR
-		support is available])
-fi
-
 dnl FreeBSD kldload support (sys/linker.h)
 AC_CHECK_HEADERS([sys/linker.h],
 	[ac_cv_sys_linker_h=yes],
diff --git a/hw/xfree86/doc/README.DRIcomp b/hw/xfree86/doc/README.DRIcomp
index 2d3ebf1..7388650 100644
--- a/hw/xfree86/doc/README.DRIcomp
+++ b/hw/xfree86/doc/README.DRIcomp
@@ -142,9 +142,6 @@ Here are the basic steps for kernel setup.
 
         o Enable all chipsets' support for AGP
 
-        o It's recommended that you turn on MTRRs under Processor type and
-          Features, but not required.
-
    o Configure the rest of the kernel as required for your system (i.e. Eth-
      ernet, SCSI, etc)
 
diff --git a/hw/xfree86/doc/Registry b/hw/xfree86/doc/Registry
index 48e24a2..ad5b9bf 100644
--- a/hw/xfree86/doc/Registry
+++ b/hw/xfree86/doc/Registry
@@ -231,7 +231,6 @@ DDC                       B     C    Enable/disable DDC
 DDC1                      B     C    Enable/disable DDC1
 DDC2                      B     C    Enable/disable DDC2
 DPMS                      O     C    Enable DPMS
-MTRR                      B     C    Enable/disable setting MTRRs
 
 BaudRate                  I     I    Serial port baud rate
 ButtonNumber              I     I    Button number (for touch screen?)
diff --git a/hw/xfree86/man/xorg.conf.man b/hw/xfree86/man/xorg.conf.man
index 1631212..378f26b 100644
--- a/hw/xfree86/man/xorg.conf.man
+++ b/hw/xfree86/man/xorg.conf.man
@@ -2023,12 +2023,6 @@ Default: false.
 Disables the Int10 module, a module that uses the int10 call to the BIOS
 of the graphics card to initialize it.
 Default: false.
-.TP 7
-.BI "Option \*qNoMTRR\*q"
-Disables MTRR (Memory Type Range Register) support, a feature of modern
-processors which can improve video performance by a factor of up to 2.5.
-Some hardware has buggy MTRR support, and some video drivers have been
-known to exhibit problems when MTRR's are used.
 .PP
 Each
 .B Screen
diff --git a/hw/xfree86/os-support/bsd/i386_video.c b/hw/xfree86/os-support/bsd/i386_video.c
index dae3555..6c3bbcb 100644
--- a/hw/xfree86/os-support/bsd/i386_video.c
+++ b/hw/xfree86/os-support/bsd/i386_video.c
@@ -34,27 +34,6 @@
 #include <errno.h>
 #include <sys/mman.h>
 
-#ifdef HAS_MTRR_SUPPORT
-#ifndef __NetBSD__
-#include <sys/types.h>
-#include <sys/memrange.h>
-#else
-#include "memrange.h"
-#endif
-#define X_MTRR_ID "XFree86"
-#endif
-
-#if defined(HAS_MTRR_BUILTIN) && defined(__NetBSD__)
-#include <machine/mtrr.h>
-#include <machine/sysarch.h>
-#include <sys/queue.h>
-#ifdef __x86_64__
-#define i386_set_mtrr x86_64_set_mtrr
-#define i386_get_mtrr x86_64_get_mtrr
-#define i386_iopl x86_64_iopl
-#endif
-#endif
-
 #include "xf86_OSlib.h"
 #include "xf86OSpriv.h"
 
@@ -85,10 +64,6 @@ static int devMemFd = -1;
 #define DEV_APERTURE "/dev/xf86"
 #endif
 
-#ifdef HAS_MTRR_SUPPORT
-static Bool cleanMTRR(void);
-#endif
-
 /*
  * Check if /dev/mem can be mmap'd.  If it can't print a warning when
  * "warn" is TRUE.
@@ -181,9 +156,6 @@ xf86OSInitVidMem(VidMemInfoPtr pVidMem)
 
     pci_system_init_dev_mem(devMemFd);
 
-#ifdef HAS_MTRR_SUPPORT
-    cleanMTRR();
-#endif
     pVidMem->initialised = TRUE;
 }
 
@@ -354,87 +326,3 @@ xf86SetRGBOut()
     return;
 }
 #endif
-
-#ifdef HAS_MTRR_SUPPORT
-/* memory range (MTRR) support for FreeBSD */
-
-/*
- * This code is experimental.  Some parts may be overkill, and other parts
- * may be incomplete.
- */
-
-/*
- * getAllRanges returns the full list of memory ranges with attributes set.
- */
-
-static struct mem_range_desc *
-getAllRanges(int *nmr)
-{
-    struct mem_range_desc *mrd;
-    struct mem_range_op mro;
-
-    /*
-     * Find how many ranges there are.  If this fails, then the kernel
-     * probably doesn't have MTRR support.
-     */
-    mro.mo_arg[0] = 0;
-    if (ioctl(devMemFd, MEMRANGE_GET, &mro))
-        return NULL;
-    *nmr = mro.mo_arg[0];
-    mrd = xnfalloc(*nmr * sizeof(struct mem_range_desc));
-    mro.mo_arg[0] = *nmr;
-    mro.mo_desc = mrd;
-    if (ioctl(devMemFd, MEMRANGE_GET, &mro)) {
-        free(mrd);
-        return NULL;
-    }
-    return mrd;
-}
-
-/*
- * cleanMTRR removes any memory attribute that may be left by a previous
- * X server.  Normally there won't be any, but this takes care of the
- * case where a server crashed without being able finish cleaning up.
- */
-
-static Bool
-cleanMTRR()
-{
-    struct mem_range_desc *mrd;
-    struct mem_range_op mro;
-    int nmr, i;
-
-    /* This shouldn't happen */
-    if (devMemFd < 0)
-        return FALSE;
-
-    if (!(mrd = getAllRanges(&nmr)))
-        return FALSE;
-
-    for (i = 0; i < nmr; i++) {
-        if (strcmp(mrd[i].mr_owner, X_MTRR_ID) == 0 &&
-            (mrd[i].mr_flags & MDF_ACTIVE)) {
-#ifdef DEBUG
-            ErrorF("Clean for (0x%lx,0x%lx)\n",
-                   (unsigned long) mrd[i].mr_base,
-                   (unsigned long) mrd[i].mr_len);
-#endif
-            if (mrd[i].mr_flags & MDF_FIXACTIVE) {
-                mro.mo_arg[0] = MEMRANGE_SET_UPDATE;
-                mrd[i].mr_flags = MDF_UNCACHEABLE;
-            }
-            else {
-                mro.mo_arg[0] = MEMRANGE_SET_REMOVE;
-            }
-            mro.mo_desc = mrd + i;
-            ioctl(devMemFd, MEMRANGE_SET, &mro);
-        }
-    }
-#ifdef DEBUG
-    sleep(10);
-#endif
-    free(mrd);
-    return TRUE;
-}
-
-#endif                          /* HAS_MTRR_SUPPORT */
diff --git a/include/dix-config.h.in b/include/dix-config.h.in
index 2203f82..4268b8f 100644
--- a/include/dix-config.h.in
+++ b/include/dix-config.h.in
@@ -57,9 +57,6 @@
 /* Support SHM */
 #undef HAS_SHM
 
-/* Define to 1 if you have the <asm/mtrr.h> header file. */
-#undef HAVE_ASM_MTRR_H
-
 /* Has backtrace support */
 #undef HAVE_BACKTRACE
 
diff --git a/include/xorg-config.h.in b/include/xorg-config.h.in
index 629ae40..7c03126 100644
--- a/include/xorg-config.h.in
+++ b/include/xorg-config.h.in
@@ -82,12 +82,6 @@
 /* Building vgahw module */
 #undef WITH_VGAHW
 
-/* Define to 1 if NetBSD built-in MTRR support is available */
-#undef HAS_MTRR_BUILTIN
-
-/* Define to 1 if BSD MTRR support is available */
-#undef HAS_MTRR_SUPPORT
-
 /* NetBSD PIO alpha IO */
 #undef USE_ALPHA_PIO
 
commit c42712ab4d8eec56704ad5422d8f54befeb1e886
Author: Adam Jackson <ajax at redhat.com>
Date:   Fri May 2 12:58:23 2014 -0400

    xfree86: Remove xf86CheckMTRR
    
    Die die die die die.
    
    Reviewed-by: Eric Anholt <eric at anholt.net>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/hw/xfree86/os-support/shared/vidmem.c b/hw/xfree86/os-support/shared/vidmem.c
index 1d4f6a9..a6bf677 100644
--- a/hw/xfree86/os-support/shared/vidmem.c
+++ b/hw/xfree86/os-support/shared/vidmem.c
@@ -42,72 +42,7 @@
  * This file contains the common part of the video memory mapping functions
  */
 
-/*
- * Get a piece of the ScrnInfoRec.  At the moment, this is only used to hold
- * the MTRR option information, but it is likely to be expanded if we do
- * auto unmapping of memory at VT switch.
- *
- */
-
-typedef struct {
-    Bool mtrrEnabled;
-    MessageType mtrrFrom;
-    Bool mtrrOptChecked;
-    ScrnInfoPtr pScrn;
-} VidMapRec, *VidMapPtr;
-
-static int vidMapIndex = -1;
-
-#define VIDMAPPTR(p) ((VidMapPtr)((p)->privates[vidMapIndex].ptr))
-
 static VidMemInfo vidMemInfo = { FALSE, };
-static VidMapRec vidMapRec = { TRUE, X_DEFAULT, FALSE, NULL };
-
-static VidMapPtr
-getVidMapRec(int scrnIndex)
-{
-    VidMapPtr vp;
-    ScrnInfoPtr pScrn;
-
-    if ((scrnIndex < 0) || !(pScrn = xf86Screens[scrnIndex]))
-        return &vidMapRec;
-
-    if (vidMapIndex < 0)
-        vidMapIndex = xf86AllocateScrnInfoPrivateIndex();
-
-    if (VIDMAPPTR(pScrn) != NULL)
-        return VIDMAPPTR(pScrn);
-
-    vp = pScrn->privates[vidMapIndex].ptr = xnfcalloc(sizeof(VidMapRec), 1);
-    vp->mtrrEnabled = TRUE;     /* default to enabled */
-    vp->mtrrFrom = X_DEFAULT;
-    vp->mtrrOptChecked = FALSE;
-    vp->pScrn = pScrn;
-    return vp;
-}
-
-enum { OPTION_MTRR };
-
-static const OptionInfoRec opts[] = {
-    {OPTION_MTRR, "mtrr", OPTV_BOOLEAN, {0}, FALSE},
-    {-1, NULL, OPTV_NONE, {0}, FALSE}
-};
-
-static void
-checkMtrrOption(VidMapPtr vp)
-{
-    if (!vp->mtrrOptChecked && vp->pScrn && vp->pScrn->options != NULL) {
-        OptionInfoPtr options;
-
-        options = xnfalloc(sizeof(opts));
-        (void) memcpy(options, opts, sizeof(opts));
-        xf86ProcessOptions(vp->pScrn->scrnIndex, vp->pScrn->options, options);
-        if (xf86GetOptValBool(options, OPTION_MTRR, &vp->mtrrEnabled))
-            vp->mtrrFrom = X_CONFIG;
-        free(options);
-        vp->mtrrOptChecked = TRUE;
-    }
-}
 
 void
 xf86InitVidMem(void)
@@ -117,20 +52,3 @@ xf86InitVidMem(void)
         xf86OSInitVidMem(&vidMemInfo);
     }
 }
-
-Bool
-xf86CheckMTRR(int ScreenNum)
-{
-    VidMapPtr vp = getVidMapRec(ScreenNum);
-
-    /*
-     * Check the "mtrr" option even when MTRR isn't supported to avoid
-     * warnings about unrecognised options.
-     */
-    checkMtrrOption(vp);
-
-    if (vp->mtrrEnabled)
-        return TRUE;
-
-    return FALSE;
-}
diff --git a/hw/xfree86/os-support/xf86_OSproc.h b/hw/xfree86/os-support/xf86_OSproc.h
index 1c1cc5e..822bab2 100644
--- a/hw/xfree86/os-support/xf86_OSproc.h
+++ b/hw/xfree86/os-support/xf86_OSproc.h
@@ -112,7 +112,6 @@
 _XFUNCPROTOBEGIN
 
 /* public functions */
-extern _X_EXPORT _X_DEPRECATED Bool xf86CheckMTRR(int);
 extern _X_EXPORT Bool xf86EnableIO(void);
 extern _X_EXPORT void xf86DisableIO(void);
 
commit 8686463de7e1ef9814824d46526d8177a7a492a0
Author: Adam Jackson <ajax at redhat.com>
Date:   Fri May 2 12:55:37 2014 -0400

    xfree86: Remove xf86ReadBIOS
    
    Not being used externally or internally anymore.
    
    Reviewed-by: Eric Anholt <eric at anholt.net>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/hw/xfree86/os-support/bsd/alpha_video.c b/hw/xfree86/os-support/bsd/alpha_video.c
index faa3a07..b65b762 100644
--- a/hw/xfree86/os-support/bsd/alpha_video.c
+++ b/hw/xfree86/os-support/bsd/alpha_video.c
@@ -231,50 +231,6 @@ xf86OSInitVidMem(VidMemInfoPtr pVidMem)
     pVidMem->initialised = TRUE;
 }
 
-/*
- * Read BIOS via mmap()ing DEV_MEM
- */
-
-int
-xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
-             int Len)
-{
-    unsigned char *ptr;
-    int psize;
-    int mlen;
-
-    checkDevMem(TRUE);
-    if (devMemFd == -1) {
-        return -1;
-    }
-
-    psize = getpagesize();
-    Offset += Base & (psize - 1);
-    Base &= ~(psize - 1);
-    mlen = (Offset + Len + psize - 1) & ~(psize - 1);
-    ptr = (unsigned char *) mmap((caddr_t) 0, mlen, PROT_READ,
-                                 MAP_SHARED, devMemFd, (off_t) Base + BUS_BASE);
-    if ((long) ptr == -1) {
-        xf86Msg(X_WARNING,
-                "xf86ReadBIOS: %s mmap[s=%x,a=%lx,o=%lx] failed (%s)\n",
-                DEV_MEM, Len, Base, Offset, strerror(errno));
-        return -1;
-    }
-#ifdef DEBUG
-    xf86MsgVerb(X_INFO, 3,
-                "xf86ReadBIOS: BIOS at 0x%08x has signature 0x%04x\n", Base,
-                ptr[0] | (ptr[1] << 8));
-#endif
-    (void) memcpy(Buf, (void *) (ptr + Offset), Len);
-    (void) munmap((caddr_t) ptr, mlen);
-#ifdef DEBUG
-    xf86MsgVerb(X_INFO, 3, "xf86ReadBIOS(%x, %x, Buf, %x)"
-                "-> %02x %02x %02x %02x...\n",
-                Base, Offset, Len, Buf[0], Buf[1], Buf[2], Buf[3]);
-#endif
-    return Len;
-}
-
 #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__)
 
 extern int ioperm(unsigned long from, unsigned long num, int on);
diff --git a/hw/xfree86/os-support/bsd/arm_video.c b/hw/xfree86/os-support/bsd/arm_video.c
index 60f5bca..3a639b8 100644
--- a/hw/xfree86/os-support/bsd/arm_video.c
+++ b/hw/xfree86/os-support/bsd/arm_video.c
@@ -130,49 +130,6 @@ xf86OSInitVidMem(VidMemInfoPtr pVidMem)
     pVidMem->initialised = TRUE;
 }
 
-/*
- * Read BIOS via mmap()ing DEV_MEM
- */
-
-int
-xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
-             int Len)
-{
-    unsigned char *ptr;
-    int psize;
-    int mlen;
-
-    checkDevMem(TRUE);
-    if (devMemFd == -1) {
-        return -1;
-    }
-
-    psize = getpagesize();
-    Offset += Base & (psize - 1);
-    Base &= ~(psize - 1);
-    mlen = (Offset + Len + psize - 1) & ~(psize - 1);
-    ptr = (unsigned char *) mmap((caddr_t) 0, mlen, PROT_READ,
-                                 MAP_SHARED, devMemFd, (off_t) Base + BUS_BASE);
-    if ((long) ptr == -1) {
-        xf86Msg(X_WARNING,
-                "xf86ReadBIOS: %s mmap[s=%x,a=%x,o=%x] failed (%s)\n",
-                DEV_MEM, Len, Base, Offset, strerror(errno));
-        return -1;
-    }
-#ifdef DEBUG
-    ErrorF("xf86ReadBIOS: BIOS at 0x%08x has signature 0x%04x\n",
-           Base, ptr[0] | (ptr[1] << 8));
-#endif
-    (void) memcpy(Buf, (void *) (ptr + Offset), Len);
-    (void) munmap((caddr_t) ptr, mlen);
-#ifdef DEBUG
-    xf86MsgVerb(X_INFO, 3, "xf86ReadBIOS(%x, %x, Buf, %x)"
-                "-> %02x %02x %02x %02x...\n",
-                Base, Offset, Len, Buf[0], Buf[1], Buf[2], Buf[3]);
-#endif
-    return Len;
-}
-
 #ifdef USE_DEV_IO
 static int IoFd = -1;
 
diff --git a/hw/xfree86/os-support/bsd/i386_video.c b/hw/xfree86/os-support/bsd/i386_video.c
index 2b2c2a3..dae3555 100644
--- a/hw/xfree86/os-support/bsd/i386_video.c
+++ b/hw/xfree86/os-support/bsd/i386_video.c
@@ -187,54 +187,6 @@ xf86OSInitVidMem(VidMemInfoPtr pVidMem)
     pVidMem->initialised = TRUE;
 }
 
-/*
- * Read BIOS via mmap()ing DEV_MEM
- */
-
-int
-xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
-             int Len)
-{
-    unsigned char *ptr;
-    int psize;
-    int mlen;
-
-    checkDevMem(TRUE);
-    if (devMemFd == -1) {
-        return -1;
-    }
-
-    psize = getpagesize();
-    Offset += Base & (psize - 1);
-    Base &= ~(psize - 1);
-    mlen = (Offset + Len + psize - 1) & ~(psize - 1);
-    ptr = (unsigned char *) mmap((caddr_t) 0, mlen, PROT_READ,
-                                 MAP_SHARED, devMemFd, (off_t) Base);
-    if ((long) ptr == -1) {
-        xf86Msg(X_WARNING,
-                "xf86ReadBIOS: %s mmap[s=%x,a=%lx,o=%lx] failed (%s)\n",
-                DEV_MEM, Len, Base, Offset, strerror(errno));
-#ifdef __OpenBSD__
-        if (Base < 0xa0000) {
-            xf86Msg(X_WARNING, SYSCTL_MSG2);
-        }
-#endif
-        return -1;
-    }
-#ifdef DEBUG
-    ErrorF("xf86ReadBIOS: BIOS at 0x%08x has signature 0x%04x\n",
-           Base, ptr[0] | (ptr[1] << 8));
-#endif
-    (void) memcpy(Buf, (void *) (ptr + Offset), Len);
-    (void) munmap((caddr_t) ptr, mlen);
-#ifdef DEBUG
-    xf86MsgVerb(X_INFO, 3, "xf86ReadBIOS(%x, %x, Buf, %x)"
-                "-> %02x %02x %02x %02x...\n",
-                Base, Offset, Len, Buf[0], Buf[1], Buf[2], Buf[3]);
-#endif
-    return Len;
-}
-
 #ifdef USE_I386_IOPL
 /***************************************************************************/
 /* I/O Permissions section                                                 */
diff --git a/hw/xfree86/os-support/bsd/ppc_video.c b/hw/xfree86/os-support/bsd/ppc_video.c
index 0cecd48..b1cf7eb 100644
--- a/hw/xfree86/os-support/bsd/ppc_video.c
+++ b/hw/xfree86/os-support/bsd/ppc_video.c
@@ -56,30 +56,6 @@ xf86OSInitVidMem(VidMemInfoPtr pVidMem)
 
 volatile unsigned char *ioBase = MAP_FAILED;
 
-int
-xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
-             int Len)
-{
-    int rv;
-    static int kmem = -1;
-
-    if (kmem == -1) {
-        kmem = open(DEV_MEM, 2);
-        if (kmem == -1) {
-            FatalError("xf86ReadBIOS: open %s", DEV_MEM);
-        }
-    }
-
-#ifdef DEBUG
-    xf86MsgVerb(X_INFO, 3, "xf86ReadBIOS() %lx %lx, %x\n", Base, Offset, Len);
-#endif
-
-    lseek(kmem, Base + Offset, 0);
-    rv = read(kmem, Buf, Len);
-
-    return rv;
-}
-
 Bool
 xf86EnableIO()
 {
diff --git a/hw/xfree86/os-support/bsd/sparc64_video.c b/hw/xfree86/os-support/bsd/sparc64_video.c
index b87afc1..5bed017 100644
--- a/hw/xfree86/os-support/bsd/sparc64_video.c
+++ b/hw/xfree86/os-support/bsd/sparc64_video.c
@@ -43,11 +43,3 @@ xf86OSInitVidMem(VidMemInfoPtr pVidMem)
 {
     pVidMem->initialised = TRUE;
 }
-
-int
-xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
-             int Len)
-{
-
-    return 0;
-}
diff --git a/hw/xfree86/os-support/hurd/Makefile.am b/hw/xfree86/os-support/hurd/Makefile.am
index f228c1c..3866054 100644
--- a/hw/xfree86/os-support/hurd/Makefile.am
+++ b/hw/xfree86/os-support/hurd/Makefile.am
@@ -1,6 +1,6 @@
 noinst_LTLIBRARIES = libhurd.la
 
-libhurd_la_SOURCES = hurd_bell.c hurd_init.c hurd_mmap.c \
+libhurd_la_SOURCES = hurd_bell.c hurd_init.c \
 		hurd_video.c \
 		$(srcdir)/../shared/VTsw_noop.c \
 		$(srcdir)/../shared/posix_tty.c \
diff --git a/hw/xfree86/os-support/hurd/hurd_mmap.c b/hw/xfree86/os-support/hurd/hurd_mmap.c
deleted file mode 100644
index 8e089ca..0000000
--- a/hw/xfree86/os-support/hurd/hurd_mmap.c
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright 1997 by UCHIYAMA Yasushi
- *
- * 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 UCHIYAMA Yasushi not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  UCHIYAMA Yasushi makes no representations
- * about the suitability of this software for any purpose.  It is provided
- * "as is" without express or implied warranty.
- *
- * UCHIYAMA YASUSHI DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL UCHIYAMA YASUSHI BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- *
- */
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include<mach.h>
-#include<device/device.h>
-#include<mach/machine/mach_i386.h>
-#include <hurd.h>
-
-#include <X11/X.h>
-
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86_OSlib.h"
-
-#define BIOS_SIZE 0x20000
-
-int
-xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
-             int Len)
-{
-    mach_port_t device, mem_dev;
-    memory_object_t mem_obj;
-    vm_address_t addr = (vm_address_t) 0;       /* serach starting address */
-    kern_return_t err;
-
-    err = get_privileged_ports(NULL, &device);
-    if (err) {
-        errno = err;
-        FatalError("xf86ReadBIOS() can't get_privileged_ports. (%s)\n",
-                   strerror(errno));
-    }
-    err = device_open(device, D_READ | D_WRITE, "mem", &mem_dev);
-    mach_port_deallocate(mach_task_self(), device);
-    if (err) {
-        errno = err;
-        FatalError("xf86ReadBIOS() can't device_open. (%s)\n", strerror(errno));
-    }
-    err =
-        device_map(mem_dev, VM_PROT_READ | VM_PROT_WRITE, Base, BIOS_SIZE,
-                   &mem_obj, 0);
-    if (err) {
-        errno = err;
-        FatalError("xf86ReadBIOS() can't device_map. (%s)\n", strerror(errno));
-    }
-    err = vm_map(mach_task_self(),
-                 &addr,
-                 BIOS_SIZE,
-                 0,
-                 TRUE,
-                 mem_obj,
-                 Base,
-                 FALSE,
-                 VM_PROT_READ | VM_PROT_WRITE,
-                 VM_PROT_READ | VM_PROT_WRITE, VM_INHERIT_SHARE);
-    mach_port_deallocate(mach_task_self(), mem_obj);
-    if (err) {
-        errno = err;
-        FatalError("xf86ReadBIOS() can't vm_map. (%s)\n", strerror(errno));
-    }
-
-    memcpy(Buf, (void *) ((int) addr + Offset), Len);
-
-    err = vm_deallocate(mach_task_self(), addr, BIOS_SIZE);
-    if (err) {
-        errno = err;
-        FatalError("xf86ReadBIOS() can't vm_deallocate. (%s)\n",
-                   strerror(errno));
-    }
-
-    return Len;
-}
diff --git a/hw/xfree86/os-support/linux/Makefile.am b/hw/xfree86/os-support/linux/Makefile.am
index 1686dc2..6fd317a 100644
--- a/hw/xfree86/os-support/linux/Makefile.am
+++ b/hw/xfree86/os-support/linux/Makefile.am
@@ -28,7 +28,6 @@ endif
 
 liblinux_la_SOURCES = lnx_init.c lnx_video.c \
                      lnx_agp.c lnx_kmod.c lnx_bell.c lnx_platform.c \
-                     $(srcdir)/../shared/bios_mmap.c \
 		     $(srcdir)/../shared/VTsw_usl.c \
 		     $(srcdir)/../shared/posix_tty.c \
                      $(srcdir)/../shared/vidmem.c \
diff --git a/hw/xfree86/os-support/shared/bios_mmap.c b/hw/xfree86/os-support/shared/bios_mmap.c
deleted file mode 100644
index e000dc9..0000000
--- a/hw/xfree86/os-support/shared/bios_mmap.c
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Copyright 1993 by David Wexelblat <dwex at goblin.org>
- *
- * 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 David Wexelblat not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  David Wexelblat makes no representations
- * about the suitability of this software for any purpose.  It is provided
- * "as is" without express or implied warranty.
- *
- * DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL DAVID WEXELBLAT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- *
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <X11/X.h>
-
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86_OSlib.h"
-
-/*
- * Read BIOS via mmap()ing DEV_MEM
- */
-
-#ifndef __alpha__
-int
-xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
-             int Len)
-{
-    int fd;
-    unsigned char *ptr;
-    int psize;
-    int mlen;
-
-    if ((fd = open(DEV_MEM, O_RDONLY)) < 0) {
-        xf86Msg(X_WARNING, "xf86ReadBIOS: Failed to open %s (%s)\n",
-                DEV_MEM, strerror(errno));
-        return -1;
-    }
-    psize = getpagesize();
-    Offset += Base & (psize - 1);
-    Base &= ~(psize - 1);
-    mlen = (Offset + Len + psize - 1) & ~(psize - 1);
-    ptr = (unsigned char *) mmap((caddr_t) 0, mlen, PROT_READ,
-                                 MAP_SHARED, fd, (off_t) Base);
-    if (ptr == MAP_FAILED) {
-        xf86Msg(X_WARNING, "xf86ReadBIOS: %s mmap failed (%s)\n",
-                DEV_MEM, strerror(errno));
-        close(fd);
-        return -1;
-    }
-    DebugF("xf86ReadBIOS: BIOS at 0x%08x has signature 0x%04x\n",
-           Base, ptr[0] | (ptr[1] << 8));
-    (void) memcpy(Buf, (void *) (ptr + Offset), Len);
-    (void) munmap((caddr_t) ptr, mlen);
-    (void) close(fd);
-    return Len;
-}
-
-#else                           /* __alpha__ */
-
-  /*
-   *  We trick "mmap" into mapping BUS memory for us via BUS_BASE,
-   *  which is the KSEG address of the start of the DENSE memory
-   *  area.
-   */
-
-  /*
-   * NOTE: there prolly ought to be more validity checks and all
-   *  re: boundaries and sizes and such...
-   */
-
-#ifdef linux
-
-extern unsigned long _bus_base(void);
-
-#define BUS_BASE _bus_base()
-
-#else
-
-extern u_int64_t dense_base(void);
-
-#define BUS_BASE dense_base()
-
-#endif
-
-int
-xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
-             int Len)
-{
-    caddr_t base;
-    int fd;
-    int psize;
-    int mlen;
-
-    if ((fd = open(DEV_MEM, O_RDONLY)) < 0) {
-        xf86Msg(X_WARNING, "xf86ReadBIOS: Failed to open %s (%s)\n",
-                DEV_MEM, strerror(errno));
-        return -1;
-    }
-
-    psize = getpagesize();
-    Offset += Base & (psize - 1);
-    Base &= ~(psize - 1);
-    mlen = (Offset + Len + psize - 1) & ~(psize - 1);
-    base = mmap((caddr_t) 0, mlen, PROT_READ,
-                MAP_SHARED, fd, (off_t) (Base + BUS_BASE));
-
-    if (base == MAP_FAILED) {
-        xf86Msg(X_WARNING, "xf86ReadBIOS: Failed to mmap %s (%s)\n",
-                DEV_MEM, strerror(errno));
-        return -1;
-    }
-
-    xf86SlowBCopyFromBus((unsigned char *) (base + Offset), Buf, Len);
-
-    munmap((caddr_t) base, mlen);
-    close(fd);
-    return Len;
-}
-
-#endif                          /* __alpha__ */
diff --git a/hw/xfree86/os-support/solaris/sun_vid.c b/hw/xfree86/os-support/solaris/sun_vid.c
index bab449d..25f7618 100644
--- a/hw/xfree86/os-support/solaris/sun_vid.c
+++ b/hw/xfree86/os-support/solaris/sun_vid.c
@@ -63,96 +63,12 @@
 /* Video Memory Mapping section 					   */
 /***************************************************************************/
 
-static char *apertureDevName = NULL;
-static int apertureDevFD_ro = -1;
-static int apertureDevFD_rw = -1;
-
-static Bool
-solOpenAperture(void)
-{
-    if (apertureDevName == NULL) {
-        apertureDevName = "/dev/xsvc";
-        if ((apertureDevFD_rw = open(apertureDevName, O_RDWR)) < 0) {
-            xf86MsgVerb(X_WARNING, 0,
-                        "solOpenAperture: failed to open %s (%s)\n",
-                        apertureDevName, strerror(errno));
-            apertureDevName = "/dev/fbs/aperture";
-            apertureDevFD_rw = open(apertureDevName, O_RDWR);
-        }
-        apertureDevFD_ro = open(apertureDevName, O_RDONLY);
-
-        if ((apertureDevFD_rw < 0) || (apertureDevFD_ro < 0)) {
-            xf86MsgVerb(X_WARNING, 0,
-                        "solOpenAperture: failed to open %s (%s)\n",
-                        apertureDevName, strerror(errno));
-            xf86MsgVerb(X_WARNING, 0,
-                        "solOpenAperture: either /dev/fbs/aperture"
-                        " or /dev/xsvc required\n");
-
-            apertureDevName = NULL;
-
-            if (apertureDevFD_rw >= 0) {
-                close(apertureDevFD_rw);
-            }
-            apertureDevFD_rw = -1;
-
-            if (apertureDevFD_ro >= 0) {
-                close(apertureDevFD_ro);
-            }
-            apertureDevFD_ro = -1;
-
-            return FALSE;
-        }
-    }
-    return TRUE;
-}
-
 _X_HIDDEN void
 xf86OSInitVidMem(VidMemInfoPtr pVidMem)
 {
     pVidMem->initialised = TRUE;
 }
 
-/*
- * Read BIOS via mmap()ing physical memory.
- */
-int
-xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
-             int Len)
-{
-    unsigned char *ptr;
-    int psize;
-    int mlen;
-
-    psize = getpagesize();
-    Offset += Base & (psize - 1);
-    Base &= ~(psize - 1);
-    mlen = (Offset + Len + psize - 1) & ~(psize - 1);
-
-    if (solOpenAperture() == FALSE) {
-        xf86Msg(X_WARNING,
-                "xf86ReadBIOS: Failed to open aperture to read BIOS\n");
-        return -1;
-    }
-
-    ptr = (unsigned char *) mmap(NULL, mlen, PROT_READ,
-                                 MAP_SHARED, apertureDevFD_ro, (off_t) Base);
-    if (ptr == MAP_FAILED) {
-        xf86Msg(X_WARNING, "xf86ReadBIOS: %s mmap failed [0x%08lx, 0x%04x]\n",
-                apertureDevName, Base, mlen);
-        return -1;
-    }
-
-    (void) memcpy(Buf, (void *) (ptr + Offset), Len);
-    if (munmap((caddr_t) ptr, mlen) != 0) {
-        xf86MsgVerb(X_WARNING, 0,
-                    "xf86ReadBIOS: failed to unmap %s (0x%p,0x%x) (%s)\n",
-                    apertureDevName, ptr, mlen, strerror(errno));
-    }
-
-    return Len;
-}
-
 /***************************************************************************/
 /* I/O Permissions section						   */
 /***************************************************************************/
diff --git a/hw/xfree86/os-support/stub/Makefile.am b/hw/xfree86/os-support/stub/Makefile.am
index a39e17d..19468c6 100644
--- a/hw/xfree86/os-support/stub/Makefile.am
+++ b/hw/xfree86/os-support/stub/Makefile.am
@@ -14,6 +14,5 @@ libstub_la_SOURCES = \
 	$(srcdir)/../shared/posix_tty.c \
 	$(srcdir)/../shared/sigio.c \
 	stub_bell.c \
-	stub_bios.c \
 	stub_init.c \
 	stub_video.c
diff --git a/hw/xfree86/os-support/stub/stub_bios.c b/hw/xfree86/os-support/stub/stub_bios.c
deleted file mode 100644
index dbc92fc..0000000
--- a/hw/xfree86/os-support/stub/stub_bios.c
+++ /dev/null
@@ -1,12 +0,0 @@
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "xf86_OSlib.h"
-
-int
-xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
-             int Len)
-{
-    return -1;
-}
diff --git a/hw/xfree86/os-support/xf86_OSproc.h b/hw/xfree86/os-support/xf86_OSproc.h
index 5337d7b..1c1cc5e 100644
--- a/hw/xfree86/os-support/xf86_OSproc.h
+++ b/hw/xfree86/os-support/xf86_OSproc.h
@@ -113,8 +113,6 @@ _XFUNCPROTOBEGIN
 
 /* public functions */
 extern _X_EXPORT _X_DEPRECATED Bool xf86CheckMTRR(int);
-extern _X_EXPORT int xf86ReadBIOS(unsigned long, unsigned long, unsigned char *,
-                                  int);
 extern _X_EXPORT Bool xf86EnableIO(void);
 extern _X_EXPORT void xf86DisableIO(void);
 
commit 21b216ad6ce2e9c89359b95e4196e42d91bf9420
Author: Adam Jackson <ajax at redhat.com>
Date:   Fri May 2 12:46:45 2014 -0400

    int10: Port off xf86ReadBIOS
    
    If the linux vm86 backend changes look somewhat horrifying to you,
    that's because you have taste.
    
    Reviewed-by: Eric Anholt <eric at anholt.net>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/hw/xfree86/int10/generic.c b/hw/xfree86/int10/generic.c
index 73a1e5e..012d194 100644
--- a/hw/xfree86/int10/generic.c
+++ b/hw/xfree86/int10/generic.c
@@ -99,6 +99,20 @@ static void UnmapVRam(xf86Int10InfoPtr pInt);
 
 static void *sysMem = NULL;
 
+static Bool
+readIntVec(struct pci_device *dev, unsigned char *buf, int len)
+{
+    void *map;
+
+    if (!pci_device_map_legacy(dev, 0, len, 0, &map))
+        return FALSE;
+
+    memcpy(buf, map, len);
+    pci_device_unmap_legacy(dev, map, len);
+
+    return TRUE;
+}
+
 xf86Int10InfoPtr
 xf86ExtendedInitInt10(int entityIndex, int Flags)
 {
@@ -144,7 +158,7 @@ xf86ExtendedInitInt10(int entityIndex, int Flags)
                               PCI_DEV_MAP_FLAG_WRITABLE, &sysMem);
     INTPriv(pInt)->sysMem = sysMem;
 
-    if (xf86ReadBIOS(0, 0, base, LOW_PAGE_SIZE) < 0) {
+    if (!readIntVec(pInt->dev, base, LOW_PAGE_SIZE)) {
         xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Cannot read int vect\n");
         goto error1;
     }
diff --git a/hw/xfree86/os-support/linux/int10/linux.c b/hw/xfree86/os-support/linux/int10/linux.c
index 6181eb9..79b9a88 100644
--- a/hw/xfree86/os-support/linux/int10/linux.c
+++ b/hw/xfree86/os-support/linux/int10/linux.c
@@ -70,6 +70,20 @@ static Int10LinuxSubModuleState int10LinuxLoadSubModule(ScrnInfoPtr pScrn);
 
 #endif                          /* DoSubModules */
 
+static Bool
+readLegacy(struct pci_device *dev, unsigned char *buf, int base, int len)
+{
+    void *map;
+
+    if (!pci_device_map_legacy(dev, base, len, 0, &map))
+        return FALSE;
+
+    memcpy(buf, map, len);
+    pci_device_unmap_legacy(dev, man, len);
+
+    return TRUE;
+}
+
 xf86Int10InfoPtr
 xf86ExtendedInitInt10(int entityIndex, int Flags)
 {
@@ -222,7 +236,8 @@ xf86ExtendedInitInt10(int entityIndex, int Flags)
     Int10Current = pInt;
 
     DebugF("Mapping int area\n");
-    if (xf86ReadBIOS(0, 0, (unsigned char *) 0, LOW_PAGE_SIZE) < 0) {
+    /* note: yes, we really are writing the 0 page here */
+    if (!readLegacy(pInt->dev, (unsigned char *) 0, 0, LOW_PAGE_SIZE)) {
         xf86DrvMsg(screen, X_ERROR, "Cannot read int vect\n");
         goto error3;
     }
@@ -236,7 +251,7 @@ xf86ExtendedInitInt10(int entityIndex, int Flags)
         memset((void *) V_BIOS, 0, SYS_BIOS - V_BIOS);
         DebugF("Reading BIOS\n");
         for (cs = V_BIOS; cs < SYS_BIOS; cs += V_BIOS_SIZE)
-            if (xf86ReadBIOS(cs, 0, (void *) cs, V_BIOS_SIZE) < V_BIOS_SIZE)
+            if (!readLegacy(pInt->dev, (void *)cs, cs, V_BIOS_SIZE))
                 xf86DrvMsg(screen, X_WARNING,
                            "Unable to retrieve all of segment 0x%06lX.\n",
                            (long) cs);
commit 96c0da812a563d8229dc1396ac801329b3bcba91
Author: Adam Jackson <ajax at redhat.com>
Date:   Fri May 2 12:39:01 2014 -0400

    xfree86: Remove xf86LinearVidMem
    
    The only driver even pretending to check the result is mach64 anyway.
    
    Reviewed-by: Eric Anholt <eric at anholt.net>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/hw/xfree86/os-support/bsd/alpha_video.c b/hw/xfree86/os-support/bsd/alpha_video.c
index 3aeae58..faa3a07 100644
--- a/hw/xfree86/os-support/bsd/alpha_video.c
+++ b/hw/xfree86/os-support/bsd/alpha_video.c
@@ -132,7 +132,6 @@ dense_base(void)
                   "\trefer to xf86(4) for details"
 #endif
 
-static Bool useDevMem = FALSE;
 static int devMemFd = -1;
 
 #ifdef HAS_APERTURE_DRV
@@ -164,7 +163,6 @@ checkDevMem(Bool warn)
         if (base != MAP_FAILED) {
             munmap((caddr_t) base, 4096);
             devMemFd = fd;
-            useDevMem = TRUE;
             xf86Msg(X_INFO, "checkDevMem: using aperture driver %s\n",
                     DEV_APERTURE);
             return;
@@ -185,7 +183,6 @@ checkDevMem(Bool warn)
         if (base != MAP_FAILED) {
             munmap((caddr_t) base, 4096);
             devMemFd = fd;
-            useDevMem = TRUE;
             return;
         }
         else {
@@ -211,7 +208,6 @@ checkDevMem(Bool warn)
 #endif
         xf86ErrorF("\tlinear framebuffer access unavailable\n");
     }
-    useDevMem = FALSE;
     return;
 }
 
@@ -219,7 +215,6 @@ void
 xf86OSInitVidMem(VidMemInfoPtr pVidMem)
 {
     checkDevMem(TRUE);
-    pVidMem->linearSupported = useDevMem;
 
     if (has_bwx()) {
         xf86Msg(X_PROBED, "Machine type has 8/16 bit access\n");
diff --git a/hw/xfree86/os-support/bsd/arm_video.c b/hw/xfree86/os-support/bsd/arm_video.c
index 95f4017..60f5bca 100644
--- a/hw/xfree86/os-support/bsd/arm_video.c
+++ b/hw/xfree86/os-support/bsd/arm_video.c
@@ -79,7 +79,6 @@
 /* Video Memory Mapping section                                            */
 /***************************************************************************/
 
-static Bool useDevMem = FALSE;
 static int devMemFd = -1;
 
 /*
@@ -105,7 +104,6 @@ checkDevMem(Bool warn)
         if (base != MAP_FAILED) {
             munmap((caddr_t) base, 4096);
             devMemFd = fd;
-            useDevMem = TRUE;
             return;
         }
         else {
@@ -114,7 +112,6 @@ checkDevMem(Bool warn)
                 xf86Msg(X_WARNING, "checkDevMem: failed to mmap %s (%s)\n",
                         DEV_MEM, strerror(errno));
             }
-            useDevMem = FALSE;
             return;
         }
     }
@@ -122,16 +119,13 @@ checkDevMem(Bool warn)
         xf86Msg(X_WARNING, "checkDevMem: failed to open %s (%s)\n",
                 DEV_MEM, strerror(errno));
     }
-    useDevMem = FALSE;
     return;
 }
 
 void
 xf86OSInitVidMem(VidMemInfoPtr pVidMem)
 {
-
     checkDevMem(TRUE);
-    pVidMem->linearSupported = useDevMem;
 
     pVidMem->initialised = TRUE;
 }
diff --git a/hw/xfree86/os-support/bsd/i386_video.c b/hw/xfree86/os-support/bsd/i386_video.c
index 526cf8a..2b2c2a3 100644
--- a/hw/xfree86/os-support/bsd/i386_video.c
+++ b/hw/xfree86/os-support/bsd/i386_video.c
@@ -178,15 +178,11 @@ void
 xf86OSInitVidMem(VidMemInfoPtr pVidMem)
 {
     checkDevMem(TRUE);
-    pVidMem->linearSupported = useDevMem;
 
-    if (useDevMem)
-        pci_system_init_dev_mem(devMemFd);
+    pci_system_init_dev_mem(devMemFd);
 
 #ifdef HAS_MTRR_SUPPORT
-    if (useDevMem) {
-        cleanMTRR();
-    }
+    cleanMTRR();
 #endif
     pVidMem->initialised = TRUE;
 }
diff --git a/hw/xfree86/os-support/bsd/ppc_video.c b/hw/xfree86/os-support/bsd/ppc_video.c
index a624d4d..0cecd48 100644
--- a/hw/xfree86/os-support/bsd/ppc_video.c
+++ b/hw/xfree86/os-support/bsd/ppc_video.c
@@ -50,7 +50,6 @@ void xf86DisableIO(void);
 void
 xf86OSInitVidMem(VidMemInfoPtr pVidMem)
 {
-    pVidMem->linearSupported = TRUE;
     pVidMem->initialised = TRUE;
     xf86EnableIO();
 }
diff --git a/hw/xfree86/os-support/bsd/sparc64_video.c b/hw/xfree86/os-support/bsd/sparc64_video.c
index 3fd0315..b87afc1 100644
--- a/hw/xfree86/os-support/bsd/sparc64_video.c
+++ b/hw/xfree86/os-support/bsd/sparc64_video.c
@@ -41,7 +41,6 @@
 void
 xf86OSInitVidMem(VidMemInfoPtr pVidMem)
 {
-    pVidMem->linearSupported = TRUE;
     pVidMem->initialised = TRUE;
 }
 
diff --git a/hw/xfree86/os-support/hurd/hurd_video.c b/hw/xfree86/os-support/hurd/hurd_video.c
index 6485917..2a96393 100644
--- a/hw/xfree86/os-support/hurd/hurd_video.c
+++ b/hw/xfree86/os-support/hurd/hurd_video.c
@@ -84,6 +84,5 @@ xf86DisableIO()
 void
 xf86OSInitVidMem(VidMemInfoPtr pVidMem)
 {
-    pVidMem->linearSupported = TRUE;
     pVidMem->initialised = TRUE;
 }
diff --git a/hw/xfree86/os-support/linux/lnx_video.c b/hw/xfree86/os-support/linux/lnx_video.c
index 2efc9fd..018d921 100644
--- a/hw/xfree86/os-support/linux/lnx_video.c
+++ b/hw/xfree86/os-support/linux/lnx_video.c
@@ -94,7 +94,6 @@ static unsigned long bus_base;
 void
 xf86OSInitVidMem(VidMemInfoPtr pVidMem)
 {
-    pVidMem->linearSupported = TRUE;
 #ifdef __alpha__
     if (axpSystem == -1) {
         axpSystem = lnxGetAXP();
diff --git a/hw/xfree86/os-support/shared/vidmem.c b/hw/xfree86/os-support/shared/vidmem.c
index 0135867..1d4f6a9 100644
--- a/hw/xfree86/os-support/shared/vidmem.c
+++ b/hw/xfree86/os-support/shared/vidmem.c
@@ -134,10 +134,3 @@ xf86CheckMTRR(int ScreenNum)
 
     return FALSE;
 }
-
-Bool
-xf86LinearVidMem(void)
-{
-    xf86InitVidMem();
-    return vidMemInfo.linearSupported;
-}
diff --git a/hw/xfree86/os-support/solaris/sun_vid.c b/hw/xfree86/os-support/solaris/sun_vid.c
index 1526ae7..bab449d 100644
--- a/hw/xfree86/os-support/solaris/sun_vid.c
+++ b/hw/xfree86/os-support/solaris/sun_vid.c
@@ -110,11 +110,6 @@ solOpenAperture(void)
 _X_HIDDEN void
 xf86OSInitVidMem(VidMemInfoPtr pVidMem)
 {
-    pVidMem->linearSupported = solOpenAperture();
-    if (!pVidMem->linearSupported) {
-        xf86MsgVerb(X_WARNING, 0,
-                    "xf86OSInitVidMem: linear memory access disabled\n");
-    }
     pVidMem->initialised = TRUE;
 }
 
diff --git a/hw/xfree86/os-support/xf86OSpriv.h b/hw/xfree86/os-support/xf86OSpriv.h
index 7240f14..ce1ec33 100644
--- a/hw/xfree86/os-support/xf86OSpriv.h
+++ b/hw/xfree86/os-support/xf86OSpriv.h
@@ -34,7 +34,6 @@
 
 typedef struct {
     Bool initialised;
-    Bool linearSupported;
 } VidMemInfo, *VidMemInfoPtr;
 
 void xf86OSInitVidMem(VidMemInfoPtr);
diff --git a/hw/xfree86/os-support/xf86_OSproc.h b/hw/xfree86/os-support/xf86_OSproc.h
index 747803c..5337d7b 100644
--- a/hw/xfree86/os-support/xf86_OSproc.h
+++ b/hw/xfree86/os-support/xf86_OSproc.h
@@ -112,7 +112,6 @@
 _XFUNCPROTOBEGIN
 
 /* public functions */
-extern _X_EXPORT Bool xf86LinearVidMem(void);
 extern _X_EXPORT _X_DEPRECATED Bool xf86CheckMTRR(int);
 extern _X_EXPORT int xf86ReadBIOS(unsigned long, unsigned long, unsigned char *,
                                   int);
commit ec0e29ed5bc71516de7feb226b548ce45cb9ffdf
Author: Adam Jackson <ajax at redhat.com>
Date:   Fri May 2 12:32:02 2014 -0400

    xfree86: Remove {set,undo}WC from VidMemInfo
    
    Now that mapMem is gone this can never actually get called.
    
    Reviewed-by: Eric Anholt <eric at anholt.net>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/hw/xfree86/os-support/bsd/i386_video.c b/hw/xfree86/os-support/bsd/i386_video.c
index cc84f44..526cf8a 100644
--- a/hw/xfree86/os-support/bsd/i386_video.c
+++ b/hw/xfree86/os-support/bsd/i386_video.c
@@ -86,15 +86,8 @@ static int devMemFd = -1;
 #endif
 
 #ifdef HAS_MTRR_SUPPORT
-static void *setWC(int, unsigned long, unsigned long, Bool, MessageType);
-static void undoWC(int, void *);
 static Bool cleanMTRR(void);
 #endif
-#if defined(HAS_MTRR_BUILTIN) && defined(__NetBSD__)
-static void *NetBSDsetWC(int, unsigned long, unsigned long, Bool,
-                           MessageType);
-static void NetBSDundoWC(int, void *);
-#endif
 
 /*
  * Check if /dev/mem can be mmap'd.  If it can't print a warning when
@@ -192,16 +185,9 @@ xf86OSInitVidMem(VidMemInfoPtr pVidMem)
 
 #ifdef HAS_MTRR_SUPPORT
     if (useDevMem) {
-        if (cleanMTRR()) {
-            pVidMem->setWC = setWC;
-            pVidMem->undoWC = undoWC;
-        }
+        cleanMTRR();
     }
 #endif
-#if defined(HAS_MTRR_BUILTIN) && defined(__NetBSD__)
-    pVidMem->setWC = NetBSDsetWC;
-    pVidMem->undoWC = NetBSDundoWC;
-#endif
     pVidMem->initialised = TRUE;
 }
 
@@ -503,334 +489,4 @@ cleanMTRR()
     return TRUE;
 }
 
-typedef struct x_RangeRec {
-    struct mem_range_desc mrd;
-    Bool wasWC;
-    struct x_RangeRec *next;
-} RangeRec, *RangePtr;
-
-static void
-freeRangeList(RangePtr range)
-{
-    RangePtr rp;
-
-    while (range) {
-        rp = range;
-        range = rp->next;
-        free(rp);
-    }
-}
-
-static RangePtr
-dupRangeList(RangePtr list)
-{
-    RangePtr new = NULL, rp, p;
-
-    rp = list;
-    while (rp) {
-        p = xnfalloc(sizeof(RangeRec));
-        *p = *rp;
-        p->next = new;
-        new = p;
-        rp = rp->next;
-    }
-    return new;
-}
-
-static RangePtr
-sortRangeList(RangePtr list)
-{
-    RangePtr rp1, rp2, copy, sorted = NULL, minp, prev, minprev;
-    unsigned long minBase;
-
-    /* Sort by base address */
-    rp1 = copy = dupRangeList(list);
-    while (rp1) {
-        minBase = rp1->mrd.mr_base;
-        minp = rp1;
-        minprev = NULL;
-        prev = rp1;
-        rp2 = rp1->next;
-        while (rp2) {
-            if (rp2->mrd.mr_base < minBase) {
-                minBase = rp2->mrd.mr_base;
-                minp = rp2;
-                minprev = prev;
-            }
-            prev = rp2;
-            rp2 = rp2->next;
-        }
-        if (minprev) {
-            minprev->next = minp->next;
-            rp1 = copy;
-        }
-        else {
-            rp1 = minp->next;
-        }
-        minp->next = sorted;
-        sorted = minp;
-    }
-    return sorted;
-}
-
-/*
- * findRanges returns a list of ranges that overlap the specified range.
- */
-
-static void
-findRanges(unsigned long base, unsigned long size, RangePtr * ucp,
-           RangePtr * wcp)
-{
-    struct mem_range_desc *mrd;
-    int nmr, i;
-    RangePtr rp, *p;
-
-    if (!(mrd = getAllRanges(&nmr)))
-        return;
-
-    for (i = 0; i < nmr; i++) {
-        if ((mrd[i].mr_flags & MDF_ACTIVE) &&
-            mrd[i].mr_base < base + size &&
-            mrd[i].mr_base + mrd[i].mr_len > base) {
-            if (mrd[i].mr_flags & MDF_WRITECOMBINE)
-                p = wcp;
-            else if (mrd[i].mr_flags & MDF_UNCACHEABLE)
-                p = ucp;
-            else
-                continue;
-            rp = xnfalloc(sizeof(RangeRec));
-            rp->mrd = mrd[i];
-            rp->next = *p;
-            *p = rp;
-        }
-    }
-    free(mrd);
-}
-
-/*
- * This checks if the existing overlapping ranges fully cover the requested
- * range.  Is this overkill?
- */
-
-static Bool
-fullCoverage(unsigned long base, unsigned long size, RangePtr overlap)
-{
-    RangePtr rp1, sorted = NULL;
-    unsigned long end;
-
-    sorted = sortRangeList(overlap);
-    /* Look for gaps */
-    rp1 = sorted;
-    end = base + size;
-    while (rp1) {
-        if (rp1->mrd.mr_base > base) {
-            freeRangeList(sorted);
-            return FALSE;
-        }
-        else {
-            base = rp1->mrd.mr_base + rp1->mrd.mr_len;
-        }
-        if (base >= end) {
-            freeRangeList(sorted);
-            return TRUE;
-        }
-        rp1 = rp1->next;
-    }
-    freeRangeList(sorted);
-    return FALSE;
-}
-
-static void *
-addWC(int screenNum, unsigned long base, unsigned long size, MessageType from)
-{
-    RangePtr uc = NULL, wc = NULL, retlist = NULL;
-    struct mem_range_desc mrd;
-    struct mem_range_op mro;
-
-    findRanges(base, size, &uc, &wc);
-
-    /* See of the full range is already WC */
-    if (!uc && fullCoverage(base, size, wc)) {
-        xf86DrvMsg(screenNum, from,
-                   "Write-combining range (0x%lx,0x%lx) was already set\n",
-                   base, size);
-        return NULL;
-    }
-
-    /* Otherwise, try to add the new range */
-    mrd.mr_base = base;
-    mrd.mr_len = size;
-    strcpy(mrd.mr_owner, X_MTRR_ID);
-    mrd.mr_flags = MDF_WRITECOMBINE;
-    mro.mo_desc = &mrd;
-    mro.mo_arg[0] = MEMRANGE_SET_UPDATE;
-    if (ioctl(devMemFd, MEMRANGE_SET, &mro)) {
-        xf86DrvMsg(screenNum, X_WARNING,
-                   "Failed to set write-combining range "
-                   "(0x%lx,0x%lx)\n", base, size);
-        return NULL;
-    }
-    else {
-        xf86DrvMsg(screenNum, from,
-                   "Write-combining range (0x%lx,0x%lx)\n", base, size);
-        retlist = xnfalloc(sizeof(RangeRec));
-        retlist->mrd = mrd;
-        retlist->wasWC = FALSE;
-        retlist->next = NULL;
-        return retlist;
-    }
-}
-
-static void *
-delWC(int screenNum, unsigned long base, unsigned long size, MessageType from)
-{
-    RangePtr uc = NULL, wc = NULL, retlist = NULL;
-    struct mem_range_desc mrd;
-    struct mem_range_op mro;
-
-    findRanges(base, size, &uc, &wc);
-
-    /*
-     * See of the full range is already not WC, or if there is full
-     * coverage from UC ranges.
-     */
-    if (!wc || fullCoverage(base, size, uc)) {
-        xf86DrvMsg(screenNum, from,
-                   "Write-combining range (0x%lx,0x%lx) was already clear\n",
-                   base, size);
-        return NULL;
-    }
-
-    /* Otherwise, try to add the new range */
-    mrd.mr_base = base;
-    mrd.mr_len = size;
-    strcpy(mrd.mr_owner, X_MTRR_ID);
-    mrd.mr_flags = MDF_UNCACHEABLE;
-    mro.mo_desc = &mrd;
-    mro.mo_arg[0] = MEMRANGE_SET_UPDATE;
-    if (ioctl(devMemFd, MEMRANGE_SET, &mro)) {
-        xf86DrvMsg(screenNum, X_WARNING,
-                   "Failed to remove write-combining range "
-                   "(0x%lx,0x%lx)\n", base, size);
-        /* XXX Should then remove all of the overlapping WC ranges */
-        return NULL;
-    }
-    else {
-        xf86DrvMsg(screenNum, from,
-                   "Removed Write-combining range (0x%lx,0x%lx)\n", base, size);
-        retlist = xnfalloc(sizeof(RangeRec));
-        retlist->mrd = mrd;
-        retlist->wasWC = TRUE;
-        retlist->next = NULL;
-        return retlist;
-    }
-}
-
-static void *
-setWC(int screenNum, unsigned long base, unsigned long size, Bool enable,
-      MessageType from)
-{
-    if (enable)
-        return addWC(screenNum, base, size, from);
-    else
-        return delWC(screenNum, base, size, from);
-}
-
-static void
-undoWC(int screenNum, void *list)
-{
-    RangePtr rp;
-    struct mem_range_op mro;
-    Bool failed;
-
-    rp = list;
-    while (rp) {
-#ifdef DEBUG
-        ErrorF("Undo for (0x%lx,0x%lx), %d\n",
-               (unsigned long) rp->mrd.mr_base,
-               (unsigned long) rp->mrd.mr_len, rp->wasWC);
-#endif
-        failed = FALSE;
-        if (rp->wasWC) {
-            mro.mo_arg[0] = MEMRANGE_SET_UPDATE;
-            rp->mrd.mr_flags = MDF_WRITECOMBINE;
-            strcpy(rp->mrd.mr_owner, "unknown");
-        }
-        else {
-            mro.mo_arg[0] = MEMRANGE_SET_REMOVE;
-        }
-        mro.mo_desc = &rp->mrd;
-
-        if (ioctl(devMemFd, MEMRANGE_SET, &mro)) {
-            if (!rp->wasWC) {
-                mro.mo_arg[0] = MEMRANGE_SET_UPDATE;
-                rp->mrd.mr_flags = MDF_UNCACHEABLE;
-                strcpy(rp->mrd.mr_owner, "unknown");
-                if (ioctl(devMemFd, MEMRANGE_SET, &mro))
-                    failed = TRUE;
-            }
-            else
-                failed = TRUE;
-        }
-        if (failed) {
-            xf86DrvMsg(screenNum, X_WARNING,
-                       "Failed to restore MTRR range (0x%lx,0x%lx)\n",
-                       (unsigned long) rp->mrd.mr_base,
-                       (unsigned long) rp->mrd.mr_len);
-        }
-        rp = rp->next;
-    }
-}
-
 #endif                          /* HAS_MTRR_SUPPORT */
-
-#if defined(HAS_MTRR_BUILTIN) && defined(__NetBSD__)
-static void *
-NetBSDsetWC(int screenNum, unsigned long base, unsigned long size, Bool enable,
-            MessageType from)
-{
-    struct mtrr *mtrrp;
-    int n;
-
-    xf86DrvMsg(screenNum, X_WARNING,
-               "%s MTRR %lx - %lx\n", enable ? "set" : "remove",
-               base, (base + size));
-
-    mtrrp = xnfalloc(sizeof(struct mtrr));
-    mtrrp->base = base;
-    mtrrp->len = size;
-    mtrrp->type = MTRR_TYPE_WC;
-
-    /*
-     * MTRR_PRIVATE will make this MTRR get reset automatically
-     * if this process exits, so we have no need for an explicit
-     * cleanup operation when starting a new server.
-     */
-
-    if (enable)
-        mtrrp->flags = MTRR_VALID | MTRR_PRIVATE;
-    else
-        mtrrp->flags = 0;
-    n = 1;
-
-    if (i386_set_mtrr(mtrrp, &n) < 0) {
-        free(mtrrp);
-        return NULL;
-    }
-    return mtrrp;
-}
-
-static void
-NetBSDundoWC(int screenNum, void *list)
-{
-    struct mtrr *mtrrp = (struct mtrr *) list;
-    int n;
-
-    if (mtrrp == NULL)
-        return;
-    n = 1;
-    mtrrp->flags &= ~MTRR_VALID;
-    i386_set_mtrr(mtrrp, &n);
-    free(mtrrp);
-}
-#endif
diff --git a/hw/xfree86/os-support/linux/lnx_video.c b/hw/xfree86/os-support/linux/lnx_video.c
index 7389d48..2efc9fd 100644
--- a/hw/xfree86/os-support/linux/lnx_video.c
+++ b/hw/xfree86/os-support/linux/lnx_video.c
@@ -42,10 +42,6 @@
 #include "shared/xf86Axp.h"
 #endif
 
-#ifdef HAS_MTRR_SUPPORT
-#include <asm/mtrr.h>
-#endif
-
 static Bool ExtendedEnabled = FALSE;
 
 #ifdef __ia64__
@@ -95,265 +91,6 @@ static unsigned long hae_mask;
 static unsigned long bus_base;
 #endif
 
-#ifdef HAS_MTRR_SUPPORT
-
-#define SPLIT_WC_REGIONS 1
-
-static void *setWC(int, unsigned long, unsigned long, Bool, MessageType);
-static void undoWC(int, void *);
-
-/* The file desc for /proc/mtrr. Once opened, left opened, and the mtrr
-   driver will clean up when we exit. */
-#define MTRR_FD_UNOPENED (-1)   /* We have yet to open /proc/mtrr */
-#define MTRR_FD_PROBLEM (-2)    /* We tried to open /proc/mtrr, but had
-                                   a problem. */
-static int mtrr_fd = MTRR_FD_UNOPENED;
-
-/* Open /proc/mtrr. FALSE on failure. Will always fail on Linux 2.0, 
-   and will fail on Linux 2.2 with MTRR support configured out,
-   so verbosity should be chosen appropriately. */
-static Bool
-mtrr_open(int verbosity)
-{
-    /* Only report absence of /proc/mtrr once. */
-    static Bool warned = FALSE;
-
-    if (mtrr_fd == MTRR_FD_UNOPENED) {
-        mtrr_fd = open("/proc/mtrr", O_WRONLY);
-
-        if (mtrr_fd < 0)
-            mtrr_fd = MTRR_FD_PROBLEM;
-    }
-
-    if (mtrr_fd == MTRR_FD_PROBLEM) {
-        /* To make sure we only ever warn once, need to check
-           verbosity outside xf86MsgVerb */
-        if (!warned && verbosity <= xf86GetVerbosity()) {
-            xf86MsgVerb(X_WARNING, verbosity,
-                        "System lacks support for changing MTRRs\n");
-            warned = TRUE;
-        }
-
-        return FALSE;
-    }
-    else
-        return TRUE;
-}
-
-/*
- * We maintain a list of WC regions for each physical mapping so they can
- * be undone when unmapping.
- */
-
-struct mtrr_wc_region {
-    struct mtrr_sentry sentry;
-    Bool added;                 /* added WC or removed it */
-    struct mtrr_wc_region *next;
-};
-
-static struct mtrr_wc_region *
-mtrr_cull_wc_region(int screenNum, unsigned long base, unsigned long size,
-                    MessageType from)
-{
-    /* Some BIOS writers thought that setting wc over the mmio
-       region of a graphics devices was a good idea. Try to fix
-       it. */
-
-    struct mtrr_gentry gent;
-    struct mtrr_wc_region *wcreturn = NULL, *wcr;
-    int count, ret = 0;
-
-    /* Linux 2.0 users should not get a warning without -verbose */
-    if (!mtrr_open(2))
-        return NULL;
-
-    for (gent.regnum = 0;
-         ioctl(mtrr_fd, MTRRIOC_GET_ENTRY, &gent) >= 0; gent.regnum++) {
-        if (gent.type != MTRR_TYPE_WRCOMB
-            || gent.base + gent.size <= base || base + size <= gent.base)
-            continue;
-
-        /* Found an overlapping region. Delete it. */
-
-        wcr = malloc(sizeof(*wcr));
-        if (!wcr)
-            return NULL;
-        wcr->sentry.base = gent.base;
-        wcr->sentry.size = gent.size;
-        wcr->sentry.type = MTRR_TYPE_WRCOMB;
-        wcr->added = FALSE;
-
-        count = 3;
-        while (count-- &&
-               (ret = ioctl(mtrr_fd, MTRRIOC_KILL_ENTRY, &(wcr->sentry))) < 0);
-
-        if (ret >= 0) {
-            xf86DrvMsg(screenNum, from,
-                       "Removed MMIO write-combining range "
-                       "(0x%lx,0x%lx)\n",
-                       (unsigned long) gent.base, (unsigned long) gent.size);
-            wcr->next = wcreturn;
-            wcreturn = wcr;
-            gent.regnum--;
-        }
-        else {
-            free(wcr);
-            xf86DrvMsgVerb(screenNum, X_WARNING, 0,
-                           "Failed to remove MMIO "
-                           "write-combining range (0x%lx,0x%lx)\n",
-                           (unsigned long)gent.base, (unsigned long) gent.size);
-        }
-    }
-    return wcreturn;
-}
-
-static struct mtrr_wc_region *
-mtrr_remove_offending(int screenNum, unsigned long base, unsigned long size,
-                      MessageType from)
-{
-    struct mtrr_gentry gent;
-    struct mtrr_wc_region *wcreturn = NULL, **wcr;
-
-    if (!mtrr_open(2))
-        return NULL;
-
-    wcr = &wcreturn;
-    for (gent.regnum = 0;
-         ioctl(mtrr_fd, MTRRIOC_GET_ENTRY, &gent) >= 0; gent.regnum++) {
-        if (gent.type == MTRR_TYPE_WRCOMB
-            && ((gent.base >= base && gent.base + gent.size < base + size) ||
-                (gent.base > base && gent.base + gent.size <= base + size))) {
-            *wcr = mtrr_cull_wc_region(screenNum, gent.base, gent.size, from);
-            if (*wcr)
-                gent.regnum--;
-            while (*wcr) {
-                wcr = &((*wcr)->next);
-            }
-        }
-    }
-    return wcreturn;
-}
-
-static struct mtrr_wc_region *
-mtrr_add_wc_region(int screenNum, unsigned long base, unsigned long size,
-                   MessageType from)
-{
-    struct mtrr_wc_region **wcr, *wcreturn, *curwcr;
-
-    /*
-     * There can be only one....
-     */
-
-    wcreturn = mtrr_remove_offending(screenNum, base, size, from);
-    wcr = &wcreturn;
-    while (*wcr) {
-        wcr = &((*wcr)->next);
-    }
-
-    /* Linux 2.0 should not warn, unless the user explicitly asks for
-       WC. */
-
-    if (!mtrr_open(from == X_CONFIG ? 0 : 2))
-        return wcreturn;
-
-    *wcr = curwcr = malloc(sizeof(**wcr));
-    if (!curwcr)
-        return wcreturn;
-
-    curwcr->sentry.base = base;
-    curwcr->sentry.size = size;
-    curwcr->sentry.type = MTRR_TYPE_WRCOMB;
-    curwcr->added = TRUE;
-    curwcr->next = NULL;
-
-#if SPLIT_WC_REGIONS
-    /*
-     * Splits up the write-combining region if it is not aligned on a
-     * size boundary.
-     */
-
-    {
-        unsigned long lbase, d_size = 1;
-        unsigned long n_size = size;
-        unsigned long n_base = base;
-
-        for (lbase = n_base, d_size = 1; !(lbase & 1);
-             lbase = lbase >> 1, d_size <<= 1);
-        while (d_size > n_size)
-            d_size = d_size >> 1;
-        DebugF("WC_BASE: 0x%lx WC_END: 0x%lx\n", base, base + d_size - 1);
-        n_base += d_size;
-        n_size -= d_size;
-        if (n_size) {
-            xf86DrvMsgVerb(screenNum, X_INFO, 3, "Splitting WC range: "
-                           "base: 0x%lx, size: 0x%lx\n", base, size);
-            curwcr->next = mtrr_add_wc_region(screenNum, n_base, n_size, from);
-        }
-        curwcr->sentry.size = d_size;
-    }
-
-        /*****************************************************************/
-#endif                          /* SPLIT_WC_REGIONS */
-
-    if (ioctl(mtrr_fd, MTRRIOC_ADD_ENTRY, &curwcr->sentry) >= 0) {
-        /* Avoid printing on every VT switch */
-        if (xf86ServerIsInitialising()) {
-            xf86DrvMsg(screenNum, from,
-                       "Write-combining range (0x%lx,0x%lx)\n", base, size);
-        }
-        return wcreturn;
-    }
-    else {
-        *wcr = curwcr->next;
-        free(curwcr);
-
-        /* Don't complain about the VGA region: MTRR fixed
-           regions aren't currently supported, but might be in
-           the future. */
-        if ((unsigned long) base >= 0x100000) {
-            xf86DrvMsgVerb(screenNum, X_WARNING, 0,
-                           "Failed to set up write-combining range "
-                           "(0x%lx,0x%lx)\n", base, size);
-        }
-        return wcreturn;
-    }
-}
-
-static void
-mtrr_undo_wc_region(int screenNum, struct mtrr_wc_region *wcr)
-{
-    struct mtrr_wc_region *p, *prev;
-
-    if (mtrr_fd >= 0) {
-        p = wcr;
-        while (p) {
-            if (p->added)
-                ioctl(mtrr_fd, MTRRIOC_DEL_ENTRY, &p->sentry);
-            prev = p;
-            p = p->next;
-            free(prev);
-        }
-    }
-}
-
-static void *
-setWC(int screenNum, unsigned long base, unsigned long size, Bool enable,
-      MessageType from)
-{
-    if (enable)
-        return mtrr_add_wc_region(screenNum, base, size, from);
-    else
-        return mtrr_cull_wc_region(screenNum, base, size, from);
-}
-
-static void
-undoWC(int screenNum, void *regioninfo)
-{
-    mtrr_undo_wc_region(screenNum, regioninfo);
-}
-
-#endif                          /* HAS_MTRR_SUPPORT */
-
 void
 xf86OSInitVidMem(VidMemInfoPtr pVidMem)
 {
@@ -375,10 +112,6 @@ xf86OSInitVidMem(VidMemInfoPtr pVidMem)
     }
 #endif                          /* __alpha__ */
 
-#ifdef HAS_MTRR_SUPPORT
-    pVidMem->setWC = setWC;
-    pVidMem->undoWC = undoWC;
-#endif
     pVidMem->initialised = TRUE;
 }
 
diff --git a/hw/xfree86/os-support/shared/vidmem.c b/hw/xfree86/os-support/shared/vidmem.c
index 1c695fe..0135867 100644
--- a/hw/xfree86/os-support/shared/vidmem.c
+++ b/hw/xfree86/os-support/shared/vidmem.c
@@ -129,7 +129,7 @@ xf86CheckMTRR(int ScreenNum)
      */
     checkMtrrOption(vp);
 
-    if (vp->mtrrEnabled && vidMemInfo.setWC)
+    if (vp->mtrrEnabled)
         return TRUE;
 
     return FALSE;
diff --git a/hw/xfree86/os-support/xf86OSpriv.h b/hw/xfree86/os-support/xf86OSpriv.h
index c586c7a..7240f14 100644
--- a/hw/xfree86/os-support/xf86OSpriv.h
+++ b/hw/xfree86/os-support/xf86OSpriv.h
@@ -32,14 +32,8 @@
 #ifndef _XF86OSPRIV_H
 #define _XF86OSPRIV_H
 
-typedef void *(*SetWCProcPtr) (int, unsigned long, unsigned long, Bool,
-                                 MessageType);
-typedef void (*UndoWCProcPtr) (int, void *);
-
 typedef struct {
     Bool initialised;
-    SetWCProcPtr setWC;
-    UndoWCProcPtr undoWC;
     Bool linearSupported;
 } VidMemInfo, *VidMemInfoPtr;
 
commit 9db2af6f757ef9680c70eb731698b7c9f9aca203
Author: Adam Jackson <ajax at redhat.com>
Date:   Fri May 2 12:14:10 2014 -0400

    xfree86: Remove xf86{Map,Unmap}VidMem
    
    This API sucks.  Fortunately it's mostly unused at this point.  geode,
    sis, and xgi need minor patches to use the corresponding pciaccess code,
    neomagic will (more explicitly) lose its non-PCI support, and newport
    will need to be ported to /dev/mem or the platform bus or something.
    
    This should also make it pretty clear that alpha's sparse memory support
    was basically not a thing anymore, very few tears shed.
    
    Reviewed-by: Eric Anholt <eric at anholt.net>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/hw/xfree86/os-support/bsd/alpha_video.c b/hw/xfree86/os-support/bsd/alpha_video.c
index f656f55..3aeae58 100644
--- a/hw/xfree86/os-support/bsd/alpha_video.c
+++ b/hw/xfree86/os-support/bsd/alpha_video.c
@@ -35,9 +35,6 @@
 #ifndef __NetBSD__
 #include <sys/sysctl.h>
 #endif
-#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__)
-#include <machine/sysarch.h>
-#endif
 
 #include "xf86Axp.h"
 
@@ -59,32 +56,6 @@ static int axpSystem = -1;
 static unsigned long hae_thresh;
 static unsigned long hae_mask;
 
-static unsigned long
-memory_base(void)
-{
-    static unsigned long base = 0;
-
-    if (base == 0) {
-        size_t len = sizeof(base);
-        int error;
-
-#ifdef __OpenBSD__
-        int mib[3];
-
-        mib[0] = CTL_MACHDEP;
-        mib[1] = CPU_CHIPSET;
-        mib[2] = CPU_CHIPSET_MEM;
-
-        if ((error = sysctl(mib, 3, &base, &len, NULL, 0)) < 0)
-#else
-        if ((error = sysctlbyname("hw.chipset.memory", &base, &len, 0, 0)) < 0)
-#endif
-            FatalError("xf86MapVidMem: can't find memory\n");
-    }
-
-    return base;
-}
-
 static int
 has_bwx(void)
 {
@@ -147,30 +118,9 @@ dense_base(void)
     return abw[0].abw_abst.abst_sys_start;
 }
 
-static unsigned long
-memory_base(void)
-{
-    if (abw_count < 0)
-        init_abw();
-
-    if (abw_count > 1) {
-        xf86Msg(X_INFO, "memory base = %#lx\n", abw[1].abw_abst.abst_sys_start);        /* XXXX */
-        return abw[1].abw_abst.abst_sys_start;
-    }
-    else if (abw_count == 1) {
-        /* assume memory_base == dense_base */
-        xf86Msg(X_INFO, "memory base = %#lx\n", abw[0].abw_abst.abst_sys_start);        /* XXXX */
-        return abw[0].abw_abst.abst_sys_start;
-    }
-    else {
-        xf86Msg(X_INFO, "no memory base\n");    /* XXXX */
-        return 0;
-    }
-}
 #endif                          /* __NetBSD__ */
 
 #define BUS_BASE	dense_base()
-#define BUS_BASE_BWX	memory_base()
 
 /***************************************************************************/
 /* Video Memory Mapping section                                            */
@@ -189,11 +139,6 @@ static int devMemFd = -1;
 #define DEV_APERTURE "/dev/xf86"
 #endif
 
-static void *mapVidMem(int, unsigned long, unsigned long, int);
-static void unmapVidMem(int, void *, unsigned long);
-static void *mapVidMemSparse(int, unsigned long, unsigned long, int);
-static void unmapVidMemSparse(int, void *, unsigned long);
-
 /*
  * Check if /dev/mem can be mmap'd.  If it can't print a warning when
  * "warn" is TRUE.
@@ -278,13 +223,9 @@ xf86OSInitVidMem(VidMemInfoPtr pVidMem)
 
     if (has_bwx()) {
         xf86Msg(X_PROBED, "Machine type has 8/16 bit access\n");
-        pVidMem->mapMem = mapVidMem;
-        pVidMem->unmapMem = unmapVidMem;
     }
     else {
         xf86Msg(X_PROBED, "Machine needs sparse mapping\n");
-        pVidMem->mapMem = mapVidMemSparse;
-        pVidMem->unmapMem = unmapVidMemSparse;
 #ifndef __NetBSD__
         if (axpSystem == -1)
             axpSystem = bsdGetAXP();
@@ -295,52 +236,6 @@ xf86OSInitVidMem(VidMemInfoPtr pVidMem)
     pVidMem->initialised = TRUE;
 }
 
-static void *
-mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
-{
-    void *base;
-
-    checkDevMem(FALSE);
-    Base = Base & ((1L << 32) - 1);
-
-    if (useDevMem) {
-        if (devMemFd < 0) {
-            FatalError("xf86MapVidMem: failed to open %s (%s)\n",
-                       DEV_MEM, strerror(errno));
-        }
-        base = mmap((caddr_t) 0, Size,
-                    (flags & VIDMEM_READONLY) ?
-                    PROT_READ : (PROT_READ | PROT_WRITE),
-                    MAP_FLAGS, devMemFd, (off_t) Base + BUS_BASE_BWX);
-        if (base == MAP_FAILED) {
-            FatalError("%s: could not mmap %s [s=%lx,a=%lx] (%s)\n",
-                       "xf86MapVidMem", DEV_MEM, Size, Base, strerror(errno));
-        }
-        return base;
-    }
-
-    /* else, mmap /dev/vga */
-    if ((unsigned long) Base < 0xA0000 || (unsigned long) Base >= 0xC0000) {
-        FatalError("%s: Address 0x%lx outside allowable range\n",
-                   "xf86MapVidMem", Base);
-    }
-    base = mmap(0, Size,
-                (flags & VIDMEM_READONLY) ?
-                PROT_READ : (PROT_READ | PROT_WRITE),
-                MAP_FLAGS, xf86Info.consoleFd, (unsigned long) Base + BUS_BASE);
-    if (base == MAP_FAILED) {
-        FatalError("xf86MapVidMem: Could not mmap /dev/vga (%s)\n",
-                   strerror(errno));
-    }
-    return base;
-}
-
-static void
-unmapVidMem(int ScreenNum, void *Base, unsigned long Size)
-{
-    munmap((caddr_t) Base, Size);
-}
-
 /*
  * Read BIOS via mmap()ing DEV_MEM
  */
@@ -422,11 +317,6 @@ xf86DisableIO()
 
 #endif                          /* USE_ALPHA_PIO */
 
-#define vuip    volatile unsigned int *
-
-static void *memSBase = 0;
-static void *memBase = 0;
-
 extern int readDense8(void *Base, register unsigned long Offset);
 extern int readDense16(void *Base, register unsigned long Offset);
 extern int readDense32(void *Base, register unsigned long Offset);
@@ -437,223 +327,6 @@ extern void
 extern void
  writeDense32(int Value, void *Base, register unsigned long Offset);
 
-static int readSparse8(void *Base, register unsigned long Offset);
-static int readSparse16(void *Base, register unsigned long Offset);
-static int readSparse32(void *Base, register unsigned long Offset);
-static void
- writeSparseNB8(int Value, void *Base, register unsigned long Offset);
-static void
- writeSparseNB16(int Value, void *Base, register unsigned long Offset);
-static void
- writeSparseNB32(int Value, void *Base, register unsigned long Offset);
-static void
- writeSparse8(int Value, void *Base, register unsigned long Offset);
-static void
- writeSparse16(int Value, void *Base, register unsigned long Offset);
-static void
- writeSparse32(int Value, void *Base, register unsigned long Offset);
-
-#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
-extern int sysarch(int, void *);
-
-struct parms {
-    u_int64_t hae;
-};
-
-static void
-sethae(u_int64_t hae)
-{
-#ifndef ALPHA_SETHAE
-#define ALPHA_SETHAE 0
-#endif
-    static struct parms p;
-
-    if (p.hae != hae) {
-        p.hae = hae;
-        sysarch(ALPHA_SETHAE, (char *) &p);
-    }
-}
-#endif
-
-static void *
-mapVidMemSparse(int ScreenNum, unsigned long Base, unsigned long Size,
-                int flags)
-{
-    static Bool was_here = FALSE;
-
-    if (!was_here) {
-        was_here = TRUE;
-
-        checkDevMem(FALSE);
-
-        xf86WriteMmio8 = writeSparse8;
-        xf86WriteMmio16 = writeSparse16;
-        xf86WriteMmio32 = writeSparse32;
-        xf86WriteMmioNB8 = writeSparseNB8;
-        xf86WriteMmioNB16 = writeSparseNB16;
-        xf86WriteMmioNB32 = writeSparseNB32;
-        xf86ReadMmio8 = readSparse8;
-        xf86ReadMmio16 = readSparse16;
-        xf86ReadMmio32 = readSparse32;
-
-        memBase = mmap((caddr_t) 0, 0x100000000,
-                       PROT_READ | PROT_WRITE,
-                       MAP_SHARED, devMemFd, (off_t) BUS_BASE);
-        memSBase = mmap((caddr_t) 0, 0x100000000,
-                        PROT_READ | PROT_WRITE,
-                        MAP_SHARED, devMemFd, (off_t) BUS_BASE_BWX);
-
-        if (memSBase == MAP_FAILED || memBase == MAP_FAILED) {
-            FatalError("xf86MapVidMem: Could not mmap framebuffer (%s)\n",
-                       strerror(errno));
-        }
-    }
-    return (void *) ((unsigned long) memBase + Base);
-}
-
-static void
-unmapVidMemSparse(int ScreenNum, void *Base, unsigned long Size)
-{
-}
-
-static int
-readSparse8(void *Base, register unsigned long Offset)
-{
-    register unsigned long result, shift;
-    register unsigned long msb;
-
-    mem_barrier();
-    Offset += (unsigned long) Base - (unsigned long) memBase;
-    shift = (Offset & 0x3) << 3;
-    if (Offset >= (hae_thresh)) {
-        msb = Offset & hae_mask;
-        Offset -= msb;
-#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
-        sethae(msb);
-#endif
-    }
-    result = *(vuip) ((unsigned long) memSBase + (Offset << 5));
-    result >>= shift;
-    return 0xffUL & result;
-}
-
-static int
-readSparse16(void *Base, register unsigned long Offset)
-{
-    register unsigned long result, shift;
-    register unsigned long msb;
-
-    mem_barrier();
-    Offset += (unsigned long) Base - (unsigned long) memBase;
-    shift = (Offset & 0x2) << 3;
-    if (Offset >= (hae_thresh)) {
-        msb = Offset & hae_mask;
-        Offset -= msb;
-#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
-        sethae(msb);
-#endif
-    }
-    result =
-        *(vuip) ((unsigned long) memSBase + (Offset << 5) + (1 << (5 - 2)));
-    result >>= shift;
-    return 0xffffUL & result;
-}
-
-static int
-readSparse32(void *Base, register unsigned long Offset)
-{
-    mem_barrier();
-    return *(vuip) ((unsigned long) Base + (Offset));
-}
-
-static void
-writeSparse8(int Value, void *Base, register unsigned long Offset)
-{
-    register unsigned long msb;
-    register unsigned int b = Value & 0xffU;
-
-    write_mem_barrier();
-    Offset += (unsigned long) Base - (unsigned long) memBase;
-    if (Offset >= (hae_thresh)) {
-        msb = Offset & hae_mask;
-        Offset -= msb;
-#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
-        sethae(msb);
-#endif
-    }
-    *(vuip) ((unsigned long) memSBase + (Offset << 5)) = b * 0x01010101;
-}
-
-static void
-writeSparse16(int Value, void *Base, register unsigned long Offset)
-{
-    register unsigned long msb;
-    register unsigned int w = Value & 0xffffU;
-
-    write_mem_barrier();
-    Offset += (unsigned long) Base - (unsigned long) memBase;
-    if (Offset >= (hae_thresh)) {
-        msb = Offset & hae_mask;
-        Offset -= msb;
-#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
-        sethae(msb);
-#endif
-    }
-    *(vuip) ((unsigned long) memSBase + (Offset << 5) + (1 << (5 - 2))) =
-        w * 0x00010001;
-
-}
-
-static void
-writeSparse32(int Value, void *Base, register unsigned long Offset)
-{
-    write_mem_barrier();
-    *(vuip) ((unsigned long) Base + (Offset)) = Value;
-    return;
-}
-
-static void
-writeSparseNB8(int Value, void *Base, register unsigned long Offset)
-{
-    register unsigned long msb;
-    register unsigned int b = Value & 0xffU;
-
-    Offset += (unsigned long) Base - (unsigned long) memBase;
-    if (Offset >= (hae_thresh)) {
-        msb = Offset & hae_mask;
-        Offset -= msb;
-#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
-        sethae(msb);
-#endif
-    }
-    *(vuip) ((unsigned long) memSBase + (Offset << 5)) = b * 0x01010101;
-}
-
-static void
-writeSparseNB16(int Value, void *Base, register unsigned long Offset)
-{
-    register unsigned long msb;
-    register unsigned int w = Value & 0xffffU;
-
-    Offset += (unsigned long) Base - (unsigned long) memBase;
-    if (Offset >= (hae_thresh)) {
-        msb = Offset & hae_mask;
-        Offset -= msb;
-#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
-        sethae(msb);
-#endif
-    }
-    *(vuip) ((unsigned long) memSBase + (Offset << 5) + (1 << (5 - 2))) =
-        w * 0x00010001;
-}
-
-static void
-writeSparseNB32(int Value, void *Base, register unsigned long Offset)
-{
-    *(vuip) ((unsigned long) Base + (Offset)) = Value;
-    return;
-}
-
 void (*xf86WriteMmio8) (int Value, void *Base, unsigned long Offset)
     = writeDense8;
 void (*xf86WriteMmio16) (int Value, void *Base, unsigned long Offset)
diff --git a/hw/xfree86/os-support/bsd/arm_video.c b/hw/xfree86/os-support/bsd/arm_video.c
index e295c92..95f4017 100644
--- a/hw/xfree86/os-support/bsd/arm_video.c
+++ b/hw/xfree86/os-support/bsd/arm_video.c
@@ -66,35 +66,6 @@
 #include "xf86_OSlib.h"
 #include "xf86OSpriv.h"
 
-#ifdef __arm32__
-#include "machine/devmap.h"
-struct memAccess {
-    int ioctl;
-    struct map_info memInfo;
-    void *regionVirtBase;
-    Bool Checked;
-    Bool OK;
-};
-
-static void *xf86MapInfoMap();
-static void xf86MapInfoUnmap();
-static struct memAccess *checkMapInfo();
-extern int vgaPhysLinearBase;
-
-/* A memAccess structure is needed for each possible region */
-struct memAccess vgaMemInfo = { CONSOLE_GET_MEM_INFO, NULL, NULL,
-    FALSE, FALSE
-};
-
-struct memAccess linearMemInfo = { CONSOLE_GET_LINEAR_INFO, NULL, NULL,
-    FALSE, FALSE
-};
-
-struct memAccess ioMemInfo = { CONSOLE_GET_IO_INFO, NULL, NULL,
-    FALSE, FALSE
-};
-#endif                          /* __arm32__ */
-
 #if defined(__NetBSD__) && !defined(MAP_FILE)
 #define MAP_FLAGS MAP_SHARED
 #else
@@ -111,9 +82,6 @@ struct memAccess ioMemInfo = { CONSOLE_GET_IO_INFO, NULL, NULL,
 static Bool useDevMem = FALSE;
 static int devMemFd = -1;
 
-static void *mapVidMem(int, unsigned long, unsigned long, int);
-static void unmapVidMem(int, void *, unsigned long);
-
 /*
  * Check if /dev/mem can be mmap'd.  If it can't print a warning when
  * "warn" is TRUE.
@@ -164,57 +132,10 @@ xf86OSInitVidMem(VidMemInfoPtr pVidMem)
 
     checkDevMem(TRUE);
     pVidMem->linearSupported = useDevMem;
-    pVidMem->mapMem = armMapVidMem;
-    pVidMem->unmapVidMem = armUnmapVidMem;
 
     pVidMem->initialised = TRUE;
 }
 
-static void *
-mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
-{
-    void *base;
-
-    checkDevMem(FALSE);
-
-    if (useDevMem) {
-        if (devMemFd < 0) {
-            FatalError("xf86MapVidMem: failed to open %s (%s)\n",
-                       DEV_MEM, strerror(errno));
-        }
-        base = mmap((caddr_t) 0, Size,
-                    (flags & VIDMEM_READONLY) ?
-                    PROT_READ : (PROT_READ | PROT_WRITE),
-                    MAP_FLAGS, devMemFd, (off_t) Base + BUS_BASE_BWX);
-        if (base == MAP_FAILED) {
-            FatalError("%s: could not mmap %s [s=%x,a=%x] (%s)\n",
-                       "xf86MapVidMem", DEV_MEM, Size, Base, strerror(errno));
-        }
-        return base;
-    }
-
-    /* else, mmap /dev/vga */
-    if ((unsigned long) Base < 0xA0000 || (unsigned long) Base >= 0xC0000) {
-        FatalError("%s: Address 0x%x outside allowable range\n",
-                   "xf86MapVidMem", Base);
-    }
-    base = mmap(0, Size,
-                (flags & VIDMEM_READONLY) ?
-                PROT_READ : (PROT_READ | PROT_WRITE),
-                MAP_FLAGS, xf86Info.consoleFd, (unsigned long) Base - 0xA0000);
-    if (base == MAP_FAILED) {
-        FatalError("xf86MapVidMem: Could not mmap /dev/vga (%s)\n",
-                   strerror(errno));
-    }
-    return base;
-}
-
-static void
-unmapVidMem(int ScreenNum, void *Base, unsigned long Size)
-{
-    munmap((caddr_t) Base, Size);
-}
-
 /*
  * Read BIOS via mmap()ing DEV_MEM
  */
@@ -258,162 +179,6 @@ xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
     return Len;
 }
 
-/* XXX This needs to be updated for the ND */
-
-/*
-** Find out whether the console driver provides memory mapping information 
-** for the specified region and return the map_info pointer. Print a warning if required.
-*/
-static struct memAccess *
-checkMapInfo(Bool warn, int Region)
-{
-    struct memAccess *memAccP;
-
-    switch (Region) {
-    case VGA_REGION:
-        memAccP = &vgaMemInfo;
-        break;
-
-    case LINEAR_REGION:
-        memAccP = &linearMemInfo;
-        break;
-
-    case MMIO_REGION:
-        memAccP = &ioMemInfo;
-        break;
-
-    default:
-        return NULL;
-        break;
-    }
-
-    if (!memAccP->Checked) {
-        if (ioctl(xf86Info.consoleFd, memAccP->ioctl, &(memAccP->memInfo)) ==
-            -1) {
-            if (warn) {
-                xf86Msg(X_WARNING,
-                        "checkMapInfo: failed to get map info for region %d\n\t(%s)\n",
-                        Region, strerror(errno));
-            }
-        }
-        else {
-            if (memAccP->memInfo.u.map_info_mmap.map_offset != MAP_INFO_UNKNOWN)
-                memAccP->OK = TRUE;
-        }
-        memAccP->Checked = TRUE;
-    }
-    if (memAccP->OK) {
-        return memAccP;
-    }
-    else {
-        return NULL;
-    }
-}
-
-static void *
-xf86MapInfoMap(struct memAccess *memInfoP, void *Base, unsigned long Size)
-{
-    struct map_info *mapInfoP = &(memInfoP->memInfo);
-
-    if (mapInfoP->u.map_info_mmap.map_size == MAP_INFO_UNKNOWN) {
-        Size = (unsigned long) Base + Size;
-    }
-    else {
-        Size = mapInfoP->u.map_info_mmap.map_size;
-    }
-
-    switch (mapInfoP->method) {
-    case MAP_MMAP:
-        /* Need to remap if size is unknown because we may not have
-           mapped the whole region initially */
-        if (memInfoP->regionVirtBase == NULL ||
-            mapInfoP->u.map_info_mmap.map_size == MAP_INFO_UNKNOWN) {
-            if ((memInfoP->regionVirtBase =
-                 mmap((caddr_t) 0,
-                      Size,
-                      PROT_READ | PROT_WRITE,
-                      MAP_SHARED,
-                      xf86Info.consoleFd,
-                      (unsigned long) mapInfoP->u.map_info_mmap.map_offset))
-                == (void *) -1) {
-                FatalError
-                    ("xf86MapInfoMap: Failed to map memory at 0x%x\n\t%s\n",
-                     mapInfoP->u.map_info_mmap.map_offset, strerror(errno));
-            }
-            if (mapInfoP->u.map_info_mmap.internal_offset > 0)
-                memInfoP->regionVirtBase +=
-                    mapInfoP->u.map_info_mmap.internal_offset;
-        }
-        break;
-
-    default:
-        FatalError("xf86MapInfoMap: Unsuported mapping method\n");
-        break;
-    }
-
-    return (void *) ((int) memInfoP->regionVirtBase + (int) Base);
-}
-
-static void
-xf86MapInfoUnmap(struct memAccess *memInfoP, unsigned long Size)
-{
-    struct map_info *mapInfoP = &(memInfoP->memInfo);
-
-    switch (mapInfoP->method) {
-    case MAP_MMAP:
-        if (memInfoP->regionVirtBase != NULL) {
-            if (mapInfoP->u.map_info_mmap.map_size != MAP_INFO_UNKNOWN)
-                Size = mapInfoP->u.map_info_mmap.map_size;
-            munmap((caddr_t) memInfoP->regionVirtBase, Size);
-            memInfoP->regionVirtBase = NULL;
-        }
-        break;
-    default:
-        FatalError("xf86MapInfoMap: Unsuported mapping method\n");
-        break;
-    }
-}
-
-static void *
-armMapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
-{
-    struct memAccess *memInfoP;
-
-    if ((memInfoP = checkMapInfo(FALSE, Region)) != NULL) {
-        /*
-         ** xf86 passes in a physical address offset from the start
-         ** of physical memory, but xf86MapInfoMap expects an 
-         ** offset from the start of the specified region - it gets 
-         ** the physical address of the region from the display driver.
-         */
-        switch (Region) {
-        case LINEAR_REGION:
-            if (vgaPhysLinearBase) {
-                Base -= vgaPhysLinearBase;
-            }
-            break;
-        case VGA_REGION:
-            Base -= 0xA0000;
-            break;
-        }
-
-        base = xf86MapInfoMap(memInfoP, Base, Size);
-        return base;
-    }
-    return mapVidMem(ScreenNum, Base, Size, flags);
-}
-
-static void
-armUnmapVidMem(int ScreenNum, void *Base, unsigned long Size)
-{
-    struct memAccess *memInfoP;
-
-    if ((memInfoP = checkMapInfo(FALSE, Region)) != NULL) {
-        xf86MapInfoUnmap(memInfoP, Base, Size);
-    }
-    unmapVidMem(ScreenNum, Base, Size);
-}
-
 #ifdef USE_DEV_IO
 static int IoFd = -1;
 
diff --git a/hw/xfree86/os-support/bsd/i386_video.c b/hw/xfree86/os-support/bsd/i386_video.c
index 7453190..cc84f44 100644
--- a/hw/xfree86/os-support/bsd/i386_video.c
+++ b/hw/xfree86/os-support/bsd/i386_video.c
@@ -85,9 +85,6 @@ static int devMemFd = -1;
 #define DEV_APERTURE "/dev/xf86"
 #endif
 
-static void *mapVidMem(int, unsigned long, unsigned long, int);
-static void unmapVidMem(int, void *, unsigned long);
-
 #ifdef HAS_MTRR_SUPPORT
 static void *setWC(int, unsigned long, unsigned long, Bool, MessageType);
 static void undoWC(int, void *);
@@ -189,8 +186,6 @@ xf86OSInitVidMem(VidMemInfoPtr pVidMem)
 {
     checkDevMem(TRUE);
     pVidMem->linearSupported = useDevMem;
-    pVidMem->mapMem = mapVidMem;
-    pVidMem->unmapMem = unmapVidMem;
 
     if (useDevMem)
         pci_system_init_dev_mem(devMemFd);
@@ -210,51 +205,6 @@ xf86OSInitVidMem(VidMemInfoPtr pVidMem)
     pVidMem->initialised = TRUE;
 }
 
-static void *
-mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
-{
-    void *base;
-
-    checkDevMem(FALSE);
-
-    if (useDevMem) {
-        if (devMemFd < 0) {
-            FatalError("xf86MapVidMem: failed to open %s (%s)",
-                       DEV_MEM, strerror(errno));
-        }
-        base = mmap((caddr_t) 0, Size,
-                    (flags & VIDMEM_READONLY) ?
-                    PROT_READ : (PROT_READ | PROT_WRITE),
-                    MAP_FLAGS, devMemFd, (off_t) Base);
-        if (base == MAP_FAILED) {
-            FatalError("%s: could not mmap %s [s=%lx,a=%lx] (%s)",
-                       "xf86MapVidMem", DEV_MEM, Size, Base, strerror(errno));
-        }
-        return base;
-    }
-
-    /* else, mmap /dev/vga */
-    if ((unsigned long) Base < 0xA0000 || (unsigned long) Base >= 0xC0000) {
-        FatalError("%s: Address 0x%lx outside allowable range",
-                   "xf86MapVidMem", Base);
-    }
-    base = mmap(0, Size,
-                (flags & VIDMEM_READONLY) ?
-                PROT_READ : (PROT_READ | PROT_WRITE),
-                MAP_FLAGS, xf86Info.consoleFd, (unsigned long) Base - 0xA0000);
-    if (base == MAP_FAILED) {
-        FatalError("xf86MapVidMem: Could not mmap /dev/vga (%s)",
-                   strerror(errno));
-    }
-    return base;
-}
-
-static void
-unmapVidMem(int ScreenNum, void *Base, unsigned long Size)
-{
-    munmap((caddr_t) Base, Size);
-}
-
 /*
  * Read BIOS via mmap()ing DEV_MEM
  */
diff --git a/hw/xfree86/os-support/bsd/ppc_video.c b/hw/xfree86/os-support/bsd/ppc_video.c
index 3fd28c3..a624d4d 100644
--- a/hw/xfree86/os-support/bsd/ppc_video.c
+++ b/hw/xfree86/os-support/bsd/ppc_video.c
@@ -44,9 +44,6 @@
 #define DEV_MEM "/dev/xf86"
 #endif
 
-static void *ppcMapVidMem(int, unsigned long, unsigned long, int flags);
-static void ppcUnmapVidMem(int, void *, unsigned long);
-
 Bool xf86EnableIO(void);
 void xf86DisableIO(void);
 
@@ -54,40 +51,12 @@ void
 xf86OSInitVidMem(VidMemInfoPtr pVidMem)
 {
     pVidMem->linearSupported = TRUE;
-    pVidMem->mapMem = ppcMapVidMem;
-    pVidMem->unmapMem = ppcUnmapVidMem;
     pVidMem->initialised = TRUE;
     xf86EnableIO();
 }
 
 volatile unsigned char *ioBase = MAP_FAILED;
 
-static void *
-ppcMapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
-{
-    int fd = xf86Info.consoleFd;
-    void *base;
-
-#ifdef DEBUG
-    xf86MsgVerb(X_INFO, 3, "mapVidMem %lx, %lx, fd = %d", Base, Size, fd);
-#endif
-
-    base = mmap(0, Size,
-                (flags & VIDMEM_READONLY) ?
-                PROT_READ : (PROT_READ | PROT_WRITE), MAP_SHARED, fd, Base);
-    if (base == MAP_FAILED)
-        FatalError("%s: could not mmap screen [s=%lx,a=%lx] (%s)",
-                   "xf86MapVidMem", Size, Base, strerror(errno));
-
-    return base;
-}
-
-static void
-ppcUnmapVidMem(int ScreenNum, void *Base, unsigned long Size)
-{
-    munmap(Base, Size);
-}
-
 int
 xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
              int Len)
diff --git a/hw/xfree86/os-support/bsd/sparc64_video.c b/hw/xfree86/os-support/bsd/sparc64_video.c
index 02951d6..3fd0315 100644
--- a/hw/xfree86/os-support/bsd/sparc64_video.c
+++ b/hw/xfree86/os-support/bsd/sparc64_video.c
@@ -38,44 +38,13 @@
 /* Video Memory Mapping section                                            */
 /***************************************************************************/
 
-static void *sparc64MapVidMem(int, unsigned long, unsigned long, int);
-static void sparc64UnmapVidMem(int, void *, unsigned long);
-
 void
 xf86OSInitVidMem(VidMemInfoPtr pVidMem)
 {
     pVidMem->linearSupported = TRUE;
-    pVidMem->mapMem = sparc64MapVidMem;
-    pVidMem->unmapMem = sparc64UnmapVidMem;
     pVidMem->initialised = TRUE;
 }
 
-static void *
-sparc64MapVidMem(int ScreenNum, unsigned long Base, unsigned long Size,
-                 int flags)
-{
-    int fd = xf86Info.consoleFd;
-    void *base;
-
-#ifdef DEBUG
-    xf86MsgVerb(X_INFO, 3, "mapVidMem %lx, %lx, fd = %d", Base, Size, fd);
-#endif
-
-    base = mmap(0, Size,
-                (flags & VIDMEM_READONLY) ?
-                PROT_READ : (PROT_READ | PROT_WRITE), MAP_SHARED, fd, Base);
-    if (base == MAP_FAILED)
-        FatalError("%s: could not mmap screen [s=%x,a=%x] (%s)",
-                   "xf86MapVidMem", Size, Base, strerror(errno));
-    return base;
-}
-
-static void
-sparc64UnmapVidMem(int ScreenNum, void *Base, unsigned long Size)
-{
-    munmap(Base, Size);
-}
-
 int
 xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
              int Len)
diff --git a/hw/xfree86/os-support/hurd/hurd_video.c b/hw/xfree86/os-support/hurd/hurd_video.c
index dc1a8e6..6485917 100644
--- a/hw/xfree86/os-support/hurd/hurd_video.c
+++ b/hw/xfree86/os-support/hurd/hurd_video.c
@@ -42,68 +42,6 @@
 /**************************************************************************
  * Video Memory Mapping section                                            
  ***************************************************************************/
-static void *
-mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int Flags)
-{
-    mach_port_t device, mem_dev;
-    memory_object_t mem_obj;
-    kern_return_t err;
-    vm_address_t addr = (vm_address_t) 0;
-
-    err = get_privileged_ports(NULL, &device);
-    if (err) {
-        errno = err;
-        FatalError("xf86MapVidMem() can't get_privileged_ports. (%s)\n",
-                   strerror(errno));
-    }
-    err = device_open(device, D_READ | D_WRITE, "mem", &mem_dev);
-    mach_port_deallocate(mach_task_self(), device);
-    if (err) {
-        errno = err;
-        FatalError("xf86MapVidMem() can't device_open. (%s)\n",
-                   strerror(errno));
-    }
-
-    err =
-        device_map(mem_dev, VM_PROT_READ | VM_PROT_WRITE, Base, Size, &mem_obj,
-                   0);
-    if (err) {
-        errno = err;
-        FatalError("xf86MapVidMem() can't device_map. (%s)\n", strerror(errno));
-    }
-    err = vm_map(mach_task_self(), &addr, Size, 0,      /* mask */
-                 TRUE,          /* anywhere */
-                 mem_obj, (vm_offset_t) Base, FALSE,    /* copy on write */
-                 VM_PROT_READ | VM_PROT_WRITE,
-                 VM_PROT_READ | VM_PROT_WRITE, VM_INHERIT_SHARE);
-    mach_port_deallocate(mach_task_self(), mem_obj);
-    if (err) {
-        errno = err;
-        FatalError("xf86MapVidMem() can't vm_map.(mem_obj) (%s)\n",
-                   strerror(errno));
-    }
-    mach_port_deallocate(mach_task_self(), mem_dev);
-    if (err) {
-        errno = err;
-        FatalError
-            ("xf86MapVidMem() can't mach_port_deallocate.(mem_dev) (%s)\n",
-             strerror(errno));
-    }
-    return (void *) addr;
-}
-
-static void
-unmapVidMem(int ScreenNum, void *Base, unsigned long Size)
-{
-    kern_return_t err = vm_deallocate(mach_task_self(), (int) Base, Size);
-
-    if (err) {
-        errno = err;
-        ErrorF("xf86UnMapVidMem: can't dealloc framebuffer space (%s)\n",
-               strerror(errno));
-    }
-    return;
-}
 
 /**************************************************************************
  * I/O Permissions section                                                 
@@ -147,7 +85,5 @@ void
 xf86OSInitVidMem(VidMemInfoPtr pVidMem)
 {
     pVidMem->linearSupported = TRUE;
-    pVidMem->mapMem = mapVidMem;
-    pVidMem->unmapMem = unmapVidMem;
     pVidMem->initialised = TRUE;
 }
diff --git a/hw/xfree86/os-support/linux/lnx_video.c b/hw/xfree86/os-support/linux/lnx_video.c
index ffffc81..7389d48 100644
--- a/hw/xfree86/os-support/linux/lnx_video.c
+++ b/hw/xfree86/os-support/linux/lnx_video.c
@@ -82,17 +82,12 @@ extern int iopl(int __level);
 /* Video Memory Mapping section                                            */
 /***************************************************************************/
 
-static void *mapVidMem(int, unsigned long, unsigned long, int);
-static void unmapVidMem(int, void *, unsigned long);
-
 #if defined (__alpha__)
 extern void sethae(unsigned long hae);
 extern unsigned long _bus_base __P((void)) __attribute__ ((const));
 extern unsigned long _bus_base_sparse __P((void)) __attribute__ ((const));
 
-static void *mapVidMemSparse(int, unsigned long, unsigned long, int);
 extern axpDevice lnxGetAXP(void);
-static void unmapVidMemSparse(int, void *, unsigned long);
 static axpDevice axpSystem = -1;
 static Bool needSparse;
 static unsigned long hae_thresh;
@@ -374,17 +369,10 @@ xf86OSInitVidMem(VidMemInfoPtr pVidMem)
     }
     if (needSparse) {
         xf86Msg(X_INFO, "Machine needs sparse mapping\n");
-        pVidMem->mapMem = mapVidMemSparse;
-        pVidMem->unmapMem = unmapVidMemSparse;
     }
     else {
         xf86Msg(X_INFO, "Machine type has 8/16 bit access\n");
-        pVidMem->mapMem = mapVidMem;
-        pVidMem->unmapMem = unmapVidMem;
     }
-#else
-    pVidMem->mapMem = mapVidMem;
-    pVidMem->unmapMem = unmapVidMem;
 #endif                          /* __alpha__ */
 
 #ifdef HAS_MTRR_SUPPORT
@@ -394,83 +382,6 @@ xf86OSInitVidMem(VidMemInfoPtr pVidMem)
     pVidMem->initialised = TRUE;
 }
 
-#ifdef __sparc__
-/* Basically, you simply cannot do this on Sparc.  You have to do something portable
- * like use /dev/fb* or mmap() on /proc/bus/pci/X/Y nodes. -DaveM
- */
-static void *
-mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
-{
-    return NULL;
-}
-#else
-static void *
-mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
-{
-    void *base;
-    int fd;
-    int mapflags = MAP_SHARED;
-    int prot;
-    memType realBase, alignOff;
-
-    realBase = Base & ~(getpagesize() - 1);
-    alignOff = Base - realBase;
-    DebugF("base: %lx, realBase: %lx, alignOff: %lx \n",
-           Base, realBase, alignOff);
-
-#if defined(__ia64__) || defined(__arm__) || defined(__s390__)
-#ifndef MAP_WRITECOMBINED
-#define MAP_WRITECOMBINED 0x00010000
-#endif
-#ifndef MAP_NONCACHED
-#define MAP_NONCACHED 0x00020000
-#endif
-    if (flags & VIDMEM_FRAMEBUFFER)
-        mapflags |= MAP_WRITECOMBINED;
-    else
-        mapflags |= MAP_NONCACHED;
-#endif
-
-#if 0
-    /* this will disappear when people upgrade their kernels */
-    fd = open(DEV_MEM,
-              ((flags & VIDMEM_READONLY) ? O_RDONLY : O_RDWR) | O_SYNC);
-#else
-    fd = open(DEV_MEM, (flags & VIDMEM_READONLY) ? O_RDONLY : O_RDWR);
-#endif
-    if (fd < 0) {
-        FatalError("xf86MapVidMem: failed to open " DEV_MEM " (%s)\n",
-                   strerror(errno));
-    }
-
-    if (flags & VIDMEM_READONLY)
-        prot = PROT_READ;
-    else
-        prot = PROT_READ | PROT_WRITE;
-
-    /* This requires linux-0.99.pl10 or above */
-    base = mmap((caddr_t) 0, Size + alignOff, prot, mapflags, fd,
-                (off_t) realBase + BUS_BASE);
-    close(fd);
-    if (base == MAP_FAILED) {
-        FatalError("xf86MapVidMem: Could not mmap framebuffer"
-                   " (0x%08lx,0x%lx) (%s)\n", Base, Size, strerror(errno));
-    }
-    DebugF("base: %lx aligned base: %lx\n", base, (char *) base + alignOff);
-    return (char *) base + alignOff;
-}
-#endif                          /* !(__sparc__) */
-
-static void
-unmapVidMem(int ScreenNum, void *Base, unsigned long Size)
-{
-    uintptr_t alignOff = (uintptr_t) Base
-        - ((uintptr_t) Base & ~(getpagesize() - 1));
-
-    DebugF("alignment offset: %lx\n", (unsigned long) alignOff);
-    munmap((void *) ((uintptr_t) Base - alignOff), (Size + alignOff));
-}
-
 /***************************************************************************/
 /* I/O Permissions section                                                 */
 /***************************************************************************/
@@ -565,8 +476,6 @@ xf86DisableIO(void)
 
 #if defined (__alpha__)
 
-#define vuip    volatile unsigned int *
-
 extern int readDense8(void *Base, register unsigned long Offset);
 extern int readDense16(void *Base, register unsigned long Offset);
 extern int readDense32(void *Base, register unsigned long Offset);
@@ -577,284 +486,6 @@ extern void
 extern void
  writeDense32(int Value, void *Base, register unsigned long Offset);
 
-static int readSparse8(void *Base, register unsigned long Offset);
-static int readSparse16(void *Base, register unsigned long Offset);
-static int readSparse32(void *Base, register unsigned long Offset);
-static void
- writeSparseNB8(int Value, void *Base, register unsigned long Offset);
-static void
- writeSparseNB16(int Value, void *Base, register unsigned long Offset);
-static void
- writeSparseNB32(int Value, void *Base, register unsigned long Offset);
-static void
- writeSparse8(int Value, void *Base, register unsigned long Offset);
-static void
- writeSparse16(int Value, void *Base, register unsigned long Offset);
-static void
- writeSparse32(int Value, void *Base, register unsigned long Offset);
-
-#define DENSE_BASE	0x2ff00000000UL
-#define SPARSE_BASE	0x30000000000UL
-
-static unsigned long msb_set = 0;
-
-static void *
-mapVidMemSparse(int ScreenNum, unsigned long Base, unsigned long Size,
-                int flags)
-{
-    int fd, prot;
-    unsigned long ret, rets = 0;
-
-    static Bool was_here = FALSE;
-
-    if (!was_here) {
-        was_here = TRUE;
-
-        xf86WriteMmio8 = writeSparse8;
-        xf86WriteMmio16 = writeSparse16;
-        xf86WriteMmio32 = writeSparse32;
-        xf86WriteMmioNB8 = writeSparseNB8;
-        xf86WriteMmioNB16 = writeSparseNB16;
-        xf86WriteMmioNB32 = writeSparseNB32;
-        xf86ReadMmio8 = readSparse8;
-        xf86ReadMmio16 = readSparse16;
-        xf86ReadMmio32 = readSparse32;
-    }
-
-    fd = open(DEV_MEM, (flags & VIDMEM_READONLY) ? O_RDONLY : O_RDWR);
-    if (fd < 0) {
-        FatalError("xf86MapVidMem: failed to open " DEV_MEM " (%s)\n",
-                   strerror(errno));
-    }
-
-#if 0
-    xf86Msg(X_INFO, "mapVidMemSparse: try Base 0x%lx size 0x%lx flags 0x%x\n",
-            Base, Size, flags);
-#endif
-
-    if (flags & VIDMEM_READONLY)
-        prot = PROT_READ;
-    else
-        prot = PROT_READ | PROT_WRITE;
-
-    /* This requirers linux-0.99.pl10 or above */
-
-    /*
-     * Always do DENSE mmap, since read32/write32 currently require it.
-     */
-    ret = (unsigned long) mmap((caddr_t) (DENSE_BASE + Base), Size,
-                               prot, MAP_SHARED, fd, (off_t) (bus_base + Base));
-
-    /*
-     * Do SPARSE mmap only when MMIO and not MMIO_32BIT, or FRAMEBUFFER
-     * and SPARSE (which should require the use of read/write macros).
-     *
-     * By not SPARSE mmapping an 8MB framebuffer, we can save approx. 256K
-     * bytes worth of pagetable (32 pages).
-     */
-    if (((flags & VIDMEM_MMIO) && !(flags & VIDMEM_MMIO_32BIT)) ||
-        ((flags & VIDMEM_FRAMEBUFFER) && (flags & VIDMEM_SPARSE))) {
-        rets = (unsigned long) mmap((caddr_t) (SPARSE_BASE + (Base << 5)),
-                                    Size << 5, prot, MAP_SHARED, fd,
-                                    (off_t) _bus_base_sparse() + (Base << 5));
-    }
-
-    close(fd);
-
-    if (ret == (unsigned long) MAP_FAILED) {
-        FatalError("xf86MapVidMemSparse: Could not (dense) mmap fb (%s)\n",
-                   strerror(errno));
-    }
-
-    if (((flags & VIDMEM_MMIO) && !(flags & VIDMEM_MMIO_32BIT)) ||
-        ((flags & VIDMEM_FRAMEBUFFER) && (flags & VIDMEM_SPARSE))) {
-        if (rets == (unsigned long) MAP_FAILED ||
-            rets != (SPARSE_BASE + (Base << 5))) {
-            FatalError("mapVidMemSparse: Could not (sparse) mmap fb (%s)\n",
-                       strerror(errno));
-        }
-    }
-
-#if 1
-    if (rets)
-        xf86Msg(X_INFO, "mapVidMemSparse: mapped Base 0x%lx size 0x%lx"
-                " to DENSE at 0x%lx and SPARSE at 0x%lx\n",
-                Base, Size, ret, rets);
-    else
-        xf86Msg(X_INFO, "mapVidMemSparse: mapped Base 0x%lx size 0x%lx"
-                " to DENSE only at 0x%lx\n", Base, Size, ret);
-
-#endif
-    return (void *) ret;
-}
-
-static void
-unmapVidMemSparse(int ScreenNum, void *Base, unsigned long Size)
-{
-    unsigned long Offset = (unsigned long) Base - DENSE_BASE;
-
-#if 1
-    xf86Msg(X_INFO, "unmapVidMemSparse: unmapping Base 0x%lx Size 0x%lx\n",
-            Base, Size);
-#endif
-    /* Unmap DENSE always. */
-    munmap((caddr_t) Base, Size);
-
-    /* Unmap SPARSE always, and ignore error in case we did not map it. */
-    munmap((caddr_t) (SPARSE_BASE + (Offset << 5)), Size << 5);
-}
-
-static int
-readSparse8(void *Base, register unsigned long Offset)
-{
-    register unsigned long result, shift;
-    register unsigned long msb;
-
-    mem_barrier();
-    Offset += (unsigned long) Base - DENSE_BASE;
-    shift = (Offset & 0x3) << 3;
-    if (Offset >= (hae_thresh)) {
-        msb = Offset & hae_mask;
-        Offset -= msb;
-        if (msb_set != msb) {
-            sethae(msb);
-            msb_set = msb;
-        }
-    }
-
-    mem_barrier();
-    result = *(vuip) (SPARSE_BASE + (Offset << 5));
-    result >>= shift;
-    return 0xffUL & result;
-}
-
-static int
-readSparse16(void *Base, register unsigned long Offset)
-{
-    register unsigned long result, shift;
-    register unsigned long msb;
-
-    mem_barrier();
-    Offset += (unsigned long) Base - DENSE_BASE;
-    shift = (Offset & 0x2) << 3;
-    if (Offset >= hae_thresh) {
-        msb = Offset & hae_mask;
-        Offset -= msb;
-        if (msb_set != msb) {
-            sethae(msb);
-            msb_set = msb;
-        }
-    }
-
-    mem_barrier();
-    result = *(vuip) (SPARSE_BASE + (Offset << 5) + (1 << (5 - 2)));
-    result >>= shift;
-    return 0xffffUL & result;
-}
-
-static int
-readSparse32(void *Base, register unsigned long Offset)
-{
-    /* NOTE: this is really using DENSE. */
-    mem_barrier();
-    return *(vuip) ((unsigned long) Base + (Offset));
-}
-
-static void
-writeSparse8(int Value, void *Base, register unsigned long Offset)
-{
-    register unsigned long msb;
-    register unsigned int b = Value & 0xffU;
-
-    write_mem_barrier();
-    Offset += (unsigned long) Base - DENSE_BASE;
-    if (Offset >= hae_thresh) {
-        msb = Offset & hae_mask;
-        Offset -= msb;
-        if (msb_set != msb) {
-            sethae(msb);
-            msb_set = msb;
-        }
-    }
-
-    write_mem_barrier();
-    *(vuip) (SPARSE_BASE + (Offset << 5)) = b * 0x01010101;
-}
-
-static void
-writeSparse16(int Value, void *Base, register unsigned long Offset)
-{
-    register unsigned long msb;
-    register unsigned int w = Value & 0xffffU;
-
-    write_mem_barrier();
-    Offset += (unsigned long) Base - DENSE_BASE;
-    if (Offset >= hae_thresh) {
-        msb = Offset & hae_mask;
-        Offset -= msb;
-        if (msb_set != msb) {
-            sethae(msb);
-            msb_set = msb;
-        }
-    }
-
-    write_mem_barrier();
-    *(vuip) (SPARSE_BASE + (Offset << 5) + (1 << (5 - 2))) = w * 0x00010001;
-}
-
-static void
-writeSparse32(int Value, void *Base, register unsigned long Offset)
-{
-    /* NOTE: this is really using DENSE. */
-    write_mem_barrier();
-    *(vuip) ((unsigned long) Base + (Offset)) = Value;
-    return;
-}
-
-static void
-writeSparseNB8(int Value, void *Base, register unsigned long Offset)
-{
-    register unsigned long msb;
-    register unsigned int b = Value & 0xffU;
-
-    Offset += (unsigned long) Base - DENSE_BASE;
-    if (Offset >= hae_thresh) {
-        msb = Offset & hae_mask;
-        Offset -= msb;
-        if (msb_set != msb) {
-            sethae(msb);
-            msb_set = msb;
-        }
-    }
-    *(vuip) (SPARSE_BASE + (Offset << 5)) = b * 0x01010101;
-}
-
-static void
-writeSparseNB16(int Value, void *Base, register unsigned long Offset)
-{
-    register unsigned long msb;
-    register unsigned int w = Value & 0xffffU;
-
-    Offset += (unsigned long) Base - DENSE_BASE;
-    if (Offset >= hae_thresh) {
-        msb = Offset & hae_mask;
-        Offset -= msb;
-        if (msb_set != msb) {
-            sethae(msb);
-            msb_set = msb;
-        }
-    }
-    *(vuip) (SPARSE_BASE + (Offset << 5) + (1 << (5 - 2))) = w * 0x00010001;
-}
-
-static void
-writeSparseNB32(int Value, void *Base, register unsigned long Offset)
-{
-    /* NOTE: this is really using DENSE. */
-    *(vuip) ((unsigned long) Base + (Offset)) = Value;
-    return;
-}
-
 void (*xf86WriteMmio8) (int Value, void *Base, unsigned long Offset)
     = writeDense8;
 void (*xf86WriteMmio16) (int Value, void *Base, unsigned long Offset)
diff --git a/hw/xfree86/os-support/shared/vidmem.c b/hw/xfree86/os-support/shared/vidmem.c
index f473293..1c695fe 100644
--- a/hw/xfree86/os-support/shared/vidmem.c
+++ b/hw/xfree86/os-support/shared/vidmem.c
@@ -50,14 +50,6 @@
  */
 
 typedef struct {
-    unsigned long size;
-    void *virtBase;
-    void *mtrrInfo;
-} MappingRec, *MappingPtr;
-
-typedef struct {
-    int numMappings;
-    MappingPtr *mappings;
     Bool mtrrEnabled;
     MessageType mtrrFrom;
     Bool mtrrOptChecked;
@@ -69,7 +61,7 @@ static int vidMapIndex = -1;
 #define VIDMAPPTR(p) ((VidMapPtr)((p)->privates[vidMapIndex].ptr))
 
 static VidMemInfo vidMemInfo = { FALSE, };
-static VidMapRec vidMapRec = { 0, NULL, TRUE, X_DEFAULT, FALSE, NULL };
+static VidMapRec vidMapRec = { TRUE, X_DEFAULT, FALSE, NULL };
 
 static VidMapPtr
 getVidMapRec(int scrnIndex)
@@ -94,45 +86,6 @@ getVidMapRec(int scrnIndex)
     return vp;
 }
 
-static MappingPtr
-newMapping(VidMapPtr vp)
-{
-    vp->mappings = xnfrealloc(vp->mappings, sizeof(MappingPtr) *
-                              (vp->numMappings + 1));
-    vp->mappings[vp->numMappings] = xnfcalloc(sizeof(MappingRec), 1);
-    return vp->mappings[vp->numMappings++];
-}
-
-static MappingPtr
-findMapping(VidMapPtr vp, void *vbase, unsigned long size)
-{
-    int i;
-
-    for (i = 0; i < vp->numMappings; i++) {
-        if (vp->mappings[i]->virtBase == vbase && vp->mappings[i]->size == size)
-            return vp->mappings[i];
-    }
-    return NULL;
-}
-
-static void
-removeMappi