[Xquartz-changes] xserver: Branch 'server-1.12-apple' - 53 commits

Jeremy Huddleston jeremyhu at freedesktop.org
Wed Sep 21 14:39:25 PDT 2011


Rebased ref, commits from common ancestor:
commit 9176530b2204f710da46f6b436a47fa49d156727
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 eaa21ad..e65a1c0 100644
--- a/fb/fb.h
+++ b/fb/fb.h
@@ -2049,11 +2049,8 @@ fbFillRegionSolid (DrawablePtr	pDrawable,
 		   FbBits	xor);
 
 extern _X_EXPORT pixman_image_t *
-image_from_pict (PicturePtr	pict,
-		 Bool		has_clip,
-		 int		*xoff,
-		 int		*yoff);
-
+image_from_pict (PicturePtr pict,
+		 Bool       has_clip);
 extern _X_EXPORT void free_pixman_pict (PicturePtr, pixman_image_t *);
 
 #endif /* _FB_H_ */
diff --git a/fb/fbpict.c b/fb/fbpict.c
index d1fd0cb..d2986c8 100644
--- a/fb/fbpict.c
+++ b/fb/fbpict.c
@@ -50,24 +50,19 @@ fbComposite (CARD8      op,
 	     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,
+				xSrc, ySrc, xMask, yMask, xDst, yDst,
 				width, height);
     }
 
@@ -146,22 +141,22 @@ create_conical_gradient_image (PictGradient *gradient)
 
 static pixman_image_t *
 create_bits_picture (PicturePtr pict,
-		     Bool       has_clip,
-		     int	*xoff,
-		     int	*yoff)
+		     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,
+	pict->pDrawable->width, pict->pDrawable->height,
 	(uint32_t *)bits, stride * sizeof (FbStride));
     
     
@@ -187,55 +182,33 @@ create_bits_picture (PicturePtr pict,
 	if (pict->clientClipType != CT_NONE)
 	    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);
+image_from_pict_internal (PicturePtr pict, Bool has_clip, 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, (pixman_transform_t *)pict->transform);
     }
     
     switch (pict->repeatType)
@@ -265,8 +238,7 @@ set_image_properties (pixman_image_t *image, PicturePtr pict, Bool has_clip, int
      */
     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);
+	pixman_image_t *alpha_map = image_from_pict_internal (pict->alphaMap, TRUE, TRUE);
 	
 	pixman_image_set_alpha_map (
 	    image, alpha_map, pict->alphaOrigin.x, pict->alphaOrigin.y);
@@ -299,7 +271,8 @@ set_image_properties (pixman_image_t *image, PicturePtr pict, Bool has_clip, int
 }
 
 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;
 
@@ -308,7 +281,7 @@ image_from_pict_internal (PicturePtr pict, Bool has_clip, int *xoff, int *yoff,
 
     if (pict->pDrawable)
     {
-	image = create_bits_picture (pict, has_clip, xoff, yoff);
+	image = create_bits_picture (pict, has_clip);
     }
     else if (pict->pSourcePict)
     {
@@ -329,19 +302,18 @@ 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 0b5a638..fbe2647 100644
--- a/fb/fbtrap.c
+++ b/fb/fbtrap.c
@@ -39,12 +39,11 @@ fbAddTraps (PicturePtr	pPicture,
 	    xTrap	*traps)
 {
     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_traps (image, x_off + dst_xoff, y_off + dst_yoff,
+    pixman_add_traps (image, x_off, y_off,
 		      ntrap, (pixman_trap_t *)traps);
 
     free_pixman_pict (pPicture, image);
@@ -57,14 +56,13 @@ fbRasterizeTrapezoid (PicturePtr    pPicture,
 		      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);
+				x_off,
+				y_off);
 
     free_pixman_pict (pPicture, image);
 }
@@ -77,13 +75,12 @@ fbAddTriangles (PicturePtr  pPicture,
 		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,
+			  x_off, y_off,
 			  ntri, (pixman_triangle_t *)tris);
 
     free_pixman_pict (pPicture, image);
@@ -110,13 +107,11 @@ fbShapes (CompositeShapesFunc	composite,
 	  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)
     {
@@ -136,10 +131,10 @@ fbShapes (CompositeShapesFunc	composite,
 	    for (i = 0; i < nshapes; ++i)
 	    {
 		composite (op, src, dst, format,
-			   xSrc + src_xoff,
-			   ySrc + src_yoff,
-			   dst_xoff,
-			   dst_yoff,
+			   xSrc,
+			   ySrc,
+			   0,
+			   0,
 			   1, shapes + i * shape_size);
 	    }
 	}
@@ -162,10 +157,10 @@ fbShapes (CompositeShapesFunc	composite,
 	    }
 	    
 	    composite (op, src, dst, format,
-		       xSrc + src_xoff,
-		       ySrc + src_yoff,
-		       dst_xoff,
-		       dst_yoff,
+		       xSrc,
+		       ySrc,
+		       0,
+		       0,
 		       nshapes, shapes);
 	}
 
commit 083b927df0f199e57c615dd47bf9dff6164c4949
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 0f1ebe5..dcbfe1c 100644
--- a/mi/miexpose.c
+++ b/mi/miexpose.c
@@ -521,6 +521,7 @@ void RootlessSetPixmapOfAncestors(WindowPtr pWin);
 void RootlessStartDrawing(WindowPtr pWin);
 void RootlessDamageRegion(WindowPtr pWin, RegionPtr prgn);
 Bool IsFramedWindow(WindowPtr pWin);
+#include "../fb/fb.h"
 #endif 
 
 void
@@ -548,24 +549,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;
-
-    if(IsFramedWindow(pWin)) {
-        RootlessStartDrawing(pWin);
-        RootlessDamageRegion(pWin, prgn);
-    
-        if(pWin->backgroundState == ParentRelative) {
-            if((what == PW_BACKGROUND) || 
-               (what == PW_BORDER && !pWin->borderIsPixel))
-                RootlessSetPixmapOfAncestors(pWin);
-        }
-    }
 #endif
     
     if (what == PW_BACKGROUND)
     {
+#ifdef ROOTLESS
+	if(IsFramedWindow(pWin)) {
+	    RootlessStartDrawing(pWin);
+	    RootlessDamageRegion(pWin, prgn);
+
+	    if(pWin->backgroundState == ParentRelative) {
+		RootlessSetPixmapOfAncestors(pWin);
+	    }
+	}
+#endif
+
 	while (pWin->backgroundState == ParentRelative)
 	    pWin = pWin->parent;
 
@@ -591,6 +605,18 @@ miPaintWindow(WindowPtr pWin, RegionPtr prgn, int what)
     {
 	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;
 	
@@ -599,6 +625,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;
@@ -661,6 +693,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 aa42a82b1ba71a86b9af9b79199a824d0bb8fe21
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Sat Oct 30 14:55:06 2010 -0700

    configure.ac: Add -fno-strict-aliasing to CFLAGS
    
    This should address https://bugs.freedesktop.org/show_bug.cgi?id=31238
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/configure.ac b/configure.ac
index 811435d..1f3476b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -87,6 +87,12 @@ XORG_PROG_RAWCPP
 # easier overrides at build time.
 XSERVER_CFLAGS='$(CWARNFLAGS)'
 
+dnl Explicitly add -fno-strict-aliasing since this option should disappear
+dnl from util-macros CWARNFLAGS
+if  test "x$GCC" = xyes ; then
+    XSERVER_CFLAGS="$XSERVER_CFLAGS -fno-strict-aliasing"
+fi
+
 dnl Check for dtrace program (needed to build Xserver dtrace probes)
 dnl Also checks for <sys/sdt.h>, since some Linux distros have an 
 dnl ISDN trace program named dtrace
commit c856ac3813869a9f3f981aee21a9be6a6083b2fe
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Wed Sep 14 13:45:18 2011 -0500

    xorg-server.pc.in: Remove libpciaccess and pixman-1 from Requires
    
    Every module building against xorg-server does not *Require* pixman nor
    libpciaccess.  If such modules need pixman or pciaccess, they should be
    depending on them directly rather than inheriting a dependency from
    xorg-server.  To do this, they should use PKG_CHECK_MODULES in configure.ac
    to check for pixman-1 or pciaccess and include the apporpriate _LIBS variable
    to the appropriate _LDFLAGS variable in Makefile.am
    
    This also moves pixman-1 to Requires.private, so CPPFLAGS is set right to
    to satisfy include dependencies but avoid linking needlessly.
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>
    Reviewed-by: Gaetan Nadon <memsize at videotron.ca>

diff --git a/configure.ac b/configure.ac
index deccd78..811435d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -783,11 +783,6 @@ VIDMODEPROTO="xf86vidmodeproto >= 2.2.99.1"
 WINDOWSWMPROTO="windowswmproto"
 APPLEWMPROTO="applewmproto >= 1.4"
 
-dnl Core modules for most extensions, et al.
-SDK_REQUIRED_MODULES="[xproto >= 7.0.22] [randrproto >= 1.2.99.3] [renderproto >= 0.11] [xextproto >= 7.1.99] [inputproto >= 1.9.99.902] [kbproto >= 1.0.3] fontsproto"
-# Make SDK_REQUIRED_MODULES available for inclusion in xorg-server.pc
-AC_SUBST(SDK_REQUIRED_MODULES)
-
 dnl List of libraries that require a specific version
 LIBAPPLEWM="applewm >= 1.4"
 LIBDMX="dmx >= 1.0.99.1"
@@ -809,6 +804,11 @@ dnl specific modules against it
 PKG_CHECK_MODULES(PIXMAN, $LIBPIXMAN)
 REQUIRED_LIBS="$REQUIRED_LIBS $LIBPIXMAN $LIBXFONT xau"
 
+dnl Core modules for most extensions, et al.
+SDK_REQUIRED_MODULES="[xproto >= 7.0.22] [randrproto >= 1.2.99.3] [renderproto >= 0.11] [xextproto >= 7.1.99] [inputproto >= 1.9.99.902] [kbproto >= 1.0.3] fontsproto $LIBPIXMAN"
+# Make SDK_REQUIRED_MODULES available for inclusion in xorg-server.pc
+AC_SUBST(SDK_REQUIRED_MODULES)
+
 REQUIRED_MODULES="[fixesproto >= 5.0] [damageproto >= 1.1] [xcmiscproto >= 1.2.0] [xtrans >= 1.2.2] [bigreqsproto >= 1.1.0] $SDK_REQUIRED_MODULES"
 
 if test "x$CONFIG_UDEV" = xyes &&
@@ -1559,6 +1559,7 @@ if test "x$XORG" = xyes; then
 	if test "x$PCI" = xyes; then
 
 	PKG_CHECK_MODULES([PCIACCESS], $LIBPCIACCESS)
+	SDK_REQUIRED_MODULES="$SDK_REQUIRED_MODULES $LIBPCIACCESS"
 	XORG_SYS_LIBS="$XORG_SYS_LIBS $PCIACCESS_LIBS $GLX_SYS_LIBS"
 	XORG_CFLAGS="$XORG_CFLAGS $PCIACCESS_CFLAGS"
 
diff --git a/xorg-server.pc.in b/xorg-server.pc.in
index fb238b5..a98eca8 100644
--- a/xorg-server.pc.in
+++ b/xorg-server.pc.in
@@ -15,7 +15,6 @@ abi_extension=@abi_extension@
 Name: xorg-server
 Description: Modular X.Org X Server
 Version: @PACKAGE_VERSION@
-Requires: pixman-1 pciaccess
 Requires.private: @SDK_REQUIRED_MODULES@
 Cflags: -I${sdkdir} @symbol_visibility@
 Libs: -L${libdir}
commit c7bda377e7b3eb12bba877084499b2074c393c73
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Wed Sep 14 10:37:38 2011 -0500

    darwin: configure: Force some irrelevant options to off on darwin
    
    This removes the need to pass the following to configure on darwin:
    --disable-pciaccess -disable-int10-module --disable-vbe --disable-vgahw --disable-libdrm
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/configure.ac b/configure.ac
index e72dffc..deccd78 100644
--- a/configure.ac
+++ b/configure.ac
@@ -718,6 +718,11 @@ case $host_os in
 		XV=no
 		;;
 	darwin*)
+		PCI=no
+		INT10MODULE=no
+		VGAHW=no
+		VBE=no
+		DRM=no
 		DRI2=no
 
 		if test x$XQUARTZ = xauto; then
commit cb0676fad478087865062cc1adab3903a4f4ff70
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Wed Sep 14 15:42:19 2011 -0500

    xfree86: Link modules with -module
    
    This makes a difference on darwin (and apparently nowhere else)
    
    https://www.gnu.org/s/libtool/manual/libtool.html#Modules-for-libltdl
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>
    Reviewed-by: Jamey Sharp <jamey at minilop.net>
    Reviewed-by: Gaetan Nadon <memsize at videotron.ca>

diff --git a/hw/xfree86/dixmods/Makefile.am b/hw/xfree86/dixmods/Makefile.am
index 1a162ab..b6eb54f 100644
--- a/hw/xfree86/dixmods/Makefile.am
+++ b/hw/xfree86/dixmods/Makefile.am
@@ -30,21 +30,21 @@ INCLUDES = @XORG_INCS@ \
            -I$(top_srcdir)/miext/shadow \
            -I$(top_srcdir)/glx
 
-libdbe_la_LDFLAGS = -avoid-version
+libdbe_la_LDFLAGS = -module -avoid-version
 libdbe_la_LIBADD = $(top_builddir)/dbe/libdbe.la
 libdbe_la_SOURCES = dbemodule.c
 
-libfb_la_LDFLAGS = -avoid-version
+libfb_la_LDFLAGS = -module -avoid-version
 libfb_la_LIBADD = $(top_builddir)/fb/libfb.la
 libfb_la_SOURCES = $(top_builddir)/fb/fbcmap_mi.c fbmodule.c
 libfb_la_CFLAGS = $(AM_CFLAGS)
 
-libwfb_la_LDFLAGS = -avoid-version
+libwfb_la_LDFLAGS = -module -avoid-version
 libwfb_la_LIBADD = $(top_builddir)/fb/libwfb.la
 libwfb_la_SOURCES = $(top_builddir)/fb/fbcmap_mi.c fbmodule.c
 libwfb_la_CFLAGS = $(AM_CFLAGS) -DFB_ACCESS_WRAPPER
 
-libglx_la_LDFLAGS = -avoid-version
+libglx_la_LDFLAGS = -module -avoid-version
 if AIGLX_DRI_LOADER
 GLXDRI_LIBRARY = $(top_builddir)/glx/libglxdri.la
 endif
@@ -53,11 +53,11 @@ libglx_la_LIBADD = \
 	$(GLXDRI_LIBRARY)
 libglx_la_SOURCES = glxmodule.c
 
-librecord_la_LDFLAGS = -avoid-version
+librecord_la_LDFLAGS = -module -avoid-version
 librecord_la_LIBADD = $(top_builddir)/record/librecord.la
 librecord_la_SOURCES = recordmod.c
 
-libshadow_la_LDFLAGS = -avoid-version
+libshadow_la_LDFLAGS = -module -avoid-version
 libshadow_la_LIBADD = $(top_builddir)/miext/shadow/libshadow.la
 libshadow_la_SOURCES = shmodule.c
 
diff --git a/hw/xfree86/dixmods/extmod/Makefile.am b/hw/xfree86/dixmods/extmod/Makefile.am
index cce19f7..87c28a4 100644
--- a/hw/xfree86/dixmods/extmod/Makefile.am
+++ b/hw/xfree86/dixmods/extmod/Makefile.am
@@ -21,7 +21,7 @@ INCLUDES = @XORG_INCS@ \
            -I$(top_srcdir)/hw/xfree86/loader \
            -I$(top_srcdir)/miext/shadow
 
-libextmod_la_LDFLAGS = -avoid-version
+libextmod_la_LDFLAGS = -module -avoid-version
 libextmod_la_SOURCES = modinit.c \
                        modinit.h \
                        $(DGA_SRCS) \
diff --git a/hw/xfree86/exa/Makefile.am b/hw/xfree86/exa/Makefile.am
index 39f7a90..3ced531 100644
--- a/hw/xfree86/exa/Makefile.am
+++ b/hw/xfree86/exa/Makefile.am
@@ -2,7 +2,7 @@ SUBDIRS = man
 
 module_LTLIBRARIES = libexa.la
 
-libexa_la_LDFLAGS = -avoid-version
+libexa_la_LDFLAGS = -module -avoid-version
 
 INCLUDES = \
 	$(XORG_INCS) \
diff --git a/hw/xfree86/fbdevhw/Makefile.am b/hw/xfree86/fbdevhw/Makefile.am
index 2a03890..4472acd 100644
--- a/hw/xfree86/fbdevhw/Makefile.am
+++ b/hw/xfree86/fbdevhw/Makefile.am
@@ -2,7 +2,7 @@ SUBDIRS = man
 
 module_LTLIBRARIES = libfbdevhw.la
 
-libfbdevhw_la_LDFLAGS = -avoid-version
+libfbdevhw_la_LDFLAGS = -module -avoid-version
 
 if FBDEVHW
 libfbdevhw_la_SOURCES = fbdevhw.c
diff --git a/hw/xfree86/shadowfb/Makefile.am b/hw/xfree86/shadowfb/Makefile.am
index 02d2dd4..39c6610 100644
--- a/hw/xfree86/shadowfb/Makefile.am
+++ b/hw/xfree86/shadowfb/Makefile.am
@@ -1,5 +1,5 @@
 module_LTLIBRARIES = libshadowfb.la
-libshadowfb_la_LDFLAGS = -avoid-version
+libshadowfb_la_LDFLAGS = -module -avoid-version
 libshadowfb_la_SOURCES = sfbmodule.c shadow.c
 
 sdk_HEADERS = shadowfb.h
diff --git a/hw/xfree86/vbe/Makefile.am b/hw/xfree86/vbe/Makefile.am
index 85c6fd8..4b794e6 100644
--- a/hw/xfree86/vbe/Makefile.am
+++ b/hw/xfree86/vbe/Makefile.am
@@ -1,5 +1,5 @@
 module_LTLIBRARIES = libvbe.la
-libvbe_la_LDFLAGS = -avoid-version
+libvbe_la_LDFLAGS = -module -avoid-version
 libvbe_la_SOURCES = vbe.c vbeModes.c vbe_module.c
 
 sdk_HEADERS = vbe.h vbeModes.h
diff --git a/hw/xfree86/xaa/Makefile.am b/hw/xfree86/xaa/Makefile.am
index 5bfb4e9..7ebe0b9 100644
--- a/hw/xfree86/xaa/Makefile.am
+++ b/hw/xfree86/xaa/Makefile.am
@@ -8,7 +8,7 @@ MSB_FIXED = mf-xaaBitmap.c mf-xaaStipple.c mf-xaaTEGlyph.c
 MSB_3_FIXED = mf3-xaaBitmap.c mf3-xaaStipple.c
 POLYSEG = s-xaaLine.c s-xaaDashLine.c
 
-libxaa_la_LDFLAGS = -avoid-version
+libxaa_la_LDFLAGS = -module -avoid-version
 if COMPOSITE
 libxaa_la_LIBADD = $(top_builddir)/miext/cw/libcw.la
 endif
commit ec6c173c235f4b9de1d4b99af6f58fd736b033ff
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Wed Sep 14 12:14:56 2011 -0500

    xfree86: fbdevhw: Remove unused include of pciaccess.h
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>
    Reviewed-by: Jamey Sharp <jamey at minilop.net>

diff --git a/hw/xfree86/fbdevhw/fbdevhw.h b/hw/xfree86/fbdevhw/fbdevhw.h
index bc46b9c..34870c2 100644
--- a/hw/xfree86/fbdevhw/fbdevhw.h
+++ b/hw/xfree86/fbdevhw/fbdevhw.h
@@ -5,8 +5,6 @@
 #include "xf86str.h"
 #include "colormapst.h"
 
-#include <pciaccess.h>
-
 #define FBDEVHW_PACKED_PIXELS		0	/* Packed Pixels	*/
 #define FBDEVHW_PLANES			1	/* Non interleaved planes */
 #define FBDEVHW_INTERLEAVED_PLANES	2	/* Interleaved planes	*/
commit a696b59100dba524c82098790144c5e03d708204
Author: Tiago Vignatti <tiago.vignatti at nokia.com>
Date:   Tue Jun 1 13:05:47 2010 +0300

    configure: wrap PCI code with macro and set it at build time
    
    --disable-pciaccess, used together with --disable-module-int10, can be used to
    disable all pci code inside the server.
    
    Note that XSERVER_LIBPCIACCESS was previously used only in the driver side and
    now it defines also whether the library is used inside the server. Also,
    XORG_BUS_PCI automake variable is introduced to track PCI code needs.
    
    Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
    Reviewed-by: Mikhail Gusarov <dottedmag at dottedmag.net>
    Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com>
    Built-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/configure.ac b/configure.ac
index 0c0d4c5..e72dffc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -637,6 +637,7 @@ AC_ARG_ENABLE(int10-module,     AS_HELP_STRING([--enable-int10-module], [Build X
 AC_ARG_ENABLE(windowswm,      AS_HELP_STRING([--enable-windowswm], [Build XWin with WindowsWM extension (default: no)]), [WINDOWSWM=$enableval], [WINDOWSWM=no])
 AC_ARG_ENABLE(libdrm,         AS_HELP_STRING([--enable-libdrm], [Build Xorg with libdrm support (default: enabled)]), [DRM=$enableval],[DRM=yes])
 AC_ARG_ENABLE(clientids,      AS_HELP_STRING([--disable-clientids], [Build Xorg with client ID tracking (default: enabled)]), [CLIENTIDS=$enableval], [CLIENTIDS=yes])
+AC_ARG_ENABLE(pciaccess, AS_HELP_STRING([--enable-pciaccess], [Build Xorg with pciaccess library (default: enabled)]), [PCI=$enableval], [PCI=yes])
 
 dnl DDXes.
 AC_ARG_ENABLE(xorg,    	      AS_HELP_STRING([--enable-xorg], [Build Xorg server (default: auto)]), [XORG=$enableval], [XORG=auto])
@@ -1549,6 +1550,9 @@ if test "x$XORG" = xyes; then
 	xorg_bus_bsdpci=no
 	xorg_bus_sparc=no
 
+	AC_MSG_CHECKING([whether to build Xorg PCI functions])
+	if test "x$PCI" = xyes; then
+
 	PKG_CHECK_MODULES([PCIACCESS], $LIBPCIACCESS)
 	XORG_SYS_LIBS="$XORG_SYS_LIBS $PCIACCESS_LIBS $GLX_SYS_LIBS"
 	XORG_CFLAGS="$XORG_CFLAGS $PCIACCESS_CFLAGS"
@@ -1568,6 +1572,10 @@ if test "x$XORG" = xyes; then
         xorg_bus_sparc="yes"
         ;;
 	esac
+	fi
+	AC_MSG_RESULT([$PCI])
+
+	AM_CONDITIONAL([XORG_BUS_PCI], [test "x$PCI" = xyes])
 	AM_CONDITIONAL([XORG_BUS_LINUXPCI], [test "x$xorg_bus_linuxpci" = xyes])
 	AM_CONDITIONAL([XORG_BUS_BSDPCI], [test "x$xorg_bus_bsdpci" = xyes])
 	AM_CONDITIONAL([XORG_BUS_SPARC], [test "x$xorg_bus_sparc" = xyes])
diff --git a/hw/xfree86/common/Makefile.am b/hw/xfree86/common/Makefile.am
index c031d4b..f634b2c 100644
--- a/hw/xfree86/common/Makefile.am
+++ b/hw/xfree86/common/Makefile.am
@@ -1,5 +1,10 @@
 noinst_LTLIBRARIES = libcommon.la
 
+if XORG_BUS_PCI
+PCI_SOURCES = xf86pciBus.c xf86VGAarbiter.c xf86VGAarbiter.h \
+              xf86VGAarbiterPriv.h
+endif
+
 if XORG_BUS_SPARC
 SBUS_SOURCES = xf86sbusBus.c
 endif
@@ -19,7 +24,7 @@ endif
 
 RANDRSOURCES = xf86RandR.c
 
-BUSSOURCES = xf86pciBus.c xf86fbBus.c xf86noBus.c $(SBUS_SOURCES)
+BUSSOURCES = xf86fbBus.c xf86noBus.c $(PCI_SOURCES) $(SBUS_SOURCES)
 
 MODEDEFSOURCES = $(srcdir)/vesamodes $(srcdir)/extramodes
 
@@ -33,7 +38,7 @@ AM_LDFLAGS = -r
 libcommon_la_SOURCES = xf86Configure.c xf86ShowOpts.c xf86Bus.c xf86Config.c \
                       xf86Cursor.c $(DGASOURCES) xf86DPMS.c \
                       xf86Events.c xf86Globals.c xf86AutoConfig.c \
-                      xf86Option.c xf86Init.c xf86VGAarbiter.c \
+                      xf86Option.c xf86Init.c \
                       xf86VidMode.c xf86fbman.c xf86cmap.c \
                       xf86Helper.c xf86PM.c xf86Xinput.c xisb.c \
                       xf86Mode.c xorgHelper.c \
diff --git a/hw/xfree86/common/xf86.h b/hw/xfree86/common/xf86.h
index b1a5ab2..e9e218f 100644
--- a/hw/xfree86/common/xf86.h
+++ b/hw/xfree86/common/xf86.h
@@ -92,6 +92,7 @@ extern _X_EXPORT Bool VTSwitchEnabled;	/* kbd driver */
 #ifndef _NO_XF86_PROTOTYPES
 
 /* PCI related */
+#ifdef XSERVER_LIBPCIACCESS
 #include <pciaccess.h>
 extern _X_EXPORT Bool pciSlotClaimed;
 
@@ -118,6 +119,15 @@ extern _X_EXPORT ScrnInfoPtr xf86ConfigPciEntity(ScrnInfoPtr pScrn,
 extern _X_EXPORT Bool xf86ConfigActivePciEntity(ScrnInfoPtr pScrn,
         int entityIndex,PciChipsets *p_chip, void *dummy, EntityProc init,
         EntityProc enter, EntityProc leave, pointer private);
+#else
+#define xf86VGAarbiterInit() do {} while (0)
+#define xf86VGAarbiterFini() do {} while (0)
+#define xf86VGAarbiterLock(x) do {} while (0)
+#define xf86VGAarbiterUnlock(x) do {} while (0)
+#define xf86VGAarbiterScrnInit(x) do {} while (0)
+#define xf86VGAarbiterDeviceDecodes() do {} while (0)
+#define xf86VGAarbiterWrapFunctions() do {} while (0)
+#endif
 
 /* xf86Bus.c */
 
diff --git a/hw/xfree86/common/xf86AutoConfig.c b/hw/xfree86/common/xf86AutoConfig.c
index 5c6e721..7fc6518 100644
--- a/hw/xfree86/common/xf86AutoConfig.c
+++ b/hw/xfree86/common/xf86AutoConfig.c
@@ -255,9 +255,9 @@ listPossibleVideoDrivers(char *matches[], int nmatches)
 	    matches[i++] = xnfstrdup(sbusDriver);
     }
 #endif
-
+#ifdef XSERVER_LIBPCIACCESS
     i = xf86PciMatchDriver(matches, nmatches);
-
+#endif
     /* Fallback to platform default hardware */
     if (i < (nmatches - 1)) {
 #if defined(__i386__) || defined(__amd64__) || defined(__hurd__)
diff --git a/hw/xfree86/common/xf86Bus.c b/hw/xfree86/common/xf86Bus.c
index 8749a29..c665a20 100644
--- a/hw/xfree86/common/xf86Bus.c
+++ b/hw/xfree86/common/xf86Bus.c
@@ -47,8 +47,9 @@
 
 #define XF86_OS_PRIVS
 #include "xf86_OSproc.h"
+#ifdef XSERVER_LIBPCIACCESS
 #include "xf86VGAarbiter.h"
-
+#endif
 /* Entity data */
 EntityPtr *xf86Entities = NULL;	/* Bus slots claimed by drivers */
 int xf86NumEntities = 0;
@@ -75,7 +76,7 @@ Bool
 xf86CallDriverProbe( DriverPtr drv, Bool detect_only )
 {
     Bool     foundScreen = FALSE;
-
+#ifdef XSERVER_LIBPCIACCESS
     if (drv->PciProbe != NULL) {
         if (xf86DoConfigure && xf86DoConfigurePass1) {
             assert(detect_only);
@@ -86,7 +87,7 @@ xf86CallDriverProbe( DriverPtr drv, Bool detect_only )
             foundScreen = xf86PciProbeDev(drv);
         }
     }
-
+#endif
     if (!foundScreen && (drv->Probe != NULL)) {
         xf86Msg( X_WARNING, "Falling back to old probe method for %s\n",
                              drv->driverName);
@@ -195,7 +196,9 @@ xf86BusConfig(void)
 void
 xf86BusProbe(void)
 {
+#ifdef XSERVER_LIBPCIACCESS
     xf86PciProbe();
+#endif
 #if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
     xf86SbusProbe();
 #endif
@@ -504,9 +507,14 @@ xf86PostProbe(void)
 {
     int i;
 
-    if (fbSlotClaimed && (pciSlotClaimed
+    if (fbSlotClaimed && (
 #if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
-	    || sbusSlotClaimed
+	    sbusSlotClaimed ||
+#endif
+#ifdef XSERVER_LIBPCIACCESS
+	    pciSlotClaimed
+#else
+        TRUE
 #endif
 	    ))
 	    FatalError("Cannot run in framebuffer mode. Please specify busIDs "
diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c
index 3aa923a..a086a48 100644
--- a/hw/xfree86/common/xf86Config.c
+++ b/hw/xfree86/common/xf86Config.c
@@ -2450,7 +2450,7 @@ xf86HandleConfigFile(Bool autoconfig)
     }
 
     xf86ProcessOptions(-1, xf86ConfigLayout.options, LayoutOptions);
-
+#ifdef XSERVER_LIBPCIACCESS
     if ((scanptr = xf86GetOptValString(LayoutOptions, LAYOUT_ISOLATEDEVICE))) {
        ; /* IsolateDevice specified; overrides SingleCard */
     } else {
@@ -2465,7 +2465,7 @@ xf86HandleConfigFile(Bool autoconfig)
        } else
            xf86PciIsolateDevice(scanptr);
     }
-
+#endif
     /* Now process everything else */
     if (!configServerFlags(xf86configptr->conf_flags,xf86ConfigLayout.options)){
              ErrorF ("Problem when converting the config data structures\n");
diff --git a/hw/xfree86/common/xf86Configure.c b/hw/xfree86/common/xf86Configure.c
index ab07515..99b8b48 100644
--- a/hw/xfree86/common/xf86Configure.c
+++ b/hw/xfree86/common/xf86Configure.c
@@ -87,9 +87,11 @@ xf86AddBusDeviceToConfigure(const char *driver, BusType bus, void *busData, int
     /* Check for duplicates */
     for (i = 0;  i < nDevToConfig;  i++) {
         switch (bus) {
+#ifdef XSERVER_LIBPCIACCESS
             case BUS_PCI:
                 ret = xf86PciConfigure(busData, DevToConfig[i].pVideo);
-                break;
+	            break;
+#endif
 #if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
             case BUS_SBUS:
                 ret = xf86SbusConfigure(busData, DevToConfig[i].sVideo);
@@ -118,10 +120,12 @@ xf86AddBusDeviceToConfigure(const char *driver, BusType bus, void *busData, int
     for (j = 0;  (DevToConfig[i].GDev.driver[j] = tolower(driver[j]));  j++);
 
     switch (bus) {
+#ifdef XSERVER_LIBPCIACCESS
         case BUS_PCI:
             xf86PciConfigureNewDev(busData, DevToConfig[i].pVideo,
                                    &DevToConfig[i].GDev, &chipset);
 	        break;
+#endif
 #if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
         case BUS_SBUS:
             xf86SbusConfigureNewDev(busData, DevToConfig[i].sVideo,
diff --git a/hw/xfree86/common/xf86DPMS.c b/hw/xfree86/common/xf86DPMS.c
index cd025dc..613c7cf 100644
--- a/hw/xfree86/common/xf86DPMS.c
+++ b/hw/xfree86/common/xf86DPMS.c
@@ -42,8 +42,9 @@
 #include <X11/extensions/dpmsconst.h>
 #include "dpmsproc.h"
 #endif
+#ifdef XSERVER_LIBPCIACCESS
 #include "xf86VGAarbiter.h"
-
+#endif
 
 #ifdef DPMSExtension
 static DevPrivateKeyRec DPMSKeyRec;
diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
index 93ea333..9efa113 100644
--- a/hw/xfree86/common/xf86Init.c
+++ b/hw/xfree86/common/xf86Init.c
@@ -78,7 +78,9 @@
 #include "picturestr.h"
 
 #include "xf86Bus.h"
+#ifdef XSERVER_LIBPCIACCESS
 #include "xf86VGAarbiter.h"
+#endif
 #include "globals.h"
 
 #ifdef DPMSExtension
@@ -87,7 +89,6 @@
 #endif
 #include <hotplug.h>
 
-
 #ifdef XF86PM
 void (*xf86OSPMClose)(void) = NULL;
 #endif
@@ -1337,6 +1338,7 @@ ddxProcessArgument(int argc, char **argv, int i)
     xf86DoShowOptions = TRUE;
     return 1;
   }
+#ifdef XSERVER_LIBPCIACCESS
   if (!strcmp(argv[i], "-isolateDevice"))
   {
     CHECK_FOR_REQUIRED_ARGUMENT();
@@ -1346,6 +1348,7 @@ ddxProcessArgument(int argc, char **argv, int i)
     xf86PciIsolateDevice(argv[i]);
     return 2;
   }
+#endif
   /* Notice cmdline xkbdir, but pass to dix as well */
   if (!strcmp(argv[i], "-xkbdir"))
   {
@@ -1414,7 +1417,9 @@ ddxUseMsg(void)
 #endif
   ErrorF("-allowMouseOpenFail    start server even if the mouse can't be initialized\n");
   ErrorF("-ignoreABI             make module ABI mismatches non-fatal\n");
+#ifdef XSERVER_LIBPCIACCESS
   ErrorF("-isolateDevice bus_id  restrict device resets to bus_id (PCI only)\n");
+#endif
   ErrorF("-version               show the server version\n");
   ErrorF("-showDefaultModulePath show the server default module path\n");
   ErrorF("-showDefaultLibPath    show the server default library path\n");
diff --git a/hw/xfree86/common/xf86fbBus.c b/hw/xfree86/common/xf86fbBus.c
index 059e378..4592980 100644
--- a/hw/xfree86/common/xf86fbBus.c
+++ b/hw/xfree86/common/xf86fbBus.c
@@ -54,8 +54,10 @@ xf86ClaimFbSlot(DriverPtr drvp, int chipset, GDevPtr dev, Bool active)
     EntityPtr p;
     int num;
 
+#ifdef XSERVER_LIBPCIACCESS
     if (pciSlotClaimed)
 	return -1;
+#endif
 #if defined(__sparc__) || defined (__sparc64__)
     if (sbusSlotClaimed)
 	return -1;
diff --git a/hw/xfree86/common/xf86str.h b/hw/xfree86/common/xf86str.h
index 43e9d1d..e2ca558 100644
--- a/hw/xfree86/common/xf86str.h
+++ b/hw/xfree86/common/xf86str.h
@@ -41,9 +41,6 @@
 #include "colormapst.h"
 #include "xf86Module.h"
 #include "xf86Opt.h"
-#include "xf86Pci.h"
-
-#include <pciaccess.h>
 
 /**
  * Integer type that is of the size of the addressable memory (machine size).
@@ -309,6 +306,8 @@ typedef struct {
 struct _SymTabRec;
 struct _PciChipsets;
 
+struct pci_device;
+
 typedef struct _DriverRec {
     int			driverVersion;
     char *		driverName;
@@ -350,8 +349,6 @@ typedef enum {
     BUS_last    /* Keep last */
 } BusType;
 
-struct pci_device;
-
 typedef struct {
     int		fbNum;
 } SbusBusId;
diff --git a/hw/xfree86/os-support/bus/Makefile.am b/hw/xfree86/os-support/bus/Makefile.am
index 16c1021..e09d4d2 100644
--- a/hw/xfree86/os-support/bus/Makefile.am
+++ b/hw/xfree86/os-support/bus/Makefile.am
@@ -1,7 +1,10 @@
 noinst_LTLIBRARIES = libbus.la
 sdk_HEADERS = xf86Pci.h
 
-PCI_SOURCES = Pci.c Pci.h
+PCI_SOURCES =
+if XORG_BUS_PCI
+PCI_SOURCES += Pci.c Pci.h
+endif
 
 if XORG_BUS_BSDPCI
 PCI_SOURCES += bsd_pci.c
diff --git a/hw/xfree86/sdksyms.sh b/hw/xfree86/sdksyms.sh
index 18bb735..19795d5 100755
--- a/hw/xfree86/sdksyms.sh
+++ b/hw/xfree86/sdksyms.sh
@@ -118,14 +118,16 @@ cat > sdksyms.c << EOF
 #include "xf86.h"
 #include "xf86Module.h"
 #include "xf86Opt.h"
-#include "xf86PciInfo.h"
+#ifdef XSERVER_LIBPCIACCESS
+ #include "xf86PciInfo.h"
+ #include "xf86VGAarbiter.h"
+#endif
 #include "xf86Priv.h"
 #include "xf86Privstr.h"
 #include "xf86cmap.h"
 #include "xf86fbman.h"
 #include "xf86str.h"
 #include "xf86Xinput.h"
-#include "xf86VGAarbiter.h"
 #include "xisb.h"
 #if XV
 # include "xf86xv.h"
@@ -170,7 +172,9 @@ cat > sdksyms.c << EOF
 
 
 /* hw/xfree86/os-support/bus/Makefile.am */
-#include "xf86Pci.h"
+#ifdef XSERVER_LIBPCIACCESS
+# include "xf86Pci.h"
+#endif
 #if defined(__sparc__) || defined(__sparc)
 # include "xf86Sbus.h"
 #endif
diff --git a/include/xorg-config.h.in b/include/xorg-config.h.in
index 33bf908..6b9230f 100644
--- a/include/xorg-config.h.in
+++ b/include/xorg-config.h.in
@@ -127,4 +127,7 @@
 /* Build with libdrm support */
 #undef WITH_LIBDRM
 
+/* Use libpciaccess */
+#undef XSERVER_LIBPCIACCESS
+
 #endif /* _XORG_CONFIG_H_ */
commit 8d23deda17572c41d5239ac850810d36b88a7b70
Author: Tiago Vignatti <tiago.vignatti at nokia.com>
Date:   Mon May 31 19:27:07 2010 +0300

    configure: make PCI configuration more sane
    
    No semantical changes. Just moved code around, grouping PCI related stuff in a
    single chunk.
    
    Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
    Reviewed-by: Mikhail Gusarov <dottedmag at dottedmag.net>
    Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com>
    Built-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/configure.ac b/configure.ac
index 7efc4c6..0c0d4c5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1245,7 +1245,6 @@ if test "x$XDMAUTH" = xyes; then
 fi
 
 AC_DEFINE_DIR(COMPILEDDEFAULTFONTPATH, FONTPATH, [Default font path])
-AC_DEFINE_DIR(PCI_TXT_IDS_PATH, PCI_TXT_IDS_DIR, [Default PCI text file ID path])
 AC_DEFINE_DIR(SERVER_MISC_CONFIG_PATH, SERVERCONFIG, [Server miscellaneous config path])
 AC_DEFINE_DIR(BASE_FONT_PATH, FONTROOTDIR, [Default base font path])
 dridriverdir=`$PKG_CONFIG --variable=dridriverdir dri`
@@ -1496,9 +1495,6 @@ if test "x$XORG" = xauto; then
 fi
 AC_MSG_RESULT([$XORG])
 
-xorg_bus_bsdpci=no
-xorg_bus_sparc=no
-
 if test "x$XORG" = xyes; then
 	XORG_DDXINCS='-I$(top_srcdir)/hw/xfree86 -I$(top_srcdir)/hw/xfree86/include -I$(top_srcdir)/hw/xfree86/common'
 	XORG_OSINCS='-I$(top_srcdir)/hw/xfree86/os-support -I$(top_srcdir)/hw/xfree86/os-support/bus -I$(top_srcdir)/os'
@@ -1546,10 +1542,39 @@ if test "x$XORG" = xyes; then
 	AC_SUBST([symbol_visibility])
 	dnl ===================================================================
 
+	dnl ===================================================================
+	dnl ================= beginning of PCI configuration ==================
+	dnl ===================================================================
+	xorg_bus_linuxpci=no
+	xorg_bus_bsdpci=no
+	xorg_bus_sparc=no
+
 	PKG_CHECK_MODULES([PCIACCESS], $LIBPCIACCESS)
 	XORG_SYS_LIBS="$XORG_SYS_LIBS $PCIACCESS_LIBS $GLX_SYS_LIBS"
 	XORG_CFLAGS="$XORG_CFLAGS $PCIACCESS_CFLAGS"
 
+	AC_DEFINE(XSERVER_LIBPCIACCESS, 1, [Use libpciaccess for all pci manipulation])
+	AC_DEFINE_DIR(PCI_TXT_IDS_PATH, PCI_TXT_IDS_DIR, [Default PCI text file ID path])
+    case $host_os in
+      linux*)
+		xorg_bus_linuxpci="yes"
+		;;
+	  gnu* | freebsd* | kfreebsd*-gnu | netbsd* | openbsd* | solaris* | dragonfly*)
+		xorg_bus_bsdpci="yes"
+		;;
+	esac
+    case $host_cpu in
+      sparc*)
+        xorg_bus_sparc="yes"
+        ;;
+	esac
+	AM_CONDITIONAL([XORG_BUS_LINUXPCI], [test "x$xorg_bus_linuxpci" = xyes])
+	AM_CONDITIONAL([XORG_BUS_BSDPCI], [test "x$xorg_bus_bsdpci" = xyes])
+	AM_CONDITIONAL([XORG_BUS_SPARC], [test "x$xorg_bus_sparc" = xyes])
+	dnl ===================================================================
+	dnl ==================== end of PCI configuration =====================
+	dnl ===================================================================
+
 	case $host_os in
 	  linux*)
 		if test "x$LNXAPM" = xyes; then
@@ -1570,11 +1595,9 @@ if test "x$XORG" = xyes; then
 		;;
 	  freebsd* | kfreebsd*-gnu | dragonfly*)
 		XORG_OS_SUBDIR="bsd"
-		xorg_bus_bsdpci="yes"
 		;;
 	  netbsd*)
 		XORG_OS_SUBDIR="bsd"
-		xorg_bus_bsdpci="yes"
 		;;
 	  openbsd*)
 		if test "x$ac_cv_BSD_APM" = xyes \
@@ -1582,14 +1605,10 @@ if test "x$XORG" = xyes; then
 			XORG_CFLAGS="$XORG_CFLAGS -DXF86PM"
 		fi
 		XORG_OS_SUBDIR="bsd"
-		xorg_bus_bsdpci="yes"
 		;;
 	  solaris*)
 		XORG_OS_SUBDIR="solaris"
 		XORG_CFLAGS="$XORG_CFLAGS -DXF86PM"
-		# Use the same stubs as BSD for old functions, since we now
-		# use libpciaccess for PCI
-		xorg_bus_bsdpci="yes"
 		AC_CHECK_HEADERS([sys/kd.h])
 		AC_CHECK_HEADERS([sys/vt.h], [solaris_vt=yes], [solaris_vt=no])
 		# Check for minimum supported release
@@ -1634,9 +1653,6 @@ if test "x$XORG" = xyes; then
 		;;
 	  gnu*)
 		XORG_OS_SUBDIR="hurd"
-		# Use the same stubs as BSD for old functions, since we now
-		# use libpciaccess for PCI
-		xorg_bus_bsdpci="yes"
 		;;
 	  *)
 		XORG_OS_SUBDIR="stub"
@@ -1649,9 +1665,6 @@ if test "x$XORG" = xyes; then
 	esac
 
 	case $host_cpu in
-	  sparc*)
-		xorg_bus_sparc="yes"
-		;;
 	  i*86)
 		;;
 	esac
@@ -1708,7 +1721,6 @@ if test "x$XORG" = xyes; then
 	AC_DEFINE_DIR(DEFAULT_LIBRARY_PATH, libdir, [Default library install path])
 	AC_DEFINE_DIR(DEFAULT_LOGPREFIX, LOGPREFIX, [Default log location])
 	AC_DEFINE_UNQUOTED(__VENDORDWEBSUPPORT__, ["$VENDOR_WEB"], [Vendor web address for support])
-	AC_DEFINE(XSERVER_LIBPCIACCESS, 1, [Use libpciaccess for all pci manipulation])
 	if test "x$VGAHW" = xyes; then
 		AC_DEFINE(WITH_VGAHW, 1, [Building vgahw module])
 	fi
@@ -1738,8 +1750,6 @@ if test "x$XORG" = xyes; then
 	AC_SUBST([abi_extension])
 fi
 AM_CONDITIONAL([XORG], [test "x$XORG" = xyes])
-AM_CONDITIONAL([XORG_BUS_BSDPCI], [test "x$xorg_bus_bsdpci" = xyes])
-AM_CONDITIONAL([XORG_BUS_SPARC], [test "x$xorg_bus_sparc" = xyes])
 AM_CONDITIONAL([LINUX_ALPHA], [test "x$linux_alpha" = xyes])
 AM_CONDITIONAL([LNXACPI], [test "x$linux_acpi" = xyes])
 AM_CONDITIONAL([SOLARIS_ASM_INLINE], [test "x$solaris_asm_inline" = xyes])
commit 96990a1d6a3f011173f95b35787eb144494ba192
Author: Tiago Vignatti <tiago.vignatti at nokia.com>
Date:   Mon May 31 18:50:50 2010 +0300

    configure: change PCI function checking by a meaningful version of the library
    
    Version 0.10.7 of libpciaccess contains all functions being checked by
    autoconf, so use it instead.
    
    People that don't want VGA arbiter active can go to the library and enable the
    stubs there.
    
    Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
    Reviewed-by: Mikhail Gusarov <dottedmag at dottedmag.net>
    Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com>
    Built-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/configure.ac b/configure.ac
index d22bd4e..7efc4c6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -792,7 +792,7 @@ LIBXEXT="xext >= 1.0.99.4"
 LIBXFONT="xfont >= 1.4.2"
 LIBXI="xi >= 1.2.99.1"
 LIBXTST="xtst >= 1.0.99.2"
-LIBPCIACCESS="pciaccess >= 0.8.0"
+LIBPCIACCESS="pciaccess >= 0.10.7"
 LIBUDEV="libudev >= 143"
 LIBSELINUX="libselinux >= 2.0.86"
 LIBDBUS="dbus-1 >= 1.0"
@@ -1547,16 +1547,6 @@ if test "x$XORG" = xyes; then
 	dnl ===================================================================
 
 	PKG_CHECK_MODULES([PCIACCESS], $LIBPCIACCESS)
-	SAVE_LIBS=$LIBS
-	SAVE_CFLAGS=$CFLAGS
-	CFLAGS=$PCIACCESS_CFLAGS
-	LIBS=$PCIACCESS_LIBS
-	AC_CHECK_FUNCS([pci_system_init_dev_mem])
-	AC_CHECK_FUNCS([pci_device_enable])
-	AC_CHECK_FUNCS([pci_device_is_boot_vga])
-	AC_CHECK_FUNCS([pci_device_vgaarb_init])
-	LIBS=$SAVE_LIBS
-	CFLAGS=$SAVE_CFLAGS
 	XORG_SYS_LIBS="$XORG_SYS_LIBS $PCIACCESS_LIBS $GLX_SYS_LIBS"
 	XORG_CFLAGS="$XORG_CFLAGS $PCIACCESS_CFLAGS"
 
diff --git a/hw/xfree86/common/xf86VGAarbiter.c b/hw/xfree86/common/xf86VGAarbiter.c
index 215e845..819ad6e 100644
--- a/hw/xfree86/common/xf86VGAarbiter.c
+++ b/hw/xfree86/common/xf86VGAarbiter.c
@@ -31,8 +31,6 @@
 #include "xorg-config.h"
 
 #include "xf86VGAarbiter.h"
-
-#ifdef HAVE_PCI_DEVICE_VGAARB_INIT
 #include "xf86VGAarbiterPriv.h"
 #include "xf86Bus.h"
 #include "xf86Priv.h"
@@ -1112,16 +1110,3 @@ VGAarbiterCompositeRects(CARD8 op, PicturePtr pDst, xRenderColor *color, int nRe
     VGAPut();
     PICTURE_EPILOGUE (CompositeRects, VGAarbiterCompositeRects);
 }
-#else
-/* dummy functions */
-void xf86VGAarbiterInit(void) {}
-void xf86VGAarbiterFini(void) {}
-
-void xf86VGAarbiterLock(ScrnInfoPtr pScrn) {}
-void xf86VGAarbiterUnlock(ScrnInfoPtr pScrn) {}
-Bool xf86VGAarbiterAllowDRI(ScreenPtr pScreen) { return TRUE; }
-void xf86VGAarbiterScrnInit(ScrnInfoPtr pScrn) {}
-void xf86VGAarbiterDeviceDecodes(ScrnInfoPtr pScrn, int rsrc) {}
-Bool xf86VGAarbiterWrapFunctions(void) { return FALSE; }
-
-#endif
diff --git a/hw/xfree86/common/xf86pciBus.c b/hw/xfree86/common/xf86pciBus.c
index 2acf486..eb5323c 100644
--- a/hw/xfree86/common/xf86pciBus.c
+++ b/hw/xfree86/common/xf86pciBus.c
@@ -121,12 +121,10 @@ xf86PciProbe(void)
 	    xf86PciVideoInfo[num - 1] = info;
 
 	    pci_device_probe(info);
-#ifdef HAVE_PCI_DEVICE_IS_BOOT_VGA
 	    if (pci_device_is_boot_vga(info)) {
                 primaryBus.type = BUS_PCI;
                 primaryBus.id.pci = info;
             }
-#endif
 	    info->user_data = 0;
 	}
     }
diff --git a/hw/xfree86/os-support/bsd/i386_video.c b/hw/xfree86/os-support/bsd/i386_video.c
index 7b4cea7..d54656f 100644
--- a/hw/xfree86/os-support/bsd/i386_video.c
+++ b/hw/xfree86/os-support/bsd/i386_video.c
@@ -175,10 +175,8 @@ xf86OSInitVidMem(VidMemInfoPtr pVidMem)
 	checkDevMem(TRUE);
 	pVidMem->linearSupported = useDevMem;
 
-#if HAVE_PCI_SYSTEM_INIT_DEV_MEM
 	if (useDevMem)
 		pci_system_init_dev_mem(devMemFd);
-#endif
 
 #ifdef HAS_MTRR_SUPPORT
 	if (useDevMem) {
diff --git a/hw/xfree86/os-support/linux/int10/linux.c b/hw/xfree86/os-support/linux/int10/linux.c
index 2965b37..564447f 100644
--- a/hw/xfree86/os-support/linux/int10/linux.c
+++ b/hw/xfree86/os-support/linux/int10/linux.c
@@ -261,10 +261,7 @@ xf86ExtendedInitInt10(int entityIndex, int Flags)
 	    struct pci_device *rom_device =
 		xf86GetPciInfoForEntity(pInt->entityIndex);
 
-#if HAVE_PCI_DEVICE_ENABLE
 	    pci_device_enable(rom_device);
-#endif
-
 	    err = pci_device_read_rom(rom_device, (unsigned char *)(V_BIOS));
 	    if (err) {
 		xf86DrvMsg(screen,X_ERROR,"Cannot read V_BIOS (%s)\n",
diff --git a/include/xorg-config.h.in b/include/xorg-config.h.in
index 0d1ea91..33bf908 100644
--- a/include/xorg-config.h.in
+++ b/include/xorg-config.h.in
@@ -118,18 +118,6 @@
 /* Have execinfo.h */
 #undef HAVE_EXECINFO_H
 
-/* Have pci_system_init_dev_mem() */
-#undef HAVE_PCI_SYSTEM_INIT_DEV_MEM
-
-/* Define to 1 if you have the `pci_device_is_boot_vga' function. */
-#undef HAVE_PCI_DEVICE_IS_BOOT_VGA
-
-/* Have pci_enable_device */
-#undef HAVE_PCI_DEVICE_ENABLE
-
-/* Define to 1 if you have the `pci_device_vgaarb_init' function. */
-#undef HAVE_PCI_DEVICE_VGAARB_INIT
-
 /* Path to text files containing PCI IDs */
 #undef PCI_TXT_IDS_PATH
 
commit a14cb58c42ba8d5734a0d5f3681b9c7e1af6fd6a
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Tue Sep 13 15:32:16 2011 -0500

    xfree86: Work around issue where ar may be told to make an archive with no contents
    
    Automake:
    
     "Be careful when selecting library components conditionally. Because building
     an empty library is not portable, you should ensure that any library
     always contains at least one object."
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>
    Reviewed-by: Gaetan Nadon <memsize at videotron.ca>

diff --git a/hw/xfree86/os-support/bus/Makefile.am b/hw/xfree86/os-support/bus/Makefile.am
index b1ca8f9..16c1021 100644
--- a/hw/xfree86/os-support/bus/Makefile.am
+++ b/hw/xfree86/os-support/bus/Makefile.am
@@ -12,7 +12,7 @@ PLATFORM_SOURCES = Sbus.c
 sdk_HEADERS += xf86Sbus.h
 endif
 
-libbus_la_SOURCES = $(PCI_SOURCES) $(PLATFORM_SOURCES)
+libbus_la_SOURCES = $(PCI_SOURCES) $(PLATFORM_SOURCES) nobus.c
 
 INCLUDES = $(XORG_INCS)
 
diff --git a/hw/xfree86/os-support/bus/nobus.c b/hw/xfree86/os-support/bus/nobus.c
new file mode 100644
index 0000000..ad23f52
--- /dev/null
+++ b/hw/xfree86/os-support/bus/nobus.c
@@ -0,0 +1 @@
+static void __noop_to_appease_ar__() { return; }
commit 05eabaccae2133fd3ace5f753bd2be8bf078cf78
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Tue Sep 13 15:38:45 2011 -0500

    xfree86: Add stubs for os-support to help adding new architecture support
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>
    Reviewed-by: Jamey Sharp <jamey at minilop.net>
    Reviewed-by: Gaetan Nadon <memsize at videotron.ca>

diff --git a/configure.ac b/configure.ac
index 7232098..d22bd4e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1649,8 +1649,8 @@ if test "x$XORG" = xyes; then
 		xorg_bus_bsdpci="yes"
 		;;
 	  *)
-		XORG_OS_SUBDIR="unknown"
-		AC_MSG_ERROR([m4_text_wrap(m4_join([ ],
+		XORG_OS_SUBDIR="stub"
+		AC_MSG_NOTICE([m4_text_wrap(m4_join([ ],
 		[Your OS is unknown. Xorg currently only supports Linux,],
 		[Free/Open/Net/DragonFlyBSD, Solaris/OpenSolaris, & GNU Hurd.],
 		[If you are interested in porting Xorg to your platform,],
@@ -2151,6 +2151,7 @@ hw/xfree86/os-support/hurd/Makefile
 hw/xfree86/os-support/misc/Makefile
 hw/xfree86/os-support/linux/Makefile
 hw/xfree86/os-support/solaris/Makefile
+hw/xfree86/os-support/stub/Makefile
 hw/xfree86/parser/Makefile
 hw/xfree86/ramdac/Makefile
 hw/xfree86/shadowfb/Makefile
diff --git a/hw/xfree86/os-support/Makefile.am b/hw/xfree86/os-support/Makefile.am
index 094563d..a0140a1 100644
--- a/hw/xfree86/os-support/Makefile.am
+++ b/hw/xfree86/os-support/Makefile.am
@@ -1,5 +1,5 @@
 SUBDIRS = bus @XORG_OS_SUBDIR@ misc $(DRI_SUBDIRS)
-DIST_SUBDIRS = bsd bus misc linux solaris hurd
+DIST_SUBDIRS = bsd bus misc linux solaris stub hurd
 
 sdk_HEADERS = xf86_OSproc.h xf86_OSlib.h
 
diff --git a/hw/xfree86/os-support/stub/Makefile.am b/hw/xfree86/os-support/stub/Makefile.am
new file mode 100644
index 0000000..a1156ef
--- /dev/null
+++ b/hw/xfree86/os-support/stub/Makefile.am
@@ -0,0 +1,19 @@
+noinst_LTLIBRARIES = libstub.la
+
+AM_CFLAGS = $(XORG_CFLAGS) $(DIX_CFLAGS)
+
+INCLUDES = $(XORG_INCS)
+
+libstub_la_SOURCES = \
+	$(srcdir)/../shared/VTsw_noop.c \
+	$(srcdir)/../shared/agp_noop.c \
+	$(srcdir)/../shared/ioperm_noop.c \
+	$(srcdir)/../shared/kmod_noop.c \
+	$(srcdir)/../shared/pm_noop.c \
+	$(srcdir)/../shared/vidmem.c \
+	$(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_bell.c b/hw/xfree86/os-support/stub/stub_bell.c
new file mode 100644
index 0000000..4862592
--- /dev/null
+++ b/hw/xfree86/os-support/stub/stub_bell.c
@@ -0,0 +1,10 @@
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86_OSlib.h"
+
+void
+xf86OSRingBell(int loudness, int pitch, int duration)
+{
+}
diff --git a/hw/xfree86/os-support/stub/stub_bios.c b/hw/xfree86/os-support/stub/stub_bios.c
new file mode 100644
index 0000000..8628316
--- /dev/null
+++ b/hw/xfree86/os-support/stub/stub_bios.c
@@ -0,0 +1,12 @@
+#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/stub/stub_init.c b/hw/xfree86/os-support/stub/stub_init.c
new file mode 100644
index 0000000..36fd2b8
--- /dev/null
+++ b/hw/xfree86/os-support/stub/stub_init.c
@@ -0,0 +1,26 @@
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86_OSlib.h"
+
+void
+xf86OpenConsole()
+{
+}
+
+void
+xf86CloseConsole()
+{
+}
+
+int
+xf86ProcessArgument(int argc, char *argv[], int i)
+{
+	return 0;
+}
+
+void
+xf86UseMsg()
+{
+}
diff --git a/hw/xfree86/os-support/stub/stub_video.c b/hw/xfree86/os-support/stub/stub_video.c
new file mode 100644
index 0000000..3274968
--- /dev/null
+++ b/hw/xfree86/os-support/stub/stub_video.c
@@ -0,0 +1,13 @@
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86_OSlib.h"
+#include "xf86OSpriv.h"
+
+void
+xf86OSInitVidMem(VidMemInfoPtr pVidMem)
+{
+	pVidMem->initialised = TRUE;
+	return;
+}
commit ecd342b6357ac67daa6fa4bd6043f605021100db
Author: Adam Jackson <ajax at redhat.com>
Date:   Tue May 10 19:26:13 2011 -0400

    incomplete: Remove xf86{Un,}MapVidMem
    
    And man does a lot of support code just fall away when you do that.
    
    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 bb3a5cb..860bbd4 100644
--- a/hw/xfree86/os-support/bsd/alpha_video.c
+++ b/hw/xfree86/os-support/bsd/alpha_video.c
@@ -67,32 +67,6 @@ static unsigned long hae_mask;
 static unsigned long bus_base;
 static unsigned long sparse_size;
 
-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)
 {
@@ -156,30 +130,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                                            */
@@ -199,11 +152,6 @@ static int  devMemFd = -1;
 #endif
 #define DEV_MEM "/dev/mem"
 
-static pointer mapVidMem(int, unsigned long, unsigned long, int);
-static void unmapVidMem(int, pointer, unsigned long);
-static pointer mapVidMemSparse(int, unsigned long, unsigned long, int);
-static void unmapVidMemSparse(int, pointer, unsigned long);
-
 /*
  * Check if /dev/mem can be mmap'd.  If it can't print a warning when
  * "warn" is TRUE.
@@ -286,12 +234,8 @@ 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(); 
@@ -303,59 +247,6 @@ xf86OSInitVidMem(VidMemInfoPtr pVidMem)
 	pVidMem->initialised = TRUE;
 }
 
-static pointer
-mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
-{
-	pointer 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.screenFd,
-		    (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, pointer Base, unsigned long Size)
-{
-	munmap((caddr_t)Base, Size);
-}
-
 /*
  * Read BIOS via mmap()ing DEV_MEM
  */
@@ -502,48 +393,6 @@ sethae(u_int64_t hae)
 }
 #endif /* __NetBSD__ */
 
-static pointer
-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 (pointer)((unsigned long)memBase + Base);
-}
-
-static void
-unmapVidMemSparse(int ScreenNum, pointer Base, unsigned long Size)
-{
-}
-
 static int
 readSparse8(pointer Base, register unsigned long Offset)
 {
diff --git a/hw/xfree86/os-support/bsd/arm_video.c b/hw/xfree86/os-support/bsd/arm_video.c
index 482d53f..4d43ba2 100644
--- a/hw/xfree86/os-support/bsd/arm_video.c
+++ b/hw/xfree86/os-support/bsd/arm_video.c
@@ -115,9 +115,6 @@ static int  devMemFd = -1;
 
 #define DEV_MEM "/dev/mem"
 
-static pointer mapVidMem(int, unsigned long, unsigned long, int);
-static void unmapVidMem(int, pointer, unsigned long);
-
 /*
  * Check if /dev/mem can be mmap'd.  If it can't print a warning when
  * "warn" is TRUE.
@@ -171,64 +168,9 @@ xf86OSInitVidMem(VidMemInfoPtr pVidMem)
 
 	checkDevMem(TRUE);
 	pVidMem->linearSupported = useDevMem;
-	pVidMem->mapMem = armMapVidMem;
-	pVidMem->unmapVidMem = armUnmapVidMem;
-
 	pVidMem->initialised = TRUE;
 }
 
-static pointer
-mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
-{
-	pointer 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.screenFd,
-		    (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, pointer Base, unsigned long Size)
-{
-	munmap((caddr_t)Base, Size);
-}
-
 /*
  * Read BIOS via mmap()ing DEV_MEM
  */
@@ -403,50 +345,6 @@ xf86MapInfoUnmap(struct memAccess *memInfoP, unsigned long Size)
     }
 }
 
-static pointer
-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, pointer 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 7aef079..7b4cea7 100644
--- a/hw/xfree86/os-support/bsd/i386_video.c
+++ b/hw/xfree86/os-support/bsd/i386_video.c
@@ -44,17 +44,6 @@
 #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"
 
@@ -90,20 +79,6 @@ static int  devMemFd = -1;
 #endif
 #define DEV_MEM "/dev/mem"
 
-static pointer mapVidMem(int, unsigned long, unsigned long, int);
-static void unmapVidMem(int, pointer, unsigned long);
-
-#ifdef HAS_MTRR_SUPPORT
-static pointer setWC(int, unsigned long, unsigned long, Bool, MessageType);
-static void undoWC(int, pointer);
-static Bool cleanMTRR(void);
-#endif
-#if defined(HAS_MTRR_BUILTIN) && defined(__NetBSD__)
-static pointer NetBSDsetWC(int, unsigned long, unsigned long, Bool,
-			   MessageType);
-static void NetBSDundoWC(int, pointer);
-#endif
-
 /*
  * Check if /dev/mem can be mmap'd.  If it can't print a warning when
  * "warn" is TRUE.
@@ -199,8 +174,6 @@ xf86OSInitVidMem(VidMemInfoPtr pVidMem)
 {
 	checkDevMem(TRUE);
 	pVidMem->linearSupported = useDevMem;
-	pVidMem->mapMem = mapVidMem;
-	pVidMem->unmapMem = unmapVidMem;
 
 #if HAVE_PCI_SYSTEM_INIT_DEV_MEM
 	if (useDevMem)
@@ -210,71 +183,12 @@ xf86OSInitVidMem(VidMemInfoPtr pVidMem)
 #ifdef HAS_MTRR_SUPPORT
 	if (useDevMem) {
 		if (cleanMTRR()) {
-			pVidMem->setWC = setWC;
-			pVidMem->undoWC = undoWC;
 		}
 	}
 #endif
-#if defined(HAS_MTRR_BUILTIN) && defined(__NetBSD__)
-	pVidMem->setWC = NetBSDsetWC;
-	pVidMem->undoWC = NetBSDundoWC;
-#endif
 	pVidMem->initialised = TRUE;
 }
 
-static pointer
-mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
-{
-	pointer 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.screenFd,
-		    (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, pointer Base, unsigned long Size)
-{
-	munmap((caddr_t)Base, Size);
-}
-
 /*
  * Read BIOS via mmap()ing DEV_MEM
  */
@@ -580,329 +494,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 pointer
-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 pointer
-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 pointer
-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, pointer 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 pointer
-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, pointer 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/bsd/ppc_video.c b/hw/xfree86/os-support/bsd/ppc_video.c
index 7e3fcdb..3000187 100644
--- a/hw/xfree86/os-support/bsd/ppc_video.c
+++ b/hw/xfree86/os-support/bsd/ppc_video.c
@@ -51,9 +51,6 @@
 #define DEV_MEM "/dev/xf86"
 #endif
 
-static pointer ppcMapVidMem(int, unsigned long, unsigned long, int flags);
-static void ppcUnmapVidMem(int, pointer, unsigned long);
-
 Bool xf86EnableIO(void);
 void xf86DisableIO(void);
 
@@ -61,42 +58,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 pointer
-ppcMapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
-{
-	int fd = xf86Info.screenFd;
-	pointer 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
-ppcUnmapVidMem(int ScreenNum, pointer 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 c838792..e61ad13 100644
--- a/hw/xfree86/os-support/bsd/sparc64_video.c
+++ b/hw/xfree86/os-support/bsd/sparc64_video.c
@@ -42,50 +42,16 @@
 /* Video Memory Mapping section                                            */
 /***************************************************************************/
 
-static pointer sparc64MapVidMem(int, unsigned long, unsigned long, int);
-static void sparc64UnmapVidMem(int, pointer, unsigned long);
-
 void
 xf86OSInitVidMem(VidMemInfoPtr pVidMem)
 {
 	pVidMem->linearSupported = TRUE;
-	pVidMem->mapMem = sparc64MapVidMem;
-	pVidMem->unmapMem = sparc64UnmapVidMem;
 	pVidMem->initialised = TRUE;
 }
 
-static pointer
-sparc64MapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, 
-		 int flags)
-{
-	int fd = xf86Info.screenFd;
-	pointer 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, pointer Base, unsigned long Size)
-{
-	munmap(Base, Size);
-}
-
 int
 xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
 	     int Len)
 {
-
 	return 0;
 }
diff --git a/hw/xfree86/os-support/hurd/hurd_video.c b/hw/xfree86/os-support/hurd/hurd_video.c
index 39f353b..db280b5 100644
--- a/hw/xfree86/os-support/hurd/hurd_video.c
+++ b/hw/xfree86/os-support/hurd/hurd_video.c
@@ -39,75 +39,6 @@
 #include "xf86OSpriv.h"
 
 /**************************************************************************
- * Video Memory Mapping section                                            
- ***************************************************************************/
-static pointer
-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 (pointer)addr;
-}
-
-static void
-unmapVidMem(int ScreenNum,pointer 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                                                 
  ***************************************************************************/
 
@@ -149,7 +80,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 3d45511..18116bd 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
-
 #ifndef MAP_FAILED
 #define MAP_FAILED ((void *)-1)
 #endif
@@ -83,16 +79,12 @@ extern int iopl(int __level);
 /* Video Memory Mapping section                                            */
 /***************************************************************************/
 
-static pointer mapVidMem(int, unsigned long, unsigned long, int);
-static void unmapVidMem(int, pointer, 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 pointer mapVidMemSparse(int, unsigned long, unsigned long, int);
 extern axpDevice lnxGetAXP(void);
-static void unmapVidMemSparse(int, pointer, unsigned long);
 static axpDevice axpSystem = -1;
 static Bool needSparse;
 static unsigned long hae_thresh;
@@ -100,269 +92,6 @@ static unsigned long hae_mask;
 static unsigned long bus_base;
 #endif
 
-#ifdef HAS_MTRR_SUPPORT
-
-#define SPLIT_WC_REGIONS 1
-
-static pointer setWC(int, unsigned long, unsigned long, Bool, MessageType);
-static void undoWC(int, pointer);
-
-/* 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",
-				       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 pointer
-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, pointer regioninfo)
-{
-	mtrr_undo_wc_region(screenNum, regioninfo);
-}
-
-#endif /* HAS_MTRR_SUPPORT */
-
 void
 xf86OSInitVidMem(VidMemInfoPtr pVidMem)
 {
@@ -378,105 +107,14 @@ 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
-	pVidMem->setWC = setWC;
-	pVidMem->undoWC = undoWC;
-#endif
 	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 pointer mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
-{
-	return NULL;
-}
-#else
-static pointer
-mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
-{
-    pointer 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, pointer Base, unsigned long Size)
-{
-    memType alignOff = (memType)Base 
-	- ((memType)Base & ~(getpagesize() - 1));
-
-    DebugF("alignment offset: %lx\n",alignOff);
-    munmap((caddr_t)((memType)Base - alignOff), (Size + alignOff));
-}
-
-
 /***************************************************************************/
 /* I/O Permissions section                                                 */
 /***************************************************************************/
@@ -599,115 +237,6 @@ writeSparse32(int Value, pointer Base, register unsigned long Offset);
 
 static unsigned long msb_set = 0;
 
-static pointer
-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 (pointer) ret;
-}
-
-static void
-unmapVidMemSparse(int ScreenNum, pointer 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(pointer Base, register unsigned long Offset)
 {
diff --git a/hw/xfree86/os-support/shared/vidmem.c b/hw/xfree86/os-support/shared/vidmem.c
index 54f6c64..146ce8b 100644
--- a/hw/xfree86/os-support/shared/vidmem.c
+++ b/hw/xfree86/os-support/shared/vidmem.c
@@ -25,7 +25,6 @@
  * authorization from the copyright holder(s) and author(s).
  */
 
-
 #ifdef HAVE_XORG_CONFIG_H
 #include <xorg-config.h>
 #endif
@@ -43,133 +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 {
-	unsigned long 	size;
-	pointer		virtBase;
-	pointer 	mtrrInfo;
-} MappingRec, *MappingPtr;
-	
-typedef struct {
-	int		numMappings;
-	MappingPtr *	mappings;
-	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  = {0, NULL, 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;
-}
-
-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, pointer 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
-removeMapping(VidMapPtr vp, MappingPtr mp)
-{
-	int i, found = 0;
-
-	for (i = 0; i < vp->numMappings; i++) {
-		if (vp->mappings[i] == mp) {
-			found = 1;
-			free(vp->mappings[i]);
-		} else if (found) {
-			vp->mappings[i - 1] = vp->mappings[i];
-		}
-	}
-	vp->numMappings--;
-	vp->mappings[vp->numMappings] = NULL;
-}
-
-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
-xf86MakeNewMapping(int ScreenNum, int Flags, unsigned long Base, unsigned long Size, pointer Vbase)
-{
-	VidMapPtr vp;
-	MappingPtr mp;
-
-	vp = getVidMapRec(ScreenNum);
-	mp = newMapping(vp);
-	mp->size = Size;
-	mp->virtBase = Vbase;
-}
 
 void
 xf86InitVidMem(void)
@@ -180,111 +53,9 @@ xf86InitVidMem(void)
 	}
 }
 
-pointer
-xf86MapVidMem(int ScreenNum, int Flags, unsigned long Base, unsigned long Size)
-{
-	pointer vbase = NULL;
-	VidMapPtr vp;
-	MappingPtr mp;
-
-	if (((Flags & VIDMEM_FRAMEBUFFER) &&
-	     (Flags & (VIDMEM_MMIO | VIDMEM_MMIO_32BIT))))
-	    FatalError("Mapping memory with more than one type\n");
-	    
-	xf86InitVidMem();
-	if (!vidMemInfo.initialised || !vidMemInfo.mapMem)
-		return NULL;
-
-	vbase = vidMemInfo.mapMem(ScreenNum, Base, Size, Flags);
-
-	if (!vbase || vbase == (pointer)-1)
-		return NULL;
-
-	vp = getVidMapRec(ScreenNum);
-	mp = newMapping(vp);
-	mp->size = Size;
-	mp->virtBase = vbase;
-
-	/*
-	 * Check the "mtrr" option even when MTRR isn't supported to avoid
-	 * warnings about unrecognised options.
-	 */
-	checkMtrrOption(vp);
-
-	if (vp->mtrrEnabled && vidMemInfo.setWC) {
-		if (Flags & (VIDMEM_MMIO | VIDMEM_MMIO_32BIT))
-			mp->mtrrInfo =
-				vidMemInfo.setWC(ScreenNum, Base, Size, FALSE,
-						 vp->mtrrFrom);
-		else if (Flags & VIDMEM_FRAMEBUFFER)
-			mp->mtrrInfo =
-				vidMemInfo.setWC(ScreenNum, Base, Size, TRUE,
-						 vp->mtrrFrom);
-	}
-	return vbase;
-}
-
-void
-xf86UnMapVidMem(int ScreenNum, pointer Base, unsigned long Size)
-{
-	VidMapPtr vp;
-	MappingPtr mp;
-
-	if (!vidMemInfo.initialised || !vidMemInfo.unmapMem) {
-		xf86DrvMsg(ScreenNum, X_WARNING,
-		  "xf86UnMapVidMem() called before xf86MapVidMem()\n");
-		return;
-	}
-
-	vp = getVidMapRec(ScreenNum);
-	mp = findMapping(vp, Base, Size);
-	if (!mp) {
-		xf86DrvMsg(ScreenNum, X_WARNING,
-		  "xf86UnMapVidMem: cannot find region for [%p,0x%lx]\n",
-		  Base, Size);
-		return;
-	}
-	if (vp->mtrrEnabled && vidMemInfo.undoWC && mp)
-		vidMemInfo.undoWC(ScreenNum, mp->mtrrInfo);
-
-	vidMemInfo.unmapMem(ScreenNum, Base, Size);
-	removeMapping(vp, mp);
-}
-
-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 && vidMemInfo.setWC)
-		return TRUE;
-		
-	return FALSE;
-}
-
 Bool
 xf86LinearVidMem(void)
 {
 	xf86InitVidMem();
 	return vidMemInfo.linearSupported;
 }
-
-void
-xf86MapReadSideEffects(int ScreenNum, int Flags, pointer base,
-			unsigned long Size)
-{
-	if (!(Flags & VIDMEM_READSIDEEFFECT))
-		return;
-
-	if (!vidMemInfo.initialised || !vidMemInfo.readSideEffects)
-		return;
-
-	vidMemInfo.readSideEffects(ScreenNum, base, Size);
-}
-
diff --git a/hw/xfree86/os-support/xf86OSpriv.h b/hw/xfree86/os-support/xf86OSpriv.h
index 754128d..cb85602 100644
--- a/hw/xfree86/os-support/xf86OSpriv.h
+++ b/hw/xfree86/os-support/xf86OSpriv.h
@@ -32,22 +32,8 @@
 #ifndef _XF86OSPRIV_H
 #define _XF86OSPRIV_H
 
-typedef pointer (*MapMemProcPtr)(int, unsigned long, unsigned long, int);
-typedef void (*UnmapMemProcPtr)(int, pointer, unsigned long);
-typedef pointer (*SetWCProcPtr)(int, unsigned long, unsigned long, Bool,
-				MessageType);
-typedef void (*ProtectMemProcPtr)(int, pointer, unsigned long, Bool); 
-typedef void (*UndoWCProcPtr)(int, pointer);
-typedef void (*ReadSideEffectsProcPtr)(int, pointer, unsigned long);
-
 typedef struct {
 	Bool			initialised;
-	MapMemProcPtr		mapMem;
-	UnmapMemProcPtr		unmapMem;
-	ProtectMemProcPtr	protectMem;
-	SetWCProcPtr		setWC;
-	UndoWCProcPtr		undoWC;
-	ReadSideEffectsProcPtr	readSideEffects;
 	Bool			linearSupported;
 } VidMemInfo, *VidMemInfoPtr;
 
diff --git a/hw/xfree86/os-support/xf86_OSproc.h b/hw/xfree86/os-support/xf86_OSproc.h
index f0cb768..66f09d0 100644
--- a/hw/xfree86/os-support/xf86_OSproc.h
+++ b/hw/xfree86/os-support/xf86_OSproc.h
@@ -75,24 +75,6 @@
  */ 
 
 /*
- * Flags for xf86MapVidMem().  Multiple flags can be or'd together.  The
- * flags may be used as hints.  For example it would be permissible to
- * enable write combining for memory marked only for framebuffer use.
- */
-
-#define VIDMEM_FRAMEBUFFER	0x01	/* memory for framebuffer use */
-#define VIDMEM_MMIO		0x02	/* memory for I/O use */
-#define VIDMEM_MMIO_32BIT	0x04	/* memory accesses >= 32bit */
-#define VIDMEM_READSIDEEFFECT	0x08	/* reads can have side-effects */
-#define VIDMEM_SPARSE		0x10	/* sparse mapping required
-					 * assumed when VIDMEM_MMIO is
-					 * set. May be used with
-					 * VIDMEM_FRAMEBUFFER) */
-#define VIDMEM_READONLY		0x20	/* read-only mapping
-					 * used when reading BIOS images
-					 * through xf86MapVidMem() */
-
-/*
  * OS-independent modem state flags for xf86SetSerialModemState() and
  * xf86GetSerialModemState().
  */
@@ -131,10 +113,6 @@ _XFUNCPROTOBEGIN
 
 /* public functions */
 extern _X_EXPORT Bool xf86LinearVidMem(void);
-extern _X_EXPORT Bool xf86CheckMTRR(int);
-extern _X_EXPORT pointer xf86MapVidMem(int, int, unsigned long, unsigned long);
-extern _X_EXPORT void xf86UnMapVidMem(int, pointer, unsigned long);
-extern _X_EXPORT void xf86MapReadSideEffects(int, int, pointer, unsigned long);
 extern _X_EXPORT int xf86ReadBIOS(unsigned long, unsigned long, unsigned char *, int);
 extern _X_EXPORT Bool xf86EnableIO(void);
 extern _X_EXPORT void xf86DisableIO(void);
@@ -208,7 +186,6 @@ extern _X_EXPORT int xf86ProcessArgument(int, char **, int);
 extern _X_EXPORT void xf86UseMsg(void);
 extern _X_EXPORT PMClose xf86OSPMOpen(void);
 
-extern _X_EXPORT void xf86MakeNewMapping(int, int, unsigned long, unsigned long, pointer);
 extern _X_EXPORT void xf86InitVidMem(void);
 
 #endif /* XF86_OS_PRIVS */
commit 8e1338cedc9ffdc4eacb5c19c4da10c12a76e9c0
Author: Adam Jackson <ajax at redhat.com>
Date:   Tue May 10 19:00:02 2011 -0400

    int10: Port internal users off xf86MapVidMem
    
    This API is apparently semi-deprecated even by XFree86 standards, and
    there are only four drivers left using it.  Let's start chopping it off.
    
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/hw/xfree86/int10/generic.c b/hw/xfree86/int10/generic.c
index 20a07fc..22ebd47 100644
--- a/hw/xfree86/int10/generic.c
+++ b/hw/xfree86/int10/generic.c
@@ -103,8 +103,8 @@ xf86ExtendedInitInt10(int entityIndex, int Flags)
     MapVRam(pInt);
 #ifdef _PC
     if (!sysMem)
-	sysMem = xf86MapVidMem(screen, VIDMEM_MMIO, V_BIOS,
-			       BIOS_SIZE + SYS_BIOS - V_BIOS);
+	pci_device_map_legacy(pInt->dev, V_BIOS, BIOS_SIZE + SYS_BIOS - V_BIOS,
+			      1, &sysMem);
     INTPriv(pInt)->sysMem = sysMem;
 
     if (xf86ReadBIOS(0, 0, base, LOW_PAGE_SIZE) < 0) {
diff --git a/hw/xfree86/int10/helper_exec.c b/hw/xfree86/int10/helper_exec.c
index 034d0f1..70e97a3 100644
--- a/hw/xfree86/int10/helper_exec.c
+++ b/hw/xfree86/int10/helper_exec.c
@@ -680,10 +680,12 @@ static void
 SetResetBIOSVars(xf86Int10InfoPtr pInt, Bool set)
 {
     int pagesize = getpagesize();
-    unsigned char* base = xf86MapVidMem(pInt->scrnIndex,
-					VIDMEM_MMIO, 0, pagesize);
+    unsigned char* base;
     int i;
 
+    if (pci_device_map_legacy(pInt->dev, 0, pagesize, 1, (void **)&base))
+	return; /* eek */
+
     if (set) {
 	for (i = BIOS_SCRATCH_OFF; i < BIOS_SCRATCH_END; i++)
 	    MEM_WW(pInt, i, *(base + i));
@@ -692,7 +694,7 @@ SetResetBIOSVars(xf86Int10InfoPtr pInt, Bool set)
 	    *(base + i) = MEM_RW(pInt, i);
     }
     
-    xf86UnMapVidMem(pInt->scrnIndex,base,pagesize);
+    pci_device_unmap_legacy(pInt->dev, base, pagesize);
 }
 
 void
@@ -706,7 +708,9 @@ xf86Int10SaveRestoreBIOSVars(xf86Int10InfoPtr pInt, Bool save)
 	|| (!save && !pInt->BIOSScratch))
 	return;
     
-    base = xf86MapVidMem(pInt->scrnIndex, VIDMEM_MMIO, 0, pagesize);
+    if (pci_device_map_legacy(pInt->dev, 0, pagesize, 1, (void **)&base))
+	return; /* eek */
+
     base += BIOS_SCRATCH_OFF;
     if (save) {
 	if ((pInt->BIOSScratch
@@ -722,7 +726,7 @@ xf86Int10SaveRestoreBIOSVars(xf86Int10InfoPtr pInt, Bool save)
 	}
     }
     
-    xf86UnMapVidMem(pInt->scrnIndex,base - BIOS_SCRATCH_OFF ,pagesize);
+    pci_device_unmap_legacy(pInt->dev, base, pagesize);
 }
 #endif
 
commit 3de307154c89d0ce0ead64758274ec662889721a
Author: Adam Jackson <ajax at redhat.com>
Date:   Tue May 10 17:34:23 2011 -0400

    pci: Remove xf86MapDomainMemory
    
    This is slightly draconian, but that API is just awful.  In all but
    one case in the callers it's used to get a map of some legacy VGA
    memory, and it would be cleaner for the caller to just call
    pci_device_map_legacy.
    
    The sole exception is in the vesa driver, which uses it to avoid having
    to look up which device the BAR belongs to.  That's similarly trivial to
    fix.
    
    Having done that, Linux's PCI layer is now very small indeed.
    
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/configure.ac b/configure.ac
index d51860d..7232098 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1496,7 +1496,6 @@ if test "x$XORG" = xauto; then
 fi
 AC_MSG_RESULT([$XORG])
 
-xorg_bus_linuxpci=no
 xorg_bus_bsdpci=no
 xorg_bus_sparc=no
 
@@ -1567,7 +1566,6 @@ if test "x$XORG" = xyes; then
 			XORG_CFLAGS="$XORG_CFLAGS -DXF86PM"
 		fi
 		XORG_OS_SUBDIR="linux"
-		xorg_bus_linuxpci="yes"
 		linux_acpi="no"
 		case $host_cpu in
 		  alpha*)
@@ -1750,7 +1748,6 @@ if test "x$XORG" = xyes; then
 	AC_SUBST([abi_extension])
 fi
 AM_CONDITIONAL([XORG], [test "x$XORG" = xyes])
-AM_CONDITIONAL([XORG_BUS_LINUXPCI], [test "x$xorg_bus_linuxpci" = xyes])
 AM_CONDITIONAL([XORG_BUS_BSDPCI], [test "x$xorg_bus_bsdpci" = xyes])
 AM_CONDITIONAL([XORG_BUS_SPARC], [test "x$xorg_bus_sparc" = xyes])
 AM_CONDITIONAL([LINUX_ALPHA], [test "x$linux_alpha" = xyes])
diff --git a/hw/xfree86/int10/generic.c b/hw/xfree86/int10/generic.c
index 040d999..20a07fc 100644
--- a/hw/xfree86/int10/generic.c
+++ b/hw/xfree86/int10/generic.c
@@ -238,9 +238,7 @@ MapVRam(xf86Int10InfoPtr pInt)
     int pagesize = getpagesize();
     int size = ((VRAM_SIZE + pagesize - 1) / pagesize) * pagesize;
 
-    INTPriv(pInt)->vRam = xf86MapDomainMemory(pInt->scrnIndex, VIDMEM_MMIO,
-					      pInt->dev, V_RAM, size);
-
+    pci_device_map_legacy(pInt->dev, V_RAM, size, 1, &(INTPriv(pInt)->vRam));
     pInt->io = pci_legacy_open_io(pInt->dev, 0, 64 * 1024);
 }
 
@@ -251,8 +249,7 @@ UnmapVRam(xf86Int10InfoPtr pInt)
     int pagesize = getpagesize();
     int size = ((VRAM_SIZE + pagesize - 1)/pagesize) * pagesize;
 
-    xf86UnMapVidMem(screen, INTPriv(pInt)->vRam, size);
-
+    pci_device_unmap_legacy(pInt->dev, INTPriv(pInt)->vRam, size);
     pci_device_close_io(pInt->dev, pInt->io);
     pInt->io = NULL;
 }
diff --git a/hw/xfree86/os-support/bus/Makefile.am b/hw/xfree86/os-support/bus/Makefile.am
index 643cb25..b1ca8f9 100644
--- a/hw/xfree86/os-support/bus/Makefile.am
+++ b/hw/xfree86/os-support/bus/Makefile.am
@@ -3,10 +3,6 @@ sdk_HEADERS = xf86Pci.h
 
 PCI_SOURCES = Pci.c Pci.h
 
-if XORG_BUS_LINUXPCI
-PCI_SOURCES += linuxPci.c
-endif
-
 if XORG_BUS_BSDPCI
 PCI_SOURCES += bsd_pci.c
 endif
diff --git a/hw/xfree86/os-support/bus/bsd_pci.c b/hw/xfree86/os-support/bus/bsd_pci.c
index f51d5c0..7a5dbbb 100644
--- a/hw/xfree86/os-support/bus/bsd_pci.c
+++ b/hw/xfree86/os-support/bus/bsd_pci.c
@@ -48,13 +48,6 @@
 
 #include "pciaccess.h"
 
-pointer
-xf86MapDomainMemory(int ScreenNum, int Flags, struct pci_device *dev,
-		    ADDRESS Base, unsigned long Size)
-{
-    return xf86MapVidMem(ScreenNum, Flags, Base, Size);
-}
-
 void
 osPciInit(void)
 {
diff --git a/hw/xfree86/os-support/bus/linuxPci.c b/hw/xfree86/os-support/bus/linuxPci.c
deleted file mode 100644
index 8f314b5..0000000
--- a/hw/xfree86/os-support/bus/linuxPci.c
+++ /dev/null
@@ -1,256 +0,0 @@
-/*
- * Copyright 1998 by Concurrent Computer Corporation
- *
- * 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 Concurrent Computer
- * Corporation not be used in advertising or publicity pertaining to
- * distribution of the software without specific, written prior
- * permission.  Concurrent Computer Corporation makes no representations
- * about the suitability of this software for any purpose.  It is
- * provided "as is" without express or implied warranty.
- *
- * CONCURRENT COMPUTER CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD
- * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS, IN NO EVENT SHALL CONCURRENT COMPUTER CORPORATION 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.
- *
- * Copyright 1998 by Metro Link Incorporated
- *
- * 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 Metro Link
- * Incorporated not be used in advertising or publicity pertaining to
- * distribution of the software without specific, written prior
- * permission.  Metro Link Incorporated makes no representations
- * about the suitability of this software for any purpose.  It is
- * provided "as is" without express or implied warranty.
- *
- * METRO LINK INCORPORATED DISCLAIMS ALL WARRANTIES WITH REGARD
- * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS, IN NO EVENT SHALL METRO LINK INCORPORATED 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 <stdio.h>
-#include "xf86_OSlib.h"
-#include "Pci.h"
-
-/**
- * \bug
- * The generation of the procfs file name for the domain != 0 case may not be 
- * correct.
- */
-static int
-linuxPciOpenFile(struct pci_device *dev, Bool write)
-{
-    static struct pci_device *last_dev = NULL;
-    static int	fd = -1,is_write = 0;
-    char		file[64];
-
-    if (dev == NULL) {
-	return -1;
-    }
-
-    if (fd == -1 || (write && (!is_write)) || (last_dev != dev)) {
-	if (fd != -1) {
-	    close(fd);
-	    fd = -1;
-	}
-
-	sprintf(file,"/sys/bus/pci/devices/%04u:%02x:%02x.%01x/config",
-		dev->domain, dev->bus, dev->dev, dev->func);
-
-	if (write) {
-	    fd = open(file,O_RDWR);
-	    if (fd != -1) is_write = TRUE;
-	} else {
-	    switch (is_write) {
-	    case TRUE:
-		fd = open(file,O_RDWR);
-		if (fd > -1)
-		    break;
-	    default:
-		fd = open(file,O_RDONLY);
-		is_write = FALSE;
-	    }
-	}
-
-	last_dev = dev;
-    }
-
-    return fd;
-}
-
-/*
- * Compiling the following simply requires the presence of <linux/pci.c>.
- * Actually running this is another matter altogether...
- *
- * This scheme requires that the kernel allow mmap()'ing of a host bridge's I/O
- * and memory spaces through its /proc/bus/pci/BUS/DFN entry.  Which one is
- * determined by a prior ioctl().
- *
- * For the sparc64 port, this means 2.4.12 or later.  For ppc, this
- * functionality is almost, but not quite there yet.  Alpha and other kernel
- * ports to multi-domain architectures still need to implement this.
- *
- * TO DO:  Address the deleterious reaction some host bridges have to master
- *         aborts.  This is already done for secondary PCI buses, but not yet
- *         for accesses to primary buses (except for the SPARC port, where
- *         master aborts are avoided during PCI scans).
- */
-
-#include <linux/pci.h>
-
-#ifndef PCIIOC_BASE		/* Ioctls for /proc/bus/pci/X/Y nodes. */
-#define PCIIOC_BASE		('P' << 24 | 'C' << 16 | 'I' << 8)
-
-/* Get controller for PCI device. */
-#define PCIIOC_CONTROLLER	(PCIIOC_BASE | 0x00)
-/* Set mmap state to I/O space. */
-#define PCIIOC_MMAP_IS_IO	(PCIIOC_BASE | 0x01)
-/* Set mmap state to MEM space. */
-#define PCIIOC_MMAP_IS_MEM	(PCIIOC_BASE | 0x02)
-/* Enable/disable write-combining. */
-#define PCIIOC_WRITE_COMBINE	(PCIIOC_BASE | 0x03)
-
-#endif
-
-static pointer
-linuxMapPci(int ScreenNum, int Flags, struct pci_device *dev,
-	    ADDRESS Base, unsigned long Size, int mmap_ioctl)
-{
-    /* Align to page boundary */
-    const ADDRESS realBase = Base & ~(getpagesize() - 1);
-    const ADDRESS Offset = Base - realBase;
-
-    do {
-	unsigned char *result;
-	int fd, mmapflags, prot;
-
-	xf86InitVidMem();
-
-	/* If dev is NULL, linuxPciOpenFile will return -1, and this routine
-	 * will fail gracefully.
-	 */
-        prot = ((Flags & VIDMEM_READONLY) == 0);
-        if (((fd = linuxPciOpenFile(dev, prot)) < 0) ||
-	    (ioctl(fd, mmap_ioctl, 0) < 0))
-	    break;
-
-/* Note:  IA-64 doesn't compile this and doesn't need to */
-#ifdef __ia64__
-
-# ifndef  MAP_WRITECOMBINED
-#  define MAP_WRITECOMBINED 0x00010000
-# endif
-# ifndef  MAP_NONCACHED
-#  define MAP_NONCACHED     0x00020000
-# endif
-
-	if (Flags & VIDMEM_FRAMEBUFFER)
-	    mmapflags = MAP_SHARED | MAP_WRITECOMBINED;
-	else
-	    mmapflags = MAP_SHARED | MAP_NONCACHED;
-
-#else /* !__ia64__ */
-
-	mmapflags = (Flags & VIDMEM_FRAMEBUFFER) / VIDMEM_FRAMEBUFFER;
-
-	if (ioctl(fd, PCIIOC_WRITE_COMBINE, mmapflags) < 0)
-	    break;
-
-	mmapflags = MAP_SHARED;
-
-#endif /* ?__ia64__ */
-
-
-	if (Flags & VIDMEM_READONLY)
-	    prot = PROT_READ;
-	else
-	    prot = PROT_READ | PROT_WRITE;
-
-	result = mmap(NULL, Size + Offset, prot, mmapflags, fd, realBase);
-
-	if (!result || ((pointer)result == MAP_FAILED))
-	    return NULL;
-
-	xf86MakeNewMapping(ScreenNum, Flags, realBase, Size + Offset, result);
-
-	return result + Offset;
-    } while (0);
-
-    if (mmap_ioctl == PCIIOC_MMAP_IS_MEM)
-	return xf86MapVidMem(ScreenNum, Flags, Base, Size);
-
-    return NULL;
-}
-
-static int
-linuxOpenLegacy(struct pci_device *dev, char *name)
-{
-    static const char PREFIX[] = "/sys/class/pci_bus/%04x:%02x/%s";
-    char path[sizeof(PREFIX) + 10];
-    int fd = -1;
-
-    while (dev != NULL) {
-	snprintf(path, sizeof(path) - 1, PREFIX, dev->domain, dev->bus, name);
-	fd = open(path, O_RDWR);
-	if (fd >= 0) {
-	    return fd;
-	}
-
-	dev = pci_device_get_parent_bridge(dev);
-    }
-
-    return fd;
-}
-
-/*
- * xf86MapDomainMemory - memory map PCI domain memory
- *
- * This routine maps the memory region in the domain specified by Tag and
- * returns a pointer to it.  The pointer is saved for future use if it's in
- * the legacy ISA memory space (memory in a domain between 0 and 1MB).
- */
-pointer
-xf86MapDomainMemory(int ScreenNum, int Flags, struct pci_device *dev,
-		    ADDRESS Base, unsigned long Size)
-{
-    int fd = -1;
-    pointer addr;
-
-    /*
-     * We use /proc/bus/pci on non-legacy addresses or if the Linux sysfs
-     * legacy_mem interface is unavailable.
-     */
-    if ((Base > 1024*1024) || ((fd = linuxOpenLegacy(dev, "legacy_mem")) < 0))
-	return linuxMapPci(ScreenNum, Flags, dev, Base, Size,
-			   PCIIOC_MMAP_IS_MEM);
-    else
-	addr = mmap(NULL, Size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, Base);
-
-    if (fd >= 0)
-	close(fd);
-    if (addr == NULL || addr == MAP_FAILED) {
-	perror("mmap failure");
-	FatalError("xf86MapDomainMem():  mmap() failure\n");
-    }
-    return addr;
-}
diff --git a/hw/xfree86/os-support/bus/xf86Pci.h b/hw/xfree86/os-support/bus/xf86Pci.h
index 929dea2..8ecead0 100644
--- a/hw/xfree86/os-support/bus/xf86Pci.h
+++ b/hw/xfree86/os-support/bus/xf86Pci.h
@@ -252,8 +252,6 @@ typedef enum {
 extern _X_EXPORT Bool xf86scanpci(void);
 
 /* Domain access functions.  Some of these probably shouldn't be public */
-extern _X_EXPORT pointer xf86MapDomainMemory(int ScreenNum, int Flags, struct pci_device *dev,
-    ADDRESS Base, unsigned long Size);
 extern _X_EXPORT struct pci_io_handle *xf86MapLegacyIO(struct pci_device *dev);
 extern _X_EXPORT void xf86UnmapLegacyIO(struct pci_device *, struct pci_io_handle *);
 
diff --git a/hw/xfree86/vgahw/vgaHW.c b/hw/xfree86/vgahw/vgaHW.c
index 2aafa57..aab2ae2 100644
--- a/hw/xfree86/vgahw/vgaHW.c
+++ b/hw/xfree86/vgahw/vgaHW.c
@@ -1742,7 +1742,6 @@ Bool
 vgaHWMapMem(ScrnInfoPtr scrp)
 {
     vgaHWPtr hwp = VGAHWPTR(scrp);
-    int scr_index = scrp->scrnIndex;
     
     if (hwp->Base)
 	return TRUE;
@@ -1760,8 +1759,7 @@ vgaHWMapMem(ScrnInfoPtr scrp)
      * for now.
      */
     DebugF("Mapping VGAMem\n");
-    hwp->Base = xf86MapDomainMemory(scr_index, VIDMEM_MMIO_32BIT, hwp->dev,
-				    hwp->MapPhys, hwp->MapSize);
+    pci_device_map_legacy(hwp->dev, hwp->MapPhys, hwp->MapSize, 1, &hwp->Base);
     return hwp->Base != NULL;
 }
 
@@ -1770,13 +1768,12 @@ void
 vgaHWUnmapMem(ScrnInfoPtr scrp)
 {
     vgaHWPtr hwp = VGAHWPTR(scrp);
-    int scr_index = scrp->scrnIndex;
 
     if (hwp->Base == NULL)
 	return;
     
     DebugF("Unmapping VGAMem\n");
-    xf86UnMapVidMem(scr_index, hwp->Base, hwp->MapSize);
+    pci_device_unmap_legacy(hwp->dev, hwp->Base, hwp->MapSize);
     hwp->Base = NULL;
 }
 
commit 1da9a4815f5a30692dc4e864004baeb97de56ea7
Author: Adam Jackson <ajax at redhat.com>
Date:   Tue May 10 18:04:10 2011 -0400

    int10: Use pciaccess rom fetch for !PC machines
    
    ... instead of rolling our own, badly.
    
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/hw/xfree86/int10/generic.c b/hw/xfree86/int10/generic.c
index beb90b5..040d999 100644
--- a/hw/xfree86/int10/generic.c
+++ b/hw/xfree86/int10/generic.c
@@ -62,62 +62,6 @@ static void UnmapVRam(xf86Int10InfoPtr pInt);
 
 static void *sysMem = NULL;
 
-/**
- * Read legacy VGA video BIOS associated with specified domain.
- * 
- * Attempts to read up to 128KiB of legacy VGA video BIOS.
- * 
- * \return
- * The number of bytes read on success or -1 on failure.
- *
- * \bug
- * PCI ROMs can contain multiple BIOS images (e.g., OpenFirmware, x86 VGA,
- * etc.).  How do we know that \c pci_device_read_rom will return the
- * legacy VGA BIOS image?
- */
-#ifndef _PC
-static int
-read_legacy_video_BIOS(struct pci_device *dev, unsigned char *Buf)
-{
-    const ADDRESS Base = 0xC0000;
-    const int Len = 0x10000 * 2;
-    const int pagemask = getpagesize() - 1;
-    const ADDRESS offset = Base & ~pagemask;
-    const unsigned long size = ((Base + Len + pagemask) & ~pagemask) - offset;
-    unsigned char *ptr, *src;
-    int len;
-
-
-    /* Try to use the civilized PCI interface first.
-     */
-    if (pci_device_read_rom(dev, Buf) == 0) {
-	return dev->rom_size;
-    }
-
-    ptr = xf86MapDomainMemory(-1, VIDMEM_READONLY, dev, offset, size);
-
-    if (!ptr)
-	return -1;
-
-    /* Using memcpy() here can hang the system */
-    src = ptr + (Base - offset);
-    for (len = 0; len < (Len / 2); len++) {
-	Buf[len] = src[len];
-    }
-
-    if ((Buf[0] == 0x55) && (Buf[1] == 0xAA) && (Buf[2] > 0x80)) {
-	for ( /* empty */ ; len < Len; len++) {
-	    Buf[len] = src[len];
-	}
-    }
-
-    xf86UnMapVidMem(-1, ptr, size);
-
-    return Len;
-}
-#endif /* _PC */
-
-
 xf86Int10InfoPtr
 xf86ExtendedInitInt10(int entityIndex, int Flags)
 {
@@ -232,7 +176,7 @@ xf86ExtendedInitInt10(int entityIndex, int Flags)
      */
     vbiosMem = (char *)base + V_BIOS;
     memset(vbiosMem, 0, 2 * V_BIOS_SIZE);
-    if (read_legacy_video_BIOS(pInt->dev, vbiosMem) < V_BIOS_SIZE) {
+    if (pci_device_read_rom(pInt->dev, vbiosMem) < V_BIOS_SIZE) {
 	xf86DrvMsg(screen, X_WARNING,
 		   "Unable to retrieve all of segment 0x0C0000.\n");
     }
commit 5ec87ed6f599348e1eb4d4d479c0d504dd758fc5
Author: Adam Jackson <ajax at redhat.com>
Date:   Tue May 10 16:41:08 2011 -0400

    pci: Remove the PCITAG type
    
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/hw/xfree86/int10/helper_exec.c b/hw/xfree86/int10/helper_exec.c
index fc218a9..034d0f1 100644
--- a/hw/xfree86/int10/helper_exec.c
+++ b/hw/xfree86/int10/helper_exec.c
@@ -475,7 +475,7 @@ static struct pci_device*
 pci_device_for_cfg_address (CARD32 addr)
 {
 	struct pci_device *dev = NULL;
-	PCITAG tag = PCI_TAG(addr);
+	CARD32 tag = PCI_TAG(addr);
 	struct pci_slot_match slot_match = {
 		.domain = PCI_DOM_FROM_TAG(tag),
 		.bus = PCI_BUS_NO_DOMAIN(PCI_BUS_FROM_TAG(tag)),
diff --git a/hw/xfree86/os-support/bus/Pci.c b/hw/xfree86/os-support/bus/Pci.c
index f1dbfc2..0362a00 100644
--- a/hw/xfree86/os-support/bus/Pci.c
+++ b/hw/xfree86/os-support/bus/Pci.c
@@ -126,12 +126,6 @@
 
 #include "Pci.h"
 
-PCITAG
-pciTag(int busnum, int devnum, int funcnum)
-{
-	return(PCI_MAKE_TAG(busnum,devnum,funcnum));
-}
-
 Bool
 xf86scanpci(void)
 {
diff --git a/hw/xfree86/os-support/bus/xf86Pci.h b/hw/xfree86/os-support/bus/xf86Pci.h
index 4f2f07e..929dea2 100644
--- a/hw/xfree86/os-support/bus/xf86Pci.h
+++ b/hw/xfree86/os-support/bus/xf86Pci.h
@@ -235,7 +235,6 @@
 
 /* Primitive Types */
 typedef unsigned long ADDRESS;		/* Memory/PCI address */
-typedef unsigned long PCITAG;
 
 typedef enum {
     PCI_MEM,
@@ -250,7 +249,6 @@ typedef enum {
 
 
 /* Public PCI access functions */
-extern _X_EXPORT PCITAG pciTag(int busnum, int devnum, int funcnum);
 extern _X_EXPORT Bool xf86scanpci(void);
 
 /* Domain access functions.  Some of these probably shouldn't be public */
commit a8289183f161e398f9478e256707a3ae42b9457d
Author: Adam Jackson <ajax at redhat.com>
Date:   Fri Jan 7 17:20:15 2011 -0500

    xfree86: Remove unused bios_devmem.c
    
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/hw/xfree86/os-support/Makefile.am b/hw/xfree86/os-support/Makefile.am
index 348b7ff..094563d 100644
--- a/hw/xfree86/os-support/Makefile.am
+++ b/hw/xfree86/os-support/Makefile.am
@@ -16,6 +16,3 @@ libxorgos_la_LIBADD = @XORG_OS_SUBDIR@/lib at XORG_OS_SUBDIR@.la \
 
 AM_CFLAGS = $(DIX_CFLAGS) 
 
-# FIXME: These don't seem to be used anywhere
-EXTRA_DIST += \
-	shared/bios_devmem.c
diff --git a/hw/xfree86/os-support/shared/bios_devmem.c b/hw/xfree86/os-support/shared/bios_devmem.c
deleted file mode 100644
index b9dfb7d..0000000
--- a/hw/xfree86/os-support/shared/bios_devmem.c
+++ /dev/null
@@ -1,75 +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"
-#include <string.h>
-
-/*
- * Read BIOS via /dev/mem.
- */
-
-#ifndef DEV_MEM
-# define DEV_MEM "/dev/mem"
-#endif
-
-int
-xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
-		int Len)
-{
- 	int fd;
-
-#ifdef __ia64__
-	if ((fd = open(DEV_MEM, O_RDONLY | O_SYNC)) < 0)
-#else
- 	if ((fd = open(DEV_MEM, O_RDONLY)) < 0)
-#endif
-	{
-		xf86Msg(X_WARNING, "xf86ReadBIOS: Failed to open %s (%s)\n",
-			DEV_MEM, strerror(errno));
-		return -1;
-	}
-
-	if (lseek(fd, (Base+Offset), SEEK_SET) < 0)
-	{
-		xf86Msg(X_WARNING, "xf86ReadBIOS: %s seek failed (%s)\n",
-			DEV_MEM, strerror(errno));
-		close(fd);
-		return -1;
-	}
-	if (read(fd, Buf, Len) != Len)
-	{
-		xf86Msg(X_WARNING, "xf86ReadBIOS: %s read failed (%s)\n",
-			DEV_MEM, strerror(errno));
-		close(fd);
-		return -1;
-	}
-	close(fd);
-	return Len;
-}
commit 29dbf7321390e377d01b520048ebf052a2bab27e
Author: Adam Jackson <ajax at redhat.com>
Date:   Fri Jan 7 16:57:15 2011 -0500

    linux: Remove ia64 domain I/O support code
    
    pciaccess handles this now.
    
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/configure.ac b/configure.ac
index b0d2643..d51860d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1570,14 +1570,10 @@ if test "x$XORG" = xyes; then
 		xorg_bus_linuxpci="yes"
 		linux_acpi="no"
 		case $host_cpu in
-		  ia64*)
-			linux_ia64=yes
-			linux_acpi="yes"
-			;;
 		  alpha*)
 		  	linux_alpha=yes
 			;;
-		  i*86|amd64*|x86_64*)
+		  i*86|amd64*|x86_64*|ia64*)
 			linux_acpi="yes"
 			;;
 		  *)
@@ -1757,7 +1753,6 @@ AM_CONDITIONAL([XORG], [test "x$XORG" = xyes])
 AM_CONDITIONAL([XORG_BUS_LINUXPCI], [test "x$xorg_bus_linuxpci" = xyes])
 AM_CONDITIONAL([XORG_BUS_BSDPCI], [test "x$xorg_bus_bsdpci" = xyes])
 AM_CONDITIONAL([XORG_BUS_SPARC], [test "x$xorg_bus_sparc" = xyes])
-AM_CONDITIONAL([LINUX_IA64], [test "x$linux_ia64" = xyes])
 AM_CONDITIONAL([LINUX_ALPHA], [test "x$linux_alpha" = xyes])
 AM_CONDITIONAL([LNXACPI], [test "x$linux_acpi" = xyes])
 AM_CONDITIONAL([SOLARIS_ASM_INLINE], [test "x$solaris_asm_inline" = xyes])
diff --git a/hw/xfree86/os-support/linux/Makefile.am b/hw/xfree86/os-support/linux/Makefile.am
index 7a82627..36748df 100644
--- a/hw/xfree86/os-support/linux/Makefile.am
+++ b/hw/xfree86/os-support/linux/Makefile.am
@@ -1,9 +1,5 @@
 noinst_LTLIBRARIES = liblinux.la
 
-if LINUX_IA64
-PLATFORM_PCI_SUPPORT = $(srcdir)/../shared/ia64Pci.c
-PLATFORM_INCLUDES = -I$(srcdir)/../shared
-endif
 if LINUX_ALPHA
 noinst_LTLIBRARIES += liblinuxev56.la
 PLATFORM_PCI_SUPPORT = \
diff --git a/hw/xfree86/os-support/shared/ia64Pci.c b/hw/xfree86/os-support/shared/ia64Pci.c
deleted file mode 100644
index c93c74c..0000000
--- a/hw/xfree86/os-support/shared/ia64Pci.c
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- * Copyright (C) 2002-2003 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.
- */
-
-/*
- * This file contains the glue needed to support various IA-64 chipsets.
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <fcntl.h>
-#include <unistd.h>
-#include <signal.h>
-#include <dirent.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/ioctl.h>
-#include <linux/pci.h>
-
-#include "compiler.h"
-#include "Pci.h"
-
-/*
- * We use special in/out routines here since Altix platforms require the
- * use of the sysfs legacy_io interface.  The legacy_io file maps to the I/O
- * space of a given PCI domain; reads and writes are used to do port I/O.
- * The file descriptor for the file is stored in the upper bits of the
- * value passed in by the caller, and is created and populated by
- * xf86MapLegacyIO.
- *
- * If the legacy_io interface doesn't exist, we fall back to the glibc in/out
- * routines, which are prefixed by an underscore (e.g. _outb).
- */
-static int ia64_port_to_fd(unsigned long port)
-{
-    return (port >> 24) & 0xffffffff;
-}
-
-void outb(unsigned long port, unsigned char val)
-{
-    int fd = ia64_port_to_fd(port);
-
-    if (!fd) {
-	_outb(val, port & 0xffff);
-	goto out;
-    }
-    if (lseek(fd, port & 0xffff, SEEK_SET) == -1) {
-	ErrorF("I/O lseek failed\n");
-	goto out;
-    }
-    if (write(fd, &val, 1) != 1) {
-	ErrorF("I/O write failed\n");
-	goto out;
-    }
- out:
-    return;
-}
-
-void outw(unsigned long port, unsigned short val)
-{
-    int fd = ia64_port_to_fd(port);
-
-    if (!fd) {
-	_outw(val, port & 0xffff);
-	goto out;
-    }
-    if (lseek(fd, port & 0xffff, SEEK_SET) == -1) {
-	ErrorF("I/O lseek failed\n");
-	goto out;
-    }
-    if (write(fd, &val, 2) != 2) {
-	ErrorF("I/O write failed\n");
-	goto out;
-    }
- out:
-    return;
-}
-
-void outl(unsigned long port, unsigned int val)
-{
-    int fd = ia64_port_to_fd(port);
-
-    if (!fd) {
-	_outl(val, port & 0xffff);
-	goto out;
-    }
-    if (lseek(fd, port & 0xffff, SEEK_SET) == -1) {
-	ErrorF("I/O lseek failed\n");
-	goto out;
-    }
-    if (write(fd, &val, 4) != 4) {
-	ErrorF("I/O write failed\n");
-	goto out;
-    }
- out:
-    return;
-}
-
-unsigned int inb(unsigned long port)
-{
-    int fd = ia64_port_to_fd(port);
-    unsigned char val;
-
-    if (!fd)
-	return _inb(port & 0xffff);
-
-    if (lseek(fd, port & 0xffff, SEEK_SET) == -1) {
-	ErrorF("I/O lseek failed\n");
-	val = -1;
-	goto out;
-    }
-    if (read(fd, &val, 1) != 1) {
-	ErrorF("I/O read failed\n");
-	val = -1;
-	goto out;
-    }
- out:
-    return val;
-}
-
-unsigned int inw(unsigned long port)
-{
-    int fd = ia64_port_to_fd(port);
-    unsigned short val;
-
-    if (!fd)
-	return _inw(port & 0xffff);
-
-    if (lseek(fd, port & 0xffff, SEEK_SET) == -1) {
-	ErrorF("I/O lseek failed\n");
-	val = -1;
-	goto out;
-    }
-    if (read(fd, &val, 2) != 2) {
-	ErrorF("I/O read failed\n");
-	val = -1;
-	goto out;
-    }
- out:
-    return val;
-}
-
-unsigned int inl(unsigned long port)
-{
-    int fd = ia64_port_to_fd(port);
-    unsigned int val;
-
-    if (!fd)
-	return _inl(port & 0xffff);
-
-    if (lseek(fd, port & 0xffff, SEEK_SET) == -1) {
-	ErrorF("I/O lseek failed\n");
-	val = -1;
-	goto out;
-    }
-    if (read(fd, &val, 4) != 4) {
-	ErrorF("I/O read failed\n");
-	val = -1;
-	goto out;
-    }
- out:
-    return val;
-}
-
commit 12faba80433a0209e5118373d8d31e91d5f4b37f
Author: Adam Jackson <ajax at redhat.com>
Date:   Fri Oct 16 16:09:56 2009 -0400

    linux: Remove pre-2.6 PCI interface support
    
    If you haven't ported 2.6 to your architecture in the intervening seven
    years, you can keep running older servers.
    
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/hw/xfree86/os-support/bus/linuxPci.c b/hw/xfree86/os-support/bus/linuxPci.c
index 2778bba..8f314b5 100644
--- a/hw/xfree86/os-support/bus/linuxPci.c
+++ b/hw/xfree86/os-support/bus/linuxPci.c
@@ -63,47 +63,19 @@ linuxPciOpenFile(struct pci_device *dev, Bool write)
     static struct pci_device *last_dev = NULL;
     static int	fd = -1,is_write = 0;
     char		file[64];
-    struct stat	ignored;
-    static int is26 = -1;
 
     if (dev == NULL) {
 	return -1;
     }
 
-    if (is26 == -1) {
-	is26 = (stat("/sys/bus/pci", &ignored) < 0) ? 0 : 1;
-    }
-	
     if (fd == -1 || (write && (!is_write)) || (last_dev != dev)) {
 	if (fd != -1) {
 	    close(fd);
 	    fd = -1;
 	}
 
-	if (is26) {
-	    sprintf(file,"/sys/bus/pci/devices/%04u:%02x:%02x.%01x/config",
-		    dev->domain, dev->bus, dev->dev, dev->func);
-	} else {
-	    if (dev->domain == 0) {
-		sprintf(file,"/proc/bus/pci/%02x", dev->bus);
-		if (stat(file, &ignored) < 0) {
-		    sprintf(file, "/proc/bus/pci/0000:%02x/%02x.%1x",
-			    dev->bus, dev->dev, dev->func);
-		} else {
-		    sprintf(file, "/proc/bus/pci/%02x/%02x.%1x",
-			    dev->bus, dev->dev, dev->func);
-		}
-	    } else {
-		sprintf(file,"/proc/bus/pci/%02x%02x", dev->domain, dev->bus);
-		if (stat(file, &ignored) < 0) {
-		    sprintf(file, "/proc/bus/pci/%04x:%04x/%02x.%1x",
-			    dev->domain, dev->bus, dev->dev, dev->func);
-		} else {
-		    sprintf(file, "/proc/bus/pci/%02x%02x/%02x.%1x",
-			    dev->domain, dev->bus, dev->dev, dev->func);
-		}
-	    }
-	}
+	sprintf(file,"/sys/bus/pci/devices/%04u:%02x:%02x.%01x/config",
+		dev->domain, dev->bus, dev->dev, dev->func);
 
 	if (write) {
 	    fd = open(file,O_RDWR);
commit 0e32df58b73b7952a7cf0d07e674c0ffd6918811
Author: Adam Jackson <ajax at redhat.com>
Date:   Fri Oct 16 14:05:54 2009 -0400

    bus: remove some dead struct fields
    
    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 89db4cc..54f6c64 100644
--- a/hw/xfree86/os-support/shared/vidmem.c
+++ b/hw/xfree86/os-support/shared/vidmem.c
@@ -51,11 +51,9 @@
  */
 
 typedef struct {
-	unsigned long 	physBase;
 	unsigned long 	size;
 	pointer		virtBase;
 	pointer 	mtrrInfo;
-	int		flags;
 } MappingRec, *MappingPtr;
 	
 typedef struct {
@@ -169,10 +167,8 @@ xf86MakeNewMapping(int ScreenNum, int Flags, unsigned long Base, unsigned long S
 
 	vp = getVidMapRec(ScreenNum);
 	mp = newMapping(vp);
-	mp->physBase = Base;
 	mp->size = Size;
 	mp->virtBase = Vbase;
-	mp->flags = Flags;
 }
 
 void
@@ -206,10 +202,8 @@ xf86MapVidMem(int ScreenNum, int Flags, unsigned long Base, unsigned long Size)
 
 	vp = getVidMapRec(ScreenNum);
 	mp = newMapping(vp);
-	mp->physBase = Base;
 	mp->size = Size;
 	mp->virtBase = vbase;
-	mp->flags = Flags;
 
 	/*
 	 * Check the "mtrr" option even when MTRR isn't supported to avoid
commit 4dcb70e7b0eab667efba7569c574f3d7ef6adf0b
Author: Adam Jackson <ajax at redhat.com>
Date:   Mon Sep 20 11:42:11 2010 -0400

    linux: Use pci_device_get_parent_bridge instead of open-coding it
    
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/hw/xfree86/os-support/bus/linuxPci.c b/hw/xfree86/os-support/bus/linuxPci.c
index 28bba01..2778bba 100644
--- a/hw/xfree86/os-support/bus/linuxPci.c
+++ b/hw/xfree86/os-support/bus/linuxPci.c
@@ -160,45 +160,6 @@ linuxPciOpenFile(struct pci_device *dev, Bool write)
 
 #endif
 
-/* This probably shouldn't be Linux-specific */
-static struct pci_device *
-get_parent_bridge(struct pci_device *dev)
-{
-    struct pci_id_match bridge_match = {
-	PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY,
-	(PCI_CLASS_BRIDGE << 16) | (PCI_SUBCLASS_BRIDGE_PCI << 8),
-	0
-    };
-    struct pci_device *bridge;
-    struct pci_device_iterator *iter;
-
-    if (dev == NULL) {
-	return NULL;
-    }
-
-    iter = pci_id_match_iterator_create(& bridge_match);
-    if (iter == NULL) {
-	return NULL;
-    }
-
-    while ((bridge = pci_device_next(iter)) != NULL) {
-	if (bridge->domain == dev->domain) {
-	    const struct pci_bridge_info *info = 
-		pci_device_get_bridge_info(bridge);
-
-	    if (info != NULL) {
-		if (info->secondary_bus == dev->bus) {
-		    break;
-		}
-	    }
-	}
-    }
-
-    pci_iterator_destroy(iter);
-
-    return bridge;
-}
-
 static pointer
 linuxMapPci(int ScreenNum, int Flags, struct pci_device *dev,
 	    ADDRESS Base, unsigned long Size, int mmap_ioctl)
@@ -283,7 +244,7 @@ linuxOpenLegacy(struct pci_device *dev, char *name)
 	    return fd;
 	}
 
-	dev = get_parent_bridge(dev);
+	dev = pci_device_get_parent_bridge(dev);
     }
 
     return fd;
commit ae154030d0895da4bf86c526e1954f4dd671d659
Author: Adam Jackson <ajax at redhat.com>
Date:   Fri Sep 16 13:33:04 2011 -0400

    pci: Port xf86MapLegacyIO to pciaccess
    
    Per-domain I/O is now something drivers must manually request, and must
    keep track of within their own state rather than in the ScrnInfoRec.
    It's not really possible to split that into two steps without an
    additional intermediate ABI break, so don't even try.  Drivers that want
    source compatibility should ifdef on the presence of xf86UnmapLegacyIO.
    
    As a fringe benefit, domain-aware I/O is now OS-independent, relying
    only on support in pciaccess.  Simplify OS PCI setup to reflect this.
    
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/hw/xfree86/common/xf86Bus.c b/hw/xfree86/common/xf86Bus.c
index 3b08968..8749a29 100644
--- a/hw/xfree86/common/xf86Bus.c
+++ b/hw/xfree86/common/xf86Bus.c
@@ -308,7 +308,6 @@ xf86AddEntityToScreen(ScrnInfoPtr pScrn, int entityIndex)
     pScrn->entityInstanceList = xnfrealloc(pScrn->entityInstanceList,
 				    pScrn->numEntities * sizeof(int));
     pScrn->entityInstanceList[pScrn->numEntities - 1] = 0;
-    pScrn->domainIOBase = xf86Entities[entityIndex]->domainIO;
 }
 
 void
diff --git a/hw/xfree86/common/xf86Bus.h b/hw/xfree86/common/xf86Bus.h
index e161c7f..0b2ebdb 100644
--- a/hw/xfree86/common/xf86Bus.h
+++ b/hw/xfree86/common/xf86Bus.h
@@ -58,7 +58,6 @@ typedef struct {
     DevUnion *                  entityPrivates;
     int                         numInstances;
     GDevPtr *                   devices;   
-    IOADDRESS                   domainIO;
 } EntityRec, *EntityPtr;
 
 #define ACCEL_IS_SHARABLE 0x100
diff --git a/hw/xfree86/common/xf86pciBus.c b/hw/xfree86/common/xf86pciBus.c
index 447b192..2acf486 100644
--- a/hw/xfree86/common/xf86pciBus.c
+++ b/hw/xfree86/common/xf86pciBus.c
@@ -235,11 +235,6 @@ xf86ClaimPciSlot(struct pci_device * d, DriverPtr drvp,
             xf86AddDevToEntity(num, dev);
 	pciSlotClaimed = TRUE;
 
-	if (active) {
-	    /* Map in this domain's I/O space */
-	   p->domainIO = xf86MapLegacyIO(d);
-	}
-	
  	return num;
     } else
  	return -1;
@@ -1357,3 +1352,15 @@ xf86PciConfigureNewDev(void *busData, struct pci_device *pVideo,
     if (*chipset < 0)
         *chipset = (pVideo->vendor_id << 16) | pVideo->device_id;
 }
+
+struct pci_io_handle *
+xf86MapLegacyIO(struct pci_device *dev)
+{
+    return pci_legacy_open_io(dev, 0, 64 * 1024);
+}
+
+void
+xf86UnmapLegacyIO(struct pci_device *dev, struct pci_io_handle *handle)
+{
+    pci_device_close_io(dev, handle);
+}
diff --git a/hw/xfree86/common/xf86str.h b/hw/xfree86/common/xf86str.h
index 0493dc5..43e9d1d 100644
--- a/hw/xfree86/common/xf86str.h
+++ b/hw/xfree86/common/xf86str.h
@@ -742,7 +742,6 @@ typedef struct _ScrnInfoRec {
     unsigned long	biosBase;		/* Base address of video BIOS */
     unsigned long	memPhysBase;		/* Physical address of FB */
     unsigned long 	fbOffset;		/* Offset of FB in the above */
-    IOADDRESS    	domainIOBase;		/* Domain I/O base address */
     int			memClk;			/* memory clock */
     int			textClockFreq;		/* clock of text mode */
     Bool		flipPixels;		/* swap default black/white */
diff --git a/hw/xfree86/os-support/bus/Pci.c b/hw/xfree86/os-support/bus/Pci.c
index fe4850e..f1dbfc2 100644
--- a/hw/xfree86/os-support/bus/Pci.c
+++ b/hw/xfree86/os-support/bus/Pci.c
@@ -140,7 +140,7 @@ xf86scanpci(void)
     success = (pci_system_init() == 0);
 
     /* choose correct platform/OS specific PCI init routine */
-	ARCH_PCI_INIT();
+    osPciInit();
 
     return success;
 }
diff --git a/hw/xfree86/os-support/bus/Pci.h b/hw/xfree86/os-support/bus/Pci.h
index 3493013..88560ec 100644
--- a/hw/xfree86/os-support/bus/Pci.h
+++ b/hw/xfree86/os-support/bus/Pci.h
@@ -137,20 +137,14 @@
 #define PCI_BUS_NO_DOMAIN(bus) ((bus) & 0xffu)
 #define PCI_TAG_NO_DOMAIN(tag) ((tag) & 0x00ffff00u)
 
-#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \
+#if defined(linux)
+#define osPciInit(x) do {} while (0)
+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \
 	defined(__OpenBSD__) || defined(__NetBSD__) || \
 	defined(__DragonFly__) || defined(__sun) || defined(__GNU__)
-#define ARCH_PCI_INIT bsdPciInit
-#endif
-
-#if defined(linux)
-#define ARCH_PCI_INIT linuxPciInit
-#endif /* defined(linux) */
-
-#ifndef ARCH_PCI_INIT
+extern void osPciInit(void);
+#else
 #error No PCI support available for this architecture/OS combination
 #endif
 
-extern void ARCH_PCI_INIT(void);
-
 #endif /* _PCI_H */
diff --git a/hw/xfree86/os-support/bus/bsd_pci.c b/hw/xfree86/os-support/bus/bsd_pci.c
index 17b52db..f51d5c0 100644
--- a/hw/xfree86/os-support/bus/bsd_pci.c
+++ b/hw/xfree86/os-support/bus/bsd_pci.c
@@ -55,15 +55,8 @@ xf86MapDomainMemory(int ScreenNum, int Flags, struct pci_device *dev,
     return xf86MapVidMem(ScreenNum, Flags, Base, Size);
 }
 
-IOADDRESS
-xf86MapLegacyIO(struct pci_device *dev)
-{
-    (void)dev;
-    return 0;
-}
-
 void
-bsdPciInit(void)
+osPciInit(void)
 {
     xf86InitVidMem();
 }
diff --git a/hw/xfree86/os-support/bus/linuxPci.c b/hw/xfree86/os-support/bus/linuxPci.c
index fcfdbcb..28bba01 100644
--- a/hw/xfree86/os-support/bus/linuxPci.c
+++ b/hw/xfree86/os-support/bus/linuxPci.c
@@ -52,21 +52,6 @@
 #include "xf86_OSlib.h"
 #include "Pci.h"
 
-static const struct pci_id_match match_host_bridge = {
-    PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY,
-    (PCI_CLASS_BRIDGE << 16) | (PCI_SUBCLASS_BRIDGE_HOST << 8),
-    0x0000ffff00, 0
-};
-
-#define MAX_DOMAINS 257
-static pointer DomainMmappedIO[MAX_DOMAINS];
-
-void
-linuxPciInit(void)
-{
-    memset(DomainMmappedIO, 0, sizeof(DomainMmappedIO));
-}
-
 /**
  * \bug
  * The generation of the procfs file name for the domain != 0 case may not be 
@@ -153,15 +138,6 @@ linuxPciOpenFile(struct pci_device *dev, Bool write)
  * functionality is almost, but not quite there yet.  Alpha and other kernel
  * ports to multi-domain architectures still need to implement this.
  *
- * This scheme is also predicated on the use of an IOADDRESS compatible type to
- * designate I/O addresses.  Although IOADDRESS is defined as an unsigned
- * integral type, it is actually the virtual address of, i.e. a pointer to, the
- * I/O port to access.  And so, the inX/outX macros in "compiler.h" need to be
- * #define'd appropriately (as is done on SPARC's).
- *
- * Another requirement to port this scheme to another multi-domain architecture
- * is to add the appropriate entries in the pciControllerSizes array below.
- *
  * TO DO:  Address the deleterious reaction some host bridges have to master
  *         aborts.  This is already done for secondary PCI buses, but not yet
  *         for accesses to primary buses (except for the SPARC port, where
@@ -223,67 +199,6 @@ get_parent_bridge(struct pci_device *dev)
     return bridge;
 }
 
-/*
- * This is ugly, but until I can extract this information from the kernel,
- * it'll have to do.  The default I/O space size is 64K, and 4G for memory.
- * Anything else needs to go in this table.  (PowerPC folk take note.)
- *
- * Note that Linux/SPARC userland is 32-bit, so 4G overflows to zero here.
- *
- * Please keep this table in ascending vendor/device order.
- */
-static const struct pciSizes {
-    unsigned short vendor, device;
-    unsigned long io_size, mem_size;
-} pciControllerSizes[] = {
-    {
-	PCI_VENDOR_SUN, PCI_CHIP_PSYCHO,
-	1U << 16, 1U << 31
-    },
-    {
-	PCI_VENDOR_SUN, PCI_CHIP_SCHIZO,
-	1U << 24, 1U << 31	/* ??? */
-    },
-    {
-	PCI_VENDOR_SUN, PCI_CHIP_SABRE,
-	1U << 24, (unsigned long)(1ULL << 32)
-    },
-    {
-	PCI_VENDOR_SUN, PCI_CHIP_HUMMINGBIRD,
-	1U << 24, (unsigned long)(1ULL << 32)
-    }
-};
-#define NUM_SIZES (sizeof(pciControllerSizes) / sizeof(pciControllerSizes[0]))
-
-static const struct pciSizes *
-linuxGetSizesStruct(const struct pci_device *dev)
-{
-    static const struct pciSizes default_size = {
-	0, 0, 1U << 16, (unsigned long)(1ULL << 32)
-    };
-    int          i;
-
-    /* Look up vendor/device */
-    if (dev != NULL) {
-	for (i = 0;  i < NUM_SIZES;  i++) {
-	    if ((dev->vendor_id == pciControllerSizes[i].vendor)
-		&& (dev->device_id == pciControllerSizes[i].device)) {
-		return & pciControllerSizes[i];
-	    }
-	}
-    }
-
-    /* Default to 64KB I/O and 4GB memory. */
-    return & default_size;
-}
-
-static __inline__ unsigned long
-linuxGetIOSize(const struct pci_device *dev)
-{
-    const struct pciSizes * const sizes = linuxGetSizesStruct(dev);
-    return sizes->io_size;
-}
-
 static pointer
 linuxMapPci(int ScreenNum, int Flags, struct pci_device *dev,
 	    ADDRESS Base, unsigned long Size, int mmap_ioctl)
@@ -406,45 +321,3 @@ xf86MapDomainMemory(int ScreenNum, int Flags, struct pci_device *dev,
     }
     return addr;
 }
-
-/**
- * Map I/O space in this domain
- *
- * Each domain has a legacy ISA I/O space.  This routine will try to
- * map it using the Linux sysfs legacy_io interface.  If that fails,
- * it'll fall back to using /proc/bus/pci.
- *
- * If the legacy_io interface \b does exist, the file descriptor (\c fd below)
- * will be saved in the \c DomainMmappedIO array in the upper bits of the
- * pointer.  Callers will do I/O with small port numbers (<64k values), so
- * the platform I/O code can extract the port number and the \c fd, \c lseek
- * to the port number in the legacy_io file, and issue the read or write.
- *
- * This has no means of returning failure, so all errors are fatal
- */
-IOADDRESS
-xf86MapLegacyIO(struct pci_device *dev)
-{
-    const int domain = dev->domain;
-    struct pci_device *bridge = get_parent_bridge(dev);
-    int fd;
-
-    if (domain >= MAX_DOMAINS)
-	FatalError("xf86MapLegacyIO():  domain out of range\n");
-
-    if (DomainMmappedIO[domain] == NULL) {
-	/* Permanently map all of I/O space */
-	fd = linuxOpenLegacy(bridge, "legacy_io");
-	if (fd < 0) {
-	    DomainMmappedIO[domain] = linuxMapPci(-1, VIDMEM_MMIO, bridge,
-						  0, linuxGetIOSize(bridge),
-						  PCIIOC_MMAP_IS_IO);
-	}
-	else { /* legacy_io file exists, encode fd */
-	    DomainMmappedIO[domain] = (pointer)(intptr_t)(fd << 24);
-	}
-    }
-
-    return (IOADDRESS)DomainMmappedIO[domain];
-}
-
diff --git a/hw/xfree86/os-support/bus/xf86Pci.h b/hw/xfree86/os-support/bus/xf86Pci.h
index ce1336b..4f2f07e 100644
--- a/hw/xfree86/os-support/bus/xf86Pci.h
+++ b/hw/xfree86/os-support/bus/xf86Pci.h
@@ -235,7 +235,6 @@
 
 /* Primitive Types */
 typedef unsigned long ADDRESS;		/* Memory/PCI address */
-typedef unsigned long IOADDRESS;	/* Must be large enough for a pointer */
 typedef unsigned long PCITAG;
 
 typedef enum {
@@ -257,6 +256,7 @@ extern _X_EXPORT Bool xf86scanpci(void);
 /* Domain access functions.  Some of these probably shouldn't be public */
 extern _X_EXPORT pointer xf86MapDomainMemory(int ScreenNum, int Flags, struct pci_device *dev,
     ADDRESS Base, unsigned long Size);
-extern _X_EXPORT IOADDRESS xf86MapLegacyIO(struct pci_device *dev);
+extern _X_EXPORT struct pci_io_handle *xf86MapLegacyIO(struct pci_device *dev);
+extern _X_EXPORT void xf86UnmapLegacyIO(struct pci_device *, struct pci_io_handle *);
 
 #endif /* _XF86PCI_H */
commit b333b778d5b2ed17a7e40ab7e5bc9654185f3b5a
Author: Adam Jackson <ajax at redhat.com>
Date:   Tue Sep 20 18:12:29 2011 -0400

    vgahw: Port to pciaccess IO space routines
    
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/hw/xfree86/vgahw/vgaHW.c b/hw/xfree86/vgahw/vgaHW.c
index 6c0e635..2aafa57 100644
--- a/hw/xfree86/vgahw/vgaHW.c
+++ b/hw/xfree86/vgahw/vgaHW.c
@@ -163,67 +163,67 @@ static CARD8 defaultDAC[768] =
 static void
 stdWriteCrtc(vgaHWPtr hwp, CARD8 index, CARD8 value)
 {
-    outb(hwp->IOBase + hwp->PIOOffset + VGA_CRTC_INDEX_OFFSET, index);
-    outb(hwp->IOBase + hwp->PIOOffset + VGA_CRTC_DATA_OFFSET, value);
+    pci_io_write8(hwp->io, hwp->IOBase + VGA_CRTC_INDEX_OFFSET, index);
+    pci_io_write8(hwp->io, hwp->IOBase + VGA_CRTC_DATA_OFFSET, value);
 }
 
 static CARD8
 stdReadCrtc(vgaHWPtr hwp, CARD8 index)
 {
-    outb(hwp->IOBase + hwp->PIOOffset + VGA_CRTC_INDEX_OFFSET, index);
-    return inb(hwp->IOBase + hwp->PIOOffset + VGA_CRTC_DATA_OFFSET);
+    pci_io_write8(hwp->io, hwp->IOBase + VGA_CRTC_INDEX_OFFSET, index);
+    return pci_io_read8(hwp->io, hwp->IOBase + VGA_CRTC_DATA_OFFSET);
 }
 
 static void
 stdWriteGr(vgaHWPtr hwp, CARD8 index, CARD8 value)
 {
-    outb(hwp->PIOOffset + VGA_GRAPH_INDEX, index);
-    outb(hwp->PIOOffset + VGA_GRAPH_DATA, value);
+    pci_io_write8(hwp->io, VGA_GRAPH_INDEX, index);
+    pci_io_write8(hwp->io, VGA_GRAPH_DATA, value);
 }
 
 static CARD8
 stdReadGr(vgaHWPtr hwp, CARD8 index)
 {
-    outb(hwp->PIOOffset + VGA_GRAPH_INDEX, index);
-    return inb(hwp->PIOOffset + VGA_GRAPH_DATA);
+    pci_io_write8(hwp->io, VGA_GRAPH_INDEX, index);
+    return pci_io_read8(hwp->io, VGA_GRAPH_DATA);
 }
 
 static void
 stdWriteSeq(vgaHWPtr hwp, CARD8 index, CARD8 value)
 {
-    outb(hwp->PIOOffset + VGA_SEQ_INDEX, index);
-    outb(hwp->PIOOffset + VGA_SEQ_DATA, value);
+    pci_io_write8(hwp->io, VGA_SEQ_INDEX, index);
+    pci_io_write8(hwp->io, VGA_SEQ_DATA, value);
 }
 
 static CARD8
 stdReadSeq(vgaHWPtr hwp, CARD8 index)
 {
-    outb(hwp->PIOOffset + VGA_SEQ_INDEX, index);
-    return inb(hwp->PIOOffset + VGA_SEQ_DATA);
+    pci_io_write8(hwp->io, VGA_SEQ_INDEX, index);
+    return pci_io_read8(hwp->io, VGA_SEQ_DATA);
 }
 
 static CARD8
 stdReadST00(vgaHWPtr hwp)
 {
-    return inb(hwp->PIOOffset + VGA_IN_STAT_0);
+    return pci_io_read8(hwp->io, VGA_IN_STAT_0);
 }
 
 static CARD8
 stdReadST01(vgaHWPtr hwp)
 {
-    return inb(hwp->IOBase + hwp->PIOOffset + VGA_IN_STAT_1_OFFSET);
+    return pci_io_read8(hwp->io, hwp->IOBase + VGA_IN_STAT_1_OFFSET);
 }
 
 static CARD8
 stdReadFCR(vgaHWPtr hwp)
 {
-    return inb(hwp->PIOOffset + VGA_FEATURE_R);
+    return pci_io_read8(hwp->io, VGA_FEATURE_R);
 }
 
 static void
 stdWriteFCR(vgaHWPtr hwp, CARD8 value)
 {
-    outb(hwp->IOBase + hwp->PIOOffset + VGA_FEATURE_W_OFFSET,value);
+    pci_io_write8(hwp->io, hwp->IOBase + VGA_FEATURE_W_OFFSET,value);
 }
 
 static void
@@ -234,9 +234,9 @@ stdWriteAttr(vgaHWPtr hwp, CARD8 index, CARD8 value)
     else
 	index |= 0x20;
 
-    (void) inb(hwp->IOBase + hwp->PIOOffset + VGA_IN_STAT_1_OFFSET);
-    outb(hwp->PIOOffset + VGA_ATTR_INDEX, index);
-    outb(hwp->PIOOffset + VGA_ATTR_DATA_W, value);
+    (void) pci_io_read8(hwp->io, hwp->IOBase + VGA_IN_STAT_1_OFFSET);
+    pci_io_write8(hwp->io, VGA_ATTR_INDEX, index);
+    pci_io_write8(hwp->io, VGA_ATTR_DATA_W, value);
 }
 
 static CARD8
@@ -247,85 +247,85 @@ stdReadAttr(vgaHWPtr hwp, CARD8 index)
     else
 	index |= 0x20;
 
-    (void) inb(hwp->IOBase + hwp->PIOOffset + VGA_IN_STAT_1_OFFSET);
-    outb(hwp->PIOOffset + VGA_ATTR_INDEX, index);
-    return inb(hwp->PIOOffset + VGA_ATTR_DATA_R);
+    (void) pci_io_read8(hwp->io, hwp->IOBase + VGA_IN_STAT_1_OFFSET);
+    pci_io_write8(hwp->io, VGA_ATTR_INDEX, index);
+    return pci_io_read8(hwp->io, VGA_ATTR_DATA_R);
 }
 
 static void
 stdWriteMiscOut(vgaHWPtr hwp, CARD8 value)
 {
-    outb(hwp->PIOOffset + VGA_MISC_OUT_W, value);
+    pci_io_write8(hwp->io, VGA_MISC_OUT_W, value);
 }
 
 static CARD8
 stdReadMiscOut(vgaHWPtr hwp)
 {
-    return inb(hwp->PIOOffset + VGA_MISC_OUT_R);
+    return pci_io_read8(hwp->io, VGA_MISC_OUT_R);
 }
 
 static void
 stdEnablePalette(vgaHWPtr hwp)
 {
-    (void) inb(hwp->IOBase + hwp->PIOOffset + VGA_IN_STAT_1_OFFSET);
-    outb(hwp->PIOOffset + VGA_ATTR_INDEX, 0x00);
+    (void) pci_io_read8(hwp->io, hwp->IOBase + VGA_IN_STAT_1_OFFSET);
+    pci_io_write8(hwp->io, VGA_ATTR_INDEX, 0x00);
     hwp->paletteEnabled = TRUE;
 }
 
 static void
 stdDisablePalette(vgaHWPtr hwp)
 {
-    (void) inb(hwp->IOBase + hwp->PIOOffset + VGA_IN_STAT_1_OFFSET);
-    outb(hwp->PIOOffset + VGA_ATTR_INDEX, 0x20);
+    (void) pci_io_read8(hwp->io, hwp->IOBase + VGA_IN_STAT_1_OFFSET);
+    pci_io_write8(hwp->io, VGA_ATTR_INDEX, 0x20);
     hwp->paletteEnabled = FALSE;
 }
 
 static void
 stdWriteDacMask(vgaHWPtr hwp, CARD8 value)
 {
-    outb(hwp->PIOOffset + VGA_DAC_MASK, value);
+    pci_io_write8(hwp->io, VGA_DAC_MASK, value);
 }
 
 static CARD8
 stdReadDacMask(vgaHWPtr hwp)
 {
-    return inb(hwp->PIOOffset + VGA_DAC_MASK);
+    return pci_io_read8(hwp->io, VGA_DAC_MASK);
 }
 
 static void
 stdWriteDacReadAddr(vgaHWPtr hwp, CARD8 value)
 {
-    outb(hwp->PIOOffset + VGA_DAC_READ_ADDR, value);
+    pci_io_write8(hwp->io, VGA_DAC_READ_ADDR, value);
 }
 
 static void
 stdWriteDacWriteAddr(vgaHWPtr hwp, CARD8 value)
 {
-    outb(hwp->PIOOffset + VGA_DAC_WRITE_ADDR, value);
+    pci_io_write8(hwp->io, VGA_DAC_WRITE_ADDR, value);
 }
 
 static void
 stdWriteDacData(vgaHWPtr hwp, CARD8 value)
 {
-    outb(hwp->PIOOffset + VGA_DAC_DATA, value);
+    pci_io_write8(hwp->io, VGA_DAC_DATA, value);
 }
 
 static CARD8
 stdReadDacData(vgaHWPtr hwp)
 {
-    return inb(hwp->PIOOffset + VGA_DAC_DATA);
+    return pci_io_read8(hwp->io, VGA_DAC_DATA);
 }
 
 static CARD8
 stdReadEnable(vgaHWPtr hwp)
 {
-    return inb(hwp->PIOOffset + VGA_ENABLE);
+    return pci_io_read8(hwp->io, VGA_ENABLE);
 }
 
 static void
 stdWriteEnable(vgaHWPtr hwp, CARD8 value)
 {
-    outb(hwp->PIOOffset + VGA_ENABLE, value);
+    pci_io_write8(hwp->io, VGA_ENABLE, value);
 }
 
 void
@@ -353,9 +353,10 @@ vgaHWSetStdFuncs(vgaHWPtr hwp)
     hwp->writeDacReadAddr	= stdWriteDacReadAddr;
     hwp->writeDacData		= stdWriteDacData;
     hwp->readDacData		= stdReadDacData;
-    hwp->PIOOffset		= 0;
     hwp->readEnable		= stdReadEnable;
     hwp->writeEnable		= stdWriteEnable;
+
+    hwp->io = pci_legacy_open_io(hwp->dev, 0, 64 * 1024);
 }
 
 /*
@@ -1720,7 +1721,9 @@ vgaHWFreeHWRec(ScrnInfoPtr scrp)
 	vgaHWPtr hwp = VGAHWPTR(scrp);
 
 	if (!hwp)
-	    return;
+            return;
+
+        pci_device_close_io(hwp->dev, hwp->io);
 
 	free(hwp->FontInfo1);
 	free(hwp->FontInfo2);
@@ -1790,8 +1793,7 @@ vgaHWGetIOBase(vgaHWPtr hwp)
     hwp->IOBase = (hwp->readMiscOut(hwp) & 0x01) ?
 				VGA_IOBASE_COLOR : VGA_IOBASE_MONO;
     xf86DrvMsgVerb(hwp->pScrn->scrnIndex, X_INFO, 3,
-	"vgaHWGetIOBase: hwp->IOBase is 0x%04x, hwp->PIOOffset is 0x%04lx\n",
-	hwp->IOBase, hwp->PIOOffset);
+	"vgaHWGetIOBase: hwp->IOBase is 0x%04x\n", hwp->IOBase);
 }
 
 
@@ -1996,11 +1998,12 @@ SaveScreenProcPtr vgaHWSaveScreenWeak(void)
 void
 xf86GetClocks(ScrnInfoPtr pScrn, int num, Bool (*ClockFunc)(ScrnInfoPtr, int),
 	      void (*ProtectRegs)(ScrnInfoPtr, Bool),
-	      void (*BlankScreen)(ScrnInfoPtr, Bool), IOADDRESS vertsyncreg,
+	      void (*BlankScreen)(ScrnInfoPtr, Bool), unsigned long vertsyncreg,
 	      int maskval, int knownclkindex, int knownclkvalue)
 {
     register int status = vertsyncreg;
     unsigned long i, cnt, rcnt, sync;
+    vgaHWPtr hwp = VGAHWPTR(pScrn);
 
     /* First save registers that get written on */
     (*ClockFunc)(pScrn, CLK_REG_SAVE);
@@ -2027,22 +2030,22 @@ xf86GetClocks(ScrnInfoPtr pScrn, int num, Bool (*ClockFunc)(ScrnInfoPtr, int),
 	cnt  = 0;
 	sync = 200000;
 
-	while ((inb(status) & maskval) == 0x00)
+	while ((pci_io_read8(hwp->io, status) & maskval) == 0x00)
 	    if (sync-- == 0) goto finish;
 	/* Something appears to be happening, so reset sync count */
 	sync = 200000;
-	while ((inb(status) & maskval) == maskval)
+	while ((pci_io_read8(hwp->io, status) & maskval) == maskval)
 	    if (sync-- == 0) goto finish;
 	/* Something appears to be happening, so reset sync count */
 	sync = 200000;
-	while ((inb(status) & maskval) == 0x00)
+	while ((pci_io_read8(hwp->io, status) & maskval) == 0x00)
 	    if (sync-- == 0) goto finish;
 
 	for (rcnt = 0; rcnt < 5; rcnt++)
 	{
-	    while (!(inb(status) & maskval))
+	    while (!(pci_io_read8(hwp->io, status) & maskval))
 		cnt++;
-	    while ((inb(status) & maskval))
+	    while ((pci_io_read8(hwp->io, status) & maskval))
 		cnt++;
 	}
 
diff --git a/hw/xfree86/vgahw/vgaHW.h b/hw/xfree86/vgahw/vgaHW.h
index 12cfac0..e943aa3 100644
--- a/hw/xfree86/vgahw/vgaHW.h
+++ b/hw/xfree86/vgahw/vgaHW.h
@@ -151,17 +151,13 @@ typedef struct _vgaHWRec {
     vgaHWWriteProcPtr		writeDacData;
     vgaHWReadProcPtr		readDacData;
     pointer                     ddc;
-    IOADDRESS			PIOOffset;	/* offset + vgareg
-						   = pioreg */
+    struct pci_io_handle        *io;
     vgaHWReadProcPtr		readEnable;
     vgaHWWriteProcPtr		writeEnable;
     struct pci_device          *dev;
 } vgaHWRec;
 
 /* Some macros that VGA drivers can use in their ChipProbe() function */
-#define VGAHW_GET_IOBASE()	((inb(VGA_MISC_OUT_R) & 0x01) ?		      \
-					 VGA_IOBASE_COLOR : VGA_IOBASE_MONO)
-
 #define OVERSCAN 0x11		/* Index of OverScan register */
 
 /* Flags that define how overscan correction should take place */
@@ -174,15 +170,11 @@ typedef struct _vgaHWRec {
 #define BITS_PER_GUN 6
 #define COLORMAP_SIZE 256
 
-#if defined(__powerpc__) || defined(__arm__) || defined(__s390__) || defined(__nds32__)
-#define DACDelay(hw) /* No legacy VGA support */
-#else
-#define DACDelay(hw)							      \
-	do {								      \
-	    (void)inb((hw)->PIOOffset + (hw)->IOBase + VGA_IN_STAT_1_OFFSET); \
-	    (void)inb((hw)->PIOOffset + (hw)->IOBase + VGA_IN_STAT_1_OFFSET); \
+#define DACDelay(hw)							 \
+	do {								 \
+	    pci_io_read8((hw)->io, (hw)->IOBase + VGA_IN_STAT_1_OFFSET); \
+	    pci_io_read8((hw)->io, (hw)->IOBase + VGA_IN_STAT_1_OFFSET); \
 	} while (0)
-#endif
 
 /* Function Prototypes */
 
@@ -235,7 +227,7 @@ extern _X_EXPORT void xf86GetClocks(ScrnInfoPtr pScrn, int num,
 		   Bool (*ClockFunc)(ScrnInfoPtr, int),
 		   void (*ProtectRegs)(ScrnInfoPtr, Bool),
 		   void (*BlankScreen)(ScrnInfoPtr, Bool),
-		   IOADDRESS vertsyncreg, int maskval,
+		   unsigned long vertsyncreg, int maskval,
 		   int knownclkindex, int knownclkvalue);
 
 #endif /* _VGAHW_H */
commit 4748e4cf490f76fd89fbf605d24df3df74828813
Author: Adam Jackson <ajax at redhat.com>
Date:   Tue Sep 20 18:06:25 2011 -0400

    vgahw: Don't default to standard (port space) access routines
    
    In fact, don't default to anything; drivers must explicitly say which
    kind they want, and they are strongly encouraged to do MMIO if possible.
    This is an ABI change in that drivers that don't will crash, but drivers
    that are explicit will work with both old and new servers.
    
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/hw/xfree86/vgahw/vgaHW.c b/hw/xfree86/vgahw/vgaHW.c
index 2ecea1c..6c0e635 100644
--- a/hw/xfree86/vgahw/vgaHW.c
+++ b/hw/xfree86/vgahw/vgaHW.c
@@ -1706,9 +1706,6 @@ vgaHWGetHWRec(ScrnInfoPtr scrp)
     hwp->MapSize = 0;
     hwp->pScrn = scrp;
 
-    /* Initialise the function pointers with the standard VGA versions */
-    vgaHWSetStdFuncs(hwp);
-
     hwp->PIOOffset = scrp->domainIOBase;
     hwp->dev = xf86GetPciInfoForEntity(scrp->entityList[0]);
 
commit 9589ab67e665ea903d73a8bcaf1c683e451ca9d7
Author: Adam Jackson <ajax at redhat.com>
Date:   Sat Sep 18 08:24:19 2010 -0400

    int10: Port to pciaccess' legacy IO API
    
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/hw/xfree86/int10/generic.c b/hw/xfree86/int10/generic.c
index 9940854..beb90b5 100644
--- a/hw/xfree86/int10/generic.c
+++ b/hw/xfree86/int10/generic.c
@@ -297,7 +297,7 @@ MapVRam(xf86Int10InfoPtr pInt)
     INTPriv(pInt)->vRam = xf86MapDomainMemory(pInt->scrnIndex, VIDMEM_MMIO,
 					      pInt->dev, V_RAM, size);
 
-    pInt->ioBase = xf86Screens[pInt->scrnIndex]->domainIOBase;
+    pInt->io = pci_legacy_open_io(pInt->dev, 0, 64 * 1024);
 }
 
 static void
@@ -308,6 +308,9 @@ UnmapVRam(xf86Int10InfoPtr pInt)
     int size = ((VRAM_SIZE + pagesize - 1)/pagesize) * pagesize;
 
     xf86UnMapVidMem(screen, INTPriv(pInt)->vRam, size);
+
+    pci_device_close_io(pInt->dev, pInt->io);
+    pInt->io = NULL;
 }
 
 Bool
diff --git a/hw/xfree86/int10/helper_exec.c b/hw/xfree86/int10/helper_exec.c
index 2efbdc5..fc218a9 100644
--- a/hw/xfree86/int10/helper_exec.c
+++ b/hw/xfree86/int10/helper_exec.c
@@ -331,7 +331,7 @@ x_inb(CARD16 port)
 	}
 #endif /* __NOT_YET__ */
     } else if (!pciCfg1inb(port, &val)) {
-	val = inb(Int10Current->ioBase + port);
+	val = pci_io_read8(Int10Current->io, port);
 	if (PRINT_PORT && DEBUG_IO_TRACE())
 	    ErrorF(" inb(%#x) = %2.2x\n", port, val);
     }
@@ -353,7 +353,7 @@ x_inw(CARD16 port)
 	X_GETTIMEOFDAY(&tv);
 	val = (CARD16)(tv.tv_usec / 3);
     } else if (!pciCfg1inw(port, &val)) {
-	val = inw(Int10Current->ioBase + port);
+	val = pci_io_read16(Int10Current->io, port);
 	if (PRINT_PORT && DEBUG_IO_TRACE())
 	    ErrorF(" inw(%#x) = %4.4x\n", port, val);
     }
@@ -387,7 +387,7 @@ x_outb(CARD16 port, CARD8 val)
     } else if (!pciCfg1outb(port, val)) {
 	if (PRINT_PORT && DEBUG_IO_TRACE())
 	    ErrorF(" outb(%#x, %2.2x)\n", port, val);
-	outb(Int10Current->ioBase + port, val);
+	pci_io_write8(Int10Current->io, port, val);
     }
 }
 
@@ -398,7 +398,7 @@ x_outw(CARD16 port, CARD16 val)
     if (!pciCfg1outw(port, val)) {
 	if (PRINT_PORT && DEBUG_IO_TRACE())
 	    ErrorF(" outw(%#x, %4.4x)\n", port, val);
-	outw(Int10Current->ioBase + port, val);
+	pci_io_write16(Int10Current->io, port, val);
     }
 }
 
@@ -408,7 +408,7 @@ x_inl(CARD16 port)
     CARD32 val;
 
     if (!pciCfg1in(port, &val)) {
-	val = inl(Int10Current->ioBase + port);
+	val = pci_io_read32(Int10Current->io, port);
 	if (PRINT_PORT && DEBUG_IO_TRACE())
 	    ErrorF(" inl(%#x) = %8.8lx\n", port, val);
     }
@@ -421,7 +421,7 @@ x_outl(CARD16 port, CARD32 val)
     if (!pciCfg1out(port, val)) {
 	if (PRINT_PORT && DEBUG_IO_TRACE())
 	    ErrorF(" outl(%#x, %8.8lx)\n", port, val);
-	outl(Int10Current->ioBase + port, val);
+	pci_io_write32(Int10Current->io, port, val);
     }
 }
 
@@ -650,29 +650,29 @@ bios_checksum(const CARD8 *start, int size)
 void
 LockLegacyVGA(xf86Int10InfoPtr pInt, legacyVGAPtr vga)
 {
-    vga->save_msr    = inb(pInt->ioBase + 0x03CC);
-    vga->save_vse    = inb(pInt->ioBase + 0x03C3);
+    vga->save_msr    = pci_io_read8(pInt->io, 0x03CC);
+    vga->save_vse    = pci_io_read8(pInt->io, 0x03C3);
 #ifndef __ia64__
-    vga->save_46e8   = inb(pInt->ioBase + 0x46E8);
+    vga->save_46e8   = pci_io_read8(pInt->io, 0x46E8);
 #endif
-    vga->save_pos102 = inb(pInt->ioBase + 0x0102);
-    outb(pInt->ioBase + 0x03C2, ~(CARD8)0x03 & vga->save_msr);
-    outb(pInt->ioBase + 0x03C3, ~(CARD8)0x01 & vga->save_vse);
+    vga->save_pos102 = pci_io_read8(pInt->io, 0x0102);
+    pci_io_write8(pInt->io, 0x03C2, ~(CARD8)0x03 & vga->save_msr);
+    pci_io_write8(pInt->io, 0x03C3, ~(CARD8)0x01 & vga->save_vse);
 #ifndef __ia64__
-    outb(pInt->ioBase + 0x46E8, ~(CARD8)0x08 & vga->save_46e8);
+    pci_io_write8(pInt->io, 0x46E8, ~(CARD8)0x08 & vga->save_46e8);
 #endif
-    outb(pInt->ioBase + 0x0102, ~(CARD8)0x01 & vga->save_pos102);
+    pci_io_write8(pInt->io, 0x0102, ~(CARD8)0x01 & vga->save_pos102);
 }
 
 void
 UnlockLegacyVGA(xf86Int10InfoPtr pInt, legacyVGAPtr vga)
 {
-    outb(pInt->ioBase + 0x0102, vga->save_pos102);
+    pci_io_write8(pInt->io, 0x0102, vga->save_pos102);
 #ifndef __ia64__
-    outb(pInt->ioBase + 0x46E8, vga->save_46e8);
+    pci_io_write8(pInt->io, 0x46E8, vga->save_46e8);
 #endif
-    outb(pInt->ioBase + 0x03C3, vga->save_vse);
-    outb(pInt->ioBase + 0x03C2, vga->save_msr);
+    pci_io_write8(pInt->io, 0x03C3, vga->save_vse);
+    pci_io_write8(pInt->io, 0x03C2, vga->save_msr);
 }
 
 #if defined (_PC)
diff --git a/hw/xfree86/int10/xf86int10.c b/hw/xfree86/int10/xf86int10.c
index 51eb91f..dd00e54 100644
--- a/hw/xfree86/int10/xf86int10.c
+++ b/hw/xfree86/int10/xf86int10.c
@@ -84,7 +84,7 @@ int42_handler(xf86Int10InfoPtr pInt)
 	/* Leave:  Nothing                                    */
 	/* Implemented (except for clearing the screen)       */
 	{                                         /* Localise */
-	    IOADDRESS ioport;
+	    unsigned int ioport;
 	    int i;
 	    CARD16 int1d, regvals, tmp;
 	    CARD8 mode, cgamode, cgacolour;
@@ -172,18 +172,15 @@ int42_handler(xf86Int10InfoPtr pInt)
 	    /* Rows */
 	    MEM_WB(pInt, 0x0484, (25 - 1));
 
-	    /* Remap I/O port number into its domain */
-	    ioport += pInt->ioBase;
-
-	    /* Programme the mode */
-	    outb(ioport + 4, cgamode & 0x37);   /* Turn off screen */
+	    /* Program the mode */
+	    pci_io_write8(pInt->io, ioport + 4, cgamode & 0x37);   /* Turn off screen */
 	    for (i = 0; i < 0x10; i++) {
 		tmp = MEM_RB(pInt, regvals + i);
-		outb(ioport, i);
-		outb(ioport + 1, tmp);
+		pci_io_write8(pInt->io, ioport, i);
+		pci_io_write8(pInt->io, ioport + 1, tmp);
 	    }
-	    outb(ioport + 5, cgacolour);        /* Select colour mode */
-	    outb(ioport + 4, cgamode);          /* Turn on screen */
+	    pci_io_write8(pInt->io, ioport + 5, cgacolour);        /* Select colour mode */
+	    pci_io_write8(pInt->io, ioport + 4, cgamode);          /* Turn on screen */
 	}
 	break;
 
@@ -194,15 +191,15 @@ int42_handler(xf86Int10InfoPtr pInt)
 	/* Leave:  Nothing                                    */
 	/* Implemented                                        */
 	{                                         /* Localise */
-	    IOADDRESS ioport = MEM_RW(pInt, 0x0463) + pInt->ioBase;
+	    unsigned int ioport = MEM_RW(pInt, 0x0463);
 
 	    MEM_WB(pInt, 0x0460, X86_CL);
 	    MEM_WB(pInt, 0x0461, X86_CH);
 
-	    outb(ioport, 0x0A);
-	    outb(ioport + 1, X86_CH);
-	    outb(ioport, 0x0B);
-	    outb(ioport + 1, X86_CL);
+	    pci_io_write8(pInt->io, ioport, 0x0A);
+	    pci_io_write8(pInt->io, ioport + 1, X86_CH);
+	    pci_io_write8(pInt->io, ioport, 0x0B);
+	    pci_io_write8(pInt->io, ioport + 1, X86_CL);
 	}
 	break;
 
@@ -214,7 +211,7 @@ int42_handler(xf86Int10InfoPtr pInt)
 	/* Leave:  Nothing                                    */
 	/* Implemented                                        */
 	{                                         /* Localise */
-	    IOADDRESS ioport;
+	    unsigned int ioport;
 	    CARD16 offset;
 
 	    MEM_WB(pInt, (X86_BH << 1) + 0x0450, X86_DL);
@@ -226,11 +223,11 @@ int42_handler(xf86Int10InfoPtr pInt)
 	    offset = (X86_DH * MEM_RW(pInt, 0x044A)) + X86_DL;
 	    offset += MEM_RW(pInt, 0x044E) << 1;
 
-	    ioport = MEM_RW(pInt, 0x0463) + pInt->ioBase;
-	    outb(ioport, 0x0E);
-	    outb(ioport + 1, offset >> 8);
-	    outb(ioport, 0x0F);
-	    outb(ioport + 1, offset & 0xFF);
+	    ioport = MEM_RW(pInt, 0x0463);
+	    pci_io_write8(pInt->io, ioport, 0x0E);
+	    pci_io_write8(pInt->io, ioport + 1, offset >> 8);
+	    pci_io_write8(pInt->io, ioport, 0x0F);
+	    pci_io_write8(pInt->io, ioport + 1, offset & 0xFF);
 	}
 	break;
 
@@ -276,7 +273,7 @@ int42_handler(xf86Int10InfoPtr pInt)
 	/* Leave:  Nothing                                    */
 	/* Implemented                                        */
 	{                                         /* Localise */
-	    IOADDRESS ioport = MEM_RW(pInt, 0x0463) + pInt->ioBase;
+	    unsigned int ioport = MEM_RW(pInt, 0x0463);
 	    CARD16 start;
 	    CARD8 x, y;
 
@@ -287,10 +284,10 @@ int42_handler(xf86Int10InfoPtr pInt)
 	    start <<= 1;
 
 	    /* Update start address */
-	    outb(ioport, 0x0C);
-	    outb(ioport + 1, start >> 8);
-	    outb(ioport, 0x0D);
-	    outb(ioport + 1, start & 0xFF);
+	    pci_io_write8(pInt->io, ioport, 0x0C);
+	    pci_io_write8(pInt->io, ioport + 1, start >> 8);
+	    pci_io_write8(pInt->io, ioport, 0x0D);
+	    pci_io_write8(pInt->io, ioport + 1, start & 0xFF);
 
 	    /* Switch cursor position */
 	    y = MEM_RB(pInt, (X86_AL << 1) + 0x0450);
@@ -298,10 +295,10 @@ int42_handler(xf86Int10InfoPtr pInt)
 	    start += (y * MEM_RW(pInt, 0x044A)) + x;
 
 	    /* Update cursor position */
-	    outb(ioport, 0x0E);
-	    outb(ioport + 1, start >> 8);
-	    outb(ioport, 0x0F);
-	    outb(ioport + 1, start & 0xFF);
+	    pci_io_write8(pInt->io, ioport, 0x0E);
+	    pci_io_write8(pInt->io, ioport + 1, start >> 8);
+	    pci_io_write8(pInt->io, ioport, 0x0F);
+	    pci_io_write8(pInt->io, ioport + 1, start & 0xFF);
 	}
 	break;
 
@@ -426,7 +423,7 @@ int42_handler(xf86Int10InfoPtr pInt)
 	/* Leave:  Nothing                                    */
 	/* Implemented                                        */
 	{                                         /* Localise */
-	    IOADDRESS ioport = MEM_RW(pInt, 0x0463) + 5 + pInt->ioBase;
+	    unsigned int ioport = MEM_RW(pInt, 0x0463) + 5;
 	    CARD8 cgacolour = MEM_RB(pInt, 0x0466);
 
 	    if (X86_BH) {
@@ -438,7 +435,7 @@ int42_handler(xf86Int10InfoPtr pInt)
 	    }
 
 	    MEM_WB(pInt, 0x0466, cgacolour);
-	    outb(ioport, cgacolour);
+	    pci_io_write8(pInt->io, ioport, cgacolour);
 	}
 	break;
 
diff --git a/hw/xfree86/int10/xf86int10.h b/hw/xfree86/int10/xf86int10.h
index ba9ee52..5bf326e 100644
--- a/hw/xfree86/int10/xf86int10.h
+++ b/hw/xfree86/int10/xf86int10.h
@@ -41,7 +41,7 @@ typedef struct {
     int flags;
     int stackseg;
     struct pci_device *dev;
-    IOADDRESS ioBase;
+    struct pci_io_handle *io;
 } xf86Int10InfoRec, *xf86Int10InfoPtr;
 
 typedef struct _int10Mem {
commit bdc5e82efe2cf341ec43c48b8556b1a9d7f66140
Author: Adam Jackson <ajax at redhat.com>
Date:   Sat Sep 18 08:05:11 2010 -0400

    xfree86: Move xf86GetClocks to vgahw
    
    This is really a vga-specific hack anyway.  The only modern driver that
    uses it is trident, but it's already loaded vgahw by the time it would
    call xf86GetClocks.
    
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/hw/xfree86/common/xf86.h b/hw/xfree86/common/xf86.h
index e1e0cd7..b1a5ab2 100644
--- a/hw/xfree86/common/xf86.h
+++ b/hw/xfree86/common/xf86.h
@@ -239,12 +239,6 @@ extern _X_EXPORT void xf86ShowClocks(ScrnInfoPtr scrp, MessageType from);
 extern _X_EXPORT void xf86PrintChipsets(const char *drvname, const char *drvmsg,
 		       SymTabPtr chips);
 extern _X_EXPORT int xf86MatchDevice(const char *drivername, GDevPtr **driversectlist);
-extern _X_EXPORT void xf86GetClocks(ScrnInfoPtr pScrn, int num,
-		   Bool (*ClockFunc)(ScrnInfoPtr, int),
-		   void (*ProtectRegs)(ScrnInfoPtr, Bool),
-		   void (*BlankScreen)(ScrnInfoPtr, Bool),
-		   IOADDRESS vertsyncreg, int maskval,
-		   int knownclkindex, int knownclkvalue);
 extern _X_EXPORT const char *xf86GetVisualName(int visual);
 extern _X_EXPORT int xf86GetVerbosity(void);
 extern _X_EXPORT Pix24Flags xf86GetPix24(void);
diff --git a/hw/xfree86/common/xf86Helper.c b/hw/xfree86/common/xf86Helper.c
index 7c76fa8..c410f1a 100644
--- a/hw/xfree86/common/xf86Helper.c
+++ b/hw/xfree86/common/xf86Helper.c
@@ -1366,96 +1366,6 @@ xf86MatchDevice(const char *drivername, GDevPtr **sectlist)
     return i;
 }
 
-/*
- * xf86GetClocks -- get the dot-clocks via a BIG BAD hack ...
- */
-void
-xf86GetClocks(ScrnInfoPtr pScrn, int num, Bool (*ClockFunc)(ScrnInfoPtr, int),
-	      void (*ProtectRegs)(ScrnInfoPtr, Bool),
-	      void (*BlankScreen)(ScrnInfoPtr, Bool), IOADDRESS vertsyncreg,
-	      int maskval, int knownclkindex, int knownclkvalue)
-{
-    register int status = vertsyncreg;
-    unsigned long i, cnt, rcnt, sync;
-
-    /* First save registers that get written on */
-    (*ClockFunc)(pScrn, CLK_REG_SAVE);
-
-    if (num > MAXCLOCKS)
-	num = MAXCLOCKS;
-
-    for (i = 0; i < num; i++)
-    {
-	if (ProtectRegs)
-	    (*ProtectRegs)(pScrn, TRUE);
-	if (!(*ClockFunc)(pScrn, i))
-	{
-	    pScrn->clock[i] = -1;
-	    continue;
-	}
-	if (ProtectRegs)
-	    (*ProtectRegs)(pScrn, FALSE);
-	if (BlankScreen)
-	    (*BlankScreen)(pScrn, FALSE);
-
-    	usleep(50000);     /* let VCO stabilise */
-
-    	cnt  = 0;
-    	sync = 200000;
-
-	while ((inb(status) & maskval) == 0x00)
-	    if (sync-- == 0) goto finish;
-	/* Something appears to be happening, so reset sync count */
-	sync = 200000;
-	while ((inb(status) & maskval) == maskval)
-	    if (sync-- == 0) goto finish;
-	/* Something appears to be happening, so reset sync count */
-	sync = 200000;
-	while ((inb(status) & maskval) == 0x00)
-	    if (sync-- == 0) goto finish;
-
-	for (rcnt = 0; rcnt < 5; rcnt++)
-	{
-	    while (!(inb(status) & maskval))
-		cnt++;
-	    while ((inb(status) & maskval))
-		cnt++;
-	}
-
-finish:
-	pScrn->clock[i] = cnt ? cnt : -1;
-	if (BlankScreen)
-            (*BlankScreen)(pScrn, TRUE);
-    }
-
-    for (i = 0; i < num; i++)
-    {
-	if (i != knownclkindex)
-	{
-	    if (pScrn->clock[i] == -1)
-	    {
-		pScrn->clock[i] = 0;
-	    }
-	    else
-	    {
-		pScrn->clock[i] = (int)(0.5 +
-                    (((float)knownclkvalue) * pScrn->clock[knownclkindex]) /
-	            (pScrn->clock[i]));
-		/* Round to nearest 10KHz */
-		pScrn->clock[i] += 5;
-		pScrn->clock[i] /= 10;
-		pScrn->clock[i] *= 10;
-	    }
-	}
-    }
-
-    pScrn->clock[knownclkindex] = knownclkvalue;
-    pScrn->numClocks = num;
-
-    /* Restore registers that were written on */
-    (*ClockFunc)(pScrn, CLK_REG_RESTORE);
-}
-
 const char *
 xf86GetVisualName(int visual)
 {
diff --git a/hw/xfree86/vgahw/vgaHW.c b/hw/xfree86/vgahw/vgaHW.c
index ee045d1..2ecea1c 100644
--- a/hw/xfree86/vgahw/vgaHW.c
+++ b/hw/xfree86/vgahw/vgaHW.c
@@ -1992,3 +1992,93 @@ SaveScreenProcPtr vgaHWSaveScreenWeak(void)
 {
     return vgaHWSaveScreen;
 }
+
+/*
+ * xf86GetClocks -- get the dot-clocks via a BIG BAD hack ...
+ */
+void
+xf86GetClocks(ScrnInfoPtr pScrn, int num, Bool (*ClockFunc)(ScrnInfoPtr, int),
+	      void (*ProtectRegs)(ScrnInfoPtr, Bool),
+	      void (*BlankScreen)(ScrnInfoPtr, Bool), IOADDRESS vertsyncreg,
+	      int maskval, int knownclkindex, int knownclkvalue)
+{
+    register int status = vertsyncreg;
+    unsigned long i, cnt, rcnt, sync;
+
+    /* First save registers that get written on */
+    (*ClockFunc)(pScrn, CLK_REG_SAVE);
+
+    if (num > MAXCLOCKS)
+	num = MAXCLOCKS;
+
+    for (i = 0; i < num; i++)
+    {
+	if (ProtectRegs)
+	    (*ProtectRegs)(pScrn, TRUE);
+	if (!(*ClockFunc)(pScrn, i))
+	{
+	    pScrn->clock[i] = -1;
+	    continue;
+	}
+	if (ProtectRegs)
+	    (*ProtectRegs)(pScrn, FALSE);
+	if (BlankScreen)
+	    (*BlankScreen)(pScrn, FALSE);
+
+	usleep(50000);     /* let VCO stabilise */
+
+	cnt  = 0;
+	sync = 200000;
+
+	while ((inb(status) & maskval) == 0x00)
+	    if (sync-- == 0) goto finish;
+	/* Something appears to be happening, so reset sync count */
+	sync = 200000;
+	while ((inb(status) & maskval) == maskval)
+	    if (sync-- == 0) goto finish;
+	/* Something appears to be happening, so reset sync count */
+	sync = 200000;
+	while ((inb(status) & maskval) == 0x00)
+	    if (sync-- == 0) goto finish;
+
+	for (rcnt = 0; rcnt < 5; rcnt++)
+	{
+	    while (!(inb(status) & maskval))
+		cnt++;
+	    while ((inb(status) & maskval))
+		cnt++;
+	}
+
+finish:
+	pScrn->clock[i] = cnt ? cnt : -1;
+	if (BlankScreen)
+            (*BlankScreen)(pScrn, TRUE);
+    }
+
+    for (i = 0; i < num; i++)
+    {
+	if (i != knownclkindex)
+	{
+	    if (pScrn->clock[i] == -1)
+	    {
+		pScrn->clock[i] = 0;
+	    }
+	    else
+	    {
+		pScrn->clock[i] = (int)(0.5 +
+                    (((float)knownclkvalue) * pScrn->clock[knownclkindex]) /
+	            (pScrn->clock[i]));
+		/* Round to nearest 10KHz */
+		pScrn->clock[i] += 5;
+		pScrn->clock[i] /= 10;
+		pScrn->clock[i] *= 10;
+	    }
+	}
+    }
+
+    pScrn->clock[knownclkindex] = knownclkvalue;
+    pScrn->numClocks = num;
+
+    /* Restore registers that were written on */
+    (*ClockFunc)(pScrn, CLK_REG_RESTORE);
+}
diff --git a/hw/xfree86/vgahw/vgaHW.h b/hw/xfree86/vgahw/vgaHW.h
index b31c007..12cfac0 100644
--- a/hw/xfree86/vgahw/vgaHW.h
+++ b/hw/xfree86/vgahw/vgaHW.h
@@ -231,5 +231,11 @@ extern _X_EXPORT Bool vgaHWAllocDefaultRegs(vgaRegPtr regp);
 
 extern _X_EXPORT DDC1SetSpeedProc vgaHWddc1SetSpeedWeak(void);
 extern _X_EXPORT SaveScreenProcPtr vgaHWSaveScreenWeak(void);
+extern _X_EXPORT void xf86GetClocks(ScrnInfoPtr pScrn, int num,
+		   Bool (*ClockFunc)(ScrnInfoPtr, int),
+		   void (*ProtectRegs)(ScrnInfoPtr, Bool),
+		   void (*BlankScreen)(ScrnInfoPtr, Bool),
+		   IOADDRESS vertsyncreg, int maskval,
+		   int knownclkindex, int knownclkvalue);
 
 #endif /* _VGAHW_H */
commit 6c9bce39f68f6b94bc17f489bc51d97d0f307e82
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Tue Sep 20 20:39:06 2011 -0700

    XQuartz: Use set_front_process rather than X11ApplicationSetFrontProcess since we're already in the AppKit thread
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index 7fd7dab..12ff53c 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -356,7 +356,7 @@ static void message_kit_thread (SEL selector, NSObject *arg) {
                          */
                         _appFlags._active = YES;
 
-                        X11ApplicationSetFrontProcess();
+                        [self set_front_process:nil];
 
                         /* Get the Spaces preference for SwitchOnActivate */
                         (void)CFPreferencesAppSynchronize(CFSTR("com.apple.dock"));
commit 98f4940093dc90c3366d3e4d3ddceacbaee299dc
Merge: b018b81... c8eacae...
Author: Keith Packard <keithp at keithp.com>
Date:   Wed Sep 21 14:30:19 2011 -0700

    Merge remote-tracking branch 'alanc/master'

commit b018b815333b256b5e06dd6251b2e539f09f89fa
Merge: 03d0329... 0f380a5...
Author: Keith Packard <keithp at keithp.com>
Date:   Wed Sep 21 14:17:14 2011 -0700

    Merge remote-tracking branch 'jamey/reviewed'

commit 03d032991da21bf866ca30dcbb6b7f9f99df441a
Author: Aaron Plattner <aplattner at nvidia.com>
Date:   Wed Sep 14 15:25:06 2011 -0700

    fb: Rename wfbTriangles and wfbTrapezoids
    
    These symbols were not renamed when they were added to libfb:
    
     # nm -D libwfb.so | grep ' fb'
     0000000000028d00 T fbTrapezoids
     0000000000028d60 T fbTriangles
    
    This causes corruption and/or crashes on wfb-ful drivers like nvidia:
    
     Program received signal SIGABRT, Aborted.
     0x00007fd67f3a0405 in *__GI_raise (sig=<optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
     64      ../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory.
         in ../nptl/sysdeps/unix/sysv/linux/raise.c
     (gdb) bt
     #0  0x00007fd67f3a0405 in *__GI_raise (sig=<optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
     #1  0x00007fd67f3a3680 in *__GI_abort () at abort.c:92
     #2  0x00007fd67f3995b1 in *__GI___assert_fail (assertion=0x7fd679ecb804 "key->initialized", file=<optimized out>, line=116, function=0x7fd679ecbbc0 "dixGetPrivateAddr")
         at assert.c:81
     #3  0x00007fd679ec55b6 in ?? () from /usr/lib/xorg/modules/libfb.so
     #4  0x00007fd679eca9ef in ?? () from /usr/lib/xorg/modules/libfb.so
     #5  0x00007fd679ecae20 in fbTriangles () from /usr/lib/xorg/modules/libfb.so
     #6  0x00007fd67a58fc55 in ?? () from /usr/lib/xorg/modules/drivers/nvidia_drv.so
     #7  0x00000000004f38d1 in ?? ()
     #8  0x0000000000437ae9 in ?? ()
     #9  0x0000000000426eaa in ?? ()
     #10 0x00007fd67f38cead in __libc_start_main (main=<optimized out>, argc=<optimized out>, ubp_av=<optimized out>, init=<optimized out>, fini=<optimized out>,
         rtld_fini=<optimized out>, stack_end=0x7fff99860d78) at libc-start.c:228
     #11 0x000000000042719d in _start ()
    
    Signed-off-by: Aaron Plattner <aplattner at nvidia.com>
    Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/fb/wfbrename.h b/fb/wfbrename.h
index e855edd..8b896eb 100644
--- a/fb/wfbrename.h
+++ b/fb/wfbrename.h
@@ -160,6 +160,8 @@
 #define fbStippleTable wfbStippleTable
 #define fbTile wfbTile
 #define fbTransparentSpan wfbTransparentSpan
+#define fbTrapezoids wfbTrapezoids
+#define fbTriangles wfbTriangles
 #define fbUninstallColormap wfbUninstallColormap
 #define fbUnmapWindow wfbUnmapWindow
 #define fbUnrealizeFont wfbUnrealizeFont
commit c8eacae4f833a0bd81907ba2b4cfaa80c08e037f
Author: Alan Coopersmith <alan.coopersmith at oracle.com>
Date:   Thu Aug 25 21:46:16 2011 -0700

    Space & style cleanup of hw/xfree86/i2c/fi1236.c
    
    Fortunately, the massive decrease in the cost of whitespace in the past
    decade has allowed us to be much more generous with it, and much more
    consistent in its application, even for code like this that clearly no
    one has ever tried to read.
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
    Reviewed-by: Jamey Sharp <jamey at minilop.net>

diff --git a/hw/xfree86/i2c/fi1236.c b/hw/xfree86/i2c/fi1236.c
index 8337c90..0bc50e5 100644
--- a/hw/xfree86/i2c/fi1236.c
+++ b/hw/xfree86/i2c/fi1236.c
@@ -1,4 +1,3 @@
-
 #ifdef HAVE_XORG_CONFIG_H
 #include <xorg-config.h>
 #endif
@@ -19,587 +18,658 @@
 const FI1236_parameters tuner_parms[NUM_TUNERS] =
 {
     /* 0 - FI1236 */
-    { 733 ,884 ,12820 ,2516 ,7220 ,0xA2 ,0x94, 0x34, 0x8e },
+    { 733, 884, 12820, 2516, 7220, 0xA2, 0x94, 0x34, 0x8e },
     /* !!!based on documentation - it should be:
-    {733 ,16*55.25 ,16*801.25 ,16*160 ,16*454 ,0xA0 ,0x90, 0x30, 0x8e},*/
-    
+    {733, 16*55.25, 16*801.25, 16*160, 16*454, 0xA0, 0x90, 0x30, 0x8e},*/
+
     /* 1 - FI1216 */
-    { 623 ,16*48.75 ,16*855.25 ,16*170 ,16*450 ,0xA0 ,0x90, 0x30, 0x8e },
+    { 623, 16*48.75, 16*855.25, 16*170, 16*450, 0xA0, 0x90, 0x30, 0x8e },
     /* 2 - TEMIC FN5AL */
-    { 623 ,16*45.75 ,16*855.25 ,16*169 ,16*454 ,0xA0 ,0x90, 0x30, 0x8e },
+    { 623, 16*45.75, 16*855.25, 16*169, 16*454, 0xA0, 0x90, 0x30, 0x8e },
     /* 3 - MT2032.. */
-    { 733 ,768 ,13760 , 0 , 0 , 0 , 0,  0, 0 },
+    { 733, 768, 13760,  0,  0,  0,  0,  0, 0 },
     /* 4 - FI1246 */
-    { 623 ,16*45.75 ,16*855.25 ,16*170 ,16*450 ,0xA0 ,0x90, 0x30, 0x8e },
+    { 623, 16*45.75, 16*855.25, 16*170, 16*450, 0xA0, 0x90, 0x30, 0x8e },
     /* 5 - FI1256 */
-    { 623 ,16*49.75 ,16*863.25 ,16*170 ,16*450 ,0xA0 ,0x90, 0x30, 0x8e },
+    { 623, 16*49.75, 16*863.25, 16*170, 16*450, 0xA0, 0x90, 0x30, 0x8e },
     /* 6 - FI1236W */
-    /*{ 733 ,884 ,12820 ,2516 ,7220 ,0x1 ,0x2, 0x4, 0x8e },*/
+    /*{ 733, 884, 12820, 2516, 7220, 0x1, 0x2, 0x4, 0x8e },*/
     { 732, 16*55.25, 16*801.25, 16*160, 16*442, 0x1, 0x2, 0x4, 0x8e },
-	 /* 7 - FM1216ME */
-    { 623 ,16*48.25 ,16*863.25 ,16*158.00 ,16*442.00 ,0x1 ,0x2, 0x4, 0x8e }
+    /* 7 - FM1216ME */
+    { 623, 16*48.25, 16*863.25, 16*158.00, 16*442.00, 0x1, 0x2, 0x4, 0x8e }
 };
 
 
-FI1236Ptr Detect_FI1236(I2CBusPtr b, I2CSlaveAddr addr)
+FI1236Ptr
+Detect_FI1236 (I2CBusPtr b, I2CSlaveAddr addr)
 {
-   FI1236Ptr f;
-   I2CByte a;
-
-   f = calloc(1,sizeof(FI1236Rec));
-   if(f == NULL) return NULL;
-   f->d.DevName = strdup("FI12xx Tuner");
-   f->d.SlaveAddr = addr;
-   f->d.pI2CBus = b;
-   f->d.NextDev = NULL;
-   f->d.StartTimeout = b->StartTimeout;
-   f->d.BitTimeout = b->BitTimeout;
-   f->d.AcknTimeout = b->AcknTimeout;
-   f->d.ByteTimeout = b->ByteTimeout;
-   f->type=TUNER_TYPE_FI1236;
-   f->afc_timer_installed=FALSE;
-   f->last_afc_hint=TUNER_OFF;
-   f->video_if=45.7812;
-  
-   if(!I2C_WriteRead(&(f->d), NULL, 0, &a, 1))
-   {
-   	free(f);
-	return NULL;
+    FI1236Ptr f;
+    I2CByte a;
+
+    f = calloc(1,sizeof(FI1236Rec));
+    if (f == NULL)
+        return NULL;
+    f->d.DevName = strdup("FI12xx Tuner");
+    f->d.SlaveAddr = addr;
+    f->d.pI2CBus = b;
+    f->d.NextDev = NULL;
+    f->d.StartTimeout = b->StartTimeout;
+    f->d.BitTimeout = b->BitTimeout;
+    f->d.AcknTimeout = b->AcknTimeout;
+    f->d.ByteTimeout = b->ByteTimeout;
+    f->type=TUNER_TYPE_FI1236;
+    f->afc_timer_installed=FALSE;
+    f->last_afc_hint=TUNER_OFF;
+    f->video_if=45.7812;
+
+    if (!I2C_WriteRead(&(f->d), NULL, 0, &a, 1)) {
+        free(f);
+        return NULL;
     }
     FI1236_set_tuner_type(f, TUNER_TYPE_FI1236);
-    if(!I2CDevInit(&(f->d)))
-    {
-       free(f);
-       return NULL;
+    if (!I2CDevInit(&(f->d))) {
+        free(f);
+        return NULL;
     }
     return f;
 }
 
-static void MT2032_dump_parameters(FI1236Ptr f, MT2032_parameters *m)
+static void
+MT2032_dump_parameters (FI1236Ptr f, MT2032_parameters *m)
 {
-xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO, "MT2032: input f_rf=%g f_if1=%g f_if2=%g f_ref=%g f_ifbw=%g f_step=%g\n", 
-	m->f_rf, m->f_if1, m->f_if2, m->f_ref, m->f_ifbw, m->f_step);
+    xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO,
+               "MT2032: input f_rf=%g f_if1=%g f_if2=%g f_ref=%g f_ifbw=%g f_step=%g\n",
+               m->f_rf, m->f_if1, m->f_if2, m->f_ref, m->f_ifbw, m->f_step);
 
-xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO, "MT2032: computed f_lo1=%g f_lo2=%g LO1I=%d LO2I=%d SEL=%d STEP=%d NUM=%d\n", 
-	m->f_lo1, m->f_lo2, m->LO1I, m->LO2I, m->SEL, m->STEP, m->NUM);
+    xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO,
+               "MT2032: computed f_lo1=%g f_lo2=%g LO1I=%d LO2I=%d SEL=%d STEP=%d NUM=%d\n",
+               m->f_lo1, m->f_lo2, m->LO1I, m->LO2I, m->SEL, m->STEP, m->NUM);
 }
 
 
-static void MT2032_getid(FI1236Ptr f)
+static void
+MT2032_getid (FI1236Ptr f)
 {
-CARD8 out[4];
-CARD8 in;
+    CARD8 out[4];
+    CARD8 in;
 
-in=0x11;
-I2C_WriteRead(&(f->d), (I2CByte *)&in, 1, out, 4);
-xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO, "MT2032: Company code 0x%02x%02x, part code 0x%02x, revision code 0x%02x\n",
-	out[0], out[1], out[2], out[3]);
+    in = 0x11;
+    I2C_WriteRead(&(f->d), (I2CByte *)&in, 1, out, 4);
+    xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO,
+               "MT2032: Company code 0x%02x%02x, part code 0x%02x, revision code 0x%02x\n",
+               out[0], out[1], out[2], out[3]);
 
 }
 
 /* might be buggy */
 #if 0
-static void MT2032_shutdown(FI1236Ptr f)
+static void
+MT2032_shutdown (FI1236Ptr f)
 {
-CARD8 data[10];
+    CARD8 data[10];
 
-data[0]=0x00; /* start with register 0x00 */
-data[1]=0x1A; 
-data[2]=0x44;
-data[3]=0x20;
+    data[0] = 0x00; /* start with register 0x00 */
+    data[1] = 0x1A;
+    data[2] = 0x44;
+    data[3] = 0x20;
 
-I2C_WriteRead(&(f->d), (I2CByte *)data, 4, NULL, 0);
+    I2C_WriteRead(&(f->d), (I2CByte *)data, 4, NULL, 0);
 
-data[0]=0x05; /* now start with register 0x05 */
-data[1]=0xD7;
-data[2]=0x14;
-data[3]=0x05;
-I2C_WriteRead(&(f->d), (I2CByte *)data, 4, NULL, 0);
+    data[0] = 0x05; /* now start with register 0x05 */
+    data[1] = 0xD7;
+    data[2] = 0x14;
+    data[3] = 0x05;
+    I2C_WriteRead(&(f->d), (I2CByte *)data, 4, NULL, 0);
 
-data[0]=0x0B; /* now start with register 0x05 */
-data[1]=0x8F;
-data[2]=0x07;
-data[3]=0x43;
-I2C_WriteRead(&(f->d), (I2CByte *)data, 4, NULL, 0);
+    data[0] = 0x0B; /* now start with register 0x05 */
+    data[1] = 0x8F;
+    data[2] = 0x07;
+    data[3] = 0x43;
+    I2C_WriteRead(&(f->d), (I2CByte *)data, 4, NULL, 0);
 
-usleep(15000);
+    usleep(15000);
 }
 #endif
 
-static void MT2032_dump_status(FI1236Ptr f);
+static void MT2032_dump_status (FI1236Ptr f);
 
-static void MT2032_init(FI1236Ptr f)
+static void
+MT2032_init (FI1236Ptr f)
 {
-CARD8 data[10];
-CARD8 value;
-CARD8 xogc = 0x00;
-
-MT2032_getid(f);
-
-data[0]=0x02; /* start with register 0x02 */
-data[1]=0xFF; 
-data[2]=0x0F;
-data[3]=0x1F;
-
-I2C_WriteRead(&(f->d), (I2CByte *)data, 4, NULL, 0);
-
-data[0]=0x06; /* now start with register 0x06 */
-data[1]=0xE4;
-data[2]=0x8F;
-data[3]=0xC3;
-data[4]=0x4E;
-data[5]=0xEC;
-I2C_WriteRead(&(f->d), (I2CByte *)data, 6, NULL, 0);
-
-data[0]=0x0d; /* now start with register 0x0d */
-data[1]=0x32;
-I2C_WriteRead(&(f->d), (I2CByte *)data, 2, NULL, 0);
-
-while(1) {
-	usleep(15000); /* wait 15 milliseconds */
-
-	data[0]=0x0e; /* register number 7, status */
-	value=0xFF;
-	if(!I2C_WriteRead(&(f->d), (I2CByte *)data, 1, &value, 1))
-		xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO, "MT2032: failed to read XOK\n"); 
-	xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO, "MT2032: XOK=%d\n", value & 0x01); 
-	if(value & 1) break;
-	
-	data[0]=0x07;
-	if(!I2C_WriteRead(&(f->d), (I2CByte *)data, 1, &value, 1))
-		xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO, "MT2032: failed to read XOGC\n"); 
-	 
-	xogc=value & 0x7;
-	if(xogc==4){
-		break; /* XOGC has reached 4.. stop */	
-		}
-	xogc--;
-	xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO, "MT2032: try XOGC=%d\n", xogc); 
-	usleep(15000);
-	data[0]=0x07; /* register number 7, control byte 2 */
-	data[1]=0x08 | xogc;
-	I2C_WriteRead(&(f->d), (I2CByte *)data, 2, NULL, 0);	
-	}
-f->xogc=xogc;
-/* wait before continuing */
-usleep(15000); /* wait 50 milliseconds */
-MT2032_dump_status(f);
+    CARD8 data[10];
+    CARD8 value;
+    CARD8 xogc = 0x00;
+
+    MT2032_getid(f);
+
+    data[0] = 0x02; /* start with register 0x02 */
+    data[1] = 0xFF;
+    data[2] = 0x0F;
+    data[3] = 0x1F;
+
+    I2C_WriteRead(&(f->d), (I2CByte *)data, 4, NULL, 0);
+
+    data[0] = 0x06; /* now start with register 0x06 */
+    data[1] = 0xE4;
+    data[2] = 0x8F;
+    data[3] = 0xC3;
+    data[4] = 0x4E;
+    data[5] = 0xEC;
+    I2C_WriteRead(&(f->d), (I2CByte *)data, 6, NULL, 0);
+
+    data[0] = 0x0d; /* now start with register 0x0d */
+    data[1] = 0x32;
+    I2C_WriteRead(&(f->d), (I2CByte *)data, 2, NULL, 0);
+
+    while (1) {
+        usleep(15000); /* wait 15 milliseconds */
+
+        data[0] = 0x0e; /* register number 7, status */
+        value = 0xFF;
+        if (!I2C_WriteRead(&(f->d), (I2CByte *)data, 1, &value, 1))
+            xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO,
+                       "MT2032: failed to read XOK\n");
+        xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO,
+                   "MT2032: XOK=%d\n", value & 0x01);
+        if (value & 1)
+            break;
+
+        data[0] = 0x07;
+        if (!I2C_WriteRead(&(f->d), (I2CByte *)data, 1, &value, 1))
+            xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO,
+                       "MT2032: failed to read XOGC\n");
+
+        xogc=value & 0x7;
+        if (xogc == 4)
+            break; /* XOGC has reached 4.. stop */
+        xogc--;
+        xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO,
+                   "MT2032: try XOGC=%d\n", xogc);
+        usleep(15000);
+        data[0] = 0x07; /* register number 7, control byte 2 */
+        data[1] = 0x08 | xogc;
+        I2C_WriteRead(&(f->d), (I2CByte *)data, 2, NULL, 0);
+    }
+    f->xogc = xogc;
+    /* wait before continuing */
+    usleep(15000); /* wait 50 milliseconds */
+    MT2032_dump_status(f);
 }
 
-static int MT2032_no_spur_in_band(MT2032_parameters *m)
+static int
+MT2032_no_spur_in_band (MT2032_parameters *m)
 {
-int n_max, n1, n2;
-double f_test;
-n_max=5;
-n1=1;
-while(1){
-	n2=-n1;
-	f_test=n1*(m->f_lo1-m->f_lo2);
-	while(1){
-		n2--;
-		f_test=f_test-m->f_lo2;
-		xf86DrvMsg(0, X_INFO, "testing f_test=%g n1=%d n2=%d f_lo1=%g f_lo2=%g f_if2=%g\n", f_test, n1, n2, m->f_lo1, m->f_lo2, m->f_if2);  
-		xf86DrvMsg(0, X_INFO, "d_f=%g f_ifbw=%g\n",fabs(fabs(f_test)-m->f_if2), m->f_ifbw);  
-		if((fabs(fabs(f_test)-m->f_if2)*2.0)<=m->f_ifbw)return 0;
-		if(n2<=-n_max)break;
-  		/* this line in the manual is bogus. I say it is faster
-		and more correct to go over all harmonics.. */
-		#if 0
-		if(f_test<(m->f_lo2-m->f_if2-m->f_ifbw))break; 
-		#endif
-		}
-	n1++;
-	if(n1>=n_max)return 1;
-	}
+    int n_max, n1, n2;
+    double f_test;
+    n_max = 5;
+    n1 = 1;
+    while (1) {
+        n2 = -n1;
+        f_test = n1 * (m->f_lo1 - m->f_lo2);
+        while (1) {
+            n2--;
+            f_test = f_test - m->f_lo2;
+            xf86DrvMsg(0, X_INFO,
+                       "testing f_test=%g n1=%d n2=%d f_lo1=%g f_lo2=%g f_if2=%g\n",
+                       f_test, n1, n2, m->f_lo1, m->f_lo2, m->f_if2);
+            xf86DrvMsg(0, X_INFO, "d_f=%g f_ifbw=%g\n",
+                       fabs(fabs(f_test) - m->f_if2), m->f_ifbw);
+            if ((fabs(fabs(f_test) - m->f_if2) * 2.0) <= m->f_ifbw)
+                return 0;
+            if (n2 <= -n_max)
+                break;
+            /* this line in the manual is bogus. I say it is faster
+               and more correct to go over all harmonics.. */
+#if 0
+            if (f_test < (m->f_lo2 - m->f_if2 - m->f_ifbw))
+                break;
+#endif
+        }
+        n1++;
+        if (n1 >= n_max)
+            return 1;
+    }
 
 }
 
-static void MT2032_calculate_register_settings(MT2032_parameters *m, double f_rf, double f_if1, double f_if2, double f_ref, double f_ifbw, double f_step)
+static void
+MT2032_calculate_register_settings (MT2032_parameters *m, double f_rf,
+   double f_if1, double f_if2, double f_ref, double f_ifbw, double f_step)
 {
-int n;
-m->f_rf=f_rf;
-m->f_if1=f_if1;
-m->f_if2=f_if2;
-m->f_ref=f_ref;
-m->f_ifbw=f_ifbw;
-m->f_step=f_step;
-
-m->f_lo1=f_rf+f_if1;
-m->LO1I=lrint(m->f_lo1/f_ref);
-m->f_lo1=f_ref*m->LO1I;
-
-m->f_lo2=m->f_lo1-f_rf-f_if2;
-
-/* check for spurs */
-n=1;
-while(n<3){
-	if(MT2032_no_spur_in_band(m))break;
-	if(m->f_lo1<(f_rf+f_if1)){
-		m->LO1I+=n;
-		} else {
-		m->LO1I-=n;
-		}
-	m->f_lo1=m->LO1I*f_ref;
-	m->f_lo2=m->f_lo1-f_rf-f_if2;
-	n++;
-	}
-/* xf86DrvMsg(0, X_INFO, "MT2032: n=%d\n", n); */
-/* select VCO */
-
-/* m->f_lo1>1100.0 */
-if(m->f_lo1<1370.0)m->SEL=4;
-	else
-if(m->f_lo1<1530.0)m->SEL=3;
-	else
-if(m->f_lo1<1720.0)m->SEL=2;
-	else
-if(m->f_lo1<1890.0)m->SEL=1;
-	else  /* m->f_lo1 < 1958.0 */
-	m->SEL=0;
-
-/* calculate the rest of the registers */
-m->LO2I=floor(m->f_lo2/f_ref);
-m->STEP=floor(3780.0*f_step/f_ref);
-m->NUM=floor(3780.0*(m->f_lo2/f_ref-m->LO2I));
-m->NUM=m->STEP*lrint((1.0*m->NUM)/(1.0*m->STEP));
+    int n;
+    m->f_rf = f_rf;
+    m->f_if1 = f_if1;
+    m->f_if2 = f_if2;
+    m->f_ref = f_ref;
+    m->f_ifbw = f_ifbw;
+    m->f_step = f_step;
+
+    m->f_lo1 = f_rf+f_if1;
+    m->LO1I = lrint(m->f_lo1 / f_ref);
+    m->f_lo1 = f_ref * m->LO1I;
+
+    m->f_lo2 = m->f_lo1 - f_rf - f_if2;
+
+    /* check for spurs */
+    n = 1;
+    while (n < 3) {
+        if (MT2032_no_spur_in_band(m))
+            break;
+
+        if (m->f_lo1 < (f_rf + f_if1))
+            m->LO1I += n;
+        else
+            m->LO1I -= n;
+
+        m->f_lo1 = m->LO1I * f_ref;
+        m->f_lo2 = m->f_lo1 - f_rf - f_if2;
+        n++;
+    }
+    /* xf86DrvMsg(0, X_INFO, "MT2032: n=%d\n", n); */
+    /* select VCO */
+
+    /* m->f_lo1>1100.0 */
+    if (m->f_lo1 < 1370.0)
+        m->SEL = 4;
+    else if (m->f_lo1 < 1530.0)
+        m->SEL = 3;
+    else if (m->f_lo1 < 1720.0)
+        m->SEL = 2;
+    else if (m->f_lo1 < 1890.0)
+        m->SEL = 1;
+    else  /* m->f_lo1 < 1958.0 */
+        m->SEL = 0;
+
+    /* calculate the rest of the registers */
+    m->LO2I = floor(m->f_lo2 / f_ref);
+    m->STEP = floor(3780.0 * f_step / f_ref);
+    m->NUM  = floor(3780.0 * (m->f_lo2 / f_ref - m->LO2I));
+    m->NUM  = m->STEP * lrint((1.0 * m->NUM) / (1.0 * m->STEP));
 }
 
-static int MT2032_wait_for_lock(FI1236Ptr f)
+static int
+MT2032_wait_for_lock (FI1236Ptr f)
 {
-int n;
-CARD8 data[10];
-CARD8 value;
-
-n=12;
-while(1){
-	data[0]=0x0e; /* register number 7, status */
-	I2C_WriteRead(&(f->d), (I2CByte *)data, 1, &value, 1);
-/*	xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO, "MT2032: LO1LK=%d LO2LK=%d\n", (value & 0x04)>>2, (value & 0x02)>>1); */
-	if((value & 6)==6) break;
-	usleep(1500);
-	n--;
-	if(n<0)break;
-	}
-if(n<0){
-	xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO, "MT2032: failed to set frequency\n");
-	return 0;
-	}
-return 1;
+    int n;
+    CARD8 data[10];
+    CARD8 value;
+
+    n=12;
+    while(1) {
+        data[0] = 0x0e; /* register number 7, status */
+        I2C_WriteRead(&(f->d), (I2CByte *)data, 1, &value, 1);
+     /* xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO,
+                   "MT2032: LO1LK=%d LO2LK=%d\n",
+                   (value & 0x04)>>2, (value & 0x02)>>1); */
+        if ((value & 6)==6)
+            break;
+        usleep (1500);
+        n--;
+        if (n < 0)
+            break;
+    }
+    if (n < 0) {
+        xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO,
+                   "MT2032: failed to set frequency\n");
+        return 0;
+    }
+    return 1;
 }
 
-static void MT2032_implement_settings(FI1236Ptr f, MT2032_parameters *m)
+static void
+MT2032_implement_settings (FI1236Ptr f, MT2032_parameters *m)
 {
-CARD8 data[10];
-CARD8 value;
-
-data[0]=0x00;     /* start with register 0x00 */
-data[1]=(m->LO1I>>3)-1;
-data[2]=(m->SEL<<4)|(m->LO1I & 0x7);
-data[3]=0x86;
-I2C_WriteRead(&(f->d), (I2CByte *)data, 4, NULL, 0);
-
-data[0]=0x05;     /* start with register 0x05 */
-data[1]=((m->LO2I & 0x7)<<5)|((m->LO2I>>3)-1);
-if(m->f_rf<400.0)data[2]=0xe4;
-	else data[2]=0xf4;
-I2C_WriteRead(&(f->d), (I2CByte *)data, 3, NULL, 0);
-
-data[0]=0x07; /* register number 7, control byte 2 */
-I2C_WriteRead(&(f->d), (I2CByte *)data, 1, &value, 1);
-xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO, "MT2032: using XOGC=%d\n", (value & 0x07));
-data[1]=8 | (value & 0x7);
-I2C_WriteRead(&(f->d), (I2CByte *)data, 2, NULL, 0);	
-
-data[0]=0x0b;   /* start with register 0x0b */
-data[1]=m->NUM & 0xff;
-data[2]=(1<<7)|((m->NUM >> 8) & 0x0f);
-I2C_WriteRead(&(f->d), (I2CByte *)data, 3, NULL, 0);
-
-MT2032_wait_for_lock(f);
+    CARD8 data[10];
+    CARD8 value;
+
+    data[0] = 0x00;     /* start with register 0x00 */
+    data[1] = (m->LO1I >> 3) - 1;
+    data[2] = (m->SEL << 4) | (m->LO1I & 0x7);
+    data[3] = 0x86;
+    I2C_WriteRead(&(f->d), (I2CByte *)data, 4, NULL, 0);
+
+    data[0] = 0x05;     /* start with register 0x05 */
+    data[1] = ((m->LO2I & 0x7) << 5) | ((m->LO2I >> 3) - 1);
+    if (m->f_rf < 400.0)
+        data[2] = 0xe4;
+    else
+        data[2] = 0xf4;
+    I2C_WriteRead(&(f->d), (I2CByte *)data, 3, NULL, 0);
+
+    data[0] = 0x07;     /* register number 7, control byte 2 */
+    I2C_WriteRead(&(f->d), (I2CByte *)data, 1, &value, 1);
+    xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO,
+               "MT2032: using XOGC=%d\n", (value & 0x07));
+    data[1] = 8 | (value & 0x7);
+    I2C_WriteRead(&(f->d), (I2CByte *)data, 2, NULL, 0);
+
+    data[0] = 0x0b;     /* start with register 0x0b */
+    data[1] = m->NUM & 0xff;
+    data[2] = (1<<7) | ((m->NUM >> 8) & 0x0f);
+    I2C_WriteRead(&(f->d), (I2CByte *)data, 3, NULL, 0);
+
+    MT2032_wait_for_lock(f);
 }
 
-static void MT2032_optimize_VCO(FI1236Ptr f, MT2032_parameters *m)
+static void
+MT2032_optimize_VCO (FI1236Ptr f, MT2032_parameters *m)
 {
-CARD8 data[10];
-CARD8 value;
-CARD8 TAD1;
-
-data[0]=0x0f; /* register number 7, status */
-I2C_WriteRead(&(f->d), (I2CByte *)data, 1, &value, 1);
-TAD1=value & 0x07;
-xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO, "MT2032: TAD1=%d SEL=%d\n", TAD1, m->SEL);
-if(TAD1 < 2)return;
-if(TAD1==2){
-	if(m->SEL==0)return;
-	m->SEL--;
-	} else {
-	if(m->SEL>=4)return;
-	m->SEL++;
-	}
-data[0]=0x01;  /* start with register 1 */
-data[1]=(m->SEL<<4)|(m->LO1I & 0x7);
-I2C_WriteRead(&(f->d), (I2CByte *)data, 2, NULL, 0);
+    CARD8 data[10];
+    CARD8 value;
+    CARD8 TAD1;
+
+    data[0] = 0x0f; /* register number 7, status */
+    I2C_WriteRead(&(f->d), (I2CByte *)data, 1, &value, 1);
+    TAD1=value & 0x07;
+    xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO,
+               "MT2032: TAD1=%d SEL=%d\n", TAD1, m->SEL);
+    if (TAD1 < 2)
+        return;
+    if (TAD1 == 2) {
+        if (m->SEL == 0)
+            return;
+        m->SEL--;
+    } else {
+        if (m->SEL >= 4)
+            return;
+        m->SEL++;
+    }
+    data[0] = 0x01;  /* start with register 1 */
+    data[1] = (m->SEL << 4) | (m->LO1I & 0x7);
+    I2C_WriteRead(&(f->d), (I2CByte *)data, 2, NULL, 0);
 
 }
 
-static int FI1236_get_afc_hint(FI1236Ptr f)
+static int
+FI1236_get_afc_hint (FI1236Ptr f)
 {
-	CARD8 out;
-	CARD8 AFC;
-
-	if ((f->type == TUNER_TYPE_FM1216ME) || (f->type == TUNER_TYPE_FI1236W))
-	{
-		TDA9885Ptr t = (TDA9885Ptr)f->afc_source;
-		if (t == NULL)
-			return TUNER_OFF; 
-		
-		tda9885_getstatus(t);
-		tda9885_dumpstatus(t);
-		AFC = t->afc_status & 0x0f;
-
-		xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO, "AFC: FI1236_get_afc_hint: %i\n", AFC);
-		if (AFC == 0) return TUNER_TUNED;
-		else if (AFC <= 0x07)return TUNER_JUST_BELOW;
-		else if (AFC < 0x0f )return TUNER_JUST_ABOVE;
-		else if (AFC == 0x0f)return TUNER_TUNED;
-	}
-	else
-	{
-		I2C_WriteRead(&(f->d), NULL, 0, &out, 1);
-		AFC=out & 0x7;
-		xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO, "AFC: FI1236_get_afc_hint: %i\n", AFC);
-		if(AFC==2)return TUNER_TUNED;
-		if(AFC==3)return TUNER_JUST_BELOW;
-		if(AFC==1)return TUNER_JUST_ABOVE;
-		return TUNER_OFF;
-	}
-	return TUNER_OFF;
+    CARD8 out;
+    CARD8 AFC;
+
+    if ((f->type == TUNER_TYPE_FM1216ME) || (f->type == TUNER_TYPE_FI1236W)) {
+        TDA9885Ptr t = (TDA9885Ptr)f->afc_source;
+        if (t == NULL)
+            return TUNER_OFF;
+
+        tda9885_getstatus(t);
+        tda9885_dumpstatus(t);
+        AFC = t->afc_status & 0x0f;
+
+        xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO,
+                   "AFC: FI1236_get_afc_hint: %i\n", AFC);
+        if (AFC == 0)
+            return TUNER_TUNED;
+        else if (AFC <= 0x07)
+            return TUNER_JUST_BELOW;
+        else if (AFC < 0x0f)
+            return TUNER_JUST_ABOVE;
+        else if (AFC == 0x0f)
+            return TUNER_TUNED;
+    } else {
+        I2C_WriteRead(&(f->d), NULL, 0, &out, 1);
+        AFC = out & 0x7;
+        xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO,
+                   "AFC: FI1236_get_afc_hint: %i\n", AFC);
+        if (AFC == 2)
+            return TUNER_TUNED;
+        if (AFC == 3)
+            return TUNER_JUST_BELOW;
+        if (AFC == 1)
+            return TUNER_JUST_ABOVE;
+        return TUNER_OFF;
+    }
+    return TUNER_OFF;
 }
 
-static int MT2032_get_afc_hint(FI1236Ptr f)
+static int
+MT2032_get_afc_hint (FI1236Ptr f)
 {
-CARD8 in;
-CARD8 out[2];
-CARD8 AFC;
-in=0x0e;
-I2C_WriteRead(&(f->d), (I2CByte *)&in, 1, out, 2);
-AFC=(out[0]>>4) & 0x7;
+    CARD8 in;
+    CARD8 out[2];
+    CARD8 AFC;
+    in = 0x0e;
+    I2C_WriteRead(&(f->d), (I2CByte *)&in, 1, out, 2);
+    AFC = (out[0] >> 4) & 0x7;
 #if 0
-xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO, "AFC=%d TAD1=%d TAD2=%d\n", AFC, out[1] & 0x7, (out[1]>>4)& 0x07);
+    xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO, "AFC=%d TAD1=%d TAD2=%d\n",
+               AFC, out[1] & 0x7, (out[1]>>4)& 0x07);
 #endif
-if(AFC==2)return TUNER_TUNED;
-if(AFC==3)return TUNER_JUST_BELOW;
-if(AFC==1)return TUNER_JUST_ABOVE;
-return TUNER_OFF;
+    if (AFC == 2)
+        return TUNER_TUNED;
+    if (AFC == 3)
+        return TUNER_JUST_BELOW;
+    if (AFC == 1)
+        return TUNER_JUST_ABOVE;
+    return TUNER_OFF;
 }
 
 /* this function is for external use only */
-int TUNER_get_afc_hint(FI1236Ptr f)
+int
+TUNER_get_afc_hint (FI1236Ptr f)
 {
-if(f->afc_timer_installed)return TUNER_STILL_TUNING;
-return f->last_afc_hint;
+    if (f->afc_timer_installed)
+        return TUNER_STILL_TUNING;
+    return f->last_afc_hint;
 }
 
-static void MT2032_dump_status(FI1236Ptr f)
+static void
+MT2032_dump_status (FI1236Ptr f)
 {
-CARD8 in;
-CARD8 out[2];
-CARD8 AFC;
-CARD8 LDONrb;
-CARD8 LO1LK, LO2LK, XOK;
-CARD8 TAD2, TAD1;
-
-in=0x0e;
-I2C_WriteRead(&(f->d), (I2CByte *)&in, 1, out, 2);
-XOK=out[0] & 1;
-LO1LK=(out[0]>>2) &1;
-LO2LK=(out[0]>>1) &1;
-LDONrb=(out[0]>>3) &1;
-
-AFC=(out[0]>>4) & 0x7;
-
-TAD1=(out[1] & 0x7);
-TAD2=(out[1]>>4) & 0x7;
-
-xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO, "MT2032: status: XOK=%d LO1LK=%d LO2LK=%d LDONrb=%d AFC=%d TAD1=%d TAD2=%d\n", 
-	XOK, LO1LK, LO2LK, LDONrb, AFC, TAD1, TAD2);
-xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO, "MT2032: status: OSCILLATOR:%s PLL1:%s PLL2:%s\n", 
-	XOK ? "ok":"off", LO1LK ? "locked" : "off" , LO2LK ? "locked" : "off");
+    CARD8 in;
+    CARD8 out[2];
+    CARD8 AFC;
+    CARD8 LDONrb;
+    CARD8 LO1LK, LO2LK, XOK;
+    CARD8 TAD2, TAD1;
+
+    in = 0x0e;
+    I2C_WriteRead(&(f->d), (I2CByte *)&in, 1, out, 2);
+    XOK = out[0] & 1;
+    LO1LK  = (out[0] >> 2) & 1;
+    LO2LK  = (out[0] >> 1) & 1;
+    LDONrb = (out[0] >> 3) & 1;
+
+    AFC    = (out[0] >> 4) & 0x7;
+
+    TAD1   = (out[1] & 0x7);
+    TAD2   = (out[1] >> 4) & 0x7;
+
+    xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO,
+               "MT2032: status: XOK=%d LO1LK=%d LO2LK=%d LDONrb=%d AFC=%d TAD1=%d TAD2=%d\n",
+               XOK, LO1LK, LO2LK, LDONrb, AFC, TAD1, TAD2);
+    xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO,
+               "MT2032: status: OSCILLATOR:%s PLL1:%s PLL2:%s\n",
+               XOK ? "ok" : "off",
+               LO1LK ? "locked" : "off",
+               LO2LK ? "locked" : "off");
 
 }
 
 static void MT2032_tune(FI1236Ptr f, double freq, double step)
 {
-MT2032_parameters m;
-CARD8 data[10];
-int i;
-/* NTSC IF is 44mhz.. but 733/16=45.8125 and all TDAXXXX docs mention
-     45.75, 39, 58.75 and 30. */
+    MT2032_parameters m;
+    CARD8 data[10];
+    int i;
+
+    /* NTSC IF is 44mhz.. but 733/16=45.8125 and all TDAXXXX docs mention
+       45.75, 39, 58.75 and 30. */
 #if 0
-MT2032_calculate_register_settings(&m, freq, 1090.0, 45.125, 5.25, 6.0, step);
-MT2032_calculate_register_settings(&m, freq, 1090.0, 45.74, 5.25, 6.0, step);
+    MT2032_calculate_register_settings(&m, freq, 1090.0, 45.125, 5.25, 6.0, step);
+    MT2032_calculate_register_settings(&m, freq, 1090.0, 45.74, 5.25, 6.0, step);
 #endif
-MT2032_calculate_register_settings(&m, freq, 1090.0, f->video_if, 5.25, 3.0, step);
-MT2032_dump_parameters(f, &m);
-MT2032_implement_settings(f, &m);
-/* MT2032_dump_parameters(f, &m); */
-for(i=0;i<3;i++){
-	MT2032_optimize_VCO(f, &m);
-	if(MT2032_wait_for_lock(f)){
-		data[0]=0x02;  /* LO Gain control register 0x02 */
-		data[1]=0x20;
-		I2C_WriteRead(&(f->d), (I2CByte *)data, 2, NULL, 0);
-		return;
-		}
-	data[0]=0x07;
-	data[1]=0x88|f->xogc;
-	I2C_WriteRead(&(f->d), (I2CByte *)data, 2, NULL, 0);
-	usleep(15000);
-	data[1]=0x08|f->xogc;
-	I2C_WriteRead(&(f->d), (I2CByte *)data, 2, NULL, 0);	
-	}
-xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO, "MT2032: failed to set frequency\n");
+    MT2032_calculate_register_settings(&m, freq, 1090.0, f->video_if, 5.25, 3.0, step);
+    MT2032_dump_parameters(f, &m);
+    MT2032_implement_settings(f, &m);
+ /* MT2032_dump_parameters(f, &m); */
+    for (i = 0; i < 3; i++) {
+        MT2032_optimize_VCO(f, &m);
+        if (MT2032_wait_for_lock(f)) {
+            data[0] = 0x02;  /* LO Gain control register 0x02 */
+            data[1] = 0x20;
+            I2C_WriteRead(&(f->d), (I2CByte *)data, 2, NULL, 0);
+            return;
+        }
+        data[0] = 0x07;
+        data[1] = 0x88 | f->xogc;
+        I2C_WriteRead(&(f->d), (I2CByte *)data, 2, NULL, 0);
+        usleep(15000);
+        data[1] = 0x08 | f->xogc;
+        I2C_WriteRead(&(f->d), (I2CByte *)data, 2, NULL, 0);
+    }
+    xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO,
+               "MT2032: failed to set frequency\n");
 }
 
-void FI1236_set_tuner_type(FI1236Ptr f, int type)
+void
+FI1236_set_tuner_type (FI1236Ptr f, int type)
 {
-f->type=type;
-if(type>=NUM_TUNERS)type = NUM_TUNERS-1;
-if(type<0)type = 0;
-memcpy(&(f->parm), &(tuner_parms[type]), sizeof(FI1236_parameters));
-f->original_frequency=f->parm.min_freq;
-f->afc_delta=0;
-if(type==TUNER_TYPE_MT2032){
-	MT2032_init(f);
-	return;
-	}
+    f->type = type;
+    if (type >= NUM_TUNERS)
+        type = NUM_TUNERS-1;
+    if (type < 0)
+        type = 0;
+    memcpy(&(f->parm), &(tuner_parms[type]), sizeof(FI1236_parameters));
+    f->original_frequency = f->parm.min_freq;
+    f->afc_delta = 0;
+    if (type == TUNER_TYPE_MT2032) {
+        MT2032_init(f);
+        return;
+    }
 }
 
 
-static CARD32 AFC_TimerCallback(OsTimerPtr timer, CARD32 time, pointer data){
-FI1236Ptr f=(FI1236Ptr)data;
-if(FI1236_AFC(f))return 150;
-	else {
-	f->afc_timer_installed=FALSE;
-	f->afc_count=0;
-	return 0;
-	}
+static CARD32
+AFC_TimerCallback(OsTimerPtr timer, CARD32 time, pointer data)
+{
+    FI1236Ptr f = (FI1236Ptr)data;
+    if (FI1236_AFC(f))
+        return 150;
+    else {
+        f->afc_timer_installed = FALSE;
+        f->afc_count = 0;
+        return 0;
+    }
 }
 
-void FI1236_tune(FI1236Ptr f, CARD32 frequency)
+void
+FI1236_tune(FI1236Ptr f, CARD32 frequency)
 {
     CARD16 divider;
-	 CARD8 data;
+    CARD8 data;
 
-    if(frequency < f->parm.min_freq) frequency = f->parm.min_freq;
-    if(frequency > f->parm.max_freq) frequency = f->parm.max_freq;
+    if (frequency < f->parm.min_freq) frequency = f->parm.min_freq;
+    if (frequency > f->parm.max_freq) frequency = f->parm.max_freq;
 
-    divider = (f->parm.fcar+(CARD16)frequency) & 0x7fff;
-    f->tuner_data.div1 = (CARD8)((divider>>8)&0x7f);
+    divider = (f->parm.fcar + (CARD16)frequency) & 0x7fff;
+    f->tuner_data.div1 = (CARD8)((divider >> 8)&0x7f);
     f->tuner_data.div2 = (CARD8)(divider & 0xff);
-    f->tuner_data.control = f->parm.control; 
+    f->tuner_data.control = f->parm.control;
 
-    if(frequency < f->parm.threshold1)
-    {
+    if (frequency < f->parm.threshold1)
         f->tuner_data.band = f->parm.band_low;
-    } 
     else if (frequency < f->parm.threshold2)
-    {
         f->tuner_data.band = f->parm.band_mid;
-    }
     else
-    {
         f->tuner_data.band = f->parm.band_high;
-    }
 
-	 xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO, "Setting tuner band to %d\n", f->tuner_data.band);
+    xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO,
+               "Setting tuner band to %d\n", f->tuner_data.band);
 
-    xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO, "Setting tuner frequency to %d\n", (int)frequency);
+    xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO,
+               "Setting tuner frequency to %d\n", (int)frequency);
 
-	 if ((f->type == TUNER_TYPE_FM1216ME) || (f->type == TUNER_TYPE_FI1236W))
-	 {
-				f->tuner_data.aux = 0x20;
-				I2C_WriteRead(&(f->d), (I2CByte *)&(f->tuner_data), 5, NULL, 0);
-				I2C_WriteRead(&(f->d), NULL, 0, &data, 1);
-				xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO, "Tuner status %x\n", data);
-
-	 }
-	 else
-				I2C_WriteRead(&(f->d), (I2CByte *)&(f->tuner_data), 4, NULL, 0);
+    if ((f->type == TUNER_TYPE_FM1216ME) || (f->type == TUNER_TYPE_FI1236W)) {
+        f->tuner_data.aux = 0x20;
+        I2C_WriteRead(&(f->d), (I2CByte *)&(f->tuner_data), 5, NULL, 0);
+        I2C_WriteRead(&(f->d), NULL, 0, &data, 1);
+        xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO, "Tuner status %x\n", data);
+    }
+    else
+        I2C_WriteRead(&(f->d), (I2CByte *)&(f->tuner_data), 4, NULL, 0);
 }
 
-void TUNER_set_frequency(FI1236Ptr f, CARD32 frequency)
+void
+TUNER_set_frequency(FI1236Ptr f, CARD32 frequency)
 {
-    if(frequency < f->parm.min_freq) frequency = f->parm.min_freq;
-    if(frequency > f->parm.max_freq) frequency = f->parm.max_freq;
+    if (frequency < f->parm.min_freq) frequency = f->parm.min_freq;
+    if (frequency > f->parm.max_freq) frequency = f->parm.max_freq;
 
     f->afc_delta=0;
     f->original_frequency=frequency;
 
-    if(f->type==TUNER_TYPE_MT2032)
-        {
-    	MT2032_tune(f, (1.0*frequency)/16.0, 0.0625);
-	} else 
-	{
-	FI1236_tune(f, frequency);
-	}
-    
-    if(!f->afc_timer_installed)
-        {
-     	f->afc_timer_installed=TRUE;
-/*     	RegisterBlockAndWakeupHandlers(FI1236_BlockHandler, AFCWakeup, f); */
-	TimerSet(NULL, 0, 300, AFC_TimerCallback, f);
-	}
-	
+    if (f->type == TUNER_TYPE_MT2032)
+        MT2032_tune(f, (1.0*frequency)/16.0, 0.0625);
+    else
+        FI1236_tune(f, frequency);
+
+    if (!f->afc_timer_installed) {
+        f->afc_timer_installed=TRUE;
+/*      RegisterBlockAndWakeupHandlers(FI1236_BlockHandler, AFCWakeup, f); */
+        TimerSet(NULL, 0, 300, AFC_TimerCallback, f);
+    }
+
 }
 
 
-int FI1236_AFC(FI1236Ptr f)
+int
+FI1236_AFC(FI1236Ptr f)
 {
-    #if 0
-    xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO, "AFC: f=%p f->count=%d f->original_frequency=%d f->afc_delta=%d\n", f, f->afc_count, f->original_frequency, f->afc_delta);
-    #endif
+#if 0
+    xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO,
+               "AFC: f=%p f->count=%d f->original_frequency=%d f->afc_delta=%d\n",
+               f, f->afc_count, f->original_frequency, f->afc_delta);
+#endif
     f->afc_count++;
-    if(f->type==TUNER_TYPE_MT2032)
-        {
-    	f->last_afc_hint=MT2032_get_afc_hint(f);
-        xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO, "AFC: afc_hint=%d\n", f->last_afc_hint);
-	if(f->last_afc_hint==TUNER_TUNED)return 0;
-	if(f->afc_count>3)f->last_afc_hint=TUNER_OFF;
-	if(f->last_afc_hint==TUNER_OFF)
-	        {
-		f->afc_delta=0;
-		} else
-		f->afc_delta+=f->last_afc_hint;
-        xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO, "AFC: Setting tuner frequency to %g\n", (0.5*(2*f->original_frequency+f->afc_delta))/16.0);
-    	MT2032_tune(f, (1.0*f->original_frequency+0.5*f->afc_delta)/16.0, 0.03125);
-	if(f->last_afc_hint==TUNER_OFF)return 0;
-	return 1; /* call me again */
-	} else 
-	{
-    	f->last_afc_hint=FI1236_get_afc_hint(f);
-	if(f->last_afc_hint==TUNER_TUNED)
-	{
-			  xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO, "AFC: TUNER_TUNNED\n");
-			  return 0;
-	}
-	if(f->afc_count>3)f->last_afc_hint=TUNER_OFF;
-	if(f->last_afc_hint==TUNER_OFF)
-	        {
-		f->afc_delta=0;
-		} else
-		f->afc_delta+=f->last_afc_hint;
-        xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO, "AFC: Setting tuner frequency to %g\n", (0.5*(2*f->original_frequency+f->afc_delta))/16.0);
-	FI1236_tune(f, f->original_frequency+f->afc_delta);
-	if(f->last_afc_hint==TUNER_OFF)return 0;
-	return 1; /* call me again */
-	}
+    if (f->type == TUNER_TYPE_MT2032) {
+        f->last_afc_hint = MT2032_get_afc_hint(f);
+        xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO,
+                   "AFC: afc_hint=%d\n", f->last_afc_hint);
+        if (f->last_afc_hint == TUNER_TUNED)
+            return 0;
+        if (f->afc_count > 3)
+            f->last_afc_hint = TUNER_OFF;
+        if (f->last_afc_hint == TUNER_OFF)
+            f->afc_delta = 0;
+        else
+            f->afc_delta += f->last_afc_hint;
+
+        xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO,
+                   "AFC: Setting tuner frequency to %g\n",
+                   (0.5 * (2 * f->original_frequency + f->afc_delta)) / 16.0);
+        MT2032_tune(f,
+                    (1.0 * f->original_frequency+ 0.5 * f->afc_delta) / 16.0,
+                    0.03125);
+        if (f->last_afc_hint == TUNER_OFF)
+            return 0;
+        return 1; /* call me again */
+    } else {
+        f->last_afc_hint = FI1236_get_afc_hint(f);
+        if (f->last_afc_hint == TUNER_TUNED) {
+            xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO, "AFC: TUNER_TUNNED\n");
+            return 0;
+        }
+        if (f->afc_count > 3)
+            f->last_afc_hint = TUNER_OFF;
+
+        if (f->last_afc_hint == TUNER_OFF)
+            f->afc_delta=0;
+        else
+            f->afc_delta+=f->last_afc_hint;
+
+        xf86DrvMsg(f->d.pI2CBus->scrnIndex, X_INFO,
+                   "AFC: Setting tuner frequency to %g\n",
+                   (0.5 * (2 * f->original_frequency + f->afc_delta)) / 16.0);
+        FI1236_tune(f, f->original_frequency + f->afc_delta);
+        if (f->last_afc_hint == TUNER_OFF)
+            return 0;
+        return 1; /* call me again */
+    }
     return 0; /* done */
 }
 
-void fi1236_dump_status(FI1236Ptr f)
+void
+fi1236_dump_status(FI1236Ptr f)
 {
-if(f->type==TUNER_TYPE_MT2032){
-	MT2032_dump_status(f);
-	}
+    if (f->type == TUNER_TYPE_MT2032)
+        MT2032_dump_status(f);
 }
commit c46215c100e964665580211a5d5893558ca9374f
Author: Alan Coopersmith <alan.coopersmith at oracle.com>
Date:   Wed Aug 10 11:17:46 2011 -0700

    Cross-reference cvt(1) & gtf(1) man pages
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
    Reviewed-by: Julien Cristau <jcristau at debian.org>

diff --git a/hw/xfree86/utils/man/cvt.man b/hw/xfree86/utils/man/cvt.man
index b380171..f5075f5 100644
--- a/hw/xfree86/utils/man/cvt.man
+++ b/hw/xfree86/utils/man/cvt.man
@@ -1,4 +1,3 @@
-.\" $XFree86$
 .TH CVT 1 __vendorversion__
 .SH NAME
 cvt - calculate VESA CVT mode lines
@@ -32,7 +31,7 @@ Create a mode with reduced blanking.  This allows for higher frequency signals,
 with a lower or equal dotclock. Not for Cathode Ray Tube based displays though.
 
 .SH "SEE ALSO"
-__xconfigfile__(__filemansuffix__)
+__xconfigfile__(__filemansuffix__), gtf(__appmansuffix__)
 .SH AUTHOR
 Luc Verhaegen.
 .PP
diff --git a/hw/xfree86/utils/man/gtf.man b/hw/xfree86/utils/man/gtf.man
index 74ade74..8e83650 100644
--- a/hw/xfree86/utils/man/gtf.man
+++ b/hw/xfree86/utils/man/gtf.man
@@ -1,4 +1,3 @@
-.\" $XFree86$
 .TH GTF 1 __vendorversion__
 .SH NAME
 gtf - calculate VESA GTF mode lines
@@ -35,7 +34,7 @@ default format.
 Print the mode parameters in a format suitable for
 .BR fbset(8) .
 .SH "SEE ALSO"
-__xconfigfile__(__filemansuffix__)
+__xconfigfile__(__filemansuffix__), cvt(__appmansuffix__)
 .SH AUTHOR
 Andy Ritger.
 .PP
commit 1526f1caf396fefc5f09eaff884d5b92aac44997
Author: Alan Coopersmith <alan.coopersmith at oracle.com>
Date:   Tue May 31 19:54:33 2011 -0700

    Remove unused ClientStateAuthenticating
    
    Appears to be leftover from the Kerberos code deleted in 2007
    (commit dfbe32b5b828cc4e3da36a0e2e6ad641164eaa5e).
    Nothing left ever set clientState to ClientStateAuthenticating
    
    Skipped over 1 to preserve existing enum numbering.
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
    Reviewed-by: Julien Cristau <jcristau at debian.org>

diff --git a/dix/dispatch.c b/dix/dispatch.c
index e21f08f..6c44c5e 100644
--- a/dix/dispatch.c
+++ b/dix/dispatch.c
@@ -3443,8 +3443,7 @@ CloseDownClient(ClientPtr client)
 	 * now.  If it hasn't gotten to Running, nClients has *not*
 	 * been incremented, so *don't* decrement it.
 	 */
-	if (client->clientState != ClientStateInitial &&
-	    client->clientState != ClientStateAuthenticating )
+	if (client->clientState != ClientStateInitial)
 	{
 	    --nClients;
 	}
@@ -3706,17 +3705,8 @@ ProcEstablishConnection(ClientPtr client)
 				  auth_proto,
 				  (unsigned short)prefix->nbytesAuthString,
 				  auth_string);
-    /*
-     * If Kerberos is being used for this client, the clientState
-     * will be set to ClientStateAuthenticating at this point.
-     * More messages need to be exchanged among the X server, Kerberos
-     * server, and client to figure out if everyone is authorized.
-     * So we don't want to send the connection setup info yet, since
-     * the auth step isn't really done.
-     */
-    if (client->clientState != ClientStateAuthenticating)
-	return(SendConnSetup(client, reason));
-    return Success;
+
+    return(SendConnSetup(client, reason));
 }
 
 void
diff --git a/include/dixstruct.h b/include/dixstruct.h
index 90e617b..6cc9614 100644
--- a/include/dixstruct.h
+++ b/include/dixstruct.h
@@ -57,8 +57,8 @@ extern _X_EXPORT void ReplyNotSwappd (
 		void *		/* pbuf */) _X_NORETURN;
 
 typedef enum {ClientStateInitial,
-	      ClientStateAuthenticating,
-	      ClientStateRunning,
+	      /* 1 is unused now, was ClientStateAuthenticating */
+	      ClientStateRunning = 2,
 	      ClientStateRetained,
 	      ClientStateGone
 } ClientState;
commit 0f380a5005f800572773cd4667ce43c7459cc467
Author: Jamey Sharp <jamey at minilop.net>
Date:   Tue Sep 14 18:35:21 2010 -0700

    Fix pixmap double-frees on error paths.
    
    If AddResource fails, it will automatically free the object that was
    passed to it by calling the appropriate deleteFunc; and of course
    FreeResource also calls the deleteFunc. In both cases it's wrong to call
    the destroy hook manually.
    
    Commit by Jamey Sharp and Josh Triplett.
    
    Signed-off-by: Jamey Sharp <jamey at minilop.net>
    Signed-off-by: Josh Triplett <josh at joshtriplett.org>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Aaron Plattner <aplattner at nvidia.com>

diff --git a/Xext/shm.c b/Xext/shm.c
index b08af82..4141a8f 100644
--- a/Xext/shm.c
+++ b/Xext/shm.c
@@ -991,7 +991,6 @@ CreatePmap:
 	    pMap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
 	    pMap->drawable.id = newPix->info[j].id;
 	    if (!AddResource(newPix->info[j].id, RT_PIXMAP, (pointer)pMap)) {
-		(*pScreen->DestroyPixmap)(pMap);
 		result = BadAlloc;
 		break;
 	    }
@@ -1002,10 +1001,8 @@ CreatePmap:
     }
 
     if(result == BadAlloc) {
-	while(j--) {
-	    (*pScreen->DestroyPixmap)(pMap);
+	while(j--)
 	    FreeResource(newPix->info[j].id, RT_NONE);
-	}
 	free(newPix);
     } else 
 	AddResource(stuff->pid, XRT_PIXMAP, newPix);
@@ -1110,7 +1107,6 @@ CreatePmap:
 	{
 	    return Success;
 	}
-	pDraw->pScreen->DestroyPixmap(pMap);
     }
     return BadAlloc;
 }
diff --git a/dix/dispatch.c b/dix/dispatch.c
index 2d17adf..34213cf 100644
--- a/dix/dispatch.c
+++ b/dix/dispatch.c
@@ -1419,7 +1419,6 @@ CreatePmap:
 	}
 	if (AddResource(stuff->pid, RT_PIXMAP, (pointer)pMap))
 	    return Success;
-	(*pDraw->pScreen->DestroyPixmap)(pMap);
     }
     return BadAlloc;
 }
commit 8f69c935f6d06ad92fd0e8d9fcb3cde86cd258f5
Author: Jamey Sharp <jamey at minilop.net>
Date:   Fri Sep 17 02:27:59 2010 +0200

    Eliminate MAXSCREENS-sized CursorScreenKey array.
    
    Use new per-screen privates API instead.
    
    Commit by Jamey Sharp and Josh Triplett.
    
    Signed-off-by: Jamey Sharp <jamey at minilop.net>
    Signed-off-by: Josh Triplett <josh at joshtriplett.org>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/dix/cursor.c b/dix/cursor.c
index c191c1e..f29cb11 100644
--- a/dix/cursor.c
+++ b/dix/cursor.c
@@ -72,7 +72,7 @@ typedef struct _GlyphShare {
 
 static GlyphSharePtr sharedGlyphs = (GlyphSharePtr)NULL;
 
-DevPrivateKeyRec cursorScreenDevPriv[MAXSCREENS];
+DevScreenPrivateKeyRec cursorScreenDevPriv;
 
 #ifdef XFIXES
 static CARD32	cursorSerial;
diff --git a/dix/dispatch.c b/dix/dispatch.c
index 192c8c3..2d17adf 100644
--- a/dix/dispatch.c
+++ b/dix/dispatch.c
@@ -3911,7 +3911,7 @@ AddScreen(
 	return -1;
     }
 
-    dixRegisterPrivateKey(&cursorScreenDevPriv[i], PRIVATE_CURSOR, 0);
+    dixRegisterScreenPrivateKey(&cursorScreenDevPriv, pScreen, PRIVATE_CURSOR, 0);
 
     return i;
 }
diff --git a/hw/dmx/dmxcursor.h b/hw/dmx/dmxcursor.h
index 5242268..fc2e118 100644
--- a/hw/dmx/dmxcursor.h
+++ b/hw/dmx/dmxcursor.h
@@ -64,9 +64,9 @@ extern void dmxBECreateCursor(ScreenPtr pScreen, CursorPtr pCursor);
 extern Bool dmxBEFreeCursor(ScreenPtr pScreen, CursorPtr pCursor);
 
 #define DMX_GET_CURSOR_PRIV(_pCursor, _pScreen) ((dmxCursorPrivPtr) \
-    dixLookupPrivate(&(_pCursor)->devPrivates, CursorScreenKey(_pScreen)))
+    dixLookupScreenPrivate(&(_pCursor)->devPrivates, CursorScreenKey, _pScreen))
 
 #define DMX_SET_CURSOR_PRIV(_pCursor, _pScreen, v) \
-    dixSetPrivate(&(_pCursor)->devPrivates, CursorScreenKey(_pScreen), v)
+    dixSetScreenPrivate(&(_pCursor)->devPrivates, CursorScreenKey, _pScreen, v)
 
 #endif /* DMXCURSOR_H */
diff --git a/hw/xfree86/modes/xf86Cursors.c b/hw/xfree86/modes/xf86Cursors.c
index 0667447..23c48eb 100644
--- a/hw/xfree86/modes/xf86Cursors.c
+++ b/hw/xfree86/modes/xf86Cursors.c
@@ -252,7 +252,7 @@ xf86_set_cursor_colors (ScrnInfoPtr scrn, int bg, int fg)
     CursorPtr		cursor = xf86_config->cursor;
     int			c;
     CARD8		*bits = cursor ?
-        dixLookupPrivate(&cursor->devPrivates, CursorScreenKey(screen))
+        dixLookupScreenPrivate(&cursor->devPrivates, CursorScreenKey, screen)
       : NULL;
 
     /* Save ARGB versions of these colors */
@@ -650,7 +650,7 @@ xf86_reload_cursors (ScreenPtr screen)
 
     if (cursor)
     {
-	void *src = dixLookupPrivate(&cursor->devPrivates, CursorScreenKey(screen));
+	void *src = dixLookupScreenPrivate(&cursor->devPrivates, CursorScreenKey, screen);
 #ifdef ARGB_CURSOR
 	if (cursor->bits->argb && cursor_info->LoadCursorARGB)
 	    (*cursor_info->LoadCursorARGB) (scrn, cursor);
diff --git a/hw/xfree86/ramdac/xf86Cursor.c b/hw/xfree86/ramdac/xf86Cursor.c
index 24c91cc..1e0f7e0 100644
--- a/hw/xfree86/ramdac/xf86Cursor.c
+++ b/hw/xfree86/ramdac/xf86Cursor.c
@@ -273,7 +273,7 @@ xf86CursorRealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCurs)
 	&pScreen->devPrivates, xf86CursorScreenKey);
 
     if (pCurs->refcnt <= 1)
-	dixSetPrivate(&pCurs->devPrivates, CursorScreenKey(pScreen), NULL);
+	dixSetScreenPrivate(&pCurs->devPrivates, CursorScreenKey, pScreen, NULL);
 
     return (*ScreenPriv->spriteFuncs->RealizeCursor)(pDev, pScreen, pCurs);
 }
@@ -286,8 +286,8 @@ xf86CursorUnrealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen,
 	&pScreen->devPrivates, xf86CursorScreenKey);
 
     if (pCurs->refcnt <= 1) {
-	free(dixLookupPrivate(&pCurs->devPrivates, CursorScreenKey(pScreen)));
-	dixSetPrivate(&pCurs->devPrivates, CursorScreenKey(pScreen), NULL);
+	free(dixLookupScreenPrivate(&pCurs->devPrivates, CursorScreenKey, pScreen));
+	dixSetScreenPrivate(&pCurs->devPrivates, CursorScreenKey, pScreen, NULL);
     }
 
     return (*ScreenPriv->spriteFuncs->UnrealizeCursor)(pDev, pScreen, pCurs);
diff --git a/hw/xfree86/ramdac/xf86HWCurs.c b/hw/xfree86/ramdac/xf86HWCurs.c
index dd2b78f..f9b09fc 100644
--- a/hw/xfree86/ramdac/xf86HWCurs.c
+++ b/hw/xfree86/ramdac/xf86HWCurs.c
@@ -123,7 +123,7 @@ xf86SetCursor(ScreenPtr pScreen, CursorPtr pCurs, int x, int y)
 	return;
     }
 
-    bits = dixLookupPrivate(&pCurs->devPrivates, CursorScreenKey(pScreen));
+    bits = dixLookupScreenPrivate(&pCurs->devPrivates, CursorScreenKey, pScreen);
 
     x -= infoPtr->pScrn->frameX0 + ScreenPriv->HotX;
     y -= infoPtr->pScrn->frameY0 + ScreenPriv->HotY;
@@ -133,7 +133,7 @@ xf86SetCursor(ScreenPtr pScreen, CursorPtr pCurs, int x, int y)
 #endif
     if (!bits) {
 	bits = (*infoPtr->RealizeCursor)(infoPtr, pCurs);
-	dixSetPrivate(&pCurs->devPrivates, CursorScreenKey(pScreen), bits);
+	dixSetScreenPrivate(&pCurs->devPrivates, CursorScreenKey, pScreen, bits);
     }
 
     if (!(infoPtr->Flags & HARDWARE_CURSOR_UPDATE_UNHIDDEN))
diff --git a/hw/xnest/XNCursor.h b/hw/xnest/XNCursor.h
index d3b18bd..473b201 100644
--- a/hw/xnest/XNCursor.h
+++ b/hw/xnest/XNCursor.h
@@ -30,10 +30,10 @@ typedef struct {
 } xnestPrivCursor;
 
 #define xnestGetCursorPriv(pCursor, pScreen) ((xnestPrivCursor *) \
-    dixLookupPrivate(&(pCursor)->devPrivates, CursorScreenKey(pScreen)))
+    dixLookupScreenPrivate(&(pCursor)->devPrivates, CursorScreenKey, pScreen))
 
 #define xnestSetCursorPriv(pCursor, pScreen, v) \
-    dixSetPrivate(&(pCursor)->devPrivates, CursorScreenKey(pScreen), v)
+    dixSetScreenPrivate(&(pCursor)->devPrivates, CursorScreenKey, pScreen, v)
 
 #define xnestCursor(pCursor, pScreen) \
   (xnestGetCursorPriv(pCursor, pScreen)->cursor)
diff --git a/include/cursor.h b/include/cursor.h
index 59978d4..394383a 100644
--- a/include/cursor.h
+++ b/include/cursor.h
@@ -63,8 +63,8 @@ struct _DeviceIntRec;
 typedef struct _Cursor *CursorPtr;
 typedef struct _CursorMetric *CursorMetricPtr;
 
-extern _X_EXPORT DevPrivateKeyRec cursorScreenDevPriv[MAXSCREENS];
-#define CursorScreenKey(pScreen) (cursorScreenDevPriv + (pScreen)->myNum)
+extern _X_EXPORT DevScreenPrivateKeyRec cursorScreenDevPriv;
+#define CursorScreenKey (&cursorScreenDevPriv)
 
 extern _X_EXPORT CursorPtr rootCursor;
 
commit c96a43888ceae72bf89c66de911120c0b6b7a71a
Author: Jamey Sharp <jamey at minilop.net>
Date:   Sat Jul 10 09:28:47 2010 -0700

    Revert "Bug #6924: Restore the ABI for DrawableRec and ColormapRec to the state"
    
    This reverts commit bc0c56c407117d1545e20d21f7d30eb3472d618b since we're
    breaking ABI anyway.
    
    Conflicts:
    
    	ChangeLog
    	dix/colormap.c
    	dix/pixmap.c
    	dix/window.c
    	include/pixmapstr.h
    
    Signed-off-by: Jamey Sharp <jamey at minilop.net>
    Reviewed-by: Aaron Plattner <aplattner at nvidia.com>

diff --git a/dix/colormap.c b/dix/colormap.c
index 0e1feb6..038457d 100644
--- a/dix/colormap.c
+++ b/dix/colormap.c
@@ -287,13 +287,6 @@ CreateColormap (Colormap mid, ScreenPtr pScreen, VisualPtr pVisual,
 	if (!pmap)
 	    return BadAlloc;
     }
-#if defined(_XSERVER64)
-    pmap->pad0 = 0;
-    pmap->pad1 = 0;
-#if (X_BYTE_ORDER == X_LITTLE_ENDIAN)
-    pmap->pad2 = 0;
-#endif
-#endif
     pmap->red = (EntryPtr)((char *)pmap + sizeof(ColormapRec));    
     sizebytes = size * sizeof(Entry);
     pmap->clientPixelsRed = (Pixel **)((char *)pmap->red + sizebytes);
diff --git a/include/colormapst.h b/include/colormapst.h
index b597e2c..bb79c86 100644
--- a/include/colormapst.h
+++ b/include/colormapst.h
@@ -48,8 +48,6 @@ SOFTWARE.
 #ifndef CMAPSTRUCT_H
 #define CMAPSTRUCT_H 1
 
-#include <X11/Xarch.h>
-
 #include "colormap.h"
 #include "screenint.h"
 #include "privates.h"
@@ -91,26 +89,15 @@ typedef struct _CMEntry
     Bool	fShared;
 } Entry;
 
-/*
- * COLORMAPs can be used for either Direct or Pseudo color.  PseudoColor
+/* COLORMAPs can be used for either Direct or Pseudo color.  PseudoColor
  * only needs one cell table, we arbitrarily pick red.  We keep track
- * of that table with freeRed, numPixelsRed, and clientPixelsRed
- *
- * The padN variables are unfortunate ABI BC. See fdo bug #6924.
- */
+ * of that table with freeRed, numPixelsRed, and clientPixelsRed */
 
 typedef struct _ColormapRec
 {
     VisualPtr	pVisual;
     short	class;		/* PseudoColor or DirectColor */
-#if defined(_LP64)
-    short	pad0;
-    XID		pad1;
-#endif
     XID		mid;		/* client's name for colormap */
-#if defined(_LP64) && (X_BYTE_ORDER == X_LITTLE_ENDIAN)
-    XID		pad2;
-#endif
     ScreenPtr	pScreen;	/* screen map is associated with */
     short	flags;		/* 1 = IsDefault
 				 * 2 = AllAllocated */
commit 13ac1ba480ee3e89163825cd2777f9a6e9dcbc9f
Author: Alan Coopersmith <alan.coopersmith at oracle.com>
Date:   Tue May 31 19:42:48 2011 -0700

    Remove unused ClientStateCheckingSecurity & ClientStateCheckedSecurity
    
    Appear to be leftovers from the XC-QUERY-SECURITY code deleted in 2007
    (commit 375864cb74cced40ae688078b1f7750998972535).
    Nothing left ever set clientState to ClientStateCheckingSecurity.
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
    Reviewed-by: Julien Cristau <jcristau at debian.org>

diff --git a/dix/dispatch.c b/dix/dispatch.c
index 192c8c3..e21f08f 100644
--- a/dix/dispatch.c
+++ b/dix/dispatch.c
@@ -3714,9 +3714,7 @@ ProcEstablishConnection(ClientPtr client)
      * So we don't want to send the connection setup info yet, since
      * the auth step isn't really done.
      */
-    if (client->clientState == ClientStateCheckingSecurity)
-	client->clientState = ClientStateCheckedSecurity;
-    else if (client->clientState != ClientStateAuthenticating)
+    if (client->clientState != ClientStateAuthenticating)
 	return(SendConnSetup(client, reason));
     return Success;
 }
diff --git a/include/dixstruct.h b/include/dixstruct.h
index 443e8b0..90e617b 100644
--- a/include/dixstruct.h
+++ b/include/dixstruct.h
@@ -60,9 +60,8 @@ typedef enum {ClientStateInitial,
 	      ClientStateAuthenticating,
 	      ClientStateRunning,
 	      ClientStateRetained,
-	      ClientStateGone,
-	      ClientStateCheckingSecurity,
-	      ClientStateCheckedSecurity} ClientState;
+	      ClientStateGone
+} ClientState;
 
 #ifdef XFIXES
 typedef struct _saveSet {
commit 78f946c297081d39d312e05928146c78f59fedcb
Author: Alan Coopersmith <alan.coopersmith at oracle.com>
Date:   Thu May 19 23:26:31 2011 -0700

    sun_init.c: Implement novtswitch & sharevts for Solaris
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
    Reviewed-by: John Martin <john.m.martin at oracle.com>

diff --git a/hw/xfree86/os-support/solaris/sun_init.c b/hw/xfree86/os-support/solaris/sun_init.c
index d8c897d..800fc1c 100644
--- a/hw/xfree86/os-support/solaris/sun_init.c
+++ b/hw/xfree86/os-support/solaris/sun_init.c
@@ -186,6 +186,11 @@ xf86OpenConsole(void)
 	    xf86Info.vtno = VTnum;
 	    from = X_CMDLINE;
 	}
+	else if (xf86Info.ShareVTs)
+	{
+	    xf86Info.vtno = vtinfo.v_active;
+	    from = X_CMDLINE;
+	}
 	else
 	{
 	    if ((ioctl(fd, VT_OPENQRY, &xf86Info.vtno) < 0) ||
@@ -217,6 +222,9 @@ OPENCONSOLE:
 	chown(consoleDev, getuid(), getgid());
 
 #ifdef HAS_USL_VTS
+	if (xf86Info.ShareVTs)
+	    return;
+
 	if (vtEnabled)
 	{
 	    /*
@@ -261,12 +269,13 @@ OPENCONSOLE:
     else /* serverGeneration != 1 */
     {
 #ifdef HAS_USL_VTS
-	if (vtEnabled)
+	if (vtEnabled && !xf86Info.ShareVTs)
 	{
 	    /*
 	     * Now re-get the VT
 	     */
-	    switch_to(xf86Info.vtno, "xf86OpenConsole");
+	    if (xf86Info.autoVTSwitch)
+		switch_to(xf86Info.vtno, "xf86OpenConsole");
 
 #ifdef VT_SET_CONSUSER /* added in snv_139 */
 	    if (strcmp(display, "0") == 0)
@@ -355,7 +364,8 @@ xf86CloseConsole(void)
 	}
 
 	/* Activate the VT that X was started on */
-	switch_to(xf86StartVT, "xf86CloseConsole");
+	if (xf86Info.autoVTSwitch)
+	    switch_to(xf86StartVT, "xf86CloseConsole");
     }
 #endif /* HAS_USL_VTS */
 
commit 87cc83474d9890d14d9bc60926a97bd0d5b059af
Author: Jamey Sharp <jamey at minilop.net>
Date:   Sun Sep 18 20:47:04 2011 -0500

    Replace XmuSnprintf with snprintf.
    
    Alan Coopersmith explains:
    
    	XmuSnprintf() can be replaced by snprintf() now. (It was a
    	implementation X provided for it's libraries to use in the days
    	before all platforms we cared about had snprintf in libc.)
    
    Reported-by: walter harms <wharms at bfs.de>
    Signed-off-by: Jamey Sharp <jamey at minilop.net>
    Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com>

diff --git a/hw/dmx/config/xdmxconfig.c b/hw/dmx/config/xdmxconfig.c
index 2de7f2b..3165ba0 100644
--- a/hw/dmx/config/xdmxconfig.c
+++ b/hw/dmx/config/xdmxconfig.c
@@ -49,7 +49,6 @@
 #include <X11/Xaw/Viewport.h>
 #include <X11/Xaw/Dialog.h>
 #include <X11/keysym.h>
-#include <X11/Xmu/SysUtil.h>
 #include "Canvas.h"
 
 #include "dmxparse.h"
@@ -199,8 +198,8 @@ static void dmxConfigDataUpdate(void)
         XtVaSetValues(ndbutton1,                XtNsensitive, False, NULL);
     } else {
         name = dmxConfigCurrent->name;
-        XmuSnprintf(cnambuf, sizeof(cnambuf), "%s", name ? name : "");
-	XmuSnprintf(cdimbuf, sizeof(cdimbuf), "%dx%d",
+        snprintf(cnambuf, sizeof(cnambuf), "%s", name ? name : "");
+        snprintf(cdimbuf, sizeof(cdimbuf), "%dx%d",
                     dmxConfigWallWidth, dmxConfigWallHeight);
         XtVaSetValues(cnamebox,   XtNlabel, cnambuf, XtNsensitive, True, NULL);
         XtVaSetValues(cdimbox,    XtNlabel, cdimbuf, XtNsensitive, True, NULL);
@@ -219,22 +218,22 @@ static void dmxConfigDataUpdate(void)
         XtVaSetValues(ddbutton,              XtNsensitive, False, NULL);
     } else {
         name = dmxConfigCurrentDisplay->name;
-        XmuSnprintf(nambuf, sizeof(nambuf), "%s", name ? name : "");
-        XmuSnprintf(dimbuf, sizeof(dimbuf), "%dx%d%c%d%c%d",
+        snprintf(nambuf, sizeof(nambuf), "%s", name ? name : "");
+        snprintf(dimbuf, sizeof(dimbuf), "%dx%d%c%d%c%d",
                     dmxConfigCurrentDisplay->scrnWidth,
                     dmxConfigCurrentDisplay->scrnHeight,
                     dmxConfigCurrentDisplay->scrnXSign < 0 ? '-' : '+',
                     dmxConfigCurrentDisplay->scrnX,
                     dmxConfigCurrentDisplay->scrnYSign < 0 ? '-' : '+',
                     dmxConfigCurrentDisplay->scrnY);
-        XmuSnprintf(rtbuf, sizeof(dimbuf), "%dx%d%c%d%c%d",
+        snprintf(rtbuf, sizeof(dimbuf), "%dx%d%c%d%c%d",
                     dmxConfigCurrentDisplay->rootWidth,
                     dmxConfigCurrentDisplay->rootHeight,
                     dmxConfigCurrentDisplay->rootXSign < 0 ? '-' : '+',
                     dmxConfigCurrentDisplay->rootX,
                     dmxConfigCurrentDisplay->rootYSign < 0 ? '-' : '+',
                     dmxConfigCurrentDisplay->rootY);
-        XmuSnprintf(offbuf, sizeof(offbuf), "@%dx%d",
+        snprintf(offbuf, sizeof(offbuf), "@%dx%d",
                     dmxConfigCurrentDisplay->rootXOrigin,
                     dmxConfigCurrentDisplay->rootYOrigin);
         XtVaSetValues(namebox, XtNlabel, nambuf, XtNsensitive, True, NULL);
@@ -596,14 +595,14 @@ static void dmxConfigCanCallback(Widget w, XtPointer closure,
 static void dmxConfigECCallback(Widget w, XtPointer closure,
                                 XtPointer callData)
 {
-    char buf[256];              /* RATS: Only used in XmuSnprintf */
+    char buf[256];              /* RATS: Only used in snprintf */
     
     if (!dmxConfigCurrent) return;
     dmxConfigSetPopupPosition(ecpopup);
     XtVaSetValues(ecdialog0, XtNvalue,
                   dmxConfigCurrent->name ? dmxConfigCurrent->name : "",
                   NULL);
-    XmuSnprintf(buf, sizeof(buf), "%dx%d",
+    snprintf(buf, sizeof(buf), "%dx%d",
                 dmxConfigCurrent->width, dmxConfigCurrent->height);
     XtVaSetValues(ecdialog1, XtNvalue, buf, NULL);
     XtPopup(ecpopup, XtGrabExclusive);
@@ -692,7 +691,7 @@ static void dmxConfigECCanCallback(Widget w, XtPointer closure,
 static void dmxConfigEDCallback(Widget w, XtPointer closure,
                                 XtPointer callData)
 {
-    char buf[256];              /* RATS: Only used in XmuSnprintf */
+    char buf[256];              /* RATS: Only used in snprintf */
     
     if (!dmxConfigCurrent || !dmxConfigCurrentDisplay) return;
     dmxConfigSetPopupPosition(edpopup);
@@ -701,7 +700,7 @@ static void dmxConfigEDCallback(Widget w, XtPointer closure,
                   ? dmxConfigCurrentDisplay->name
                   : "",
                   NULL);
-    XmuSnprintf(buf, sizeof(buf), "%dx%d%c%d%c%d",
+    snprintf(buf, sizeof(buf), "%dx%d%c%d%c%d",
                 dmxConfigCurrentDisplay->scrnWidth,
                 dmxConfigCurrentDisplay->scrnHeight,
                 dmxConfigCurrentDisplay->scrnXSign < 0 ? '-' : '+',
@@ -709,7 +708,7 @@ static void dmxConfigEDCallback(Widget w, XtPointer closure,
                 dmxConfigCurrentDisplay->scrnYSign < 0 ? '-' : '+',
                 dmxConfigCurrentDisplay->scrnY);
     XtVaSetValues(eddialog1, XtNvalue, buf, NULL);
-    XmuSnprintf(buf, sizeof(buf), "@%dx%d",
+    snprintf(buf, sizeof(buf), "@%dx%d",
                 dmxConfigCurrentDisplay->rootXOrigin,
                 dmxConfigCurrentDisplay->rootYOrigin);
     XtVaSetValues(eddialog2, XtNvalue, buf, NULL);
diff --git a/hw/dmx/dmxclient.h b/hw/dmx/dmxclient.h
index c45f71f..f0f235f 100644
--- a/hw/dmx/dmxclient.h
+++ b/hw/dmx/dmxclient.h
@@ -82,7 +82,6 @@ typedef XID           KeySym64;
 #include <X11/Xutil.h>
 #include <X11/Xatom.h>
 #include <X11/cursorfont.h>
-#include <X11/Xmu/SysUtil.h>    /* For XmuSnprintf */
 
 #include <X11/extensions/shape.h>
 
diff --git a/hw/dmx/dmxinit.c b/hw/dmx/dmxinit.c
index bc1509b..165476c 100644
--- a/hw/dmx/dmxinit.c
+++ b/hw/dmx/dmxinit.c
@@ -56,6 +56,7 @@
 #include "dmxpict.h"
 
 #include <X11/Xos.h>                /* For gettimeofday */
+#include <X11/Xmu/SysUtil.h>        /* For XmuGetHostname */
 #include "dixstruct.h"
 #ifdef PANORAMIX
 #include "panoramiXsrv.h"
@@ -131,7 +132,7 @@ static int dmxErrorHandler(Display *dpy, XErrorEvent *ev)
 
                                 /* Find major opcode name */
     if (ev->request_code < 128) {
-        XmuSnprintf(request, sizeof(request), "%d", ev->request_code);
+        snprintf(request, sizeof(request), "%d", ev->request_code);
         XGetErrorDatabaseText(dpy, "XRequest", request, "", buf, sizeof(buf));
     } else {
         for (ext = dpy->ext_procs;
@@ -145,8 +146,8 @@ static int dmxErrorHandler(Display *dpy, XErrorEvent *ev)
 
                                 /* Find minor opcode name */
     if (ev->request_code >= 128 && ext) {
-        XmuSnprintf(request, sizeof(request), "%d", ev->request_code);
-        XmuSnprintf(request, sizeof(request), "%s.%d",
+        snprintf(request, sizeof(request), "%d", ev->request_code);
+        snprintf(request, sizeof(request), "%s.%d",
                     ext->name, ev->minor_code);
         XGetErrorDatabaseText(dpy, "XRequest", request, "", buf, sizeof(buf));
         dmxLog(dmxWarning, "                 Minor opcode: %d (%s)\n",
@@ -515,7 +516,7 @@ static const char *dmxExecOS(void)
     if (!initialized++) {
         memset(buffer, 0, sizeof(buffer));
         uname(&u);
-        XmuSnprintf(buffer, sizeof(buffer)-1, "%s %s %s",
+        snprintf(buffer, sizeof(buffer)-1, "%s %s %s",
                     u.sysname, u.release, u.version);
     }
     return buffer;
@@ -530,7 +531,7 @@ static const char *dmxBuildCompiler(void)
     if (!initialized++) {
         memset(buffer, 0, sizeof(buffer));
 #if defined(__GNUC__) && defined(__GNUC_MINOR__) &&defined(__GNUC_PATCHLEVEL__)
-        XmuSnprintf(buffer, sizeof(buffer)-1, "gcc %d.%d.%d",
+        snprintf(buffer, sizeof(buffer)-1, "gcc %d.%d.%d",
                     __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__);
 #endif
     }
diff --git a/hw/dmx/dmxprop.c b/hw/dmx/dmxprop.c
index d4618e3..b4695dd 100644
--- a/hw/dmx/dmxprop.c
+++ b/hw/dmx/dmxprop.c
@@ -62,6 +62,7 @@
 #include "dmx.h"
 #include "dmxprop.h"
 #include "dmxlog.h"
+#include <X11/Xmu/SysUtil.h>        /* For XmuGetHostname */
 
 /** Holds the window id of all DMX windows on the backend X server. */
 #define DMX_ATOMNAME "DMX_NAME"
@@ -87,7 +88,7 @@ static const unsigned char *dmxPropertyIdentifier(void)
     if (initialized++) return (unsigned char *)buf;
     
     XmuGetHostname(hostname, sizeof(hostname));
-    XmuSnprintf(buf, sizeof(buf), "%s:%s:%s", DMX_IDENT, hostname, display);
+    snprintf(buf, sizeof(buf), "%s:%s:%s", DMX_IDENT, hostname, display);
     return (unsigned char *)buf;
 }
 
@@ -319,7 +320,7 @@ void dmxPropertyWindow(DMXScreenInfo *dmxScreen)
     Display             *dpy = dmxScreen->beDisplay;
     Window              win  = dmxScreen->scrnWin;
     DMXScreenInfo       *other;
-    char                buf[128]; /* RATS: only used with XmuSnprintf */
+    char                buf[128]; /* RATS: only used with snprintf */
 
     if (!dpy)
 	return; /* FIXME: What should be done here if Xdmx is started
@@ -336,12 +337,12 @@ void dmxPropertyWindow(DMXScreenInfo *dmxScreen)
                other->index, other->name, other->scrnWin);
     }
 
-    XmuSnprintf(buf, sizeof(buf), ".%d,%lu", dmxScreen->index,
+    snprintf(buf, sizeof(buf), ".%d,%lu", dmxScreen->index,
                 (long unsigned)win);
     XChangeProperty(dpy, RootWindow(dpy,0), atom, XA_STRING, 8,
                     PropModeAppend, (unsigned char *)buf, strlen(buf));
 
-    XmuSnprintf(buf, sizeof(buf), "%s,%d", id, dmxScreen->index);
+    snprintf(buf, sizeof(buf), "%s,%d", id, dmxScreen->index);
     XChangeProperty(dpy, win, atom, XA_STRING, 8,
                     PropModeAppend, (unsigned char *)buf, strlen(buf));
 }
diff --git a/hw/dmx/doc/dmx.xml b/hw/dmx/doc/dmx.xml
index 8dbb7d8..ce472c2 100644
--- a/hw/dmx/doc/dmx.xml
+++ b/hw/dmx/doc/dmx.xml
@@ -3392,7 +3392,7 @@ Unrepaired warnings are as follows:
 <orderedlist>
     <listitem><para>
         Fixed-size buffers are used in many areas, but code has been
-        added to protect against buffer overflows (e.g., XmuSnprint).
+        added to protect against buffer overflows (e.g., snprintf).
         The only instances that have not yet been fixed are in
         config/xdmxconfig.c (which is not part of the Xdmx server) and
         input/usb-common.c.
diff --git a/hw/dmx/examples/dmxwininfo.c b/hw/dmx/examples/dmxwininfo.c
index 6cf1d41..3d027d5 100644
--- a/hw/dmx/examples/dmxwininfo.c
+++ b/hw/dmx/examples/dmxwininfo.c
@@ -39,7 +39,6 @@
 #include <string.h>
 #include <X11/Xlib.h>
 #include <X11/Xutil.h>
-#include <X11/Xmu/SysUtil.h>
 #include <X11/extensions/dmxext.h>
 
 static const char *FontName = "fixed";
@@ -80,7 +79,7 @@ EventLoop(Display *dpy, Window win, GC gc)
             y += 20;
             for (i = 0; i < count; i++) {
                char str[500];
-               XmuSnprintf(str, sizeof(str),
+               snprintf(str, sizeof(str),
                        "screen %d:  pos: %dx%d+%d+%d  visible: %dx%d+%d+%d",
                        winInfo[i].screen,
                        winInfo[i].pos.width, winInfo[i].pos.height,
diff --git a/hw/dmx/input/dmxinputinit.c b/hw/dmx/input/dmxinputinit.c
index 1b067c7..16ecae3 100644
--- a/hw/dmx/input/dmxinputinit.c
+++ b/hw/dmx/input/dmxinputinit.c
@@ -671,9 +671,9 @@ static char *dmxMakeUniqueDeviceName(DMXLocalInputInfoPtr dmxLocal)
     }
 
     switch (dmxLocal->type) {
-    case DMX_LOCAL_KEYBOARD: XmuSnprintf(buf, LEN, "Keyboard%d", k++); break;
-    case DMX_LOCAL_MOUSE:    XmuSnprintf(buf, LEN, "Mouse%d", m++);    break;
-    default:                 XmuSnprintf(buf, LEN, "Other%d", o++);    break;
+    case DMX_LOCAL_KEYBOARD: snprintf(buf, LEN, "Keyboard%d", k++); break;
+    case DMX_LOCAL_MOUSE:    snprintf(buf, LEN, "Mouse%d", m++);    break;
+    default:                 snprintf(buf, LEN, "Other%d", o++);    break;
     }
 
     return buf;
diff --git a/hw/dmx/input/lnx-keyboard.c b/hw/dmx/input/lnx-keyboard.c
index 5b92f3b..06e9ec7 100644
--- a/hw/dmx/input/lnx-keyboard.c
+++ b/hw/dmx/input/lnx-keyboard.c
@@ -430,10 +430,10 @@ static int kbdLinuxOpenVT(int vtno)
     int        fd = -1;
     int        i;
     const char *vcs[] = { "/dev/vc/", "/dev/tty", NULL };
-    char       name[64];        /* RATS: Only used in XmuSnprintf */
+    char       name[64];        /* RATS: Only used in snprintf */
 
     for (i = 0; vcs[i]; i++) {
-        XmuSnprintf(name, sizeof(name), "%s%d", vcs[i], vtno);
+        snprintf(name, sizeof(name), "%s%d", vcs[i], vtno);
         if ((fd = open(name, O_RDWR | O_NONBLOCK, 0)) >= 0) break;
     }
     if (fd < 0)
diff --git a/hw/dmx/input/usb-common.c b/hw/dmx/input/usb-common.c
index 25479ae..944033e 100644
--- a/hw/dmx/input/usb-common.c
+++ b/hw/dmx/input/usb-common.c
@@ -272,7 +272,7 @@ device. */
 void usbInit(DevicePtr pDev, usbType type)
 {
     GETPRIV;
-    char          name[64];            /* RATS: Only used in XmuSnprintf */
+    char          name[64];            /* RATS: Only used in snprintf */
     int           i, j, k;
     char          buf[256] = { 0, };   /* RATS: Use ok */
     int           version;
@@ -284,7 +284,7 @@ void usbInit(DevicePtr pDev, usbType type)
     if (priv->fd >=0) return;
 
     for (i = 0; i < 32; i++) {
-        XmuSnprintf(name, sizeof(name), "/dev/input/event%d", i);
+        snprintf(name, sizeof(name), "/dev/input/event%d", i);
         if ((priv->fd = open(name, O_RDWR | O_NONBLOCK, 0)) >= 0) {
             ioctl(priv->fd, EVIOCGVERSION, &version);
             ioctl(priv->fd, EVIOCGNAME(sizeof(buf)), buf);
commit df4eeb1256c7c5e7a3f88f10da2915c7a07a8db8
Author: Jamey Sharp <jamey at minilop.net>
Date:   Tue Jun 8 13:58:04 2010 -0700

    xnest: Delete unused nClipRects GC-private field.
    
    This field was never read at any time in the git history.
    
    Signed-off-by: Jamey Sharp <jamey at minilop.net>
    Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com>

diff --git a/hw/xnest/GC.c b/hw/xnest/GC.c
index 7968b4f..48fe4dc 100644
--- a/hw/xnest/GC.c
+++ b/hw/xnest/GC.c
@@ -81,7 +81,6 @@ xnestCreateGC(GCPtr pGC)
   xnestGCPriv(pGC)->gc = XCreateGC(xnestDisplay, 
 				   xnestDefaultDrawables[pGC->depth], 
 				   0L, NULL);
-  xnestGCPriv(pGC)->nClipRects = 0;
 
   return True;
 }
@@ -282,7 +281,6 @@ xnestChangeClip(GCPtr pGC, int type, pointer pValue, int nRects)
 
   pGC->clientClipType = type;
   pGC->clientClip = pValue;
-  xnestGCPriv(pGC)->nClipRects = nRects;
 }
 
 void
@@ -294,7 +292,6 @@ xnestDestroyClip(GCPtr pGC)
  
   pGC->clientClipType = CT_NONE;
   pGC->clientClip = NULL;
-  xnestGCPriv(pGC)->nClipRects = 0;
 }
 
 void
diff --git a/hw/xnest/XNGC.h b/hw/xnest/XNGC.h
index 9f10456..c4a6cef 100644
--- a/hw/xnest/XNGC.h
+++ b/hw/xnest/XNGC.h
@@ -19,7 +19,6 @@ is" without express or implied warranty.
 
 typedef struct {
   XlibGC gc;
-  int nClipRects;
 } xnestPrivGC;
 
 extern DevPrivateKeyRec xnestGCPrivateKeyRec;
commit 53a4744b69ab76ecabdde5dabfb56830570c0f4e
Author: Jamey Sharp <jamey at minilop.net>
Date:   Sat Sep 18 01:23:12 2010 +0200

    XineramaInitData ignores its argument. Quit passing one.
    
    Also fix up XineramaInitData's caller, XineramaReinitData.
    
    Commit by Jamey Sharp and Josh Triplett.
    
    Signed-off-by: Jamey Sharp <jamey at minilop.net>
    Signed-off-by: Josh Triplett <josh at joshtriplett.org>
    Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com>

diff --git a/Xext/panoramiX.c b/Xext/panoramiX.c
index 00afe94..425c10c 100644
--- a/Xext/panoramiX.c
+++ b/Xext/panoramiX.c
@@ -388,7 +388,7 @@ XineramaRegisterConnectionBlockCallback(void (*func)(void))
     return TRUE;
 }
 
-static void XineramaInitData(ScreenPtr pScreen)
+static void XineramaInitData(void)
 {
     int i, w, h;
 
@@ -397,7 +397,7 @@ static void XineramaInitData(ScreenPtr pScreen)
 	BoxRec TheBox;
 	RegionRec ScreenRegion;
 
-        pScreen = screenInfo.screens[i];
+	ScreenPtr pScreen = screenInfo.screens[i];
 
 	TheBox.x1 = pScreen->x;
 	TheBox.x2 = TheBox.x1 + pScreen->width;
@@ -414,7 +414,7 @@ static void XineramaInitData(ScreenPtr pScreen)
     PanoramiXPixHeight = screenInfo.screens[0]->y + screenInfo.screens[0]->height;
 
     FOR_NSCREENS_FORWARD_SKIP(i) {
-	pScreen = screenInfo.screens[i];
+	ScreenPtr pScreen = screenInfo.screens[i];
 	w = pScreen->x + pScreen->width;
 	h = pScreen->y + pScreen->height;
 
@@ -425,10 +425,10 @@ static void XineramaInitData(ScreenPtr pScreen)
     }
 }
 
-void XineramaReinitData(ScreenPtr pScreen)
+void XineramaReinitData(void)
 {
     RegionUninit(&PanoramiXScreenRegion);
-    XineramaInitData(pScreen);
+    XineramaInitData();
 }
 
 /*
@@ -525,7 +525,7 @@ void PanoramiXExtensionInit(int argc, char *argv[])
 	return;
     }
   
-    XineramaInitData(pScreen);
+    XineramaInitData();
 
     /*
      *	Put our processes into the ProcVector
diff --git a/Xext/panoramiXsrv.h b/Xext/panoramiXsrv.h
index 6fc903b..39d4952 100644
--- a/Xext/panoramiXsrv.h
+++ b/Xext/panoramiXsrv.h
@@ -19,7 +19,7 @@ extern _X_EXPORT PanoramiXRes * PanoramiXFindIDByScrnum(RESTYPE, XID, int);
 extern _X_EXPORT Bool XineramaRegisterConnectionBlockCallback(void (*func)(void));
 extern _X_EXPORT int XineramaDeleteResource(pointer, XID);
 
-extern _X_EXPORT void XineramaReinitData(ScreenPtr);
+extern _X_EXPORT void XineramaReinitData(void);
 
 extern _X_EXPORT RESTYPE XRC_DRAWABLE;
 extern _X_EXPORT RESTYPE XRT_WINDOW;
diff --git a/hw/dmx/dmxextension.c b/hw/dmx/dmxextension.c
index db5709e..80d11ee 100644
--- a/hw/dmx/dmxextension.c
+++ b/hw/dmx/dmxextension.c
@@ -455,7 +455,7 @@ static void dmxSetRootWindowOrigin(int idx, int x, int y)
     pScreen->y = dmxScreen->rootYOrigin;
 
     /* Recalculate the Xinerama regions and data structs */
-    XineramaReinitData(pScreen);
+    XineramaReinitData();
 
     /* Adjust each of the root window's children */
     if (!idx) ReinitializeRootWindow(screenInfo.screens[0]->root, xoff, yoff);
commit b85c10a35d44ad695797d0d19757e5f62eab4b98
Author: Jamey Sharp <jamey at minilop.net>
Date:   Tue May 25 16:23:31 2010 -0700

    dmx: Fix some "no previous prototype" warnings by making functions static.
    
    Signed-off-by: Jamey Sharp <jamey at minilop.net>
    Reviewed-by: Matt Turner <mattst88 at gmail.com>

diff --git a/hw/dmx/glxProxy/glxcmds.c b/hw/dmx/glxProxy/glxcmds.c
index f79264e..a76201d 100644
--- a/hw/dmx/glxProxy/glxcmds.c
+++ b/hw/dmx/glxProxy/glxcmds.c
@@ -59,9 +59,6 @@
 extern __GLXFBConfig **__glXFBConfigs;
 extern int            __glXNumFBConfigs;
 
-extern __GLXFBConfig *glxLookupFBConfig( GLXFBConfigID id );
-extern __GLXFBConfig *glxLookupFBConfigByVID( VisualID vid );
-extern __GLXFBConfig *glxLookupBackEndFBConfig( GLXFBConfigID id, int screen );
 extern int glxIsExtensionSupported( char *ext );
 extern int __glXGetFBConfigsSGIX(__GLXclientState *cl, GLbyte *pc);
 
@@ -70,6 +67,44 @@ extern int __glXGetFBConfigsSGIX(__GLXclientState *cl, GLbyte *pc);
              (x) - dmxScreen->glxErrorBase + __glXerrorBase \
 	     : (x) )
 
+static __GLXFBConfig *glxLookupFBConfig( GLXFBConfigID id )
+{
+   int i,j;
+
+   for (i=0, j=0; i<__glXNumFBConfigs; i++,j+=(__glXNumActiveScreens+1) ) {
+      if ( __glXFBConfigs[j]->id == id)
+	 return __glXFBConfigs[j];
+   }
+
+   return NULL;
+}
+
+static __GLXFBConfig *glxLookupFBConfigByVID( VisualID vid )
+{
+   int i,j;
+
+   for (i=0, j=0; i<__glXNumFBConfigs; i++,j+=(__glXNumActiveScreens+1) ) {
+      if ( __glXFBConfigs[j]->associatedVisualId == vid)
+	 return __glXFBConfigs[j];
+   }
+
+   return NULL;
+}
+
+static __GLXFBConfig *glxLookupBackEndFBConfig( GLXFBConfigID id, int screen )
+{
+   int i;
+   int j;
+
+   for (i=0, j=0; i<__glXNumFBConfigs; i++,j+=(__glXNumActiveScreens+1) ) {
+      if ( __glXFBConfigs[j]->id == id)
+	 return __glXFBConfigs[j+screen+1];
+   }
+
+   return NULL;
+
+}
+
 Display *GetBackEndDisplay( __GLXclientState *cl, int s )
 {
    if (! cl->be_displays[s] ) {
diff --git a/hw/dmx/glxProxy/glxscreens.c b/hw/dmx/glxProxy/glxscreens.c
index 4cbac66..01e041c 100644
--- a/hw/dmx/glxProxy/glxscreens.c
+++ b/hw/dmx/glxProxy/glxscreens.c
@@ -326,45 +326,6 @@ char *__glXGetServerString( unsigned int name )
 
 }
 
-
-__GLXFBConfig *glxLookupFBConfig( GLXFBConfigID id )
-{
-   int i,j;
-
-   for (i=0, j=0; i<__glXNumFBConfigs; i++,j+=(__glXNumActiveScreens+1) ) {
-      if ( __glXFBConfigs[j]->id == id) 
-	 return __glXFBConfigs[j];
-   }
-
-   return NULL;
-}
-
-__GLXFBConfig *glxLookupFBConfigByVID( VisualID vid )
-{
-   int i,j;
-
-   for (i=0, j=0; i<__glXNumFBConfigs; i++,j+=(__glXNumActiveScreens+1) ) {
-      if ( __glXFBConfigs[j]->associatedVisualId == vid) 
-	 return __glXFBConfigs[j];
-   }
-
-   return NULL;
-}
-
-__GLXFBConfig *glxLookupBackEndFBConfig( GLXFBConfigID id, int screen )
-{
-   int i;
-   int j;
-
-   for (i=0, j=0; i<__glXNumFBConfigs; i++,j+=(__glXNumActiveScreens+1) ) {
-      if ( __glXFBConfigs[j]->id == id) 
-	 return __glXFBConfigs[j+screen+1];
-   }
-
-   return NULL;
-
-}
-
 int glxIsExtensionSupported( char *ext )
 {
    return( strstr(ExtensionsString, ext) != NULL );
diff --git a/hw/dmx/glxProxy/render2swap.c b/hw/dmx/glxProxy/render2swap.c
index 81bb501..da9b565 100644
--- a/hw/dmx/glxProxy/render2swap.c
+++ b/hw/dmx/glxProxy/render2swap.c
@@ -32,7 +32,7 @@
 #include "unpack.h"
 #include "g_disptab.h"
 
-GLint __glEvalComputeK(GLenum target)
+static GLint __glEvalComputeK(GLenum target)
 {
     switch (target) {
     case GL_MAP1_VERTEX_4:
commit d423012e776a81a197cde86be5c6bd471a593c39
Author: Jamey Sharp <jamey at minilop.net>
Date:   Fri May 21 14:21:52 2010 -0700

    dmx: Fix a non-constant printf format string warning.
    
    Signed-off-by: Jamey Sharp <jamey at minilop.net>
    Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com>

diff --git a/hw/dmx/input/lnx-keyboard.c b/hw/dmx/input/lnx-keyboard.c
index 5bfb881..5b92f3b 100644
--- a/hw/dmx/input/lnx-keyboard.c
+++ b/hw/dmx/input/lnx-keyboard.c
@@ -429,11 +429,11 @@ static int kbdLinuxOpenVT(int vtno)
 {
     int        fd = -1;
     int        i;
-    const char *vcs[] = { "/dev/vc/%d", "/dev/tty%d", NULL };
+    const char *vcs[] = { "/dev/vc/", "/dev/tty", NULL };
     char       name[64];        /* RATS: Only used in XmuSnprintf */
 
     for (i = 0; vcs[i]; i++) {
-        XmuSnprintf(name, sizeof(name), vcs[i], vtno);
+        XmuSnprintf(name, sizeof(name), "%s%d", vcs[i], vtno);
         if ((fd = open(name, O_RDWR | O_NONBLOCK, 0)) >= 0) break;
     }
     if (fd < 0)
commit 7e127f12a24acb8f43055af0a9be1ec585bbed36
Author: Alan Coopersmith <alan.coopersmith at oracle.com>
Date:   Thu May 19 23:22:27 2011 -0700

    sun_init.c: Move vt switches to a switch_to helper function like lnx_init.c
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
    Reviewed-by: Julien Cristau <jcristau at debian.org>

diff --git a/hw/xfree86/os-support/solaris/sun_init.c b/hw/xfree86/os-support/solaris/sun_init.c
index 281a6df..d8c897d 100644
--- a/hw/xfree86/os-support/solaris/sun_init.c
+++ b/hw/xfree86/os-support/solaris/sun_init.c
@@ -63,6 +63,22 @@ static char consoleDev[PATH_MAX] = "/dev/fb";
    Used by hw/xfree86/common/xf86AutoConfig.c for VIS_GETIDENTIFIER */
 _X_HIDDEN char xf86SolarisFbDev[PATH_MAX] = "/dev/fb";
 
+static void
+switch_to(int vt, const char *from)
+{
+    int ret;
+
+    SYSCALL(ret = ioctl(xf86Info.consoleFd, VT_ACTIVATE, vt));
+    if (ret != 0)
+        xf86Msg(X_WARNING, "%s: VT_ACTIVATE failed: %s\n",
+		from, strerror(errno));
+
+    SYSCALL(ret = ioctl(xf86Info.consoleFd, VT_WAITACTIVE, vt));
+    if (ret != 0)
+        xf86Msg(X_WARNING, "%s: VT_WAITACTIVE failed: %s\n",
+		from, strerror(errno));
+}
+
 void
 xf86OpenConsole(void)
 {
@@ -206,11 +222,7 @@ OPENCONSOLE:
 	    /*
 	     * Now get the VT
 	     */
-	    if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0)
-		xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n");
-
-	    if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) != 0)
-		xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed\n");
+	    switch_to(xf86Info.vtno, "xf86OpenConsole");
 
 #ifdef VT_SET_CONSUSER /* added in snv_139 */
 	    if (strcmp(display, "0") == 0)
@@ -254,11 +266,7 @@ OPENCONSOLE:
 	    /*
 	     * Now re-get the VT
 	     */
-	    if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0)
-		xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n");
-
-	    if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) != 0)
-		xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed\n");
+	    switch_to(xf86Info.vtno, "xf86OpenConsole");
 
 #ifdef VT_SET_CONSUSER /* added in snv_139 */
 	    if (strcmp(display, "0") == 0)
@@ -347,7 +355,7 @@ xf86CloseConsole(void)
 	}
 
 	/* Activate the VT that X was started on */
-	ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86StartVT);
+	switch_to(xf86StartVT, "xf86CloseConsole");
     }
 #endif /* HAS_USL_VTS */
 
commit a00dc6af6e84d0bee3f69d8df89d7f68cb535d35
Author: Alan Coopersmith <alan.coopersmith at oracle.com>
Date:   Thu May 19 22:43:56 2011 -0700

    Xorg.man: Add -novtswitch and -sharevts options
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
    Reviewed-by: Julien Cristau <jcristau at debian.org>

diff --git a/hw/xfree86/man/Xorg.man b/hw/xfree86/man/Xorg.man
index c89b5ee..2fa72d6 100644
--- a/hw/xfree86/man/Xorg.man
+++ b/hw/xfree86/man/Xorg.man
@@ -334,6 +334,10 @@ as root (i.e, with real-uid 0).
 .B \-nosilk
 Disable Silken Mouse support.
 .TP 8
+.B \-novtswitch
+Disable the automatic switching on X server reset and shutdown to the
+VT that was active when the server started, if supported by the OS.
+.TP 8
 .B \-pixmap24
 Set the internal pixmap format for depth 24 pixmaps to 24 bits per pixel.
 The default is usually 32 bits per pixel.  There is normally little
@@ -376,6 +380,9 @@ and
 .B \-ggamma
 options.
 .TP 8
+.B \-sharevts
+Share virtual terminals with another X server, if supported by the OS.
+.TP 8
 .BI \-screen " screen-name"
 Use the __xconfigfile__(__filemansuffix__) file
 .B Screen
commit 93abda6bddf770dbfc3d4d0ada61ea84a7b7b9be
Author: Alan Coopersmith <alan.coopersmith at oracle.com>
Date:   Thu May 19 22:39:09 2011 -0700

    xfree86: move -novtswitch & -sharevts argument handling up to common layer
    
    Stop duplicating in each os-support variant before it gets replicated
    even further.
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
    Reviewed-by: Julien Cristau <jcristau at debian.org>
    Reviewed-by: Alexandr Shadchin <Alexandr.Shadchin at gmail.com>

diff --git a/hw/xfree86/common/xf86Globals.c b/hw/xfree86/common/xf86Globals.c
index 16d5557..f2e88c2 100644
--- a/hw/xfree86/common/xf86Globals.c
+++ b/hw/xfree86/common/xf86Globals.c
@@ -103,6 +103,8 @@ xf86InfoRec xf86Info = {
     .vtPendingNum               = -1,
 #endif
     .dontVTSwitch               = FALSE,
+    .autoVTSwitch               = TRUE,
+    .ShareVTs                   = FALSE,
     .dontZap                    = FALSE,
     .dontZoom                   = FALSE,
     .notrapSignals              = FALSE,
diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
index 71926f8..93ea333 100644
--- a/hw/xfree86/common/xf86Init.c
+++ b/hw/xfree86/common/xf86Init.c
@@ -1352,6 +1352,16 @@ ddxProcessArgument(int argc, char **argv, int i)
     xf86xkbdirFlag = TRUE;
     return 0;
   }
+  if (!strcmp(argv[i], "-novtswitch"))
+  {
+    xf86Info.autoVTSwitch = FALSE;
+    return 1;
+  }
+  if (!strcmp(argv[i], "-sharevts"))
+  {
+    xf86Info.ShareVTs = TRUE;
+    return 1;
+  }
 
   /* OS-specific processing */
   return xf86ProcessArgument(argc, argv, i);
@@ -1408,6 +1418,8 @@ ddxUseMsg(void)
   ErrorF("-version               show the server version\n");
   ErrorF("-showDefaultModulePath show the server default module path\n");
   ErrorF("-showDefaultLibPath    show the server default library path\n");
+  ErrorF("-novtswitch            don't automatically switch VT at reset & exit\n");
+  ErrorF("-sharevts              share VTs with another X server\n");
   /* OS-specific usage */
   xf86UseMsg();
   ErrorF("\n");
diff --git a/hw/xfree86/common/xf86Privstr.h b/hw/xfree86/common/xf86Privstr.h
index 608f9bd..cdc67cb 100644
--- a/hw/xfree86/common/xf86Privstr.h
+++ b/hw/xfree86/common/xf86Privstr.h
@@ -66,6 +66,8 @@ typedef struct {
     int			vtPendingNum;
 #endif
     Bool		dontVTSwitch;
+    Bool		autoVTSwitch;
+    Bool		ShareVTs;
     Bool		dontZap;
     Bool		dontZoom;
     Bool		notrapSignals;	/* don't exit cleanly - die at fault */
diff --git a/hw/xfree86/os-support/bsd/bsd_init.c b/hw/xfree86/os-support/bsd/bsd_init.c
index 123eb17..837a2f4 100644
--- a/hw/xfree86/os-support/bsd/bsd_init.c
+++ b/hw/xfree86/os-support/bsd/bsd_init.c
@@ -45,7 +45,6 @@ static int devConsoleFd = -1;
 #if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
 static int VTnum = -1;
 static int initialVT = -1;
-static Bool ShareVTs = FALSE;
 #endif
 
 #ifdef PCCONS_SUPPORT
@@ -266,7 +265,7 @@ xf86OpenConsole()
 	    }
 #endif
 acquire_vt:
-	    if (!ShareVTs) {
+	    if (!xf86Info.ShareVTs) {
 		    /*
 		     * now get the VT
 		     */
@@ -304,7 +303,7 @@ acquire_vt:
 		    {
 			FatalError("xf86OpenConsole: KDSETMODE KD_GRAPHICS failed");
 		    }
-	    } else { /* ShareVTs */
+	    } else { /* xf86Info.ShareVTs */
 		    close(xf86Info.consoleFd);
 	    }	
   	    break; 
@@ -320,7 +319,8 @@ acquire_vt:
     {
 	/* serverGeneration != 1 */
 #if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
-    	if (!ShareVTs) if (xf86Info.consType == SYSCONS || xf86Info.consType == PCVT)
+	if (!xf86Info.ShareVTs &&
+	    (xf86Info.consType == SYSCONS || xf86Info.consType == PCVT))
     	{
 	    if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0)
 	    {
@@ -393,7 +393,7 @@ xf86OpenSyscons()
 	    if (ioctl(fd, VT_GETACTIVE, &initialVT) < 0)
 		initialVT = -1;
 #endif
-            if (ShareVTs)
+            if (xf86Info.ShareVTs)
 		xf86Info.vtno = initialVT;
 
 	    if (xf86Info.vtno == -1)
@@ -655,7 +655,7 @@ xf86CloseConsole()
     struct vt_mode   VT;
 #endif
 
-    if (ShareVTs) return;
+    if (xf86Info.ShareVTs) return;
 
     switch (xf86Info.consType)
     {
@@ -723,11 +723,6 @@ xf86ProcessArgument(int argc, char *argv[], int i)
 		return 1;
 	}
 #if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
-	if (!strcmp(argv[i], "-sharevts"))
-	{	
-		ShareVTs = TRUE;
-		return 1;
-	}
 	if ((argv[i][0] == 'v') && (argv[i][1] == 't'))
 	{
 		if (sscanf(argv[i], "vt%2d", &VTnum) == 0 ||
diff --git a/hw/xfree86/os-support/linux/lnx_init.c b/hw/xfree86/os-support/linux/lnx_init.c
index 77dfb2f..9c91740 100644
--- a/hw/xfree86/os-support/linux/lnx_init.c
+++ b/hw/xfree86/os-support/linux/lnx_init.c
@@ -39,8 +39,6 @@
 #include <sys/stat.h>
 
 static Bool KeepTty = FALSE;
-static Bool VTSwitch = TRUE;
-static Bool ShareVTs = FALSE;
 static int activeVT = -1;
 
 static char vtname[11];
@@ -109,7 +107,7 @@ xf86OpenConsole(void)
 		    "xf86OpenConsole: Cannot open /dev/tty0 (%s)\n",
 		    strerror(errno));
 
-            if (ShareVTs)
+            if (xf86Info.ShareVTs)
             {
 		SYSCALL(ret = ioctl(fd, VT_GETSTATE, &vts));
 		if (ret < 0)
@@ -184,7 +182,7 @@ xf86OpenConsole(void)
 	}
 #endif
 
-        if (!ShareVTs)
+        if (!xf86Info.ShareVTs)
         {
             struct termios nTty;
 
@@ -240,7 +238,7 @@ xf86OpenConsole(void)
 	     * of Init?$#*&Device(). So I just place it here */
         }
     } else { 	/* serverGeneration != 1 */
-        if (!ShareVTs && VTSwitch)
+        if (!xf86Info.ShareVTs && xf86Info.autoVTSwitch)
         {
 	    /* now get the VT */
             switch_to(xf86Info.vtno, "xf86OpenConsole");
@@ -254,7 +252,7 @@ xf86CloseConsole(void)
     struct vt_mode   VT;
     int ret;
 
-    if (ShareVTs) {
+    if (xf86Info.ShareVTs) {
         close(xf86Info.consoleFd);
         return;
     }
@@ -286,7 +284,7 @@ xf86CloseConsole(void)
 		    strerror(errno));
     }
 
-    if (VTSwitch)
+    if (xf86Info.autoVTSwitch)
     {
         /*
          * Perform a switch back to the active VT when we were started
@@ -311,16 +309,7 @@ xf86ProcessArgument(int argc, char *argv[], int i)
 		KeepTty = TRUE;
 		return 1;
 	}
-        if (!strcmp(argv[i], "-novtswitch"))
-        {
-                VTSwitch = FALSE;
-                return 1;
-        }
-        if (!strcmp(argv[i], "-sharevts"))
-        {
-                ShareVTs = TRUE;
-                return 1;
-        }
+
 	if ((argv[i][0] == 'v') && (argv[i][1] == 't'))
 	{
 		if (sscanf(argv[i], "vt%2d", &xf86Info.vtno) == 0)
@@ -340,6 +329,4 @@ xf86UseMsg(void)
 	ErrorF("vtXX                   use the specified VT number\n");
 	ErrorF("-keeptty               ");
 	ErrorF("don't detach controlling tty (for debugging only)\n");
-	ErrorF("-novtswitch            don't immediately switch to new VT\n");
-	ErrorF("-sharevts              share VTs with another X server\n");
 }
commit d8d99e14b1241fd8c099d69b8d0ed0817585fe8d
Author: Jamey Sharp <jamey at minilop.net>
Date:   Wed Sep 14 09:52:58 2011 -0500

    configure.ac: Remove unreachable check for VM86 headers.
    
    "configure --with-int10" is not a valid configuration, and the check for
    sys/vm86.h and sys/io.h is not used. Delete it.
    
    Signed-off-by: Jamey Sharp <jamey at minilop.net>
    Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com>
    Reviewed-by: Gaetan Nadon <memsize at videotron.ca>

diff --git a/configure.ac b/configure.ac
index 93cd6a9..06cf9bf 100644
--- a/configure.ac
+++ b/configure.ac
@@ -702,10 +702,6 @@ AM_CONDITIONAL(SECURE_RPC, [test "x$SECURE_RPC" = xyes])
 AM_CONDITIONAL(INT10_VM86, [test "x$INT10" = xvm86])
 AM_CONDITIONAL(INT10_X86EMU, [test "x$INT10" = xx86emu])
 AM_CONDITIONAL(INT10_STUB, [test "x$INT10" = xstub])
-if test "x$INT10" = xyes; then
-	dnl VM86 headers
-	AC_CHECK_HEADERS([sys/vm86.h sys/io.h])
-fi
 
 dnl Handle installing libxf86config
 AM_CONDITIONAL(INSTALL_LIBXF86CONFIG, [test "x$INSTALL_LIBXF86CONFIG" = xyes])
diff --git a/include/dix-config.h.in b/include/dix-config.h.in
index 4710ef8..5facb11 100644
--- a/include/dix-config.h.in
+++ b/include/dix-config.h.in
@@ -209,9 +209,6 @@
    */
 #undef HAVE_SYS_DIR_H
 
-/* Define to 1 if you have the <sys/io.h> header file. */
-#undef HAVE_SYS_IO_H
-
 /* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'.
    */
 #undef HAVE_SYS_NDIR_H
@@ -225,9 +222,6 @@
 /* Define to 1 if you have the <sys/utsname.h> header file. */
 #undef HAVE_SYS_UTSNAME_H
 
-/* Define to 1 if you have the <sys/vm86.h> header file. */
-#undef HAVE_SYS_VM86_H
-
 /* Define to 1 if you have the <tslib.h> header file. */
 #undef HAVE_TSLIB_H
 
commit 94b2eea86319934316bdb013f6f3940685a88a2f
Author: Jamey Sharp <jamey at minilop.net>
Date:   Wed Sep 14 11:23:03 2011 -0500

    int10: Delete #if 0'd implementation that's older than our git history.
    
    Throughout the xserver git history, the generic portion of the int10
    module has always used other methods for reading the video BIOS. For
    some time now it's been purely libpciaccess based. This commented-out
    use of xf86ReadBIOS is entirely superfluous.
    
    Signed-off-by: Jamey Sharp <jamey at minilop.net>
    Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/hw/xfree86/int10/generic.c b/hw/xfree86/int10/generic.c
index fe8bb69..9940854 100644
--- a/hw/xfree86/int10/generic.c
+++ b/hw/xfree86/int10/generic.c
@@ -128,10 +128,6 @@ xf86ExtendedInitInt10(int entityIndex, int Flags)
     int screen;
     legacyVGARec vga;
  
-#if 0
-    CARD32 cs;
-#endif
-
     screen = (xf86FindScreenForEntity(entityIndex))->scrnIndex;
 
     options = xf86HandleInt10Options(xf86Screens[screen],entityIndex);
@@ -174,17 +170,9 @@ xf86ExtendedInitInt10(int entityIndex, int Flags)
 
     /*
      * Retrieve everything between V_BIOS and SYS_BIOS as some system BIOSes
-     * have executable code there.  Note that xf86ReadBIOS() can only read in
-     * 64kB at a time.
+     * have executable code there.
      */
     memset((char *)base + V_BIOS, 0, SYS_BIOS - V_BIOS);
-#if 0
-    for (cs = V_BIOS;  cs < SYS_BIOS;  cs += V_BIOS_SIZE)
-	if (xf86ReadBIOS(cs, 0, (unsigned char *)base + cs, V_BIOS_SIZE) <
-		V_BIOS_SIZE)
-	    xf86DrvMsg(screen, X_WARNING,
-		       "Unable to retrieve all of segment 0x%06X.\n", cs);
-#endif
     INTPriv(pInt)->highMemory = V_BIOS;
     
     if (xf86IsEntityPrimary(entityIndex) && !(initPrimary(options))) {
commit 6ad7bb69eebd5e5b4068bd9aa0b9a7168f075006
Author: Jamey Sharp <jamey at minilop.net>
Date:   Tue Sep 13 17:45:19 2011 -0500

    Remove PC98 support.
    
    Gaetan Nadon wrote:
    
        Alan Coopersmith wrote:
    
        "I think we recently dropped PC98 support from the X server, so I'd
        be okay with dropping the documentation now".
    
    Let's make them be right, shall we?
    
    Signed-off-by: Jamey Sharp <jamey at minilop.net>
    Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com>
    Acked-by: Gaetan Nadon <memsize at videotron.ca>
    Acked-by: Alan Coopersmith <alan.coopersmith at oracle.com>

diff --git a/configure.ac b/configure.ac
index 6c4fffd..93cd6a9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -582,9 +582,6 @@ AC_ARG_ENABLE(install-libxf86config,
 AC_ARG_ENABLE(visibility,     AC_HELP_STRING([--enable-visibility], [Enable symbol visibility (default: auto)]),
 				[SYMBOL_VISIBILITY=$enableval],
 				[SYMBOL_VISIBILITY=auto])
-AC_ARG_ENABLE(pc98,     	AC_HELP_STRING([--enable-pc98], [Enable PC98 support in Xorg (default: auto)]),
-				[SUPPORT_PC98=$enableval],
-				[SUPPORT_PC98=auto])
 
 dnl GLX build options
 AC_ARG_ENABLE(aiglx,          AS_HELP_STRING([--enable-aiglx], [Build accelerated indirect GLX (default: enabled)]),
@@ -1654,9 +1651,6 @@ if test "x$XORG" = xyes; then
 			XORG_CFLAGS="${XORG_CFLAGS} "'$(SOLARIS_ASM_CFLAGS)'
 		fi
 		AC_SUBST([SOLARIS_ASM_CFLAGS])
-		if test "x$SUPPORT_PC98" = xauto; then
-			SUPPORT_PC98="no"
-		fi
 		;;
 	  gnu*)
 		XORG_OS_SUBDIR="hurd"
@@ -1679,18 +1673,9 @@ if test "x$XORG" = xyes; then
 		xorg_bus_sparc="yes"
 		;;
 	  i*86)
-		if test "x$SUPPORT_PC98" = xauto; then
-			SUPPORT_PC98="yes"
-		fi
 		;;
 	esac
 
-	if test "x$SUPPORT_PC98" = xauto; then
-		SUPPORT_PC98="no"
-	fi
-	if test "x$SUPPORT_PC98" = xyes; then
-		AC_DEFINE(SUPPORT_PC98, 1, [Support PC98])
-	fi
 	if test "x$DGA" = xauto; then
 		PKG_CHECK_MODULES(DGA, $DGAPROTO, [DGA=yes], [DGA=no])
 	fi
diff --git a/hw/xfree86/common/xf86.h b/hw/xfree86/common/xf86.h
index 54332e3..e1e0cd7 100644
--- a/hw/xfree86/common/xf86.h
+++ b/hw/xfree86/common/xf86.h
@@ -263,7 +263,6 @@ extern _X_EXPORT Bool xf86GetVidModeEnabled(void);
 extern _X_EXPORT Bool xf86GetModInDevAllowNonLocal(void);
 extern _X_EXPORT Bool xf86GetModInDevEnabled(void);
 extern _X_EXPORT Bool xf86GetAllowMouseOpenFail(void);
-extern _X_EXPORT Bool xf86IsPc98(void);
 extern _X_EXPORT void xf86DisableRandR(void);
 extern _X_EXPORT CARD32 xorgGetVersion(void);
 extern _X_EXPORT CARD32 xf86GetModuleVersion(pointer module);
diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c
index 58b30dd..3aa923a 100644
--- a/hw/xfree86/common/xf86Config.c
+++ b/hw/xfree86/common/xf86Config.c
@@ -676,7 +676,6 @@ typedef enum {
     FLAG_DPMS_SUSPENDTIME,
     FLAG_DPMS_OFFTIME,
     FLAG_PIXMAP,
-    FLAG_PC98,
     FLAG_NOPM,
     FLAG_XINERAMA,
     FLAG_LOG,
@@ -724,8 +723,6 @@ static OptionInfoRec FlagOptions[] = {
 	{0}, FALSE },
   { FLAG_PIXMAP,		"Pixmap",			OPTV_INTEGER,
 	{0}, FALSE },
-  { FLAG_PC98,			"PC98",				OPTV_BOOLEAN,
-	{0}, FALSE },
   { FLAG_NOPM,			"NoPM",				OPTV_BOOLEAN,
 	{0}, FALSE },
   { FLAG_XINERAMA,		"Xinerama",			OPTV_BOOLEAN,
@@ -756,21 +753,6 @@ static OptionInfoRec FlagOptions[] = {
 	{0}, FALSE },
 };
 
-#ifdef SUPPORT_PC98
-static Bool
-detectPC98(void)
-{
-    unsigned char buf[2];
-
-    if (xf86ReadBIOS(0xf8000, 0xe80, buf, 2) != 2)
-	return FALSE;
-    if ((buf[0] == 0x98) && (buf[1] == 0x21))
-	return TRUE;
-    else
-	return FALSE;
-}
-#endif
-
 static Bool
 configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts)
 {
@@ -1026,18 +1008,6 @@ configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts)
 	xf86Info.pixmap24 = Pix24DontCare;
 	xf86Info.pix24From = X_DEFAULT;
     }
-#ifdef SUPPORT_PC98
-    if (xf86GetOptValBool(FlagOptions, FLAG_PC98, &value)) {
-	xf86Info.pc98 = value;
-	if (value) {
-	    xf86Msg(X_CONFIG, "Japanese PC98 architecture\n");
-	}
-    } else
-	if (detectPC98()) {
-	    xf86Info.pc98 = TRUE;
-	    xf86Msg(X_PROBED, "Japanese PC98 architecture\n");
-	}
-#endif
 
 #ifdef PANORAMIX
     from = X_DEFAULT;
diff --git a/hw/xfree86/common/xf86Globals.c b/hw/xfree86/common/xf86Globals.c
index 16d5557..b45b114 100644
--- a/hw/xfree86/common/xf86Globals.c
+++ b/hw/xfree86/common/xf86Globals.c
@@ -119,9 +119,6 @@ xf86InfoRec xf86Info = {
     .miscModInDevAllowNonLocal  = FALSE,
     .pixmap24                   = Pix24DontCare,
     .pix24From                  = X_DEFAULT,
-#ifdef SUPPORT_PC98
-    .pc98                       = FALSE,
-#endif
     .pmFlag                     = TRUE,
     .log                        = LogNone,
     .disableRandR               = FALSE,
diff --git a/hw/xfree86/common/xf86Helper.c b/hw/xfree86/common/xf86Helper.c
index f8e6c8b..7c76fa8 100644
--- a/hw/xfree86/common/xf86Helper.c
+++ b/hw/xfree86/common/xf86Helper.c
@@ -1583,16 +1583,6 @@ xf86GetAllowMouseOpenFail(void)
 }
 
 
-Bool
-xf86IsPc98(void)
-{
-#if SUPPORT_PC98
-    return xf86Info.pc98;
-#else
-    return FALSE;
-#endif
-}
-
 void
 xf86DisableRandR(void)
 {
diff --git a/hw/xfree86/common/xf86Privstr.h b/hw/xfree86/common/xf86Privstr.h
index 608f9bd..b001f9d 100644
--- a/hw/xfree86/common/xf86Privstr.h
+++ b/hw/xfree86/common/xf86Privstr.h
@@ -91,9 +91,6 @@ typedef struct {
 						   input device events */
     Pix24Flags		pixmap24;
     MessageType		pix24From;
-#ifdef SUPPORT_PC98
-    Bool		pc98;
-#endif
     Bool		pmFlag;
     Log			log;
     Bool		disableRandR;
diff --git a/hw/xfree86/int10/helper_exec.c b/hw/xfree86/int10/helper_exec.c
index ec84200..2efbdc5 100644
--- a/hw/xfree86/int10/helper_exec.c
+++ b/hw/xfree86/int10/helper_exec.c
@@ -347,7 +347,7 @@ x_inw(CARD16 port)
 	struct timeval tv;
 
 	/*
-	 * Emulate a PC98's timer.  Typical resolution is 3.26 usec.
+	 * Emulate a PC's timer.  Typical resolution is 3.26 usec.
 	 * Approximate this by dividing by 3.
 	 */
 	X_GETTIMEOFDAY(&tv);
diff --git a/hw/xfree86/int10/helper_mem.c b/hw/xfree86/int10/helper_mem.c
index 496c9a5..9088298 100644
--- a/hw/xfree86/int10/helper_mem.c
+++ b/hw/xfree86/int10/helper_mem.c
@@ -241,9 +241,6 @@ int10_check_bios(int scrnIndex, int codeSeg, const unsigned char* vbiosMem)
 	((codeSeg << 4) >= SYS_SIZE))
 	return FALSE;
 
-    if (xf86IsPc98())
-	return FALSE;
-
     if ((*vbiosMem != 0x55) || (*(vbiosMem+1) != 0xAA) || !*(vbiosMem+2))
 	return FALSE;
 
diff --git a/hw/xfree86/man/xorg.conf.man b/hw/xfree86/man/xorg.conf.man
index f406f82..8f14efb 100644
--- a/hw/xfree86/man/xorg.conf.man
+++ b/hw/xfree86/man/xorg.conf.man
@@ -634,12 +634,6 @@ are 24 and 32.
 Default: 32 unless driver constraints don't allow this (which is rare).
 Note: some clients don't behave well when this value is set to 24.
 .TP 7
-.BI "Option \*qPC98\*q  \*q" boolean \*q
-Specify that the machine is a Japanese PC\-98 machine.
-This should not be enabled for anything other than the Japanese\-specific
-PC\-98 architecture.
-Default: auto\-detected.
-.TP 7
 .BI "Option \*qNoPM\*q  \*q" boolean \*q
 Disables something to do with power management events.
 Default: PM enabled on platforms that support it.
diff --git a/include/xorg-config.h.in b/include/xorg-config.h.in
index 56ffda2..0d1ea91 100644
--- a/include/xorg-config.h.in
+++ b/include/xorg-config.h.in
@@ -136,9 +136,6 @@
 /* Use SIGIO handlers for input device events by default */
 #undef USE_SIGIO_BY_DEFAULT
 
-/* Support PC98 */
-#undef SUPPORT_PC98
-
 /* Build with libdrm support */
 #undef WITH_LIBDRM
 
commit 9eb22ebf46b77c15e53017a37c7ef605521dc164
Author: Jamey Sharp <jamey at minilop.net>
Date:   Tue Sep 13 16:30:06 2011 -0500

    configure.ac: XORG_OS is not used, so delete it.
    
    Signed-off-by: Jamey Sharp <jamey at minilop.net>
    Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com>
    Reviewed-by: Gaetan Nadon <memsize at videotron.ca>

diff --git a/configure.ac b/configure.ac
index bc34c72..6c4fffd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1573,7 +1573,6 @@ if test "x$XORG" = xyes; then
 		if test "x$LNXAPM" = xyes; then
 			XORG_CFLAGS="$XORG_CFLAGS -DXF86PM"
 		fi
-	  	XORG_OS="linux"
 		XORG_OS_SUBDIR="linux"
 		xorg_bus_linuxpci="yes"
 		linux_acpi="no"
@@ -1593,12 +1592,10 @@ if test "x$XORG" = xyes; then
 		esac
 		;;
 	  freebsd* | kfreebsd*-gnu | dragonfly*)
-	  	XORG_OS="freebsd"
 		XORG_OS_SUBDIR="bsd"
 		xorg_bus_bsdpci="yes"
 		;;
 	  netbsd*)
-	  	XORG_OS="netbsd"
 		XORG_OS_SUBDIR="bsd"
 		xorg_bus_bsdpci="yes"
 		;;
@@ -1607,12 +1604,10 @@ if test "x$XORG" = xyes; then
 			-o "x$ac_cv_BSD_KQUEUE_APM" = xyes; then
 			XORG_CFLAGS="$XORG_CFLAGS -DXF86PM"
 		fi
-	  	XORG_OS="openbsd"
 		XORG_OS_SUBDIR="bsd"
 		xorg_bus_bsdpci="yes"
 		;;
 	  solaris*)
-	  	XORG_OS="solaris"
 		XORG_OS_SUBDIR="solaris"
 		XORG_CFLAGS="$XORG_CFLAGS -DXF86PM"
 		# Use the same stubs as BSD for old functions, since we now
@@ -1664,14 +1659,12 @@ if test "x$XORG" = xyes; then
 		fi
 		;;
 	  gnu*)
-	  	XORG_OS="gnu"
 		XORG_OS_SUBDIR="hurd"
 		# Use the same stubs as BSD for old functions, since we now
 		# use libpciaccess for PCI
 		xorg_bus_bsdpci="yes"
 		;;
 	  *)
-	  	XORG_OS="unknown"
 		XORG_OS_SUBDIR="unknown"
 		AC_MSG_ERROR([m4_text_wrap(m4_join([ ],
 		[Your OS is unknown. Xorg currently only supports Linux,],
@@ -1726,7 +1719,6 @@ if test "x$XORG" = xyes; then
 	AC_SUBST([XORG_LIBS])
 	AC_SUBST([XORG_SYS_LIBS])
 	AC_SUBST([XORG_INCS])
-	AC_SUBST([XORG_OS])
 	AC_SUBST([XORG_OS_SUBDIR])
 	AC_SUBST([XORG_CFLAGS])
 
commit 76636f30f7cf2344f4038c59bf292db19be33d53
Author: Jamey Sharp <jamey at minilop.net>
Date:   Tue Sep 13 13:10:10 2011 -0500

    configure.ac: Remove unused XORG_OS_PCI variable.
    
    This is the last mention after ccfaf82367c9d057fd8314ce36b47f0a8eb696b6
    quit using the variable.
    
    Signed-off-by: Jamey Sharp <jamey at minilop.net>
    Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com>
    Reviewed-by: Gaetan Nadon <memsize at videotron.ca>
    
    Tiago Vignatti posted an identical patch in June 2010, which I only
    noticed after getting the above reviews. His patch was:
    
    Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
    Reviewed-by: Mikhail Gusarov <dottedmag at dottedmag.net>

diff --git a/configure.ac b/configure.ac
index 2ac1f2e..bc34c72 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1698,9 +1698,6 @@ if test "x$XORG" = xyes; then
 	if test "x$SUPPORT_PC98" = xyes; then
 		AC_DEFINE(SUPPORT_PC98, 1, [Support PC98])
 	fi
-	if test "x$XORG_OS_PCI" = x ; then
-		XORG_OS_PCI=$XORG_OS
-	fi
 	if test "x$DGA" = xauto; then
 		PKG_CHECK_MODULES(DGA, $DGAPROTO, [DGA=yes], [DGA=no])
 	fi
commit 60b4bd181bbdc794c7f3547f67df916132aa111e
Author: Jamey Sharp <jamey at minilop.net>
Date:   Tue Sep 13 14:31:24 2011 -0500

    x86emu: There is no NO_INLINE implementation of unaligned access here.
    
    Patch produced with:
    	unifdef -UNO_INLINE -B
    
    This change isn't relevant to the similar code in
    hw/xfree86/common/compiler.h, because x86emu is expected to someday move
    out of xserver entirely and so should not depend on any xserver headers.
    Also, some platforms apparently do have NO_INLINE versions of
    compiler.h.
    
    Signed-off-by: Jamey Sharp <jamey at minilop.net>
    Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com>
    Reviewed-by: Matt Turner <mattst88 at gmail.com>

diff --git a/hw/xfree86/x86emu/sys.c b/hw/xfree86/x86emu/sys.c
index 602b0bb..f389767 100644
--- a/hw/xfree86/x86emu/sys.c
+++ b/hw/xfree86/x86emu/sys.c
@@ -49,7 +49,6 @@
 #include <string.h>
 #endif                                                                                           
 
-# ifndef NO_INLINE
 #  ifdef __GNUC__
 
 /* Define some packed structures to use with unaligned accesses */
@@ -139,7 +138,6 @@ static __inline__ void stw_u(u16 val, u16 *p)
 }
 
 #  endif /* __GNUC__ */
-# endif /* NO_INLINE */
 /*------------------------- Global Variables ------------------------------*/
 
 X86EMU_sysEnv		_X86EMU_env;		/* Global emulator machine state */


More information about the Xquartz-changes mailing list