[Xquartz-changes] xserver: Branch 'server-1.11-apple' - 86 commits

Jeremy Huddleston jeremyhu at freedesktop.org
Wed Jun 1 15:19:09 PDT 2011


Rebased ref, commits from common ancestor:
commit 480a9bfaaebf26576b673df6a14f8591e9f3e055
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..f5aaee8 100644
--- a/fb/fbtrap.c
+++ b/fb/fbtrap.c
@@ -39,9 +39,8 @@ 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,
@@ -57,9 +56,8 @@ 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,
commit 3546cbcb54f97ce72815a9f70235e202a733dd4e
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 94258b8..4f25c23 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;
 
@@ -587,6 +601,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;
 	
@@ -595,6 +621,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;
@@ -657,6 +689,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 4e094834310f6ac47992e8e9d26e72ccfb0eb83f
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 22566c9..f3f298e 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 1e1d2956df3b9bd01eb8ce9aacb1f64307b286d4
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Sun May 29 01:20:44 2011 -0700

    XQuartz: Move -lXplugin to LDFLAGS from LDADD
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/hw/xquartz/mach-startup/Makefile.am b/hw/xquartz/mach-startup/Makefile.am
index 1ce54ad..4b7b2bc 100644
--- a/hw/xquartz/mach-startup/Makefile.am
+++ b/hw/xquartz/mach-startup/Makefile.am
@@ -22,9 +22,10 @@ X11_bin_LDADD = \
 	$(top_builddir)/dix/dixfonts.lo \
 	$(top_builddir)/miext/rootless/librootless.la \
 	$(top_builddir)/hw/xquartz/pbproxy/libxpbproxy.la \
-	$(DARWIN_LIBS) $(MAIN_LIB) $(XSERVER_LIBS) $(XSERVER_SYS_LIBS) -lXplugin
+	$(DARWIN_LIBS) $(MAIN_LIB) $(XSERVER_LIBS)
 
 X11_bin_LDFLAGS =  \
+	$(XSERVER_SYS_LIBS) -lXplugin \
 	-XCClinker -Objc \
 	-Wl,-u,_miDCInitialize \
 	-Wl,-framework,Carbon \
commit 8abe9a6d880c7674938b83f037e00f06cbdc6006
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Tue May 31 13:01:05 2011 -0700

    XQuartz: GLX: Create a new dispatch table rather than modifying the existing one
    
    Fixes regression introduced by b0c665ac0fe6840dda581e4d0d0b76c703d62a7b
    
    0   X11.bin                       	0x0000000100118293 __glXAquaScreenCreateContext + 684
    1   X11.bin                       	0x00000001001315b0 DoCreateContext + 163
    2   X11.bin                       	0x000000010013509f __glXDispatch + 211
    3   X11.bin                       	0x00000001000c7dad Dispatch + 785
    4   X11.bin                       	0x00000001000b97e5 dix_main + 1022
    5   X11.bin                       	0x00000001000122bc server_thread + 50
    6   libSystem.B.dylib             	0x00007fff836554f6 _pthread_start + 331
    7   libSystem.B.dylib             	0x00007fff836553a9 thread_start + 13
    
    http://lists.apple.com/archives/X11-users/2011/May/msg00045.html
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>
    Reviewed-by: Adam Jackson <ajax at redhat.com>

diff --git a/hw/xquartz/GL/indirect.c b/hw/xquartz/GL/indirect.c
index 6da27c7..d15b9a3 100644
--- a/hw/xquartz/GL/indirect.c
+++ b/hw/xquartz/GL/indirect.c
@@ -666,7 +666,15 @@ GLuint __glFloorLog2(GLuint val)
 }
 
 static void setup_dispatch_table(void) {
-    struct _glapi_table *disp=_glapi_get_dispatch();
+    static struct _glapi_table *disp = NULL;
+
+    if(disp)  {
+        _glapi_set_dispatch(disp);
+        return;
+    }
+
+    disp=calloc(1,sizeof(struct _glapi_table));
+    assert(disp);
 
     /* to update:
      * for f in $(grep 'define SET_' ../../../glx/dispatch.h  | cut -f2 -d' ' | cut -f1 -d\( | sort -u); do grep -q $f indirect.c || echo $f ; done | grep -v by_offset | sed 's:SET_\(.*\)$:SET_\1(disp, gl\1)\;:' | pbcopy
@@ -1610,4 +1618,6 @@ static void setup_dispatch_table(void) {
     SET_PixelTexGenParameterivSGIS(disp, glPixelTexGenParameterivSGIS);
     SET_PixelTexGenSGIX(disp, glPixelTexGenSGIX);
 #endif
+
+    _glapi_set_dispatch(disp);
 }
commit db228d3d07a6d831f53e4c05c878327ad4d045eb
Author: Keith Packard <keithp at keithp.com>
Date:   Wed Jun 1 11:20:10 2011 -0700

    Version bumped to 1.10.99.901 (1.11 RC1)
    
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/configure.ac b/configure.ac
index fcb8ea9..22566c9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -26,8 +26,8 @@ dnl
 dnl Process this file with autoconf to create configure.
 
 AC_PREREQ(2.57)
-AC_INIT([xorg-server], 1.10.99.1, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server)
-RELEASE_DATE="unreleased"
+AC_INIT([xorg-server], 1.10.99.901, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server)
+RELEASE_DATE="2011-06-01"
 AC_CONFIG_SRCDIR([Makefile.am])
 AM_INIT_AUTOMAKE([foreign dist-bzip2])
 AM_MAINTAINER_MODE
commit 0643c056512d10be8db223d18d6563292d57e916
Merge: a2e6cfc... d45f5b2...
Author: Keith Packard <keithp at keithp.com>
Date:   Tue May 31 23:45:07 2011 -0700

    Merge remote-tracking branch 'ajax/xserver-next'

commit a2e6cfc18aec1c0027b51572b03ec9f2ab074b56
Merge: bc04065... 8d84fd2...
Author: Keith Packard <keithp at keithp.com>
Date:   Tue May 31 23:42:52 2011 -0700

    Merge remote-tracking branch 'sandmann/for-keithp'

commit d45f5b2493bc0a2882bf972849b5c9c50cd533ca
Author: Adam Jackson <ajax at redhat.com>
Date:   Wed May 25 05:54:35 2011 -0400

    fixes: Add support for pointer barriers
    
    Implements pointer barriers as specified by version 5 of the XFIXES
    protocol. Barriers are axis-aligned, zero-width lines that block pointer
    movement for relative input devices. Barriers may block motion in either
    the positive or negative direction, or both.
    
    v3:
    - Fix off-by-one in version_requests array
    - Port to non-glib test harness
    - Fix review notes from Søren Sandmann Pedersen, add tests to match
    
    Co-authored-by: Peter Hutterer <peter.hutterer at who-t.net>
    Tested-by: Peter Hutterer <peter.hutterer at who-t.net>
    Signed-off-by: Adam Jackson <ajax at redhat.com>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/configure.ac b/configure.ac
index 655c0e4..ba1d176 100644
--- a/configure.ac
+++ b/configure.ac
@@ -810,7 +810,7 @@ dnl specific modules against it
 PKG_CHECK_MODULES(PIXMAN, $LIBPIXMAN)
 REQUIRED_LIBS="$REQUIRED_LIBS $LIBPIXMAN $LIBXFONT xau"
 
-REQUIRED_MODULES="[fixesproto >= 4.1] [damageproto >= 1.1] [xcmiscproto >= 1.2.0] [xtrans >= 1.2.2] [bigreqsproto >= 1.1.0] $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 &&
  { test "x$CONFIG_DBUS_API" = xyes || test "x$CONFIG_HAL" = xyes; }; then
diff --git a/include/protocol-versions.h b/include/protocol-versions.h
index 8692ded..7b7a9f5 100644
--- a/include/protocol-versions.h
+++ b/include/protocol-versions.h
@@ -122,7 +122,7 @@
 #define SERVER_XF86VIDMODE_MINOR_VERSION	2
 
 /* Fixes */
-#define SERVER_XFIXES_MAJOR_VERSION		4
+#define SERVER_XFIXES_MAJOR_VERSION		5
 #define SERVER_XFIXES_MINOR_VERSION		0
 
 /* X Input */
diff --git a/test/Makefile.am b/test/Makefile.am
index b7ee070..5574e7d 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -1,7 +1,7 @@
 if ENABLE_UNIT_TESTS
 if HAVE_LD_WRAP
 SUBDIRS= . xi2
-noinst_PROGRAMS = xkb input xtest list misc
+noinst_PROGRAMS = xkb input xtest list misc fixes
 check_LTLIBRARIES = libxservertest.la
 
 TESTS=$(noinst_PROGRAMS)
@@ -19,6 +19,7 @@ input_LDADD=$(TEST_LDADD)
 xtest_LDADD=$(TEST_LDADD)
 list_LDADD=$(TEST_LDADD)
 misc_LDADD=$(TEST_LDADD)
+fixes_LDADD=$(TEST_LDADD)
 
 libxservertest_la_LIBADD = \
             $(XSERVER_LIBS) \
diff --git a/test/fixes.c b/test/fixes.c
new file mode 100644
index 0000000..8c804ba
--- /dev/null
+++ b/test/fixes.c
@@ -0,0 +1,327 @@
+/**
+ * Copyright © 2011 Red Hat, Inc.
+ *
+ *  Permission is hereby granted, free of charge, to any person obtaining a
+ *  copy of this software and associated documentation files (the "Software"),
+ *  to deal in the Software without restriction, including without limitation
+ *  the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ *  and/or sell copies of the Software, and to permit persons to whom the
+ *  Software is furnished to do so, subject to the following conditions:
+ *
+ *  The above copyright notice and this permission notice (including the next
+ *  paragraph) shall be included in all copies or substantial portions of the
+ *  Software.
+ *
+ *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ *  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ *  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ *  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ *  DEALINGS IN THE SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <X11/X.h>
+#include <xfixesint.h>
+#include <X11/extensions/xfixeswire.h>
+
+static void
+_fixes_test_direction(struct PointerBarrier *barrier, int d[4], int permitted)
+{
+    BOOL blocking;
+    int i, j;
+    int dir = barrier_get_direction(d[0], d[1], d[2], d[3]);
+
+    barrier->directions = 0;
+    blocking = barrier_is_blocking_direction(barrier, dir);
+    assert(blocking);
+
+    for (j = 0; j <= BarrierNegativeY; j++)
+    {
+        for (i = 0; i <= BarrierNegativeY; i++)
+        {
+            barrier->directions |= 1 << i;
+            blocking = barrier_is_blocking_direction(barrier, dir);
+            assert((barrier->directions & permitted) == permitted ? !blocking : blocking);
+        }
+    }
+
+}
+
+static void
+fixes_pointer_barrier_direction_test(void)
+{
+    struct PointerBarrier barrier;
+
+    int x = 100;
+    int y = 100;
+
+    int directions[8][4] = {
+        { x, y, x, y + 100},            /* S  */
+        { x + 50, y, x - 50, y + 100},  /* SW */
+        { x + 100, y, x, y},            /* W  */
+        { x + 100, y + 50, x, y - 50},  /* NW */
+        { x, y + 100, x, y},            /* N  */
+        { x - 50, y + 100, x + 50, y},  /* NE */
+        { x, y, x + 100, y},            /* E  */
+        { x, y - 50, x + 100, y + 50},  /* SE */
+    };
+
+    barrier.x1 = x;
+    barrier.x2 = x;
+    barrier.y1 = y - 50;
+    barrier.y2 = y + 49;
+
+
+    _fixes_test_direction(&barrier, directions[0], BarrierPositiveY);
+    _fixes_test_direction(&barrier, directions[1], BarrierPositiveY | BarrierNegativeX);
+    _fixes_test_direction(&barrier, directions[2], BarrierNegativeX);
+    _fixes_test_direction(&barrier, directions[3], BarrierNegativeY | BarrierNegativeX);
+    _fixes_test_direction(&barrier, directions[4], BarrierNegativeY);
+    _fixes_test_direction(&barrier, directions[5], BarrierPositiveX | BarrierNegativeY);
+    _fixes_test_direction(&barrier, directions[6], BarrierPositiveX);
+    _fixes_test_direction(&barrier, directions[7], BarrierPositiveY | BarrierPositiveX);
+
+
+}
+
+
+static void
+fixes_pointer_barriers_test(void)
+{
+    struct PointerBarrier barrier;
+    int x1, y1, x2, y2;
+    double distance;
+
+    int x = 100;
+    int y = 100;
+
+    /* vert barrier */
+    barrier.x1 = x;
+    barrier.x2 = x;
+    barrier.y1 = y - 50;
+    barrier.y2 = y + 50;
+
+    /* across at half-way */
+    x1 = x + 1;
+    x2 = x - 1;
+    y1 = y;
+    y2 = y;
+    assert(barrier_is_blocking(&barrier, x1, y1, x2, y2, &distance));
+    assert(distance == 1);
+
+    /* definitely not across */
+    x1 = x + 10;
+    x2 = x + 5;
+    assert(!barrier_is_blocking(&barrier, x1, y1, x2, y2, &distance));
+
+    /* across, but outside of y range */
+    x1 = x + 1;
+    x2 = x -1;
+    y1 = y + 100;
+    y2 = y + 100;
+    assert(!barrier_is_blocking(&barrier, x1, y1, x2, y2, &distance));
+
+    /* across, diagonally */
+    x1 = x + 5;
+    x2 = x - 5;
+    y1 = y + 5;
+    y2 = y - 5;
+    assert(barrier_is_blocking(&barrier, x1, y1, x2, y2, &distance));
+
+    /* across but outside boundary, diagonally */
+    x1 = x + 5;
+    x2 = x - 5;
+    y1 = y + 100;
+    y2 = y + 50;
+    assert(!barrier_is_blocking(&barrier, x1, y1, x2, y2, &distance));
+
+    /* edge case: startpoint of movement on barrier → blocking */
+    x1 = x;
+    x2 = x - 1;
+    y1 = y;
+    y2 = y;
+    assert(barrier_is_blocking(&barrier, x1, y1, x2, y2, &distance));
+
+    /* edge case: startpoint of movement on barrier → not blocking, positive */
+    x1 = x;
+    x2 = x + 1;
+    y1 = y;
+    y2 = y;
+    assert(!barrier_is_blocking(&barrier, x1, y1, x2, y2, &distance));
+
+    /* edge case: startpoint of movement on barrier → not blocking, negative */
+    x1 = x - 1;
+    x2 = x - 2;
+    y1 = y;
+    y2 = y;
+    assert(!barrier_is_blocking(&barrier, x1, y1, x2, y2, &distance));
+
+    /* edge case: endpoint of movement on barrier → blocking */
+    x1 = x + 1;
+    x2 = x;
+    y1 = y;
+    y2 = y;
+    assert(barrier_is_blocking(&barrier, x1, y1, x2, y2, &distance));
+
+    /* startpoint on barrier but outside y range */
+    x1 = x;
+    x2 = x - 1;
+    y1 = y + 100;
+    y2 = y + 100;
+    assert(!barrier_is_blocking(&barrier, x1, y1, x2, y2, &distance));
+
+    /* endpoint on barrier but outside y range */
+    x1 = x + 1;
+    x2 = x;
+    y1 = y + 100;
+    y2 = y + 100;
+    assert(!barrier_is_blocking(&barrier, x1, y1, x2, y2, &distance));
+
+
+    /* horizontal barrier */
+    barrier.x1 = x - 50;
+    barrier.x2 = x + 50;
+    barrier.y1 = y;
+    barrier.y2 = y;
+
+    /* across at half-way */
+    x1 = x;
+    x2 = x;
+    y1 = y - 1;
+    y2 = y + 1;
+    assert(barrier_is_blocking(&barrier, x1, y1, x2, y2, &distance));
+
+    /* definitely not across */
+    y1 = y + 10;
+    y2 = y + 5;
+    assert(!barrier_is_blocking(&barrier, x1, y1, x2, y2, &distance));
+
+    /* across, but outside of y range */
+    x1 = x + 100;
+    x2 = x + 100;
+    y1 = y + 1;
+    y2 = y -1;
+    assert(!barrier_is_blocking(&barrier, x1, y1, x2, y2, &distance));
+
+    /* across, diagonally */
+    y1 = y + 5;
+    y2 = y - 5;
+    x1 = x + 5;
+    x2 = x - 5;
+    assert(barrier_is_blocking(&barrier, x1, y1, x2, y2, &distance));
+
+    /* across but outside boundary, diagonally */
+    y1 = y + 5;
+    y2 = y - 5;
+    x1 = x + 100;
+    x2 = x + 50;
+    assert(!barrier_is_blocking(&barrier, x1, y1, x2, y2, &distance));
+
+    /* edge case: startpoint of movement on barrier → blocking */
+    y1 = y;
+    y2 = y - 1;
+    x1 = x;
+    x2 = x;
+    assert(barrier_is_blocking(&barrier, x1, y1, x2, y2, &distance));
+
+    /* edge case: startpoint of movement on barrier → not blocking, positive */
+    y1 = y;
+    y2 = y + 1;
+    x1 = x;
+    x2 = x;
+    assert(!barrier_is_blocking(&barrier, x1, y1, x2, y2, &distance));
+
+    /* edge case: startpoint of movement on barrier → not blocking, negative */
+    y1 = y - 1;
+    y2 = y - 2;
+    x1 = x;
+    x2 = x;
+    assert(!barrier_is_blocking(&barrier, x1, y1, x2, y2, &distance));
+
+    /* edge case: endpoint of movement on barrier → blocking */
+    y1 = y + 1;
+    y2 = y;
+    x1 = x;
+    x2 = x;
+    assert(barrier_is_blocking(&barrier, x1, y1, x2, y2, &distance));
+
+    /* startpoint on barrier but outside y range */
+    y1 = y;
+    y2 = y - 1;
+    x1 = x + 100;
+    x2 = x + 100;
+    assert(!barrier_is_blocking(&barrier, x1, y1, x2, y2, &distance));
+
+    /* endpoint on barrier but outside y range */
+    y1 = y + 1;
+    y2 = y;
+    x1 = x + 100;
+    x2 = x + 100;
+    assert(!barrier_is_blocking(&barrier, x1, y1, x2, y2, &distance));
+
+}
+
+static void fixes_pointer_barrier_clamp_test(void)
+{
+    struct PointerBarrier barrier;
+
+    int x = 100;
+    int y = 100;
+
+    int cx, cy; /* clamped */
+
+    /* vert barrier */
+    barrier.x1 = x;
+    barrier.x2 = x;
+    barrier.y1 = y - 50;
+    barrier.y2 = y + 49;
+    barrier.directions = 0;
+
+    cx = INT_MAX;
+    cy = INT_MAX;
+    barrier_clamp_to_barrier(&barrier, BarrierPositiveX, &cx, &cy);
+    assert(cx == barrier.x1 - 1);
+    assert(cy == INT_MAX);
+
+    cx = 0;
+    cy = INT_MAX;
+    barrier_clamp_to_barrier(&barrier, BarrierNegativeX, &cx, &cy);
+    assert(cx == barrier.x1);
+    assert(cy == INT_MAX);
+
+    /* horiz barrier */
+    barrier.x1 = x - 50;
+    barrier.x2 = x + 49;
+    barrier.y1 = y;
+    barrier.y2 = y;
+    barrier.directions = 0;
+
+    cx = INT_MAX;
+    cy = INT_MAX;
+    barrier_clamp_to_barrier(&barrier, BarrierPositiveY, &cx, &cy);
+    assert(cx == INT_MAX);
+    assert(cy == barrier.y1 - 1);
+
+    cx = INT_MAX;
+    cy = 0;
+    barrier_clamp_to_barrier(&barrier, BarrierNegativeY, &cx, &cy);
+    assert(cx == INT_MAX);
+    assert(cy == barrier.y1);
+}
+
+int main(int argc, char** argv)
+{
+
+    fixes_pointer_barriers_test();
+    fixes_pointer_barrier_direction_test();
+    fixes_pointer_barrier_clamp_test();
+
+    return 0;
+}
diff --git a/xfixes/cursor.c b/xfixes/cursor.c
index fb608f6..01eb70d 100644
--- a/xfixes/cursor.c
+++ b/xfixes/cursor.c
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2010 Red Hat, Inc.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -50,13 +51,16 @@
 #include "cursorstr.h"
 #include "dixevents.h"
 #include "servermd.h"
+#include "mipointer.h"
 #include "inputstr.h"
 #include "windowstr.h"
 #include "xace.h"
+#include "list.h"
 
 static RESTYPE		CursorClientType;
 static RESTYPE		CursorHideCountType;
 static RESTYPE		CursorWindowType;
+RESTYPE			PointerBarrierType;
 static CursorPtr	CursorCurrent[MAXDEVICES];
 
 static DevPrivateKeyRec CursorScreenPrivateKeyRec;
@@ -107,6 +111,14 @@ typedef struct _CursorHideCountRec {
     XID			 resource;
 } CursorHideCountRec;
 
+typedef struct PointerBarrierClient *PointerBarrierClientPtr;
+
+struct PointerBarrierClient {
+    ScreenPtr screen;
+    struct PointerBarrier barrier;
+    struct list entry;
+};
+
 /*
  * Wrap DisplayCursor to catch cursor change events
  */
@@ -114,7 +126,9 @@ typedef struct _CursorHideCountRec {
 typedef struct _CursorScreen {
     DisplayCursorProcPtr	DisplayCursor;
     CloseScreenProcPtr		CloseScreen;
+    ConstrainCursorHarderProcPtr ConstrainCursorHarder;
     CursorHideCountPtr          pCursorHideCounts;
+    struct list                 barriers;
 } CursorScreenRec, *CursorScreenPtr;
 
 #define GetCursorScreen(s) ((CursorScreenPtr)dixLookupPrivate(&(s)->devPrivates, CursorScreenPrivateKey))
@@ -184,9 +198,11 @@ CursorCloseScreen (int index, ScreenPtr pScreen)
     Bool		ret;
     CloseScreenProcPtr	close_proc;
     DisplayCursorProcPtr display_proc;
+    ConstrainCursorHarderProcPtr constrain_proc;
 
     Unwrap (cs, pScreen, CloseScreen, close_proc);
     Unwrap (cs, pScreen, DisplayCursor, display_proc);
+    Unwrap (cs, pScreen, ConstrainCursorHarder, constrain_proc);
     deleteCursorHideCountsForScreen(pScreen);
     ret = (*pScreen->CloseScreen) (index, pScreen);
     free(cs);
@@ -1029,6 +1045,382 @@ CursorFreeWindow (pointer data, XID id)
     return 1;
 }
 
+static BOOL
+barrier_is_horizontal(const struct PointerBarrier *barrier)
+{
+    return barrier->y1 == barrier->y2;
+}
+
+static BOOL
+barrier_is_vertical(const struct PointerBarrier *barrier)
+{
+    return barrier->x1 == barrier->x2;
+}
+
+/**
+ * @return The set of barrier movement directions the movement vector
+ * x1/y1 → x2/y2 represents.
+ */
+int
+barrier_get_direction(int x1, int y1, int x2, int y2)
+{
+    int direction = 0;
+
+    /* which way are we trying to go */
+    if (x2 > x1)
+	direction |= BarrierPositiveX;
+    if (x2 < x1)
+	direction |= BarrierNegativeX;
+    if (y2 > y1)
+	direction |= BarrierPositiveY;
+    if (y2 < y1)
+	direction |= BarrierNegativeY;
+
+    return direction;
+}
+
+/**
+ * Test if the barrier may block movement in the direction defined by
+ * x1/y1 → x2/y2. This function only tests whether the directions could be
+ * blocked, it does not test if the barrier actually blocks the movement.
+ *
+ * @return TRUE if the barrier blocks the direction of movement or FALSE
+ * otherwise.
+ */
+BOOL
+barrier_is_blocking_direction(const struct PointerBarrier *barrier, int direction)
+{
+    /* Barriers define which way is ok, not which way is blocking */
+    return (barrier->directions & direction) != direction;
+}
+
+/**
+ * Test if the movement vector x1/y1 → x2/y2 is intersecting with the
+ * barrier. A movement vector with the startpoint or endpoint adjacent to
+ * the barrier itself counts as intersecting.
+ *
+ * @param x1 X start coordinate of movement vector
+ * @param y1 Y start coordinate of movement vector
+ * @param x2 X end coordinate of movement vector
+ * @param y2 Y end coordinate of movement vector
+ * @param[out] distance The distance between the start point and the
+ * intersection with the barrier (if applicable).
+ * @return TRUE if the barrier intersects with the given vector
+ */
+BOOL
+barrier_is_blocking(const struct PointerBarrier *barrier,
+		    int x1, int y1, int x2, int y2,
+		    double *distance)
+{
+    BOOL rc = FALSE;
+    float ua, ub, ud;
+    int dir = barrier_get_direction(x1, y1, x2, y2);
+
+    /* Algorithm below doesn't handle edge cases well, hence the extra
+     * checks. */
+    if (barrier_is_vertical(barrier)) {
+	/* handle immediate barrier adjacency, moving away */
+	if (dir & BarrierPositiveX && x1 == barrier->x1)
+	    return FALSE;
+	if (dir & BarrierNegativeX && x1 == (barrier->x1 - 1))
+	    return FALSE;
+	/* startpoint adjacent to barrier, moving towards -> block */
+	if (x1 == barrier->x1 && y1 >= barrier->y1 && y1 <= barrier->y2) {
+	    *distance = 0;
+	    return TRUE;
+	}
+    } else {
+	/* handle immediate barrier adjacency, moving away */
+	if (dir & BarrierPositiveY && y1 == barrier->y1)
+	    return FALSE;
+	if (dir & BarrierNegativeY && y1 == (barrier->y1 - 1))
+	    return FALSE;
+	/* startpoint adjacent to barrier, moving towards -> block */
+	if (y1 == barrier->y1 && x1 >= barrier->x1 && x1 <= barrier->x2) {
+	    *distance = 0;
+	    return TRUE;
+        }
+    }
+
+    /* not an edge case, compute distance */
+    ua = 0;
+    ud = (barrier->y2 - barrier->y1) * (x2 - x1) - (barrier->x2 - barrier->x1) * (y2 - y1);
+    if (ud != 0) {
+	ua = ((barrier->x2 - barrier->x1) * (y1 - barrier->y1) -
+	     (barrier->y2 - barrier->y1) * (x1 - barrier->x1)) / ud;
+	ub = ((x2 - x1) * (y1 - barrier->y1) -
+	     (y2 - y1) * (x1 - barrier->x1)) / ud;
+	if (ua < 0 || ua > 1 || ub < 0 || ub > 1)
+	    ua = 0;
+    }
+
+    if (ua > 0 && ua <= 1)
+    {
+	double ix = barrier->x1 + ua * (barrier->x2 - barrier->x1);
+	double iy = barrier->y1 + ua * (barrier->y2 - barrier->y1);
+
+	*distance = sqrt(pow(x1 - ix, 2) + pow(y1 - iy, 2));
+	rc = TRUE;
+    }
+
+    return rc;
+}
+
+/**
+ * Find the nearest barrier that is blocking movement from x1/y1 to x2/y2.
+ *
+ * @param dir Only barriers blocking movement in direction dir are checked
+ * @param x1 X start coordinate of movement vector
+ * @param y1 Y start coordinate of movement vector
+ * @param x2 X end coordinate of movement vector
+ * @param y2 Y end coordinate of movement vector
+ * @return The barrier nearest to the movement origin that blocks this movement.
+ */
+static struct PointerBarrier*
+barrier_find_nearest(CursorScreenPtr cs, int dir,
+		     int x1, int y1, int x2, int y2)
+{
+    struct PointerBarrierClient *c;
+    struct PointerBarrier *nearest = NULL;
+    double min_distance = INT_MAX; /* can't get higher than that in X anyway */
+
+    list_for_each_entry(c, &cs->barriers, entry) {
+	struct PointerBarrier *b = &c->barrier;
+	double distance;
+
+	if (!barrier_is_blocking_direction(b, dir))
+	    continue;
+
+	if (barrier_is_blocking(b, x1, y1, x2, y2, &distance))
+	{
+	    if (min_distance > distance)
+	    {
+		min_distance = distance;
+		nearest = b;
+	    }
+	}
+    }
+
+    return nearest;
+}
+
+/**
+ * Clamp to the given barrier given the movement direction specified in dir.
+ *
+ * @param barrier The barrier to clamp to
+ * @param dir The movement direction
+ * @param[out] x The clamped x coordinate.
+ * @param[out] y The clamped x coordinate.
+ */
+void
+barrier_clamp_to_barrier(struct PointerBarrier *barrier, int dir, int *x, int *y)
+{
+    if (barrier_is_vertical(barrier))
+    {
+	if ((dir & BarrierNegativeX) & ~barrier->directions)
+	    *x = barrier->x1;
+	if ((dir & BarrierPositiveX) & ~barrier->directions)
+	    *x = barrier->x1 - 1;
+    }
+    if (barrier_is_horizontal(barrier))
+    {
+	if ((dir & BarrierNegativeY) & ~barrier->directions)
+	    *y = barrier->y1;
+	if ((dir & BarrierPositiveY) & ~barrier->directions)
+	    *y = barrier->y1 - 1;
+    }
+}
+
+static void
+CursorConstrainCursorHarder(DeviceIntPtr dev, ScreenPtr screen, int mode, int *x, int *y)
+{
+    CursorScreenPtr cs = GetCursorScreen(screen);
+
+    if (!list_is_empty(&cs->barriers) && !IsFloating(dev) && mode == Relative) {
+	int ox, oy;
+	int dir;
+	struct PointerBarrier *nearest = NULL;
+
+	/* where are we coming from */
+	miPointerGetPosition(dev, &ox, &oy);
+
+	/* How this works:
+	 * Given the origin and the movement vector, get the nearest barrier
+	 * to the origin that is blocking the movement.
+	 * Clamp to that barrier.
+	 * Then, check from the clamped intersection to the original
+	 * destination, again finding the nearest barrier and clamping.
+	 */
+	dir = barrier_get_direction(ox, oy, *x, *y);
+
+	nearest = barrier_find_nearest(cs, dir, ox, oy, *x, *y);
+	if (nearest) {
+	    barrier_clamp_to_barrier(nearest, dir, x, y);
+
+	    if (barrier_is_vertical(nearest)) {
+		dir &= ~(BarrierNegativeX | BarrierPositiveX);
+		ox = *x;
+	    } else if (barrier_is_horizontal(nearest)) {
+		dir &= ~(BarrierNegativeY | BarrierPositiveY);
+		oy = *y;
+	    }
+
+	    nearest = barrier_find_nearest(cs, dir, ox, oy, *x, *y);
+	    if (nearest) {
+		barrier_clamp_to_barrier(nearest, dir, x, y);
+	    }
+	}
+    }
+
+    if (cs->ConstrainCursorHarder) {
+	screen->ConstrainCursorHarder = cs->ConstrainCursorHarder;
+	screen->ConstrainCursorHarder(dev, screen, mode, x, y);
+	screen->ConstrainCursorHarder = CursorConstrainCursorHarder;
+    }
+}
+
+static struct PointerBarrierClient *
+CreatePointerBarrierClient(ScreenPtr screen, ClientPtr client,
+			   xXFixesCreatePointerBarrierReq *stuff)
+{
+    CursorScreenPtr cs = GetCursorScreen(screen);
+    struct PointerBarrierClient *ret = malloc(sizeof(*ret));
+
+    if (ret) {
+	ret->screen = screen;
+	ret->barrier.x1 = min(stuff->x1, stuff->x2);
+	ret->barrier.x2 = max(stuff->x1, stuff->x2);
+	ret->barrier.y1 = min(stuff->y1, stuff->y2);
+	ret->barrier.y2 = max(stuff->y1, stuff->y2);
+	ret->barrier.directions = stuff->directions & 0x0f;
+	if (barrier_is_horizontal(&ret->barrier))
+	    ret->barrier.directions &= ~(BarrierPositiveX | BarrierNegativeX);
+	if (barrier_is_vertical(&ret->barrier))
+	    ret->barrier.directions &= ~(BarrierPositiveY | BarrierNegativeY);
+	list_add(&ret->entry, &cs->barriers);
+    }
+
+    return ret;
+}
+
+int
+ProcXFixesCreatePointerBarrier (ClientPtr client)
+{
+    int err;
+    WindowPtr pWin;
+    struct PointerBarrierClient *barrier;
+    struct PointerBarrier b;
+    REQUEST (xXFixesCreatePointerBarrierReq);
+
+    REQUEST_SIZE_MATCH(xXFixesCreatePointerBarrierReq);
+    LEGAL_NEW_RESOURCE(stuff->barrier, client);
+
+    err = dixLookupWindow(&pWin, stuff->window, client, DixReadAccess);
+    if (err != Success) {
+	client->errorValue = stuff->window;
+	return err;
+    }
+
+    /* This sure does need fixing. */
+    if (stuff->num_devices)
+	return BadImplementation;
+
+    b.x1 = stuff->x1;
+    b.x2 = stuff->x2;
+    b.y1 = stuff->y1;
+    b.y2 = stuff->y2;
+
+    if (!barrier_is_horizontal(&b) && !barrier_is_vertical(&b))
+	return BadValue;
+
+    /* no 0-sized barriers */
+    if (barrier_is_horizontal(&b) && barrier_is_vertical(&b))
+	return BadValue;
+
+    if (!(barrier = CreatePointerBarrierClient(pWin->drawable.pScreen,
+					       client, stuff)))
+	return BadAlloc;
+
+    if (!AddResource(stuff->barrier, PointerBarrierType, &barrier->barrier))
+	return BadAlloc;
+
+    return Success;
+}
+
+int
+SProcXFixesCreatePointerBarrier (ClientPtr client)
+{
+    int n;
+    REQUEST(xXFixesCreatePointerBarrierReq);
+
+    swaps(&stuff->length, n);
+    REQUEST_SIZE_MATCH(xXFixesCreatePointerBarrierReq);
+    swapl(&stuff->barrier, n);
+    swapl(&stuff->window, n);
+    swaps(&stuff->x1, n);
+    swaps(&stuff->y1, n);
+    swaps(&stuff->x2, n);
+    swaps(&stuff->y2, n);
+    swapl(&stuff->directions, n);
+    return ProcXFixesVector[stuff->xfixesReqType](client);
+}
+
+static int
+CursorFreeBarrier(void *data, XID id)
+{
+    struct PointerBarrierClient *b = NULL, *barrier;
+    ScreenPtr screen;
+    CursorScreenPtr cs;
+
+    barrier = container_of(data, struct PointerBarrierClient, barrier);
+    screen = barrier->screen;
+    cs = GetCursorScreen(screen);
+
+    /* find and unlink from the screen private */
+    list_for_each_entry(b, &cs->barriers, entry) {
+	if (b == barrier) {
+	    list_del(&b->entry);
+	    break;
+	}
+    }
+
+    free(barrier);
+    return Success;
+}
+
+int
+ProcXFixesDestroyPointerBarrier (ClientPtr client)
+{
+    int err;
+    void *barrier;
+    REQUEST (xXFixesDestroyPointerBarrierReq);
+
+    REQUEST_SIZE_MATCH(xXFixesDestroyPointerBarrierReq);
+
+    err = dixLookupResourceByType((void **)&barrier, stuff->barrier,
+				  PointerBarrierType, client,
+				  DixDestroyAccess);
+    if (err != Success) {
+	client->errorValue = stuff->barrier;
+	return err;
+    }
+
+    FreeResource(stuff->barrier, RT_NONE);
+    return Success;
+}
+
+int
+SProcXFixesDestroyPointerBarrier (ClientPtr client)
+{
+    int n;
+    REQUEST(xXFixesDestroyPointerBarrierReq);
+
+    swaps(&stuff->length, n);
+    REQUEST_SIZE_MATCH(xXFixesDestroyPointerBarrierReq);
+    swapl(&stuff->barrier, n);
+    return ProcXFixesVector[stuff->xfixesReqType](client);
+}
+
 Bool
 XFixesCursorInit (void)
 {
@@ -1048,8 +1440,10 @@ XFixesCursorInit (void)
 	cs = (CursorScreenPtr) calloc(1, sizeof (CursorScreenRec));
 	if (!cs)
 	    return FALSE;
+	list_init(&cs->barriers);
 	Wrap (cs, pScreen, CloseScreen, CursorCloseScreen);
 	Wrap (cs, pScreen, DisplayCursor, CursorDisplayCursor);
+	Wrap (cs, pScreen, ConstrainCursorHarder, CursorConstrainCursorHarder);
 	cs->pCursorHideCounts = NULL;
 	SetCursorScreen (pScreen, cs);
     }
@@ -1059,7 +1453,10 @@ XFixesCursorInit (void)
 						"XFixesCursorHideCount");
     CursorWindowType = CreateNewResourceType(CursorFreeWindow,
 					     "XFixesCursorWindow");
+    PointerBarrierType = CreateNewResourceType(CursorFreeBarrier,
+					      "XFixesPointerBarrier");
 
-    return CursorClientType && CursorHideCountType && CursorWindowType;
+    return CursorClientType && CursorHideCountType && CursorWindowType &&
+	   PointerBarrierType;
 }
 
diff --git a/xfixes/xfixes.c b/xfixes/xfixes.c
index 54f0df3..e0ebedd 100644
--- a/xfixes/xfixes.c
+++ b/xfixes/xfixes.c
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2010 Red Hat, Inc.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -47,10 +48,6 @@
 
 #include "xfixesint.h"
 #include "protocol-versions.h"
-/*
- * Must use these instead of the constants from xfixeswire.h.  They advertise
- * what we implement, not what the protocol headers define.
- */
 
 static unsigned char	XFixesReqCode;
 int		XFixesEventBase;
@@ -97,11 +94,12 @@ ProcXFixesQueryVersion(ClientPtr client)
 
 /* Major version controls available requests */
 static const int version_requests[] = {
-    X_XFixesQueryVersion,	/* before client sends QueryVersion */
-    X_XFixesGetCursorImage,	/* Version 1 */
-    X_XFixesChangeCursorByName,	/* Version 2 */
-    X_XFixesExpandRegion,	/* Version 3 */
-    X_XFixesShowCursor,	        /* Version 4 */
+    X_XFixesQueryVersion,	    /* before client sends QueryVersion */
+    X_XFixesGetCursorImage,	    /* Version 1 */
+    X_XFixesChangeCursorByName,	    /* Version 2 */
+    X_XFixesExpandRegion,	    /* Version 3 */
+    X_XFixesShowCursor,		    /* Version 4 */
+    X_XFixesDestroyPointerBarrier,  /* Version 5 */
 };
 
 #define NUM_VERSION_REQUESTS	(sizeof (version_requests) / sizeof (version_requests[0]))
@@ -142,6 +140,9 @@ int	(*ProcXFixesVector[XFixesNumberRequests])(ClientPtr) = {
 /*************** Version 4 ****************/
     ProcXFixesHideCursor,
     ProcXFixesShowCursor,
+/*************** Version 5 ****************/
+    ProcXFixesCreatePointerBarrier,
+    ProcXFixesDestroyPointerBarrier,
 };
 
 static int
@@ -205,6 +206,9 @@ static int (*SProcXFixesVector[XFixesNumberRequests])(ClientPtr) = {
 /*************** Version 4 ****************/
     SProcXFixesHideCursor,
     SProcXFixesShowCursor,
+/*************** Version 5 ****************/
+    SProcXFixesCreatePointerBarrier,
+    SProcXFixesDestroyPointerBarrier,
 };
 
 static int
@@ -260,6 +264,8 @@ XFixesExtensionInit(void)
 	EventSwapVector[XFixesEventBase + XFixesCursorNotify] =
 	    (EventSwapPtr) SXFixesCursorNotifyEvent;
 	SetResourceTypeErrorValue(RegionResType, XFixesErrorBase + BadRegion);
+	SetResourceTypeErrorValue(PointerBarrierType,
+				  XFixesErrorBase + BadBarrier);
     }
 }
 
diff --git a/xfixes/xfixes.h b/xfixes/xfixes.h
index 1638350..5765e64 100644
--- a/xfixes/xfixes.h
+++ b/xfixes/xfixes.h
@@ -30,6 +30,7 @@
 #include "resource.h"
 
 extern _X_EXPORT RESTYPE RegionResType;
+extern _X_EXPORT RESTYPE PointerBarrierType;
 extern _X_EXPORT int XFixesErrorBase;
 
 #define VERIFY_REGION(pRegion, rid, client, mode)			\
@@ -51,5 +52,21 @@ extern _X_EXPORT int XFixesErrorBase;
 extern _X_EXPORT RegionPtr
 XFixesRegionCopy (RegionPtr pRegion);
 
+struct PointerBarrier {
+    CARD16 x1, x2, y1, y2;
+    CARD32 directions;
+};
+
+
+extern int
+barrier_get_direction(int, int, int, int);
+extern BOOL
+barrier_is_blocking(const struct PointerBarrier*, int, int, int, int, double*);
+extern BOOL
+barrier_is_blocking_direction(const struct PointerBarrier*, int);
+extern void
+barrier_clamp_to_barrier(struct PointerBarrier *barrier, int dir, int *x, int *y);
+
+
 
 #endif /* _XFIXES_H_ */
diff --git a/xfixes/xfixesint.h b/xfixes/xfixesint.h
index d005369..6ba276e 100644
--- a/xfixes/xfixesint.h
+++ b/xfixes/xfixesint.h
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2010 Red Hat, Inc.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -278,6 +279,21 @@ ProcXFixesShowCursor (ClientPtr client);
 int 
 SProcXFixesShowCursor (ClientPtr client);
 
+/* Version 5 */
+
+int
+ProcXFixesCreatePointerBarrier (ClientPtr client);
+
+int
+SProcXFixesCreatePointerBarrier (ClientPtr client);
+
+int
+ProcXFixesDestroyPointerBarrier (ClientPtr client);
+
+int
+SProcXFixesDestroyPointerBarrier (ClientPtr client);
+
+/* Xinerama */
 extern int (*PanoramiXSaveXFixesVector[XFixesNumberRequests])(ClientPtr);
 void PanoramiXFixesInit (void);
 void PanoramiXFixesReset (void);
commit bc04065b5ce277f3ac3491ff221a60ef3c7605cf
Author: Alan Coopersmith <alan.coopersmith at oracle.com>
Date:   Fri May 20 19:24:34 2011 -0700

    "privates.h", line 198: warning: void function cannot return value
    
    Providing an argument to return in a function with void return type
    is not allowed by the C standard, and makes the Sun compilers unhappy.
    (They actually flag it as an error, unless using a new enough version
     to be able to downgrade it to a warning with "-features=extensions".)
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
    Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>
    Reviewed-by: Cyril Brulebois <kibi at debian.org>

diff --git a/include/privates.h b/include/privates.h
index 7ef2cb7..2b0040c 100644
--- a/include/privates.h
+++ b/include/privates.h
@@ -195,7 +195,7 @@ dixGetScreenPrivate(PrivatePtr *privates, const DevScreenPrivateKey key, ScreenP
 static inline void
 dixSetScreenPrivate(PrivatePtr *privates, const DevScreenPrivateKey key, ScreenPtr pScreen, pointer val)
 {
-    return dixSetPrivate(privates, _dixGetScreenPrivateKey(key, pScreen), val);
+    dixSetPrivate(privates, _dixGetScreenPrivateKey(key, pScreen), val);
 }
 
 static inline pointer
commit eadf5021794782fde861d471ed408675f4926b89
Author: Alan Coopersmith <alan.coopersmith at oracle.com>
Date:   Mon May 2 19:48:42 2011 -0700

    Use XORG_STRICT_OPTION from util-macros 1.14 to set -Werror flags
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
    Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/m4/xorg-tls.m4 b/m4/xorg-tls.m4
index 5638504..237fdcd 100644
--- a/m4/xorg-tls.m4
+++ b/m4/xorg-tls.m4
@@ -22,6 +22,7 @@ dnl
 dnl Authors: Jeremy Huddleston <jeremyhu at apple.com>
 
 AC_DEFUN([XORG_TLS], [
+    AC_REQUIRE([XORG_STRICT_OPTION])
     AC_MSG_CHECKING(for thread local storage (TLS) support)
     AC_CACHE_VAL(ac_cv_tls, [
         ac_cv_tls=none
@@ -36,10 +37,7 @@ AC_DEFUN([XORG_TLS], [
         AC_MSG_CHECKING(for tls_model attribute support)
         AC_CACHE_VAL(ac_cv_tls_model, [
             save_CFLAGS="$CFLAGS"
-            dnl -Werror causes clang's default -Wunknown-attributes to become an error
-            dnl We can't use -Werror=unknown-attributes because gcc doesn't understand it
-            dnl -Werror=attributes is for gcc, clang seems to ignore it
-            CFLAGS="$CFLAGS -Werror -Werror=attributes"
+            CFLAGS="$CFLAGS $STRICT_CFLAGS"
             AC_TRY_COMPILE([int $ac_cv_tls __attribute__((tls_model("initial-exec"))) test;], [],
                            ac_cv_tls_model=yes, ac_cv_tls_model=no)
             CFLAGS="$save_CFLAGS"
commit 9275b1fb6f82a6971c4177ddd3d5a859a8f24119
Author: Alan Coopersmith <alan.coopersmith at oracle.com>
Date:   Mon May 2 19:47:44 2011 -0700

    Use XORG_COMPILER_BRAND from util-macros 1.14 to check for SUNCC
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/configure.ac b/configure.ac
index 655c0e4..262ea18 100644
--- a/configure.ac
+++ b/configure.ac
@@ -32,10 +32,10 @@ AC_CONFIG_SRCDIR([Makefile.am])
 AM_INIT_AUTOMAKE([foreign dist-bzip2])
 AM_MAINTAINER_MODE
 
-# Require xorg-macros minimum of 1.13 for XORG_ENABLE_UNIT_TESTS
+# Require xorg-macros minimum of 1.14 for XORG_COMPILER_BRAND in XORG_DEFAULT_OPTIONS
 m4_ifndef([XORG_MACROS_VERSION],
-          [m4_fatal([must install xorg-macros 1.13 or later before running autoconf/autogen])])
-XORG_MACROS_VERSION(1.13)
+          [m4_fatal([must install xorg-macros 1.14 or later before running autoconf/autogen])])
+XORG_MACROS_VERSION(1.14)
 XORG_DEFAULT_OPTIONS
 XORG_WITH_DOXYGEN(1.6.1)
 XORG_CHECK_SGML_DOCTOOLS(1.7)
@@ -1522,7 +1522,6 @@ if test "x$XORG" = xyes; then
 	    if test x$GCC = xyes; then
 		VISIBILITY_CFLAGS="-fvisibility=hidden"
 	    else
-		AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"])
 		if test x$SUNCC = xyes; then
 		    VISIBILITY_CFLAGS="-xldscope=hidden"
 		else
@@ -1631,7 +1630,6 @@ if test "x$XORG" = xyes; then
 		if test "${OS_MINOR}" -lt 8 ; then
 			AC_MSG_ERROR([This release no longer supports Solaris versions older than Solaris 8.])
 		fi
-		AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"])
 		if test "x$SUNCC" = "xyes"; then
 			solaris_asm_inline="yes"
 		fi
commit 4621bb270a36d35d4ab67f1d7fb47674683dfc5b
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Wed May 18 15:00:54 2011 +1000

    Add a property for device/product ID.
    
    In some cases, knowing about the device model number and the device's vendor
    is important to activate product-specific settings. Since this is
    nonetheless driver-specific, only provide the property but don't do anything
    with it.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>

diff --git a/include/xserver-properties.h b/include/xserver-properties.h
index a49291b..2b1feab 100644
--- a/include/xserver-properties.h
+++ b/include/xserver-properties.h
@@ -35,6 +35,11 @@
 /* BOOL. If present, device is a virtual XTEST device */
 #define XI_PROP_XTEST_DEVICE  "XTEST Device"
 
+/* CARD32, 2 values, vendor, product.
+ * This property is set by the driver and may not be available for some
+ * drivers. Read-Only */
+#define XI_PROP_PRODUCT_ID "Device Product ID"
+
 /* Coordinate transformation matrix for absolute input devices
  * FLOAT, 9 values in row-major order, coordinates in 0..1 range:
  * [c0 c1 c2]   [x]
commit f26a5b9a994a980ab309bc7f3b4295a4992d81c2
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Mon Jan 31 14:43:01 2011 +1000

    Xi: add device node property to known properties.
    
    Since the server has little choice (or even knowledge) of the actual device
    node used by the driver, this property is merely provided for
    standardisation. It is up to the driver to set it to the appropriate value,
    usually a device node in the form of /dev/input/event0 or similar.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Acked-by: Dan Nicholson <dbn.lists at gmail.com>

diff --git a/include/xserver-properties.h b/include/xserver-properties.h
index c6259ae..a49291b 100644
--- a/include/xserver-properties.h
+++ b/include/xserver-properties.h
@@ -42,6 +42,9 @@
  * [c6 c7 c8]   [1] */
 #define XI_PROP_TRANSFORM "Coordinate Transformation Matrix"
 
+/* STRING. Device node path of device */
+#define XI_PROP_DEVICE_NODE "Device Node"
+
 /* Pointer acceleration properties */
 /* INTEGER of any format */
 #define ACCEL_PROP_PROFILE_NUMBER "Device Accel Profile"
commit 8d84fd2566f8466b6152724df7eefc73780df093
Author: Søren Sandmann Pedersen <ssp at redhat.com>
Date:   Wed May 25 12:14:05 2011 -0400

    Don't call pixman_disable_out_of_bounds_workaround() anymore
    
    Pixman used to have a workaround for a bug in old X servers, and this
    function was used to disable that workaround in servers known to be
    fixed.
    
    Since 0.22, which the X server depends on, the workaround doesn't
    exist anymore, so there is no point disabling it.
    
    Reviewed-by: Cyril Brulebois <kibi at debian.org>
    Signed-off-by: Soren Sandmann <sandmann at cs.au.dk>

diff --git a/dix/main.c b/dix/main.c
index bc958b8..955b7ea 100644
--- a/dix/main.c
+++ b/dix/main.c
@@ -139,8 +139,6 @@ int main(int argc, char *argv[], char *envp[])
 
     InitRegions();
 
-    pixman_disable_out_of_bounds_workaround();
-
     CheckUserParameters(argc, argv, envp);
 
     CheckUserAuthorization();
commit b6c7b9b2f39e970cedb6bc1e073f901e28cb0fa3
Author: Aaron Plattner <aplattner at nvidia.com>
Date:   Tue May 24 16:02:42 2011 -0700

    randr: check rotated virtual size limits correctly
    
    Commit d1107918d4626268803b54033a07405122278e7f introduced checks to
    the RandR path that cause RRSetScreenConfig requests to fail if the
    size is too large.  Unfortunately, when RandR 1.1 rotation is enabled
    it compares the rotated screen dimensions to the unrotated limits,
    which causes 90- and 270-degree rotation to fail unless your screen
    happens to be square:
    
      X Error of failed request:  BadValue (integer parameter out of range for operation)
        Major opcode of failed request:  153 (RANDR)
        Minor opcode of failed request:  2 (RRSetScreenConfig)
        Value in failed request:  0x780
        Serial number of failed request:  14
        Current serial number in output stream:  14
    
    Fix this by moving the check above the code that swaps the dimensions
    based on the rotation.
    
    Signed-off-by: Aaron Plattner <aplattner at nvidia.com>
    Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com>
    Tested-by: Robert Hooker <robert.hooker at canonical.com>
    Tested-by: Kent Baxley <kent.baxley at canonical.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/randr/rrscreen.c b/randr/rrscreen.c
index 1bc1a9e..da6d48d 100644
--- a/randr/rrscreen.c
+++ b/randr/rrscreen.c
@@ -910,12 +910,6 @@ ProcRRSetScreenConfig (ClientPtr client)
      */
     width = mode->mode.width;
     height = mode->mode.height;
-    if (rotation & (RR_Rotate_90|RR_Rotate_270))
-    {
-	width = mode->mode.height;
-	height = mode->mode.width;
-    }
-
     if (width < pScrPriv->minWidth || pScrPriv->maxWidth < width) {
 	client->errorValue = width;
 	free(pData);
@@ -927,6 +921,12 @@ ProcRRSetScreenConfig (ClientPtr client)
 	return BadValue;
     }
 
+    if (rotation & (RR_Rotate_90|RR_Rotate_270))
+    {
+	width = mode->mode.height;
+	height = mode->mode.width;
+    }
+
     if (width != pScreen->width || height != pScreen->height)
     {
 	int	c;
commit 4725d6b0dbb6371af4a1b2fbef851dcfe155514a
Merge: 1b2d177... b5d8287...
Author: Keith Packard <keithp at keithp.com>
Date:   Wed May 25 09:40:51 2011 -0600

    Merge remote-tracking branch 'whot/for-keith'

commit 1b2d17748f0154da142e9b421d4f6a46e4e5a18c
Author: Alan Coopersmith <alan.coopersmith at oracle.com>
Date:   Sun May 22 13:50:14 2011 -0700

    fbbltone.c: Mark bitmasks as unsigned ints
    
    Clears many Sun compiler warnings:
    "fbbltone.c", line 491: warning: integer overflow detected: op "<<"
    "fbbltone.c", line 491: warning: integer overflow detected: op "<<"
    "fbbltone.c", line 491: warning: integer overflow detected: op "<<"
    "fbbltone.c", line 491: warning: initializer will be sign-extended: -16777216
    "fbbltone.c", line 491: warning: integer overflow detected: op "<<"
    "fbbltone.c", line 491: warning: initializer will be sign-extended: -1
    "fbbltone.c", line 495: warning: integer overflow detected: op "<<"
    "fbbltone.c", line 495: warning: integer overflow detected: op "<<"
    "fbbltone.c", line 495: warning: integer overflow detected: op "<<"
    "fbbltone.c", line 495: warning: initializer will be sign-extended: -256
    "fbbltone.c", line 495: warning: integer overflow detected: op "<<"
    "fbbltone.c", line 495: warning: initializer will be sign-extended: -1
    "fbbltone.c", line 499: warning: integer overflow detected: op "<<"
    "fbbltone.c", line 499: warning: integer overflow detected: op "<<"
    "fbbltone.c", line 499: warning: integer overflow detected: op "<<"
    "fbbltone.c", line 499: warning: initializer will be sign-extended: -65536
    "fbbltone.c", line 499: warning: integer overflow detected: op "<<"
    "fbbltone.c", line 499: warning: initializer will be sign-extended: -1
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
    Reviewed-by: Jamey Sharp <jamey at minilop.net>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/fb/fbbltone.c b/fb/fbbltone.c
index 0a91575..67e7853 100644
--- a/fb/fbbltone.c
+++ b/fb/fbbltone.c
@@ -428,8 +428,8 @@ fbBltOne (FbStip    *src,
 
 #define Mask24(x,r) (Mask24Pos(x,r) < FB_UNIT ? \
 		     (Mask24Pos(x,r) < 0 ? \
-		      0xffffff >> Mask24Neg (x,r) : \
-		      0xffffff << Mask24Check(x,r)) : 0)
+		      0xffffffU >> Mask24Neg (x,r) : \
+		      0xffffffU << Mask24Check(x,r)) : 0)
 
 #define SelMask24(b,n,r)	((((b) >> n) & 1) * Mask24(n,r))
 
commit b5d828789c092c994722a896c252212e2b3614ab
Author: Simon Thum <simon.thum at gmx.de>
Date:   Thu Mar 10 21:03:40 2011 +0100

    xserver: remove AbsoluteClass, breaking the A(P|B)I
    
    This struct was unused and has been effectively removed in
    commit 633b81e8ba09cc6a1ea8b43f323874fda2cf0bde
    Refs: xorg-server-1.10.0-133-g633b81e
    
    Remove the remainder, with an ABI bump to 13.0.
    
    Signed-off-by: Simon Thum <simon.thum at gmx.de>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/dix/devices.c b/dix/devices.c
index 9a4498b..0ccf252 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -1361,15 +1361,6 @@ InitPointerAccelerationScheme(DeviceIntPtr dev,
 }
 
 Bool
-InitAbsoluteClassDeviceStruct(DeviceIntPtr dev)
-{
-    /* This is an API-preserving noop. Instructions: Kill when no more drivers
-     * call it. The infrastructure behind hasn't really been used, so any calls
-     * are likely just a declaration that the device is absolute. */
-    return FALSE;
-}
-
-Bool
 InitFocusClassDeviceStruct(DeviceIntPtr dev)
 {
     FocusClassPtr focc;
diff --git a/hw/xfree86/common/xf86Module.h b/hw/xfree86/common/xf86Module.h
index 94f17e9..2a5c805 100644
--- a/hw/xfree86/common/xf86Module.h
+++ b/hw/xfree86/common/xf86Module.h
@@ -83,7 +83,7 @@ typedef enum {
  */
 #define ABI_ANSIC_VERSION	SET_ABI_VERSION(0, 4)
 #define ABI_VIDEODRV_VERSION	SET_ABI_VERSION(11, 0)
-#define ABI_XINPUT_VERSION	SET_ABI_VERSION(12, 2)
+#define ABI_XINPUT_VERSION	SET_ABI_VERSION(13, 0)
 #define ABI_EXTENSION_VERSION	SET_ABI_VERSION(5, 0)
 #define ABI_FONT_VERSION	SET_ABI_VERSION(0, 6)
 
diff --git a/include/input.h b/include/input.h
index 4de4ff5..56847ed 100644
--- a/include/input.h
+++ b/include/input.h
@@ -305,12 +305,6 @@ extern _X_EXPORT Bool InitPointerAccelerationScheme(
     DeviceIntPtr /*dev*/,
     int /*scheme*/);
 
-/**
- * This is not implemented and just returns FALSE.
- */
-extern _X_EXPORT _X_DEPRECATED Bool InitAbsoluteClassDeviceStruct(
-    DeviceIntPtr /*device*/);
-
 extern _X_EXPORT Bool InitFocusClassDeviceStruct(
     DeviceIntPtr /*device*/);
 
diff --git a/include/inputstr.h b/include/inputstr.h
index bc0accc..00f72c2 100644
--- a/include/inputstr.h
+++ b/include/inputstr.h
@@ -371,7 +371,6 @@ typedef struct _ClassesRec {
     ButtonClassPtr	button;
     FocusClassPtr	focus;
     ProximityClassPtr	proximity;
-    void*               _pad0; /* keep ABI during AbsoluteClass removal */
     KbdFeedbackPtr	kbdfeed;
     PtrFeedbackPtr	ptrfeed;
     IntegerFeedbackPtr	intfeed;
@@ -496,7 +495,6 @@ typedef struct _DeviceIntRec {
     ButtonClassPtr	button;
     FocusClassPtr	focus;
     ProximityClassPtr	proximity;
-    void*               _pad0;          /* keep ABI, was pointer to abs class */
     KbdFeedbackPtr	kbdfeed;
     PtrFeedbackPtr	ptrfeed;
     IntegerFeedbackPtr	intfeed;
commit c05c8640f13708384e77579e7714ca846fa93f5c
Author: Oleh Nykyforchyn <oleh.nyk at gmail.com>
Date:   Thu May 19 09:39:52 2011 +0300

    xfree86: Allow "MatchLayout" statements in config files
    
    Usage example (tested on a dual-seat PC):
    Section "InputClass"
     	Identifier "keyboard-all"
     	MatchIsKeyboard "on"
     	MatchDevicePath "/dev/input/event*"
     	MatchLayout "!GeForce|!Matrox"
     	Driver "evdev"
     	Option "XkbLayout" "us"
     	Option "XkbOptions" "terminate:ctrl_alt_bksp"
    EndSection
    
    It disables auto keyboard configuration for layouts "GeForce" and "Matrox".
    Note that "" in patterns means "no Layout sections found", e.g.
     	MatchLayout "GeForce|"
    is "in layout GeForce or without explicit layout at all".
    
    Signed-off-by: Oleh Nykyforchyn <oleh.nyk at gmail.com>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Acked-by: Dan Nicholson <dbn.lists at gmail.com>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index e7e1ce1..26051ad 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -470,6 +470,20 @@ match_path_pattern(const char *attr, const char *pattern)
 #endif
 
 /*
+ * If no Layout section is found, xf86ServerLayout.id becomes "(implicit)"
+ * It is convenient that "" in patterns means "no explicit layout"
+ */
+static int
+match_string_implicit(const char *attr, const char *pattern)
+{
+    if (strlen(pattern)) {
+        return strcmp(attr, pattern);
+    } else {
+        return strcmp(attr,"(implicit)");
+    }
+}
+
+/*
  * Match an attribute against a list of NULL terminated arrays of patterns.
  * If a pattern in each list entry is matched, return TRUE.
  */
@@ -564,6 +578,13 @@ InputClassMatches(const XF86ConfInputClassPtr iclass, const InputInfoPtr idev,
             return FALSE;
     }
 
+    /* MatchLayout string */
+    if (!list_is_empty(&iclass->match_layout)) {
+        if (!MatchAttrToken(xf86ConfigLayout.id,
+                            &iclass->match_layout, match_string_implicit))
+            return FALSE;
+    }
+
     /* MatchIs* booleans */
     if (iclass->is_keyboard.set &&
         iclass->is_keyboard.val != !!(attrs->flags & ATTR_KEYBOARD))
diff --git a/hw/xfree86/man/xorg.conf.man b/hw/xfree86/man/xorg.conf.man
index 4bec316..f406f82 100644
--- a/hw/xfree86/man/xorg.conf.man
+++ b/hw/xfree86/man/xorg.conf.man
@@ -1140,6 +1140,16 @@ matches the
 pattern. A match is found if at least one of the tags given in
 .RI \*q matchtag \*q
 matches at least one of the tags assigned by the backend.
+.TP 7
+.BI "MatchLayout \*q" matchlayout \*q
+Check the case-sensitive string
+.RI \*q matchlayout \*q
+against the currently active
+.B ServerLayout
+section. The empty string "" matches an implicit layout which appears
+if no named
+.B ServerLayout
+sections have been found.
 .PP
 The second type of entry is used to match device types. These entries take a
 boolean argument similar to
diff --git a/hw/xfree86/parser/InputClass.c b/hw/xfree86/parser/InputClass.c
index 9f88e7e..3f80170 100644
--- a/hw/xfree86/parser/InputClass.c
+++ b/hw/xfree86/parser/InputClass.c
@@ -52,6 +52,7 @@ xf86ConfigSymTabRec InputClassTab[] =
     {MATCH_USBID, "matchusbid"},
     {MATCH_DRIVER, "matchdriver"},
     {MATCH_TAG, "matchtag"},
+    {MATCH_LAYOUT, "matchlayout"},
     {MATCH_IS_KEYBOARD, "matchiskeyboard"},
     {MATCH_IS_POINTER, "matchispointer"},
     {MATCH_IS_JOYSTICK, "matchisjoystick"},
@@ -94,6 +95,7 @@ xf86parseInputClassSection(void)
     list_init(&ptr->match_usbid);
     list_init(&ptr->match_driver);
     list_init(&ptr->match_tag);
+    list_init(&ptr->match_layout);
 
     while ((token = xf86getToken(InputClassTab)) != ENDSECTION) {
         switch (token) {
@@ -169,6 +171,12 @@ xf86parseInputClassSection(void)
             add_group_entry(&ptr->match_tag,
                             xstrtokenize(val.str, TOKEN_SEP));
             break;
+        case MATCH_LAYOUT:
+            if (xf86getSubToken(&(ptr->comment)) != STRING)
+                Error(QUOTE_MSG, "MatchLayout");
+            add_group_entry(&ptr->match_layout,
+                            xstrtokenize(val.str, TOKEN_SEP));
+            break;
         case MATCH_IS_KEYBOARD:
             if (xf86getSubToken(&(ptr->comment)) != STRING)
                 Error(QUOTE_MSG, "MatchIsKeyboard");
@@ -307,6 +315,13 @@ xf86printInputClassSection (FILE * cf, XF86ConfInputClassPtr ptr)
                         *cur);
             fprintf(cf, "\"\n");
         }
+        list_for_each_entry(group, &ptr->match_layout, entry) {
+            fprintf(cf, "\tMatchLayout     \"");
+            for (cur = group->values; *cur; cur++)
+                fprintf(cf, "%s%s", cur == group->values ? "" : TOKEN_SEP,
+                        *cur);
+            fprintf(cf, "\"\n");
+        }
 
         if (ptr->is_keyboard.set)
             fprintf(cf, "\tIsKeyboard      \"%s\"\n",
@@ -392,6 +407,12 @@ xf86freeInputClassList (XF86ConfInputClassPtr ptr)
                 free(*list);
             free(group);
         }
+        list_for_each_entry_safe(group, next, &ptr->match_layout, entry) {
+            list_del(&group->entry);
+            for (list = group->values; *list; list++)
+                free(*list);
+            free(group);
+        }
 
         TestFree(ptr->comment);
         xf86optionListFree(ptr->option_lst);
diff --git a/hw/xfree86/parser/xf86Parser.h b/hw/xfree86/parser/xf86Parser.h
index 4f279f1..a8785c5 100644
--- a/hw/xfree86/parser/xf86Parser.h
+++ b/hw/xfree86/parser/xf86Parser.h
@@ -358,6 +358,7 @@ typedef struct
 	struct list match_usbid;
 	struct list match_driver;
 	struct list match_tag;
+	struct list match_layout;
 	xf86TriState is_keyboard;
 	xf86TriState is_pointer;
 	xf86TriState is_joystick;
diff --git a/hw/xfree86/parser/xf86tokens.h b/hw/xfree86/parser/xf86tokens.h
index 468a2ff..abcafcf 100644
--- a/hw/xfree86/parser/xf86tokens.h
+++ b/hw/xfree86/parser/xf86tokens.h
@@ -282,6 +282,7 @@ typedef enum {
     MATCH_USBID,
     MATCH_DRIVER,
     MATCH_TAG,
+    MATCH_LAYOUT,
     MATCH_IS_KEYBOARD,
     MATCH_IS_POINTER,
     MATCH_IS_JOYSTICK,
commit 83c059f03463f2d7f41e172afe510d1ca9bba8b0
Author: Tomas Frydrych <tomas at sleepfive.com>
Date:   Wed May 18 20:49:52 2011 +0100

    Xephyr: fix pointer coordinate translation when screen is rotated
    
    In the Xephyr case the position of the pointer relative toward the
    Xephyr window is controlled by the host server without taking into
    account rotation of the Xephyr screen. Consequently the pointer coords
    must always be translated when the fb is rotated.
    
    Signed-off-by: Tomas Frydrych <tomas at sleepfive.com>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/hw/kdrive/ephyr/ephyr.c b/hw/kdrive/ephyr/ephyr.c
index 8096a24..ac8e5be 100644
--- a/hw/kdrive/ephyr/ephyr.c
+++ b/hw/kdrive/ephyr/ephyr.c
@@ -52,6 +52,7 @@ Bool ephyrNoDRI=FALSE ;
 Bool ephyrNoXV=FALSE ;
 
 static int mouseState = 0;
+static Rotation ephyrRandr = RR_Rotate_0;
 
 typedef struct _EphyrInputPrivate {
     Bool    enabled;
@@ -249,7 +250,11 @@ ephyrMapFramebuffer (KdScreenInfo *screen)
   EPHYR_LOG("screen->width: %d, screen->height: %d index=%d",
 	     screen->width, screen->height, screen->mynum);
   
-  KdComputePointerMatrix (&m, scrpriv->randr, screen->width, screen->height);
+  /*
+   * Use the rotation last applied to ourselves (in the Xephyr case the fb
+   * coordinate system moves independently of the pointer coordiante system).
+   */
+  KdComputePointerMatrix (&m, ephyrRandr, screen->width, screen->height);
   KdSetPointerMatrix (&m);
   
   priv->bytes_per_line = ((screen->width * screen->fb.bitsPerPixel + 31) >> 5) << 2;
@@ -530,7 +535,15 @@ ephyrRandRSetConfig (ScreenPtr		pScreen,
    * Set new configuration
    */
   
-  scrpriv->randr = KdAddRotation (screen->randr, randr);
+  /*
+   * We need to store the rotation value for pointer coords transformation;
+   * though initially the pointer and fb rotation are identical, when we map
+   * the fb, the screen will be reinitialized and return into an unrotated
+   * state (presumably the HW is taking care of the rotation of the fb), but the
+   * pointer still needs to be transformed.
+   */
+  ephyrRandr = KdAddRotation (screen->randr, randr);
+  scrpriv->randr = ephyrRandr;
   
   ephyrUnmapFramebuffer (screen); 
   
@@ -1058,6 +1071,14 @@ MouseInit (KdPointerInfo *pi)
     pi->nButtons = 32;
     free(pi->name);
     pi->name = strdup("Xephyr virtual mouse");
+
+    /*
+     * Must transform pointer coords since the pointer position
+     * relative to the Xephyr window is controlled by the host server and
+     * remains constant regardless of any rotation applied to the Xephyr screen.
+     */
+    pi->transformCoordinates = TRUE;
+
     ephyrMouse = pi;
     return Success;
 }
commit b387069fafbe549f2091f364e2aa92af6cc21261
Author: Tomas Frydrych <tomas at sleepfive.com>
Date:   Wed May 18 20:47:52 2011 +0100

    Xephyr: added dummy ephyrDeviceCursorCleanup() to avoid crashing
    
    The DeviceCursorCleanup in miPointerSpriteFuncRec can no longer be
    NULL it seems.
    
    Signed-off-by: Tomas Frydrych <tomas at sleepfive.com>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/hw/kdrive/ephyr/ephyrinit.c b/hw/kdrive/ephyr/ephyrinit.c
index 27cab3b..2deb7b8 100644
--- a/hw/kdrive/ephyr/ephyrinit.c
+++ b/hw/kdrive/ephyr/ephyrinit.c
@@ -358,13 +358,18 @@ ephyrDeviceCursorInitialize(DeviceIntPtr pDev, ScreenPtr pScreen)
   return TRUE;
 }
 
+static void
+ephyrDeviceCursorCleanup(DeviceIntPtr pDev, ScreenPtr pScreen)
+{
+}
+
 miPointerSpriteFuncRec EphyrPointerSpriteFuncs = {
 	ephyrRealizeCursor,
 	ephyrUnrealizeCursor,
 	ephyrSetCursor,
 	ephyrMoveCursor,
 	ephyrDeviceCursorInitialize,
-	NULL
+	ephyrDeviceCursorCleanup
 };
 
 
commit 53ccc54ac71c2655276678e13f0b3d879d691489
Author: Colin Harrison <colin.harrison at virgin.net>
Date:   Mon May 16 19:31:57 2011 +0100

    Fix XWin compilation after updates for input API changes
    
    Fix XWin compilation after updates for input API changes in commits
    e7150db5 8670c46b and 20fb07f4
    
    Also remove a no longer needed InternalEvent* variable
    
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/hw/xwin/winkeybd.c b/hw/xwin/winkeybd.c
index 2fa6b3f..a3112ff 100644
--- a/hw/xwin/winkeybd.c
+++ b/hw/xwin/winkeybd.c
@@ -472,8 +472,6 @@ winKeybdReleaseKeys (void)
 void
 winSendKeyEvent (DWORD dwKey, Bool fDown)
 {
-  InternalEvent* events;
-
   /*
    * When alt-tabing between screens we can get phantom key up messages
    * Here we only pass them through it we think we should!
@@ -485,8 +483,8 @@ winSendKeyEvent (DWORD dwKey, Bool fDown)
 
   QueueKeyboardEvents(g_pwinKeyboard, fDown ? KeyPress : KeyRelease, dwKey + MIN_KEYCODE, NULL);
 
-  winDebug("winSendKeyEvent: dwKey: %d, fDown: %d, nEvents %d\n",
-           dwKey, fDown, nevents);
+  winDebug("winSendKeyEvent: dwKey: %d, fDown: %d\n",
+           dwKey, fDown);
 }
 
 BOOL winCheckKeyPressed(WPARAM wParam, LPARAM lParam)
diff --git a/hw/xwin/winmouse.c b/hw/xwin/winmouse.c
index b1b0657..752334a 100644
--- a/hw/xwin/winmouse.c
+++ b/hw/xwin/winmouse.c
@@ -244,8 +244,8 @@ winMouseButtonsSendEvent (int iEventType, int iButton)
 		     POINTER_RELATIVE, &mask);
 
 #if CYGDEBUG
-  ErrorF("winMouseButtonsSendEvent: iEventType: %d, iButton: %d, nEvents %d\n",
-          iEventType, iButton, nevents);
+  ErrorF("winMouseButtonsSendEvent: iEventType: %d, iButton: %d\n",
+          iEventType, iButton);
 #endif
 }
 
commit 4c4df3ac0d8162c874b85fede12ffbe42f0062c3
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Sat May 14 16:23:59 2011 -0700

    input: Don't implicitly define verify_internal_event
    
    Fixes regression introduced by 56901998020b6f443cbaa5eb303100d979e81b22
    
    mieq.c:159:5: error: implicit declaration of function 'verify_internal_event' is invalid in C99 [-Wimplicit-function-declaration,Semantic Issue]
        verify_internal_event(e);
        ^
    1 error generated.
    
    Also includes some other warning cleanups in events.c we're there.
    
    events.c:2198:24: warning: equality comparison with extraneous parentheses [-Wparentheses,Semantic Issue]
            else if ((type == MotionNotify))
                      ~~~~~^~~~~~~~~~~~~~~
    events.c:2198:24: note: remove extraneous parentheses around the comparison to silence this warning [Semantic Issue]
            else if ((type == MotionNotify))
                     ~     ^              ~
    events.c:2198:24: note: use '=' to turn this equality comparison into an assignment [Semantic Issue]
            else if ((type == MotionNotify))
                           ^~
                           =
    events.c:2487:5: error: implicit declaration of function 'verify_internal_event' is invalid in C99 [-Wimplicit-function-declaration,Semantic Issue]
        verify_internal_event(event);
        ^
    events.c:5909:22: warning: declaration shadows a local variable [-Wshadow,Semantic Issue]
            DeviceIntPtr it = inputInfo.devices;
                         ^
    events.c:5893:18: note: previous declaration is here
        DeviceIntPtr it = inputInfo.devices;
                     ^
    3 warnings and 1 error generated.
    
    events.c:2836:27: warning: incompatible pointer types passing 'DeviceEvent *' (aka 'struct _DeviceEvent *') to parameter of type
          'const InternalEvent *' (aka 'const union _InternalEvent *')
        verify_internal_event(ev);
                              ^~
    ../include/inpututils.h:40:56: note: passing argument to parameter 'ev' here
    extern void verify_internal_event(const InternalEvent *ev);
                                                           ^
    1 warning generated.
    
    Found-by: yuffie tinderbox (-Werror=implicit)
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/dix/events.c b/dix/events.c
index 14f6f90..b60c299 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -112,6 +112,7 @@ Equipment Corporation.
 #include <X11/Xproto.h>
 #include "windowstr.h"
 #include "inputstr.h"
+#include "inpututils.h"
 #include "scrnintstr.h"
 #include "cursorstr.h"
 
@@ -2195,7 +2196,7 @@ DeliverEventsToWindow(DeviceIntPtr pDev, WindowPtr pWin, xEvent
          */
         if (!grab && ActivateImplicitGrab(pDev, client, pWin, pEvents, deliveryMask))
             /* grab activated */;
-        else if ((type == MotionNotify))
+        else if (type == MotionNotify)
             pDev->valuator->motionHintWindow = pWin;
         else if (type == DeviceMotionNotify || type == DeviceButtonPress)
                 CheckDeviceGrabAndHintWindow (pWin, type,
@@ -2832,7 +2833,7 @@ CheckMotion(DeviceEvent *ev, DeviceIntPtr pDev)
     WindowPtr prevSpriteWin, newSpriteWin;
     SpritePtr pSprite = pDev->spriteInfo->sprite;
 
-    verify_internal_event(ev);
+    verify_internal_event((InternalEvent *)ev);
 
     prevSpriteWin = pSprite->win;
 
@@ -5906,7 +5907,7 @@ PickPointer(ClientPtr client)
 
     if (!client->clientPtr)
     {
-        DeviceIntPtr it = inputInfo.devices;
+        it = inputInfo.devices;
         while (it)
         {
             if (IsMaster(it) && it->spriteInfo->spriteOwner)
diff --git a/mi/mieq.c b/mi/mieq.c
index 031b11a..fc3738a 100644
--- a/mi/mieq.c
+++ b/mi/mieq.c
@@ -43,6 +43,7 @@ in this Software without prior written authorization from The Open Group.
 # include   "windowstr.h"
 # include   "pixmapstr.h"
 # include   "inputstr.h"
+# include   "inpututils.h"
 # include   "mi.h"
 # include   "mipointer.h"
 # include   "scrnintstr.h"
commit ba7d1020ac0135ebc8acda4cd57ed48b331e0133
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Sat May 14 16:31:10 2011 -0700

    input: Fix format string for verify_internal_event
    
    inpututils.c:577:25: warning: conversion specifies type 'unsigned short' but the argument has type 'unsigned char' [-Wformat,Format String Issue]
                ErrorF("%02hx ", *data);
                        ~~~~^    ~~~~~
                        %02hhx
    1 warning generated.
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/dix/inpututils.c b/dix/inpututils.c
index aeace6e..49e1758 100644
--- a/dix/inpututils.c
+++ b/dix/inpututils.c
@@ -574,7 +574,7 @@ void verify_internal_event(const InternalEvent *ev)
 
         for (i = 0; i < sizeof(xEvent); i++, data++)
         {
-            ErrorF("%02hx ", *data);
+            ErrorF("%02hhx ", *data);
 
             if ((i % 8) == 7)
                 ErrorF("\n");
commit 0de7cec90738a7a5020150309866bb0e23b6f479
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Thu May 19 15:36:29 2011 +1000

    xfree86: bump to video ABI 11
    
    We've broken the ABI with some commit and drivers built against ABI 10
    happily segfault now.
    
    (The relevant patch is 51f353d0a0d116af16d7d9590cadef6c56328746 which
    changed the ATOM typedef from unsigned long to uint32_t, thanks to
    Cyril Brulebois <kibi at debian.org>  for figuring this out)
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/xfree86/common/xf86Module.h b/hw/xfree86/common/xf86Module.h
index 581047d..94f17e9 100644
--- a/hw/xfree86/common/xf86Module.h
+++ b/hw/xfree86/common/xf86Module.h
@@ -82,7 +82,7 @@ typedef enum {
  * mask is 0xFFFF0000.
  */
 #define ABI_ANSIC_VERSION	SET_ABI_VERSION(0, 4)
-#define ABI_VIDEODRV_VERSION	SET_ABI_VERSION(10, 0)
+#define ABI_VIDEODRV_VERSION	SET_ABI_VERSION(11, 0)
 #define ABI_XINPUT_VERSION	SET_ABI_VERSION(12, 2)
 #define ABI_EXTENSION_VERSION	SET_ABI_VERSION(5, 0)
 #define ABI_FONT_VERSION	SET_ABI_VERSION(0, 6)
commit 1fb501ad1521cfedaa5cf3052d45a924ef1866cf
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Sun May 22 10:18:36 2011 -0700

    XQuartz: Don't crash if CG increases our display resolution
    
    miPaintWindow would cause fbFill() to overwrite pScreen's pixmap which was
    sized for the old resolution.
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/hw/xquartz/quartz.c b/hw/xquartz/quartz.c
index 68a059c..c395b42 100644
--- a/hw/xquartz/quartz.c
+++ b/hw/xquartz/quartz.c
@@ -239,8 +239,6 @@ void QuartzUpdateScreens(void) {
     AppleWMSetScreenOrigin(pRoot);
     pScreen->ResizeWindow(pRoot, x - sx, y - sy, width, height, NULL);
 
-    miPaintWindow(pRoot, &pRoot->borderClip,  PW_BACKGROUND);
-
     /* <rdar://problem/7770779> pointer events are clipped to old display region after display reconfiguration
      * http://xquartz.macosforge.org/trac/ticket/346
      */
@@ -268,6 +266,9 @@ void QuartzUpdateScreens(void) {
 
     quartzProcs->UpdateScreen(pScreen);
 
+    /* miPaintWindow needs to be called after RootlessUpdateScreenPixmap (from xprUpdateScreen) */
+    miPaintWindow(pRoot, &pRoot->borderClip,  PW_BACKGROUND);
+
     /* Tell RandR about the new size, so new connections get the correct info */
     RRScreenSizeNotify(pScreen);
 }
commit 60af79e35ee8546a99d15a1358aac3deabfa22be
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Sun May 22 09:32:57 2011 -0700

    XQuartz: RandR: Don't crash if X11 is launched while there are no attached displays
    
    If CG reports no displays when launching, we could crash in RandR.  Instead, just
    provide a fake 800x600 display until we are notified about displays being attached.
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/hw/xquartz/quartz.c b/hw/xquartz/quartz.c
index 0e71d36..68a059c 100644
--- a/hw/xquartz/quartz.c
+++ b/hw/xquartz/quartz.c
@@ -464,11 +464,15 @@ void QuartzSpaceChanged(uint32_t space_id) {
 void QuartzCopyDisplayIDs(ScreenPtr pScreen,
                           int displayCount, CGDirectDisplayID *displayIDs) {
     QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen);
-    int size = displayCount * sizeof(CGDirectDisplayID);
 
     free(pQuartzScreen->displayIDs);
-    pQuartzScreen->displayIDs = malloc(size);
-    memcpy(pQuartzScreen->displayIDs, displayIDs, size);
+    if(displayCount) {
+        size_t size = displayCount * sizeof(CGDirectDisplayID);
+        pQuartzScreen->displayIDs = malloc(size);
+        memcpy(pQuartzScreen->displayIDs, displayIDs, size);
+    } else {
+       pQuartzScreen->displayIDs = NULL;
+    }
     pQuartzScreen->displayCount = displayCount;
 }
 
diff --git a/hw/xquartz/quartzRandR.c b/hw/xquartz/quartzRandR.c
index d452b02..98b382d 100644
--- a/hw/xquartz/quartzRandR.c
+++ b/hw/xquartz/quartzRandR.c
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 2001-2004 Greg Parker and Torrey T. Lyons,
  *               2010      Jan Hauffa.
- *               2010      Apple Inc.
+ *               2010-2011 Apple Inc.
  *                 All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
@@ -124,44 +124,48 @@ static Bool QuartzRandRSetCGMode (CGDirectDisplayID screenId,
 static Bool QuartzRandREnumerateModes (ScreenPtr pScreen,
                                        QuartzModeCallback callback,
                                        void *data) {
-    CFDictionaryRef curModeRef, modeRef;
-    long curBpp;
-    CFArrayRef modes;
-    QuartzModeInfo modeInfo;
-    int i;
-    BOOL retval = FALSE;
+    Bool retval = FALSE;
     QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen);
-    CGDirectDisplayID screenId = pQuartzScreen->displayIDs[0];
 
-    curModeRef = CGDisplayCurrentMode(screenId);
-    if (!curModeRef)
-        return FALSE;
-    curBpp = getDictLong(curModeRef, kCGDisplayBitsPerPixel);
+    /* Just an 800x600 fallback if we have no attached heads */
+    if(pQuartzScreen->displayIDs) {
+        CFDictionaryRef curModeRef, modeRef;
+        long curBpp;
+        CFArrayRef modes;
+        QuartzModeInfo modeInfo;
+        int i;
+        CGDirectDisplayID screenId = pQuartzScreen->displayIDs[0];
+
+        curModeRef = CGDisplayCurrentMode(screenId);
+        if (!curModeRef)
+            return FALSE;
+        curBpp = getDictLong(curModeRef, kCGDisplayBitsPerPixel);
 
-    modes = CGDisplayAvailableModes(screenId);
-    if (!modes)
-        return FALSE;
-    for (i = 0; i < CFArrayGetCount(modes); i++) {
-        int cb;
-        modeRef = (CFDictionaryRef) CFArrayGetValueAtIndex(modes, i);
-
-        /* Skip modes that are not usable on the current display or have a
-           different pixel encoding than the current mode. */
-        if (((unsigned long) getDictLong(modeRef, kCGDisplayIOFlags) &
-             kDisplayModeUsableFlags) != kDisplayModeUsableFlags)
-            continue;
-        if (getDictLong(modeRef, kCGDisplayBitsPerPixel) != curBpp)
-            continue;
-
-        QuartzRandRGetModeInfo(modeRef, &modeInfo);
-        modeInfo.ref = (void *)modeRef;
-        cb = callback(pScreen, &modeInfo, data);
-        if (cb == CALLBACK_CONTINUE)
-            retval = TRUE;
-        else if (cb == CALLBACK_SUCCESS)
-            return TRUE;
-        else if (cb == CALLBACK_ERROR)
+        modes = CGDisplayAvailableModes(screenId);
+        if (!modes)
             return FALSE;
+        for (i = 0; i < CFArrayGetCount(modes); i++) {
+            int cb;
+            modeRef = (CFDictionaryRef) CFArrayGetValueAtIndex(modes, i);
+
+            /* Skip modes that are not usable on the current display or have a
+               different pixel encoding than the current mode. */
+            if (((unsigned long) getDictLong(modeRef, kCGDisplayIOFlags) &
+                 kDisplayModeUsableFlags) != kDisplayModeUsableFlags)
+                continue;
+            if (getDictLong(modeRef, kCGDisplayBitsPerPixel) != curBpp)
+                continue;
+
+            QuartzRandRGetModeInfo(modeRef, &modeInfo);
+            modeInfo.ref = (void *)modeRef;
+            cb = callback(pScreen, &modeInfo, data);
+            if (cb == CALLBACK_CONTINUE)
+                retval = TRUE;
+            else if (cb == CALLBACK_SUCCESS)
+                return TRUE;
+            else if (cb == CALLBACK_ERROR)
+                return FALSE;
+        }
     }
 
     switch(callback(pScreen, &pQuartzScreen->rootlessMode, data)) {
@@ -225,61 +229,64 @@ static Bool QuartzRandRSetCGMode (CGDirectDisplayID screenId,
 static Bool QuartzRandREnumerateModes (ScreenPtr pScreen,
                                        QuartzModeCallback callback,
                                        void *data) {
-    CGDisplayModeRef curModeRef, modeRef;
-    CFStringRef curPixelEnc, pixelEnc;
-    CFComparisonResult pixelEncEqual;
-    CFArrayRef modes;
-    QuartzModeInfo modeInfo;
-    int i;
     Bool retval = FALSE;
-
     QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen);
-    CGDirectDisplayID screenId = pQuartzScreen->displayIDs[0];
 
-    curModeRef = CGDisplayCopyDisplayMode(screenId);
-    if (!curModeRef)
-        return FALSE;
-    curPixelEnc = CGDisplayModeCopyPixelEncoding(curModeRef);
-    CGDisplayModeRelease(curModeRef);
+    /* Just an 800x600 fallback if we have no attached heads */
+    if(pQuartzScreen->displayIDs) {
+        CGDisplayModeRef curModeRef, modeRef;
+        CFStringRef curPixelEnc, pixelEnc;
+        CFComparisonResult pixelEncEqual;
+        CFArrayRef modes;
+        QuartzModeInfo modeInfo;
+        int i;
+        CGDirectDisplayID screenId = pQuartzScreen->displayIDs[0];
+
+        curModeRef = CGDisplayCopyDisplayMode(screenId);
+        if (!curModeRef)
+            return FALSE;
+        curPixelEnc = CGDisplayModeCopyPixelEncoding(curModeRef);
+        CGDisplayModeRelease(curModeRef);
 
-    modes = CGDisplayCopyAllDisplayModes(screenId, NULL);
-    if (!modes) {
-        CFRelease(curPixelEnc);
-        return FALSE;
-    }
-    for (i = 0; i < CFArrayGetCount(modes); i++) {
-        int cb;
-        modeRef = (CGDisplayModeRef) CFArrayGetValueAtIndex(modes, i);
-
-        /* Skip modes that are not usable on the current display or have a
-           different pixel encoding than the current mode. */
-        if ((CGDisplayModeGetIOFlags(modeRef) & kDisplayModeUsableFlags) !=
-            kDisplayModeUsableFlags)
-            continue;
-        pixelEnc = CGDisplayModeCopyPixelEncoding(modeRef);
-        pixelEncEqual = CFStringCompare(pixelEnc, curPixelEnc, 0);
-        CFRelease(pixelEnc);
-        if (pixelEncEqual != kCFCompareEqualTo)
-            continue;
-
-        QuartzRandRGetModeInfo(modeRef, &modeInfo);
-        modeInfo.ref = modeRef;
-        cb = callback(pScreen, &modeInfo, data);
-        if (cb == CALLBACK_CONTINUE) {
-            retval = TRUE;
-        } else if (cb == CALLBACK_SUCCESS) {
-            CFRelease(modes);
-            CFRelease(curPixelEnc);
-            return TRUE;
-        } else if (cb == CALLBACK_ERROR) {
-            CFRelease(modes);
+        modes = CGDisplayCopyAllDisplayModes(screenId, NULL);
+        if (!modes) {
             CFRelease(curPixelEnc);
             return FALSE;
         }
-    }
+        for (i = 0; i < CFArrayGetCount(modes); i++) {
+            int cb;
+            modeRef = (CGDisplayModeRef) CFArrayGetValueAtIndex(modes, i);
+
+            /* Skip modes that are not usable on the current display or have a
+               different pixel encoding than the current mode. */
+            if ((CGDisplayModeGetIOFlags(modeRef) & kDisplayModeUsableFlags) !=
+                kDisplayModeUsableFlags)
+                continue;
+            pixelEnc = CGDisplayModeCopyPixelEncoding(modeRef);
+            pixelEncEqual = CFStringCompare(pixelEnc, curPixelEnc, 0);
+            CFRelease(pixelEnc);
+            if (pixelEncEqual != kCFCompareEqualTo)
+                continue;
+
+            QuartzRandRGetModeInfo(modeRef, &modeInfo);
+            modeInfo.ref = modeRef;
+            cb = callback(pScreen, &modeInfo, data);
+            if (cb == CALLBACK_CONTINUE) {
+                retval = TRUE;
+            } else if (cb == CALLBACK_SUCCESS) {
+                CFRelease(modes);
+                CFRelease(curPixelEnc);
+                return TRUE;
+            } else if (cb == CALLBACK_ERROR) {
+                CFRelease(modes);
+                CFRelease(curPixelEnc);
+                return FALSE;
+            }
+        }
 
-    CFRelease(modes);
-    CFRelease(curPixelEnc);
+        CFRelease(modes);
+        CFRelease(curPixelEnc);
+    }
 
     switch(callback(pScreen, &pQuartzScreen->rootlessMode, data)) {
         case CALLBACK_SUCCESS:
@@ -347,9 +354,13 @@ static int QuartzRandRRegisterModeCallback (ScreenPtr pScreen,
 
 static Bool QuartzRandRSetMode(ScreenPtr pScreen, QuartzModeInfoPtr pMode, BOOL doRegister) {
     QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen);
-    CGDirectDisplayID screenId = pQuartzScreen->displayIDs[0];
     Bool captureDisplay = (pMode->refresh != FAKE_REFRESH_FULLSCREEN && pMode->refresh != FAKE_REFRESH_ROOTLESS);
+    CGDirectDisplayID screenId;
 
+    if(pQuartzScreen->displayIDs == NULL)
+        return FALSE;
+
+    screenId = pQuartzScreen->displayIDs[0];
     if(XQuartzShieldingWindowLevel == 0 && captureDisplay) {
         if(!X11ApplicationCanEnterRandR())
             return FALSE;
@@ -379,7 +390,8 @@ static Bool QuartzRandRSetMode(ScreenPtr pScreen, QuartzModeInfoPtr pMode, BOOL
     if(pQuartzScreen->currentMode.ref)
         CFRelease(pQuartzScreen->currentMode.ref);
     pQuartzScreen->currentMode = *pMode;
-    CFRetain(pQuartzScreen->currentMode.ref);
+    if(pQuartzScreen->currentMode.ref)
+        CFRetain(pQuartzScreen->currentMode.ref);
     
     if(XQuartzShieldingWindowLevel != 0 && !captureDisplay) {
         CGReleaseAllDisplays();
@@ -406,13 +418,8 @@ static int QuartzRandRSetModeCallback (ScreenPtr pScreen,
 }
 
 static Bool QuartzRandRGetInfo (ScreenPtr pScreen, Rotation *rotations) {
-    QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen);
-
     *rotations = RR_Rotate_0;  /* TODO: support rotation */
 
-    if (pQuartzScreen->displayCount == 0)
-        return FALSE;
-
     return QuartzRandREnumerateModes(pScreen, QuartzRandRRegisterModeCallback, NULL);
 }
 
@@ -427,9 +434,6 @@ static Bool QuartzRandRSetConfig (ScreenPtr           pScreen,
     reqMode.height = pSize->height;
     reqMode.refresh = rate;
 
-    if (pQuartzScreen->displayCount == 0)
-        return FALSE;
-
     /* Do not switch modes if requested mode is equal to current mode. */
     if (QuartzRandRModesEqual(&reqMode, &pQuartzScreen->currentMode))
         return TRUE;
@@ -446,9 +450,16 @@ static Bool _QuartzRandRUpdateFakeModes (ScreenPtr pScreen) {
     QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen);
     QuartzModeInfo activeMode;
 
-    if (!QuartzRandRCopyCurrentModeInfo(pQuartzScreen->displayIDs[0], &activeMode)) {
-        ErrorF("Unable to determine current display mode.\n");
-        return FALSE;
+    if(pQuartzScreen->displayCount > 0) {
+        if(!QuartzRandRCopyCurrentModeInfo(pQuartzScreen->displayIDs[0], &activeMode)) {
+            ErrorF("Unable to determine current display mode.\n");
+            return FALSE;
+        }
+    } else {
+        memset(&activeMode, 0, sizeof(activeMode));
+        activeMode.width = 800;
+        activeMode.height = 600;
+        activeMode.refresh = 60;
     }
 
     if(pQuartzScreen->fullscreenMode.ref)
@@ -456,7 +467,7 @@ static Bool _QuartzRandRUpdateFakeModes (ScreenPtr pScreen) {
     if(pQuartzScreen->currentMode.ref)
         CFRelease(pQuartzScreen->currentMode.ref);
 
-    if (pQuartzScreen->displayCount > 1) {
+    if(pQuartzScreen->displayCount > 1) {
         activeMode.width = pScreen->width;
         activeMode.height = pScreen->height;
         if(XQuartzIsRootless)
@@ -479,7 +490,8 @@ static Bool _QuartzRandRUpdateFakeModes (ScreenPtr pScreen) {
     /* This extra retain is for currentMode's copy.
      * fullscreen and rootless share a retain.
      */
-    CFRetain(pQuartzScreen->currentMode.ref);
+    if(pQuartzScreen->currentMode.ref)
+        CFRetain(pQuartzScreen->currentMode.ref);
     
     DEBUG_LOG("rootlessMode: %d x %d\n", (int)pQuartzScreen->rootlessMode.width, (int)pQuartzScreen->rootlessMode.height);
     DEBUG_LOG("fullscreenMode: %d x %d\n", (int)pQuartzScreen->fullscreenMode.width, (int)pQuartzScreen->fullscreenMode.height);
diff --git a/hw/xquartz/xpr/xprScreen.c b/hw/xquartz/xpr/xprScreen.c
index d2968dc..98250e6 100644
--- a/hw/xquartz/xpr/xprScreen.c
+++ b/hw/xquartz/xpr/xprScreen.c
@@ -193,6 +193,7 @@ xprAddPseudoramiXScreens(int *x, int *y, int *width, int *height, ScreenPtr pScr
         *width = 800;
         *height = 600;
         PseudoramiXAddScreen(*x, *y, *width, *height);
+        QuartzCopyDisplayIDs(pScreen, 0, NULL);
         return;
     }
 
commit f25ca898c54cb88c7886005fc75a53762c42710b
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Thu May 19 14:39:22 2011 -0700

    XQuartz: Mark functions _X_NORETURN
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/hw/xquartz/darwin.c b/hw/xquartz/darwin.c
index e90c33e..fa8d4ce 100644
--- a/hw/xquartz/darwin.c
+++ b/hw/xquartz/darwin.c
@@ -772,8 +772,8 @@ void ddxGiveUp( void )
  *      made to restore all original setting of the displays. Also all devices
  *      are closed.
  */
-void AbortDDX( void )
-{
+_X_NORETURN
+void AbortDDX( void ) {
     ErrorF( "   AbortDDX\n" );
     OsAbort();
 }
diff --git a/hw/xquartz/mach-startup/stub.c b/hw/xquartz/mach-startup/stub.c
index 8319dd0..d8e4abd 100644
--- a/hw/xquartz/mach-startup/stub.c
+++ b/hw/xquartz/mach-startup/stub.c
@@ -164,6 +164,7 @@ static void send_fd_handoff(int connected_fd, int launchd_fd) {
     close(connected_fd);
 }
 
+__attribute__((__noreturn__))
 static void signal_handler(int sig) {
     if(x11app_pid)
         kill(x11app_pid, sig);
diff --git a/hw/xquartz/quartzStartup.c b/hw/xquartz/quartzStartup.c
index 00a9e48..25ef76e 100644
--- a/hw/xquartz/quartzStartup.c
+++ b/hw/xquartz/quartzStartup.c
@@ -56,6 +56,7 @@ struct arg {
     char **envp;
 };
 
+_X_NORETURN
 static void server_thread (void *arg) {
     struct arg args = *((struct arg *)arg);
     free(arg);
commit 7413886d650aef492ecbfdc4298c2d92d9af5f87
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Thu May 19 14:35:56 2011 -0700

    XQuartz: Silence clang warnings about shadow declarations
    
    X11Application.m:1272:26: warning: declaration shadows a local variable [-Wshadow,Semantic Issue]
                    xp_error e;
                             ^
    X11Application.m:1098:36: note: previous declaration is here
    - (void) sendX11NSEvent:(NSEvent *)e {
                                       ^
    1 warning generated.
    
    bundle-main.c:648:36: warning: declaration shadows a local variable [-Wshadow,Semantic Issue]
                        int max_files, i;
                                       ^
    bundle-main.c:594:9: note: previous declaration is here
        int i;
            ^
    1 warning generated.
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index 283132e..7c41cbc 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -1269,7 +1269,7 @@ static const char *untrusted_str(NSEvent *e) {
 #if defined(XPLUGIN_VERSION) && XPLUGIN_VERSION > 0
 /* Older libXplugin (Tiger/"Stock" Leopard) aren't thread safe, so we can't call xp_find_window from the Appkit thread */
                 xp_window_id wid = 0;
-                xp_error e;
+                xp_error err;
 
                 /* Sigh. Need to check that we're really over one of
                  * our windows. (We need to receive pointer events while
@@ -1277,9 +1277,9 @@ static const char *untrusted_str(NSEvent *e) {
                  * when another window is over us or we might show a tooltip)
                  */
 
-                e = xp_find_window(location.x, location.y, 0, &wid);
+                err = xp_find_window(location.x, location.y, 0, &wid);
 
-                if (e != XP_Success || (e == XP_Success && wid == 0))
+                if (err != XP_Success || (err == XP_Success && wid == 0))
 #endif
                 {
                     bgMouseLocation = location;
diff --git a/hw/xquartz/mach-startup/bundle-main.c b/hw/xquartz/mach-startup/bundle-main.c
index 0e62914..94c6068 100644
--- a/hw/xquartz/mach-startup/bundle-main.c
+++ b/hw/xquartz/mach-startup/bundle-main.c
@@ -645,7 +645,7 @@ int main(int argc, char **argv, char **envp) {
                 child2 = fork();
 
                 switch (child2) {
-                    int max_files, i;
+                    int max_files;
 
                     case -1:                            /* error */
                         FatalError("fork() failed: %s\n", strerror(errno));
commit 96ac4e61f4618332d95d1fd0e4799dd82844f90f
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Thu May 19 14:34:39 2011 -0700

    XQuartz: Update DEBUG_LOG to report to ASL
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/hw/xquartz/darwin.c b/hw/xquartz/darwin.c
index 50234f2..e90c33e 100644
--- a/hw/xquartz/darwin.c
+++ b/hw/xquartz/darwin.c
@@ -60,6 +60,7 @@
 #include <stdio.h>
 #include <fcntl.h>
 #include <unistd.h>
+#include <stdarg.h>
 
 #define HAS_UTSNAME 1
 #include <sys/utsname.h>
@@ -76,9 +77,31 @@
 #include "quartzKeyboard.h"
 #include "quartz.h"
 
-#ifdef ENABLE_DEBUG_LOG
-FILE *debug_log_fp = NULL;
-#endif
+aslclient aslc;
+
+void debug_asl (const char *file, const char *function, int line, const char *fmt, ...) {
+    va_list args;
+    aslmsg msg = asl_new(ASL_TYPE_MSG);
+
+    if(msg) {
+        char *_line;
+
+        asl_set(msg, "File", file);
+        asl_set(msg, "Function", function);
+        asprintf(&_line, "%d", line);
+        if(_line) {
+            asl_set(msg, "Line", _line);
+            free(_line);
+        }
+    }
+
+    va_start(args, fmt);
+    asl_vlog(aslc, msg, ASL_LEVEL_DEBUG, fmt, args);
+    va_end(args);
+
+    if(msg)
+        asl_free(msg);
+}
 
 /*
  * X server shared global variables
diff --git a/hw/xquartz/darwin.h b/hw/xquartz/darwin.h
index 507c6f7..659de43 100644
--- a/hw/xquartz/darwin.h
+++ b/hw/xquartz/darwin.h
@@ -32,7 +32,7 @@
 #include "inputstr.h"
 #include "scrnintstr.h"
 #include <X11/extensions/XKB.h>
-#include <assert.h>
+#include <asl.h>
 
 #include "darwinfb.h"
 
@@ -76,16 +76,9 @@ extern int              darwinMainScreenY;
 // bundle-main.c
 extern char *bundle_id_prefix;
 
-#define ENABLE_DEBUG_LOG 1
+extern void debug_asl (const char *file, const char *function, int line, const char *fmt, ...) _X_ATTRIBUTE_PRINTF(4,5);
 
-#ifdef ENABLE_DEBUG_LOG
-extern FILE *debug_log_fp;
-#define DEBUG_LOG_NAME "x11-debug.txt"
-#define DEBUG_LOG(msg, args...) if (debug_log_fp) fprintf(debug_log_fp, "%s:%s:%d " msg, __FILE__, __FUNCTION__, __LINE__, ##args ); fflush(debug_log_fp);
-#else
-#define DEBUG_LOG(msg, args...) 
-#endif
-
-#define TRACE() DEBUG_LOG("\n")
+#define DEBUG_LOG(msg, args...) debug_asl(__FILE__, __FUNCTION__, __LINE__, msg, ##args);
+#define TRACE() DEBUG_LOG("TRACE")
 
 #endif  /* _DARWIN_H */
diff --git a/hw/xquartz/mach-startup/bundle-main.c b/hw/xquartz/mach-startup/bundle-main.c
index 8e34376..0e62914 100644
--- a/hw/xquartz/mach-startup/bundle-main.c
+++ b/hw/xquartz/mach-startup/bundle-main.c
@@ -66,6 +66,8 @@
 /* From darwinEvents.c ... but don't want to pull in all the server cruft */
 void DarwinListenOnOpenFD(int fd);
 
+extern aslclient aslc;
+
 /* Ditto, from os/log.c */
 extern void ErrorF(const char *f, ...) _X_ATTRIBUTE_PRINTF(1,2);
 extern void FatalError(const char *f, ...) _X_ATTRIBUTE_PRINTF(1,2) _X_NORETURN;
@@ -485,7 +487,6 @@ static void ensure_path(const char *dir) {
 static void setup_console_redirect(const char *bundle_id) {
     char *asl_sender;
     char *asl_facility;
-    aslclient aslc;
 
     asprintf(&asl_sender, "%s.server", bundle_id);
     assert(asl_sender);
diff --git a/hw/xquartz/man/Xquartz.man b/hw/xquartz/man/Xquartz.man
index 19e8efb..aea56c9 100644
--- a/hw/xquartz/man/Xquartz.man
+++ b/hw/xquartz/man/Xquartz.man
@@ -111,7 +111,11 @@ In addition to this server log, XQuartz sends messages to syslogd(8) using
 asl(3).  These logs are sent to the __bundle_id_prefix__ facility, and you can
 watch these logs using the following syslog(1) command:
 .TP 8
-.B $ syslog -w -k Facility __bundle_id_prefix__
+.B $ syslog -w -k Facility eq __bundle_id_prefix__
+.PP
+or you can include extra information such as the file, line, and function where the message originated:
+.TP 8
+.B $ syslog -w -F '$(Time) $(Sender) <$(Level)> $(File):$(Line) $(Function) :: $(Message)' -k Facility eq __bundle_id_prefix__
 .PP
 By default, XQaurtz sets an ASL mask which prevents it from logging messages
 below the ASL_LEVEL_WARNING level (meaning almost all logging is done strictly
diff --git a/hw/xquartz/xpr/xprScreen.c b/hw/xquartz/xpr/xprScreen.c
index f6a7129..d2968dc 100644
--- a/hw/xquartz/xpr/xprScreen.c
+++ b/hw/xquartz/xpr/xprScreen.c
@@ -253,7 +253,7 @@ xprDisplayInit(void)
 {
     CGDisplayCount displayCount;
 
-    DEBUG_LOG("");
+    TRACE();
 
     CGGetActiveDisplayList(0, NULL, &displayCount);
 
commit 384eb45b944a4386eae74a5503423c13b5f2a659
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Sat May 14 18:33:57 2011 -0700

    XQuartz: RandR: Avoid over-releasing if we are unable to determine the current display mode.
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/hw/xquartz/quartzRandR.c b/hw/xquartz/quartzRandR.c
index 05641a6..d452b02 100644
--- a/hw/xquartz/quartzRandR.c
+++ b/hw/xquartz/quartzRandR.c
@@ -444,26 +444,29 @@ static Bool QuartzRandRSetConfig (ScreenPtr           pScreen,
 
 static Bool _QuartzRandRUpdateFakeModes (ScreenPtr pScreen) {
     QuartzScreenPtr pQuartzScreen = QUARTZ_PRIV(pScreen);
+    QuartzModeInfo activeMode;
+
+    if (!QuartzRandRCopyCurrentModeInfo(pQuartzScreen->displayIDs[0], &activeMode)) {
+        ErrorF("Unable to determine current display mode.\n");
+        return FALSE;
+    }
 
     if(pQuartzScreen->fullscreenMode.ref)
         CFRelease(pQuartzScreen->fullscreenMode.ref);
     if(pQuartzScreen->currentMode.ref)
         CFRelease(pQuartzScreen->currentMode.ref);
-        
-    if (!QuartzRandRCopyCurrentModeInfo(pQuartzScreen->displayIDs[0],
-                                        &pQuartzScreen->fullscreenMode))
-        return FALSE;
 
     if (pQuartzScreen->displayCount > 1) {
-        pQuartzScreen->fullscreenMode.width = pScreen->width;
-        pQuartzScreen->fullscreenMode.height = pScreen->height;
+        activeMode.width = pScreen->width;
+        activeMode.height = pScreen->height;
         if(XQuartzIsRootless)
-            pQuartzScreen->fullscreenMode.height += aquaMenuBarHeight;
+            activeMode.height += aquaMenuBarHeight;
     }
 
+    pQuartzScreen->fullscreenMode = activeMode; 
     pQuartzScreen->fullscreenMode.refresh = FAKE_REFRESH_FULLSCREEN;
 
-    pQuartzScreen->rootlessMode = pQuartzScreen->fullscreenMode;
+    pQuartzScreen->rootlessMode = activeMode;
     pQuartzScreen->rootlessMode.refresh = FAKE_REFRESH_ROOTLESS;
     pQuartzScreen->rootlessMode.height -= aquaMenuBarHeight;
 
commit 25191648b8db87735a99243697f73036255c1eb6
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Sat May 14 16:11:32 2011 -0700

    XQuartz: Don't call mieqEnqueue during server shutdown
    
    Found-by: GuardMalloc
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/dix/main.c b/dix/main.c
index 31e2d48..bc958b8 100644
--- a/dix/main.c
+++ b/dix/main.c
@@ -121,9 +121,9 @@ extern void Dispatch(void);
 #ifdef XQUARTZ
 #include <pthread.h>
 
-BOOL serverInitComplete = FALSE;
-pthread_mutex_t serverInitCompleteMutex = PTHREAD_MUTEX_INITIALIZER;
-pthread_cond_t serverInitCompleteCond = PTHREAD_COND_INITIALIZER;
+BOOL serverRunning = FALSE;
+pthread_mutex_t serverRunningMutex = PTHREAD_MUTEX_INITIALIZER;
+pthread_cond_t serverRunningCond = PTHREAD_COND_INITIALIZER;
 
 int dix_main(int argc, char *argv[], char *envp[]);
 
@@ -277,18 +277,25 @@ int main(int argc, char *argv[], char *envp[])
 	}
 
 #ifdef XQUARTZ
-    /* Let the other threads know the server is done with its init */
-    pthread_mutex_lock(&serverInitCompleteMutex);
-    serverInitComplete = TRUE;
-    pthread_cond_broadcast(&serverInitCompleteCond);
-    pthread_mutex_unlock(&serverInitCompleteMutex);
+	/* Let the other threads know the server is done with its init */
+	pthread_mutex_lock(&serverRunningMutex);
+	serverRunning = TRUE;
+	pthread_cond_broadcast(&serverRunningCond);
+	pthread_mutex_unlock(&serverRunningMutex);
 #endif
         
 	NotifyParentProcess();
 
 	Dispatch();
 
-        UndisplayDevices();
+#ifdef XQUARTZ
+	/* Let the other threads know the server is no longer running */
+	pthread_mutex_lock(&serverRunningMutex);
+	serverRunning = FALSE;
+	pthread_mutex_unlock(&serverRunningMutex);
+#endif
+
+	UndisplayDevices();
 
 	/* Now free up whatever must be freed */
 	if (screenIsSaved == SCREEN_SAVER_ON)
diff --git a/hw/xquartz/pbproxy/app-main.m b/hw/xquartz/pbproxy/app-main.m
index 9055bad..a8c3a60 100644
--- a/hw/xquartz/pbproxy/app-main.m
+++ b/hw/xquartz/pbproxy/app-main.m
@@ -39,9 +39,9 @@ CFStringRef app_prefs_domain_cfstr;
 
 /* Stubs */
 char *display = NULL;
-BOOL serverInitComplete = YES;
-pthread_mutex_t serverInitCompleteMutex = PTHREAD_MUTEX_INITIALIZER;
-pthread_cond_t serverInitCompleteCond = PTHREAD_COND_INITIALIZER;
+BOOL serverRunning = YES;
+pthread_mutex_t serverRunningMutex = PTHREAD_MUTEX_INITIALIZER;
+pthread_cond_t serverRunningCond = PTHREAD_COND_INITIALIZER;
 
 static void signal_handler (int sig) {
     switch(sig) {
diff --git a/hw/xquartz/pbproxy/main.m b/hw/xquartz/pbproxy/main.m
index dbdb6d0..29ce83b 100644
--- a/hw/xquartz/pbproxy/main.m
+++ b/hw/xquartz/pbproxy/main.m
@@ -47,17 +47,17 @@ BOOL xpbproxy_is_standalone = NO;
 
 x_selection *_selection_object;
 
-extern BOOL serverInitComplete;
-extern pthread_mutex_t serverInitCompleteMutex;
-extern pthread_cond_t serverInitCompleteCond;
+extern BOOL serverRunning;
+extern pthread_mutex_t serverRunningMutex;
+extern pthread_cond_t serverRunningCond;
 
 static inline void wait_for_server_init(void) {
     /* If the server hasn't finished initializing, wait for it... */
-    if(!serverInitComplete) {
-        pthread_mutex_lock(&serverInitCompleteMutex);
-        while(!serverInitComplete)
-            pthread_cond_wait(&serverInitCompleteCond, &serverInitCompleteMutex);
-        pthread_mutex_unlock(&serverInitCompleteMutex);
+    if(!serverRunning) {
+        pthread_mutex_lock(&serverRunningMutex);
+        while(!serverRunning)
+            pthread_cond_wait(&serverRunningCond, &serverRunningMutex);
+        pthread_mutex_unlock(&serverRunningMutex);
     }
 }
 
diff --git a/mi/mieq.c b/mi/mieq.c
index 236ffcc..031b11a 100644
--- a/mi/mieq.c
+++ b/mi/mieq.c
@@ -83,17 +83,17 @@ static EventQueueRec miEventQueue;
 #include  <pthread.h>
 static pthread_mutex_t miEventQueueMutex = PTHREAD_MUTEX_INITIALIZER;
 
-extern BOOL serverInitComplete;
-extern pthread_mutex_t serverInitCompleteMutex;
-extern pthread_cond_t serverInitCompleteCond;
+extern BOOL serverRunning;
+extern pthread_mutex_t serverRunningMutex;
+extern pthread_cond_t serverRunningCond;
 
 static inline void wait_for_server_init(void) {
     /* If the server hasn't finished initializing, wait for it... */
-    if(!serverInitComplete) {
-        pthread_mutex_lock(&serverInitCompleteMutex);
-        while(!serverInitComplete)
-            pthread_cond_wait(&serverInitCompleteCond, &serverInitCompleteMutex);
-        pthread_mutex_unlock(&serverInitCompleteMutex);
+    if(!serverRunning) {
+        pthread_mutex_lock(&serverRunningMutex);
+        while(!serverRunning)
+            pthread_cond_wait(&serverRunningCond, &serverRunningMutex);
+        pthread_mutex_unlock(&serverRunningMutex);
     }
 }
 #endif
commit fd5f630bc41de73be3b1d26bf9ce3e9ef1badc3b
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Sat May 14 14:09:45 2011 -0700

    XQuartz: Fix an array-index-out-of-bounds crasher
    
    Found-by: GuardMalloc
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/hw/xquartz/console_redirect.c b/hw/xquartz/console_redirect.c
index cdd2b89..70a819e 100644
--- a/hw/xquartz/console_redirect.c
+++ b/hw/xquartz/console_redirect.c
@@ -116,7 +116,7 @@ static inline int _read_redirect(int fd, int flush) {
                 *s='\0';
                 asl_log(aslr->asl, aslr->msg, aslr->level, "%s", p);
             } else if(aslr->buf != p) {
-                memmove(aslr->buf, p, BUF_SIZE);
+                memmove(aslr->buf, p, BUF_SIZE - (p - aslr->buf));
                 aslr->w = aslr->buf + (s - p);
                 break;
             } else if(nbytes == BUF_SIZE - 1) {
commit 0e7f61d72c4a929319e57c9b5b777e9413c23051
Author: Gaetan Nadon <memsize at videotron.ca>
Date:   Sat May 14 13:30:20 2011 -0400

    doc: use devbook.am for developers documentation
    
    Relocate the docs under the doc subdir.
    Remove redundant xml subdir.
    The xmlrules set of makefiles are no longer used.
    
    Reviewed-by Jeremy Huddleston <jeremyhu at apple.com>
    Signed-off-by: Gaetan Nadon <memsize at videotron.ca>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/configure.ac b/configure.ac
index 9d0854f..655c0e4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2153,7 +2153,6 @@ dbe/Makefile
 dix/Makefile
 doc/Makefile
 doc/dtrace/Makefile
-doc/xml/Makefile
 man/Makefile
 fb/Makefile
 record/Makefile
diff --git a/doc/.gitignore b/doc/.gitignore
new file mode 100644
index 0000000..2ee2ac5
--- /dev/null
+++ b/doc/.gitignore
@@ -0,0 +1,4 @@
+*.html
+*.pdf
+*.ps
+*.txt
diff --git a/doc/Makefile.am b/doc/Makefile.am
index e8634fd..e6974fe 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -1,3 +1,15 @@
-SUBDIRS = dtrace xml
+SUBDIRS = dtrace
 
-dist_noinst_DATA = smartsched
+if ENABLE_DEVEL_DOCS
+if HAVE_XMLTO
+
+# Main DocBook/XML files (DOCTYPE book)
+docbook = Xserver-spec.xml Xinput.xml
+
+# Generate DocBook/XML output formats with or without stylesheets
+include $(top_srcdir)/devbook.am
+
+endif HAVE_XMLTO
+endif ENABLE_DEVEL_DOCS
+
+EXTRA_DIST = smartsched
diff --git a/doc/Xinput.xml b/doc/Xinput.xml
new file mode 100644
index 0000000..1ae7afe
--- /dev/null
+++ b/doc/Xinput.xml
@@ -0,0 +1,1209 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
+                   "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd">
+
+
+<!-- lifted from troff+ms+XMan by doclifter -->
+<book id="porting">
+
+<bookinfo>
+   <title>X11 Input Extension Porting Document</title>
+   <releaseinfo>X Version 11, Release 6.7</releaseinfo>
+   <authorgroup>
+      <author>
+         <firstname>George</firstname><surname>Sachs</surname>
+         <affiliation><orgname>Hewlett-Packard</orgname></affiliation>
+      </author>
+   </authorgroup>
+   <corpname>X Consortium Standard</corpname>
+   <copyright><year>1989</year><holder>Hewlett-Packard Company</holder></copyright>
+   <copyright><year>1990</year><holder>Hewlett-Packard Company</holder></copyright>
+   <copyright><year>1991</year><holder>Hewlett-Packard Company</holder></copyright>
+
+   <copyright><year>1989</year><holder>X Consortium</holder></copyright>
+   <copyright><year>1990</year><holder>X Consortium</holder></copyright>
+   <copyright><year>1991</year><holder>X Consortium</holder></copyright>
+   <affiliation><orgname>X Consortium</orgname></affiliation>
+   <productnumber>X Version 11, Release 6.7</productnumber>
+
+<legalnotice>
+
+
+<para>
+Permission to use, copy, modify, and distribute this documentation for any purpose and without fee is
+hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
+Hewlett-Packard makes no representations about the suitability for any purpose of the information in this
+document. It is provided "as is" without express or implied warranty. This document is only a draft stan-
+dard of the X Consortium and is therefore subject to change.
+</para>
+
+<para>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:</para>
+
+<para>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:</para>
+
+<para>The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.</para>
+
+<para>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 X CONSORTIUM 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.</para>
+
+<para>Except as contained in this notice, the name of the X Consortium 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 X Consortium.</para>
+
+<para>X Window System is a trademark of The Open Group.</para>
+</legalnotice>
+
+</bookinfo>
+
+<chapter id="x11_input_extension_porting_document">
+<title>X11 Input Extension Porting Document</title>
+
+<para>
+This document is intended to aid the process of integrating the 
+X11 Input Extension into an X server.
+</para>
+<para>
+<!-- .LP -->
+Most of the functionality provided by the input extension is 
+device- and implementation-independent, and should require no changes.  
+The functionality is implemented by
+routines that typically reside in the server source tree directory 
+extensions/server/xinput.
+This extension includes functions to enable and disable input extension devices,
+select input, grab and focus those device, query and change key 
+and button mappings, and others.  The only input extension requirements 
+for the device-dependent part of X are that the input devices be 
+correctly initialized and input events from those devices be correctly
+generated.  Device-dependent X is responsible for reading input data from 
+the input device hardware and if necessary, reformatting it into X events.
+</para>
+<para>
+<!-- .LP -->
+The process of initializing input extension devices is similar to that used 
+for the core devices, and is described in the following sections.  When
+multiple input devices are attached to X server, the choice of which devices
+to initially use as the core X pointer and keyboard is left 
+implementation-dependent.  It is also up to each implementation to decide
+whether all input devices will be opened by the server during its 
+initialization and kept open for the life of the server.  The alternative is
+to open only the X keyboard and X pointer during server initialization, and
+open other input devices only when requested by a client to do so.  Either
+type of implementation is supported by the input extension.
+</para>
+<para>
+<!-- .LP -->
+Input extension events generated by the X server use the same 32-byte xEvent
+wire event as do core input events.  However, additional information must be
+sent for input extension devices, requiring that multiple xEvents be generated
+each time data is received from an input extension device.  These xEvents are
+combined into a single client XEvent by the input extension library.  A later
+section of this document describes the format and generation of input extension
+events.
+</para>
+<sect1 id="Initializing_Extension_Devices">
+<title>Initializing Extension Devices</title>
+<para>
+<!-- .LP -->
+Extension input devices are initialized in the same manner as the core 
+X input devices.  Device-Independent X provides functions that can be 
+called from DDX to initialize these devices.  Which functions are called
+and when will vary by implementation, and will depend on whether the 
+implementation opens all the input devices available to X when X is initialized,
+or waits until a client requests that a device be opened.
+In the simplest case, DDX will open all input devices as part of its
+initialization, when the InitInput routine is called.
+</para>
+<sect2 id="Summary_of_Calling_Sequence">
+<title>Summary of Calling Sequence</title>
+<para>
+<!-- .LP -->
+<literallayout class="monospaced">
+Device-Independent X       |  Device-Dependent X
+--------------------       |  -------------------             
+                           |                                        
+InitInput -------------->  |  - do device-specific initialization
+                           |                                        
+                           |  - call AddInputDevice  (deviceProc,AutoStart)
+AddInputDevice             |   
+  - creates DeviceIntRec   |
+  - records deviceProc     |
+  - adds new device to     | 
+    list of off_devices.   |
+sets dev->startup=AutoStart|           
+                           |  - call one of:                       
+                           |    - RegisterPointerDevice (X pointer)
+                           |      - processInputProc = ProcessPointerEvents
+                           |    - RegisterKeyboardDevice (X keyboard)
+                           |      - processInputProc = ProcessKeyboardEvents
+                           |    - RegisterOtherDevice  (extension device)
+                           |      - processInputProc = ProcessOtherEvents
+                           |                                        
+                           |                                        
+InitAndStartDevices -----> |  - calls deviceProc with parameters
+                           |    (DEVICE_INIT, AutoStart)
+sets dev->inited = return  |
+  value from deviceProc    |    
+                           |                                        
+                           |  - in deviceProc, do one of:                       
+                           |    - call InitPointerDeviceStruct (X pointer)
+                           |    - call InitKeyboardDeviceStruct (X keybd)
+                           |    - init extension device by calling some of:
+                           |      - InitKeyClassDeviceStruct
+                           |      - InitButtonClassDeviceStruct
+                           |      - InitValuatorClassDeviceStruct
+                           |      - InitValuatorAxisStruct
+                           |      - InitFocusClassDeviceStruct
+                           |      - InitProximityClassDeviceStruct
+                           |      - InitKbdFeedbackClassDeviceStruct
+                           |      - InitPtrFeedbackClassDeviceStruct
+                           |      - InitLedFeedbackClassDeviceStruct
+                           |      - InitStringFeedbackClassDeviceStruct
+                           |      - InitIntegerFeedbackClassDeviceStruct
+                           |      - InitBellFeedbackClassDeviceStruct
+                           |    - init device name and type by:
+                           |      - calling MakeAtom with one of the 
+                           |        predefined names
+                           |      - calling AssignTypeAndName
+                           |                                        
+                           |                                        
+for each device added      |                                        
+    by AddInputDevice,     |                                        
+    InitAndStartDevices    |                                        
+    calls EnableDevice if  |  - EnableDevice calls deviceProc with 
+    dev->startup &         |    (DEVICE_ON, AutoStart)
+    dev->inited            |  
+                           |                                        
+If deviceProc returns      |  - core devices are now enabled, extension
+    Success, EnableDevice  |    devices are now available to be accessed
+    move the device from   |    through the input extension protocol
+    inputInfo.off_devices  |    requests.                           
+    to inputInfo.devices   |                                        
+</literallayout>
+</para>
+</sect2>
+<sect2 id="Initialization_Called_From_InitInput">
+<title>Initialization Called From InitInput</title>
+<para>
+<!-- .LP -->
+InitInput is the first DDX input entry point called during X server startup.
+This routine is responsible for
+device- and implementation- specific initialization, and for calling
+AddInputDevice to create and initialize the DeviceIntRec structure for each
+input device.  AddInputDevice is passed the address of a procedure to be called
+by the DIX routine InitAndStartDevices when input devices are enabled.
+This procedure is expected to perform X initialization for the input device.
+</para>
+<para>
+<!-- .LP -->
+If the device is to be used as the X pointer, DDX should then call
+RegisterPointerDevice, passing the DeviceIntRec pointer,
+to initialize the device as the X pointer.
+</para>
+<para>
+<!-- .LP -->
+If the device is to be used as the X keyboard, DDX should instead call
+RegisterKeyboardDevice to initialize the device as the X keyboard.
+</para>
+<para>
+<!-- .LP -->
+If the device is to be used as an extension device, DDX should instead
+call RegisterOtherDevice, passing the DeviceIntPtr returned by
+AddInputDevice.
+</para>
+<para>
+<!-- .LP -->
+A sample InitInput implementation is shown below.
+</para>
+<para>
+<!-- .LP -->
+<literallayout class="monospaced">
+InitInput(argc,argv)
+    {
+    int i, numdevs, ReadInput();
+    DeviceIntPtr dev;
+    LocalDevice localdevs[LOCAL_MAX_DEVS];
+    DeviceProc kbdproc, ptrproc, extproc;
+
+    /**************************************************************
+     * Open the appropriate input devices, determine which are 
+     * available, and choose an X pointer and X keyboard device
+     * in some implementation-dependent manner.
+     ***************************************************************/
+
+    open_input_devices (&numdevs, localdevs);
+
+    /**************************************************************
+     * Register a WakeupHandler to handle input when it is generated.
+     ***************************************************************/
+
+    RegisterBlockAndWakeupHandlers (NoopDDA, ReadInput, NULL);
+
+    /**************************************************************
+     * Register the input devices with DIX.
+     ***************************************************************/
+
+    for (i=0; i<numdevs; i++)
+        {
+        if (localdevs[i].use == IsXKeyboard)
+            {
+            dev = AddInputDevice (kbdproc, TRUE);
+            RegisterKeyboardDevice (dev);
+            }
+        else if (localdevs[i].use == IsXPointer)
+            {
+            dev = AddInputDevice (ptrproc, TRUE);
+            RegisterPointerDevice (dev);
+            }
+        else 
+            {
+            dev = AddInputDevice (extproc, FALSE);
+            RegisterOtherDevice (dev);
+            }
+        if (dev == NULL)
+            FatalError ("Too many input devices.");
+        dev->devicePrivate = (pointer) &localdevs[i];
+        }
+</literallayout>
+</para>
+</sect2>
+<sect2 id="Initialization_Called_From_InitAndStartDevices">
+<title>Initialization Called From InitAndStartDevices</title>
+<para>
+<!-- .LP -->
+After InitInput has returned,
+InitAndStartDevices is the DIX routine that is called to enable input devices. 
+It calls the device control routine that was passed to AddInputDevice,
+with a mode value of DEVICE_INIT.  The action taken by the device control
+routine depends on how the device is to be used.  If the device is to be
+the X pointer, the device control routine should call
+InitPointerDeviceStruct to initialize it.  If the device is to be the
+X keyboard, the device control routine should call
+InitKeyboardDeviceStruct.  Since input extension devices may support various
+combinations of keys, buttons, valuators, and feedbacks,
+each class of input that it supports must be initialized.
+Entry points are defined by DIX to initialize each of the supported classes of
+input, and are described in the following sections.
+</para>
+<para>
+<!-- .LP -->
+A sample device control routine called from InitAndStartDevices is 
+shown below.
+</para>
+<para>
+<!-- .LP -->
+<literallayout class="monospaced">
+Bool extproc (dev, mode)
+    DeviceIntPtr dev;
+    int mode;
+    {
+    LocalDevice *localdev = (LocalDevice *) dev->devicePrivate;
+
+    switch (mode)
+        {
+        case DEVICE_INIT:
+            if (strcmp(localdev->name, XI_TABLET) == 0)
+                {
+                /****************************************************
+                 * This device reports proximity, has buttons,
+                 * reports two axes of motion, and can be focused.
+                 * It also supports the same feedbacks as the X pointer
+                 * (acceleration and threshold can be set).
+                 ****************************************************/
+
+                InitButtonClassDeviceStruct (dev, button_count, button_map);
+                InitValuatorClassDeviceStruct (dev, localdev->n_axes,);
+                    motionproc, MOTION_BUF_SIZE, Absolute);
+                for (i=0; i<localdev->n_axes; i++)
+                    InitValuatorAxisStruct (dev, i, min_val, max_val, 
+                        resolution);
+                InitFocusClassDeviceStruct (dev);
+                InitProximityClassDeviceStruct (dev);
+                InitPtrFeedbackClassDeviceStruct (dev, p_controlproc);
+                }
+            else if (strcmp(localdev->name, XI_BUTTONBOX) == 0)
+                {
+                /****************************************************
+                 * This device has keys and LEDs, and can be focused.
+                 ****************************************************/
+
+                InitKeyClassDeviceStruct (dev, syms, modmap);
+                InitFocusClassDeviceStruct (dev);
+                InitLedFeedbackClassDeviceStruct (dev, ledcontrol);
+                }
+            else if (strcmp(localdev->name, XI_KNOBBOX) == 0)
+                {
+                /****************************************************
+                 * This device reports motion.
+                 * It can be focused.
+                 ****************************************************/
+
+                InitValuatorClassDeviceStruct (dev, localdev->n_axes,);
+                    motionproc, MOTION_BUF_SIZE, Absolute);
+                for (i=0; i<localdev->n_axes; i++)
+                    InitValuatorAxisStruct (dev, i, min_val, max_val, 
+                        resolution);
+                InitFocusClassDeviceStruct (dev);
+                }
+            localdev->atom = 
+                MakeAtom(localdev->name, strlen(localdev->name), FALSE);
+            AssignTypeAndName (dev, localdev->atom, localdev->name);
+            break;
+        case DEVICE_ON:
+            AddEnabledDevice (localdev->file_ds);
+            dev->on = TRUE;
+            break;
+        case DEVICE_OFF:
+            dev->on = FALSE;
+            RemoveEnabledDevice (localdev->file_ds);
+            break;
+        case DEVICE_CLOSE:
+            break;
+        }
+    }
+</literallayout>
+</para>
+<para>
+<!-- .LP -->
+The device control routine is called with a mode value of DEVICE_ON
+by the DIX routine EnableDevice, which is called from InitAndStartDevices.  
+When called with this mode, it should call AddEnabledDevice to cause the 
+server to begin checking for available input from this device.
+</para>
+<para>
+<!-- .LP -->
+>From InitAndStartDevices, EnableDevice is called for all devices that have
+the "inited" and "startup" fields in the DeviceIntRec set to TRUE.  The
+"inited" field is set by InitAndStartDevices to the value returned by
+the deviceproc when called with a mode value of DEVICE_INIT.  The "startup"
+field is set by AddInputDevice to value of the second parameter (autoStart).
+</para>
+<para>
+<!-- .LP -->
+When the server is first initialized, it should only be checking for input
+from the core X keyboard and pointer.  One way to accomplish this is to
+call AddInputDevice for the core X keyboard and pointer with an
+autoStart value equal to TRUE, while calling AddInputDevice for 
+input extension devices with an autoStart value equal to FALSE.  If this is 
+done, EnableDevice will skip all input extension devices during server
+initialization.  In this case,
+the OpenInputDevice routine should set the "startup" field to TRUE
+when called for input extension devices.  This will cause ProcXOpenInputDevice
+to call EnableDevice for those devices when a client first does an
+XOpenDevice request.
+</para>
+</sect2>
+<sect2 id="DIX_Input_Class_Initialization_Routines">
+<title>DIX Input Class Initialization Routines</title>
+<para>
+<!-- .LP -->
+DIX routines are defined to initialize each of the defined input classes.
+The defined classes are:
+<!-- .RS -->
+<!-- .in +5n -->
+</para>
+<itemizedlist>
+  <listitem>
+    <para>
+KeyClass - the device has keys.
+    </para>
+  </listitem>
+  <listitem>
+    <para>
+ButtonClass - the device has buttons.
+    </para>
+  </listitem>
+  <listitem>
+    <para>
+ValuatorClass - the device reports motion data or positional data.
+    </para>
+  </listitem>
+  <listitem>
+    <para>
+Proximitylass - the device reports proximity information.
+    </para>
+  </listitem>
+  <listitem>
+    <para>
+FocusClass - the device can be focused.
+    </para>
+  </listitem>
+  <listitem>
+    <para>
+FeedbackClass - the device supports some kind of feedback
+<!-- .in -5n -->
+<!-- .RE -->
+    </para>
+  </listitem>
+</itemizedlist>
+<para>
+<!-- .LP -->
+DIX routines are provided to initialize the X pointer and keyboard, as in
+previous releases of X.  During X initialization, InitPointerDeviceStruct 
+is called to initialize the X pointer, and InitKeyboardDeviceStruct is
+called to initialize the X keyboard.  There is no
+corresponding routine for extension input devices, since they do not all
+support the same classes of input.  Instead, DDX is responsible for the 
+initialization of the input classes supported by extension devices.  
+A description of the routines provided by DIX to perform that initialization
+follows.
+</para>
+<sect3 id="InitKeyClassDeviceStruct">
+<title>InitKeyClassDeviceStruct</title>
+<para>
+<!-- .LP -->
+This function is provided to allocate and initialize a KeyClassRec, and 
+should be called for extension devices that have keys.  It is passed a pointer
+to the device, and pointers to arrays of keysyms and modifiers reported by
+the device.  It returns FALSE if the KeyClassRec could not be allocated,
+or if the maps for the keysyms and and modifiers could not be allocated.
+Its parameters are:
+</para>
+<para>
+<!-- .LP -->
+<literallayout class="monospaced">
+Bool
+InitKeyClassDeviceStruct(dev, pKeySyms, pModifiers)
+    DeviceIntPtr dev;
+    KeySymsPtr pKeySyms;
+    CARD8 pModifiers[];
+</literallayout>
+</para>
+<para>
+<!-- .LP -->
+The DIX entry point InitKeyboardDeviceStruct calls this routine for the
+core X keyboard.  It must be called explicitly for extension devices
+that have keys.
+</para>
+</sect3>
+<sect3 id="InitButtonClassDeviceStruct">
+<title>InitButtonClassDeviceStruct</title>
+<para>
+<!-- .LP -->
+This function is provided to allocate and initialize a ButtonClassRec, and 
+should be called for extension devices that have buttons.  It is passed a 
+pointer to the device, the number of buttons supported, and a map of the 
+reported button codes.  It returns FALSE if the ButtonClassRec could not be 
+allocated.  Its parameters are:
+</para>
+<para>
+<!-- .LP -->
+<literallayout class="monospaced">
+Bool
+InitButtonClassDeviceStruct(dev, numButtons, map)
+    register DeviceIntPtr dev;
+    int numButtons;
+    CARD8 *map;
+</literallayout>
+</para>
+<para>
+<!-- .LP -->
+The DIX entry point InitPointerDeviceStruct calls this routine for the
+core X pointer.  It must be called explicitly for extension devices that
+have buttons.
+</para>
+</sect3>
+<sect3 id="InitValuatorClassDeviceStruct">
+<title>InitValuatorClassDeviceStruct</title>
+<para>
+<!-- .LP -->
+This function is provided to allocate and initialize a ValuatorClassRec, and 
+should be called for extension devices that have valuators.  It is passed the
+number of axes of motion reported by the device, the address of the motion
+history procedure for the device, the size of the motion history buffer,
+and the mode (Absolute or Relative) of the device.  It returns FALSE if 
+the ValuatorClassRec could not be allocated.  Its parameters are:
+</para>
+<para>
+<!-- .LP -->
+<literallayout class="monospaced">
+Bool
+InitValuatorClassDeviceStruct(dev, numAxes, motionProc, numMotionEvents, mode)
+    DeviceIntPtr dev;
+    int (*motionProc)();
+    int numAxes;
+    int numMotionEvents;
+    int mode;
+</literallayout>
+</para>
+<para>
+<!-- .LP -->
+The DIX entry point InitPointerDeviceStruct calls this routine for the
+core X pointer.  It must be called explicitly for extension devices that
+report motion.
+</para>
+</sect3>
+<sect3 id="InitValuatorAxisStruct">
+<title>InitValuatorAxisStruct</title>
+<para>
+<!-- .LP -->
+This function is provided to initialize an XAxisInfoRec, and 
+should be called for core and extension devices that have valuators.  
+The space for the XAxisInfoRec is allocated by 
+the InitValuatorClassDeviceStruct function, but is not initialized.
+</para>
+<para>
+<!-- .LP -->
+InitValuatorAxisStruct should be called once for each axis of motion 
+reported by the device.  Each
+invocation should be passed the axis number (starting with 0), the
+minimum value for that axis, the maximum value for that axis, and the
+resolution of the device in counts per meter.  If the device reports
+relative motion, 0 should be reported as the minimum and maximum values.
+InitValuatorAxisStruct has the following parameters:
+<literallayout class="monospaced">
+InitValuatorAxisStruct(dev, axnum, minval, maxval, resolution)
+    DeviceIntPtr dev;
+    int axnum;
+    int minval;
+    int maxval;
+    int resolution;
+</literallayout>
+</para>
+<para>
+<!-- .LP -->
+This routine is not called by InitPointerDeviceStruct for the
+core X pointer.  It must be called explicitly for core and extension devices 
+that report motion.
+</para>
+</sect3>
+<sect3 id="InitFocusClassDeviceStruct">
+<title>InitFocusClassDeviceStruct</title>
+<para>
+<!-- .LP -->
+This function is provided to allocate and initialize a FocusClassRec, and 
+should be called for extension devices that can be focused.  It is passed a
+pointer to the device, and returns FALSE if the allocation fails.
+It has the following parameter:
+<literallayout class="monospaced">
+Bool
+InitFocusClassDeviceStruct(dev)
+    DeviceIntPtr dev;
+</literallayout>
+</para>
+<para>
+<!-- .LP -->
+The DIX entry point InitKeyboardDeviceStruct calls this routine for the
+core X keyboard.  It must be called explicitly for extension devices
+that can be focused.  Whether or not a particular device can be focused
+is left implementation-dependent.
+</para>
+</sect3>
+<sect3 id="InitProximityClassDeviceStruct">
+<title>InitProximityClassDeviceStruct</title>
+<para>
+<!-- .LP -->
+This function is provided to allocate and initialize a ProximityClassRec, and 
+should be called for extension absolute pointing devices that report proximity.
+It is passed a pointer to the device, and returns FALSE if the allocation fails.
+It has the following parameter:
+<literallayout class="monospaced">
+Bool
+InitProximityClassDeviceStruct(dev)
+    DeviceIntPtr dev;
+</literallayout>
+</para>
+</sect3>
+<sect3 id="Initializing_Feedbacks">
+<title>Initializing Feedbacks</title>
+<para>
+<!-- .LP -->
+</para>
+<sect4 id="InitKbdFeedbackClassDeviceStruct">
+<title>InitKbdFeedbackClassDeviceStruct</title>
+<para>
+<!-- .LP -->
+This function is provided to allocate and initialize a KbdFeedbackClassRec, and 
+may be called for extension devices that support some or all of the 
+feedbacks that the core keyboard supports.  It is passed a
+pointer to the device, a pointer to the procedure that sounds the bell,
+and a pointer to the device control procedure.
+It returns FALSE if the allocation fails, and has the following parameters:
+<literallayout class="monospaced">
+Bool
+InitKbdFeedbackClassDeviceStruct(dev, bellProc, controlProc)
+    DeviceIntPtr dev;
+    void (*bellProc)();
+    void (*controlProc)();
+</literallayout>
+The DIX entry point InitKeyboardDeviceStruct calls this routine for the
+core X keyboard.  It must be called explicitly for extension devices
+that have the same feedbacks as a keyboard.  Some feedbacks, such as LEDs and
+bell, can be supported either with a KbdFeedbackClass or with BellFeedbackClass
+and LedFeedbackClass feedbacks.
+</para>
+</sect4>
+<sect4 id="InitPtrFeedbackClassDeviceStruct">
+<title>InitPtrFeedbackClassDeviceStruct</title>
+<para>
+<!-- .LP -->
+This function is provided to allocate and initialize a PtrFeedbackClassRec, and 
+should be called for extension devices that allow the setting of acceleration
+and threshold.  It is passed a pointer to the device,
+and a pointer to the device control procedure.
+It returns FALSE if the allocation fails, and has the following parameters:
+<literallayout class="monospaced">
+Bool
+InitPtrFeedbackClassDeviceStruct(dev, controlProc)
+    DeviceIntPtr dev;
+    void (*controlProc)();
+</literallayout>
+</para>
+<para>
+<!-- .LP -->
+The DIX entry point InitPointerDeviceStruct calls this routine for the
+core X pointer.  It must be called explicitly for extension devices
+that support the setting of acceleration and threshold.
+</para>
+</sect4>
+<sect4 id="InitLedFeedbackClassDeviceStruct">
+<title>InitLedFeedbackClassDeviceStruct</title>
+<para>
+<!-- .LP -->
+This function is provided to allocate and initialize a LedFeedbackClassRec, and 
+should be called for extension devices that have LEDs.
+It is passed a pointer to the device,
+and a pointer to the device control procedure.
+It returns FALSE if the allocation fails, and has the following parameters:
+<literallayout class="monospaced">
+Bool
+InitLedFeedbackClassDeviceStruct(dev, controlProc)
+    DeviceIntPtr dev;
+    void (*controlProc)();
+</literallayout>
+</para>
+<para>
+<!-- .LP -->
+Up to 32 LEDs per feedback can be supported, and a device may have 
+multiple feedbacks of the same type.
+</para>
+</sect4>
+<sect4 id="InitBellFeedbackClassDeviceStruct">
+<title>InitBellFeedbackClassDeviceStruct</title>
+<para>
+<!-- .LP -->
+This function is provided to allocate and initialize a BellFeedbackClassRec, 
+and should be called for extension devices that have a bell.
+It is passed a pointer to the device,
+and a pointer to the device control procedure.
+It returns FALSE if the allocation fails, and has the following parameters:
+<literallayout class="monospaced">
+Bool
+InitBellFeedbackClassDeviceStruct(dev, bellProc, controlProc)
+    DeviceIntPtr dev;
+    void (*bellProc)();
+    void (*controlProc)();
+</literallayout>
+</para>
+</sect4>
+<sect4 id="InitStringFeedbackClassDeviceStruct">
+<title>InitStringFeedbackClassDeviceStruct</title>
+<para>
+<!-- .LP -->
+This function is provided to allocate and initialize a StringFeedbackClassRec, 
+and should be called for extension devices that have a display upon which a 
+string can be displayed.
+It is passed a pointer to the device,
+and a pointer to the device control procedure.
+It returns FALSE if the allocation fails, and has the following parameters:
+<literallayout class="monospaced">
+Bool
+InitStringFeedbackClassDeviceStruct(dev, controlProc, max_symbols, 
+	num_symbols_supported, symbols)
+    DeviceIntPtr dev;
+    void (*controlProc)();
+    int max_symbols:
+    int num_symbols_supported;
+    KeySym *symbols;
+</literallayout>
+</para>
+</sect4>
+<sect4 id="InitIntegerFeedbackClassDeviceStruct">
+<title>InitIntegerFeedbackClassDeviceStruct</title>
+<para>
+<!-- .LP -->
+This function is provided to allocate and initialize an 
+IntegerFeedbackClassRec, 
+and should be called for extension devices that have a display upon which an
+integer can be displayed.
+It is passed a pointer to the device,
+and a pointer to the device control procedure.
+It returns FALSE if the allocation fails, and has the following parameters:
+<literallayout class="monospaced">
+Bool
+InitIntegerFeedbackClassDeviceStruct(dev, controlProc)
+    DeviceIntPtr dev;
+    void (*controlProc)();
+</literallayout>
+</para>
+</sect4>
+</sect3>
+</sect2>
+<sect2 id="Initializing_The_Device_Name_And_Type">
+<title>Initializing The Device Name And Type</title>
+<para>
+<!-- .LP -->
+The device name and type can be initialized by calling AssignTypeAndName
+with the following parameters:
+<literallayout class="monospaced">
+void
+AssignTypeAndName(dev, type, name)
+    DeviceIntPtr dev;
+    Atom type;
+    char *name;
+</literallayout>
+</para>
+<para>
+<!-- .LP -->
+This will allocate space for the device name and copy the name that was passed.
+The device type can be obtained by calling MakeAtom with one of the names
+defined for input devices.  MakeAtom has the following parameters:
+<literallayout class="monospaced">
+Atom
+MakeAtom(name, len, makeit)
+    char *name;
+    int len;
+    Bool makeit;
+</literallayout>
+</para>
+<para>
+<!-- .LP -->
+Since the atom was already made when the input extension was initialized, the
+value of makeit should be FALSE;
+</para>
+</sect2>
+</sect1>
+<sect1 id="Closing_Extension_Devices">
+<title>Closing Extension Devices</title>
+<para>
+<!-- .LP -->
+The DisableDevice entry point is provided by DIX to disable input devices.
+It calls the device control routine for the specified
+device with a mode value of DEVICE_OFF.  The device control routine should
+call RemoveEnabledDevice to stop the server from checking for input from
+that device.
+</para>
+<para>
+<!-- .LP -->
+DisableDevice is not called by any input extension routines.  It can be 
+called from the CloseInputDevice routine, which is called by
+ProcXCloseDevice when a client makes an XCloseDevice request.  If
+DisableDevice is called, it should only be called when the last client
+using the extension device has terminated or called XCloseDevice.
+</para>
+</sect1>
+<sect1 id="Implementation_Dependent_Routines">
+<title>Implementation-Dependent Routines</title>
+<para>
+<!-- .LP -->
+Several input extension protocol requests have 
+implementation-dependent  entry points.  Default routines
+are defined for these entry points and contained in the source
+file extensions/server/xinput/xstubs.c.  Some implementations may
+be able to use the default routines without change.
+The following sections describe each of these routines.
+</para>
+<sect2 id="AddOtherInputDevices">
+<title>AddOtherInputDevices</title>
+<para>
+<!-- .LP -->
+AddOtherInputDevice is called from ProcXListInputDevices as a result of 
+an XListInputDevices protocol request.  It may be needed by
+implementations that do not open extension input devices until requested
+to do so by some client.  These implementations may not initialize
+all devices when the X server starts up, because some of those devices
+may be in use.  Since the XListInputDevices
+function only lists those devices that have been initialized,
+AddOtherInputDevices is called to give DDX a chance to 
+initialize any previously unavailable input devices.
+</para>
+<para>
+<!-- .LP -->
+A sample AddOtherInputDevices routine might look like the following:
+<literallayout class="monospaced">
+void
+AddOtherInputDevices ()
+    {
+    DeviceIntPtr dev;
+    int i;
+
+    for (i=0; i<MAX_DEVICES; i++) 
+        {
+        if (!local_dev[i].initialized && available(local_dev[i]))
+            {
+            dev = (DeviceIntPtr) AddInputDevice (local_dev[i].deviceProc, TRUE);
+            dev->public.devicePrivate = local_dev[i];
+            RegisterOtherDevice (dev);
+            dev->inited = ((*dev->deviceProc)(dev, DEVICE_INIT) == Success);
+            }
+        }
+    }
+</literallayout>
+</para>
+<para>
+<!-- .LP -->
+The default AddOtherInputDevices routine in xstubs.c does nothing.
+If all input extension devices are initialized when the server 
+starts up, it can be left as a null routine.
+</para>
+</sect2>
+<sect2 id="OpenInputDevice">
+<title>OpenInputDevice</title>
+<para>
+<!-- .LP -->
+Some X server implementations open all input devices when the server
+is initialized and never close them.  Other implementations may open only
+the X pointer and keyboard devices during server initialization,
+and open other input devices only when some client makes an
+XOpenDevice request.  This entry point is for the latter type of 
+implementation.
+</para>
+<para>
+<!-- .LP -->
+If the physical device is not already open, it can be done in this routine.  
+In this case, the server must keep track of the fact that one or more clients 
+have the device open, and physically close it when the last client that has
+it open makes an XCloseDevice request.
+</para>
+<para>
+<!-- .LP -->
+The default implementation is to do nothing (assume all input devices
+are opened during X server initialization and kept open).
+</para>
+</sect2>
+<sect2 id="CloseInputDevice">
+<title>CloseInputDevice</title>
+<para>
+<!-- .LP -->
+Some implementations may close an input device when the last client
+using that device requests that it be closed, or terminates.
+CloseInputDevice is called from ProcXCloseDevice when a client
+makes an XCloseDevice protocol request.
+</para>
+<para>
+<!-- .LP -->
+The default implementation is to do nothing (assume all input devices
+are opened during X server initialization and kept open).
+</para>
+</sect2>
+<sect2 id="SetDeviceMode">
+<title>SetDeviceMode</title>
+<para>
+<!-- .LP -->
+Some implementations support input devices that can report 
+either absolute positional data or relative motion.  The XSetDeviceMode
+protocol request is provided to allow DDX to change the current mode of 
+such a device.
+</para>
+<para>
+<!-- .LP -->
+The default implementation is to always return a BadMatch error.  If the
+implementation does not support any input devices that are capable of 
+reporting both relative motion and absolute position information, the
+default implementation may be left unchanged.
+</para>
+</sect2>
+<sect2 id="SetDeviceValuators">
+<title>SetDeviceValuators</title>
+<para>
+<!-- .LP -->
+Some implementations support input devices that allow their valuators to be 
+set to an initial value.  The XSetDeviceValuators 
+protocol request is provided to allow DDX to set the valuators of
+such a device.
+</para>
+<para>
+<!-- .LP -->
+The default implementation is to always return a BadMatch error.  If the
+implementation does not support any input devices that are allow their
+valuators to be set, the default implementation may be left unchanged.
+</para>
+</sect2>
+<sect2 id="ChangePointerDevice">
+<title>ChangePointerDevice</title>
+<para>
+<!-- .LP -->
+The XChangePointerDevice protocol request is provided to change which device is
+used as the X pointer.  Some implementations may maintain information
+specific to the X pointer in the private data structure pointed to by
+the DeviceIntRec.  ChangePointerDevice is called to allow such 
+implementations to move that information to the new pointer device.
+The current location of the X cursor is an example of the type of 
+information that might be affected.
+</para>
+<para>
+<!-- .LP -->
+The DeviceIntRec structure that describes the X pointer device does not 
+contain a FocusRec.  If the device that has been made into the new X pointer 
+was previously a device that could be focused, ProcXChangePointerDevice will 
+free the FocusRec associated with that device.
+</para>
+<para>
+<!-- .LP -->
+If the server implementation desires to allow clients to focus the old pointer 
+device (which is now accessible through the input extension), it should call
+InitFocusClassDeviceStruct for the old pointer device.
+</para>
+<para>
+<!-- .LP -->
+The XChangePointerDevice protocol request also allows the client
+to choose which axes of the new pointer device are used to move 
+the X cursor in the X- and Y- directions.  If the axes are different
+than the default ones, the server implementation should record that fact.
+</para>
+<para>
+<!-- .LP -->
+If the server implementation supports input devices with valuators that 
+are not allowed to be used as the X pointer, they should be screened out
+by this routine and a  BadDevice error returned.
+</para>
+<para>
+<!-- .LP -->
+The default implementation is to do nothing. 
+</para>
+</sect2>
+<sect2 id="ChangeKeyboardDevice">
+<title>ChangeKeyboardDevice</title>
+<para>
+<!-- .LP -->
+The XChangeKeyboardDevice protocol request is provided to change which device is
+used as the X keyboard.  Some implementations may maintain information
+specific to the X keyboard in the private data structure pointed to by
+the DeviceIntRec.  ChangeKeyboardDevice is called to allow such 
+implementations to move that information to the new keyboard device.
+</para>
+<para>
+<!-- .LP -->
+The X keyboard device can be focused, and the DeviceIntRec that describes
+that device has a FocusRec.  If the device that has been made into the new X 
+keyboard did not previously have a FocusRec, 
+ProcXChangeKeyboardDevice will allocate one for it.
+</para>
+<para>
+<!-- .LP -->
+If the implementation does not want clients to be able to focus the old X 
+keyboard (which has now become available as an input extension device)
+it should call DeleteFocusClassDeviceStruct to free the FocusRec.
+</para>
+<para>
+<!-- .LP -->
+If the implementation supports input devices with keys that are not allowed
+to be used as the X keyboard, they should be checked for here, and a
+BadDevice error returned.
+</para>
+<para>
+<!-- .LP -->
+The default implementation is to do nothing. 
+</para>
+</sect2>
+</sect1>
+<sect1 id="Input_Extension_Events">
+<title>Input Extension Events</title>
+<para>
+<!-- .LP -->
+Events accessed through the input extension are analogous to the core input
+events, but have different event types.  They are of types 
+<function>DeviceKeyPress</function>, <function>DeviceKeyRelease</function>, <function>DeviceButtonPress</function>,
+<function>DeviceButtonRelease</function>, <function>DeviceDeviceMotionNotify</function>,
+<function>DeviceProximityIn</function>, <function>DeviceProximityOut</function>, and <function>DeviceValuator</function>.
+These event types are not constants.  Instead, they are external integers 
+defined by the input extension.  Their actual values will depend on which
+extensions are supported by a server, and the order in which they are
+initialized.
+</para>
+<para>
+<!-- .LP -->
+The data structures that define these
+events are defined in the file <function>extensions/include/XIproto.h</function>.  Other
+input extension constants needed by DDX are defined in the file
+<function>extensions/include/XI.h</function>.
+</para>
+<para>
+<!-- .LP -->
+Some events defined by the input extension contain more information than can
+be contained in the 32-byte xEvent data structure.  To send this information
+to clients, DDX must generate two or more 32-byte wire events.  The following
+sections describe the contents of these events. 
+</para>
+<sect2 id="Device_Key_Events">
+<title>Device Key Events</title>
+<para>
+<!-- .LP -->
+<function>DeviceKeyPresss</function> events contain all the information that is contained in
+a core <function>KeyPress</function> event, and also the following additional information:
+</para>
+<para>
+<!-- .LP -->
+<!-- .RS -->
+<!-- .in +5n -->
+</para>
+<itemizedlist>
+  <listitem>
+    <para>
+deviceid - the identifier of the device that generated the event.
+    </para>
+  </listitem>
+  <listitem>
+    <para>
+device_state - the state of any modifiers on the device that generated the event
+    </para>
+  </listitem>
+  <listitem>
+    <para>
+num_valuators - the number of valuators reported in this event.
+    </para>
+  </listitem>
+  <listitem>
+    <para>
+first_valuator - the first valuator reported in this event.
+    </para>
+  </listitem>
+  <listitem>
+    <para>
+valuator0 through valuator5 - the values of the valuators.
+<!-- .in -5n -->
+<!-- .RE -->
+    </para>
+  </listitem>
+</itemizedlist>
+<para>
+<!-- .LP -->
+In order to pass this information to the input extension library, two 32-byte
+wire events must be generated by DDX.  The first has an event type of 
+<function>DeviceKeyPress</function>, and the second has an event type of \fPDeviceValuator\fP.
+</para>
+<para>
+<!-- .LP -->
+The following code fragment shows how the two wire events could be initialized:
+</para>
+<para>
+<!-- .LP -->
+<literallayout class="monospaced">
+    extern int DeviceKeyPress;
+    DeviceIntPtr dev;
+    xEvent xE[2];
+    CARD8 id, num_valuators;
+    INT16 x, y, pointerx, pointery;
+    Time timestamp;
+    deviceKeyButtonPointer *xev = (deviceKeyButtonPointer *) xE;
+    deviceValuator *xv;
+
+    xev->type = DeviceKeyPress;                /* defined by input extension */
+    xev->detail = keycode;              /* key pressed on this device */
+    xev->time = timestamp;              /* same as for core events    */
+    xev->rootX = pointerx;              /* x location of core pointer */
+    xev->rootY = pointery;              /* y location of core pointer */
+
+    /******************************************************************/
+    /*                                                                */
+    /* The following field does not exist for core input events.      */
+    /* It contains the device id for the device that generated the    */
+    /* event, and also indicates whether more than one 32-byte wire   */
+    /* event is being sent.                                           */
+    /*                                                                */
+    /******************************************************************/
+
+    xev->deviceid = dev->id | MORE_EVENTS;        /* sending more than 1*/
+
+    /******************************************************************/
+    /* Fields in the second 32-byte wire event:                       */
+    /******************************************************************/
+
+    xv = (deviceValuator *) ++xev;
+    xv->type = DeviceValuator;          /* event type of second event */
+    xv->deviceid = dev->id;             /* id of this device          */
+    xv->num_valuators = 0;              /* no valuators being sent    */
+    xv->device_state  = 0;              /* will be filled in by DIX   */
+</literallayout>
+</para>
+</sect2>
+<sect2 id="Device_Button_Events">
+<title>Device Button Events</title>
+<para>
+<!-- .LP -->
+<function>DeviceButton</function> events contain all the information that is contained in
+a core button event, and also the same additional information that a 
+<function>DeviceKey</function> event contains.
+</para>
+</sect2>
+<sect2 id="Device_Motion_Events">
+<title>Device Motion Events</title>
+<para>
+<!-- .LP -->
+<function>DeviceMotion</function> events contain all the information that is contained in
+a core motion event, and also additional valuator information.  At least
+two wire events are required to contain this information.
+The following code fragment shows how the two wire events could be initialized:
+</para>
+<para>
+<!-- .LP -->
+<literallayout class="monospaced">
+    extern int DeviceMotionNotify;
+    DeviceIntPtr dev;
+    xEvent xE[2];
+    CARD8 id, num_valuators;
+    INT16 x, y, pointerx, pointery;
+    Time timestamp;
+    deviceKeyButtonPointer *xev = (deviceKeyButtonPointer *) xE;
+    deviceValuator *xv;
+
+    xev->type = DeviceMotionNotify;     /* defined by input extension */
+    xev->detail = keycode;              /* key pressed on this device */
+    xev->time = timestamp;              /* same as for core events    */
+    xev->rootX = pointerx;              /* x location of core pointer */
+    xev->rootY = pointery;              /* y location of core pointer */
+
+    /******************************************************************/
+    /*                                                                */
+    /* The following field does not exist for core input events.      */
+    /* It contains the device id for the device that generated the    */
+    /* event, and also indicates whether more than one 32-byte wire   */
+    /* event is being sent.                                           */
+    /*                                                                */
+    /******************************************************************/
+
+    xev->deviceid = dev->id | MORE_EVENTS;        /* sending more than 1*/
+
+    /******************************************************************/
+    /* Fields in the second 32-byte wire event:                       */
+    /******************************************************************/
+
+    xv = (deviceValuator *) ++xev;
+    xv->type = DeviceValuator;          /* event type of second event */
+    xv->deviceid = dev->id;             /* id of this device          */
+    xv->num_valuators = 2;              /* 2 valuators being sent     */
+    xv->first_valuator = 0;             /* first valuator being sent  */
+    xv->device_state  = 0;              /* will be filled in by DIX   */
+    xv->valuator0 = x;                  /* first axis of this device  */
+    xv->valuator1 = y;                  /* second axis of this device */
+</literallayout>
+</para>
+<para>
+<!-- .LP -->
+Up to six axes can be reported in the deviceValuator event.  If the device
+is reporting more than 6 axes, additional pairs of DeviceMotionNotify and
+DeviceValuator events should be sent,  with the first_valuator field
+set correctly.
+</para>
+</sect2>
+<sect2 id="Device_Proximity_Events">
+<title>Device Proximity Events</title>
+<para>
+<!-- .LP -->
+Some input devices that report absolute positional information, such as 
+graphics tablets and touchscreens, may report proximity events.  
+<function>ProximityIn</function>
+events are generated when a pointing device like a stylus, or in the case
+of a touchscreen, the user's finger, comes into close proximity with the
+surface of the input device.  <function>ProximityOut</function> events are generated when
+the stylus or finger leaves the proximity of the input devices surface.
+</para>
+<para>
+<!-- .LP -->
+<function>Proximity</function> events contain almost the same information as button events.
+The event type is <function>ProximityIn</function> or <function>ProximityOut</function>, and there is no
+detail information.
+<!-- .bp -->
+<!-- .\" .TC -->
+
+</para>
+</sect2>
+</sect1>
+</chapter>
+</book>
diff --git a/doc/Xserver-spec.xml b/doc/Xserver-spec.xml
new file mode 100644
index 0000000..7d7f915
--- /dev/null
+++ b/doc/Xserver-spec.xml
@@ -0,0 +1,5102 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
+ "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
+ <!ENTITY % defs SYSTEM "/xserver/doc/xml/xserver.ent"> %defs;
+]>
+
+<article>
+  <articleinfo>
+    <author>
+      <firstname>Susan</firstname><surname>Angebranndt</surname>
+      <affiliation><orgname>Digital Equipment Corporation</orgname></affiliation>
+    </author>
+    <author>
+      <firstname>Raymond</firstname><surname>Drewry</surname>
+      <affiliation><orgname>Digital Equipment Corporation</orgname></affiliation>
+    </author>
+    <author>
+      <firstname>Philip</firstname><surname>Karlton</surname>
+      <affiliation><orgname>Digital Equipment Corporation</orgname></affiliation>
+    </author>
+    <author>
+      <firstname>Todd</firstname><surname>Newman</surname>
+      <affiliation><orgname>Digital Equipment Corporation</orgname></affiliation>
+    </author>
+    <author>
+      <firstname>Bob</firstname><surname>Scheifler</surname>
+      <affiliation><orgname>Massachusetts Institute of Technology</orgname></affiliation>
+    </author>
+    <author>
+      <firstname>Keith</firstname><surname>Packard</surname>
+      <affiliation><orgname>MIT X Consortium</orgname></affiliation>
+    </author>
+    <author>
+      <firstname>David</firstname><othername>P.</othername><surname>Wiggins</surname>
+      <affiliation><orgname>X Consortium</orgname></affiliation>
+    </author>
+    <author>
+      <firstname>Jim</firstname><surname>Gettys</surname>
+      <affiliation><orgname>X.org Foundation and Hewlett Packard</orgname></affiliation>
+    </author>
+    <publisher><publishername>The X.Org Foundation</publishername></publisher>
+    <pubdate>&xserver.reldate;</pubdate>
+    <releaseinfo>X server version &xserver.version;</releaseinfo>
+    <title>Definition of the Porting Layer for the X v11 Sample Server</title>
+    <titleabbrev>X Porting Layer</titleabbrev>
+    <revhistory>
+      <revision>
+	<revnumber>1.0</revnumber>
+	<date>27 Oct 2004</date>
+	<authorinitials>sa</authorinitials>
+	<revremark>Initial Version</revremark>
+      </revision>
+      <revision>
+	<revnumber>1.1</revnumber>
+	<date>27 Oct 2004</date>
+	<authorinitials>bs</authorinitials>
+	<revremark>Minor Revisions</revremark>
+      </revision>
+      <revision>
+	<revnumber>2.0</revnumber>
+	<date>27 Oct 2004</date>
+	<authorinitials>kp</authorinitials>
+	<revremark>Revised for Release 4 and 5</revremark>
+      </revision>
+      <revision>
+	<revnumber>3.0</revnumber>
+	<date>27 Oct 2004</date>
+	<authorinitials>dpw</authorinitials>
+	<revremark>Revised for Release 6</revremark>
+      </revision>
+      <revision>
+	<revnumber>3.1</revnumber>
+	<date>27 Oct 2004</date>
+	<authorinitials>jg</authorinitials>
+	<revremark>Revised for Release 6.8.2</revremark>
+      </revision>
+      <revision>
+	<revnumber>3.2</revnumber>
+	<date>17 Dec 2006</date>
+	<authorinitials>efw</authorinitials>
+	<revremark>DocBook conversion</revremark>
+      </revision>
+      <revision>
+	<revnumber>3.3</revnumber>
+	<date>17 Feb 2008</date>
+	<authorinitials>aj</authorinitials>
+	<revremark>Revised for backing store changes</revremark>
+      </revision>
+      <revision>
+	<revnumber>3.4</revnumber>
+	<date>31 Mar 2008</date>
+	<authorinitials>efw</authorinitials>
+	<revremark>Revised for devPrivates changes</revremark>
+      </revision>
+      <revision>
+	<revnumber>3.5</revnumber>
+	<date>July 2010</date>
+	<authorinitials>ac</authorinitials>
+	<revremark>Revised for Xorg 1.9 devPrivates changes
+	  and 1.8 CreateNewResourceType changes</revremark>
+      </revision>
+    </revhistory>
+    <legalnotice>
+      <para>Copyright &#xA9; 1994 X Consortium, Inc., 2004 X.org Foundation, Inc.</para>
+      <para>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:</para>
+      <para>The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.</para>
+      <para>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 X CONSORTIUM 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.</para>
+      <para>LK201 and DEC are trademarks of Digital Equipment Corporation.  Macintosh and Apple are trademarks of Apple Computer, Inc.  PostScript is a trademark of Adobe Systems, Inc.  Ethernet is a trademark of Xerox Corporation.  X Window System is a trademark of the X.org Foundation, Inc.  Cray is a trademark of Cray Research, Inc.</para>
+    </legalnotice>
+    <abstract>
+      <para>The following document explains the structure of the X Window System display server and the interfaces among the larger pieces.  It is intended as a reference for programmers who are implementing an X Display Server on their workstation hardware.  It is included with the X Window System source tape, along with the document "Strategies for Porting the X v11 Sample Server."  The order in which you should read these documents is:
+      <orderedlist>
+	<listitem><para>Read the first section of the "Strategies for Porting" document (Overview of Porting Process).</para></listitem>
+	<listitem><para>Skim over this document (the Definition document).</para></listitem>
+	<listitem><para>Skim over the remainder of the Strategies document.</para></listitem>
+	<listitem><para>Start planning and working, referring to the Strategies and Definition documents.</para></listitem>
+      </orderedlist>
+      You may also want to look at the following documents:
+      <itemizedlist>
+	<listitem><para>"The X Window System" for an overview of X.</para></listitem>
+	<listitem><para>"Xlib - C Language X Interface" for a view of what the client programmer sees.</para></listitem>
+	<listitem><para>"X Window System Protocol" for a terse description of the byte stream protocol between the client and server.</para></listitem>
+      </itemizedlist>
+      </para>
+      <para>To understand this document and the accompanying source code, you should know the C language.  You should be familiar with 2D graphics and windowing concepts such as clipping, bitmaps, fonts, etc.  You should have a general knowledge of the X Window System.  To implement the server code on your hardware, you need to know a lot about your hardware, its graphic display device(s), and (possibly) its networking and multitasking facilities.  This document depends a lot on the source code, so you should have a listing of the code handy.</para>
+      <para>Some source in the distribution is directly compilable on your machine.  Some of it will require modification.  Other parts may have to be completely written from scratch.  The distribution also includes source for a sample implementation of a display server which runs on a very wide variety of color and monochrome displays on Linux and *BSD which you will find useful for implementing any type of X server.</para>
+      <para>Note to the 2008 edition: at this time this document must be considered incomplete, though improved over the 2004 edition.  In particular, the new Render extension is still lacking good documentation, and has become vital to high performance X implementations.  Modern applications and desktop environments are now much more sensitive to good implementation of the Render extension than in most operations of the old X graphics model.  The shadow frame buffer implementation is also very useful in many circumstances, and also needs documentation.  We hope to rectify these shortcomings in our documentation in the future.  Help would be greatly appreciated.</para>
+    </abstract>
+  </articleinfo>
+
+<!-- Original authorship information:
+
+.OF 'Porting Layer Definition'- % -'October 27, 2004'
+Definition of the Porting Layer
+for the X v11 Sample Server
+Susan Angebranndt
+Raymond Drewry
+Philip Karlton
+Todd Newman
+Digital Equipment Corporation
+
+minor revisions by
+Bob Scheifler
+Massachusetts Institute of Technology
+
+Revised for Release 4 and Release 5 by
+Keith Packard
+MIT X Consortium
+
+Revised for Release 6 by
+David P. Wiggins
+X Consortium
+
+Minor Revisions for Release 6.8.2 by
+Jim Gettys
+X.org Foundation and Hewlett Packard
+-->
+
+<section>
+  <title>The X Window System</title>
+<para>
+The X Window System, or simply "X," is a
+windowing system that provides high-performance, high-level,
+device-independent graphics.
+</para>
+<para>
+X is a windowing system designed for bitmapped graphic displays.
+The display can have a
+simple, monochrome display or it can have a color display with up to 32 bits
+per pixel with a special graphics processor doing the work.  (In this
+document, monochrome means a black and white display with one bit per pixel.
+Even though the usual meaning of monochrome is more general, this special
+case is so common that we decided to reserve the word for this purpose.)
+In practice, monochrome displays are now almost unheard of, with 4 bit
+gray scale displays being the low end.
+</para>
+<para>
+X is designed for a networking environment where
+users can run applications on machines other than their own workstations.
+Sometimes, the connection is over an Ethernet network with a protocol such as TCP/IP;
+but, any "reliable" byte stream is allowable.
+A high-bandwidth byte stream is preferable; RS-232 at
+9600 baud would be slow without compression techniques.
+</para>
+<para>
+X by itself allows great freedom of design.
+For instance, it does not include any user interface standard.
+Its intent is to "provide mechanism, not policy."
+By making it general, it can be the foundation for a wide
+variety of interactive software.
+</para>
+<para>
+For a more detailed overview, see the document "The X Window System."
+For details on the byte stream protocol, see "X Window System protocol."
+</para>
+</section>
+<section>
+<title>Overview of the Server</title>
+<para>
+The display server
+manages windows and simple graphics requests
+for the user on behalf of different client applications.
+The client applications can be running on any machine on the network.
+The server mainly does three things:
+<itemizedlist>
+  <listitem><para>Responds to protocol requests from existing clients (mostly graphic and text drawing commands)</para></listitem>
+  <listitem><para>Sends device input (keystrokes and mouse actions) and other events to existing clients</para></listitem>
+  <listitem><para>Maintains client connections</para></listitem>
+</itemizedlist>
+</para>
+<para>
+The server code is organized into four major pieces:
+<itemizedlist>
+  <listitem><para>Device Independent (DIX) layer - code shared among all implementations</para></listitem>
+  <listitem><para>Operating System (OS) layer - code that is different for each operating system but is shared among all graphic devices for this operating system</para></listitem>
+  <listitem><para>Device Dependent (DDX) layer - code that is (potentially) different for each combination of operating system and graphic device</para></listitem>
+  <listitem><para>Extension Interface - a standard way to add features to the X server</para></listitem>
+</itemizedlist>
+</para>
+<para>
+The "porting layer" consists of the OS and DDX layers; these are
+actually parallel and neither one is on top of the other.
+The DIX layer is intended to be portable
+without change to target systems and is not
+detailed here, although several routines
+in DIX that are called by DDX are
+documented.
+Extensions incorporate new functionality into the server; and require
+additional functionality over a simple DDX.
+</para>
+<para>
+The following sections outline the functions of the layers.
+Section 3 briefly tells what you need to know about the DIX layer.
+The OS layer is explained in Section 4.
+Section 5 gives the theory of operation and procedural interface for the
+DDX layer.
+Section 6 describes the functions which exist for the extension writer.
+</para>
+</section>
+
+<section>
+  <title>DIX Layer</title>
+<para>
+The DIX layer is the machine and device independent part of X.
+The source should be common to all operating systems and devices.
+The port process should not include changes to this part, therefore internal interfaces to DIX
+modules are not discussed, except for public interfaces to the DDX and the OS layers.
+The functions described in this section are available for extension writers to use.
+</para>
+<para>
+In the process of getting your server to work, if
+you think that DIX must be modified for purposes other than bug fixes,
+you may be doing something wrong.
+Keep looking for a more compatible solution.
+When the next release of the X server code is available,
+you should be able to just drop in the new DIX code and compile it.
+If you change DIX,
+you will have to remember what changes you made and will have
+to change the new sources before you can update to the new version.
+</para>
+<para>
+The heart of the DIX code is a loop called the dispatch loop.
+Each time the processor goes around the loop, it sends off accumulated input events
+from the input devices to the clients, and it processes requests from the clients.
+This loop is the most organized way for the server to
+process the asynchronous requests that
+it needs to process.
+Most of these operations are performed by OS and DDX routines that you must supply.
+</para>
+<section>
+  <title>Server Resource System</title>
+<para>
+X resources are C structs inside the server.
+Client applications create and manipulate these objects
+according to the rules of the X byte stream protocol.
+Client applications refer to resources with resource IDs,
+which are 32-bit integers that are sent over the network.
+Within the server, of course, they are just C structs, and we refer to them
+by pointers.
+</para>
+<section>
+  <title>Pre-Defined Resource Types</title>
+<para>
+The DDX layer has several kinds of resources:
+<itemizedlist>
+<listitem><para>Window</para></listitem>
+<listitem><para>Pixmap</para></listitem>
+<listitem><para>Screen</para></listitem>
+<listitem><para>Device</para></listitem>
+<listitem><para>Colormap</para></listitem>
+<listitem><para>Font</para></listitem>
+<listitem><para>Cursor</para></listitem>
+<listitem><para>Graphics Contexts</para></listitem>
+</itemizedlist>
+</para>
+<para>
+The type names of the more
+important server
+structs usually end in "Rec," such as "DeviceRec;"
+the pointer types usually end in "Ptr," such as "DevicePtr."
+</para>
+<para>
+The structs and
+important defined constants are declared
+in .h files that have names that suggest the name of the object.
+For instance, there are two .h files for windows,
+window.h and windowstr.h.
+window.h defines only what needs to be defined in order to use windows
+without peeking inside of them;
+windowstr.h defines the structs with all of their components in great detail
+for those who need it.
+</para>
+<para>
+Three kinds of fields are in these structs:
+<itemizedlist>
+<listitem><para>Attribute fields - struct fields that contain values like normal structs</para></listitem>
+<listitem><para>Pointers to procedures, or structures of procedures, that operate on the object</para></listitem>
+<listitem><para>A single private field or a devPrivates list (see <xref linkend="wrappers_and_privates"/>)
+used by your DDX code to store private data.</para></listitem>
+</itemizedlist>
+</para>
+<para>
+DIX calls through
+the struct's procedure pointers to do its tasks.
+These procedures are set either directly or indirectly by DDX procedures.
+Most of
+the procedures described in the remainder of this
+document are accessed through one of these structs.
+For example, the procedure to create a pixmap
+is attached to a ScreenRec and might be called by using the expression
+</para>
+<para>
+<blockquote>
+<programlisting>(* pScreen->CreatePixmap)(pScreen, width, height, depth).</programlisting>
+</blockquote>
+</para>
+<para>
+All procedure pointers must be set to some routine unless noted otherwise;
+a null pointer will have unfortunate consequences.
+</para>
+<para>
+Procedure routines will be indicated in the documentation by this convention:
+<blockquote>
+<programlisting>void pScreen->MyScreenRoutine(arg, arg, ...)</programlisting>
+</blockquote>
+as opposed to a free routine, not in a data structure:
+<blockquote>
+<programlisting>void MyFreeRoutine(arg, arg, ...)</programlisting>
+</blockquote>
+</para>
+<para>
+The attribute fields are mostly set by DIX; DDX should not modify them
+unless noted otherwise.
+</para>
+</section>
+<section>
+  <title>Creating Resources and Resource Types</title>
+<para>
+These functions should also be called from your extensionInitProc to
+allocate all of the various resource classes and types required for
+the extension.  Each time the server resets, these types must be reallocated
+as the old allocations will have been discarded.
+Resource types are integer values starting at 1.  Get
+a resource type by calling
+<blockquote><programlisting>
+
+    RESTYPE CreateNewResourceType(deleteFunc, char *name)
+
+</programlisting></blockquote>
+deleteFunc will be called to destroy all resources with this
+type.   name will be used to identify this type of resource
+to clients using the X-Resource extension, to security
+extensions such as SELinux, and to tracing frameworks such as DTrace.
+[The name argument was added in xorg-server 1.8.]
+</para>
+<para>
+Resource classes are masks starting at 1 << 31 which can
+be or'ed with any resource type to provide attributes for the
+type.  To allocate a new class bit, call
+<blockquote><programlisting>
+
+    RESTYPE CreateNewResourceClass()
+
+</programlisting></blockquote>
+</para>
+<para>
+There are two ways of looking up resources, by type or
+by class.  Classes are non-exclusive subsets of the space of
+all resources, so you can lookup the union of multiple classes.
+(RC_ANY is the union of all classes).</para>
+<para>
+Note that the appropriate class bits must be or'ed into the value returned
+by CreateNewResourceType when calling resource lookup functions.</para>
+<para>
+If you need to create a ``private'' resource ID for internal use, you
+can call FakeClientID.
+<blockquote><programlisting>
+
+	XID FakeClientID(client)
+	    int client;
+
+</programlisting></blockquote>
+This allocates from ID space reserved for the server.</para>
+<para>
+To associate a resource value with an ID, use AddResource.
+<blockquote><programlisting>
+
+	Bool AddResource(id, type, value)
+	    XID id;
+	    RESTYPE type;
+	    pointer value;
+
+</programlisting></blockquote>
+The type should be the full type of the resource, including any class
+bits.  If AddResource fails to allocate memory to store the resource,
+it will call the deleteFunc for the type, and then return False.</para>
+<para>
+To free a resource, use one of the following.
+<blockquote><programlisting>
+
+	void FreeResource(id, skipDeleteFuncType)
+	    XID id;
+	    RESTYPE skipDeleteFuncType;
+
+	void FreeResourceByType(id, type, skipFree)
+	    XID id;
+	    RESTYPE type;
+	    Bool    skipFree;
+
+</programlisting></blockquote>
+FreeResource frees all resources matching the given id, regardless of
+type; the type's deleteFunc will be called on each matching resource,
+except that skipDeleteFuncType can be set to a single type for which
+the deleteFunc should not be called (otherwise pass RT_NONE).
+FreeResourceByType frees a specific resource matching a given id
+and type; if skipFree is true, then the deleteFunc is not called.
+</para>
+</section>
+<section>
+  <title>Looking Up Resources</title>
+<para>
+To look up a resource, use one of the following.
+<blockquote><programlisting>
+
+	int dixLookupResourceByType(
+	    pointer *result,
+	    XID id,
+	    RESTYPE rtype,
+	    ClientPtr client,
+	    Mask access_mode);
+
+	int dixLookupResourceByClass(
+	    pointer *result,
+	    XID id,
+	    RESTYPE rclass,
+	    ClientPtr client,
+	    Mask access_mode);
+
+</programlisting></blockquote>
+dixLookupResourceByType finds a resource with the given id and exact type.
+dixLookupResourceByClass finds a resource with the given id whose type is
+included in any one of the specified classes.
+The client and access_mode must be provided to allow security extensions to
+check if the client has the right privileges for the requested access.
+The bitmask values defined in the dixaccess.h header are or'ed together
+to define the requested access_mode.
+</para>
+</section>
+</section>
+<section>
+  <title>Callback Manager</title>
+<para>
+To satisfy a growing number of requests for the introduction of ad hoc
+notification style hooks in the server, a generic callback manager was
+introduced in R6.  A callback list object can be introduced for each
+new hook that is desired, and other modules in the server can register
+interest in the new callback list.  The following functions support
+these operations.</para>
+<para>
+Before getting bogged down in the interface details, an typical usage
+example should establish the framework.  Let's look at the
+ClientStateCallback in dix/dispatch.c.  The purpose of this particular
+callback is to notify interested parties when a client's state
+(initial, running, gone) changes.  The callback is "created" in this
+case by simply declaring a variable:
+<blockquote><programlisting>
+	CallbackListPtr ClientStateCallback;
+</programlisting></blockquote>
+</para>
+<para>
+Whenever the client's state changes, the following code appears, which notifies
+all interested parties of the change:
+<blockquote><programlisting>
+	if (ClientStateCallback) CallCallbacks(&ClientStateCallback, (pointer)client);
+</programlisting></blockquote>
+</para>
+<para>
+Interested parties subscribe to the ClientStateCallback list by saying:
+<blockquote><programlisting>
+	AddCallback(&ClientStateCallback, func, data);
+</programlisting></blockquote>
+</para>
+<para>
+When CallCallbacks is invoked on the list, func will be called thusly:
+<blockquote><programlisting>
+	(*func)(&ClientStateCallback, data, client)
+</programlisting></blockquote>
+</para>
+<para>
+Now for the details.
+<blockquote><programlisting>
+
+	Bool AddCallback(pcbl, callback, subscriber_data)
+	    CallbackListPtr *pcbl;
+	    CallbackProcPtr callback;
+	    pointer         subscriber_data;
+
+</programlisting></blockquote>
+Adds the (callback, subscriber_data) pair to the given callback list.  Creates the callback
+list if it doesn't exist.  Returns TRUE if successful.</para>
+<para>
+<blockquote><programlisting>
+
+	Bool DeleteCallback(pcbl, callback, subscriber_data)
+	    CallbackListPtr *pcbl;
+	    CallbackProcPtr callback;
+	    pointer         subscriber_data;
+
+</programlisting></blockquote>
+Removes the (callback, data) pair to the given callback list if present.
+Returns TRUE if (callback, data) was found.</para>
+<para>
+<blockquote><programlisting>
+
+	void CallCallbacks(pcbl, call_data)
+	    CallbackListPtr    *pcbl;
+	    pointer	    call_data;
+
+</programlisting></blockquote>
+For each callback currently registered on the given callback list, call
+it as follows:
+<blockquote><programlisting>
+
+	(*callback)(pcbl, subscriber_data, call_data);
+</programlisting></blockquote>
+</para>
+<para>
+<blockquote><programlisting>
+	void DeleteCallbackList(pcbl)
+	    CallbackListPtr    *pcbl;
+
+</programlisting></blockquote>
+Destroys the given callback list.</para>
+</section>
+<section>
+  <title>Extension Interfaces</title>
+<para>
+This function should be called from your extensionInitProc which
+should be called by InitExtensions.
+<blockquote><programlisting>
+
+	ExtensionEntry *AddExtension(name, NumEvents,NumErrors,
+		MainProc, SwappedMainProc, CloseDownProc, MinorOpcodeProc)
+
+		char *name;  /*Null terminate string; case matters*/
+		int NumEvents;
+		int NumErrors;
+		int (* MainProc)(ClientPtr);/*Called if client matches server order*/
+		int (* SwappedMainProc)(ClientPtr);/*Called if client differs from server*/
+		void (* CloseDownProc)(ExtensionEntry *);
+		unsigned short (*MinorOpcodeProc)(ClientPtr);
+
+</programlisting></blockquote>
+name is the name used by clients to refer to the extension.  NumEvents is the
+number of event types used by the extension, NumErrors is the number of
+error codes needed by the extension.  MainProc is called whenever a client
+accesses the major opcode assigned to the extension.  SwappedMainProc is
+identical, except the client using the extension has reversed byte-sex.
+CloseDownProc is called at server reset time to deallocate any private
+storage used by the extension.  MinorOpcodeProc is used by DIX to place the
+appropriate value into errors.  The DIX routine StandardMinorOpcode can be
+used here which takes the minor opcode from the normal place in the request
+(i.e. just after the major opcode).</para>
+</section>
+<section>
+  <title>Macros and Other Helpers</title>
+<para>
+There are a number of macros in Xserver/include/dix.h which
+are useful to the extension writer.  Ones of particular interest
+are: REQUEST, REQUEST_SIZE_MATCH, REQUEST_AT_LEAST_SIZE,
+REQUEST_FIXED_SIZE, LEGAL_NEW_RESOURCE, and
+VALIDATE_DRAWABLE_AND_GC. Useful byte swapping macros can be found
+in Xserver/include/dix.h: WriteReplyToClient and WriteSwappedDataToClient; and
+in Xserver/include/misc.h: lswapl, lswaps, LengthRestB, LengthRestS,
+LengthRestL, SwapRestS, SwapRestL, swapl, swaps, cpswapl, and cpswaps.</para>
+</section>
+</section>
+
+<section>
+  <title>OS Layer</title>
+<para>
+This part of the source consists of a few routines that you have to rewrite
+for each operating system.
+These OS functions maintain the client connections and schedule work
+to be done for clients.
+They also provide an interface to font files,
+font name to file name translation, and
+low level memory management.
+<blockquote>
+<programlisting>void OsInit()</programlisting>
+</blockquote>
+OsInit initializes your OS code, performing whatever tasks need to be done.
+Frequently there is not much to be done.
+The sample server implementation is in Xserver/os/osinit.c.
+</para>
+<section>
+  <title>Scheduling and Request Delivery</title>
+<para>
+The main dispatch loop in DIX creates the illusion of multitasking between
+different windows, while the server is itself but a single process.
+The dispatch loop breaks up the work for each client into small digestible parts.
+Some parts are requests from a client, such as individual graphic commands.
+Some parts are events delivered to the client, such as keystrokes from the user.
+The processing of events and requests for different
+clients can be interleaved with one another so true multitasking
+is not needed in the server.
+</para>
+<para>
+You must supply some of the pieces for proper scheduling between clients.
+<blockquote>
+<programlisting>
+	int WaitForSomething(pClientReady)
+		int *pClientReady;
+</programlisting>
+</blockquote>
+</para>
+<para>
+WaitForSomething is the scheduler procedure you must write that will
+suspend your server process until something needs to be done.
+This call should
+make the server suspend until one or more of the following occurs:
+<itemizedlist>
+<listitem><para>There is an input event from the user or hardware (see SetInputCheck())</para></listitem>
+<listitem><para>There are requests waiting from known clients, in which case you should return a count of clients stored in pClientReady</para></listitem>
+<listitem><para>A new client tries to connect, in which case you should create the client and then continue waiting</para></listitem>
+</itemizedlist>
+</para>
+<para>
+Before WaitForSomething() computes the masks to pass to select, poll or
+similar operating system interface, it needs to
+see if there is anything to do on the work queue; if so, it must call a DIX
+routine called ProcessWorkQueue.
+<blockquote>
+<programlisting>
+	extern WorkQueuePtr	workQueue;
+
+	if (workQueue)
+		ProcessWorkQueue ();
+</programlisting>
+</blockquote>
+</para>
+<para>
+If WaitForSomething() decides it is about to do something that might block
+(in the sample server,  before it calls select() or poll) it must call a DIX
+routine called BlockHandler().
+<blockquote>
+<programlisting>
+	void BlockHandler(pTimeout, pReadmask)
+		pointer pTimeout;
+		pointer pReadmask;
+</programlisting>
+</blockquote>
+The types of the arguments are for agreement between the OS and DDX
+implementations,  but the pTimeout is a pointer to the information
+determining how long the block is allowed to last,  and the
+pReadmask is a pointer to the information describing the descriptors
+that will be waited on.
+</para>
+<para>
+In the sample server,  pTimeout is a struct timeval **,  and pReadmask is
+the address of the select() mask for reading.
+</para>
+<para>
+The DIX BlockHandler() iterates through the Screens,  for each one calling
+its BlockHandler.  A BlockHandler is declared thus:
+<blockquote>
+<programlisting>
+	void xxxBlockHandler(nscreen, pbdata, pptv, pReadmask)
+		int nscreen;
+		pointer pbdata;
+		struct timeval ** pptv;
+		pointer pReadmask;
+</programlisting>
+</blockquote>
+The arguments are the index of the Screen,  the blockData field
+of the Screen,  and the arguments to the DIX BlockHandler().
+</para>
+<para>
+Immediately after WaitForSomething returns from the
+block,  even if it didn't actually block,  it must call the DIX routine
+WakeupHandler().
+<blockquote>
+<programlisting>
+	void WakeupHandler(result, pReadmask)
+		int result;
+		pointer pReadmask;
+</programlisting>
+</blockquote>
+Once again,  the types are not specified by DIX.  The result is the
+success indicator for the thing that (may have) blocked,
+and the pReadmask is a mask of the descriptors that came active.
+In the sample server,  result is the result from select() (or equivalent
+operating system function),  and pReadmask is
+the address of the select() mask for reading.
+</para>
+<para>
+The DIX WakeupHandler() calls each Screen's
+WakeupHandler.  A WakeupHandler is declared thus:
+<blockquote>
+<programlisting>
+	void xxxWakeupHandler(nscreen, pbdata, err, pReadmask)
+		int nscreen;
+		pointer pbdata;
+		unsigned long result;
+		pointer pReadmask;
+</programlisting>
+</blockquote>
+The arguments are the index of the Screen,  the blockData field
+of the Screen,  and the arguments to the DIX WakeupHandler().
+</para>
+<para>
+In addition to the per-screen BlockHandlers, any module may register
+block and wakeup handlers (only together) using:
+<blockquote>
+<programlisting>
+	Bool RegisterBlockAndWakeupHandlers (blockHandler, wakeupHandler, blockData)
+		BlockHandlerProcPtr    blockHandler;
+		WakeupHandlerProcPtr   wakeupHandler;
+		pointer blockData;
+</programlisting>
+</blockquote>
+A FALSE return code indicates that the registration failed for lack of
+memory.  To remove a registered Block handler at other than server reset time
+(when they are all removed automatically), use:
+<blockquote>
+<programlisting>
+	RemoveBlockAndWakeupHandlers (blockHandler, wakeupHandler, blockData)
+		BlockHandlerProcPtr   blockHandler;
+		WakeupHandlerProcPtr  wakeupHandler;
+		pointer blockData;
+</programlisting>
+</blockquote>
+All three arguments must match the values passed to
+RegisterBlockAndWakeupHandlers.
+</para>
+<para>
+These registered block handlers are called after the per-screen handlers:
+<blockquote>
+<programlisting>
+	void (*BlockHandler) (blockData, pptv, pReadmask)
+		pointer	blockData;
+		OsTimerPtr pptv;
+		pointer	pReadmask;
+</programlisting>
+</blockquote>
+</para>
+<para>
+Sometimes block handlers need to adjust the time in a OSTimePtr structure,
+which on UNIX family systems is generally represented by a struct timeval
+consisting of seconds and microseconds in 32 bit values.
+As a convenience to reduce error prone struct timeval computations which
+require modulus arithmetic and correct overflow behavior in the face of
+millisecond wrapping through 32 bits,
+<blockquote><programlisting>
+
+	void AdjustWaitForDelay(pointer /*waitTime*, unsigned long /* newdelay */)
+
+</programlisting></blockquote>
+has been provided.
+</para>
+<para>
+Any wakeup handlers registered with RegisterBlockAndWakeupHandlers will
+be called before the Screen handlers:
+<blockquote><programlisting>
+
+	void (*WakeupHandler) (blockData, err, pReadmask)
+		pointer	blockData;
+		int err;
+		pointer pReadmask;
+</programlisting></blockquote>
+</para>
+<para>
+The WaitForSomething on the sample server also has a built
+in screen saver that darkens the screen if no input happens for a period of time.
+The sample server implementation is in Xserver/os/WaitFor.c.
+</para>
+<para>
+Note that WaitForSomething() may be called when you already have several
+outstanding things (events, requests, or new clients) queued up.
+For instance, your server may have just done a large graphics request,
+and it may have been a long time since WaitForSomething() was last called.
+If many clients have lots of requests queued up, DIX will only service
+some of them for a given client
+before going on to the next client (see isItTimeToYield, below).
+Therefore, WaitForSomething() will have to report that these same clients
+still have requests queued up the next time around.
+</para>
+<para>
+An implementation should return information on as
+many outstanding things as it can.
+For instance, if your implementation always checks for client data first and does not
+report any input events until there is no client data left,
+your mouse and keyboard might get locked out by an application that constantly
+barrages the server with graphics drawing requests.
+Therefore, as a general rule, input devices should always have priority over graphics
+devices.
+</para>
+<para>
+A list of indexes (client->index) for clients with data ready to be read or
+processed should be returned in pClientReady, and the count of indexes
+returned as the result value of the call.
+These are not clients that have full requests ready, but any clients who have
+any data ready to be read or processed.
+The DIX dispatcher
+will process requests from each client in turn by calling
+ReadRequestFromClient(), below.
+</para>
+<para>
+WaitForSomething() must create new clients as they are requested (by
+whatever mechanism at the transport level).  A new client is created
+by calling the DIX routine:
+<blockquote><programlisting>
+
+	ClientPtr NextAvailableClient(ospriv)
+		pointer ospriv;
+</programlisting></blockquote>
+This routine returns NULL if a new client cannot be allocated (e.g. maximum
+number of clients reached).  The ospriv argument will be stored into the OS
+private field (pClient->osPrivate), to store OS private information about the
+client.  In the sample server, the osPrivate field contains the
+number of the socket for this client. See also "New Client Connections."
+NextAvailableClient() will call InsertFakeRequest(), so you must be
+prepared for this.
+</para>
+<para>
+If there are outstanding input events,
+you should make sure that the two SetInputCheck() locations are unequal.
+The DIX dispatcher will call your implementation of ProcessInputEvents()
+until the SetInputCheck() locations are equal.
+</para>
+<para>
+The sample server contains an implementation of WaitForSomething().
+The
+following two routines indicate to WaitForSomething() what devices should
+be waited for.   fd is an OS dependent type; in the sample server
+it is an open file descriptor.
+<blockquote><programlisting>
+
+	int AddEnabledDevice(fd)
+		int fd;
+
+	int RemoveEnabledDevice(fd)
+		int fd;
+</programlisting></blockquote>
+These two routines are
+usually called by DDX from the initialize cases of the
+Input Procedures that are stored in the DeviceRec (the
+routine passed to AddInputDevice()).
+The sample server implementation of AddEnabledDevice
+and RemoveEnabledDevice are in Xserver/os/connection.c.
+</para>
+<section>
+  <title>Timer Facilities</title>
+<para>
+Similarly, the X server or an extension may need to wait for some timeout.
+Early X releases implemented this functionality using block and wakeup handlers,
+but this has been rewritten to use a general timer facilty, and the
+internal screen saver facilities reimplemented to use Timers.
+These functions are TimerInit, TimerForce, TimerSet, TimerCheck, TimerCancel,
+and TimerFree, as defined in Xserver/include/os.h. A callback function will be called
+when the timer fires, along with the current time, and a user provided argument.
+<blockquote><programlisting>
+	typedef	struct _OsTimerRec *OsTimerPtr;
+
+	typedef CARD32 (*OsTimerCallback)(
+		OsTimerPtr /* timer */,
+		CARD32 /* time */,
+		pointer /* arg */);
+
+	 OsTimerPtr TimerSet( OsTimerPtr /* timer */,
+		int /* flags */,
+		CARD32 /* millis */,
+		OsTimerCallback /* func */,
+		pointer /* arg */);
+
+</programlisting></blockquote>
+</para>
+<para>
+TimerSet returns a pointer to a timer structure and sets a timer to the specified time
+with the specified argument.  The flags can be TimerAbsolute and TimerForceOld.
+The TimerSetOld flag controls whether if the timer is reset and the timer is pending, the
+whether the callback function will get called.
+The TimerAbsolute flag sets the callback time to an absolute time in the future rather
+than a time relative to when TimerSet is called.
+TimerFree should be called to free the memory allocated
+for the timer entry.
+<blockquote><programlisting>
+	void TimerInit(void)
+
+	Bool TimerForce(OsTimerPtr /* pTimer */)
+
+	void TimerCheck(void);
+
+	void TimerCancel(OsTimerPtr /* pTimer */)
+
+	void TimerFree(OsTimerPtr /* pTimer */)
+</programlisting></blockquote>
+</para>
+<para>
+TimerInit frees any existing timer entries. TimerForce forces a call to the timer's
+callback function and returns true if the timer entry existed, else it returns false and
+does not call the callback function. TimerCancel will cancel the specified timer.
+TimerFree calls TimerCancel and frees the specified timer.
+Calling TimerCheck will force the server to see if any timer callbacks should be called.
+</para>
+</section>
+</section>
+<section>
+  <title>New Client Connections</title>
+<para>
+The process whereby a new client-server connection starts up is
+very dependent upon what your byte stream mechanism.
+This section describes byte stream initiation using examples from the TCP/IP
+implementation on the sample server.
+</para>
+<para>
+The first thing that happens is a client initiates a connection with the server.
+How a client knows to do this depends upon your network facilities and the
+Xlib implementation.
+In a typical scenario, a user named Fred
+on his X workstation is logged onto a Cray
+supercomputer running a command shell in an X window.  Fred can type shell
+commands and have the Cray respond as though the X server were a dumb terminal.
+Fred types in a command to run an X client application that was linked with Xlib.
+Xlib looks at the shell environment variable DISPLAY, which has the
+value "fredsbittube:0.0."
+The host name of Fred's workstation is "fredsbittube," and the 0s are
+for multiple screens and multiple X server processes.
+(Precisely what
+happens on your system depends upon how X and Xlib are implemented.)
+</para>
+<para>
+The client application calls a TCP routine on the
+Cray to open a TCP connection for X
+to communicate with the network node "fredsbittube."
+The TCP software on the Cray does this by looking up the TCP
+address of "fredsbittube" and sending an open request to TCP port 6000
+on fredsbittube.
+</para>
+<para>
+All X servers on TCP listen for new clients on port 6000 by default;
+this is known as a "well-known port" in IP terminology.
+</para>
+<para>
+The server receives this request from its port 6000
+and checks where it came from to see if it is on the server's list
+of "trustworthy" hosts to talk to.
+Then, it opens another port for communications with the client.
+This is the byte stream that all X communications will go over.
+</para>
+<para>
+Actually, it is a bit more complicated than that.
+Each X server process running on the host machine is called a "display."
+Each display can have more than one screen that it manages.
+"corporatehydra:3.2" represents screen 2 on display 3 on
+the multi-screened network node corporatehydra.
+The open request would be sent on well-known port number 6003.
+</para>
+<para>
+Once the byte stream is set up, what goes on does not depend very much
+upon whether or not it is TCP.
+The client sends an xConnClientPrefix struct (see Xproto.h) that has the
+version numbers for the version of Xlib it is running, some byte-ordering information,
+and two character strings used for authorization.
+If the server does not like the authorization strings
+or the version numbers do not match within the rules,
+or if anything else is wrong, it sends a failure
+response with a reason string.
+</para>
+<para>
+If the information never comes, or comes much too slowly, the connection
+should be broken off.  You must implement the connection timeout.  The
+sample server implements this by keeping a timestamp for each still-connecting
+client and, each time just before it attempts to accept new connections, it
+closes any connection that are too old.
+The connection timeout can be set from the command line.
+</para>
+<para>
+You must implement whatever authorization schemes you want to support.
+The sample server on the distribution tape supports a simple authorization
+scheme.  The only interface seen by DIX is:
+<blockquote><programlisting>
+
+	char *
+	ClientAuthorized(client, proto_n, auth_proto, string_n, auth_string)
+	    ClientPtr client;
+	    unsigned int proto_n;
+	    char *auth_proto;
+	    unsigned int string_n;
+	    char *auth_string;
+</programlisting></blockquote>
+DIX will only call this once per client, once it has read the full initial
+connection data from the client.  If the connection should be
+accepted ClientAuthorized() should return NULL, and otherwise should
+return an error message string.
+</para>
+<para>
+Accepting new connections happens internally to WaitForSomething().
+WaitForSomething() must call the DIX routine NextAvailableClient()
+to create a client object.
+Processing of the initial connection data will be handled by DIX.
+Your OS layer must be able to map from a client
+to whatever information your OS code needs to communicate
+on the given byte stream to the client.
+DIX uses this ClientPtr to refer to
+the client from now on.   The sample server uses the osPrivate field in
+the ClientPtr to store the file descriptor for the socket, the
+input and output buffers, and authorization information.
+</para>
+<para>
+To initialize the methods you choose to allow clients to connect to
+your server, main() calls the routine
+<blockquote><programlisting>
+
+	void CreateWellKnownSockets()
+</programlisting></blockquote>
+This routine is called only once, and not called when the server
+is reset.  To recreate any sockets during server resets, the following
+routine is called from the main loop:
+<blockquote><programlisting>
+
+	void ResetWellKnownSockets()
+</programlisting></blockquote>
+Sample implementations of both of these routines are found in
+Xserver/os/connection.c.
+</para>
+<para>
+For more details, see the section called "Connection Setup" in the X protocol specification.
+</para>
+</section>
+<section>
+  <title>Reading Data from Clients</title>
+<para>
+Requests from the client are read in as a byte stream by the OS layer.
+They may be in the form of several blocks of bytes delivered in sequence; requests may
+be broken up over block boundaries or there may be many requests per block.
+Each request carries with it length information.
+It is the responsibility of the following routine to break it up into request blocks.
+<blockquote><programlisting>
+
+	int ReadRequestFromClient(who)
+		ClientPtr who;
+</programlisting></blockquote>
+</para>
+<para>
+You must write
+the routine ReadRequestFromClient() to get one request from the byte stream
+belonging to client "who."
+You must swap the third and fourth bytes (the second 16-bit word) according to the
+byte-swap rules of
+the protocol to determine the length of the
+request.
+This length is measured in 32-bit words, not in bytes.  Therefore, the
+theoretical maximum request is 256K.
+(However, the maximum length allowed is dependent upon the server's input
+buffer.  This size is sent to the client upon connection.  The maximum
+size is the constant MAX_REQUEST_SIZE in Xserver/include/os.h)
+The rest of the request you return is
+assumed NOT to be correctly swapped for internal
+use, because that is the responsibility of DIX.
+</para>
+<para>
+The 'who' argument is the ClientPtr returned from WaitForSomething.
+The return value indicating status should be set to the (positive) byte count if the read is successful,
+0 if the read was blocked, or a negative error code if an error happened.
+</para>
+<para>
+You must then store a pointer to
+the bytes of the request in the client request buffer field;
+who->requestBuffer.  This can simply be a pointer into your buffer;
+DIX may modify it in place but will not otherwise cause damage.
+Of course, the request must be contiguous; you must
+shuffle it around in your buffers if not.
+</para>
+<para>
+The sample server implementation is in Xserver/os/io.c.
+</para>
+<section><title>Inserting Data for Clients</title>
+<para>
+DIX can insert data into the client stream, and can cause a "replay" of
+the current request.
+<blockquote><programlisting>
+
+	Bool InsertFakeRequest(client, data, count)
+	    ClientPtr client;
+	    char *data;
+	    int count;
+
+	int ResetCurrentRequest(client)
+	    ClientPtr client;
+</programlisting></blockquote>
+</para>
+<para>
+InsertFakeRequest() must insert the specified number of bytes of data
+into the head of the input buffer for the client.  This may be a
+complete request, or it might be a partial request.  For example,
+NextAvailableCient() will insert a partial request in order to read
+the initial connection data sent by the client.  The routine returns FALSE
+if memory could not be allocated.  ResetCurrentRequest()
+should "back up" the input buffer so that the currently executing request
+will be reexecuted.  DIX may have altered some values (e.g. the overall
+request length), so you must recheck to see if you still have a complete
+request.  ResetCurrentRequest() should always cause a yield (isItTimeToYield).
+</para>
+</section>
+</section>
+
+<section>
+  <title>Sending Events, Errors And Replies To Clients</title>
+<para>
+<blockquote><programlisting>
+
+	int WriteToClient(who, n, buf)
+		ClientPtr who;
+		int n;
+		char *buf;
+</programlisting></blockquote>
+WriteToClient should write n bytes starting at buf to the
+ClientPtr "who".
+It returns the number of bytes written, but for simplicity,
+the number returned must be either the same value as the number
+requested, or -1, signaling an error.
+The sample server implementation is in Xserver/os/io.c.
+</para>
+<para>
+<blockquote><programlisting>
+	void SendErrorToClient(client, majorCode, minorCode, resId, errorCode)
+	    ClientPtr client;
+	    unsigned int majorCode;
+	    unsigned int minorCode;
+	    XID resId;
+	    int errorCode;
+</programlisting></blockquote>
+SendErrorToClient can be used to send errors back to clients,
+although in most cases your request function should simply return
+the error code, having set client->errorValue to the appropriate
+error value to return to the client, and DIX will call this
+function with the correct opcodes for you.
+</para>
+<para>
+<blockquote><programlisting>
+
+	void FlushAllOutput()
+
+	void FlushIfCriticalOutputPending()
+
+	void SetCriticalOutputPending()
+</programlisting></blockquote>
+These three routines may be implemented to support buffered or delayed
+writes to clients, but at the very least, the stubs must exist.
+FlushAllOutput() unconditionally flushes all output to clients;
+FlushIfCriticalOutputPending() flushes output only if
+SetCriticalOutputPending() has be called since the last time output
+was flushed.
+The sample server implementation is in Xserver/os/io.c and
+actually ignores requests to flush output on a per-client basis
+if it knows that there
+are requests in that client's input queue.
+</para>
+</section>
+<section>
+  <title>Font Support</title>
+<para>
+In the sample server, fonts are encoded in disk files or fetched from the
+font server.   The two fonts required by the server, <quote>fixed</quote>
+and <quote>cursor</quote> are commonly compiled into the font library.
+For disk fonts, there is one file per font, with a file name like
+"fixed.pcf".  Font server fonts are read over the network using the
+X Font Server Protocol.  The disk directories containing disk fonts and
+the names of the font servers are listed together in the current "font path."
+</para>
+<para>
+In principle, you can put all your fonts in ROM or in RAM in your server.
+You can put them all in one library file on disk.
+You could generate them on the fly from stroke descriptions.  By placing the
+appropriate code in the Font Library, you will automatically export fonts in
+that format both through the X server and the Font server.
+</para>
+<para>
+The code for processing fonts in different formats, as well as handling the
+metadata files for them on disk (such as <filename>fonts.dir</filename>) is
+located in the libXfont library, which is provided as a separately compiled
+module.  These routines are
+shared between the X server and the Font server, so instead of this document
+specifying what you must implement, simply refer to the font
+library interface specification for the details.  All of the interface code to the Font
+library is contained in dix/dixfonts.c
+</para>
+</section>
+<section>
+  <title>Memory Management</title>
+<para>
+Memory management is based on functions in the C runtime library.
+Xalloc(), Xrealloc(), and Xfree() are deprecated aliases for malloc(),
+realloc(), and free(), and you should simply call the C library functions
+directly.  Consult a C runtime library reference
+manual for more details.
+</para>
+<para>
+Treat memory allocation carefully in your implementation.  Memory
+leaks can be very hard to find and are frustrating to a user.  An X
+server could be running for days or weeks without being reset, just
+like a regular terminal.  If you leak a few dozen k per day, that will
+add up and will cause problems for users that leave their workstations
+on.
+</para>
+</section>
+<section>
+  <title>Client Scheduling</title>
+<para>
+The X server
+has the ability to schedule clients much like an operating system would,
+suspending and restarting them without regard for the state of their input
+buffers.  This functionality allows the X server to suspend one client and
+continue processing requests from other clients while waiting for a
+long-term network activity (like loading a font) before continuing with the
+first client.
+<blockquote><programlisting>
+	Bool isItTimeToYield;
+</programlisting></blockquote>
+isItTimeToYield is a global variable you can set
+if you want to tell
+DIX to end the client's "time slice" and start paying attention to the next client.
+After the current request is finished, DIX will move to the next client.
+</para>
+<para>
+In the sample
+server, ReadRequestFromClient() sets isItTimeToYield after
+10 requests packets in a row are read from the same client.
+</para>
+<para>
+This scheduling algorithm can have a serious effect upon performance when two
+clients are drawing into their windows simultaneously.
+If it allows one client to run until its request
+queue is empty by ignoring isItTimeToYield, the client's queue may
+in fact never empty and other clients will be blocked out.
+On the other hand, if it switchs between different clients too quickly,
+performance may suffer due to too much switching between contexts.
+For example, if a graphics processor needs to be set up with drawing modes
+before drawing, and two different clients are drawing with
+different modes into two different windows, you may
+switch your graphics processor modes so often that performance is impacted.
+</para>
+<para>
+See the Strategies document for
+heuristics on setting isItTimeToYield.
+</para>
+<para>
+The following functions provide the ability to suspend request
+processing on a particular client, resuming it at some later time:
+<blockquote><programlisting>
+
+	int IgnoreClient (who)
+		ClientPtr who;
+
+	int AttendClient (who)
+		ClientPtr who;
+</programlisting></blockquote>
+Ignore client is responsible for pretending that the given client doesn't
+exist.  WaitForSomething should not return this client as ready for reading
+and should not return if only this client is ready.  AttendClient undoes
+whatever IgnoreClient did, setting it up for input again.
+</para>
+<para>
+Three functions support "process control" for X clients:
+<blockquote><programlisting>
+
+	Bool ClientSleep (client, function, closure)
+		ClientPtr	client;
+		Bool		(*function)();
+		pointer		closure;
+
+</programlisting></blockquote>
+This suspends the current client (the calling routine is responsible for
+making its way back to Dispatch()).  No more X requests will be processed
+for this client until ClientWakeup is called.
+<blockquote><programlisting>
+
+	Bool ClientSignal (client)
+		ClientPtr	client;
+
+</programlisting></blockquote>
+This function causes a call to the (*function) parameter passed to
+ClientSleep to be queued on the work queue.  This does not automatically
+"wakeup" the client, but the function called is free to do so by calling:
+<blockquote><programlisting>
+
+	ClientWakeup (client)
+		ClientPtr	client;
+
+</programlisting></blockquote>
+This re-enables X request processing for the specified client.
+</para>
+</section>
+<section>
+  <title>Other OS Functions</title>
+<para>
+<blockquote><programlisting>
+	void
+	ErrorF(char *f, ...)
+
+	void
+	FatalError(char *f, ...)
+
+	void
+	Error(str)
+	    char *str;
+</programlisting></blockquote>
+You should write these three routines to provide for diagnostic output
+from the dix and ddx layers, although implementing them to produce no
+output will not affect the correctness of your server.  ErrorF() and
+FatalError() take a printf() type of format specification in the first
+argument and an implementation-dependent number of arguments following
+that.  Normally, the formats passed to ErrorF() and FatalError()
+should be terminated with a newline.  Error() provides an os interface
+for printing out the string passed as an argument followed by a
+meaningful explanation of the last system error.  Normally the string
+does not contain a newline, and it is only called by the ddx layer.
+In the sample implementation, Error() uses the perror() function.
+</para>
+<para>
+After printing the message arguments, FatalError() must be implemented
+such that the server will call AbortDDX() to give the ddx layer
+a chance to reset the hardware, and then
+terminate the server; it must not return.
+</para>
+<para>
+The sample server implementation for these routines
+is in Xserver/os/log.c along with other routines for logging messages.
+</para>
+</section>
+</section>
+
+<section>
+  <title>DDX Layer</title>
+<para>
+This section describes the
+interface between DIX and DDX.
+While there may be an OS-dependent driver interface between DDX
+and the physical device, that interface is left to the DDX
+implementor and is not specified here.
+</para>
+<para>
+The DDX layer does most of its work through procedures that are
+pointed to by different structs.
+As previously described, the behavior of these resources is largely determined by
+these procedure pointers.
+Most of these routines are for graphic display on the screen or support functions thereof.
+The rest are for user input from input devices.
+</para>
+<section>
+  <title>Input</title>
+<para>
+In this document "input" refers to input from the user,
+such as mouse, keyboard, and
+bar code readers.
+X input devices are of several types: keyboard, pointing device, and
+many others.  The core server has support for extension devices as
+described by the X Input Extension document; the interfaces used by
+that extension are described elsewhere.  The core devices are actually
+implemented as two collections of devices, the mouse is a ButtonDevice,
+a ValuatorDevice and a PtrFeedbackDevice while the keyboard is a KeyDevice,
+a FocusDevice and a KbdFeedbackDevice.  Each part implements a portion of
+the functionality of the device.  This abstraction is hidden from view for
+core devices by DIX.
+</para>
+<para>
+You, the DDX programmer, are
+responsible for some of the routines in this section.
+Others are DIX routines that you should call to do the things you need to do in these DDX routines.
+Pay attention to which is which.
+</para>
+<section>
+  <title>Input Device Data Structures</title>
+<para>
+DIX keeps a global directory of devices in a central data structure
+called InputInfo.
+For each device there is a device structure called a DeviceRec.
+DIX can locate any DeviceRec through InputInfo.
+In addition, it has a special pointer to identify the main pointing device
+and a special pointer to identify the main keyboard.
+</para>
+<para>
+The DeviceRec (Xserver/include/input.h) is a device-independent
+structure that contains the state of an input device.
+A DevicePtr is simply a pointer to a DeviceRec.
+</para>
+<para>
+An xEvent describes an event the server reports to a client.
+Defined in Xproto.h, it is a huge struct of union of structs that have fields for
+all kinds of events.
+All of the variants overlap, so that the struct is actually very small in memory.
+</para>
+</section>
+<section>
+  <title>Processing Events</title>
+<para>
+The main DDX input interface is the following routine:
+<blockquote><programlisting>
+
+	void ProcessInputEvents()
+</programlisting></blockquote>
+You must write this routine to deliver input events from the user.
+DIX calls it when input is pending (see next section), and possibly
+even when it is not.
+You should write it to get events from each device and deliver
+the events to DIX.
+To deliver the events to DIX, DDX should call the following
+routine:
+<blockquote><programlisting>
+
+	void DevicePtr->processInputProc(pEvent, device, count)
+		    xEventPtr events;
+		    DeviceIntPtr device;
+		    int count;
+</programlisting></blockquote>
+This is the "input proc" for the device, a DIX procedure.
+DIX will fill in this procedure pointer to one of its own routines by
+the time ProcessInputEvents() is called the first time.
+Call this input proc routine as many times as needed to
+deliver as many events as should be delivered.
+DIX will buffer them up and send them out as needed.  Count is set
+to the number of event records which make up one atomic device event and
+is always 1 for the core devices (see the X Input Extension for descriptions
+of devices which may use count &#x3E; 1).
+</para>
+<para>
+For example, your ProcessInputEvents() routine might check the mouse and the
+keyboard.
+If the keyboard had several keystrokes queued up, it could just call
+the keyboard's processInputProc as many times as needed to flush its internal queue.
+</para>
+<para>
+event is an xEvent struct you pass to the input proc.
+When the input proc returns, it is finished with the event rec, and you can fill
+in new values and call the input proc again with it.
+</para>
+<para>
+You should deliver the events in the same order that they were generated.
+</para>
+<para>
+For keyboard and pointing devices the xEvent variant should be keyButtonPointer.
+Fill in the following fields in the xEvent record:
+<itemizedlist>
+
+<listitem><para>type - is one of the following: KeyPress, KeyRelease, ButtonPress,
+					ButtonRelease, or MotionNotify</para></listitem>
+<listitem><para>detail - for KeyPress or KeyRelease fields, this should be the
+					key number (not the ASCII code); otherwise unused</para></listitem>
+<listitem><para>time - is the time that the event happened (32-bits, in milliseconds, arbitrary origin)</para></listitem>
+<listitem><para>rootX - is the x coordinate of cursor</para></listitem>
+<listitem><para>rootY - is the y coordinate of cursor</para></listitem>
+
+</itemizedlist>
+The rest of the fields are filled in by DIX.
+</para>
+<para>
+The time stamp is maintained by your code in the DDX layer, and it is your responsibility to
+stamp all events correctly.
+</para>
+<para>
+The x and y coordinates of the pointing device and the time must be filled in for all event types
+including keyboard events.
+</para>
+<para>
+The pointing device must report all button press and release events.
+In addition, it should report a MotionNotify event every time it gets called
+if the pointing device has moved since the last notify.
+Intermediate pointing device moves are stored in a special GetMotionEvents buffer,
+because most client programs are not interested in them.
+</para>
+<para>
+There are quite a collection of sample implementations of this routine,
+one for each supported device.
+</para>
+</section>
+<section>
+<title>Telling DIX When Input is Pending</title>
+<para>
+In the server's dispatch loop, DIX checks to see
+if there is any device input pending whenever WaitForSomething() returns.
+If the check says that input is pending, DIX calls the
+DDX routine ProcessInputEvents().
+</para>
+<para>
+This check for pending input must be very quick; a procedure call
+is too slow.
+The code that does the check is a hardwired IF
+statement in DIX code that simply compares the values
+pointed to by two pointers.
+If the values are different, then it assumes that input is pending and
+ProcessInputEvents() is called by DIX.
+</para>
+<para>
+You must pass pointers to DIX to tell it what values to compare.
+The following procedure
+is used to set these pointers:
+<blockquote><programlisting>
+
+	void SetInputCheck(p1, p2)
+		long *p1, *p2;
+</programlisting></blockquote>
+You should call it sometime during initialization to indicate to DIX the
+correct locations to check.
+You should
+pay special attention to the size of what they actually point to,
+because the locations are assumed to be longs.
+</para>
+<para>
+These two pointers are initialized by DIX
+to point to arbitrary values that
+are different.
+In other words, if you forget to call this routine during initialization,
+the worst thing that will happen is that
+ProcessInputEvents will be called when
+there are no events to process.
+</para>
+<para>
+p1 and p2 might
+point at the head and tail of some shared
+memory queue.
+Another use would be to have one point at a constant 0, with the
+other pointing at some mask containing 1s
+for each input device that has
+something pending.
+</para>
+<para>
+The DDX layer of the sample server calls SetInputCheck()
+once when the
+server's private internal queue is initialized.
+It passes pointers to the queue's head and tail.  See Xserver/mi/mieq.c.
+</para>
+<para>
+<blockquote><programlisting>
+	int TimeSinceLastInputEvent()
+</programlisting></blockquote>
+DDX must time stamp all hardware input
+events.  But DIX sometimes needs to know the
+time and the OS layer needs to know the time since the last hardware
+input event in
+order for the screen saver to work.   TimeSinceLastInputEvent() returns
+the this time in milliseconds.
+</para>
+</section>
+<section>
+  <title>Controlling Input Devices</title>
+<para>
+You must write four routines to do various device-specific
+things with the keyboard and pointing device.
+They can have any name you wish because
+you pass the procedure pointers to DIX routines.
+</para>
+<para>
+<blockquote><programlisting>
+
+	int pInternalDevice->valuator->GetMotionProc(pdevice, coords, start, stop, pScreen)
+		DeviceIntPtr pdevice;
+		xTimecoord * coords;
+		unsigned long start;
+		unsigned long stop;
+		ScreenPtr pScreen;
+</programlisting></blockquote>
+You write this DDX routine to fill in coords with all the motion
+events that have times (32-bit count of milliseconds) between time
+start and time stop.  It should return the number of motion events
+returned.  If there is no motion events support, this routine should
+do nothing and return zero.  The maximum number of coords to return is
+set in InitPointerDeviceStruct(), below.
+</para>
+<para>
+When the user drags the pointing device, the cursor position
+theoretically sweeps through an infinite number of points.  Normally,
+a client that is concerned with points other than the starting and
+ending points will receive a pointer-move event only as often as the
+server generates them. (Move events do not queue up; each new one
+replaces the last in the queue.)  A server, if desired, can implement
+a scheme to save these intermediate events in a motion buffer.  A
+client application, like a paint program, may then request that these
+events be delivered to it through the GetMotionProc routine.
+</para>
+<para>
+<blockquote><programlisting>
+
+	void pInternalDevice->bell->BellProc(percent, pDevice, ctrl, unknown)
+		int percent;
+		DeviceIntPtr pDevice;
+		pointer ctrl;
+		int class;
+</programlisting></blockquote>
+You need to write this routine to ring the bell on the keyboard.
+loud is a number from 0 to 100, with 100 being the loudest.
+Class is either BellFeedbackClass or KbdFeedbackClass (from XI.h).
+</para>
+<para>
+<blockquote><programlisting>
+
+	void pInternalDevice->somedevice->CtrlProc(device, ctrl)
+		DevicePtr device;
+		SomethingCtrl *ctrl;
+
+</programlisting></blockquote>
+You write two versions of this procedure, one for the keyboard and one for the pointing device.
+DIX calls it to inform DDX when a client has requested changes in the current
+settings for the particular device.
+For a keyboard, this might be the repeat threshold and rate.
+For a pointing device, this might be a scaling factor (coarse or fine) for position reporting.
+See input.h for the ctrl structures.
+</para>
+</section>
+<section>
+  <title>Input Initialization</title>
+<para>
+Input initialization is a bit complicated.
+It all starts with InitInput(), a routine that you write to call
+AddInputDevice() twice
+(once for pointing device and once for keyboard.)
+</para>
+<para>
+When you Add the devices, a routine you supply for each device
+gets called to initialize them.
+Your individual initialize routines must call InitKeyboardDeviceStruct()
+or InitPointerDeviceStruct(), depending upon which it is.
+In other words, you indicate twice that the keyboard is the keyboard and
+the pointer is the pointer.
+</para>
+<para>
+<blockquote><programlisting>
+
+	void InitInput(argc, argv)
+	    int argc;
+	    char **argv;
+</programlisting></blockquote>
+InitInput is a DDX routine you must write to initialize the
+input subsystem in DDX.
+It must call AddInputDevice() for each device that might generate events.
+</para>
+<para>
+<blockquote><programlisting>
+
+	DevicePtr AddInputDevice(deviceProc, autoStart)
+		DeviceProc deviceProc;
+		Bool autoStart;
+</programlisting></blockquote>
+AddInputDevice is a DIX routine you call to create a device object.
+deviceProc is a DDX routine that is called by DIX to do various operations.
+AutoStart should be TRUE for devices that need to be turned on at
+initialization time with a special call, as opposed to waiting for some
+client application to
+turn them on.
+This routine returns NULL if sufficient memory cannot be allocated to
+install the device.
+</para>
+<para>
+Note also that except for the main keyboard and pointing device,
+an extension is needed to provide for a client interface to a device.
+</para>
+<para>
+The following DIX
+procedures return the specified DevicePtr. They may or may not be useful
+to DDX implementors.
+</para>
+<para>
+<blockquote><programlisting>
+
+	DevicePtr LookupKeyboardDevice()
+</programlisting></blockquote>
+LookupKeyboardDevice returns pointer for current main keyboard device.
+</para>
+<para>
+<blockquote><programlisting>
+
+	DevicePtr LookupPointerDevice()
+</programlisting></blockquote>
+LookupPointerDevice returns pointer for current main pointing device.
+</para>
+<para>
+A DeviceProc (the kind passed to AddInputDevice()) in the following form:
+<blockquote><programlisting>
+
+	Bool pInternalDevice->DeviceProc(device, action);
+		DeviceIntPtr device;
+		int action;
+</programlisting></blockquote>
+You must write a DeviceProc for each device.
+device points to the device record.
+action tells what action to take;
+it will be one of  these defined constants  (defined in input.h):
+<itemizedlist>
+<listitem><para>
+DEVICE_INIT -
+At DEVICE_INIT time, the device should initialize itself by calling
+InitPointerDeviceStruct(), InitKeyboardDeviceStruct(), or a similar
+routine (see below)
+and "opening" the device if necessary.
+If you return a non-zero (i.e., != Success) value from the DEVICE_INIT
+call, that device will be considered unavailable. If either the main keyboard
+or main pointing device cannot be initialized, the DIX code will refuse
+to continue booting up.</para></listitem>
+<listitem><para>
+DEVICE_ON - If the DeviceProc is called with DEVICE_ON, then it is
+allowed to start
+putting events into the client stream by calling through the ProcessInputProc
+in the device.</para></listitem>
+<listitem><para>
+DEVICE_OFF - If the DeviceProc is called with DEVICE_OFF, no further
+events from that
+device should be given to the DIX layer.
+The device will appear to be dead to the user.</para></listitem>
+<listitem><para>
+DEVICE_CLOSE - At DEVICE_CLOSE (terminate or reset) time, the device should
+be totally closed down.</para></listitem>
+</itemizedlist>
+</para>
+<para>
+<blockquote><programlisting>
+
+	void InitPointerDeviceStruct(device, map, mapLength,
+			GetMotionEvents, ControlProc, numMotionEvents)
+		DevicePtr device;
+		CARD8 *map;
+		int mapLength;
+		ValuatorMotionProcPtr ControlProc;
+		PtrCtrlProcPtr GetMotionEvents;
+		int numMotionEvents;
+</programlisting></blockquote>
+InitPointerDeviceStruct is a DIX routine you call at DEVICE_INIT time to declare
+some operating routines and data structures for a pointing device.
+map and mapLength are as described in the X Window
+System protocol specification.
+ControlProc and GetMotionEvents are DDX routines, see above.
+</para>
+<para>
+numMotionEvents is for the motion-buffer-size for the GetMotionEvents
+request.
+A typical length for a motion buffer would be 100 events.
+A server that does not implement this capability should set
+numMotionEvents to zero.
+</para>
+<para>
+<blockquote><programlisting>
+
+	void InitKeyboardDeviceStruct(device, pKeySyms, pModifiers, Bell, ControlProc)
+		DevicePtr device;
+		KeySymsPtr pKeySyms;
+		CARD8 *pModifiers;
+		BellProcPtr Bell;
+		KbdCtrlProcPtr ControlProc;
+
+</programlisting></blockquote>
+You call this DIX routine when a keyboard device is initialized and
+its device procedure is called with
+DEVICE_INIT.
+The formats of the keysyms and modifier maps are defined in
+Xserver/include/input.h.
+They describe the layout of keys on the keyboards, and the glyphs
+associated with them.  ( See the next section for information on
+setting up the modifier map and the keysym map.)
+ControlProc and Bell are DDX routines, see above.
+</para>
+</section>
+<section>
+  <title>Keyboard Mapping and Keycodes</title>
+<para>
+When you send a keyboard event, you send a report that a given key has
+either been pressed or has been released.  There must be a keycode for
+each key that identifies the key; the keycode-to-key mapping can be
+any mapping you desire, because you specify the mapping in a table you
+set up for DIX.  However, you are restricted by the protocol
+specification to keycode values in the range 8 to 255 inclusive.
+</para>
+<para>
+The keycode mapping information that you set up consists of the following:
+<itemizedlist>
+<listitem><para>
+A minimum and maximum keycode number</para></listitem>
+<listitem><para>
+An array of sets of keysyms for each key, that is of length
+maxkeycode - minkeycode + 1.
+Each element of this array is a list of codes for symbols that are on that key.
+There is no limit to the number of symbols that can be on a key.</para></listitem>
+</itemizedlist>
+Once the map is set up, DIX keeps and
+maintains the client's changes to it.
+</para>
+<para>
+The X protocol defines standard names to indicate the symbol(s)
+printed on each keycap. (See X11/keysym.h)
+</para>
+<para>
+Legal modifier keys must generate both up and down transitions.  When
+a client tries to change a modifier key (for instance, to make "A" the
+"Control" key), DIX calls the following routine, which should return
+TRUE if the key can be used as a modifier on the given device:
+<blockquote><programlisting>
+
+	Bool LegalModifier(key, pDev)
+	    unsigned int key;
+	    DevicePtr pDev;
+</programlisting></blockquote>
+</para>
+</section>
+</section>
+<section>
+<title>Screens</title>
+<para>
+Different computer graphics
+displays have different capabilities.
+Some are simple monochrome
+frame buffers that are just lying
+there in memory, waiting to be written into.
+Others are color displays with many bits per pixel using some color lookup table.
+Still others have high-speed graphic processors that prefer to do all of the work
+themselves,
+including maintaining their own high-level, graphic data structures.
+</para>
+<section>
+  <title>Screen Hardware Requirements</title>
+<para>
+The only requirement on screens is that you be able to both read
+and write locations in the frame buffer.
+All screens must have a depth of 32 or less (unless you use
+an X extension to allow a greater depth).
+All screens must fit into one of the classes listed in the section
+in this document on Visuals and Depths.
+</para>
+<para>
+X uses the pixel as its fundamental unit of distance on the screen.
+Therefore, most programs will measure everything in pixels.</para>
+<para>
+The sample server assumes square pixels.
+Serious WYSIWYG (what you see is what you get) applications for
+publishing and drawing programs will adjust for
+different screen resolutions automatically.
+Considerable work
+is involved in compensating for non-square pixels (a bit in the DDX
+code for the sample server but quite a bit in the client applications).</para>
+</section>
+<section>
+  <title>Data Structures</title>
+<para>
+X supports multiple screens that are connected to the same
+server.  Therefore, all the per-screen information is bundled into one data
+structure of attributes and procedures, which is the ScreenRec (see
+Xserver/include/scrnintstr.h).
+The procedure entry points in a ScreenRec operate on
+regions, colormaps, cursors, and fonts, because these resources
+can differ in format from one screen to another.</para>
+<para>
+Windows are areas on the screen that can be drawn into by graphic
+routines.  "Pixmaps" are off-screen graphic areas that can be drawn
+into.  They are both considered drawables and are described in the
+section on Drawables.  All graphic operations work on drawables, and
+operations are available to copy patches from one drawable to another.</para>
+<para>
+The pixel image data in all drawables is in a format that is private
+to DDX.  In fact, each instance of a drawable is associated with a
+given screen.  Presumably, the pixel image data for pixmaps is chosen
+to be conveniently understood by the hardware.  All screens in a
+single server must be able to handle all pixmaps depths declared in
+the connection setup information.</para>
+<para>
+Pixmap images are transferred to the server in one of two ways:
+XYPixmap or ZPimap.  XYPixmaps are a series of bitmaps, one for each
+bit plane of the image, using the bitmap padding rules from the
+connection setup.  ZPixmaps are a series of bits, nibbles, bytes or
+words, one for each pixel, using the format rules (padding and so on)
+for the appropriate depth.</para>
+<para>
+All screens in a given server must agree on a set of pixmap image
+formats (PixmapFormat) to support (depth, number of bits per pixel,
+etc.).</para>
+<para>
+There is no color interpretation of bits in the pixmap.  Pixmaps
+do not contain pixel values.  The interpretation is made only when
+the bits are transferred onto the screen.</para>
+<para>
+The screenInfo structure (in scrnintstr.h) is a global data structure
+that has a pointer to an array of ScreenRecs, one for each screen on
+the server.  (These constitute the one and only description of each
+screen in the server.)  Each screen has an identifying index (0, 1, 2, ...).
+In addition, the screenInfo struct contains global server-wide
+details, such as the bit- and byte- order in all bit images, and the
+list of pixmap image formats that are supported.  The X protocol
+insists that these must be the same for all screens on the server.</para>
+</section>
+<section>
+  <title>Output Initialization</title>
+<para>
+<blockquote><programlisting>
+
+	InitOutput(pScreenInfo, argc, argv)
+		ScreenInfo *pScreenInfo;
+		int argc;
+		char **argv;
+</programlisting></blockquote>
+Upon initialization, your DDX routine InitOutput() is called by DIX.
+It is passed a pointer to screenInfo to initialize.  It is also passed
+the argc and argv from main() for your server for the command-line
+arguments.  These arguments may indicate what or how many screen
+device(s) to use or in what way to use them.  For instance, your
+server command line may allow a "-D" flag followed by the name of the
+screen device to use.</para>
+<para>
+Your InitOutput() routine should initialize each screen you wish to
+use by calling AddScreen(), and then it should initialize the pixmap
+formats that you support by storing values directly into the
+screenInfo data structure.  You should also set certain
+implementation-dependent numbers and procedures in your screenInfo,
+which determines the pixmap and scanline padding rules for all screens
+in the server.</para>
+<para>
+<blockquote><programlisting>
+
+	int AddScreen(scrInitProc, argc, argv)
+		Bool (*scrInitProc)();
+		int argc;
+		char **argv;
+</programlisting></blockquote>
+You should call AddScreen(), a DIX procedure, in InitOutput() once for
+each screen to add it to the screenInfo database.  The first argument
+is an initialization procedure for the screen that you supply.  The
+second and third are the argc and argv from main().  It returns the
+screen number of the screen installed, or -1 if there is either
+insufficient memory to add the screen, or (*scrInitProc) returned
+FALSE.</para>
+<para>
+The scrInitProc should be of the following form:
+<blockquote><programlisting>
+
+	Bool scrInitProc(iScreen, pScreen, argc, argv)
+		int iScreen;
+		ScreenPtr pScreen;
+		int argc;
+		char **argv;
+</programlisting></blockquote>
+iScreen is the index for this screen; 0 for the first one initialized,
+1 for the second, etc.  pScreen is the pointer to the screen's new
+ScreenRec.  argc and argv are as before.  Your screen initialize
+procedure should return TRUE upon success or FALSE if the screen
+cannot be initialized (for instance, if the screen hardware does not
+exist on this machine).</para>
+<para>
+This procedure must determine what actual device it is supposed to initialize.
+If you have a different procedure for each screen, then it is no problem.
+If you have the same procedure for multiple screens, it may have trouble
+figuring out which screen to initialize each time around, especially if
+InitOutput() does not initialize all of the screens.
+It is probably easiest to have one procedure for each screen.</para>
+<para>
+The initialization procedure should fill in all the screen procedures
+for that screen (windowing functions, region functions, etc.) and certain
+screen attributes for that screen.</para>
+</section>
+<section>
+  <title>Region Routines in the ScreenRec</title>
+<para>
+A region is a dynamically allocated data structure that describes an
+irregularly shaped piece of real estate in XY pixel space.  You can
+think of it as a set of pixels on the screen to be operated upon with
+set operations such as AND and OR.</para>
+<para>
+A region is frequently implemented as a list of rectangles or bitmaps
+that enclose the selected pixels.  Region operators control the
+"clipping policy," or the operations that work on regions.  (The
+sample server uses YX-banded rectangles.  Unless you have something
+already implemented for your graphics system, you should keep that
+implementation.)  The procedure pointers to the region operators are
+located in the ScreenRec data structure.  The definition of a region
+can be found in the file Xserver/include/regionstr.h.  The region code
+is found in Xserver/mi/miregion.c.  DDX implementations using other
+region formats will need to supply different versions of the region
+operators.</para>
+<para>
+Since the list of rectangles is unbounded in size, part of the region
+data structure is usually a large, dynamically allocated chunk of
+memory.  As your region operators calculate logical combinations of
+regions, these blocks may need to be reallocated by your region
+software.  For instance, in the sample server, a RegionRec has some
+header information and a pointer to a dynamically allocated rectangle
+list.  Periodically, the rectangle list needs to be expanded with
+Xrealloc(), whereupon the new pointer is remembered in the RegionRec.</para>
+<para>
+Most of the region operations come in two forms: a function pointer in
+the Screen structure, and a macro.  The server can be compiled so that
+the macros make direct calls to the appropriate functions (instead of
+indirecting through a screen function pointer), or it can be compiled
+so that the macros are identical to the function pointer forms.
+Making direct calls is faster on many architectures.</para>
+<para>
+<blockquote><programlisting>
+
+	RegionPtr pScreen->RegionCreate( rect, size)
+		BoxPtr rect;
+		int size;
+
+	macro: RegionPtr RegionCreate(rect, size)
+
+</programlisting></blockquote>
+RegionCreate creates a region that describes ONE rectangle.  The
+caller can avoid unnecessary reallocation and copying by declaring the
+probable maximum number of rectangles that this region will need to
+describe itself.  Your region routines, though, cannot fail just
+because the region grows beyond this size.  The caller of this routine
+can pass almost anything as the size; the value is merely a good guess
+as to the maximum size until it is proven wrong by subsequent use.
+Your region procedures are then on their own in estimating how big the
+region will get.  Your implementation might ignore size, if
+applicable.</para>
+<para>
+<blockquote><programlisting>
+
+	void pScreen->RegionInit (pRegion, rect, size)
+		RegionPtr	pRegion;
+		BoxPtr		rect;
+		int		size;
+
+	macro: RegionInit(pRegion, rect, size)
+
+</programlisting></blockquote>
+Given an existing raw region structure (such as an local variable), this
+routine fills in the appropriate fields to make this region as usable as
+one returned from RegionCreate.  This avoids the additional dynamic memory
+allocation overhead for the region structure itself.
+</para>
+<para>
+<blockquote><programlisting>
+
+	Bool pScreen->RegionCopy(dstrgn, srcrgn)
+		RegionPtr dstrgn, srcrgn;
+
+	macro: Bool RegionCopy(dstrgn, srcrgn)
+
+</programlisting></blockquote>
+RegionCopy copies the description of one region, srcrgn, to another
+already-created region,
+dstrgn; returning TRUE if the copy succeeded, and FALSE otherwise.</para>
+<para>
+<blockquote><programlisting>
+
+	void pScreen->RegionDestroy( pRegion)
+		RegionPtr pRegion;
+
+	macro: RegionDestroy(pRegion)
+
+</programlisting></blockquote>
+RegionDestroy destroys a region and frees all allocated memory.</para>
+<para>
+<blockquote><programlisting>
+
+	void pScreen->RegionUninit (pRegion)
+		RegionPtr pRegion;
+
+	macro: RegionUninit(pRegion)
+
+</programlisting></blockquote>
+Frees everything except the region structure itself, useful when the
+region was originally passed to RegionInit instead of received from
+RegionCreate.  When this call returns, pRegion must not be reused until
+it has been RegionInit'ed again.</para>
+<para>
+<blockquote><programlisting>
+
+	Bool pScreen->Intersect(newReg, reg1, reg2)
+		RegionPtr newReg, reg1, reg2;
+
+	macro: Bool RegionIntersect(newReg, reg1, reg2)
+
+	Bool  pScreen->Union(newReg, reg1, reg2)
+		RegionPtr newReg, reg1, reg2;
+
+	macro: Bool RegionUnion(newReg, reg1, reg2)
+
+	Bool  pScreen->Subtract(newReg, regMinuend, regSubtrahend)
+		RegionPtr newReg, regMinuend, regSubtrahend;
+
+	macro: Bool RegionUnion(newReg, regMinuend, regSubtrahend)
+
+	Bool pScreen->Inverse(newReg, pReg,  pBox)
+		RegionPtr newReg, pReg;
+		BoxPtr pBox;
+
+	macro: Bool RegionInverse(newReg, pReg,  pBox)
+
+</programlisting></blockquote>
+The above four calls all do basic logical operations on regions.  They
+set the new region (which already exists) to describe the logical
+intersection, union, set difference, or inverse of the region(s) that
+were passed in.  Your routines must be able to handle a situation
+where the newReg is the same region as one of the other region
+arguments.</para>
+<para>
+The subtract function removes the Subtrahend from the Minuend and
+puts the result in newReg.</para>
+<para>
+The inverse function returns a region that is the pBox minus the
+region passed in.  (A true "inverse" would make a region that extends
+to infinity in all directions but has holes in the middle.)  It is
+undefined for situations where the region extends beyond the box.</para>
+<para>
+Each routine must return the value TRUE for success.</para>
+<para>
+<blockquote><programlisting>
+
+	void pScreen->RegionReset(pRegion, pBox)
+		RegionPtr pRegion;
+		BoxPtr pBox;
+
+	macro: RegionReset(pRegion, pBox)
+
+</programlisting></blockquote>
+RegionReset sets the region to describe
+one rectangle and reallocates it to a size of one rectangle, if applicable.</para>
+<para>
+<blockquote><programlisting>
+
+	void  pScreen->TranslateRegion(pRegion, x, y)
+		RegionPtr pRegion;
+		int x, y;
+
+	macro: RegionTranslate(pRegion, x, y)
+
+</programlisting></blockquote>
+TranslateRegion simply moves a region +x in the x direction and +y in the y
+direction.</para>
+<para>
+<blockquote><programlisting>
+
+	int  pScreen->RectIn(pRegion, pBox)
+		RegionPtr pRegion;
+		BoxPtr pBox;
+
+	macro: int RegionContainsRect(pRegion, pBox)
+
+</programlisting></blockquote>
+RectIn returns one of the defined constants rgnIN, rgnOUT, or rgnPART,
+depending upon whether the box is entirely inside the region, entirely
+outside of the region, or partly in and partly out of the region.
+These constants are defined in Xserver/include/region.h.</para>
+<para>
+<blockquote><programlisting>
+
+	Bool pScreen->PointInRegion(pRegion, x, y, pBox)
+		RegionPtr pRegion;
+		int x, y;
+		BoxPtr pBox;
+
+	macro: Bool RegionContainsPoint(pRegion, x, y, pBox)
+
+</programlisting></blockquote>
+PointInRegion returns true if the point x, y is in the region.  In
+addition, it fills the rectangle pBox with coordinates of a rectangle
+that is entirely inside of pRegion and encloses the point.  In the mi
+implementation, it is the largest such rectangle.  (Due to the sample
+server implementation, this comes cheaply.)</para>
+<para>
+This routine used by DIX when tracking the pointing device and
+deciding whether to report mouse events or change the cursor.  For
+instance, DIX needs to change the cursor when it moves from one window
+to another.  Due to overlapping windows, the shape to check may be
+irregular.  A PointInRegion() call for every pointing device movement
+may be too expensive.  The pBox is a kind of wake-up box; DIX need not
+call PointInRegion() again until the cursor wanders outside of the
+returned box.</para>
+<para>
+<blockquote><programlisting>
+
+	Bool pScreen->RegionNotEmpty(pRegion)
+		RegionPtr pRegion;
+
+	macro: Bool RegionNotEmpty(pRegion)
+
+</programlisting></blockquote>
+RegionNotEmpty is a boolean function that returns
+true or false depending upon whether the region encloses any pixels.</para>
+<para>
+<blockquote><programlisting>
+
+	void pScreen->RegionEmpty(pRegion)
+		RegionPtr pRegion;
+
+	macro: RegionEmpty(pRegion)
+
+</programlisting></blockquote>
+RegionEmpty sets the region to be empty.</para>
+<para>
+<blockquote><programlisting>
+
+	BoxPtr pScreen->RegionExtents(pRegion)
+		RegionPtr pRegion;
+
+	macro: RegionExtents(pRegion)
+
+</programlisting></blockquote>
+RegionExtents returns a rectangle that is the smallest
+possible superset of the entire region.
+The caller will not modify this rectangle, so it can be the one
+in your region struct.</para>
+<para>
+<blockquote><programlisting>
+
+	Bool pScreen->RegionAppend (pDstRgn, pRegion)
+		RegionPtr pDstRgn;
+		RegionPtr pRegion;
+
+	macro: Bool RegionAppend(pDstRgn, pRegion)
+
+	Bool pScreen->RegionValidate (pRegion, pOverlap)
+		RegionPtr pRegion;
+		Bool *pOverlap;
+
+	macro: Bool RegionValidate(pRegion, pOverlap)
+
+</programlisting></blockquote>
+These functions provide an optimization for clip list generation and
+must be used in conjunction.  The combined effect is to produce the
+union of a collection of regions, by using RegionAppend several times,
+and finally calling RegionValidate which takes the intermediate
+representation (which needn't be a valid region) and produces the
+desired union.  pOverlap is set to TRUE if any of the original
+regions overlap; FALSE otherwise.</para>
+<para>
+<blockquote><programlisting>
+
+	RegionPtr pScreen->BitmapToRegion (pPixmap)
+		PixmapPtr pPixmap;
+
+	macro: RegionPtr BitmapToRegion(pScreen, pPixmap)
+
+</programlisting></blockquote>
+Given a depth-1 pixmap, this routine must create a valid region which
+includes all the areas of the pixmap filled with 1's and excludes the
+areas filled with 0's.  This routine returns NULL if out of memory.</para>
+<para>
+<blockquote><programlisting>
+
+	RegionPtr pScreen->RectsToRegion (nrects, pRects, ordering)
+		int nrects;
+		xRectangle *pRects;
+		int ordering;
+
+	macro: RegionPtr RegionFromRects(nrects, pRects, ordering)
+
+</programlisting></blockquote>
+Given a client-supplied list of rectangles, produces a region which includes
+the union of all the rectangles.  Ordering may be used as a hint which
+describes how the rectangles are sorted.  As the hint is provided by a
+client, it must not be required to be correct, but the results when it is
+not correct are not defined (core dump is not an option here).</para>
+<para>
+<blockquote><programlisting>
+
+	void pScreen->SendGraphicsExpose(client,pRegion,drawable,major,minor)
+		ClientPtr client;
+		RegionPtr pRegion;
+		XID drawable;
+		int major;
+		int minor;
+
+</programlisting></blockquote>
+SendGraphicsExpose dispatches a list of GraphicsExposure events which
+span the region to the specified client.  If the region is empty, or
+a NULL pointer, a NoExpose event is sent instead.</para>
+</section>
+<section>
+  <title>Cursor Routines for a Screen</title>
+<para>
+A cursor is the visual form tied to the pointing device.  The default
+cursor is an "X" shape, but the cursor can have any shape.  When a
+client creates a window, it declares what shape the cursor will be
+when it strays into that window on the screen.</para>
+<para>
+For each possible shape the cursor assumes, there is a CursorRec data
+structure.  This data structure contains a pointer to a CursorBits
+data structure which contains a bitmap for the image of the cursor and
+a bitmap for a mask behind the cursor, in addition, the CursorRec data
+structure contains foreground and background colors for the cursor.
+The CursorBits data structure is shared among multiple CursorRec
+structures which use the same font and glyph to describe both source
+and mask.  The cursor image is applied to the screen by applying the
+mask first, clearing 1 bits in its form to the background color, and
+then overwriting on the source image, in the foreground color.  (One
+bits of the source image that fall on top of zero bits of the mask
+image are undefined.)  This way, a cursor can have transparent parts,
+and opaque parts in two colors.  X allows any cursor size, but some
+hardware cursor schemes allow a maximum of N pixels by M pixels.
+Therefore, you are allowed to transform the cursor to a smaller size,
+but be sure to include the hot-spot.</para>
+<para>
+CursorBits in Xserver/include/cursorstr.h is a device-independent
+structure containing a device-independent representation of the bits
+for the source and mask.  (This is possible because the bitmap
+representation is the same for all screens.)</para>
+<para>
+When a cursor is created, it is "realized" for each screen.  At
+realization time, each screen has the chance to convert the bits into
+some other representation that may be more convenient (for instance,
+putting the cursor into off-screen memory) and set up its
+device-private area in either the CursorRec data structure or
+CursorBits data structure as appropriate to possibly point to whatever
+data structures are needed.  It is more memory-conservative to share
+realizations by using the CursorBits private field, but this makes the
+assumption that the realization is independent of the colors used
+(which is typically true).  For instance, the following are the device
+private entries for a particular screen and cursor:
+<blockquote><programlisting>
+
+	pCursor->devPriv[pScreen->myNum]
+	pCursor->bits->devPriv[pScreen->myNum]
+
+</programlisting></blockquote>
+This is done because the change from one cursor shape to another must
+be fast and responsive; the cursor image should be able to flutter as
+fast as the user moves it across the screen.</para>
+<para>
+You must implement the following routines for your hardware:
+<blockquote><programlisting>
+
+	Bool pScreen->RealizeCursor( pScr, pCurs)
+		ScreenPtr pScr;
+		CursorPtr pCurs;
+
+	Bool pScreen->UnrealizeCursor( pScr, pCurs)
+		ScreenPtr pScr;
+		CursorPtr pCurs;
+
+</programlisting></blockquote>
+</para>
+<para>
+RealizeCursor and UnrealizeCursor should realize (allocate and
+calculate all data needed) and unrealize (free the dynamically
+allocated data) a given cursor when DIX needs them.  They are called
+whenever a device-independent cursor is created or destroyed.  The
+source and mask bits pointed to by fields in pCurs are undefined for
+bits beyond the right edge of the cursor.  This is so because the bits
+are in Bitmap format, which may have pad bits on the right edge.  You
+should inhibit UnrealizeCursor() if the cursor is currently in use;
+this happens when the system is reset.</para>
+<para>
+<blockquote><programlisting>
+
+	Bool pScreen->DisplayCursor( pScr, pCurs)
+		ScreenPtr pScr;
+		CursorPtr pCurs;
+
+</programlisting></blockquote>
+DisplayCursor should change the cursor on the given screen to the one
+passed in.  It is called by DIX when the user moves the pointing
+device into a different window with a different cursor.  The hotspot
+in the cursor should be aligned with the current cursor position.</para>
+<para>
+<blockquote><programlisting>
+
+	void pScreen->RecolorCursor( pScr, pCurs, displayed)
+		ScreenPtr pScr;
+		CursorPtr pCurs;
+		Bool displayed;
+</programlisting></blockquote>
+RecolorCursor notifies DDX that the colors in pCurs have changed and
+indicates whether this is the cursor currently being displayed.  If it
+is, the cursor hardware state may have to be updated.  Whether
+displayed or not, state created at RealizeCursor time may have to be
+updated.  A generic version, miRecolorCursor, may be used that
+does an unrealize, a realize, and possibly a display (in micursor.c);
+however this constrains UnrealizeCursor and RealizeCursor to always return
+TRUE as no error indication is returned here.</para>
+<para>
+<blockquote><programlisting>
+
+	void pScreen->ConstrainCursor( pScr, pBox)
+		ScreenPtr pScr;
+		BoxPtr pBox;
+
+</programlisting></blockquote>
+ConstrainCursor should cause the cursor to restrict its motion to the
+rectangle pBox.  DIX code is capable of enforcing this constraint by
+forcefully moving the cursor if it strays out of the rectangle, but
+ConstrainCursor offers a way to send a hint to the driver or hardware
+if such support is available.  This can prevent the cursor from
+wandering out of the box, then jumping back, as DIX forces it back.</para>
+<para>
+<blockquote><programlisting>
+
+	void pScreen->PointerNonInterestBox( pScr, pBox)
+		ScreenPtr pScr;
+		BoxPtr pBox;
+
+</programlisting></blockquote>
+PointerNonInterestBox is DIX's way of telling the pointing device code
+not to report motion events while the cursor is inside a given
+rectangle on the given screen.  It is optional and, if not
+implemented, it should do nothing.  This routine is called only when
+the client has declared that it is not interested in motion events in
+a given window.  The rectangle you get may be a subset of that window.
+It saves DIX code the time required to discard uninteresting mouse
+motion events.  This is only a hint, which may speed performance.
+Nothing in DIX currently calls PointerNonInterestBox.</para>
+<para>
+<blockquote><programlisting>
+
+	void pScreen->CursorLimits( pScr, pCurs, pHotBox, pTopLeftBox)
+		ScreenPtr pScr;
+		CursorPtr pCurs;
+		BoxPtr pHotBox;
+		BoxPtr pTopLeftBox;	/* return value */
+
+</programlisting></blockquote>
+CursorLimits should calculate the box that the cursor hot spot is
+physically capable of moving within, as a function of the screen pScr,
+the device-independent cursor pCurs, and a box that DIX hypothetically
+would want the hot spot confined within, pHotBox.  This routine is for
+informing DIX only; it alters no state within DDX.</para>
+<para>
+<blockquote><programlisting>
+
+	Bool pScreen->SetCursorPosition( pScr, newx, newy, generateEvent)
+		ScreenPtr pScr;
+		int newx;
+		int newy;
+		Bool generateEvent;
+
+</programlisting></blockquote>
+SetCursorPosition should artificially move the cursor as though the
+user had jerked the pointing device very quickly.  This is called in
+response to the WarpPointer request from the client, and at other
+times.  If generateEvent is True, the device should decide whether or
+not to call ProcessInputEvents() and then it must call
+DevicePtr->processInputProc.  Its effects are, of course, limited in
+value for absolute pointing devices such as a tablet.</para>
+<para>
+<blockquote><programlisting>
+
+	void NewCurrentScreen(newScreen, x, y)
+	    ScreenPtr newScreen;
+	    int x,y;
+
+</programlisting></blockquote>
+If your ddx provides some mechanism for the user to magically move the
+pointer between multiple screens, you need to inform DIX when this
+occurs.  You should call NewCurrentScreen to accomplish this, specifying
+the new screen and the new x and y coordinates of the pointer on that screen.</para>
+</section>
+<section>
+  <title>Visuals, Depths and Pixmap Formats for Screens</title>
+<para>
+The "depth" of a image is the number of bits that are used per pixel to display it.</para>
+<para>
+The "bits per pixel" of a pixmap image that is sent over the client
+byte stream is a number that is either 4, 8, 16, 24 or 32.  It is the
+number of bits used per pixel in Z format.  For instance, a pixmap
+image that has a depth of six is best sent in Z format as 8 bits per
+pixel.</para>
+<para>
+A "pixmap image format" or a "pixmap format" is a description of the
+format of a pixmap image as it is sent over the byte stream.  For each
+depth available on a server, there is one and only one pixmap format.
+This pixmap image format gives the bits per pixel and the scanline
+padding unit. (For instance, are pixel rows padded to bytes, 16-bit
+words, or 32-bit words?)</para>
+<para>
+For each screen, you must decide upon what depth(s) it supports.  You
+should only count the number of bits used for the actual image.  Some
+displays store additional bits to indicate what window this pixel is
+in, how close this object is to a viewer, transparency, and other
+data; do not count these bits.</para>
+<para>
+A "display class" tells whether the display is monochrome or color,
+whether there is a lookup table, and how the lookup table works.</para>
+<para>
+A "visual" is a combination of depth, display class, and a description
+of how the pixel values result in a color on the screen.  Each visual
+has a set of masks and offsets that are used to separate a pixel value
+into its red, green, and blue components and a count of the number of
+colormap entries.  Some of these fields are only meaningful when the
+class dictates so.  Each visual also has a screen ID telling which
+screen it is usable on.  Note that the depth does not imply the number
+of map_entries; for instance, a display can have 8 bits per pixel but
+only 254 colormap entries for use by applications (the other two being
+reserved by hardware for the cursor).</para>
+<para>
+Each visual is identified by a 32-bit visual ID which the client uses
+to choose what visual is desired on a given window.  Clients can be
+using more than one visual on the same screen at the same time.</para>
+<para>
+The class of a display describes how this translation takes place.
+There are three ways to do the translation.
+<itemizedlist>
+<listitem><para>
+Pseudo - The pixel value, as a whole, is looked up
+in a table of length map_entries to
+determine the color to display.</para></listitem>
+<listitem><para>
+True - The
+pixel value is broken up into red, green, and blue fields, each of which
+are looked up in separate red, green, and blue lookup tables,
+each of length map_entries.</para></listitem>
+<listitem><para>
+Gray - The pixel value is looked up in a table of length map_entries to
+determine a gray level to display.</para></listitem>
+</itemizedlist>
+</para>
+<para>
+In addition, the lookup table can be static (resulting colors are fixed for each
+pixel value)
+or dynamic (lookup entries are under control of the client program).
+This leads to a total of six classes:
+<itemizedlist>
+<listitem><para>
+Static Gray - The pixel value (of however many bits) determines directly the
+level of gray
+that the pixel assumes.</para></listitem>
+<listitem><para>
+Gray Scale - The pixel value is fed through a lookup table to arrive at the level
+of gray to display
+for the given pixel.</para></listitem>
+<listitem><para>
+Static Color - The pixel value is fed through a fixed lookup table that yields the
+color to display
+for that pixel.</para></listitem>
+<listitem><para>
+PseudoColor - The whole pixel value is fed through a programmable lookup
+table that has one
+color (including red, green, and blue intensities) for each possible pixel value,
+and that color is displayed.</para></listitem>
+<listitem><para>
+True Color - Each pixel value consists of one or more bits
+that directly determine each primary color intensity after being fed through
+a fixed table.</para></listitem>
+<listitem><para>
+Direct Color - Each pixel value consists of one or more bits for each primary color.
+Each primary color value is individually looked up in a table for that primary
+color, yielding
+an intensity for that primary color.
+For each pixel, the red value is looked up in the
+red table, the green value in the green table, and
+the blue value in the blue table.</para></listitem>
+</itemizedlist>
+</para>
+<para>
+Here are some examples:
+<itemizedlist>
+<listitem><para>
+A simple monochrome 1 bit per pixel display is Static Gray.</para></listitem>
+<listitem><para>
+A display that has 2 bits per pixel for a choice
+between the colors of black, white, green and violet is Static Color.</para></listitem>
+<listitem><para>
+A display that has three bits per pixel, where
+each bit turns on or off one of the red, green or
+blue guns, is in the True Color class.</para></listitem>
+<listitem><para>
+If you take the last example and scramble the
+correspondence between pixel values and colors
+it becomes a Static Color display.</para></listitem>
+</itemizedlist></para>
+<para>
+A display has 8 bits per pixel.  The 8 bits select one entry out of 256 entries
+in a lookup table, each entry consisting of 24 bits (8bits each for red, green,
+and blue).
+The display can show any 256 of 16 million colors on the screen at once.
+This is a pseudocolor display.
+The client application gets to fill the lookup table in this class of display.</para>
+<para>
+Imagine the same hardware from the last example.
+Your server software allows the user, on the
+command line that starts up the server
+program,
+to fill the lookup table to his liking once and for all.
+From then on, the server software would not change the lookup table
+until it exits.
+For instance, the default might be a lookup table with a reasonable sample of
+colors from throughout the color space.
+But the user could specify that the table be filled with 256 steps of gray scale
+because he knew ahead of time he would be manipulating a lot of black-and-white
+scanned photographs
+and not very many color things.
+Clients would be presented with this unchangeable lookup table.
+Although the hardware qualifies as a PseudoColor display,
+the facade presented to the X client is that this is a Static Color display.</para>
+<para>
+You have to decide what kind of display you have or want
+to pretend you have.
+When you initialize the screen(s), this class value must be set in the
+VisualRec data structure along with other display characteristics like the
+depth and other numbers.</para>
+<para>
+The allowable DepthRec's and VisualRec's are pointed to by fields in the ScreenRec.
+These are set up when InitOutput() is called; you should Xalloc() appropriate blocks
+or use static variables initialized to the correct values.</para>
+</section>
+<section>
+<title>Colormaps for Screens</title>
+<para>
+A colormap is a device-independent
+mapping between pixel values and colors displayed on the screen.</para>
+<para>
+Different windows on the same screen can have different
+colormaps at the same time.
+At any given time, the most recently installed
+colormap(s) will be in use in the server
+so that its (their) windows' colors will be guaranteed to be correct.
+Other windows may be off-color.
+Although this may seem to be chaotic, in practice most clients
+use the default colormap for the screen.</para>
+<para>
+The default colormap for a screen is initialized when the screen is initialized.
+It always remains in existence and is not owned by any regular client.  It
+is owned by client 0 (the server itself).
+Many clients will simply use this default colormap for their drawing.
+Depending upon the class of the screen, the entries in this colormap may
+be modifiable by client applications.</para>
+</section>
+<section>
+  <title>Colormap Routines</title>
+<para>
+You need to implement the following routines to handle the device-dependent
+aspects of color maps.  You will end up placing pointers to these procedures
+in your ScreenRec data structure(s).  The sample server implementations of
+many of these routines are in fbcmap.c.</para>
+<para>
+<blockquote><programlisting>
+
+	Bool pScreen->CreateColormap(pColormap)
+		ColormapPtr pColormap;
+
+</programlisting></blockquote>
+This routine is called by the DIX CreateColormap routine after it has allocated
+all the data for the new colormap and just before it returns to the dispatcher.
+It is the DDX layer's chance to initialize the colormap, particularly if it is
+a static map.  See the following
+section for more details on initializing colormaps.
+The routine returns FALSE if creation failed, such as due to memory
+limitations.
+Notice that the colormap has a devPriv field from which you can hang any
+colormap specific storage you need.  Since each colormap might need special
+information, we attached the field to the colormap and not the visual.</para>
+<para>
+<blockquote><programlisting>
+
+	void pScreen->DestroyColormap(pColormap)
+		ColormapPtr pColormap;
+
+</programlisting></blockquote>
+This routine is called by the DIX FreeColormap routine after it has uninstalled
+the colormap and notified all interested parties, and before it has freed
+any of the colormap storage.
+It is the DDX layer's chance to free any data it added to the colormap.</para>
+<para>
+<blockquote><programlisting>
+
+	void pScreen->InstallColormap(pColormap)
+		ColormapPtr pColormap;
+
+</programlisting></blockquote>
+InstallColormap should
+fill a lookup table on the screen with which the colormap is associated with
+the colors in pColormap.
+If there is only one hardware lookup table for the screen, then all colors on
+the screen may change simultaneously.</para>
+<para>
+In the more general case of multiple hardware lookup tables,
+this may cause some other colormap to be
+uninstalled, meaning that windows that subscribed to the colormap
+that was uninstalled may end up being off-color.
+See the note, below, about uninstalling maps.</para>
+<para>
+<blockquote><programlisting>
+
+	void pScreen->UninstallColormap(pColormap)
+		ColormapPtr pColormap;
+
+</programlisting></blockquote>
+UninstallColormap should
+remove pColormap from screen pColormap->pScreen.
+Some other map, such as the default map if possible,
+should be installed in place of pColormap if applicable.
+If
+pColormap is the default map, do nothing.
+If any client has requested ColormapNotify events, the DDX layer must notify the client.
+(The routine WalkTree() is
+be used to find such windows.  The DIX routines TellNoMap(),
+TellNewMap()  and TellGainedMap() are provided to be used as
+the procedure parameter to WalkTree.  These procedures are in
+Xserver/dix/colormap.c.)</para>
+<para>
+<blockquote><programlisting>
+
+	int pScreen->ListInstalledColormaps(pScreen, pCmapList)
+		ScreenPtr pScreen;
+		XID *pCmapList;
+
+
+</programlisting></blockquote>
+ListInstalledColormaps fills the pCmapList in with the resource ids
+of the installed maps and returns a count of installed maps.
+pCmapList will point to an array of size MaxInstalledMaps that was allocated
+by the caller.</para>
+<para>
+<blockquote><programlisting>
+
+	void pScreen->StoreColors (pmap, ndef, pdefs)
+		ColormapPtr pmap;
+		int ndef;
+		xColorItem *pdefs;
+
+</programlisting></blockquote>
+StoreColors changes some of the entries in the colormap pmap.
+The number of entries to change are ndef, and pdefs points to the information
+describing what to change.
+Note that partial changes of entries in the colormap are allowed.
+Only the colors
+indicated in the flags field of each xColorItem need to be changed.
+However, all three color fields will be sent with the proper value for the
+benefit of screens that may not be able to set part of a colormap value.
+If the screen is a static class, this routine does nothing.
+The structure of colormap entries is nontrivial; see colormapst.h
+and the definition of xColorItem in Xproto.h for
+more details.</para>
+<para>
+<blockquote><programlisting>
+
+	void pScreen->ResolveColor(pRed, pGreen, pBlue, pVisual)
+		unsigned short *pRed, *pGreen, *pBlue;
+		VisualPtr pVisual;
+
+
+</programlisting></blockquote>
+Given a requested color, ResolveColor returns the nearest color that this hardware is
+capable of displaying on this visual.
+In other words, this rounds off each value, in place, to the number of bits
+per primary color that your screen can use.
+Remember that each screen has one of these routines.
+The level of roundoff should be what you would expect from the value
+you put in the bits_per_rgb field of the pVisual.</para>
+<para>
+Each value is an unsigned value ranging from 0 to 65535.
+The bits least likely to be used are the lowest ones.</para>
+<para>
+For example, if you had a pseudocolor display
+with any number of bits per pixel
+that had a lookup table supplying 6 bits for each color gun
+(a total of 256K different colors), you would
+round off each value to 6 bits.  Please don't simply truncate these values
+to the upper 6 bits, scale the result so that the maximum value seen
+by the client will be 65535 for each primary.  This makes color values
+more portable between different depth displays (a 6-bit truncated white
+will not look white on an 8-bit display).</para>
+<section>
+<title>Initializing a Colormap</title>
+<para>
+When a client requests a new colormap and when the server creates the default
+colormap, the procedure CreateColormap in the DIX layer is invoked.
+That procedure allocates memory for the colormap and related storage such as
+the lists of which client owns which pixels.
+It then sets a bit, BeingCreated, in the flags field of the ColormapRec
+and calls the DDX layer's CreateColormap routine.
+This is your chance to initialize the colormap.
+If the colormap is static, which you can tell by looking at the class field,
+you will want to fill in each color cell to match the hardwares notion of the
+color for that pixel.
+If the colormap is the default for the screen, which you can tell by looking
+at the IsDefault bit in the flags field, you should allocate BlackPixel
+and WhitePixel to match the values you set in the pScreen structure.
+(Of course, you picked those values to begin with.)</para>
+<para>
+You can also wait and use AllocColor() to allocate blackPixel
+and whitePixel after the default colormap has been created.
+If the default colormap is static and you initialized it in
+pScreen->CreateColormap, then use can use AllocColor afterwards
+to choose pixel values with the closest rgb values to those
+desired for blackPixel and whitePixel.
+If the default colormap is dynamic and uninitialized, then
+the rgb values you request will be obeyed, and AllocColor will
+again choose pixel values for you.
+These pixel values can then be stored into the screen.</para>
+<para>
+There are two ways to fill in the colormap.
+The simplest way is to use the DIX function AllocColor.
+<blockquote><programlisting>
+
+int AllocColor (pmap, pred, pgreen, pblue, pPix, client)
+    ColormapPtr         pmap;
+    unsigned short      *pred, *pgreen, *pblue;
+    Pixel               *pPix;
+    int                 client;
+
+</programlisting></blockquote>
+This takes three pointers to 16 bit color values and a pointer to a suggested
+pixel value.  The pixel value is either an index into one colormap or a
+combination of three indices depending on the type of pmap.
+If your colormap starts out empty, and you don't deliberately pick the same
+value twice, you will always get your suggested pixel.
+The truly nervous could check that the value returned in *pPix is the one
+AllocColor was called with.
+If you don't care which pixel is used, or would like them sequentially
+allocated from entry 0, set *pPix to 0.  This will find the first free
+pixel and use that.</para>
+<para>
+AllocColor will take care of all the  bookkeeping  and  will
+call StoreColors to get the colormap rgb values initialized.
+The hardware colormap will be changed whenever this colormap
+is installed.</para>
+<para>
+If for some reason AllocColor doesn't do what you want, you can do your
+own bookkeeping and call StoreColors yourself.  This is much more difficult
+and shouldn't be necessary for most devices.</para>
+</section>
+</section>
+<section>
+  <title>Fonts for Screens</title>
+<para>
+A font is a set of bitmaps that depict the symbols in a character set.
+Each font is for only one typeface in a given size, in other words,
+just one bitmap for each character.  Parallel fonts may be available
+in a variety of sizes and variations, including "bold" and "italic."
+X supports fonts for 8-bit and 16-bit character codes (for oriental
+languages that have more than 256 characters in the font).  Glyphs are
+bitmaps for individual characters.</para>
+<para>
+The source comes with some useful font files in an ASCII, plain-text
+format that should be comprehensible on a wide variety of operating
+systems.  The text format, referred to as BDF, is a slight extension
+of the current Adobe 2.1 Bitmap Distribution Format (Adobe Systems,
+Inc.).</para>
+<para>
+A short paper in PostScript format is included with the sample server
+that defines BDF.  It includes helpful pictures, which is why it is
+done in PostScript and is not included in this document.</para>
+<para>
+Your implementation should include some sort of font compiler to read
+these files and generate binary files that are directly usable by your
+server implementation.  The sample server comes with the source for a
+font compiler.</para>
+<para>
+It is important the font properties contained in the BDF files are
+preserved across any font compilation. In particular, copyright
+information cannot be casually tossed aside without legal
+ramifications. Other properties will be important to some
+sophisticated applications.</para>
+<para>
+All clients get font information from the server.  Therefore, your
+server can support any fonts it wants to.  It should probably support
+at least the fonts supplied with the X11 tape.  In principle, you can
+convert fonts from other sources or dream up your own fonts for use on
+your server.</para>
+<section>
+<title>Portable Compiled Format</title>
+<para>
+A font compiler is supplied with the sample server.  It has
+compile-time switches to convert the BDF files into a portable binary
+form, called Portable Compiled Format or PCF.  This allows for an
+arbitrary data format inside the file, and by describing the details
+of the format in the header of the file, any PCF file can be read by
+any PCF reading client.  By selecting the format which matches the
+required internal format for your renderer, the PCF reader can avoid
+reformatting the data each time it is read in.  The font compiler
+should be quite portable.</para>
+<para>
+The fonts included with the tape are stored in fonts/bdf.  The
+font compiler is found in fonts/tools/bdftopcf.</para>
+</section>
+<section>
+  <title>Font Realization</title>
+<para>
+Each screen configured into the server
+has an opportunity at font-load time
+to "realize" a font into some internal format if necessary.
+This happens every time the font is loaded into memory.</para>
+<para>
+A font (FontRec in Xserver/include/dixfontstr.h) is
+a device-independent structure containing a device-independent
+representation of the font.  When a font is created, it is "realized"
+for each screen.  At this point, the screen has the chance to convert
+the font into some other format.  The DDX layer can also put information
+in the devPrivate storage.</para>
+<para>
+<blockquote><programlisting>
+
+	Bool pScreen->RealizeFont(pScr, pFont)
+		ScreenPtr pScr;
+		FontPtr pFont;
+
+	Bool pScreen->UnrealizeFont(pScr, pFont)
+		ScreenPtr pScr;
+		FontPtr pFont;
+
+</programlisting></blockquote>
+RealizeFont and UnrealizeFont should calculate and allocate these extra data structures and
+dispose of them when no longer needed.
+These are called in response to OpenFont and CloseFont requests from
+the client.
+The sample server implementation is in fbscreen.c (which does very little).</para>
+</section>
+</section>
+<section>
+  <title>Other Screen Routines</title>
+<para>
+You must supply several other screen-specific routines for
+your X server implementation.
+Some of these are described in other sections:
+<itemizedlist>
+<listitem><para>
+GetImage() is described in the Drawing Primitives section.</para></listitem>
+<listitem><para>
+GetSpans() is described in the Pixblit routine section.</para></listitem>
+<listitem><para>
+Several window and pixmap manipulation procedures are
+described in the Window section under Drawables.</para></listitem>
+<listitem><para>
+The CreateGC() routine is described under Graphics Contexts.</para></listitem>
+</itemizedlist>
+</para>
+<para>
+<blockquote><programlisting>
+
+	void pScreen->QueryBestSize(kind, pWidth, pHeight)
+		int kind;
+		unsigned short *pWidth, *pHeight;
+		ScreenPtr pScreen;
+
+</programlisting></blockquote>
+QueryBestSize() returns the best sizes for cursors, tiles, and stipples
+in response to client requests.
+kind is one of the defined constants CursorShape, TileShape, or StippleShape
+(defined in X.h).
+For CursorShape, return the maximum width and
+height for cursors that you can handle.
+For TileShape and StippleShape, start with the suggested values in pWidth
+and pHeight and modify them in place to be optimal values that are
+greater than or equal to the suggested values.
+The sample server implementation is in Xserver/fb/fbscreen.c.</para>
+<para>
+<blockquote><programlisting>
+
+	pScreen->SourceValidate(pDrawable, x, y, width, height)
+		DrawablePtr pDrawable;
+		int x, y, width, height;
+		unsigned int subWindowMode;
+
+</programlisting></blockquote>
+SourceValidate should be called by CopyArea/CopyPlane primitives when
+the SourceValidate function pointer in the screen is non-null.  If you know that
+you will never need SourceValidate, you can avoid this check.  Currently,
+SourceValidate is used by the mi software cursor code to remove the cursor
+from the screen when the source rectangle overlaps the cursor position.
+x,y,width,height describe the source rectangle (source relative, that is)
+for the copy operation.  subWindowMode comes from the GC or source Picture.
+</para>
+<para>
+<blockquote><programlisting>
+
+	Bool pScreen->SaveScreen(pScreen, on)
+		ScreenPtr pScreen;
+		int on;
+
+</programlisting></blockquote>
+SaveScreen() is used for Screen Saver support (see WaitForSomething()).
+pScreen is the screen to save.</para>
+<para>
+<blockquote><programlisting>
+
+	Bool pScreen->CloseScreen(pScreen)
+	    ScreenPtr pScreen;
+
+</programlisting></blockquote>
+When the server is reset, it calls this routine for each screen.</para>
+<para>
+<blockquote><programlisting>
+
+	Bool pScreen->CreateScreenResources(pScreen)
+	    ScreenPtr pScreen;
+
+</programlisting></blockquote>
+If this routine is not NULL, it will be called once per screen per
+server initialization/reset after all modules have had a chance to
+request private space on all structures that support them (see
+<xref linkend="wrappers_and_privates"/> below).  You may create resources
+in this function instead of in the
+screen init function passed to AddScreen in order to guarantee that
+all pre-allocated space requests have been registered first.  With the
+new devPrivates mechanism, this is not strictly necessary, however.
+This routine returns TRUE if successful.</para>
+</section>
+</section>
+<section>
+<title>Drawables</title>
+<para>
+A drawable is a descriptor of a surface that graphics are drawn into, either
+a window on the screen or a pixmap in memory.</para>
+<para>
+Each drawable has a type, class,
+ScreenPtr for the screen it is associated with, depth, position, size,
+and serial number.
+The type is one of the defined constants DRAWABLE_PIXMAP,
+DRAWABLE_WINDOW and UNDRAWABLE_WINDOW.
+(An undrawable window is used for window class InputOnly.)
+The serial number is guaranteed to be unique across drawables, and
+is used in determining
+the validity of the clipping information in a GC.
+The screen selects the set of procedures used to manipulate and draw into the
+drawable.  Position is used (currently) only by windows; pixmaps must
+set these fields to 0,0 as this reduces the amount of conditional code
+executed throughout the mi code.  Size indicates the actual client-specified
+size of the drawable.
+There are, in fact, no other fields that a window drawable and pixmap
+drawable have in common besides those mentioned here.</para>
+<para>
+Both PixmapRecs and WindowRecs are structs that start with a drawable
+and continue on with more fields.  Pixmaps have a single pointer field
+named devPrivate which usually points to the pixmap data but could conceivably be
+used for anything that DDX wants.  Both windows and pixmaps also have a
+devPrivates field which can be used for DDX specific data (see <xref linkend="wrappers_and_privates"/>
+below).  This is done because different graphics hardware has
+different requirements for management; if the graphics is always
+handled by a processor with an independent address space, there is no
+point having a pointer to the bit image itself.</para>
+<para>
+The definition of a drawable and a pixmap can be found in the file
+Xserver/include/pixmapstr.h.
+The definition of a window can be found in the file Xserver/include/windowstr.h.</para>
+<section>
+  <title>Pixmaps</title>
+<para>
+A pixmap is a three-dimensional array of bits stored somewhere offscreen,
+rather than in the visible portion of the screen's display frame buffer.  It
+can be used as a source or destination in graphics operations.  There is no
+implied interpretation of the pixel values in a pixmap, because it has no
+associated visual or colormap.  There is only a depth that indicates the
+number of significant bits per pixel.  Also, there is no implied physical
+size for each pixel; all graphic units are in numbers of pixels.  Therefore,
+a pixmap alone does not constitute a complete image; it represents only a
+rectangular array of pixel values.</para>
+<para>
+Note that the pixmap data structure is reference-counted.</para>
+<para>
+The server implementation is free to put the pixmap data
+anywhere it sees fit, according to its graphics hardware setup.  Many
+implementations will simply have the data dynamically allocated in the
+server's address space.  More sophisticated implementations may put the
+data in undisplayed framebuffer storage.</para>
+<para>
+In addition to dynamic devPrivates (see <xref linkend="wrappers_and_privates"/>
+below), the pixmap data structure has two fields that are private to
+the device.  Although you can use them for anything you want, they
+have intended purposes.  devKind is intended to be a device specific
+indication of the pixmap location (host memory, off-screen, etc.).  In
+the sample server, since all pixmaps are in memory, devKind stores the
+width of the pixmap in bitmap scanline units.  devPrivate is usually
+a pointer to the bits in the pixmap.</para>
+<para>
+A bitmap is a pixmap that is one bit deep.</para>
+<para>
+<blockquote><programlisting>
+
+	PixmapPtr pScreen->CreatePixmap(pScreen, width, height, depth)
+		ScreenPtr pScreen;
+		int width, height, depth;
+
+</programlisting></blockquote>
+This ScreenRec procedure must create a pixmap of the size
+requested.
+It must allocate a PixmapRec and fill in all of the fields.
+The reference count field must be set to 1.
+If width or height are zero, no space should be allocated
+for the pixmap data, and if the implementation is using the
+devPrivate field as a pointer to the pixmap data, it should be
+set to NULL.
+If successful, it returns a pointer to the new pixmap; if not, it returns NULL.
+See Xserver/fb/fbpixmap.c for the sample server implementation.</para>
+<para>
+<blockquote><programlisting>
+
+	Bool pScreen->DestroyPixmap(pPixmap)
+		PixmapPtr pPixmap;
+
+</programlisting></blockquote>
+This ScreenRec procedure must "destroy" a pixmap.
+It should decrement the reference count and, if zero, it
+must deallocate the PixmapRec and all attached devPrivate blocks.
+If successful, it returns TRUE.
+See Xserver/fb/fbpixmap.c for the sample server implementation.</para>
+<para>
+<blockquote><programlisting>
+
+	Bool
+	pScreen->ModifyPixmapHeader(pPixmap, width, height, depth, bitsPerPixel, devKind, pPixData)
+		PixmapPtr   pPixmap;
+		int	    width;
+		int	    height;
+		int	    depth;
+		int	    bitsPerPixel;
+		int	    devKind;
+		pointer     pPixData;
+
+</programlisting></blockquote>
+This routine takes a pixmap header and initializes the fields of the PixmapRec to the
+parameters of the same name.  pPixmap must have been created via
+pScreen->CreatePixmap with a zero width or height to avoid
+allocating space for the pixmap data.  pPixData is assumed to be the
+pixmap data; it will be stored in an implementation-dependent place
+(usually pPixmap->devPrivate.ptr).  This routine returns
+TRUE if successful.  See Xserver/mi/miscrinit.c for the sample
+server implementation.</para>
+<para>
+<blockquote><programlisting>
+
+	PixmapPtr
+	GetScratchPixmapHeader(pScreen, width, height, depth, bitsPerPixel, devKind, pPixData)
+		ScreenPtr   pScreen;
+		int	    width;
+		int	    height;
+		int	    depth;
+		int	    bitsPerPixel;
+		int	    devKind;
+		pointer     pPixData;
+
+	void FreeScratchPixmapHeader(pPixmap)
+		PixmapPtr pPixmap;
+
+</programlisting></blockquote>
+DDX should use these two DIX routines when it has a buffer of raw
+image data that it wants to manipulate as a pixmap temporarily,
+usually so that some other part of the server can be leveraged to
+perform some operation on the data.  The data should be passed in
+pPixData, and will be stored in an implementation-dependent place
+(usually pPixmap->devPrivate.ptr). The other
+fields go into the corresponding PixmapRec fields.
+If successful, GetScratchPixmapHeader returns a valid PixmapPtr which can
+be used anywhere the server expects a pixmap, else
+it returns NULL.  The pixmap should be released when no longer needed
+(usually within the same function that allocated it)
+with FreeScratchPixmapHeader.</para>
+</section>
+<section>
+  <title>Windows</title>
+<para>
+A window is a visible, or potentially visible, rectangle on the screen.
+DIX windowing functions maintain an internal n-ary tree data structure, which
+represents the current relationships of the mapped windows.
+Windows that are contained in another window are children of that window and
+are clipped to the boundaries of the parent.
+The root window in the tree is the window for the entire screen.
+Sibling windows constitute a doubly-linked list; the parent window has a pointer
+to the head and tail of this list.
+Each child also has a pointer to its parent.</para>
+<para>
+The border of a window is drawn by a DDX procedure when DIX requests that it
+be drawn.  The contents of the window is drawn by the client through
+requests to the server.</para>
+<para>
+Window painting is orchestrated through an expose event system.
+When a region is exposed,
+DIX generates an expose event, telling the client to repaint the window and
+passing the region that is the minimal area needed to be repainted.</para>
+<para>
+As a favor to clients, the server may retain
+the output to the hidden parts of windows
+in off-screen memory; this is called "backing store".
+When a part of such a window becomes exposed, it
+can quickly move pixels into place instead of
+triggering an expose event and waiting for a client on the other
+end of the network to respond.
+Even if the network response is insignificant, the time to
+intelligently paint a section of a window is usually more than
+the time to just copy already-painted sections.
+At best, the repainting involves blanking out the area to a background color,
+which will take about the
+same amount of time.
+In this way, backing store can dramatically increase the
+performance of window moves.</para>
+<para>
+On the other hand, backing store can be quite complex, because
+all graphics drawn to hidden areas must be intercepted and redirected
+to the off-screen window sections.
+Not only can this be complicated for the server programmer,
+but it can also impact window painting performance.
+The backing store implementation can choose, at any time, to
+forget pieces of backing that are written into, relying instead upon
+expose events to repaint for simplicity.</para>
+<para>
+In X, the decision to use the backing-store scheme is made
+by you, the server implementor.  The sample server implements
+backing store "for free" by reusing the infrastructure for the Composite
+extension.  As a side effect, it treats the WhenMapped and Always hints
+as equivalent.  However, it will never forget pixel contents when the
+window is mapped.</para>
+<para>
+When a window operation is requested by the client,
+such as a window being created or moved,
+a new state is computed.
+During this transition, DIX informs DDX what rectangles in what windows are about to
+become obscured and what rectangles in what windows have become exposed.
+This provides a hook for the implementation of backing store.
+If DDX is unable to restore exposed regions, DIX generates expose
+events to the client.
+It is then the client's responsibility to paint the
+window parts that were exposed but not restored.</para>
+<para>
+If a window is resized, pixels sometimes need to be
+moved, depending upon
+the application.
+The client can request "Gravity" so that
+certain blocks of the window are
+moved as a result of a resize.
+For instance, if the window has controls or other items
+that always hang on the edge of the
+window, and that edge is moved as a result of the resize,
+then those pixels should be moved
+to avoid having the client repaint it.
+If the client needs to repaint it anyway, such an operation takes
+time, so it is desirable
+for the server to approximate the appearance of the window as best
+it can while waiting for the client
+to do it perfectly.
+Gravity is used for that, also.</para>
+<para>
+The window has several fields used in drawing
+operations:
+<itemizedlist>
+<listitem><para>
+clipList - This region, in conjunction with
+the client clip region in the gc, is used to clip output.
+clipList has the window's children subtracted from it, in addition to pieces of sibling windows
+that overlap this window.  To get the list with the
+children included (subwindow-mode is IncludeInferiors),
+the routine NotClippedByChildren(pWin) returns the unclipped region.</para></listitem>
+<listitem><para>
+borderClip is the region used by CopyWindow and
+includes the area of the window, its children, and the border, but with the
+overlapping areas of sibling children removed.</para></listitem>
+</itemizedlist>
+Most of the other fields are for DIX use only.</para>
+<section>
+<title>Window Procedures in the ScreenRec</title>
+<para>
+You should implement
+all of the following procedures and store pointers to them in the screen record.</para>
+<para>
+The device-independent portion of the server "owns" the window tree.
+However, clever hardware might want to know the relationship of
+mapped windows.  There are pointers to procedures
+in the ScreenRec data structure that are called to give the hardware
+a chance to update its internal state.  These are helpers and
+hints to DDX only;
+they do not change the window tree, which is only changed by DIX.</para>
+<para>
+<blockquote><programlisting>
+
+	Bool pScreen->CreateWindow(pWin)
+		WindowPtr pWin;
+
+</programlisting></blockquote>
+This routine is a hook for when DIX creates a window.
+It should fill in the "Window Procedures in the WindowRec" below
+and also allocate the devPrivate block for it.</para>
+<para>
+See Xserver/fb/fbwindow.c for the sample server implementation.</para>
+<para>
+<blockquote><programlisting>
+
+	Bool pScreen->DestroyWindow(pWin);
+		WindowPtr pWin;
+
+</programlisting></blockquote>
+This routine is a hook for when DIX destroys a window.
+It should deallocate the devPrivate block for it and any other blocks that need
+to be freed, besides doing other cleanup actions.</para>
+<para>
+See Xserver/fb/fbwindow.c for the sample server implementation.</para>
+<para>
+<blockquote><programlisting>
+
+	Bool pScreen->PositionWindow(pWin, x, y);
+		WindowPtr pWin;
+		int x, y;
+
+</programlisting></blockquote>
+This routine is a hook for when DIX moves or resizes a window.
+It should do whatever private operations need to be done when a window is moved or resized.
+For instance, if DDX keeps a pixmap tile used for drawing the background
+or border, and it keeps the tile rotated such that it is longword
+aligned to longword locations in the frame buffer, then you should rotate your tiles here.
+The actual graphics involved in moving the pixels on the screen and drawing the
+border are handled by CopyWindow(), below.</para>
+<para>
+See Xserver/fb/fbwindow.c for the sample server implementation.</para>
+<para>
+<blockquote><programlisting>
+
+	Bool pScreen->RealizeWindow(pWin);
+		WindowPtr pWin;
+
+	Bool  pScreen->UnrealizeWindow(pWin);
+		WindowPtr pWin;
+
+</programlisting></blockquote>
+These routines are hooks for when DIX maps (makes visible) and unmaps
+(makes invisible) a window.  It should do whatever private operations
+need to be done when these happen, such as allocating or deallocating
+structures that are only needed for visible windows.  RealizeWindow
+does NOT draw the window border, background or contents;
+UnrealizeWindow does NOT erase the window or generate exposure events
+for underlying windows; this is taken care of by DIX.  DIX does,
+however, call PaintWindowBackground() and PaintWindowBorder() to
+perform some of these.</para>
+<para>
+<blockquote><programlisting>
+
+	Bool pScreen->ChangeWindowAttributes(pWin, vmask)
+		WindowPtr pWin;
+		unsigned long vmask;
+
+</programlisting></blockquote>
+ChangeWindowAttributes is called whenever DIX changes window
+attributes, such as the size, front-to-back ordering, title, or
+anything of lesser severity that affects the window itself.  The
+sample server implements this routine.  It computes accelerators for
+quickly putting up background and border tiles.  (See description of
+the set of routines stored in the WindowRec.)</para>
+<para>
+<blockquote><programlisting>
+
+	int pScreen->ValidateTree(pParent,  pChild, kind)
+		WindowPtr pParent, pChild;
+		VTKind kind;
+
+</programlisting></blockquote>
+ValidateTree calculates the clipping region for the parent window and
+all of its children.  This routine must be provided. The sample server
+has a machine-independent version in Xserver/mi/mivaltree.c.  This is
+a very difficult routine to replace.</para>
+<para>
+<blockquote><programlisting>
+
+	void pScreen->PostValidateTree(pParent,  pChild, kind)
+		WindowPtr pParent, pChild;
+		VTKind kind;
+
+</programlisting></blockquote>
+If this routine is not NULL, DIX calls it shortly after calling
+ValidateTree, passing it the same arguments.  This is useful for
+managing multi-layered framebuffers.
+The sample server sets this to NULL.</para>
+<para>
+<blockquote><programlisting>
+
+	void pScreen->WindowExposures(pWin, pRegion, pBSRegion)
+		WindowPtr pWin;
+		RegionPtr pRegion;
+		RegionPtr pBSRegion;
+
+</programlisting></blockquote>
+The WindowExposures() routine
+paints the border and generates exposure events for the window.
+pRegion is an unoccluded region of the window, and pBSRegion is an
+occluded region that has backing store.
+Since exposure events include a rectangle describing what was exposed,
+this routine may have to send back a series of exposure events, one for
+each rectangle of the region.
+The count field in the expose event is a hint to the
+client as to the number of
+regions that are after this one.
+This routine must be provided. The sample
+server has a machine-independent version in Xserver/mi/miexpose.c.</para>
+<para>
+<blockquote><programlisting>
+
+	void pScreen->ClipNotify (pWin, dx, dy)
+		WindowPtr pWin;
+		int dx, dy;
+
+</programlisting></blockquote>
+Whenever the cliplist for a window is changed, this function is called to
+perform whatever hardware manipulations might be necessary.  When called,
+the clip list and border clip regions in the window are set to the new
+values.  dx,dy are the distance that the window has been moved (if at all).</para>
+</section>
+<section>
+  <title>Window Painting Procedures</title>
+<para>
+In addition to the procedures listed above, there are two routines which
+manipulate the actual window image directly.
+In the sample server, mi implementations will work for
+most purposes and fb routines speed up situations, such
+as solid backgrounds/borders or tiles that are 8, 16 or 32 pixels square.</para>
+<para>
+<blockquote><programlisting>
+
+	void pScreen->ClearToBackground(pWin, x, y, w, h, generateExposures);
+		WindowPtr pWin;
+		int x, y, w, h;
+		Bool generateExposures;
+
+</programlisting></blockquote>
+This routine is called on a window in response to a ClearToBackground request
+from the client.
+This request has two different but related functions, depending upon generateExposures.</para>
+<para>
+If generateExposures is true, the client is declaring that the given rectangle
+on the window is incorrectly painted and needs to be repainted.
+The sample server implementation calculates the exposure region
+and hands it to the DIX procedure HandleExposures(), which
+calls the WindowExposures() routine, below, for the window
+and all of its child windows.</para>
+<para>
+If generateExposures is false, the client is trying to simply erase part
+of the window to the background fill style.
+ClearToBackground should write the background color or tile to the
+rectangle in question (probably using PaintWindowBackground).
+If w or h is zero, it clears all the way to the right or lower edge of the window.</para>
+<para>
+The sample server implementation is in Xserver/mi/miwindow.c.</para>
+<para>
+<blockquote><programlisting>
+
+	void pScreen->CopyWindow(pWin, oldpt, oldRegion);
+		WindowPtr pWin;
+		DDXPointRec oldpt;
+		RegionPtr oldRegion;
+
+</programlisting></blockquote>
+CopyWindow is called when a window is moved, and graphically moves to
+pixels of a window on the screen.  It should not change any other
+state within DDX (see PositionWindow(), above).</para>
+<para>
+oldpt is the old location of the upper-left corner.  oldRegion is the
+old region it is coming from.  The new location and new region is
+stored in the WindowRec.  oldRegion might modified in place by this
+routine (the sample implementation does this).</para>
+<para>
+CopyArea could be used, except that this operation has more
+complications.  First of all, you do not want to copy a rectangle onto
+a rectangle.  The original window may be obscured by other windows,
+and the new window location may be similarly obscured.  Second, some
+hardware supports multiple windows with multiple depths, and your
+routine needs to take care of that.</para>
+<para>
+The pixels in oldRegion (with reference point oldpt) are copied to the
+window's new region (pWin->borderClip).  pWin->borderClip is gotten
+directly from the window, rather than passing it as a parameter.</para>
+<para>
+The sample server implementation is in Xserver/fb/fbwindow.c.</para>
+</section>
+<section>
+<title>Screen Operations for Multi-Layered Framebuffers</title>
+<para>
+The following screen functions are useful if you have a framebuffer with
+multiple sets of independent bit planes, e.g. overlays or underlays in
+addition to the "main" planes.  If you have a simple single-layer
+framebuffer, you should probably use the mi versions of these routines
+in mi/miwindow.c.  This can be easily accomplished by calling miScreenInit.</para>
+<para>
+<blockquote><programlisting>
+
+    void pScreen->MarkWindow(pWin)
+	WindowPtr pWin;
+
+</programlisting></blockquote>
+This formerly dix function MarkWindow has moved to ddx and is accessed
+via this screen function.  This function should store something,
+usually a pointer to a device-dependent structure, in pWin->valdata so
+that ValidateTree has the information it needs to validate the window.</para>
+<para>
+<blockquote><programlisting>
+
+    Bool pScreen->MarkOverlappedWindows(parent, firstChild, ppLayerWin)
+	WindowPtr parent;
+	WindowPtr firstChild;
+	WindowPtr * ppLayerWin;
+
+</programlisting></blockquote>
+This formerly dix function MarkWindow has moved to ddx and is accessed
+via this screen function.  In the process, it has grown another
+parameter: ppLayerWin, which is filled in with a pointer to the window
+at which save under marking and ValidateTree should begin.  In the
+single-layered framebuffer case, pLayerWin == pWin.</para>
+<para>
+<blockquote><programlisting>
+
+    Bool pScreen->ChangeSaveUnder(pLayerWin, firstChild)
+	WindowPtr pLayerWin;
+	WindowPtr firstChild;
+
+</programlisting></blockquote>
+The dix functions ChangeSaveUnder and CheckSaveUnder have moved to ddx and
+are accessed via this screen function.  pLayerWin should be the window
+returned in the ppLayerWin parameter of MarkOverlappedWindows.  The function
+may turn on backing store for windows that might be covered, and may partially
+turn off backing store for windows.  It returns TRUE if PostChangeSaveUnder
+needs to be called to finish turning off backing store.</para>
+<para>
+<blockquote><programlisting>
+
+    void pScreen->PostChangeSaveUnder(pLayerWin, firstChild)
+	WindowPtr pLayerWin;
+	WindowPtr firstChild;
+
+</programlisting></blockquote>
+The dix function DoChangeSaveUnder has moved to ddx and is accessed via
+this screen function.  This function completes the job of turning off
+backing store that was started by ChangeSaveUnder.</para>
+<para>
+<blockquote><programlisting>
+
+    void pScreen->MoveWindow(pWin, x, y, pSib, kind)
+	WindowPtr pWin;
+	int x;
+	int y;
+	WindowPtr pSib;
+	VTKind kind;
+
+</programlisting></blockquote>
+The formerly dix function MoveWindow has moved to ddx and is accessed via
+this screen function.  The new position of the window is given by
+x,y.  kind is VTMove if the window is only moving, or VTOther if
+the border is also changing.</para>
+<para>
+<blockquote><programlisting>
+
+    void pScreen->ResizeWindow(pWin, x, y, w, h, pSib)
+	WindowPtr pWin;
+	int x;
+	int y;
+	unsigned int w;
+	unsigned int h;
+	WindowPtr pSib;
+
+</programlisting></blockquote>
+The formerly dix function SlideAndSizeWindow has moved to ddx and is accessed via
+this screen function.  The new position is given by x,y.  The new size
+is given by w,h.</para>
+<para>
+<blockquote><programlisting>
+
+    WindowPtr pScreen->GetLayerWindow(pWin)
+	WindowPtr pWin
+
+</programlisting></blockquote>
+This is a new function which returns a child of the layer parent of pWin.</para>
+<para>
+<blockquote><programlisting>
+
+    void pScreen->HandleExposures(pWin)
+	WindowPtr pWin;
+
+</programlisting></blockquote>
+The formerly dix function HandleExposures has moved to ddx and is accessed via
+this screen function.  This function is called after ValidateTree and
+uses the information contained in valdata to send exposures to windows.</para>
+<para>
+<blockquote><programlisting>
+
+    void pScreen->ReparentWindow(pWin, pPriorParent)
+	WindowPtr pWin;
+	WindowPtr pPriorParent;
+
+</programlisting></blockquote>
+This function will be called when a window is reparented.  At the time of
+the call, pWin will already be spliced into its new position in the
+window tree, and pPriorParent is its previous parent.  This function
+can be NULL.</para>
+<para>
+<blockquote><programlisting>
+
+    void pScreen->SetShape(pWin)
+	WindowPtr pWin;
+
+</programlisting></blockquote>
+The formerly dix function SetShape has moved to ddx and is accessed via
+this screen function.  The window's new shape will have already been
+stored in the window when this function is called.</para>
+<para>
+<blockquote><programlisting>
+
+    void pScreen->ChangeBorderWidth(pWin, width)
+	WindowPtr pWin;
+	unsigned int width;
+
+</programlisting></blockquote>
+The formerly dix function ChangeBorderWidth has moved to ddx and is accessed via
+this screen function.  The new border width is given by width.</para>
+<para>
+<blockquote><programlisting>
+
+    void pScreen->MarkUnrealizedWindow(pChild, pWin, fromConfigure)
+	WindowPtr pChild;
+	WindowPtr pWin;
+	Bool fromConfigure;
+
+</programlisting></blockquote>
+This function is called for windows that are being unrealized as part of
+an UnrealizeTree.  pChild is the window being unrealized, pWin is an
+ancestor, and the fromConfigure value is simply propagated from UnrealizeTree.</para>
+</section>
+</section>
+</section>
+<section>
+<title>Graphics Contexts and Validation</title>
+<para>
+This graphics context (GC) contains state variables such as foreground and
+background pixel value (color), the current line style and width,
+the current tile or stipple for pattern generation, the current font for text
+generation, and other similar attributes.</para>
+<para>
+In many graphics systems, the equivalent of the graphics context and the
+drawable are combined as one entity.
+The main distinction between the two kinds of status is that a drawable
+describes a writing surface and the writings that may have already been done
+on it, whereas a graphics context describes the drawing process.
+A drawable is like a chalkboard.
+A GC is like a piece of chalk.</para>
+<para>
+Unlike many similar systems, there is no "current pen location."
+Every graphic operation is accompanied by the coordinates where it is to happen.</para>
+<para>
+The GC also includes two vectors of procedure pointers, the first
+operate on the GC itself and are called GC funcs.  The second, called
+GC ops,
+contains the functions that carry out the fundamental graphic operations
+such as drawing lines, polygons, arcs, text, and copying bitmaps.
+The DDX graphic software can, if it
+wants to be smart, change these two vectors of procedure pointers
+to take advantage of hardware/firmware in the server machine, which can do
+a better job under certain circumstances.  To reduce the amount of memory
+consumed by each GC, it is wise to create a few "boilerplate" GC ops vectors
+which can be shared by every GC which matches the constraints for that set.
+Also, it is usually reasonable to have every GC created by a particular
+module to share a common set of GC funcs.  Samples of this sort of
+sharing can be seen in fb/fbgc.c.</para>
+<para>
+The DDX software is notified any time the client (or DIX) uses a changed GC.
+For instance, if the hardware has special support for drawing fixed-width
+fonts, DDX can intercept changes to the current font in a GC just before
+drawing is done.  It can plug into either a fixed-width procedure that makes
+the hardware draw characters, or a variable-width procedure that carefully
+lays out glyphs by hand in software, depending upon the new font that is
+selected.</para>
+<para>
+A definition of these structures can be found in the file
+Xserver/include/gcstruct.h.</para>
+<para>
+Also included in each GC is support for dynamic devPrivates, which the
+DDX can use for any purpose (see <xref linkend="wrappers_and_privates"/> below).</para>
+<para>
+The DIX routines available for manipulating GCs are
+CreateGC, ChangeGC, ChangeGCXIDs, CopyGC, SetClipRects, SetDashes, and FreeGC.
+<blockquote><programlisting>
+
+	GCPtr CreateGC(pDrawable, mask, pval, pStatus)
+	    DrawablePtr pDrawable;
+	    BITS32 mask;
+	    XID *pval;
+	    int *pStatus;
+
+	int ChangeGC(client, pGC, mask, pUnion)
+	    ClientPtr client;
+	    GCPtr pGC;
+	    BITS32 mask;
+	    ChangeGCValPtr pUnion;
+
+	int ChangeGCXIDs(client, pGC, mask, pC32)
+	    ClientPtr client;
+	    GCPtr pGC;
+	    BITS32 mask;
+	    CARD32 *pC32;
+
+	int CopyGC(pgcSrc, pgcDst, mask)
+	    GCPtr pgcSrc;
+	    GCPtr pgcDst;
+	    BITS32 mask;
+
+	int SetClipRects(pGC, xOrigin, yOrigin, nrects, prects, ordering)
+	    GCPtr pGC;
+	    int xOrigin, yOrigin;
+	    int nrects;
+	    xRectangle *prects;
+	    int ordering;
+
+	SetDashes(pGC, offset, ndash, pdash)
+	    GCPtr pGC;
+	    unsigned offset;
+	    unsigned ndash;
+	    unsigned char *pdash;
+
+	int FreeGC(pGC, gid)
+	    GCPtr pGC;
+	    GContext gid;
+
+</programlisting></blockquote>
+</para>
+<para>
+As a convenience, each Screen structure contains an array of
+GCs that are preallocated, one at each depth the screen supports.
+These are particularly useful in the mi code.  Two DIX routines
+must be used to get these GCs:
+<blockquote><programlisting>
+
+	GCPtr GetScratchGC(depth, pScreen)
+	    int depth;
+	    ScreenPtr pScreen;
+
+	FreeScratchGC(pGC)
+	    GCPtr pGC;
+
+</programlisting></blockquote>
+Always use these two routines, don't try to extract the scratch
+GC yourself -- someone else might be using it, so a new one must
+be created on the fly.</para>
+<para>
+If you need a GC for a very long time, say until the server is restarted,
+you should not take one from the pool used by GetScratchGC, but should
+get your own using CreateGC or CreateScratchGC.
+This leaves the ones in the pool free for routines that only need it for
+a little while and don't want to pay a heavy cost to get it.
+<blockquote><programlisting>
+
+	GCPtr CreateScratchGC(pScreen, depth)
+	    ScreenPtr pScreen;
+	    int depth;
+
+</programlisting></blockquote>
+NULL is returned if the GC cannot be created.
+The GC returned can be freed with FreeScratchGC.</para>
+<section>
+  <title>Details of Operation</title>
+<para>
+At screen initialization, a screen must supply a GC creation procedure.
+At GC creation, the screen must fill in GC funcs and GC ops vectors
+(Xserver/include/gcstruct.h).  For any particular GC, the func vector
+must remain constant, while the op vector may vary.  This invariant is to
+ensure that Wrappers work correctly.</para>
+<para>
+When a client request is processed that results in a change
+to the GC, the device-independent state of the GC is updated.
+This includes a record of the state that changed.
+Then the ChangeGC GC func is called.
+This is useful for graphics subsystems that are able to process
+state changes in parallel with the server CPU.
+DDX may opt not to take any action at GC-modify time.
+This is more efficient if multiple GC-modify requests occur
+between draws using a given GC.</para>
+<para>
+Validation occurs at the first draw operation that specifies the GC after
+that GC was modified.  DIX calls then the ValidateGC GC func.  DDX should
+then update its internal state.  DDX internal state may be stored as one or
+more of the following:  1) device private block on the GC; 2) hardware
+state; 3) changes to the GC ops.</para>
+<para>
+The GC contains a serial number, which is loaded with a number fetched from
+the window that was drawn into the last time the GC was used.  The serial
+number in the drawable is changed when the drawable's
+clipList or absCorner changes.  Thus, by
+comparing the GC serial number with the drawable serial number, DIX can
+force a validate if the drawable has been changed since the last time it
+was used with this GC.</para>
+<para>
+In addition, the drawable serial number is always guaranteed to have the
+most significant bit set to 0.  Thus, the DDX layer can set the most
+significant bit of the serial number to 1 in a GC to force a validate the next time
+the GC is used.  DIX also uses this technique to indicate that a change has
+been made to the GC by way of a SetGC, a SetDashes or a SetClip request.</para>
+</section>
+<section>
+  <title>GC Handling Routines</title>
+<para>
+The ScreenRec data structure has a pointer for
+CreateGC().
+<blockquote><programlisting>
+
+	Bool pScreen->CreateGC(pGC)
+		GCPtr pGC;
+</programlisting></blockquote>
+This routine must fill in the fields of
+a dynamically allocated GC that is passed in.
+It does NOT allocate the GC record itself or fill
+in the defaults; DIX does that.</para>
+<para>
+This must fill in both the GC funcs and ops; none of the drawing
+functions will be called before the GC has been validated,
+but the others (dealing with allocating of clip regions,
+changing and destroying the GC, etc.) might be.</para>
+<para>
+The GC funcs vector contains pointers to 7
+routines and a devPrivate field:
+<blockquote><programlisting>
+
+	pGC->funcs->ChangeGC(pGC, changes)
+		GCPtr pGC;
+		unsigned long changes;
+
+</programlisting></blockquote>
+This GC func is called immediately after a field in the GC is changed.
+changes is a bit mask indicating the changed fields of the GC in this
+request.</para>
+<para>
+The ChangeGC routine is useful if you have a system where
+state-changes to the GC can be swallowed immediately by your graphics
+system, and a validate is not necessary.</para>
+<para>
+<blockquote><programlisting>
+
+	pGC->funcs->ValidateGC(pGC, changes, pDraw)
+		GCPtr pGC;
+		unsigned long changes;
+		DrawablePtr pDraw;
+
+</programlisting></blockquote>
+ValidateGC is called by DIX just before the GC will be used when one
+of many possible changes to the GC or the graphics system has
+happened.  It can modify devPrivates data attached to the GC,
+change the op vector, or change hardware according to the
+values in the GC.  It may not change the device-independent portion of
+the GC itself.</para>
+<para>
+In almost all cases, your ValidateGC() procedure should take the
+regions that drawing needs to be clipped to and combine them into a
+composite clip region, which you keep a pointer to in the private part
+of the GC.  In this way, your drawing primitive routines (and whatever
+is below them) can easily determine what to clip and where.  You
+should combine the regions clientClip (the region that the client
+desires to clip output to) and the region returned by
+NotClippedByChildren(), in DIX.  An example is in Xserver/fb/fbgc.c.</para>
+<para>
+Some kinds of extension software may cause this routine to be called
+more than originally intended; you should not rely on algorithms that
+will break under such circumstances.</para>
+<para>
+See the Strategies document for more information on creatively using
+this routine.</para>
+<para>
+<blockquote><programlisting>
+
+	pGC->funcs->CopyGC(pGCSrc, mask, pGCDst)
+		GCPtr pGCSrc;
+		unsigned long mask;
+		GCPtr pGCDst;
+
+</programlisting></blockquote>
+This routine is called by DIX when a GC is being copied to another GC.
+This is for situations where dynamically allocated chunks of memory
+are stored in the GC's dynamic devPrivates and need to be transferred to
+the destination GC.</para>
+<para>
+<blockquote><programlisting>
+
+	pGC->funcs->DestroyGC(pGC)
+		GCPtr pGC;
+
+</programlisting></blockquote>
+This routine is called before the GC is destroyed for the
+entity interested in this GC to clean up after itself.
+This routine is responsible for freeing any auxiliary storage allocated.</para>
+</section>
+<section>
+  <title>GC Clip Region Routines</title>
+<para>
+The GC clientClip field requires three procedures to manage it.  These
+procedures are in the GC funcs vector.  The underlying principle is that dix
+knows nothing about the internals of the clipping information, (except when
+it has come from the client), and so calls ddX whenever it needs to copy,
+set, or destroy such information.  It could have been possible for dix not
+to allow ddX to touch the field in the GC, and require it to keep its own
+copy in devPriv, but since clip masks can be very large, this seems like a
+bad idea.  Thus, the server allows ddX to do whatever it wants to the
+clientClip field of the GC, but requires it to do all manipulation itself.</para>
+<para>
+<blockquote><programlisting>
+
+	void pGC->funcs->ChangeClip(pGC, type, pValue, nrects)
+		GCPtr pGC;
+		int type;
+		char *pValue;
+		int nrects;
+
+</programlisting></blockquote>
+This routine is called whenever the client changes the client clip
+region.  The pGC points to the GC involved, the type tells what form
+the region has been sent in.  If type is CT_NONE, then there is no
+client clip.  If type is CT_UNSORTED, CT_YBANDED or CT_YXBANDED, then
+pValue pointer to a list of rectangles, nrects long.  If type is
+CT_REGION, then pValue pointer to a RegionRec from the mi region code.
+If type is CT_PIXMAP pValue is a pointer to a pixmap.  (The defines
+for CT_NONE, etc. are in Xserver/include/gc.h.)  This routine is
+responsible for incrementing any necessary reference counts (e.g. for
+a pixmap clip mask) for the new clipmask and freeing anything that
+used to be in the GC's clipMask field.  The lists of rectangles passed
+in can be freed with Xfree(), the regions can be destroyed with the
+RegionDestroy field in the screen, and pixmaps can be destroyed by
+calling the screen's DestroyPixmap function.  DIX and MI code expect
+what they pass in to this to be freed or otherwise inaccessible, and
+will never look inside what's been put in the GC.  This is a good
+place to be wary of storage leaks.</para>
+<para>
+In the sample server, this routine transforms either the bitmap or the
+rectangle list into a region, so that future routines will have a more
+predictable starting point to work from.  (The validate routine must
+take this client clip region and merge it with other regions to arrive
+at a composite clip region before any drawing is done.)</para>
+<para>
+<blockquote><programlisting>
+
+	void pGC->funcs->DestroyClip(pGC)
+		GCPtr pGC;
+
+</programlisting></blockquote>
+This routine is called whenever the client clip region must be destroyed.
+The pGC points to the GC involved.  This call should set the clipType
+field of the GC to CT_NONE.
+In the sample server, the pointer to the client clip region is set to NULL
+by this routine after destroying the region, so that other software
+(including ChangeClip() above) will recognize that there is no client clip region.</para>
+<para>
+<blockquote><programlisting>
+
+	void pGC->funcs->CopyClip(pgcDst, pgcSrc)
+		GCPtr pgcDst, pgcSrc;
+
+</programlisting></blockquote>
+This routine makes a copy of the clipMask and clipType from pgcSrc
+into pgcDst.  It is responsible for destroying any previous clipMask
+in pgcDst.  The clip mask in the source can be the same as the
+clip mask in the dst (clients do the strangest things), so care must
+be taken when destroying things.  This call is required because dix
+does not know how to copy the clip mask from pgcSrc.</para>
+</section>
+</section>
+<section>
+  <title>Drawing Primitives</title>
+<para>
+The X protocol (rules for the byte stream that goes between client and server)
+does all graphics using primitive
+operations, which are called Drawing Primitives.
+These include line drawing, area filling, arcs, and text drawing.
+Your implementation must supply 16 routines
+to perform these on your hardware.
+(The number 16 is arbitrary.)</para>
+<para>
+More specifically, 16 procedure pointers are in each
+GC op vector.
+At any given time, ALL of them MUST point to a valid procedure that
+attempts to do the operation assigned, although
+the procedure pointers may change and may
+point to different procedures to carry out the same operation.
+A simple server will leave them all pointing to the same 16 routines, while
+a more optimized implementation will switch each from one
+procedure to another, depending upon what is most optimal
+for the current GC and drawable.</para>
+<para>
+The sample server contains a considerable chunk of code called the
+mi (machine independent)
+routines, which serve as drawing primitive routines.
+Many server implementations will be able to use these as-is,
+because they work for arbitrary depths.
+They make no assumptions about the formats of pixmaps
+and frame buffers, since they call a set of routines
+known as the "Pixblit Routines" (see next section).
+They do assume that the way to draw is
+through these low-level routines that apply pixel values rows at a time.
+If your hardware or firmware gives more performance when
+things are done differently, you will want to take this fact into account
+and rewrite some or all of the drawing primitives to fit your needs.</para>
+<section>
+  <title>GC Components</title>
+<para>
+This section describes the fields in the GC that affect each drawing primitive.
+The only primitive that is not affected is GetImage, which does not use a GC
+because its destination is a protocol-style bit image.
+Since each drawing primitive mirrors exactly the X protocol request of the
+same name, you should refer to the X protocol specification document
+for more details.</para>
+<para>
+ALL of these routines MUST CLIP to the
+appropriate regions in the drawable.
+Since there are many regions to clip to simultaneously,
+your ValidateGC routine should combine these into a unified
+clip region to which your drawing routines can quickly refer.
+This is exactly what the fb routines supplied with the sample server
+do.
+The mi implementation passes responsibility for clipping while drawing
+down to the Pixblit routines.</para>
+<para>
+Also, all of them must adhere to the current plane mask.
+The plane mask has one bit for every bit plane in the drawable;
+only planes with 1 bits in the mask are affected by any drawing operation.</para>
+<para>
+All functions except for ImageText calls must obey the alu function.
+This is usually Copy, but could be any of the allowable 16 raster-ops.</para>
+<para>
+All of the functions, except for CopyArea, might use the current
+foreground and background pixel values.
+Each pixel value is 32 bits.
+These correspond to foreground and background colors, but you have
+to run them through the colormap to find out what color the pixel values
+represent.  Do not worry about the color, just apply the pixel value.</para>
+<para>
+The routines that draw lines (PolyLine, PolySegment, PolyRect, and PolyArc)
+use the line width, line style, cap style, and join style.
+Line width is in pixels.
+The line style specifies whether it is solid or dashed, and what kind of dash.
+The cap style specifies whether Rounded, Butt, etc.
+The join style specifies whether joins between joined lines are Miter, Round or Beveled.
+When lines cross as part of the same polyline, they are assumed to be drawn once.
+(See the X protocol specification for more details.)</para>
+<para>
+Zero-width lines are NOT meant to be really zero width; this is the client's way
+of telling you that you can optimize line drawing with little regard to
+the end caps and joins.
+They are called "thin" lines and are meant to be one pixel wide.
+These are frequently done in hardware or in a streamlined assembly language
+routine.</para>
+<para>
+Lines with widths greater than zero, though, must all be drawn with the same
+algorithm, because client software assumes that every jag on every
+line at an angle will come at the same place.
+Two lines that should have
+one pixel in the space between them
+(because of their distance apart and their widths) should have such a one-pixel line
+of space between them if drawn, regardless of angle.</para>
+<para>
+The solid area fill routines (FillPolygon, PolyFillRect, PolyFillArc)
+all use the fill rule, which specifies subtle interpretations of
+what points are inside and what are outside of a given polygon.
+The PolyFillArc routine also uses the arc mode, which specifies
+whether to fill pie segments or single-edge slices of an ellipse.</para>
+<para>
+The line drawing, area fill, and PolyText routines must all
+apply the correct "fill style."
+This can be either a solid foreground color, a transparent stipple,
+an opaque stipple, or a tile.
+Stipples are bitmaps where the 1 bits represent that the foreground color is written,
+and 0 bits represent that either the pixel is left alone (transparent) or that
+the background color is written (opaque).
+A tile is a pixmap of the full depth of the GC that is applied in its full glory to all areas.
+The stipple and tile patterns can be any rectangular size, although some implementations
+will be faster for certain sizes such as 8x8 or 32x32.
+The mi implementation passes this responsibility down to the Pixblit routines.</para>
+<para>
+See the X protocol document for full details.
+The description of the CreateGC request has a very good, detailed description of these
+attributes.</para>
+</section>
+<section>
+<title>The Primitives</title>
+<para>
+The Drawing Primitives are as follows:
+
+<blockquote><programlisting>
+
+	RegionPtr pGC->ops->CopyArea(src, dst, pGC, srcx, srcy, w, h, dstx, dsty)
+		DrawablePtr dst, src;
+		GCPtr pGC;
+		int srcx, srcy, w, h, dstx, dsty;
+
+</programlisting></blockquote>
+CopyArea copies a rectangle of pixels from one drawable to another of
+the same depth.  To effect scrolling, this must be able to copy from
+any drawable to itself, overlapped.  No squeezing or stretching is done
+because the source and destination are the same size.  However,
+everything is still clipped to the clip regions of the destination
+drawable.</para>
+<para>
+If pGC->graphicsExposures is True, any portions of the destination which
+were not valid in the source (either occluded by covering windows, or
+outside the bounds of the drawable) should be collected together and
+returned as a region (if this resultant region is empty, NULL can be
+returned instead).  Furthermore, the invalid bits of the source are
+not copied to the destination and (when the destination is a window)
+are filled with the background tile.  The sample routine
+miHandleExposures generates the appropriate return value and fills the
+invalid area using pScreen->PaintWindowBackground.</para>
+<para>
+For instance, imagine a window that is partially obscured by other
+windows in front of it.  As text is scrolled on your window, the pixels
+that are scrolled out from under obscuring windows will not be
+available on the screen to copy to the right places, and so an exposure
+event must be sent for the client to correctly repaint them.  Of
+course, if you implement backing store, you could do this without resorting
+to exposure events.</para>
+<para>
+An example implementation is fbCopyArea() in Xserver/fb/fbcopy.c.</para>
+<para>
+<blockquote><programlisting>
+
+	RegionPtr pGC->ops->CopyPlane(src, dst, pGC, srcx, srcy, w, h, dstx, dsty, plane)
+		DrawablePtr dst, src;
+		GCPtr pGC;
+		int srcx, srcy, w, h, dstx, dsty;
+		unsigned long plane;
+
+</programlisting></blockquote>
+CopyPlane must copy one plane of a rectangle from the source drawable
+onto the destination drawable.  Because this routine only copies one
+bit out of each pixel, it can copy between drawables of different
+depths.  This is the only way of copying between drawables of
+different depths, except for copying bitmaps to pixmaps and applying
+foreground and background colors to it.  All other conditions of
+CopyArea apply to CopyPlane too.</para>
+<para>
+An example implementation is fbCopyPlane() in
+Xserver/fb/fbcopy.c.</para>
+<para>
+<blockquote><programlisting>
+
+	void pGC->ops->PolyPoint(dst, pGC, mode, n, pPoint)
+		DrawablePtr dst;
+		GCPtr pGC;
+		int mode;
+		int n;
+		DDXPointPtr pPoint;
+
+</programlisting></blockquote>
+PolyPoint draws a set of one-pixel dots (foreground color)
+at the locations given in the array.
+mode is one of the defined constants Origin (absolute coordinates) or Previous
+(each coordinate is relative to the last).
+Note that this does not use the background color or any tiles or stipples.</para>
+<para>
+Example implementations are fbPolyPoint() in Xserver/fb/fbpoint.c and
+miPolyPoint in Xserver/mi/mipolypnt.c.</para>
+<para>
+<blockquote><programlisting>
+
+	void pGC->ops->Polylines(dst, pGC, mode, n, pPoint)
+		DrawablePtr dst;
+		GCPtr pGC;
+		int mode;
+		int n;
+		DDXPointPtr pPoint;
+
+</programlisting></blockquote>
+Similar to PolyPoint, Polylines draws lines between the locations given in the array.
+Zero-width lines are NOT meant to be really zero width; this is the client's way of
+telling you that you can maximally optimize line drawing with little regard to
+the end caps and joins.
+mode is one of the defined constants Previous or Origin, depending upon
+whether the points are each relative to the last or are absolute.</para>
+<para>
+Example implementations are miWideLine() and miWideDash() in
+mi/miwideline.c and miZeroLine() in mi/mizerline.c.</para>
+<para>
+<blockquote><programlisting>
+
+	void pGC->ops->PolySegment(dst, pGC, n, pPoint)
+		DrawablePtr dst;
+		GCPtr pGC;
+		int n;
+		xSegment *pSegments;
+
+</programlisting></blockquote>
+PolySegments draws unconnected
+lines between pairs of points in the array; the array must be of
+even size; no interconnecting lines are drawn.</para>
+<para>
+An example implementation is miPolySegment() in mipolyseg.c.</para>
+<para>
+<blockquote><programlisting>
+
+	void pGC->ops->PolyRectangle(dst, pGC, n, pRect)
+		DrawablePtr dst;
+		GCPtr pGC;
+		int n;
+		xRectangle *pRect;
+
+</programlisting></blockquote>
+PolyRectangle draws outlines of rectangles for each rectangle in the array.</para>
+<para>
+An example implementation is miPolyRectangle() in Xserver/mi/mipolyrect.c.</para>
+<para>
+<blockquote><programlisting>
+
+	void pGC->ops->PolyArc(dst, pGC, n, pArc)
+		DrawablePtr dst;
+		GCPtr pGC;
+		int n;
+		xArc*pArc;
+
+</programlisting></blockquote>
+PolyArc draws connected conic arcs according to the descriptions in the array.
+See the protocol specification for more details.</para>
+<para>
+Example implementations are miZeroPolyArc in Xserver/mi/mizerarc. and
+miPolyArc() in Xserver/mi/miarc.c.</para>
+<para>
+<blockquote><programlisting>
+
+	void pGC->ops->FillPolygon(dst, pGC, shape, mode, count, pPoint)
+		DrawablePtr dst;
+		GCPtr pGC;
+		int shape;
+		int mode;
+		int count;
+		DDXPointPtr pPoint;
+
+</programlisting></blockquote>
+FillPolygon fills a polygon specified by the points in the array
+with the appropriate fill style.
+If necessary, an extra border line is assumed between the starting and ending lines.
+The shape can be used as a hint
+to optimize filling; it indicates whether it is convex (all interior angles
+less than 180), nonconvex (some interior angles greater than 180 but
+border does not cross itself), or complex (border crosses itself).
+You can choose appropriate algorithms or hardware based upon mode.
+mode is one of the defined constants Previous or Origin, depending upon
+whether the points are each relative to the last or are absolute.</para>
+<para>
+An example implementation is miFillPolygon() in Xserver/mi/mipoly.c.</para>
+<para>
+<blockquote><programlisting>
+
+	void pGC->ops->PolyFillRect(dst, pGC, n, pRect)
+		DrawablePtr dst;
+		GCPtr pGC;
+		int n;
+		xRectangle *pRect;
+
+</programlisting></blockquote>
+PolyFillRect fills multiple rectangles.</para>
+<para>
+Example implementations are fbPolyFillRect() in Xserver/fb/fbfillrect.c and
+miPolyFillRect() in Xserver/mi/mifillrct.c.</para>
+<para>
+<blockquote><programlisting>
+
+	void pGC->ops->PolyFillArc(dst, pGC, n, pArc)
+		DrawablePtr dst;
+		GCPtr pGC;
+		int n;
+		xArc *pArc;
+
+</programlisting></blockquote>
+PolyFillArc fills a shape for each arc in the
+list that is bounded by the arc and one or two
+line segments with the current fill style.</para>
+<para>
+An example implementation is miPolyFillArc() in Xserver/mi/mifillarc.c.</para>
+<para>
+<blockquote><programlisting>
+
+	void pGC->ops->PutImage(dst, pGC, depth, x, y, w, h, leftPad, format, pBinImage)
+		DrawablePtr dst;
+		GCPtr pGC;
+		int x, y, w, h;
+		int format;
+		char *pBinImage;
+
+</programlisting></blockquote>
+PutImage copies a pixmap image into the drawable.  The pixmap image
+must be in X protocol format (either Bitmap, XYPixmap, or ZPixmap),
+and format tells the format.  (See the X protocol specification for
+details on these formats).  You must be able to accept all three
+formats, because the client gets to decide which format to send.
+Either the drawable and the pixmap image have the same depth, or the
+source pixmap image must be a Bitmap.  If a Bitmap, the foreground and
+background colors will be applied to the destination.</para>
+<para>
+An example implementation is fbPutImage() in Xserver/fb/fbimage.c.</para>
+<para>
+<blockquote><programlisting>
+
+	void pScreen->GetImage(src, x, y, w, h, format, planeMask, pBinImage)
+		 DrawablePtr src;
+		 int x, y, w, h;
+		 unsigned int format;
+		 unsigned long planeMask;
+		 char *pBinImage;
+
+</programlisting></blockquote>
+GetImage copies the bits from the source drawable into
+the destination pointer.  The bits are written into the buffer
+according to the server-defined pixmap padding rules.
+pBinImage is guaranteed to be big enough to hold all
+the bits that must be written.</para>
+<para>
+This routine does not correspond exactly to the X protocol GetImage
+request, since DIX has to break the reply up into buffers of a size
+requested by the transport layer.  If format is ZPixmap, the bits are
+written in the ZFormat for the depth of the drawable; if there is a 0
+bit in the planeMask for a particular plane, all pixels must have the
+bit in that plane equal to 0.  If format is XYPixmap, planemask is
+guaranteed to have a single bit set; the bits should be written in
+Bitmap format, which is the format for a single plane of an XYPixmap.</para>
+<para>
+An example implementation is miGetImage() in Xserver/mi/mibitblt.c.
+<blockquote><programlisting>
+
+	void pGC->ops->ImageText8(pDraw, pGC, x, y, count, chars)
+		DrawablePtr pDraw;
+		GCPtr pGC;
+		int x, y;
+		int count;
+		char *chars;
+
+</programlisting></blockquote>
+ImageText8 draws text.  The text is drawn in the foreground color; the
+background color fills the remainder of the character rectangles.  The
+coordinates specify the baseline and start of the text.</para>
+<para>
+An example implementation is miImageText8() in Xserver/mi/mipolytext.c.</para>
+<para>
+<blockquote><programlisting>
+
+	int pGC->ops->PolyText8(pDraw, pGC, x, y, count, chars)
+		DrawablePtr pDraw;
+		GCPtr pGC;
+		int x, y;
+		int count;
+		char *chars;
+
+</programlisting></blockquote>
+PolyText8 works like ImageText8, except it draws with
+the current fill style for special effects such as
+shaded text.
+See the X protocol specification for more details.</para>
+<para>
+An example implementation is miPolyText8() in Xserver/mi/mipolytext.c.</para>
+<para>
+<blockquote><programlisting>
+
+	int pGC->ops->PolyText16(pDraw, pGC, x, y, count, chars)
+		DrawablePtr pDraw;
+		GCPtr pGC;
+		int x, y;
+		int count;
+		unsigned short *chars;
+
+	void pGC->ops->ImageText16(pDraw, pGC, x, y, count, chars)
+		DrawablePtr pDraw;
+		GCPtr pGC;
+		int x, y;
+		int count;
+		unsigned short *chars;
+
+</programlisting></blockquote>
+These two routines are the same as the "8" versions,
+except that they are for 16-bit character codes (useful
+for oriental writing systems).</para>
+<para>
+The primary difference is in the way the character information is
+looked up.  The 8-bit and the 16-bit versions obviously have different
+kinds of character values to look up; the main goal of the lookup is
+to provide a pointer to the CharInfo structs for the characters to
+draw and to pass these pointers to the Glyph routines.  Given a
+CharInfo struct, lower-level software can draw the glyph desired with
+little concern for other characteristics of the font.</para>
+<para>
+16-bit character fonts have a row-and-column scheme, where the 2bytes
+of the character code constitute the row and column in a square matrix
+of CharInfo structs.  Each font has row and column minimum and maximum
+values; the CharInfo structures form a two-dimensional matrix.</para>
+<para>
+Example implementations are miPolyText16() and
+miImageText16() in Xserver/mi/mipolytext.c.</para>
+<para>
+See the X protocol specification for more details on these graphic operations.</para>
+<para>
+There is a hook in the GC ops, called LineHelper, that used to be used in the
+sample implementation by the code for wide lines.  It no longer servers any
+purpose in the sample servers, but still exists, #ifdef'ed by NEED_LINEHELPER,
+in case someone needs it.</para>
+</section>
+</section>
+<section>
+  <title>Pixblit Procedures</title>
+<para>
+The Drawing Primitive functions must be defined for your server.
+One possible way to do this is to use the mi routines from the sample server.
+If you choose to use the mi routines (even part of them!) you must implement
+these Pixblit routines.
+These routines read and write pixel values
+and deal directly with the image data.</para>
+<para>
+The Pixblit routines for the sample server are part of the "fb"
+routines.  As with the mi routines, the fb routines are
+portable but are not as portable as the mi routines.</para>
+<para>
+The fb subsystem is a depth-independent framebuffer core, capable of
+operating at any depth from 1 to 32, based on the depth of the window
+or pixmap it is currently operating on.  In particular, this means it
+can support pixmaps of multiple depths on the same screen.  It supplies
+both Pixblit routines and higher-level optimized implementations of the
+Drawing Primitive routines.  It does make the assumption that the pixel
+data it touches is available in the server's address space.</para>
+<para>
+In other words, if you have a "normal" frame buffer type display, you
+can probably use the fb code, and the mi code.  If you
+have a stranger hardware, you will have to supply your own Pixblit
+routines, but you can use the mi routines on top of them.  If you have
+better ways of doing some of the Drawing Primitive functions, then you
+may want to supply some of your own Drawing Primitive routines.  (Even
+people who write their own Drawing Primitives save at least some of
+the mi code for certain special cases that their hardware or library
+or fancy algorithm does not handle.)</para>
+<para>
+The client, DIX, and the machine-independent routines do not carry the
+final responsibility of clipping.  They all depend upon the Pixblit
+routines to do their clipping for them.  The rule is, if you touch the
+frame buffer, you clip.</para>
+<para>
+(The higher level routines may decide to clip at a high level, but
+this is only for increased performance and cannot substitute for
+bottom-level clipping.  For instance, the mi routines, DIX, or the
+client may decide to check all character strings to be drawn and chop
+off all characters that would not be displayed.  If so, it must retain
+the character on the edge that is partly displayed so that the Pixblit
+routines can clip off precisely at the right place.)</para>
+<para>
+To make this easier, all of the reasons to clip can be combined into
+one region in your ValidateGC procedure.  You take this composite clip
+region with you into the Pixblit routines.  (The sample server does
+this.)</para>
+<para>
+Also, FillSpans() has to apply tile and stipple patterns.  The
+patterns are all aligned to the window origin so that when two people
+write patches that are contiguous, they will merge nicely.  (Really,
+they are aligned to the patOrg point in the GC.  This defaults to (0,
+0) but can be set by the client to anything.)</para>
+<para>
+However, the mi routines can translate (relocate) the points from
+window-relative to screen-relative if desired.  If you set the
+miTranslate field in the GC (set it in the CreateGC or ValidateGC
+routine), then the mi output routines will translate all coordinates.
+If it is false, then the coordinates will be passed window-relative.
+Screens with no hardware translation will probably set miTranslate to
+TRUE, so that geometry (e.g. polygons, rectangles) can be translated,
+rather than having the resulting list of scanlines translated; this is
+good because the list vertices in a drawing request will generally be
+much smaller than the list of scanlines it produces.  Similarly,
+hardware that does translation can set miTranslate to FALSE, and avoid
+the extra addition per vertex, which can be (but is not always)
+important for getting the highest possible performance.  (Contrast the
+behavior of GetSpans, which is not expected to be called as often, and
+so has different constraints.)  The miTranslate field is settable in
+each GC, if , for example, you are mixing several kinds of
+destinations (offscreen pixmaps, main memory pixmaps, backing store,
+and windows), all of which have different requirements, on one screen.</para>
+<para>
+As with other drawing routines, there are fields in the GC to direct
+higher code to the correct routine to execute for each function.  In
+this way, you can optimize for special cases, for example, drawing
+solids versus drawing stipples.</para>
+<para>
+The Pixblit routines are broken up into three sets.  The Span routines
+simply fill in rows of pixels.  The Glyph routines fill in character
+glyphs.  The PushPixels routine is a three-input bitblt for more
+sophisticated image creation.</para>
+<para>
+It turns out that the Glyph and PushPixels routines actually have a
+machine-independent implementation that depends upon the Span
+routines.  If you are really pressed for time, you can use these
+versions, although they are quite slow.</para>
+<section>
+<title>Span Routines</title>
+<para>
+For these routines, all graphic operations have been reduced to "spans."
+A span is a horizontal row of pixels.
+If you can design these routines which write into and read from
+rows of pixels at a time, you can use the mi routines.</para>
+<para>
+Each routine takes
+a destination drawable to draw into, a GC to use while drawing,
+the number of spans to do, and two pointers to arrays that indicate the list
+of starting points and the list of widths of spans.</para>
+<para>
+<blockquote><programlisting>
+
+	void pGC->ops->FillSpans(dst, pGC, nSpans, pPoints, pWidths, sorted)
+		DrawablePtr dst;
+		GCPtr pGC;
+		int nSpans;
+		DDXPointPtr pPoints;
+		int *pWidths;
+		int sorted;
+
+</programlisting></blockquote>
+FillSpans should fill horizontal rows of pixels with
+the appropriate patterns, stipples, etc.,
+based on the values in the GC.
+The starting points are in the array at pPoints; the widths are in pWidths.
+If sorted is true, the scan lines are in increasing y order, in which case
+you may be able to make assumptions and optimizations.</para>
+<para>
+GC components: alu, clipOrg, clientClip, and fillStyle.</para>
+<para>
+GC mode-dependent components: fgPixel (for fillStyle Solid); tile, patOrg
+(for fillStyle Tile); stipple, patOrg, fgPixel (for fillStyle Stipple);
+and stipple, patOrg, fgPixel and bgPixel (for fillStyle OpaqueStipple).</para>
+<para>
+<blockquote><programlisting>
+
+	void pGC->ops->SetSpans(pDrawable, pGC, pSrc, ppt, pWidths, nSpans, sorted)
+		DrawablePtr pDrawable;
+		GCPtr pGC;
+		char *pSrc;
+		DDXPointPtr pPoints;
+		int *pWidths;
+		int nSpans;
+		int sorted;
+
+</programlisting></blockquote>
+For each span, this routine should copy pWidths bits from pSrc to
+pDrawable at pPoints using the raster-op from the GC.
+If sorted is true, the scan lines are in increasing y order.
+The pixels in pSrc are
+padded according to the screen's padding rules.
+These
+can be used to support
+interesting extension libraries, for example, shaded primitives.   It does not
+use the tile and stipple.</para>
+<para>
+GC components: alu, clipOrg, and clientClip</para>
+<para>
+The above functions are expected to handle all modifiers in the current
+GC.  Therefore, it is expedient to have
+different routines to quickly handle common special cases
+and reload the procedure pointers
+at validate time, as with the other output functions.</para>
+<para>
+<blockquote><programlisting>
+
+	void pScreen->GetSpans(pDrawable, wMax, pPoints, pWidths, nSpans)
+		DrawablePtr pDrawable;
+		int wMax;
+		DDXPointPtr pPoints;
+		int *pWidths;
+		int nSpans;
+		char *pDst;
+
+</programlisting></blockquote>
+For each span, GetSpans gets bits from the drawable starting at pPoints
+and continuing for pWidths bits.
+Each scanline returned will be server-scanline padded.
+The routine can return NULL if memory cannot be allocated to hold the
+result.</para>
+<para>
+GetSpans never translates -- for a window, the coordinates are already
+screen-relative.  Consider the case of hardware that doesn't do
+translation: the mi code that calls ddX will translate each shape
+(rectangle, polygon,. etc.) before scan-converting it, which requires
+many fewer additions that having GetSpans translate each span does.
+Conversely, consider hardware that does translate: it can set its
+translation point to (0, 0) and get each span, and the only penalty is
+the small number of additions required to translate each shape being
+scan-converted by the calling code.  Contrast the behavior of
+FillSpans and SetSpans (discussed above under miTranslate), which are
+expected to be used more often.</para>
+<para>
+Thus, the penalty to hardware that does hardware translation is
+negligible, and code that wants to call GetSpans() is greatly
+simplified, both for extensions and the machine-independent core
+implementation.</para>
+<section>
+  <title>Glyph Routines</title>
+<para>
+The Glyph routines draw individual character glyphs for text drawing requests.</para>
+<para>
+You have a choice in implementing these routines.  You can use the mi
+versions; they depend ultimately upon the span routines.  Although
+text drawing will work, it will be very slow.</para>
+<para>
+<blockquote><programlisting>
+
+	void pGC->ops->PolyGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase)
+		DrawablePtr pDrawable;
+		GCPtr pGC;
+		int x , y;
+		unsigned int nglyph;
+		CharInfoRec **ppci;		/* array of character info */
+		pointer unused;			/* unused since R5 */
+
+</programlisting></blockquote>
+GC components: alu, clipOrg, clientClip, font, and fillStyle.</para>
+<para>
+GC mode-dependent components: fgPixel (for fillStyle Solid); tile, patOrg
+(for fillStyle Tile); stipple, patOrg, fgPixel (for fillStyle Stipple);
+and stipple, patOrg, fgPixel and bgPixel (for fillStyle OpaqueStipple).</para>
+<para>
+<blockquote><programlisting>
+
+	void pGC->ops->ImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase)
+		DrawablePtr pDrawable;
+		GCPtr pGC;
+		int x , y;
+		unsigned int nglyph;
+		CharInfoRec **ppci;	/* array of character info */
+		pointer unused;		/* unused since R5 */
+
+</programlisting></blockquote>
+GC components: clipOrg, clientClip, font, fgPixel, bgPixel</para>
+<para>
+These routines must copy the glyphs defined by the bitmaps in
+pglyphBase and the font metrics in ppci to the DrawablePtr, pDrawable.
+The poly routine follows all fill, stipple, and tile rules.  The image
+routine simply blasts the glyph onto the glyph's rectangle, in
+foreground and background colors.</para>
+<para>
+More precisely, the Image routine fills the character rectangle with
+the background color, and then the glyph is applied in the foreground
+color.  The glyph can extend outside of the character rectangle.
+ImageGlyph() is used for terminal emulators and informal text purposes
+such as button labels.</para>
+<para>
+The exact specification for the Poly routine is that the glyph is
+painted with the current fill style.  The character rectangle is
+irrelevant for this operation.  PolyText, at a higher level, includes
+facilities for font changes within strings and such; it is to be used
+for WYSIWYG word processing and similar systems.</para>
+<para>
+Both of these routines must clip themselves to the overall clipping region.</para>
+<para>
+Example implementations in mi are miPolyGlyphBlt() and
+miImageGlyphBlt() in Xserver/mi/miglblt.c.</para>
+</section>
+<section>
+<title>PushPixels routine</title>
+<para>
+The PushPixels routine writes the current fill style onto the drawable
+in a certain shape defined by a bitmap.  PushPixels is equivalent to
+using a second stipple.  You can thing of it as pushing the fillStyle
+through a stencil.  PushPixels is not used by any of the mi rendering code,
+but is used by the mi software cursor code.
+<blockquote><para>
+	Suppose the stencil is:	00111100
+	and the stipple is:	10101010
+	PushPixels result:	00101000
+</para></blockquote>
+</para>
+<para>
+You have a choice in implementing this routine.
+You can use the mi version which depends ultimately upon FillSpans().
+Although it will work, it will be slow.</para>
+<para>
+<blockquote><programlisting>
+
+	void pGC->ops->PushPixels(pGC, pBitMap, pDrawable, dx, dy, xOrg, yOrg)
+		GCPtr pGC;
+		PixmapPtr pBitMap;
+		DrawablePtr pDrawable;
+		int dx, dy, xOrg, yOrg;
+
+</programlisting></blockquote>
+GC components: alu, clipOrg, clientClip, and fillStyle.</para>
+<para>
+GC mode-dependent components: fgPixel (for fillStyle Solid); tile, patOrg
+(for fillStyle Tile); stipple, patOrg, fgPixel (for fillStyle Stipple);
+and stipple, patOrg, fgPixel and bgPixel (for fillStyle OpaqueStipple).</para>
+<para>
+PushPixels applys the foreground color, tile, or stipple from the pGC
+through a stencil onto pDrawable.  pBitMap points to a stencil (of
+which we use an area dx wide by dy high), which is oriented over the
+drawable at xOrg, yOrg.  Where there is a 1 bit in the bitmap, the
+destination is set according to the current fill style.  Where there
+is a 0 bit in the bitmap, the destination is left the way it is.</para>
+<para>
+This routine must clip to the overall clipping region.</para>
+<para>
+An Example implementation is miPushPixels() in Xserver/mi/mipushpxl.c.</para>
+</section>
+</section>
+</section>
+<section>
+  <title>Shutdown Procedures</title>
+<para>
+<blockquote><programlisting>
+	void AbortDDX()
+	void ddxGiveUp()
+</programlisting></blockquote>
+Some hardware may require special work to be done before the server
+exits so that it is not left in an intermediate state.  As explained
+in the OS layer, FatalError() will call AbortDDX() just before
+terminating the server.  In addition, ddxGiveUp() will be called just
+before terminating the server on a "clean" death.  What AbortDDX() and
+ddxGiveUP do is left unspecified, only that stubs must exist in the
+ddx layer.  It is up to local implementors as to what they should
+accomplish before termination.</para>
+<section>
+  <title>Command Line Procedures</title>
+<para>
+<blockquote><programlisting>
+	int ddxProcessArgument(argc, argv, i)
+	    int argc;
+	    char *argv[];
+	    int i;
+
+	void
+	ddxUseMsg()
+
+</programlisting></blockquote>
+You should write these routines to deal with device-dependent command line
+arguments.  The routine ddxProcessArgument() is called with the command line,
+and the current index into argv; you should return zero if the argument
+is not a device-dependent one, and otherwise return a count of the number
+of elements of argv that are part of this one argument.  For a typical
+option (e.g., "-realtime"), you should return the value one.  This
+routine gets called before checks are made against device-independent
+arguments, so it is possible to peek at all arguments or to override
+device-independent argument processing.  You can document the
+device-dependent arguments in ddxUseMsg(), which will be
+called from UseMsg() after printing out the device-independent arguments.</para>
+</section>
+</section>
+<section id="wrappers_and_privates">
+  <title>Wrappers and Privates</title>
+<para>
+Two new extensibility concepts have been developed for release 4, Wrappers
+and devPrivates.  These replace the R3 GCInterest queues, which were not a
+general enough mechanism for many extensions and only provided hooks into a
+single data structure.  devPrivates have been revised substantially for
+X.Org X server release 1.5, and updated again for the 1.9 release.</para>
+<section>
+  <title>devPrivates</title>
+<para>
+devPrivates provides a way to attach arbitrary private data to various server structures.
+Any structure which contains a <structfield>devPrivates</structfield> field of
+type <type>PrivateRec</type> supports this mechanism.  Some structures allow
+allocating space for private data after some objects have been created, others
+require all space allocations be registered before any objects of that type
+are created.  <filename class="headerfile">Xserver/include/privates.h</filename>
+lists which of these cases applies to each structure containing
+<structfield>devPrivates</structfield>.</para>
+
+<para>
+To request private space, use
+<blockquote><programlisting>
+	Bool dixRegisterPrivateKey(DevPrivateKey key, DevPrivateType type, unsigned size);
+</programlisting></blockquote>
+The first argument is a pointer to a <type>DevPrivateKeyRec</type> which
+will serve as the unique identifier for the private data.  Typically this is
+the address of a static <type>DevPrivateKeyRec</type> in your code.
+The second argument is the class of objects for which this key will apply.
+The third argument is the size of the space being requested, or
+<constant>0</constant> to only allocate a pointer that the caller will manage.
+If space is requested, this space will be automatically freed when the object
+is destroyed.  Note that a call to <function>dixSetPrivate</function>
+that changes the pointer value may cause the space to be unreachable by the caller, however it will still be automatically freed.
+The function returns <literal>TRUE</literal> unless memory allocation fails.
+If the function is called more than once on the same key, all calls must use
+the same value for <type>size</type> or the server will abort.</para>
+
+<para>
+To request per-screen private space in an object, use
+<blockquote><programlisting>
+	Bool dixRegisterScreenPrivateKey(DevScreenPrivateKey key, ScreenPtr pScreen, DevPrivateType type, unsigned size);
+</programlisting></blockquote>
+The <parameter>type</parameter> and <parameter>size</parameter> arguments are
+the same as those to <function>dixRegisterPrivateKey</function> but this
+function ensures the given <parameter>key</parameter> exists on objects of
+the specified type with distinct storage for the given
+<parameter>pScreen</parameter>. The key is usable on ScreenPrivate variants
+that are otherwise equivalent to the following Private functions.</para>
+
+<para>
+To attach a piece of private data to an object, use:
+<blockquote><programlisting>
+	void dixSetPrivate(PrivateRec **privates, const DevPrivateKey key, pointer val)
+</programlisting></blockquote>
+The first argument is the address of the <structfield>devPrivates</structfield>
+field in the target structure.  This field is managed privately by the DIX
+layer and should not be directly modified.  The second argument is a pointer
+to the <type>DevPrivateKeyRec</type> which you registered with
+<function>dixRegisterPrivateKey</function> or allocated with
+<function>dixCreatePrivateKey</function>.  Only one
+piece of data with a given key can be attached to an object, and in most cases
+each key is specific to the type of object it was registered for.   (An
+exception is the PRIVATE_XSELINUX class which applies to multiple object types.)
+The third argument is the value to store.</para>
+<para>
+If private data with the given key is already associated with the object,
+<function>dixSetPrivate</function> will overwrite the old value with the
+new one.</para>
+
+<para>
+To look up a piece of private data, use one of:
+<blockquote><programlisting>
+	pointer dixLookupPrivate(PrivateRec **privates, const DevPrivateKey key)
+	pointer *dixLookupPrivateAddr(PrivateRec **privates, const DevPrivateKey key)
+</programlisting></blockquote>
+The first argument is the address of the <structfield>devPrivates</structfield> field
+in the target structure.  The second argument is the key to look up.
+If a non-zero size was given when the key was registered, or if private data
+with the given key is already associated with the object, then
+<function>dixLookupPrivate</function> will return the pointer value
+while <function>dixLookupPrivateAddr</function>
+will return the address of the pointer.</para>
+
+<para>
+When implementing new server resource objects that support devPrivates, there
+are four steps to perform:
+Add a type value to the <type>DevPrivateType</type> enum in
+<filename class="headerfile">Xserver/include/privates.h</filename>,
+declare a field of type <type>PrivateRec *</type> in your structure;
+initialize this field to <literal>NULL</literal> when creating any objects; and
+when freeing any objects call the <function>dixFreePrivates</function> or
+<function>dixFreeObjectWithPrivates</function> function.</para>
+</section>
+<section>
+  <title>Wrappers</title>
+<para>
+Wrappers are not a body of code, nor an interface spec.  They are, instead,
+a technique for hooking a new module into an existing calling sequence.
+There are limitations on other portions of the server implementation which
+make using wrappers possible; limits on when specific fields of data
+structures may be modified.  They are intended as a replacement for
+GCInterest queues, which were not general enough to support existing
+modules; in particular software cursors needed more
+control over the activity.  The general mechanism for using wrappers is:
+<blockquote><programlisting>
+privateWrapperFunction (object, ...)
+	ObjectPtr	object;
+{
+	pre-wrapped-function-stuff ...
+
+	object->functionVector = dixLookupPrivate(&object->devPrivates, privateKey);
+	(*object->functionVector) (object, ...);
+	/*
+	 * this next line is occasionally required by the rules governing
+	 * wrapper functions.  Always using it will not cause problems.
+	 * Not using it when necessary can cause severe troubles.
+	 */
+	dixSetPrivate(&object->devPrivates, privateKey, object->functionVector);
+	object->functionVector = privateWrapperFunction;
+
+	post-wrapped-function-stuff ...
+}
+
+privateInitialize (object)
+	ObjectPtr	object;
+{
+	dixSetPrivate(&object->devPrivates, privateKey, object->functionVector);
+	object->functionVector = privateWrapperFunction;
+}
+</programlisting></blockquote>
+</para>
+<para>
+Thus the privateWrapperFunction provides hooks for performing work both
+before and after the wrapped function has been called; the process of
+resetting the functionVector is called "unwrapping" while the process of
+fetching the wrapped function and replacing it with the wrapping function
+is called "wrapping".  It should be clear that GCInterest queues could
+be emulated using wrappers.  In general, any function vectors contained in
+objects can be wrapped, but only vectors in GCs and Screens have been tested.</para>
+<para>
+Wrapping screen functions is quite easy; each vector is individually
+wrapped.  Screen functions are not supposed to change after initialization,
+so rewrapping is technically not necessary, but causes no problems.</para>
+<para>
+Wrapping GC functions is a bit more complicated.  GC's have two tables of
+function vectors, one hanging from gc->ops and the other from gc->funcs, which
+should be initially wrapped from a CreateGC wrapper.  Wrappers should modify
+only table pointers, not the contents of the tables, as they
+may be shared by more than one GC (and, in the case of funcs, are probably
+shared by all gcs).  Your func wrappers may change the GC funcs or ops
+pointers, and op wrappers may change the GC op pointers but not the funcs.</para>
+<para>
+Thus, the rule for GC wrappings is: wrap the funcs from CreateGC and, in each
+func wrapper, unwrap the ops and funcs, call down, and re-wrap.  In each op
+wrapper, unwrap the ops, call down, and rewrap afterwards.  Note that in
+re-wrapping you must save out the pointer you're replacing again.  This way the
+chain will be maintained when wrappers adjust the funcs/ops tables they use.</para>
+</section>
+</section>
+<section>
+    <title>Work Queue</title>
+<para>
+To queue work for execution when all clients are in a stable state (i.e.
+just before calling select() in WaitForSomething), call:
+<blockquote><programlisting>
+	Bool QueueWorkProc(function,client,closure)
+		Bool		(*function)();
+		ClientPtr	client;
+		pointer		closure;
+</programlisting></blockquote>
+</para>
+<para>
+When the server is about to suspend itself, the given function will be
+executed:
+<blockquote><programlisting>
+	(*function) (client, closure)
+</programlisting></blockquote>
+</para>
+<para>
+Neither client nor closure are actually used inside the work queue routines.</para>
+</section>
+</section>
+<section>
+  <title>Summary of Routines</title>
+<para>
+This is a summary of the routines discussed in this document.
+The procedure names are in alphabetical order.
+The Struct is the structure it is attached to; if blank, this
+procedure is not attached to a struct and must be named as shown.
+The sample server provides implementations in the following
+categories.  Notice that many of the graphics routines have both
+mi and fb implementations.</para>
+<para>
+<itemizedlist>
+<listitem><para>dix	portable to all systems; do not attempt to rewrite (Xserver/dix)</para></listitem>
+<listitem><para>os	routine provided in Xserver/os or Xserver/include/os.h</para></listitem>
+<listitem><para>ddx	frame buffer dependent (examples in Xserver/fb)</para></listitem>
+<listitem><para>mi	routine provided in Xserver/mi</para></listitem>
+<listitem><para>hd	hardware dependent (examples in many Xserver/hw directories)</para></listitem>
+<listitem><para>none	not implemented in sample implementation</para></listitem>
+</itemizedlist>
+</para>
+	<table frame="all" id="routines-1">
+	  <title>Server Routines (Page 1)</title>
+	  <tgroup cols='3' align='left' colsep='1' rowsep='1'>
+	    <thead>
+	      <row>
+		<entry>Procedure</entry>
+		<entry>Port</entry>
+		<entry>Struct</entry>
+	      </row>
+	    </thead>
+	    <tbody>
+<row><entry><function>ALLOCATE_LOCAL</function></entry><entry><literal>os</literal></entry><entry><para></para></entry></row>
+<row><entry><function>AbortDDX</function></entry><entry><literal>hd</literal></entry><entry><para></para></entry></row>
+<row><entry><function>AddCallback</function></entry><entry><literal>dix</literal></entry><entry><para></para></entry></row>
+<row><entry><function>AddEnabledDevice</function></entry><entry><literal>os</literal></entry><entry><para></para></entry></row>
+<row><entry><function>AddInputDevice</function></entry><entry><literal>dix</literal></entry><entry><para></para></entry></row>
+<row><entry><function>AddScreen</function></entry><entry><literal>dix</literal></entry><entry><para></para></entry></row>
+<row><entry><function>AdjustWaitForDelay</function></entry><entry><literal>os</literal></entry><entry><para></para></entry></row>
+<row><entry><function>Bell</function></entry><entry><literal>hd</literal></entry><entry><para>Device</para></entry></row>
+<row><entry><function>ChangeClip</function></entry><entry><literal>mi</literal></entry><entry><para>GC func</para></entry></row>
+<row><entry><function>ChangeGC</function></entry><entry><literal></literal></entry><entry><para>GC func</para></entry></row>
+<row><entry><function>ChangeWindowAttributes</function></entry><entry><literal>ddx</literal></entry><entry><para>Screen</para></entry></row>
+<row><entry><function>ClearToBackground</function></entry><entry><literal>ddx</literal></entry><entry><para>Window</para></entry></row>
+<row><entry><function>ClientAuthorized</function></entry><entry><literal>os</literal></entry><entry><para></para></entry></row>
+<row><entry><function>ClientSignal</function></entry><entry><literal>dix</literal></entry><entry><para></para></entry></row>
+<row><entry><function>ClientSleep</function></entry><entry><literal>dix</literal></entry><entry><para></para></entry></row>
+<row><entry><function>ClientWakeup</function></entry><entry><literal>dix</literal></entry><entry><para></para></entry></row>
+<row><entry><function>ClipNotify</function></entry><entry><literal>ddx</literal></entry><entry><para>Screen</para></entry></row>
+<row><entry><function>CloseScreen</function></entry><entry><literal>hd</literal></entry><entry><para></para></entry></row>
+<row><entry><function>ConstrainCursor</function></entry><entry><literal>hd</literal></entry><entry><para>Screen</para></entry></row>
+<row><entry><function>CopyArea</function></entry><entry><literal>mi</literal></entry><entry><para>GC op</para></entry></row>
+<row><entry><function>CopyGCDest</function></entry><entry><literal>ddx</literal></entry><entry><para>GC func</para></entry></row>
+<row><entry><function>CopyGCSource</function></entry><entry><literal>none</literal></entry><entry><para>GC func</para></entry></row>
+<row><entry><function>CopyPlane</function></entry><entry><literal>mi</literal></entry><entry><para>GC op</para></entry></row>
+<row><entry><function>CopyWindow</function></entry><entry><literal>ddx</literal></entry><entry><para>Window</para></entry></row>
+<row><entry><function>CreateGC</function></entry><entry><literal>ddx</literal></entry><entry><para>Screen</para></entry></row>
+<row><entry><function>CreateCallbackList</function></entry><entry><literal>dix</literal></entry><entry><para></para></entry></row>
+<row><entry><function>CreatePixmap</function></entry><entry><literal>ddx</literal></entry><entry><para>Screen</para></entry></row>
+<row><entry><function>CreateScreenResources</function></entry><entry><literal>ddx</literal></entry><entry><para>Screen</para></entry></row>
+<row><entry><function>CreateWellKnowSockets</function></entry><entry><literal>os</literal></entry><entry><para></para></entry></row>
+<row><entry><function>CreateWindow</function></entry><entry><literal>ddx</literal></entry><entry><para>Screen</para></entry></row>
+<row><entry><function>CursorLimits</function></entry><entry><literal>hd</literal></entry><entry><para>Screen</para></entry></row>
+<row><entry><function>DEALLOCATE_LOCAL</function></entry><entry><literal>os</literal></entry><entry><para></para></entry></row>
+<row><entry><function>DeleteCallback</function></entry><entry><literal>dix</literal></entry><entry><para></para></entry></row>
+<row><entry><function>DeleteCallbackList</function></entry><entry><literal>dix</literal></entry><entry><para></para></entry></row>
+<row><entry><function>DestroyClip</function></entry><entry><literal>ddx</literal></entry><entry><para>GC func</para></entry></row>
+<row><entry><function>DestroyGC</function></entry><entry><literal>ddx</literal></entry><entry><para>GC func</para></entry></row>
+<row><entry><function>DestroyPixmap</function></entry><entry><literal>ddx</literal></entry><entry><para>Screen</para></entry></row>
+<row><entry><function>DestroyWindow</function></entry><entry><literal>ddx</literal></entry><entry><para>Screen</para></entry></row>
+<row><entry><function>DisplayCursor</function></entry><entry><literal>hd</literal></entry><entry><para>Screen</para></entry></row>
+<row><entry><function>Error</function></entry><entry><literal>os</literal></entry><entry><para></para></entry></row>
+<row><entry><function>ErrorF</function></entry><entry><literal>os</literal></entry><entry><para></para></entry></row>
+<row><entry><function>FatalError</function></entry><entry><literal>os</literal></entry><entry><para></para></entry></row>
+<row><entry><function>FillPolygon</function></entry><entry><literal>mi</literal></entry><entry><para>GC op</para></entry></row>
+<row><entry><function>FillSpans</function></entry><entry><literal>ddx</literal></entry><entry><para>GC op</para></entry></row>
+<row><entry><function>FlushAllOutput</function></entry><entry><literal>os</literal></entry><entry><para></para></entry></row>
+<row><entry><function>FlushIfCriticalOutputPending</function></entry><entry><literal>os</literal></entry><entry><para></para></entry></row>
+<row><entry><function>FreeScratchPixmapHeader</function></entry><entry><literal>dix</literal></entry><entry><para></para></entry></row>
+<row><entry><function>GetImage</function></entry><entry><literal>mi</literal></entry><entry><para>Screen</para></entry></row>
+<row><entry><function>GetMotionEvents</function></entry><entry><literal>hd</literal></entry><entry><para>Device</para></entry></row>
+<row><entry><function>GetScratchPixmapHeader</function></entry><entry><literal>dix</literal></entry><entry><para></para></entry></row>
+<row><entry><function>GetSpans</function></entry><entry><literal>ddx</literal></entry><entry><para>Screen</para></entry></row>
+<row><entry><function>GetStaticColormap</function></entry><entry><literal>ddx</literal></entry><entry><para>Screen</para></entry></row>
+	    </tbody>
+	  </tgroup>
+	</table>
+
+	<table frame="all" id="routines-2">
+	  <title>Server Routines (Page 2)</title>
+	  <tgroup cols='3' align='left' colsep='1' rowsep='1'>
+	    <thead>
+	      <row>
+		<entry>Procedure</entry>
+		<entry>Port</entry>
+		<entry>Struct</entry>
+	      </row>
+	    </thead>
+	    <tbody>
+<row><entry><function>ImageGlyphBlt</function></entry><entry><literal>mi</literal></entry><entry><para>GC op</para></entry></row>
+<row><entry><function>ImageText16</function></entry><entry><literal>mi</literal></entry><entry><para>GC op</para></entry></row>
+<row><entry><function>ImageText8</function></entry><entry><literal>mi</literal></entry><entry><para>GC op</para></entry></row>
+<row><entry><function>InitInput</function></entry><entry><literal>hd</literal></entry><entry><para></para></entry></row>
+<row><entry><function>InitKeyboardDeviceStruct</function></entry><entry><literal>dix</literal></entry><entry><para></para></entry></row>
+<row><entry><function>InitOutput</function></entry><entry><literal>hd</literal></entry><entry><para></para></entry></row>
+<row><entry><function>InitPointerDeviceStruct</function></entry><entry><literal>dix</literal></entry><entry><para></para></entry></row>
+<row><entry><function>InsertFakeRequest</function></entry><entry><literal>os</literal></entry><entry><para></para></entry></row>
+<row><entry><function>InstallColormap</function></entry><entry><literal>ddx</literal></entry><entry><para>Screen</para></entry></row>
+<row><entry><function>Intersect</function></entry><entry><literal>mi</literal></entry><entry><para>Screen</para></entry></row>
+<row><entry><function>Inverse</function></entry><entry><literal>mi</literal></entry><entry><para>Screen</para></entry></row>
+<row><entry><function>LegalModifier</function></entry><entry><literal>hd</literal></entry><entry><para></para></entry></row>
+<row><entry><function>LineHelper</function></entry><entry><literal>mi</literal></entry><entry><para>GC op</para></entry></row>
+<row><entry><function>ListInstalledColormaps</function></entry><entry><literal>ddx</literal></entry><entry><para>Screen</para></entry></row>
+<row><entry><function>LookupKeyboardDevice</function></entry><entry><literal>dix</literal></entry><entry><para></para></entry></row>
+<row><entry><function>LookupPointerDevice</function></entry><entry><literal>dix</literal></entry><entry><para></para></entry></row>
+<row><entry><function>ModifyPixmapHeader</function></entry><entry><literal>mi</literal></entry><entry><para>Screen</para></entry></row>
+<row><entry><function>NextAvailableClient</function></entry><entry><literal>dix</literal></entry><entry><para></para></entry></row>
+<row><entry><function>OsInit</function></entry><entry><literal>os</literal></entry><entry><para></para></entry></row>
+<row><entry><function>PaintWindowBackground</function></entry><entry><literal>mi</literal></entry><entry><para>Window</para></entry></row>
+<row><entry><function>PaintWindowBorder</function></entry><entry><literal>mi</literal></entry><entry><para>Window</para></entry></row>
+<row><entry><function>PointerNonInterestBox</function></entry><entry><literal>hd</literal></entry><entry><para>Screen</para></entry></row>
+<row><entry><function>PointInRegion</function></entry><entry><literal>mi</literal></entry><entry><para>Screen</para></entry></row>
+<row><entry><function>PolyArc</function></entry><entry><literal>mi</literal></entry><entry><para>GC op</para></entry></row>
+<row><entry><function>PolyFillArc</function></entry><entry><literal>mi</literal></entry><entry><para>GC op</para></entry></row>
+<row><entry><function>PolyFillRect</function></entry><entry><literal>mi</literal></entry><entry><para>GC op</para></entry></row>
+<row><entry><function>PolyGlyphBlt</function></entry><entry><literal>mi</literal></entry><entry><para>GC op</para></entry></row>
+<row><entry><function>Polylines</function></entry><entry><literal>mi</literal></entry><entry><para>GC op</para></entry></row>
+<row><entry><function>PolyPoint</function></entry><entry><literal>mi</literal></entry><entry><para>GC op</para></entry></row>
+<row><entry><function>PolyRectangle</function></entry><entry><literal>mi</literal></entry><entry><para>GC op</para></entry></row>
+<row><entry><function>PolySegment</function></entry><entry><literal>mi</literal></entry><entry><para>GC op</para></entry></row>
+<row><entry><function>PolyText16</function></entry><entry><literal>mi</literal></entry><entry><para>GC op</para></entry></row>
+<row><entry><function>PolyText8</function></entry><entry><literal>mi</literal></entry><entry><para>GC op</para></entry></row>
+<row><entry><function>PositionWindow</function></entry><entry><literal>ddx</literal></entry><entry><para>Screen</para></entry></row>
+<row><entry><function>ProcessInputEvents</function></entry><entry><literal>hd</literal></entry><entry><para></para></entry></row>
+<row><entry><function>PushPixels</function></entry><entry><literal>mi</literal></entry><entry><para>GC op</para></entry></row>
+<row><entry><function>PutImage</function></entry><entry><literal>mi</literal></entry><entry><para>GC op</para></entry></row>
+<row><entry><function>QueryBestSize</function></entry><entry><literal>hd</literal></entry><entry><para>Screen</para></entry></row>
+<row><entry><function>ReadRequestFromClient</function></entry><entry><literal>os</literal></entry><entry><para></para></entry></row>
+<row><entry><function>RealizeCursor</function></entry><entry><literal>hd</literal></entry><entry><para>Screen</para></entry></row>
+<row><entry><function>RealizeFont</function></entry><entry><literal>ddx</literal></entry><entry><para>Screen</para></entry></row>
+<row><entry><function>RealizeWindow</function></entry><entry><literal>ddx</literal></entry><entry><para>Screen</para></entry></row>
+<row><entry><function>RecolorCursor</function></entry><entry><literal>hd</literal></entry><entry><para>Screen</para></entry></row>
+<row><entry><function>RectIn</function></entry><entry><literal>mi</literal></entry><entry><para>Screen</para></entry></row>
+<row><entry><function>RegionCopy</function></entry><entry><literal>mi</literal></entry><entry><para>Screen</para></entry></row>
+<row><entry><function>RegionCreate</function></entry><entry><literal>mi</literal></entry><entry><para>Screen</para></entry></row>
+<row><entry><function>RegionDestroy</function></entry><entry><literal>mi</literal></entry><entry><para>Screen</para></entry></row>
+<row><entry><function>RegionEmpty</function></entry><entry><literal>mi</literal></entry><entry><para>Screen</para></entry></row>
+<row><entry><function>RegionExtents</function></entry><entry><literal>mi</literal></entry><entry><para>Screen</para></entry></row>
+<row><entry><function>RegionNotEmpty</function></entry><entry><literal>mi</literal></entry><entry><para>Screen</para></entry></row>
+<row><entry><function>RegionReset</function></entry><entry><literal>mi</literal></entry><entry><para>Screen</para></entry></row>
+<row><entry><function>ResolveColor</function></entry><entry><literal>ddx</literal></entry><entry><para>Screen</para></entry></row>
+	    </tbody>
+	  </tgroup>
+	</table>
+
+	<table frame="all" id="routines-3">
+	  <title>Server Routines (Page 3)</title>
+	  <tgroup cols='3' align='left' colsep='1' rowsep='1'>
+	    <thead>
+	      <row>
+		<entry>Procedure</entry>
+		<entry>Port</entry>
+		<entry>Struct</entry>
+	      </row>
+	    </thead>
+	    <tbody>
+<row><entry><function>RemoveEnabledDevice</function></entry><entry><literal>os</literal></entry><entry><para></para></entry></row>
+<row><entry><function>ResetCurrentRequest</function></entry><entry><literal>os</literal></entry><entry><para></para></entry></row>
+<row><entry><function>SaveScreen</function></entry><entry><literal>ddx</literal></entry><entry><para>Screen</para></entry></row>
+<row><entry><function>SetCriticalOutputPending</function></entry><entry><literal>os</literal></entry><entry><para></para></entry></row>
+<row><entry><function>SetCursorPosition</function></entry><entry><literal>hd</literal></entry><entry><para>Screen</para></entry></row>
+<row><entry><function>SetInputCheck</function></entry><entry><literal>dix</literal></entry><entry><para></para></entry></row>
+<row><entry><function>SetSpans</function></entry><entry><literal>ddx</literal></entry><entry><para>GC op</para></entry></row>
+<row><entry><function>StoreColors</function></entry><entry><literal>ddx</literal></entry><entry><para>Screen</para></entry></row>
+<row><entry><function>Subtract</function></entry><entry><literal>mi</literal></entry><entry><para>Screen</para></entry></row>
+<row><entry><function>TimerCancel</function></entry><entry><literal>os</literal></entry><entry><para></para></entry></row>
+<row><entry><function>TimerCheck</function></entry><entry><literal>os</literal></entry><entry><para></para></entry></row>
+<row><entry><function>TimerForce</function></entry><entry><literal>os</literal></entry><entry><para></para></entry></row>
+<row><entry><function>TimerFree</function></entry><entry><literal>os</literal></entry><entry><para></para></entry></row>
+<row><entry><function>TimerInit</function></entry><entry><literal>os</literal></entry><entry><para></para></entry></row>
+<row><entry><function>TimerSet</function></entry><entry><literal>os</literal></entry><entry><para></para></entry></row>
+<row><entry><function>TimeSinceLastInputEvent</function></entry><entry><literal>hd</literal></entry><entry><para></para></entry></row>
+<row><entry><function>TranslateRegion</function></entry><entry><literal>mi</literal></entry><entry><para>Screen</para></entry></row>
+<row><entry><function>UninstallColormap</function></entry><entry><literal>ddx</literal></entry><entry><para>Screen</para></entry></row>
+<row><entry><function>Union</function></entry><entry><literal>mi</literal></entry><entry><para>Screen</para></entry></row>
+<row><entry><function>UnrealizeCursor</function></entry><entry><literal>hd</literal></entry><entry><para>Screen</para></entry></row>
+<row><entry><function>UnrealizeFont</function></entry><entry><literal>ddx</literal></entry><entry><para>Screen</para></entry></row>
+<row><entry><function>UnrealizeWindow</function></entry><entry><literal>ddx</literal></entry><entry><para>Screen</para></entry></row>
+<row><entry><function>ValidateGC</function></entry><entry><literal>ddx</literal></entry><entry><para>GC func</para></entry></row>
+<row><entry><function>ValidateTree</function></entry><entry><literal>mi</literal></entry><entry><para>Screen</para></entry></row>
+<row><entry><function>WaitForSomething</function></entry><entry><literal>os</literal></entry><entry><para></para></entry></row>
+<row><entry><function>WindowExposures</function></entry><entry><literal>mi</literal></entry><entry><para>Window</para></entry></row>
+<row><entry><function>WriteToClient</function></entry><entry><literal>os</literal></entry><entry><para></para></entry></row>
+<row><entry><function>Xalloc</function></entry><entry><literal>os</literal></entry><entry><para></para></entry></row>
+<row><entry><function>Xfree</function></entry><entry><literal>os</literal></entry><entry><para></para></entry></row>
+<row><entry><function>Xrealloc</function></entry><entry><literal>os</literal></entry><entry><para></para></entry></row>
+	    </tbody>
+	  </tgroup>
+	</table>
+</section>
+</article>
diff --git a/doc/xml/.gitignore b/doc/xml/.gitignore
deleted file mode 100644
index 3f0ed13..0000000
--- a/doc/xml/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-Xserver-spec.html
-Xserver-spec.pdf
-Xserver-spec.txt
diff --git a/doc/xml/Makefile.am b/doc/xml/Makefile.am
deleted file mode 100644
index b35ceec..0000000
--- a/doc/xml/Makefile.am
+++ /dev/null
@@ -1,29 +0,0 @@
-#
-# Copyright (c) 2010, Oracle and/or its affiliates. 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 (including the next
-# paragraph) shall be included in all copies or substantial portions of the
-# Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
-# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-# DEALINGS IN THE SOFTWARE.
-#
-
-doc_sources =  Xserver-spec.xml Xinput.xml
-
-# Developer's documentation is not installed
-if ENABLE_DEVEL_DOCS
-include $(top_srcdir)/doc/xml/xmlrules-noinst.in
-endif
diff --git a/doc/xml/Xinput.xml b/doc/xml/Xinput.xml
deleted file mode 100644
index 1ae7afe..0000000
--- a/doc/xml/Xinput.xml
+++ /dev/null
@@ -1,1209 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
-                   "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd">
-
-
-<!-- lifted from troff+ms+XMan by doclifter -->
-<book id="porting">
-
-<bookinfo>
-   <title>X11 Input Extension Porting Document</title>
-   <releaseinfo>X Version 11, Release 6.7</releaseinfo>
-   <authorgroup>
-      <author>
-         <firstname>George</firstname><surname>Sachs</surname>
-         <affiliation><orgname>Hewlett-Packard</orgname></affiliation>
-      </author>
-   </authorgroup>
-   <corpname>X Consortium Standard</corpname>
-   <copyright><year>1989</year><holder>Hewlett-Packard Company</holder></copyright>
-   <copyright><year>1990</year><holder>Hewlett-Packard Company</holder></copyright>
-   <copyright><year>1991</year><holder>Hewlett-Packard Company</holder></copyright>
-
-   <copyright><year>1989</year><holder>X Consortium</holder></copyright>
-   <copyright><year>1990</year><holder>X Consortium</holder></copyright>
-   <copyright><year>1991</year><holder>X Consortium</holder></copyright>
-   <affiliation><orgname>X Consortium</orgname></affiliation>
-   <productnumber>X Version 11, Release 6.7</productnumber>
-
-<legalnotice>
-
-
-<para>
-Permission to use, copy, modify, and distribute this documentation for any purpose and without fee is
-hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
-Hewlett-Packard makes no representations about the suitability for any purpose of the information in this
-document. It is provided "as is" without express or implied warranty. This document is only a draft stan-
-dard of the X Consortium and is therefore subject to change.
-</para>
-
-<para>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:</para>
-
-<para>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:</para>
-
-<para>The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.</para>
-
-<para>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 X CONSORTIUM 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.</para>
-
-<para>Except as contained in this notice, the name of the X Consortium 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 X Consortium.</para>
-
-<para>X Window System is a trademark of The Open Group.</para>
-</legalnotice>
-
-</bookinfo>
-
-<chapter id="x11_input_extension_porting_document">
-<title>X11 Input Extension Porting Document</title>
-
-<para>
-This document is intended to aid the process of integrating the 
-X11 Input Extension into an X server.
-</para>
-<para>
-<!-- .LP -->
-Most of the functionality provided by the input extension is 
-device- and implementation-independent, and should require no changes.  
-The functionality is implemented by
-routines that typically reside in the server source tree directory 
-extensions/server/xinput.
-This extension includes functions to enable and disable input extension devices,
-select input, grab and focus those device, query and change key 
-and button mappings, and others.  The only input extension requirements 
-for the device-dependent part of X are that the input devices be 
-correctly initialized and input events from those devices be correctly
-generated.  Device-dependent X is responsible for reading input data from 
-the input device hardware and if necessary, reformatting it into X events.
-</para>
-<para>
-<!-- .LP -->
-The process of initializing input extension devices is similar to that used 
-for the core devices, and is described in the following sections.  When
-multiple input devices are attached to X server, the choice of which devices
-to initially use as the core X pointer and keyboard is left 
-implementation-dependent.  It is also up to each implementation to decide
-whether all input devices will be opened by the server during its 
-initialization and kept open for the life of the server.  The alternative is
-to open only the X keyboard and X pointer during server initialization, and
-open other input devices only when requested by a client to do so.  Either
-type of implementation is supported by the input extension.
-</para>
-<para>
-<!-- .LP -->
-Input extension events generated by the X server use the same 32-byte xEvent
-wire event as do core input events.  However, additional information must be
-sent for input extension devices, requiring that multiple xEvents be generated
-each time data is received from an input extension device.  These xEvents are
-combined into a single client XEvent by the input extension library.  A later
-section of this document describes the format and generation of input extension
-events.
-</para>
-<sect1 id="Initializing_Extension_Devices">
-<title>Initializing Extension Devices</title>
-<para>
-<!-- .LP -->
-Extension input devices are initialized in the same manner as the core 
-X input devices.  Device-Independent X provides functions that can be 
-called from DDX to initialize these devices.  Which functions are called
-and when will vary by implementation, and will depend on whether the 
-implementation opens all the input devices available to X when X is initialized,
-or waits until a client requests that a device be opened.
-In the simplest case, DDX will open all input devices as part of its
-initialization, when the InitInput routine is called.
-</para>
-<sect2 id="Summary_of_Calling_Sequence">
-<title>Summary of Calling Sequence</title>
-<para>
-<!-- .LP -->
-<literallayout class="monospaced">
-Device-Independent X       |  Device-Dependent X
---------------------       |  -------------------             
-                           |                                        
-InitInput -------------->  |  - do device-specific initialization
-                           |                                        
-                           |  - call AddInputDevice  (deviceProc,AutoStart)
-AddInputDevice             |   
-  - creates DeviceIntRec   |
-  - records deviceProc     |
-  - adds new device to     | 
-    list of off_devices.   |
-sets dev->startup=AutoStart|           
-                           |  - call one of:                       
-                           |    - RegisterPointerDevice (X pointer)
-                           |      - processInputProc = ProcessPointerEvents
-                           |    - RegisterKeyboardDevice (X keyboard)
-                           |      - processInputProc = ProcessKeyboardEvents
-                           |    - RegisterOtherDevice  (extension device)
-                           |      - processInputProc = ProcessOtherEvents
-                           |                                        
-                           |                                        
-InitAndStartDevices -----> |  - calls deviceProc with parameters
-                           |    (DEVICE_INIT, AutoStart)
-sets dev->inited = return  |
-  value from deviceProc    |    
-                           |                                        
-                           |  - in deviceProc, do one of:                       
-                           |    - call InitPointerDeviceStruct (X pointer)
-                           |    - call InitKeyboardDeviceStruct (X keybd)
-                           |    - init extension device by calling some of:
-                           |      - InitKeyClassDeviceStruct
-                           |      - InitButtonClassDeviceStruct
-                           |      - InitValuatorClassDeviceStruct
-                           |      - InitValuatorAxisStruct
-                           |      - InitFocusClassDeviceStruct
-                           |      - InitProximityClassDeviceStruct
-                           |      - InitKbdFeedbackClassDeviceStruct
-                           |      - InitPtrFeedbackClassDeviceStruct
-                           |      - InitLedFeedbackClassDeviceStruct
-                           |      - InitStringFeedbackClassDeviceStruct
-                           |      - InitIntegerFeedbackClassDeviceStruct
-                           |      - InitBellFeedbackClassDeviceStruct
-                           |    - init device name and type by:
-                           |      - calling MakeAtom with one of the 
-                           |        predefined names
-                           |      - calling AssignTypeAndName
-                           |                                        
-                           |                                        
-for each device added      |                                        
-    by AddInputDevice,     |                                        
-    InitAndStartDevices    |                                        
-    calls EnableDevice if  |  - EnableDevice calls deviceProc with 
-    dev->startup &         |    (DEVICE_ON, AutoStart)
-    dev->inited            |  
-                           |                                        
-If deviceProc returns      |  - core devices are now enabled, extension
-    Success, EnableDevice  |    devices are now available to be accessed
-    move the device from   |    through the input extension protocol
-    inputInfo.off_devices  |    requests.                           
-    to inputInfo.devices   |                                        
-</literallayout>
-</para>
-</sect2>
-<sect2 id="Initialization_Called_From_InitInput">
-<title>Initialization Called From InitInput</title>
-<para>
-<!-- .LP -->
-InitInput is the first DDX input entry point called during X server startup.
-This routine is responsible for
-device- and implementation- specific initialization, and for calling
-AddInputDevice to create and initialize the DeviceIntRec structure for each
-input device.  AddInputDevice is passed the address of a procedure to be called
-by the DIX routine InitAndStartDevices when input devices are enabled.
-This procedure is expected to perform X initialization for the input device.
-</para>
-<para>
-<!-- .LP -->
-If the device is to be used as the X pointer, DDX should then call
-RegisterPointerDevice, passing the DeviceIntRec pointer,
-to initialize the device as the X pointer.
-</para>
-<para>
-<!-- .LP -->
-If the device is to be used as the X keyboard, DDX should instead call
-RegisterKeyboardDevice to initialize the device as the X keyboard.
-</para>
-<para>
-<!-- .LP -->
-If the device is to be used as an extension device, DDX should instead
-call RegisterOtherDevice, passing the DeviceIntPtr returned by
-AddInputDevice.
-</para>
-<para>
-<!-- .LP -->
-A sample InitInput implementation is shown below.
-</para>
-<para>
-<!-- .LP -->
-<literallayout class="monospaced">
-InitInput(argc,argv)
-    {
-    int i, numdevs, ReadInput();
-    DeviceIntPtr dev;
-    LocalDevice localdevs[LOCAL_MAX_DEVS];
-    DeviceProc kbdproc, ptrproc, extproc;
-
-    /**************************************************************
-     * Open the appropriate input devices, determine which are 
-     * available, and choose an X pointer and X keyboard device
-     * in some implementation-dependent manner.
-     ***************************************************************/
-
-    open_input_devices (&numdevs, localdevs);
-
-    /**************************************************************
-     * Register a WakeupHandler to handle input when it is generated.
-     ***************************************************************/
-
-    RegisterBlockAndWakeupHandlers (NoopDDA, ReadInput, NULL);
-
-    /**************************************************************
-     * Register the input devices with DIX.
-     ***************************************************************/
-
-    for (i=0; i<numdevs; i++)
-        {
-        if (localdevs[i].use == IsXKeyboard)
-            {
-            dev = AddInputDevice (kbdproc, TRUE);
-            RegisterKeyboardDevice (dev);
-            }
-        else if (localdevs[i].use == IsXPointer)
-            {
-            dev = AddInputDevice (ptrproc, TRUE);
-            RegisterPointerDevice (dev);
-            }
-        else 
-            {
-            dev = AddInputDevice (extproc, FALSE);
-            RegisterOtherDevice (dev);
-            }
-        if (dev == NULL)
-            FatalError ("Too many input devices.");
-        dev->devicePrivate = (pointer) &localdevs[i];
-        }
-</literallayout>
-</para>
-</sect2>
-<sect2 id="Initialization_Called_From_InitAndStartDevices">
-<title>Initialization Called From InitAndStartDevices</title>
-<para>
-<!-- .LP -->
-After InitInput has returned,
-InitAndStartDevices is the DIX routine that is called to enable input devices. 
-It calls the device control routine that was passed to AddInputDevice,
-with a mode value of DEVICE_INIT.  The action taken by the device control
-routine depends on how the device is to be used.  If the device is to be
-the X pointer, the device control routine should call
-InitPointerDeviceStruct to initialize it.  If the device is to be the
-X keyboard, the device control routine should call
-InitKeyboardDeviceStruct.  Since input extension devices may support various
-combinations of keys, buttons, valuators, and feedbacks,
-each class of input that it supports must be initialized.
-Entry points are defined by DIX to initialize each of the supported classes of
-input, and are described in the following sections.
-</para>
-<para>
-<!-- .LP -->
-A sample device control routine called from InitAndStartDevices is 
-shown below.
-</para>
-<para>
-<!-- .LP -->
-<literallayout class="monospaced">
-Bool extproc (dev, mode)
-    DeviceIntPtr dev;
-    int mode;
-    {
-    LocalDevice *localdev = (LocalDevice *) dev->devicePrivate;
-
-    switch (mode)
-        {
-        case DEVICE_INIT:
-            if (strcmp(localdev->name, XI_TABLET) == 0)
-                {
-                /****************************************************
-                 * This device reports proximity, has buttons,
-                 * reports two axes of motion, and can be focused.
-                 * It also supports the same feedbacks as the X pointer
-                 * (acceleration and threshold can be set).
-                 ****************************************************/
-
-                InitButtonClassDeviceStruct (dev, button_count, button_map);
-                InitValuatorClassDeviceStruct (dev, localdev->n_axes,);
-                    motionproc, MOTION_BUF_SIZE, Absolute);
-                for (i=0; i<localdev->n_axes; i++)
-                    InitValuatorAxisStruct (dev, i, min_val, max_val, 
-                        resolution);
-                InitFocusClassDeviceStruct (dev);
-                InitProximityClassDeviceStruct (dev);
-                InitPtrFeedbackClassDeviceStruct (dev, p_controlproc);
-                }
-            else if (strcmp(localdev->name, XI_BUTTONBOX) == 0)
-                {
-                /****************************************************
-                 * This device has keys and LEDs, and can be focused.
-                 ****************************************************/
-
-                InitKeyClassDeviceStruct (dev, syms, modmap);
-                InitFocusClassDeviceStruct (dev);
-                InitLedFeedbackClassDeviceStruct (dev, ledcontrol);
-                }
-            else if (strcmp(localdev->name, XI_KNOBBOX) == 0)
-                {
-                /****************************************************
-                 * This device reports motion.
-                 * It can be focused.
-                 ****************************************************/
-
-                InitValuatorClassDeviceStruct (dev, localdev->n_axes,);
-                    motionproc, MOTION_BUF_SIZE, Absolute);
-                for (i=0; i<localdev->n_axes; i++)
-                    InitValuatorAxisStruct (dev, i, min_val, max_val, 
-                        resolution);
-                InitFocusClassDeviceStruct (dev);
-                }
-            localdev->atom = 
-                MakeAtom(localdev->name, strlen(localdev->name), FALSE);
-            AssignTypeAndName (dev, localdev->atom, localdev->name);
-            break;
-        case DEVICE_ON:
-            AddEnabledDevice (localdev->file_ds);
-            dev->on = TRUE;
-            break;
-        case DEVICE_OFF:
-            dev->on = FALSE;
-            RemoveEnabledDevice (localdev->file_ds);
-            break;
-        case DEVICE_CLOSE:
-            break;
-        }
-    }
-</literallayout>
-</para>
-<para>
-<!-- .LP -->
-The device control routine is called with a mode value of DEVICE_ON
-by the DIX routine EnableDevice, which is called from InitAndStartDevices.  
-When called with this mode, it should call AddEnabledDevice to cause the 
-server to begin checking for available input from this device.
-</para>
-<para>
-<!-- .LP -->
->From InitAndStartDevices, EnableDevice is called for all devices that have
-the "inited" and "startup" fields in the DeviceIntRec set to TRUE.  The
-"inited" field is set by InitAndStartDevices to the value returned by
-the deviceproc when called with a mode value of DEVICE_INIT.  The "startup"
-field is set by AddInputDevice to value of the second parameter (autoStart).
-</para>
-<para>
-<!-- .LP -->
-When the server is first initialized, it should only be checking for input
-from the core X keyboard and pointer.  One way to accomplish this is to
-call AddInputDevice for the core X keyboard and pointer with an
-autoStart value equal to TRUE, while calling AddInputDevice for 
-input extension devices with an autoStart value equal to FALSE.  If this is 
-done, EnableDevice will skip all input extension devices during server
-initialization.  In this case,
-the OpenInputDevice routine should set the "startup" field to TRUE
-when called for input extension devices.  This will cause ProcXOpenInputDevice
-to call EnableDevice for those devices when a client first does an
-XOpenDevice request.
-</para>
-</sect2>
-<sect2 id="DIX_Input_Class_Initialization_Routines">
-<title>DIX Input Class Initialization Routines</title>
-<para>
-<!-- .LP -->
-DIX routines are defined to initialize each of the defined input classes.
-The defined classes are:
-<!-- .RS -->
-<!-- .in +5n -->
-</para>
-<itemizedlist>
-  <listitem>
-    <para>
-KeyClass - the device has keys.
-    </para>
-  </listitem>
-  <listitem>
-    <para>
-ButtonClass - the device has buttons.
-    </para>
-  </listitem>
-  <listitem>
-    <para>
-ValuatorClass - the device reports motion data or positional data.
-    </para>
-  </listitem>
-  <listitem>
-    <para>
-Proximitylass - the device reports proximity information.
-    </para>
-  </listitem>
-  <listitem>
-    <para>
-FocusClass - the device can be focused.
-    </para>
-  </listitem>
-  <listitem>
-    <para>
-FeedbackClass - the device supports some kind of feedback
-<!-- .in -5n -->
-<!-- .RE -->
-    </para>
-  </listitem>
-</itemizedlist>
-<para>
-<!-- .LP -->
-DIX routines are provided to initialize the X pointer and keyboard, as in
-previous releases of X.  During X initialization, InitPointerDeviceStruct 
-is called to initialize the X pointer, and InitKeyboardDeviceStruct is
-called to initialize the X keyboard.  There is no
-corresponding routine for extension input devices, since they do not all
-support the same classes of input.  Instead, DDX is responsible for the 
-initialization of the input classes supported by extension devices.  
-A description of the routines provided by DIX to perform that initialization
-follows.
-</para>
-<sect3 id="InitKeyClassDeviceStruct">
-<title>InitKeyClassDeviceStruct</title>
-<para>
-<!-- .LP -->
-This function is provided to allocate and initialize a KeyClassRec, and 
-should be called for extension devices that have keys.  It is passed a pointer
-to the device, and pointers to arrays of keysyms and modifiers reported by
-the device.  It returns FALSE if the KeyClassRec could not be allocated,
-or if the maps for the keysyms and and modifiers could not be allocated.
-Its parameters are:
-</para>
-<para>
-<!-- .LP -->
-<literallayout class="monospaced">
-Bool
-InitKeyClassDeviceStruct(dev, pKeySyms, pModifiers)
-    DeviceIntPtr dev;
-    KeySymsPtr pKeySyms;
-    CARD8 pModifiers[];
-</literallayout>
-</para>
-<para>
-<!-- .LP -->
-The DIX entry point InitKeyboardDeviceStruct calls this routine for the
-core X keyboard.  It must be called explicitly for extension devices
-that have keys.
-</para>
-</sect3>
-<sect3 id="InitButtonClassDeviceStruct">
-<title>InitButtonClassDeviceStruct</title>
-<para>
-<!-- .LP -->
-This function is provided to allocate and initialize a ButtonClassRec, and 
-should be called for extension devices that have buttons.  It is passed a 
-pointer to the device, the number of buttons supported, and a map of the 
-reported button codes.  It returns FALSE if the ButtonClassRec could not be 
-allocated.  Its parameters are:
-</para>
-<para>
-<!-- .LP -->
-<literallayout class="monospaced">
-Bool
-InitButtonClassDeviceStruct(dev, numButtons, map)
-    register DeviceIntPtr dev;
-    int numButtons;
-    CARD8 *map;
-</literallayout>
-</para>
-<para>
-<!-- .LP -->
-The DIX entry point InitPointerDeviceStruct calls this routine for the
-core X pointer.  It must be called explicitly for extension devices that
-have buttons.
-</para>
-</sect3>
-<sect3 id="InitValuatorClassDeviceStruct">
-<title>InitValuatorClassDeviceStruct</title>
-<para>
-<!-- .LP -->
-This function is provided to allocate and initialize a ValuatorClassRec, and 
-should be called for extension devices that have valuators.  It is passed the
-number of axes of motion reported by the device, the address of the motion
-history procedure for the device, the size of the motion history buffer,
-and the mode (Absolute or Relative) of the device.  It returns FALSE if 
-the ValuatorClassRec could not be allocated.  Its parameters are:
-</para>
-<para>
-<!-- .LP -->
-<literallayout class="monospaced">
-Bool
-InitValuatorClassDeviceStruct(dev, numAxes, motionProc, numMotionEvents, mode)
-    DeviceIntPtr dev;
-    int (*motionProc)();
-    int numAxes;
-    int numMotionEvents;
-    int mode;
-</literallayout>
-</para>
-<para>
-<!-- .LP -->
-The DIX entry point InitPointerDeviceStruct calls this routine for the
-core X pointer.  It must be called explicitly for extension devices that
-report motion.
-</para>
-</sect3>
-<sect3 id="InitValuatorAxisStruct">
-<title>InitValuatorAxisStruct</title>
-<para>
-<!-- .LP -->
-This function is provided to initialize an XAxisInfoRec, and 
-should be called for core and extension devices that have valuators.  
-The space for the XAxisInfoRec is allocated by 
-the InitValuatorClassDeviceStruct function, but is not initialized.
-</para>
-<para>
-<!-- .LP -->
-InitValuatorAxisStruct should be called once for each axis of motion 
-reported by the device.  Each
-invocation should be passed the axis number (starting with 0), the
-minimum value for that axis, the maximum value for that axis, and the
-resolution of the device in counts per meter.  If the device reports
-relative motion, 0 should be reported as the minimum and maximum values.
-InitValuatorAxisStruct has the following parameters:
-<literallayout class="monospaced">
-InitValuatorAxisStruct(dev, axnum, minval, maxval, resolution)
-    DeviceIntPtr dev;
-    int axnum;
-    int minval;
-    int maxval;
-    int resolution;
-</literallayout>
-</para>
-<para>
-<!-- .LP -->
-This routine is not called by InitPointerDeviceStruct for the
-core X pointer.  It must be called explicitly for core and extension devices 
-that report motion.
-</para>
-</sect3>
-<sect3 id="InitFocusClassDeviceStruct">
-<title>InitFocusClassDeviceStruct</title>
-<para>
-<!-- .LP -->
-This function is provided to allocate and initialize a FocusClassRec, and 
-should be called for extension devices that can be focused.  It is passed a
-pointer to the device, and returns FALSE if the allocation fails.
-It has the following parameter:
-<literallayout class="monospaced">
-Bool
-InitFocusClassDeviceStruct(dev)
-    DeviceIntPtr dev;
-</literallayout>
-</para>
-<para>
-<!-- .LP -->
-The DIX entry point InitKeyboardDeviceStruct calls this routine for the
-core X keyboard.  It must be called explicitly for extension devices
-that can be focused.  Whether or not a particular device can be focused
-is left implementation-dependent.
-</para>
-</sect3>
-<sect3 id="InitProximityClassDeviceStruct">
-<title>InitProximityClassDeviceStruct</title>
-<para>
-<!-- .LP -->
-This function is provided to allocate and initialize a ProximityClassRec, and 
-should be called for extension absolute pointing devices that report proximity.
-It is passed a pointer to the device, and returns FALSE if the allocation fails.
-It has the following parameter:
-<literallayout class="monospaced">
-Bool
-InitProximityClassDeviceStruct(dev)
-    DeviceIntPtr dev;
-</literallayout>
-</para>
-</sect3>
-<sect3 id="Initializing_Feedbacks">
-<title>Initializing Feedbacks</title>
-<para>
-<!-- .LP -->
-</para>
-<sect4 id="InitKbdFeedbackClassDeviceStruct">
-<title>InitKbdFeedbackClassDeviceStruct</title>
-<para>
-<!-- .LP -->
-This function is provided to allocate and initialize a KbdFeedbackClassRec, and 
-may be called for extension devices that support some or all of the 
-feedbacks that the core keyboard supports.  It is passed a
-pointer to the device, a pointer to the procedure that sounds the bell,
-and a pointer to the device control procedure.
-It returns FALSE if the allocation fails, and has the following parameters:
-<literallayout class="monospaced">
-Bool
-InitKbdFeedbackClassDeviceStruct(dev, bellProc, controlProc)
-    DeviceIntPtr dev;
-    void (*bellProc)();
-    void (*controlProc)();
-</literallayout>
-The DIX entry point InitKeyboardDeviceStruct calls this routine for the
-core X keyboard.  It must be called explicitly for extension devices
-that have the same feedbacks as a keyboard.  Some feedbacks, such as LEDs and
-bell, can be supported either with a KbdFeedbackClass or with BellFeedbackClass
-and LedFeedbackClass feedbacks.
-</para>
-</sect4>
-<sect4 id="InitPtrFeedbackClassDeviceStruct">
-<title>InitPtrFeedbackClassDeviceStruct</title>
-<para>
-<!-- .LP -->
-This function is provided to allocate and initialize a PtrFeedbackClassRec, and 
-should be called for extension devices that allow the setting of acceleration
-and threshold.  It is passed a pointer to the device,
-and a pointer to the device control procedure.
-It returns FALSE if the allocation fails, and has the following parameters:
-<literallayout class="monospaced">
-Bool
-InitPtrFeedbackClassDeviceStruct(dev, controlProc)
-    DeviceIntPtr dev;
-    void (*controlProc)();
-</literallayout>
-</para>
-<para>
-<!-- .LP -->
-The DIX entry point InitPointerDeviceStruct calls this routine for the
-core X pointer.  It must be called explicitly for extension devices
-that support the setting of acceleration and threshold.
-</para>
-</sect4>
-<sect4 id="InitLedFeedbackClassDeviceStruct">
-<title>InitLedFeedbackClassDeviceStruct</title>
-<para>
-<!-- .LP -->
-This function is provided to allocate and initialize a LedFeedbackClassRec, and 
-should be called for extension devices that have LEDs.
-It is passed a pointer to the device,
-and a pointer to the device control procedure.
-It returns FALSE if the allocation fails, and has the following parameters:
-<literallayout class="monospaced">
-Bool
-InitLedFeedbackClassDeviceStruct(dev, controlProc)
-    DeviceIntPtr dev;
-    void (*controlProc)();
-</literallayout>
-</para>
-<para>
-<!-- .LP -->
-Up to 32 LEDs per feedback can be supported, and a device may have 
-multiple feedbacks of the same type.
-</para>
-</sect4>
-<sect4 id="InitBellFeedbackClassDeviceStruct">
-<title>InitBellFeedbackClassDeviceStruct</title>
-<para>
-<!-- .LP -->
-This function is provided to allocate and initialize a BellFeedbackClassRec, 
-and should be called for extension devices that have a bell.
-It is passed a pointer to the device,
-and a pointer to the device control procedure.
-It returns FALSE if the allocation fails, and has the following parameters:
-<literallayout class="monospaced">
-Bool
-InitBellFeedbackClassDeviceStruct(dev, bellProc, controlProc)
-    DeviceIntPtr dev;
-    void (*bellProc)();
-    void (*controlProc)();
-</literallayout>
-</para>
-</sect4>
-<sect4 id="InitStringFeedbackClassDeviceStruct">
-<title>InitStringFeedbackClassDeviceStruct</title>
-<para>
-<!-- .LP -->
-This function is provided to allocate and initialize a StringFeedbackClassRec, 
-and should be called for extension devices that have a display upon which a 
-string can be displayed.
-It is passed a pointer to the device,
-and a pointer to the device control procedure.
-It returns FALSE if the allocation fails, and has the following parameters:
-<literallayout class="monospaced">
-Bool
-InitStringFeedbackClassDeviceStruct(dev, controlProc, max_symbols, 
-	num_symbols_supported, symbols)
-    DeviceIntPtr dev;
-    void (*controlProc)();
-    int max_symbols:
-    int num_symbols_supported;
-    KeySym *symbols;
-</literallayout>
-</para>
-</sect4>
-<sect4 id="InitIntegerFeedbackClassDeviceStruct">
-<title>InitIntegerFeedbackClassDeviceStruct</title>
-<para>
-<!-- .LP -->
-This function is provided to allocate and initialize an 
-IntegerFeedbackClassRec, 
-and should be called for extension devices that have a display upon which an
-integer can be displayed.
-It is passed a pointer to the device,
-and a pointer to the device control procedure.
-It returns FALSE if the allocation fails, and has the following parameters:
-<literallayout class="monospaced">
-Bool
-InitIntegerFeedbackClassDeviceStruct(dev, controlProc)
-    DeviceIntPtr dev;
-    void (*controlProc)();
-</literallayout>
-</para>
-</sect4>
-</sect3>
-</sect2>
-<sect2 id="Initializing_The_Device_Name_And_Type">
-<title>Initializing The Device Name And Type</title>
-<para>
-<!-- .LP -->
-The device name and type can be initialized by calling AssignTypeAndName
-with the following parameters:
-<literallayout class="monospaced">
-void
-AssignTypeAndName(dev, type, name)
-    DeviceIntPtr dev;
-    Atom type;
-    char *name;
-</literallayout>
-</para>
-<para>
-<!-- .LP -->
-This will allocate space for the device name and copy the name that was passed.
-The device type can be obtained by calling MakeAtom with one of the names
-defined for input devices.  MakeAtom has the following parameters:
-<literallayout class="monospaced">
-Atom
-MakeAtom(name, len, makeit)
-    char *name;
-    int len;
-    Bool makeit;
-</literallayout>
-</para>
-<para>
-<!-- .LP -->
-Since the atom was already made when the input extension was initialized, the
-value of makeit should be FALSE;
-</para>
-</sect2>
-</sect1>
-<sect1 id="Closing_Extension_Devices">
-<title>Closing Extension Devices</title>
-<para>
-<!-- .LP -->
-The DisableDevice entry point is provided by DIX to disable input devices.
-It calls the device control routine for the specified
-device with a mode value of DEVICE_OFF.  The device control routine should
-call RemoveEnabledDevice to stop the server from checking for input from
-that device.
-</para>
-<para>
-<!-- .LP -->
-DisableDevice is not called by any input extension routines.  It can be 
-called from the CloseInputDevice routine, which is called by
-ProcXCloseDevice when a client makes an XCloseDevice request.  If
-DisableDevice is called, it should only be called when the last client
-using the extension device has terminated or called XCloseDevice.
-</para>
-</sect1>
-<sect1 id="Implementation_Dependent_Routines">
-<title>Implementation-Dependent Routines</title>
-<para>
-<!-- .LP -->
-Several input extension protocol requests have 
-implementation-dependent  entry points.  Default routines
-are defined for these entry points and contained in the source
-file extensions/server/xinput/xstubs.c.  Some implementations may
-be able to use the default routines without change.
-The following sections describe each of these routines.
-</para>
-<sect2 id="AddOtherInputDevices">
-<title>AddOtherInputDevices</title>
-<para>
-<!-- .LP -->
-AddOtherInputDevice is called from ProcXListInputDevices as a result of 
-an XListInputDevices protocol request.  It may be needed by
-implementations that do not open extension input devices until requested
-to do so by some client.  These implementations may not initialize
-all devices when the X server starts up, because some of those devices
-may be in use.  Since the XListInputDevices
-function only lists those devices that have been initialized,
-AddOtherInputDevices is called to give DDX a chance to 
-initialize any previously unavailable input devices.
-</para>
-<para>
-<!-- .LP -->
-A sample AddOtherInputDevices routine might look like the following:
-<literallayout class="monospaced">
-void
-AddOtherInputDevices ()
-    {
-    DeviceIntPtr dev;
-    int i;
-
-    for (i=0; i<MAX_DEVICES; i++) 
-        {
-        if (!local_dev[i].initialized && available(local_dev[i]))
-            {
-            dev = (DeviceIntPtr) AddInputDevice (local_dev[i].deviceProc, TRUE);
-            dev->public.devicePrivate = local_dev[i];
-            RegisterOtherDevice (dev);
-            dev->inited = ((*dev->deviceProc)(dev, DEVICE_INIT) == Success);
-            }
-        }
-    }
-</literallayout>
-</para>
-<para>
-<!-- .LP -->
-The default AddOtherInputDevices routine in xstubs.c does nothing.
-If all input extension devices are initialized when the server 
-starts up, it can be left as a null routine.
-</para>
-</sect2>
-<sect2 id="OpenInputDevice">
-<title>OpenInputDevice</title>
-<para>
-<!-- .LP -->
-Some X server implementations open all input devices when the server
-is initialized and never close them.  Other implementations may open only
-the X pointer and keyboard devices during server initialization,
-and open other input devices only when some client makes an
-XOpenDevice request.  This entry point is for the latter type of 
-implementation.
-</para>
-<para>
-<!-- .LP -->
-If the physical device is not already open, it can be done in this routine.  
-In this case, the server must keep track of the fact that one or more clients 
-have the device open, and physically close it when the last client that has
-it open makes an XCloseDevice request.
-</para>
-<para>
-<!-- .LP -->
-The default implementation is to do nothing (assume all input devices
-are opened during X server initialization and kept open).
-</para>
-</sect2>
-<sect2 id="CloseInputDevice">
-<title>CloseInputDevice</title>
-<para>
-<!-- .LP -->
-Some implementations may close an input device when the last client
-using that device requests that it be closed, or terminates.
-CloseInputDevice is called from ProcXCloseDevice when a client
-makes an XCloseDevice protocol request.
-</para>
-<para>
-<!-- .LP -->
-The default implementation is to do nothing (assume all input devices
-are opened during X server initialization and kept open).
-</para>
-</sect2>
-<sect2 id="SetDeviceMode">
-<title>SetDeviceMode</title>
-<para>
-<!-- .LP -->
-Some implementations support input devices that can report 
-either absolute positional data or relative motion.  The XSetDeviceMode
-protocol request is provided to allow DDX to change the current mode of 
-such a device.
-</para>
-<para>
-<!-- .LP -->
-The default implementation is to always return a BadMatch error.  If the
-implementation does not support any input devices that are capable of 
-reporting both relative motion and absolute position information, the
-default implementation may be left unchanged.
-</para>
-</sect2>
-<sect2 id="SetDeviceValuators">
-<title>SetDeviceValuators</title>
-<para>
-<!-- .LP -->
-Some implementations support input devices that allow their valuators to be 
-set to an initial value.  The XSetDeviceValuators 
-protocol request is provided to allow DDX to set the valuators of
-such a device.
-</para>
-<para>
-<!-- .LP -->
-The default implementation is to always return a BadMatch error.  If the
-implementation does not support any input devices that are allow their
-valuators to be set, the default implementation may be left unchanged.
-</para>
-</sect2>
-<sect2 id="ChangePointerDevice">
-<title>ChangePointerDevice</title>
-<para>
-<!-- .LP -->
-The XChangePointerDevice protocol request is provided to change which device is
-used as the X pointer.  Some implementations may maintain information
-specific to the X pointer in the private data structure pointed to by
-the DeviceIntRec.  ChangePointerDevice is called to allow such 
-implementations to move that information to the new pointer device.
-The current location of the X cursor is an example of the type of 
-information that might be affected.
-</para>
-<para>
-<!-- .LP -->
-The DeviceIntRec structure that describes the X pointer device does not 
-contain a FocusRec.  If the device that has been made into the new X pointer 
-was previously a device that could be focused, ProcXChangePointerDevice will 
-free the FocusRec associated with that device.
-</para>
-<para>
-<!-- .LP -->
-If the server implementation desires to allow clients to focus the old pointer 
-device (which is now accessible through the input extension), it should call
-InitFocusClassDeviceStruct for the old pointer device.
-</para>
-<para>
-<!-- .LP -->
-The XChangePointerDevice protocol request also allows the client
-to choose which axes of the new pointer device are used to move 
-the X cursor in the X- and Y- directions.  If the axes are different
-than the default ones, the server implementation should record that fact.
-</para>
-<para>
-<!-- .LP -->
-If the server implementation supports input devices with valuators that 
-are not allowed to be used as the X pointer, they should be screened out
-by this routine and a  BadDevice error returned.
-</para>
-<para>
-<!-- .LP -->
-The default implementation is to do nothing. 
-</para>
-</sect2>
-<sect2 id="ChangeKeyboardDevice">
-<title>ChangeKeyboardDevice</title>
-<para>
-<!-- .LP -->
-The XChangeKeyboardDevice protocol request is provided to change which device is
-used as the X keyboard.  Some implementations may maintain information
-specific to the X keyboard in the private data structure pointed to by
-the DeviceIntRec.  ChangeKeyboardDevice is called to allow such 
-implementations to move that information to the new keyboard device.
-</para>
-<para>
-<!-- .LP -->
-The X keyboard device can be focused, and the DeviceIntRec that describes
-that device has a FocusRec.  If the device that has been made into the new X 
-keyboard did not previously have a FocusRec, 
-ProcXChangeKeyboardDevice will allocate one for it.
-</para>
-<para>
-<!-- .LP -->
-If the implementation does not want clients to be able to focus the old X 
-keyboard (which has now become available as an input extension device)
-it should call DeleteFocusClassDeviceStruct to free the FocusRec.
-</para>
-<para>
-<!-- .LP -->
-If the implementation supports input devices with keys that are not allowed
-to be used as the X keyboard, they should be checked for here, and a
-BadDevice error returned.
-</para>
-<para>
-<!-- .LP -->
-The default implementation is to do nothing. 
-</para>
-</sect2>
-</sect1>
-<sect1 id="Input_Extension_Events">
-<title>Input Extension Events</title>
-<para>
-<!-- .LP -->
-Events accessed through the input extension are analogous to the core input
-events, but have different event types.  They are of types 
-<function>DeviceKeyPress</function>, <function>DeviceKeyRelease</function>, <function>DeviceButtonPress</function>,
-<function>DeviceButtonRelease</function>, <function>DeviceDeviceMotionNotify</function>,
-<function>DeviceProximityIn</function>, <function>DeviceProximityOut</function>, and <function>DeviceValuator</function>.
-These event types are not constants.  Instead, they are external integers 
-defined by the input extension.  Their actual values will depend on which
-extensions are supported by a server, and the order in which they are
-initialized.
-</para>
-<para>
-<!-- .LP -->
-The data structures that define these
-events are defined in the file <function>extensions/include/XIproto.h</function>.  Other
-input extension constants needed by DDX are defined in the file
-<function>extensions/include/XI.h</function>.
-</para>
-<para>
-<!-- .LP -->
-Some events defined by the input extension contain more information than can
-be contained in the 32-byte xEvent data structure.  To send this information
-to clients, DDX must generate two or more 32-byte wire events.  The following
-sections describe the contents of these events. 
-</para>
-<sect2 id="Device_Key_Events">
-<title>Device Key Events</title>
-<para>
-<!-- .LP -->
-<function>DeviceKeyPresss</function> events contain all the information that is contained in
-a core <function>KeyPress</function> event, and also the following additional information:
-</para>
-<para>
-<!-- .LP -->
-<!-- .RS -->
-<!-- .in +5n -->
-</para>
-<itemizedlist>
-  <listitem>
-    <para>
-deviceid - the identifier of the device that generated the event.
-    </para>
-  </listitem>
-  <listitem>
-    <para>
-device_state - the state of any modifiers on the device that generated the event
-    </para>
-  </listitem>
-  <listitem>
-    <para>
-num_valuators - the number of valuators reported in this event.
-    </para>
-  </listitem>
-  <listitem>
-    <para>
-first_valuator - the first valuator reported in this event.
-    </para>
-  </listitem>
-  <listitem>
-    <para>
-valuator0 through valuator5 - the values of the valuators.
-<!-- .in -5n -->
-<!-- .RE -->
-    </para>
-  </listitem>
-</itemizedlist>
-<para>
-<!-- .LP -->
-In order to pass this information to the input extension library, two 32-byte
-wire events must be generated by DDX.  The first has an event type of 
-<function>DeviceKeyPress</function>, and the second has an event type of \fPDeviceValuator\fP.
-</para>
-<para>
-<!-- .LP -->
-The following code fragment shows how the two wire events could be initialized:
-</para>
-<para>
-<!-- .LP -->
-<literallayout class="monospaced">
-    extern int DeviceKeyPress;
-    DeviceIntPtr dev;
-    xEvent xE[2];
-    CARD8 id, num_valuators;
-    INT16 x, y, pointerx, pointery;
-    Time timestamp;
-    deviceKeyButtonPointer *xev = (deviceKeyButtonPointer *) xE;
-    deviceValuator *xv;
-
-    xev->type = DeviceKeyPress;                /* defined by input extension */
-    xev->detail = keycode;              /* key pressed on this device */
-    xev->time = timestamp;              /* same as for core events    */
-    xev->rootX = pointerx;              /* x location of core pointer */
-    xev->rootY = pointery;              /* y location of core pointer */
-
-    /******************************************************************/
-    /*                                                                */
-    /* The following field does not exist for core input events.      */
-    /* It contains the device id for the device that generated the    */
-    /* event, and also indicates whether more than one 32-byte wire   */
-    /* event is being sent.                                           */
-    /*                                                                */
-    /******************************************************************/
-
-    xev->deviceid = dev->id | MORE_EVENTS;        /* sending more than 1*/
-
-    /******************************************************************/
-    /* Fields in the second 32-byte wire event:                       */
-    /******************************************************************/
-
-    xv = (deviceValuator *) ++xev;
-    xv->type = DeviceValuator;          /* event type of second event */
-    xv->deviceid = dev->id;             /* id of this device          */
-    xv->num_valuators = 0;              /* no valuators being sent    */
-    xv->device_state  = 0;              /* will be filled in by DIX   */
-</literallayout>
-</para>
-</sect2>
-<sect2 id="Device_Button_Events">
-<title>Device Button Events</title>
-<para>
-<!-- .LP -->
-<function>DeviceButton</function> events contain all the information that is contained in
-a core button event, and also the same additional information that a 
-<function>DeviceKey</function> event contains.
-</para>
-</sect2>
-<sect2 id="Device_Motion_Events">
-<title>Device Motion Events</title>
-<para>
-<!-- .LP -->
-<function>DeviceMotion</function> events contain all the information that is contained in
-a core motion event, and also additional valuator information.  At least
-two wire events are required to contain this information.
-The following code fragment shows how the two wire events could be initialized:
-</para>
-<para>
-<!-- .LP -->
-<literallayout class="monospaced">
-    extern int DeviceMotionNotify;
-    DeviceIntPtr dev;
-    xEvent xE[2];
-    CARD8 id, num_valuators;
-    INT16 x, y, pointerx, pointery;
-    Time timestamp;
-    deviceKeyButtonPointer *xev = (deviceKeyButtonPointer *) xE;
-    deviceValuator *xv;
-
-    xev->type = DeviceMotionNotify;     /* defined by input extension */
-    xev->detail = keycode;              /* key pressed on this device */
-    xev->time = timestamp;              /* same as for core events    */
-    xev->rootX = pointerx;              /* x location of core pointer */
-    xev->rootY = pointery;              /* y location of core pointer */
-
-    /******************************************************************/
-    /*                                                                */
-    /* The following field does not exist for core input events.      */
-    /* It contains the device id for the device that generated the    */
-    /* event, and also indicates whether more than one 32-byte wire   */
-    /* event is being sent.                                           */
-    /*                                                                */
-    /******************************************************************/
-
-    xev->deviceid = dev->id | MORE_EVENTS;        /* sending more than 1*/
-
-    /******************************************************************/
-    /* Fields in the second 32-byte wire event:                       */
-    /******************************************************************/
-
-    xv = (deviceValuator *) ++xev;
-    xv->type = DeviceValuator;          /* event type of second event */
-    xv->deviceid = dev->id;             /* id of this device          */
-    xv->num_valuators = 2;              /* 2 valuators being sent     */
-    xv->first_valuator = 0;             /* first valuator being sent  */
-    xv->device_state  = 0;              /* will be filled in by DIX   */
-    xv->valuator0 = x;                  /* first axis of this device  */
-    xv->valuator1 = y;                  /* second axis of this device */
-</literallayout>
-</para>
-<para>
-<!-- .LP -->
-Up to six axes can be reported in the deviceValuator event.  If the device
-is reporting more than 6 axes, additional pairs of DeviceMotionNotify and
-DeviceValuator events should be sent,  with the first_valuator field
-set correctly.
-</para>
-</sect2>
-<sect2 id="Device_Proximity_Events">
-<title>Device Proximity Events</title>
-<para>
-<!-- .LP -->
-Some input devices that report absolute positional information, such as 
-graphics tablets and touchscreens, may report proximity events.  
-<function>ProximityIn</function>
-events are generated when a pointing device like a stylus, or in the case
-of a touchscreen, the user's finger, comes into close proximity with the
-surface of the input device.  <function>ProximityOut</function> events are generated when
-the stylus or finger leaves the proximity of the input devices surface.
-</para>
-<para>
-<!-- .LP -->
-<function>Proximity</function> events contain almost the same information as button events.
-The event type is <function>ProximityIn</function> or <function>ProximityOut</function>, and there is no
-detail information.
-<!-- .bp -->
-<!-- .\" .TC -->
-
-</para>
-</sect2>
-</sect1>
-</chapter>
-</book>
diff --git a/doc/xml/Xserver-spec.xml b/doc/xml/Xserver-spec.xml
deleted file mode 100644
index 7d7f915..0000000
--- a/doc/xml/Xserver-spec.xml
+++ /dev/null
@@ -1,5102 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
- "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
- <!ENTITY % defs SYSTEM "/xserver/doc/xml/xserver.ent"> %defs;
-]>
-
-<article>
-  <articleinfo>
-    <author>
-      <firstname>Susan</firstname><surname>Angebranndt</surname>
-      <affiliation><orgname>Digital Equipment Corporation</orgname></affiliation>
-    </author>
-    <author>
-      <firstname>Raymond</firstname><surname>Drewry</surname>
-      <affiliation><orgname>Digital Equipment Corporation</orgname></affiliation>
-    </author>
-    <author>
-      <firstname>Philip</firstname><surname>Karlton</surname>
-      <affiliation><orgname>Digital Equipment Corporation</orgname></affiliation>
-    </author>
-    <author>
-      <firstname>Todd</firstname><surname>Newman</surname>
-      <affiliation><orgname>Digital Equipment Corporation</orgname></affiliation>
-    </author>
-    <author>
-      <firstname>Bob</firstname><surname>Scheifler</surname>
-      <affiliation><orgname>Massachusetts Institute of Technology</orgname></affiliation>
-    </author>
-    <author>
-      <firstname>Keith</firstname><surname>Packard</surname>
-      <affiliation><orgname>MIT X Consortium</orgname></affiliation>
-    </author>
-    <author>
-      <firstname>David</firstname><othername>P.</othername><surname>Wiggins</surname>
-      <affiliation><orgname>X Consortium</orgname></affiliation>
-    </author>
-    <author>
-      <firstname>Jim</firstname><surname>Gettys</surname>
-      <affiliation><orgname>X.org Foundation and Hewlett Packard</orgname></affiliation>
-    </author>
-    <publisher><publishername>The X.Org Foundation</publishername></publisher>
-    <pubdate>&xserver.reldate;</pubdate>
-    <releaseinfo>X server version &xserver.version;</releaseinfo>
-    <title>Definition of the Porting Layer for the X v11 Sample Server</title>
-    <titleabbrev>X Porting Layer</titleabbrev>
-    <revhistory>
-      <revision>
-	<revnumber>1.0</revnumber>
-	<date>27 Oct 2004</date>
-	<authorinitials>sa</authorinitials>
-	<revremark>Initial Version</revremark>
-      </revision>
-      <revision>
-	<revnumber>1.1</revnumber>
-	<date>27 Oct 2004</date>
-	<authorinitials>bs</authorinitials>
-	<revremark>Minor Revisions</revremark>
-      </revision>
-      <revision>
-	<revnumber>2.0</revnumber>
-	<date>27 Oct 2004</date>
-	<authorinitials>kp</authorinitials>
-	<revremark>Revised for Release 4 and 5</revremark>
-      </revision>
-      <revision>
-	<revnumber>3.0</revnumber>
-	<date>27 Oct 2004</date>
-	<authorinitials>dpw</authorinitials>
-	<revremark>Revised for Release 6</revremark>
-      </revision>
-      <revision>
-	<revnumber>3.1</revnumber>
-	<date>27 Oct 2004</date>
-	<authorinitials>jg</authorinitials>
-	<revremark>Revised for Release 6.8.2</revremark>
-      </revision>
-      <revision>
-	<revnumber>3.2</revnumber>
-	<date>17 Dec 2006</date>
-	<authorinitials>efw</authorinitials>
-	<revremark>DocBook conversion</revremark>
-      </revision>
-      <revision>
-	<revnumber>3.3</revnumber>
-	<date>17 Feb 2008</date>
-	<authorinitials>aj</authorinitials>
-	<revremark>Revised for backing store changes</revremark>
-      </revision>
-      <revision>
-	<revnumber>3.4</revnumber>
-	<date>31 Mar 2008</date>
-	<authorinitials>efw</authorinitials>
-	<revremark>Revised for devPrivates changes</revremark>
-      </revision>
-      <revision>
-	<revnumber>3.5</revnumber>
-	<date>July 2010</date>
-	<authorinitials>ac</authorinitials>
-	<revremark>Revised for Xorg 1.9 devPrivates changes
-	  and 1.8 CreateNewResourceType changes</revremark>
-      </revision>
-    </revhistory>
-    <legalnotice>
-      <para>Copyright &#xA9; 1994 X Consortium, Inc., 2004 X.org Foundation, Inc.</para>
-      <para>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:</para>
-      <para>The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.</para>
-      <para>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 X CONSORTIUM 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.</para>
-      <para>LK201 and DEC are trademarks of Digital Equipment Corporation.  Macintosh and Apple are trademarks of Apple Computer, Inc.  PostScript is a trademark of Adobe Systems, Inc.  Ethernet is a trademark of Xerox Corporation.  X Window System is a trademark of the X.org Foundation, Inc.  Cray is a trademark of Cray Research, Inc.</para>
-    </legalnotice>
-    <abstract>
-      <para>The following document explains the structure of the X Window System display server and the interfaces among the larger pieces.  It is intended as a reference for programmers who are implementing an X Display Server on their workstation hardware.  It is included with the X Window System source tape, along with the document "Strategies for Porting the X v11 Sample Server."  The order in which you should read these documents is:
-      <orderedlist>
-	<listitem><para>Read the first section of the "Strategies for Porting" document (Overview of Porting Process).</para></listitem>
-	<listitem><para>Skim over this document (the Definition document).</para></listitem>
-	<listitem><para>Skim over the remainder of the Strategies document.</para></listitem>
-	<listitem><para>Start planning and working, referring to the Strategies and Definition documents.</para></listitem>
-      </orderedlist>
-      You may also want to look at the following documents:
-      <itemizedlist>
-	<listitem><para>"The X Window System" for an overview of X.</para></listitem>
-	<listitem><para>"Xlib - C Language X Interface" for a view of what the client programmer sees.</para></listitem>
-	<listitem><para>"X Window System Protocol" for a terse description of the byte stream protocol between the client and server.</para></listitem>
-      </itemizedlist>
-      </para>
-      <para>To understand this document and the accompanying source code, you should know the C language.  You should be familiar with 2D graphics and windowing concepts such as clipping, bitmaps, fonts, etc.  You should have a general knowledge of the X Window System.  To implement the server code on your hardware, you need to know a lot about your hardware, its graphic display device(s), and (possibly) its networking and multitasking facilities.  This document depends a lot on the source code, so you should have a listing of the code handy.</para>
-      <para>Some source in the distribution is directly compilable on your machine.  Some of it will require modification.  Other parts may have to be completely written from scratch.  The distribution also includes source for a sample implementation of a display server which runs on a very wide variety of color and monochrome displays on Linux and *BSD which you will find useful for implementing any type of X server.</para>
-      <para>Note to the 2008 edition: at this time this document must be considered incomplete, though improved over the 2004 edition.  In particular, the new Render extension is still lacking good documentation, and has become vital to high performance X implementations.  Modern applications and desktop environments are now much more sensitive to good implementation of the Render extension than in most operations of the old X graphics model.  The shadow frame buffer implementation is also very useful in many circumstances, and also needs documentation.  We hope to rectify these shortcomings in our documentation in the future.  Help would be greatly appreciated.</para>
-    </abstract>
-  </articleinfo>
-
-<!-- Original authorship information:
-
-.OF 'Porting Layer Definition'- % -'October 27, 2004'
-Definition of the Porting Layer
-for the X v11 Sample Server
-Susan Angebranndt
-Raymond Drewry
-Philip Karlton
-Todd Newman
-Digital Equipment Corporation
-
-minor revisions by
-Bob Scheifler
-Massachusetts Institute of Technology
-
-Revised for Release 4 and Release 5 by
-Keith Packard
-MIT X Consortium
-
-Revised for Release 6 by
-David P. Wiggins
-X Consortium
-
-Minor Revisions for Release 6.8.2 by
-Jim Gettys
-X.org Foundation and Hewlett Packard
--->
-
-<section>
-  <title>The X Window System</title>
-<para>
-The X Window System, or simply "X," is a
-windowing system that provides high-performance, high-level,
-device-independent graphics.
-</para>
-<para>
-X is a windowing system designed for bitmapped graphic displays.
-The display can have a
-simple, monochrome display or it can have a color display with up to 32 bits
-per pixel with a special graphics processor doing the work.  (In this
-document, monochrome means a black and white display with one bit per pixel.
-Even though the usual meaning of monochrome is more general, this special
-case is so common that we decided to reserve the word for this purpose.)
-In practice, monochrome displays are now almost unheard of, with 4 bit
-gray scale displays being the low end.
-</para>
-<para>
-X is designed for a networking environment where
-users can run applications on machines other than their own workstations.
-Sometimes, the connection is over an Ethernet network with a protocol such as TCP/IP;
-but, any "reliable" byte stream is allowable.
-A high-bandwidth byte stream is preferable; RS-232 at
-9600 baud would be slow without compression techniques.
-</para>
-<para>
-X by itself allows great freedom of design.
-For instance, it does not include any user interface standard.
-Its intent is to "provide mechanism, not policy."
-By making it general, it can be the foundation for a wide
-variety of interactive software.
-</para>
-<para>
-For a more detailed overview, see the document "The X Window System."
-For details on the byte stream protocol, see "X Window System protocol."
-</para>
-</section>
-<section>
-<title>Overview of the Server</title>
-<para>
-The display server
-manages windows and simple graphics requests
-for the user on behalf of different client applications.
-The client applications can be running on any machine on the network.
-The server mainly does three things:
-<itemizedlist>
-  <listitem><para>Responds to protocol requests from existing clients (mostly graphic and text drawing commands)</para></listitem>
-  <listitem><para>Sends device input (keystrokes and mouse actions) and other events to existing clients</para></listitem>
-  <listitem><para>Maintains client connections</para></listitem>
-</itemizedlist>
-</para>
-<para>
-The server code is organized into four major pieces:
-<itemizedlist>
-  <listitem><para>Device Independent (DIX) layer - code shared among all implementations</para></listitem>
-  <listitem><para>Operating System (OS) layer - code that is different for each operating system but is shared among all graphic devices for this operating system</para></listitem>
-  <listitem><para>Device Dependent (DDX) layer - code that is (potentially) different for each combination of operating system and graphic device</para></listitem>
-  <listitem><para>Extension Interface - a standard way to add features to the X server</para></listitem>
-</itemizedlist>
-</para>
-<para>
-The "porting layer" consists of the OS and DDX layers; these are
-actually parallel and neither one is on top of the other.
-The DIX layer is intended to be portable
-without change to target systems and is not
-detailed here, although several routines
-in DIX that are called by DDX are
-documented.
-Extensions incorporate new functionality into the server; and require
-additional functionality over a simple DDX.
-</para>
-<para>
-The following sections outline the functions of the layers.
-Section 3 briefly tells what you need to know about the DIX layer.
-The OS layer is explained in Section 4.
-Section 5 gives the theory of operation and procedural interface for the
-DDX layer.
-Section 6 describes the functions which exist for the extension writer.
-</para>
-</section>
-
-<section>
-  <title>DIX Layer</title>
-<para>
-The DIX layer is the machine and device independent part of X.
-The source should be common to all operating systems and devices.
-The port process should not include changes to this part, therefore internal interfaces to DIX
-modules are not discussed, except for public interfaces to the DDX and the OS layers.
-The functions described in this section are available for extension writers to use.
-</para>
-<para>
-In the process of getting your server to work, if
-you think that DIX must be modified for purposes other than bug fixes,
-you may be doing something wrong.
-Keep looking for a more compatible solution.
-When the next release of the X server code is available,
-you should be able to just drop in the new DIX code and compile it.
-If you change DIX,
-you will have to remember what changes you made and will have
-to change the new sources before you can update to the new version.
-</para>
-<para>
-The heart of the DIX code is a loop called the dispatch loop.
-Each time the processor goes around the loop, it sends off accumulated input events
-from the input devices to the clients, and it processes requests from the clients.
-This loop is the most organized way for the server to
-process the asynchronous requests that
-it needs to process.
-Most of these operations are performed by OS and DDX routines that you must supply.
-</para>
-<section>
-  <title>Server Resource System</title>
-<para>
-X resources are C structs inside the server.
-Client applications create and manipulate these objects
-according to the rules of the X byte stream protocol.
-Client applications refer to resources with resource IDs,
-which are 32-bit integers that are sent over the network.
-Within the server, of course, they are just C structs, and we refer to them
-by pointers.
-</para>
-<section>
-  <title>Pre-Defined Resource Types</title>
-<para>
-The DDX layer has several kinds of resources:
-<itemizedlist>
-<listitem><para>Window</para></listitem>
-<listitem><para>Pixmap</para></listitem>
-<listitem><para>Screen</para></listitem>
-<listitem><para>Device</para></listitem>
-<listitem><para>Colormap</para></listitem>
-<listitem><para>Font</para></listitem>
-<listitem><para>Cursor</para></listitem>
-<listitem><para>Graphics Contexts</para></listitem>
-</itemizedlist>
-</para>
-<para>
-The type names of the more
-important server
-structs usually end in "Rec," such as "DeviceRec;"
-the pointer types usually end in "Ptr," such as "DevicePtr."
-</para>
-<para>
-The structs and
-important defined constants are declared
-in .h files that have names that suggest the name of the object.
-For instance, there are two .h files for windows,
-window.h and windowstr.h.
-window.h defines only what needs to be defined in order to use windows
-without peeking inside of them;
-windowstr.h defines the structs with all of their components in great detail
-for those who need it.
-</para>
-<para>
-Three kinds of fields are in these structs:
-<itemizedlist>
-<listitem><para>Attribute fields - struct fields that contain values like normal structs</para></listitem>
-<listitem><para>Pointers to procedures, or structures of procedures, that operate on the object</para></listitem>
-<listitem><para>A single private field or a devPrivates list (see <xref linkend="wrappers_and_privates"/>)
-used by your DDX code to store private data.</para></listitem>
-</itemizedlist>
-</para>
-<para>
-DIX calls through
-the struct's procedure pointers to do its tasks.
-These procedures are set either directly or indirectly by DDX procedures.
-Most of
-the procedures described in the remainder of this
-document are accessed through one of these structs.
-For example, the procedure to create a pixmap
-is attached to a ScreenRec and might be called by using the expression
-</para>
-<para>
-<blockquote>
-<programlisting>(* pScreen->CreatePixmap)(pScreen, width, height, depth).</programlisting>
-</blockquote>
-</para>
-<para>
-All procedure pointers must be set to some routine unless noted otherwise;
-a null pointer will have unfortunate consequences.
-</para>
-<para>
-Procedure routines will be indicated in the documentation by this convention:
-<blockquote>
-<programlisting>void pScreen->MyScreenRoutine(arg, arg, ...)</programlisting>
-</blockquote>
-as opposed to a free routine, not in a data structure:
-<blockquote>
-<programlisting>void MyFreeRoutine(arg, arg, ...)</programlisting>
-</blockquote>
-</para>
-<para>
-The attribute fields are mostly set by DIX; DDX should not modify them
-unless noted otherwise.
-</para>
-</section>
-<section>
-  <title>Creating Resources and Resource Types</title>
-<para>
-These functions should also be called from your extensionInitProc to
-allocate all of the various resource classes and types required for
-the extension.  Each time the server resets, these types must be reallocated
-as the old allocations will have been discarded.
-Resource types are integer values starting at 1.  Get
-a resource type by calling
-<blockquote><programlisting>
-
-    RESTYPE CreateNewResourceType(deleteFunc, char *name)
-
-</programlisting></blockquote>
-deleteFunc will be called to destroy all resources with this
-type.   name will be used to identify this type of resource
-to clients using the X-Resource extension, to security
-extensions such as SELinux, and to tracing frameworks such as DTrace.
-[The name argument was added in xorg-server 1.8.]
-</para>
-<para>
-Resource classes are masks starting at 1 << 31 which can
-be or'ed with any resource type to provide attributes for the
-type.  To allocate a new class bit, call
-<blockquote><programlisting>
-
-    RESTYPE CreateNewResourceClass()
-
-</programlisting></blockquote>
-</para>
-<para>
-There are two ways of looking up resources, by type or
-by class.  Classes are non-exclusive subsets of the space of
-all resources, so you can lookup the union of multiple classes.
-(RC_ANY is the union of all classes).</para>
-<para>
-Note that the appropriate class bits must be or'ed into the value returned
-by CreateNewResourceType when calling resource lookup functions.</para>
-<para>
-If you need to create a ``private'' resource ID for internal use, you
-can call FakeClientID.
-<blockquote><programlisting>
-
-	XID FakeClientID(client)
-	    int client;
-
-</programlisting></blockquote>
-This allocates from ID space reserved for the server.</para>
-<para>
-To associate a resource value with an ID, use AddResource.
-<blockquote><programlisting>
-
-	Bool AddResource(id, type, value)
-	    XID id;
-	    RESTYPE type;
-	    pointer value;
-
-</programlisting></blockquote>
-The type should be the full type of the resource, including any class
-bits.  If AddResource fails to allocate memory to store the resource,
-it will call the deleteFunc for the type, and then return False.</para>
-<para>
-To free a resource, use one of the following.
-<blockquote><programlisting>
-
-	void FreeResource(id, skipDeleteFuncType)
-	    XID id;
-	    RESTYPE skipDeleteFuncType;
-
-	void FreeResourceByType(id, type, skipFree)
-	    XID id;
-	    RESTYPE type;
-	    Bool    skipFree;
-
-</programlisting></blockquote>
-FreeResource frees all resources matching the given id, regardless of
-type; the type's deleteFunc will be called on each matching resource,
-except that skipDeleteFuncType can be set to a single type for which
-the deleteFunc should not be called (otherwise pass RT_NONE).
-FreeResourceByType frees a specific resource matching a given id
-and type; if skipFree is true, then the deleteFunc is not called.
-</para>
-</section>
-<section>
-  <title>Looking Up Resources</title>
-<para>
-To look up a resource, use one of the following.
-<blockquote><programlisting>
-
-	int dixLookupResourceByType(
-	    pointer *result,
-	    XID id,
-	    RESTYPE rtype,
-	    ClientPtr client,
-	    Mask access_mode);
-
-	int dixLookupResourceByClass(
-	    pointer *result,
-	    XID id,
-	    RESTYPE rclass,
-	    ClientPtr client,
-	    Mask access_mode);
-
-</programlisting></blockquote>
-dixLookupResourceByType finds a resource with the given id and exact type.
-dixLookupResourceByClass finds a resource with the given id whose type is
-included in any one of the specified classes.
-The client and access_mode must be provided to allow security extensions to
-check if the client has the right privileges for the requested access.
-The bitmask values defined in the dixaccess.h header are or'ed together
-to define the requested access_mode.
-</para>
-</section>
-</section>
-<section>
-  <title>Callback Manager</title>
-<para>
-To satisfy a growing number of requests for the introduction of ad hoc
-notification style hooks in the server, a generic callback manager was
-introduced in R6.  A callback list object can be introduced for each
-new hook that is desired, and other modules in the server can register
-interest in the new callback list.  The following functions support
-these operations.</para>
-<para>
-Before getting bogged down in the interface details, an typical usage
-example should establish the framework.  Let's look at the
-ClientStateCallback in dix/dispatch.c.  The purpose of this particular
-callback is to notify interested parties when a client's state
-(initial, running, gone) changes.  The callback is "created" in this
-case by simply declaring a variable:
-<blockquote><programlisting>
-	CallbackListPtr ClientStateCallback;
-</programlisting></blockquote>
-</para>
-<para>
-Whenever the client's state changes, the following code appears, which notifies
-all interested parties of the change:
-<blockquote><programlisting>
-	if (ClientStateCallback) CallCallbacks(&ClientStateCallback, (pointer)client);
-</programlisting></blockquote>
-</para>
-<para>
-Interested parties subscribe to the ClientStateCallback list by saying:
-<blockquote><programlisting>
-	AddCallback(&ClientStateCallback, func, data);
-</programlisting></blockquote>
-</para>
-<para>
-When CallCallbacks is invoked on the list, func will be called thusly:
-<blockquote><programlisting>
-	(*func)(&ClientStateCallback, data, client)
-</programlisting></blockquote>
-</para>
-<para>
-Now for the details.
-<blockquote><programlisting>
-
-	Bool AddCallback(pcbl, callback, subscriber_data)
-	    CallbackListPtr *pcbl;
-	    CallbackProcPtr callback;
-	    pointer         subscriber_data;
-
-</programlisting></blockquote>
-Adds the (callback, subscriber_data) pair to the given callback list.  Creates the callback
-list if it doesn't exist.  Returns TRUE if successful.</para>
-<para>
-<blockquote><programlisting>
-
-	Bool DeleteCallback(pcbl, callback, subscriber_data)
-	    CallbackListPtr *pcbl;
-	    CallbackProcPtr callback;
-	    pointer         subscriber_data;
-
-</programlisting></blockquote>
-Removes the (callback, data) pair to the given callback list if present.
-Returns TRUE if (callback, data) was found.</para>
-<para>
-<blockquote><programlisting>
-
-	void CallCallbacks(pcbl, call_data)
-	    CallbackListPtr    *pcbl;
-	    pointer	    call_data;
-
-</programlisting></blockquote>
-For each callback currently registered on the given callback list, call
-it as follows:
-<blockquote><programlisting>
-
-	(*callback)(pcbl, subscriber_data, call_data);
-</programlisting></blockquote>
-</para>
-<para>
-<blockquote><programlisting>
-	void DeleteCallbackList(pcbl)
-	    CallbackListPtr    *pcbl;
-
-</programlisting></blockquote>
-Destroys the given callback list.</para>
-</section>
-<section>
-  <title>Extension Interfaces</title>
-<para>
-This function should be called from your extensionInitProc which
-should be called by InitExtensions.
-<blockquote><programlisting>
-
-	ExtensionEntry *AddExtension(name, NumEvents,NumErrors,
-		MainProc, SwappedMainProc, CloseDownProc, MinorOpcodeProc)
-
-		char *name;  /*Null terminate string; case matters*/
-		int NumEvents;
-		int NumErrors;
-		int (* MainProc)(ClientPtr);/*Called if client matches server order*/
-		int (* SwappedMainProc)(ClientPtr);/*Called if client differs from server*/
-		void (* CloseDownProc)(ExtensionEntry *);
-		unsigned short (*MinorOpcodeProc)(ClientPtr);
-
-</programlisting></blockquote>
-name is the name used by clients to refer to the extension.  NumEvents is the
-number of event types used by the extension, NumErrors is the number of
-error codes needed by the extension.  MainProc is called whenever a client
-accesses the major opcode assigned to the extension.  SwappedMainProc is
-identical, except the client using the extension has reversed byte-sex.
-CloseDownProc is called at server reset time to deallocate any private
-storage used by the extension.  MinorOpcodeProc is used by DIX to place the
-appropriate value into errors.  The DIX routine StandardMinorOpcode can be
-used here which takes the minor opcode from the normal place in the request
-(i.e. just after the major opcode).</para>
-</section>
-<section>
-  <title>Macros and Other Helpers</title>
-<para>
-There are a number of macros in Xserver/include/dix.h which
-are useful to the extension writer.  Ones of particular interest
-are: REQUEST, REQUEST_SIZE_MATCH, REQUEST_AT_LEAST_SIZE,
-REQUEST_FIXED_SIZE, LEGAL_NEW_RESOURCE, and
-VALIDATE_DRAWABLE_AND_GC. Useful byte swapping macros can be found
-in Xserver/include/dix.h: WriteReplyToClient and WriteSwappedDataToClient; and
-in Xserver/include/misc.h: lswapl, lswaps, LengthRestB, LengthRestS,
-LengthRestL, SwapRestS, SwapRestL, swapl, swaps, cpswapl, and cpswaps.</para>
-</section>
-</section>
-
-<section>
-  <title>OS Layer</title>
-<para>
-This part of the source consists of a few routines that you have to rewrite
-for each operating system.
-These OS functions maintain the client connections and schedule work
-to be done for clients.
-They also provide an interface to font files,
-font name to file name translation, and
-low level memory management.
-<blockquote>
-<programlisting>void OsInit()</programlisting>
-</blockquote>
-OsInit initializes your OS code, performing whatever tasks need to be done.
-Frequently there is not much to be done.
-The sample server implementation is in Xserver/os/osinit.c.
-</para>
-<section>
-  <title>Scheduling and Request Delivery</title>
-<para>
-The main dispatch loop in DIX creates the illusion of multitasking between
-different windows, while the server is itself but a single process.
-The dispatch loop breaks up the work for each client into small digestible parts.
-Some parts are requests from a client, such as individual graphic commands.
-Some parts are events delivered to the client, such as keystrokes from the user.
-The processing of events and requests for different
-clients can be interleaved with one another so true multitasking
-is not needed in the server.
-</para>
-<para>
-You must supply some of the pieces for proper scheduling between clients.
-<blockquote>
-<programlisting>
-	int WaitForSomething(pClientReady)
-		int *pClientReady;
-</programlisting>
-</blockquote>
-</para>
-<para>
-WaitForSomething is the scheduler procedure you must write that will
-suspend your server process until something needs to be done.
-This call should
-make the server suspend until one or more of the following occurs:
-<itemizedlist>
-<listitem><para>There is an input event from the user or hardware (see SetInputCheck())</para></listitem>
-<listitem><para>There are requests waiting from known clients, in which case you should return a count of clients stored in pClientReady</para></listitem>
-<listitem><para>A new client tries to connect, in which case you should create the client and then continue waiting</para></listitem>
-</itemizedlist>
-</para>
-<para>
-Before WaitForSomething() computes the masks to pass to select, poll or
-similar operating system interface, it needs to
-see if there is anything to do on the work queue; if so, it must call a DIX
-routine called ProcessWorkQueue.
-<blockquote>
-<programlisting>
-	extern WorkQueuePtr	workQueue;
-
-	if (workQueue)
-		ProcessWorkQueue ();
-</programlisting>
-</blockquote>
-</para>
-<para>
-If WaitForSomething() decides it is about to do something that might block
-(in the sample server,  before it calls select() or poll) it must call a DIX
-routine called BlockHandler().
-<blockquote>
-<programlisting>
-	void BlockHandler(pTimeout, pReadmask)
-		pointer pTimeout;
-		pointer pReadmask;
-</programlisting>
-</blockquote>
-The types of the arguments are for agreement between the OS and DDX
-implementations,  but the pTimeout is a pointer to the information
-determining how long the block is allowed to last,  and the
-pReadmask is a pointer to the information describing the descriptors
-that will be waited on.
-</para>
-<para>
-In the sample server,  pTimeout is a struct timeval **,  and pReadmask is
-the address of the select() mask for reading.
-</para>
-<para>
-The DIX BlockHandler() iterates through the Screens,  for each one calling
-its BlockHandler.  A BlockHandler is declared thus:
-<blockquote>
-<programlisting>
-	void xxxBlockHandler(nscreen, pbdata, pptv, pReadmask)
-		int nscreen;
-		pointer pbdata;
-		struct timeval ** pptv;
-		pointer pReadmask;
-</programlisting>
-</blockquote>
-The arguments are the index of the Screen,  the blockData field
-of the Screen,  and the arguments to the DIX BlockHandler().
-</para>
-<para>
-Immediately after WaitForSomething returns from the
-block,  even if it didn't actually block,  it must call the DIX routine
-WakeupHandler().
-<blockquote>
-<programlisting>
-	void WakeupHandler(result, pReadmask)
-		int result;
-		pointer pReadmask;
-</programlisting>
-</blockquote>
-Once again,  the types are not specified by DIX.  The result is the
-success indicator for the thing that (may have) blocked,
-and the pReadmask is a mask of the descriptors that came active.
-In the sample server,  result is the result from select() (or equivalent
-operating system function),  and pReadmask is
-the address of the select() mask for reading.
-</para>
-<para>
-The DIX WakeupHandler() calls each Screen's
-WakeupHandler.  A WakeupHandler is declared thus:
-<blockquote>
-<programlisting>
-	void xxxWakeupHandler(nscreen, pbdata, err, pReadmask)
-		int nscreen;
-		pointer pbdata;
-		unsigned long result;
-		pointer pReadmask;
-</programlisting>
-</blockquote>
-The arguments are the index of the Screen,  the blockData field
-of the Screen,  and the arguments to the DIX WakeupHandler().
-</para>
-<para>
-In addition to the per-screen BlockHandlers, any module may register
-block and wakeup handlers (only together) using:
-<blockquote>
-<programlisting>
-	Bool RegisterBlockAndWakeupHandlers (blockHandler, wakeupHandler, blockData)
-		BlockHandlerProcPtr    blockHandler;
-		WakeupHandlerProcPtr   wakeupHandler;
-		pointer blockData;
-</programlisting>
-</blockquote>
-A FALSE return code indicates that the registration failed for lack of
-memory.  To remove a registered Block handler at other than server reset time
-(when they are all removed automatically), use:
-<blockquote>
-<programlisting>
-	RemoveBlockAndWakeupHandlers (blockHandler, wakeupHandler, blockData)
-		BlockHandlerProcPtr   blockHandler;
-		WakeupHandlerProcPtr  wakeupHandler;
-		pointer blockData;
-</programlisting>
-</blockquote>
-All three arguments must match the values passed to
-RegisterBlockAndWakeupHandlers.
-</para>
-<para>
-These registered block handlers are called after the per-screen handlers:
-<blockquote>
-<programlisting>
-	void (*BlockHandler) (blockData, pptv, pReadmask)
-		pointer	blockData;
-		OsTimerPtr pptv;
-		pointer	pReadmask;
-</programlisting>
-</blockquote>
-</para>
-<para>
-Sometimes block handlers need to adjust the time in a OSTimePtr structure,
-which on UNIX family systems is generally represented by a struct timeval
-consisting of seconds and microseconds in 32 bit values.
-As a convenience to reduce error prone struct timeval computations which
-require modulus arithmetic and correct overflow behavior in the face of
-millisecond wrapping through 32 bits,
-<blockquote><programlisting>
-
-	void AdjustWaitForDelay(pointer /*waitTime*, unsigned long /* newdelay */)
-
-</programlisting></blockquote>
-has been provided.
-</para>
-<para>
-Any wakeup handlers registered with RegisterBlockAndWakeupHandlers will
-be called before the Screen handlers:
-<blockquote><programlisting>
-
-	void (*WakeupHandler) (blockData, err, pReadmask)
-		pointer	blockData;
-		int err;
-		pointer pReadmask;
-</programlisting></blockquote>
-</para>
-<para>
-The WaitForSomething on the sample server also has a built
-in screen saver that darkens the screen if no input happens for a period of time.
-The sample server implementation is in Xserver/os/WaitFor.c.
-</para>
-<para>
-Note that WaitForSomething() may be called when you already have several
-outstanding things (events, requests, or new clients) queued up.
-For instance, your server may have just done a large graphics request,
-and it may have been a long time since WaitForSomething() was last called.
-If many clients have lots of requests queued up, DIX will only service
-some of them for a given client
-before going on to the next client (see isItTimeToYield, below).
-Therefore, WaitForSomething() will have to report that these same clients
-still have requests queued up the next time around.
-</para>
-<para>
-An implementation should return information on as
-many outstanding things as it can.
-For instance, if your implementation always checks for client data first and does not
-report any input events until there is no client data left,
-your mouse and keyboard might get locked out by an application that constantly
-barrages the server with graphics drawing requests.
-Therefore, as a general rule, input devices should always have priority over graphics
-devices.
-</para>
-<para>
-A list of indexes (client->index) for clients with data ready to be read or
-processed should be returned in pClientReady, and the count of indexes
-returned as the result value of the call.
-These are not clients that have full requests ready, but any clients who have
-any data ready to be read or processed.
-The DIX dispatcher
-will process requests from each client in turn by calling
-ReadRequestFromClient(), below.
-</para>
-<para>
-WaitForSomething() must create new clients as they are requested (by
-whatever mechanism at the transport level).  A new client is created
-by calling the DIX routine:
-<blockquote><programlisting>
-
-	ClientPtr NextAvailableClient(ospriv)
-		pointer ospriv;
-</programlisting></blockquote>
-This routine returns NULL if a new client cannot be allocated (e.g. maximum
-number of clients reached).  The ospriv argument will be stored into the OS
-private field (pClient->osPrivate), to store OS private information about the
-client.  In the sample server, the osPrivate field contains the
-number of the socket for this client. See also "New Client Connections."
-NextAvailableClient() will call InsertFakeRequest(), so you must be
-prepared for this.
-</para>
-<para>
-If there are outstanding input events,
-you should make sure that the two SetInputCheck() locations are unequal.
-The DIX dispatcher will call your implementation of ProcessInputEvents()
-until the SetInputCheck() locations are equal.
-</para>
-<para>
-The sample server contains an implementation of WaitForSomething().
-The
-following two routines indicate to WaitForSomething() what devices should
-be waited for.   fd is an OS dependent type; in the sample server
-it is an open file descriptor.
-<blockquote><programlisting>
-
-	int AddEnabledDevice(fd)
-		int fd;
-
-	int RemoveEnabledDevice(fd)
-		int fd;
-</programlisting></blockquote>
-These two routines are
-usually called by DDX from the initialize cases of the
-Input Procedures that are stored in the DeviceRec (the
-routine passed to AddInputDevice()).
-The sample server implementation of AddEnabledDevice
-and RemoveEnabledDevice are in Xserver/os/connection.c.
-</para>
-<section>
-  <title>Timer Facilities</title>
-<para>
-Similarly, the X server or an extension may need to wait for some timeout.
-Early X releases implemented this functionality using block and wakeup handlers,
-but this has been rewritten to use a general timer facilty, and the
-internal screen saver facilities reimplemented to use Timers.
-These functions are TimerInit, TimerForce, TimerSet, TimerCheck, TimerCancel,
-and TimerFree, as defined in Xserver/include/os.h. A callback function will be called
-when the timer fires, along with the current time, and a user provided argument.
-<blockquote><programlisting>
-	typedef	struct _OsTimerRec *OsTimerPtr;
-
-	typedef CARD32 (*OsTimerCallback)(
-		OsTimerPtr /* timer */,
-		CARD32 /* time */,
-		pointer /* arg */);
-
-	 OsTimerPtr TimerSet( OsTimerPtr /* timer */,
-		int /* flags */,
-		CARD32 /* millis */,
-		OsTimerCallback /* func */,
-		pointer /* arg */);
-
-</programlisting></blockquote>
-</para>
-<para>
-TimerSet returns a pointer to a timer structure and sets a timer to the specified time
-with the specified argument.  The flags can be TimerAbsolute and TimerForceOld.
-The TimerSetOld flag controls whether if the timer is reset and the timer is pending, the
-whether the callback function will get called.
-The TimerAbsolute flag sets the callback time to an absolute time in the future rather
-than a time relative to when TimerSet is called.
-TimerFree should be called to free the memory allocated
-for the timer entry.
-<blockquote><programlisting>
-	void TimerInit(void)
-
-	Bool TimerForce(OsTimerPtr /* pTimer */)
-
-	void TimerCheck(void);
-
-	void TimerCancel(OsTimerPtr /* pTimer */)
-
-	void TimerFree(OsTimerPtr /* pTimer */)
-</programlisting></blockquote>
-</para>
-<para>
-TimerInit frees any existing timer entries. TimerForce forces a call to the timer's
-callback function and returns true if the timer entry existed, else it returns false and
-does not call the callback function. TimerCancel will cancel the specified timer.
-TimerFree calls TimerCancel and frees the specified timer.
-Calling TimerCheck will force the server to see if any timer callbacks should be called.
-</para>
-</section>
-</section>
-<section>
-  <title>New Client Connections</title>
-<para>
-The process whereby a new client-server connection starts up is
-very dependent upon what your byte stream mechanism.
-This section describes byte stream initiation using examples from the TCP/IP
-implementation on the sample server.
-</para>
-<para>
-The first thing that happens is a client initiates a connection with the server.
-How a client knows to do this depends upon your network facilities and the
-Xlib implementation.
-In a typical scenario, a user named Fred
-on his X workstation is logged onto a Cray
-supercomputer running a command shell in an X window.  Fred can type shell
-commands and have the Cray respond as though the X server were a dumb terminal.
-Fred types in a command to run an X client application that was linked with Xlib.
-Xlib looks at the shell environment variable DISPLAY, which has the
-value "fredsbittube:0.0."
-The host name of Fred's workstation is "fredsbittube," and the 0s are
-for multiple screens and multiple X server processes.
-(Precisely what
-happens on your system depends upon how X and Xlib are implemented.)
-</para>
-<para>
-The client application calls a TCP routine on the
-Cray to open a TCP connection for X
-to communicate with the network node "fredsbittube."
-The TCP software on the Cray does this by looking up the TCP
-address of "fredsbittube" and sending an open request to TCP port 6000
-on fredsbittube.
-</para>
-<para>
-All X servers on TCP listen for new clients on port 6000 by default;
-this is known as a "well-known port" in IP terminology.
-</para>
-<para>
-The server receives this request from its port 6000
-and checks where it came from to see if it is on the server's list
-of "trustworthy" hosts to talk to.
-Then, it opens another port for communications with the client.
-This is the byte stream that all X communications will go over.
-</para>
-<para>
-Actually, it is a bit more complicated than that.
-Each X server process running on the host machine is called a "display."
-Each display can have more than one screen that it manages.
-"corporatehydra:3.2" represents screen 2 on display 3 on
-the multi-screened network node corporatehydra.
-The open request would be sent on well-known port number 6003.
-</para>
-<para>
-Once the byte stream is set up, what goes on does not depend very much
-upon whether or not it is TCP.
-The client sends an xConnClientPrefix struct (see Xproto.h) that has the
-version numbers for the version of Xlib it is running, some byte-ordering information,
-and two character strings used for authorization.
-If the server does not like the authorization strings
-or the version numbers do not match within the rules,
-or if anything else is wrong, it sends a failure
-response with a reason string.
-</para>
-<para>
-If the information never comes, or comes much too slowly, the connection
-should be broken off.  You must implement the connection timeout.  The
-sample server implements this by keeping a timestamp for each still-connecting
-client and, each time just before it attempts to accept new connections, it
-closes any connection that are too old.
-The connection timeout can be set from the command line.
-</para>
-<para>
-You must implement whatever authorization schemes you want to support.
-The sample server on the distribution tape supports a simple authorization
-scheme.  The only interface seen by DIX is:
-<blockquote><programlisting>
-
-	char *
-	ClientAuthorized(client, proto_n, auth_proto, string_n, auth_string)
-	    ClientPtr client;
-	    unsigned int proto_n;
-	    char *auth_proto;
-	    unsigned int string_n;
-	    char *auth_string;
-</programlisting></blockquote>
-DIX will only call this once per client, once it has read the full initial
-connection data from the client.  If the connection should be
-accepted ClientAuthorized() should return NULL, and otherwise should
-return an error message string.
-</para>
-<para>
-Accepting new connections happens internally to WaitForSomething().
-WaitForSomething() must call the DIX routine NextAvailableClient()
-to create a client object.
-Processing of the initial connection data will be handled by DIX.
-Your OS layer must be able to map from a client
-to whatever information your OS code needs to communicate
-on the given byte stream to the client.
-DIX uses this ClientPtr to refer to
-the client from now on.   The sample server uses the osPrivate field in
-the ClientPtr to store the file descriptor for the socket, the
-input and output buffers, and authorization information.
-</para>
-<para>
-To initialize the methods you choose to allow clients to connect to
-your server, main() calls the routine
-<blockquote><programlisting>
-
-	void CreateWellKnownSockets()
-</programlisting></blockquote>
-This routine is called only once, and not called when the server
-is reset.  To recreate any sockets during server resets, the following
-routine is called from the main loop:
-<blockquote><programlisting>
-
-	void ResetWellKnownSockets()
-</programlisting></blockquote>
-Sample implementations of both of these routines are found in
-Xserver/os/connection.c.
-</para>
-<para>
-For more details, see the section called "Connection Setup" in the X protocol specification.
-</para>
-</section>
-<section>
-  <title>Reading Data from Clients</title>
-<para>
-Requests from the client are read in as a byte stream by the OS layer.
-They may be in the form of several blocks of bytes delivered in sequence; requests may
-be broken up over block boundaries or there may be many requests per block.
-Each request carries with it length information.
-It is the responsibility of the following routine to break it up into request blocks.
-<blockquote><programlisting>
-
-	int ReadRequestFromClient(who)
-		ClientPtr who;
-</programlisting></blockquote>
-</para>
-<para>
-You must write
-the routine ReadRequestFromClient() to get one request from the byte stream
-belonging to client "who."
-You must swap the third and fourth bytes (the second 16-bit word) according to the
-byte-swap rules of
-the protocol to determine the length of the
-request.
-This length is measured in 32-bit words, not in bytes.  Therefore, the
-theoretical maximum request is 256K.
-(However, the maximum length allowed is dependent upon the server's input
-buffer.  This size is sent to the client upon connection.  The maximum
-size is the constant MAX_REQUEST_SIZE in Xserver/include/os.h)
-The rest of the request you return is
-assumed NOT to be correctly swapped for internal
-use, because that is the responsibility of DIX.
-</para>
-<para>
-The 'who' argument is the ClientPtr returned from WaitForSomething.
-The return value indicating status should be set to the (positive) byte count if the read is successful,
-0 if the read was blocked, or a negative error code if an error happened.
-</para>
-<para>
-You must then store a pointer to
-the bytes of the request in the client request buffer field;
-who->requestBuffer.  This can simply be a pointer into your buffer;
-DIX may modify it in place but will not otherwise cause damage.
-Of course, the request must be contiguous; you must
-shuffle it around in your buffers if not.
-</para>
-<para>
-The sample server implementation is in Xserver/os/io.c.
-</para>
-<section><title>Inserting Data for Clients</title>
-<para>
-DIX can insert data into the client stream, and can cause a "replay" of
-the current request.
-<blockquote><programlisting>
-
-	Bool InsertFakeRequest(client, data, count)
-	    ClientPtr client;
-	    char *data;
-	    int count;
-
-	int ResetCurrentRequest(client)
-	    ClientPtr client;
-</programlisting></blockquote>
-</para>
-<para>
-InsertFakeRequest() must insert the specified number of bytes of data
-into the head of the input buffer for the client.  This may be a
-complete request, or it might be a partial request.  For example,
-NextAvailableCient() will insert a partial request in order to read
-the initial connection data sent by the client.  The routine returns FALSE
-if memory could not be allocated.  ResetCurrentRequest()
-should "back up" the input buffer so that the currently executing request
-will be reexecuted.  DIX may have altered some values (e.g. the overall
-request length), so you must recheck to see if you still have a complete
-request.  ResetCurrentRequest() should always cause a yield (isItTimeToYield).
-</para>
-</section>
-</section>
-
-<section>
-  <title>Sending Events, Errors And Replies To Clients</title>
-<para>
-<blockquote><programlisting>
-
-	int WriteToClient(who, n, buf)
-		ClientPtr who;
-		int n;
-		char *buf;
-</programlisting></blockquote>
-WriteToClient should write n bytes starting at buf to the
-ClientPtr "who".
-It returns the number of bytes written, but for simplicity,
-the number returned must be either the same value as the number
-requested, or -1, signaling an error.
-The sample server implementation is in Xserver/os/io.c.
-</para>
-<para>
-<blockquote><programlisting>
-	void SendErrorToClient(client, majorCode, minorCode, resId, errorCode)
-	    ClientPtr client;
-	    unsigned int majorCode;
-	    unsigned int minorCode;
-	    XID resId;
-	    int errorCode;
-</programlisting></blockquote>
-SendErrorToClient can be used to send errors back to clients,
-although in most cases your request function should simply return
-the error code, having set client->errorValue to the appropriate
-error value to return to the client, and DIX will call this
-function with the correct opcodes for you.
-</para>
-<para>
-<blockquote><programlisting>
-
-	void FlushAllOutput()
-
-	void FlushIfCriticalOutputPending()
-
-	void SetCriticalOutputPending()
-</programlisting></blockquote>
-These three routines may be implemented to support buffered or delayed
-writes to clients, but at the very least, the stubs must exist.
-FlushAllOutput() unconditionally flushes all output to clients;
-FlushIfCriticalOutputPending() flushes output only if
-SetCriticalOutputPending() has be called since the last time output
-was flushed.
-The sample server implementation is in Xserver/os/io.c and
-actually ignores requests to flush output on a per-client basis
-if it knows that there
-are requests in that client's input queue.
-</para>
-</section>
-<section>
-  <title>Font Support</title>
-<para>
-In the sample server, fonts are encoded in disk files or fetched from the
-font server.   The two fonts required by the server, <quote>fixed</quote>
-and <quote>cursor</quote> are commonly compiled into the font library.
-For disk fonts, there is one file per font, with a file name like
-"fixed.pcf".  Font server fonts are read over the network using the
-X Font Server Protocol.  The disk directories containing disk fonts and
-the names of the font servers are listed together in the current "font path."
-</para>
-<para>
-In principle, you can put all your fonts in ROM or in RAM in your server.
-You can put them all in one library file on disk.
-You could generate them on the fly from stroke descriptions.  By placing the
-appropriate code in the Font Library, you will automatically export fonts in
-that format both through the X server and the Font server.
-</para>
-<para>
-The code for processing fonts in different formats, as well as handling the
-metadata files for them on disk (such as <filename>fonts.dir</filename>) is
-located in the libXfont library, which is provided as a separately compiled
-module.  These routines are
-shared between the X server and the Font server, so instead of this document
-specifying what you must implement, simply refer to the font
-library interface specification for the details.  All of the interface code to the Font
-library is contained in dix/dixfonts.c
-</para>
-</section>
-<section>
-  <title>Memory Management</title>
-<para>
-Memory management is based on functions in the C runtime library.
-Xalloc(), Xrealloc(), and Xfree() are deprecated aliases for malloc(),
-realloc(), and free(), and you should simply call the C library functions
-directly.  Consult a C runtime library reference
-manual for more details.
-</para>
-<para>
-Treat memory allocation carefully in your implementation.  Memory
-leaks can be very hard to find and are frustrating to a user.  An X
-server could be running for days or weeks without being reset, just
-like a regular terminal.  If you leak a few dozen k per day, that will
-add up and will cause problems for users that leave their workstations
-on.
-</para>
-</section>
-<section>
-  <title>Client Scheduling</title>
-<para>
-The X server
-has the ability to schedule clients much like an operating system would,
-suspending and restarting them without regard for the state of their input
-buffers.  This functionality allows the X server to suspend one client and
-continue processing requests from other clients while waiting for a
-long-term network activity (like loading a font) before continuing with the
-first client.
-<blockquote><programlisting>
-	Bool isItTimeToYield;
-</programlisting></blockquote>
-isItTimeToYield is a global variable you can set
-if you want to tell
-DIX to end the client's "time slice" and start paying attention to the next client.
-After the current request is finished, DIX will move to the next client.
-</para>
-<para>
-In the sample
-server, ReadRequestFromClient() sets isItTimeToYield after
-10 requests packets in a row are read from the same client.
-</para>
-<para>
-This scheduling algorithm can have a serious effect upon performance when two
-clients are drawing into their windows simultaneously.
-If it allows one client to run until its request
-queue is empty by ignoring isItTimeToYield, the client's queue may
-in fact never empty and other clients will be blocked out.
-On the other hand, if it switchs between different clients too quickly,
-performance may suffer due to too much switching between contexts.
-For example, if a graphics processor needs to be set up with drawing modes
-before drawing, and two different clients are drawing with
-different modes into two different windows, you may
-switch your graphics processor modes so often that performance is impacted.
-</para>
-<para>
-See the Strategies document for
-heuristics on setting isItTimeToYield.
-</para>
-<para>
-The following functions provide the ability to suspend request
-processing on a particular client, resuming it at some later time:
-<blockquote><programlisting>
-
-	int IgnoreClient (who)
-		ClientPtr who;
-
-	int AttendClient (who)
-		ClientPtr who;
-</programlisting></blockquote>
-Ignore client is responsible for pretending that the given client doesn't
-exist.  WaitForSomething should not return this client as ready for reading
-and should not return if only this client is ready.  AttendClient undoes
-whatever IgnoreClient did, setting it up for input again.
-</para>
-<para>
-Three functions support "process control" for X clients:
-<blockquote><programlisting>
-
-	Bool ClientSleep (client, function, closure)
-		ClientPtr	client;
-		Bool		(*function)();
-		pointer		closure;
-
-</programlisting></blockquote>
-This suspends the current client (the calling routine is responsible for
-making its way back to Dispatch()).  No more X requests will be processed
-for this client until ClientWakeup is called.
-<blockquote><programlisting>
-
-	Bool ClientSignal (client)
-		ClientPtr	client;
-
-</programlisting></blockquote>
-This function causes a call to the (*function) parameter passed to
-ClientSleep to be queued on the work queue.  This does not automatically
-"wakeup" the client, but the function called is free to do so by calling:
-<blockquote><programlisting>
-
-	ClientWakeup (client)
-		ClientPtr	client;
-
-</programlisting></blockquote>
-This re-enables X request processing for the specified client.
-</para>
-</section>
-<section>
-  <title>Other OS Functions</title>
-<para>
-<blockquote><programlisting>
-	void
-	ErrorF(char *f, ...)
-
-	void
-	FatalError(char *f, ...)
-
-	void
-	Error(str)
-	    char *str;
-</programlisting></blockquote>
-You should write these three routines to provide for diagnostic output
-from the dix and ddx layers, although implementing them to produce no
-output will not affect the correctness of your server.  ErrorF() and
-FatalError() take a printf() type of format specification in the first
-argument and an implementation-dependent number of arguments following
-that.  Normally, the formats passed to ErrorF() and FatalError()
-should be terminated with a newline.  Error() provides an os interface
-for printing out the string passed as an argument followed by a
-meaningful explanation of the last system error.  Normally the string
-does not contain a newline, and it is only called by the ddx layer.
-In the sample implementation, Error() uses the perror() function.
-</para>
-<para>
-After printing the message arguments, FatalError() must be implemented
-such that the server will call AbortDDX() to give the ddx layer
-a chance to reset the hardware, and then
-terminate the server; it must not return.
-</para>
-<para>
-The sample server implementation for these routines
-is in Xserver/os/log.c along with other routines for logging messages.
-</para>
-</section>
-</section>
-
-<section>
-  <title>DDX Layer</title>
-<para>
-This section describes the
-interface between DIX and DDX.
-While there may be an OS-dependent driver interface between DDX
-and the physical device, that interface is left to the DDX
-implementor and is not specified here.
-</para>
-<para>
-The DDX layer does most of its work through procedures that are
-pointed to by different structs.
-As previously described, the behavior of these resources is largely determined by
-these procedure pointers.
-Most of these routines are for graphic display on the screen or support functions thereof.
-The rest are for user input from input devices.
-</para>
-<section>
-  <title>Input</title>
-<para>
-In this document "input" refers to input from the user,
-such as mouse, keyboard, and
-bar code readers.
-X input devices are of several types: keyboard, pointing device, and
-many others.  The core server has support for extension devices as
-described by the X Input Extension document; the interfaces used by
-that extension are described elsewhere.  The core devices are actually
-implemented as two collections of devices, the mouse is a ButtonDevice,
-a ValuatorDevice and a PtrFeedbackDevice while the keyboard is a KeyDevice,
-a FocusDevice and a KbdFeedbackDevice.  Each part implements a portion of
-the functionality of the device.  This abstraction is hidden from view for
-core devices by DIX.
-</para>
-<para>
-You, the DDX programmer, are
-responsible for some of the routines in this section.
-Others are DIX routines that you should call to do the things you need to do in these DDX routines.
-Pay attention to which is which.
-</para>
-<section>
-  <title>Input Device Data Structures</title>
-<para>
-DIX keeps a global directory of devices in a central data structure
-called InputInfo.
-For each device there is a device structure called a DeviceRec.
-DIX can locate any DeviceRec through InputInfo.
-In addition, it has a special pointer to identify the main pointing device
-and a special pointer to identify the main keyboard.
-</para>
-<para>
-The DeviceRec (Xserver/include/input.h) is a device-independent
-structure that contains the state of an input device.
-A DevicePtr is simply a pointer to a DeviceRec.
-</para>
-<para>
-An xEvent describes an event the server reports to a client.
-Defined in Xproto.h, it is a huge struct of union of structs that have fields for
-all kinds of events.
-All of the variants overlap, so that the struct is actually very small in memory.
-</para>
-</section>
-<section>
-  <title>Processing Events</title>
-<para>
-The main DDX input interface is the following routine:
-<blockquote><programlisting>
-
-	void ProcessInputEvents()
-</programlisting></blockquote>
-You must write this routine to deliver input events from the user.
-DIX calls it when input is pending (see next section), and possibly
-even when it is not.
-You should write it to get events from each device and deliver
-the events to DIX.
-To deliver the events to DIX, DDX should call the following
-routine:
-<blockquote><programlisting>
-
-	void DevicePtr->processInputProc(pEvent, device, count)
-		    xEventPtr events;
-		    DeviceIntPtr device;
-		    int count;
-</programlisting></blockquote>
-This is the "input proc" for the device, a DIX procedure.
-DIX will fill in this procedure pointer to one of its own routines by
-the time ProcessInputEvents() is called the first time.
-Call this input proc routine as many times as needed to
-deliver as many events as should be delivered.
-DIX will buffer them up and send them out as needed.  Count is set
-to the number of event records which make up one atomic device event and
-is always 1 for the core devices (see the X Input Extension for descriptions
-of devices which may use count &#x3E; 1).
-</para>
-<para>
-For example, your ProcessInputEvents() routine might check the mouse and the
-keyboard.
-If the keyboard had several keystrokes queued up, it could just call
-the keyboard's processInputProc as many times as needed to flush its internal queue.
-</para>
-<para>
-event is an xEvent struct you pass to the input proc.
-When the input proc returns, it is finished with the event rec, and you can fill
-in new values and call the input proc again with it.
-</para>
-<para>
-You should deliver the events in the same order that they were generated.
-</para>
-<para>
-For keyboard and pointing devices the xEvent variant should be keyButtonPointer.
-Fill in the following fields in the xEvent record:
-<itemizedlist>
-
-<listitem><para>type - is one of the following: KeyPress, KeyRelease, ButtonPress,
-					ButtonRelease, or MotionNotify</para></listitem>
-<listitem><para>detail - for KeyPress or KeyRelease fields, this should be the
-					key number (not the ASCII code); otherwise unused</para></listitem>
-<listitem><para>time - is the time that the event happened (32-bits, in milliseconds, arbitrary origin)</para></listitem>
-<listitem><para>rootX - is the x coordinate of cursor</para></listitem>
-<listitem><para>rootY - is the y coordinate of cursor</para></listitem>
-
-</itemizedlist>
-The rest of the fields are filled in by DIX.
-</para>
-<para>
-The time stamp is maintained by your code in the DDX layer, and it is your responsibility to
-stamp all events correctly.
-</para>
-<para>
-The x and y coordinates of the pointing device and the time must be filled in for all event types
-including keyboard events.
-</para>
-<para>
-The pointing device must report all button press and release events.
-In addition, it should report a MotionNotify event every time it gets called
-if the pointing device has moved since the last notify.
-Intermediate pointing device moves are stored in a special GetMotionEvents buffer,
-because most client programs are not interested in them.
-</para>
-<para>
-There are quite a collection of sample implementations of this routine,
-one for each supported device.
-</para>
-</section>
-<section>
-<title>Telling DIX When Input is Pending</title>
-<para>
-In the server's dispatch loop, DIX checks to see
-if there is any device input pending whenever WaitForSomething() returns.
-If the check says that input is pending, DIX calls the
-DDX routine ProcessInputEvents().
-</para>
-<para>
-This check for pending input must be very quick; a procedure call
-is too slow.
-The code that does the check is a hardwired IF
-statement in DIX code that simply compares the values
-pointed to by two pointers.
-If the values are different, then it assumes that input is pending and
-ProcessInputEvents() is called by DIX.
-</para>
-<para>
-You must pass pointers to DIX to tell it what values to compare.
-The following procedure
-is used to set these pointers:
-<blockquote><programlisting>
-
-	void SetInputCheck(p1, p2)
-		long *p1, *p2;
-</programlisting></blockquote>
-You should call it sometime during initialization to indicate to DIX the
-correct locations to check.
-You should
-pay special attention to the size of what they actually point to,
-because the locations are assumed to be longs.
-</para>
-<para>
-These two pointers are initialized by DIX
-to point to arbitrary values that
-are different.
-In other words, if you forget to call this routine during initialization,
-the worst thing that will happen is that
-ProcessInputEvents will be called when
-there are no events to process.
-</para>
-<para>
-p1 and p2 might
-point at the head and tail of some shared
-memory queue.
-Another use would be to have one point at a constant 0, with the
-other pointing at some mask containing 1s
-for each input device that has
-something pending.
-</para>
-<para>
-The DDX layer of the sample server calls SetInputCheck()
-once when the
-server's private internal queue is initialized.
-It passes pointers to the queue's head and tail.  See Xserver/mi/mieq.c.
-</para>
-<para>
-<blockquote><programlisting>
-	int TimeSinceLastInputEvent()
-</programlisting></blockquote>
-DDX must time stamp all hardware input
-events.  But DIX sometimes needs to know the
-time and the OS layer needs to know the time since the last hardware
-input event in
-order for the screen saver to work.   TimeSinceLastInputEvent() returns
-the this time in milliseconds.
-</para>
-</section>
-<section>
-  <title>Controlling Input Devices</title>
-<para>
-You must write four routines to do various device-specific
-things with the keyboard and pointing device.
-They can have any name you wish because
-you pass the procedure pointers to DIX routines.
-</para>
-<para>
-<blockquote><programlisting>
-
-	int pInternalDevice->valuator->GetMotionProc(pdevice, coords, start, stop, pScreen)
-		DeviceIntPtr pdevice;
-		xTimecoord * coords;
-		unsigned long start;
-		unsigned long stop;
-		ScreenPtr pScreen;
-</programlisting></blockquote>
-You write this DDX routine to fill in coords with all the motion
-events that have times (32-bit count of milliseconds) between time
-start and time stop.  It should return the number of motion events
-returned.  If there is no motion events support, this routine should
-do nothing and return zero.  The maximum number of coords to return is
-set in InitPointerDeviceStruct(), below.
-</para>
-<para>
-When the user drags the pointing device, the cursor position
-theoretically sweeps through an infinite number of points.  Normally,
-a client that is concerned with points other than the starting and
-ending points will receive a pointer-move event only as often as the
-server generates them. (Move events do not queue up; each new one
-replaces the last in the queue.)  A server, if desired, can implement
-a scheme to save these intermediate events in a motion buffer.  A
-client application, like a paint program, may then request that these
-events be delivered to it through the GetMotionProc routine.
-</para>
-<para>
-<blockquote><programlisting>
-
-	void pInternalDevice->bell->BellProc(percent, pDevice, ctrl, unknown)
-		int percent;
-		DeviceIntPtr pDevice;
-		pointer ctrl;
-		int class;
-</programlisting></blockquote>
-You need to write this routine to ring the bell on the keyboard.
-loud is a number from 0 to 100, with 100 being the loudest.
-Class is either BellFeedbackClass or KbdFeedbackClass (from XI.h).
-</para>
-<para>
-<blockquote><programlisting>
-
-	void pInternalDevice->somedevice->CtrlProc(device, ctrl)
-		DevicePtr device;
-		SomethingCtrl *ctrl;
-
-</programlisting></blockquote>
-You write two versions of this procedure, one for the keyboard and one for the pointing device.
-DIX calls it to inform DDX when a client has requested changes in the current
-settings for the particular device.
-For a keyboard, this might be the repeat threshold and rate.
-For a pointing device, this might be a scaling factor (coarse or fine) for position reporting.
-See input.h for the ctrl structures.
-</para>
-</section>
-<section>
-  <title>Input Initialization</title>
-<para>
-Input initialization is a bit complicated.
-It all starts with InitInput(), a routine that you write to call
-AddInputDevice() twice
-(once for pointing device and once for keyboard.)
-</para>
-<para>
-When you Add the devices, a routine you supply for each device
-gets called to initialize them.
-Your individual initialize routines must call InitKeyboardDeviceStruct()
-or InitPointerDeviceStruct(), depending upon which it is.
-In other words, you indicate twice that the keyboard is the keyboard and
-the pointer is the pointer.
-</para>
-<para>
-<blockquote><programlisting>
-
-	void InitInput(argc, argv)
-	    int argc;
-	    char **argv;
-</programlisting></blockquote>
-InitInput is a DDX routine you must write to initialize the
-input subsystem in DDX.
-It must call AddInputDevice() for each device that might generate events.
-</para>
-<para>
-<blockquote><programlisting>
-
-	DevicePtr AddInputDevice(deviceProc, autoStart)
-		DeviceProc deviceProc;
-		Bool autoStart;
-</programlisting></blockquote>
-AddInputDevice is a DIX routine you call to create a device object.
-deviceProc is a DDX routine that is called by DIX to do various operations.
-AutoStart should be TRUE for devices that need to be turned on at
-initialization time with a special call, as opposed to waiting for some
-client application to
-turn them on.
-This routine returns NULL if sufficient memory cannot be allocated to
-install the device.
-</para>
-<para>
-Note also that except for the main keyboard and pointing device,
-an extension is needed to provide for a client interface to a device.
-</para>
-<para>
-The following DIX
-procedures return the specified DevicePtr. They may or may not be useful
-to DDX implementors.
-</para>
-<para>
-<blockquote><programlisting>
-
-	DevicePtr LookupKeyboardDevice()
-</programlisting></blockquote>
-LookupKeyboardDevice returns pointer for current main keyboard device.
-</para>
-<para>
-<blockquote><programlisting>
-
-	DevicePtr LookupPointerDevice()
-</programlisting></blockquote>
-LookupPointerDevice returns pointer for current main pointing device.
-</para>
-<para>
-A DeviceProc (the kind passed to AddInputDevice()) in the following form:
-<blockquote><programlisting>
-
-	Bool pInternalDevice->DeviceProc(device, action);
-		DeviceIntPtr device;
-		int action;
-</programlisting></blockquote>
-You must write a DeviceProc for each device.
-device points to the device record.
-action tells what action to take;
-it will be one of  these defined constants  (defined in input.h):
-<itemizedlist>
-<listitem><para>
-DEVICE_INIT -
-At DEVICE_INIT time, the device should initialize itself by calling
-InitPointerDeviceStruct(), InitKeyboardDeviceStruct(), or a similar
-routine (see below)
-and "opening" the device if necessary.
-If you return a non-zero (i.e., != Success) value from the DEVICE_INIT
-call, that device will be considered unavailable. If either the main keyboard
-or main pointing device cannot be initialized, the DIX code will refuse
-to continue booting up.</para></listitem>
-<listitem><para>
-DEVICE_ON - If the DeviceProc is called with DEVICE_ON, then it is
-allowed to start
-putting events into the client stream by calling through the ProcessInputProc
-in the device.</para></listitem>
-<listitem><para>
-DEVICE_OFF - If the DeviceProc is called with DEVICE_OFF, no further
-events from that
-device should be given to the DIX layer.
-The device will appear to be dead to the user.</para></listitem>
-<listitem><para>
-DEVICE_CLOSE - At DEVICE_CLOSE (terminate or reset) time, the device should
-be totally closed down.</para></listitem>
-</itemizedlist>
-</para>
-<para>
-<blockquote><programlisting>
-
-	void InitPointerDeviceStruct(device, map, mapLength,
-			GetMotionEvents, ControlProc, numMotionEvents)
-		DevicePtr device;
-		CARD8 *map;
-		int mapLength;
-		ValuatorMotionProcPtr ControlProc;
-		PtrCtrlProcPtr GetMotionEvents;
-		int numMotionEvents;
-</programlisting></blockquote>
-InitPointerDeviceStruct is a DIX routine you call at DEVICE_INIT time to declare
-some operating routines and data structures for a pointing device.
-map and mapLength are as described in the X Window
-System protocol specification.
-ControlProc and GetMotionEvents are DDX routines, see above.
-</para>
-<para>
-numMotionEvents is for the motion-buffer-size for the GetMotionEvents
-request.
-A typical length for a motion buffer would be 100 events.
-A server that does not implement this capability should set
-numMotionEvents to zero.
-</para>
-<para>
-<blockquote><programlisting>
-
-	void InitKeyboardDeviceStruct(device, pKeySyms, pModifiers, Bell, ControlProc)
-		DevicePtr device;
-		KeySymsPtr pKeySyms;
-		CARD8 *pModifiers;
-		BellProcPtr Bell;
-		KbdCtrlProcPtr ControlProc;
-
-</programlisting></blockquote>
-You call this DIX routine when a keyboard device is initialized and
-its device procedure is called with
-DEVICE_INIT.
-The formats of the keysyms and modifier maps are defined in
-Xserver/include/input.h.
-They describe the layout of keys on the keyboards, and the glyphs
-associated with them.  ( See the next section for information on
-setting up the modifier map and the keysym map.)
-ControlProc and Bell are DDX routines, see above.
-</para>
-</section>
-<section>
-  <title>Keyboard Mapping and Keycodes</title>
-<para>
-When you send a keyboard event, you send a report that a given key has
-either been pressed or has been released.  There must be a keycode for
-each key that identifies the key; the keycode-to-key mapping can be
-any mapping you desire, because you specify the mapping in a table you
-set up for DIX.  However, you are restricted by the protocol
-specification to keycode values in the range 8 to 255 inclusive.
-</para>
-<para>
-The keycode mapping information that you set up consists of the following:
-<itemizedlist>
-<listitem><para>
-A minimum and maximum keycode number</para></listitem>
-<listitem><para>
-An array of sets of keysyms for each key, that is of length
-maxkeycode - minkeycode + 1.
-Each element of this array is a list of codes for symbols that are on that key.
-There is no limit to the number of symbols that can be on a key.</para></listitem>
-</itemizedlist>
-Once the map is set up, DIX keeps and
-maintains the client's changes to it.
-</para>
-<para>
-The X protocol defines standard names to indicate the symbol(s)
-printed on each keycap. (See X11/keysym.h)
-</para>
-<para>
-Legal modifier keys must generate both up and down transitions.  When
-a client tries to change a modifier key (for instance, to make "A" the
-"Control" key), DIX calls the following routine, which should return
-TRUE if the key can be used as a modifier on the given device:
-<blockquote><programlisting>
-
-	Bool LegalModifier(key, pDev)
-	    unsigned int key;
-	    DevicePtr pDev;
-</programlisting></blockquote>
-</para>
-</section>
-</section>
-<section>
-<title>Screens</title>
-<para>
-Different computer graphics
-displays have different capabilities.
-Some are simple monochrome
-frame buffers that are just lying
-there in memory, waiting to be written into.
-Others are color displays with many bits per pixel using some color lookup table.
-Still others have high-speed graphic processors that prefer to do all of the work
-themselves,
-including maintaining their own high-level, graphic data structures.
-</para>
-<section>
-  <title>Screen Hardware Requirements</title>
-<para>
-The only requirement on screens is that you be able to both read
-and write locations in the frame buffer.
-All screens must have a depth of 32 or less (unless you use
-an X extension to allow a greater depth).
-All screens must fit into one of the classes listed in the section
-in this document on Visuals and Depths.
-</para>
-<para>
-X uses the pixel as its fundamental unit of distance on the screen.
-Therefore, most programs will measure everything in pixels.</para>
-<para>
-The sample server assumes square pixels.
-Serious WYSIWYG (what you see is what you get) applications for
-publishing and drawing programs will adjust for
-different screen resolutions automatically.
-Considerable work
-is involved in compensating for non-square pixels (a bit in the DDX
-code for the sample server but quite a bit in the client applications).</para>
-</section>
-<section>
-  <title>Data Structures</title>
-<para>
-X supports multiple screens that are connected to the same
-server.  Therefore, all the per-screen information is bundled into one data
-structure of attributes and procedures, which is the ScreenRec (see
-Xserver/include/scrnintstr.h).
-The procedure entry points in a ScreenRec operate on
-regions, colormaps, cursors, and fonts, because these resources
-can differ in format from one screen to another.</para>
-<para>
-Windows are areas on the screen that can be drawn into by graphic
-routines.  "Pixmaps" are off-screen graphic areas that can be drawn
-into.  They are both considered drawables and are described in the
-section on Drawables.  All graphic operations work on drawables, and
-operations are available to copy patches from one drawable to another.</para>
-<para>
-The pixel image data in all drawables is in a format that is private
-to DDX.  In fact, each instance of a drawable is associated with a
-given screen.  Presumably, the pixel image data for pixmaps is chosen
-to be conveniently understood by the hardware.  All screens in a
-single server must be able to handle all pixmaps depths declared in
-the connection setup information.</para>
-<para>
-Pixmap images are transferred to the server in one of two ways:
-XYPixmap or ZPimap.  XYPixmaps are a series of bitmaps, one for each
-bit plane of the image, using the bitmap padding rules from the
-connection setup.  ZPixmaps are a series of bits, nibbles, bytes or
-words, one for each pixel, using the format rules (padding and so on)
-for the appropriate depth.</para>
-<para>
-All screens in a given server must agree on a set of pixmap image
-formats (PixmapFormat) to support (depth, number of bits per pixel,
-etc.).</para>
-<para>
-There is no color interpretation of bits in the pixmap.  Pixmaps
-do not contain pixel values.  The interpretation is made only when
-the bits are transferred onto the screen.</para>
-<para>
-The screenInfo structure (in scrnintstr.h) is a global data structure
-that has a pointer to an array of ScreenRecs, one for each screen on
-the server.  (These constitute the one and only description of each
-screen in the server.)  Each screen has an identifying index (0, 1, 2, ...).
-In addition, the screenInfo struct contains global server-wide
-details, such as the bit- and byte- order in all bit images, and the
-list of pixmap image formats that are supported.  The X protocol
-insists that these must be the same for all screens on the server.</para>
-</section>
-<section>
-  <title>Output Initialization</title>
-<para>
-<blockquote><programlisting>
-
-	InitOutput(pScreenInfo, argc, argv)
-		ScreenInfo *pScreenInfo;
-		int argc;
-		char **argv;
-</programlisting></blockquote>
-Upon initialization, your DDX routine InitOutput() is called by DIX.
-It is passed a pointer to screenInfo to initialize.  It is also passed
-the argc and argv from main() for your server for the command-line
-arguments.  These arguments may indicate what or how many screen
-device(s) to use or in what way to use them.  For instance, your
-server command line may allow a "-D" flag followed by the name of the
-screen device to use.</para>
-<para>
-Your InitOutput() routine should initialize each screen you wish to
-use by calling AddScreen(), and then it should initialize the pixmap
-formats that you support by storing values directly into the
-screenInfo data structure.  You should also set certain
-implementation-dependent numbers and procedures in your screenInfo,
-which determines the pixmap and scanline padding rules for all screens
-in the server.</para>
-<para>
-<blockquote><programlisting>
-
-	int AddScreen(scrInitProc, argc, argv)
-		Bool (*scrInitProc)();
-		int argc;
-		char **argv;
-</programlisting></blockquote>
-You should call AddScreen(), a DIX procedure, in InitOutput() once for
-each screen to add it to the screenInfo database.  The first argument
-is an initialization procedure for the screen that you supply.  The
-second and third are the argc and argv from main().  It returns the
-screen number of the screen installed, or -1 if there is either
-insufficient memory to add the screen, or (*scrInitProc) returned
-FALSE.</para>
-<para>
-The scrInitProc should be of the following form:
-<blockquote><programlisting>
-
-	Bool scrInitProc(iScreen, pScreen, argc, argv)
-		int iScreen;
-		ScreenPtr pScreen;
-		int argc;
-		char **argv;
-</programlisting></blockquote>
-iScreen is the index for this screen; 0 for the first one initialized,
-1 for the second, etc.  pScreen is the pointer to the screen's new
-ScreenRec.  argc and argv are as before.  Your screen initialize
-procedure should return TRUE upon success or FALSE if the screen
-cannot be initialized (for instance, if the screen hardware does not
-exist on this machine).</para>
-<para>
-This procedure must determine what actual device it is supposed to initialize.
-If you have a different procedure for each screen, then it is no problem.
-If you have the same procedure for multiple screens, it may have trouble
-figuring out which screen to initialize each time around, especially if
-InitOutput() does not initialize all of the screens.
-It is probably easiest to have one procedure for each screen.</para>
-<para>
-The initialization procedure should fill in all the screen procedures
-for that screen (windowing functions, region functions, etc.) and certain
-screen attributes for that screen.</para>
-</section>
-<section>
-  <title>Region Routines in the ScreenRec</title>
-<para>
-A region is a dynamically allocated data structure that describes an
-irregularly shaped piece of real estate in XY pixel space.  You can
-think of it as a set of pixels on the screen to be operated upon with
-set operations such as AND and OR.</para>
-<para>
-A region is frequently implemented as a list of rectangles or bitmaps
-that enclose the selected pixels.  Region operators control the
-"clipping policy," or the operations that work on regions.  (The
-sample server uses YX-banded rectangles.  Unless you have something
-already implemented for your graphics system, you should keep that
-implementation.)  The procedure pointers to the region operators are
-located in the ScreenRec data structure.  The definition of a region
-can be found in the file Xserver/include/regionstr.h.  The region code
-is found in Xserver/mi/miregion.c.  DDX implementations using other
-region formats will need to supply different versions of the region
-operators.</para>
-<para>
-Since the list of rectangles is unbounded in size, part of the region
-data structure is usually a large, dynamically allocated chunk of
-memory.  As your region operators calculate logical combinations of
-regions, these blocks may need to be reallocated by your region
-software.  For instance, in the sample server, a RegionRec has some
-header information and a pointer to a dynamically allocated rectangle
-list.  Periodically, the rectangle list needs to be expanded with
-Xrealloc(), whereupon the new pointer is remembered in the RegionRec.</para>
-<para>
-Most of the region operations come in two forms: a function pointer in
-the Screen structure, and a macro.  The server can be compiled so that
-the macros make direct calls to the appropriate functions (instead of
-indirecting through a screen function pointer), or it can be compiled
-so that the macros are identical to the function pointer forms.
-Making direct calls is faster on many architectures.</para>
-<para>
-<blockquote><programlisting>
-
-	RegionPtr pScreen->RegionCreate( rect, size)
-		BoxPtr rect;
-		int size;
-
-	macro: RegionPtr RegionCreate(rect, size)
-
-</programlisting></blockquote>
-RegionCreate creates a region that describes ONE rectangle.  The
-caller can avoid unnecessary reallocation and copying by declaring the
-probable maximum number of rectangles that this region will need to
-describe itself.  Your region routines, though, cannot fail just
-because the region grows beyond this size.  The caller of this routine
-can pass almost anything as the size; the value is merely a good guess
-as to the maximum size until it is proven wrong by subsequent use.
-Your region procedures are then on their own in estimating how big the
-region will get.  Your implementation might ignore size, if
-applicable.</para>
-<para>
-<blockquote><programlisting>
-
-	void pScreen->RegionInit (pRegion, rect, size)
-		RegionPtr	pRegion;
-		BoxPtr		rect;
-		int		size;
-
-	macro: RegionInit(pRegion, rect, size)
-
-</programlisting></blockquote>
-Given an existing raw region structure (such as an local variable), this
-routine fills in the appropriate fields to make this region as usable as
-one returned from RegionCreate.  This avoids the additional dynamic memory
-allocation overhead for the region structure itself.
-</para>
-<para>
-<blockquote><programlisting>
-
-	Bool pScreen->RegionCopy(dstrgn, srcrgn)
-		RegionPtr dstrgn, srcrgn;
-
-	macro: Bool RegionCopy(dstrgn, srcrgn)
-
-</programlisting></blockquote>
-RegionCopy copies the description of one region, srcrgn, to another
-already-created region,
-dstrgn; returning TRUE if the copy succeeded, and FALSE otherwise.</para>
-<para>
-<blockquote><programlisting>
-
-	void pScreen->RegionDestroy( pRegion)
-		RegionPtr pRegion;
-
-	macro: RegionDestroy(pRegion)
-
-</programlisting></blockquote>
-RegionDestroy destroys a region and frees all allocated memory.</para>
-<para>
-<blockquote><programlisting>
-
-	void pScreen->RegionUninit (pRegion)
-		RegionPtr pRegion;
-
-	macro: RegionUninit(pRegion)
-
-</programlisting></blockquote>
-Frees everything except the region structure itself, useful when the
-region was originally passed to RegionInit instead of received from
-RegionCreate.  When this call returns, pRegion must not be reused until
-it has been RegionInit'ed again.</para>
-<para>
-<blockquote><programlisting>
-
-	Bool pScreen->Intersect(newReg, reg1, reg2)
-		RegionPtr newReg, reg1, reg2;
-
-	macro: Bool RegionIntersect(newReg, reg1, reg2)
-
-	Bool  pScreen->Union(newReg, reg1, reg2)
-		RegionPtr newReg, reg1, reg2;
-
-	macro: Bool RegionUnion(newReg, reg1, reg2)
-
-	Bool  pScreen->Subtract(newReg, regMinuend, regSubtrahend)
-		RegionPtr newReg, regMinuend, regSubtrahend;
-
-	macro: Bool RegionUnion(newReg, regMinuend, regSubtrahend)
-
-	Bool pScreen->Inverse(newReg, pReg,  pBox)
-		RegionPtr newReg, pReg;
-		BoxPtr pBox;
-
-	macro: Bool RegionInverse(newReg, pReg,  pBox)
-
-</programlisting></blockquote>
-The above four calls all do basic logical operations on regions.  They
-set the new region (which already exists) to describe the logical
-intersection, union, set difference, or inverse of the region(s) that
-were passed in.  Your routines must be able to handle a situation
-where the newReg is the same region as one of the other region
-arguments.</para>
-<para>
-The subtract function removes the Subtrahend from the Minuend and
-puts the result in newReg.</para>
-<para>
-The inverse function returns a region that is the pBox minus the
-region passed in.  (A true "inverse" would make a region that extends
-to infinity in all directions but has holes in the middle.)  It is
-undefined for situations where the region extends beyond the box.</para>
-<para>
-Each routine must return the value TRUE for success.</para>
-<para>
-<blockquote><programlisting>
-
-	void pScreen->RegionReset(pRegion, pBox)
-		RegionPtr pRegion;
-		BoxPtr pBox;
-
-	macro: RegionReset(pRegion, pBox)
-
-</programlisting></blockquote>
-RegionReset sets the region to describe
-one rectangle and reallocates it to a size of one rectangle, if applicable.</para>
-<para>
-<blockquote><programlisting>
-
-	void  pScreen->TranslateRegion(pRegion, x, y)
-		RegionPtr pRegion;
-		int x, y;
-
-	macro: RegionTranslate(pRegion, x, y)
-
-</programlisting></blockquote>
-TranslateRegion simply moves a region +x in the x direction and +y in the y
-direction.</para>
-<para>
-<blockquote><programlisting>
-
-	int  pScreen->RectIn(pRegion, pBox)
-		RegionPtr pRegion;
-		BoxPtr pBox;
-
-	macro: int RegionContainsRect(pRegion, pBox)
-
-</programlisting></blockquote>
-RectIn returns one of the defined constants rgnIN, rgnOUT, or rgnPART,
-depending upon whether the box is entirely inside the region, entirely
-outside of the region, or partly in and partly out of the region.
-These constants are defined in Xserver/include/region.h.</para>
-<para>
-<blockquote><programlisting>
-
-	Bool pScreen->PointInRegion(pRegion, x, y, pBox)
-		RegionPtr pRegion;
-		int x, y;
-		BoxPtr pBox;
-
-	macro: Bool RegionContainsPoint(pRegion, x, y, pBox)
-
-</programlisting></blockquote>
-PointInRegion returns true if the point x, y is in the region.  In
-addition, it fills the rectangle pBox with coordinates of a rectangle
-that is entirely inside of pRegion and encloses the point.  In the mi
-implementation, it is the largest such rectangle.  (Due to the sample
-server implementation, this comes cheaply.)</para>
-<para>
-This routine used by DIX when tracking the pointing device and
-deciding whether to report mouse events or change the cursor.  For
-instance, DIX needs to change the cursor when it moves from one window
-to another.  Due to overlapping windows, the shape to check may be
-irregular.  A PointInRegion() call for every pointing device movement
-may be too expensive.  The pBox is a kind of wake-up box; DIX need not
-call PointInRegion() again until the cursor wanders outside of the
-returned box.</para>
-<para>
-<blockquote><programlisting>
-
-	Bool pScreen->RegionNotEmpty(pRegion)
-		RegionPtr pRegion;
-
-	macro: Bool RegionNotEmpty(pRegion)
-
-</programlisting></blockquote>
-RegionNotEmpty is a boolean function that returns
-true or false depending upon whether the region encloses any pixels.</para>
-<para>
-<blockquote><programlisting>
-
-	void pScreen->RegionEmpty(pRegion)
-		RegionPtr pRegion;
-
-	macro: RegionEmpty(pRegion)
-
-</programlisting></blockquote>
-RegionEmpty sets the region to be empty.</para>
-<para>
-<blockquote><programlisting>
-
-	BoxPtr pScreen->RegionExtents(pRegion)
-		RegionPtr pRegion;
-
-	macro: RegionExtents(pRegion)
-
-</programlisting></blockquote>
-RegionExtents returns a rectangle that is the smallest
-possible superset of the entire region.
-The caller will not modify this rectangle, so it can be the one
-in your region struct.</para>
-<para>
-<blockquote><programlisting>
-
-	Bool pScreen->RegionAppend (pDstRgn, pRegion)
-		RegionPtr pDstRgn;
-		RegionPtr pRegion;
-
-	macro: Bool RegionAppend(pDstRgn, pRegion)
-
-	Bool pScreen->RegionValidate (pRegion, pOverlap)
-		RegionPtr pRegion;
-		Bool *pOverlap;
-
-	macro: Bool RegionValidate(pRegion, pOverlap)
-
-</programlisting></blockquote>
-These functions provide an optimization for clip list generation and
-must be used in conjunction.  The combined effect is to produce the
-union of a collection of regions, by using RegionAppend several times,
-and finally calling RegionValidate which takes the intermediate
-representation (which needn't be a valid region) and produces the
-desired union.  pOverlap is set to TRUE if any of the original
-regions overlap; FALSE otherwise.</para>
-<para>
-<blockquote><programlisting>
-
-	RegionPtr pScreen->BitmapToRegion (pPixmap)
-		PixmapPtr pPixmap;
-
-	macro: RegionPtr BitmapToRegion(pScreen, pPixmap)
-
-</programlisting></blockquote>
-Given a depth-1 pixmap, this routine must create a valid region which
-includes all the areas of the pixmap filled with 1's and excludes the
-areas filled with 0's.  This routine returns NULL if out of memory.</para>
-<para>
-<blockquote><programlisting>
-
-	RegionPtr pScreen->RectsToRegion (nrects, pRects, ordering)
-		int nrects;
-		xRectangle *pRects;
-		int ordering;
-
-	macro: RegionPtr RegionFromRects(nrects, pRects, ordering)
-
-</programlisting></blockquote>
-Given a client-supplied list of rectangles, produces a region which includes
-the union of all the rectangles.  Ordering may be used as a hint which
-describes how the rectangles are sorted.  As the hint is provided by a
-client, it must not be required to be correct, but the results when it is
-not correct are not defined (core dump is not an option here).</para>
-<para>
-<blockquote><programlisting>
-
-	void pScreen->SendGraphicsExpose(client,pRegion,drawable,major,minor)
-		ClientPtr client;
-		RegionPtr pRegion;
-		XID drawable;
-		int major;
-		int minor;
-
-</programlisting></blockquote>
-SendGraphicsExpose dispatches a list of GraphicsExposure events which
-span the region to the specified client.  If the region is empty, or
-a NULL pointer, a NoExpose event is sent instead.</para>
-</section>
-<section>
-  <title>Cursor Routines for a Screen</title>
-<para>
-A cursor is the visual form tied to the pointing device.  The default
-cursor is an "X" shape, but the cursor can have any shape.  When a
-client creates a window, it declares what shape the cursor will be
-when it strays into that window on the screen.</para>
-<para>
-For each possible shape the cursor assumes, there is a CursorRec data
-structure.  This data structure contains a pointer to a CursorBits
-data structure which contains a bitmap for the image of the cursor and
-a bitmap for a mask behind the cursor, in addition, the CursorRec data
-structure contains foreground and background colors for the cursor.
-The CursorBits data structure is shared among multiple CursorRec
-structures which use the same font and glyph to describe both source
-and mask.  The cursor image is applied to the screen by applying the
-mask first, clearing 1 bits in its form to the background color, and
-then overwriting on the source image, in the foreground color.  (One
-bits of the source image that fall on top of zero bits of the mask
-image are undefined.)  This way, a cursor can have transparent parts,
-and opaque parts in two colors.  X allows any cursor size, but some
-hardware cursor schemes allow a maximum of N pixels by M pixels.
-Therefore, you are allowed to transform the cursor to a smaller size,
-but be sure to include the hot-spot.</para>
-<para>
-CursorBits in Xserver/include/cursorstr.h is a device-independent
-structure containing a device-independent representation of the bits
-for the source and mask.  (This is possible because the bitmap
-representation is the same for all screens.)</para>
-<para>
-When a cursor is created, it is "realized" for each screen.  At
-realization time, each screen has the chance to convert the bits into
-some other representation that may be more convenient (for instance,
-putting the cursor into off-screen memory) and set up its
-device-private area in either the CursorRec data structure or
-CursorBits data structure as appropriate to possibly point to whatever
-data structures are needed.  It is more memory-conservative to share
-realizations by using the CursorBits private field, but this makes the
-assumption that the realization is independent of the colors used
-(which is typically true).  For instance, the following are the device
-private entries for a particular screen and cursor:
-<blockquote><programlisting>
-
-	pCursor->devPriv[pScreen->myNum]
-	pCursor->bits->devPriv[pScreen->myNum]
-
-</programlisting></blockquote>
-This is done because the change from one cursor shape to another must
-be fast and responsive; the cursor image should be able to flutter as
-fast as the user moves it across the screen.</para>
-<para>
-You must implement the following routines for your hardware:
-<blockquote><programlisting>
-
-	Bool pScreen->RealizeCursor( pScr, pCurs)
-		ScreenPtr pScr;
-		CursorPtr pCurs;
-
-	Bool pScreen->UnrealizeCursor( pScr, pCurs)
-		ScreenPtr pScr;
-		CursorPtr pCurs;
-
-</programlisting></blockquote>
-</para>
-<para>
-RealizeCursor and UnrealizeCursor should realize (allocate and
-calculate all data needed) and unrealize (free the dynamically
-allocated data) a given cursor when DIX needs them.  They are called
-whenever a device-independent cursor is created or destroyed.  The
-source and mask bits pointed to by fields in pCurs are undefined for
-bits beyond the right edge of the cursor.  This is so because the bits
-are in Bitmap format, which may have pad bits on the right edge.  You
-should inhibit UnrealizeCursor() if the cursor is currently in use;
-this happens when the system is reset.</para>
-<para>
-<blockquote><programlisting>
-
-	Bool pScreen->DisplayCursor( pScr, pCurs)
-		ScreenPtr pScr;
-		CursorPtr pCurs;
-
-</programlisting></blockquote>
-DisplayCursor should change the cursor on the given screen to the one
-passed in.  It is called by DIX when the user moves the pointing
-device into a different window with a different cursor.  The hotspot
-in the cursor should be aligned with the current cursor position.</para>
-<para>
-<blockquote><programlisting>
-
-	void pScreen->RecolorCursor( pScr, pCurs, displayed)
-		ScreenPtr pScr;
-		CursorPtr pCurs;
-		Bool displayed;
-</programlisting></blockquote>
-RecolorCursor notifies DDX that the colors in pCurs have changed and
-indicates whether this is the cursor currently being displayed.  If it
-is, the cursor hardware state may have to be updated.  Whether
-displayed or not, state created at RealizeCursor time may have to be
-updated.  A generic version, miRecolorCursor, may be used that
-does an unrealize, a realize, and possibly a display (in micursor.c);
-however this constrains UnrealizeCursor and RealizeCursor to always return
-TRUE as no error indication is returned here.</para>
-<para>
-<blockquote><programlisting>
-
-	void pScreen->ConstrainCursor( pScr, pBox)
-		ScreenPtr pScr;
-		BoxPtr pBox;
-
-</programlisting></blockquote>
-ConstrainCursor should cause the cursor to restrict its motion to the
-rectangle pBox.  DIX code is capable of enforcing this constraint by
-forcefully moving the cursor if it strays out of the rectangle, but
-ConstrainCursor offers a way to send a hint to the driver or hardware
-if such support is available.  This can prevent the cursor from
-wandering out of the box, then jumping back, as DIX forces it back.</para>
-<para>
-<blockquote><programlisting>
-
-	void pScreen->PointerNonInterestBox( pScr, pBox)
-		ScreenPtr pScr;
-		BoxPtr pBox;
-
-</programlisting></blockquote>
-PointerNonInterestBox is DIX's way of telling the pointing device code
-not to report motion events while the cursor is inside a given
-rectangle on the given screen.  It is optional and, if not
-implemented, it should do nothing.  This routine is called only when
-the client has declared that it is not interested in motion events in
-a given window.  The rectangle you get may be a subset of that window.
-It saves DIX code the time required to discard uninteresting mouse
-motion events.  This is only a hint, which may speed performance.
-Nothing in DIX currently calls PointerNonInterestBox.</para>
-<para>
-<blockquote><programlisting>
-
-	void pScreen->CursorLimits( pScr, pCurs, pHotBox, pTopLeftBox)
-		ScreenPtr pScr;
-		CursorPtr pCurs;
-		BoxPtr pHotBox;
-		BoxPtr pTopLeftBox;	/* return value */
-
-</programlisting></blockquote>
-CursorLimits should calculate the box that the cursor hot spot is
-physically capable of moving within, as a function of the screen pScr,
-the device-independent cursor pCurs, and a box that DIX hypothetically
-would want the hot spot confined within, pHotBox.  This routine is for
-informing DIX only; it alters no state within DDX.</para>
-<para>
-<blockquote><programlisting>
-
-	Bool pScreen->SetCursorPosition( pScr, newx, newy, generateEvent)
-		ScreenPtr pScr;
-		int newx;
-		int newy;
-		Bool generateEvent;
-
-</programlisting></blockquote>
-SetCursorPosition should artificially move the cursor as though the
-user had jerked the pointing device very quickly.  This is called in
-response to the WarpPointer request from the client, and at other
-times.  If generateEvent is True, the device should decide whether or
-not to call ProcessInputEvents() and then it must call
-DevicePtr->processInputProc.  Its effects are, of course, limited in
-value for absolute pointing devices such as a tablet.</para>
-<para>
-<blockquote><programlisting>
-
-	void NewCurrentScreen(newScreen, x, y)
-	    ScreenPtr newScreen;
-	    int x,y;
-
-</programlisting></blockquote>
-If your ddx provides some mechanism for the user to magically move the
-pointer between multiple screens, you need to inform DIX when this
-occurs.  You should call NewCurrentScreen to accomplish this, specifying
-the new screen and the new x and y coordinates of the pointer on that screen.</para>
-</section>
-<section>
-  <title>Visuals, Depths and Pixmap Formats for Screens</title>
-<para>
-The "depth" of a image is the number of bits that are used per pixel to display it.</para>
-<para>
-The "bits per pixel" of a pixmap image that is sent over the client
-byte stream is a number that is either 4, 8, 16, 24 or 32.  It is the
-number of bits used per pixel in Z format.  For instance, a pixmap
-image that has a depth of six is best sent in Z format as 8 bits per
-pixel.</para>
-<para>
-A "pixmap image format" or a "pixmap format" is a description of the
-format of a pixmap image as it is sent over the byte stream.  For each
-depth available on a server, there is one and only one pixmap format.
-This pixmap image format gives the bits per pixel and the scanline
-padding unit. (For instance, are pixel rows padded to bytes, 16-bit
-words, or 32-bit words?)</para>
-<para>
-For each screen, you must decide upon what depth(s) it supports.  You
-should only count the number of bits used for the actual image.  Some
-displays store additional bits to indicate what window this pixel is
-in, how close this object is to a viewer, transparency, and other
-data; do not count these bits.</para>
-<para>
-A "display class" tells whether the display is monochrome or color,
-whether there is a lookup table, and how the lookup table works.</para>
-<para>
-A "visual" is a combination of depth, display class, and a description
-of how the pixel values result in a color on the screen.  Each visual
-has a set of masks and offsets that are used to separate a pixel value
-into its red, green, and blue components and a count of the number of
-colormap entries.  Some of these fields are only meaningful when the
-class dictates so.  Each visual also has a screen ID telling which
-screen it is usable on.  Note that the depth does not imply the number
-of map_entries; for instance, a display can have 8 bits per pixel but
-only 254 colormap entries for use by applications (the other two being
-reserved by hardware for the cursor).</para>
-<para>
-Each visual is identified by a 32-bit visual ID which the client uses
-to choose what visual is desired on a given window.  Clients can be
-using more than one visual on the same screen at the same time.</para>
-<para>
-The class of a display describes how this translation takes place.
-There are three ways to do the translation.
-<itemizedlist>
-<listitem><para>
-Pseudo - The pixel value, as a whole, is looked up
-in a table of length map_entries to
-determine the color to display.</para></listitem>
-<listitem><para>
-True - The
-pixel value is broken up into red, green, and blue fields, each of which
-are looked up in separate red, green, and blue lookup tables,
-each of length map_entries.</para></listitem>
-<listitem><para>
-Gray - The pixel value is looked up in a table of length map_entries to
-determine a gray level to display.</para></listitem>
-</itemizedlist>
-</para>
-<para>
-In addition, the lookup table can be static (resulting colors are fixed for each
-pixel value)
-or dynamic (lookup entries are under control of the client program).
-This leads to a total of six classes:
-<itemizedlist>
-<listitem><para>
-Static Gray - The pixel value (of however many bits) determines directly the
-level of gray
-that the pixel assumes.</para></listitem>
-<listitem><para>
-Gray Scale - The pixel value is fed through a lookup table to arrive at the level
-of gray to display
-for the given pixel.</para></listitem>
-<listitem><para>
-Static Color - The pixel value is fed through a fixed lookup table that yields the
-color to display
-for that pixel.</para></listitem>
-<listitem><para>
-PseudoColor - The whole pixel value is fed through a programmable lookup
-table that has one
-color (including red, green, and blue intensities) for each possible pixel value,
-and that color is displayed.</para></listitem>
-<listitem><para>
-True Color - Each pixel value consists of one or more bits
-that directly determine each primary color intensity after being fed through
-a fixed table.</para></listitem>
-<listitem><para>
-Direct Color - Each pixel value consists of one or more bits for each primary color.
-Each primary color value is individually looked up in a table for that primary
-color, yielding
-an intensity for that primary color.
-For each pixel, the red value is looked up in the
-red table, the green value in the green table, and
-the blue value in the blue table.</para></listitem>
-</itemizedlist>
-</para>
-<para>
-Here are some examples:
-<itemizedlist>
-<listitem><para>
-A simple monochrome 1 bit per pixel display is Static Gray.</para></listitem>
-<listitem><para>
-A display that has 2 bits per pixel for a choice
-between the colors of black, white, green and violet is Static Color.</para></listitem>
-<listitem><para>
-A display that has three bits per pixel, where
-each bit turns on or off one of the red, green or
-blue guns, is in the True Color class.</para></listitem>
-<listitem><para>
-If you take the last example and scramble the
-correspondence between pixel values and colors
-it becomes a Static Color display.</para></listitem>
-</itemizedlist></para>
-<para>
-A display has 8 bits per pixel.  The 8 bits select one entry out of 256 entries
-in a lookup table, each entry consisting of 24 bits (8bits each for red, green,
-and blue).
-The display can show any 256 of 16 million colors on the screen at once.
-This is a pseudocolor display.
-The client application gets to fill the lookup table in this class of display.</para>
-<para>
-Imagine the same hardware from the last example.
-Your server software allows the user, on the
-command line that starts up the server
-program,
-to fill the lookup table to his liking once and for all.
-From then on, the server software would not change the lookup table
-until it exits.
-For instance, the default might be a lookup table with a reasonable sample of
-colors from throughout the color space.
-But the user could specify that the table be filled with 256 steps of gray scale
-because he knew ahead of time he would be manipulating a lot of black-and-white
-scanned photographs
-and not very many color things.
-Clients would be presented with this unchangeable lookup table.
-Although the hardware qualifies as a PseudoColor display,
-the facade presented to the X client is that this is a Static Color display.</para>
-<para>
-You have to decide what kind of display you have or want
-to pretend you have.
-When you initialize the screen(s), this class value must be set in the
-VisualRec data structure along with other display characteristics like the
-depth and other numbers.</para>
-<para>
-The allowable DepthRec's and VisualRec's are pointed to by fields in the ScreenRec.
-These are set up when InitOutput() is called; you should Xalloc() appropriate blocks
-or use static variables initialized to the correct values.</para>
-</section>
-<section>
-<title>Colormaps for Screens</title>
-<para>
-A colormap is a device-independent
-mapping between pixel values and colors displayed on the screen.</para>
-<para>
-Different windows on the same screen can have different
-colormaps at the same time.
-At any given time, the most recently installed
-colormap(s) will be in use in the server
-so that its (their) windows' colors will be guaranteed to be correct.
-Other windows may be off-color.
-Although this may seem to be chaotic, in practice most clients
-use the default colormap for the screen.</para>
-<para>
-The default colormap for a screen is initialized when the screen is initialized.
-It always remains in existence and is not owned by any regular client.  It
-is owned by client 0 (the server itself).
-Many clients will simply use this default colormap for their drawing.
-Depending upon the class of the screen, the entries in this colormap may
-be modifiable by client applications.</para>
-</section>
-<section>
-  <title>Colormap Routines</title>
-<para>
-You need to implement the following routines to handle the device-dependent
-aspects of color maps.  You will end up placing pointers to these procedures
-in your ScreenRec data structure(s).  The sample server implementations of
-many of these routines are in fbcmap.c.</para>
-<para>
-<blockquote><programlisting>
-
-	Bool pScreen->CreateColormap(pColormap)
-		ColormapPtr pColormap;
-
-</programlisting></blockquote>
-This routine is called by the DIX CreateColormap routine after it has allocated
-all the data for the new colormap and just before it returns to the dispatcher.
-It is the DDX layer's chance to initialize the colormap, particularly if it is
-a static map.  See the following
-section for more details on initializing colormaps.
-The routine returns FALSE if creation failed, such as due to memory
-limitations.
-Notice that the colormap has a devPriv field from which you can hang any
-colormap specific storage you need.  Since each colormap might need special
-information, we attached the field to the colormap and not the visual.</para>
-<para>
-<blockquote><programlisting>
-
-	void pScreen->DestroyColormap(pColormap)
-		ColormapPtr pColormap;
-
-</programlisting></blockquote>
-This routine is called by the DIX FreeColormap routine after it has uninstalled
-the colormap and notified all interested parties, and before it has freed
-any of the colormap storage.
-It is the DDX layer's chance to free any data it added to the colormap.</para>
-<para>
-<blockquote><programlisting>
-
-	void pScreen->InstallColormap(pColormap)
-		ColormapPtr pColormap;
-
-</programlisting></blockquote>
-InstallColormap should
-fill a lookup table on the screen with which the colormap is associated with
-the colors in pColormap.
-If there is only one hardware lookup table for the screen, then all colors on
-the screen may change simultaneously.</para>
-<para>
-In the more general case of multiple hardware lookup tables,
-this may cause some other colormap to be
-uninstalled, meaning that windows that subscribed to the colormap
-that was uninstalled may end up being off-color.
-See the note, below, about uninstalling maps.</para>
-<para>
-<blockquote><programlisting>
-
-	void pScreen->UninstallColormap(pColormap)
-		ColormapPtr pColormap;
-
-</programlisting></blockquote>
-UninstallColormap should
-remove pColormap from screen pColormap->pScreen.
-Some other map, such as the default map if possible,
-should be installed in place of pColormap if applicable.
-If
-pColormap is the default map, do nothing.
-If any client has requested ColormapNotify events, the DDX layer must notify the client.
-(The routine WalkTree() is
-be used to find such windows.  The DIX routines TellNoMap(),
-TellNewMap()  and TellGainedMap() are provided to be used as
-the procedure parameter to WalkTree.  These procedures are in
-Xserver/dix/colormap.c.)</para>
-<para>
-<blockquote><programlisting>
-
-	int pScreen->ListInstalledColormaps(pScreen, pCmapList)
-		ScreenPtr pScreen;
-		XID *pCmapList;
-
-
-</programlisting></blockquote>
-ListInstalledColormaps fills the pCmapList in with the resource ids
-of the installed maps and returns a count of installed maps.
-pCmapList will point to an array of size MaxInstalledMaps that was allocated
-by the caller.</para>
-<para>
-<blockquote><programlisting>
-
-	void pScreen->StoreColors (pmap, ndef, pdefs)
-		ColormapPtr pmap;
-		int ndef;
-		xColorItem *pdefs;
-
-</programlisting></blockquote>
-StoreColors changes some of the entries in the colormap pmap.
-The number of entries to change are ndef, and pdefs points to the information
-describing what to change.
-Note that partial changes of entries in the colormap are allowed.
-Only the colors
-indicated in the flags field of each xColorItem need to be changed.
-However, all three color fields will be sent with the proper value for the
-benefit of screens that may not be able to set part of a colormap value.
-If the screen is a static class, this routine does nothing.
-The structure of colormap entries is nontrivial; see colormapst.h
-and the definition of xColorItem in Xproto.h for
-more details.</para>
-<para>
-<blockquote><programlisting>
-
-	void pScreen->ResolveColor(pRed, pGreen, pBlue, pVisual)
-		unsigned short *pRed, *pGreen, *pBlue;
-		VisualPtr pVisual;
-
-
-</programlisting></blockquote>
-Given a requested color, ResolveColor returns the nearest color that this hardware is
-capable of displaying on this visual.
-In other words, this rounds off each value, in place, to the number of bits
-per primary color that your screen can use.
-Remember that each screen has one of these routines.
-The level of roundoff should be what you would expect from the value
-you put in the bits_per_rgb field of the pVisual.</para>
-<para>
-Each value is an unsigned value ranging from 0 to 65535.
-The bits least likely to be used are the lowest ones.</para>
-<para>
-For example, if you had a pseudocolor display
-with any number of bits per pixel
-that had a lookup table supplying 6 bits for each color gun
-(a total of 256K different colors), you would
-round off each value to 6 bits.  Please don't simply truncate these values
-to the upper 6 bits, scale the result so that the maximum value seen
-by the client will be 65535 for each primary.  This makes color values
-more portable between different depth displays (a 6-bit truncated white
-will not look white on an 8-bit display).</para>
-<section>
-<title>Initializing a Colormap</title>
-<para>
-When a client requests a new colormap and when the server creates the default
-colormap, the procedure CreateColormap in the DIX layer is invoked.
-That procedure allocates memory for the colormap and related storage such as
-the lists of which client owns which pixels.
-It then sets a bit, BeingCreated, in the flags field of the ColormapRec
-and calls the DDX layer's CreateColormap routine.
-This is your chance to initialize the colormap.
-If the colormap is static, which you can tell by looking at the class field,
-you will want to fill in each color cell to match the hardwares notion of the
-color for that pixel.
-If the colormap is the default for the screen, which you can tell by looking
-at the IsDefault bit in the flags field, you should allocate BlackPixel
-and WhitePixel to match the values you set in the pScreen structure.
-(Of course, you picked those values to begin with.)</para>
-<para>
-You can also wait and use AllocColor() to allocate blackPixel
-and whitePixel after the default colormap has been created.
-If the default colormap is static and you initialized it in
-pScreen->CreateColormap, then use can use AllocColor afterwards
-to choose pixel values with the closest rgb values to those
-desired for blackPixel and whitePixel.
-If the default colormap is dynamic and uninitialized, then
-the rgb values you request will be obeyed, and AllocColor will
-again choose pixel values for you.
-These pixel values can then be stored into the screen.</para>
-<para>
-There are two ways to fill in the colormap.
-The simplest way is to use the DIX function AllocColor.
-<blockquote><programlisting>
-
-int AllocColor (pmap, pred, pgreen, pblue, pPix, client)
-    ColormapPtr         pmap;
-    unsigned short      *pred, *pgreen, *pblue;
-    Pixel               *pPix;
-    int                 client;
-
-</programlisting></blockquote>
-This takes three pointers to 16 bit color values and a pointer to a suggested
-pixel value.  The pixel value is either an index into one colormap or a
-combination of three indices depending on the type of pmap.
-If your colormap starts out empty, and you don't deliberately pick the same
-value twice, you will always get your suggested pixel.
-The truly nervous could check that the value returned in *pPix is the one
-AllocColor was called with.
-If you don't care which pixel is used, or would like them sequentially
-allocated from entry 0, set *pPix to 0.  This will find the first free
-pixel and use that.</para>
-<para>
-AllocColor will take care of all the  bookkeeping  and  will
-call StoreColors to get the colormap rgb values initialized.
-The hardware colormap will be changed whenever this colormap
-is installed.</para>
-<para>
-If for some reason AllocColor doesn't do what you want, you can do your
-own bookkeeping and call StoreColors yourself.  This is much more difficult
-and shouldn't be necessary for most devices.</para>
-</section>
-</section>
-<section>
-  <title>Fonts for Screens</title>
-<para>
-A font is a set of bitmaps that depict the symbols in a character set.
-Each font is for only one typeface in a given size, in other words,
-just one bitmap for each character.  Parallel fonts may be available
-in a variety of sizes and variations, including "bold" and "italic."
-X supports fonts for 8-bit and 16-bit character codes (for oriental
-languages that have more than 256 characters in the font).  Glyphs are
-bitmaps for individual characters.</para>
-<para>
-The source comes with some useful font files in an ASCII, plain-text
-format that should be comprehensible on a wide variety of operating
-systems.  The text format, referred to as BDF, is a slight extension
-of the current Adobe 2.1 Bitmap Distribution Format (Adobe Systems,
-Inc.).</para>
-<para>
-A short paper in PostScript format is included with the sample server
-that defines BDF.  It includes helpful pictures, which is why it is
-done in PostScript and is not included in this document.</para>
-<para>
-Your implementation should include some sort of font compiler to read
-these files and generate binary files that are directly usable by your
-server implementation.  The sample server comes with the source for a
-font compiler.</para>
-<para>
-It is important the font properties contained in the BDF files are
-preserved across any font compilation. In particular, copyright
-information cannot be casually tossed aside without legal
-ramifications. Other properties will be important to some
-sophisticated applications.</para>
-<para>
-All clients get font information from the server.  Therefore, your
-server can support any fonts it wants to.  It should probably support
-at least the fonts supplied with the X11 tape.  In principle, you can
-convert fonts from other sources or dream up your own fonts for use on
-your server.</para>
-<section>
-<title>Portable Compiled Format</title>
-<para>
-A font compiler is supplied with the sample server.  It has
-compile-time switches to convert the BDF files into a portable binary
-form, called Portable Compiled Format or PCF.  This allows for an
-arbitrary data format inside the file, and by describing the details
-of the format in the header of the file, any PCF file can be read by
-any PCF reading client.  By selecting the format which matches the
-required internal format for your renderer, the PCF reader can avoid
-reformatting the data each time it is read in.  The font compiler
-should be quite portable.</para>
-<para>
-The fonts included with the tape are stored in fonts/bdf.  The
-font compiler is found in fonts/tools/bdftopcf.</para>
-</section>
-<section>
-  <title>Font Realization</title>
-<para>
-Each screen configured into the server
-has an opportunity at font-load time
-to "realize" a font into some internal format if necessary.
-This happens every time the font is loaded into memory.</para>
-<para>
-A font (FontRec in Xserver/include/dixfontstr.h) is
-a device-independent structure containing a device-independent
-representation of the font.  When a font is created, it is "realized"
-for each screen.  At this point, the screen has the chance to convert
-the font into some other format.  The DDX layer can also put information
-in the devPrivate storage.</para>
-<para>
-<blockquote><programlisting>
-
-	Bool pScreen->RealizeFont(pScr, pFont)
-		ScreenPtr pScr;
-		FontPtr pFont;
-
-	Bool pScreen->UnrealizeFont(pScr, pFont)
-		ScreenPtr pScr;
-		FontPtr pFont;
-
-</programlisting></blockquote>
-RealizeFont and UnrealizeFont should calculate and allocate these extra data structures and
-dispose of them when no longer needed.
-These are called in response to OpenFont and CloseFont requests from
-the client.
-The sample server implementation is in fbscreen.c (which does very little).</para>
-</section>
-</section>
-<section>
-  <title>Other Screen Routines</title>
-<para>
-You must supply several other screen-specific routines for
-your X server implementation.
-Some of these are described in other sections:
-<itemizedlist>
-<listitem><para>
-GetImage() is described in the Drawing Primitives section.</para></listitem>
-<listitem><para>
-GetSpans() is described in the Pixblit routine section.</para></listitem>
-<listitem><para>
-Several window and pixmap manipulation procedures are
-described in the Window section under Drawables.</para></listitem>
-<listitem><para>
-The CreateGC() routine is described under Graphics Contexts.</para></listitem>
-</itemizedlist>
-</para>
-<para>
-<blockquote><programlisting>
-
-	void pScreen->QueryBestSize(kind, pWidth, pHeight)
-		int kind;
-		unsigned short *pWidth, *pHeight;
-		ScreenPtr pScreen;
-
-</programlisting></blockquote>
-QueryBestSize() returns the best sizes for cursors, tiles, and stipples
-in response to client requests.
-kind is one of the defined constants CursorShape, TileShape, or StippleShape
-(defined in X.h).
-For CursorShape, return the maximum width and
-height for cursors that you can handle.
-For TileShape and StippleShape, start with the suggested values in pWidth
-and pHeight and modify them in place to be optimal values that are
-greater than or equal to the suggested values.
-The sample server implementation is in Xserver/fb/fbscreen.c.</para>
-<para>
-<blockquote><programlisting>
-
-	pScreen->SourceValidate(pDrawable, x, y, width, height)
-		DrawablePtr pDrawable;
-		int x, y, width, height;
-		unsigned int subWindowMode;
-
-</programlisting></blockquote>
-SourceValidate should be called by CopyArea/CopyPlane primitives when
-the SourceValidate function pointer in the screen is non-null.  If you know that
-you will never need SourceValidate, you can avoid this check.  Currently,
-SourceValidate is used by the mi software cursor code to remove the cursor
-from the screen when the source rectangle overlaps the cursor position.
-x,y,width,height describe the source rectangle (source relative, that is)
-for the copy operation.  subWindowMode comes from the GC or source Picture.
-</para>
-<para>
-<blockquote><programlisting>
-
-	Bool pScreen->SaveScreen(pScreen, on)
-		ScreenPtr pScreen;
-		int on;
-
-</programlisting></blockquote>
-SaveScreen() is used for Screen Saver support (see WaitForSomething()).
-pScreen is the screen to save.</para>
-<para>
-<blockquote><programlisting>
-
-	Bool pScreen->CloseScreen(pScreen)
-	    ScreenPtr pScreen;
-
-</programlisting></blockquote>
-When the server is reset, it calls this routine for each screen.</para>
-<para>
-<blockquote><programlisting>
-
-	Bool pScreen->CreateScreenResources(pScreen)
-	    ScreenPtr pScreen;
-
-</programlisting></blockquote>
-If this routine is not NULL, it will be called once per screen per
-server initialization/reset after all modules have had a chance to
-request private space on all structures that support them (see
-<xref linkend="wrappers_and_privates"/> below).  You may create resources
-in this function instead of in the
-screen init function passed to AddScreen in order to guarantee that
-all pre-allocated space requests have been registered first.  With the
-new devPrivates mechanism, this is not strictly necessary, however.
-This routine returns TRUE if successful.</para>
-</section>
-</section>
-<section>
-<title>Drawables</title>
-<para>
-A drawable is a descriptor of a surface that graphics are drawn into, either
-a window on the screen or a pixmap in memory.</para>
-<para>
-Each drawable has a type, class,
-ScreenPtr for the screen it is associated with, depth, position, size,
-and serial number.
-The type is one of the defined constants DRAWABLE_PIXMAP,
-DRAWABLE_WINDOW and UNDRAWABLE_WINDOW.
-(An undrawable window is used for window class InputOnly.)
-The serial number is guaranteed to be unique across drawables, and
-is used in determining
-the validity of the clipping information in a GC.
-The screen selects the set of procedures used to manipulate and draw into the
-drawable.  Position is used (currently) only by windows; pixmaps must
-set these fields to 0,0 as this reduces the amount of conditional code
-executed throughout the mi code.  Size indicates the actual client-specified
-size of the drawable.
-There are, in fact, no other fields that a window drawable and pixmap
-drawable have in common besides those mentioned here.</para>
-<para>
-Both PixmapRecs and WindowRecs are structs that start with a drawable
-and continue on with more fields.  Pixmaps have a single pointer field
-named devPrivate which usually points to the pixmap data but could conceivably be
-used for anything that DDX wants.  Both windows and pixmaps also have a
-devPrivates field which can be used for DDX specific data (see <xref linkend="wrappers_and_privates"/>
-below).  This is done because different graphics hardware has
-different requirements for management; if the graphics is always
-handled by a processor with an independent address space, there is no
-point having a pointer to the bit image itself.</para>
-<para>
-The definition of a drawable and a pixmap can be found in the file
-Xserver/include/pixmapstr.h.
-The definition of a window can be found in the file Xserver/include/windowstr.h.</para>
-<section>
-  <title>Pixmaps</title>
-<para>
-A pixmap is a three-dimensional array of bits stored somewhere offscreen,
-rather than in the visible portion of the screen's display frame buffer.  It
-can be used as a source or destination in graphics operations.  There is no
-implied interpretation of the pixel values in a pixmap, because it has no
-associated visual or colormap.  There is only a depth that indicates the
-number of significant bits per pixel.  Also, there is no implied physical
-size for each pixel; all graphic units are in numbers of pixels.  Therefore,
-a pixmap alone does not constitute a complete image; it represents only a
-rectangular array of pixel values.</para>
-<para>
-Note that the pixmap data structure is reference-counted.</para>
-<para>
-The server implementation is free to put the pixmap data
-anywhere it sees fit, according to its graphics hardware setup.  Many
-implementations will simply have the data dynamically allocated in the
-server's address space.  More sophisticated implementations may put the
-data in undisplayed framebuffer storage.</para>
-<para>
-In addition to dynamic devPrivates (see <xref linkend="wrappers_and_privates"/>
-below), the pixmap data structure has two fields that are private to
-the device.  Although you can use them for anything you want, they
-have intended purposes.  devKind is intended to be a device specific
-indication of the pixmap location (host memory, off-screen, etc.).  In
-the sample server, since all pixmaps are in memory, devKind stores the
-width of the pixmap in bitmap scanline units.  devPrivate is usually
-a pointer to the bits in the pixmap.</para>
-<para>
-A bitmap is a pixmap that is one bit deep.</para>
-<para>
-<blockquote><programlisting>
-
-	PixmapPtr pScreen->CreatePixmap(pScreen, width, height, depth)
-		ScreenPtr pScreen;
-		int width, height, depth;
-
-</programlisting></blockquote>
-This ScreenRec procedure must create a pixmap of the size
-requested.
-It must allocate a PixmapRec and fill in all of the fields.
-The reference count field must be set to 1.
-If width or height are zero, no space should be allocated
-for the pixmap data, and if the implementation is using the
-devPrivate field as a pointer to the pixmap data, it should be
-set to NULL.
-If successful, it returns a pointer to the new pixmap; if not, it returns NULL.
-See Xserver/fb/fbpixmap.c for the sample server implementation.</para>
-<para>
-<blockquote><programlisting>
-
-	Bool pScreen->DestroyPixmap(pPixmap)
-		PixmapPtr pPixmap;
-
-</programlisting></blockquote>
-This ScreenRec procedure must "destroy" a pixmap.
-It should decrement the reference count and, if zero, it
-must deallocate the PixmapRec and all attached devPrivate blocks.
-If successful, it returns TRUE.
-See Xserver/fb/fbpixmap.c for the sample server implementation.</para>
-<para>
-<blockquote><programlisting>
-
-	Bool
-	pScreen->ModifyPixmapHeader(pPixmap, width, height, depth, bitsPerPixel, devKind, pPixData)
-		PixmapPtr   pPixmap;
-		int	    width;
-		int	    height;
-		int	    depth;
-		int	    bitsPerPixel;
-		int	    devKind;
-		pointer     pPixData;
-
-</programlisting></blockquote>
-This routine takes a pixmap header and initializes the fields of the PixmapRec to the
-parameters of the same name.  pPixmap must have been created via
-pScreen->CreatePixmap with a zero width or height to avoid
-allocating space for the pixmap data.  pPixData is assumed to be the
-pixmap data; it will be stored in an implementation-dependent place
-(usually pPixmap->devPrivate.ptr).  This routine returns
-TRUE if successful.  See Xserver/mi/miscrinit.c for the sample
-server implementation.</para>
-<para>
-<blockquote><programlisting>
-
-	PixmapPtr
-	GetScratchPixmapHeader(pScreen, width, height, depth, bitsPerPixel, devKind, pPixData)
-		ScreenPtr   pScreen;
-		int	    width;
-		int	    height;
-		int	    depth;
-		int	    bitsPerPixel;
-		int	    devKind;
-		pointer     pPixData;
-
-	void FreeScratchPixmapHeader(pPixmap)
-		PixmapPtr pPixmap;
-
-</programlisting></blockquote>
-DDX should use these two DIX routines when it has a buffer of raw
-image data that it wants to manipulate as a pixmap temporarily,
-usually so that some other part of the server can be leveraged to
-perform some operation on the data.  The data should be passed in
-pPixData, and will be stored in an implementation-dependent place
-(usually pPixmap->devPrivate.ptr). The other
-fields go into the corresponding PixmapRec fields.
-If successful, GetScratchPixmapHeader returns a valid PixmapPtr which can
-be used anywhere the server expects a pixmap, else
-it returns NULL.  The pixmap should be released when no longer needed
-(usually within the same function that allocated it)
-with FreeScratchPixmapHeader.</para>
-</section>
-<section>
-  <title>Windows</title>
-<para>
-A window is a visible, or potentially visible, rectangle on the screen.
-DIX windowing functions maintain an internal n-ary tree data structure, which
-represents the current relationships of the mapped windows.
-Windows that are contained in another window are children of that window and
-are clipped to the boundaries of the parent.
-The root window in the tree is the window for the entire screen.
-Sibling windows constitute a doubly-linked list; the parent window has a pointer
-to the head and tail of this list.
-Each child also has a pointer to its parent.</para>
-<para>
-The border of a window is drawn by a DDX procedure when DIX requests that it
-be drawn.  The contents of the window is drawn by the client through
-requests to the server.</para>
-<para>
-Window painting is orchestrated through an expose event system.
-When a region is exposed,
-DIX generates an expose event, telling the client to repaint the window and
-passing the region that is the minimal area needed to be repainted.</para>
-<para>
-As a favor to clients, the server may retain
-the output to the hidden parts of windows
-in off-screen memory; this is called "backing store".
-When a part of such a window becomes exposed, it
-can quickly move pixels into place instead of
-triggering an expose event and waiting for a client on the other
-end of the network to respond.
-Even if the network response is insignificant, the time to
-intelligently paint a section of a window is usually more than
-the time to just copy already-painted sections.
-At best, the repainting involves blanking out the area to a background color,
-which will take about the
-same amount of time.
-In this way, backing store can dramatically increase the
-performance of window moves.</para>
-<para>
-On the other hand, backing store can be quite complex, because
-all graphics drawn to hidden areas must be intercepted and redirected
-to the off-screen window sections.
-Not only can this be complicated for the server programmer,
-but it can also impact window painting performance.
-The backing store implementation can choose, at any time, to
-forget pieces of backing that are written into, relying instead upon
-expose events to repaint for simplicity.</para>
-<para>
-In X, the decision to use the backing-store scheme is made
-by you, the server implementor.  The sample server implements
-backing store "for free" by reusing the infrastructure for the Composite
-extension.  As a side effect, it treats the WhenMapped and Always hints
-as equivalent.  However, it will never forget pixel contents when the
-window is mapped.</para>
-<para>
-When a window operation is requested by the client,
-such as a window being created or moved,
-a new state is computed.
-During this transition, DIX informs DDX what rectangles in what windows are about to
-become obscured and what rectangles in what windows have become exposed.
-This provides a hook for the implementation of backing store.
-If DDX is unable to restore exposed regions, DIX generates expose
-events to the client.
-It is then the client's responsibility to paint the
-window parts that were exposed but not restored.</para>
-<para>
-If a window is resized, pixels sometimes need to be
-moved, depending upon
-the application.
-The client can request "Gravity" so that
-certain blocks of the window are
-moved as a result of a resize.
-For instance, if the window has controls or other items
-that always hang on the edge of the
-window, and that edge is moved as a result of the resize,
-then those pixels should be moved
-to avoid having the client repaint it.
-If the client needs to repaint it anyway, such an operation takes
-time, so it is desirable
-for the server to approximate the appearance of the window as best
-it can while waiting for the client
-to do it perfectly.
-Gravity is used for that, also.</para>
-<para>
-The window has several fields used in drawing
-operations:
-<itemizedlist>
-<listitem><para>
-clipList - This region, in conjunction with
-the client clip region in the gc, is used to clip output.
-clipList has the window's children subtracted from it, in addition to pieces of sibling windows
-that overlap this window.  To get the list with the
-children included (subwindow-mode is IncludeInferiors),
-the routine NotClippedByChildren(pWin) returns the unclipped region.</para></listitem>
-<listitem><para>
-borderClip is the region used by CopyWindow and
-includes the area of the window, its children, and the border, but with the
-overlapping areas of sibling children removed.</para></listitem>
-</itemizedlist>
-Most of the other fields are for DIX use only.</para>
-<section>
-<title>Window Procedures in the ScreenRec</title>
-<para>
-You should implement
-all of the following procedures and store pointers to them in the screen record.</para>
-<para>
-The device-independent portion of the server "owns" the window tree.
-However, clever hardware might want to know the relationship of
-mapped windows.  There are pointers to procedures
-in the ScreenRec data structure that are called to give the hardware
-a chance to update its internal state.  These are helpers and
-hints to DDX only;
-they do not change the window tree, which is only changed by DIX.</para>
-<para>
-<blockquote><programlisting>
-
-	Bool pScreen->CreateWindow(pWin)
-		WindowPtr pWin;
-
-</programlisting></blockquote>
-This routine is a hook for when DIX creates a window.
-It should fill in the "Window Procedures in the WindowRec" below
-and also allocate the devPrivate block for it.</para>
-<para>
-See Xserver/fb/fbwindow.c for the sample server implementation.</para>
-<para>
-<blockquote><programlisting>
-
-	Bool pScreen->DestroyWindow(pWin);
-		WindowPtr pWin;
-
-</programlisting></blockquote>
-This routine is a hook for when DIX destroys a window.
-It should deallocate the devPrivate block for it and any other blocks that need
-to be freed, besides doing other cleanup actions.</para>
-<para>
-See Xserver/fb/fbwindow.c for the sample server implementation.</para>
-<para>
-<blockquote><programlisting>
-
-	Bool pScreen->PositionWindow(pWin, x, y);
-		WindowPtr pWin;
-		int x, y;
-
-</programlisting></blockquote>
-This routine is a hook for when DIX moves or resizes a window.
-It should do whatever private operations need to be done when a window is moved or resized.
-For instance, if DDX keeps a pixmap tile used for drawing the background
-or border, and it keeps the tile rotated such that it is longword
-aligned to longword locations in the frame buffer, then you should rotate your tiles here.
-The actual graphics involved in moving the pixels on the screen and drawing the
-border are handled by CopyWindow(), below.</para>
-<para>
-See Xserver/fb/fbwindow.c for the sample server implementation.</para>
-<para>
-<blockquote><programlisting>
-
-	Bool pScreen->RealizeWindow(pWin);
-		WindowPtr pWin;
-
-	Bool  pScreen->UnrealizeWindow(pWin);
-		WindowPtr pWin;
-
-</programlisting></blockquote>
-These routines are hooks for when DIX maps (makes visible) and unmaps
-(makes invisible) a window.  It should do whatever private operations
-need to be done when these happen, such as allocating or deallocating
-structures that are only needed for visible windows.  RealizeWindow
-does NOT draw the window border, background or contents;
-UnrealizeWindow does NOT erase the window or generate exposure events
-for underlying windows; this is taken care of by DIX.  DIX does,
-however, call PaintWindowBackground() and PaintWindowBorder() to
-perform some of these.</para>
-<para>
-<blockquote><programlisting>
-
-	Bool pScreen->ChangeWindowAttributes(pWin, vmask)
-		WindowPtr pWin;
-		unsigned long vmask;
-
-</programlisting></blockquote>
-ChangeWindowAttributes is called whenever DIX changes window
-attributes, such as the size, front-to-back ordering, title, or
-anything of lesser severity that affects the window itself.  The
-sample server implements this routine.  It computes accelerators for
-quickly putting up background and border tiles.  (See description of
-the set of routines stored in the WindowRec.)</para>
-<para>
-<blockquote><programlisting>
-
-	int pScreen->ValidateTree(pParent,  pChild, kind)
-		WindowPtr pParent, pChild;
-		VTKind kind;
-
-</programlisting></blockquote>
-ValidateTree calculates the clipping region for the parent window and
-all of its children.  This routine must be provided. The sample server
-has a machine-independent version in Xserver/mi/mivaltree.c.  This is
-a very difficult routine to replace.</para>
-<para>
-<blockquote><programlisting>
-
-	void pScreen->PostValidateTree(pParent,  pChild, kind)
-		WindowPtr pParent, pChild;
-		VTKind kind;
-
-</programlisting></blockquote>
-If this routine is not NULL, DIX calls it shortly after calling
-ValidateTree, passing it the same arguments.  This is useful for
-managing multi-layered framebuffers.
-The sample server sets this to NULL.</para>
-<para>
-<blockquote><programlisting>
-
-	void pScreen->WindowExposures(pWin, pRegion, pBSRegion)
-		WindowPtr pWin;
-		RegionPtr pRegion;
-		RegionPtr pBSRegion;
-
-</programlisting></blockquote>
-The WindowExposures() routine
-paints the border and generates exposure events for the window.
-pRegion is an unoccluded region of the window, and pBSRegion is an
-occluded region that has backing store.
-Since exposure events include a rectangle describing what was exposed,
-this routine may have to send back a series of exposure events, one for
-each rectangle of the region.
-The count field in the expose event is a hint to the
-client as to the number of
-regions that are after this one.
-This routine must be provided. The sample
-server has a machine-independent version in Xserver/mi/miexpose.c.</para>
-<para>
-<blockquote><programlisting>
-
-	void pScreen->ClipNotify (pWin, dx, dy)
-		WindowPtr pWin;
-		int dx, dy;
-
-</programlisting></blockquote>
-Whenever the cliplist for a window is changed, this function is called to
-perform whatever hardware manipulations might be necessary.  When called,
-the clip list and border clip regions in the window are set to the new
-values.  dx,dy are the distance that the window has been moved (if at all).</para>
-</section>
-<section>
-  <title>Window Painting Procedures</title>
-<para>
-In addition to the procedures listed above, there are two routines which
-manipulate the actual window image directly.
-In the sample server, mi implementations will work for
-most purposes and fb routines speed up situations, such
-as solid backgrounds/borders or tiles that are 8, 16 or 32 pixels square.</para>
-<para>
-<blockquote><programlisting>
-
-	void pScreen->ClearToBackground(pWin, x, y, w, h, generateExposures);
-		WindowPtr pWin;
-		int x, y, w, h;
-		Bool generateExposures;
-
-</programlisting></blockquote>
-This routine is called on a window in response to a ClearToBackground request
-from the client.
-This request has two different but related functions, depending upon generateExposures.</para>
-<para>
-If generateExposures is true, the client is declaring that the given rectangle
-on the window is incorrectly painted and needs to be repainted.
-The sample server implementation calculates the exposure region
-and hands it to the DIX procedure HandleExposures(), which
-calls the WindowExposures() routine, below, for the window
-and all of its child windows.</para>
-<para>
-If generateExposures is false, the client is trying to simply erase part
-of the window to the background fill style.
-ClearToBackground should write the background color or tile to the
-rectangle in question (probably using PaintWindowBackground).
-If w or h is zero, it clears all the way to the right or lower edge of the window.</para>
-<para>
-The sample server implementation is in Xserver/mi/miwindow.c.</para>
-<para>
-<blockquote><programlisting>
-
-	void pScreen->CopyWindow(pWin, oldpt, oldRegion);
-		WindowPtr pWin;
-		DDXPointRec oldpt;
-		RegionPtr oldRegion;
-
-</programlisting></blockquote>
-CopyWindow is called when a window is moved, and graphically moves to
-pixels of a window on the screen.  It should not change any other
-state within DDX (see PositionWindow(), above).</para>
-<para>
-oldpt is the old location of the upper-left corner.  oldRegion is the
-old region it is coming from.  The new location and new region is
-stored in the WindowRec.  oldRegion might modified in place by this
-routine (the sample implementation does this).</para>
-<para>
-CopyArea could be used, except that this operation has more
-complications.  First of all, you do not want to copy a rectangle onto
-a rectangle.  The original window may be obscured by other windows,
-and the new window location may be similarly obscured.  Second, some
-hardware supports multiple windows with multiple depths, and your
-routine needs to take care of that.</para>
-<para>
-The pixels in oldRegion (with reference point oldpt) are copied to the
-window's new region (pWin->borderClip).  pWin->borderClip is gotten
-directly from the window, rather than passing it as a parameter.</para>
-<para>
-The sample server implementation is in Xserver/fb/fbwindow.c.</para>
-</section>
-<section>
-<title>Screen Operations for Multi-Layered Framebuffers</title>
-<para>
-The following screen functions are useful if you have a framebuffer with
-multiple sets of independent bit planes, e.g. overlays or underlays in
-addition to the "main" planes.  If you have a simple single-layer
-framebuffer, you should probably use the mi versions of these routines
-in mi/miwindow.c.  This can be easily accomplished by calling miScreenInit.</para>
-<para>
-<blockquote><programlisting>
-
-    void pScreen->MarkWindow(pWin)
-	WindowPtr pWin;
-
-</programlisting></blockquote>
-This formerly dix function MarkWindow has moved to ddx and is accessed
-via this screen function.  This function should store something,
-usually a pointer to a device-dependent structure, in pWin->valdata so
-that ValidateTree has the information it needs to validate the window.</para>
-<para>
-<blockquote><programlisting>
-
-    Bool pScreen->MarkOverlappedWindows(parent, firstChild, ppLayerWin)
-	WindowPtr parent;
-	WindowPtr firstChild;
-	WindowPtr * ppLayerWin;
-
-</programlisting></blockquote>
-This formerly dix function MarkWindow has moved to ddx and is accessed
-via this screen function.  In the process, it has grown another
-parameter: ppLayerWin, which is filled in with a pointer to the window
-at which save under marking and ValidateTree should begin.  In the
-single-layered framebuffer case, pLayerWin == pWin.</para>
-<para>
-<blockquote><programlisting>
-
-    Bool pScreen->ChangeSaveUnder(pLayerWin, firstChild)
-	WindowPtr pLayerWin;
-	WindowPtr firstChild;
-
-</programlisting></blockquote>
-The dix functions ChangeSaveUnder and CheckSaveUnder have moved to ddx and
-are accessed via this screen function.  pLayerWin should be the window
-returned in the ppLayerWin parameter of MarkOverlappedWindows.  The function
-may turn on backing store for windows that might be covered, and may partially
-turn off backing store for windows.  It returns TRUE if PostChangeSaveUnder
-needs to be called to finish turning off backing store.</para>
-<para>
-<blockquote><programlisting>
-
-    void pScreen->PostChangeSaveUnder(pLayerWin, firstChild)
-	WindowPtr pLayerWin;
-	WindowPtr firstChild;
-
-</programlisting></blockquote>
-The dix function DoChangeSaveUnder has moved to ddx and is accessed via
-this screen function.  This function completes the job of turning off
-backing store that was started by ChangeSaveUnder.</para>
-<para>
-<blockquote><programlisting>
-
-    void pScreen->MoveWindow(pWin, x, y, pSib, kind)
-	WindowPtr pWin;
-	int x;
-	int y;
-	WindowPtr pSib;
-	VTKind kind;
-
-</programlisting></blockquote>
-The formerly dix function MoveWindow has moved to ddx and is accessed via
-this screen function.  The new position of the window is given by
-x,y.  kind is VTMove if the window is only moving, or VTOther if
-the border is also changing.</para>
-<para>
-<blockquote><programlisting>
-
-    void pScreen->ResizeWindow(pWin, x, y, w, h, pSib)
-	WindowPtr pWin;
-	int x;
-	int y;
-	unsigned int w;
-	unsigned int h;
-	WindowPtr pSib;
-
-</programlisting></blockquote>
-The formerly dix function SlideAndSizeWindow has moved to ddx and is accessed via
-this screen function.  The new position is given by x,y.  The new size
-is given by w,h.</para>
-<para>
-<blockquote><programlisting>
-
-    WindowPtr pScreen->GetLayerWindow(pWin)
-	WindowPtr pWin
-
-</programlisting></blockquote>
-This is a new function which returns a child of the layer parent of pWin.</para>
-<para>
-<blockquote><programlisting>
-
-    void pScreen->HandleExposures(pWin)
-	WindowPtr pWin;
-
-</programlisting></blockquote>
-The formerly dix function HandleExposures has moved to ddx and is accessed via
-this screen function.  This function is called after ValidateTree and
-uses the information contained in valdata to send exposures to windows.</para>
-<para>
-<blockquote><programlisting>
-
-    void pScreen->ReparentWindow(pWin, pPriorParent)
-	WindowPtr pWin;
-	WindowPtr pPriorParent;
-
-</programlisting></blockquote>
-This function will be called when a window is reparented.  At the time of
-the call, pWin will already be spliced into its new position in the
-window tree, and pPriorParent is its previous parent.  This function
-can be NULL.</para>
-<para>
-<blockquote><programlisting>
-
-    void pScreen->SetShape(pWin)
-	WindowPtr pWin;
-
-</programlisting></blockquote>
-The formerly dix function SetShape has moved to ddx and is accessed via
-this screen function.  The window's new shape will have already been
-stored in the window when this function is called.</para>
-<para>
-<blockquote><programlisting>
-
-    void pScreen->ChangeBorderWidth(pWin, width)
-	WindowPtr pWin;
-	unsigned int width;
-
-</programlisting></blockquote>
-The formerly dix function ChangeBorderWidth has moved to ddx and is accessed via
-this screen function.  The new border width is given by width.</para>
-<para>
-<blockquote><programlisting>
-
-    void pScreen->MarkUnrealizedWindow(pChild, pWin, fromConfigure)
-	WindowPtr pChild;
-	WindowPtr pWin;
-	Bool fromConfigure;
-
-</programlisting></blockquote>
-This function is called for windows that are being unrealized as part of
-an UnrealizeTree.  pChild is the window being unrealized, pWin is an
-ancestor, and the fromConfigure value is simply propagated from UnrealizeTree.</para>
-</section>
-</section>
-</section>
-<section>
-<title>Graphics Contexts and Validation</title>
-<para>
-This graphics context (GC) contains state variables such as foreground and
-background pixel value (color), the current line style and width,
-the current tile or stipple for pattern generation, the current font for text
-generation, and other similar attributes.</para>
-<para>
-In many graphics systems, the equivalent of the graphics context and the
-drawable are combined as one entity.
-The main distinction between the two kinds of status is that a drawable
-describes a writing surface and the writings that may have already been done
-on it, whereas a graphics context describes the drawing process.
-A drawable is like a chalkboard.
-A GC is like a piece of chalk.</para>
-<para>
-Unlike many similar systems, there is no "current pen location."
-Every graphic operation is accompanied by the coordinates where it is to happen.</para>
-<para>
-The GC also includes two vectors of procedure pointers, the first
-operate on the GC itself and are called GC funcs.  The second, called
-GC ops,
-contains the functions that carry out the fundamental graphic operations
-such as drawing lines, polygons, arcs, text, and copying bitmaps.
-The DDX graphic software can, if it
-wants to be smart, change these two vectors of procedure pointers
-to take advantage of hardware/firmware in the server machine, which can do
-a better job under certain circumstances.  To reduce the amount of memory
-consumed by each GC, it is wise to create a few "boilerplate" GC ops vectors
-which can be shared by every GC which matches the constraints for that set.
-Also, it is usually reasonable to have every GC created by a particular
-module to share a common set of GC funcs.  Samples of this sort of
-sharing can be seen in fb/fbgc.c.</para>
-<para>
-The DDX software is notified any time the client (or DIX) uses a changed GC.
-For instance, if the hardware has special support for drawing fixed-width
-fonts, DDX can intercept changes to the current font in a GC just before
-drawing is done.  It can plug into either a fixed-width procedure that makes
-the hardware draw characters, or a variable-width procedure that carefully
-lays out glyphs by hand in software, depending upon the new font that is
-selected.</para>
-<para>
-A definition of these structures can be found in the file
-Xserver/include/gcstruct.h.</para>
-<para>
-Also included in each GC is support for dynamic devPrivates, which the
-DDX can use for any purpose (see <xref linkend="wrappers_and_privates"/> below).</para>
-<para>
-The DIX routines available for manipulating GCs are
-CreateGC, ChangeGC, ChangeGCXIDs, CopyGC, SetClipRects, SetDashes, and FreeGC.
-<blockquote><programlisting>
-
-	GCPtr CreateGC(pDrawable, mask, pval, pStatus)
-	    DrawablePtr pDrawable;
-	    BITS32 mask;
-	    XID *pval;
-	    int *pStatus;
-
-	int ChangeGC(client, pGC, mask, pUnion)
-	    ClientPtr client;
-	    GCPtr pGC;
-	    BITS32 mask;
-	    ChangeGCValPtr pUnion;
-
-	int ChangeGCXIDs(client, pGC, mask, pC32)
-	    ClientPtr client;
-	    GCPtr pGC;
-	    BITS32 mask;
-	    CARD32 *pC32;
-
-	int CopyGC(pgcSrc, pgcDst, mask)
-	    GCPtr pgcSrc;
-	    GCPtr pgcDst;
-	    BITS32 mask;
-
-	int SetClipRects(pGC, xOrigin, yOrigin, nrects, prects, ordering)
-	    GCPtr pGC;
-	    int xOrigin, yOrigin;
-	    int nrects;
-	    xRectangle *prects;
-	    int ordering;
-
-	SetDashes(pGC, offset, ndash, pdash)
-	    GCPtr pGC;
-	    unsigned offset;
-	    unsigned ndash;
-	    unsigned char *pdash;
-
-	int FreeGC(pGC, gid)
-	    GCPtr pGC;
-	    GContext gid;
-
-</programlisting></blockquote>
-</para>
-<para>
-As a convenience, each Screen structure contains an array of
-GCs that are preallocated, one at each depth the screen supports.
-These are particularly useful in the mi code.  Two DIX routines
-must be used to get these GCs:
-<blockquote><programlisting>
-
-	GCPtr GetScratchGC(depth, pScreen)
-	    int depth;
-	    ScreenPtr pScreen;
-
-	FreeScratchGC(pGC)
-	    GCPtr pGC;
-
-</programlisting></blockquote>
-Always use these two routines, don't try to extract the scratch
-GC yourself -- someone else might be using it, so a new one must
-be created on the fly.</para>
-<para>
-If you need a GC for a very long time, say until the server is restarted,
-you should not take one from the pool used by GetScratchGC, but should
-get your own using CreateGC or CreateScratchGC.
-This leaves the ones in the pool free for routines that only need it for
-a little while and don't want to pay a heavy cost to get it.
-<blockquote><programlisting>
-
-	GCPtr CreateScratchGC(pScreen, depth)
-	    ScreenPtr pScreen;
-	    int depth;
-
-</programlisting></blockquote>
-NULL is returned if the GC cannot be created.
-The GC returned can be freed with FreeScratchGC.</para>
-<section>
-  <title>Details of Operation</title>
-<para>
-At screen initialization, a screen must supply a GC creation procedure.
-At GC creation, the screen must fill in GC funcs and GC ops vectors
-(Xserver/include/gcstruct.h).  For any particular GC, the func vector
-must remain constant, while the op vector may vary.  This invariant is to
-ensure that Wrappers work correctly.</para>
-<para>
-When a client request is processed that results in a change
-to the GC, the device-independent state of the GC is updated.
-This includes a record of the state that changed.
-Then the ChangeGC GC func is called.
-This is useful for graphics subsystems that are able to process
-state changes in parallel with the server CPU.
-DDX may opt not to take any action at GC-modify time.
-This is more efficient if multiple GC-modify requests occur
-between draws using a given GC.</para>
-<para>
-Validation occurs at the first draw operation that specifies the GC after
-that GC was modified.  DIX calls then the ValidateGC GC func.  DDX should
-then update its internal state.  DDX internal state may be stored as one or
-more of the following:  1) device private block on the GC; 2) hardware
-state; 3) changes to the GC ops.</para>
-<para>
-The GC contains a serial number, which is loaded with a number fetched from
-the window that was drawn into the last time the GC was used.  The serial
-number in the drawable is changed when the drawable's
-clipList or absCorner changes.  Thus, by
-comparing the GC serial number with the drawable serial number, DIX can
-force a validate if the drawable has been changed since the last time it
-was used with this GC.</para>
-<para>
-In addition, the drawable serial number is always guaranteed to have the
-most significant bit set to 0.  Thus, the DDX layer can set the most
-significant bit of the serial number to 1 in a GC to force a validate the next time
-the GC is used.  DIX also uses this technique to indicate that a change has
-been made to the GC by way of a SetGC, a SetDashes or a SetClip request.</para>
-</section>
-<section>
-  <title>GC Handling Routines</title>
-<para>
-The ScreenRec data structure has a pointer for
-CreateGC().
-<blockquote><programlisting>
-
-	Bool pScreen->CreateGC(pGC)
-		GCPtr pGC;
-</programlisting></blockquote>
-This routine must fill in the fields of
-a dynamically allocated GC that is passed in.
-It does NOT allocate the GC record itself or fill
-in the defaults; DIX does that.</para>
-<para>
-This must fill in both the GC funcs and ops; none of the drawing
-functions will be called before the GC has been validated,
-but the others (dealing with allocating of clip regions,
-changing and destroying the GC, etc.) might be.</para>
-<para>
-The GC funcs vector contains pointers to 7
-routines and a devPrivate field:
-<blockquote><programlisting>
-
-	pGC->funcs->ChangeGC(pGC, changes)
-		GCPtr pGC;
-		unsigned long changes;
-
-</programlisting></blockquote>
-This GC func is called immediately after a field in the GC is changed.
-changes is a bit mask indicating the changed fields of the GC in this
-request.</para>
-<para>
-The ChangeGC routine is useful if you have a system where
-state-changes to the GC can be swallowed immediately by your graphics
-system, and a validate is not necessary.</para>
-<para>
-<blockquote><programlisting>
-
-	pGC->funcs->ValidateGC(pGC, changes, pDraw)
-		GCPtr pGC;
-		unsigned long changes;
-		DrawablePtr pDraw;
-
-</programlisting></blockquote>
-ValidateGC is called by DIX just before the GC will be used when one
-of many possible changes to the GC or the graphics system has
-happened.  It can modify devPrivates data attached to the GC,
-change the op vector, or change hardware according to the
-values in the GC.  It may not change the device-independent portion of
-the GC itself.</para>
-<para>
-In almost all cases, your ValidateGC() procedure should take the
-regions that drawing needs to be clipped to and combine them into a
-composite clip region, which you keep a pointer to in the private part
-of the GC.  In this way, your drawing primitive routines (and whatever
-is below them) can easily determine what to clip and where.  You
-should combine the regions clientClip (the region that the client
-desires to clip output to) and the region returned by
-NotClippedByChildren(), in DIX.  An example is in Xserver/fb/fbgc.c.</para>
-<para>
-Some kinds of extension software may cause this routine to be called
-more than originally intended; you should not rely on algorithms that
-will break under such circumstances.</para>
-<para>
-See the Strategies document for more information on creatively using
-this routine.</para>
-<para>
-<blockquote><programlisting>
-
-	pGC->funcs->CopyGC(pGCSrc, mask, pGCDst)
-		GCPtr pGCSrc;
-		unsigned long mask;
-		GCPtr pGCDst;
-
-</programlisting></blockquote>
-This routine is called by DIX when a GC is being copied to another GC.
-This is for situations where dynamically allocated chunks of memory
-are stored in the GC's dynamic devPrivates and need to be transferred to
-the destination GC.</para>
-<para>
-<blockquote><programlisting>
-
-	pGC->funcs->DestroyGC(pGC)
-		GCPtr pGC;
-
-</programlisting></blockquote>
-This routine is called before the GC is destroyed for the
-entity interested in this GC to clean up after itself.
-This routine is responsible for freeing any auxiliary storage allocated.</para>
-</section>
-<section>
-  <title>GC Clip Region Routines</title>
-<para>
-The GC clientClip field requires three procedures to manage it.  These
-procedures are in the GC funcs vector.  The underlying principle is that dix
-knows nothing about the internals of the clipping information, (except when
-it has come from the client), and so calls ddX whenever it needs to copy,
-set, or destroy such information.  It could have been possible for dix not
-to allow ddX to touch the field in the GC, and require it to keep its own
-copy in devPriv, but since clip masks can be very large, this seems like a
-bad idea.  Thus, the server allows ddX to do whatever it wants to the
-clientClip field of the GC, but requires it to do all manipulation itself.</para>
-<para>
-<blockquote><programlisting>
-
-	void pGC->funcs->ChangeClip(pGC, type, pValue, nrects)
-		GCPtr pGC;
-		int type;
-		char *pValue;
-		int nrects;
-
-</programlisting></blockquote>
-This routine is called whenever the client changes the client clip
-region.  The pGC points to the GC involved, the type tells what form
-the region has been sent in.  If type is CT_NONE, then there is no
-client clip.  If type is CT_UNSORTED, CT_YBANDED or CT_YXBANDED, then
-pValue pointer to a list of rectangles, nrects long.  If type is
-CT_REGION, then pValue pointer to a RegionRec from the mi region code.
-If type is CT_PIXMAP pValue is a pointer to a pixmap.  (The defines
-for CT_NONE, etc. are in Xserver/include/gc.h.)  This routine is
-responsible for incrementing any necessary reference counts (e.g. for
-a pixmap clip mask) for the new clipmask and freeing anything that
-used to be in the GC's clipMask field.  The lists of rectangles passed
-in can be freed with Xfree(), the regions can be destroyed with the
-RegionDestroy field in the screen, and pixmaps can be destroyed by
-calling the screen's DestroyPixmap function.  DIX and MI code expect
-what they pass in to this to be freed or otherwise inaccessible, and
-will never look inside what's been put in the GC.  This is a good
-place to be wary of storage leaks.</para>
-<para>
-In the sample server, this routine transforms either the bitmap or the
-rectangle list into a region, so that future routines will have a more
-predictable starting point to work from.  (The validate routine must
-take this client clip region and merge it with other regions to arrive
-at a composite clip region before any drawing is done.)</para>
-<para>
-<blockquote><programlisting>
-
-	void pGC->funcs->DestroyClip(pGC)
-		GCPtr pGC;
-
-</programlisting></blockquote>
-This routine is called whenever the client clip region must be destroyed.
-The pGC points to the GC involved.  This call should set the clipType
-field of the GC to CT_NONE.
-In the sample server, the pointer to the client clip region is set to NULL
-by this routine after destroying the region, so that other software
-(including ChangeClip() above) will recognize that there is no client clip region.</para>
-<para>
-<blockquote><programlisting>
-
-	void pGC->funcs->CopyClip(pgcDst, pgcSrc)
-		GCPtr pgcDst, pgcSrc;
-
-</programlisting></blockquote>
-This routine makes a copy of the clipMask and clipType from pgcSrc
-into pgcDst.  It is responsible for destroying any previous clipMask
-in pgcDst.  The clip mask in the source can be the same as the
-clip mask in the dst (clients do the strangest things), so care must
-be taken when destroying things.  This call is required because dix
-does not know how to copy the clip mask from pgcSrc.</para>
-</section>
-</section>
-<section>
-  <title>Drawing Primitives</title>
-<para>
-The X protocol (rules for the byte stream that goes between client and server)
-does all graphics using primitive
-operations, which are called Drawing Primitives.
-These include line drawing, area filling, arcs, and text drawing.
-Your implementation must supply 16 routines
-to perform these on your hardware.
-(The number 16 is arbitrary.)</para>
-<para>
-More specifically, 16 procedure pointers are in each
-GC op vector.
-At any given time, ALL of them MUST point to a valid procedure that
-attempts to do the operation assigned, although
-the procedure pointers may change and may
-point to different procedures to carry out the same operation.
-A simple server will leave them all pointing to the same 16 routines, while
-a more optimized implementation will switch each from one
-procedure to another, depending upon what is most optimal
-for the current GC and drawable.</para>
-<para>
-The sample server contains a considerable chunk of code called the
-mi (machine independent)
-routines, which serve as drawing primitive routines.
-Many server implementations will be able to use these as-is,
-because they work for arbitrary depths.
-They make no assumptions about the formats of pixmaps
-and frame buffers, since they call a set of routines
-known as the "Pixblit Routines" (see next section).
-They do assume that the way to draw is
-through these low-level routines that apply pixel values rows at a time.
-If your hardware or firmware gives more performance when
-things are done differently, you will want to take this fact into account
-and rewrite some or all of the drawing primitives to fit your needs.</para>
-<section>
-  <title>GC Components</title>
-<para>
-This section describes the fields in the GC that affect each drawing primitive.
-The only primitive that is not affected is GetImage, which does not use a GC
-because its destination is a protocol-style bit image.
-Since each drawing primitive mirrors exactly the X protocol request of the
-same name, you should refer to the X protocol specification document
-for more details.</para>
-<para>
-ALL of these routines MUST CLIP to the
-appropriate regions in the drawable.
-Since there are many regions to clip to simultaneously,
-your ValidateGC routine should combine these into a unified
-clip region to which your drawing routines can quickly refer.
-This is exactly what the fb routines supplied with the sample server
-do.
-The mi implementation passes responsibility for clipping while drawing
-down to the Pixblit routines.</para>
-<para>
-Also, all of them must adhere to the current plane mask.
-The plane mask has one bit for every bit plane in the drawable;
-only planes with 1 bits in the mask are affected by any drawing operation.</para>
-<para>
-All functions except for ImageText calls must obey the alu function.
-This is usually Copy, but could be any of the allowable 16 raster-ops.</para>
-<para>
-All of the functions, except for CopyArea, might use the current
-foreground and background pixel values.
-Each pixel value is 32 bits.
-These correspond to foreground and background colors, but you have
-to run them through the colormap to find out what color the pixel values
-represent.  Do not worry about the color, just apply the pixel value.</para>
-<para>
-The routines that draw lines (PolyLine, PolySegment, PolyRect, and PolyArc)
-use the line width, line style, cap style, and join style.
-Line width is in pixels.
-The line style specifies whether it is solid or dashed, and what kind of dash.
-The cap style specifies whether Rounded, Butt, etc.
-The join style specifies whether joins between joined lines are Miter, Round or Beveled.
-When lines cross as part of the same polyline, they are assumed to be drawn once.
-(See the X protocol specification for more details.)</para>
-<para>
-Zero-width lines are NOT meant to be really zero width; this is the client's way
-of telling you that you can optimize line drawing with little regard to
-the end caps and joins.
-They are called "thin" lines and are meant to be one pixel wide.
-These are frequently done in hardware or in a streamlined assembly language
-routine.</para>
-<para>
-Lines with widths greater than zero, though, must all be drawn with the same
-algorithm, because client software assumes that every jag on every
-line at an angle will come at the same place.
-Two lines that should have
-one pixel in the space between them
-(because of their distance apart and their widths) should have such a one-pixel line
-of space between them if drawn, regardless of angle.</para>
-<para>
-The solid area fill routines (FillPolygon, PolyFillRect, PolyFillArc)
-all use the fill rule, which specifies subtle interpretations of
-what points are inside and what are outside of a given polygon.
-The PolyFillArc routine also uses the arc mode, which specifies
-whether to fill pie segments or single-edge slices of an ellipse.</para>
-<para>
-The line drawing, area fill, and PolyText routines must all
-apply the correct "fill style."
-This can be either a solid foreground color, a transparent stipple,
-an opaque stipple, or a tile.
-Stipples are bitmaps where the 1 bits represent that the foreground color is written,
-and 0 bits represent that either the pixel is left alone (transparent) or that
-the background color is written (opaque).
-A tile is a pixmap of the full depth of the GC that is applied in its full glory to all areas.
-The stipple and tile patterns can be any rectangular size, although some implementations
-will be faster for certain sizes such as 8x8 or 32x32.
-The mi implementation passes this responsibility down to the Pixblit routines.</para>
-<para>
-See the X protocol document for full details.
-The description of the CreateGC request has a very good, detailed description of these
-attributes.</para>
-</section>
-<section>
-<title>The Primitives</title>
-<para>
-The Drawing Primitives are as follows:
-
-<blockquote><programlisting>
-
-	RegionPtr pGC->ops->CopyArea(src, dst, pGC, srcx, srcy, w, h, dstx, dsty)
-		DrawablePtr dst, src;
-		GCPtr pGC;
-		int srcx, srcy, w, h, dstx, dsty;
-
-</programlisting></blockquote>
-CopyArea copies a rectangle of pixels from one drawable to another of
-the same depth.  To effect scrolling, this must be able to copy from
-any drawable to itself, overlapped.  No squeezing or stretching is done
-because the source and destination are the same size.  However,
-everything is still clipped to the clip regions of the destination
-drawable.</para>
-<para>
-If pGC->graphicsExposures is True, any portions of the destination which
-were not valid in the source (either occluded by covering windows, or
-outside the bounds of the drawable) should be collected together and
-returned as a region (if this resultant region is empty, NULL can be
-returned instead).  Furthermore, the invalid bits of the source are
-not copied to the destination and (when the destination is a window)
-are filled with the background tile.  The sample routine
-miHandleExposures generates the appropriate return value and fills the
-invalid area using pScreen->PaintWindowBackground.</para>
-<para>
-For instance, imagine a window that is partially obscured by other
-windows in front of it.  As text is scrolled on your window, the pixels
-that are scrolled out from under obscuring windows will not be
-available on the screen to copy to the right places, and so an exposure
-event must be sent for the client to correctly repaint them.  Of
-course, if you implement backing store, you could do this without resorting
-to exposure events.</para>
-<para>
-An example implementation is fbCopyArea() in Xserver/fb/fbcopy.c.</para>
-<para>
-<blockquote><programlisting>
-
-	RegionPtr pGC->ops->CopyPlane(src, dst, pGC, srcx, srcy, w, h, dstx, dsty, plane)
-		DrawablePtr dst, src;
-		GCPtr pGC;
-		int srcx, srcy, w, h, dstx, dsty;
-		unsigned long plane;
-
-</programlisting></blockquote>
-CopyPlane must copy one plane of a rectangle from the source drawable
-onto the destination drawable.  Because this routine only copies one
-bit out of each pixel, it can copy between drawables of different
-depths.  This is the only way of copying between drawables of
-different depths, except for copying bitmaps to pixmaps and applying
-foreground and background colors to it.  All other conditions of
-CopyArea apply to CopyPlane too.</para>
-<para>
-An example implementation is fbCopyPlane() in
-Xserver/fb/fbcopy.c.</para>
-<para>
-<blockquote><programlisting>
-
-	void pGC->ops->PolyPoint(dst, pGC, mode, n, pPoint)
-		DrawablePtr dst;
-		GCPtr pGC;
-		int mode;
-		int n;
-		DDXPointPtr pPoint;
-
-</programlisting></blockquote>
-PolyPoint draws a set of one-pixel dots (foreground color)
-at the locations given in the array.
-mode is one of the defined constants Origin (absolute coordinates) or Previous
-(each coordinate is relative to the last).
-Note that this does not use the background color or any tiles or stipples.</para>
-<para>
-Example implementations are fbPolyPoint() in Xserver/fb/fbpoint.c and
-miPolyPoint in Xserver/mi/mipolypnt.c.</para>
-<para>
-<blockquote><programlisting>
-
-	void pGC->ops->Polylines(dst, pGC, mode, n, pPoint)
-		DrawablePtr dst;
-		GCPtr pGC;
-		int mode;
-		int n;
-		DDXPointPtr pPoint;
-
-</programlisting></blockquote>
-Similar to PolyPoint, Polylines draws lines between the locations given in the array.
-Zero-width lines are NOT meant to be really zero width; this is the client's way of
-telling you that you can maximally optimize line drawing with little regard to
-the end caps and joins.
-mode is one of the defined constants Previous or Origin, depending upon
-whether the points are each relative to the last or are absolute.</para>
-<para>
-Example implementations are miWideLine() and miWideDash() in
-mi/miwideline.c and miZeroLine() in mi/mizerline.c.</para>
-<para>
-<blockquote><programlisting>
-
-	void pGC->ops->PolySegment(dst, pGC, n, pPoint)
-		DrawablePtr dst;
-		GCPtr pGC;
-		int n;
-		xSegment *pSegments;
-
-</programlisting></blockquote>
-PolySegments draws unconnected
-lines between pairs of points in the array; the array must be of
-even size; no interconnecting lines are drawn.</para>
-<para>
-An example implementation is miPolySegment() in mipolyseg.c.</para>
-<para>
-<blockquote><programlisting>
-
-	void pGC->ops->PolyRectangle(dst, pGC, n, pRect)
-		DrawablePtr dst;
-		GCPtr pGC;
-		int n;
-		xRectangle *pRect;
-
-</programlisting></blockquote>
-PolyRectangle draws outlines of rectangles for each rectangle in the array.</para>
-<para>
-An example implementation is miPolyRectangle() in Xserver/mi/mipolyrect.c.</para>
-<para>
-<blockquote><programlisting>
-
-	void pGC->ops->PolyArc(dst, pGC, n, pArc)
-		DrawablePtr dst;
-		GCPtr pGC;
-		int n;
-		xArc*pArc;
-
-</programlisting></blockquote>
-PolyArc draws connected conic arcs according to the descriptions in the array.
-See the protocol specification for more details.</para>
-<para>
-Example implementations are miZeroPolyArc in Xserver/mi/mizerarc. and
-miPolyArc() in Xserver/mi/miarc.c.</para>
-<para>
-<blockquote><programlisting>
-
-	void pGC->ops->FillPolygon(dst, pGC, shape, mode, count, pPoint)
-		DrawablePtr dst;
-		GCPtr pGC;
-		int shape;
-		int mode;
-		int count;
-		DDXPointPtr pPoint;
-
-</programlisting></blockquote>
-FillPolygon fills a polygon specified by the points in the array
-with the appropriate fill style.
-If necessary, an extra border line is assumed between the starting and ending lines.
-The shape can be used as a hint
-to optimize filling; it indicates whether it is convex (all interior angles
-less than 180), nonconvex (some interior angles greater than 180 but
-border does not cross itself), or complex (border crosses itself).
-You can choose appropriate algorithms or hardware based upon mode.
-mode is one of the defined constants Previous or Origin, depending upon
-whether the points are each relative to the last or are absolute.</para>
-<para>
-An example implementation is miFillPolygon() in Xserver/mi/mipoly.c.</para>
-<para>
-<blockquote><programlisting>
-
-	void pGC->ops->PolyFillRect(dst, pGC, n, pRect)
-		DrawablePtr dst;
-		GCPtr pGC;
-		int n;
-		xRectangle *pRect;
-
-</programlisting></blockquote>
-PolyFillRect fills multiple rectangles.</para>
-<para>
-Example implementations are fbPolyFillRect() in Xserver/fb/fbfillrect.c and
-miPolyFillRect() in Xserver/mi/mifillrct.c.</para>
-<para>
-<blockquote><programlisting>
-
-	void pGC->ops->PolyFillArc(dst, pGC, n, pArc)
-		DrawablePtr dst;
-		GCPtr pGC;
-		int n;
-		xArc *pArc;
-
-</programlisting></blockquote>
-PolyFillArc fills a shape for each arc in the
-list that is bounded by the arc and one or two
-line segments with the current fill style.</para>
-<para>
-An example implementation is miPolyFillArc() in Xserver/mi/mifillarc.c.</para>
-<para>
-<blockquote><programlisting>
-
-	void pGC->ops->PutImage(dst, pGC, depth, x, y, w, h, leftPad, format, pBinImage)
-		DrawablePtr dst;
-		GCPtr pGC;
-		int x, y, w, h;
-		int format;
-		char *pBinImage;
-
-</programlisting></blockquote>
-PutImage copies a pixmap image into the drawable.  The pixmap image
-must be in X protocol format (either Bitmap, XYPixmap, or ZPixmap),
-and format tells the format.  (See the X protocol specification for
-details on these formats).  You must be able to accept all three
-formats, because the client gets to decide which format to send.
-Either the drawable and the pixmap image have the same depth, or the
-source pixmap image must be a Bitmap.  If a Bitmap, the foreground and
-background colors will be applied to the destination.</para>
-<para>
-An example implementation is fbPutImage() in Xserver/fb/fbimage.c.</para>
-<para>
-<blockquote><programlisting>
-
-	void pScreen->GetImage(src, x, y, w, h, format, planeMask, pBinImage)
-		 DrawablePtr src;
-		 int x, y, w, h;
-		 unsigned int format;
-		 unsigned long planeMask;
-		 char *pBinImage;
-
-</programlisting></blockquote>
-GetImage copies the bits from the source drawable into
-the destination pointer.  The bits are written into the buffer
-according to the server-defined pixmap padding rules.
-pBinImage is guaranteed to be big enough to hold all
-the bits that must be written.</para>
-<para>
-This routine does not correspond exactly to the X protocol GetImage
-request, since DIX has to break the reply up into buffers of a size
-requested by the transport layer.  If format is ZPixmap, the bits are
-written in the ZFormat for the depth of the drawable; if there is a 0
-bit in the planeMask for a particular plane, all pixels must have the
-bit in that plane equal to 0.  If format is XYPixmap, planemask is
-guaranteed to have a single bit set; the bits should be written in
-Bitmap format, which is the format for a single plane of an XYPixmap.</para>
-<para>
-An example implementation is miGetImage() in Xserver/mi/mibitblt.c.
-<blockquote><programlisting>
-
-	void pGC->ops->ImageText8(pDraw, pGC, x, y, count, chars)
-		DrawablePtr pDraw;
-		GCPtr pGC;
-		int x, y;
-		int count;
-		char *chars;
-
-</programlisting></blockquote>
-ImageText8 draws text.  The text is drawn in the foreground color; the
-background color fills the remainder of the character rectangles.  The
-coordinates specify the baseline and start of the text.</para>
-<para>
-An example implementation is miImageText8() in Xserver/mi/mipolytext.c.</para>
-<para>
-<blockquote><programlisting>
-
-	int pGC->ops->PolyText8(pDraw, pGC, x, y, count, chars)
-		DrawablePtr pDraw;
-		GCPtr pGC;
-		int x, y;
-		int count;
-		char *chars;
-
-</programlisting></blockquote>
-PolyText8 works like ImageText8, except it draws with
-the current fill style for special effects such as
-shaded text.
-See the X protocol specification for more details.</para>
-<para>
-An example implementation is miPolyText8() in Xserver/mi/mipolytext.c.</para>
-<para>
-<blockquote><programlisting>
-
-	int pGC->ops->PolyText16(pDraw, pGC, x, y, count, chars)
-		DrawablePtr pDraw;
-		GCPtr pGC;
-		int x, y;
-		int count;
-		unsigned short *chars;
-
-	void pGC->ops->ImageText16(pDraw, pGC, x, y, count, chars)
-		DrawablePtr pDraw;
-		GCPtr pGC;
-		int x, y;
-		int count;
-		unsigned short *chars;
-
-</programlisting></blockquote>
-These two routines are the same as the "8" versions,
-except that they are for 16-bit character codes (useful
-for oriental writing systems).</para>
-<para>
-The primary difference is in the way the character information is
-looked up.  The 8-bit and the 16-bit versions obviously have different
-kinds of character values to look up; the main goal of the lookup is
-to provide a pointer to the CharInfo structs for the characters to
-draw and to pass these pointers to the Glyph routines.  Given a
-CharInfo struct, lower-level software can draw the glyph desired with
-little concern for other characteristics of the font.</para>
-<para>
-16-bit character fonts have a row-and-column scheme, where the 2bytes
-of the character code constitute the row and column in a square matrix
-of CharInfo structs.  Each font has row and column minimum and maximum
-values; the CharInfo structures form a two-dimensional matrix.</para>
-<para>
-Example implementations are miPolyText16() and
-miImageText16() in Xserver/mi/mipolytext.c.</para>
-<para>
-See the X protocol specification for more details on these graphic operations.</para>
-<para>
-There is a hook in the GC ops, called LineHelper, that used to be used in the
-sample implementation by the code for wide lines.  It no longer servers any
-purpose in the sample servers, but still exists, #ifdef'ed by NEED_LINEHELPER,
-in case someone needs it.</para>
-</section>
-</section>
-<section>
-  <title>Pixblit Procedures</title>
-<para>
-The Drawing Primitive functions must be defined for your server.
-One possible way to do this is to use the mi routines from the sample server.
-If you choose to use the mi routines (even part of them!) you must implement
-these Pixblit routines.
-These routines read and write pixel values
-and deal directly with the image data.</para>
-<para>
-The Pixblit routines for the sample server are part of the "fb"
-routines.  As with the mi routines, the fb routines are
-portable but are not as portable as the mi routines.</para>
-<para>
-The fb subsystem is a depth-independent framebuffer core, capable of
-operating at any depth from 1 to 32, based on the depth of the window
-or pixmap it is currently operating on.  In particular, this means it
-can support pixmaps of multiple depths on the same screen.  It supplies
-both Pixblit routines and higher-level optimized implementations of the
-Drawing Primitive routines.  It does make the assumption that the pixel
-data it touches is available in the server's address space.</para>
-<para>
-In other words, if you have a "normal" frame buffer type display, you
-can probably use the fb code, and the mi code.  If you
-have a stranger hardware, you will have to supply your own Pixblit
-routines, but you can use the mi routines on top of them.  If you have
-better ways of doing some of the Drawing Primitive functions, then you
-may want to supply some of your own Drawing Primitive routines.  (Even
-people who write their own Drawing Primitives save at least some of
-the mi code for certain special cases that their hardware or library
-or fancy algorithm does not handle.)</para>
-<para>
-The client, DIX, and the machine-independent routines do not carry the
-final responsibility of clipping.  They all depend upon the Pixblit
-routines to do their clipping for them.  The rule is, if you touch the
-frame buffer, you clip.</para>
-<para>
-(The higher level routines may decide to clip at a high level, but
-this is only for increased performance and cannot substitute for
-bottom-level clipping.  For instance, the mi routines, DIX, or the
-client may decide to check all character strings to be drawn and chop
-off all characters that would not be displayed.  If so, it must retain
-the character on the edge that is partly displayed so that the Pixblit
-routines can clip off precisely at the right place.)</para>
-<para>
-To make this easier, all of the reasons to clip can be combined into
-one region in your ValidateGC procedure.  You take this composite clip
-region with you into the Pixblit routines.  (The sample server does
-this.)</para>
-<para>
-Also, FillSpans() has to apply tile and stipple patterns.  The
-patterns are all aligned to the window origin so that when two people
-write patches that are contiguous, they will merge nicely.  (Really,
-they are aligned to the patOrg point in the GC.  This defaults to (0,
-0) but can be set by the client to anything.)</para>
-<para>
-However, the mi routines can translate (relocate) the points from
-window-relative to screen-relative if desired.  If you set the
-miTranslate field in the GC (set it in the CreateGC or ValidateGC
-routine), then the mi output routines will translate all coordinates.
-If it is false, then the coordinates will be passed window-relative.
-Screens with no hardware translation will probably set miTranslate to
-TRUE, so that geometry (e.g. polygons, rectangles) can be translated,
-rather than having the resulting list of scanlines translated; this is
-good because the list vertices in a drawing request will generally be
-much smaller than the list of scanlines it produces.  Similarly,
-hardware that does translation can set miTranslate to FALSE, and avoid
-the extra addition per vertex, which can be (but is not always)
-important for getting the highest possible performance.  (Contrast the
-behavior of GetSpans, which is not expected to be called as often, and
-so has different constraints.)  The miTranslate field is settable in
-each GC, if , for example, you are mixing several kinds of
-destinations (offscreen pixmaps, main memory pixmaps, backing store,
-and windows), all of which have different requirements, on one screen.</para>
-<para>
-As with other drawing routines, there are fields in the GC to direct
-higher code to the correct routine to execute for each function.  In
-this way, you can optimize for special cases, for example, drawing
-solids versus drawing stipples.</para>
-<para>
-The Pixblit routines are broken up into three sets.  The Span routines
-simply fill in rows of pixels.  The Glyph routines fill in character
-glyphs.  The PushPixels routine is a three-input bitblt for more
-sophisticated image creation.</para>
-<para>
-It turns out that the Glyph and PushPixels routines actually have a
-machine-independent implementation that depends upon the Span
-routines.  If you are really pressed for time, you can use these
-versions, although they are quite slow.</para>
-<section>
-<title>Span Routines</title>
-<para>
-For these routines, all graphic operations have been reduced to "spans."
-A span is a horizontal row of pixels.
-If you can design these routines which write into and read from
-rows of pixels at a time, you can use the mi routines.</para>
-<para>
-Each routine takes
-a destination drawable to draw into, a GC to use while drawing,
-the number of spans to do, and two pointers to arrays that indicate the list
-of starting points and the list of widths of spans.</para>
-<para>
-<blockquote><programlisting>
-
-	void pGC->ops->FillSpans(dst, pGC, nSpans, pPoints, pWidths, sorted)
-		DrawablePtr dst;
-		GCPtr pGC;
-		int nSpans;
-		DDXPointPtr pPoints;
-		int *pWidths;
-		int sorted;
-
-</programlisting></blockquote>
-FillSpans should fill horizontal rows of pixels with
-the appropriate patterns, stipples, etc.,
-based on the values in the GC.
-The starting points are in the array at pPoints; the widths are in pWidths.
-If sorted is true, the scan lines are in increasing y order, in which case
-you may be able to make assumptions and optimizations.</para>
-<para>
-GC components: alu, clipOrg, clientClip, and fillStyle.</para>
-<para>
-GC mode-dependent components: fgPixel (for fillStyle Solid); tile, patOrg
-(for fillStyle Tile); stipple, patOrg, fgPixel (for fillStyle Stipple);
-and stipple, patOrg, fgPixel and bgPixel (for fillStyle OpaqueStipple).</para>
-<para>
-<blockquote><programlisting>
-
-	void pGC->ops->SetSpans(pDrawable, pGC, pSrc, ppt, pWidths, nSpans, sorted)
-		DrawablePtr pDrawable;
-		GCPtr pGC;
-		char *pSrc;
-		DDXPointPtr pPoints;
-		int *pWidths;
-		int nSpans;
-		int sorted;
-
-</programlisting></blockquote>
-For each span, this routine should copy pWidths bits from pSrc to
-pDrawable at pPoints using the raster-op from the GC.
-If sorted is true, the scan lines are in increasing y order.
-The pixels in pSrc are
-padded according to the screen's padding rules.
-These
-can be used to support
-interesting extension libraries, for example, shaded primitives.   It does not
-use the tile and stipple.</para>
-<para>
-GC components: alu, clipOrg, and clientClip</para>
-<para>
-The above functions are expected to handle all modifiers in the current
-GC.  Therefore, it is expedient to have
-different routines to quickly handle common special cases
-and reload the procedure pointers
-at validate time, as with the other output functions.</para>
-<para>
-<blockquote><programlisting>
-
-	void pScreen->GetSpans(pDrawable, wMax, pPoints, pWidths, nSpans)
-		DrawablePtr pDrawable;
-		int wMax;
-		DDXPointPtr pPoints;
-		int *pWidths;
-		int nSpans;
-		char *pDst;
-
-</programlisting></blockquote>
-For each span, GetSpans gets bits from the drawable starting at pPoints
-and continuing for pWidths bits.
-Each scanline returned will be server-scanline padded.
-The routine can return NULL if memory cannot be allocated to hold the
-result.</para>
-<para>
-GetSpans never translates -- for a window, the coordinates are already
-screen-relative.  Consider the case of hardware that doesn't do
-translation: the mi code that calls ddX will translate each shape
-(rectangle, polygon,. etc.) before scan-converting it, which requires
-many fewer additions that having GetSpans translate each span does.
-Conversely, consider hardware that does translate: it can set its
-translation point to (0, 0) and get each span, and the only penalty is
-the small number of additions required to translate each shape being
-scan-converted by the calling code.  Contrast the behavior of
-FillSpans and SetSpans (discussed above under miTranslate), which are
-expected to be used more often.</para>
-<para>
-Thus, the penalty to hardware that does hardware translation is
-negligible, and code that wants to call GetSpans() is greatly
-simplified, both for extensions and the machine-independent core
-implementation.</para>
-<section>
-  <title>Glyph Routines</title>
-<para>
-The Glyph routines draw individual character glyphs for text drawing requests.</para>
-<para>
-You have a choice in implementing these routines.  You can use the mi
-versions; they depend ultimately upon the span routines.  Although
-text drawing will work, it will be very slow.</para>
-<para>
-<blockquote><programlisting>
-
-	void pGC->ops->PolyGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase)
-		DrawablePtr pDrawable;
-		GCPtr pGC;
-		int x , y;
-		unsigned int nglyph;
-		CharInfoRec **ppci;		/* array of character info */
-		pointer unused;			/* unused since R5 */
-
-</programlisting></blockquote>
-GC components: alu, clipOrg, clientClip, font, and fillStyle.</para>
-<para>
-GC mode-dependent components: fgPixel (for fillStyle Solid); tile, patOrg
-(for fillStyle Tile); stipple, patOrg, fgPixel (for fillStyle Stipple);
-and stipple, patOrg, fgPixel and bgPixel (for fillStyle OpaqueStipple).</para>
-<para>
-<blockquote><programlisting>
-
-	void pGC->ops->ImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase)
-		DrawablePtr pDrawable;
-		GCPtr pGC;
-		int x , y;
-		unsigned int nglyph;
-		CharInfoRec **ppci;	/* array of character info */
-		pointer unused;		/* unused since R5 */
-
-</programlisting></blockquote>
-GC components: clipOrg, clientClip, font, fgPixel, bgPixel</para>
-<para>
-These routines must copy the glyphs defined by the bitmaps in
-pglyphBase and the font metrics in ppci to the DrawablePtr, pDrawable.
-The poly routine follows all fill, stipple, and tile rules.  The image
-routine simply blasts the glyph onto the glyph's rectangle, in
-foreground and background colors.</para>
-<para>
-More precisely, the Image routine fills the character rectangle with
-the background color, and then the glyph is applied in the foreground
-color.  The glyph can extend outside of the character rectangle.
-ImageGlyph() is used for terminal emulators and informal text purposes
-such as button labels.</para>
-<para>
-The exact specification for the Poly routine is that the glyph is
-painted with the current fill style.  The character rectangle is
-irrelevant for this operation.  PolyText, at a higher level, includes
-facilities for font changes within strings and such; it is to be used
-for WYSIWYG word processing and similar systems.</para>
-<para>
-Both of these routines must clip themselves to the overall clipping region.</para>
-<para>
-Example implementations in mi are miPolyGlyphBlt() and
-miImageGlyphBlt() in Xserver/mi/miglblt.c.</para>
-</section>
-<section>
-<title>PushPixels routine</title>
-<para>
-The PushPixels routine writes the current fill style onto the drawable
-in a certain shape defined by a bitmap.  PushPixels is equivalent to
-using a second stipple.  You can thing of it as pushing the fillStyle
-through a stencil.  PushPixels is not used by any of the mi rendering code,
-but is used by the mi software cursor code.
-<blockquote><para>
-	Suppose the stencil is:	00111100
-	and the stipple is:	10101010
-	PushPixels result:	00101000
-</para></blockquote>
-</para>
-<para>
-You have a choice in implementing this routine.
-You can use the mi version which depends ultimately upon FillSpans().
-Although it will work, it will be slow.</para>
-<para>
-<blockquote><programlisting>
-
-	void pGC->ops->PushPixels(pGC, pBitMap, pDrawable, dx, dy, xOrg, yOrg)
-		GCPtr pGC;
-		PixmapPtr pBitMap;
-		DrawablePtr pDrawable;
-		int dx, dy, xOrg, yOrg;
-
-</programlisting></blockquote>
-GC components: alu, clipOrg, clientClip, and fillStyle.</para>
-<para>
-GC mode-dependent components: fgPixel (for fillStyle Solid); tile, patOrg
-(for fillStyle Tile); stipple, patOrg, fgPixel (for fillStyle Stipple);
-and stipple, patOrg, fgPixel and bgPixel (for fillStyle OpaqueStipple).</para>
-<para>
-PushPixels applys the foreground color, tile, or stipple from the pGC
-through a stencil onto pDrawable.  pBitMap points to a stencil (of
-which we use an area dx wide by dy high), which is oriented over the
-drawable at xOrg, yOrg.  Where there is a 1 bit in the bitmap, the
-destination is set according to the current fill style.  Where there
-is a 0 bit in the bitmap, the destination is left the way it is.</para>
-<para>
-This routine must clip to the overall clipping region.</para>
-<para>
-An Example implementation is miPushPixels() in Xserver/mi/mipushpxl.c.</para>
-</section>
-</section>
-</section>
-<section>
-  <title>Shutdown Procedures</title>
-<para>
-<blockquote><programlisting>
-	void AbortDDX()
-	void ddxGiveUp()
-</programlisting></blockquote>
-Some hardware may require special work to be done before the server
-exits so that it is not left in an intermediate state.  As explained
-in the OS layer, FatalError() will call AbortDDX() just before
-terminating the server.  In addition, ddxGiveUp() will be called just
-before terminating the server on a "clean" death.  What AbortDDX() and
-ddxGiveUP do is left unspecified, only that stubs must exist in the
-ddx layer.  It is up to local implementors as to what they should
-accomplish before termination.</para>
-<section>
-  <title>Command Line Procedures</title>
-<para>
-<blockquote><programlisting>
-	int ddxProcessArgument(argc, argv, i)
-	    int argc;
-	    char *argv[];
-	    int i;
-
-	void
-	ddxUseMsg()
-
-</programlisting></blockquote>
-You should write these routines to deal with device-dependent command line
-arguments.  The routine ddxProcessArgument() is called with the command line,
-and the current index into argv; you should return zero if the argument
-is not a device-dependent one, and otherwise return a count of the number
-of elements of argv that are part of this one argument.  For a typical
-option (e.g., "-realtime"), you should return the value one.  This
-routine gets called before checks are made against device-independent
-arguments, so it is possible to peek at all arguments or to override
-device-independent argument processing.  You can document the
-device-dependent arguments in ddxUseMsg(), which will be
-called from UseMsg() after printing out the device-independent arguments.</para>
-</section>
-</section>
-<section id="wrappers_and_privates">
-  <title>Wrappers and Privates</title>
-<para>
-Two new extensibility concepts have been developed for release 4, Wrappers
-and devPrivates.  These replace the R3 GCInterest queues, which were not a
-general enough mechanism for many extensions and only provided hooks into a
-single data structure.  devPrivates have been revised substantially for
-X.Org X server release 1.5, and updated again for the 1.9 release.</para>
-<section>
-  <title>devPrivates</title>
-<para>
-devPrivates provides a way to attach arbitrary private data to various server structures.
-Any structure which contains a <structfield>devPrivates</structfield> field of
-type <type>PrivateRec</type> supports this mechanism.  Some structures allow
-allocating space for private data after some objects have been created, others
-require all space allocations be registered before any objects of that type
-are created.  <filename class="headerfile">Xserver/include/privates.h</filename>
-lists which of these cases applies to each structure containing
-<structfield>devPrivates</structfield>.</para>
-
-<para>
-To request private space, use
-<blockquote><programlisting>
-	Bool dixRegisterPrivateKey(DevPrivateKey key, DevPrivateType type, unsigned size);
-</programlisting></blockquote>
-The first argument is a pointer to a <type>DevPrivateKeyRec</type> which
-will serve as the unique identifier for the private data.  Typically this is
-the address of a static <type>DevPrivateKeyRec</type> in your code.
-The second argument is the class of objects for which this key will apply.
-The third argument is the size of the space being requested, or
-<constant>0</constant> to only allocate a pointer that the caller will manage.
-If space is requested, this space will be automatically freed when the object
-is destroyed.  Note that a call to <function>dixSetPrivate</function>
-that changes the pointer value may cause the space to be unreachable by the caller, however it will still be automatically freed.
-The function returns <literal>TRUE</literal> unless memory allocation fails.
-If the function is called more than once on the same key, all calls must use
-the same value for <type>size</type> or the server will abort.</para>
-
-<para>
-To request per-screen private space in an object, use
-<blockquote><programlisting>
-	Bool dixRegisterScreenPrivateKey(DevScreenPrivateKey key, ScreenPtr pScreen, DevPrivateType type, unsigned size);
-</programlisting></blockquote>
-The <parameter>type</parameter> and <parameter>size</parameter> arguments are
-the same as those to <function>dixRegisterPrivateKey</function> but this
-function ensures the given <parameter>key</parameter> exists on objects of
-the specified type with distinct storage for the given
-<parameter>pScreen</parameter>. The key is usable on ScreenPrivate variants
-that are otherwise equivalent to the following Private functions.</para>
-
-<para>
-To attach a piece of private data to an object, use:
-<blockquote><programlisting>
-	void dixSetPrivate(PrivateRec **privates, const DevPrivateKey key, pointer val)
-</programlisting></blockquote>
-The first argument is the address of the <structfield>devPrivates</structfield>
-field in the target structure.  This field is managed privately by the DIX
-layer and should not be directly modified.  The second argument is a pointer
-to the <type>DevPrivateKeyRec</type> which you registered with
-<function>dixRegisterPrivateKey</function> or allocated with
-<function>dixCreatePrivateKey</function>.  Only one
-piece of data with a given key can be attached to an object, and in most cases
-each key is specific to the type of object it was registered for.   (An
-exception is the PRIVATE_XSELINUX class which applies to multiple object types.)
-The third argument is the value to store.</para>
-<para>
-If private data with the given key is already associated with the object,
-<function>dixSetPrivate</function> will overwrite the old value with the
-new one.</para>
-
-<para>
-To look up a piece of private data, use one of:
-<blockquote><programlisting>
-	pointer dixLookupPrivate(PrivateRec **privates, const DevPrivateKey key)
-	pointer *dixLookupPrivateAddr(PrivateRec **privates, const DevPrivateKey key)
-</programlisting></blockquote>
-The first argument is the address of the <structfield>devPrivates</structfield> field
-in the target structure.  The second argument is the key to look up.
-If a non-zero size was given when the key was registered, or if private data
-with the given key is already associated with the object, then
-<function>dixLookupPrivate</function> will return the pointer value
-while <function>dixLookupPrivateAddr</function>
-will return the address of the pointer.</para>
-
-<para>
-When implementing new server resource objects that support devPrivates, there
-are four steps to perform:
-Add a type value to the <type>DevPrivateType</type> enum in
-<filename class="headerfile">Xserver/include/privates.h</filename>,
-declare a field of type <type>PrivateRec *</type> in your structure;
-initialize this field to <literal>NULL</literal> when creating any objects; and
-when freeing any objects call the <function>dixFreePrivates</function> or
-<function>dixFreeObjectWithPrivates</function> function.</para>
-</section>
-<section>
-  <title>Wrappers</title>
-<para>
-Wrappers are not a body of code, nor an interface spec.  They are, instead,
-a technique for hooking a new module into an existing calling sequence.
-There are limitations on other portions of the server implementation which
-make using wrappers possible; limits on when specific fields of data
-structures may be modified.  They are intended as a replacement for
-GCInterest queues, which were not general enough to support existing
-modules; in particular software cursors needed more
-control over the activity.  The general mechanism for using wrappers is:
-<blockquote><programlisting>
-privateWrapperFunction (object, ...)
-	ObjectPtr	object;
-{
-	pre-wrapped-function-stuff ...
-
-	object->functionVector = dixLookupPrivate(&object->devPrivates, privateKey);
-	(*object->functionVector) (object, ...);
-	/*
-	 * this next line is occasionally required by the rules governing
-	 * wrapper functions.  Always using it will not cause problems.
-	 * Not using it when necessary can cause severe troubles.
-	 */
-	dixSetPrivate(&object->devPrivates, privateKey, object->functionVector);
-	object->functionVector = privateWrapperFunction;
-
-	post-wrapped-function-stuff ...
-}
-
-privateInitialize (object)
-	ObjectPtr	object;
-{
-	dixSetPrivate(&object->devPrivates, privateKey, object->functionVector);
-	object->functionVector = privateWrapperFunction;
-}
-</programlisting></blockquote>
-</para>
-<para>
-Thus the privateWrapperFunction provides hooks for performing work both
-before and after the wrapped function has been called; the process of
-resetting the functionVector is called "unwrapping" while the process of
-fetching the wrapped function and replacing it with the wrapping function
-is called "wrapping".  It should be clear that GCInterest queues could
-be emulated using wrappers.  In general, any function vectors contained in
-objects can be wrapped, but only vectors in GCs and Screens have been tested.</para>
-<para>
-Wrapping screen functions is quite easy; each vector is individually
-wrapped.  Screen functions are not supposed to change after initialization,
-so rewrapping is technically not necessary, but causes no problems.</para>
-<para>
-Wrapping GC functions is a bit more complicated.  GC's have two tables of
-function vectors, one hanging from gc->ops and the other from gc->funcs, which
-should be initially wrapped from a CreateGC wrapper.  Wrappers should modify
-only table pointers, not the contents of the tables, as they
-may be shared by more than one GC (and, in the case of funcs, are probably
-shared by all gcs).  Your func wrappers may change the GC funcs or ops
-pointers, and op wrappers may change the GC op pointers but not the funcs.</para>
-<para>
-Thus, the rule for GC wrappings is: wrap the funcs from CreateGC and, in each
-func wrapper, unwrap the ops and funcs, call down, and re-wrap.  In each op
-wrapper, unwrap the ops, call down, and rewrap afterwards.  Note that in
-re-wrapping you must save out the pointer you're replacing again.  This way the
-chain will be maintained when wrappers adjust the funcs/ops tables they use.</para>
-</section>
-</section>
-<section>
-    <title>Work Queue</title>
-<para>
-To queue work for execution when all clients are in a stable state (i.e.
-just before calling select() in WaitForSomething), call:
-<blockquote><programlisting>
-	Bool QueueWorkProc(function,client,closure)
-		Bool		(*function)();
-		ClientPtr	client;
-		pointer		closure;
-</programlisting></blockquote>
-</para>
-<para>
-When the server is about to suspend itself, the given function will be
-executed:
-<blockquote><programlisting>
-	(*function) (client, closure)
-</programlisting></blockquote>
-</para>
-<para>
-Neither client nor closure are actually used inside the work queue routines.</para>
-</section>
-</section>
-<section>
-  <title>Summary of Routines</title>
-<para>
-This is a summary of the routines discussed in this document.
-The procedure names are in alphabetical order.
-The Struct is the structure it is attached to; if blank, this
-procedure is not attached to a struct and must be named as shown.
-The sample server provides implementations in the following
-categories.  Notice that many of the graphics routines have both
-mi and fb implementations.</para>
-<para>
-<itemizedlist>
-<listitem><para>dix	portable to all systems; do not attempt to rewrite (Xserver/dix)</para></listitem>
-<listitem><para>os	routine provided in Xserver/os or Xserver/include/os.h</para></listitem>
-<listitem><para>ddx	frame buffer dependent (examples in Xserver/fb)</para></listitem>
-<listitem><para>mi	routine provided in Xserver/mi</para></listitem>
-<listitem><para>hd	hardware dependent (examples in many Xserver/hw directories)</para></listitem>
-<listitem><para>none	not implemented in sample implementation</para></listitem>
-</itemizedlist>
-</para>
-	<table frame="all" id="routines-1">
-	  <title>Server Routines (Page 1)</title>
-	  <tgroup cols='3' align='left' colsep='1' rowsep='1'>
-	    <thead>
-	      <row>
-		<entry>Procedure</entry>
-		<entry>Port</entry>
-		<entry>Struct</entry>
-	      </row>
-	    </thead>
-	    <tbody>
-<row><entry><function>ALLOCATE_LOCAL</function></entry><entry><literal>os</literal></entry><entry><para></para></entry></row>
-<row><entry><function>AbortDDX</function></entry><entry><literal>hd</literal></entry><entry><para></para></entry></row>
-<row><entry><function>AddCallback</function></entry><entry><literal>dix</literal></entry><entry><para></para></entry></row>
-<row><entry><function>AddEnabledDevice</function></entry><entry><literal>os</literal></entry><entry><para></para></entry></row>
-<row><entry><function>AddInputDevice</function></entry><entry><literal>dix</literal></entry><entry><para></para></entry></row>
-<row><entry><function>AddScreen</function></entry><entry><literal>dix</literal></entry><entry><para></para></entry></row>
-<row><entry><function>AdjustWaitForDelay</function></entry><entry><literal>os</literal></entry><entry><para></para></entry></row>
-<row><entry><function>Bell</function></entry><entry><literal>hd</literal></entry><entry><para>Device</para></entry></row>
-<row><entry><function>ChangeClip</function></entry><entry><literal>mi</literal></entry><entry><para>GC func</para></entry></row>
-<row><entry><function>ChangeGC</function></entry><entry><literal></literal></entry><entry><para>GC func</para></entry></row>
-<row><entry><function>ChangeWindowAttributes</function></entry><entry><literal>ddx</literal></entry><entry><para>Screen</para></entry></row>
-<row><entry><function>ClearToBackground</function></entry><entry><literal>ddx</literal></entry><entry><para>Window</para></entry></row>
-<row><entry><function>ClientAuthorized</function></entry><entry><literal>os</literal></entry><entry><para></para></entry></row>
-<row><entry><function>ClientSignal</function></entry><entry><literal>dix</literal></entry><entry><para></para></entry></row>
-<row><entry><function>ClientSleep</function></entry><entry><literal>dix</literal></entry><entry><para></para></entry></row>
-<row><entry><function>ClientWakeup</function></entry><entry><literal>dix</literal></entry><entry><para></para></entry></row>
-<row><entry><function>ClipNotify</function></entry><entry><literal>ddx</literal></entry><entry><para>Screen</para></entry></row>
-<row><entry><function>CloseScreen</function></entry><entry><literal>hd</literal></entry><entry><para></para></entry></row>
-<row><entry><function>ConstrainCursor</function></entry><entry><literal>hd</literal></entry><entry><para>Screen</para></entry></row>
-<row><entry><function>CopyArea</function></entry><entry><literal>mi</literal></entry><entry><para>GC op</para></entry></row>
-<row><entry><function>CopyGCDest</function></entry><entry><literal>ddx</literal></entry><entry><para>GC func</para></entry></row>
-<row><entry><function>CopyGCSource</function></entry><entry><literal>none</literal></entry><entry><para>GC func</para></entry></row>
-<row><entry><function>CopyPlane</function></entry><entry><literal>mi</literal></entry><entry><para>GC op</para></entry></row>
-<row><entry><function>CopyWindow</function></entry><entry><literal>ddx</literal></entry><entry><para>Window</para></entry></row>
-<row><entry><function>CreateGC</function></entry><entry><literal>ddx</literal></entry><entry><para>Screen</para></entry></row>
-<row><entry><function>CreateCallbackList</function></entry><entry><literal>dix</literal></entry><entry><para></para></entry></row>
-<row><entry><function>CreatePixmap</function></entry><entry><literal>ddx</literal></entry><entry><para>Screen</para></entry></row>
-<row><entry><function>CreateScreenResources</function></entry><entry><literal>ddx</literal></entry><entry><para>Screen</para></entry></row>
-<row><entry><function>CreateWellKnowSockets</function></entry><entry><literal>os</literal></entry><entry><para></para></entry></row>
-<row><entry><function>CreateWindow</function></entry><entry><literal>ddx</literal></entry><entry><para>Screen</para></entry></row>
-<row><entry><function>CursorLimits</function></entry><entry><literal>hd</literal></entry><entry><para>Screen</para></entry></row>
-<row><entry><function>DEALLOCATE_LOCAL</function></entry><entry><literal>os</literal></entry><entry><para></para></entry></row>
-<row><entry><function>DeleteCallback</function></entry><entry><literal>dix</literal></entry><entry><para></para></entry></row>
-<row><entry><function>DeleteCallbackList</function></entry><entry><literal>dix</literal></entry><entry><para></para></entry></row>
-<row><entry><function>DestroyClip</function></entry><entry><literal>ddx</literal></entry><entry><para>GC func</para></entry></row>
-<row><entry><function>DestroyGC</function></entry><entry><literal>ddx</literal></entry><entry><para>GC func</para></entry></row>
-<row><entry><function>DestroyPixmap</function></entry><entry><literal>ddx</literal></entry><entry><para>Screen</para></entry></row>
-<row><entry><function>DestroyWindow</function></entry><entry><literal>ddx</literal></entry><entry><para>Screen</para></entry></row>
-<row><entry><function>DisplayCursor</function></entry><entry><literal>hd</literal></entry><entry><para>Screen</para></entry></row>
-<row><entry><function>Error</function></entry><entry><literal>os</literal></entry><entry><para></para></entry></row>
-<row><entry><function>ErrorF</function></entry><entry><literal>os</literal></entry><entry><para></para></entry></row>
-<row><entry><function>FatalError</function></entry><entry><literal>os</literal></entry><entry><para></para></entry></row>
-<row><entry><function>FillPolygon</function></entry><entry><literal>mi</literal></entry><entry><para>GC op</para></entry></row>
-<row><entry><function>FillSpans</function></entry><entry><literal>ddx</literal></entry><entry><para>GC op</para></entry></row>
-<row><entry><function>FlushAllOutput</function></entry><entry><literal>os</literal></entry><entry><para></para></entry></row>
-<row><entry><function>FlushIfCriticalOutputPending</function></entry><entry><literal>os</literal></entry><entry><para></para></entry></row>
-<row><entry><function>FreeScratchPixmapHeader</function></entry><entry><literal>dix</literal></entry><entry><para></para></entry></row>
-<row><entry><function>GetImage</function></entry><entry><literal>mi</literal></entry><entry><para>Screen</para></entry></row>
-<row><entry><function>GetMotionEvents</function></entry><entry><literal>hd</literal></entry><entry><para>Device</para></entry></row>
-<row><entry><function>GetScratchPixmapHeader</function></entry><entry><literal>dix</literal></entry><entry><para></para></entry></row>
-<row><entry><function>GetSpans</function></entry><entry><literal>ddx</literal></entry><entry><para>Screen</para></entry></row>
-<row><entry><function>GetStaticColormap</function></entry><entry><literal>ddx</literal></entry><entry><para>Screen</para></entry></row>
-	    </tbody>
-	  </tgroup>
-	</table>
-
-	<table frame="all" id="routines-2">
-	  <title>Server Routines (Page 2)</title>
-	  <tgroup cols='3' align='left' colsep='1' rowsep='1'>
-	    <thead>
-	      <row>
-		<entry>Procedure</entry>
-		<entry>Port</entry>
-		<entry>Struct</entry>
-	      </row>
-	    </thead>
-	    <tbody>
-<row><entry><function>ImageGlyphBlt</function></entry><entry><literal>mi</literal></entry><entry><para>GC op</para></entry></row>
-<row><entry><function>ImageText16</function></entry><entry><literal>mi</literal></entry><entry><para>GC op</para></entry></row>
-<row><entry><function>ImageText8</function></entry><entry><literal>mi</literal></entry><entry><para>GC op</para></entry></row>
-<row><entry><function>InitInput</function></entry><entry><literal>hd</literal></entry><entry><para></para></entry></row>
-<row><entry><function>InitKeyboardDeviceStruct</function></entry><entry><literal>dix</literal></entry><entry><para></para></entry></row>
-<row><entry><function>InitOutput</function></entry><entry><literal>hd</literal></entry><entry><para></para></entry></row>
-<row><entry><function>InitPointerDeviceStruct</function></entry><entry><literal>dix</literal></entry><entry><para></para></entry></row>
-<row><entry><function>InsertFakeRequest</function></entry><entry><literal>os</literal></entry><entry><para></para></entry></row>
-<row><entry><function>InstallColormap</function></entry><entry><literal>ddx</literal></entry><entry><para>Screen</para></entry></row>
-<row><entry><function>Intersect</function></entry><entry><literal>mi</literal></entry><entry><para>Screen</para></entry></row>
-<row><entry><function>Inverse</function></entry><entry><literal>mi</literal></entry><entry><para>Screen</para></entry></row>
-<row><entry><function>LegalModifier</function></entry><entry><literal>hd</literal></entry><entry><para></para></entry></row>
-<row><entry><function>LineHelper</function></entry><entry><literal>mi</literal></entry><entry><para>GC op</para></entry></row>
-<row><entry><function>ListInstalledColormaps</function></entry><entry><literal>ddx</literal></entry><entry><para>Screen</para></entry></row>
-<row><entry><function>LookupKeyboardDevice</function></entry><entry><literal>dix</literal></entry><entry><para></para></entry></row>
-<row><entry><function>LookupPointerDevice</function></entry><entry><literal>dix</literal></entry><entry><para></para></entry></row>
-<row><entry><function>ModifyPixmapHeader</function></entry><entry><literal>mi</literal></entry><entry><para>Screen</para></entry></row>
-<row><entry><function>NextAvailableClient</function></entry><entry><literal>dix</literal></entry><entry><para></para></entry></row>
-<row><entry><function>OsInit</function></entry><entry><literal>os</literal></entry><entry><para></para></entry></row>
-<row><entry><function>PaintWindowBackground</function></entry><entry><literal>mi</literal></entry><entry><para>Window</para></entry></row>
-<row><entry><function>PaintWindowBorder</function></entry><entry><literal>mi</literal></entry><entry><para>Window</para></entry></row>
-<row><entry><function>PointerNonInterestBox</function></entry><entry><literal>hd</literal></entry><entry><para>Screen</para></entry></row>
-<row><entry><function>PointInRegion</function></entry><entry><literal>mi</literal></entry><entry><para>Screen</para></entry></row>
-<row><entry><function>PolyArc</function></entry><entry><literal>mi</literal></entry><entry><para>GC op</para></entry></row>
-<row><entry><function>PolyFillArc</function></entry><entry><literal>mi</literal></entry><entry><para>GC op</para></entry></row>
-<row><entry><function>PolyFillRect</function></entry><entry><literal>mi</literal></entry><entry><para>GC op</para></entry></row>
-<row><entry><function>PolyGlyphBlt</function></entry><entry><literal>mi</literal></entry><entry><para>GC op</para></entry></row>
-<row><entry><function>Polylines</function></entry><entry><literal>mi</literal></entry><entry><para>GC op</para></entry></row>
-<row><entry><function>PolyPoint</function></entry><entry><literal>mi</literal></entry><entry><para>GC op</para></entry></row>
-<row><entry><function>PolyRectangle</function></entry><entry><literal>mi</literal></entry><entry><para>GC op</para></entry></row>
-<row><entry><function>PolySegment</function></entry><entry><literal>mi</literal></entry><entry><para>GC op</para></entry></row>
-<row><entry><function>PolyText16</function></entry><entry><literal>mi</literal></entry><entry><para>GC op</para></entry></row>
-<row><entry><function>PolyText8</function></entry><entry><literal>mi</literal></entry><entry><para>GC op</para></entry></row>
-<row><entry><function>PositionWindow</function></entry><entry><literal>ddx</literal></entry><entry><para>Screen</para></entry></row>
-<row><entry><function>ProcessInputEvents</function></entry><entry><literal>hd</literal></entry><entry><para></para></entry></row>
-<row><entry><function>PushPixels</function></entry><entry><literal>mi</literal></entry><entry><para>GC op</para></entry></row>
-<row><entry><function>PutImage</function></entry><entry><literal>mi</literal></entry><entry><para>GC op</para></entry></row>
-<row><entry><function>QueryBestSize</function></entry><entry><literal>hd</literal></entry><entry><para>Screen</para></entry></row>
-<row><entry><function>ReadRequestFromClient</function></entry><entry><literal>os</literal></entry><entry><para></para></entry></row>
-<row><entry><function>RealizeCursor</function></entry><entry><literal>hd</literal></entry><entry><para>Screen</para></entry></row>
-<row><entry><function>RealizeFont</function></entry><entry><literal>ddx</literal></entry><entry><para>Screen</para></entry></row>
-<row><entry><function>RealizeWindow</function></entry><entry><literal>ddx</literal></entry><entry><para>Screen</para></entry></row>
-<row><entry><function>RecolorCursor</function></entry><entry><literal>hd</literal></entry><entry><para>Screen</para></entry></row>
-<row><entry><function>RectIn</function></entry><entry><literal>mi</literal></entry><entry><para>Screen</para></entry></row>
-<row><entry><function>RegionCopy</function></entry><entry><literal>mi</literal></entry><entry><para>Screen</para></entry></row>
-<row><entry><function>RegionCreate</function></entry><entry><literal>mi</literal></entry><entry><para>Screen</para></entry></row>
-<row><entry><function>RegionDestroy</function></entry><entry><literal>mi</literal></entry><entry><para>Screen</para></entry></row>
-<row><entry><function>RegionEmpty</function></entry><entry><literal>mi</literal></entry><entry><para>Screen</para></entry></row>
-<row><entry><function>RegionExtents</function></entry><entry><literal>mi</literal></entry><entry><para>Screen</para></entry></row>
-<row><entry><function>RegionNotEmpty</function></entry><entry><literal>mi</literal></entry><entry><para>Screen</para></entry></row>
-<row><entry><function>RegionReset</function></entry><entry><literal>mi</literal></entry><entry><para>Screen</para></entry></row>
-<row><entry><function>ResolveColor</function></entry><entry><literal>ddx</literal></entry><entry><para>Screen</para></entry></row>
-	    </tbody>
-	  </tgroup>
-	</table>
-
-	<table frame="all" id="routines-3">
-	  <title>Server Routines (Page 3)</title>
-	  <tgroup cols='3' align='left' colsep='1' rowsep='1'>
-	    <thead>
-	      <row>
-		<entry>Procedure</entry>
-		<entry>Port</entry>
-		<entry>Struct</entry>
-	      </row>
-	    </thead>
-	    <tbody>
-<row><entry><function>RemoveEnabledDevice</function></entry><entry><literal>os</literal></entry><entry><para></para></entry></row>
-<row><entry><function>ResetCurrentRequest</function></entry><entry><literal>os</literal></entry><entry><para></para></entry></row>
-<row><entry><function>SaveScreen</function></entry><entry><literal>ddx</literal></entry><entry><para>Screen</para></entry></row>
-<row><entry><function>SetCriticalOutputPending</function></entry><entry><literal>os</literal></entry><entry><para></para></entry></row>
-<row><entry><function>SetCursorPosition</function></entry><entry><literal>hd</literal></entry><entry><para>Screen</para></entry></row>
-<row><entry><function>SetInputCheck</function></entry><entry><literal>dix</literal></entry><entry><para></para></entry></row>
-<row><entry><function>SetSpans</function></entry><entry><literal>ddx</literal></entry><entry><para>GC op</para></entry></row>
-<row><entry><function>StoreColors</function></entry><entry><literal>ddx</literal></entry><entry><para>Screen</para></entry></row>
-<row><entry><function>Subtract</function></entry><entry><literal>mi</literal></entry><entry><para>Screen</para></entry></row>
-<row><entry><function>TimerCancel</function></entry><entry><literal>os</literal></entry><entry><para></para></entry></row>
-<row><entry><function>TimerCheck</function></entry><entry><literal>os</literal></entry><entry><para></para></entry></row>
-<row><entry><function>TimerForce</function></entry><entry><literal>os</literal></entry><entry><para></para></entry></row>
-<row><entry><function>TimerFree</function></entry><entry><literal>os</literal></entry><entry><para></para></entry></row>
-<row><entry><function>TimerInit</function></entry><entry><literal>os</literal></entry><entry><para></para></entry></row>
-<row><entry><function>TimerSet</function></entry><entry><literal>os</literal></entry><entry><para></para></entry></row>
-<row><entry><function>TimeSinceLastInputEvent</function></entry><entry><literal>hd</literal></entry><entry><para></para></entry></row>
-<row><entry><function>TranslateRegion</function></entry><entry><literal>mi</literal></entry><entry><para>Screen</para></entry></row>
-<row><entry><function>UninstallColormap</function></entry><entry><literal>ddx</literal></entry><entry><para>Screen</para></entry></row>
-<row><entry><function>Union</function></entry><entry><literal>mi</literal></entry><entry><para>Screen</para></entry></row>
-<row><entry><function>UnrealizeCursor</function></entry><entry><literal>hd</literal></entry><entry><para>Screen</para></entry></row>
-<row><entry><function>UnrealizeFont</function></entry><entry><literal>ddx</literal></entry><entry><para>Screen</para></entry></row>
-<row><entry><function>UnrealizeWindow</function></entry><entry><literal>ddx</literal></entry><entry><para>Screen</para></entry></row>
-<row><entry><function>ValidateGC</function></entry><entry><literal>ddx</literal></entry><entry><para>GC func</para></entry></row>
-<row><entry><function>ValidateTree</function></entry><entry><literal>mi</literal></entry><entry><para>Screen</para></entry></row>
-<row><entry><function>WaitForSomething</function></entry><entry><literal>os</literal></entry><entry><para></para></entry></row>
-<row><entry><function>WindowExposures</function></entry><entry><literal>mi</literal></entry><entry><para>Window</para></entry></row>
-<row><entry><function>WriteToClient</function></entry><entry><literal>os</literal></entry><entry><para></para></entry></row>
-<row><entry><function>Xalloc</function></entry><entry><literal>os</literal></entry><entry><para></para></entry></row>
-<row><entry><function>Xfree</function></entry><entry><literal>os</literal></entry><entry><para></para></entry></row>
-<row><entry><function>Xrealloc</function></entry><entry><literal>os</literal></entry><entry><para></para></entry></row>
-	    </tbody>
-	  </tgroup>
-	</table>
-</section>
-</article>
diff --git a/doc/xml/xmlrules-inst.in b/doc/xml/xmlrules-inst.in
deleted file mode 100644
index 9b90278..0000000
--- a/doc/xml/xmlrules-inst.in
+++ /dev/null
@@ -1,23 +0,0 @@
-
-# The doc_sources variable contains one or more DocBook/XML source file.
-# The generated documents will be installed in $(docdir),
-# The DocBook/XML files will always be included in the tarball
-
-dist_doc_DATA = $(doc_sources)
-
-if HAVE_XMLTO
-doc_DATA = $(doc_sources:.xml=.html)
-
-if HAVE_FOP
-doc_DATA += $(doc_sources:.xml=.pdf)
-endif
-
-if HAVE_XMLTO_TEXT
-doc_DATA += $(doc_sources:.xml=.txt)
-endif
-
-CLEANFILES = $(doc_DATA)
-include $(top_srcdir)/doc/xml/xmlrules.in
-
-endif HAVE_XMLTO
-
diff --git a/doc/xml/xmlrules-noinst.in b/doc/xml/xmlrules-noinst.in
deleted file mode 100644
index 0333652..0000000
--- a/doc/xml/xmlrules-noinst.in
+++ /dev/null
@@ -1,22 +0,0 @@
-
-# The doc_sources variable contains one or more DocBook/XML source file.
-# The generated documents will NOT be installed in $(docdir),
-# The DocBook/XML files will always be included in the tarball
-
-dist_noinst_DATA = $(doc_sources)
-
-if HAVE_XMLTO
-noinst_DATA = $(doc_sources:.xml=.html)
-
-if HAVE_FOP
-noinst_DATA += $(doc_sources:.xml=.pdf)
-endif
-
-if HAVE_XMLTO_TEXT
-noinst_DATA += $(doc_sources:.xml=.txt)
-endif
-
-CLEANFILES = $(noinst_DATA)
-include $(top_srcdir)/doc/xml/xmlrules.in
-
-endif HAVE_XMLTO
diff --git a/doc/xml/xmlrules.in b/doc/xml/xmlrules.in
deleted file mode 100644
index 8b22761..0000000
--- a/doc/xml/xmlrules.in
+++ /dev/null
@@ -1,47 +0,0 @@
-#
-# Copyright (c) 2010, Oracle and/or its affiliates. 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 (including the next
-# paragraph) shall be included in all copies or substantial portions of the
-# Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
-# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-# DEALINGS IN THE SOFTWARE.
-#
-
-# This file provides pattern rules to generate html/pdf/txt from DocBook/XML
-# A stylesheet is used if xorg-sgml-doctools is installed
-# This file is included by xmlrules-inst.in for installable user's documentation
-# It is included by xmlrules-noinst for non installable developer's documentation
-# If the server version or release date changes, autogen && make
-
-XML_ENT_DIR = $(abs_top_builddir)
-SUFFIXES = .xml .txt .html .pdf
-
-XMLTO_FLAGS = --searchpath $(XML_ENT_DIR)
-
-if HAVE_STYLESHEETS
-XMLTO_FLAGS += -m $(XSL_STYLESHEET) \
-	--stringparam html.stylesheet=$(STYLESHEET_SRCDIR)/xorg.css
-endif
-
-%.txt: %.xml $(XML_ENT_DIR)/xserver.ent
-	$(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) txt $<
-
-%.html: %.xml $(XML_ENT_DIR)/xserver.ent
-	$(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) xhtml-nochunks $<
-
-%.pdf: %.xml $(XML_ENT_DIR)/xserver.ent
-	$(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) --with-fop pdf $<
commit 96c65be39b98cfe035be0a3988dce519549249f3
Author: Gaetan Nadon <memsize at videotron.ca>
Date:   Sat May 14 13:30:19 2011 -0400

    doc: relocate xserver.ent in the package root directory
    
    This is the appropriate location for reusable configuration and/or
    makefile artifacts as opposed to picking one of the subdirs where
    it is used.
    
    It shields them from future doc reorg as every subdir
    will refer to the root package which never changes location.
    
    Reviewed-by Jeremy Huddleston <jeremyhu at apple.com>
    Signed-off-by: Gaetan Nadon <memsize at videotron.ca>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/.gitignore b/.gitignore
index 72390a0..94a12fd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -78,3 +78,4 @@ core
 # 
 doltcompile
 doltlibtool
+xserver.ent
diff --git a/configure.ac b/configure.ac
index ba6bacb..9d0854f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2154,7 +2154,6 @@ dix/Makefile
 doc/Makefile
 doc/dtrace/Makefile
 doc/xml/Makefile
-doc/xml/xserver.ent
 man/Makefile
 fb/Makefile
 record/Makefile
@@ -2244,5 +2243,6 @@ hw/kdrive/linux/Makefile
 hw/kdrive/src/Makefile
 test/Makefile
 test/xi2/Makefile
+xserver.ent
 xorg-server.pc
 ])
diff --git a/devbook.am b/devbook.am
index dbc9d8a..4e23bb7 100644
--- a/devbook.am
+++ b/devbook.am
@@ -30,7 +30,7 @@ if HAVE_STYLESHEETS
 # The location where all cross reference databases are installed
 XMLTO_FLAGS =						\
 	--searchpath "$(XORG_SGML_PATH)/X11"		\
-	--searchpath "$(abs_top_builddir)/doc/xml"	\
+	--searchpath "$(abs_top_builddir)"		\
 	--stringparam current.docid="$(<:.xml=)"
 
 XMLTO_XHTML_FLAGS = \
diff --git a/doc/xml/.gitignore b/doc/xml/.gitignore
index 4961738..3f0ed13 100644
--- a/doc/xml/.gitignore
+++ b/doc/xml/.gitignore
@@ -1,5 +1,3 @@
-#		Add & Override for this directory and its subdirectories
-xserver.ent
 Xserver-spec.html
 Xserver-spec.pdf
 Xserver-spec.txt
diff --git a/doc/xml/xmlrules.in b/doc/xml/xmlrules.in
index f6a2e4f..8b22761 100644
--- a/doc/xml/xmlrules.in
+++ b/doc/xml/xmlrules.in
@@ -27,7 +27,7 @@
 # It is included by xmlrules-noinst for non installable developer's documentation
 # If the server version or release date changes, autogen && make
 
-XML_ENT_DIR = $(abs_top_builddir)/doc/xml
+XML_ENT_DIR = $(abs_top_builddir)
 SUFFIXES = .xml .txt .html .pdf
 
 XMLTO_FLAGS = --searchpath $(XML_ENT_DIR)
diff --git a/doc/xml/xserver.ent.in b/doc/xml/xserver.ent.in
deleted file mode 100644
index 5cb4e23..0000000
--- a/doc/xml/xserver.ent.in
+++ /dev/null
@@ -1,3 +0,0 @@
-<!-- shared -*-xml-*- entity definitions for the X server documentation -->
-<!ENTITY xserver.version "@PACKAGE_VERSION@">
-<!ENTITY xserver.reldate "@RELEASE_DATE@">
diff --git a/docbook.am b/docbook.am
index 50a542e..7ab7a00 100644
--- a/docbook.am
+++ b/docbook.am
@@ -32,7 +32,7 @@ sgmldbsdir = $(XORG_SGML_PATH)/X11/dbs
 masterdb = "$(sgmldbsdir)/masterdb$(suffix $@).xml"
 XMLTO_FLAGS =							\
 	--searchpath "$(XORG_SGML_PATH)/X11"			\
-	--searchpath "$(abs_top_builddir)/doc/xml"		\
+	--searchpath "$(abs_top_builddir)"			\
 	--stringparam target.database.document=$(masterdb)	\
 	--stringparam current.docid="$(<:.xml=)"		\
 	--stringparam collect.xref.targets="no"
diff --git a/xserver.ent.in b/xserver.ent.in
new file mode 100644
index 0000000..5cb4e23
--- /dev/null
+++ b/xserver.ent.in
@@ -0,0 +1,3 @@
+<!-- shared -*-xml-*- entity definitions for the X server documentation -->
+<!ENTITY xserver.version "@PACKAGE_VERSION@">
+<!ENTITY xserver.reldate "@RELEASE_DATE@">
commit dbe26634e4f12eba905540666783c9879aa3a49a
Author: Gaetan Nadon <memsize at videotron.ca>
Date:   Sat May 14 13:30:18 2011 -0400

    doc: add external doc references support to Xserver-DTrace
    
    This makefile is used to build the 60+ docbooks in xorg.
    Dtrace is a user document and should be located under doc subdir.
    
    This user document can now refer to external user/specs docs
    or can be referred to by such documnets.
    
    Reviewed-by Jeremy Huddleston <jeremyhu at apple.com>
    Signed-off-by: Gaetan Nadon <memsize at videotron.ca>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/configure.ac b/configure.ac
index e23274c..ba6bacb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -38,11 +38,12 @@ m4_ifndef([XORG_MACROS_VERSION],
 XORG_MACROS_VERSION(1.13)
 XORG_DEFAULT_OPTIONS
 XORG_WITH_DOXYGEN(1.6.1)
-XORG_CHECK_SGML_DOCTOOLS(1.5)
+XORG_CHECK_SGML_DOCTOOLS(1.7)
 XORG_ENABLE_DOCS
 XORG_ENABLE_DEVEL_DOCS
 XORG_WITH_XMLTO(0.0.20)
 XORG_WITH_FOP
+XORG_WITH_XSLTPROC
 XORG_ENABLE_UNIT_TESTS
 XORG_LD_WRAP
 
@@ -2151,8 +2152,8 @@ damageext/Makefile
 dbe/Makefile
 dix/Makefile
 doc/Makefile
+doc/dtrace/Makefile
 doc/xml/Makefile
-doc/xml/dtrace/Makefile
 doc/xml/xserver.ent
 man/Makefile
 fb/Makefile
diff --git a/doc/Makefile.am b/doc/Makefile.am
index b9015bc..e8634fd 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -1,3 +1,3 @@
-SUBDIRS = xml
+SUBDIRS = dtrace xml
 
 dist_noinst_DATA = smartsched
diff --git a/doc/dtrace/.gitignore b/doc/dtrace/.gitignore
new file mode 100644
index 0000000..0d40e0d
--- /dev/null
+++ b/doc/dtrace/.gitignore
@@ -0,0 +1,5 @@
+*.html
+*.pdf
+*.ps
+*.txt
+*.db
diff --git a/doc/dtrace/Makefile.am b/doc/dtrace/Makefile.am
new file mode 100644
index 0000000..aaf5a12
--- /dev/null
+++ b/doc/dtrace/Makefile.am
@@ -0,0 +1,17 @@
+
+if ENABLE_DOCS
+if HAVE_XMLTO
+if XSERVER_DTRACE
+
+# Main DocBook/XML files (DOCTYPE book)
+docbook = Xserver-DTrace.xml
+
+# The location where the DocBook/XML files and their generated formats are installed
+shelfdir = $(docdir)
+
+# Generate DocBook/XML output formats with or without stylesheets
+include $(top_srcdir)/docbook.am
+
+endif XSERVER_DTRACE
+endif HAVE_XMLTO
+endif ENABLE_DOCS
diff --git a/doc/dtrace/Xserver-DTrace.xml b/doc/dtrace/Xserver-DTrace.xml
new file mode 100644
index 0000000..69cd30e
--- /dev/null
+++ b/doc/dtrace/Xserver-DTrace.xml
@@ -0,0 +1,578 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
+ "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
+ <!ENTITY % defs SYSTEM "/xserver/doc/xml/xserver.ent"> %defs;
+]>
+
+<article id="Xserver-DTrace">
+  <articleinfo>
+    <title>Xserver provider for DTrace</title>
+    <author>
+      <firstname>Alan</firstname><surname>Coopersmith</surname>
+      <affiliation>
+	<orgname>Oracle Corporation</orgname>
+	<orgdiv>Solaris Engineering</orgdiv>
+      </affiliation>
+    </author>
+    <releaseinfo>X.Org Xserver version &xserver.version;</releaseinfo>
+    <legalnotice>
+      <para>
+Copyright (c) 2005, 2006, 2007, 2010, Oracle and/or its affiliates.
+All rights reserved.
+      </para><para>
+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:
+      </para><para>
+The above copyright notice and this permission notice (including the next
+paragraph) shall be included in all copies or substantial portions of the
+Software.
+      </para><para>
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
+      </para>
+    </legalnotice>
+  </articleinfo>
+
+  <sect1 id="introduction">
+    <title>Introduction</title>
+    <para>
+      This page provides details on a
+      <ulink url="http://wikis.sun.com/display/DTrace/Statically+Defined+Tracing+for+User+Applications">statically defined user application tracing provider</ulink>
+      for the
+      <ulink url="http://hub.opensolaris.org/bin/view/Community+Group+dtrace/">DTrace</ulink>
+      facility in <productname>Solaris</productname> 10,
+      <productname>MacOS X</productname> 10.5, and later releases.  This
+      provider instruments various points in the X server, to allow
+      tracing what client applications are up to.
+    </para>
+
+    <para>
+      The provider was integrated into the X.Org git master repository
+      with Solaris 10 & OpenSolaris support for the Xserver 1.4 release,
+      released in 2007 with X11R7.3.   Support for DTrace on MacOS X
+      was added in Xserver 1.7.
+    </para>
+
+    <para>
+      These probes expose the request and reply structure of the X protocol
+      between clients and the X server, so an understanding of that basic
+      nature will aid in learning how to use these probes.
+    </para>
+  </sect1>
+
+  <sect1 id="probes">
+    <title>Available probes</title>
+
+    <para>
+      Due to the way User-Defined DTrace probes work, arguments to
+      these probes all bear undistinguished names of
+      <parameter>arg0</parameter>, <parameter>arg1</parameter>,
+      <parameter>arg2</parameter>, etc.  These tables should help you
+      determine what the real data is for each of the probe arguments.
+
+    <table>
+      <title>Probes and their arguments</title>
+      <tgroup cols='7'>
+	<colspec colname="probe" colwidth="2*"/>
+	<colspec colname="desc" colwidth="3*"/>
+	<colspec colname="arg0" colwidth="1*"/>
+	<colspec colname="arg1" colwidth="1*"/>
+	<colspec colname="arg2" colwidth="1*"/>
+	<colspec colname="arg3" colwidth="1*"/>
+	<colspec colname="arg4" colwidth="1*"/>
+	<spanspec spanname="all" namest="probe" nameend="arg4"/>
+	<thead>
+	  <row>
+	    <entry>Probe name</entry>
+	    <entry>Description</entry>
+	    <entry>arg0</entry>
+	    <entry>arg1</entry>
+	    <entry>arg2</entry>
+	    <entry>arg3</entry>
+	    <entry>arg4</entry>
+	  </row>
+	</thead>
+	<tbody>
+	  <row>
+	    <entry spanname="all" class="grouphead">Request Probes</entry>
+	  </row>
+	  <row>
+	    <entry>request-start</entry>
+	    <entry>Called just before processing each client request.</entry>
+	    <entry><parameter>requestName</parameter></entry>
+	    <entry><parameter>requestCode</parameter></entry>
+	    <entry><parameter>requestLength</parameter></entry>
+	    <entry><parameter>clientId</parameter></entry>
+	    <entry><parameter>requestBuffer</parameter></entry>
+	  </row>
+	  <row>
+	    <entry>request-done</entry>
+	    <entry>Called just after processing each client request.</entry>
+	    <entry><parameter>requestName</parameter></entry>
+	    <entry><parameter>requestCode</parameter></entry>
+	    <entry><parameter>sequenceNumber</parameter></entry>
+	    <entry><parameter>clientId</parameter></entry>
+	    <entry><parameter>resultCode</parameter></entry>
+	  </row>
+	  <row>
+	    <entry spanname="all" class="grouphead">Event Probes</entry>
+	  </row>
+	  <row>
+	    <entry>send-event</entry>
+	    <entry>Called just before send each event to a client.</entry>
+	    <entry><parameter>clientId</parameter></entry>
+	    <entry><parameter>eventCode</parameter></entry>
+	    <entry><parameter>eventBuffer</parameter></entry>
+	    <entry nameend="arg4" class="unused"/>
+	  </row>
+	  <row>
+	    <entry spanname="all" class="grouphead">Client Connection Probes</entry>
+	  </row>
+	  <row>
+	    <entry>client-connect</entry>
+	    <entry>Called when a new connection is opened from a client</entry>
+	    <entry><parameter>clientId</parameter></entry>
+	    <entry><parameter>clientFD</parameter></entry>
+	    <entry nameend="arg4" class="unused"/>
+	  </row>
+	  <row>
+	    <entry>client-auth</entry>
+	    <entry>Called when client authenticates (normally just after connection opened)</entry>
+	    <entry><parameter>clientId</parameter></entry>
+	    <entry><parameter>clientAddr</parameter></entry>
+	    <entry><parameter>clientPid</parameter></entry>
+	    <entry><parameter>clientZoneId</parameter></entry>
+	    <entry nameend="arg4" class="unused"/>
+	  </row>
+	  <row>
+	    <entry>client-disconnect</entry>
+	    <entry>Called when a client connection is closed</entry>
+	    <entry><parameter>clientId</parameter></entry>
+	    <entry nameend="arg4" class="unused"/>
+	  </row>
+	  <row>
+	    <entry spanname="all" class="grouphead">Resource Allocation Probes</entry>
+	  </row>
+	  <row>
+	    <entry>resource-alloc</entry>
+	    <entry>Called when a new resource (pixmap, gc, colormap, etc.) is allocated</entry>
+	    <entry><parameter>resourceId</parameter></entry>
+	    <entry><parameter>resourceTypeId</parameter></entry>
+	    <entry><parameter>resourceValue</parameter></entry>
+	    <entry><parameter>resourceTypeName</parameter></entry>
+	    <entry nameend="arg4" class="unused"/>
+	  </row>
+	  <row>
+	    <entry>resource-free</entry>
+	    <entry>Called when a resource is freed</entry>
+	    <entry><parameter>resourceId</parameter></entry>
+	    <entry><parameter>resourceTypeId</parameter></entry>
+	    <entry><parameter>resourceValue</parameter></entry>
+	    <entry><parameter>resourceTypeName</parameter></entry>
+	    <entry nameend="arg4" class="unused"/>
+	  </row>
+	</tbody>
+      </tgroup>
+    </table>
+    </para>
+  </sect1>
+
+  <sect1 id="arguments">
+    <title>Data Available in Probe Arguments</title>
+
+    <para>
+      To access data in arguments of type <type>string</type>, you will need
+      to use <ulink url="http://wikis.sun.com/display/DTrace/Actions+and+Subroutines#ActionsandSubroutines-{{copyinstr}}"><function>copyinstr()</function></ulink>.
+      To access data buffers referenced via <type>uintptr_t</type>'s, you will
+      need to use <ulink url="http://wikis.sun.com/display/DTrace/Actions+and+Subroutines#ActionsandSubroutines-{{copyin}}"><function>copyin()</function></ulink>.
+
+    <table>
+      <title>Probe Arguments</title>
+      <tgroup cols='3'>
+	<colspec colname="arg" colwidth="2*"/>
+	<colspec colname="type" colwidth="1*"/>
+	<colspec colname="desc" colwidth="7*"/>
+	<thead>
+	  <row>
+	    <entry>Argument name</entry>
+	    <entry>Type</entry>
+	    <entry>Description</entry>
+	  </row>
+	</thead>
+	<tbody>
+	  <row>
+	    <entry><parameter>clientAddr</parameter></entry>
+	    <entry><type>string</type></entry>
+	    <entry>String representing address client connected from</entry>
+	  </row>
+	  <row>
+	    <entry><parameter>clientFD</parameter></entry>
+	    <entry><type>int</type></entry>
+	    <entry>X server's file descriptor for server side of each connection</entry>
+	  </row>
+	  <row>
+	    <entry><parameter>clientId</parameter></entry>
+	    <entry><type>int</type></entry>
+	    <entry>Unique integer identifier for each connection to the
+	      X server</entry>
+	  </row>
+	  <row>
+	    <entry><parameter>clientPid</parameter></entry>
+	    <entry><type>pid_t</type></entry>
+	    <entry>Process id of client, if connection is local
+	      (from <function>getpeerucred()</function>)</entry>
+	  </row>
+	  <row>
+	    <entry><parameter>clientZoneId</parameter></entry>
+	    <entry><type>zoneid_t</type></entry>
+	    <entry>Solaris: Zone id of client, if connection is local
+	      (from <function>getpeerucred()</function>)</entry>
+	  </row>
+	  <row>
+	    <entry><parameter>eventBuffer</parameter></entry>
+	    <entry><type>uintptr_t</type></entry>
+	    <entry>Pointer to buffer containing X event - decode using
+	      structures in
+	      <<ulink url="http://cgit.freedesktop.org/xorg/proto/xproto/tree/Xproto.h"><filename class="headerfile">X11/Xproto.h</filename></ulink>>
+	      and similar headers for each extension</entry>
+	  </row>
+	  <row>
+	    <entry><parameter>eventCode</parameter></entry>
+	    <entry><type>uint8_t</type></entry>
+	    <entry>Event number of X event</entry>
+	  </row>
+	  <row>
+	    <entry><parameter>resourceId</parameter></entry>
+	    <entry><type>uint32_t</type></entry>
+	    <entry>X resource id (XID)</entry>
+	  </row>
+	  <row>
+	    <entry><parameter>resourceTypeId</parameter></entry>
+	    <entry><type>uint32_t</type></entry>
+	    <entry>Resource type id</entry>
+	  </row>
+	  <row>
+	    <entry><parameter>resourceTypeName</parameter></entry>
+	    <entry><type>string</type></entry>
+	    <entry>String representing X resource type
+		(<literal>"PIXMAP"</literal>, etc.)</entry>
+	  </row>
+	  <row>
+	    <entry><parameter>resourceValue</parameter></entry>
+	    <entry><type>uintptr_t</type></entry>
+	    <entry>Pointer to data for X resource</entry>
+	  </row>
+	  <row>
+	    <entry><parameter>resultCode</parameter></entry>
+	    <entry><type>int</type></entry>
+	    <entry>Integer code representing result status of request</entry>
+	  </row>
+	  <row>
+	    <entry><parameter>requestBuffer</parameter></entry>
+	    <entry><type>uintptr_t</type></entry>
+	    <entry>Pointer to buffer containing X request - decode using
+	      structures in
+	      <<ulink url="http://cgit.freedesktop.org/xorg/proto/xproto/tree/Xproto.h"><filename class="headerfile">X11/Xproto.h</filename></ulink>>
+	      and similar headers for each extension</entry>
+	  </row>
+	  <row>
+	    <entry><parameter>requestCode</parameter></entry>
+	    <entry><type>uint8_t</type></entry>
+	    <entry>Request number of X request or Extension</entry>
+	  </row>
+	  <row>
+	    <entry><parameter>requestName</parameter></entry>
+	    <entry><type>string</type></entry>
+	    <entry>Name of X request or Extension</entry>
+	  </row>
+	  <row>
+	    <entry><parameter>requestLength</parameter></entry>
+	    <entry><type>uint16_t</type></entry>
+	    <entry>Length of X request</entry>
+	  </row>
+	  <row>
+	    <entry><parameter>sequenceNumber</parameter></entry>
+	    <entry><type>uint32_t</type></entry>
+	    <entry>Number of X request in in this connection</entry>
+	  </row>
+	</tbody>
+      </tgroup>
+    </table>
+    </para>
+  </sect1>
+
+  <sect1 id="examples">
+    <title>Examples</title>
+
+    <example>
+      <title>Counting requests by request name</title>
+
+      <para>
+	This script simply increments a counter for each different request
+	made, and when you exit the script (such as by hitting
+	<keycombo action='simul'><keycap>Control</keycap><keycap>C</keycap>
+	</keycombo>) prints the counts.
+
+	<programlisting>
+#!/usr/sbin/dtrace -s
+
+Xserver*:::request-start
+{
+    @counts[copyinstr(arg0)] = count();
+}
+	</programlisting>
+
+	The output from a short run may appear as:
+	<screen>
+  QueryPointer                                                      1
+  CreatePixmap                                                      2
+  FreePixmap                                                        2
+  PutImage                                                          2
+  ChangeGC                                                         10
+  CopyArea                                                         10
+  CreateGC                                                         14
+  FreeGC                                                           14
+  RENDER                                                           28
+  SetClipRectangles                                                40
+	</screen>
+      </para>
+
+      <para>
+	This can be rewritten slightly to cache the string containing the name
+	of the request since it will be reused many times, instead of copying
+	it over and over from the kernel:
+
+	<programlisting>
+#!/usr/sbin/dtrace -s
+
+string Xrequest[uintptr_t];
+
+Xserver*:::request-start
+/Xrequest[arg0] == ""/
+{
+    Xrequest[arg0] = copyinstr(arg0);
+}
+
+Xserver*:::request-start
+{
+    @counts[Xrequest[arg0]] = count();
+}
+	</programlisting>
+      </para>
+    </example>
+
+    <example>
+      <title>Get average CPU time per request</title>
+
+      <para>This script records the CPU time used between the probes at
+	the start and end of each request and aggregates it per request type.
+
+	<programlisting>
+#!/usr/sbin/dtrace -s
+
+Xserver*:::request-start
+{
+    reqstart = vtimestamp;
+}
+
+Xserver*:::request-done
+{
+    @times[copyinstr(arg0)] = avg(vtimestamp - reqstart);
+}
+	</programlisting>
+
+	The output from a sample run might look like:
+
+	<screen>
+  ChangeGC                                                        889
+  MapWindow                                                       907
+  SetClipRectangles                                              1319
+  PolyPoint                                                      1413
+  PolySegment                                                    1434
+  PolyRectangle                                                  1828
+  FreeCursor                                                     1895
+  FreeGC                                                         1950
+  CreateGC                                                       2244
+  FreePixmap                                                     2246
+  GetInputFocus                                                  2249
+  TranslateCoords                                                8508
+  QueryTree                                                      8846
+  GetGeometry                                                    9948
+  CreatePixmap                                                  12111
+  AllowEvents                                                   14090
+  GrabServer                                                    14791
+  MIT-SCREEN-SAVER                                              16747
+  ConfigureWindow                                               22917
+  SetInputFocus                                                 28521
+  PutImage                                                     240841
+
+	</screen>
+      </para>
+    </example>
+
+    <example>
+      <title>Monitoring clients that connect and disconnect</title>
+
+      <para>
+	This script simply prints information about each client that
+	connects or disconnects from the server while it is running.
+	Since the provider is specified as <code>Xserver$1</code> instead
+	of <code>Xserver*</code> like previous examples, it won't monitor
+	all Xserver processes running on the machine, but instead expects
+	the process id of the X server to monitor to be specified as the
+	argument to the script.
+
+	<programlisting>
+#!/usr/sbin/dtrace -s
+
+Xserver$1:::client-connect
+{
+	printf("** Client Connect: id %d\n", arg0);
+}
+
+Xserver$1:::client-auth
+{
+	printf("** Client auth'ed: id %d => %s pid %d\n",
+		arg0, copyinstr(arg1), arg2);
+}
+
+Xserver$1:::client-disconnect
+{
+	printf("** Client Disconnect: id %d\n", arg0);
+}
+	</programlisting>
+
+	A sample run:
+
+	<screen>
+<prompt>#</prompt> <userinput>./foo.d 5790</userinput>
+<computeroutput>dtrace: script './foo.d' matched 4 probes
+CPU     ID                    FUNCTION:NAME
+  0  15774 CloseDownClient:client-disconnect ** Client Disconnect: id 65
+
+  2  15774 CloseDownClient:client-disconnect ** Client Disconnect: id 64
+
+  0  15773 EstablishNewConnections:client-connect ** Client Connect: id 64
+
+  0  15772            AuthAudit:client-auth ** Client auth'ed: id 64 => local host pid 2034
+
+  0  15773 EstablishNewConnections:client-connect ** Client Connect: id 65
+
+  0  15772            AuthAudit:client-auth ** Client auth'ed: id 65 => local host pid 2034
+
+  0  15774 CloseDownClient:client-disconnect ** Client Disconnect: id 64
+	  </computeroutput>
+	</screen>
+
+      </para>
+    </example>
+
+    <example>
+      <title>Monitoring clients creating Pixmaps</title>
+
+      <para>
+	This script can be used to determine which clients are creating
+	pixmaps in the X server, printing information about each client
+	as it connects to help trace it back to the program on the other
+	end of the X connection.
+
+	<programlisting>
+#!/usr/sbin/dtrace -qs
+
+string Xrequest[uintptr_t];
+string Xrestype[uintptr_t];
+
+Xserver$1:::request-start
+/Xrequest[arg0] == ""/
+{
+	Xrequest[arg0] = copyinstr(arg0);
+}
+
+Xserver$1:::resource-alloc
+/arg3 != 0 && Xrestype[arg3] == ""/
+{
+	Xrestype[arg3] = copyinstr(arg3);
+}
+
+
+Xserver$1:::request-start
+/Xrequest[arg0] == "X_CreatePixmap"/
+{
+	printf("-> %s: client %d\n", Xrequest[arg0], arg3);
+}
+
+Xserver$1:::request-done
+/Xrequest[arg0] == "X_CreatePixmap"/
+{
+	printf("<- %s: client %d\n", Xrequest[arg0], arg3);
+}
+
+Xserver$1:::resource-alloc
+/Xrestype[arg3] == "PIXMAP"/
+{
+	printf("** Pixmap alloc: %08x\n", arg0);
+}
+
+
+Xserver$1:::resource-free
+/Xrestype[arg3] == "PIXMAP"/
+{
+	printf("** Pixmap free:  %08x\n", arg0);
+}
+
+Xserver$1:::client-connect
+{
+	printf("** Client Connect: id %d\n", arg0);
+}
+
+Xserver$1:::client-auth
+{
+	printf("** Client auth'ed: id %d => %s pid %d\n",
+		arg0, copyinstr(arg1), arg2);
+}
+
+Xserver$1:::client-disconnect
+{
+	printf("** Client Disconnect: id %d\n", arg0);
+}
+	</programlisting>
+
+	Sample output from a run of this script:
+	<screen><computeroutput>
+** Client Connect: id 17
+** Client auth'ed: id 17 => local host pid 20273
+-> X_CreatePixmap: client 17
+** Pixmap alloc: 02200009
+<- X_CreatePixmap: client 17
+-> X_CreatePixmap: client 15
+** Pixmap alloc: 01e00180
+<- X_CreatePixmap: client 15
+-> X_CreatePixmap: client 15
+** Pixmap alloc: 01e00181
+<- X_CreatePixmap: client 15
+-> X_CreatePixmap: client 14
+** Pixmap alloc: 01c004c8
+<- X_CreatePixmap: client 14
+** Pixmap free:  02200009
+** Client Disconnect: id 17
+** Pixmap free:  01e00180
+** Pixmap free:  01e00181
+	  </computeroutput></screen>
+
+      </para>
+
+    </example>
+
+
+  </sect1>
+
+</article>
diff --git a/doc/xml/Makefile.am b/doc/xml/Makefile.am
index b793e7b..b35ceec 100644
--- a/doc/xml/Makefile.am
+++ b/doc/xml/Makefile.am
@@ -21,7 +21,6 @@
 # DEALINGS IN THE SOFTWARE.
 #
 
-SUBDIRS = dtrace
 doc_sources =  Xserver-spec.xml Xinput.xml
 
 # Developer's documentation is not installed
diff --git a/doc/xml/dtrace/.gitignore b/doc/xml/dtrace/.gitignore
deleted file mode 100644
index e2a21d1..0000000
--- a/doc/xml/dtrace/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-Xserver-DTrace.html
-Xserver-DTrace.pdf
-Xserver-DTrace.txt
diff --git a/doc/xml/dtrace/Makefile.am b/doc/xml/dtrace/Makefile.am
deleted file mode 100644
index 1a5ad15..0000000
--- a/doc/xml/dtrace/Makefile.am
+++ /dev/null
@@ -1,36 +0,0 @@
-#
-# Copyright (c) 2010, Oracle and/or its affiliates. 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 (including the next
-# paragraph) shall be included in all copies or substantial portions of the
-# Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
-# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-# DEALINGS IN THE SOFTWARE.
-#
-
-doc_sources =  Xserver-DTrace.xml
-
-if ENABLE_DOCS
-
-# This user's documentation is installed only if tracing is available
-if XSERVER_DTRACE
-include $(top_srcdir)/doc/xml/xmlrules-inst.in
-else
-include $(top_srcdir)/doc/xml/xmlrules-noinst.in
-endif
-
-endif
-
diff --git a/doc/xml/dtrace/Xserver-DTrace.xml b/doc/xml/dtrace/Xserver-DTrace.xml
deleted file mode 100644
index 290f0d3..0000000
--- a/doc/xml/dtrace/Xserver-DTrace.xml
+++ /dev/null
@@ -1,579 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
- "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
- <!ENTITY % defs SYSTEM "/xserver/doc/xml/xserver.ent"> %defs;
-]>
-
-<article id="Xserver-DTrace">
-  <articleinfo>
-    <title>Xserver provider for DTrace</title>
-    <author>
-      <firstname>Alan</firstname><surname>Coopersmith</surname>
-      <affiliation>
-	<orgname>Oracle Corporation</orgname>
-	<orgdiv>Solaris Engineering</orgdiv>
-      </affiliation>
-    </author>
-    <releaseinfo>X.Org Xserver version &xserver.version;</releaseinfo>
-    <legalnotice>
-      <para>
-Copyright (c) 2005, 2006, 2007, 2010, Oracle and/or its affiliates.
-All rights reserved.
-      </para><para>
-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:
-      </para><para>
-The above copyright notice and this permission notice (including the next
-paragraph) shall be included in all copies or substantial portions of the
-Software.
-      </para><para>
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
-THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-DEALINGS IN THE SOFTWARE.
-      </para>
-    </legalnotice>
-  </articleinfo>
-
-  <sect1 id="introduction">
-    <title>Introduction</title>
-    <para>
-      This page provides details on a
-      <ulink url="http://wikis.sun.com/display/DTrace/Statically+Defined+Tracing+for+User+Applications">statically defined user application tracing provider</ulink>
-      for the
-      <ulink url="http://hub.opensolaris.org/bin/view/Community+Group+dtrace/">DTrace</ulink>
-      facility in <productname>Solaris</productname> 10,
-      <productname>MacOS X</productname> 10.5, and later releases.  This
-      provider instruments various points in the X server, to allow
-      tracing what client applications are up to.
-    </para>
-
-    <para>
-      The provider was integrated into the X.Org git master repository
-      with Solaris 10 & OpenSolaris support for the Xserver 1.4 release,
-      released in 2007 with X11R7.3.   Support for DTrace on MacOS X
-      was added in Xserver 1.7.
-    </para>
-
-    <para>
-      These probes expose the request and reply structure of the X protocol
-      between clients and the X server, so an understanding of that basic
-      nature will aid in learning how to use these probes.
-    </para>
-  </sect1>
-
-  <sect1 id="probes">
-    <title>Available probes</title>
-
-    <para>
-      Due to the way User-Defined DTrace probes work, arguments to
-      these probes all bear undistinguished names of
-      <parameter>arg0</parameter>, <parameter>arg1</parameter>,
-      <parameter>arg2</parameter>, etc.  These tables should help you
-      determine what the real data is for each of the probe arguments.
-
-    <table>
-      <title>Probes and their arguments</title>
-      <tgroup cols='7'>
-	<colspec colname="probe" colwidth="2*"/>
-	<colspec colname="desc" colwidth="3*"/>
-	<colspec colname="arg0" colwidth="1*"/>
-	<colspec colname="arg1" colwidth="1*"/>
-	<colspec colname="arg2" colwidth="1*"/>
-	<colspec colname="arg3" colwidth="1*"/>
-	<colspec colname="arg4" colwidth="1*"/>
-	<spanspec spanname="all" namest="probe" nameend="arg4"/>
-	<thead>
-	  <row>
-	    <entry>Probe name</entry>
-	    <entry>Description</entry>
-	    <entry>arg0</entry>
-	    <entry>arg1</entry>
-	    <entry>arg2</entry>
-	    <entry>arg3</entry>
-	    <entry>arg4</entry>
-	  </row>
-	</thead>
-	<tbody>
-	  <row>
-	    <entry spanname="all" class="grouphead">Request Probes</entry>
-	  </row>
-	  <row>
-	    <entry>request-start</entry>
-	    <entry>Called just before processing each client request.</entry>
-	    <entry><parameter>requestName</parameter></entry>
-	    <entry><parameter>requestCode</parameter></entry>
-	    <entry><parameter>requestLength</parameter></entry>
-	    <entry><parameter>clientId</parameter></entry>
-	    <entry><parameter>requestBuffer</parameter></entry>
-	  </row>
-	  <row>
-	    <entry>request-done</entry>
-	    <entry>Called just after processing each client request.</entry>
-	    <entry><parameter>requestName</parameter></entry>
-	    <entry><parameter>requestCode</parameter></entry>
-	    <entry><parameter>sequenceNumber</parameter></entry>
-	    <entry><parameter>clientId</parameter></entry>
-	    <entry><parameter>resultCode</parameter></entry>
-	  </row>
-	  <row>
-	    <entry spanname="all" class="grouphead">Event Probes</entry>
-	  </row>
-	  <row>
-	    <entry>send-event</entry>
-	    <entry>Called just before send each event to a client.</entry>
-	    <entry><parameter>clientId</parameter></entry>
-	    <entry><parameter>eventCode</parameter></entry>
-	    <entry><parameter>eventBuffer</parameter></entry>
-	    <entry nameend="arg4" class="unused"/>
-	  </row>
-	  <row>
-	    <entry spanname="all" class="grouphead">Client Connection Probes</entry>
-	  </row>
-	  <row>
-	    <entry>client-connect</entry>
-	    <entry>Called when a new connection is opened from a client</entry>
-	    <entry><parameter>clientId</parameter></entry>
-	    <entry><parameter>clientFD</parameter></entry>
-	    <entry nameend="arg4" class="unused"/>
-	  </row>
-	  <row>
-	    <entry>client-auth</entry>
-	    <entry>Called when client authenticates (normally just after connection opened)</entry>
-	    <entry><parameter>clientId</parameter></entry>
-	    <entry><parameter>clientAddr</parameter></entry>
-	    <entry><parameter>clientPid</parameter></entry>
-	    <entry><parameter>clientZoneId</parameter></entry>
-	    <entry nameend="arg4" class="unused"/>
-	  </row>
-	  <row>
-	    <entry>client-disconnect</entry>
-	    <entry>Called when a client connection is closed</entry>
-	    <entry><parameter>clientId</parameter></entry>
-	    <entry nameend="arg4" class="unused"/>
-	  </row>
-	  <row>
-	    <entry spanname="all" class="grouphead">Resource Allocation Probes</entry>
-	  </row>
-	  <row>
-	    <entry>resource-alloc</entry>
-	    <entry>Called when a new resource (pixmap, gc, colormap, etc.) is allocated</entry>
-	    <entry><parameter>resourceId</parameter></entry>
-	    <entry><parameter>resourceTypeId</parameter></entry>
-	    <entry><parameter>resourceValue</parameter></entry>
-	    <entry><parameter>resourceTypeName</parameter></entry>
-	    <entry nameend="arg4" class="unused"/>
-	  </row>
-	  <row>
-	    <entry>resource-free</entry>
-	    <entry>Called when a resource is freed</entry>
-	    <entry><parameter>resourceId</parameter></entry>
-	    <entry><parameter>resourceTypeId</parameter></entry>
-	    <entry><parameter>resourceValue</parameter></entry>
-	    <entry><parameter>resourceTypeName</parameter></entry>
-	    <entry nameend="arg4" class="unused"/>
-	  </row>
-	</tbody>
-      </tgroup>
-    </table>
-    </para>
-  </sect1>
-
-  <sect1 id="arguments">
-    <title>Data Available in Probe Arguments</title>
-
-    <para>
-      To access data in arguments of type <type>string</type>, you will need
-      to use <ulink url="http://wikis.sun.com/display/DTrace/Actions+and+Subroutines#ActionsandSubroutines-{{copyinstr}}"><function>copyinstr()</function></ulink>.
-      To access data buffers referenced via <type>uintptr_t</type>'s, you will
-      need to use <ulink url="http://wikis.sun.com/display/DTrace/Actions+and+Subroutines#ActionsandSubroutines-{{copyin}}"><function>copyin()</function></ulink>.
-
-    <table>
-      <title>Probe Arguments</title>
-      <tgroup cols='3'>
-	<colspec colname="arg" colwidth="2*"/>
-	<colspec colname="type" colwidth="1*"/>
-	<colspec colname="desc" colwidth="7*"/>
-	<thead>
-	  <row>
-	    <entry>Argument name</entry>
-	    <entry>Type</entry>
-	    <entry>Description</entry>
-	  </row>
-	</thead>
-	<tbody>
-	  <row>
-	    <entry><parameter>clientAddr</parameter></entry>
-	    <entry><type>string</type></entry>
-	    <entry>String representing address client connected from</entry>
-	  </row>
-	  <row>
-	    <entry><parameter>clientFD</parameter></entry>
-	    <entry><type>int</type></entry>
-	    <entry>X server's file descriptor for server side of each connection</entry>
-	  </row>
-	  <row>
-	    <entry><parameter>clientId</parameter></entry>
-	    <entry><type>int</type></entry>
-	    <entry>Unique integer identifier for each connection to the
-	      X server</entry>
-	  </row>
-	  <row>
-	    <entry><parameter>clientPid</parameter></entry>
-	    <entry><type>pid_t</type></entry>
-	    <entry>Process id of client, if connection is local
-	      (from <function>getpeerucred()</function>)</entry>
-	  </row>
-	  <row>
-	    <entry><parameter>clientZoneId</parameter></entry>
-	    <entry><type>zoneid_t</type></entry>
-	    <entry>Solaris: Zone id of client, if connection is local
-	      (from <function>getpeerucred()</function>)</entry>
-	  </row>
-	  <row>
-	    <entry><parameter>eventBuffer</parameter></entry>
-	    <entry><type>uintptr_t</type></entry>
-	    <entry>Pointer to buffer containing X event - decode using
-	      structures in
-	      <<ulink url="http://cgit.freedesktop.org/xorg/proto/xproto/tree/Xproto.h"><filename class="headerfile">X11/Xproto.h</filename></ulink>>
-	      and similar headers for each extension</entry>
-	  </row>
-	  <row>
-	    <entry><parameter>eventCode</parameter></entry>
-	    <entry><type>uint8_t</type></entry>
-	    <entry>Event number of X event</entry>
-	  </row>
-	  <row>
-	    <entry><parameter>resourceId</parameter></entry>
-	    <entry><type>uint32_t</type></entry>
-	    <entry>X resource id (XID)</entry>
-	  </row>
-	  <row>
-	    <entry><parameter>resourceTypeId</parameter></entry>
-	    <entry><type>uint32_t</type></entry>
-	    <entry>Resource type id</entry>
-	  </row>
-	  <row>
-	    <entry><parameter>resourceTypeName</parameter></entry>
-	    <entry><type>string</type></entry>
-	    <entry>String representing X resource type
-		(<literal>"PIXMAP"</literal>, etc.)</entry>
-	  </row>
-	  <row>
-	    <entry><parameter>resourceValue</parameter></entry>
-	    <entry><type>uintptr_t</type></entry>
-	    <entry>Pointer to data for X resource</entry>
-	  </row>
-	  <row>
-	    <entry><parameter>resultCode</parameter></entry>
-	    <entry><type>int</type></entry>
-	    <entry>Integer code representing result status of request</entry>
-	  </row>
-	  <row>
-	    <entry><parameter>requestBuffer</parameter></entry>
-	    <entry><type>uintptr_t</type></entry>
-	    <entry>Pointer to buffer containing X request - decode using
-	      structures in
-	      <<ulink url="http://cgit.freedesktop.org/xorg/proto/xproto/tree/Xproto.h"><filename class="headerfile">X11/Xproto.h</filename></ulink>>
-	      and similar headers for each extension</entry>
-	  </row>
-	  <row>
-	    <entry><parameter>requestCode</parameter></entry>
-	    <entry><type>uint8_t</type></entry>
-	    <entry>Request number of X request or Extension</entry>
-	  </row>
-	  <row>
-	    <entry><parameter>requestName</parameter></entry>
-	    <entry><type>string</type></entry>
-	    <entry>Name of X request or Extension</entry>
-	  </row>
-	  <row>
-	    <entry><parameter>requestLength</parameter></entry>
-	    <entry><type>uint16_t</type></entry>
-	    <entry>Length of X request</entry>
-	  </row>
-	  <row>
-	    <entry><parameter>sequenceNumber</parameter></entry>
-	    <entry><type>uint32_t</type></entry>
-	    <entry>Number of X request in in this connection</entry>
-	  </row>
-	</tbody>
-      </tgroup>
-    </table>
-    </para>
-  </sect1>
-
-  <sect1 id="examples">
-    <title>Examples</title>
-
-    <example>
-      <title>Counting requests by request name</title>
-
-      <para>
-	This script simply increments a counter for each different request
-	made, and when you exit the script (such as by hitting
-	<keycombo action='simul'><keycap>Control</keycap><keycap>C</keycap>
-	</keycombo>) prints the counts.
-
-	<programlisting>
-#!/usr/sbin/dtrace -s
-
-Xserver*:::request-start
-{
-    @counts[copyinstr(arg0)] = count();
-}
-	</programlisting>
-
-	The output from a short run may appear as:
-	<screen>
-  QueryPointer                                                      1
-  CreatePixmap                                                      2
-  FreePixmap                                                        2
-  PutImage                                                          2
-  ChangeGC                                                         10
-  CopyArea                                                         10
-  CreateGC                                                         14
-  FreeGC                                                           14
-  RENDER                                                           28
-  SetClipRectangles                                                40
-	</screen>
-      </para>
-
-      <para>
-	This can be rewritten slightly to cache the string containing the name
-	of the request since it will be reused many times, instead of copying
-	it over and over from the kernel:
-
-	<programlisting>
-#!/usr/sbin/dtrace -s
-
-string Xrequest[uintptr_t];
-
-Xserver*:::request-start
-/Xrequest[arg0] == ""/
-{
-    Xrequest[arg0] = copyinstr(arg0);
-}
-
-Xserver*:::request-start
-{
-    @counts[Xrequest[arg0]] = count();
-}
-	</programlisting>
-      </para>
-    </example>
-
-    <example>
-      <title>Get average CPU time per request</title>
-
-      <para>This script records the CPU time used between the probes at
-	the start and end of each request and aggregates it per request type.
-
-	<programlisting>
-#!/usr/sbin/dtrace -s
-
-Xserver*:::request-start
-{
-    reqstart = vtimestamp;
-}
-
-Xserver*:::request-done
-{
-    @times[copyinstr(arg0)] = avg(vtimestamp - reqstart);
-}
-	</programlisting>
-
-	The output from a sample run might look like:
-
-	<screen>
-  ChangeGC                                                        889
-  MapWindow                                                       907
-  SetClipRectangles                                              1319
-  PolyPoint                                                      1413
-  PolySegment                                                    1434
-  PolyRectangle                                                  1828
-  FreeCursor                                                     1895
-  FreeGC                                                         1950
-  CreateGC                                                       2244
-  FreePixmap                                                     2246
-  GetInputFocus                                                  2249
-  TranslateCoords                                                8508
-  QueryTree                                                      8846
-  GetGeometry                                                    9948
-  CreatePixmap                                                  12111
-  AllowEvents                                                   14090
-  GrabServer                                                    14791
-  MIT-SCREEN-SAVER                                              16747
-  ConfigureWindow                                               22917
-  SetInputFocus                                                 28521
-  PutImage                                                     240841
-
-	</screen>
-      </para>
-    </example>
-
-    <example>
-      <title>Monitoring clients that connect and disconnect</title>
-
-      <para>
-	This script simply prints information about each client that
-	connects or disconnects from the server while it is running.
-	Since the provider is specified as <code>Xserver$1</code> instead
-	of <code>Xserver*</code> like previous examples, it won't monitor
-	all Xserver processes running on the machine, but instead expects
-	the process id of the X server to monitor to be specified as the
-	argument to the script.
-
-	<programlisting>
-#!/usr/sbin/dtrace -s
-
-Xserver$1:::client-connect
-{
-	printf("** Client Connect: id %d\n", arg0);
-}
-
-Xserver$1:::client-auth
-{
-	printf("** Client auth'ed: id %d => %s pid %d\n",
-		arg0, copyinstr(arg1), arg2);
-}
-
-Xserver$1:::client-disconnect
-{
-	printf("** Client Disconnect: id %d\n", arg0);
-}
-	</programlisting>
-
-	A sample run:
-
-	<screen>
-<prompt>#</prompt> <userinput>./foo.d 5790</userinput>
-<computeroutput>dtrace: script './foo.d' matched 4 probes
-CPU     ID                    FUNCTION:NAME
-  0  15774 CloseDownClient:client-disconnect ** Client Disconnect: id 65
-
-  2  15774 CloseDownClient:client-disconnect ** Client Disconnect: id 64
-
-  0  15773 EstablishNewConnections:client-connect ** Client Connect: id 64
-
-  0  15772            AuthAudit:client-auth ** Client auth'ed: id 64 => local host pid 2034
-
-  0  15773 EstablishNewConnections:client-connect ** Client Connect: id 65
-
-  0  15772            AuthAudit:client-auth ** Client auth'ed: id 65 => local host pid 2034
-
-  0  15774 CloseDownClient:client-disconnect ** Client Disconnect: id 64
-	  </computeroutput>
-	</screen>
-
-      </para>
-    </example>
-
-    <example>
-      <title>Monitoring clients creating Pixmaps</title>
-
-      <para>
-	This script can be used to determine which clients are creating
-	pixmaps in the X server, printing information about each client
-	as it connects to help trace it back to the program on the other
-	end of the X connection.
-
-	<programlisting>
-#!/usr/sbin/dtrace -qs
-
-string Xrequest[uintptr_t];
-string Xrestype[uintptr_t];
-
-Xserver$1:::request-start
-/Xrequest[arg0] == ""/
-{
-	Xrequest[arg0] = copyinstr(arg0);
-}
-
-Xserver$1:::resource-alloc
-/arg3 != 0 && Xrestype[arg3] == ""/
-{
-	Xrestype[arg3] = copyinstr(arg3);
-}
-
-
-Xserver$1:::request-start
-/Xrequest[arg0] == "X_CreatePixmap"/
-{
-	printf("-> %s: client %d\n", Xrequest[arg0], arg3);
-}
-
-Xserver$1:::request-done
-/Xrequest[arg0] == "X_CreatePixmap"/
-{
-	printf("<- %s: client %d\n", Xrequest[arg0], arg3);
-}
-
-Xserver$1:::resource-alloc
-/Xrestype[arg3] == "PIXMAP"/
-{
-	printf("** Pixmap alloc: %08x\n", arg0);
-}
-
-
-Xserver$1:::resource-free
-/Xrestype[arg3] == "PIXMAP"/
-{
-	printf("** Pixmap free:  %08x\n", arg0);
-}
-
-Xserver$1:::client-connect
-{
-	printf("** Client Connect: id %d\n", arg0);
-}
-
-Xserver$1:::client-auth
-{
-	printf("** Client auth'ed: id %d => %s pid %d\n",
-		arg0, copyinstr(arg1), arg2);
-}
-
-Xserver$1:::client-disconnect
-{
-	printf("** Client Disconnect: id %d\n", arg0);
-}
-	</programlisting>
-
-	Sample output from a run of this script:
-	<screen><computeroutput>
-** Client Connect: id 17
-** Client auth'ed: id 17 => local host pid 20273
--> X_CreatePixmap: client 17
-** Pixmap alloc: 02200009
-<- X_CreatePixmap: client 17
--> X_CreatePixmap: client 15
-** Pixmap alloc: 01e00180
-<- X_CreatePixmap: client 15
--> X_CreatePixmap: client 15
-** Pixmap alloc: 01e00181
-<- X_CreatePixmap: client 15
--> X_CreatePixmap: client 14
-** Pixmap alloc: 01c004c8
-<- X_CreatePixmap: client 14
-** Pixmap free:  02200009
-** Client Disconnect: id 17
-** Pixmap free:  01e00180
-** Pixmap free:  01e00181
-	  </computeroutput></screen>
-
-      </para>
-
-    </example>
-
-
-  </sect1>
-
-</article>
-
diff --git a/docbook.am b/docbook.am
new file mode 100644
index 0000000..50a542e
--- /dev/null
+++ b/docbook.am
@@ -0,0 +1,96 @@
+#
+# Generate output formats for a single DocBook/XML with/without chapters
+#
+# Variables set by the calling Makefile:
+# shelfdir: the location where the docs/specs are installed. Typically $(docdir)
+# docbook:  the main DocBook/XML file, no chapters, appendix or image files
+# chapters: all files pulled in by an XInclude statement and images.
+#
+
+#
+# This makefile is intended for Users Documentation and Functional Specifications.
+# Do not use for Developer Documentation which is not installed and does not require olink.
+# Refer to http://www.x.org/releases/X11R7.6/doc/xorg-docs/ReleaseNotes.html#id2584393
+# for an explanation on documents classification.
+#
+
+# DocBook/XML generated output formats to be installed
+shelf_DATA =
+
+# DocBook/XML file with chapters, appendix and images it includes
+dist_shelf_DATA = $(docbook) $(chapters)
+
+#
+# Generate DocBook/XML output formats with or without stylesheets
+#
+
+# Stylesheets are available if the package xorg-sgml-doctools is installed
+if HAVE_STYLESHEETS
+
+# The location where all cross reference databases are installed
+sgmldbsdir = $(XORG_SGML_PATH)/X11/dbs
+masterdb = "$(sgmldbsdir)/masterdb$(suffix $@).xml"
+XMLTO_FLAGS =							\
+	--searchpath "$(XORG_SGML_PATH)/X11"			\
+	--searchpath "$(abs_top_builddir)/doc/xml"		\
+	--stringparam target.database.document=$(masterdb)	\
+	--stringparam current.docid="$(<:.xml=)"		\
+	--stringparam collect.xref.targets="no"
+
+XMLTO_XHTML_FLAGS = \
+	-x $(STYLESHEET_SRCDIR)/xorg-xhtml.xsl \
+	--stringparam html.stylesheet=$(STYLESHEET_SRCDIR)/xorg.css
+
+XMLTO_FO_FLAGS = \
+	-x $(STYLESHEET_SRCDIR)/xorg-fo.xsl
+endif HAVE_STYLESHEETS
+
+shelf_DATA += $(docbook:.xml=.html)
+%.html: %.xml  $(chapters)
+	$(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) $(XMLTO_XHTML_FLAGS) xhtml-nochunks $<
+
+if HAVE_FOP
+shelf_DATA += $(docbook:.xml=.pdf) $(docbook:.xml=.ps)
+%.pdf: %.xml $(chapters)
+	$(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) $(XMLTO_FO_FLAGS) --with-fop pdf $<
+%.ps: %.xml $(chapters)
+	$(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) $(XMLTO_FO_FLAGS) --with-fop ps $<
+endif HAVE_FOP
+
+if HAVE_XMLTO_TEXT
+shelf_DATA += $(docbook:.xml=.txt)
+%.txt: %.xml $(chapters)
+	$(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) $(XMLTO_XHTML_FLAGS) txt $<
+endif HAVE_XMLTO_TEXT
+
+#
+# Generate documents cross-reference target databases
+#
+
+# This is only possible if the xorg-sgml-doctools package is installed
+if HAVE_STYLESHEETS
+if HAVE_XSLTPROC
+
+# DocBook/XML generated document cross-reference database
+sgmldbs_DATA = $(docbook:.xml=.html.db) $(docbook:.xml=.fo.db)
+
+# Generate DocBook/XML document cross-reference database
+# Flags for the XSL Transformation processor generating xref target databases
+XSLTPROC_FLAGS =					\
+	--path "$(XORG_SGML_PATH)/X11"			\
+	--stringparam targets.filename "$@"		\
+	--stringparam collect.xref.targets "only"	\
+	--nonet --xinclude
+
+%.html.db: %.xml  $(chapters)
+	$(AM_V_GEN)$(XSLTPROC) $(XSLTPROC_FLAGS) \
+	http://docbook.sourceforge.net/release/xsl/current/xhtml/docbook.xsl $<
+
+%.fo.db: %.xml $(chapters)
+	$(AM_V_GEN)$(XSLTPROC) $(XSLTPROC_FLAGS) \
+	http://docbook.sourceforge.net/release/xsl/current/fo/docbook.xsl $<
+
+endif HAVE_XSLTPROC
+endif HAVE_STYLESHEETS
+
+CLEANFILES = $(shelf_DATA) $(sgmldbs_DATA)
commit 221507e3bf6fcaa4a4c2e1bc264a1f806b4362c0
Author: Gaetan Nadon <memsize at videotron.ca>
Date:   Thu Apr 28 21:16:13 2011 -0400

    man: relocate manual pages in the man subdir outside doc
    
    The convention is to have the manual pages in a man subdir
    which is not under a doc dir. The doc dir contains users docs.
    This will move man pages out of the way for upcoming DocBook patches.
    
    Reviewed-by Jeremy Huddleston <jeremyhu at apple.com>
    Signed-off-by: Gaetan Nadon <memsize at videotron.ca>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/Makefile.am b/Makefile.am
index 62c8d95..cea140b 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -19,6 +19,7 @@ endif
 
 SUBDIRS = \
 	doc \
+	man \
 	include \
 	dix  \
 	fb \
@@ -68,6 +69,7 @@ dist-hook: ChangeLog INSTALL
 
 DIST_SUBDIRS = \
 	doc \
+	man \
 	include \
 	dix  \
 	fb \
diff --git a/configure.ac b/configure.ac
index c6b16b5..e23274c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2151,10 +2151,10 @@ damageext/Makefile
 dbe/Makefile
 dix/Makefile
 doc/Makefile
-doc/man/Makefile
 doc/xml/Makefile
 doc/xml/dtrace/Makefile
 doc/xml/xserver.ent
+man/Makefile
 fb/Makefile
 record/Makefile
 config/Makefile
diff --git a/doc/Makefile.am b/doc/Makefile.am
index 4c08b6f..b9015bc 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -1,3 +1,3 @@
-SUBDIRS = man xml
+SUBDIRS = xml
 
 dist_noinst_DATA = smartsched
diff --git a/doc/man/Makefile.am b/doc/man/Makefile.am
deleted file mode 100644
index 71d7049..0000000
--- a/doc/man/Makefile.am
+++ /dev/null
@@ -1,6 +0,0 @@
-# Xserver.man covers options generic to all X servers built in this tree
-# (i.e. those handled in the os/utils.c options processing instead of in
-#  the DDX-level options processing)
-
-include $(top_srcdir)/manpages.am
-appman_PRE = Xserver.man
diff --git a/doc/man/Xserver.man b/doc/man/Xserver.man
deleted file mode 100644
index b725949..0000000
--- a/doc/man/Xserver.man
+++ /dev/null
@@ -1,584 +0,0 @@
-.\" $Xorg: Xserver.man,v 1.4 2001/02/09 02:04:07 xorgcvs Exp $
-.\" $XdotOrg: xserver/xorg/doc/Xserver.man.pre,v 1.4 2005/12/23 20:11:12 alanc Exp $
-.\" Copyright 1984 - 1991, 1993, 1994, 1998  The Open Group
-.\"
-.\" Permission to use, copy, modify, distribute, and sell this software and its
-.\" documentation for any purpose is hereby granted without fee, provided that
-.\" the above copyright notice appear in all copies and that both that
-.\" copyright notice and this permission notice appear in supporting
-.\" documentation.
-.\"
-.\" The above copyright notice and this permission notice shall be included
-.\" in all copies or substantial portions of the Software.
-.\"
-.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-.\" IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
-.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-.\" OTHER DEALINGS IN THE SOFTWARE.
-.\"
-.\" Except as contained in this notice, the name of The Open Group shall
-.\" not be used in advertising or otherwise to promote the sale, use or
-.\" other dealings in this Software without prior written authorization
-.\" from The Open Group.
-.\" $XFree86: xc/programs/Xserver/Xserver.man,v 3.31 2004/01/10 22:27:46 dawes Exp $
-.\" shorthand for double quote that works everywhere.
-.ds q \N'34'
-.TH XSERVER 1 __xorgversion__
-.SH NAME
-Xserver \- X Window System display server
-.SH SYNOPSIS
-.B X
-[option ...]
-.SH DESCRIPTION
-.I X
-is the generic name for the X Window System display server.  It is
-frequently a link or a copy of the appropriate server binary for
-driving the most frequently used server on a given machine.
-.SH "STARTING THE SERVER"
-The X server is usually started from the X Display Manager program
-\fIxdm\fP(1) or a similar display manager program.
-This utility is run from the system boot files and takes care of keeping
-the server running, prompting for usernames and passwords, and starting up
-the user sessions.
-.PP
-Installations that run more than one window system may need to use the
-\fIxinit\fP(1) utility instead of a display manager.  However, \fIxinit\fP is
-to be considered a tool for building startup scripts and is not
-intended for use by end users.  Site administrators are \fBstrongly\fP
-urged to use a display manager, or build other interfaces for novice users.
-.PP
-The X server may also be started directly by the user, though this
-method is usually reserved for testing and is not recommended for
-normal operation.  On some platforms, the user must have special
-permission to start the X server, often because access to certain
-devices (e.g. \fI/dev/mouse\fP) is restricted.
-.PP
-When the X server starts up, it typically takes over the display.  If
-you are running on a workstation whose console is the display, you may
-not be able to log into the console while the server is running.
-.SH OPTIONS
-Many X servers have device-specific command line options.  See the manual
-pages for the individual servers for more details; a list of
-server-specific manual pages is provided in the SEE ALSO section below.
-.PP
-All of the X servers accept the command line options described below.
-Some X servers may have alternative ways of providing the parameters
-described here, but the values provided via the command line options
-should override values specified via other mechanisms.
-.TP 8
-.B :\fIdisplaynumber\fP
-The X server runs as the given \fIdisplaynumber\fP, which by default is 0.
-If multiple X servers are to run simultaneously on a host, each must have
-a unique display number.  See the DISPLAY
-NAMES section of the \fIX\fP(__miscmansuffix__) manual page to learn how to
-specify which display number clients should try to use.
-.TP 8
-.B \-a \fInumber\fP
-sets pointer acceleration (i.e. the ratio of how much is reported to how much
-the user actually moved the pointer).
-.TP 8
-.B \-ac
-disables host-based access control mechanisms.  Enables access by any host,
-and permits any host to modify the access control list.
-Use with extreme caution.
-This option exists primarily for running test suites remotely.
-.TP 8
-.B \-audit \fIlevel\fP
-sets the audit trail level.  The default level is 1, meaning only connection
-rejections are reported.  Level 2 additionally reports all successful
-connections and disconnects.  Level 4 enables messages from the
-SECURITY extension, if present, including generation and revocation of
-authorizations and violations of the security policy.
-Level 0 turns off the audit trail.
-Audit lines are sent as standard error output.
-.TP 8
-.B \-auth \fIauthorization-file\fP
-specifies a file which contains a collection of authorization records used
-to authenticate access.  See also the \fIxdm\fP(1) and
-\fIXsecurity\fP(__miscmansuffix__) manual pages.
-.TP 8
-.B \-br
-sets the default root window to solid black instead of the standard root weave
-pattern.   This is the default unless -retro or -wr is specified.
-.TP 8
-.B \-bs
-disables backing store support on all screens.
-.TP 8
-.B \-c
-turns off key-click.
-.TP 8
-.B c \fIvolume\fP
-sets key-click volume (allowable range: 0-100).
-.TP 8
-.B \-cc \fIclass\fP
-sets the visual class for the root window of color screens.
-The class numbers are as specified in the X protocol.
-Not obeyed by all servers.
-.TP 8
-.B \-core
-causes the server to generate a core dump on fatal errors.
-.TP 8
-.B \-deferglyphs \fIwhichfonts\fP
-specifies the types of fonts for which the server should attempt to use
-deferred glyph loading.  \fIwhichfonts\fP can be all (all fonts),
-none (no fonts), or 16 (16 bit fonts only).
-.TP 8
-.B \-dpi \fIresolution\fP
-sets the resolution for all screens, in dots per inch.
-To be used when the server cannot determine the screen size(s) from the
-hardware.
-.TP 8
-.B dpms
-enables DPMS (display power management services), where supported.  The
-default state is platform and configuration specific.
-.TP 8
-.B \-dpms
-disables DPMS (display power management services).  The default state
-is platform and configuration specific.
-.TP 8
-.BI \-extension extensionName
-disables named extension.   If an unknown extension name is specified,
-a list of accepted extension names is printed.
-.TP 8
-.BI \+extension extensionName
-enables named extension.   If an unknown extension name is specified,
-a list of accepted extension names is printed.
-.TP 8
-.B \-f \fIvolume\fP
-sets feep (bell) volume (allowable range: 0-100).
-.TP 8
-.B \-fc \fIcursorFont\fP
-sets default cursor font.
-.TP 8
-.B \-fn \fIfont\fP
-sets the default font.
-.TP 8
-.B \-fp \fIfontPath\fP
-sets the search path for fonts.  This path is a comma separated list
-of directories which the X server searches for font databases.
-See the FONTS section of this manual page for more information and the default
-list.
-.TP 8
-.B \-help
-prints a usage message.
-.TP 8
-.B \-I
-causes all remaining command line arguments to be ignored.
-.TP 8
-.B \-maxbigreqsize \fIsize\fP
-sets the maximum big request to
-.I size
-MB.
-.TP 8
-.B \-nocursor
-disable the display of the pointer cursor.
-.TP 8
-.B \-nolisten \fItrans-type\fP
-disables a transport type.  For example, TCP/IP connections can be disabled
-with
-.BR "\-nolisten tcp" .
-This option may be issued multiple times to disable listening to different
-transport types.
-.TP 8
-.B \-noreset
-prevents a server reset when the last client connection is closed.  This
-overrides a previous
-.B \-terminate
-command line option.
-.TP 8
-.B \-p \fIminutes\fP
-sets screen-saver pattern cycle time in minutes.
-.TP 8
-.B \-pn
-permits the server to continue running if it fails to establish all of
-its well-known sockets (connection points for clients), but
-establishes at least one.  This option is set by default.
-.TP 8
-.B \-nopn
-causes the server to exit if it fails to establish all of its well-known
-sockets (connection points for clients).
-.TP 8
-.B \-r
-turns off auto-repeat.
-.TP 8
-.B r
-turns on auto-repeat.
-.TP 8
-.B -retro
-starts the stipple with the classic stipple and cursor visible.  The default
-is to start with a black root window, and to suppress display of the cursor
-until the first time an application calls XDefineCursor().  For the Xorg
-server, this also sets the default for the DontZap option to FALSE.  For
-kdrive servers, this implies -zap.
-.TP 8
-.B \-s \fIminutes\fP
-sets screen-saver timeout time in minutes.
-.TP 8
-.B \-su
-disables save under support on all screens.
-.TP 8
-.B \-t \fInumber\fP
-sets pointer acceleration threshold in pixels (i.e. after how many pixels
-pointer acceleration should take effect).
-.TP 8
-.B \-terminate
-causes the server to terminate at server reset, instead of continuing to run.
-This overrides a previous
-.B \-noreset
-command line option.
-.TP 8
-.B \-to \fIseconds\fP
-sets default connection timeout in seconds.
-.TP 8
-.B \-tst
-disables all testing extensions (e.g., XTEST, XTrap, XTestExtension1, RECORD).
-.TP 8
-.B tty\fIxx\fP
-ignored, for servers started the ancient way (from init).
-.TP 8
-.B v
-sets video-off screen-saver preference.
-.TP 8
-.B \-v
-sets video-on screen-saver preference.
-.TP 8
-.B \-wm
-forces the default backing-store of all windows to be WhenMapped.  This
-is a backdoor way of getting backing-store to apply to all windows.
-Although all mapped windows will have backing store, the backing store
-attribute value reported by the server for a window will be the last
-value established by a client.  If it has never been set by a client,
-the server will report the default value, NotUseful.  This behavior is
-required by the X protocol, which allows the server to exceed the
-client's backing store expectations but does not provide a way to tell
-the client that it is doing so.
-.TP 8
-.B \-wr
-sets the default root window to solid white instead of the standard root weave
-pattern.
-.TP 8
-.B \-x \fIextension\fP
-loads the specified extension at init.
-This is a no-op for most implementations.
-.TP 8
-.B [+-]xinerama
-enables(+) or disables(-) the XINERAMA extension.  The default state is
-platform and configuration specific.
-.SH SERVER DEPENDENT OPTIONS
-Some X servers accept the following options:
-.TP 8
-.B \-ld \fIkilobytes\fP
-sets the data space limit of the server to the specified number of kilobytes.
-A value of zero makes the data size as large as possible.  The default value
-of \-1 leaves the data space limit unchanged.
-.TP 8
-.B \-lf \fIfiles\fP
-sets the number-of-open-files limit of the server to the specified number.
-A value of zero makes the limit as large as possible.  The default value
-of \-1 leaves the limit unchanged.
-.TP 8
-.B \-ls \fIkilobytes\fP
-sets the stack space limit of the server to the specified number of kilobytes.
-A value of zero makes the stack size as large as possible.  The default value
-of \-1 leaves the stack space limit unchanged.
-.TP 8
-.B \-render
-.BR default | mono | gray | color
-sets the color allocation policy that will be used by the render extension.
-.RS 8
-.TP 8
-.I default
-selects the default policy defined for the display depth of the X
-server.
-.TP 8
-.I mono
-don't use any color cell.
-.TP 8
-.I gray
-use a gray map of 13 color cells for the X render extension.
-.TP 8
-.I color
-use a color cube of at most 4*4*4 colors (that is 64 color cells).
-.RE
-.TP 8
-.B \-dumbSched
-disables smart scheduling on platforms that support the smart scheduler.
-.TP
-.B \-schedInterval \fIinterval\fP
-sets the smart scheduler's scheduling interval to
-.I interval
-milliseconds.
-.SH XDMCP OPTIONS
-X servers that support XDMCP have the following options.
-See the \fIX Display Manager Control Protocol\fP specification for more
-information.
-.TP 8
-.B \-query \fIhostname\fP
-enables XDMCP and sends Query packets to the specified
-.IR hostname .
-.TP 8
-.B \-broadcast
-enable XDMCP and broadcasts BroadcastQuery packets to the network.  The
-first responding display manager will be chosen for the session.
-.TP 8
-.B \-multicast [\fIaddress\fP [\fIhop count\fP]]
-Enable XDMCP and multicast BroadcastQuery packets to the  network.
-The first responding display manager is chosen for the session.  If an
-address is specified, the multicast is sent to that address.  If no
-address is specified, the multicast is sent to the default XDMCP IPv6
-multicast group.  If a hop count is specified, it is used as the maximum
-hop count for the multicast.  If no hop count is specified, the multicast
-is set to a maximum of 1 hop, to prevent the multicast from being routed
-beyond the local network.
-.TP 8
-.B \-indirect \fIhostname\fP
-enables XDMCP and send IndirectQuery packets to the specified
-.IR hostname .
-.TP 8
-.B \-port \fIport-number\fP
-uses the specified \fIport-number\fP for XDMCP packets, instead of the
-default.  This option must be specified before any \-query, \-broadcast,
-\-multicast, or \-indirect options.
-.TP 8
-.B \-from \fIlocal-address\fP
-specifies the local address to connect from (useful if the connecting host
-has multiple network interfaces).  The \fIlocal-address\fP may be expressed
-in any form acceptable to the host platform's \fIgethostbyname\fP(3)
-implementation.
-.TP 8
-.B \-once
-causes the server to terminate (rather than reset) when the XDMCP session
-ends.
-.TP 8
-.B \-class \fIdisplay-class\fP
-XDMCP has an additional display qualifier used in resource lookup for
-display-specific options.  This option sets that value, by default it
-is "MIT-Unspecified" (not a very useful value).
-.TP 8
-.B \-cookie \fIxdm-auth-bits\fP
-When testing XDM-AUTHENTICATION-1, a private key is shared between the
-server and the manager.  This option sets the value of that private
-data (not that it is very private, being on the command line!).
-.TP 8
-.B \-displayID \fIdisplay-id\fP
-Yet another XDMCP specific value, this one allows the display manager to
-identify each display so that it can locate the shared key.
-.SH XKEYBOARD OPTIONS
-X servers that support the XKEYBOARD (a.k.a. \*qXKB\*q) extension accept the
-following options.  All layout files specified on the command line must be
-located in the XKB base directory or a subdirectory, and specified as the
-relative path from the XKB base directory.  The default XKB base directory is
-.IR __projectroot__/lib/X11/xkb .
-.TP 8
-.BR [+-]accessx " [ \fItimeout\fP [ \fItimeout_mask\fP [ \fIfeedback\fP [ \fIoptions_mask\fP ] ] ] ]"
-enables(+) or disables(-) AccessX key sequences.
-.TP 8
-.B \-xkbdir \fIdirectory\fP
-base directory for keyboard layout files.  This option is not available
-for setuid X servers (i.e., when the X server's real and effective uids
-are different).
-.TP 8
-.B \-ardelay \fImilliseconds\fP
-sets the autorepeat delay (length of time in milliseconds that a key must
-be depressed before autorepeat starts).
-.TP 8
-.B \-arinterval \fImilliseconds\fP
-sets the autorepeat interval (length of time in milliseconds that should
-elapse between autorepeat-generated keystrokes).
-.TP 8
-.B \-xkbmap \fIfilename\fP
-loads keyboard description in \fIfilename\fP on server startup.
-.SH "NETWORK CONNECTIONS"
-The X server supports client connections via a platform-dependent subset of
-the following transport types: TCP\/IP, Unix Domain sockets, DECnet,
-and several varieties of SVR4 local connections.  See the DISPLAY
-NAMES section of the \fIX\fP(__miscmansuffix__) manual page to learn how to
-specify which transport type clients should try to use.
-.SH GRANTING ACCESS
-The X server implements a platform-dependent subset of the following
-authorization protocols: MIT-MAGIC-COOKIE-1, XDM-AUTHORIZATION-1,
-XDM-AUTHORIZATION-2, SUN-DES-1, and MIT-KERBEROS-5.  See the
-\fIXsecurity\fP(__miscmansuffix__) manual page for information on the
-operation of these protocols.
-.PP
-Authorization data required by the above protocols is passed to the
-server in a private file named with the \fB\-auth\fP command line
-option.  Each time the server is about to accept the first connection
-after a reset (or when the server is starting), it reads this file.
-If this file contains any authorization records, the local host is not
-automatically allowed access to the server, and only clients which
-send one of the authorization records contained in the file in the
-connection setup information will be allowed access.  See the
-\fIXau\fP manual page for a description of the binary format of this
-file.  See \fIxauth\fP(1) for maintenance of this file, and distribution
-of its contents to remote hosts.
-.PP
-The X server also uses a host-based access control list for deciding
-whether or not to accept connections from clients on a particular machine.
-If no other authorization mechanism is being used,
-this list initially consists of the host on which the server is running as
-well as any machines listed in the file \fI/etc/X\fBn\fI.hosts\fR, where
-\fBn\fP is the display number of the server.  Each line of the file should
-contain either an Internet hostname (e.g. expo.lcs.mit.edu) or a DECnet
-hostname in double colon format (e.g. hydra::) or a complete name in the format
-\fIfamily\fP:\fIname\fP as described in the \fIxhost\fP(1) manual page.
-There should be no leading or trailing spaces on any lines.  For example:
-.sp
-.in +8
-.nf
-joesworkstation
-corporate.company.com
-star::
-inet:bigcpu
-local:
-.fi
-.in -8
-.PP
-Users can add or remove hosts from this list and enable or disable access
-control using the \fIxhost\fP command from the same machine as the server.
-.PP
-If the X FireWall Proxy (\fIxfwp\fP) is being used without a sitepolicy,
-host-based authorization must be turned on for clients to be able to
-connect to the X server via the \fIxfwp\fP.  If \fIxfwp\fP is run without
-a configuration file and thus no sitepolicy is defined, if \fIxfwp\fP
-is using an X server where xhost + has been run to turn off host-based
-authorization checks, when a client tries to connect to this X server
-via \fIxfwp\fP, the X server will deny the connection.  See \fIxfwp\fP(1)
-for more information about this proxy.
-.PP
-The X protocol intrinsically does not have any notion of window operation
-permissions or place any restrictions on what a client can do; if a program can
-connect to a display, it has full run of the screen.
-X servers that support the SECURITY extension fare better because clients
-can be designated untrusted via the authorization they use to connect; see
-the \fIxauth\fP(1) manual page for details.  Restrictions are imposed
-on untrusted clients that curtail the mischief they can do.  See the SECURITY
-extension specification for a complete list of these restrictions.
-.PP
-Sites that have better
-authentication and authorization systems might wish to make
-use of the hooks in the libraries and the server to provide additional
-security models.
-.SH SIGNALS
-The X server attaches special meaning to the following signals:
-.TP 8
-.I SIGHUP
-This signal causes the server to close all existing connections, free all
-resources, and restore all defaults.  It is sent by the display manager
-whenever the main user's main application (usually an \fIxterm\fP or window
-manager) exits to force the server to clean up and prepare for the next
-user.
-.TP 8
-.I SIGTERM
-This signal causes the server to exit cleanly.
-.TP 8
-.I SIGUSR1
-This signal is used quite differently from either of the above.  When the
-server starts, it checks to see if it has inherited SIGUSR1 as SIG_IGN
-instead of the usual SIG_DFL.  In this case, the server sends a SIGUSR1 to
-its parent process after it has set up the various connection schemes.
-\fIXdm\fP uses this feature to recognize when connecting to the server
-is possible.
-.SH FONTS
-The X server can obtain fonts from directories and/or from font servers.
-The list of directories and font servers
-the X server uses when trying to open a font is controlled
-by the \fIfont path\fP.
-.LP
-The default font path is
-__default_font_path__ .
-.LP
-A special kind of directory can be specified using the \fBcatalogue\fP:
-prefix. Directories specified this way can contain symlinks pointing to the
-real font directories. See the FONTPATH.D section for details.
-.LP
-The font path can be set with the \fB\-fp\fP option or by \fIxset\fP(1)
-after the server has started.
-.SH "FONTPATH.D"
-You can specify a special kind of font path in the form \fBcatalogue:<dir>\fR.
-The directory specified after the catalogue: prefix will be scanned for symlinks
-and each symlink destination will be added as a local fontfile FPE.
-.PP
-The symlink can be suffixed by attributes such as '\fBunscaled\fR', which
-will be passed through to the underlying fontfile FPE. The only exception is
-the newly introduced '\fBpri\fR' attribute, which will be used for ordering
-the font paths specified by the symlinks.
-
-An example configuration:
-
-.nf
-    75dpi:unscaled:pri=20 \-> /usr/share/X11/fonts/75dpi
-    ghostscript:pri=60 \-> /usr/share/fonts/default/ghostscript
-    misc:unscaled:pri=10 \-> /usr/share/X11/fonts/misc
-    type1:pri=40 \-> /usr/share/X11/fonts/Type1
-    type1:pri=50 \-> /usr/share/fonts/default/Type1
-.fi
-
-This will add /usr/share/X11/fonts/misc as the first FPE with the attribute
-'unscaled', second FPE will be /usr/share/X11/fonts/75dpi, also with
-the attribute unscaled etc. This is functionally equivalent to setting
-the following font path:
-
-.nf
-    /usr/share/X11/fonts/misc:unscaled,
-    /usr/share/X11/fonts/75dpi:unscaled,
-    /usr/share/X11/fonts/Type1,
-    /usr/share/fonts/default/Type1,
-    /usr/share/fonts/default/ghostscript
-.fi
-
-.SH FILES
-.TP 30
-.I /etc/X\fBn\fP.hosts
-Initial access control list for display number \fBn\fP
-.TP 30
-.IR __datadir__/fonts/X11/misc , __datadir__/fonts/X11/75dpi , __datadir__/fonts/X11/100dpi
-Bitmap font directories
-.TP 30
-.IR __datadir__/fonts/X11/TTF , __datadir__/fonts/X11/Type1
-Outline font directories
-.TP 30
-.I /tmp/.X11-unix/X\fBn\fP
-Unix domain socket for display number \fBn\fP
-.TP 30
-.I /usr/adm/X\fBn\fPmsgs
-Error log file for display number \fBn\fP if run from \fIinit\fP(__adminmansuffix__)
-.TP 30
-.I __projectroot__/lib/X11/xdm/xdm-errors
-Default error log file if the server is run from \fIxdm\fP(1)
-.SH "SEE ALSO"
-General information: \fIX\fP(__miscmansuffix__)
-.PP
-Protocols:
-.I "X Window System Protocol,"
-.I "The X Font Service Protocol,"
-.I "X Display Manager Control Protocol"
-.PP
-Fonts: \fIbdftopcf\fP(1), \fImkfontdir\fP(1), \fImkfontscale\fP(1),
-\fIxfs\fP(1), \fIxlsfonts\fP(1), \fIxfontsel\fP(1), \fIxfd\fP(1),
-.I "X Logical Font Description Conventions"
-.PP
-Security: \fIXsecurity\fP(__miscmansuffix__), \fIxauth\fP(1), \fIXau\fP(1),
-\fIxdm\fP(1), \fIxhost\fP(1), \fIxfwp\fP(1),
-.I "Security Extension Specification"
-.PP
-Starting the server: \fIstartx\fP(1), \fIxdm\fP(1), \fIxinit\fP(1)
-.PP
-Controlling the server once started: \fIxset\fP(1), \fIxsetroot\fP(1),
-\fIxhost\fP(1), \fIxinput\fP(1), \fIxrandr\fP(1)
-.PP
-Server-specific man pages:
-\fIXorg\fP(1), \fIXdmx\fP(1), \fIXephyr\fP(1), \fIXnest\fP(1),
-\fIXvfb\fP(1), \fIXquartz\fP(1), \fIXWin\fP(1).
-.PP
-Server internal documentation:
-.I "Definition of the Porting Layer for the X v11 Sample Server"
-.SH AUTHORS
-The sample server was originally written by Susan Angebranndt, Raymond
-Drewry, Philip Karlton, and Todd Newman, from Digital Equipment
-Corporation, with support from a large cast.  It has since been
-extensively rewritten by Keith Packard and Bob Scheifler, from MIT.
-Dave Wiggins took over post-R5 and made substantial improvements.
diff --git a/man/Makefile.am b/man/Makefile.am
new file mode 100644
index 0000000..71d7049
--- /dev/null
+++ b/man/Makefile.am
@@ -0,0 +1,6 @@
+# Xserver.man covers options generic to all X servers built in this tree
+# (i.e. those handled in the os/utils.c options processing instead of in
+#  the DDX-level options processing)
+
+include $(top_srcdir)/manpages.am
+appman_PRE = Xserver.man
diff --git a/man/Xserver.man b/man/Xserver.man
new file mode 100644
index 0000000..b725949
--- /dev/null
+++ b/man/Xserver.man
@@ -0,0 +1,584 @@
+.\" $Xorg: Xserver.man,v 1.4 2001/02/09 02:04:07 xorgcvs Exp $
+.\" $XdotOrg: xserver/xorg/doc/Xserver.man.pre,v 1.4 2005/12/23 20:11:12 alanc Exp $
+.\" Copyright 1984 - 1991, 1993, 1994, 1998  The Open Group
+.\"
+.\" Permission to use, copy, modify, distribute, and sell this software and its
+.\" documentation for any purpose is hereby granted without fee, provided that
+.\" the above copyright notice appear in all copies and that both that
+.\" copyright notice and this permission notice appear in supporting
+.\" documentation.
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of The Open Group shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from The Open Group.
+.\" $XFree86: xc/programs/Xserver/Xserver.man,v 3.31 2004/01/10 22:27:46 dawes Exp $
+.\" shorthand for double quote that works everywhere.
+.ds q \N'34'
+.TH XSERVER 1 __xorgversion__
+.SH NAME
+Xserver \- X Window System display server
+.SH SYNOPSIS
+.B X
+[option ...]
+.SH DESCRIPTION
+.I X
+is the generic name for the X Window System display server.  It is
+frequently a link or a copy of the appropriate server binary for
+driving the most frequently used server on a given machine.
+.SH "STARTING THE SERVER"
+The X server is usually started from the X Display Manager program
+\fIxdm\fP(1) or a similar display manager program.
+This utility is run from the system boot files and takes care of keeping
+the server running, prompting for usernames and passwords, and starting up
+the user sessions.
+.PP
+Installations that run more than one window system may need to use the
+\fIxinit\fP(1) utility instead of a display manager.  However, \fIxinit\fP is
+to be considered a tool for building startup scripts and is not
+intended for use by end users.  Site administrators are \fBstrongly\fP
+urged to use a display manager, or build other interfaces for novice users.
+.PP
+The X server may also be started directly by the user, though this
+method is usually reserved for testing and is not recommended for
+normal operation.  On some platforms, the user must have special
+permission to start the X server, often because access to certain
+devices (e.g. \fI/dev/mouse\fP) is restricted.
+.PP
+When the X server starts up, it typically takes over the display.  If
+you are running on a workstation whose console is the display, you may
+not be able to log into the console while the server is running.
+.SH OPTIONS
+Many X servers have device-specific command line options.  See the manual
+pages for the individual servers for more details; a list of
+server-specific manual pages is provided in the SEE ALSO section below.
+.PP
+All of the X servers accept the command line options described below.
+Some X servers may have alternative ways of providing the parameters
+described here, but the values provided via the command line options
+should override values specified via other mechanisms.
+.TP 8
+.B :\fIdisplaynumber\fP
+The X server runs as the given \fIdisplaynumber\fP, which by default is 0.
+If multiple X servers are to run simultaneously on a host, each must have
+a unique display number.  See the DISPLAY
+NAMES section of the \fIX\fP(__miscmansuffix__) manual page to learn how to
+specify which display number clients should try to use.
+.TP 8
+.B \-a \fInumber\fP
+sets pointer acceleration (i.e. the ratio of how much is reported to how much
+the user actually moved the pointer).
+.TP 8
+.B \-ac
+disables host-based access control mechanisms.  Enables access by any host,
+and permits any host to modify the access control list.
+Use with extreme caution.
+This option exists primarily for running test suites remotely.
+.TP 8
+.B \-audit \fIlevel\fP
+sets the audit trail level.  The default level is 1, meaning only connection
+rejections are reported.  Level 2 additionally reports all successful
+connections and disconnects.  Level 4 enables messages from the
+SECURITY extension, if present, including generation and revocation of
+authorizations and violations of the security policy.
+Level 0 turns off the audit trail.
+Audit lines are sent as standard error output.
+.TP 8
+.B \-auth \fIauthorization-file\fP
+specifies a file which contains a collection of authorization records used
+to authenticate access.  See also the \fIxdm\fP(1) and
+\fIXsecurity\fP(__miscmansuffix__) manual pages.
+.TP 8
+.B \-br
+sets the default root window to solid black instead of the standard root weave
+pattern.   This is the default unless -retro or -wr is specified.
+.TP 8
+.B \-bs
+disables backing store support on all screens.
+.TP 8
+.B \-c
+turns off key-click.
+.TP 8
+.B c \fIvolume\fP
+sets key-click volume (allowable range: 0-100).
+.TP 8
+.B \-cc \fIclass\fP
+sets the visual class for the root window of color screens.
+The class numbers are as specified in the X protocol.
+Not obeyed by all servers.
+.TP 8
+.B \-core
+causes the server to generate a core dump on fatal errors.
+.TP 8
+.B \-deferglyphs \fIwhichfonts\fP
+specifies the types of fonts for which the server should attempt to use
+deferred glyph loading.  \fIwhichfonts\fP can be all (all fonts),
+none (no fonts), or 16 (16 bit fonts only).
+.TP 8
+.B \-dpi \fIresolution\fP
+sets the resolution for all screens, in dots per inch.
+To be used when the server cannot determine the screen size(s) from the
+hardware.
+.TP 8
+.B dpms
+enables DPMS (display power management services), where supported.  The
+default state is platform and configuration specific.
+.TP 8
+.B \-dpms
+disables DPMS (display power management services).  The default state
+is platform and configuration specific.
+.TP 8
+.BI \-extension extensionName
+disables named extension.   If an unknown extension name is specified,
+a list of accepted extension names is printed.
+.TP 8
+.BI \+extension extensionName
+enables named extension.   If an unknown extension name is specified,
+a list of accepted extension names is printed.
+.TP 8
+.B \-f \fIvolume\fP
+sets feep (bell) volume (allowable range: 0-100).
+.TP 8
+.B \-fc \fIcursorFont\fP
+sets default cursor font.
+.TP 8
+.B \-fn \fIfont\fP
+sets the default font.
+.TP 8
+.B \-fp \fIfontPath\fP
+sets the search path for fonts.  This path is a comma separated list
+of directories which the X server searches for font databases.
+See the FONTS section of this manual page for more information and the default
+list.
+.TP 8
+.B \-help
+prints a usage message.
+.TP 8
+.B \-I
+causes all remaining command line arguments to be ignored.
+.TP 8
+.B \-maxbigreqsize \fIsize\fP
+sets the maximum big request to
+.I size
+MB.
+.TP 8
+.B \-nocursor
+disable the display of the pointer cursor.
+.TP 8
+.B \-nolisten \fItrans-type\fP
+disables a transport type.  For example, TCP/IP connections can be disabled
+with
+.BR "\-nolisten tcp" .
+This option may be issued multiple times to disable listening to different
+transport types.
+.TP 8
+.B \-noreset
+prevents a server reset when the last client connection is closed.  This
+overrides a previous
+.B \-terminate
+command line option.
+.TP 8
+.B \-p \fIminutes\fP
+sets screen-saver pattern cycle time in minutes.
+.TP 8
+.B \-pn
+permits the server to continue running if it fails to establish all of
+its well-known sockets (connection points for clients), but
+establishes at least one.  This option is set by default.
+.TP 8
+.B \-nopn
+causes the server to exit if it fails to establish all of its well-known
+sockets (connection points for clients).
+.TP 8
+.B \-r
+turns off auto-repeat.
+.TP 8
+.B r
+turns on auto-repeat.
+.TP 8
+.B -retro
+starts the stipple with the classic stipple and cursor visible.  The default
+is to start with a black root window, and to suppress display of the cursor
+until the first time an application calls XDefineCursor().  For the Xorg
+server, this also sets the default for the DontZap option to FALSE.  For
+kdrive servers, this implies -zap.
+.TP 8
+.B \-s \fIminutes\fP
+sets screen-saver timeout time in minutes.
+.TP 8
+.B \-su
+disables save under support on all screens.
+.TP 8
+.B \-t \fInumber\fP
+sets pointer acceleration threshold in pixels (i.e. after how many pixels
+pointer acceleration should take effect).
+.TP 8
+.B \-terminate
+causes the server to terminate at server reset, instead of continuing to run.
+This overrides a previous
+.B \-noreset
+command line option.
+.TP 8
+.B \-to \fIseconds\fP
+sets default connection timeout in seconds.
+.TP 8
+.B \-tst
+disables all testing extensions (e.g., XTEST, XTrap, XTestExtension1, RECORD).
+.TP 8
+.B tty\fIxx\fP
+ignored, for servers started the ancient way (from init).
+.TP 8
+.B v
+sets video-off screen-saver preference.
+.TP 8
+.B \-v
+sets video-on screen-saver preference.
+.TP 8
+.B \-wm
+forces the default backing-store of all windows to be WhenMapped.  This
+is a backdoor way of getting backing-store to apply to all windows.
+Although all mapped windows will have backing store, the backing store
+attribute value reported by the server for a window will be the last
+value established by a client.  If it has never been set by a client,
+the server will report the default value, NotUseful.  This behavior is
+required by the X protocol, which allows the server to exceed the
+client's backing store expectations but does not provide a way to tell
+the client that it is doing so.
+.TP 8
+.B \-wr
+sets the default root window to solid white instead of the standard root weave
+pattern.
+.TP 8
+.B \-x \fIextension\fP
+loads the specified extension at init.
+This is a no-op for most implementations.
+.TP 8
+.B [+-]xinerama
+enables(+) or disables(-) the XINERAMA extension.  The default state is
+platform and configuration specific.
+.SH SERVER DEPENDENT OPTIONS
+Some X servers accept the following options:
+.TP 8
+.B \-ld \fIkilobytes\fP
+sets the data space limit of the server to the specified number of kilobytes.
+A value of zero makes the data size as large as possible.  The default value
+of \-1 leaves the data space limit unchanged.
+.TP 8
+.B \-lf \fIfiles\fP
+sets the number-of-open-files limit of the server to the specified number.
+A value of zero makes the limit as large as possible.  The default value
+of \-1 leaves the limit unchanged.
+.TP 8
+.B \-ls \fIkilobytes\fP
+sets the stack space limit of the server to the specified number of kilobytes.
+A value of zero makes the stack size as large as possible.  The default value
+of \-1 leaves the stack space limit unchanged.
+.TP 8
+.B \-render
+.BR default | mono | gray | color
+sets the color allocation policy that will be used by the render extension.
+.RS 8
+.TP 8
+.I default
+selects the default policy defined for the display depth of the X
+server.
+.TP 8
+.I mono
+don't use any color cell.
+.TP 8
+.I gray
+use a gray map of 13 color cells for the X render extension.
+.TP 8
+.I color
+use a color cube of at most 4*4*4 colors (that is 64 color cells).
+.RE
+.TP 8
+.B \-dumbSched
+disables smart scheduling on platforms that support the smart scheduler.
+.TP
+.B \-schedInterval \fIinterval\fP
+sets the smart scheduler's scheduling interval to
+.I interval
+milliseconds.
+.SH XDMCP OPTIONS
+X servers that support XDMCP have the following options.
+See the \fIX Display Manager Control Protocol\fP specification for more
+information.
+.TP 8
+.B \-query \fIhostname\fP
+enables XDMCP and sends Query packets to the specified
+.IR hostname .
+.TP 8
+.B \-broadcast
+enable XDMCP and broadcasts BroadcastQuery packets to the network.  The
+first responding display manager will be chosen for the session.
+.TP 8
+.B \-multicast [\fIaddress\fP [\fIhop count\fP]]
+Enable XDMCP and multicast BroadcastQuery packets to the  network.
+The first responding display manager is chosen for the session.  If an
+address is specified, the multicast is sent to that address.  If no
+address is specified, the multicast is sent to the default XDMCP IPv6
+multicast group.  If a hop count is specified, it is used as the maximum
+hop count for the multicast.  If no hop count is specified, the multicast
+is set to a maximum of 1 hop, to prevent the multicast from being routed
+beyond the local network.
+.TP 8
+.B \-indirect \fIhostname\fP
+enables XDMCP and send IndirectQuery packets to the specified
+.IR hostname .
+.TP 8
+.B \-port \fIport-number\fP
+uses the specified \fIport-number\fP for XDMCP packets, instead of the
+default.  This option must be specified before any \-query, \-broadcast,
+\-multicast, or \-indirect options.
+.TP 8
+.B \-from \fIlocal-address\fP
+specifies the local address to connect from (useful if the connecting host
+has multiple network interfaces).  The \fIlocal-address\fP may be expressed
+in any form acceptable to the host platform's \fIgethostbyname\fP(3)
+implementation.
+.TP 8
+.B \-once
+causes the server to terminate (rather than reset) when the XDMCP session
+ends.
+.TP 8
+.B \-class \fIdisplay-class\fP
+XDMCP has an additional display qualifier used in resource lookup for
+display-specific options.  This option sets that value, by default it
+is "MIT-Unspecified" (not a very useful value).
+.TP 8
+.B \-cookie \fIxdm-auth-bits\fP
+When testing XDM-AUTHENTICATION-1, a private key is shared between the
+server and the manager.  This option sets the value of that private
+data (not that it is very private, being on the command line!).
+.TP 8
+.B \-displayID \fIdisplay-id\fP
+Yet another XDMCP specific value, this one allows the display manager to
+identify each display so that it can locate the shared key.
+.SH XKEYBOARD OPTIONS
+X servers that support the XKEYBOARD (a.k.a. \*qXKB\*q) extension accept the
+following options.  All layout files specified on the command line must be
+located in the XKB base directory or a subdirectory, and specified as the
+relative path from the XKB base directory.  The default XKB base directory is
+.IR __projectroot__/lib/X11/xkb .
+.TP 8
+.BR [+-]accessx " [ \fItimeout\fP [ \fItimeout_mask\fP [ \fIfeedback\fP [ \fIoptions_mask\fP ] ] ] ]"
+enables(+) or disables(-) AccessX key sequences.
+.TP 8
+.B \-xkbdir \fIdirectory\fP
+base directory for keyboard layout files.  This option is not available
+for setuid X servers (i.e., when the X server's real and effective uids
+are different).
+.TP 8
+.B \-ardelay \fImilliseconds\fP
+sets the autorepeat delay (length of time in milliseconds that a key must
+be depressed before autorepeat starts).
+.TP 8
+.B \-arinterval \fImilliseconds\fP
+sets the autorepeat interval (length of time in milliseconds that should
+elapse between autorepeat-generated keystrokes).
+.TP 8
+.B \-xkbmap \fIfilename\fP
+loads keyboard description in \fIfilename\fP on server startup.
+.SH "NETWORK CONNECTIONS"
+The X server supports client connections via a platform-dependent subset of
+the following transport types: TCP\/IP, Unix Domain sockets, DECnet,
+and several varieties of SVR4 local connections.  See the DISPLAY
+NAMES section of the \fIX\fP(__miscmansuffix__) manual page to learn how to
+specify which transport type clients should try to use.
+.SH GRANTING ACCESS
+The X server implements a platform-dependent subset of the following
+authorization protocols: MIT-MAGIC-COOKIE-1, XDM-AUTHORIZATION-1,
+XDM-AUTHORIZATION-2, SUN-DES-1, and MIT-KERBEROS-5.  See the
+\fIXsecurity\fP(__miscmansuffix__) manual page for information on the
+operation of these protocols.
+.PP
+Authorization data required by the above protocols is passed to the
+server in a private file named with the \fB\-auth\fP command line
+option.  Each time the server is about to accept the first connection
+after a reset (or when the server is starting), it reads this file.
+If this file contains any authorization records, the local host is not
+automatically allowed access to the server, and only clients which
+send one of the authorization records contained in the file in the
+connection setup information will be allowed access.  See the
+\fIXau\fP manual page for a description of the binary format of this
+file.  See \fIxauth\fP(1) for maintenance of this file, and distribution
+of its contents to remote hosts.
+.PP
+The X server also uses a host-based access control list for deciding
+whether or not to accept connections from clients on a particular machine.
+If no other authorization mechanism is being used,
+this list initially consists of the host on which the server is running as
+well as any machines listed in the file \fI/etc/X\fBn\fI.hosts\fR, where
+\fBn\fP is the display number of the server.  Each line of the file should
+contain either an Internet hostname (e.g. expo.lcs.mit.edu) or a DECnet
+hostname in double colon format (e.g. hydra::) or a complete name in the format
+\fIfamily\fP:\fIname\fP as described in the \fIxhost\fP(1) manual page.
+There should be no leading or trailing spaces on any lines.  For example:
+.sp
+.in +8
+.nf
+joesworkstation
+corporate.company.com
+star::
+inet:bigcpu
+local:
+.fi
+.in -8
+.PP
+Users can add or remove hosts from this list and enable or disable access
+control using the \fIxhost\fP command from the same machine as the server.
+.PP
+If the X FireWall Proxy (\fIxfwp\fP) is being used without a sitepolicy,
+host-based authorization must be turned on for clients to be able to
+connect to the X server via the \fIxfwp\fP.  If \fIxfwp\fP is run without
+a configuration file and thus no sitepolicy is defined, if \fIxfwp\fP
+is using an X server where xhost + has been run to turn off host-based
+authorization checks, when a client tries to connect to this X server
+via \fIxfwp\fP, the X server will deny the connection.  See \fIxfwp\fP(1)
+for more information about this proxy.
+.PP
+The X protocol intrinsically does not have any notion of window operation
+permissions or place any restrictions on what a client can do; if a program can
+connect to a display, it has full run of the screen.
+X servers that support the SECURITY extension fare better because clients
+can be designated untrusted via the authorization they use to connect; see
+the \fIxauth\fP(1) manual page for details.  Restrictions are imposed
+on untrusted clients that curtail the mischief they can do.  See the SECURITY
+extension specification for a complete list of these restrictions.
+.PP
+Sites that have better
+authentication and authorization systems might wish to make
+use of the hooks in the libraries and the server to provide additional
+security models.
+.SH SIGNALS
+The X server attaches special meaning to the following signals:
+.TP 8
+.I SIGHUP
+This signal causes the server to close all existing connections, free all
+resources, and restore all defaults.  It is sent by the display manager
+whenever the main user's main application (usually an \fIxterm\fP or window
+manager) exits to force the server to clean up and prepare for the next
+user.
+.TP 8
+.I SIGTERM
+This signal causes the server to exit cleanly.
+.TP 8
+.I SIGUSR1
+This signal is used quite differently from either of the above.  When the
+server starts, it checks to see if it has inherited SIGUSR1 as SIG_IGN
+instead of the usual SIG_DFL.  In this case, the server sends a SIGUSR1 to
+its parent process after it has set up the various connection schemes.
+\fIXdm\fP uses this feature to recognize when connecting to the server
+is possible.
+.SH FONTS
+The X server can obtain fonts from directories and/or from font servers.
+The list of directories and font servers
+the X server uses when trying to open a font is controlled
+by the \fIfont path\fP.
+.LP
+The default font path is
+__default_font_path__ .
+.LP
+A special kind of directory can be specified using the \fBcatalogue\fP:
+prefix. Directories specified this way can contain symlinks pointing to the
+real font directories. See the FONTPATH.D section for details.
+.LP
+The font path can be set with the \fB\-fp\fP option or by \fIxset\fP(1)
+after the server has started.
+.SH "FONTPATH.D"
+You can specify a special kind of font path in the form \fBcatalogue:<dir>\fR.
+The directory specified after the catalogue: prefix will be scanned for symlinks
+and each symlink destination will be added as a local fontfile FPE.
+.PP
+The symlink can be suffixed by attributes such as '\fBunscaled\fR', which
+will be passed through to the underlying fontfile FPE. The only exception is
+the newly introduced '\fBpri\fR' attribute, which will be used for ordering
+the font paths specified by the symlinks.
+
+An example configuration:
+
+.nf
+    75dpi:unscaled:pri=20 \-> /usr/share/X11/fonts/75dpi
+    ghostscript:pri=60 \-> /usr/share/fonts/default/ghostscript
+    misc:unscaled:pri=10 \-> /usr/share/X11/fonts/misc
+    type1:pri=40 \-> /usr/share/X11/fonts/Type1
+    type1:pri=50 \-> /usr/share/fonts/default/Type1
+.fi
+
+This will add /usr/share/X11/fonts/misc as the first FPE with the attribute
+'unscaled', second FPE will be /usr/share/X11/fonts/75dpi, also with
+the attribute unscaled etc. This is functionally equivalent to setting
+the following font path:
+
+.nf
+    /usr/share/X11/fonts/misc:unscaled,
+    /usr/share/X11/fonts/75dpi:unscaled,
+    /usr/share/X11/fonts/Type1,
+    /usr/share/fonts/default/Type1,
+    /usr/share/fonts/default/ghostscript
+.fi
+
+.SH FILES
+.TP 30
+.I /etc/X\fBn\fP.hosts
+Initial access control list for display number \fBn\fP
+.TP 30
+.IR __datadir__/fonts/X11/misc , __datadir__/fonts/X11/75dpi , __datadir__/fonts/X11/100dpi
+Bitmap font directories
+.TP 30
+.IR __datadir__/fonts/X11/TTF , __datadir__/fonts/X11/Type1
+Outline font directories
+.TP 30
+.I /tmp/.X11-unix/X\fBn\fP
+Unix domain socket for display number \fBn\fP
+.TP 30
+.I /usr/adm/X\fBn\fPmsgs
+Error log file for display number \fBn\fP if run from \fIinit\fP(__adminmansuffix__)
+.TP 30
+.I __projectroot__/lib/X11/xdm/xdm-errors
+Default error log file if the server is run from \fIxdm\fP(1)
+.SH "SEE ALSO"
+General information: \fIX\fP(__miscmansuffix__)
+.PP
+Protocols:
+.I "X Window System Protocol,"
+.I "The X Font Service Protocol,"
+.I "X Display Manager Control Protocol"
+.PP
+Fonts: \fIbdftopcf\fP(1), \fImkfontdir\fP(1), \fImkfontscale\fP(1),
+\fIxfs\fP(1), \fIxlsfonts\fP(1), \fIxfontsel\fP(1), \fIxfd\fP(1),
+.I "X Logical Font Description Conventions"
+.PP
+Security: \fIXsecurity\fP(__miscmansuffix__), \fIxauth\fP(1), \fIXau\fP(1),
+\fIxdm\fP(1), \fIxhost\fP(1), \fIxfwp\fP(1),
+.I "Security Extension Specification"
+.PP
+Starting the server: \fIstartx\fP(1), \fIxdm\fP(1), \fIxinit\fP(1)
+.PP
+Controlling the server once started: \fIxset\fP(1), \fIxsetroot\fP(1),
+\fIxhost\fP(1), \fIxinput\fP(1), \fIxrandr\fP(1)
+.PP
+Server-specific man pages:
+\fIXorg\fP(1), \fIXdmx\fP(1), \fIXephyr\fP(1), \fIXnest\fP(1),
+\fIXvfb\fP(1), \fIXquartz\fP(1), \fIXWin\fP(1).
+.PP
+Server internal documentation:
+.I "Definition of the Porting Layer for the X v11 Sample Server"
+.SH AUTHORS
+The sample server was originally written by Susan Angebranndt, Raymond
+Drewry, Philip Karlton, and Todd Newman, from Digital Equipment
+Corporation, with support from a large cast.  It has since been
+extensively rewritten by Keith Packard and Bob Scheifler, from MIT.
+Dave Wiggins took over post-R5 and made substantial improvements.
commit 9129beb507642e2414ef1f90d650572325d8c2dc
Author: Gaetan Nadon <memsize at videotron.ca>
Date:   Thu Apr 28 21:16:12 2011 -0400

    dmx: fix warning for doxygen explicit links
    
    Explicit links to functions in another file are not supported.
    
    Reviewed-by Jeremy Huddleston <jeremyhu at apple.com>
    Signed-off-by: Gaetan Nadon <memsize at videotron.ca>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/dmx/dmxwindow.c b/hw/dmx/dmxwindow.c
index c3b4700..704fcff 100644
--- a/hw/dmx/dmxwindow.c
+++ b/hw/dmx/dmxwindow.c
@@ -115,7 +115,7 @@ Window dmxCreateRootWindow(WindowPtr pWindow)
 }
 
 /** Change the location and size of the "screen" window.  Called from
- *  #dmxConfigureScreenWindow(). */
+ *  dmxextension.c dmxConfigureScreenWindow(). */
 void dmxResizeScreenWindow(ScreenPtr pScreen,
 			   int x, int y, int w, int h)
 {
@@ -138,7 +138,7 @@ void dmxResizeScreenWindow(ScreenPtr pScreen,
 }
 
 /** Change the location and size of the "root" window.  Called from
- *  #dmxConfigureRootWindow. */
+ *  #dmxCreateWindow. */
 void dmxResizeRootWindow(WindowPtr pRoot,
 			 int x, int y, int w, int h)
 {
commit 0d8a5766a39320dedd34a215fc6655f9ac19e8bc
Author: Gaetan Nadon <memsize at videotron.ca>
Date:   Thu Apr 28 21:16:11 2011 -0400

    dmx: modernize doxygen generation.
    
    The configuration and stylesheet were very old.
    The stylesheet is not checked-in, use the generated one.
    The header is not checked-in, use the generated one.
    Add datetime and projectname in default footer.
    Developer documentation is not installed and not included in tarball.
    
    Reviewed-by Jeremy Huddleston <jeremyhu at apple.com>
    Signed-off-by: Gaetan Nadon <memsize at videotron.ca>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/dmx/doxygen/Makefile.am b/hw/dmx/doxygen/Makefile.am
index d705fbe..fe159df 100644
--- a/hw/dmx/doxygen/Makefile.am
+++ b/hw/dmx/doxygen/Makefile.am
@@ -19,250 +19,18 @@
 #  NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
 #  CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
-DOXYGEN_HEAD=\
-	html/annotated.html
-
-DOXYGEN_REST= \
-	html/ChkNotMaskEv_8c.html \
-	html/ChkNotMaskEv_8h.html \
-	html/ChkNotMaskEv_8h_source.html \
-	html/classes.html \
-	html/dmx_8h.html \
-	html/dmx_8h_source.html \
-	html/dmxarg_8c.html \
-	html/dmxarg_8h.html \
-	html/dmxarg_8h_source.html \
-	html/dmxbackend_8c.html \
-	html/dmxbackend_8h.html \
-	html/dmxbackend_8h_source.html \
-	html/dmxcb_8c.html \
-	html/dmxcb_8h.html \
-	html/dmxcb_8h_source.html \
-	html/dmxclient_8h.html \
-	html/dmxclient_8h_source.html \
-	html/dmxcmap_8c.html \
-	html/dmxcmap_8h.html \
-	html/dmxcmap_8h_source.html \
-	html/dmxcommon_8c.html \
-	html/dmxcommon_8h.html \
-	html/dmxcommon_8h_source.html \
-	html/dmxcompat_8c.html \
-	html/dmxcompat_8h.html \
-	html/dmxcompat_8h_source.html \
-	html/dmxconfig_8c.html \
-	html/dmxconfig_8h.html \
-	html/dmxconfig_8h_source.html \
-	html/dmxconsole_8c.html \
-	html/dmxconsole_8h.html \
-	html/dmxconsole_8h_source.html \
-	html/dmxcursor_8c.html \
-	html/dmxcursor_8h.html \
-	html/dmxcursor_8h_source.html \
-	html/dmxdetach_8c.html \
-	html/dmxdpms_8c.html \
-	html/dmxdpms_8h.html \
-	html/dmxdpms_8h_source.html \
-	html/dmxdummy_8c.html \
-	html/dmxdummy_8h.html \
-	html/dmxdummy_8h_source.html \
-	html/dmxevents_8c.html \
-	html/dmxevents_8h.html \
-	html/dmxevents_8h_source.html \
-	html/dmxextension_8c.html \
-	html/dmxextension_8h.html \
-	html/dmxextension_8h_source.html \
-	html/dmxfont_8c.html \
-	html/dmxfont_8h.html \
-	html/dmxfont_8h_source.html \
-	html/dmxgc_8c.html \
-	html/dmxgc_8h.html \
-	html/dmxgc_8h_source.html \
-	html/dmxgcops_8c.html \
-	html/dmxgcops_8h.html \
-	html/dmxgcops_8h_source.html \
-	html/dmx__glxvisuals_8h_source.html \
-	html/dmxinit_8c.html \
-	html/dmxinit_8h.html \
-	html/dmxinit_8h_source.html \
-	html/dmxinput_8c.html \
-	html/dmxinput_8h.html \
-	html/dmxinput_8h_source.html \
-	html/dmxinputinit_8c.html \
-	html/dmxinputinit_8h.html \
-	html/dmxinputinit_8h_source.html \
-	html/dmxlog_8c.html \
-	html/dmxlog_8h.html \
-	html/dmxlog_8h_source.html \
-	html/dmxmap_8c.html \
-	html/dmxmap_8h.html \
-	html/dmxmap_8h_source.html \
-	html/dmxmotion_8c.html \
-	html/dmxmotion_8h.html \
-	html/dmxmotion_8h_source.html \
-	html/dmxparse_8c.html \
-	html/dmxparse_8h.html \
-	html/dmxparse_8h_source.html \
-	html/dmxpict_8c.html \
-	html/dmxpict_8h.html \
-	html/dmxpict_8h_source.html \
-	html/dmxpixmap_8c.html \
-	html/dmxpixmap_8h.html \
-	html/dmxpixmap_8h_source.html \
-	html/dmxprint_8c.html \
-	html/dmxprint_8h.html \
-	html/dmxprint_8h_source.html \
-	html/dmxprop_8c.html \
-	html/dmxprop_8h.html \
-	html/dmxprop_8h_source.html \
-	html/dmxscrinit_8c.html \
-	html/dmxscrinit_8h.html \
-	html/dmxscrinit_8h_source.html \
-	html/dmxshadow_8c.html \
-	html/dmxshadow_8h.html \
-	html/dmxshadow_8h_source.html \
-	html/dmxsigio_8c.html \
-	html/dmxsigio_8h.html \
-	html/dmxsigio_8h_source.html \
-	html/dmxstat_8c.html \
-	html/dmxstat_8h.html \
-	html/dmxstat_8h_source.html \
-	html/dmxsync_8c.html \
-	html/dmxsync_8h.html \
-	html/dmxsync_8h_source.html \
-	html/dmxvisual_8c.html \
-	html/dmxvisual_8h.html \
-	html/dmxvisual_8h_source.html \
-	html/dmxwindow_8c.html \
-	html/dmxwindow_8h.html \
-	html/dmxwindow_8h_source.html \
-	html/dmxxinput_8c.html \
-	html/doxygen.css \
-	html/doxygen.png \
-	html/files.html \
-	html/ftv2blank.png \
-	html/ftv2doc.png \
-	html/ftv2folderclosed.png \
-	html/ftv2folderopen.png \
-	html/ftv2lastnode.png \
-	html/ftv2link.png \
-	html/ftv2mlastnode.png \
-	html/ftv2mnode.png \
-	html/ftv2node.png \
-	html/ftv2plastnode.png \
-	html/ftv2pnode.png \
-	html/ftv2vertline.png \
-	html/functions.html \
-	html/functions_vars.html \
-	html/globals_defs.html \
-	html/globals_enum.html \
-	html/globals_eval.html \
-	html/globals_func.html \
-	html/globals.html \
-	html/globals_type.html \
-	html/globals_vars.html \
-	html/index.html \
-	html/lnx-keyboard_8c.html \
-	html/lnx-keyboard_8h.html \
-	html/lnx-keyboard_8h_source.html \
-	html/lnx-ms_8c.html \
-	html/lnx-ms_8h.html \
-	html/lnx-ms_8h_source.html \
-	html/lnx-ps2_8c.html \
-	html/lnx-ps2_8h.html \
-	html/lnx-ps2_8h_source.html \
-	html/main.html \
-	html/struct__dmxArg.html \
-	html/struct__dmxColormapPriv.html \
-	html/structDMXConfigCmdStruct.html \
-	html/struct__DMXConfigComment.html \
-	html/struct__DMXConfigDisplay.html \
-	html/struct__DMXConfigEntry.html \
-	html/struct__DMXConfigFullDim.html \
-	html/structDMXConfigListStruct.html \
-	html/struct__DMXConfigNumber.html \
-	html/struct__DMXConfigOption.html \
-	html/struct__DMXConfigPair.html \
-	html/struct__DMXConfigParam.html \
-	html/struct__DMXConfigPartDim.html \
-	html/struct__DMXConfigString.html \
-	html/struct__DMXConfigSub.html \
-	html/struct__DMXConfigToken.html \
-	html/struct__DMXConfigVirtual.html \
-	html/struct__DMXConfigWall.html \
-	html/struct__dmxCursorPriv.html \
-	html/structDMXDesktopAttributesRec.html \
-	html/struct__DMXEventMap.html \
-	html/struct__dmxFontPriv.html \
-	html/struct__dmxGCPriv.html \
-	html/structdmxGlxVisualPrivate.html \
-	html/struct__dmxGlyphPriv.html \
-	html/structDMXInputAttributesRec.html \
-	html/struct__DMXInputInfo.html \
-	html/struct__DMXLocalInitInfo.html \
-	html/struct__DMXLocalInputInfo.html \
-	html/struct__dmxPictPriv.html \
-	html/struct__dmxPixPriv.html \
-	html/structDMXScreenAttributesRec.html \
-	html/struct__DMXScreenInfo.html \
-	html/struct__DMXStatAvg.html \
-	html/struct__DMXStatInfo.html \
-	html/structDMXWindowAttributesRec.html \
-	html/struct__dmxWinPriv.html \
-	html/struct__myPrivate.html \
-	html/tree.html \
-	html/usb-common_8c.html \
-	html/usb-common_8h.html \
-	html/usb-common_8h_source.html \
-	html/usb-keyboard_8c.html \
-	html/usb-keyboard_8h.html \
-	html/usb-keyboard_8h_source.html \
-	html/usb-mouse_8c.html \
-	html/usb-mouse_8h.html \
-	html/usb-mouse_8h_source.html \
-	html/usb-other_8c.html \
-	html/usb-other_8h.html \
-	html/usb-other_8h_source.html \
-	html/usb-private_8h.html \
-	html/usb-private_8h_source.html
-
-DOXYGEN_FILES=$(DOXYGEN_HEAD) $(DOXYGEN_REST)
-
-EXTRA_DIST = \
-	doxygen.conf \
-	doxygen.css \
-	doxygen.foot \
-	doxygen.head \
-	$(DOXYGEN_FILES)
-
 if ENABLE_DEVEL_DOCS
 if HAVE_DOXYGEN
 
-DOXYGEN_SRC=doxygen.head doxygen.foot doxygen.css doxygen.conf
-
-all-local: $(DOXYGEN_FILES)
-
-dist-local: $(DOXYGEN_FILES)
+# Developers documentation is not installed
+noinst_DATA = html/index.html
+dist_noinst_DATA = doxygen.conf.in footer.html
 
-$(DOXYGEN_HEAD): $(DOXYGEN_SRC)
-	$(DOXYGEN) doxygen.conf
+html/index.html:
+	$(AM_V_GEN)$(DOXYGEN) doxygen.conf
 
-$(DOXYGEN_REST): $(DOXYGEN_HEAD)
-
-maintainer-clean-local:
-	rm -rf html/
-
-distclean-local:
-	rm -rf html/
+clean-local:
+	$(AM_V_at)rm -fr html/
 
 endif HAVE_DOXYGEN
 endif ENABLE_DEVEL_DOCS
-
-$(builddir)/doxygen.head:
-	$(LN_S) $(srcdir)/doxygen.head $@
-
-$(builddir)/doxygen.foot:
-	$(LN_S) $(srcdir)/doxygen.foot $@
-
-$(builddir)doxygen.css:
-	$(LN_S) $(srcdir)/doxygen.css $@
-
diff --git a/hw/dmx/doxygen/doxygen.conf.in b/hw/dmx/doxygen/doxygen.conf.in
index f886a43..3dbb27e 100644
--- a/hw/dmx/doxygen/doxygen.conf.in
+++ b/hw/dmx/doxygen/doxygen.conf.in
@@ -1,4 +1,4 @@
-# Doxyfile 1.3.4
+# Doxyfile 1.6.2
 
 # This file describes the settings to be used by the documentation system
 # doxygen (www.doxygen.org) for a project
@@ -14,412 +14,674 @@
 # Project related configuration options
 #---------------------------------------------------------------------------
 
-# The PROJECT_NAME tag is a single word (or a sequence of words surrounded 
+# This tag specifies the encoding used for all characters in the config file
+# that follow. The default is UTF-8 which is also the encoding used for all
+# text before the first occurrence of this tag. Doxygen uses libiconv (or the
+# iconv built into libc) for the transcoding. See
+# http://www.gnu.org/software/libiconv for the list of possible encodings.
+
+DOXYFILE_ENCODING      = UTF-8
+
+# The PROJECT_NAME tag is a single word (or a sequence of words surrounded
 # by quotes) that should identify the project.
 
 PROJECT_NAME           = "Distributed Multihead X"
 
-# The PROJECT_NUMBER tag can be used to enter a project or revision number. 
-# This could be handy for archiving the generated documentation or 
+# The PROJECT_NUMBER tag can be used to enter a project or revision number.
+# This could be handy for archiving the generated documentation or
 # if some version control system is used.
 
-PROJECT_NUMBER         = "dmx-1-2-20040604 and later"
+PROJECT_NUMBER         = "@PACKAGE_VERSION@"
 
-# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) 
-# base path where the generated documentation will be put. 
-# If a relative path is entered, it will be relative to the location 
+# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
+# base path where the generated documentation will be put.
+# If a relative path is entered, it will be relative to the location
 # where doxygen was started. If left blank the current directory will be used.
 
-OUTPUT_DIRECTORY       = 
+OUTPUT_DIRECTORY       =
+
+# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create
+# 4096 sub-directories (in 2 levels) under the output directory of each output
+# format and will distribute the generated files over these directories.
+# Enabling this option can be useful when feeding doxygen a huge amount of
+# source files, where putting all generated files in the same directory would
+# otherwise cause performance problems for the file system.
 
-# The OUTPUT_LANGUAGE tag is used to specify the language in which all 
-# documentation generated by doxygen is written. Doxygen will use this 
-# information to generate all constant output in the proper language. 
-# The default language is English, other supported languages are: 
-# Brazilian, Catalan, Chinese, Chinese-Traditional, Croatian, Czech, Danish, Dutch, 
-# Finnish, French, German, Greek, Hungarian, Italian, Japanese, Japanese-en 
-# (Japanese with English messages), Korean, Norwegian, Polish, Portuguese, 
-# Romanian, Russian, Serbian, Slovak, Slovene, Spanish, Swedish, and Ukrainian.
+CREATE_SUBDIRS         = NO
+
+# The OUTPUT_LANGUAGE tag is used to specify the language in which all
+# documentation generated by doxygen is written. Doxygen will use this
+# information to generate all constant output in the proper language.
+# The default language is English, other supported languages are:
+# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional,
+# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German,
+# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English
+# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian,
+# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrilic, Slovak,
+# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese.
 
 OUTPUT_LANGUAGE        = English
 
-# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will 
-# include brief member descriptions after the members that are listed in 
-# the file and class documentation (similar to JavaDoc). 
+# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will
+# include brief member descriptions after the members that are listed in
+# the file and class documentation (similar to JavaDoc).
 # Set to NO to disable this.
 
 BRIEF_MEMBER_DESC      = YES
 
-# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend 
-# the brief description of a member or function before the detailed description. 
-# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the 
+# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend
+# the brief description of a member or function before the detailed description.
+# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the
 # brief descriptions will be completely suppressed.
 
 REPEAT_BRIEF           = YES
 
-# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then 
-# Doxygen will generate a detailed section even if there is only a brief 
+# This tag implements a quasi-intelligent brief description abbreviator
+# that is used to form the text in various listings. Each string
+# in this list, if found as the leading text of the brief description, will be
+# stripped from the text and the result after processing the whole list, is
+# used as the annotated text. Otherwise, the brief description is used as-is.
+# If left blank, the following values are used ("$name" is automatically
+# replaced with the name of the entity): "The $name class" "The $name widget"
+# "The $name file" "is" "provides" "specifies" "contains"
+# "represents" "a" "an" "the"
+
+ABBREVIATE_BRIEF       =
+
+# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then
+# Doxygen will generate a detailed section even if there is only a brief
 # description.
 
 ALWAYS_DETAILED_SEC    = YES
 
-# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all inherited 
-# members of a class in the documentation of that class as if those members were 
-# ordinary class members. Constructors, destructors and assignment operators of 
-# the base classes will not be shown.
+# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all
+# inherited members of a class in the documentation of that class as if those
+# members were ordinary class members. Constructors, destructors and assignment
+# operators of the base classes will not be shown.
 
 INLINE_INHERITED_MEMB  = NO
 
-# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full 
-# path before files name in the file list and in the header files. If set 
+# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full
+# path before files name in the file list and in the header files. If set
 # to NO the shortest path that makes the file name unique will be used.
 
 FULL_PATH_NAMES        = NO
 
-# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag 
-# can be used to strip a user-defined part of the path. Stripping is 
-# only done if one of the specified strings matches the left-hand part of 
-# the path. It is allowed to use relative paths in the argument list.
+# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag
+# can be used to strip a user-defined part of the path. Stripping is
+# only done if one of the specified strings matches the left-hand part of
+# the path. The tag can be used to show relative paths in the file list.
+# If left blank the directory from which doxygen is run is used as the
+# path to strip.
+
+STRIP_FROM_PATH        =
 
-STRIP_FROM_PATH        = 
+# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of
+# the path mentioned in the documentation of a class, which tells
+# the reader which header file to include in order to use a class.
+# If left blank only the name of the header file containing the class
+# definition is used. Otherwise one should specify the include paths that
+# are normally passed to the compiler using the -I flag.
 
-# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter 
-# (but less readable) file names. This can be useful is your file systems 
+STRIP_FROM_INC_PATH    =
+
+# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter
+# (but less readable) file names. This can be useful is your file systems
 # doesn't support long names like on DOS, Mac, or CD-ROM.
 
 SHORT_NAMES            = NO
 
-# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen 
-# will interpret the first line (until the first dot) of a JavaDoc-style 
-# comment as the brief description. If set to NO, the JavaDoc 
-# comments will behave just like the Qt-style comments (thus requiring an 
-# explict @brief command for a brief description.
+# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen
+# will interpret the first line (until the first dot) of a JavaDoc-style
+# comment as the brief description. If set to NO, the JavaDoc
+# comments will behave just like regular Qt-style comments
+# (thus requiring an explicit @brief command for a brief description.)
 
 JAVADOC_AUTOBRIEF      = NO
 
-# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen 
-# treat a multi-line C++ special comment block (i.e. a block of //! or /// 
-# comments) as a brief description. This used to be the default behaviour. 
-# The new default is to treat a multi-line C++ comment block as a detailed 
+# If the QT_AUTOBRIEF tag is set to YES then Doxygen will
+# interpret the first line (until the first dot) of a Qt-style
+# comment as the brief description. If set to NO, the comments
+# will behave just like regular Qt-style comments (thus requiring
+# an explicit \brief command for a brief description.)
+
+QT_AUTOBRIEF           = NO
+
+# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen
+# treat a multi-line C++ special comment block (i.e. a block of //! or ///
+# comments) as a brief description. This used to be the default behaviour.
+# The new default is to treat a multi-line C++ comment block as a detailed
 # description. Set this tag to YES if you prefer the old behaviour instead.
 
 MULTILINE_CPP_IS_BRIEF = NO
 
-# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented 
-# member inherits the documentation from any documented member that it 
-# reimplements.
+# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented
+# member inherits the documentation from any documented member that it
+# re-implements.
 
 INHERIT_DOCS           = YES
 
-# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC 
-# tag is set to YES, then doxygen will reuse the documentation of the first 
-# member in the group (if any) for the other members of the group. By default 
-# all members of a group must be documented explicitly.
+# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce
+# a new page for each member. If set to NO, the documentation of a member will
+# be part of the file/class/namespace that contains it.
 
-DISTRIBUTE_GROUP_DOC   = NO
+SEPARATE_MEMBER_PAGES  = NO
 
-# The TAB_SIZE tag can be used to set the number of spaces in a tab. 
+# The TAB_SIZE tag can be used to set the number of spaces in a tab.
 # Doxygen uses this value to replace tabs by spaces in code fragments.
 
 TAB_SIZE               = 8
 
-# This tag can be used to specify a number of aliases that acts 
-# as commands in the documentation. An alias has the form "name=value". 
-# For example adding "sideeffect=\par Side Effects:\n" will allow you to 
-# put the command \sideeffect (or @sideeffect) in the documentation, which 
-# will result in a user-defined paragraph with heading "Side Effects:". 
+# This tag can be used to specify a number of aliases that acts
+# as commands in the documentation. An alias has the form "name=value".
+# For example adding "sideeffect=\par Side Effects:\n" will allow you to
+# put the command \sideeffect (or @sideeffect) in the documentation, which
+# will result in a user-defined paragraph with heading "Side Effects:".
 # You can put \n's in the value part of an alias to insert newlines.
 
-ALIASES                = 
+ALIASES                =
 
-# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources 
-# only. Doxygen will then generate output that is more tailored for C. 
-# For instance, some of the names that are used will be different. The list 
+# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C
+# sources only. Doxygen will then generate output that is more tailored for C.
+# For instance, some of the names that are used will be different. The list
 # of all members will be omitted, etc.
 
 OPTIMIZE_OUTPUT_FOR_C  = YES
 
-# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java sources 
-# only. Doxygen will then generate output that is more tailored for Java. 
-# For instance, namespaces will be presented as packages, qualified scopes 
-# will look different, etc.
+# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java
+# sources only. Doxygen will then generate output that is more tailored for
+# Java. For instance, namespaces will be presented as packages, qualified
+# scopes will look different, etc.
 
 OPTIMIZE_OUTPUT_JAVA   = NO
 
-# Set the SUBGROUPING tag to YES (the default) to allow class member groups of 
-# the same type (for instance a group of public functions) to be put as a 
-# subgroup of that type (e.g. under the Public Functions section). Set it to 
-# NO to prevent subgrouping. Alternatively, this can be done per class using 
+# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran
+# sources only. Doxygen will then generate output that is more tailored for
+# Fortran.
+
+OPTIMIZE_FOR_FORTRAN   = NO
+
+# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL
+# sources. Doxygen will then generate output that is tailored for
+# VHDL.
+
+OPTIMIZE_OUTPUT_VHDL   = NO
+
+# Doxygen selects the parser to use depending on the extension of the files it parses.
+# With this tag you can assign which parser to use for a given extension.
+# Doxygen has a built-in mapping, but you can override or extend it using this tag.
+# The format is ext=language, where ext is a file extension, and language is one of
+# the parsers supported by doxygen: IDL, Java, Javascript, C#, C, C++, D, PHP,
+# Objective-C, Python, Fortran, VHDL, C, C++. For instance to make doxygen treat
+# .inc files as Fortran files (default is PHP), and .f files as C (default is Fortran),
+# use: inc=Fortran f=C. Note that for custom extensions you also need to set FILE_PATTERNS otherwise the files are not read by doxygen.
+
+EXTENSION_MAPPING      =
+
+# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want
+# to include (a tag file for) the STL sources as input, then you should
+# set this tag to YES in order to let doxygen match functions declarations and
+# definitions whose arguments contain STL classes (e.g. func(std::string); v.s.
+# func(std::string) {}). This also make the inheritance and collaboration
+# diagrams that involve STL classes more complete and accurate.
+
+BUILTIN_STL_SUPPORT    = NO
+
+# If you use Microsoft's C++/CLI language, you should set this option to YES to
+# enable parsing support.
+
+CPP_CLI_SUPPORT        = NO
+
+# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only.
+# Doxygen will parse them like normal C++ but will assume all classes use public
+# instead of private inheritance when no explicit protection keyword is present.
+
+SIP_SUPPORT            = NO
+
+# For Microsoft's IDL there are propget and propput attributes to indicate getter
+# and setter methods for a property. Setting this option to YES (the default)
+# will make doxygen to replace the get and set methods by a property in the
+# documentation. This will only work if the methods are indeed getting or
+# setting a simple type. If this is not the case, or you want to show the
+# methods anyway, you should set this option to NO.
+
+IDL_PROPERTY_SUPPORT   = YES
+
+# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC
+# tag is set to YES, then doxygen will reuse the documentation of the first
+# member in the group (if any) for the other members of the group. By default
+# all members of a group must be documented explicitly.
+
+DISTRIBUTE_GROUP_DOC   = NO
+
+# Set the SUBGROUPING tag to YES (the default) to allow class member groups of
+# the same type (for instance a group of public functions) to be put as a
+# subgroup of that type (e.g. under the Public Functions section). Set it to
+# NO to prevent subgrouping. Alternatively, this can be done per class using
 # the \nosubgrouping command.
 
 SUBGROUPING            = YES
 
+# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum
+# is documented as struct, union, or enum with the name of the typedef. So
+# typedef struct TypeS {} TypeT, will appear in the documentation as a struct
+# with name TypeT. When disabled the typedef will appear as a member of a file,
+# namespace, or class. And the struct will be named TypeS. This can typically
+# be useful for C code in case the coding convention dictates that all compound
+# types are typedef'ed and only the typedef is referenced, never the tag name.
+
+TYPEDEF_HIDES_STRUCT   = NO
+
+# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to
+# determine which symbols to keep in memory and which to flush to disk.
+# When the cache is full, less often used symbols will be written to disk.
+# For small to medium size projects (<1000 input files) the default value is
+# probably good enough. For larger projects a too small cache size can cause
+# doxygen to be busy swapping symbols to and from disk most of the time
+# causing a significant performance penality.
+# If the system has enough physical memory increasing the cache will improve the
+# performance by keeping more symbols in memory. Note that the value works on
+# a logarithmic scale so increasing the size by one will rougly double the
+# memory usage. The cache size is given by this formula:
+# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0,
+# corresponding to a cache size of 2^16 = 65536 symbols
+
+SYMBOL_CACHE_SIZE      = 0
+
 #---------------------------------------------------------------------------
 # Build related configuration options
 #---------------------------------------------------------------------------
 
-# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in 
-# documentation are documented, even if no documentation was available. 
-# Private class members and static file members will be hidden unless 
+# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in
+# documentation are documented, even if no documentation was available.
+# Private class members and static file members will be hidden unless
 # the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
 
 EXTRACT_ALL            = YES
 
-# If the EXTRACT_PRIVATE tag is set to YES all private members of a class 
+# If the EXTRACT_PRIVATE tag is set to YES all private members of a class
 # will be included in the documentation.
 
 EXTRACT_PRIVATE        = NO
 
-# If the EXTRACT_STATIC tag is set to YES all static members of a file 
+# If the EXTRACT_STATIC tag is set to YES all static members of a file
 # will be included in the documentation.
 
 EXTRACT_STATIC         = YES
 
-# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) 
-# defined locally in source files will be included in the documentation. 
+# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs)
+# defined locally in source files will be included in the documentation.
 # If set to NO only classes defined in header files are included.
 
 EXTRACT_LOCAL_CLASSES  = YES
 
-# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all 
-# undocumented members of documented classes, files or namespaces. 
-# If set to NO (the default) these members will be included in the 
-# various overviews, but no documentation section is generated. 
+# This flag is only useful for Objective-C code. When set to YES local
+# methods, which are defined in the implementation section but not in
+# the interface are included in the documentation.
+# If set to NO (the default) only methods in the interface are included.
+
+EXTRACT_LOCAL_METHODS  = NO
+
+# If this flag is set to YES, the members of anonymous namespaces will be
+# extracted and appear in the documentation as a namespace called
+# 'anonymous_namespace{file}', where file will be replaced with the base
+# name of the file that contains the anonymous namespace. By default
+# anonymous namespace are hidden.
+
+EXTRACT_ANON_NSPACES   = NO
+
+# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all
+# undocumented members of documented classes, files or namespaces.
+# If set to NO (the default) these members will be included in the
+# various overviews, but no documentation section is generated.
 # This option has no effect if EXTRACT_ALL is enabled.
 
 HIDE_UNDOC_MEMBERS     = YES
 
-# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all 
-# undocumented classes that are normally visible in the class hierarchy. 
-# If set to NO (the default) these classes will be included in the various 
+# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all
+# undocumented classes that are normally visible in the class hierarchy.
+# If set to NO (the default) these classes will be included in the various
 # overviews. This option has no effect if EXTRACT_ALL is enabled.
 
 HIDE_UNDOC_CLASSES     = NO
 
-# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all 
-# friend (class|struct|union) declarations. 
-# If set to NO (the default) these declarations will be included in the 
+# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all
+# friend (class|struct|union) declarations.
+# If set to NO (the default) these declarations will be included in the
 # documentation.
 
 HIDE_FRIEND_COMPOUNDS  = NO
 
-# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any 
-# documentation blocks found inside the body of a function. 
-# If set to NO (the default) these blocks will be appended to the 
+# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any
+# documentation blocks found inside the body of a function.
+# If set to NO (the default) these blocks will be appended to the
 # function's detailed documentation block.
 
 HIDE_IN_BODY_DOCS      = NO
 
-# The INTERNAL_DOCS tag determines if documentation 
-# that is typed after a \internal command is included. If the tag is set 
-# to NO (the default) then the documentation will be excluded. 
+# The INTERNAL_DOCS tag determines if documentation
+# that is typed after a \internal command is included. If the tag is set
+# to NO (the default) then the documentation will be excluded.
 # Set it to YES to include the internal documentation.
 
 INTERNAL_DOCS          = NO
 
-# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate 
-# file names in lower-case letters. If set to YES upper-case letters are also 
-# allowed. This is useful if you have classes or files whose names only differ 
-# in case and if your file system supports case sensitive file names. Windows 
-# users are advised to set this option to NO.
+# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate
+# file names in lower-case letters. If set to YES upper-case letters are also
+# allowed. This is useful if you have classes or files whose names only differ
+# in case and if your file system supports case sensitive file names. Windows
+# and Mac users are advised to set this option to NO.
 
 CASE_SENSE_NAMES       = YES
 
-# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen 
-# will show members with their full class and namespace scopes in the 
+# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen
+# will show members with their full class and namespace scopes in the
 # documentation. If set to YES the scope will be hidden.
 
 HIDE_SCOPE_NAMES       = NO
 
-# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen 
-# will put a list of the files that are included by a file in the documentation 
+# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen
+# will put a list of the files that are included by a file in the documentation
 # of that file.
 
 SHOW_INCLUDE_FILES     = YES
 
-# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] 
+# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen
+# will list include files with double quotes in the documentation
+# rather than with sharp brackets.
+
+FORCE_LOCAL_INCLUDES   = NO
+
+# If the INLINE_INFO tag is set to YES (the default) then a tag [inline]
 # is inserted in the documentation for inline members.
 
 INLINE_INFO            = YES
 
-# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen 
-# will sort the (detailed) documentation of file and class members 
-# alphabetically by member name. If set to NO the members will appear in 
+# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen
+# will sort the (detailed) documentation of file and class members
+# alphabetically by member name. If set to NO the members will appear in
 # declaration order.
 
 SORT_MEMBER_DOCS       = YES
 
-# The GENERATE_TODOLIST tag can be used to enable (YES) or 
-# disable (NO) the todo list. This list is created by putting \todo 
+# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the
+# brief documentation of file, namespace and class members alphabetically
+# by member name. If set to NO (the default) the members will appear in
+# declaration order.
+
+SORT_BRIEF_DOCS        = NO
+
+# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the (brief and detailed) documentation of class members so that constructors and destructors are listed first. If set to NO (the default) the constructors will appear in the respective orders defined by SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO.
+
+SORT_MEMBERS_CTORS_1ST = NO
+
+# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the
+# hierarchy of group names into alphabetical order. If set to NO (the default)
+# the group names will appear in their defined order.
+
+SORT_GROUP_NAMES       = NO
+
+# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be
+# sorted by fully-qualified names, including namespaces. If set to
+# NO (the default), the class list will be sorted only by class name,
+# not including the namespace part.
+# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.
+# Note: This option applies only to the class list, not to the
+# alphabetical list.
+
+SORT_BY_SCOPE_NAME     = NO
+
+# The GENERATE_TODOLIST tag can be used to enable (YES) or
+# disable (NO) the todo list. This list is created by putting \todo
 # commands in the documentation.
 
 GENERATE_TODOLIST      = YES
 
-# The GENERATE_TESTLIST tag can be used to enable (YES) or 
-# disable (NO) the test list. This list is created by putting \test 
+# The GENERATE_TESTLIST tag can be used to enable (YES) or
+# disable (NO) the test list. This list is created by putting \test
 # commands in the documentation.
 
 GENERATE_TESTLIST      = YES
 
-# The GENERATE_BUGLIST tag can be used to enable (YES) or 
-# disable (NO) the bug list. This list is created by putting \bug 
+# The GENERATE_BUGLIST tag can be used to enable (YES) or
+# disable (NO) the bug list. This list is created by putting \bug
 # commands in the documentation.
 
 GENERATE_BUGLIST       = YES
 
-# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or 
-# disable (NO) the deprecated list. This list is created by putting 
+# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or
+# disable (NO) the deprecated list. This list is created by putting
 # \deprecated commands in the documentation.
 
 GENERATE_DEPRECATEDLIST= YES
 
-# The ENABLED_SECTIONS tag can be used to enable conditional 
+# The ENABLED_SECTIONS tag can be used to enable conditional
 # documentation sections, marked by \if sectionname ... \endif.
 
-ENABLED_SECTIONS       = 
+ENABLED_SECTIONS       =
 
-# The MAX_INITIALIZER_LINES tag determines the maximum number of lines 
-# the initial value of a variable or define consists of for it to appear in 
-# the documentation. If the initializer consists of more lines than specified 
-# here it will be hidden. Use a value of 0 to hide initializers completely. 
-# The appearance of the initializer of individual variables and defines in the 
-# documentation can be controlled using \showinitializer or \hideinitializer 
+# The MAX_INITIALIZER_LINES tag determines the maximum number of lines
+# the initial value of a variable or define consists of for it to appear in
+# the documentation. If the initializer consists of more lines than specified
+# here it will be hidden. Use a value of 0 to hide initializers completely.
+# The appearance of the initializer of individual variables and defines in the
+# documentation can be controlled using \showinitializer or \hideinitializer
 # command in the documentation regardless of this setting.
 
 MAX_INITIALIZER_LINES  = 30
 
-# Set the SHOW_USED_FILES tag to NO to disable the list of files generated 
-# at the bottom of the documentation of classes and structs. If set to YES the 
+# Set the SHOW_USED_FILES tag to NO to disable the list of files generated
+# at the bottom of the documentation of classes and structs. If set to YES the
 # list will mention the files that were used to generate the documentation.
 
 SHOW_USED_FILES        = YES
 
+# If the sources in your project are distributed over multiple directories
+# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy
+# in the documentation. The default is NO.
+
+SHOW_DIRECTORIES       = NO
+
+# Set the SHOW_FILES tag to NO to disable the generation of the Files page.
+# This will remove the Files entry from the Quick Index and from the
+# Folder Tree View (if specified). The default is YES.
+
+SHOW_FILES             = YES
+
+# Set the SHOW_NAMESPACES tag to NO to disable the generation of the
+# Namespaces page.
+# This will remove the Namespaces entry from the Quick Index
+# and from the Folder Tree View (if specified). The default is YES.
+
+SHOW_NAMESPACES        = YES
+
+# The FILE_VERSION_FILTER tag can be used to specify a program or script that
+# doxygen should invoke to get the current version for each file (typically from
+# the version control system). Doxygen will invoke the program by executing (via
+# popen()) the command <command> <input-file>, where <command> is the value of
+# the FILE_VERSION_FILTER tag, and <input-file> is the name of an input file
+# provided by doxygen. Whatever the program writes to standard output
+# is used as the file version. See the manual for examples.
+
+FILE_VERSION_FILTER    =
+
+# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed by
+# doxygen. The layout file controls the global structure of the generated output files
+# in an output format independent way. The create the layout file that represents
+# doxygen's defaults, run doxygen with the -l option. You can optionally specify a
+# file name after the option, if omitted DoxygenLayout.xml will be used as the name
+# of the layout file.
+
+LAYOUT_FILE            =
+
 #---------------------------------------------------------------------------
 # configuration options related to warning and progress messages
 #---------------------------------------------------------------------------
 
-# The QUIET tag can be used to turn on/off the messages that are generated 
+# The QUIET tag can be used to turn on/off the messages that are generated
 # by doxygen. Possible values are YES and NO. If left blank NO is used.
 
 QUIET                  = YES
 
-# The WARNINGS tag can be used to turn on/off the warning messages that are 
-# generated by doxygen. Possible values are YES and NO. If left blank 
+# The WARNINGS tag can be used to turn on/off the warning messages that are
+# generated by doxygen. Possible values are YES and NO. If left blank
 # NO is used.
 
 WARNINGS               = YES
 
-# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings 
-# for undocumented members. If EXTRACT_ALL is set to YES then this flag will 
+# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings
+# for undocumented members. If EXTRACT_ALL is set to YES then this flag will
 # automatically be disabled.
 
 WARN_IF_UNDOCUMENTED   = YES
 
-# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for 
-# potential errors in the documentation, such as not documenting some 
-# parameters in a documented function, or documenting parameters that 
+# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for
+# potential errors in the documentation, such as not documenting some
+# parameters in a documented function, or documenting parameters that
 # don't exist or using markup commands wrongly.
 
 WARN_IF_DOC_ERROR      = YES
 
-# The WARN_FORMAT tag determines the format of the warning messages that 
-# doxygen can produce. The string should contain the $file, $line, and $text 
-# tags, which will be replaced by the file and line number from which the 
-# warning originated and the warning text.
+# This WARN_NO_PARAMDOC option can be abled to get warnings for
+# functions that are documented, but have no documentation for their parameters
+# or return value. If set to NO (the default) doxygen will only warn about
+# wrong or incomplete parameter documentation, but not about the absence of
+# documentation.
+
+WARN_NO_PARAMDOC       = NO
+
+# The WARN_FORMAT tag determines the format of the warning messages that
+# doxygen can produce. The string should contain the $file, $line, and $text
+# tags, which will be replaced by the file and line number from which the
+# warning originated and the warning text. Optionally the format may contain
+# $version, which will be replaced by the version of the file (if it could
+# be obtained via FILE_VERSION_FILTER)
 
 WARN_FORMAT            = "$file:$line: $text"
 
-# The WARN_LOGFILE tag can be used to specify a file to which warning 
-# and error messages should be written. If left blank the output is written 
+# The WARN_LOGFILE tag can be used to specify a file to which warning
+# and error messages should be written. If left blank the output is written
 # to stderr.
 
-WARN_LOGFILE           = 
+WARN_LOGFILE           =
 
 #---------------------------------------------------------------------------
 # configuration options related to the input files
 #---------------------------------------------------------------------------
 
-# The INPUT tag can be used to specify the files and/or directories that contain 
-# documented source files. You may enter file names like "myfile.cpp" or 
-# directories like "/usr/src/myproject". Separate the files or directories 
+# The INPUT tag can be used to specify the files and/or directories that contain
+# documented source files. You may enter file names like "myfile.cpp" or
+# directories like "/usr/src/myproject". Separate the files or directories
 # with spaces.
 
 INPUT                  = @srcdir@/.. \
                          @srcdir@/../input \
                          @srcdir@/../config
 
-# If the value of the INPUT tag contains directories, you can use the 
-# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp 
-# and *.h) to filter out the source-files in the directories. If left 
-# blank the following patterns are tested: 
-# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx *.hpp 
-# *.h++ *.idl *.odl *.cs *.php *.php3 *.inc
+# This tag can be used to specify the character encoding of the source files
+# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
+# also the default input encoding. Doxygen uses libiconv (or the iconv built
+# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for
+# the list of possible encodings.
 
-FILE_PATTERNS          = 
+INPUT_ENCODING         = UTF-8
 
-# The RECURSIVE tag can be used to turn specify whether or not subdirectories 
-# should be searched for input files as well. Possible values are YES and NO. 
+# If the value of the INPUT tag contains directories, you can use the
+# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
+# and *.h) to filter out the source-files in the directories. If left
+# blank the following patterns are tested:
+# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx
+# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90
+
+FILE_PATTERNS          =
+
+# The RECURSIVE tag can be used to turn specify whether or not subdirectories
+# should be searched for input files as well. Possible values are YES and NO.
 # If left blank NO is used.
 
 RECURSIVE              = NO
 
-# The EXCLUDE tag can be used to specify files and/or directories that should 
-# excluded from the INPUT source files. This way you can easily exclude a 
+# The EXCLUDE tag can be used to specify files and/or directories that should
+# excluded from the INPUT source files. This way you can easily exclude a
 # subdirectory from a directory tree whose root is specified with the INPUT tag.
 
 EXCLUDE                = @srcdir@/../config/parser.c \
                          @srcdir@/../config/parser.h \
                          @srcdir@/../config/scanner.c
 
-# The EXCLUDE_SYMLINKS tag can be used select whether or not files or directories 
-# that are symbolic links (a Unix filesystem feature) are excluded from the input.
+# The EXCLUDE_SYMLINKS tag can be used select whether or not files or
+# directories that are symbolic links (a Unix filesystem feature) are excluded
+# from the input.
 
 EXCLUDE_SYMLINKS       = YES
 
-# If the value of the INPUT tag contains directories, you can use the 
-# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude 
-# certain files from those directories.
+# If the value of the INPUT tag contains directories, you can use the
+# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude
+# certain files from those directories. Note that the wildcards are matched
+# against the file with absolute path, so to exclude all test directories
+# for example use the pattern */test/*
 
 EXCLUDE_PATTERNS       = atKeynames.h \
                          Canvas*.*
 
-# The EXAMPLE_PATH tag can be used to specify one or more files or 
-# directories that contain example code fragments that are included (see 
+# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
+# (namespaces, classes, functions, etc.) that should be excluded from the
+# output. The symbol name can be a fully qualified name, a word, or if the
+# wildcard * is used, a substring. Examples: ANamespace, AClass,
+# AClass::ANamespace, ANamespace::*Test
+
+EXCLUDE_SYMBOLS        =
+
+# The EXAMPLE_PATH tag can be used to specify one or more files or
+# directories that contain example code fragments that are included (see
 # the \include command).
 
-EXAMPLE_PATH           = 
+EXAMPLE_PATH           =
 
-# If the value of the EXAMPLE_PATH tag contains directories, you can use the 
-# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp 
-# and *.h) to filter out the source-files in the directories. If left 
+# If the value of the EXAMPLE_PATH tag contains directories, you can use the
+# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
+# and *.h) to filter out the source-files in the directories. If left
 # blank all files are included.
 
-EXAMPLE_PATTERNS       = 
+EXAMPLE_PATTERNS       =
 
-# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be 
-# searched for input files to be used with the \include or \dontinclude 
-# commands irrespective of the value of the RECURSIVE tag. 
+# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be
+# searched for input files to be used with the \include or \dontinclude
+# commands irrespective of the value of the RECURSIVE tag.
 # Possible values are YES and NO. If left blank NO is used.
 
 EXAMPLE_RECURSIVE      = NO
 
-# The IMAGE_PATH tag can be used to specify one or more files or 
-# directories that contain image that are included in the documentation (see 
+# The IMAGE_PATH tag can be used to specify one or more files or
+# directories that contain image that are included in the documentation (see
 # the \image command).
 
-IMAGE_PATH             = 
+IMAGE_PATH             =
 
-# The INPUT_FILTER tag can be used to specify a program that doxygen should 
-# invoke to filter for each input file. Doxygen will invoke the filter program 
-# by executing (via popen()) the command <filter> <input-file>, where <filter> 
-# is the value of the INPUT_FILTER tag, and <input-file> is the name of an 
-# input file. Doxygen will then use the output that the filter program writes 
+# The INPUT_FILTER tag can be used to specify a program that doxygen should
+# invoke to filter for each input file. Doxygen will invoke the filter program
+# by executing (via popen()) the command <filter> <input-file>, where <filter>
+# is the value of the INPUT_FILTER tag, and <input-file> is the name of an
+# input file. Doxygen will then use the output that the filter program writes
 # to standard output.
+# If FILTER_PATTERNS is specified, this tag will be
+# ignored.
 
-INPUT_FILTER           = 
+INPUT_FILTER           =
 
-# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using 
-# INPUT_FILTER) will be used to filter the input files when producing source 
+# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern
+# basis.
+# Doxygen will compare the file name with each pattern and apply the
+# filter if there is a match.
+# The filters are a list of the form:
+# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further
+# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER
+# is applied to all files.
+
+FILTER_PATTERNS        =
+
+# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using
+# INPUT_FILTER) will be used to filter the input files when producing source
 # files to browse (i.e. when SOURCE_BROWSER is set to YES).
 
 FILTER_SOURCE_FILES    = NO
@@ -428,36 +690,54 @@ FILTER_SOURCE_FILES    = NO
 # configuration options related to source browsing
 #---------------------------------------------------------------------------
 
-# If the SOURCE_BROWSER tag is set to YES then a list of source files will 
+# If the SOURCE_BROWSER tag is set to YES then a list of source files will
 # be generated. Documented entities will be cross-referenced with these sources.
+# Note: To get rid of all source code in the generated output, make sure also
+# VERBATIM_HEADERS is set to NO.
 
 SOURCE_BROWSER         = NO
 
-# Setting the INLINE_SOURCES tag to YES will include the body 
+# Setting the INLINE_SOURCES tag to YES will include the body
 # of functions and classes directly in the documentation.
 
 INLINE_SOURCES         = NO
 
-# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct 
-# doxygen to hide any special comment blocks from generated source code 
+# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct
+# doxygen to hide any special comment blocks from generated source code
 # fragments. Normal C and C++ comments will always remain visible.
 
 STRIP_CODE_COMMENTS    = YES
 
-# If the REFERENCED_BY_RELATION tag is set to YES (the default) 
-# then for each documented function all documented 
+# If the REFERENCED_BY_RELATION tag is set to YES
+# then for each documented function all documented
 # functions referencing it will be listed.
 
 REFERENCED_BY_RELATION = YES
 
-# If the REFERENCES_RELATION tag is set to YES (the default) 
-# then for each documented function all documented entities 
+# If the REFERENCES_RELATION tag is set to YES
+# then for each documented function all documented entities
 # called/used by that function will be listed.
 
 REFERENCES_RELATION    = YES
 
-# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen 
-# will generate a verbatim copy of the header file for each class for 
+# If the REFERENCES_LINK_SOURCE tag is set to YES (the default)
+# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from
+# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will
+# link to the source code.
+# Otherwise they will link to the documentation.
+
+REFERENCES_LINK_SOURCE = YES
+
+# If the USE_HTAGS tag is set to YES then the references to source code
+# will point to the HTML generated by the htags(1) tool instead of doxygen
+# built-in source browser. The htags tool is part of GNU's global source
+# tagging system (see http://www.gnu.org/software/global/global.html). You
+# will need version 4.8.6 or higher.
+
+USE_HTAGS              = NO
+
+# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen
+# will generate a verbatim copy of the header file for each class for
 # which an include is specified. Set to NO to disable this.
 
 VERBATIM_HEADERS       = YES
@@ -466,277 +746,424 @@ VERBATIM_HEADERS       = YES
 # configuration options related to the alphabetical class index
 #---------------------------------------------------------------------------
 
-# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index 
-# of all compounds will be generated. Enable this if the project 
+# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index
+# of all compounds will be generated. Enable this if the project
 # contains a lot of classes, structs, unions or interfaces.
 
 ALPHABETICAL_INDEX     = YES
 
-# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then 
-# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns 
+# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then
+# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns
 # in which this list will be split (can be a number in the range [1..20])
 
 COLS_IN_ALPHA_INDEX    = 5
 
-# In case all classes in a project start with a common prefix, all 
-# classes will be put under the same header in the alphabetical index. 
-# The IGNORE_PREFIX tag can be used to specify one or more prefixes that 
+# In case all classes in a project start with a common prefix, all
+# classes will be put under the same header in the alphabetical index.
+# The IGNORE_PREFIX tag can be used to specify one or more prefixes that
 # should be ignored while generating the index headers.
 
-IGNORE_PREFIX          = 
+IGNORE_PREFIX          =
 
 #---------------------------------------------------------------------------
 # configuration options related to the HTML output
 #---------------------------------------------------------------------------
 
-# If the GENERATE_HTML tag is set to YES (the default) Doxygen will 
+# If the GENERATE_HTML tag is set to YES (the default) Doxygen will
 # generate HTML output.
 
 GENERATE_HTML          = YES
 
-# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. 
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# The HTML_OUTPUT tag is used to specify where the HTML docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
 # put in front of it. If left blank `html' will be used as the default path.
 
 HTML_OUTPUT            = html
 
-# The HTML_FILE_EXTENSION tag can be used to specify the file extension for 
-# each generated HTML page (for example: .htm,.php,.asp). If it is left blank 
+# The HTML_FILE_EXTENSION tag can be used to specify the file extension for
+# each generated HTML page (for example: .htm,.php,.asp). If it is left blank
 # doxygen will generate files with .html extension.
 
 HTML_FILE_EXTENSION    = .html
 
-# The HTML_HEADER tag can be used to specify a personal HTML header for 
-# each generated HTML page. If it is left blank doxygen will generate a 
+# The HTML_HEADER tag can be used to specify a personal HTML header for
+# each generated HTML page. If it is left blank doxygen will generate a
 # standard header.
 
-HTML_HEADER            = @srcdir@/doxygen.head
+HTML_HEADER            =
 
-# The HTML_FOOTER tag can be used to specify a personal HTML footer for 
-# each generated HTML page. If it is left blank doxygen will generate a 
+# The HTML_FOOTER tag can be used to specify a personal HTML footer for
+# each generated HTML page. If it is left blank doxygen will generate a
 # standard footer.
 
-HTML_FOOTER            = @srcdir@/doxygen.foot
+HTML_FOOTER            = @srcdir@/footer.html
+
+# The HTML_STYLESHEET tag can be used to specify a user-defined cascading
+# style sheet that is used by each HTML page. It can be used to
+# fine-tune the look of the HTML output. If the tag is left blank doxygen
+# will generate a default style sheet. Note that doxygen will try to copy
+# the style sheet file to the HTML output directory, so don't put your own
+# stylesheet in the HTML output directory as well, or it will be erased!
 
-# The HTML_STYLESHEET tag can be used to specify a user-defined cascading 
-# style sheet that is used by each HTML page. It can be used to 
-# fine-tune the look of the HTML output. If the tag is left blank doxygen 
-# will generate a default style sheet
+HTML_STYLESHEET        =
 
-HTML_STYLESHEET        = @srcdir@/doxygen.css
+# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML
+# page will contain the date and time when the page was generated. Setting
+# this to NO can help when comparing the output of multiple runs.
 
-# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, 
-# files or namespaces will be aligned in HTML using tables. If set to 
+HTML_TIMESTAMP         = NO
+
+# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes,
+# files or namespaces will be aligned in HTML using tables. If set to
 # NO a bullet list will be used.
 
 HTML_ALIGN_MEMBERS     = YES
 
-# If the GENERATE_HTMLHELP tag is set to YES, additional index files 
-# will be generated that can be used as input for tools like the 
-# Microsoft HTML help workshop to generate a compressed HTML help file (.chm) 
+# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML
+# documentation will contain sections that can be hidden and shown after the
+# page has loaded. For this to work a browser that supports
+# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox
+# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari).
+
+HTML_DYNAMIC_SECTIONS  = NO
+
+# If the GENERATE_DOCSET tag is set to YES, additional index files
+# will be generated that can be used as input for Apple's Xcode 3
+# integrated development environment, introduced with OSX 10.5 (Leopard).
+# To create a documentation set, doxygen will generate a Makefile in the
+# HTML output directory. Running make will produce the docset in that
+# directory and running "make install" will install the docset in
+# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find
+# it at startup.
+# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html for more information.
+
+GENERATE_DOCSET        = NO
+
+# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the
+# feed. A documentation feed provides an umbrella under which multiple
+# documentation sets from a single provider (such as a company or product suite)
+# can be grouped.
+
+DOCSET_FEEDNAME        = "Doxygen generated docs"
+
+# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that
+# should uniquely identify the documentation set bundle. This should be a
+# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen
+# will append .docset to the name.
+
+DOCSET_BUNDLE_ID       = org.doxygen.Project
+
+# If the GENERATE_HTMLHELP tag is set to YES, additional index files
+# will be generated that can be used as input for tools like the
+# Microsoft HTML help workshop to generate a compiled HTML help file (.chm)
 # of the generated HTML documentation.
 
 GENERATE_HTMLHELP      = NO
 
-# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can 
-# be used to specify the file name of the resulting .chm file. You 
-# can add a path in front of the file if the result should not be 
-# written to the html output dir.
+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can
+# be used to specify the file name of the resulting .chm file. You
+# can add a path in front of the file if the result should not be
+# written to the html output directory.
 
-CHM_FILE               = 
+CHM_FILE               =
 
-# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can 
-# be used to specify the location (absolute path including file name) of 
-# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run 
+# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can
+# be used to specify the location (absolute path including file name) of
+# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run
 # the HTML help compiler on the generated index.hhp.
 
-HHC_LOCATION           = 
+HHC_LOCATION           =
 
-# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag 
-# controls if a separate .chi index file is generated (YES) or that 
+# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag
+# controls if a separate .chi index file is generated (YES) or that
 # it should be included in the master .chm file (NO).
 
 GENERATE_CHI           = NO
 
-# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag 
-# controls whether a binary table of contents is generated (YES) or a 
+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING
+# is used to encode HtmlHelp index (hhk), content (hhc) and project file
+# content.
+
+CHM_INDEX_ENCODING     =
+
+# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag
+# controls whether a binary table of contents is generated (YES) or a
 # normal table of contents (NO) in the .chm file.
 
 BINARY_TOC             = NO
 
-# The TOC_EXPAND flag can be set to YES to add extra items for group members 
+# The TOC_EXPAND flag can be set to YES to add extra items for group members
 # to the contents of the HTML help documentation and to the tree view.
 
 TOC_EXPAND             = NO
 
-# The DISABLE_INDEX tag can be used to turn on/off the condensed index at 
-# top of each HTML page. The value NO (the default) enables the index and 
+# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and QHP_VIRTUAL_FOLDER
+# are set, an additional index file will be generated that can be used as input for
+# Qt's qhelpgenerator to generate a Qt Compressed Help (.qch) of the generated
+# HTML documentation.
+
+GENERATE_QHP           = NO
+
+# If the QHG_LOCATION tag is specified, the QCH_FILE tag can
+# be used to specify the file name of the resulting .qch file.
+# The path specified is relative to the HTML output folder.
+
+QCH_FILE               =
+
+# The QHP_NAMESPACE tag specifies the namespace to use when generating
+# Qt Help Project output. For more information please see
+# http://doc.trolltech.com/qthelpproject.html#namespace
+
+QHP_NAMESPACE          = org.doxygen.Project
+
+# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating
+# Qt Help Project output. For more information please see
+# http://doc.trolltech.com/qthelpproject.html#virtual-folders
+
+QHP_VIRTUAL_FOLDER     = doc
+
+# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to add.
+# For more information please see
+# http://doc.trolltech.com/qthelpproject.html#custom-filters
+
+QHP_CUST_FILTER_NAME   =
+
+# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the custom filter to add.For more information please see
+# <a href="http://doc.trolltech.com/qthelpproject.html#custom-filters">Qt Help Project / Custom Filters</a>.
+
+QHP_CUST_FILTER_ATTRS  =
+
+# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this project's
+# filter section matches.
+# <a href="http://doc.trolltech.com/qthelpproject.html#filter-attributes">Qt Help Project / Filter Attributes</a>.
+
+QHP_SECT_FILTER_ATTRS  =
+
+# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can
+# be used to specify the location of Qt's qhelpgenerator.
+# If non-empty doxygen will try to run qhelpgenerator on the generated
+# .qhp file.
+
+QHG_LOCATION           =
+
+# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files
+#  will be generated, which together with the HTML files, form an Eclipse help
+#  plugin. To install this plugin and make it available under the help contents
+# menu in Eclipse, the contents of the directory containing the HTML and XML
+# files needs to be copied into the plugins directory of eclipse. The name of
+# the directory within the plugins directory should be the same as
+# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before the help appears.
+
+GENERATE_ECLIPSEHELP   = NO
+
+# A unique identifier for the eclipse help plugin. When installing the plugin
+# the directory name containing the HTML and XML files should also have
+# this name.
+
+ECLIPSE_DOC_ID         = org.doxygen.Project
+
+# The DISABLE_INDEX tag can be used to turn on/off the condensed index at
+# top of each HTML page. The value NO (the default) enables the index and
 # the value YES disables it.
 
 DISABLE_INDEX          = NO
 
-# This tag can be used to set the number of enum values (range [1..20]) 
+# This tag can be used to set the number of enum values (range [1..20])
 # that doxygen will group on one line in the generated HTML documentation.
 
 ENUM_VALUES_PER_LINE   = 4
 
-# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be
-# generated containing a tree-like index structure (just like the one that 
-# is generated for HTML Help). For this to work a browser that supports 
-# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, 
-# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are 
-# probably better off using the HTML help feature.
+# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index
+# structure should be generated to display hierarchical information.
+# If the tag value is set to YES, a side panel will be generated
+# containing a tree-like index structure (just like the one that
+# is generated for HTML Help). For this to work a browser that supports
+# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser).
+# Windows users are probably better off using the HTML help feature.
 
 GENERATE_TREEVIEW      = YES
 
-# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be 
-# used to set the initial width (in pixels) of the frame in which the tree 
+# By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories,
+# and Class Hierarchy pages using a tree view instead of an ordered list.
+
+USE_INLINE_TREES       = NO
+
+# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be
+# used to set the initial width (in pixels) of the frame in which the tree
 # is shown.
 
 TREEVIEW_WIDTH         = 250
 
+# Use this tag to change the font size of Latex formulas included
+# as images in the HTML documentation. The default is 10. Note that
+# when you change the font size after a successful doxygen run you need
+# to manually remove any form_*.png images from the HTML output directory
+# to force them to be regenerated.
+
+FORMULA_FONTSIZE       = 10
+
+# When the SEARCHENGINE tag is enabled doxygen will generate a search box for the HTML output. The underlying search engine uses javascript
+# and DHTML and should work on any modern browser. Note that when using HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets (GENERATE_DOCSET) there is already a search function so this one should
+# typically be disabled. For large projects the javascript based search engine
+# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution.
+
+SEARCHENGINE           = NO
+
+# When the SERVER_BASED_SEARCH tag is enabled the search engine will be implemented using a PHP enabled web server instead of at the web client using Javascript. Doxygen will generate the search PHP script and index
+# file to put on the web server. The advantage of the server based approach is that it scales better to large projects and allows full text search. The disadvances is that it is more difficult to setup
+# and does not have live searching capabilities.
+
+SERVER_BASED_SEARCH    = NO
+
 #---------------------------------------------------------------------------
 # configuration options related to the LaTeX output
 #---------------------------------------------------------------------------
 
-# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will 
+# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will
 # generate Latex output.
 
 GENERATE_LATEX         = NO
 
-# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. 
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
 # put in front of it. If left blank `latex' will be used as the default path.
 
 LATEX_OUTPUT           = latex
 
-# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be 
+# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be
 # invoked. If left blank `latex' will be used as the default command name.
+# Note that when enabling USE_PDFLATEX this option is only used for
+# generating bitmaps for formulas in the HTML output, but not in the
+# Makefile that is written to the output directory.
 
 LATEX_CMD_NAME         = latex
 
-# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to 
-# generate index for LaTeX. If left blank `makeindex' will be used as the 
+# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to
+# generate index for LaTeX. If left blank `makeindex' will be used as the
 # default command name.
 
 MAKEINDEX_CMD_NAME     = makeindex
 
-# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact 
-# LaTeX documents. This may be useful for small projects and may help to 
+# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact
+# LaTeX documents. This may be useful for small projects and may help to
 # save some trees in general.
 
 COMPACT_LATEX          = NO
 
-# The PAPER_TYPE tag can be used to set the paper type that is used 
-# by the printer. Possible values are: a4, a4wide, letter, legal and 
+# The PAPER_TYPE tag can be used to set the paper type that is used
+# by the printer. Possible values are: a4, a4wide, letter, legal and
 # executive. If left blank a4wide will be used.
 
 PAPER_TYPE             = a4wide
 
-# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX 
+# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX
 # packages that should be included in the LaTeX output.
 
-EXTRA_PACKAGES         = 
+EXTRA_PACKAGES         =
 
-# The LATEX_HEADER tag can be used to specify a personal LaTeX header for 
-# the generated latex document. The header should contain everything until 
-# the first chapter. If it is left blank doxygen will generate a 
+# The LATEX_HEADER tag can be used to specify a personal LaTeX header for
+# the generated latex document. The header should contain everything until
+# the first chapter. If it is left blank doxygen will generate a
 # standard header. Notice: only use this tag if you know what you are doing!
 
-LATEX_HEADER           = 
+LATEX_HEADER           =
 
-# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated 
-# is prepared for conversion to pdf (using ps2pdf). The pdf file will 
-# contain links (just like the HTML output) instead of page references 
+# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated
+# is prepared for conversion to pdf (using ps2pdf). The pdf file will
+# contain links (just like the HTML output) instead of page references
 # This makes the output suitable for online browsing using a pdf viewer.
 
 PDF_HYPERLINKS         = NO
 
-# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of 
-# plain latex in the generated Makefile. Set this option to YES to get a 
+# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of
+# plain latex in the generated Makefile. Set this option to YES to get a
 # higher quality PDF documentation.
 
 USE_PDFLATEX           = NO
 
-# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. 
-# command to the generated LaTeX files. This will instruct LaTeX to keep 
-# running if errors occur, instead of asking the user for help. 
+# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode.
+# command to the generated LaTeX files. This will instruct LaTeX to keep
+# running if errors occur, instead of asking the user for help.
 # This option is also used when generating formulas in HTML.
 
 LATEX_BATCHMODE        = NO
 
-# If LATEX_HIDE_INDICES is set to YES then doxygen will not 
-# include the index chapters (such as File Index, Compound Index, etc.) 
+# If LATEX_HIDE_INDICES is set to YES then doxygen will not
+# include the index chapters (such as File Index, Compound Index, etc.)
 # in the output.
 
 LATEX_HIDE_INDICES     = NO
 
+# If LATEX_SOURCE_CODE is set to YES then doxygen will include source code with syntax highlighting in the LaTeX output. Note that which sources are shown also depends on other settings such as SOURCE_BROWSER.
+
+LATEX_SOURCE_CODE      = NO
+
 #---------------------------------------------------------------------------
 # configuration options related to the RTF output
 #---------------------------------------------------------------------------
 
-# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output 
-# The RTF output is optimised for Word 97 and may not look very pretty with 
+# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output
+# The RTF output is optimized for Word 97 and may not look very pretty with
 # other RTF readers or editors.
 
 GENERATE_RTF           = NO
 
-# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. 
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# The RTF_OUTPUT tag is used to specify where the RTF docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
 # put in front of it. If left blank `rtf' will be used as the default path.
 
 RTF_OUTPUT             = rtf
 
-# If the COMPACT_RTF tag is set to YES Doxygen generates more compact 
-# RTF documents. This may be useful for small projects and may help to 
+# If the COMPACT_RTF tag is set to YES Doxygen generates more compact
+# RTF documents. This may be useful for small projects and may help to
 # save some trees in general.
 
 COMPACT_RTF            = NO
 
-# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated 
-# will contain hyperlink fields. The RTF file will 
-# contain links (just like the HTML output) instead of page references. 
-# This makes the output suitable for online browsing using WORD or other 
-# programs which support those fields. 
+# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated
+# will contain hyperlink fields. The RTF file will
+# contain links (just like the HTML output) instead of page references.
+# This makes the output suitable for online browsing using WORD or other
+# programs which support those fields.
 # Note: wordpad (write) and others do not support links.
 
 RTF_HYPERLINKS         = NO
 
-# Load stylesheet definitions from file. Syntax is similar to doxygen's 
-# config file, i.e. a series of assigments. You only have to provide 
+# Load stylesheet definitions from file. Syntax is similar to doxygen's
+# config file, i.e. a series of assignments. You only have to provide
 # replacements, missing definitions are set to their default value.
 
-RTF_STYLESHEET_FILE    = 
+RTF_STYLESHEET_FILE    =
 
-# Set optional variables used in the generation of an rtf document. 
+# Set optional variables used in the generation of an rtf document.
 # Syntax is similar to doxygen's config file.
 
-RTF_EXTENSIONS_FILE    = 
+RTF_EXTENSIONS_FILE    =
 
 #---------------------------------------------------------------------------
 # configuration options related to the man page output
 #---------------------------------------------------------------------------
 
-# If the GENERATE_MAN tag is set to YES (the default) Doxygen will 
+# If the GENERATE_MAN tag is set to YES (the default) Doxygen will
 # generate man pages
 
 GENERATE_MAN           = NO
 
-# The MAN_OUTPUT tag is used to specify where the man pages will be put. 
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# The MAN_OUTPUT tag is used to specify where the man pages will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
 # put in front of it. If left blank `man' will be used as the default path.
 
 MAN_OUTPUT             = man
 
-# The MAN_EXTENSION tag determines the extension that is added to 
+# The MAN_EXTENSION tag determines the extension that is added to
 # the generated man pages (default is the subroutine's section .3)
 
 MAN_EXTENSION          = .3
 
-# If the MAN_LINKS tag is set to YES and Doxygen generates man output, 
-# then it will generate one additional man file for each entity 
-# documented in the real man page(s). These additional files 
-# only source the real man page, but without them the man command 
+# If the MAN_LINKS tag is set to YES and Doxygen generates man output,
+# then it will generate one additional man file for each entity
+# documented in the real man page(s). These additional files
+# only source the real man page, but without them the man command
 # would be unable to find the correct page. The default is NO.
 
 MAN_LINKS              = NO
@@ -745,40 +1172,45 @@ MAN_LINKS              = NO
 # configuration options related to the XML output
 #---------------------------------------------------------------------------
 
-# If the GENERATE_XML tag is set to YES Doxygen will 
-# generate an XML file that captures the structure of 
-# the code including all documentation. Note that this 
-# feature is still experimental and incomplete at the 
-# moment.
+# If the GENERATE_XML tag is set to YES Doxygen will
+# generate an XML file that captures the structure of
+# the code including all documentation.
 
 GENERATE_XML           = NO
 
-# The XML_OUTPUT tag is used to specify where the XML pages will be put. 
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# The XML_OUTPUT tag is used to specify where the XML pages will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
 # put in front of it. If left blank `xml' will be used as the default path.
 
 XML_OUTPUT             = xml
 
-# The XML_SCHEMA tag can be used to specify an XML schema, 
-# which can be used by a validating XML parser to check the 
+# The XML_SCHEMA tag can be used to specify an XML schema,
+# which can be used by a validating XML parser to check the
 # syntax of the XML files.
 
-XML_SCHEMA             = 
+XML_SCHEMA             =
 
-# The XML_DTD tag can be used to specify an XML DTD, 
-# which can be used by a validating XML parser to check the 
+# The XML_DTD tag can be used to specify an XML DTD,
+# which can be used by a validating XML parser to check the
 # syntax of the XML files.
 
-XML_DTD                = 
+XML_DTD                =
+
+# If the XML_PROGRAMLISTING tag is set to YES Doxygen will
+# dump the program listings (including syntax highlighting
+# and cross-referencing information) to the XML output. Note that
+# enabling this will significantly increase the size of the XML output.
+
+XML_PROGRAMLISTING     = YES
 
 #---------------------------------------------------------------------------
 # configuration options for the AutoGen Definitions output
 #---------------------------------------------------------------------------
 
-# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will 
-# generate an AutoGen Definitions (see autogen.sf.net) file 
-# that captures the structure of the code including all 
-# documentation. Note that this feature is still experimental 
+# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will
+# generate an AutoGen Definitions (see autogen.sf.net) file
+# that captures the structure of the code including all
+# documentation. Note that this feature is still experimental
 # and incomplete at the moment.
 
 GENERATE_AUTOGEN_DEF   = NO
@@ -787,267 +1219,341 @@ GENERATE_AUTOGEN_DEF   = NO
 # configuration options related to the Perl module output
 #---------------------------------------------------------------------------
 
-# If the GENERATE_PERLMOD tag is set to YES Doxygen will 
-# generate a Perl module file that captures the structure of 
-# the code including all documentation. Note that this 
-# feature is still experimental and incomplete at the 
+# If the GENERATE_PERLMOD tag is set to YES Doxygen will
+# generate a Perl module file that captures the structure of
+# the code including all documentation. Note that this
+# feature is still experimental and incomplete at the
 # moment.
 
 GENERATE_PERLMOD       = NO
 
-# If the PERLMOD_LATEX tag is set to YES Doxygen will generate 
-# the necessary Makefile rules, Perl scripts and LaTeX code to be able 
+# If the PERLMOD_LATEX tag is set to YES Doxygen will generate
+# the necessary Makefile rules, Perl scripts and LaTeX code to be able
 # to generate PDF and DVI output from the Perl module output.
 
 PERLMOD_LATEX          = NO
 
-# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be 
-# nicely formatted so it can be parsed by a human reader.  This is useful 
-# if you want to understand what is going on.  On the other hand, if this 
-# tag is set to NO the size of the Perl module output will be much smaller 
+# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be
+# nicely formatted so it can be parsed by a human reader.
+# This is useful
+# if you want to understand what is going on.
+# On the other hand, if this
+# tag is set to NO the size of the Perl module output will be much smaller
 # and Perl will parse it just the same.
 
 PERLMOD_PRETTY         = YES
 
-# The names of the make variables in the generated doxyrules.make file 
-# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. 
-# This is useful so different doxyrules.make files included by the same 
+# The names of the make variables in the generated doxyrules.make file
+# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX.
+# This is useful so different doxyrules.make files included by the same
 # Makefile don't overwrite each other's variables.
 
-PERLMOD_MAKEVAR_PREFIX = 
+PERLMOD_MAKEVAR_PREFIX =
 
 #---------------------------------------------------------------------------
-# Configuration options related to the preprocessor   
+# Configuration options related to the preprocessor
 #---------------------------------------------------------------------------
 
-# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will 
-# evaluate all C-preprocessor directives found in the sources and include 
+# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will
+# evaluate all C-preprocessor directives found in the sources and include
 # files.
 
 ENABLE_PREPROCESSING   = YES
 
-# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro 
-# names in the source code. If set to NO (the default) only conditional 
-# compilation will be performed. Macro expansion can be done in a controlled 
+# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro
+# names in the source code. If set to NO (the default) only conditional
+# compilation will be performed. Macro expansion can be done in a controlled
 # way by setting EXPAND_ONLY_PREDEF to YES.
 
 MACRO_EXPANSION        = NO
 
-# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES 
-# then the macro expansion is limited to the macros specified with the 
-# PREDEFINED and EXPAND_AS_PREDEFINED tags.
+# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES
+# then the macro expansion is limited to the macros specified with the
+# PREDEFINED and EXPAND_AS_DEFINED tags.
 
 EXPAND_ONLY_PREDEF     = NO
 
-# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files 
+# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files
 # in the INCLUDE_PATH (see below) will be search if a #include is found.
 
 SEARCH_INCLUDES        = YES
 
-# The INCLUDE_PATH tag can be used to specify one or more directories that 
-# contain include files that are not input files but should be processed by 
+# The INCLUDE_PATH tag can be used to specify one or more directories that
+# contain include files that are not input files but should be processed by
 # the preprocessor.
 
-INCLUDE_PATH           = 
+INCLUDE_PATH           =
 
-# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard 
-# patterns (like *.h and *.hpp) to filter out the header-files in the 
-# directories. If left blank, the patterns specified with FILE_PATTERNS will 
+# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
+# patterns (like *.h and *.hpp) to filter out the header-files in the
+# directories. If left blank, the patterns specified with FILE_PATTERNS will
 # be used.
 
-INCLUDE_FILE_PATTERNS  = 
+INCLUDE_FILE_PATTERNS  =
 
-# The PREDEFINED tag can be used to specify one or more macro names that 
-# are defined before the preprocessor is started (similar to the -D option of 
-# gcc). The argument of the tag is a list of macros of the form: name 
-# or name=definition (no spaces). If the definition and the = are 
-# omitted =1 is assumed.
+# The PREDEFINED tag can be used to specify one or more macro names that
+# are defined before the preprocessor is started (similar to the -D option of
+# gcc). The argument of the tag is a list of macros of the form: name
+# or name=definition (no spaces). If the definition and the = are
+# omitted =1 is assumed. To prevent a macro definition from being
+# undefined via #undef or recursively expanded use the := operator
+# instead of the = operator.
 
 PREDEFINED             = SHAPE \
                          RENDER \
                          XKB \
                          XINPUT
 
-# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then 
-# this tag can be used to specify a list of macro names that should be expanded. 
-# The macro definition that is found in the sources will be used. 
+# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
+# this tag can be used to specify a list of macro names that should be expanded.
+# The macro definition that is found in the sources will be used.
 # Use the PREDEFINED tag if you want to use a different macro definition.
 
-EXPAND_AS_DEFINED      = 
+EXPAND_AS_DEFINED      =
 
-# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then 
-# doxygen's preprocessor will remove all function-like macros that are alone 
-# on a line, have an all uppercase name, and do not end with a semicolon. Such 
-# function macros are typically used for boiler-plate code, and will confuse the 
-# parser if not removed.
+# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then
+# doxygen's preprocessor will remove all function-like macros that are alone
+# on a line, have an all uppercase name, and do not end with a semicolon. Such
+# function macros are typically used for boiler-plate code, and will confuse
+# the parser if not removed.
 
 SKIP_FUNCTION_MACROS   = YES
 
 #---------------------------------------------------------------------------
-# Configuration::addtions related to external references   
+# Configuration::additions related to external references
 #---------------------------------------------------------------------------
 
-# The TAGFILES option can be used to specify one or more tagfiles. 
-# Optionally an initial location of the external documentation 
-# can be added for each tagfile. The format of a tag file without 
-# this location is as follows: 
-#   TAGFILES = file1 file2 ... 
-# Adding location for the tag files is done as follows: 
-#   TAGFILES = file1=loc1 "file2 = loc2" ... 
-# where "loc1" and "loc2" can be relative or absolute paths or 
-# URLs. If a location is present for each tag, the installdox tool 
+# The TAGFILES option can be used to specify one or more tagfiles.
+# Optionally an initial location of the external documentation
+# can be added for each tagfile. The format of a tag file without
+# this location is as follows:
+#
+# TAGFILES = file1 file2 ...
+# Adding location for the tag files is done as follows:
+#
+# TAGFILES = file1=loc1 "file2 = loc2" ...
+# where "loc1" and "loc2" can be relative or absolute paths or
+# URLs. If a location is present for each tag, the installdox tool
 # does not have to be run to correct the links.
 # Note that each tag file must have a unique name
 # (where the name does NOT include the path)
-# If a tag file is not located in the directory in which doxygen 
+# If a tag file is not located in the directory in which doxygen
 # is run, you must also specify the path to the tagfile here.
 
-TAGFILES               = 
+TAGFILES               =
 
-# When a file name is specified after GENERATE_TAGFILE, doxygen will create 
+# When a file name is specified after GENERATE_TAGFILE, doxygen will create
 # a tag file that is based on the input files it reads.
 
-GENERATE_TAGFILE       = 
+GENERATE_TAGFILE       =
 
-# If the ALLEXTERNALS tag is set to YES all external classes will be listed 
-# in the class index. If set to NO only the inherited external classes 
+# If the ALLEXTERNALS tag is set to YES all external classes will be listed
+# in the class index. If set to NO only the inherited external classes
 # will be listed.
 
 ALLEXTERNALS           = NO
 
-# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed 
-# in the modules index. If set to NO, only the current project's groups will 
+# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed
+# in the modules index. If set to NO, only the current project's groups will
 # be listed.
 
 EXTERNAL_GROUPS        = YES
 
-# The PERL_PATH should be the absolute path and name of the perl script 
+# The PERL_PATH should be the absolute path and name of the perl script
 # interpreter (i.e. the result of `which perl').
 
 PERL_PATH              = /usr/bin/perl
 
 #---------------------------------------------------------------------------
-# Configuration options related to the dot tool   
+# Configuration options related to the dot tool
 #---------------------------------------------------------------------------
 
-# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will 
-# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base or 
-# super classes. Setting the tag to NO turns the diagrams off. Note that this 
-# option is superceded by the HAVE_DOT option below. This is only a fallback. It is 
-# recommended to install and use dot, since it yields more powerful graphs.
+# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will
+# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base
+# or super classes. Setting the tag to NO turns the diagrams off. Note that
+# this option is superseded by the HAVE_DOT option below. This is only a
+# fallback. It is recommended to install and use dot, since it yields more
+# powerful graphs.
 
 CLASS_DIAGRAMS         = YES
 
-# If set to YES, the inheritance and collaboration graphs will hide 
-# inheritance and usage relations if the target is undocumented 
+# You can define message sequence charts within doxygen comments using the \msc
+# command. Doxygen will then run the mscgen tool (see
+# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the
+# documentation. The MSCGEN_PATH tag allows you to specify the directory where
+# the mscgen tool resides. If left empty the tool is assumed to be found in the
+# default search path.
+
+MSCGEN_PATH            =
+
+# If set to YES, the inheritance and collaboration graphs will hide
+# inheritance and usage relations if the target is undocumented
 # or is not a class.
 
 HIDE_UNDOC_RELATIONS   = YES
 
-# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is 
-# available from the path. This tool is part of Graphviz, a graph visualization 
-# toolkit from AT&T and Lucent Bell Labs. The other options in this section 
+# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is
+# available from the path. This tool is part of Graphviz, a graph visualization
+# toolkit from AT&T and Lucent Bell Labs. The other options in this section
 # have no effect if this option is set to NO (the default)
 
 HAVE_DOT               = NO
 
-# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen 
-# will generate a graph for each documented class showing the direct and 
-# indirect inheritance relations. Setting this tag to YES will force the 
+# By default doxygen will write a font called FreeSans.ttf to the output
+# directory and reference it in all dot files that doxygen generates. This
+# font does not include all possible unicode characters however, so when you need
+# these (or just want a differently looking font) you can specify the font name
+# using DOT_FONTNAME. You need need to make sure dot is able to find the font,
+# which can be done by putting it in a standard location or by setting the
+# DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory
+# containing the font.
+
+DOT_FONTNAME           = FreeSans
+
+# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs.
+# The default size is 10pt.
+
+DOT_FONTSIZE           = 10
+
+# By default doxygen will tell dot to use the output directory to look for the
+# FreeSans.ttf font (which doxygen will put there itself). If you specify a
+# different font using DOT_FONTNAME you can set the path where dot
+# can find it using this tag.
+
+DOT_FONTPATH           =
+
+# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for each documented class showing the direct and
+# indirect inheritance relations. Setting this tag to YES will force the
 # the CLASS_DIAGRAMS tag to NO.
 
 CLASS_GRAPH            = YES
 
-# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen 
-# will generate a graph for each documented class showing the direct and 
-# indirect implementation dependencies (inheritance, containment, and 
+# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for each documented class showing the direct and
+# indirect implementation dependencies (inheritance, containment, and
 # class references variables) of the class with other documented classes.
 
 COLLABORATION_GRAPH    = YES
 
-# If the UML_LOOK tag is set to YES doxygen will generate inheritance and 
-# collaboration diagrams in a style similiar to the OMG's Unified Modeling 
+# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for groups, showing the direct groups dependencies
+
+GROUP_GRAPHS           = YES
+
+# If the UML_LOOK tag is set to YES doxygen will generate inheritance and
+# collaboration diagrams in a style similar to the OMG's Unified Modeling
 # Language.
 
 UML_LOOK               = NO
 
-# If set to YES, the inheritance and collaboration graphs will show the 
+# If set to YES, the inheritance and collaboration graphs will show the
 # relations between templates and their instances.
 
 TEMPLATE_RELATIONS     = YES
 
-# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT 
-# tags are set to YES then doxygen will generate a graph for each documented 
-# file showing the direct and indirect include dependencies of the file with 
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT
+# tags are set to YES then doxygen will generate a graph for each documented
+# file showing the direct and indirect include dependencies of the file with
 # other documented files.
 
 INCLUDE_GRAPH          = YES
 
-# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and 
-# HAVE_DOT tags are set to YES then doxygen will generate a graph for each 
-# documented header file showing the documented files that directly or 
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and
+# HAVE_DOT tags are set to YES then doxygen will generate a graph for each
+# documented header file showing the documented files that directly or
 # indirectly include this file.
 
 INCLUDED_BY_GRAPH      = YES
 
-# If the CALL_GRAPH and HAVE_DOT tags are set to YES then doxygen will 
-# generate a call dependency graph for every global function or class method. 
-# Note that enabling this option will significantly increase the time of a run. 
-# So in most cases it will be better to enable call graphs for selected 
-# functions only using the \callgraph command.
+# If the CALL_GRAPH and HAVE_DOT options are set to YES then
+# doxygen will generate a call dependency graph for every global function
+# or class method. Note that enabling this option will significantly increase
+# the time of a run. So in most cases it will be better to enable call graphs
+# for selected functions only using the \callgraph command.
 
 CALL_GRAPH             = NO
 
-# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen 
+# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then
+# doxygen will generate a caller dependency graph for every global function
+# or class method. Note that enabling this option will significantly increase
+# the time of a run. So in most cases it will be better to enable caller
+# graphs for selected functions only using the \callergraph command.
+
+CALLER_GRAPH           = NO
+
+# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen
 # will graphical hierarchy of all classes instead of a textual one.
 
 GRAPHICAL_HIERARCHY    = YES
 
-# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images 
+# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES
+# then doxygen will show the dependencies a directory has on other directories
+# in a graphical way. The dependency relations are determined by the #include
+# relations between the files in the directories.
+
+DIRECTORY_GRAPH        = YES
+
+# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images
 # generated by dot. Possible values are png, jpg, or gif
 # If left blank png will be used.
 
 DOT_IMAGE_FORMAT       = gif
 
-# The tag DOT_PATH can be used to specify the path where the dot tool can be 
-# found. If left blank, it is assumed the dot tool can be found on the path.
+# The tag DOT_PATH can be used to specify the path where the dot tool can be
+# found. If left blank, it is assumed the dot tool can be found in the path.
 
-DOT_PATH               = 
+DOT_PATH               =
 
-# The DOTFILE_DIRS tag can be used to specify one or more directories that 
-# contain dot files that are included in the documentation (see the 
+# The DOTFILE_DIRS tag can be used to specify one or more directories that
+# contain dot files that are included in the documentation (see the
 # \dotfile command).
 
-DOTFILE_DIRS           = 
+DOTFILE_DIRS           =
 
-# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the 
-# graphs generated by dot. A depth value of 3 means that only nodes reachable 
-# from the root by following a path via at most 3 edges will be shown. Nodes that 
-# lay further from the root node will be omitted. Note that setting this option to 
-# 1 or 2 may greatly reduce the computation time needed for large code bases. Also 
-# note that a graph may be further truncated if the graph's image dimensions are 
-# not sufficient to fit the graph (see MAX_DOT_GRAPH_WIDTH and MAX_DOT_GRAPH_HEIGHT). 
-# If 0 is used for the depth value (the default), the graph is not depth-constrained.
+# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of
+# nodes that will be shown in the graph. If the number of nodes in a graph
+# becomes larger than this value, doxygen will truncate the graph, which is
+# visualized by representing a node as a red box. Note that doxygen if the
+# number of direct children of the root node in a graph is already larger than
+# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note
+# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH.
+
+DOT_GRAPH_MAX_NODES    = 50
+
+# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the
+# graphs generated by dot. A depth value of 3 means that only nodes reachable
+# from the root by following a path via at most 3 edges will be shown. Nodes
+# that lay further from the root node will be omitted. Note that setting this
+# option to 1 or 2 may greatly reduce the computation time needed for large
+# code bases. Also note that the size of a graph can be further restricted by
+# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction.
 
 MAX_DOT_GRAPH_DEPTH    = 0
 
-# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will 
-# generate a legend page explaining the meaning of the various boxes and 
+# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent
+# background. This is disabled by default, because dot on Windows does not
+# seem to support this out of the box. Warning: Depending on the platform used,
+# enabling this option may lead to badly anti-aliased labels on the edges of
+# a graph (i.e. they become hard to read).
+
+DOT_TRANSPARENT        = NO
+
+# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output
+# files in one run (i.e. multiple -o and -T options on the command line). This
+# makes dot run faster, but since only newer versions of dot (>1.8.10)
+# support this, this feature is disabled by default.
+
+DOT_MULTI_TARGETS      = YES
+
+# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will
+# generate a legend page explaining the meaning of the various boxes and
 # arrows in the dot generated graphs.
 
 GENERATE_LEGEND        = YES
 
-# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will 
-# remove the intermediate dot files that are used to generate 
+# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will
+# remove the intermediate dot files that are used to generate
 # the various graphs.
 
 DOT_CLEANUP            = YES
-
-#---------------------------------------------------------------------------
-# Configuration::addtions related to the search engine   
-#---------------------------------------------------------------------------
-
-# The SEARCHENGINE tag specifies whether or not a search engine should be 
-# used. If set to NO the values of all tags below this one will be ignored.
-
-SEARCHENGINE           = NO
diff --git a/hw/dmx/doxygen/doxygen.css b/hw/dmx/doxygen/doxygen.css
deleted file mode 100644
index 841f709..0000000
--- a/hw/dmx/doxygen/doxygen.css
+++ /dev/null
@@ -1,49 +0,0 @@
-H1 { text-align: center; }
-CAPTION { font-weight: bold }
-A.qindex {}
-A.qindexRef {}
-A.el { text-decoration: none; font-weight: bold }
-A.elRef { font-weight: bold }
-A.code { text-decoration: none; font-weight: normal; color: #4444ee }
-A.codeRef { font-weight: normal; color: #4444ee }
-A:hover { text-decoration: none; background-color: #f2f2ff }
-DL.el { margin-left: -1cm }
-DIV.fragment { width: 100%; border: none; background-color: #eeeeee }
-DIV.ah { background-color: black; font-weight: bold; color: #ffffff; margin-bottom: 3px; margin-top: 3px }
-TD.md { background-color: #f2f2ff; font-weight: bold; }
-TD.mdname1 { background-color: #f2f2ff; font-weight: bold; color: #602020; }
-TD.mdname { background-color: #f2f2ff; font-weight: bold; color: #602020; width: 600px; }
-DIV.groupHeader { margin-left: 16px; margin-top: 12px; margin-bottom: 6px; font-weight: bold }
-DIV.groupText { margin-left: 16px; font-style: italic; font-size: smaller }
-BODY { background: white }
-TD.indexkey { 
-   background-color: #eeeeff; 
-   font-weight: bold; 
-   padding-right  : 10px; 
-   padding-top    : 2px; 
-   padding-left   : 10px; 
-   padding-bottom : 2px; 
-   margin-left    : 0px; 
-   margin-right   : 0px; 
-   margin-top     : 2px; 
-   margin-bottom  : 2px  
-}
-TD.indexvalue { 
-   background-color: #eeeeff; 
-   font-style: italic; 
-   padding-right  : 10px; 
-   padding-top    : 2px; 
-   padding-left   : 10px; 
-   padding-bottom : 2px; 
-   margin-left    : 0px; 
-   margin-right   : 0px; 
-   margin-top     : 2px; 
-   margin-bottom  : 2px  
-}
-FONT.keyword       { color: #008000 }
-FONT.keywordtype   { color: #604020 }
-FONT.keywordflow   { color: #e08000 }
-FONT.comment       { color: #800000 }
-FONT.preprocessor  { color: #806020 }
-FONT.stringliteral { color: #002080 }
-FONT.charliteral   { color: #008080 }
diff --git a/hw/dmx/doxygen/doxygen.foot b/hw/dmx/doxygen/doxygen.foot
deleted file mode 100644
index 3aca117..0000000
--- a/hw/dmx/doxygen/doxygen.foot
+++ /dev/null
@@ -1,12 +0,0 @@
-    <hr>
-    <address>
-      <small>
-        Generated June 29, 2004 for <a
-        href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
-        <a href="http://www.doxygen.org/index.html">doxygen</a>
-        1.3.4.
-      </small>
-    </addres>
-    </hr>
-  </body>
-</html>
diff --git a/hw/dmx/doxygen/doxygen.head b/hw/dmx/doxygen/doxygen.head
deleted file mode 100644
index 89bda8f..0000000
--- a/hw/dmx/doxygen/doxygen.head
+++ /dev/null
@@ -1,8 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-<html>
-  <head>
-    <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
-    <title>File Index</title>
-    <link href="doxygen.css" rel="stylesheet" type="text/css">
-  </head>
-  <body>
diff --git a/hw/dmx/doxygen/footer.html b/hw/dmx/doxygen/footer.html
new file mode 100644
index 0000000..f80dc82
--- /dev/null
+++ b/hw/dmx/doxygen/footer.html
@@ -0,0 +1,4 @@
+<hr size="1"/><address style="text-align: right;"><small>
+Generated on $datetime for $projectname by <a href="http://www.doxygen.org/index.html"><img class="footer" src="doxygen.png" alt="doxygen"/></a> $doxygenversion</small></address>
+</body>
+</html>
commit 622ebb88157b0ed99355419767685dd70ce0f16c
Author: Gaetan Nadon <memsize at videotron.ca>
Date:   Thu Apr 28 21:16:10 2011 -0400

    dmx: split DocBook/XML and Doxygen makefile targets
    
    Maintaining either requires full knowledge of both.
    It's not obvious one has to check the usage of global variables
    in devbook.am when maintaining doxygen target. Or vice-versa.
    
    Being in their respective directory, one less thing to worry about.
    
    Reviewed-by Jeremy Huddleston <jeremyhu at apple.com>
    Signed-off-by: Gaetan Nadon <memsize at videotron.ca>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/configure.ac b/configure.ac
index 3dce5a6..c6b16b5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2213,7 +2213,8 @@ hw/xfree86/utils/gtf/Makefile
 hw/dmx/config/Makefile
 hw/dmx/config/man/Makefile
 hw/dmx/doc/Makefile
-hw/dmx/doc/doxygen.conf
+hw/dmx/doxygen/doxygen.conf
+hw/dmx/doxygen/Makefile
 hw/dmx/examples/Makefile
 hw/dmx/input/Makefile
 hw/dmx/glxProxy/Makefile
diff --git a/hw/dmx/Makefile.am b/hw/dmx/Makefile.am
index e0b201b..fb727e6 100644
--- a/hw/dmx/Makefile.am
+++ b/hw/dmx/Makefile.am
@@ -1,5 +1,5 @@
 
-SUBDIRS = input config examples doc man
+SUBDIRS = input config examples doc doxygen man
 bin_PROGRAMS = Xdmx
 
 if XINERAMA
diff --git a/hw/dmx/doc/.gitignore b/hw/dmx/doc/.gitignore
index 92c1150..9629c15 100644
--- a/hw/dmx/doc/.gitignore
+++ b/hw/dmx/doc/.gitignore
@@ -1,11 +1,6 @@
-#		Add & Override for this directory and it's subdirectories
-html/
-dmx.html
-dmx.pdf
-dmx.ps
-dmx.txt
-scaled.html
-scaled.pdf
-scaled.ps
-scaled.txt
-doxygen.conf
+*.html
+*.pdf
+*.ps
+*.txt
+!DMXSpec.txt
+!DMXSpec-v1.txt
diff --git a/hw/dmx/doc/Makefile.am b/hw/dmx/doc/Makefile.am
index 40d0550..0713884 100644
--- a/hw/dmx/doc/Makefile.am
+++ b/hw/dmx/doc/Makefile.am
@@ -31,252 +31,4 @@ include $(top_srcdir)/devbook.am
 endif HAVE_XMLTO
 endif ENABLE_DEVEL_DOCS
 
-DOXYGEN_HEAD=\
-	html/annotated.html
-
-DOXYGEN_REST= \
-	html/ChkNotMaskEv_8c.html \
-	html/ChkNotMaskEv_8h.html \
-	html/ChkNotMaskEv_8h_source.html \
-	html/classes.html \
-	html/dmx_8h.html \
-	html/dmx_8h_source.html \
-	html/dmxarg_8c.html \
-	html/dmxarg_8h.html \
-	html/dmxarg_8h_source.html \
-	html/dmxbackend_8c.html \
-	html/dmxbackend_8h.html \
-	html/dmxbackend_8h_source.html \
-	html/dmxcb_8c.html \
-	html/dmxcb_8h.html \
-	html/dmxcb_8h_source.html \
-	html/dmxclient_8h.html \
-	html/dmxclient_8h_source.html \
-	html/dmxcmap_8c.html \
-	html/dmxcmap_8h.html \
-	html/dmxcmap_8h_source.html \
-	html/dmxcommon_8c.html \
-	html/dmxcommon_8h.html \
-	html/dmxcommon_8h_source.html \
-	html/dmxcompat_8c.html \
-	html/dmxcompat_8h.html \
-	html/dmxcompat_8h_source.html \
-	html/dmxconfig_8c.html \
-	html/dmxconfig_8h.html \
-	html/dmxconfig_8h_source.html \
-	html/dmxconsole_8c.html \
-	html/dmxconsole_8h.html \
-	html/dmxconsole_8h_source.html \
-	html/dmxcursor_8c.html \
-	html/dmxcursor_8h.html \
-	html/dmxcursor_8h_source.html \
-	html/dmxdetach_8c.html \
-	html/dmxdpms_8c.html \
-	html/dmxdpms_8h.html \
-	html/dmxdpms_8h_source.html \
-	html/dmxdummy_8c.html \
-	html/dmxdummy_8h.html \
-	html/dmxdummy_8h_source.html \
-	html/dmxevents_8c.html \
-	html/dmxevents_8h.html \
-	html/dmxevents_8h_source.html \
-	html/dmxextension_8c.html \
-	html/dmxextension_8h.html \
-	html/dmxextension_8h_source.html \
-	html/dmxfont_8c.html \
-	html/dmxfont_8h.html \
-	html/dmxfont_8h_source.html \
-	html/dmxgc_8c.html \
-	html/dmxgc_8h.html \
-	html/dmxgc_8h_source.html \
-	html/dmxgcops_8c.html \
-	html/dmxgcops_8h.html \
-	html/dmxgcops_8h_source.html \
-	html/dmx__glxvisuals_8h_source.html \
-	html/dmxinit_8c.html \
-	html/dmxinit_8h.html \
-	html/dmxinit_8h_source.html \
-	html/dmxinput_8c.html \
-	html/dmxinput_8h.html \
-	html/dmxinput_8h_source.html \
-	html/dmxinputinit_8c.html \
-	html/dmxinputinit_8h.html \
-	html/dmxinputinit_8h_source.html \
-	html/dmxlog_8c.html \
-	html/dmxlog_8h.html \
-	html/dmxlog_8h_source.html \
-	html/dmxmap_8c.html \
-	html/dmxmap_8h.html \
-	html/dmxmap_8h_source.html \
-	html/dmxmotion_8c.html \
-	html/dmxmotion_8h.html \
-	html/dmxmotion_8h_source.html \
-	html/dmxparse_8c.html \
-	html/dmxparse_8h.html \
-	html/dmxparse_8h_source.html \
-	html/dmxpict_8c.html \
-	html/dmxpict_8h.html \
-	html/dmxpict_8h_source.html \
-	html/dmxpixmap_8c.html \
-	html/dmxpixmap_8h.html \
-	html/dmxpixmap_8h_source.html \
-	html/dmxprint_8c.html \
-	html/dmxprint_8h.html \
-	html/dmxprint_8h_source.html \
-	html/dmxprop_8c.html \
-	html/dmxprop_8h.html \
-	html/dmxprop_8h_source.html \
-	html/dmxscrinit_8c.html \
-	html/dmxscrinit_8h.html \
-	html/dmxscrinit_8h_source.html \
-	html/dmxshadow_8c.html \
-	html/dmxshadow_8h.html \
-	html/dmxshadow_8h_source.html \
-	html/dmxsigio_8c.html \
-	html/dmxsigio_8h.html \
-	html/dmxsigio_8h_source.html \
-	html/dmxstat_8c.html \
-	html/dmxstat_8h.html \
-	html/dmxstat_8h_source.html \
-	html/dmxsync_8c.html \
-	html/dmxsync_8h.html \
-	html/dmxsync_8h_source.html \
-	html/dmxvisual_8c.html \
-	html/dmxvisual_8h.html \
-	html/dmxvisual_8h_source.html \
-	html/dmxwindow_8c.html \
-	html/dmxwindow_8h.html \
-	html/dmxwindow_8h_source.html \
-	html/dmxxinput_8c.html \
-	html/doxygen.css \
-	html/doxygen.png \
-	html/files.html \
-	html/ftv2blank.png \
-	html/ftv2doc.png \
-	html/ftv2folderclosed.png \
-	html/ftv2folderopen.png \
-	html/ftv2lastnode.png \
-	html/ftv2link.png \
-	html/ftv2mlastnode.png \
-	html/ftv2mnode.png \
-	html/ftv2node.png \
-	html/ftv2plastnode.png \
-	html/ftv2pnode.png \
-	html/ftv2vertline.png \
-	html/functions.html \
-	html/functions_vars.html \
-	html/globals_defs.html \
-	html/globals_enum.html \
-	html/globals_eval.html \
-	html/globals_func.html \
-	html/globals.html \
-	html/globals_type.html \
-	html/globals_vars.html \
-	html/index.html \
-	html/lnx-keyboard_8c.html \
-	html/lnx-keyboard_8h.html \
-	html/lnx-keyboard_8h_source.html \
-	html/lnx-ms_8c.html \
-	html/lnx-ms_8h.html \
-	html/lnx-ms_8h_source.html \
-	html/lnx-ps2_8c.html \
-	html/lnx-ps2_8h.html \
-	html/lnx-ps2_8h_source.html \
-	html/main.html \
-	html/struct__dmxArg.html \
-	html/struct__dmxColormapPriv.html \
-	html/structDMXConfigCmdStruct.html \
-	html/struct__DMXConfigComment.html \
-	html/struct__DMXConfigDisplay.html \
-	html/struct__DMXConfigEntry.html \
-	html/struct__DMXConfigFullDim.html \
-	html/structDMXConfigListStruct.html \
-	html/struct__DMXConfigNumber.html \
-	html/struct__DMXConfigOption.html \
-	html/struct__DMXConfigPair.html \
-	html/struct__DMXConfigParam.html \
-	html/struct__DMXConfigPartDim.html \
-	html/struct__DMXConfigString.html \
-	html/struct__DMXConfigSub.html \
-	html/struct__DMXConfigToken.html \
-	html/struct__DMXConfigVirtual.html \
-	html/struct__DMXConfigWall.html \
-	html/struct__dmxCursorPriv.html \
-	html/structDMXDesktopAttributesRec.html \
-	html/struct__DMXEventMap.html \
-	html/struct__dmxFontPriv.html \
-	html/struct__dmxGCPriv.html \
-	html/structdmxGlxVisualPrivate.html \
-	html/struct__dmxGlyphPriv.html \
-	html/structDMXInputAttributesRec.html \
-	html/struct__DMXInputInfo.html \
-	html/struct__DMXLocalInitInfo.html \
-	html/struct__DMXLocalInputInfo.html \
-	html/struct__dmxPictPriv.html \
-	html/struct__dmxPixPriv.html \
-	html/structDMXScreenAttributesRec.html \
-	html/struct__DMXScreenInfo.html \
-	html/struct__DMXStatAvg.html \
-	html/struct__DMXStatInfo.html \
-	html/structDMXWindowAttributesRec.html \
-	html/struct__dmxWinPriv.html \
-	html/struct__myPrivate.html \
-	html/tree.html \
-	html/usb-common_8c.html \
-	html/usb-common_8h.html \
-	html/usb-common_8h_source.html \
-	html/usb-keyboard_8c.html \
-	html/usb-keyboard_8h.html \
-	html/usb-keyboard_8h_source.html \
-	html/usb-mouse_8c.html \
-	html/usb-mouse_8h.html \
-	html/usb-mouse_8h_source.html \
-	html/usb-other_8c.html \
-	html/usb-other_8h.html \
-	html/usb-other_8h_source.html \
-	html/usb-private_8h.html \
-	html/usb-private_8h_source.html
-
-DOXYGEN_FILES=$(DOXYGEN_HEAD) $(DOXYGEN_REST)
-
-EXTRA_DIST = \
-	DMXSpec.txt \
-	DMXSpec-v1.txt \
-	doxygen.conf \
-	doxygen.css \
-	doxygen.foot \
-	doxygen.head \
-	$(DOXYGEN_FILES)
-
-if ENABLE_DEVEL_DOCS
-if HAVE_DOXYGEN
-
-DOXYGEN_SRC=doxygen.head doxygen.foot doxygen.css doxygen.conf
-
-all-local: $(DOXYGEN_FILES)
-
-dist-local: $(DOXYGEN_FILES)
-
-$(DOXYGEN_HEAD): $(DOXYGEN_SRC)
-	$(DOXYGEN) doxygen.conf
-
-$(DOXYGEN_REST): $(DOXYGEN_HEAD)
-
-maintainer-clean-local:
-	rm -rf html/
-
-distclean-local:
-	rm -rf html/
-
-endif HAVE_DOXYGEN
-endif ENABLE_DEVEL_DOCS
-
-$(builddir)/doxygen.head:
-	$(LN_S) $(srcdir)/doxygen.head $@
-
-$(builddir)/doxygen.foot:
-	$(LN_S) $(srcdir)/doxygen.foot $@
-
-$(builddir)doxygen.css:
-	$(LN_S) $(srcdir)/doxygen.css $@
-
+EXTRA_DIST = DMXSpec.txt DMXSpec-v1.txt
diff --git a/hw/dmx/doc/doxygen.conf.in b/hw/dmx/doc/doxygen.conf.in
deleted file mode 100644
index f886a43..0000000
--- a/hw/dmx/doc/doxygen.conf.in
+++ /dev/null
@@ -1,1053 +0,0 @@
-# Doxyfile 1.3.4
-
-# This file describes the settings to be used by the documentation system
-# doxygen (www.doxygen.org) for a project
-#
-# All text after a hash (#) is considered a comment and will be ignored
-# The format is:
-#       TAG = value [value, ...]
-# For lists items can also be appended using:
-#       TAG += value [value, ...]
-# Values that contain spaces should be placed between quotes (" ")
-
-#---------------------------------------------------------------------------
-# Project related configuration options
-#---------------------------------------------------------------------------
-
-# The PROJECT_NAME tag is a single word (or a sequence of words surrounded 
-# by quotes) that should identify the project.
-
-PROJECT_NAME           = "Distributed Multihead X"
-
-# The PROJECT_NUMBER tag can be used to enter a project or revision number. 
-# This could be handy for archiving the generated documentation or 
-# if some version control system is used.
-
-PROJECT_NUMBER         = "dmx-1-2-20040604 and later"
-
-# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) 
-# base path where the generated documentation will be put. 
-# If a relative path is entered, it will be relative to the location 
-# where doxygen was started. If left blank the current directory will be used.
-
-OUTPUT_DIRECTORY       = 
-
-# The OUTPUT_LANGUAGE tag is used to specify the language in which all 
-# documentation generated by doxygen is written. Doxygen will use this 
-# information to generate all constant output in the proper language. 
-# The default language is English, other supported languages are: 
-# Brazilian, Catalan, Chinese, Chinese-Traditional, Croatian, Czech, Danish, Dutch, 
-# Finnish, French, German, Greek, Hungarian, Italian, Japanese, Japanese-en 
-# (Japanese with English messages), Korean, Norwegian, Polish, Portuguese, 
-# Romanian, Russian, Serbian, Slovak, Slovene, Spanish, Swedish, and Ukrainian.
-
-OUTPUT_LANGUAGE        = English
-
-# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will 
-# include brief member descriptions after the members that are listed in 
-# the file and class documentation (similar to JavaDoc). 
-# Set to NO to disable this.
-
-BRIEF_MEMBER_DESC      = YES
-
-# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend 
-# the brief description of a member or function before the detailed description. 
-# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the 
-# brief descriptions will be completely suppressed.
-
-REPEAT_BRIEF           = YES
-
-# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then 
-# Doxygen will generate a detailed section even if there is only a brief 
-# description.
-
-ALWAYS_DETAILED_SEC    = YES
-
-# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all inherited 
-# members of a class in the documentation of that class as if those members were 
-# ordinary class members. Constructors, destructors and assignment operators of 
-# the base classes will not be shown.
-
-INLINE_INHERITED_MEMB  = NO
-
-# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full 
-# path before files name in the file list and in the header files. If set 
-# to NO the shortest path that makes the file name unique will be used.
-
-FULL_PATH_NAMES        = NO
-
-# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag 
-# can be used to strip a user-defined part of the path. Stripping is 
-# only done if one of the specified strings matches the left-hand part of 
-# the path. It is allowed to use relative paths in the argument list.
-
-STRIP_FROM_PATH        = 
-
-# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter 
-# (but less readable) file names. This can be useful is your file systems 
-# doesn't support long names like on DOS, Mac, or CD-ROM.
-
-SHORT_NAMES            = NO
-
-# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen 
-# will interpret the first line (until the first dot) of a JavaDoc-style 
-# comment as the brief description. If set to NO, the JavaDoc 
-# comments will behave just like the Qt-style comments (thus requiring an 
-# explict @brief command for a brief description.
-
-JAVADOC_AUTOBRIEF      = NO
-
-# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen 
-# treat a multi-line C++ special comment block (i.e. a block of //! or /// 
-# comments) as a brief description. This used to be the default behaviour. 
-# The new default is to treat a multi-line C++ comment block as a detailed 
-# description. Set this tag to YES if you prefer the old behaviour instead.
-
-MULTILINE_CPP_IS_BRIEF = NO
-
-# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented 
-# member inherits the documentation from any documented member that it 
-# reimplements.
-
-INHERIT_DOCS           = YES
-
-# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC 
-# tag is set to YES, then doxygen will reuse the documentation of the first 
-# member in the group (if any) for the other members of the group. By default 
-# all members of a group must be documented explicitly.
-
-DISTRIBUTE_GROUP_DOC   = NO
-
-# The TAB_SIZE tag can be used to set the number of spaces in a tab. 
-# Doxygen uses this value to replace tabs by spaces in code fragments.
-
-TAB_SIZE               = 8
-
-# This tag can be used to specify a number of aliases that acts 
-# as commands in the documentation. An alias has the form "name=value". 
-# For example adding "sideeffect=\par Side Effects:\n" will allow you to 
-# put the command \sideeffect (or @sideeffect) in the documentation, which 
-# will result in a user-defined paragraph with heading "Side Effects:". 
-# You can put \n's in the value part of an alias to insert newlines.
-
-ALIASES                = 
-
-# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources 
-# only. Doxygen will then generate output that is more tailored for C. 
-# For instance, some of the names that are used will be different. The list 
-# of all members will be omitted, etc.
-
-OPTIMIZE_OUTPUT_FOR_C  = YES
-
-# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java sources 
-# only. Doxygen will then generate output that is more tailored for Java. 
-# For instance, namespaces will be presented as packages, qualified scopes 
-# will look different, etc.
-
-OPTIMIZE_OUTPUT_JAVA   = NO
-
-# Set the SUBGROUPING tag to YES (the default) to allow class member groups of 
-# the same type (for instance a group of public functions) to be put as a 
-# subgroup of that type (e.g. under the Public Functions section). Set it to 
-# NO to prevent subgrouping. Alternatively, this can be done per class using 
-# the \nosubgrouping command.
-
-SUBGROUPING            = YES
-
-#---------------------------------------------------------------------------
-# Build related configuration options
-#---------------------------------------------------------------------------
-
-# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in 
-# documentation are documented, even if no documentation was available. 
-# Private class members and static file members will be hidden unless 
-# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
-
-EXTRACT_ALL            = YES
-
-# If the EXTRACT_PRIVATE tag is set to YES all private members of a class 
-# will be included in the documentation.
-
-EXTRACT_PRIVATE        = NO
-
-# If the EXTRACT_STATIC tag is set to YES all static members of a file 
-# will be included in the documentation.
-
-EXTRACT_STATIC         = YES
-
-# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) 
-# defined locally in source files will be included in the documentation. 
-# If set to NO only classes defined in header files are included.
-
-EXTRACT_LOCAL_CLASSES  = YES
-
-# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all 
-# undocumented members of documented classes, files or namespaces. 
-# If set to NO (the default) these members will be included in the 
-# various overviews, but no documentation section is generated. 
-# This option has no effect if EXTRACT_ALL is enabled.
-
-HIDE_UNDOC_MEMBERS     = YES
-
-# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all 
-# undocumented classes that are normally visible in the class hierarchy. 
-# If set to NO (the default) these classes will be included in the various 
-# overviews. This option has no effect if EXTRACT_ALL is enabled.
-
-HIDE_UNDOC_CLASSES     = NO
-
-# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all 
-# friend (class|struct|union) declarations. 
-# If set to NO (the default) these declarations will be included in the 
-# documentation.
-
-HIDE_FRIEND_COMPOUNDS  = NO
-
-# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any 
-# documentation blocks found inside the body of a function. 
-# If set to NO (the default) these blocks will be appended to the 
-# function's detailed documentation block.
-
-HIDE_IN_BODY_DOCS      = NO
-
-# The INTERNAL_DOCS tag determines if documentation 
-# that is typed after a \internal command is included. If the tag is set 
-# to NO (the default) then the documentation will be excluded. 
-# Set it to YES to include the internal documentation.
-
-INTERNAL_DOCS          = NO
-
-# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate 
-# file names in lower-case letters. If set to YES upper-case letters are also 
-# allowed. This is useful if you have classes or files whose names only differ 
-# in case and if your file system supports case sensitive file names. Windows 
-# users are advised to set this option to NO.
-
-CASE_SENSE_NAMES       = YES
-
-# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen 
-# will show members with their full class and namespace scopes in the 
-# documentation. If set to YES the scope will be hidden.
-
-HIDE_SCOPE_NAMES       = NO
-
-# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen 
-# will put a list of the files that are included by a file in the documentation 
-# of that file.
-
-SHOW_INCLUDE_FILES     = YES
-
-# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] 
-# is inserted in the documentation for inline members.
-
-INLINE_INFO            = YES
-
-# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen 
-# will sort the (detailed) documentation of file and class members 
-# alphabetically by member name. If set to NO the members will appear in 
-# declaration order.
-
-SORT_MEMBER_DOCS       = YES
-
-# The GENERATE_TODOLIST tag can be used to enable (YES) or 
-# disable (NO) the todo list. This list is created by putting \todo 
-# commands in the documentation.
-
-GENERATE_TODOLIST      = YES
-
-# The GENERATE_TESTLIST tag can be used to enable (YES) or 
-# disable (NO) the test list. This list is created by putting \test 
-# commands in the documentation.
-
-GENERATE_TESTLIST      = YES
-
-# The GENERATE_BUGLIST tag can be used to enable (YES) or 
-# disable (NO) the bug list. This list is created by putting \bug 
-# commands in the documentation.
-
-GENERATE_BUGLIST       = YES
-
-# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or 
-# disable (NO) the deprecated list. This list is created by putting 
-# \deprecated commands in the documentation.
-
-GENERATE_DEPRECATEDLIST= YES
-
-# The ENABLED_SECTIONS tag can be used to enable conditional 
-# documentation sections, marked by \if sectionname ... \endif.
-
-ENABLED_SECTIONS       = 
-
-# The MAX_INITIALIZER_LINES tag determines the maximum number of lines 
-# the initial value of a variable or define consists of for it to appear in 
-# the documentation. If the initializer consists of more lines than specified 
-# here it will be hidden. Use a value of 0 to hide initializers completely. 
-# The appearance of the initializer of individual variables and defines in the 
-# documentation can be controlled using \showinitializer or \hideinitializer 
-# command in the documentation regardless of this setting.
-
-MAX_INITIALIZER_LINES  = 30
-
-# Set the SHOW_USED_FILES tag to NO to disable the list of files generated 
-# at the bottom of the documentation of classes and structs. If set to YES the 
-# list will mention the files that were used to generate the documentation.
-
-SHOW_USED_FILES        = YES
-
-#---------------------------------------------------------------------------
-# configuration options related to warning and progress messages
-#---------------------------------------------------------------------------
-
-# The QUIET tag can be used to turn on/off the messages that are generated 
-# by doxygen. Possible values are YES and NO. If left blank NO is used.
-
-QUIET                  = YES
-
-# The WARNINGS tag can be used to turn on/off the warning messages that are 
-# generated by doxygen. Possible values are YES and NO. If left blank 
-# NO is used.
-
-WARNINGS               = YES
-
-# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings 
-# for undocumented members. If EXTRACT_ALL is set to YES then this flag will 
-# automatically be disabled.
-
-WARN_IF_UNDOCUMENTED   = YES
-
-# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for 
-# potential errors in the documentation, such as not documenting some 
-# parameters in a documented function, or documenting parameters that 
-# don't exist or using markup commands wrongly.
-
-WARN_IF_DOC_ERROR      = YES
-
-# The WARN_FORMAT tag determines the format of the warning messages that 
-# doxygen can produce. The string should contain the $file, $line, and $text 
-# tags, which will be replaced by the file and line number from which the 
-# warning originated and the warning text.
-
-WARN_FORMAT            = "$file:$line: $text"
-
-# The WARN_LOGFILE tag can be used to specify a file to which warning 
-# and error messages should be written. If left blank the output is written 
-# to stderr.
-
-WARN_LOGFILE           = 
-
-#---------------------------------------------------------------------------
-# configuration options related to the input files
-#---------------------------------------------------------------------------
-
-# The INPUT tag can be used to specify the files and/or directories that contain 
-# documented source files. You may enter file names like "myfile.cpp" or 
-# directories like "/usr/src/myproject". Separate the files or directories 
-# with spaces.
-
-INPUT                  = @srcdir@/.. \
-                         @srcdir@/../input \
-                         @srcdir@/../config
-
-# If the value of the INPUT tag contains directories, you can use the 
-# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp 
-# and *.h) to filter out the source-files in the directories. If left 
-# blank the following patterns are tested: 
-# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx *.hpp 
-# *.h++ *.idl *.odl *.cs *.php *.php3 *.inc
-
-FILE_PATTERNS          = 
-
-# The RECURSIVE tag can be used to turn specify whether or not subdirectories 
-# should be searched for input files as well. Possible values are YES and NO. 
-# If left blank NO is used.
-
-RECURSIVE              = NO
-
-# The EXCLUDE tag can be used to specify files and/or directories that should 
-# excluded from the INPUT source files. This way you can easily exclude a 
-# subdirectory from a directory tree whose root is specified with the INPUT tag.
-
-EXCLUDE                = @srcdir@/../config/parser.c \
-                         @srcdir@/../config/parser.h \
-                         @srcdir@/../config/scanner.c
-
-# The EXCLUDE_SYMLINKS tag can be used select whether or not files or directories 
-# that are symbolic links (a Unix filesystem feature) are excluded from the input.
-
-EXCLUDE_SYMLINKS       = YES
-
-# If the value of the INPUT tag contains directories, you can use the 
-# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude 
-# certain files from those directories.
-
-EXCLUDE_PATTERNS       = atKeynames.h \
-                         Canvas*.*
-
-# The EXAMPLE_PATH tag can be used to specify one or more files or 
-# directories that contain example code fragments that are included (see 
-# the \include command).
-
-EXAMPLE_PATH           = 
-
-# If the value of the EXAMPLE_PATH tag contains directories, you can use the 
-# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp 
-# and *.h) to filter out the source-files in the directories. If left 
-# blank all files are included.
-
-EXAMPLE_PATTERNS       = 
-
-# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be 
-# searched for input files to be used with the \include or \dontinclude 
-# commands irrespective of the value of the RECURSIVE tag. 
-# Possible values are YES and NO. If left blank NO is used.
-
-EXAMPLE_RECURSIVE      = NO
-
-# The IMAGE_PATH tag can be used to specify one or more files or 
-# directories that contain image that are included in the documentation (see 
-# the \image command).
-
-IMAGE_PATH             = 
-
-# The INPUT_FILTER tag can be used to specify a program that doxygen should 
-# invoke to filter for each input file. Doxygen will invoke the filter program 
-# by executing (via popen()) the command <filter> <input-file>, where <filter> 
-# is the value of the INPUT_FILTER tag, and <input-file> is the name of an 
-# input file. Doxygen will then use the output that the filter program writes 
-# to standard output.
-
-INPUT_FILTER           = 
-
-# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using 
-# INPUT_FILTER) will be used to filter the input files when producing source 
-# files to browse (i.e. when SOURCE_BROWSER is set to YES).
-
-FILTER_SOURCE_FILES    = NO
-
-#---------------------------------------------------------------------------
-# configuration options related to source browsing
-#---------------------------------------------------------------------------
-
-# If the SOURCE_BROWSER tag is set to YES then a list of source files will 
-# be generated. Documented entities will be cross-referenced with these sources.
-
-SOURCE_BROWSER         = NO
-
-# Setting the INLINE_SOURCES tag to YES will include the body 
-# of functions and classes directly in the documentation.
-
-INLINE_SOURCES         = NO
-
-# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct 
-# doxygen to hide any special comment blocks from generated source code 
-# fragments. Normal C and C++ comments will always remain visible.
-
-STRIP_CODE_COMMENTS    = YES
-
-# If the REFERENCED_BY_RELATION tag is set to YES (the default) 
-# then for each documented function all documented 
-# functions referencing it will be listed.
-
-REFERENCED_BY_RELATION = YES
-
-# If the REFERENCES_RELATION tag is set to YES (the default) 
-# then for each documented function all documented entities 
-# called/used by that function will be listed.
-
-REFERENCES_RELATION    = YES
-
-# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen 
-# will generate a verbatim copy of the header file for each class for 
-# which an include is specified. Set to NO to disable this.
-
-VERBATIM_HEADERS       = YES
-
-#---------------------------------------------------------------------------
-# configuration options related to the alphabetical class index
-#---------------------------------------------------------------------------
-
-# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index 
-# of all compounds will be generated. Enable this if the project 
-# contains a lot of classes, structs, unions or interfaces.
-
-ALPHABETICAL_INDEX     = YES
-
-# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then 
-# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns 
-# in which this list will be split (can be a number in the range [1..20])
-
-COLS_IN_ALPHA_INDEX    = 5
-
-# In case all classes in a project start with a common prefix, all 
-# classes will be put under the same header in the alphabetical index. 
-# The IGNORE_PREFIX tag can be used to specify one or more prefixes that 
-# should be ignored while generating the index headers.
-
-IGNORE_PREFIX          = 
-
-#---------------------------------------------------------------------------
-# configuration options related to the HTML output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_HTML tag is set to YES (the default) Doxygen will 
-# generate HTML output.
-
-GENERATE_HTML          = YES
-
-# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. 
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
-# put in front of it. If left blank `html' will be used as the default path.
-
-HTML_OUTPUT            = html
-
-# The HTML_FILE_EXTENSION tag can be used to specify the file extension for 
-# each generated HTML page (for example: .htm,.php,.asp). If it is left blank 
-# doxygen will generate files with .html extension.
-
-HTML_FILE_EXTENSION    = .html
-
-# The HTML_HEADER tag can be used to specify a personal HTML header for 
-# each generated HTML page. If it is left blank doxygen will generate a 
-# standard header.
-
-HTML_HEADER            = @srcdir@/doxygen.head
-
-# The HTML_FOOTER tag can be used to specify a personal HTML footer for 
-# each generated HTML page. If it is left blank doxygen will generate a 
-# standard footer.
-
-HTML_FOOTER            = @srcdir@/doxygen.foot
-
-# The HTML_STYLESHEET tag can be used to specify a user-defined cascading 
-# style sheet that is used by each HTML page. It can be used to 
-# fine-tune the look of the HTML output. If the tag is left blank doxygen 
-# will generate a default style sheet
-
-HTML_STYLESHEET        = @srcdir@/doxygen.css
-
-# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, 
-# files or namespaces will be aligned in HTML using tables. If set to 
-# NO a bullet list will be used.
-
-HTML_ALIGN_MEMBERS     = YES
-
-# If the GENERATE_HTMLHELP tag is set to YES, additional index files 
-# will be generated that can be used as input for tools like the 
-# Microsoft HTML help workshop to generate a compressed HTML help file (.chm) 
-# of the generated HTML documentation.
-
-GENERATE_HTMLHELP      = NO
-
-# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can 
-# be used to specify the file name of the resulting .chm file. You 
-# can add a path in front of the file if the result should not be 
-# written to the html output dir.
-
-CHM_FILE               = 
-
-# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can 
-# be used to specify the location (absolute path including file name) of 
-# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run 
-# the HTML help compiler on the generated index.hhp.
-
-HHC_LOCATION           = 
-
-# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag 
-# controls if a separate .chi index file is generated (YES) or that 
-# it should be included in the master .chm file (NO).
-
-GENERATE_CHI           = NO
-
-# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag 
-# controls whether a binary table of contents is generated (YES) or a 
-# normal table of contents (NO) in the .chm file.
-
-BINARY_TOC             = NO
-
-# The TOC_EXPAND flag can be set to YES to add extra items for group members 
-# to the contents of the HTML help documentation and to the tree view.
-
-TOC_EXPAND             = NO
-
-# The DISABLE_INDEX tag can be used to turn on/off the condensed index at 
-# top of each HTML page. The value NO (the default) enables the index and 
-# the value YES disables it.
-
-DISABLE_INDEX          = NO
-
-# This tag can be used to set the number of enum values (range [1..20]) 
-# that doxygen will group on one line in the generated HTML documentation.
-
-ENUM_VALUES_PER_LINE   = 4
-
-# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be
-# generated containing a tree-like index structure (just like the one that 
-# is generated for HTML Help). For this to work a browser that supports 
-# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, 
-# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are 
-# probably better off using the HTML help feature.
-
-GENERATE_TREEVIEW      = YES
-
-# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be 
-# used to set the initial width (in pixels) of the frame in which the tree 
-# is shown.
-
-TREEVIEW_WIDTH         = 250
-
-#---------------------------------------------------------------------------
-# configuration options related to the LaTeX output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will 
-# generate Latex output.
-
-GENERATE_LATEX         = NO
-
-# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. 
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
-# put in front of it. If left blank `latex' will be used as the default path.
-
-LATEX_OUTPUT           = latex
-
-# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be 
-# invoked. If left blank `latex' will be used as the default command name.
-
-LATEX_CMD_NAME         = latex
-
-# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to 
-# generate index for LaTeX. If left blank `makeindex' will be used as the 
-# default command name.
-
-MAKEINDEX_CMD_NAME     = makeindex
-
-# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact 
-# LaTeX documents. This may be useful for small projects and may help to 
-# save some trees in general.
-
-COMPACT_LATEX          = NO
-
-# The PAPER_TYPE tag can be used to set the paper type that is used 
-# by the printer. Possible values are: a4, a4wide, letter, legal and 
-# executive. If left blank a4wide will be used.
-
-PAPER_TYPE             = a4wide
-
-# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX 
-# packages that should be included in the LaTeX output.
-
-EXTRA_PACKAGES         = 
-
-# The LATEX_HEADER tag can be used to specify a personal LaTeX header for 
-# the generated latex document. The header should contain everything until 
-# the first chapter. If it is left blank doxygen will generate a 
-# standard header. Notice: only use this tag if you know what you are doing!
-
-LATEX_HEADER           = 
-
-# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated 
-# is prepared for conversion to pdf (using ps2pdf). The pdf file will 
-# contain links (just like the HTML output) instead of page references 
-# This makes the output suitable for online browsing using a pdf viewer.
-
-PDF_HYPERLINKS         = NO
-
-# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of 
-# plain latex in the generated Makefile. Set this option to YES to get a 
-# higher quality PDF documentation.
-
-USE_PDFLATEX           = NO
-
-# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. 
-# command to the generated LaTeX files. This will instruct LaTeX to keep 
-# running if errors occur, instead of asking the user for help. 
-# This option is also used when generating formulas in HTML.
-
-LATEX_BATCHMODE        = NO
-
-# If LATEX_HIDE_INDICES is set to YES then doxygen will not 
-# include the index chapters (such as File Index, Compound Index, etc.) 
-# in the output.
-
-LATEX_HIDE_INDICES     = NO
-
-#---------------------------------------------------------------------------
-# configuration options related to the RTF output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output 
-# The RTF output is optimised for Word 97 and may not look very pretty with 
-# other RTF readers or editors.
-
-GENERATE_RTF           = NO
-
-# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. 
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
-# put in front of it. If left blank `rtf' will be used as the default path.
-
-RTF_OUTPUT             = rtf
-
-# If the COMPACT_RTF tag is set to YES Doxygen generates more compact 
-# RTF documents. This may be useful for small projects and may help to 
-# save some trees in general.
-
-COMPACT_RTF            = NO
-
-# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated 
-# will contain hyperlink fields. The RTF file will 
-# contain links (just like the HTML output) instead of page references. 
-# This makes the output suitable for online browsing using WORD or other 
-# programs which support those fields. 
-# Note: wordpad (write) and others do not support links.
-
-RTF_HYPERLINKS         = NO
-
-# Load stylesheet definitions from file. Syntax is similar to doxygen's 
-# config file, i.e. a series of assigments. You only have to provide 
-# replacements, missing definitions are set to their default value.
-
-RTF_STYLESHEET_FILE    = 
-
-# Set optional variables used in the generation of an rtf document. 
-# Syntax is similar to doxygen's config file.
-
-RTF_EXTENSIONS_FILE    = 
-
-#---------------------------------------------------------------------------
-# configuration options related to the man page output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_MAN tag is set to YES (the default) Doxygen will 
-# generate man pages
-
-GENERATE_MAN           = NO
-
-# The MAN_OUTPUT tag is used to specify where the man pages will be put. 
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
-# put in front of it. If left blank `man' will be used as the default path.
-
-MAN_OUTPUT             = man
-
-# The MAN_EXTENSION tag determines the extension that is added to 
-# the generated man pages (default is the subroutine's section .3)
-
-MAN_EXTENSION          = .3
-
-# If the MAN_LINKS tag is set to YES and Doxygen generates man output, 
-# then it will generate one additional man file for each entity 
-# documented in the real man page(s). These additional files 
-# only source the real man page, but without them the man command 
-# would be unable to find the correct page. The default is NO.
-
-MAN_LINKS              = NO
-
-#---------------------------------------------------------------------------
-# configuration options related to the XML output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_XML tag is set to YES Doxygen will 
-# generate an XML file that captures the structure of 
-# the code including all documentation. Note that this 
-# feature is still experimental and incomplete at the 
-# moment.
-
-GENERATE_XML           = NO
-
-# The XML_OUTPUT tag is used to specify where the XML pages will be put. 
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
-# put in front of it. If left blank `xml' will be used as the default path.
-
-XML_OUTPUT             = xml
-
-# The XML_SCHEMA tag can be used to specify an XML schema, 
-# which can be used by a validating XML parser to check the 
-# syntax of the XML files.
-
-XML_SCHEMA             = 
-
-# The XML_DTD tag can be used to specify an XML DTD, 
-# which can be used by a validating XML parser to check the 
-# syntax of the XML files.
-
-XML_DTD                = 
-
-#---------------------------------------------------------------------------
-# configuration options for the AutoGen Definitions output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will 
-# generate an AutoGen Definitions (see autogen.sf.net) file 
-# that captures the structure of the code including all 
-# documentation. Note that this feature is still experimental 
-# and incomplete at the moment.
-
-GENERATE_AUTOGEN_DEF   = NO
-
-#---------------------------------------------------------------------------
-# configuration options related to the Perl module output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_PERLMOD tag is set to YES Doxygen will 
-# generate a Perl module file that captures the structure of 
-# the code including all documentation. Note that this 
-# feature is still experimental and incomplete at the 
-# moment.
-
-GENERATE_PERLMOD       = NO
-
-# If the PERLMOD_LATEX tag is set to YES Doxygen will generate 
-# the necessary Makefile rules, Perl scripts and LaTeX code to be able 
-# to generate PDF and DVI output from the Perl module output.
-
-PERLMOD_LATEX          = NO
-
-# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be 
-# nicely formatted so it can be parsed by a human reader.  This is useful 
-# if you want to understand what is going on.  On the other hand, if this 
-# tag is set to NO the size of the Perl module output will be much smaller 
-# and Perl will parse it just the same.
-
-PERLMOD_PRETTY         = YES
-
-# The names of the make variables in the generated doxyrules.make file 
-# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. 
-# This is useful so different doxyrules.make files included by the same 
-# Makefile don't overwrite each other's variables.
-
-PERLMOD_MAKEVAR_PREFIX = 
-
-#---------------------------------------------------------------------------
-# Configuration options related to the preprocessor   
-#---------------------------------------------------------------------------
-
-# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will 
-# evaluate all C-preprocessor directives found in the sources and include 
-# files.
-
-ENABLE_PREPROCESSING   = YES
-
-# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro 
-# names in the source code. If set to NO (the default) only conditional 
-# compilation will be performed. Macro expansion can be done in a controlled 
-# way by setting EXPAND_ONLY_PREDEF to YES.
-
-MACRO_EXPANSION        = NO
-
-# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES 
-# then the macro expansion is limited to the macros specified with the 
-# PREDEFINED and EXPAND_AS_PREDEFINED tags.
-
-EXPAND_ONLY_PREDEF     = NO
-
-# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files 
-# in the INCLUDE_PATH (see below) will be search if a #include is found.
-
-SEARCH_INCLUDES        = YES
-
-# The INCLUDE_PATH tag can be used to specify one or more directories that 
-# contain include files that are not input files but should be processed by 
-# the preprocessor.
-
-INCLUDE_PATH           = 
-
-# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard 
-# patterns (like *.h and *.hpp) to filter out the header-files in the 
-# directories. If left blank, the patterns specified with FILE_PATTERNS will 
-# be used.
-
-INCLUDE_FILE_PATTERNS  = 
-
-# The PREDEFINED tag can be used to specify one or more macro names that 
-# are defined before the preprocessor is started (similar to the -D option of 
-# gcc). The argument of the tag is a list of macros of the form: name 
-# or name=definition (no spaces). If the definition and the = are 
-# omitted =1 is assumed.
-
-PREDEFINED             = SHAPE \
-                         RENDER \
-                         XKB \
-                         XINPUT
-
-# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then 
-# this tag can be used to specify a list of macro names that should be expanded. 
-# The macro definition that is found in the sources will be used. 
-# Use the PREDEFINED tag if you want to use a different macro definition.
-
-EXPAND_AS_DEFINED      = 
-
-# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then 
-# doxygen's preprocessor will remove all function-like macros that are alone 
-# on a line, have an all uppercase name, and do not end with a semicolon. Such 
-# function macros are typically used for boiler-plate code, and will confuse the 
-# parser if not removed.
-
-SKIP_FUNCTION_MACROS   = YES
-
-#---------------------------------------------------------------------------
-# Configuration::addtions related to external references   
-#---------------------------------------------------------------------------
-
-# The TAGFILES option can be used to specify one or more tagfiles. 
-# Optionally an initial location of the external documentation 
-# can be added for each tagfile. The format of a tag file without 
-# this location is as follows: 
-#   TAGFILES = file1 file2 ... 
-# Adding location for the tag files is done as follows: 
-#   TAGFILES = file1=loc1 "file2 = loc2" ... 
-# where "loc1" and "loc2" can be relative or absolute paths or 
-# URLs. If a location is present for each tag, the installdox tool 
-# does not have to be run to correct the links.
-# Note that each tag file must have a unique name
-# (where the name does NOT include the path)
-# If a tag file is not located in the directory in which doxygen 
-# is run, you must also specify the path to the tagfile here.
-
-TAGFILES               = 
-
-# When a file name is specified after GENERATE_TAGFILE, doxygen will create 
-# a tag file that is based on the input files it reads.
-
-GENERATE_TAGFILE       = 
-
-# If the ALLEXTERNALS tag is set to YES all external classes will be listed 
-# in the class index. If set to NO only the inherited external classes 
-# will be listed.
-
-ALLEXTERNALS           = NO
-
-# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed 
-# in the modules index. If set to NO, only the current project's groups will 
-# be listed.
-
-EXTERNAL_GROUPS        = YES
-
-# The PERL_PATH should be the absolute path and name of the perl script 
-# interpreter (i.e. the result of `which perl').
-
-PERL_PATH              = /usr/bin/perl
-
-#---------------------------------------------------------------------------
-# Configuration options related to the dot tool   
-#---------------------------------------------------------------------------
-
-# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will 
-# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base or 
-# super classes. Setting the tag to NO turns the diagrams off. Note that this 
-# option is superceded by the HAVE_DOT option below. This is only a fallback. It is 
-# recommended to install and use dot, since it yields more powerful graphs.
-
-CLASS_DIAGRAMS         = YES
-
-# If set to YES, the inheritance and collaboration graphs will hide 
-# inheritance and usage relations if the target is undocumented 
-# or is not a class.
-
-HIDE_UNDOC_RELATIONS   = YES
-
-# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is 
-# available from the path. This tool is part of Graphviz, a graph visualization 
-# toolkit from AT&T and Lucent Bell Labs. The other options in this section 
-# have no effect if this option is set to NO (the default)
-
-HAVE_DOT               = NO
-
-# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen 
-# will generate a graph for each documented class showing the direct and 
-# indirect inheritance relations. Setting this tag to YES will force the 
-# the CLASS_DIAGRAMS tag to NO.
-
-CLASS_GRAPH            = YES
-
-# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen 
-# will generate a graph for each documented class showing the direct and 
-# indirect implementation dependencies (inheritance, containment, and 
-# class references variables) of the class with other documented classes.
-
-COLLABORATION_GRAPH    = YES
-
-# If the UML_LOOK tag is set to YES doxygen will generate inheritance and 
-# collaboration diagrams in a style similiar to the OMG's Unified Modeling 
-# Language.
-
-UML_LOOK               = NO
-
-# If set to YES, the inheritance and collaboration graphs will show the 
-# relations between templates and their instances.
-
-TEMPLATE_RELATIONS     = YES
-
-# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT 
-# tags are set to YES then doxygen will generate a graph for each documented 
-# file showing the direct and indirect include dependencies of the file with 
-# other documented files.
-
-INCLUDE_GRAPH          = YES
-
-# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and 
-# HAVE_DOT tags are set to YES then doxygen will generate a graph for each 
-# documented header file showing the documented files that directly or 
-# indirectly include this file.
-
-INCLUDED_BY_GRAPH      = YES
-
-# If the CALL_GRAPH and HAVE_DOT tags are set to YES then doxygen will 
-# generate a call dependency graph for every global function or class method. 
-# Note that enabling this option will significantly increase the time of a run. 
-# So in most cases it will be better to enable call graphs for selected 
-# functions only using the \callgraph command.
-
-CALL_GRAPH             = NO
-
-# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen 
-# will graphical hierarchy of all classes instead of a textual one.
-
-GRAPHICAL_HIERARCHY    = YES
-
-# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images 
-# generated by dot. Possible values are png, jpg, or gif
-# If left blank png will be used.
-
-DOT_IMAGE_FORMAT       = gif
-
-# The tag DOT_PATH can be used to specify the path where the dot tool can be 
-# found. If left blank, it is assumed the dot tool can be found on the path.
-
-DOT_PATH               = 
-
-# The DOTFILE_DIRS tag can be used to specify one or more directories that 
-# contain dot files that are included in the documentation (see the 
-# \dotfile command).
-
-DOTFILE_DIRS           = 
-
-# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the 
-# graphs generated by dot. A depth value of 3 means that only nodes reachable 
-# from the root by following a path via at most 3 edges will be shown. Nodes that 
-# lay further from the root node will be omitted. Note that setting this option to 
-# 1 or 2 may greatly reduce the computation time needed for large code bases. Also 
-# note that a graph may be further truncated if the graph's image dimensions are 
-# not sufficient to fit the graph (see MAX_DOT_GRAPH_WIDTH and MAX_DOT_GRAPH_HEIGHT). 
-# If 0 is used for the depth value (the default), the graph is not depth-constrained.
-
-MAX_DOT_GRAPH_DEPTH    = 0
-
-# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will 
-# generate a legend page explaining the meaning of the various boxes and 
-# arrows in the dot generated graphs.
-
-GENERATE_LEGEND        = YES
-
-# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will 
-# remove the intermediate dot files that are used to generate 
-# the various graphs.
-
-DOT_CLEANUP            = YES
-
-#---------------------------------------------------------------------------
-# Configuration::addtions related to the search engine   
-#---------------------------------------------------------------------------
-
-# The SEARCHENGINE tag specifies whether or not a search engine should be 
-# used. If set to NO the values of all tags below this one will be ignored.
-
-SEARCHENGINE           = NO
diff --git a/hw/dmx/doc/doxygen.css b/hw/dmx/doc/doxygen.css
deleted file mode 100644
index 841f709..0000000
--- a/hw/dmx/doc/doxygen.css
+++ /dev/null
@@ -1,49 +0,0 @@
-H1 { text-align: center; }
-CAPTION { font-weight: bold }
-A.qindex {}
-A.qindexRef {}
-A.el { text-decoration: none; font-weight: bold }
-A.elRef { font-weight: bold }
-A.code { text-decoration: none; font-weight: normal; color: #4444ee }
-A.codeRef { font-weight: normal; color: #4444ee }
-A:hover { text-decoration: none; background-color: #f2f2ff }
-DL.el { margin-left: -1cm }
-DIV.fragment { width: 100%; border: none; background-color: #eeeeee }
-DIV.ah { background-color: black; font-weight: bold; color: #ffffff; margin-bottom: 3px; margin-top: 3px }
-TD.md { background-color: #f2f2ff; font-weight: bold; }
-TD.mdname1 { background-color: #f2f2ff; font-weight: bold; color: #602020; }
-TD.mdname { background-color: #f2f2ff; font-weight: bold; color: #602020; width: 600px; }
-DIV.groupHeader { margin-left: 16px; margin-top: 12px; margin-bottom: 6px; font-weight: bold }
-DIV.groupText { margin-left: 16px; font-style: italic; font-size: smaller }
-BODY { background: white }
-TD.indexkey { 
-   background-color: #eeeeff; 
-   font-weight: bold; 
-   padding-right  : 10px; 
-   padding-top    : 2px; 
-   padding-left   : 10px; 
-   padding-bottom : 2px; 
-   margin-left    : 0px; 
-   margin-right   : 0px; 
-   margin-top     : 2px; 
-   margin-bottom  : 2px  
-}
-TD.indexvalue { 
-   background-color: #eeeeff; 
-   font-style: italic; 
-   padding-right  : 10px; 
-   padding-top    : 2px; 
-   padding-left   : 10px; 
-   padding-bottom : 2px; 
-   margin-left    : 0px; 
-   margin-right   : 0px; 
-   margin-top     : 2px; 
-   margin-bottom  : 2px  
-}
-FONT.keyword       { color: #008000 }
-FONT.keywordtype   { color: #604020 }
-FONT.keywordflow   { color: #e08000 }
-FONT.comment       { color: #800000 }
-FONT.preprocessor  { color: #806020 }
-FONT.stringliteral { color: #002080 }
-FONT.charliteral   { color: #008080 }
diff --git a/hw/dmx/doc/doxygen.foot b/hw/dmx/doc/doxygen.foot
deleted file mode 100644
index 3aca117..0000000
--- a/hw/dmx/doc/doxygen.foot
+++ /dev/null
@@ -1,12 +0,0 @@
-    <hr>
-    <address>
-      <small>
-        Generated June 29, 2004 for <a
-        href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
-        <a href="http://www.doxygen.org/index.html">doxygen</a>
-        1.3.4.
-      </small>
-    </addres>
-    </hr>
-  </body>
-</html>
diff --git a/hw/dmx/doc/doxygen.head b/hw/dmx/doc/doxygen.head
deleted file mode 100644
index 89bda8f..0000000
--- a/hw/dmx/doc/doxygen.head
+++ /dev/null
@@ -1,8 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-<html>
-  <head>
-    <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
-    <title>File Index</title>
-    <link href="doxygen.css" rel="stylesheet" type="text/css">
-  </head>
-  <body>
diff --git a/hw/dmx/doxygen/.gitignore b/hw/dmx/doxygen/.gitignore
new file mode 100644
index 0000000..550262f
--- /dev/null
+++ b/hw/dmx/doxygen/.gitignore
@@ -0,0 +1,2 @@
+html/
+doxygen.conf
diff --git a/hw/dmx/doxygen/Makefile.am b/hw/dmx/doxygen/Makefile.am
new file mode 100644
index 0000000..d705fbe
--- /dev/null
+++ b/hw/dmx/doxygen/Makefile.am
@@ -0,0 +1,268 @@
+#  Copyright 2005 Red Hat, Inc.
+#
+#  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 Red Hat
+#  not be used in advertising or publicity pertaining to distribution
+#  of the software without specific, written prior permission.  Red
+#  Hat makes no representations about the suitability of this software
+#  for any purpose.  It is provided "as is" without express or implied
+#  warranty.
+#
+#  RED HAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+#  INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
+#  NO EVENT SHALL RED HAT 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.
+
+DOXYGEN_HEAD=\
+	html/annotated.html
+
+DOXYGEN_REST= \
+	html/ChkNotMaskEv_8c.html \
+	html/ChkNotMaskEv_8h.html \
+	html/ChkNotMaskEv_8h_source.html \
+	html/classes.html \
+	html/dmx_8h.html \
+	html/dmx_8h_source.html \
+	html/dmxarg_8c.html \
+	html/dmxarg_8h.html \
+	html/dmxarg_8h_source.html \
+	html/dmxbackend_8c.html \
+	html/dmxbackend_8h.html \
+	html/dmxbackend_8h_source.html \
+	html/dmxcb_8c.html \
+	html/dmxcb_8h.html \
+	html/dmxcb_8h_source.html \
+	html/dmxclient_8h.html \
+	html/dmxclient_8h_source.html \
+	html/dmxcmap_8c.html \
+	html/dmxcmap_8h.html \
+	html/dmxcmap_8h_source.html \
+	html/dmxcommon_8c.html \
+	html/dmxcommon_8h.html \
+	html/dmxcommon_8h_source.html \
+	html/dmxcompat_8c.html \
+	html/dmxcompat_8h.html \
+	html/dmxcompat_8h_source.html \
+	html/dmxconfig_8c.html \
+	html/dmxconfig_8h.html \
+	html/dmxconfig_8h_source.html \
+	html/dmxconsole_8c.html \
+	html/dmxconsole_8h.html \
+	html/dmxconsole_8h_source.html \
+	html/dmxcursor_8c.html \
+	html/dmxcursor_8h.html \
+	html/dmxcursor_8h_source.html \
+	html/dmxdetach_8c.html \
+	html/dmxdpms_8c.html \
+	html/dmxdpms_8h.html \
+	html/dmxdpms_8h_source.html \
+	html/dmxdummy_8c.html \
+	html/dmxdummy_8h.html \
+	html/dmxdummy_8h_source.html \
+	html/dmxevents_8c.html \
+	html/dmxevents_8h.html \
+	html/dmxevents_8h_source.html \
+	html/dmxextension_8c.html \
+	html/dmxextension_8h.html \
+	html/dmxextension_8h_source.html \
+	html/dmxfont_8c.html \
+	html/dmxfont_8h.html \
+	html/dmxfont_8h_source.html \
+	html/dmxgc_8c.html \
+	html/dmxgc_8h.html \
+	html/dmxgc_8h_source.html \
+	html/dmxgcops_8c.html \
+	html/dmxgcops_8h.html \
+	html/dmxgcops_8h_source.html \
+	html/dmx__glxvisuals_8h_source.html \
+	html/dmxinit_8c.html \
+	html/dmxinit_8h.html \
+	html/dmxinit_8h_source.html \
+	html/dmxinput_8c.html \
+	html/dmxinput_8h.html \
+	html/dmxinput_8h_source.html \
+	html/dmxinputinit_8c.html \
+	html/dmxinputinit_8h.html \
+	html/dmxinputinit_8h_source.html \
+	html/dmxlog_8c.html \
+	html/dmxlog_8h.html \
+	html/dmxlog_8h_source.html \
+	html/dmxmap_8c.html \
+	html/dmxmap_8h.html \
+	html/dmxmap_8h_source.html \
+	html/dmxmotion_8c.html \
+	html/dmxmotion_8h.html \
+	html/dmxmotion_8h_source.html \
+	html/dmxparse_8c.html \
+	html/dmxparse_8h.html \
+	html/dmxparse_8h_source.html \
+	html/dmxpict_8c.html \
+	html/dmxpict_8h.html \
+	html/dmxpict_8h_source.html \
+	html/dmxpixmap_8c.html \
+	html/dmxpixmap_8h.html \
+	html/dmxpixmap_8h_source.html \
+	html/dmxprint_8c.html \
+	html/dmxprint_8h.html \
+	html/dmxprint_8h_source.html \
+	html/dmxprop_8c.html \
+	html/dmxprop_8h.html \
+	html/dmxprop_8h_source.html \
+	html/dmxscrinit_8c.html \
+	html/dmxscrinit_8h.html \
+	html/dmxscrinit_8h_source.html \
+	html/dmxshadow_8c.html \
+	html/dmxshadow_8h.html \
+	html/dmxshadow_8h_source.html \
+	html/dmxsigio_8c.html \
+	html/dmxsigio_8h.html \
+	html/dmxsigio_8h_source.html \
+	html/dmxstat_8c.html \
+	html/dmxstat_8h.html \
+	html/dmxstat_8h_source.html \
+	html/dmxsync_8c.html \
+	html/dmxsync_8h.html \
+	html/dmxsync_8h_source.html \
+	html/dmxvisual_8c.html \
+	html/dmxvisual_8h.html \
+	html/dmxvisual_8h_source.html \
+	html/dmxwindow_8c.html \
+	html/dmxwindow_8h.html \
+	html/dmxwindow_8h_source.html \
+	html/dmxxinput_8c.html \
+	html/doxygen.css \
+	html/doxygen.png \
+	html/files.html \
+	html/ftv2blank.png \
+	html/ftv2doc.png \
+	html/ftv2folderclosed.png \
+	html/ftv2folderopen.png \
+	html/ftv2lastnode.png \
+	html/ftv2link.png \
+	html/ftv2mlastnode.png \
+	html/ftv2mnode.png \
+	html/ftv2node.png \
+	html/ftv2plastnode.png \
+	html/ftv2pnode.png \
+	html/ftv2vertline.png \
+	html/functions.html \
+	html/functions_vars.html \
+	html/globals_defs.html \
+	html/globals_enum.html \
+	html/globals_eval.html \
+	html/globals_func.html \
+	html/globals.html \
+	html/globals_type.html \
+	html/globals_vars.html \
+	html/index.html \
+	html/lnx-keyboard_8c.html \
+	html/lnx-keyboard_8h.html \
+	html/lnx-keyboard_8h_source.html \
+	html/lnx-ms_8c.html \
+	html/lnx-ms_8h.html \
+	html/lnx-ms_8h_source.html \
+	html/lnx-ps2_8c.html \
+	html/lnx-ps2_8h.html \
+	html/lnx-ps2_8h_source.html \
+	html/main.html \
+	html/struct__dmxArg.html \
+	html/struct__dmxColormapPriv.html \
+	html/structDMXConfigCmdStruct.html \
+	html/struct__DMXConfigComment.html \
+	html/struct__DMXConfigDisplay.html \
+	html/struct__DMXConfigEntry.html \
+	html/struct__DMXConfigFullDim.html \
+	html/structDMXConfigListStruct.html \
+	html/struct__DMXConfigNumber.html \
+	html/struct__DMXConfigOption.html \
+	html/struct__DMXConfigPair.html \
+	html/struct__DMXConfigParam.html \
+	html/struct__DMXConfigPartDim.html \
+	html/struct__DMXConfigString.html \
+	html/struct__DMXConfigSub.html \
+	html/struct__DMXConfigToken.html \
+	html/struct__DMXConfigVirtual.html \
+	html/struct__DMXConfigWall.html \
+	html/struct__dmxCursorPriv.html \
+	html/structDMXDesktopAttributesRec.html \
+	html/struct__DMXEventMap.html \
+	html/struct__dmxFontPriv.html \
+	html/struct__dmxGCPriv.html \
+	html/structdmxGlxVisualPrivate.html \
+	html/struct__dmxGlyphPriv.html \
+	html/structDMXInputAttributesRec.html \
+	html/struct__DMXInputInfo.html \
+	html/struct__DMXLocalInitInfo.html \
+	html/struct__DMXLocalInputInfo.html \
+	html/struct__dmxPictPriv.html \
+	html/struct__dmxPixPriv.html \
+	html/structDMXScreenAttributesRec.html \
+	html/struct__DMXScreenInfo.html \
+	html/struct__DMXStatAvg.html \
+	html/struct__DMXStatInfo.html \
+	html/structDMXWindowAttributesRec.html \
+	html/struct__dmxWinPriv.html \
+	html/struct__myPrivate.html \
+	html/tree.html \
+	html/usb-common_8c.html \
+	html/usb-common_8h.html \
+	html/usb-common_8h_source.html \
+	html/usb-keyboard_8c.html \
+	html/usb-keyboard_8h.html \
+	html/usb-keyboard_8h_source.html \
+	html/usb-mouse_8c.html \
+	html/usb-mouse_8h.html \
+	html/usb-mouse_8h_source.html \
+	html/usb-other_8c.html \
+	html/usb-other_8h.html \
+	html/usb-other_8h_source.html \
+	html/usb-private_8h.html \
+	html/usb-private_8h_source.html
+
+DOXYGEN_FILES=$(DOXYGEN_HEAD) $(DOXYGEN_REST)
+
+EXTRA_DIST = \
+	doxygen.conf \
+	doxygen.css \
+	doxygen.foot \
+	doxygen.head \
+	$(DOXYGEN_FILES)
+
+if ENABLE_DEVEL_DOCS
+if HAVE_DOXYGEN
+
+DOXYGEN_SRC=doxygen.head doxygen.foot doxygen.css doxygen.conf
+
+all-local: $(DOXYGEN_FILES)
+
+dist-local: $(DOXYGEN_FILES)
+
+$(DOXYGEN_HEAD): $(DOXYGEN_SRC)
+	$(DOXYGEN) doxygen.conf
+
+$(DOXYGEN_REST): $(DOXYGEN_HEAD)
+
+maintainer-clean-local:
+	rm -rf html/
+
+distclean-local:
+	rm -rf html/
+
+endif HAVE_DOXYGEN
+endif ENABLE_DEVEL_DOCS
+
+$(builddir)/doxygen.head:
+	$(LN_S) $(srcdir)/doxygen.head $@
+
+$(builddir)/doxygen.foot:
+	$(LN_S) $(srcdir)/doxygen.foot $@
+
+$(builddir)doxygen.css:
+	$(LN_S) $(srcdir)/doxygen.css $@
+
diff --git a/hw/dmx/doxygen/doxygen.conf.in b/hw/dmx/doxygen/doxygen.conf.in
new file mode 100644
index 0000000..f886a43
--- /dev/null
+++ b/hw/dmx/doxygen/doxygen.conf.in
@@ -0,0 +1,1053 @@
+# Doxyfile 1.3.4
+
+# This file describes the settings to be used by the documentation system
+# doxygen (www.doxygen.org) for a project
+#
+# All text after a hash (#) is considered a comment and will be ignored
+# The format is:
+#       TAG = value [value, ...]
+# For lists items can also be appended using:
+#       TAG += value [value, ...]
+# Values that contain spaces should be placed between quotes (" ")
+
+#---------------------------------------------------------------------------
+# Project related configuration options
+#---------------------------------------------------------------------------
+
+# The PROJECT_NAME tag is a single word (or a sequence of words surrounded 
+# by quotes) that should identify the project.
+
+PROJECT_NAME           = "Distributed Multihead X"
+
+# The PROJECT_NUMBER tag can be used to enter a project or revision number. 
+# This could be handy for archiving the generated documentation or 
+# if some version control system is used.
+
+PROJECT_NUMBER         = "dmx-1-2-20040604 and later"
+
+# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) 
+# base path where the generated documentation will be put. 
+# If a relative path is entered, it will be relative to the location 
+# where doxygen was started. If left blank the current directory will be used.
+
+OUTPUT_DIRECTORY       = 
+
+# The OUTPUT_LANGUAGE tag is used to specify the language in which all 
+# documentation generated by doxygen is written. Doxygen will use this 
+# information to generate all constant output in the proper language. 
+# The default language is English, other supported languages are: 
+# Brazilian, Catalan, Chinese, Chinese-Traditional, Croatian, Czech, Danish, Dutch, 
+# Finnish, French, German, Greek, Hungarian, Italian, Japanese, Japanese-en 
+# (Japanese with English messages), Korean, Norwegian, Polish, Portuguese, 
+# Romanian, Russian, Serbian, Slovak, Slovene, Spanish, Swedish, and Ukrainian.
+
+OUTPUT_LANGUAGE        = English
+
+# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will 
+# include brief member descriptions after the members that are listed in 
+# the file and class documentation (similar to JavaDoc). 
+# Set to NO to disable this.
+
+BRIEF_MEMBER_DESC      = YES
+
+# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend 
+# the brief description of a member or function before the detailed description. 
+# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the 
+# brief descriptions will be completely suppressed.
+
+REPEAT_BRIEF           = YES
+
+# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then 
+# Doxygen will generate a detailed section even if there is only a brief 
+# description.
+
+ALWAYS_DETAILED_SEC    = YES
+
+# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all inherited 
+# members of a class in the documentation of that class as if those members were 
+# ordinary class members. Constructors, destructors and assignment operators of 
+# the base classes will not be shown.
+
+INLINE_INHERITED_MEMB  = NO
+
+# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full 
+# path before files name in the file list and in the header files. If set 
+# to NO the shortest path that makes the file name unique will be used.
+
+FULL_PATH_NAMES        = NO
+
+# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag 
+# can be used to strip a user-defined part of the path. Stripping is 
+# only done if one of the specified strings matches the left-hand part of 
+# the path. It is allowed to use relative paths in the argument list.
+
+STRIP_FROM_PATH        = 
+
+# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter 
+# (but less readable) file names. This can be useful is your file systems 
+# doesn't support long names like on DOS, Mac, or CD-ROM.
+
+SHORT_NAMES            = NO
+
+# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen 
+# will interpret the first line (until the first dot) of a JavaDoc-style 
+# comment as the brief description. If set to NO, the JavaDoc 
+# comments will behave just like the Qt-style comments (thus requiring an 
+# explict @brief command for a brief description.
+
+JAVADOC_AUTOBRIEF      = NO
+
+# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen 
+# treat a multi-line C++ special comment block (i.e. a block of //! or /// 
+# comments) as a brief description. This used to be the default behaviour. 
+# The new default is to treat a multi-line C++ comment block as a detailed 
+# description. Set this tag to YES if you prefer the old behaviour instead.
+
+MULTILINE_CPP_IS_BRIEF = NO
+
+# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented 
+# member inherits the documentation from any documented member that it 
+# reimplements.
+
+INHERIT_DOCS           = YES
+
+# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC 
+# tag is set to YES, then doxygen will reuse the documentation of the first 
+# member in the group (if any) for the other members of the group. By default 
+# all members of a group must be documented explicitly.
+
+DISTRIBUTE_GROUP_DOC   = NO
+
+# The TAB_SIZE tag can be used to set the number of spaces in a tab. 
+# Doxygen uses this value to replace tabs by spaces in code fragments.
+
+TAB_SIZE               = 8
+
+# This tag can be used to specify a number of aliases that acts 
+# as commands in the documentation. An alias has the form "name=value". 
+# For example adding "sideeffect=\par Side Effects:\n" will allow you to 
+# put the command \sideeffect (or @sideeffect) in the documentation, which 
+# will result in a user-defined paragraph with heading "Side Effects:". 
+# You can put \n's in the value part of an alias to insert newlines.
+
+ALIASES                = 
+
+# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources 
+# only. Doxygen will then generate output that is more tailored for C. 
+# For instance, some of the names that are used will be different. The list 
+# of all members will be omitted, etc.
+
+OPTIMIZE_OUTPUT_FOR_C  = YES
+
+# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java sources 
+# only. Doxygen will then generate output that is more tailored for Java. 
+# For instance, namespaces will be presented as packages, qualified scopes 
+# will look different, etc.
+
+OPTIMIZE_OUTPUT_JAVA   = NO
+
+# Set the SUBGROUPING tag to YES (the default) to allow class member groups of 
+# the same type (for instance a group of public functions) to be put as a 
+# subgroup of that type (e.g. under the Public Functions section). Set it to 
+# NO to prevent subgrouping. Alternatively, this can be done per class using 
+# the \nosubgrouping command.
+
+SUBGROUPING            = YES
+
+#---------------------------------------------------------------------------
+# Build related configuration options
+#---------------------------------------------------------------------------
+
+# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in 
+# documentation are documented, even if no documentation was available. 
+# Private class members and static file members will be hidden unless 
+# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
+
+EXTRACT_ALL            = YES
+
+# If the EXTRACT_PRIVATE tag is set to YES all private members of a class 
+# will be included in the documentation.
+
+EXTRACT_PRIVATE        = NO
+
+# If the EXTRACT_STATIC tag is set to YES all static members of a file 
+# will be included in the documentation.
+
+EXTRACT_STATIC         = YES
+
+# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) 
+# defined locally in source files will be included in the documentation. 
+# If set to NO only classes defined in header files are included.
+
+EXTRACT_LOCAL_CLASSES  = YES
+
+# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all 
+# undocumented members of documented classes, files or namespaces. 
+# If set to NO (the default) these members will be included in the 
+# various overviews, but no documentation section is generated. 
+# This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_MEMBERS     = YES
+
+# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all 
+# undocumented classes that are normally visible in the class hierarchy. 
+# If set to NO (the default) these classes will be included in the various 
+# overviews. This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_CLASSES     = NO
+
+# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all 
+# friend (class|struct|union) declarations. 
+# If set to NO (the default) these declarations will be included in the 
+# documentation.
+
+HIDE_FRIEND_COMPOUNDS  = NO
+
+# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any 
+# documentation blocks found inside the body of a function. 
+# If set to NO (the default) these blocks will be appended to the 
+# function's detailed documentation block.
+
+HIDE_IN_BODY_DOCS      = NO
+
+# The INTERNAL_DOCS tag determines if documentation 
+# that is typed after a \internal command is included. If the tag is set 
+# to NO (the default) then the documentation will be excluded. 
+# Set it to YES to include the internal documentation.
+
+INTERNAL_DOCS          = NO
+
+# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate 
+# file names in lower-case letters. If set to YES upper-case letters are also 
+# allowed. This is useful if you have classes or files whose names only differ 
+# in case and if your file system supports case sensitive file names. Windows 
+# users are advised to set this option to NO.
+
+CASE_SENSE_NAMES       = YES
+
+# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen 
+# will show members with their full class and namespace scopes in the 
+# documentation. If set to YES the scope will be hidden.
+
+HIDE_SCOPE_NAMES       = NO
+
+# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen 
+# will put a list of the files that are included by a file in the documentation 
+# of that file.
+
+SHOW_INCLUDE_FILES     = YES
+
+# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] 
+# is inserted in the documentation for inline members.
+
+INLINE_INFO            = YES
+
+# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen 
+# will sort the (detailed) documentation of file and class members 
+# alphabetically by member name. If set to NO the members will appear in 
+# declaration order.
+
+SORT_MEMBER_DOCS       = YES
+
+# The GENERATE_TODOLIST tag can be used to enable (YES) or 
+# disable (NO) the todo list. This list is created by putting \todo 
+# commands in the documentation.
+
+GENERATE_TODOLIST      = YES
+
+# The GENERATE_TESTLIST tag can be used to enable (YES) or 
+# disable (NO) the test list. This list is created by putting \test 
+# commands in the documentation.
+
+GENERATE_TESTLIST      = YES
+
+# The GENERATE_BUGLIST tag can be used to enable (YES) or 
+# disable (NO) the bug list. This list is created by putting \bug 
+# commands in the documentation.
+
+GENERATE_BUGLIST       = YES
+
+# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or 
+# disable (NO) the deprecated list. This list is created by putting 
+# \deprecated commands in the documentation.
+
+GENERATE_DEPRECATEDLIST= YES
+
+# The ENABLED_SECTIONS tag can be used to enable conditional 
+# documentation sections, marked by \if sectionname ... \endif.
+
+ENABLED_SECTIONS       = 
+
+# The MAX_INITIALIZER_LINES tag determines the maximum number of lines 
+# the initial value of a variable or define consists of for it to appear in 
+# the documentation. If the initializer consists of more lines than specified 
+# here it will be hidden. Use a value of 0 to hide initializers completely. 
+# The appearance of the initializer of individual variables and defines in the 
+# documentation can be controlled using \showinitializer or \hideinitializer 
+# command in the documentation regardless of this setting.
+
+MAX_INITIALIZER_LINES  = 30
+
+# Set the SHOW_USED_FILES tag to NO to disable the list of files generated 
+# at the bottom of the documentation of classes and structs. If set to YES the 
+# list will mention the files that were used to generate the documentation.
+
+SHOW_USED_FILES        = YES
+
+#---------------------------------------------------------------------------
+# configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+
+# The QUIET tag can be used to turn on/off the messages that are generated 
+# by doxygen. Possible values are YES and NO. If left blank NO is used.
+
+QUIET                  = YES
+
+# The WARNINGS tag can be used to turn on/off the warning messages that are 
+# generated by doxygen. Possible values are YES and NO. If left blank 
+# NO is used.
+
+WARNINGS               = YES
+
+# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings 
+# for undocumented members. If EXTRACT_ALL is set to YES then this flag will 
+# automatically be disabled.
+
+WARN_IF_UNDOCUMENTED   = YES
+
+# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for 
+# potential errors in the documentation, such as not documenting some 
+# parameters in a documented function, or documenting parameters that 
+# don't exist or using markup commands wrongly.
+
+WARN_IF_DOC_ERROR      = YES
+
+# The WARN_FORMAT tag determines the format of the warning messages that 
+# doxygen can produce. The string should contain the $file, $line, and $text 
+# tags, which will be replaced by the file and line number from which the 
+# warning originated and the warning text.
+
+WARN_FORMAT            = "$file:$line: $text"
+
+# The WARN_LOGFILE tag can be used to specify a file to which warning 
+# and error messages should be written. If left blank the output is written 
+# to stderr.
+
+WARN_LOGFILE           = 
+
+#---------------------------------------------------------------------------
+# configuration options related to the input files
+#---------------------------------------------------------------------------
+
+# The INPUT tag can be used to specify the files and/or directories that contain 
+# documented source files. You may enter file names like "myfile.cpp" or 
+# directories like "/usr/src/myproject". Separate the files or directories 
+# with spaces.
+
+INPUT                  = @srcdir@/.. \
+                         @srcdir@/../input \
+                         @srcdir@/../config
+
+# If the value of the INPUT tag contains directories, you can use the 
+# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp 
+# and *.h) to filter out the source-files in the directories. If left 
+# blank the following patterns are tested: 
+# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx *.hpp 
+# *.h++ *.idl *.odl *.cs *.php *.php3 *.inc
+
+FILE_PATTERNS          = 
+
+# The RECURSIVE tag can be used to turn specify whether or not subdirectories 
+# should be searched for input files as well. Possible values are YES and NO. 
+# If left blank NO is used.
+
+RECURSIVE              = NO
+
+# The EXCLUDE tag can be used to specify files and/or directories that should 
+# excluded from the INPUT source files. This way you can easily exclude a 
+# subdirectory from a directory tree whose root is specified with the INPUT tag.
+
+EXCLUDE                = @srcdir@/../config/parser.c \
+                         @srcdir@/../config/parser.h \
+                         @srcdir@/../config/scanner.c
+
+# The EXCLUDE_SYMLINKS tag can be used select whether or not files or directories 
+# that are symbolic links (a Unix filesystem feature) are excluded from the input.
+
+EXCLUDE_SYMLINKS       = YES
+
+# If the value of the INPUT tag contains directories, you can use the 
+# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude 
+# certain files from those directories.
+
+EXCLUDE_PATTERNS       = atKeynames.h \
+                         Canvas*.*
+
+# The EXAMPLE_PATH tag can be used to specify one or more files or 
+# directories that contain example code fragments that are included (see 
+# the \include command).
+
+EXAMPLE_PATH           = 
+
+# If the value of the EXAMPLE_PATH tag contains directories, you can use the 
+# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp 
+# and *.h) to filter out the source-files in the directories. If left 
+# blank all files are included.
+
+EXAMPLE_PATTERNS       = 
+
+# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be 
+# searched for input files to be used with the \include or \dontinclude 
+# commands irrespective of the value of the RECURSIVE tag. 
+# Possible values are YES and NO. If left blank NO is used.
+
+EXAMPLE_RECURSIVE      = NO
+
+# The IMAGE_PATH tag can be used to specify one or more files or 
+# directories that contain image that are included in the documentation (see 
+# the \image command).
+
+IMAGE_PATH             = 
+
+# The INPUT_FILTER tag can be used to specify a program that doxygen should 
+# invoke to filter for each input file. Doxygen will invoke the filter program 
+# by executing (via popen()) the command <filter> <input-file>, where <filter> 
+# is the value of the INPUT_FILTER tag, and <input-file> is the name of an 
+# input file. Doxygen will then use the output that the filter program writes 
+# to standard output.
+
+INPUT_FILTER           = 
+
+# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using 
+# INPUT_FILTER) will be used to filter the input files when producing source 
+# files to browse (i.e. when SOURCE_BROWSER is set to YES).
+
+FILTER_SOURCE_FILES    = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to source browsing
+#---------------------------------------------------------------------------
+
+# If the SOURCE_BROWSER tag is set to YES then a list of source files will 
+# be generated. Documented entities will be cross-referenced with these sources.
+
+SOURCE_BROWSER         = NO
+
+# Setting the INLINE_SOURCES tag to YES will include the body 
+# of functions and classes directly in the documentation.
+
+INLINE_SOURCES         = NO
+
+# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct 
+# doxygen to hide any special comment blocks from generated source code 
+# fragments. Normal C and C++ comments will always remain visible.
+
+STRIP_CODE_COMMENTS    = YES
+
+# If the REFERENCED_BY_RELATION tag is set to YES (the default) 
+# then for each documented function all documented 
+# functions referencing it will be listed.
+
+REFERENCED_BY_RELATION = YES
+
+# If the REFERENCES_RELATION tag is set to YES (the default) 
+# then for each documented function all documented entities 
+# called/used by that function will be listed.
+
+REFERENCES_RELATION    = YES
+
+# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen 
+# will generate a verbatim copy of the header file for each class for 
+# which an include is specified. Set to NO to disable this.
+
+VERBATIM_HEADERS       = YES
+
+#---------------------------------------------------------------------------
+# configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
+
+# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index 
+# of all compounds will be generated. Enable this if the project 
+# contains a lot of classes, structs, unions or interfaces.
+
+ALPHABETICAL_INDEX     = YES
+
+# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then 
+# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns 
+# in which this list will be split (can be a number in the range [1..20])
+
+COLS_IN_ALPHA_INDEX    = 5
+
+# In case all classes in a project start with a common prefix, all 
+# classes will be put under the same header in the alphabetical index. 
+# The IGNORE_PREFIX tag can be used to specify one or more prefixes that 
+# should be ignored while generating the index headers.
+
+IGNORE_PREFIX          = 
+
+#---------------------------------------------------------------------------
+# configuration options related to the HTML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_HTML tag is set to YES (the default) Doxygen will 
+# generate HTML output.
+
+GENERATE_HTML          = YES
+
+# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `html' will be used as the default path.
+
+HTML_OUTPUT            = html
+
+# The HTML_FILE_EXTENSION tag can be used to specify the file extension for 
+# each generated HTML page (for example: .htm,.php,.asp). If it is left blank 
+# doxygen will generate files with .html extension.
+
+HTML_FILE_EXTENSION    = .html
+
+# The HTML_HEADER tag can be used to specify a personal HTML header for 
+# each generated HTML page. If it is left blank doxygen will generate a 
+# standard header.
+
+HTML_HEADER            = @srcdir@/doxygen.head
+
+# The HTML_FOOTER tag can be used to specify a personal HTML footer for 
+# each generated HTML page. If it is left blank doxygen will generate a 
+# standard footer.
+
+HTML_FOOTER            = @srcdir@/doxygen.foot
+
+# The HTML_STYLESHEET tag can be used to specify a user-defined cascading 
+# style sheet that is used by each HTML page. It can be used to 
+# fine-tune the look of the HTML output. If the tag is left blank doxygen 
+# will generate a default style sheet
+
+HTML_STYLESHEET        = @srcdir@/doxygen.css
+
+# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, 
+# files or namespaces will be aligned in HTML using tables. If set to 
+# NO a bullet list will be used.
+
+HTML_ALIGN_MEMBERS     = YES
+
+# If the GENERATE_HTMLHELP tag is set to YES, additional index files 
+# will be generated that can be used as input for tools like the 
+# Microsoft HTML help workshop to generate a compressed HTML help file (.chm) 
+# of the generated HTML documentation.
+
+GENERATE_HTMLHELP      = NO
+
+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can 
+# be used to specify the file name of the resulting .chm file. You 
+# can add a path in front of the file if the result should not be 
+# written to the html output dir.
+
+CHM_FILE               = 
+
+# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can 
+# be used to specify the location (absolute path including file name) of 
+# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run 
+# the HTML help compiler on the generated index.hhp.
+
+HHC_LOCATION           = 
+
+# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag 
+# controls if a separate .chi index file is generated (YES) or that 
+# it should be included in the master .chm file (NO).
+
+GENERATE_CHI           = NO
+
+# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag 
+# controls whether a binary table of contents is generated (YES) or a 
+# normal table of contents (NO) in the .chm file.
+
+BINARY_TOC             = NO
+
+# The TOC_EXPAND flag can be set to YES to add extra items for group members 
+# to the contents of the HTML help documentation and to the tree view.
+
+TOC_EXPAND             = NO
+
+# The DISABLE_INDEX tag can be used to turn on/off the condensed index at 
+# top of each HTML page. The value NO (the default) enables the index and 
+# the value YES disables it.
+
+DISABLE_INDEX          = NO
+
+# This tag can be used to set the number of enum values (range [1..20]) 
+# that doxygen will group on one line in the generated HTML documentation.
+
+ENUM_VALUES_PER_LINE   = 4
+
+# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be
+# generated containing a tree-like index structure (just like the one that 
+# is generated for HTML Help). For this to work a browser that supports 
+# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, 
+# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are 
+# probably better off using the HTML help feature.
+
+GENERATE_TREEVIEW      = YES
+
+# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be 
+# used to set the initial width (in pixels) of the frame in which the tree 
+# is shown.
+
+TREEVIEW_WIDTH         = 250
+
+#---------------------------------------------------------------------------
+# configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will 
+# generate Latex output.
+
+GENERATE_LATEX         = NO
+
+# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `latex' will be used as the default path.
+
+LATEX_OUTPUT           = latex
+
+# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be 
+# invoked. If left blank `latex' will be used as the default command name.
+
+LATEX_CMD_NAME         = latex
+
+# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to 
+# generate index for LaTeX. If left blank `makeindex' will be used as the 
+# default command name.
+
+MAKEINDEX_CMD_NAME     = makeindex
+
+# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact 
+# LaTeX documents. This may be useful for small projects and may help to 
+# save some trees in general.
+
+COMPACT_LATEX          = NO
+
+# The PAPER_TYPE tag can be used to set the paper type that is used 
+# by the printer. Possible values are: a4, a4wide, letter, legal and 
+# executive. If left blank a4wide will be used.
+
+PAPER_TYPE             = a4wide
+
+# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX 
+# packages that should be included in the LaTeX output.
+
+EXTRA_PACKAGES         = 
+
+# The LATEX_HEADER tag can be used to specify a personal LaTeX header for 
+# the generated latex document. The header should contain everything until 
+# the first chapter. If it is left blank doxygen will generate a 
+# standard header. Notice: only use this tag if you know what you are doing!
+
+LATEX_HEADER           = 
+
+# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated 
+# is prepared for conversion to pdf (using ps2pdf). The pdf file will 
+# contain links (just like the HTML output) instead of page references 
+# This makes the output suitable for online browsing using a pdf viewer.
+
+PDF_HYPERLINKS         = NO
+
+# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of 
+# plain latex in the generated Makefile. Set this option to YES to get a 
+# higher quality PDF documentation.
+
+USE_PDFLATEX           = NO
+
+# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. 
+# command to the generated LaTeX files. This will instruct LaTeX to keep 
+# running if errors occur, instead of asking the user for help. 
+# This option is also used when generating formulas in HTML.
+
+LATEX_BATCHMODE        = NO
+
+# If LATEX_HIDE_INDICES is set to YES then doxygen will not 
+# include the index chapters (such as File Index, Compound Index, etc.) 
+# in the output.
+
+LATEX_HIDE_INDICES     = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the RTF output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output 
+# The RTF output is optimised for Word 97 and may not look very pretty with 
+# other RTF readers or editors.
+
+GENERATE_RTF           = NO
+
+# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `rtf' will be used as the default path.
+
+RTF_OUTPUT             = rtf
+
+# If the COMPACT_RTF tag is set to YES Doxygen generates more compact 
+# RTF documents. This may be useful for small projects and may help to 
+# save some trees in general.
+
+COMPACT_RTF            = NO
+
+# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated 
+# will contain hyperlink fields. The RTF file will 
+# contain links (just like the HTML output) instead of page references. 
+# This makes the output suitable for online browsing using WORD or other 
+# programs which support those fields. 
+# Note: wordpad (write) and others do not support links.
+
+RTF_HYPERLINKS         = NO
+
+# Load stylesheet definitions from file. Syntax is similar to doxygen's 
+# config file, i.e. a series of assigments. You only have to provide 
+# replacements, missing definitions are set to their default value.
+
+RTF_STYLESHEET_FILE    = 
+
+# Set optional variables used in the generation of an rtf document. 
+# Syntax is similar to doxygen's config file.
+
+RTF_EXTENSIONS_FILE    = 
+
+#---------------------------------------------------------------------------
+# configuration options related to the man page output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_MAN tag is set to YES (the default) Doxygen will 
+# generate man pages
+
+GENERATE_MAN           = NO
+
+# The MAN_OUTPUT tag is used to specify where the man pages will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `man' will be used as the default path.
+
+MAN_OUTPUT             = man
+
+# The MAN_EXTENSION tag determines the extension that is added to 
+# the generated man pages (default is the subroutine's section .3)
+
+MAN_EXTENSION          = .3
+
+# If the MAN_LINKS tag is set to YES and Doxygen generates man output, 
+# then it will generate one additional man file for each entity 
+# documented in the real man page(s). These additional files 
+# only source the real man page, but without them the man command 
+# would be unable to find the correct page. The default is NO.
+
+MAN_LINKS              = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the XML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_XML tag is set to YES Doxygen will 
+# generate an XML file that captures the structure of 
+# the code including all documentation. Note that this 
+# feature is still experimental and incomplete at the 
+# moment.
+
+GENERATE_XML           = NO
+
+# The XML_OUTPUT tag is used to specify where the XML pages will be put. 
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be 
+# put in front of it. If left blank `xml' will be used as the default path.
+
+XML_OUTPUT             = xml
+
+# The XML_SCHEMA tag can be used to specify an XML schema, 
+# which can be used by a validating XML parser to check the 
+# syntax of the XML files.
+
+XML_SCHEMA             = 
+
+# The XML_DTD tag can be used to specify an XML DTD, 
+# which can be used by a validating XML parser to check the 
+# syntax of the XML files.
+
+XML_DTD                = 
+
+#---------------------------------------------------------------------------
+# configuration options for the AutoGen Definitions output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will 
+# generate an AutoGen Definitions (see autogen.sf.net) file 
+# that captures the structure of the code including all 
+# documentation. Note that this feature is still experimental 
+# and incomplete at the moment.
+
+GENERATE_AUTOGEN_DEF   = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the Perl module output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_PERLMOD tag is set to YES Doxygen will 
+# generate a Perl module file that captures the structure of 
+# the code including all documentation. Note that this 
+# feature is still experimental and incomplete at the 
+# moment.
+
+GENERATE_PERLMOD       = NO
+
+# If the PERLMOD_LATEX tag is set to YES Doxygen will generate 
+# the necessary Makefile rules, Perl scripts and LaTeX code to be able 
+# to generate PDF and DVI output from the Perl module output.
+
+PERLMOD_LATEX          = NO
+
+# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be 
+# nicely formatted so it can be parsed by a human reader.  This is useful 
+# if you want to understand what is going on.  On the other hand, if this 
+# tag is set to NO the size of the Perl module output will be much smaller 
+# and Perl will parse it just the same.
+
+PERLMOD_PRETTY         = YES
+
+# The names of the make variables in the generated doxyrules.make file 
+# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. 
+# This is useful so different doxyrules.make files included by the same 
+# Makefile don't overwrite each other's variables.
+
+PERLMOD_MAKEVAR_PREFIX = 
+
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor   
+#---------------------------------------------------------------------------
+
+# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will 
+# evaluate all C-preprocessor directives found in the sources and include 
+# files.
+
+ENABLE_PREPROCESSING   = YES
+
+# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro 
+# names in the source code. If set to NO (the default) only conditional 
+# compilation will be performed. Macro expansion can be done in a controlled 
+# way by setting EXPAND_ONLY_PREDEF to YES.
+
+MACRO_EXPANSION        = NO
+
+# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES 
+# then the macro expansion is limited to the macros specified with the 
+# PREDEFINED and EXPAND_AS_PREDEFINED tags.
+
+EXPAND_ONLY_PREDEF     = NO
+
+# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files 
+# in the INCLUDE_PATH (see below) will be search if a #include is found.
+
+SEARCH_INCLUDES        = YES
+
+# The INCLUDE_PATH tag can be used to specify one or more directories that 
+# contain include files that are not input files but should be processed by 
+# the preprocessor.
+
+INCLUDE_PATH           = 
+
+# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard 
+# patterns (like *.h and *.hpp) to filter out the header-files in the 
+# directories. If left blank, the patterns specified with FILE_PATTERNS will 
+# be used.
+
+INCLUDE_FILE_PATTERNS  = 
+
+# The PREDEFINED tag can be used to specify one or more macro names that 
+# are defined before the preprocessor is started (similar to the -D option of 
+# gcc). The argument of the tag is a list of macros of the form: name 
+# or name=definition (no spaces). If the definition and the = are 
+# omitted =1 is assumed.
+
+PREDEFINED             = SHAPE \
+                         RENDER \
+                         XKB \
+                         XINPUT
+
+# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then 
+# this tag can be used to specify a list of macro names that should be expanded. 
+# The macro definition that is found in the sources will be used. 
+# Use the PREDEFINED tag if you want to use a different macro definition.
+
+EXPAND_AS_DEFINED      = 
+
+# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then 
+# doxygen's preprocessor will remove all function-like macros that are alone 
+# on a line, have an all uppercase name, and do not end with a semicolon. Such 
+# function macros are typically used for boiler-plate code, and will confuse the 
+# parser if not removed.
+
+SKIP_FUNCTION_MACROS   = YES
+
+#---------------------------------------------------------------------------
+# Configuration::addtions related to external references   
+#---------------------------------------------------------------------------
+
+# The TAGFILES option can be used to specify one or more tagfiles. 
+# Optionally an initial location of the external documentation 
+# can be added for each tagfile. The format of a tag file without 
+# this location is as follows: 
+#   TAGFILES = file1 file2 ... 
+# Adding location for the tag files is done as follows: 
+#   TAGFILES = file1=loc1 "file2 = loc2" ... 
+# where "loc1" and "loc2" can be relative or absolute paths or 
+# URLs. If a location is present for each tag, the installdox tool 
+# does not have to be run to correct the links.
+# Note that each tag file must have a unique name
+# (where the name does NOT include the path)
+# If a tag file is not located in the directory in which doxygen 
+# is run, you must also specify the path to the tagfile here.
+
+TAGFILES               = 
+
+# When a file name is specified after GENERATE_TAGFILE, doxygen will create 
+# a tag file that is based on the input files it reads.
+
+GENERATE_TAGFILE       = 
+
+# If the ALLEXTERNALS tag is set to YES all external classes will be listed 
+# in the class index. If set to NO only the inherited external classes 
+# will be listed.
+
+ALLEXTERNALS           = NO
+
+# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed 
+# in the modules index. If set to NO, only the current project's groups will 
+# be listed.
+
+EXTERNAL_GROUPS        = YES
+
+# The PERL_PATH should be the absolute path and name of the perl script 
+# interpreter (i.e. the result of `which perl').
+
+PERL_PATH              = /usr/bin/perl
+
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool   
+#---------------------------------------------------------------------------
+
+# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will 
+# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base or 
+# super classes. Setting the tag to NO turns the diagrams off. Note that this 
+# option is superceded by the HAVE_DOT option below. This is only a fallback. It is 
+# recommended to install and use dot, since it yields more powerful graphs.
+
+CLASS_DIAGRAMS         = YES
+
+# If set to YES, the inheritance and collaboration graphs will hide 
+# inheritance and usage relations if the target is undocumented 
+# or is not a class.
+
+HIDE_UNDOC_RELATIONS   = YES
+
+# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is 
+# available from the path. This tool is part of Graphviz, a graph visualization 
+# toolkit from AT&T and Lucent Bell Labs. The other options in this section 
+# have no effect if this option is set to NO (the default)
+
+HAVE_DOT               = NO
+
+# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen 
+# will generate a graph for each documented class showing the direct and 
+# indirect inheritance relations. Setting this tag to YES will force the 
+# the CLASS_DIAGRAMS tag to NO.
+
+CLASS_GRAPH            = YES
+
+# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen 
+# will generate a graph for each documented class showing the direct and 
+# indirect implementation dependencies (inheritance, containment, and 
+# class references variables) of the class with other documented classes.
+
+COLLABORATION_GRAPH    = YES
+
+# If the UML_LOOK tag is set to YES doxygen will generate inheritance and 
+# collaboration diagrams in a style similiar to the OMG's Unified Modeling 
+# Language.
+
+UML_LOOK               = NO
+
+# If set to YES, the inheritance and collaboration graphs will show the 
+# relations between templates and their instances.
+
+TEMPLATE_RELATIONS     = YES
+
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT 
+# tags are set to YES then doxygen will generate a graph for each documented 
+# file showing the direct and indirect include dependencies of the file with 
+# other documented files.
+
+INCLUDE_GRAPH          = YES
+
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and 
+# HAVE_DOT tags are set to YES then doxygen will generate a graph for each 
+# documented header file showing the documented files that directly or 
+# indirectly include this file.
+
+INCLUDED_BY_GRAPH      = YES
+
+# If the CALL_GRAPH and HAVE_DOT tags are set to YES then doxygen will 
+# generate a call dependency graph for every global function or class method. 
+# Note that enabling this option will significantly increase the time of a run. 
+# So in most cases it will be better to enable call graphs for selected 
+# functions only using the \callgraph command.
+
+CALL_GRAPH             = NO
+
+# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen 
+# will graphical hierarchy of all classes instead of a textual one.
+
+GRAPHICAL_HIERARCHY    = YES
+
+# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images 
+# generated by dot. Possible values are png, jpg, or gif
+# If left blank png will be used.
+
+DOT_IMAGE_FORMAT       = gif
+
+# The tag DOT_PATH can be used to specify the path where the dot tool can be 
+# found. If left blank, it is assumed the dot tool can be found on the path.
+
+DOT_PATH               = 
+
+# The DOTFILE_DIRS tag can be used to specify one or more directories that 
+# contain dot files that are included in the documentation (see the 
+# \dotfile command).
+
+DOTFILE_DIRS           = 
+
+# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the 
+# graphs generated by dot. A depth value of 3 means that only nodes reachable 
+# from the root by following a path via at most 3 edges will be shown. Nodes that 
+# lay further from the root node will be omitted. Note that setting this option to 
+# 1 or 2 may greatly reduce the computation time needed for large code bases. Also 
+# note that a graph may be further truncated if the graph's image dimensions are 
+# not sufficient to fit the graph (see MAX_DOT_GRAPH_WIDTH and MAX_DOT_GRAPH_HEIGHT). 
+# If 0 is used for the depth value (the default), the graph is not depth-constrained.
+
+MAX_DOT_GRAPH_DEPTH    = 0
+
+# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will 
+# generate a legend page explaining the meaning of the various boxes and 
+# arrows in the dot generated graphs.
+
+GENERATE_LEGEND        = YES
+
+# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will 
+# remove the intermediate dot files that are used to generate 
+# the various graphs.
+
+DOT_CLEANUP            = YES
+
+#---------------------------------------------------------------------------
+# Configuration::addtions related to the search engine   
+#---------------------------------------------------------------------------
+
+# The SEARCHENGINE tag specifies whether or not a search engine should be 
+# used. If set to NO the values of all tags below this one will be ignored.
+
+SEARCHENGINE           = NO
diff --git a/hw/dmx/doxygen/doxygen.css b/hw/dmx/doxygen/doxygen.css
new file mode 100644
index 0000000..841f709
--- /dev/null
+++ b/hw/dmx/doxygen/doxygen.css
@@ -0,0 +1,49 @@
+H1 { text-align: center; }
+CAPTION { font-weight: bold }
+A.qindex {}
+A.qindexRef {}
+A.el { text-decoration: none; font-weight: bold }
+A.elRef { font-weight: bold }
+A.code { text-decoration: none; font-weight: normal; color: #4444ee }
+A.codeRef { font-weight: normal; color: #4444ee }
+A:hover { text-decoration: none; background-color: #f2f2ff }
+DL.el { margin-left: -1cm }
+DIV.fragment { width: 100%; border: none; background-color: #eeeeee }
+DIV.ah { background-color: black; font-weight: bold; color: #ffffff; margin-bottom: 3px; margin-top: 3px }
+TD.md { background-color: #f2f2ff; font-weight: bold; }
+TD.mdname1 { background-color: #f2f2ff; font-weight: bold; color: #602020; }
+TD.mdname { background-color: #f2f2ff; font-weight: bold; color: #602020; width: 600px; }
+DIV.groupHeader { margin-left: 16px; margin-top: 12px; margin-bottom: 6px; font-weight: bold }
+DIV.groupText { margin-left: 16px; font-style: italic; font-size: smaller }
+BODY { background: white }
+TD.indexkey { 
+   background-color: #eeeeff; 
+   font-weight: bold; 
+   padding-right  : 10px; 
+   padding-top    : 2px; 
+   padding-left   : 10px; 
+   padding-bottom : 2px; 
+   margin-left    : 0px; 
+   margin-right   : 0px; 
+   margin-top     : 2px; 
+   margin-bottom  : 2px  
+}
+TD.indexvalue { 
+   background-color: #eeeeff; 
+   font-style: italic; 
+   padding-right  : 10px; 
+   padding-top    : 2px; 
+   padding-left   : 10px; 
+   padding-bottom : 2px; 
+   margin-left    : 0px; 
+   margin-right   : 0px; 
+   margin-top     : 2px; 
+   margin-bottom  : 2px  
+}
+FONT.keyword       { color: #008000 }
+FONT.keywordtype   { color: #604020 }
+FONT.keywordflow   { color: #e08000 }
+FONT.comment       { color: #800000 }
+FONT.preprocessor  { color: #806020 }
+FONT.stringliteral { color: #002080 }
+FONT.charliteral   { color: #008080 }
diff --git a/hw/dmx/doxygen/doxygen.foot b/hw/dmx/doxygen/doxygen.foot
new file mode 100644
index 0000000..3aca117
--- /dev/null
+++ b/hw/dmx/doxygen/doxygen.foot
@@ -0,0 +1,12 @@
+    <hr>
+    <address>
+      <small>
+        Generated June 29, 2004 for <a
+        href="http://dmx.sourceforge.net">Distributed Multihead X</a> by
+        <a href="http://www.doxygen.org/index.html">doxygen</a>
+        1.3.4.
+      </small>
+    </addres>
+    </hr>
+  </body>
+</html>
diff --git a/hw/dmx/doxygen/doxygen.head b/hw/dmx/doxygen/doxygen.head
new file mode 100644
index 0000000..89bda8f
--- /dev/null
+++ b/hw/dmx/doxygen/doxygen.head
@@ -0,0 +1,8 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+  <head>
+    <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+    <title>File Index</title>
+    <link href="doxygen.css" rel="stylesheet" type="text/css">
+  </head>
+  <body>
commit 595460c397a543fe512becd3c432de2a0a68d187
Author: Gaetan Nadon <memsize at videotron.ca>
Date:   Thu Apr 28 21:16:09 2011 -0400

    dmx/doc: use common makefile for developers documentation
    
    The user/specs docs now have external references support.
    Developers doc are not installed so they do not participate.
    However, using a similar makefile shared amongst developers
    document reduces maintenance and is forward looking.
    
    Reviewed-by Jeremy Huddleston <jeremyhu at apple.com>
    Signed-off-by: Gaetan Nadon <memsize at videotron.ca>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/dmx/doc/Makefile.am b/hw/dmx/doc/Makefile.am
index 53fb784..40d0550 100644
--- a/hw/dmx/doc/Makefile.am
+++ b/hw/dmx/doc/Makefile.am
@@ -19,11 +19,16 @@
 #  NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
 #  CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
-doc_sources = dmx.xml scaled.xml
-
-# Developer's documentation is not installed
 if ENABLE_DEVEL_DOCS
-include $(top_srcdir)/doc/xml/xmlrules-noinst.in
+if HAVE_XMLTO
+
+# Main DocBook/XML files (DOCTYPE book)
+docbook = dmx.xml scaled.xml
+
+# Generate DocBook/XML output formats with or without stylesheets
+include $(top_srcdir)/devbook.am
+
+endif HAVE_XMLTO
 endif ENABLE_DEVEL_DOCS
 
 DOXYGEN_HEAD=\
commit 04011b0bc3b5b59efa0d981866349c4ad0868d8f
Author: Gaetan Nadon <memsize at videotron.ca>
Date:   Thu Apr 28 21:16:08 2011 -0400

    doc: use common makefile for developers documentation
    
    The user/specs docs now have external references support.
    Developers doc are not installed so they do not participate.
    However, using a similar makefile shared amongst developers
    document reduces maintenance and is forward looking.
    
    Man pages being out of here, reorg developers docs under the same roof.
    Drop the obsolete sgml subdir.
    
    Reviewed-by Jeremy Huddleston <jeremyhu at apple.com>
    Signed-off-by: Gaetan Nadon <memsize at videotron.ca>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/configure.ac b/configure.ac
index a474073..3dce5a6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2181,8 +2181,6 @@ hw/xfree86/ddc/Makefile
 hw/xfree86/dixmods/Makefile
 hw/xfree86/dixmods/extmod/Makefile
 hw/xfree86/doc/Makefile
-hw/xfree86/doc/devel/Makefile
-hw/xfree86/doc/sgml/Makefile
 hw/xfree86/dri/Makefile
 hw/xfree86/dri2/Makefile
 hw/xfree86/exa/Makefile
diff --git a/devbook.am b/devbook.am
new file mode 100644
index 0000000..dbc9d8a
--- /dev/null
+++ b/devbook.am
@@ -0,0 +1,62 @@
+#
+# Generate output formats for a single DocBook/XML with/without chapters
+#
+# Variables set by the calling Makefile:
+# noinst_DATA: developers docs are not installed
+# docbook:  the main DocBook/XML file, no chapters, appendix or image files
+# chapters: all files pulled in by an XInclude statement and images.
+#
+
+#
+# This makefile is intended for Developers Documentation and is not installed.
+# Do not use for Users docs or Specs which need to be installed and require olink support
+# Refer to http://www.x.org/releases/X11R7.6/doc/xorg-docs/ReleaseNotes.html#id2584393
+# for an explanation on documents classification.
+#
+
+# Developers documnetation is not installed
+noinst_DATA =
+
+# DocBook/XML file with chapters, appendix and images it includes
+dist_noinst_DATA = $(docbook) $(chapters)
+
+#
+# Generate DocBook/XML output formats with or without stylesheets
+#
+
+# Stylesheets are available if the package xorg-sgml-doctools is installed
+if HAVE_STYLESHEETS
+
+# The location where all cross reference databases are installed
+XMLTO_FLAGS =						\
+	--searchpath "$(XORG_SGML_PATH)/X11"		\
+	--searchpath "$(abs_top_builddir)/doc/xml"	\
+	--stringparam current.docid="$(<:.xml=)"
+
+XMLTO_XHTML_FLAGS = \
+	-m $(STYLESHEET_SRCDIR)/xorg-xhtml.xsl \
+	--stringparam html.stylesheet=$(STYLESHEET_SRCDIR)/xorg.css
+
+XMLTO_FO_FLAGS = \
+	-m $(STYLESHEET_SRCDIR)/xorg-fo.xsl
+endif HAVE_STYLESHEETS
+
+noinst_DATA += $(docbook:.xml=.html)
+%.html: %.xml  $(chapters)
+	$(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) $(XMLTO_XHTML_FLAGS) xhtml-nochunks $<
+
+if HAVE_FOP
+noinst_DATA += $(docbook:.xml=.pdf) $(docbook:.xml=.ps)
+%.pdf: %.xml $(chapters)
+	$(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) $(XMLTO_FO_FLAGS) --with-fop pdf $<
+%.ps: %.xml $(chapters)
+	$(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) $(XMLTO_FO_FLAGS) --with-fop ps $<
+endif HAVE_FOP
+
+if HAVE_XMLTO_TEXT
+noinst_DATA += $(docbook:.xml=.txt)
+%.txt: %.xml $(chapters)
+	$(AM_V_GEN)$(XMLTO) $(XMLTO_FLAGS) $(XMLTO_XHTML_FLAGS) txt $<
+endif HAVE_XMLTO_TEXT
+
+CLEANFILES = $(noinst_DATA)
diff --git a/hw/xfree86/doc/.gitignore b/hw/xfree86/doc/.gitignore
new file mode 100644
index 0000000..63eee59
--- /dev/null
+++ b/hw/xfree86/doc/.gitignore
@@ -0,0 +1,4 @@
+ddxDesign.html
+ddxDesign.pdf
+ddxDesign.ps
+ddxDesign.txt
diff --git a/hw/xfree86/doc/Makefile.am b/hw/xfree86/doc/Makefile.am
index ac316e0..1c3620a 100644
--- a/hw/xfree86/doc/Makefile.am
+++ b/hw/xfree86/doc/Makefile.am
@@ -1,4 +1,18 @@
-SUBDIRS = devel sgml
 
-EXTRA_DIST = \
+if ENABLE_DEVEL_DOCS
+if HAVE_XMLTO
+
+# Main DocBook/XML files (DOCTYPE book)
+docbook = ddxDesign.xml
+
+# Generate DocBook/XML output formats with or without stylesheets
+include $(top_srcdir)/devbook.am
+
+endif HAVE_XMLTO
+endif ENABLE_DEVEL_DOCS
+
+EXTRA_DIST =		\
+	Registry	\
+	exa-driver.txt	\
+	README.DRIcomp	\
 	README.modes
diff --git a/hw/xfree86/doc/README.DRIcomp b/hw/xfree86/doc/README.DRIcomp
new file mode 100644
index 0000000..2d3ebf1
--- /dev/null
+++ b/hw/xfree86/doc/README.DRIcomp
@@ -0,0 +1,554 @@
+                            DRI Compilation Guide
+
+          VA Linux Systems, Inc. Professional Services - Graphics.
+
+                                21 April 2001
+
+1.  Preamble
+
+1.1  Copyright
+
+Copyright 2000-2001 by VA Linux Systems, Inc.  All Rights Reserved.
+
+Permission is granted to make and distribute verbatim copies of this document
+provided the copyright notice and this permission notice are preserved on all
+copies.
+
+1.2  Trademarks
+
+OpenGL is a registered trademark and SGI is a trademark of Silicon Graphics,
+Inc.  Unix is a registered trademark of The Open Group.  The `X' device and X
+Window System are trademarks of The Open Group.  XFree86 is a trademark of
+The XFree86 Project.  Linux is a registered trademark of Linus Torvalds.
+Intel is a registered trademark of Intel Corporation.  3Dlabs, GLINT, and
+Oxygen are either registered trademarks or trademarks of 3Dlabs Inc. Ltd.
+3dfx, Voodoo3, Voodoo4, and Voodoo5 are registered trademarks of 3dfx Inter-
+active, Incorporated.  Matrox is a registered trademark of Matrox Electronic
+Systems Ltd.  ATI Rage and Radeon is a registered trademark of ATI Technolo-
+gies, Inc.  All other trademarks mentioned are the property of their respec-
+tive owners.
+
+2.  Introduction
+
+This document describes how to download, compile and install the DRI.  The
+DRI provides 3D graphics hardware acceleration for the XFree86 project.  This
+information is intended for experienced Linux developers.  Beginners are
+probably better off installing precompiled packages.
+
+Edits, corrections and updates to this document may be mailed to <brian at tung-
+stengraphics.com>.
+
+Last updated on 13 February 2002 by Brian Paul.
+
+3.  Prerequisites
+
+You'll need the following:
+
+   o An installation of XFree86 4.1 or later.  The DRI tree has been pruned
+     down to minimize its size.  But in order to build the DRI tree you need
+     to have recent X header files, etc. already installed.  If you don't
+     have XFree86 4.1 (or later) installed you can probably install it from
+     RPMs (or another package format).  Or, you can download XFree86 as
+     sources and compile/install it yourself.
+
+   o At least 200MB of free disk space.  If you compile for debugging (the -g
+     option) then you'll need about 600MB.
+
+   o GCC compiler and related tools.
+
+   o ssh (secure shell) if you're a DRI developer and don't want to use
+     anonymous CVS download.
+
+   o A 2.4.x Linux Kernel.  See below for details.
+
+   o FreeBSD support is not currently being maintained and may not work.
+
+The DRI 3D drivers generally work on systems with Intel or AMD CPUs.  How-
+ever, limited support for Alpha and PowerPC support is underway.
+
+For 3dfx Voodoo hardware, you'll also need the Glide3 runtime library
+(libglide3-v3.so for Voodoo3 or libglide3-v5.so for Voodoo4/5).  These can be
+downloaded from the DRI website.  You can compile them yourself, but it's
+often a painful process.
+
+For Matrox G200/G400, Intel i810/i830 or ATI Rage128/Radeon hardware, you'll
+also need AGP support in your Linux kernel, either built-in or as a loadable
+module.
+
+4.  Linux Kernel Preparation
+
+Only the Linux 2.4.x kernels are currently supported by the DRI hardware
+drivers.  2.5.x kernels may work, but aren't tested.
+
+Most of the DRI drivers require AGP support and using Intel Pentium III SSE
+optimizations also requires an up-to-date Linux kernel.  Configuring your
+kernel correctly is very important, as features such as SSE optimizations
+will be disabled if your kernel does not support them.  Thus, if you have a
+Pentium III processor, you must configure your kernel for the Pentium III
+processor family.
+
+Building a new Linux kernel can be difficult for beginners but there are
+resources on the Internet to help.  This document assumes experience with
+configuring, building and installing Linux kernels.
+
+Linux kernels can be downloaded from www.kernel.org
+
+Here are the basic steps for kernel setup.
+
+   o Download the needed kernel and put it in /usr/src.  Create a directory
+     for the source and unpack it.  For example:
+
+                    cd /usr/src
+                    rm -f linux
+                    mkdir linux-2.4.x
+                    ln -s linux-2.4.x linux
+                    bzcat linux-2.4.x.tar.bz2 | tar xf -
+
+     It is critical that /usr/src/linux point to your new kernel sources,
+     otherwise the kernel headers will not be used when building the DRI.
+     This will almost certainly cause compilation problems.
+
+   o Read /usr/src/linux/Documentation/Changes.  This file lists the minimum
+     requirements for all software packages required to build the kernel.
+     You must upgrade at least gcc, make, binutils and modutils to at least
+     the versions specified in this file.  The other packages may not be
+     needed.  If you are upgrading from Linux 2.2.x you must upgrade your
+     modutils package for Linux 2.4.x.
+
+   o Configure your kernel.  You might, for example, use make menuconfig and
+     do the following:
+
+        o Go to Code maturity level options
+
+        o Enable Prompt for development and/or incomplete code/drivers
+
+        o hit ESC to return to the top-level menu
+
+        o Go to Processor type and features
+
+        o Select your processor type from Processor Family
+
+        o hit ESC to return to the top-level menu
+
+        o Go to Character devices
+
+        o Disable Direct Rendering Manager (XFree86 DRI support) since we'll
+          use the DRI code from the XFree86/DRI tree and will compile it
+          there.
+
+        o Go to /dev/agpgart (AGP Support) (EXPERIMENTAL) (NEW)
+
+        o Hit SPACE twice to build AGP support into the kernel
+
+        o Enable all chipsets' support for AGP
+
+        o It's recommended that you turn on MTRRs under Processor type and
+          Features, but not required.
+
+   o Configure the rest of the kernel as required for your system (i.e. Eth-
+     ernet, SCSI, etc)
+
+   o Exit, saving your kernel configuration.
+
+   o Edit your /etc/lilo.conf file.  Make sure you have an image entry as
+     follows (or similar):
+
+                      image=/boot/vmlinuz
+                            label=linux.2.4.x
+                            read-only
+                            root=/dev/hda1
+
+     The important part is that you have /boot/vmlinuz without a trailing
+     version number.  If this is the first entry in your /etc/lilo.conf AND
+     you haven't set a default, then this will be your default kernel.
+
+   o Compile the new kernel.
+
+                    cd /usr/src/linux-2.4.x
+                    make dep
+                    make bzImage
+                    make modules
+                    make modules_install
+                    make install
+
+     Note that last make command will automatically run lilo for you.
+
+   o Now reboot to use the new kernel.
+
+5.  CPU Architectures
+
+In general, nothing special has to be done to use the DRI on different CPU
+architectures.  There are, however, a few optimizations that are CPU-depen-
+dent.  Mesa will determine at runtime which CPU-dependent optimizations
+should be used and enable them where appropriate.
+
+5.1  Intel Pentium III Features
+
+The Pentium III SSE instructions are used in optimized vertex transformation
+functions in the Mesa-based DRI drivers.  On Linux, SSE requires a recent
+kernel (such as 2.4.0-test11 or later) both at compile time and runtime.
+
+5.2  AMD 3DNow! Features
+
+AMD's 3DNow! instructions are used in optimized vertex transformation func-
+tions in the Mesa-based DRI drivers.  3DNow! is supported in most versions of
+Linux.
+
+5.3  Alpha Features
+
+On newer Alpha processors a significant performance increase can be seen with
+the addition of the -mcpu= option to GCC.  This option is dependent on the
+architecture of the processor.  For example, -mcpu=ev6 will build specifi-
+cally for the EV6 based AXP's, giving both byte and word alignment access to
+the DRI/Mesa drivers.
+
+To enable this optimization edit your xc/config/host.def file and add the
+line:
+
+#define DefaultGcc2AxpOpt -O2 -mcpu=ev6
+
+Additional speed improvements to 3D rendering can be achieved by installing
+Compaq's Math Libraries (CPML) which can be obtained from http://www.sup-
+port.compaq.com/alpha-tools/software/index.html
+
+Once installed, you can add this line to your host.def to build with the CPML
+libraries:
+
+#define UseCompaqMathLibrary YES
+
+The host.def file is explained below.
+
+6.  Downloading the XFree86/DRI CVS Sources
+
+The DRI project is hosted by SourceForge.  The DRI source code, which is a
+subset of the XFree86 source tree, is kept in a CVS repository there.
+
+The DRI CVS sources may be accessed either anonymously or as a registered
+SourceForge user.  It's recommended that you become a registered SourceForge
+user so that you may submit non-anonymous bug reports and can participate in
+the mailing lists.
+
+6.1  Anonymous CVS download:
+
+  1.  Create a directory to store the CVS files:
+
+                       cd ~
+                       mkdir DRI-CVS
+
+      You could put your CVS directory in a different place but we'll use
+      ~/DRI-CVS/ here.
+
+  2.  Check out the CVS sources:
+
+                       cd ~/DRI-CVS
+                       cvs -d:pserver:anonymous at cvs.dri.sourceforge.net:/cvsroot/dri login
+                         (hit ENTER when prompted for a password)
+                       cvs -z3 -d:pserver:anonymous at cvs.dri.sourceforge.net:/cvsroot/dri co xc
+
+      The -z3 flag causes compression to be used in order to reduce the down-
+      load time.
+
+6.2  Registered CVS download:
+
+  1.  Create a directory to store the CVS files:
+
+                       cd ~
+                       mkdir DRI-CVS
+
+      You could put your CVS directory in a different place but we'll use
+      ~/DRI-CVS/ here.
+
+  2.  Set the CVS_RSH environment variable:
+
+                       setenv CVS_RSH ssh      // if using csh or tcsh
+                       export CVS_RSH=ssh      // if using sh or bash
+
+  3.  Check out the CVS sources:
+
+                       cd ~/DRI-CVS
+                       cvs -z3 -d:ext:YOURID at cvs.dri.sourceforge.net:/cvsroot/dri co xc
+
+      Replace YOURID with your CVS login name.  You'll be prompted to enter
+      your sourceforge password.
+
+      The -z3 flag causes compression to be used in order to reduce the down-
+      load time.
+
+6.3  Updating your CVS sources
+
+In the future you'll want to occasionally update your local copy of the DRI
+source code to get the latest changes.  This can be done with:
+
+                cd ~/DRI-CVS
+                cvs -z3 update -dA xc
+
+The -d flag causes any new subdirectories to be created and -A causes most
+recent trunk sources to be fetched, not branch sources.
+
+7.  Mesa
+
+Most of the DRI 3D drivers are based on Mesa (the free implementation of the
+OpenGL API).  The relevant files from Mesa are already included in the
+XFree86/DRI source tree.  There is no need to download or install the Mesa
+source files separately.
+
+Sometimes a newer version of Mesa will be available than the version included
+in XFree86/DRI.  Upgrading Mesa within XFree86/DRI is not always straightfor-
+ward.  It can be an error-prone undertaking, especially for beginners, and is
+not generally recommended.  The DRI developers will upgrade Mesa when appro-
+priate.
+
+8.  Compiling the XFree86/DRI tree
+
+8.1  Make a build tree
+
+Rather than placing object files and library files right in the source tree,
+they're instead put into a parallel build tree.  The build tree is made with
+the lndir command:
+
+                 cd ~/DRI-CVS
+                 ln -s xc XFree40
+                 mkdir build
+                 cd build
+                 lndir -silent -ignorelinks ../XFree40
+
+The build tree will be populated with symbolic links which point back into
+the CVS source tree.
+
+Advanced users may have several build trees for compiling and testing with
+different options.
+
+8.2  Edit the host.def file
+
+The ~/DRI-CVS/build/xc/config/cf/host.def file is used to configure the
+XFree86 build process.  You can change it to customize your build options or
+make adjustments for your particular system configuration
+
+The default host.def file will look something like this:
+
+                 #define DefaultCCOptions -Wall
+     (i386)      #define DefaultGcc2i386Opt -O2
+     (Alpha)     #define DefaultGcc2AxpOpt -O2 -mcpu=ev6 (or similar)
+                 #define LibraryCDebugFlags -O2
+                 #define BuildServersOnly YES
+                 #define XF86CardDrivers vga tdfx mga ati i810
+                 #define LinuxDistribution LinuxRedHat
+                 #define DefaultCCOptions -ansi GccWarningOptions -pipe
+                 #define BuildXF86DRI YES
+                 /* Optionally turn these on for debugging */
+                 /* #define GlxBuiltInTdfx YES */
+                 /* #define GlxBuiltInMga YES */
+                 /* #define GlxBuiltInR128 YES */
+                 /* #define GlxBuiltInRadeon YES */
+                 /* #define DoLoadableServer NO */
+                 #define SharedLibFont NO
+
+The ProjectRoot variable specifies where the XFree86 files will be installed.
+We recommend installing the DRI files over your existing XFree86 installation
+- it's generally safe to do and less error-prone.  This policy is different
+than what we used to recommend.
+
+If XFree86 4.x is not installed in /usr/X11R6/ you'll have to add the follow-
+ing to the host.def file:
+
+                 #define ProjectRoot pathToYourXFree86installation
+
+Note the XF86CardDrivers line to be sure your card's driver is listed.
+
+If you want to enable 3DNow! optimizations in Mesa and the DRI drivers, you
+should add the following:
+
+                 #define MesaUse3DNow YES
+
+You don't have to be using an AMD processor in order to enable this option.
+The DRI will look for 3DNow! support and runtime and only enable it if appli-
+cable.
+
+If you want to enable SSE optimizations in Mesa and the DRI drivers, you must
+upgrade to a Linux 2.4.x kernel.  Mesa will verify that SSE is supported by
+both your processor and your operating system, but to build Mesa inside the
+DRI you need to have the Linux 2.4.x kernel headers in /usr/src/linux.  If
+you enable SSE optimizations with an earlier version of the Linux kernel in
+/usr/src/linux, Mesa will not compile.  You have been warned.  If you do have
+a 2.4.x kernel, you should add the following:
+
+                 #define MesaUseSSE YES
+
+If you want to build the DRM kernel modules as part of the full build pro-
+cess, add the following:
+
+                 #define BuildXF86DRM YES
+
+Otherwise, you'll need to build them separately as described below.
+
+8.3  Compilation
+
+To compile the complete DRI tree:
+
+                 cd ~/DRI-CVS/build/xc/
+                 make World >& world.log
+
+Or if you want to watch the compilation progress:
+
+                 cd ~/DRI-CVS/build/xc/
+                 make World >& world.log &
+                 tail -f world.log
+
+With the default compilation flags it's normal to get a lot of warnings dur-
+ing compilation.
+
+Building will take some time so you may want to go check your email or visit
+slashdot.
+
+WARNING: do not use the -j option with make.  It's reported that it does not
+work with XFree86/DRI.
+
+8.4  Check for compilation errors
+
+Using your text editor, examine world.log for errors by searching for the
+pattern ***.
+
+After fixing the errors, run make World again.  Later, you might just compile
+parts of the source tree but it's important that the whole tree will build
+first.
+
+If you edited your host.def file to enable automatic building of the DRI ker-
+nel module(s), verify that they were built:
+
+               cd ~/DRI-CVS/build/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel
+               ls
+
+Otherwise, build them now by running
+
+               cd ~/DRI-CVS/build/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel
+               make -f Makefile.linux
+
+For the 3dfx Voodoo, you should see tdfx.o.  For the Matrox G200/G400, you
+should see mga.o.  For the ATI Rage 128, you should see r128.o.  For the ATI
+Radeon, you should see radeon.o.  For the Intel i810, you should see i810.o.
+
+If the DRI kernel module(s) failed to build you should verify that you're
+using the right version of the Linux kernel.  The most recent kernels are not
+always supported.
+
+If your build machine is running a different version of the kernel than your
+target machine (i.e. 2.2.x vs. 2.4.x), make will select the wrong kernel
+source tree. This can be fixed by explicitly setting the value of LINUXDIR.
+If the path to your kernel source is /usr/src/linux-2.4.x,
+
+               cd ~/DRI-CVS/build/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel
+               make -f Makefile.linux LINUXDIR=/usr/src/linux-2.4.x
+
+or alternatively, edit Makefile.linux to set LINUXDIR before the ifndef LIN-
+UXDIR line.
+
+8.5  DRI kernel module installation
+
+The DRI kernel modules will be in ~/DRI-CVS/build/xc/pro-
+grams/Xserver/hw/xfree86/os-support/linux/drm/kernel/.
+
+To load the appropriate DRM module in your running kernel you can either use
+ismod and restart your X server or copy the kernel module to /lib/mod-
+ules/2.4.x/kernel/drivers/char/drm/ then run depmod and restart your X
+server.
+
+Make sure you first unload any older DRI kernel modules that might be already
+loaded.
+
+Note that some DRM modules require that the agpgart module be loaded first.
+
+9.  Normal Installation and Configuration
+
+Most users will want to install the new X server and use it in place of their
+old X server.  This section explains how to do that.
+
+Developers, on the other hand, may just want to test the X server without
+actually installing it as their default server.  If you want to do that, skip
+to the next section.
+
+9.1  Installation
+
+Here are the installation commands:
+
+                su
+                cd ~/DRI-CVS/build/xc
+                make install
+
+9.2  Update the XF86Config File
+
+You may need to edit your XF86Config file to enable the DRI.  The config file
+is usually installed as /etc/X11/XF86Config-4.  See the DRI User Guide for
+details, but basically, you need to load the "glx" and "dri" modules and add
+a "DRI" section.
+
+On the DRI web site, in the resources section, you'll find example XF86Config
+files for a number of graphics cards.  These configuration files also setup
+DRI options so it's highly recommended that you look at these examples.
+
+The XFree86 4.x server can generate a basic configuration file itself.  Sim-
+ply do this:
+
+                  cd /usr/X11R6/bin
+                  ./XFree86 -configure
+
+A file named /root/XF86Config.new will be created.  It should allow you to
+try your X server but you'll almost certainly have to edit it.  For example,
+you should add HorizSync and VertRefresh options to the Monitor section and
+Modes options to the Screen section.  Also, the ModulePath option in the
+Files section should be set to /usr/X11R6/lib/modules.
+
+9.3  Start the New X Server
+
+The new X server should be ready to use now.  Start your X server in your
+usual manner.  Often times the startx command is used:
+
+                  startx
+
+10.  Testing the Server Without Installing It
+
+As mentioned at the start of section 9, developers may want to simply run the
+X server without installing it.  This can save some time and allow you to
+keep a number of X servers available for testing.
+
+10.1  Configuration
+
+As described in the preceding section, you'll need to create a configuration
+file for the new server.  Put the XF86Config file in your ~/DRI-
+CVS/build/xc/programs/Xserver directory.
+
+Be sure the ModulePath option in your XF86Config file is set correctly.
+
+10.2  A Startup Script
+
+A simple shell script can be used to start the X server.  Here's an example.
+
+             #!/bin/sh
+             export DISPLAY=:0
+             ./XFree86 -xf86config XF86Config & \
+             sleep 2
+             fvwm2 &
+             xset b off
+             xmodmap -e "clear mod4"
+             xsetroot -solid "#00306f"
+             xterm -geometry 80x40+0+0
+
+You might name this script start-dri.  Put it in your ~/DRI-CVS/build/xc/pro-
+grams/Xserver directory.
+
+To test the server run the script:
+
+                  cd ~/DRI-CVS/build/xc/programs/Xserver
+                  ./start-dri
+
+For debugging, you may also want to capture the log messages printed by the
+server in a file.  If you're using the C-shell:
+
+                  ./start-dri >& log
+
+11.  Where To Go From Here
+
+At this point your X server should be up and running with hardware-acceler-
+ated direct rendering.  Please read the DRI User Guide for information about
+trouble shooting and how to use the DRI-enabled X server for 3D applications.
+
+     Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/DRIcomp.sgml,v 1.19 dawes Exp $
diff --git a/hw/xfree86/doc/Registry b/hw/xfree86/doc/Registry
new file mode 100644
index 0000000..48e24a2
--- /dev/null
+++ b/hw/xfree86/doc/Registry
@@ -0,0 +1,409 @@
+This is the XFree86 driver/module registry.  To avoid name space clashes and
+to maintain some consistency between drivers the important name spaces are
+maintained here.
+
+1. Module Names.
+
+Each module is required to have a unique name.  Registered names are:
+
+GLcore
+acecad
+afb
+apm
+ark
+ati
+atimisc
+bitmap
+bt8xx
+calcomp
+cfb
+cfb16
+cfb24
+cfb32
+chips
+cirrus
+citron
+cyrix
+dbe
+ddc
+digitaledge
+dmc
+dri
+drm
+dynapro
+elo2300
+elographics
+extmod
+fb
+fbdev
+fbdevhw
+fi12x6
+freetype
+glide
+glint
+glx
+hyperpen
+i128
+i2c
+i740
+i810
+imstt
+int10
+joystick
+keyboard
+layer
+magellan
+magictouch
+mfb
+mga
+microtouch
+mouse
+msp34xx
+mutouch
+neomagic
+newport
+nv
+pcidata
+penmount
+pex5
+r128
+radeon
+rac
+ramdac
+record
+rendition
+s3
+s3virge
+savage
+shadow
+shadowfb
+siliconmotion
+sis
+spaceorb
+speedo
+summa
+sunbw2
+suncg14
+suncg3
+suncg6
+sunffb
+sunleo
+suntcx
+tdfx
+tga
+trident
+tseng
+type1
+v4l
+vbe
+vesa
+vga
+vgahw
+vmware
+void
+wacom
+xaa
+xf1bpp
+xf24_32bpp
+xf4bpp
+xf8_16bpp
+xf8_32bpp
+xf8_32wid
+xie
+xtrap
+xtt
+
+2. External Module Object Symbols.
+
+Each module is required to use a unique prefix or prefixes for all of
+its externally visible symbols. They should be unique without regard to
+case.  Registered prefixes are:
+
+ati
+bt8xx
+cfb
+chips
+fi12x6
+glide
+glint
+mfb
+mga
+msp34xx
+neo
+permedia
+tseng
+vga
+vgahw
+vmware
+xaa
+xf1bpp
+xf4bpp
+
+3. Chipset Names.
+
+Each video driver is required to use a unique set of chipset names.  Case,
+white space and underscore characters are ignored when comparing chipset
+names.  All names listed here are in lower case with all white space and
+underscores removed.  Registered chipset names are:
+
+ati
+ativga
+ct64200
+ct64300
+ct65520
+ct65525
+ct65530
+ct65535
+ct65540
+ct65545
+ct65546
+ct65548
+ct65550
+ct65554
+ct65555
+ct68554
+ct69000
+et4000
+et4000w32
+et4000w32i
+et4000w32p
+et6000
+et6100
+generic
+ibmvga
+ibm8514
+mach32
+mach64
+mach8
+mga2064w
+mga1064sg
+mga2164w
+mga2164wagp
+neo2070
+neo2090
+neo2093
+neo2097
+neo2160
+neo2200
+tipm2
+vgawonder
+voodoo
+
+4. Option Names.
+
+Option names and their usage should be consistent between drivers.
+Case, white space and underscore characters are ignored when comparing
+option names.  The prefix "no" may be added or removed from boolean
+option names.  All names listed here are in their preferred user-visible
+form.  Some registered option names are:
+
+Types are:  B = boolean, O = set/unset (no value), I = integer, S = string,
+            A = optional string, F = floating point number Q = frequency
+
+Scopes are: F = global flags, V = video driver, C = common (per screen),
+            I = input drivers, X = XAA, Xv = Xv extension, M = misc.
+
+Names currently in use:
+
+Name                    Type  Scope      Description
+----------------------------------------------------------------------------
+AllowMouseOpenFail        B     F    ignore mouse dev open failure
+AllowNonLocalModInDev     B     F    allow non-local mod of input devs
+AllowNonLocalXvidtune     B     F    allow non-local VidMode connections
+BlankTime                 I     F    Screen saver timeout (min)
+DisableModInDev           B     F    disallow changing input devs
+DisableVidModeExtension   B     F    disable VidMode extension
+DontVTSwitch              B     F    disable Ctrl-Alt-Fn
+DontZap                   B     F    disable Ctrl-Alt-BS sequence
+DontZoom                  B     F    disable Ctrl-Alt-+/-
+NoTrapSignals             B     F    don't trap signals
+OffTime                   I     F    Time before DPMS off mode active (min)
+PciProbe1                 O     F    use PCI probe algorithm 1
+PciProbe2                 O     F    use PCI probe algorithm 2
+PciForceConfig1           O     F    force PCI config type 1
+PciForceConfig2           O     F    force PCI config type 2
+Pixmap                    I     F    depth 24 pixmap size (24 or 32)
+StandbyTime               I     F    Time before DPMS standby active (min)
+SuspendTime               I     F    Time before DPMS suspend mode active (min)
+
+BackingStore              B     C    Enable backing store
+DDC                       B     C    Enable/disable DDC
+DDC1                      B     C    Enable/disable DDC1
+DDC2                      B     C    Enable/disable DDC2
+DPMS                      O     C    Enable DPMS
+MTRR                      B     C    Enable/disable setting MTRRs
+
+BaudRate                  I     I    Serial port baud rate
+ButtonNumber              I     I    Button number (for touch screen?)
+ButtonThreshold           I     I    ??
+ClearDTR                  O     I    Clear serial port DTR
+ClearRTS                  O     I    Clear serial port RTS
+DataBits                  I     I    Serial port data bits
+DemandLoad                O     I    ??
+Device                    S     I    Device file name
+DeviceName                S     I    Input device name
+FlowControl               S     I    Serial flow control ("xon", "none")
+Floating                  B     I    Device initialised as floating
+HistorySize               I     I    ??
+MaxX                      I     I    Maximum X coordinate
+MaxY                      I     I    Maximum Y coordinate
+MinX                      I     I    Minimum X coordinate
+MinY                      I     I    Minimum Y coordinate
+Parity                    S     I    Serial port parity ("odd", "even", "none")
+ReportDelay               I     I    ??
+ReportingMode             S     I    may be "raw" or "scaled"
+ScreenNumber              I     I    Screen number (for touch screen)
+SendCoreEvents            B     I    Send core events
+StopBits                  I     I    Serial port stop bits
+SwapXY                    B     I    Swap the X and Y axes
+UntouchDelay              I     I    ??
+Vmin                      I     I    Tty VMIN
+Vtime                     I     I    Tty VTIME
+
+
+18BitBus                  B     V    ??
+8Plus16                   B     V    Enable depth 8 + depth 16 with overlay
+8Plus24                   B     V    Enable depth 8 + depth 24 with overlay
+BlockWrite                B     V    Enable/disable block write
+ColorKey                  I     V    Set the color key for overlay modes
+CompositeSync             B     V    Composite sync
+CRTDisplay                B     V    Force display on CRT, not LCD
+CRTScreen                 B     V    Display on CRT, not LCD (Obsolete)
+EarlyRasPrecharge         O     V    Early RAS pre-charge
+FastDRAM                  O     V    Fast DRAM
+FifoAggressive            O     V    Aggressive FIFO setting
+FifoConservative          O     V    Conservative FIFO setting
+FifoModerate              O     V    Moderate FIFO setting
+FireGL3000                B     V    Card is Diamond FireGL3000
+FixPanelSize              B     V    ??
+FPClock8                  Q     V    Flat panel clock for 8bpp fb (MHz)
+FPClock16                 Q     V    Flat panel clock for 16bpp fb (MHz)
+FPClock24                 Q     V    Flat panel clock for 24bpp fb (MHz)
+FPClock32                 Q     V    Flat panel clock for 32bpp fb (MHz)
+FPMVRAM                   O     V    Fast page mode VRAM
+FramebufferWC             B     V    Enable/disable WC for the framebuffer
+GlideDevice               I     V    Selects which Voodoo board to use
+HiBitHigh                 O     V    High clock bit default to set
+HiBitLow                  O     V    High clock bit default to cleared
+HWClocks                  B     V    Enable/disable HW clocks
+HWCursor                  B     V    Enable/disable HW cursor
+LateRasPrecharge          O     V    Late RAS pre-charge
+Legend                    O     V    Card is Legend ET4000
+LCDCenter                 B     V    Enable/disable centering for LCD displays
+Linear                    B     V    Enable/disable linear framebuffer
+MCLK                      Q     V    Specify the current MCLK value (MHz)
+MedDRAM                   B     V    Medium speed DRAM
+MemCfg1                   I     V    ??
+MemCfg2                   I     V    ??
+MGASDRAM                  B     V    Mga card has SDRAM
+MMIO                      B     V    Enable/disable memory mapped I/O
+MMIOCache                 B     V    Enable/Disable MMIO cache
+MuxThreshold              I     V    Multiplexing threshold (kHz)
+NoAccel                   B     V    Disable/enable acceleration
+NoClockChip               B     V    ??
+NoStretch                 B     V    Disable/enable stretching for LCD displays
+OnAtExit                  B     V    Leave video signal on when exiting server
+OverclockMem              B     V    Enable memory overclocking
+Overlay                   A     V    Enable multi-depth/overlay.  An optional
+                                     string "M,N" may be specified, where
+                                     M, N are the depths.
+PanelDisplay              B     V    Force display on LCD
+PciBurst                  B     V    Enable/disable PCI burst mode
+PciRetry                  B     V    Enable/disable PCI retries
+ProbeClocks               B     V    Force probe for non-programmable clocks
+ReferenceClock            Q     V    Clock generator reference frequency
+RGBbits                   I     V    Number of significant bits per rgb
+Rotate                    S     V    Rotate the virtual display (CW or CCW)
+SetLCDClk                 Q     V    Set LCD clock (MHz)
+SetMclk                   Q     V    Set Memory Clock (MHz)
+ShadowFB                  B     V    Enable shadow framebuffer layer
+ShowCache                 B     V    Enable viewing of offscreen memory
+ShowOverscan              O     V    Set the overscan area to a visible colour
+SlowDRAM                  O     V    Slow DRAM
+SlowEDODRAM               O     V    Slow EDO DRAM
+STN                       B     V    STN screen type (??)
+SWCursor                  B     V    Enable/disable SW cursor
+SuspendHack               B     V    ??
+SyncOnGreen               B     V    Enable/disable sync on green
+TurboQueue                B     V    Enable/disable turbo queue
+UseFBDev                  B     V    Use the fbdev driver interface
+UseModeLine               B     V    Use Modeline (??)
+W32Interleave             B     V    ??
+
+Buffers			  I	Xv   Number of buffers
+Device			  S	Xv   Device file name
+Expose                    B     Xv   Disable occlusion clipping (see DESIGN)
+FramesPerSec		  I	Xv   Max. refresh frequency
+
+XAA options.  All are of type "O" and scope "X", and are self-explanatory
+
+XaaNoColor8x8PatternFillRect
+XaaNoColor8x8PatternFillTrap
+XaaNoCPUToScreenColorExpandFill
+XaaNoDashedBresenhamLine
+XaaNoDashedTwoPointLine
+XaaNoScreenToScreenCopy
+XaaNoImageReadRect
+XaaNoImageWriteRect
+XaaNoMono8x8PatternFillRect
+XaaNoMono8x8PatternFillTrap
+XaaNoOffscreenPixmaps
+XaaNoPixmapCache
+XaaNoScanlineCPUToScreenColorExpandFill
+XaaNoScanlineImageWriteRect
+XaaNoScreenToScreenColorExpandFill
+XaaNoSolidBresenhamLine
+XaaNoSolidFillRect
+XaaNoSolidFillTrap
+XaaNoSolidHorVertLine
+XaaNoSolidTwoPointLine
+
+
+Names used in previous versions:
+
+16Clocks
+8Clocks
+ClkDiv2
+EDO VRAM
+ExternDisp
+ExtFramBuf
+FastVRAM
+FavorBitBlt
+InternDisp
+NoBitBlt
+NoFontCache
+NoImageBlt
+NoMemAccess
+NoPciDisconnect
+NoPixmapCache
+NoProgramClocks
+NoSplitXfer
+OverrideBIOS
+OverrideValidateMode
+ProgLcdModeRegs
+ProgLcdModeStretch
+SlowDRAMrefresh
+SlowVRAM
+SwapHiBit
+
+
+5. Ramdac Names.
+
+Ramdac names should be consistent between drivers.  Case, white space
+and underscore characters are ignored when comparing ramdac names.  All
+names listed here are in lower case with all white space and underscores
+removed.
+
+
+6. Clock Chip Names.
+
+Clock chip names should be consistent between drivers.  Case, white
+space and underscore characters are ignored when comparing clock chip
+names.  All names listed here are in lower case with all white space
+and underscores removed.
+
+
+
+
+
+$XFree86: xc/programs/Xserver/hw/xfree86/Registry,v 1.18 2002/04/06 18:31:09 tsi Exp $
diff --git a/hw/xfree86/doc/ddxDesign.xml b/hw/xfree86/doc/ddxDesign.xml
new file mode 100644
index 0000000..0290960
--- /dev/null
+++ b/hw/xfree86/doc/ddxDesign.xml
@@ -0,0 +1,9394 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
+ "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
+ <!ENTITY % defs SYSTEM "/xserver/doc/xml/xserver.ent"> %defs;
+ <!-- config file keyword markup -->
+ <!-- specific config file keywords -->
+ <!ENTITY k.device "<emphasis>Device</emphasis>">
+ <!ENTITY k.monitor "<emphasis>Monitor</emphasis>">
+ <!ENTITY k.display "<emphasis>Display</emphasis>">
+ <!ENTITY k.inputdevice "<emphasis>InputDevice</emphasis>">
+ <!ENTITY k.screen "<emphasis>Screen</emphasis>">
+ <!ENTITY k.serverlayout "<emphasis>ServerLayout</emphasis>">
+ <!ENTITY k.driver "<emphasis>Driver</emphasis>">
+ <!ENTITY k.module "<emphasis>Module</emphasis>">
+ <!ENTITY k.identifier "<emphasis>Identifier</emphasis>">
+ <!ENTITY k.serverflags "<emphasis>ServerFlags</emphasis>">
+] >
+
+<article id="ddxDesign">
+  <articleinfo>
+
+    <title>XFree86 DDX Design (Xorg server version &xserver.version;)</title>
+
+    <authorgroup>
+      <corpauthor><ulink url="http://www.xfree86.org/">
+	The XFree86 Project, Inc.</ulink></corpauthor>
+      <corpauthor><ulink url="http://www.x.org/">
+	The X.Org Foundation, Inc.</ulink></corpauthor>
+
+      <othercredit>
+	<firstname>Jim</firstname><surname>Gettys</surname>
+	<contrib>Updates for X11R6.7</contrib>
+      </othercredit>
+    </authorgroup>
+
+    <pubdate>&xserver.reldate;</pubdate>
+    <releaseinfo>Xorg server version &xserver.version;</releaseinfo>
+
+  </articleinfo>
+
+  <note><para>
+This document describes software undergoing continual evolution, and
+the interfaces described here are subject to change without notice.
+This document is intended to cover the interfaces as found in the
+xorg-server-&xserver.version; release, but is probably not completely
+in sync with the code base.
+    </para></note>
+
+
+  <sect1>
+    <title>Preface</title>
+
+    <para>
+This document was originally the design spec for the DDX layer of the
+XFree86 4.0 X server.  The X.Org Foundation adopted the XFree86 4.4rc2
+version of that server as the basis of the Xorg server project, and has
+evolved the XFree86 DDX layer greatly since forking.   This document thus
+covers only the current implementation of the XFree86 DDX as found in the
+Xorg server &xserver.version; release, and no longer matches the XFree86
+server itself.
+      </para>
+
+    <para>
+The XFree86 Project's broad design principles for XFree86 4.0 were:
+      <itemizedlist>
+	<listitem><para>keep it reasonable
+	    <itemizedlist>
+	      <listitem><para>We cannot rewrite the complete server
+		</para></listitem>
+	      <listitem><para>We don't want to re-invent the wheel
+		</para></listitem>
+	    </itemizedlist></para></listitem>
+	<listitem><para>keep it modular
+	    <itemizedlist>
+	      <listitem><para>As many things as possible should go into modules
+		</para></listitem>
+	      <listitem><para>The basic loader binary should be minimal
+		</para></listitem>
+	      <listitem><para>A clean design with well defined layering is
+		  important</para></listitem>
+	      <listitem><para>DDX specific global variables are a nono
+		</para></listitem>
+	      <listitem><para>The structure should be flexible enough to allow
+		  future extensions</para></listitem>
+	      <listitem><para>The structure should minimize duplication of
+		  common code</para></listitem>
+	    </itemizedlist></para></listitem>
+	<listitem><para>keep important features in mind
+	    <itemizedlist>
+	      <listitem><para>multiple screens, including multiple instances
+		  of drivers</para></listitem>
+	      <listitem><para>mixing different color depths and visuals on
+		  different and ideally even on the same screen
+		</para></listitem>
+	      <listitem><para>better control of the PCI device used
+		</para></listitem>
+	      <listitem><para>better config file parser</para></listitem>
+	      <listitem><para>get rid of all VGA compatibility assumptions
+		</para></listitem>
+	    </itemizedlist></para></listitem>
+      </itemizedlist>
+    </para>
+
+    <para>
+While the XFree86 project had a goal of avoiding changes to the DIX
+layer unless they found major deficiencies there, to avoid divergence from
+the X.Org sample implementation they were integrating changes from, the
+X.Org developers now maintain both sides, and make changes where they are
+most appropriate.   This document concentrates on the XFree86 DDX layer used
+in the Xorg server itself (the code found in <filename>hw/xfree86</filename>
+in the source tree), and developers will also want to refer to the
+<filename>Xserver-spec</filename> documentation that covers the DIX layer
+routines common to all the X servers in the sample implementation.
+    </para>
+  </sect1>
+
+  <sect1>
+    <title>The xorg.conf File</title>
+
+    <para>
+The xorg.conf file format is based on the XF86Config format from XFree86 4.4,
+which is in turn similar to the old XFree86 3.x XF86Config format, with the
+following changes:
+    </para>
+
+    <sect2>
+      <title>&k.device; section</title>
+
+      <para>
+    The &k.device; sections are similar to what they used to be, and
+    describe hardware-specific information for a single video card.
+    &k.device;
+    Some new keywords are added:
+
+
+	<variablelist>
+	  <varlistentry><term>Driver "drivername"</term>
+	    <listitem><para>
+        Specifies the name of the driver to be used for the card.  This
+        is mandatory.
+	      </para></listitem></varlistentry>
+	  <varlistentry><term>BusID "busslot"</term>
+	    <listitem><para>
+        Specifies uniquely the location of the card on the bus.  The
+        purpose is to identify particular cards in a multi-headed
+        configuration.  The format of the argument is intentionally
+        vague, and may be architecture dependent.  For a PCI bus, it
+        is something like "bus:slot:func".
+	      </para></listitem></varlistentry>
+	</variablelist>
+      </para>
+
+      <para>
+    A &k.device; section is considered <quote>active</quote> if there is a reference
+    to it in an active &k.screen; section.
+      </para>
+    </sect2>
+
+    <sect2>
+      <title>&k.screen; section</title>
+
+      <para>
+    The &k.screen; sections are similar to what they used to be.  They
+    no longer have a &k.driver; keyword, but an &k.identifier; keyword
+    is added.  (The &k.driver; keyword may be accepted in place of the
+    &k.identifier; keyword for compatibility purposes.)  The identifier
+    can be used to identify which screen is to be active when multiple
+    &k.screen; sections are present.  It is possible to specify the active
+    screen from the command line.  A default is chosen in the absence
+    of one being specified.  A &k.screen; section is considered <quote>active</quote>
+    if there is a reference to it either from the command line, or from
+    an active &k.serverlayout; section.
+      </para>
+    </sect2>
+
+    <sect2>
+      <title>&k.inputdevice; section</title>
+
+      <para>
+    The &k.inputdevice; section is a new section that describes
+    configuration information for input devices.  It replaces the old
+    <emphasis>Keyboard</emphasis>, <emphasis>Pointer</emphasis> and <emphasis>XInput</emphasis>
+    sections.  Like the &k.device; section, it has two mandatory keywords:
+    &k.identifier; and &k.driver;.  For compatibility purposes the old
+    <emphasis>Keyboard</emphasis> and <emphasis>Pointer</emphasis> sections are
+    converted by the parser into &k.inputdevice; sections as follows:
+
+	<variablelist>
+	  <varlistentry><term><emphasis>Keyboard</emphasis></term>
+	    <listitem><literallayout>
+             &k.identifier; "Implicit Core Keyboard"
+             &k.driver; "keyboard"
+	      </literallayout></listitem></varlistentry>
+	  <varlistentry><term><emphasis>Pointer</emphasis></term>
+	    <listitem><literallayout>
+             &k.identifier; "Implicit Core Pointer"
+             &k.driver; "mouse"
+	      </literallayout></listitem></varlistentry>
+	</variablelist>
+      </para>
+
+      <para>
+    An &k.inputdevice; section is considered active if there is a
+    reference to it in an active &k.serverlayout; section.  An
+    &k.inputdevice; section may also be referenced implicitly if there
+    is no &k.serverlayout; section, if the <option>-screen</option> command
+    line options is used, or if the &k.serverlayout; section doesn't
+    reference any &k.inputdevice; sections.  In this case, the first
+    sections with drivers "keyboard" and "mouse" are used as the core
+    keyboard and pointer respectively.
+      </para>
+    </sect2>
+
+    <sect2>
+      <title>&k.serverlayout; section</title>
+
+      <para>
+    The &k.serverlayout; section is a new section that is used to identify
+    which &k.screen; sections are to be used in a multi-headed configuration,
+    and the relative layout of those screens.  It also identifies which
+    &k.inputdevice; sections are to be used.  Each &k.serverlayout; section
+    has an identifier, a list of &k.screen; section identifiers, and a list of
+    &k.inputdevice; section identifiers.  &k.serverflags; options may also be
+    included in a &k.serverlayout; section, making it possible to override
+    the global values in the &k.serverflags; section.
+      </para>
+
+      <para>
+    A &k.serverlayout; section can be made active by being referenced on
+    the command line.  In the absence of this, a default will be chosen
+    (the first one found).  The screen names may optionally be followed
+    by a number specifying the preferred screen number, and optionally
+    by information specifying the physical positioning of the screen,
+    either in absolute terms or relative to another screen (or screens).
+    When no screen number is specified, they are numbered according to
+    the order in which they are listed.  The old (now obsolete) method
+    of providing the positioning information is to give the names of
+    the four adjacent screens.  The order of these is top, bottom, left,
+    right.  Here is an example of a &k.serverlayout; section for two
+    screens using the old method, with the second located to the right
+    of the first:
+
+	<programlisting>
+      Section "ServerLayout"
+        Identifier "Main Layout"
+        Screen     0 "Screen 1" ""  ""  ""  "Screen 2"
+        Screen     1 "Screen 2"
+        Screen     "Screen 3"
+      EndSection
+	</programlisting>
+      </para>
+
+      <para>
+    The preferred way of specifying the layout is to explicitly specify
+    the screen's location in absolute terms or relative to another
+    screen.
+      </para>
+
+      <para>
+    In the absolute case, the upper left corner's coordinates are given
+    after the <emphasis>Absolute</emphasis> keyword.  If the coordinates are
+    omitted, a value of <code>(0,0)</code> is assumed.  An example
+    of absolute positioning follows:
+
+	<programlisting>
+      Section "ServerLayout"
+        Identifier "Main Layout"
+        Screen     0 "Screen 1" Absolute 0 0
+        Screen     1 "Screen 2" Absolute 1024 0
+        Screen     "Screen 3" Absolute 2048 0
+      EndSection
+	</programlisting>
+      </para>
+
+      <para>
+    In the relative case, the position is specified by either using one of
+    the following keywords followed by the name of the reference screen:
+
+	<simplelist type='vert' columns='1'>
+	  <member><emphasis>RightOf</emphasis></member>
+	  <member><emphasis>LeftOf</emphasis></member>
+	  <member><emphasis>Above</emphasis></member>
+	  <member><emphasis>Below</emphasis></member>
+	  <member><emphasis>Relative</emphasis></member>
+	</simplelist>
+      </para>
+
+      <para>
+    When the <emphasis>Relative</emphasis> keyword is used, the reference screen
+    name is followed by the coordinates of the new screen's origin
+    relative to reference screen.  The following example shows how to use
+    some of the relative positioning options.
+
+	<programlisting>
+      Section "ServerLayout"
+        Identifier "Main Layout"
+        Screen     0 "Screen 1"
+        Screen     1 "Screen 2" RightOf "Screen 1"
+        Screen     "Screen 3" Relative "Screen 1" 2048 0
+      EndSection
+	</programlisting>
+      </para>
+    </sect2>
+
+    <sect2>
+      <title>Options</title>
+
+      <para>
+    Options are used more extensively.  They may appear in most sections
+    now.  Options related to drivers can be present in the &k.screen;,
+    &k.device; and &k.monitor; sections and the &k.display; subsections.
+    The order of precedence is &k.display;, &k.screen;, &k.monitor;,
+    &k.device;.  Options have been extended to allow an optional value
+    to be specified in addition to the option name.  For more details
+    about options, see the <link linkend="options">Options</link> section
+    for details.
+      </para>
+    </sect2>
+  </sect1>
+
+  <sect1>
+    <title>Driver Interface</title>
+
+    <para>
+The driver interface consists of a minimal set of entry points that are
+required based on the external events that the driver must react to.
+No non-essential structure is imposed on the way they are used beyond
+that.  This is a significant difference compared with the old design.
+    </para>
+
+    <para>
+The entry points for drawing operations are already taken care of by
+the framebuffer code (including, XAA).  Extensions and enhancements to
+framebuffer code are outside the scope of this document.
+    </para>
+
+    <para>
+This approach to the driver interface provides good flexibility, but does
+increase the complexity of drivers.  To help address this, the XFree86
+common layer provides a set of <quote>helper</quote> functions to take care of things
+that most drivers need.  These helpers help minimise the amount of code
+duplication between drivers.  The use of helper functions by drivers is
+however optional, though encouraged.  The basic philosophy behind the
+helper functions is that they should be useful to many drivers, that
+they should balance this against the complexity of their interface.  It
+is inevitable that some drivers may find some helpers unsuitable and
+need to provide their own code.
+    </para>
+
+    <para>
+Events that a driver needs to react to are:
+
+      <variablelist>
+	<varlistentry><term>ScreenInit</term>
+
+	  <listitem><para>
+     An initialisation function is called from the DIX layer for each
+     screen at the start of each server generation.
+	    </para></listitem></varlistentry>
+
+	<varlistentry><term>Enter VT</term>
+
+	  <listitem><para>
+     The server takes control of the console.
+	    </para></listitem></varlistentry>
+
+	<varlistentry><term>Leave VT</term>
+
+	  <listitem><para>
+     The server releases control of the console.
+	    </para></listitem></varlistentry>
+
+	<varlistentry><term>Mode Switch</term>
+
+	  <listitem><para>
+     Change video mode.
+	    </para></listitem></varlistentry>
+
+	<varlistentry><term>ViewPort change</term>
+
+	  <listitem><para>
+     Change the origin of the physical view port.
+	    </para></listitem></varlistentry>
+
+	<varlistentry><term>ScreenSaver state change</term>
+
+	  <listitem><para>
+     Screen saver activation/deactivation.
+	    </para></listitem></varlistentry>
+
+	<varlistentry><term>CloseScreen</term>
+
+	  <listitem><para>
+     A close screen function is called from the DIX layer for each screen
+     at the end of each server generation.
+	    </para></listitem></varlistentry>
+      </variablelist>
+    </para>
+
+
+    <para>
+In addition to these events, the following functions are required by
+the XFree86 common layer:
+
+      <variablelist>
+	<varlistentry><term>Identify</term>
+
+	  <listitem><para>
+     Print a driver identifying message.
+	    </para></listitem></varlistentry>
+
+	<varlistentry><term>Probe</term>
+
+	  <listitem><para>
+     This is how a driver identifies if there is any hardware present that
+     it knows how to drive.
+	    </para></listitem></varlistentry>
+
+	<varlistentry><term>PreInit</term>
+
+	  <listitem><para>
+     Process information from the xorg.conf file, determine the
+     full characteristics of the hardware, and determine if a valid
+     configuration is present.
+	    </para></listitem></varlistentry>
+      </variablelist>
+    </para>
+
+    <para>
+The VidMode extension also requires:
+
+      <variablelist>
+	<varlistentry><term>ValidMode</term>
+
+	  <listitem><para>
+     Identify if a new mode is usable with the current configuration.
+     The PreInit function (and/or helpers it calls) may also make use
+     of the ValidMode function or something similar.
+	    </para></listitem></varlistentry>
+      </variablelist>
+    </para>
+
+
+    <para>
+Other extensions may require other entry points.  The drivers will
+inform the common layer of these in such cases.
+    </para>
+  </sect1>
+
+  <sect1>
+    <title>Resource Access Control Introduction</title>
+
+    <para>
+Graphics devices are accessed through ranges in I/O or memory space.
+While most modern graphics devices allow relocation of such ranges many
+of them still require the use of well established interfaces such as
+VGA memory and IO ranges or 8514/A IO ranges.  With modern buses (like
+PCI) it is possible for multiple video devices to share access to these
+resources.  The RAC (Resource Access Control) subsystem provides a
+mechanism for this.
+    </para>
+
+    <sect2>
+      <title>Terms and Definitions</title>
+
+      <sect3>
+	<title>Bus</title>
+
+	<para>
+    <quote>Bus</quote> is ambiguous as it is used for different things: it may refer
+    to physical incompatible extension connectors in a computer system.
+    The RAC system knows two such systems: The ISA bus and the PCI bus.
+    (On the software level EISA, MCA and VL buses are currently treated
+    like ISA buses).  <quote>Bus</quote> may also refer to logically different
+    entities on a single bus system which are connected via bridges.  A
+    PCI system may have several distinct PCI buses connecting each other
+    by PCI-PCI bridges or to the host CPU by HOST-PCI bridges.
+	</para>
+
+	<para>
+    Systems that host more than one bus system link these together using
+    bridges.  Bridges are a concern to RAC as they might block or pass
+    specific resources.  PCI-PCI bridges may be set up to pass VGA
+    resources to the secondary bus.  PCI-ISA buses pass any resources not
+    decoded on the primary PCI bus to the ISA bus.  This way VGA resources
+    (although exclusive on the ISA bus) can be shared by ISA and PCI
+    cards.  Currently HOST-PCI bridges are not yet handled by RAC as they
+    require specific drivers.
+	</para>
+      </sect3>
+
+      <sect3>
+	<title>Entity</title>
+
+	<para>
+    The smallest independently addressable unit on a system bus is
+    referred to as an entity.  So far we know ISA and PCI entities.  PCI
+    entities can be located on the PCI bus by an unique ID consisting of
+    the bus, card and function number.
+	</para>
+      </sect3>
+
+      <sect3>
+	<title>Resource</title>
+
+	<para>
+    <quote>Resource</quote> refers to a range of memory or I/O addresses an entity
+    can decode.
+	</para>
+
+	<para>
+    If a device is capable of disabling this decoding the resource is
+    called sharable.  For PCI devices a generic method is provided to
+    control resource decoding.  Other devices will have to provide a
+    device specific function to control decoding.
+	</para>
+
+	<para>
+    If the entity is capable of decoding this range at a different
+    location this resource is considered relocatable.
+	</para>
+
+	<para>
+    Resources which start at a specific address and occupy a single
+    continuous range are called block resources.
+	</para>
+
+	<para>
+    Alternatively resource addresses can be decoded in a way that they
+    satisfy the conditions:
+	  <programlisting>
+                    address & mask == base
+	  </programlisting>
+    and
+	  <programlisting>
+                       base & mask == base
+	  </programlisting>
+    Resources addressed in such a way are called sparse resources.
+	</para>
+
+      </sect3>
+
+      <sect3>
+	<title>Server States</title>
+
+	<para>
+    The resource access control system knows two server states: the
+    SETUP and the OPERATING state.  The SETUP state is entered whenever
+    a mode change takes place or the server exits or does VT switching.
+    During this state all entity resources are under resource access
+    control.  During OPERATING state only those entities are controlled
+    which actually have shared resources that conflict with others.
+	</para>
+      </sect3>
+    </sect2>
+  </sect1>
+
+  <sect1>
+    <title>Control Flow in the Server and Mandatory Driver Functions</title>
+
+    <para>
+At the start of each server generation, <function>main()</function>
+(<filename>dix/main.c</filename>) calls the DDX function
+<function>InitOutput()</function>.  This is the first place that the DDX gets
+control.  <function>InitOutput()</function> is expected to fill in the global
+<structname>screenInfo</structname> struct, and one
+<structfield>screenInfo.screen[]</structfield> entry for each screen present.
+Here is what <function>InitOutput()</function> does:
+    </para>
+
+    <sect2>
+      <title>Parse the xorg.conf file</title>
+
+      <para>
+    This is done at the start of the first server generation only.
+      </para>
+
+      <para>
+    The xorg.conf file is read in full, and the resulting information
+    stored in data structures.  None of the parsed information is
+    processed at this point.  The parser data structures are opaque to
+    the video drivers and to most of the common layer code.
+      </para>
+
+      <para>
+    The entire file is parsed first to remove any section ordering
+    requirements.
+      </para>
+    </sect2>
+
+
+    <sect2>
+      <title>Initial processing of parsed information and command line options
+      </title>
+
+      <para>
+    This is done at the start of the first server generation only.
+      </para>
+
+      <para>
+    The initial processing is to determine paths like the
+    <emphasis>ModulePath</emphasis>, etc, and to determine which &k.serverlayout;,
+    &k.screen; and &k.device; sections are active.
+      </para>
+    </sect2>
+
+
+    <sect2>
+      <title>Enable port I/O access</title>
+
+      <para>
+    Port I/O access is controlled from the XFree86 common layer, and is
+    <quote>all or nothing</quote>.  It is enabled prior to calling driver probes, at
+    the start of subsequent server generations, and when VT switching
+    back to the Xserver.  It is disabled at the end of server generations,
+    and when VT switching away from the Xserver.
+      </para>
+
+      <para>
+    The implementation details of this may vary on different platforms.
+      </para>
+    </sect2>
+
+
+    <sect2>
+      <title>General bus probe</title>
+
+      <para>
+    This is done at the start of the first server generation only.
+      </para>
+
+      <para>
+    In the case of ix86 machines, this will be a general PCI probe.
+    The full information obtained here will be available to the drivers.
+    This information persists for the life of the Xserver.  In the PCI
+    case, the PCI information for all video cards found is available by
+    calling <function>xf86GetPciVideoInfo()</function>.
+      </para>
+
+      <blockquote><para>
+	  <programlisting>
+    pciVideoPtr *xf86GetPciVideoInfo(void);
+	  </programlisting>
+	  <blockquote><para>
+	returns a pointer to a list of pointers to
+	<structname>pciVideoRec</structname> entries, of which there is one for
+	each detected PCI video card.  The list is terminated with a
+	<constant>NULL</constant> pointer.  If no PCI video cards were
+	detected, the return value is <constant>NULL</constant>.
+
+	    </para></blockquote>
+	</para></blockquote>
+
+      <para>
+    After the bus probe, the resource broker is initialised.
+      </para>
+    </sect2>
+
+
+    <sect2>
+      <title>Load initial set of modules</title>
+
+      <para>
+    This is done at the start of the first server generation only.
+      </para>
+
+      <para>
+    The core server contains a list of mandatory modules.  These are loaded
+    first.  Currently the only module on this list is the bitmap font module.
+      </para>
+
+      <para>
+    The next set of modules loaded are those specified explicitly in the
+    &k.module; section of the config file.
+      </para>
+
+      <para>
+    The final set of initial modules are the driver modules referenced
+    by the active &k.device; and &k.inputdevice; sections in the config
+    file.  Each of these modules is loaded exactly once.
+      </para>
+    </sect2>
+
+
+    <sect2>
+      <title>Register Video and Input Drivers</title>
+
+      <para>
+    This is done at the start of the first server generation only.
+      </para>
+
+      <para>
+    When a driver module is loaded, the loader calls its
+    <function>Setup</function> function.  For video drivers, this function
+    calls <function>xf86AddDriver()</function> to register the driver's
+    <structname>DriverRec</structname>, which contains a small set of essential
+    details and driver entry points required during the early phase of
+    <function>InitOutput()</function>.  <function>xf86AddDriver()</function>
+    adds it to the global <varname>xf86DriverList[]</varname> array.
+      </para>
+
+      <para>
+    The <structname>DriverRec</structname> contains the driver canonical name,
+    the <function>Identify()</function>,
+    <function>Probe()</function> and <function>AvailableOptions()</function>
+    function entry points as well as a pointer
+    to the driver's module (as returned from the loader when the driver
+    was loaded) and a reference count which keeps track of how many
+    screens are using the driver.  The entry driver entry points are
+    those required prior to the driver allocating and filling in its
+    <structname>ScrnInfoRec</structname>.
+      </para>
+
+      <para>
+    For a static server, the <varname>xf86DriverList[]</varname> array is
+    initialised at build time, and the loading of modules is not done.
+      </para>
+
+      <para>
+    A similar procedure is used for input drivers.  The input driver's
+    <function>Setup</function> function calls
+    <function>xf86AddInputDriver()</function> to register the driver's
+    <structname>InputDriverRec</structname>, which contains a small set of
+    essential details and driver entry points required during the early
+    phase of <function>InitInput()</function>.
+    <function>xf86AddInputDriver()</function> adds it to the global
+    <varname>xf86InputDriverList[]</varname> array.  For a static server,
+    the <varname>xf86InputDriverList[]</varname> array is initialised at
+    build time.
+      </para>
+
+      <para>
+    Both the <varname>xf86DriverList[]</varname> and
+    <varname>xf86InputDriverList[]</varname> arrays have been initialised
+    by the end of this stage.
+      </para>
+
+      <para>
+    Once all the drivers are registered, their
+    <function>ChipIdentify()</function> functions are called.
+      </para>
+
+      <blockquote><para>
+	  <programlisting>
+    void ChipIdentify(int flags);
+	  </programlisting>
+	  <blockquote><para>
+      This is expected to print a message indicating the driver name,
+      a short summary of what it supports, and a list of the chipset
+      names that it supports.  It may use the xf86PrintChipsets() helper
+      to do this.
+	    </para></blockquote>
+	</para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    void xf86PrintChipsets(const char *drvname, const char *drvmsg,
+                           SymTabPtr chips);
+	  </programlisting>
+	  <blockquote><para>
+      This function provides an easy way for a driver's ChipIdentify
+      function to format the identification message.
+	    </para></blockquote>
+	</para></blockquote>
+    </sect2>
+
+    <sect2>
+      <title>Initialise Access Control</title>
+
+      <para>
+    This is done at the start of the first server generation only.
+      </para>
+
+      <para>
+    The Resource Access Control (RAC) subsystem is initialised before
+    calling any driver functions that may access hardware.  All generic
+    bus information is probed and saved (for restoration later).  All
+    (shared resource) video devices are disabled at the generic bus
+    level, and a probe is done to find the <quote>primary</quote> video device.  These
+    devices remain disabled for the next step.
+      </para>
+    </sect2>
+
+
+    <sect2 id="probe">
+      <title>Video Driver Probe</title>
+
+      <para>
+    This is done at the start of the first server generation only.  The
+    <function>ChipProbe()</function> function of each registered video driver
+    is called.
+      </para>
+
+      <blockquote><para>
+	  <programlisting>
+    Bool ChipProbe(DriverPtr drv, int flags);
+	  </programlisting>
+	  <blockquote><para>
+      The purpose of this is to identify all instances of hardware
+      supported by the driver.  The flags value is currently either 0,
+      <constant>PROBE_DEFAULT</constant> or <constant>PROBE_DETECT</constant>.
+      <constant>PROBE_DETECT</constant> is used if "-configure" or "-probe"
+      command line arguments are given and indicates to the
+      <function>Probe()</function> function that it should not configure the
+      bus entities and that no xorg.conf information is available.
+	    </para>
+
+	  <para>
+      The probe must find the active device sections that match the
+      driver by calling <function>xf86MatchDevice()</function>.  The number
+      of matches found limits the maximum number of instances for this
+      driver.  If no matches are found, the function should return
+      <constant>FALSE</constant> immediately.
+	  </para>
+
+	<para>
+      Devices that cannot be identified by using device-independent
+      methods should be probed at this stage (keeping in mind that access
+      to all resources that can be disabled in a device-independent way
+      are disabled during this phase).  The probe must be a minimal
+      probe.  It should just determine if there is a card present that
+      the driver can drive.  It should use the least intrusive probe
+      methods possible.  It must not do anything that is not essential,
+      like probing for other details such as the amount of memory
+      installed, etc.  It is recommended that the
+      <function>xf86MatchPciInstances()</function> helper function be used
+      for identifying matching PCI devices, and similarly the
+      <function>xf86MatchIsaInstances()</function> for ISA (non-PCI) devices
+      (see the <link linkend="rac">RAC</link> section).  These helpers also
+      checks and claims the appropriate entity.  When not using the
+      helper, that should be done with <function>xf86CheckPciSlot()</function>
+      and <function>xf86ClaimPciSlot()</function> for PCI devices and
+      <function>xf86ClaimIsaSlot()</function> for ISA devices (see the
+      <link linkend="rac">RAC</link> section).
+	</para>
+
+	<para>
+      The probe must register all non-relocatable resources at this
+      stage.  If a resource conflict is found between exclusive resources
+      the driver will fail immediately.  This is usually best done with
+      the <function>xf86ConfigPciEntity()</function> helper function
+      for PCI and <function>xf86ConfigIsaEntity()</function> for ISA
+      (see the <link linkend="rac">RAC</link> section).  It is possible to
+      register some entity specific functions with those helpers.  When
+      not using the helpers, the <function>xf86AddEntityToScreen()</function>
+      <function>xf86ClaimFixedResources()</function> and
+      <function>xf86SetEntityFuncs()</function> should be used instead (see
+      the <link linkend="rac">RAC</link> section).
+	</para>
+
+	<para>
+      If a chipset is specified in an active device section which the
+      driver considers relevant (ie it has no driver specified, or the
+      driver specified matches the driver doing the probe), the Probe
+      must return <constant>FALSE</constant> if the chipset doesn't match
+      one supported by the driver.
+	</para>
+
+	<para>
+      If there are no active device sections that the driver considers
+      relevant, it must return <constant>FALSE</constant>.
+	</para>
+
+	<para>
+      Allocate a <structname>ScrnInfoRec</structname> for each active instance of the
+      hardware found, and fill in the basic information, including the
+      other driver entry points.   This is best done with the
+      <function>xf86ConfigIsaEntity()</function> helper function for ISA
+      instances or <function>xf86ConfigPciEntity()</function> for PCI instances.
+      These functions allocate a <structname>ScrnInfoRec</structname> for active
+      entities. Optionally <function>xf86AllocateScreen()</function>
+      function may also be used to allocate the <structname>ScrnInfoRec</structname>.
+      Any of these functions take care of initialising fields to defined
+      <quote>unused</quote> values.
+	</para>
+
+	<para>
+      Claim the entities for each instance of the hardware found.  This
+      prevents other drivers from claiming the same hardware.
+	</para>
+
+	<para>
+      Must leave hardware in the same state it found it in, and must not
+      do any hardware initialisation.
+	</para>
+
+	<para>
+      All detection can be overridden via the config file, and that
+      parsed information is available to the driver at this stage.
+	</para>
+
+	<para>
+      Returns <constant>TRUE</constant> if one or more instances are found,
+      and <constant>FALSE</constant> otherwise.
+	</para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    int xf86MatchDevice(const char *drivername,
+                        GDevPtr **driversectlist)
+	  </programlisting>
+	  <blockquote><para>
+      This function takes the name of the driver and returns via
+      <parameter>driversectlist</parameter> a list of device sections that
+      match the driver name.  The function return value is the number
+      of matches found.  If a fatal error is encountered the return
+      value is <literal>-1</literal>.
+	    </para>
+
+	    <para>
+      The caller should use <function>xfree()</function> to free
+      <parameter>*driversectlist</parameter> when it is no longer needed.
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    ScrnInfoPtr xf86AllocateScreen(DriverPtr drv, int flags)
+	  </programlisting>
+	  <blockquote><para>
+      This function allocates a new <structname>ScrnInfoRec</structname> in the
+      <varname>xf86Screens[]</varname> array.  This function is normally
+      called by the video driver <function>ChipProbe()</function> functions.
+      The return value is a pointer to the newly allocated
+      <structname>ScrnInfoRec</structname>.  The <structfield>scrnIndex</structfield>,
+      <structfield>origIndex</structfield>, <structfield>module</structfield> and
+      <structfield>drv</structfield> fields are initialised.  The reference count
+      in <parameter>drv</parameter> is incremented.  The storage for any
+      currently allocated <quote>privates</quote> pointers is also allocated and
+      the <structfield>privates</structfield> field initialised (the privates data
+      is of course not allocated or initialised).  This function never
+      returns on failure.  If the allocation fails, the server exits
+      with a fatal error.  The flags value is not currently used, and
+      should be set to zero.
+	    </para></blockquote>
+	</para></blockquote>
+
+      <para>
+    At the completion of this, a list of <structname>ScrnInfoRecs</structname>
+    have been allocated in the <varname>xf86Screens[]</varname> array, and
+    the associated entities and fixed resources have been claimed.  The
+    following <structname>ScrnInfoRec</structname> fields must be initialised at
+    this point:
+
+	<literallayout>
+          driverVersion
+          driverName
+          scrnIndex(*)
+          origIndex(*)
+          drv(*)
+          module(*)
+          name
+          Probe
+          PreInit
+          ScreenInit
+          EnterVT
+          LeaveVT
+          numEntities
+          entityList
+          access
+	</literallayout>
+
+    <literal>(*)</literal> These are initialised when the <structname>ScrnInfoRec</structname>
+    is allocated, and not explicitly by the driver.
+      </para>
+
+      <para>
+    The following <structname>ScrnInfoRec</structname> fields must be initialised
+    if the driver is going to use them:
+
+	<literallayout>
+          SwitchMode
+          AdjustFrame
+          FreeScreen
+          ValidMode
+	</literallayout>
+      </para>
+    </sect2>
+
+    <sect2>
+      <title>Matching Screens</title>
+
+      <para>
+    This is done at the start of the first server generation only.
+      </para>
+
+      <para>
+    After the Probe phase is finished, there will be some number of
+    <structname>ScrnInfoRec</structname>s.  These are then matched with the active
+    &k.screen; sections in the xorg.conf, and those not having an active
+    &k.screen; section are deleted.  If the number of remaining screens
+    is 0, <function>InitOutput()</function> sets
+    <structfield>screenInfo.numScreens</structfield> to <constant>0</constant> and
+    returns.
+      </para>
+
+      <para>
+    At this point the following fields of the <structname>ScrnInfoRec</structname>s
+    must be initialised:
+
+	<literallayout>
+          confScreen
+	</literallayout>
+      </para>
+
+    </sect2>
+
+    <sect2>
+      <title>Allocate non-conflicting resources</title>
+
+      <para>
+    This is done at the start of the first server generation only.
+      </para>
+
+      <para>
+    Before calling the drivers again, the resource information collected
+    from the Probe phase is processed.  This includes checking the extent
+    of PCI resources for the probed devices, and resolving any conflicts
+    in the relocatable PCI resources.  It also reports conflicts, checks
+    bus routing issues, and anything else that is needed to enable the
+    entities for the next phase.
+      </para>
+
+      <para>
+    If any drivers registered an <function>EntityInit()</function> function
+    during the Probe phase, then they are called here.
+      </para>
+
+    </sect2>
+
+    <sect2>
+      <title>Sort the Screens and pre-check Monitor Information</title>
+
+      <para>
+    This is done at the start of the first server generation only.
+      </para>
+
+      <para>
+    The list of screens is sorted to match the ordering requested in the
+    config file.
+      </para>
+
+      <para>
+    The list of modes for each active monitor is checked against the
+    monitor's parameters.  Invalid modes are pruned.
+      </para>
+
+    </sect2>
+
+    <sect2>
+      <title>PreInit</title>
+
+      <para>
+    This is done at the start of the first server generation only.
+      </para>
+
+      <para>
+    For each <structname>ScrnInfoRec</structname>, enable access to the screens entities and call
+    the <function>ChipPreInit()</function> function.
+      </para>
+
+      <blockquote><para>
+	  <programlisting>
+    Bool ChipPreInit(ScrnInfoRec screen, int flags);
+	  </programlisting>
+	  <blockquote><para>
+      The purpose of this function is to find out all the information
+      required to determine if the configuration is usable, and to
+      initialise those parts of the <structname>ScrnInfoRec</structname> that
+      can be set once at the beginning of the first server generation.
+	    </para>
+
+	    <para>
+      The number of entities registered for the screen should be checked
+      against the expected number (most drivers expect only one).  The
+      entity information for each of them should be retrieved (with
+      <function>xf86GetEntityInfo()</function>) and checked for the correct
+      bus type and that none of the sharable resources registered during
+      the Probe phase was rejected.
+	    </para>
+
+	    <para>
+      Access to resources for the entities that can be controlled in a
+      device-independent way are enabled before this function is called.
+      If the driver needs to access any resources that it has disabled
+      in an <function>EntityInit()</function> function that it registered,
+      then it may enable them here providing that it disables them before
+      this function returns.
+	    </para>
+
+	    <para>
+      This includes probing for video memory, clocks, ramdac, and all
+      other HW info that is needed.  It includes determining the
+      depth/bpp/visual and related info.  It includes validating and
+      determining the set of video modes that will be used (and anything
+      that is required to determine that).
+	    </para>
+
+	    <para>
+      This information should be determined in the least intrusive way
+      possible.  The state of the HW must remain unchanged by this
+      function.  Although video memory (including MMIO) may be mapped
+      within this function, it must be unmapped before returning.  Driver
+      specific information should be stored in a structure hooked into
+      the <structname>ScrnInfoRec</structname>'s <structfield>driverPrivate</structfield>
+      field.  Any other modules which require persistent data (ie data
+      that persists across server generations) should be initialised in
+      this function, and they should allocate a <quote>privates</quote> index to
+      hook their data into by calling
+      <function>xf86AllocateScrnInfoPrivateIndex()</function>.  The <quote>privates</quote>
+      data is persistent.
+	    </para>
+
+	    <para>
+      Helper functions for some of these things are provided at the
+      XFree86 common level, and the driver can choose to make use of
+      them.
+	    </para>
+
+	    <para>
+      All additional resources that the screen needs must be registered
+      here.  This should be done with
+      <function>xf86RegisterResources()</function>.  If some of the fixed
+      resources registered in the Probe phase are not needed or not
+      decoded by the hardware when in the OPERATING server state, their
+      status should be updated with
+      <function>xf86SetOperatingState()</function>.
+	    </para>
+
+	    <para>
+      Modules may be loaded at any point in this function, and all
+      modules that the driver will need must be loaded before the end
+      of this function.  Either the  <function>xf86LoadSubModule()</function>
+      or the <function>xf86LoadDrvSubModule()</function> function should be
+      used to load modules depending on whether a
+      <structname>ScrnInfoRec</structname> has been set up. A driver may unload
+      a module within this function if it was only needed temporarily,
+      and the <function>xf86UnloadSubModule()</function> function should be used
+      to do that.  Otherwise there is no need to explicitly unload modules
+      because the loader takes care of module dependencies and will
+      unload submodules automatically if/when the driver module is
+      unloaded.
+	    </para>
+
+	    <para>
+      The bulk of the <structname>ScrnInfoRec</structname> fields should be filled
+      out in this function.
+	    </para>
+
+	    <para>
+      <function>ChipPreInit()</function> returns <constant>FALSE</constant> when
+      the configuration is unusable in some way (unsupported depth, no
+      valid modes, not enough video memory, etc), and <constant>TRUE</constant>
+      if it is usable.
+	    </para>
+
+	    <para>
+      It is expected that if the <function>ChipPreInit()</function> function
+      returns <constant>TRUE</constant>, then the only reasons that subsequent
+      stages in the driver might fail are lack or resources (like xalloc
+      failures).  All other possible reasons for failure should be
+      determined by the <function>ChipPreInit()</function> function.
+	    </para></blockquote>
+	</para></blockquote>
+
+      <para>
+    The <structname>ScrnInfoRec</structname>s for screens where the <function>ChipPreInit()</function> fails are removed.
+    If none remain, <function>InitOutput()</function> sets <structfield>screenInfo.numScreens</structfield> to <constant>0</constant> and returns.
+      </para>
+
+      <para>
+    At this point, further fields of the <structname>ScrnInfoRec</structname>s would normally be
+    filled in.  Most are not strictly mandatory, but many are required
+    by other layers and/or helper functions that the driver may choose
+    to use.  The documentation for those layers and helper functions
+    indicates which they require.
+      </para>
+
+      <para>
+    The following fields of the <structname>ScrnInfoRec</structname>s should be filled in if the
+    driver is going to use them:
+
+	<literallayout>
+          monitor
+          display
+          depth
+          pixmapBPP
+          bitsPerPixel
+          weight                (>8bpp only)
+          mask                  (>8bpp only)
+          offset                (>8bpp only)
+          rgbBits               (8bpp only)
+          gamma
+          defaultVisual
+          maxHValue
+          maxVValue
+          virtualX
+          virtualY
+          displayWidth
+          frameX0
+          frameY0
+          frameX1
+          frameY1
+          zoomLocked
+          modePool
+          modes
+          currentMode
+          progClock             (TRUE if clock is programmable)
+          chipset
+          ramdac
+          clockchip
+          numClocks             (if not programmable)
+          clock[]               (if not programmable)
+          videoRam
+          biosBase
+          memBase
+          memClk
+          driverPrivate
+          chipID
+          chipRev
+	</literallayout>
+      </para>
+
+      <blockquote><para>
+	  <programlisting>
+    pointer xf86LoadSubModule(ScrnInfoPtr pScrn, const char *name);
+      and
+    pointer xf86LoadDrvSubModule(DriverPtr drv, const char *name);
+	  </programlisting>
+	  <blockquote><para>
+      Load a module that a driver depends on.  This function loads the
+      module <parameter>name</parameter> as a sub module of the driver.  The
+      return value is a handle identifying the new module.  If the load
+      fails, the return value will be <constant>NULL</constant>.  If a driver
+      needs to explicitly unload a module it has loaded in this way,
+      the return value must be saved and passed to
+      <function>xf86UnloadSubModule()</function> when unloading.
+
+	    </para></blockquote>
+	</para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    void xf86UnloadSubModule(pointer module);
+	  </programlisting>
+	  <blockquote><para>
+      Unloads the module referenced by <parameter>module</parameter>.
+      <parameter>module</parameter> should be a pointer returned previously
+      by <function>xf86LoadSubModule()</function> or
+      <function>xf86LoadDrvSubModule()</function> .
+
+	    </para></blockquote>
+	</para></blockquote>
+    </sect2>
+
+    <sect2>
+      <title>Cleaning up Unused Drivers</title>
+
+      <para>
+    At this point it is known which screens will be in use, and which
+    drivers are being used.  Unreferenced drivers (and modules they
+    may have loaded) are unloaded here.
+      </para>
+
+    </sect2>
+
+    <sect2>
+      <title>Consistency Checks</title>
+
+      <para>
+    The parameters that must be global to the server, like pixmap formats,
+    bitmap bit order, bitmap scanline unit and image byte order are
+    compared for each of the screens.  If a mismatch is found, the server
+    exits with an appropriate message.
+      </para>
+
+    </sect2>
+
+    <sect2>
+      <title>Check if Resource Control is Needed</title>
+
+      <para>
+    Determine if resource access control is needed.  This is the case
+    if more than one screen is used.  If necessary the RAC wrapper module
+    is loaded.
+      </para>
+    </sect2>
+
+    <sect2>
+      <title>AddScreen (ScreenInit)</title>
+
+      <para>
+    At this point, the valid screens are known.
+    <function>AddScreen()</function> is called for each of them, passing
+    <function>ChipScreenInit()</function> as the argument.
+    <function>AddScreen()</function> is a DIX function that allocates a new
+    <structfield>screenInfo.screen[]</structfield> entry (aka
+    <varname>pScreen</varname>), and does some basic initialisation of it.
+    It then calls the <function>ChipScreenInit()</function> function, with
+    <parameter>pScreen</parameter> as one of its arguments.  If
+    <function>ChipScreenInit()</function> returns <constant>FALSE</constant>,
+    <function>AddScreen()</function> returns <constant>-1</constant>.  Otherwise
+    it returns the index of the screen.  <function>AddScreen()</function>
+    should only fail because of programming errors or failure to allocate
+    resources (like memory).  All configuration problems should be
+    detected BEFORE this point.
+      </para>
+
+      <blockquote><para>
+	  <programlisting>
+    Bool ChipScreenInit(int index, ScreenPtr pScreen,
+                        int argc, char **argv);
+	  </programlisting>
+	  <blockquote><para>
+      This is called at the start of each server generation.
+	    </para>
+
+	    <para>
+      Fill in all of <parameter>pScreen</parameter>, possibly doing some of
+      this by calling ScreenInit functions from other layers like mi,
+      framebuffers (cfb, etc), and extensions.
+	    </para>
+
+	    <para>
+      Decide which operations need to be placed under resource access
+      control.  The classes of operations are the frame buffer operations
+      (<constant>RAC_FB</constant>), the pointer operations
+      (<constant>RAC_CURSOR</constant>), the viewport change operations
+      (<constant>RAC_VIEWPORT</constant>) and the colormap operations
+      (<constant>RAC_COLORMAP</constant>).  Any operation that requires
+      resources which might be disabled during OPERATING state should
+      be set to use RAC.  This can be specified separately for memory
+      and IO resources (the <structfield>racMemFlags</structfield> and
+      <structfield>racIoFlags</structfield> fields of the <structname>ScrnInfoRec</structname>
+      respectively).
+	    </para>
+
+	    <para>
+      Map any video memory or other memory regions.
+	    </para>
+
+	    <para>
+      Save the video card state.  Enough state must be saved so that
+      the original state can later be restored.
+	    </para>
+
+	    <para>
+      Initialise the initial video mode.  The <structname>ScrnInfoRec</structname>'s
+      <structfield>vtSema</structfield> field should be set to <constant>TRUE</constant>
+      just prior to changing the video hardware's state.
+
+	    </para></blockquote>
+	</para></blockquote>
+
+
+      <para>
+    The <function>ChipScreenInit()</function> function (or functions from other
+    layers that it calls) should allocate entries in the
+    <structname>ScreenRec</structname>'s <structfield>devPrivates</structfield> area by
+    calling <function>AllocateScreenPrivateIndex()</function> if it needs
+    per-generation storage.  Since the <structname>ScreenRec</structname>'s
+    <structfield>devPrivates</structfield> information is cleared for each server
+    generation, this is the correct place to initialise it.
+      </para>
+
+      <para>
+    After <function>AddScreen()</function> has successfully returned, the
+    following <structname>ScrnInfoRec</structname> fields are initialised:
+
+	<literallayout>
+          pScreen
+          racMemFlags
+          racIoFlags
+	</literallayout>
+      </para>
+
+      <para>
+    The <function>ChipScreenInit()</function> function should initialise the
+    <structfield>CloseScreen</structfield> and <structfield>SaveScreen</structfield> fields
+    of <parameter>pScreen</parameter>.  The old value of
+    <structfield>pScreen->CloseScreen</structfield> should be saved as part of
+    the driver's per-screen private data, allowing it to be called from
+    <function>ChipCloseScreen()</function>.  This means that the existing
+    <function>CloseScreen()</function> function is wrapped.
+      </para>
+    </sect2>
+
+    <sect2>
+      <title>Finalising RAC Initialisation</title>
+
+      <para>
+    After all the <function>ChipScreenInit()</function> functions have been
+    called, each screen has registered its RAC requirements.  This
+    information is used to determine which shared resources are requested
+    by more than one driver and set the access functions accordingly.
+    This is done following these rules:
+
+	<orderedlist>
+	  <listitem><para>
+	The sharable resources registered by each entity are compared.
+	If a resource is registered by more than one entity the entity
+	will be marked to indicate that it needs to share this resources
+	type (IO or MEM).
+	    </para></listitem>
+
+	  <listitem><para>
+        A resource marked <quote>disabled</quote> during OPERATING state will be
+        ignored entirely.
+	    </para></listitem>
+
+	  <listitem><para>
+	A resource marked <quote>unused</quote> will only conflict with an overlapping
+	resource of an other entity if the second is actually in use
+	during OPERATING state.
+	    </para></listitem>
+
+	  <listitem><para>
+	If an <quote>unused</quote> resource was found to conflict but the entity
+	does not use any other resource of this type the entire resource
+	type will be disabled for that entity.
+	    </para></listitem>
+	</orderedlist>
+      </para>
+
+    </sect2>
+
+    <sect2>
+      <title>Finishing InitOutput()</title>
+
+      <para>
+    At this point <function>InitOutput()</function> is finished, and all the
+    screens have been setup in their initial video mode.
+      </para>
+
+    </sect2>
+
+    <sect2>
+      <title>Mode Switching</title>
+
+      <para>
+    When a SwitchMode event is received, <function>ChipSwitchMode()</function>
+    is called (when it exists):
+      </para>
+
+      <blockquote><para>
+	  <programlisting>
+    Bool ChipSwitchMode(int index, DisplayModePtr mode, int flags);
+	  </programlisting>
+	  <blockquote><para>
+      Initialises the new mode for the screen identified by
+      <parameter>index;</parameter>.  The viewport may need to be adjusted
+      also.
+
+	    </para></blockquote>
+	</para></blockquote>
+
+    </sect2>
+
+    <sect2>
+      <title>Changing Viewport</title>
+
+      <para>
+    When a Change Viewport event is received,
+    <function>ChipAdjustFrame()</function> is called (when it exists):
+      </para>
+
+      <blockquote><para>
+	  <programlisting>
+    void ChipAdjustFrame(int index, int x, int y, int flags);
+	  </programlisting>
+	  <blockquote><para>
+      Changes the viewport for the screen identified by
+      <parameter>index;</parameter>.
+	    </para>
+
+	    <para>
+      It should be noted that many chipsets impose restrictions on where the
+      viewport may be placed in the virtual resolution, either for alignment
+      reasons, or to prevent the start of the viewport from being positioned
+      within a pixel (as can happen in a 24bpp mode).  After calculating the
+      value the chipset's panning registers need to be set to for non-DGA
+      modes, this function should recalculate the ScrnInfoRec's
+      <structfield>frameX0</structfield>, <structfield>frameY0</structfield>, <structfield>frameX1</structfield>
+      and <structfield>frameY1</structfield> fields to correspond to that value.  If
+      this is not done, switching to another mode might cause the position
+      of a hardware cursor to change.
+
+	    </para></blockquote>
+	</para></blockquote>
+
+    </sect2>
+
+    <sect2>
+      <title>VT Switching</title>
+
+      <para>
+    When a VT switch event is received, <function>xf86VTSwitch()</function>
+    is called.  <function>xf86VTSwitch()</function> does the following:
+
+	<variablelist>
+	  <varlistentry><term>On ENTER:</term>
+	    <listitem>
+	      <itemizedlist>
+		<listitem><para>
+		    enable port I/O access
+		  </para></listitem>
+
+		<listitem><para>
+		    save and initialise the bus/resource state
+		  </para></listitem>
+
+		<listitem><para>
+		    enter the SETUP server state
+		  </para></listitem>
+
+		<listitem><para>
+		    calls <function>ChipEnterVT()</function> for each screen
+		  </para></listitem>
+
+		<listitem><para>
+		    enter the OPERATING server state
+		  </para></listitem>
+
+		<listitem><para>
+		    validate GCs
+		  </para></listitem>
+
+		<listitem><para>
+		    Restore fb from saved pixmap for each screen
+		  </para></listitem>
+
+		<listitem><para>
+		    Enable all input devices
+		  </para></listitem>
+	      </itemizedlist>
+	    </listitem>
+	  </varlistentry>
+	  <varlistentry>
+	    <term>On LEAVE:</term>
+	    <listitem>
+	      <itemizedlist>
+		<listitem><para>
+		    Save fb to pixmap for each screen
+		  </para></listitem>
+
+		<listitem><para>
+		    validate GCs
+		  </para></listitem>
+
+		<listitem><para>
+		    enter the SETUP server state
+		  </para></listitem>
+
+		<listitem><para>
+		    calls <function>ChipLeaveVT()</function> for each screen
+		  </para></listitem>
+
+		<listitem><para>
+		    disable all input devices
+		  </para></listitem>
+
+		<listitem><para>
+		    restore bus/resource state
+		  </para></listitem>
+
+		<listitem><para>
+		    disables port I/O access
+		  </para></listitem>
+	      </itemizedlist>
+	    </listitem>
+	  </varlistentry>
+	</variablelist>
+      </para>
+
+      <blockquote><para>
+	  <programlisting>
+    Bool ChipEnterVT(int index, int flags);
+	  </programlisting>
+	  <blockquote><para>
+      This function should initialise the current video mode and
+      initialise the viewport, turn on the HW cursor if appropriate,
+      etc.
+	    </para>
+
+	    <para>
+      Should it re-save the video state before initialising the video
+      mode?
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    void ChipLeaveVT(int index, int flags);
+	  </programlisting>
+	  <blockquote><para>
+      This function should restore the saved video state.  If
+      appropriate it should also turn off the HW cursor, and invalidate
+      any pixmap/font caches.
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <para>
+    Optionally, <function>ChipLeaveVT()</function> may also unmap memory
+    regions.  If so, <function>ChipEnterVT()</function> will need to remap
+    them.  Additionally, if an aperture used to access video memory is
+    unmapped and remapped in this fashion, <function>ChipEnterVT()</function>
+    will also need to notify the framebuffer layers of the aperture's new
+    location in virtual memory.  This is done with a call to the screen's
+    <function>ModifyPixmapHeader()</function> function, as follows
+      </para>
+
+      <blockquote><para>
+	  <programlisting>
+    (*pScreen->ModifyPixmapHeader)(pScrn->ppix,
+                                   -1, -1, -1, -1, -1, NewApertureAddress);
+	  </programlisting>
+	  <blockquote><para>
+        where the <structfield>ppix</structfield> field in a ScrnInfoRec
+        points to the pixmap used by the screen's
+        <function>SaveRestoreImage()</function> function to hold the screen's
+        contents while switched out.
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <para>
+    Other layers may wrap the <function>ChipEnterVT()</function> and
+    <function>ChipLeaveVT()</function> functions if they need to take some
+    action when these events are received.
+      </para>
+    </sect2>
+
+    <sect2>
+      <title>End of server generation</title>
+
+      <para>
+    At the end of each server generation, the DIX layer calls
+    <function>ChipCloseScreen()</function> for each screen:
+      </para>
+
+      <blockquote><para>
+	  <programlisting>
+    Bool ChipCloseScreen(int index, ScreenPtr pScreen);
+	  </programlisting>
+	  <blockquote><para>
+      This function should restore the saved video state and unmap the
+      memory regions.
+	    </para>
+
+	    <para>
+      It should also free per-screen data structures allocated by the
+      driver.  Note that the persistent data held in the
+      <structname>ScrnInfoRec</structname>'s <structfield>driverPrivate</structfield> field
+      should not be freed here because it is needed by subsequent server
+      generations.
+	    </para>
+
+	    <para>
+      The <structname>ScrnInfoRec</structname>'s <structfield>vtSema</structfield> field
+      should be set to <constant>FALSE</constant> once the video HW state
+      has been restored.
+	    </para>
+
+	    <para>
+      Before freeing the per-screen driver data the saved
+      <structfield>CloseScreen</structfield> value should be restored to
+      <structfield>pScreen->CloseScreen</structfield>, and that function should
+      be called after freeing the data.
+
+	    </para></blockquote>
+	</para></blockquote>
+    </sect2>
+  </sect1>
+
+  <sect1>
+    <title>Optional Driver Functions</title>
+
+    <para>
+The functions outlined here can be called from the XFree86 common layer,
+but their presence is optional.
+    </para>
+
+    <sect2>
+      <title>Mode Validation</title>
+
+      <para>
+    When a mode validation helper supplied by the XFree86-common layer is
+    being used, it can be useful to provide a function to check for hw
+    specific mode constraints:
+      </para>
+
+      <blockquote><para>
+	  <programlisting>
+    ModeStatus ChipValidMode(int index, DisplayModePtr mode,
+                             Bool verbose, int flags);
+	  </programlisting>
+	  <blockquote><para>
+      Check the passed mode for hw-specific constraints, and return the
+      appropriate status value.
+
+	    </para></blockquote>
+	</para></blockquote>
+
+      <para>
+This function may also modify the effective timings and clock of the passed
+mode.  These have been stored in the mode's <structfield>Crtc*</structfield> and
+<structfield>SynthClock</structfield> elements, and have already been adjusted for
+interlacing, doublescanning, multiscanning and clock multipliers and dividers.
+The function should not modify any other mode field, unless it wants to modify
+the mode timings reported to the user by <function>xf86PrintModes()</function>.
+      </para>
+
+      <para>
+The function is called once for every mode in the xorg.conf Monitor section
+assigned to the screen, with <parameter>flags</parameter> set to
+<constant>MODECHECK_INITIAL</constant>.  It is subsequently called for every mode
+in the xorg.conf Display subsection assigned to the screen, with
+<parameter>flags</parameter> set to <constant>MODECHECK_FINAL</constant>.  In the second
+case, the mode will have successfully passed all other tests.  In addition,
+the <structname>ScrnInfoRec</structname>'s <structfield>virtualX</structfield>,
+<structfield>virtualY</structfield> and <structfield>displayWidth</structfield> fields will have been
+set as if the mode to be validated were to be the last mode accepted.
+      </para>
+
+      <para>
+In effect, calls with MODECHECK_INITIAL are intended for checks that do not
+depend on any mode other than the one being validated, while calls with
+MODECHECK_FINAL are intended for checks that may involve more than one mode.
+      </para>
+    </sect2>
+
+    <sect2>
+      <title>Free screen data</title>
+
+      <para>
+    When a screen is deleted prior to the completion of the ScreenInit
+    phase the <function>ChipFreeScreen()</function> function is called when defined.
+      </para>
+
+      <blockquote><para>
+	  <programlisting>
+    void ChipFreeScreen(int scrnindex, int flags);
+	  </programlisting>
+	  <blockquote><para>
+      Free any driver-allocated data that may have been allocated up to
+      and including an unsuccessful <function>ChipScreenInit()</function>
+      call.  This would predominantly be data allocated by
+      <function>ChipPreInit()</function> that persists across server
+      generations.  It would include the <structfield>driverPrivate</structfield>,
+      and any <quote>privates</quote> entries that modules may have allocated.
+
+	    </para></blockquote>
+	</para></blockquote>
+
+    </sect2>
+</sect1>
+
+  <sect1>
+    <title>Recommended driver functions</title>
+
+    <para>
+The functions outlined here are for internal use by the driver only.
+They are entirely optional, and are never accessed directly from higher
+layers.  The sample function declarations shown here are just examples.
+The interface (if any) used is up to the driver.
+    </para>
+
+    <sect2>
+      <title>Save</title>
+
+      <para>
+    Save the video state.  This could be called from <function>ChipScreenInit()</function> and
+    (possibly) <function>ChipEnterVT()</function>.
+      </para>
+
+      <blockquote><para>
+	  <programlisting>
+    void ChipSave(ScrnInfoPtr pScrn);
+	  </programlisting>
+	  <blockquote><para>
+      Saves the current state.  This will only be saving pre-server
+      states or states before returning to the server.  There is only
+      one current saved state per screen and it is stored in private
+      storage in the screen.
+
+	    </para></blockquote>
+	</para></blockquote>
+    </sect2>
+
+    <sect2>
+      <title>Restore</title>
+
+      <para>
+    Restore the original video state.  This could be called from the
+    <function>ChipLeaveVT()</function> and <function>ChipCloseScreen()</function>
+    functions.
+      </para>
+
+      <blockquote><para>
+	  <programlisting>
+    void ChipRestore(ScrnInfoPtr pScrn);
+	  </programlisting>
+	  <blockquote><para>
+      Restores the saved state from the private storage.  Usually only
+      used for restoring text modes.
+
+	    </para></blockquote>
+	</para></blockquote>
+
+    </sect2>
+
+    <sect2>
+      <title>Initialise Mode</title>
+
+      <para>
+    Initialise a video mode.  This could be called from the
+    <function>ChipScreenInit()</function>, <function>ChipSwitchMode()</function>
+    and <function>ChipEnterVT()</function> functions.
+      </para>
+
+      <blockquote><para>
+	  <programlisting>
+    Bool ChipModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode);
+	  </programlisting>
+	  <blockquote><para>
+      Programs the hardware for the given video mode.
+
+	    </para></blockquote>
+	</para></blockquote>
+
+    </sect2>
+  </sect1>
+
+  <sect1>
+    <title>Data and Data Structures</title>
+
+    <sect2>
+      <title>Command line data</title>
+
+      <para>
+Command line options are typically global, and are stored in global
+variables.  These variables are read-only and are available to drivers
+via a function call interface.  Most of these command line values are
+processed via helper functions to ensure that they are treated consistently
+by all drivers.  The other means of access is provided for cases where
+the supplied helper functions might not be appropriate.
+      </para>
+
+      <para>
+Some of them are:
+
+	<literallayout>
+    xf86Verbose               verbosity level
+    xf86Bpp                   -bpp from the command line
+    xf86Depth                 -depth from the command line
+    xf86Weight                -weight from the command line
+    xf86Gamma                 -{r,g,b,}gamma from the command line
+    xf86FlipPixels            -flippixels from the command line
+    xf86ProbeOnly             -probeonly from the command line
+    defaultColorVisualClass   -cc from the command line
+	</literallayout>
+      </para>
+
+      <para>
+If we ever do allow for screen-specific command line options, we may
+need to rethink this.
+      </para>
+
+      <para>
+These can be accessed in a read-only manner by drivers with the following
+functions:
+      </para>
+
+     <blockquote><para>
+	  <programlisting>
+    int xf86GetVerbosity();
+	  </programlisting>
+	  <blockquote><para>
+      Returns the value of <varname>xf86Verbose</varname>.
+	    </para></blockquote>
+
+	</para></blockquote>
+
+     <blockquote><para>
+	  <programlisting>
+    int xf86GetDepth();
+	  </programlisting>
+	  <blockquote><para>
+      Returns the <option>-depth</option> command line setting.  If not
+      set on the command line, <constant>-1</constant> is returned.
+	    </para></blockquote>
+
+	</para></blockquote>
+
+     <blockquote><para>
+	  <programlisting>
+    rgb xf86GetWeight();
+	  </programlisting>
+	  <blockquote><para>
+      Returns the <option>-weight</option> command line setting.  If not
+      set on the command line, <literal remap="tt">{0, 0, 0}</literal> is returned.
+	    </para></blockquote>
+
+	</para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    Gamma xf86GetGamma();
+	  </programlisting>
+	  <blockquote><para>
+      Returns the <option>-gamma</option> or <option>-rgamma</option>,
+      <option>-ggamma</option>, <option>-bgamma</option> command line settings.
+      If not set on the command line, <literal remap="tt">{0.0, 0.0, 0.0}</literal>
+      is returned.
+	    </para></blockquote>
+
+	</para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    Bool xf86GetFlipPixels();
+	  </programlisting>
+	  <blockquote><para>
+      Returns <constant>TRUE</constant> if <option>-flippixels</option> is
+      present on the command line, and <constant>FALSE</constant> otherwise.
+	    </para></blockquote>
+
+	</para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    const char *xf86GetServerName();
+	  </programlisting>
+	  <blockquote><para>
+      Returns the name of the X server from the command line.
+	    </para></blockquote>
+
+	</para></blockquote>
+    </sect2>
+
+    <sect2>
+      <title>Data handling</title>
+
+      <para>
+Config file data contains parts that are global, and parts that are
+Screen specific.  All of it is parsed into data structures that neither
+the drivers or most other parts of the server need to know about.
+      </para>
+
+      <para>
+The global data is typically not required by drivers, and as such, most
+of it is stored in the private <structname>xf86InfoRec</structname>.
+      </para>
+
+      <para>
+The screen-specific data collected from the config file is stored in
+screen, device, display, monitor-specific data structures that are separate
+from the <varname>ScrnInfoRecs</varname>, with the appropriate elements/fields
+hooked into the <varname>ScrnInfoRecs</varname> as required.  The screen
+config data is held in <structname>confScreenRec</structname>, device data in
+the <structname>GDevRec</structname>, monitor data in the <structname>MonRec</structname>,
+and display data in the <structname>DispRec</structname>.
+      </para>
+
+      <para>
+The XFree86 common layer's screen specific data (the actual data in use
+for each screen) is held in the <varname>ScrnInfoRecs</varname>.  As has
+been outlined above, the <varname>ScrnInfoRecs</varname> are allocated at probe
+time, and it is the responsibility of the Drivers' <function>Probe()</function>
+and <function>PreInit()</function> functions to finish filling them in based
+on both data provided on the command line and data provided from the
+Config file.  The precedence for this is:
+
+	<blockquote><para>
+    command line  ->  config file  ->  probed/default data
+	</para></blockquote>
+      </para>
+
+      <para>
+For most things in this category there are helper functions that the
+drivers can use to ensure that the above precedence is consistently
+used.
+      </para>
+
+      <para>
+As well as containing screen-specific data that the XFree86 common layer
+(including essential parts of the server infrastructure as well as helper
+functions) needs to access, it also contains some data that drivers use
+internally.  When considering whether to add a new field to the
+<structname>ScrnInfoRec</structname>, consider the balance between the convenience
+of things that lots of drivers need and the size/obscurity of the
+<structname>ScrnInfoRec</structname>.
+      </para>
+
+      <para>
+Per-screen driver specific data that cannot be accommodated with the
+static <structname>ScrnInfoRec</structname> fields is held in a driver-defined
+data structure, a pointer to which is assigned to the
+<structname>ScrnInfoRec</structname>'s <structfield>driverPrivate</structfield> field.  This
+is per-screen data that persists across server generations (as does the
+bulk of the static <structname>ScrnInfoRec</structname> data).  It would typically
+also include the video card's saved state.
+      </para>
+
+      <para>
+Per-screen data for other modules that the driver uses (for example,
+the XAA module) that is reset for each server generation is hooked into
+the <structname>ScrnInfoRec</structname> through it's <structfield>privates</structfield>
+field.
+      </para>
+
+      <para>
+Once it has stabilised, the data structures and variables accessible to
+video drivers will be documented here.  In the meantime, those things
+defined in the <filename>xf86.h</filename> and <filename>xf86str.h</filename>
+files are visible to video drivers.  Things defined in
+<filename>xf86Priv.h</filename> and <filename>xf86Privstr.h</filename> are NOT
+intended to be visible to video drivers, and it is an error for a driver
+to include those files.
+      </para>
+
+    </sect2>
+
+    <sect2>
+      <title>Accessing global data</title>
+
+      <para>
+Some other global state information that the drivers may access via
+functions is as follows:
+      </para>
+
+      <blockquote><para>
+	  <programlisting>
+    Bool xf86ServerIsExiting();
+	  </programlisting>
+	  <blockquote><para>
+      Returns <constant>TRUE</constant> if the server is at the end of a
+      generation and is in the process of exiting, and
+      <constant>FALSE</constant> otherwise.
+	    </para></blockquote>
+
+	</para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    Bool xf86ServerIsResetting();
+	  </programlisting>
+	  <blockquote><para>
+      Returns <constant>TRUE</constant> if the server is at the end of a
+      generation and is in the process of resetting, and
+      <constant>FALSE</constant> otherwise.
+	    </para></blockquote>
+
+	</para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    Bool xf86ServerIsInitialising();
+	  </programlisting>
+	  <blockquote><para>
+      Returns <constant>TRUE</constant> if the server is at the beginning of
+      a generation and is in the process of initialising, and
+      <constant>FALSE</constant> otherwise.
+	    </para></blockquote>
+
+	</para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    Bool xf86ServerIsOnlyProbing();
+	  </programlisting>
+	  <blockquote><para>
+      Returns <constant>TRUE</constant> if the -probeonly command line flag
+      was specified, and <constant>FALSE</constant> otherwise.
+	    </para></blockquote>
+
+	</para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    Bool xf86CaughtSignal();
+	  </programlisting>
+	  <blockquote><para>
+      Returns <constant>TRUE</constant> if the server has caught a signal,
+      and <constant>FALSE</constant> otherwise.
+	    </para></blockquote>
+
+	</para></blockquote>
+    </sect2>
+
+    <sect2>
+      <title>Allocating private data</title>
+
+      <para>
+A driver and any module it uses may allocate per-screen private storage
+in either the <structname>ScreenRec</structname> (DIX level) or
+<structname>ScrnInfoRec</structname> (XFree86 common layer level).
+<structname>ScreenRec</structname> storage persists only for a single server
+generation, and <structname>ScrnInfoRec</structname> storage persists across
+generations for the lifetime of the server.
+      </para>
+
+      <para>
+The <structname>ScreenRec</structname> <structfield>devPrivates</structfield> data must be
+reallocated/initialised at the start of each new generation.  This is
+normally done from the <function>ChipScreenInit()</function> function, and
+Init functions for other modules that it calls.  Data allocated in this
+way should be freed by the driver's <function>ChipCloseScreen()</function>
+functions, and Close functions for other modules that it calls.  A new
+<structfield>devPrivates</structfield> entry is allocated by calling the
+<function>AllocateScreenPrivateIndex()</function> function.
+      </para>
+
+      <blockquote><para>
+	  <programlisting>
+    int AllocateScreenPrivateIndex();
+	  </programlisting>
+	  <blockquote><para>
+      This function allocates a new element in the
+      <structfield>devPrivates</structfield> field of all currently existing
+      <literal remap="tt">ScreenRecs</literal>.  The return value is the index of this
+      new element in the <structfield>devPrivates</structfield> array.  The
+      <structfield>devPrivates</structfield> field is of type
+      <structname>DevUnion</structname>:
+
+	      <programlisting>
+        typedef union _DevUnion {
+            pointer             ptr;
+            long                val;
+            unsigned long       uval;
+            pointer             (*fptr)(void);
+        } DevUnion;
+	      </programlisting>
+
+      which allows the element to be used for any of the above types.
+      It is commonly used as a pointer to data that the caller allocates
+      after the new index has been allocated.
+	    </para>
+
+	    <para>
+      This function will return <constant>-1</constant> when there is an
+      error allocating the new index.
+	    </para>
+
+	  </blockquote>
+	</para></blockquote>
+
+      <para>
+The <structname>ScrnInfoRec</structname> <structfield>privates</structfield> data persists
+for the life of the server, so only needs to be allocated once.  This
+should be done from the <function>ChipPreInit()</function> function, and Init
+functions for other modules that it calls.  Data allocated in this way
+should be freed by the driver's <function>ChipFreeScreen()</function> functions,
+and Free functions for other modules that it calls.  A new
+<structfield>privates</structfield> entry is allocated by calling the
+<function>xf86AllocateScrnInfoPrivateIndex()</function> function.
+      </para>
+
+      <blockquote><para>
+	  <programlisting>
+    int xf86AllocateScrnInfoPrivateIndex();
+	  </programlisting>
+	  <blockquote><para>
+      This function allocates a new element in the <structfield>privates</structfield>
+      field of all currently existing <varname>ScrnInfoRecs</varname>.
+      The return value is the index of this new element in the
+      <structfield>privates</structfield> array.  The <structfield>privates</structfield>
+      field is of type <structfield>DevUnion</structfield>:
+
+	      <programlisting>
+        typedef union _DevUnion {
+            pointer             ptr;
+            long                val;
+            unsigned long       uval;
+            pointer             (*fptr)(void);
+        } DevUnion;
+	      </programlisting>
+
+      which allows the element to be used for any of the above types.
+      It is commonly used as a pointer to data that the caller allocates
+      after the new index has been allocated.
+	    </para>
+
+	    <para>
+      This function will not return when there is an error allocating
+      the new index.  When there is an error it will cause the server
+      to exit with a fatal error.  The similar function for allocation
+      privates in the <structname>ScreenRec</structname>
+      (<function>AllocateScreenPrivateIndex()</function>) differs in this
+      respect by returning <constant>-1</constant> when the allocation fails.
+	    </para>
+
+	  </blockquote>
+	</para></blockquote>
+    </sect2>
+  </sect1>
+
+  <sect1 id="rac">
+    <title>Keeping Track of Bus Resources</title>
+
+    <sect2>
+      <title>Theory of Operation</title>
+
+      <para>
+The XFree86 common layer has knowledge of generic access control mechanisms
+for devices on certain bus systems (currently the PCI bus) as well as
+of methods to enable or disable access to the buses itself.  Furthermore
+it can access information on resources decoded by these devices and if
+necessary modify it.
+      </para>
+
+      <para>
+When first starting the Xserver collects all this information, saves it
+for restoration, checks it for consistency, and if necessary, corrects
+it.  Finally it disables all resources on a generic level prior to
+calling any driver function.
+      </para>
+
+      <para>
+When the <function>Probe()</function> function of each driver is called the
+device sections are matched against the devices found in the system.
+The driver may probe devices at this stage that cannot be identified by
+using device independent methods.  Access to all resources that can be
+controlled in a device independent way is disabled.  The
+<function>Probe()</function> function should register all non-relocatable
+resources at this stage.  If a resource conflict is found between
+exclusive resources the driver will fail immediately.  Optionally the
+driver might specify an <function>EntityInit()</function>,
+<function>EntityLeave()</function> and <function>EntityEnter()</function> function.
+      </para>
+
+      <para>
+<function>EntityInit()</function> can be used to disable any shared resources
+that are not controlled by the generic access control functions.  It is
+called prior to the PreInit phase regardless if an entity is active or
+not.  When calling the <function>EntityInit()</function>,
+<function>EntityEnter()</function> and <function>EntityLeave()</function> functions
+the common level will disable access to all other entities on a generic
+level.  Since the common level has no knowledge of device specific
+methods to disable access to resources it cannot be guaranteed that
+certain resources are not decoded by any other entity until the
+<function>EntityInit()</function> or <function>EntityEnter()</function> phase is
+finished.  Device drivers should therefore register all those resources
+which they are going to disable.  If these resources are never to be
+used by any driver function they may be flagged <constant>ResInit</constant>
+so that they can be removed from the resource list after processing all
+<function>EntityInit()</function> functions.  <function>EntityEnter()</function>
+should disable decoding of all resources which are not registered as
+exclusive and which are not handled by the generic access control in
+the common level.  The difference to <function>EntityInit()</function> is
+that the latter one is only called once during lifetime of the server.
+It can therefore be used to set up variables prior to disabling resources.
+<function>EntityLeave()</function> should restore the original state when
+exiting the server or switching to a different VT.  It also needs to
+disable device specific access functions if they need to be disabled on
+server exit or VT switch.  The default state is to enable them before
+giving up the VT.
+      </para>
+
+      <para>
+In <function>PreInit()</function> phase each driver should check if any
+sharable resources it has registered during <function>Probe()</function> has
+been denied and take appropriate action which could simply be to fail.
+If it needs to access resources it has disabled during
+<function>EntitySetup()</function> it can do so provided it has registered
+these and will disable them before returning from
+<function>PreInit()</function>.  This also applies to all other driver
+functions.  Several functions are provided to request resource ranges,
+register these, correct PCI config space and add replacements for the
+generic access functions.  Resources may be marked <quote>disabled</quote> or
+<quote>unused</quote> during OPERATING stage.  Although these steps could also be
+performed in <function>ScreenInit()</function>, this is not desirable.
+      </para>
+
+      <para>
+Following <function>PreInit()</function> phase the common level determines
+if resource access control is needed.  This is the case if more than
+one screen is used.  If necessary the RAC wrapper module is loaded.  In
+<function>ScreenInit()</function> the drivers can decide which operations
+need to be placed under RAC.  Available are the frame buffer operations,
+the pointer operations and the colormap operations.  Any operation that
+requires resources which might be disabled during OPERATING state should
+be set to use RAC.  This can be specified separately for memory and IO
+resources.
+      </para>
+
+      <para>
+When <function>ScreenInit()</function> phase is done the common level will
+determine which shared resources are requested by more than one driver
+and set the access functions accordingly.  This is done following these
+rules:
+
+	<orderedlist>
+	  <listitem><para>
+   The sharable resources registered by each entity are compared.  If
+   a resource is registered by more than one entity the entity will be
+   marked to need to share this resources type (<constant>IO</constant> or
+   <constant>MEM</constant>).
+	    </para></listitem>
+
+	  <listitem><para>
+   A resource marked <quote>disabled</quote> during OPERATING state will be ignored
+   entirely.
+	    </para></listitem>
+
+	  <listitem><para>
+   A resource marked <quote>unused</quote> will only conflicts with an overlapping
+   resource of an other entity if the second is actually in use during
+   OPERATING state.
+	    </para></listitem>
+
+	  <listitem><para>
+   If an <quote>unused</quote> resource was found to conflict however the entity
+   does not use any other resource of this type the entire resource type
+   will be disabled for that entity.
+	    </para></listitem>
+	</orderedlist>
+      </para>
+
+      <para>
+The driver has the choice among different ways to control access to
+certain resources:
+
+	<orderedlist>
+	  <listitem><para>
+   It can rely on the generic access functions.  This is probably the
+   most common case.  Here the driver only needs to register any resource
+   it is going to use.
+	    </para></listitem>
+
+	  <listitem><para>
+   It can replace the generic access functions by driver specific
+   ones.  This will mostly be used in cases where no generic access
+   functions are available.  In this case the driver has to make sure
+   these resources are disabled when entering the <function>PreInit()</function>
+   stage.  Since the replacement functions are registered in
+   <function>PreInit()</function> the driver will have to enable these
+   resources itself if it needs to access them during this state.  The
+   driver can specify if the replacement functions can control memory
+   and/or I/O resources separately.
+	    </para></listitem>
+
+	  <listitem><para>
+   The driver can enable resources itself when it needs them.  Each
+   driver function enabling them needs to disable them before it will
+   return.  This should be used if a resource which can be controlled
+   in a device dependent way is only required during SETUP state.  This
+   way it can be marked <quote>unused</quote> during OPERATING state.
+	    </para></listitem>
+	</orderedlist>
+      </para>
+
+      <para>
+A resource which is decoded during OPERATING state however never accessed
+by the driver should be marked unused.
+      </para>
+
+      <para>
+Since access switching latencies are an issue during Xserver operation,
+the common level attempts to minimize the number of entities that need
+to be placed under RAC control.  When a wrapped operation is called,
+the <function>EnableAccess()</function> function is called before control is
+passed on.  <function>EnableAccess()</function> checks if a screen is under
+access control.  If not it just establishes bus routing and returns.
+If the screen needs to be under access control,
+<function>EnableAccess()</function> determines which resource types
+(<literal remap="tt">MEM</literal>, <literal remap="tt">IO</literal>) are required.  Then it tests
+if this access is already established.  If so it simply returns.  If
+not it disables the currently established access, fixes bus routing and
+enables access to all entities registered for this screen.
+      </para>
+
+      <para>
+Whenever a mode switch or a VT-switch is performed the common level will
+return to SETUP state.
+      </para>
+    </sect2>
+
+    <sect2>
+      <title>Resource Types</title>
+
+      <para>
+Resource have certain properties.  When registering resources each range
+is accompanied by a flag consisting of the ORed flags of the different
+properties the resource has.  Each resource range may be classified
+according to
+
+	<itemizedlist>
+	  <listitem><para>
+       its physical properties i.e., if it addresses
+       memory (<constant>ResMem</constant>)  or
+       I/O space (<constant>ResIo</constant>),
+	    </para></listitem>
+	  <listitem><para>
+       if it addresses a
+       block (<constant>ResBlock</constant>) or
+       sparse (<constant>ResSparse</constant>)
+       range,
+	    </para></listitem>
+	  <listitem><para>
+       its access properties.
+	    </para></listitem>
+	</itemizedlist>
+      </para>
+
+      <para>
+There are two known access properties:
+
+	<itemizedlist>
+	  <listitem><para>
+  <constant>ResExclusive</constant>
+    for resources which may not be shared with any other device and
+	    </para></listitem>
+	  <listitem><para>
+  <constant>ResShared</constant>
+    for resources which can be disabled and therefore can be shared.
+	    </para></listitem>
+	</itemizedlist>
+      </para>
+
+      <para>
+If it is necessary to test a resource against any type a generic access
+type <constant>ResAny</constant> is provided.  If this is set the resource
+will conflict with any resource of a different entity intersecting its
+range.  Further it can be specified that a resource is decoded however
+never used during any stage (<constant>ResUnused</constant>) or during
+OPERATING state (<constant>ResUnusedOpr</constant>).  A resource only visible
+during the init functions (ie.  <function>EntityInit()</function>,
+<function>EntityEnter()</function> and <function>EntityLeave()</function> should
+be registered with the flag <constant>ResInit</constant>.  A resource that
+might conflict with background resource ranges may be flagged with
+<constant>ResBios</constant>.  This might be useful when registering resources
+ranges that were assigned by the system Bios.
+      </para>
+
+      <para>
+Several predefined resource lists are available for VGA and 8514/A
+resources in <filename>common/xf86Resources.h</filename>.
+      </para>
+    </sect2>
+
+    <sect2 id="avail">
+      <title>Available Functions</title>
+
+      <para>
+The functions provided for resource management are listed in their order
+of use in the driver.
+      </para>
+
+      <sect3>
+	<title>Probe Phase</title>
+
+	<para>
+In this phase each driver detects those resources it is able to drive,
+creates an entity record for each of them, registers non-relocatable
+resources and allocates screens and adds the resources to screens.
+	</para>
+
+	<para>
+Two helper functions are provided for matching device sections in the
+xorg.conf file to the devices:
+	</para>
+
+	<blockquote><para>
+	    <programlisting>
+    int xf86MatchPciInstances(const char *driverName, int vendorID,
+                              SymTabPtr chipsets, PciChipsets *PCIchipsets,
+                              GDevPtr *devList, int numDevs, DriverPtr drvp,
+                              int **foundEntities);
+	    </programlisting>
+	    <blockquote><para>
+      This function finds matches between PCI cards that a driver supports
+      and config file device sections.  It is intended for use in the
+      <function>ChipProbe()</function> function of drivers for PCI cards.
+      Only probed PCI devices with a vendor ID matching
+      <parameter>vendorID</parameter> are considered.  <parameter>devList</parameter>
+      and <parameter>numDevs</parameter> are typically those found from
+      calling <function>xf86MatchDevice()</function>, and represent the active
+      config file device sections relevant to the driver.
+      <parameter>PCIchipsets</parameter> is a table that provides a mapping
+      between the PCI device IDs, the driver's internal chipset tokens
+      and a list of fixed resources.
+	      </para>
+
+	      <para>
+      When a device section doesn't have a <emphasis>BusID</emphasis> entry it
+      can only match the primary video device.  Secondary devices are
+      only matched with device sections that have a matching
+      <emphasis>BusID</emphasis> entry.
+	      </para>
+
+	      <para>
+      Once the preliminary matches have been found, a final match is
+      confirmed by checking if the chipset override, ChipID override or
+      probed PCI chipset type match one of those given in the
+      <parameter>chipsets</parameter> and <parameter>PCIchipsets</parameter> lists.
+      The <parameter>PCIchipsets</parameter> list includes a list of the PCI
+      device IDs supported by the driver.  The list should be terminated
+      with an entry with PCI ID <constant>-1</constant>".  The
+      <parameter>chipsets</parameter> list is a table mapping the driver's
+      internal chipset tokens to names, and should be terminated with
+      a <constant>NULL</constant> entry.  Only those entries with a
+      corresponding entry in the <parameter>PCIchipsets</parameter> list are
+      considered.  The order of precedence is: config file chipset,
+      config file ChipID, probed PCI device ID.
+	      </para>
+
+	      <para>
+      In cases where a driver handles PCI chipsets with more than one
+      vendor ID, it may set <parameter>vendorID</parameter> to
+      <constant>0</constant>, and OR each devID in the list with (the
+      vendor ID << 16).
+	      </para>
+
+	      <para>
+      Entity index numbers for confirmed matches are returned as an
+      array via <parameter>foundEntities</parameter>.  The PCI information,
+      chipset token and device section for each match are found in the
+      <structname>EntityInfoRec</structname> referenced by the indices.
+	      </para>
+
+	      <para>
+      The function return value is the number of confirmed matches.  A
+      return value of <constant>-1</constant> indicates an internal error.
+      The returned <parameter>foundEntities</parameter> array should be freed
+      by the driver with <function>xfree()</function> when it is no longer
+      needed in cases where the return value is greater than zero.
+	      </para>
+
+	    </blockquote></para></blockquote>
+
+	<blockquote><para>
+	    <programlisting>
+    int xf86MatchIsaInstances(const char *driverName,
+                              SymTabPtr chipsets, IsaChipsets *ISAchipsets,
+                              DriverPtr drvp, FindIsaDevProc FindIsaDevice,
+                              GDevPtr *devList, int numDevs,
+                              int **foundEntities);
+	    </programlisting>
+	    <blockquote><para>
+      This function finds matches between ISA cards that a driver supports
+      and config file device sections.  It is intended for use in the
+      <function>ChipProbe()</function> function of drivers for ISA cards.
+      <parameter>devList</parameter> and <parameter>numDevs</parameter> are
+      typically those found from calling <function>xf86MatchDevice()</function>,
+      and represent the active config file device sections relevant to
+      the driver.  <parameter>ISAchipsets</parameter> is a table that provides
+      a mapping between the driver's internal chipset tokens and the
+      resource classes.  <parameter>FindIsaDevice</parameter> is a
+      driver-provided function that probes the hardware and returns the
+      chipset token corresponding to what was detected, and
+      <constant>-1</constant> if nothing was detected.
+	      </para>
+
+	      <para>
+      If the config file device section contains a chipset entry, then
+      it is checked against the <parameter>chipsets</parameter> list.  When
+      no chipset entry is present, the <parameter>FindIsaDevice</parameter>
+      function is called instead.
+	      </para>
+
+	      <para>
+      Entity index numbers for confirmed matches are returned as an
+      array via <parameter>foundEntities</parameter>.  The chipset token and
+      device section for each match are found in the
+      <structname>EntityInfoRec</structname> referenced by the indices.
+	      </para>
+
+	      <para>
+      The function return value is the number of confirmed matches.  A
+      return value of <constant>-1</constant> indicates an internal error.
+      The returned <parameter>foundEntities</parameter> array should be freed
+      by the driver with <function>xfree()</function> when it is no longer
+      needed in cases where the return value is greater than zero.
+	      </para>
+
+	    </blockquote></para></blockquote>
+
+	<para>
+These two helper functions make use of several core functions that are
+available at the driver level:
+	</para>
+
+	<blockquote><para>
+	    <programlisting>
+    Bool xf86ParsePciBusString(const char *busID, int *bus,
+                               int *device, int *func);
+	    </programlisting>
+	    <blockquote><para>
+      Takes a <parameter>BusID</parameter> string, and if it is in the correct
+      format, returns the PCI <parameter>bus</parameter>, <parameter>device</parameter>,
+      <parameter>func</parameter> values that it indicates.  The format of the
+      string is expected to be "PCI:bus:device:func" where each of <quote>bus</quote>,
+      <quote>device</quote> and <quote>func</quote> are decimal integers.  The ":func" part may
+      be omitted, and the func value assumed to be zero, but this isn't
+      encouraged.  The "PCI" prefix may also be omitted.  The prefix
+      "AGP" is currently equivalent to the "PCI" prefix.  If the string
+      isn't a valid PCI BusID, the return value is <constant>FALSE</constant>.
+	      </para>
+
+	    </blockquote></para></blockquote>
+
+	<blockquote><para>
+	    <programlisting>
+    Bool xf86ComparePciBusString(const char *busID, int bus,
+                                 int device, int func);
+	    </programlisting>
+	    <blockquote><para>
+      Compares a <parameter>BusID</parameter> string with PCI <parameter>bus</parameter>,
+      <parameter>device</parameter>, <parameter>func</parameter> values.  If they
+      match <constant>TRUE</constant> is returned, and <constant>FALSE</constant>
+      if they don't.
+	      </para>
+
+	    </blockquote></para></blockquote>
+
+	<blockquote><para>
+	    <programlisting>
+    Bool xf86ParseIsaBusString(const char *busID);
+	    </programlisting>
+	    <blockquote><para>
+      Compares a <parameter>BusID</parameter> string with the ISA bus ID string
+      ("ISA" or "ISA:").  If they match <constant>TRUE</constant> is returned,
+      and <constant>FALSE</constant> if they don't.
+	      </para>
+
+	    </blockquote></para></blockquote>
+
+	<blockquote><para>
+	    <programlisting>
+    Bool xf86CheckPciSlot(int bus, int device, int func);
+	    </programlisting>
+	    <blockquote><para>
+      Checks if the PCI slot <literal remap="tt">bus:device:func</literal> has been
+      claimed.  If so, it returns <constant>FALSE</constant>, and otherwise
+      <constant>TRUE</constant>.
+	      </para>
+
+	    </blockquote></para></blockquote>
+
+	<blockquote><para>
+	    <programlisting>
+    int xf86ClaimPciSlot(int bus, int device, int func, DriverPtr drvp,
+                         int chipset, GDevPtr dev, Bool active);
+	    </programlisting>
+	    <blockquote><para>
+      This function is used to claim a PCI slot, allocate the associated
+      entity record and initialise their data structures.  The return
+      value is the index of the newly allocated entity record, or
+      <constant>-1</constant> if the claim fails.  This function should always
+      succeed if <function>xf86CheckPciSlot()</function> returned
+      <constant>TRUE</constant> for the same PCI slot.
+	      </para>
+
+	    </blockquote></para></blockquote>
+
+	<blockquote><para>
+	    <programlisting>
+    Bool xf86IsPrimaryPci(void);
+	    </programlisting>
+	    <blockquote><para>
+      This function returns <constant>TRUE</constant> if the primary card is
+      a PCI device, and <constant>FALSE</constant> otherwise.
+	      </para>
+
+	    </blockquote></para></blockquote>
+
+	<blockquote><para>
+	    <programlisting>
+    int xf86ClaimIsaSlot(DriverPtr drvp, int chipset,
+                         GDevPtr dev, Bool active);
+	    </programlisting>
+	    <blockquote><para>
+      This allocates an entity record entity and initialise the data
+      structures.  The return value is the index of the newly allocated
+      entity record.
+	      </para>
+
+	    </blockquote></para></blockquote>
+
+	<blockquote><para>
+	    <programlisting>
+    Bool xf86IsPrimaryIsa(void);
+	    </programlisting>
+	    <blockquote><para>
+      This function returns <constant>TRUE</constant> if the primary card is
+      an ISA (non-PCI) device, and <constant>FALSE</constant> otherwise.
+	      </para>
+
+	    </blockquote></para></blockquote>
+
+	<para>
+Two helper functions are provided to aid configuring entities:
+	</para>
+
+	<blockquote><para>
+	    <programlisting>
+    ScrnInfoPtr xf86ConfigPciEntity(ScrnInfoPtr pScrn,
+                                    int scrnFlag, int entityIndex,
+                                    PciChipsets *p_chip,
+                                    resList res, EntityProc init,
+                                    EntityProc enter, EntityProc leave,
+                                    pointer private);
+
+    ScrnInfoPtr xf86ConfigIsaEntity(ScrnInfoPtr pScrn,
+                                    int scrnFlag, int entityIndex,
+                                    IsaChipsets *i_chip,
+                                    resList res, EntityProc init,
+                                    EntityProc enter, EntityProc leave,
+                                    pointer private);
+	    </programlisting>
+	    <blockquote><para>
+      These functions are used to register the non-relocatable resources
+      for an entity, and the optional entity-specific <parameter>Init</parameter>, <parameter>Enter</parameter> and
+      <parameter>Leave</parameter> functions.  Usually the list of fixed resources is obtained
+      from the Isa/PciChipsets lists.  However an additional list of
+      resources may be passed.  Generally this is not required.
+      For active entities a <structname>ScrnInfoRec</structname> is allocated
+      if the <parameter>pScrn</parameter> argument is <constant>NULL</constant>.
+The
+      return value is <constant>TRUE</constant> when successful.  The init, enter, leave
+      functions are defined as follows:
+
+		<blockquote><para>
+		    <programlisting>
+        typedef void (*EntityProc)(int entityIndex,
+                                   pointer private);
+		    </programlisting>
+		  </para></blockquote>
+
+      They are passed the entity index and a pointer to a private scratch
+      area.  This can be set up during <function>Probe()</function> and
+      its address can be passed to
+      <function>xf86ConfigIsaEntity()</function> and
+      <function>xf86ConfigPciEntity()</function> as the last argument.
+	      </para>
+
+	    </blockquote></para></blockquote>
+
+	<para>
+These two helper functions make use of several core functions that are
+available at the driver level:
+
+	  <blockquote><para>
+	      <programlisting>
+    void xf86ClaimFixedResources(resList list, int entityIndex);
+	      </programlisting>
+	      <blockquote><para>
+      This function registers the non-relocatable resources which cannot
+      be disabled and which therefore would cause the server to fail
+      immediately if they were found to conflict.  It also records
+      non-relocatable but sharable resources for processing after the
+      <function>Probe()</function> phase.
+		</para>
+
+	      </blockquote></para></blockquote>
+
+	  <blockquote><para>
+	      <programlisting>
+    Bool xf86SetEntityFuncs(int entityIndex, EntityProc init,
+                            EntityProc enter, EntityProc leave, pointer);
+	      </programlisting>
+	      <blockquote><para>
+      This function registers with an entity the <parameter>init</parameter>,
+      <parameter>enter</parameter>, <parameter>leave</parameter> functions along
+      with the pointer to their private area.
+		</para>
+
+	    </blockquote></para></blockquote>
+
+	  <blockquote><para>
+	      <programlisting>
+    void xf86AddEntityToScreen(ScrnInfoPtr pScrn, int entityIndex);
+	      </programlisting>
+	      <blockquote><para>
+      This function associates the entity referenced by
+      <parameter>entityIndex</parameter> with the screen.
+		</para>
+
+	      </blockquote></para></blockquote>
+	</para>
+      </sect3>
+
+      <sect3>
+	<title>PreInit Phase</title>
+
+	<para>
+During this phase the remaining resources should be registered.
+<function>PreInit()</function> should call <function>xf86GetEntityInfo()</function>
+to obtain a pointer to an <structname>EntityInfoRec</structname> for each entity
+it is able to drive and check if any resource are listed in its
+<structfield>resources</structfield> field.  If resources registered in the Probe
+phase have been rejected in the post-Probe phase
+(<structfield>resources</structfield> is non-<constant>NULL</constant>), then the driver should
+decide if it can continue without using these or if it should fail.
+	</para>
+
+	<blockquote><para>
+	    <programlisting>
+    EntityInfoPtr xf86GetEntityInfo(int entityIndex);
+	    </programlisting>
+	    <blockquote><para>
+      This function returns a pointer to the <structname>EntityInfoRec</structname>
+      referenced by <parameter>entityIndex</parameter>.  The returned
+      <structname>EntityInfoRec</structname> should be freed with
+      <function>xfree()</function> when no longer needed.
+	      </para>
+
+	    </blockquote></para></blockquote>
+
+	<para>
+Several functions are provided to simplify resource registration:
+	  <blockquote><para>
+	      <programlisting>
+    Bool xf86IsEntityPrimary(int entityIndex);
+	      </programlisting>
+	      <blockquote><para>
+      This function returns <constant>TRUE</constant> if the entity referenced
+      by <parameter>entityIndex</parameter> is the primary display device (i.e.,
+      the one initialised at boot time and used in text mode).
+		</para>
+
+	      </blockquote></para></blockquote>
+
+	  <blockquote><para>
+	      <programlisting>
+    Bool xf86IsScreenPrimary(int scrnIndex);
+	      </programlisting>
+	      <blockquote><para>
+      This function returns <constant>TRUE</constant> if the primary entity
+      is registered with the screen referenced by
+      <parameter>scrnIndex</parameter>.
+		</para>
+
+	      </blockquote></para></blockquote>
+
+	  <blockquote><para>
+	      <programlisting>
+    pciVideoPtr xf86GetPciInfoForEntity(int entityIndex);
+	      </programlisting>
+	      <blockquote><para>
+      This function returns a pointer to the <structname>pciVideoRec</structname>
+      for the specified entity.  If the entity is not a PCI device,
+      <constant>NULL</constant> is returned.
+		</para>
+
+	      </blockquote></para></blockquote>
+	</para>
+
+	<para>
+The primary function for registration of resources is:
+	  <blockquote><para>
+	      <programlisting>
+    resPtr xf86RegisterResources(int entityIndex, resList list,
+                                 int access);
+	      </programlisting>
+	      <blockquote><para>
+      This function tries to register the resources in
+      <parameter>list</parameter>.  If list is <constant>NULL</constant> it tries
+      to determine the resources automatically.  This only works for
+      entities that provide a generic way to read out the resource ranges
+      they decode.  So far this is only the case for PCI devices.  By
+      default the PCI resources are registered as shared
+      (<constant>ResShared</constant>) if the driver wants to set a different
+      access type it can do so by specifying the access flags in the
+      third argument.  A value of <constant>0</constant> means to use the
+      default settings.  If for any reason the resource broker is not
+      able to register some of the requested resources the function will
+      return a pointer to a list of the failed ones.  In this case the
+      driver may be able to move the resource to different locations.
+      In case of PCI bus entities this is done by passing the list of
+      failed resources to <function>xf86ReallocatePciResources()</function>.
+      When the registration succeeds, the return value is
+      <constant>NULL</constant>.
+		</para>
+
+	      </blockquote></para></blockquote>
+	  </para>
+
+	<blockquote><para>
+	    <programlisting>
+    resPtr xf86ReallocatePciResources(int entityIndex, resPtr pRes);
+	    </programlisting>
+	    <blockquote><para>
+      This function takes a list of PCI resources that need to be
+      reallocated and returns <constant>NULL</constant> when all relocations are
+      successful.
+      <function>xf86RegisterResources()</function> should be called again to
+      register the relocated resources with the broker.
+      If the reallocation fails, a list of the resources that could not be
+      relocated is returned.
+	      </para>
+
+	    </blockquote></para></blockquote>
+
+<para>
+Two functions are provided to obtain a resource range of a given type:
+	  <blockquote><para>
+	      <programlisting>
+    resRange xf86GetBlock(long type, memType size,
+                          memType window_start, memType window_end,
+                          memType align_mask, resPtr avoid);
+	      </programlisting>
+	      <blockquote><para>
+      This function tries to find a block range of size
+      <parameter>size</parameter> and type <parameter>type</parameter> in a window
+      bound by <parameter>window_start</parameter> and <parameter>window_end</parameter>
+      with the alignment specified in <parameter>align_mask</parameter>.
+      Optionally a list of resource ranges which should be avoided within
+      the window can be supplied.  On failure a zero-length range of
+      type <constant>ResEnd</constant> will be returned.
+		</para>
+	      </blockquote></para></blockquote>
+
+	  <blockquote><para>
+	      <programlisting>
+    resRange xf86GetSparse(long type, memType fixed_bits,
+                           memType decode_mask, memType address_mask,
+                           resPtr avoid);
+	      </programlisting>
+	      <blockquote><para>
+      This function is like the previous one, but attempts to find a
+      sparse range instead of a block range.  Here three values have to
+      be specified: the <parameter>address_mask</parameter> which marks all
+      bits of the mask part of the address, the <parameter>decode_mask</parameter>
+      which masks out the bits which are hardcoded and are therefore
+      not available for relocation and the values of the fixed bits.
+      The function tries to find a base that satisfies the given condition.
+      If the function fails it will return a zero range of type
+      <constant>ResEnd</constant>.  Optionally it might be passed a list of
+      resource ranges to avoid.
+		</para>
+
+	      </blockquote></para></blockquote>
+	</para>
+
+	<para>
+Some PCI devices are broken in the sense that they return invalid size
+information for a certain resource.  In this case the driver can supply
+the correct size and make sure that the resource range allocated for
+the card is large enough to hold the address range decoded by the card.
+The function <function>xf86FixPciResource()</function> can be used to do this:
+	  <blockquote><para>
+	      <programlisting>
+    Bool xf86FixPciResource(int entityIndex, unsigned int prt,
+                            CARD32 alignment, long type);
+	      </programlisting>
+	      <blockquote><para>
+      This function fixes a PCI resource allocation.  The
+      <parameter>prt</parameter> parameter contains the number of the PCI base
+      register that needs to be fixed (<constant>0-5</constant>, and
+      <constant>6</constant> for the BIOS base register).  The size is
+      specified by the alignment.  Since PCI resources need to span an
+      integral range of size <literal remap="tt">2ˆn</literal>, the alignm      ent also
+      specifies the number of addresses that will be decoded.  If the
+      driver specifies a type mask it can override the default type for
+      PCI resources which is <constant>ResShared</constant>.  The resource
+      broker needs to know that to find a matching resource range.  This
+      function should be called before calling
+      <function>xf86RegisterResources()</function>.  The return value is
+      <constant>TRUE</constant> when the function succeeds.
+		</para>
+
+	      </blockquote></para></blockquote>
+
+	  <blockquote><para>
+	      <programlisting>
+    Bool xf86CheckPciMemBase(pciVideoPtr pPci, memType base);
+	      </programlisting>
+	      <blockquote><para>
+      This function checks that the memory base address specified matches
+      one of the PCI base address register values for the given PCI
+      device.  This is mostly used to check that an externally provided
+      base address (e.g., from a config file) matches an actual value
+      allocated to a device.
+		</para>
+
+	      </blockquote></para></blockquote>
+	</para>
+
+	<para>
+The driver may replace the generic access control functions for an entity.
+This is done with the <function>xf86SetAccessFuncs()</function>:
+	  <blockquote><para>
+	      <programlisting>
+    void xf86SetAccessFuncs(EntityInfoPtr pEnt,
+                            xf86SetAccessFuncPtr funcs,
+                            xf86SetAccessFuncPtr oldFuncs);
+	      </programlisting>
+     with:
+	      <programlisting>
+      typedef struct {
+          xf86AccessPtr mem;
+          xf86AccessPtr io;
+          xf86AccessPtr io_mem;
+      } xf86SetAccessFuncRec, *xf86SetAccessFuncPtr;
+	      </programlisting>
+	      <blockquote><para>
+      The driver can pass three functions: one for I/O access, one for
+      memory access and one for combined memory and I/O access.  If the
+      memory access and combined access functions are identical the
+      common level assumes that the memory access cannot be controlled
+      independently of I/O access, if the I/O access function and the
+      combined access functions are the same it is assumed that I/O can
+      not be controlled independently.  If memory and I/O have to be
+      controlled together all three values should be the same.  If a
+      non <constant>NULL</constant> value is passed as third argument it is
+      interpreted as an address where to store the old access record.
+      If the third argument is <constant>NULL</constant> it will be assumed
+      that the generic access should be enabled before replacing the
+      access functions.  Otherwise it will be disabled.  The driver may
+      enable them itself using the returned values.  It should do this
+      from its replacement access functions as the generic access may
+      be disabled by the common level on certain occasions.  If replacement
+      functions are specified they must control all resources of the
+      specific type registered for the entity.
+		</para>
+
+	      </blockquote></para></blockquote>
+	</para>
+
+	<para>
+To find out if a specific resource range conflicts with another
+resource the <function>xf86ChkConflict()</function> function may be used:
+	  <blockquote><para>
+	      <programlisting>
+    memType xf86ChkConflict(resRange *rgp, int entityIndex);
+	      </programlisting>
+	      <blockquote><para>
+      This function checks if the resource range <parameter>rgp</parameter> of
+      for the specified entity conflicts with with another resource.
+      If a conflict is found, the address of the start of the conflict
+      is returned.  The return value is zero when there is no conflict.
+		</para>
+
+	      </blockquote></para></blockquote>
+	</para>
+
+	<para>
+The OPERATING state properties of previously registered fixed resources
+can be set with the <function>xf86SetOperatingState()</function> function:
+	  <blockquote><para>
+	      <programlisting>
+    resPtr xf86SetOperatingState(resList list, int entityIndex,
+                                 int mask);
+	      </programlisting>
+	      <blockquote><para>
+      This function is used to set the status of a resource during
+      OPERATING state.  <parameter>list</parameter> holds a list to which
+      <parameter>mask</parameter> is to be applied.  The parameter
+      <parameter>mask</parameter> may have the value <constant>ResUnusedOpr</constant>
+      and <constant>ResDisableOpr</constant>.  The first one should be used
+      if a resource isn't used by the driver during OPERATING state
+      although it is decoded by the device, while the latter one indicates
+      that the resource is not decoded during OPERATING state.  Note
+      that the resource ranges have to match those specified during
+      registration.  If a range has been specified starting at
+      <literal remap="tt">A</literal> and ending at <literal remap="tt">B</literal> and suppose
+      <literal remap="tt">C</literal> us a value satisfying
+      <literal remap="tt">A < C < B</literal> one may not
+      specify the resource range <literal remap="tt">(A,B)</literal> by splitting it
+      into two ranges <literal remap="tt">(A,C)</literal> and <literal remap="tt">(C,B)</literal>.
+		</para>
+
+	      </blockquote></para></blockquote>
+	</para>
+
+	<para>
+The following two functions are provided for special cases:
+	  <blockquote><para>
+	      <programlisting>
+    void xf86RemoveEntityFromScreen(ScrnInfoPtr pScrn, int entityIndex);
+	      </programlisting>
+	      <blockquote><para>
+      This function may be used to remove an entity from a screen.  This
+      only makes sense if a screen has more than one entity assigned or
+      the screen is to be deleted.  No test is made if the screen has
+      any entities left.
+		</para>
+
+	      </blockquote></para></blockquote>
+
+	  <blockquote><para>
+	      <programlisting>
+    void xf86DeallocateResourcesForEntity(int entityIndex, long type);
+	      </programlisting>
+	      <blockquote><para>
+      This function deallocates all resources of a given type registered
+      for a certain entity from the resource broker list.
+		</para>
+
+	      </blockquote></para></blockquote>
+	</para>
+
+      </sect3>
+
+      <sect3>
+	<title>ScreenInit Phase</title>
+
+	<para>
+All that is required in this phase is to setup the RAC flags.  Note that
+it is also permissible to set these flags up in the PreInit phase.  The
+RAC flags are held in the <structfield>racIoFlags</structfield> and <structfield>racMemFlags</structfield> fields of the
+<structname>ScrnInfoRec</structname> for each screen.  They specify which graphics operations
+might require the use of shared resources.  This can be specified
+separately for memory and I/O resources.  The available flags are defined
+in <filename>rac/xf86RAC.h</filename>.  They are:
+
+	  <variablelist>
+	    <varlistentry><term><constant>RAC_FB</constant></term>
+	      <listitem><para>
+	for framebuffer operations (including hw acceleration)
+		</para></listitem></varlistentry>
+	    <varlistentry><term><constant>RAC_CURSOR</constant></term>
+	      <listitem><para>
+	for Cursor operations
+        (??? I'm not sure if we need this for SW cursor it depends
+         on which level the sw cursor is drawn)
+		</para></listitem></varlistentry>
+	    <varlistentry><term><constant>RAC_COLORMAP</constant></term>
+	      <listitem><para>
+	for colormap operations
+		</para></listitem></varlistentry>
+	    <varlistentry><term><constant>RAC_VIEWPORT</constant></term>
+	      <listitem><para>
+	for the call to <function>ChipAdjustFrame()</function>
+		</para></listitem></varlistentry>
+	    </variablelist>
+
+
+The flags are ORed together.
+	</para>
+      </sect3>
+    </sect2>
+  </sect1>
+
+  <sect1 id="options">
+    <title>Config file <quote>Option</quote> entries</title>
+
+    <para>
+Option entries are permitted in most sections and subsections of the
+config file.  There are two forms of option entries:
+
+      <variablelist>
+	<varlistentry><term>Option "option-name"</term>
+	  <listitem><para>
+	A boolean option.
+	    </para></listitem></varlistentry>
+	<varlistentry><term>Option "option-name" "option-value"</term>
+	  <listitem><para>
+	An option with an arbitrary value.
+	    </para></listitem></varlistentry>
+      </variablelist>
+    </para>
+
+    <para>
+The option entries are handled by the parser, and a list of the parsed
+options is included with each of the appropriate data structures that
+the drivers have access to.  The data structures used to hold the option
+information are opaque to the driver, and a driver must not access the
+option data directly.  Instead, the common layer provides a set of
+functions that may be used to access, check and manipulate the option
+data.
+    </para>
+
+    <para>
+First, the low level option handling functions.  In most cases drivers
+would not need to use these directly.
+    </para>
+
+    <blockquote><para>
+	<programlisting>
+    pointer xf86FindOption(pointer options, const char *name);
+	</programlisting>
+	<blockquote><para>
+      Takes a list of options and an option name, and returns a handle
+      for the first option entry in the list matching the name.  Returns
+      <constant>NULL</constant> if no match is found.
+	  </para>
+
+	</blockquote></para></blockquote>
+
+    <blockquote><para>
+	<programlisting>
+    char *xf86FindOptionValue(pointer options, const char *name);
+	</programlisting>
+	<blockquote><para>
+      Takes a list of options and an option name, and returns the value
+      associated with the first option entry in the list matching the
+      name.  If the matching option has no value, an empty string
+      (<constant>""</constant>) is returned.  Returns <constant>NULL</constant>
+      if no match is found.
+	  </para>
+
+	</blockquote></para></blockquote>
+
+    <blockquote><para>
+	<programlisting>
+    void xf86MarkOptionUsed(pointer option);
+	</programlisting>
+	<blockquote><para>
+      Takes a handle for an option, and marks that option as used.
+	  </para>
+
+	</blockquote></para></blockquote>
+
+    <blockquote><para>
+	<programlisting>
+    void xf86MarkOptionUsedByName(pointer options, const char *name);
+	</programlisting>
+	<blockquote><para>
+      Takes a list of options and an option name and marks the first
+      option entry in the list matching the name as used.
+	  </para>
+
+	</blockquote></para></blockquote>
+
+    <para>
+Next, the higher level functions that most drivers would use.
+    </para>
+    <blockquote><para>
+	<programlisting>
+    void xf86CollectOptions(ScrnInfoPtr pScrn, pointer extraOpts);
+	</programlisting>
+	<blockquote><para>
+      Collect the options from each of the config file sections used by
+      the screen (<parameter>pScrn</parameter>) and return the merged list as
+      <structfield>pScrn->options</structfield>.  This function requires that
+      <structfield>pScrn->confScreen</structfield>, <structfield>pScrn->display</structfield>,
+      <structfield>pScrn->monitor</structfield>,
+      <structfield>pScrn->numEntities</structfield>, and
+      <structfield>pScrn->entityList</structfield> are initialised.
+      <parameter>extraOpts</parameter> may optionally be set to an additional
+      list of options to be combined with the others.  The order of
+      precedence for options is <parameter>extraOpts</parameter>, display,
+      confScreen, monitor, device.
+	  </para>
+
+	</blockquote></para></blockquote>
+
+    <blockquote><para>
+	<programlisting>
+    void xf86ProcessOptions(int scrnIndex, pointer options,
+                            OptionInfoPtr optinfo);
+	</programlisting>
+	<blockquote><para>
+      Processes a list of options according to the information in the
+      array of <structname>OptionInfoRecs</structname> (<parameter>optinfo</parameter>).
+      The resulting information is stored in the <structfield>value</structfield>
+      fields of the appropriate <parameter>optinfo</parameter> entries.  The
+      <structfield>found</structfield> fields are set to <constant>TRUE</constant>
+      when an option with a value of the correct type if found, and
+      <constant>FALSE</constant> otherwise.  The <structfield>type</structfield> field
+      is used to determine the expected value type for each option.
+      Each option in the list of options for which there is a name match
+      (but not necessarily a value type match) is marked as used.
+      Warning messages are printed when option values don't match the
+      types specified in the optinfo data.
+	  </para>
+
+	  <para>
+      NOTE: If this function is called before a driver's screen number
+      is known (e.g., from the <function>ChipProbe()</function> function) a
+      <parameter>scrnIndex</parameter> value of <constant>-1</constant> should be
+      used.
+	  </para>
+
+	  <para>
+      NOTE 2: Given that this function stores into the
+      <literal remap="tt">OptionInfoRecs</literal> pointed to by <parameter>optinfo</parameter>,
+      the caller should ensure the <literal remap="tt">OptionInfoRecs</literal> are
+      (re-)initialised before the call, especially if the caller expects
+      to use the predefined option values as defaults.
+	  </para>
+
+	  <para>
+      The <structname>OptionInfoRec</structname> is defined as follows:
+
+	    <programlisting>
+      typedef struct {
+          double freq;
+          int units;
+      } OptFrequency;
+
+      typedef union {
+          unsigned long       num;
+          char *              str;
+          double              realnum;
+          Bool                bool;
+          OptFrequency        freq;
+      } ValueUnion;
+
+      typedef enum {
+          OPTV_NONE = 0,
+          OPTV_INTEGER,
+          OPTV_STRING,  /* a non-empty string */
+          OPTV_ANYSTR,  /* Any string, including an empty one */
+          OPTV_REAL,
+          OPTV_BOOLEAN,
+          OPTV_PERCENT,
+          OPTV_FREQ
+      } OptionValueType;
+
+      typedef enum {
+          OPTUNITS_HZ = 1,
+          OPTUNITS_KHZ,
+          OPTUNITS_MHZ
+      } OptFreqUnits;
+
+      typedef struct {
+          int                 token;
+          const char*         name;
+          OptionValueType     type;
+          ValueUnion          value;
+          Bool                found;
+      } OptionInfoRec, *OptionInfoPtr;
+	    </programlisting>
+	  </para>
+	  <para>
+      <constant>OPTV_FREQ</constant> can be used for options values that are
+      frequencies.  These values are a floating point number with an
+      optional unit name appended.  The unit name can be one of "Hz",
+      "kHz", "k", "MHz", "M".  The multiplier associated with the unit
+      is stored in <structfield>freq.units</structfield>, and the scaled frequency
+      is stored in <structfield>freq.freq</structfield>.  When no unit is specified,
+      <structfield>freq.units</structfield> is set to <constant>0</constant>, and
+      <structfield>freq.freq</structfield> is unscaled.
+	  </para>
+
+	  <para>
+      <constant>OPTV_PERCENT</constant> can be used for option values that are
+      specified in percent (e.g. "20%"). These values are a floating point
+      number with a percent sign appended. If the percent sign is missing,
+      the parser will fail to match the value.
+	  </para>
+
+	  <para>
+      Typical usage is to setup an array of
+      <structname>OptionInfoRec</structname>s with all fields initialised.
+      The <structfield>value</structfield> and <structfield>found</structfield> fields get
+      set by <function>xf86ProcessOptions()</function>.  For cases where the
+      value parsing is more complex, the driver should specify
+      <constant>OPTV_STRING</constant>, and parse the string itself.  An
+      example of using this option handling is included in the
+      <link linkend="sample">Sample Driver</link> section.
+	  </para>
+
+	</blockquote></para></blockquote>
+
+    <blockquote><para>
+	<programlisting>
+    void xf86ShowUnusedOptions(int scrnIndex, pointer options);
+	</programlisting>
+	<blockquote><para>
+      Prints out warning messages for each option in the list of options
+      that isn't marked as used.  This is intended to show options that
+      the driver hasn't recognised.  It would normally be called near
+      the end of the <function>ChipScreenInit()</function> function, but only
+      when <code>serverGeneration == 1</code>
+	  </para>
+	</blockquote></para></blockquote>
+
+    <blockquote><para>
+	<programlisting>
+    OptionInfoPtr xf86TokenToOptinfo(const OptionInfoRec *table,
+                                     int token);
+	</programlisting>
+	<blockquote><para>
+      Returns a pointer to the <structname>OptionInfoRec</structname> in
+      <parameter>table</parameter> with a token field matching
+      <parameter>token</parameter>.  Returns <constant>NULL</constant> if no match
+      is found.
+	  </para>
+
+	</blockquote></para></blockquote>
+
+    <blockquote><para>
+	<programlisting>
+    Bool xf86IsOptionSet(const OptionInfoRec *table, int token);
+	</programlisting>
+	<blockquote><para>
+      Returns the <literal remap="tt">found</literal> field of the
+      <structname>OptionInfoRec</structname> in <parameter>table</parameter> with a
+      <structfield>token</structfield> field matching <parameter>token</parameter>.  This
+      can be used for options of all types.  Note that for options of
+      type <constant>OPTV_BOOLEAN</constant>, it isn't sufficient to check
+      this to determine the value of the option.  Returns
+      <constant>FALSE</constant> if no match is found.
+	  </para>
+
+	</blockquote></para></blockquote>
+
+    <blockquote><para>
+	<programlisting>
+    char *xf86GetOptValString(const OptionInfoRec *table, int token);
+	</programlisting>
+	<blockquote><para>
+      Returns the <structfield>value.str</structfield> field of the
+      <structname>OptionInfoRec</structname> in <parameter>table</parameter> with a
+      token field matching <parameter>token</parameter>.  Returns
+      <constant>NULL</constant> if no match is found.
+	  </para>
+
+	</blockquote></para></blockquote>
+
+	  <blockquote><para>
+	      <programlisting>
+    Bool xf86GetOptValInteger(const OptionInfoRec *table, int token,
+
+                                int *value);
+	      </programlisting>
+	      <blockquote><para>
+      Returns via <parameter>*value</parameter> the <structfield>value.num</structfield>
+      field of the <structname>OptionInfoRec</structname> in <parameter>table</parameter>
+      with a <structfield>token</structfield> field matching <parameter>token</parameter>.
+      <parameter>*value</parameter> is only changed when a match is found so
+      it can be safely initialised with a default prior to calling this
+      function.  The function return value is as for
+      <function>xf86IsOptionSet()</function>.
+	  </para>
+
+	</blockquote></para></blockquote>
+
+    <blockquote><para>
+	<programlisting>
+    Bool xf86GetOptValULong(const OptionInfoRec *table, int token,
+                            unsigned long *value);
+	</programlisting>
+	<blockquote><para>
+      Like <function>xf86GetOptValInteger()</function>, except the value is
+      treated as an <type>unsigned long</type>.
+	  </para>
+
+	</blockquote></para></blockquote>
+
+    <blockquote><para>
+	<programlisting>
+    Bool xf86GetOptValReal(const OptionInfoRec *table, int token,
+                           double *value);
+	</programlisting>
+	<blockquote><para>
+      Like <function>xf86GetOptValInteger()</function>, except that
+      <structfield>value.realnum</structfield> is used.
+	  </para>
+
+	</blockquote></para></blockquote>
+
+    <blockquote><para>
+	<programlisting>
+    Bool xf86GetOptValFreq(const OptionInfoRec *table, int token,
+                           OptFreqUnits expectedUnits, double *value);
+	</programlisting>
+	<blockquote><para>
+      Like <function>xf86GetOptValInteger()</function>, except that the
+      <structfield>value.freq</structfield> data is returned.  The frequency value
+      is scaled to the units indicated by <parameter>expectedUnits</parameter>.
+      The scaling is exact when the units were specified explicitly in
+      the option's value.  Otherwise, the <parameter>expectedUnits</parameter>
+      field is used as a hint when doing the scaling.  In this case,
+      values larger than <constant>1000</constant> are assumed to have be
+      specified in the next smallest units.  For example, if the Option
+      value is "10000" and expectedUnits is <constant>OPTUNITS_MHZ</constant>,
+      the value returned is <constant>10</constant>.
+	  </para>
+
+	</blockquote></para></blockquote>
+
+    <blockquote><para>
+      <programlisting>
+    Bool xf86GetOptValBool(const OptionInfoRec *table, int token, Bool *value);
+      </programlisting>
+	<blockquote><para>
+      This function is used to check boolean options
+      (<constant>OPTV_BOOLEAN</constant>).  If the function return value is
+      <constant>FALSE</constant>, it means the option wasn't set.  Otherwise
+      <parameter>*value</parameter> is set to the boolean value indicated by
+      the option's value.  No option <parameter>value</parameter> is interpreted
+      as <constant>TRUE</constant>.  Option values meaning <constant>TRUE</constant>
+      are "1", "yes", "on", "true", and option values meaning
+      <constant>FALSE</constant> are "0", "no", "off", "false".  Option names
+      both with the "no" prefix in their names, and with that prefix
+      removed are also checked and handled in the obvious way.
+      <parameter>*value</parameter> is not changed when the option isn't present.
+      It should normally be set to a default value before calling this
+      function.
+	  </para>
+
+	</blockquote></para></blockquote>
+
+    <blockquote><para>
+	<programlisting>
+    Bool xf86ReturnOptValBool(const OptionInfoRec *table, int token, Bool def);
+	</programlisting>
+	<blockquote><para>
+      This function is used to check boolean options
+      (<constant>OPTV_BOOLEAN</constant>).  If the option is set, its value
+      is returned.  If the options is not set, the default value specified
+      by <parameter>def</parameter> is returned.  The option interpretation is
+      the same as for <function>xf86GetOptValBool()</function>.
+	  </para>
+
+	</blockquote></para></blockquote>
+
+    <blockquote><para>
+	<programlisting>
+    int xf86NameCmp(const char *s1, const char *s2);
+	</programlisting>
+	<blockquote><para>
+      This function should be used when comparing strings from the config
+      file with expected values.  It works like <function>strcmp()</function>,
+      but is not case sensitive and space, tab, and <quote><literal>_</literal></quote> characters
+      are ignored in the comparison.  The use of this function isn't
+      restricted to parsing option values.  It may be used anywhere
+      where this functionality required.
+	  </para>
+
+	</blockquote></para></blockquote>
+  </sect1>
+
+  <sect1>
+    <title>Modules, Drivers, Include Files and Interface Issues</title>
+
+    <para>
+NOTE: this section is incomplete.
+    </para>
+
+
+    <sect2>
+      <title>Include files</title>
+
+      <para>
+The following include files are typically required by video drivers:
+
+	<blockquote><para>
+  All drivers should include these:
+	    <literallayout><filename>
+    "xf86.h"
+    "xf86_OSproc.h"
+    "xf86_ansic.h"
+    "xf86Resources.h"
+	    </filename></literallayout>
+  Wherever inb/outb (and related things) are used the following should be
+  included:
+	    <literallayout><filename>
+    "compiler.h"
+	      </filename></literallayout>
+  Note: in drivers, this must be included after <filename>"xf86_ansic.h"</filename>.
+	  </para>
+
+	  <para>
+  Drivers that need to access PCI vendor/device definitions need this:
+	    <literallayout><filename>
+    "xf86PciInfo.h"
+	      </filename></literallayout>
+	  </para>
+
+	  <para>
+  Drivers that need to access the PCI config space need this:
+	    <literallayout><filename>
+    "xf86Pci.h"
+	      </filename></literallayout>
+	  </para>
+
+	  <para>
+  Drivers that initialise a SW cursor need this:
+	    <literallayout><filename>
+    "mipointer.h"
+	      </filename></literallayout>
+	  </para>
+
+	  <para>
+  All drivers implementing backing store need this:
+	    <literallayout><filename>
+    "mibstore.h"
+	      </filename></literallayout>
+	  </para>
+
+	  <para>
+  All drivers using the mi colourmap code need this:
+	    <literallayout><filename>
+    "micmap.h"
+	      </filename></literallayout>
+	  </para>
+
+	  <para>
+  If a driver uses the vgahw module, it needs this:
+	    <literallayout><filename>
+    "vgaHW.h"
+	      </filename></literallayout>
+	  </para>
+
+	  <para>
+  Drivers supporting VGA or Hercules monochrome screens need:
+	    <literallayout><filename>
+    "xf1bpp.h"
+	      </filename></literallayout>
+	  </para>
+
+	  <para>
+  Drivers supporting VGA or EGC 16-colour screens need:
+	    <literallayout><filename>
+    "xf4bpp.h"
+	      </filename></literallayout>
+	  </para>
+
+	  <para>
+  Drivers using cfb need:
+	    <programlisting>
+    #define PSZ 8
+    #include "cfb.h"
+    #undef PSZ
+	    </programlisting>
+	  </para>
+
+	  <para>
+  Drivers supporting bpp 16, 24 or 32 with cfb need one or more of:
+	    <literallayout><filename>
+    "cfb16.h"
+    "cfb24.h"
+    "cfb32.h"
+	      </filename></literallayout>
+	  </para>
+
+	  <para>
+  If a driver uses XAA, it needs these:
+	    <literallayout><filename>
+    "xaa.h"
+    "xaalocal.h"
+	      </filename></literallayout>
+	  </para>
+
+	  <para>
+  If a driver uses the fb manager, it needs this:
+	    <literallayout><filename>
+    "xf86fbman.h"
+	      </filename></literallayout>
+	  </para>
+	</blockquote>
+      </para>
+
+      <para>
+Non-driver modules should include <filename>"xf86_ansic.h"</filename> to get the correct
+wrapping of ANSI C/libc functions.
+      </para>
+
+      <para>
+All modules must NOT include any system include files, or the following:
+
+	<literallayout><filename>
+    "xf86Priv.h"
+    "xf86Privstr.h"
+    "xf86_OSlib.h"
+    "Xos.h"
+	  </filename></literallayout>
+      </para>
+
+      <para>
+In addition, "xf86_libc.h" must not be included explicitly.  It is
+included implicitly by "xf86_ansic.h".
+      </para>
+
+    </sect2>
+  </sect1>
+
+  <sect1>
+    <title>Offscreen Memory Manager</title>
+
+    <para>
+Management of offscreen video memory may be handled by the XFree86
+framebuffer manager.  Once the offscreen memory manager is running,
+drivers or extensions may allocate, free or resize areas of offscreen
+video memory using the following functions (definitions taken from
+<filename>xf86fbman.h</filename>):
+
+      <programlisting>
+    typedef struct _FBArea {
+        ScreenPtr    pScreen;
+        BoxRec       box;
+        int          granularity;
+        void         (*MoveAreaCallback)(struct _FBArea*, struct _FBArea*)
+        void         (*RemoveAreaCallback)(struct _FBArea*)
+        DevUnion     devPrivate;
+    } FBArea, *FBAreaPtr;
+
+    typedef void (*MoveAreaCallbackProcPtr)(FBAreaPtr from, FBAreaPtr to)
+    typedef void (*RemoveAreaCallbackProcPtr)(FBAreaPtr)
+
+    FBAreaPtr xf86AllocateOffscreenArea (
+        ScreenPtr pScreen,
+        int width, int height,
+        int granularity,
+        MoveAreaCallbackProcPtr MoveAreaCallback,
+        RemoveAreaCallbackProcPtr RemoveAreaCallback,
+        pointer privData
+    )
+
+    void xf86FreeOffscreenArea (FBAreaPtr area)
+
+    Bool xf86ResizeOffscreenArea (
+	FBAreaPtr area
+	int w, int h
+    )
+      </programlisting>
+    </para>
+
+    <para>
+The function:
+      <programlisting>
+    Bool xf86FBManagerRunning(ScreenPtr pScreen);
+      </programlisting>
+
+can be used by an extension to check if the driver has initialized
+the memory manager.  The manager is not available if this returns
+<constant>FALSE</constant> and the functions above will all fail.
+    </para>
+
+
+    <para>
+<function>xf86AllocateOffscreenArea()</function> can be used to request a
+rectangle of dimensions <parameter>width</parameter> × <parameter>height</parameter>
+(in pixels) from unused offscreen memory.  <parameter>granularity</parameter>
+specifies that the leftmost edge of the rectangle must lie on some
+multiple of <parameter>granularity</parameter> pixels.  A granularity of zero
+means the same thing as a granularity of one - no alignment preference.
+A <parameter>MoveAreaCallback</parameter> can be provided to notify the requester
+when the offscreen area is moved.  If no <parameter>MoveAreaCallback</parameter>
+is supplied then the area is considered to be immovable.  The
+<parameter>privData</parameter> field will be stored in the manager's internal
+structure for that allocated area and will be returned to the requester
+in the <parameter>FBArea</parameter> passed via the
+<parameter>MoveAreaCallback</parameter>.  An optional
+<parameter>RemoveAreaCallback</parameter> is provided.  If the driver provides
+this it indicates that the area should be allocated with a lower priority.
+Such an area may be removed when a higher priority request (one that
+doesn't have a <parameter>RemoveAreaCallback</parameter>) is made.  When this
+function is called, the driver will have an opportunity to do whatever
+cleanup it needs to do to deal with the loss of the area, but it must
+finish its cleanup before the function exits since the offscreen memory
+manager will free the area immediately after.
+    </para>
+
+    <para>
+<function>xf86AllocateOffscreenArea()</function> returns <constant>NULL</constant>
+if it was unable to allocate the requested area.  When no longer needed,
+areas should be freed with <function>xf86FreeOffscreenArea()</function>.
+    </para>
+
+    <para>
+<function>xf86ResizeOffscreenArea()</function> resizes an existing
+<literal remap="tt">FBArea</literal>.  <function>xf86ResizeOffscreenArea()</function>
+returns <constant>TRUE</constant> if the resize was successful.  If
+<function>xf86ResizeOffscreenArea()</function> returns <constant>FALSE</constant>,
+the original <literal remap="tt">FBArea</literal> is left unmodified.  Resizing an
+area maintains the area's original <literal remap="tt">granularity</literal>,
+<literal remap="tt">devPrivate</literal>, and <literal remap="tt">MoveAreaCallback</literal>.
+<function>xf86ResizeOffscreenArea()</function> has considerably less overhead
+than freeing the old area then reallocating the new size, so it should
+be used whenever possible.
+    </para>
+
+    <para>
+The function:
+      <programlisting>
+    Bool xf86QueryLargestOffscreenArea(
+      ScreenPtr pScreen,
+      int *width, int *height,
+      int granularity,
+      int preferences,
+      int priority
+    );
+	</programlisting>
+
+is provided to query the width and height of the largest single
+<structname>FBArea</structname> allocatable given a particular priority.
+<parameter>preferences</parameter> can be one of the following to indicate
+whether width, height or area should be considered when determining
+which is the largest single <structname>FBArea</structname> available.
+
+      <programlisting>
+  FAVOR_AREA_THEN_WIDTH
+  FAVOR_AREA_THEN_HEIGHT
+  FAVOR_WIDTH_THEN_AREA
+  FAVOR_HEIGHT_THEN_AREA
+      </programlisting>
+    </para>
+
+    <para>
+<parameter>priority</parameter> is one of the following:
+
+      <blockquote>
+	<para>
+  <constant>PRIORITY_LOW</constant>
+	  <blockquote><para>
+     Return the largest block available without stealing anyone else's
+     space.  This corresponds to the priority of allocating a
+     <structname>FBArea</structname> when a <function>RemoveAreaCallback</function>
+     is provided.
+	    </para></blockquote>
+	</para>
+
+	<para>
+   <constant>PRIORITY_NORMAL</constant>
+	  <blockquote><para>
+     Return the largest block available if it is acceptable to steal a
+     lower priority area from someone.  This corresponds to the priority
+     of allocating a <structname>FBArea</structname> without providing a
+     <function>RemoveAreaCallback</function>.
+	    </para></blockquote>
+	</para>
+
+	<para>
+    <constant>PRIORITY_EXTREME</constant>
+	  <blockquote><para>
+     Return the largest block available if all <structname>FBArea</structname>s
+     that aren't locked down were expunged from memory first.  This
+     corresponds to any allocation made directly after a call to
+     <function>xf86PurgeUnlockedOffscreenAreas()</function>.
+	    </para></blockquote>
+	</para>
+
+      </blockquote>
+    </para>
+
+
+    <para>
+The function:
+
+      <programlisting>
+    Bool xf86PurgeUnlockedOffscreenAreas(ScreenPtr pScreen);
+      </programlisting>
+
+is provided as an extreme method to free up offscreen memory.  This
+will remove all removable <structname>FBArea</structname> allocations.
+    </para>
+
+
+    <para>
+Initialization of the XFree86 framebuffer manager is done via
+
+      <programlisting>
+    Bool xf86InitFBManager(ScreenPtr pScreen, BoxPtr FullBox);
+      </programlisting>
+
+<parameter>FullBox</parameter> represents the area of the framebuffer that the
+manager is allowed to manage.  This is typically a box with a width of
+<structfield>pScrn->displayWidth</structfield> and a height of as many lines as
+can be fit within the total video memory, however, the driver can reserve
+areas at the extremities by passing a smaller area to the manager.
+    </para>
+
+    <para>
+<function>xf86InitFBManager()</function> must be called before XAA is
+initialized since XAA uses the manager for it's pixmap cache.
+    </para>
+
+    <para>
+An alternative function is provided to allow the driver to initialize
+the framebuffer manager with a Region rather than a box.
+
+    <programlisting>
+    Bool xf86InitFBManagerRegion(ScreenPtr pScreen,
+                                 RegionPtr FullRegion);
+    </programlisting>
+
+<function>xf86InitFBManagerRegion()</function>, unlike
+<function>xf86InitFBManager()</function>, does not remove the area used for
+the visible screen so that area should not be included in the region
+passed to the function.  <function>xf86InitFBManagerRegion()</function> is
+useful when non-contiguous areas are available to be managed, and is
+required when multiple framebuffers are stored in video memory (as in
+the case where an overlay of a different depth is stored as a second
+framebuffer in offscreen memory).
+    </para>
+
+  </sect1>
+
+  <sect1 id="cmap">
+    <title>Colormap Handling</title>
+
+    <para>
+A generic colormap handling layer is provided within the XFree86 common
+layer.  This layer takes care of most of the details, and only requires
+a function from the driver that loads the hardware palette when required.
+To use the colormap layer, a driver calls the
+<function>xf86HandleColormaps()</function> function.
+
+      <blockquote><para>
+	  <programlisting>
+    Bool xf86HandleColormaps(ScreenPtr pScreen, int maxColors,
+                             int sigRGBbits, LoadPaletteFuncPtr loadPalette,
+                             SetOverscanFuncPtr setOverscan,
+                             unsigned int flags);
+	  </programlisting>
+	  <blockquote><para>
+      This function must be called after the default colormap has been
+      initialised.  The <structfield>pScrn->gamma</structfield> field must also
+      be initialised, preferably by calling <function>xf86SetGamma()</function>.
+      <parameter>maxColors</parameter> is the number of entries in the palette.
+      <parameter>sigRGBbits</parameter> is the size in bits of each color
+      component in the DAC's palette.  <parameter>loadPalette</parameter>
+      is a driver-provided function for loading a colormap into the
+      hardware, and is described below.  <parameter>setOverscan</parameter> is
+      an optional function that may be provided when the overscan color
+      is an index from the standard LUT and when it needs to be adjusted
+      to keep it as close to black as possible.  The
+      <parameter>setOverscan</parameter> function programs the overscan index.
+      It shouldn't normally be used for depths other than 8.
+      <parameter>setOverscan</parameter> should be set to <constant>NULL</constant>
+      when it isn't needed.  <parameter>flags</parameter> may be set to the
+      following (which may be ORed together):
+
+	      <variablelist>
+		<varlistentry>
+		  <term><constant>CMAP_PALETTED_TRUECOLOR</constant></term>
+		  <listitem><para>
+				    the TrueColor visual is paletted and is
+				    just a special case of DirectColor.
+				    This flag is only valid for
+				    <code>bpp > 8</code>.
+
+		    </para></listitem></varlistentry>
+		<varlistentry>
+		  <term><constant>CMAP_RELOAD_ON_MODE_SWITCH</constant></term>
+		  <listitem><para>
+				    reload the colormap automatically
+                                    after mode switches.  This is useful
+                                    for when the driver is resetting the
+                                    hardware during mode switches and
+                                    corrupting or erasing the hardware
+                                    palette.
+
+		    </para></listitem></varlistentry>
+		<varlistentry>
+		  <term><constant>CMAP_LOAD_EVEN_IF_OFFSCREEN</constant></term>
+		  <listitem><para>
+				    reload the colormap even if the screen
+				    is switched out of the server's VC.
+				    The palette is <emphasis>not</emphasis> reloaded when
+				    the screen is switched back in, nor after
+				    mode switches.  This is useful when the
+				    driver needs to keep track of palette
+				    changes.
+
+		    </para></listitem></varlistentry>
+	      </variablelist>
+	    </para>
+
+	    <para>
+      The colormap layer normally reloads the palette after VT enters so it
+      is not necessary for the driver to save and restore the palette
+      when switching VTs.  The driver must, however, still save the
+      initial palette during server start up and restore it during
+      server exit.
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    void LoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices,
+                     LOCO *colors, VisualPtr pVisual);
+	  </programlisting>
+	  <blockquote><para>
+      <function>LoadPalette()</function> is a driver-provided function for
+      loading a colormap into hardware.  <parameter>colors</parameter> is the
+      array of RGB values that represent the full colormap.
+      <parameter>indices</parameter> is a list of index values into the colors
+      array.  These indices indicate the entries that need to be updated.
+      <parameter>numColors</parameter> is the number of the indices to be
+      updated.
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    void SetOverscan(ScrnInfoPtr pScrn, int overscan);
+	  </programlisting>
+	  <blockquote><para>
+      <function>SetOverscan()</function> is a driver-provided function for
+      programming the <parameter>overscan</parameter> index.  As described
+      above, it is normally only appropriate for LUT modes where all
+      colormap entries are available for the display, but where one of
+      them is also used for the overscan (typically 8bpp for VGA compatible
+      LUTs).  It isn't required in cases where the overscan area is
+      never visible.
+	    </para>
+
+	  </blockquote></para>
+      </blockquote></para>
+
+  </sect1>
+
+  <sect1>
+    <title>DPMS Extension</title>
+
+    <para>
+Support code for the DPMS extension is included in the XFree86 common layer.
+This code provides an interface between the main extension code, and a means
+for drivers to initialise DPMS when they support it.  One function is
+available to drivers to do this initialisation, and it is always available,
+even when the DPMS extension is not supported by the core server (in
+which case it returns a failure result).
+    </para>
+
+    <blockquote><para>
+	<programlisting>
+    Bool xf86DPMSInit(ScreenPtr pScreen, DPMSSetProcPtr set, int flags);
+	</programlisting>
+	<blockquote><para>
+      This function registers a driver's DPMS level programming function
+      <parameter>set</parameter>.  It also checks
+      <structfield>pScrn->options</structfield> for the "dpms" option, and when
+      present marks DPMS as being enabled for that screen.  The
+      <parameter>set</parameter> function is called whenever the DPMS level
+      changes, and is used to program the requested level.
+      <parameter>flags</parameter> is currently not used, and should be
+      <constant>0</constant>.  If the initialisation fails for any reason,
+      including when there is no DPMS support in the core server, the
+      function returns <constant>FALSE</constant>.
+	  </para>
+
+	</blockquote></para></blockquote>
+
+
+    <para>
+Drivers that implement DPMS support must provide the following function,
+that gets called when the DPMS level is changed:
+
+
+      <blockquote><para>
+	  <programlisting>
+    void ChipDPMSSet(ScrnInfoPtr pScrn, int level, int flags);
+	  </programlisting>
+	  <blockquote><para>
+      Program the DPMS level specified by <parameter>level</parameter>.  Valid
+      values of <parameter>level</parameter> are <constant>DPMSModeOn</constant>,
+      <constant>DPMSModeStandby</constant>, <constant>DPMSModeSuspend</constant>,
+      <constant>DPMSModeOff</constant>.  These values are defined in
+      <filename>"extensions/dpms.h"</filename>.
+	    </para>
+
+	  </blockquote></para></blockquote>
+    </para>
+
+  </sect1>
+
+  <sect1>
+    <title>DGA Extension</title>
+
+    <para>
+Drivers can support the XFree86 Direct Graphics Architecture (DGA) by
+filling out a structure of function pointers and a list of modes and
+passing them to DGAInit.
+    </para>
+
+    <blockquote><para>
+	<programlisting>
+    Bool DGAInit(ScreenPtr pScreen, DGAFunctionPtr funcs,
+                 DGAModePtr modes, int num);
+
+/** The DGAModeRec **/
+
+typedef struct {
+  int num;
+  DisplayModePtr mode;
+  int flags;
+  int imageWidth;
+  int imageHeight;
+  int pixmapWidth;
+  int pixmapHeight;
+  int bytesPerScanline;
+  int byteOrder;
+  int depth;
+  int bitsPerPixel;
+  unsigned long red_mask;
+  unsigned long green_mask;
+  unsigned long blue_mask;
+  int viewportWidth;
+  int viewportHeight;
+  int xViewportStep;
+  int yViewportStep;
+  int maxViewportX;
+  int maxViewportY;
+  int viewportFlags;
+  int offset;
+  unsigned char *address;
+  int reserved1;
+  int reserved2;
+} DGAModeRec, *DGAModePtr;
+	</programlisting>
+
+	<variablelist>
+	  <varlistentry>
+	    <term><structfield>num</structfield></term>
+	    <listitem><para>
+	 Can be ignored.  The DGA DDX will assign these numbers.
+	      </para></listitem></varlistentry>
+
+	  <varlistentry>
+	    <term><structfield>mode</structfield></term>
+	    <listitem><para>
+	A pointer to the <structname>DisplayModeRec</structname> for this mode.
+	      </para></listitem></varlistentry>
+
+	  <varlistentry>
+	    <term><structfield>flags</structfield></term>
+	      <listitem><para>
+	The following flags are defined and may be OR'd together:
+
+		  <variablelist>
+		    <varlistentry>
+		      <term><constant>DGA_CONCURRENT_ACCESS</constant></term>
+		      <listitem><para>
+            Indicates that the driver supports concurrent graphics
+            accelerator and linear framebuffer access.
+
+			</para></listitem></varlistentry>
+
+		    <varlistentry>
+		      <term><constant>DGA_FILL_RECT
+			  DGA_BLIT_RECT
+			  DGA_BLIT_RECT_TRANS</constant></term>
+		      <listitem><para>
+	    Indicates that the driver supports the FillRect, BlitRect
+            or BlitTransRect functions in this mode.
+
+			</para></listitem></varlistentry>
+
+		    <varlistentry>
+		      <term><constant>DGA_PIXMAP_AVAILABLE</constant></term>
+		      <listitem><para>
+	    Indicates that Xlib may be used on the framebuffer.
+            This flag will usually be set unless the driver wishes
+            to prohibit this for some reason.
+
+			</para></listitem></varlistentry>
+
+		    <varlistentry>
+		      <term><constant>DGA_INTERLACED
+			  DGA_DOUBLESCAN</constant></term>
+		      <listitem><para>
+            Indicates that these are interlaced or double scan modes.
+
+			</para></listitem></varlistentry>
+		  </variablelist>
+		</para></listitem></varlistentry>
+
+	  <varlistentry>
+	    <term><structfield>imageWidth
+		imageHeight</structfield></term>
+	    <listitem><para>
+		    These are the dimensions of the linear framebuffer
+                     accessible by the client.
+
+	      </para></listitem></varlistentry>
+
+	  <varlistentry>
+	    <term><structfield>pixmapWidth
+		pixmapHeight</structfield></term>
+	    <listitem><para>
+		     These are the dimensions of the area of the
+                     framebuffer accessible by the graphics accelerator.
+
+	      </para></listitem></varlistentry>
+
+	  <varlistentry>
+	    <term><structfield>bytesPerScanline</structfield></term>
+	    <listitem><para>
+		      Pitch of the framebuffer in bytes.
+
+	      </para></listitem></varlistentry>
+
+	  <varlistentry>
+	    <term><structfield>byteOrder</structfield></term>
+	    <listitem><para>
+		     Usually the same as
+		     <structfield>pScrn->imageByteOrder</structfield>.
+
+	      </para></listitem></varlistentry>
+
+	  <varlistentry>
+	    <term><structfield>depth</structfield></term>
+	    <listitem><para>
+		     The depth of the framebuffer in this mode.
+
+	      </para></listitem></varlistentry>
+
+	  <varlistentry>
+	    <term><structfield>bitsPerPixel</structfield></term>
+	    <listitem><para>
+		      The number of bits per pixel in this mode.
+
+	      </para></listitem></varlistentry>
+
+	  <varlistentry>
+	    <term><structfield>red_mask</structfield></term>
+	    <term><structfield>green_mask</structfield></term>
+	    <term><structfield>blue_mask</structfield></term>
+	    <listitem><para>
+		      The RGB masks for this mode, if applicable.
+
+	      </para></listitem></varlistentry>
+
+	  <varlistentry>
+	    <term><structfield>viewportWidth</structfield></term>
+	    <term><structfield>viewportHeight</structfield></term>
+	    <listitem><para>
+		      Dimensions of the visible part of the framebuffer.
+		      Usually <structfield>mode->HDisplay</structfield> and
+		      <structfield>mode->VDisplay</structfield>.
+
+	      </para></listitem></varlistentry>
+
+	  <varlistentry>
+	    <term><structfield>xViewportStep
+		yViewportStep</structfield></term>
+	    <listitem><para>
+		     The granularity of x and y viewport positions that
+                     the driver supports in this mode.
+
+	      </para></listitem></varlistentry>
+
+	  <varlistentry>
+	    <term><structfield>maxViewportX
+		maxViewportY</structfield></term>
+	    <listitem><para>
+		      The maximum viewport position supported by the
+                       driver in this mode.
+	      </para></listitem></varlistentry>
+
+	  <varlistentry>
+	    <term><structfield>viewportFlags</structfield></term>
+	    <listitem><para>
+		     The following may be OR'd together:
+
+		<variablelist>
+		  <varlistentry>
+		    <term><constant>DGA_FLIP_IMMEDIATE</constant></term>
+		    <listitem><para>
+		The driver supports immediate viewport changes.
+		      </para></listitem></varlistentry>
+
+		  <varlistentry>
+		    <term><constant>DGA_FLIP_RETRACE</constant></term>
+
+		    <listitem><para>
+		The driver supports viewport changes at retrace.
+		      </para></listitem></varlistentry>
+		  </variablelist>
+	      </para></listitem></varlistentry>
+
+	  <varlistentry>
+	    <term><structfield>offset</structfield></term>
+	    <listitem><para>
+	        The offset into the linear framebuffer that corresponds to
+                pixel (0,0) for this mode.
+	      </para></listitem></varlistentry>
+
+	  <varlistentry>
+	    <term><structfield>address</structfield></term>
+	    <listitem><para>
+                The virtual address of the framebuffer as mapped by the driver.
+                This is needed when DGA_PIXMAP_AVAILABLE is set.
+	      </para></listitem></varlistentry>
+
+	</variablelist>
+
+	<programlisting>
+/** The DGAFunctionRec **/
+
+typedef struct {
+  Bool (*OpenFramebuffer)(
+       ScrnInfoPtr pScrn,
+       char **name,
+       unsigned char **mem,
+       int *size,
+       int *offset,
+       int *extra
+  );
+  void (*CloseFramebuffer)(ScrnInfoPtr pScrn);
+  Bool (*SetMode)(ScrnInfoPtr pScrn, DGAModePtr pMode);
+  void (*SetViewport)(ScrnInfoPtr pScrn, int x, int y, int flags);
+  int  (*GetViewport)(ScrnInfoPtr pScrn);
+  void (*Sync)(ScrnInfoPtr);
+  void (*FillRect)(
+       ScrnInfoPtr pScrn,
+       int x, int y, int w, int h,
+       unsigned long color
+  );
+  void (*BlitRect)(
+       ScrnInfoPtr pScrn,
+       int srcx, int srcy,
+       int w, int h,
+       int dstx, int dsty
+  );
+  void (*BlitTransRect)(
+       ScrnInfoPtr pScrn,
+       int srcx, int srcy,
+       int w, int h,
+       int dstx, int dsty,
+       unsigned long color
+  );
+} DGAFunctionRec, *DGAFunctionPtr;
+	</programlisting>
+
+
+	<blockquote><para>
+	    <programlisting>
+    Bool OpenFramebuffer (pScrn, name, mem, size, offset, extra);
+	    </programlisting>
+	    <blockquote><para>
+      <function>OpenFramebuffer()</function> should pass the client everything
+      it needs to know to be able to open the framebuffer.  These
+      parameters are OS specific and their meanings are to be interpreted
+      by an OS specific client library.
+
+		<variablelist>
+		  <varlistentry>
+		    <term><parameter>name</parameter></term>
+		    <listitem><para>
+	      The name of the device to open or <constant>NULL</constant> if
+	      there is no special device to open.  A <constant>NULL</constant>
+	      name tells the client that it should open whatever device
+	      one would usually open to access physical memory.
+		      </para></listitem></varlistentry>
+
+		  <varlistentry>
+		    <term><parameter>mem</parameter></term>
+		    <listitem><para>
+	      The physical address of the start of the framebuffer.
+		      </para></listitem></varlistentry>
+
+		  <varlistentry>
+		    <term><parameter>size</parameter></term>
+		    <listitem><para>
+	      The size of the framebuffer in bytes.
+		      </para></listitem></varlistentry>
+
+		  <varlistentry>
+		    <term><parameter>offset</parameter></term>
+		    <listitem><para>
+	      Any offset into the device, if applicable.
+		      </para></listitem></varlistentry>
+
+		  <varlistentry>
+		    <term><parameter>flags</parameter></term>
+		    <listitem><para>
+	      Any additional information that the client may need.
+	      Currently, only the <constant>DGA_NEED_ROOT</constant> flag is
+	      defined.
+		      </para></listitem></varlistentry>
+
+		</variablelist>
+	      </para></blockquote>
+	  </para></blockquote>
+
+	<blockquote><para>
+	    <programlisting>
+    void CloseFramebuffer (pScrn);
+	    </programlisting>
+	    <blockquote><para>
+      <function>CloseFramebuffer()</function> merely informs the driver (if it
+      even cares) that client no longer needs to access the framebuffer
+      directly.  This function is optional.
+	      </para>
+
+	    </blockquote></para></blockquote>
+
+	<blockquote><para>
+	    <programlisting>
+    Bool SetMode (pScrn, pMode);
+	    </programlisting>
+	    <blockquote><para>
+      <function>SetMode()</function> tells the driver to initialize the mode
+      passed to it.  If <parameter>pMode</parameter> is <constant>NULL</constant>,
+      then the driver should restore the original pre-DGA mode.
+	      </para>
+
+	    </blockquote></para></blockquote>
+
+	<blockquote><para>
+	    <programlisting>
+    void SetViewport (pScrn, x, y, flags);
+	    </programlisting>
+	    <blockquote><para>
+      <function>SetViewport()</function> tells the driver to make the upper
+      left-hand corner of the visible screen correspond to coordinate
+      <literal remap="tt">(x,y)</literal> on the framebuffer.  <parameter>flags</parameter>
+      currently defined are:
+
+		<variablelist>
+		  <varlistentry>
+		    <term><constant>DGA_FLIP_IMMEDIATE</constant></term>
+		    <listitem><para>
+	    The viewport change should occur immediately.
+		      </para></listitem></varlistentry>
+
+		  <varlistentry>
+		    <term><constant>DGA_FLIP_RETRACE</constant></term>
+		    <listitem><para>
+	    The viewport change should occur at the
+            vertical retrace, but this function should
+            return sooner if possible.
+			</para></listitem></varlistentry>
+		</variablelist>
+	      </para>
+
+	      <para>
+      The <literal remap="tt">(x,y)</literal> locations will be passed as the client
+      specified them, however, the driver is expected to round these
+      locations down to the next supported location as specified by the
+      <structfield>xViewportStep</structfield> and <structfield>yViewportStep</structfield>
+      for the current mode.
+	      </para>
+	    </blockquote></para></blockquote>
+
+	<blockquote><para>
+	    <programlisting>
+    int GetViewport (pScrn);
+	    </programlisting>
+	    <blockquote><para>
+      <function>GetViewport()</function> gets the current page flip status.
+      Set bits in the returned int correspond to viewport change requests
+      still pending.  For instance, set bit zero if the last SetViewport
+      request is still pending, bit one if the one before that is still
+      pending, etc.
+	      </para>
+
+	    </blockquote></para></blockquote>
+
+	<blockquote><para>
+	    <programlisting>
+    void Sync (pScrn);
+	    </programlisting>
+	    <blockquote><para>
+      This function should ensure that any graphics accelerator operations
+      have finished.  This function should not return until the graphics
+      accelerator is idle.
+	      </para>
+
+	    </blockquote></para></blockquote>
+
+	<blockquote><para>
+	    <programlisting>
+    void FillRect (pScrn, x, y, w, h, color);
+	    </programlisting>
+	    <blockquote><para>
+      This optional function should fill a rectangle
+      <parameter>w × h</parameter> located at
+      <parameter>(x,y)</parameter> in the given color.
+	      </para>
+
+	    </blockquote></para></blockquote>
+
+	<blockquote><para>
+	    <programlisting>
+    void BlitRect (pScrn, srcx, srcy, w, h, dstx, dsty);
+	    </programlisting>
+	    <blockquote><para>
+      This optional function should copy an area
+      <parameter>w × h</parameter> located at
+      <parameter>(srcx,srcy)</parameter> to location <parameter>(dstx,dsty)</parameter>.
+      This function will need to handle copy directions as appropriate.
+	      </para>
+
+	    </blockquote></para></blockquote>
+
+	<blockquote><para>
+	    <programlisting>
+    void BlitTransRect (pScrn, srcx, srcy, w, h, dstx, dsty, color);
+	    </programlisting>
+	    <blockquote><para>
+      This optional function is the same as BlitRect except that pixels
+      in the source corresponding to the color key <parameter>color</parameter>
+      should be skipped.
+	      </para>
+
+	    </blockquote></para></blockquote>
+    </para></blockquote>
+
+  </sect1>
+
+  <sect1>
+    <title>The XFree86 X Video Extension (Xv) Device Dependent Layer</title>
+
+    <para>
+XFree86 offers the X Video Extension which allows clients to treat video
+as any another primitive and <quote>Put</quote> video into drawables.  By default,
+the extension reports no video adaptors as being available since the
+DDX layer has not been initialized.  The driver can initialize the DDX
+layer by filling out one or more <literal remap="tt">XF86VideoAdaptorRecs</literal>
+as described later in this document and passing a list of
+<literal remap="tt">XF86VideoAdaptorPtr</literal> pointers to the following function:
+
+      <programlisting>
+    Bool xf86XVScreenInit(ScreenPtr pScreen,
+                          XF86VideoAdaptorPtr *adaptPtrs,
+                          int num);
+      </programlisting>
+    </para>
+
+    <para>
+After doing this, the extension will report video adaptors as being
+available, providing the data in their respective
+<literal remap="tt">XF86VideoAdaptorRecs</literal> was valid.
+<function>xf86XVScreenInit()</function> <emphasis>copies</emphasis> data from the structure
+passed to it so the driver may free it after the initialization.  At
+the moment, the DDX only supports rendering into Window drawables.
+Pixmap rendering will be supported after a sufficient survey of suitable
+hardware is completed.
+    </para>
+
+    <para>
+The <structname>XF86VideoAdaptorRec</structname>:
+
+      <programlisting>
+typedef struct {
+	unsigned int type;
+	int flags;
+	char *name;
+	int nEncodings;
+	XF86VideoEncodingPtr pEncodings;
+	int nFormats;
+	XF86VideoFormatPtr pFormats;
+	int nPorts;
+	DevUnion *pPortPrivates;
+	int nAttributes;
+	XF86AttributePtr pAttributes;
+	int nImages;
+	XF86ImagePtr pImages;
+	PutVideoFuncPtr PutVideo;
+	PutStillFuncPtr PutStill;
+	GetVideoFuncPtr GetVideo;
+	GetStillFuncPtr GetStill;
+	StopVideoFuncPtr StopVideo;
+	SetPortAttributeFuncPtr SetPortAttribute;
+	GetPortAttributeFuncPtr GetPortAttribute;
+	QueryBestSizeFuncPtr QueryBestSize;
+	PutImageFuncPtr PutImage;
+	QueryImageAttributesFuncPtr QueryImageAttributes;
+} XF86VideoAdaptorRec, *XF86VideoAdaptorPtr;
+      </programlisting></para>
+
+    <para>
+Each adaptor will have its own XF86VideoAdaptorRec.  The fields are
+as follows:
+
+      <variablelist>
+	<varlistentry>
+	  <term><structfield>type</structfield></term>
+	  <listitem><para>
+	This can be any of the following flags OR'd together.
+
+	      <variablelist>
+		<varlistentry>
+		  <term><constant>XvInputMask</constant>
+		    <constant>XvOutputMask</constant></term>
+		  <listitem><para>
+	    These refer to the target drawable and are similar to a Window's
+	    class. <literal remap="tt">XvInputMask</literal> indicates that the adaptor
+	    can put video into a drawable.  <literal remap="tt">XvOutputMask</literal>
+	    indicates that the adaptor can get video from a drawable.
+		    </para></listitem></varlistentry>
+
+		<varlistentry>
+		  <term><constant>XvVideoMask</constant>
+		    <constant>XvStillMask</constant>
+		    <constant>XvImageMask</constant></term>
+		  <listitem><para>
+	    These indicate that the adaptor supports video, still or
+	    image primitives respectively.
+		    </para></listitem></varlistentry>
+
+		<varlistentry>
+		  <term><constant>XvWindowMask</constant>
+		    <constant>XvPixmapMask</constant></term>
+		  <listitem><para>
+	    These indicate the types of drawables the adaptor is capable
+	    of rendering into.  At the moment, Pixmap rendering is not
+	    supported and the <constant>XvPixmapMask</constant> flag is ignored.
+		    </para></listitem></varlistentry>
+	      </variablelist>
+
+	    </para></listitem></varlistentry>
+
+	<varlistentry>
+	  <term><structfield>flags</structfield></term>
+	  <listitem><para>
+	Currently, the following flags are defined:
+
+	      <variablelist>
+		<varlistentry>
+		  <term><constant>VIDEO_NO_CLIPPING</constant></term>
+		  <listitem><para>
+	   This indicates that the video adaptor does not support
+	   clipping.  The driver will never receive <quote>Put</quote> requests
+	   where less than the entire area determined by
+	   <parameter>drw_x</parameter>, <parameter>drw_y</parameter>,
+	   <parameter>drw_w</parameter> and <parameter>drw_h</parameter> is visible.
+	   This flag does not apply to <quote>Get</quote> requests.  Hardware
+	   that is incapable of clipping <quote>Gets</quote> may punt or get
+	   the extents of the clipping region passed to it.
+		    </para></listitem>
+
+		</varlistentry>
+
+		<varlistentry>
+		  <term><constant>VIDEO_INVERT_CLIPLIST</constant></term>
+		  <listitem><para>
+	   This indicates that the video driver requires the clip
+	   list to contain the regions which are obscured rather
+	   than the regions which are are visible.
+		    </para></listitem>
+
+		</varlistentry>
+
+		<varlistentry>
+		  <term><constant>VIDEO_OVERLAID_STILLS</constant></term>
+		  <listitem><para>
+	   Implementing PutStill for hardware that does video as an
+	   overlay can be awkward since it's unclear how long to leave
+	   the video up for.  When this flag is set, StopVideo will be
+	   called whenever the destination gets clipped or moved so that
+	   the still can be left up until then.
+		    </para></listitem>
+
+		</varlistentry>
+
+		<varlistentry>
+		  <term><constant>VIDEO_OVERLAID_IMAGES</constant></term>
+		  <listitem><para>
+	   Same as <constant>VIDEO_OVERLAID_STILLS</constant> but for images.
+		    </para></listitem>
+		</varlistentry>
+
+		<varlistentry>
+		  <term><constant>VIDEO_CLIP_TO_VIEWPORT</constant></term>
+		  <listitem><para>
+	    Indicates that the clip region passed to the driver functions
+	    should be clipped to the visible portion of the screen in the
+	    case where the viewport is smaller than the virtual desktop.
+		    </para></listitem></varlistentry>
+
+	      </variablelist>
+	    </para></listitem></varlistentry>
+
+	<varlistentry>
+	  <term><structfield>name</structfield></term>
+	  <listitem><para>
+	The name of the adaptor.
+	    </para></listitem></varlistentry>
+
+
+	<varlistentry>
+	  <term><structfield>nEncodings</structfield>
+	    <structfield>pEncodings</structfield></term>
+	  <listitem><para>
+	The number of encodings the adaptor is capable of and pointer
+	to the <structname>XF86VideoEncodingRec</structname> array.  The
+	<structname>XF86VideoEncodingRec</structname> is described later on.
+	For drivers that only support XvImages there should be an encoding
+	named "XV_IMAGE" and the width and height should specify
+	the maximum size source image supported.
+	  </para></listitem></varlistentry>
+
+
+	<varlistentry>
+	  <term><structfield>nFormats</structfield>
+	      <structfield>pFormats</structfield></term>
+	  <listitem><para>
+	The number of formats the adaptor is capable of and pointer to
+	the <structname>XF86VideoFormatRec</structname> array.  The
+	<structname>XF86VideoFormatRec</structname> is described later on.
+	    </para></listitem></varlistentry>
+
+
+	<varlistentry>
+	  <term><structfield>nPorts</structfield>
+	    <structfield>pPortPrivates</structfield></term>
+	  <listitem><para>
+	The number of ports is the number of separate data streams which
+	the adaptor can handle simultaneously.  If you have more than
+	one port, the adaptor is expected to be able to render into more
+	than one window at a time.  <structfield>pPortPrivates</structfield> is
+	an array of pointers or ints - one for each port.  A port's
+	private data will be passed to the driver any time the port is
+	requested to do something like put the video or stop the video.
+	In the case where there may be many ports, this enables the
+	driver to know which port the request is intended for.  Most
+	commonly, this will contain a pointer to the data structure
+	containing information about the port.  In Xv, all ports on
+	a particular adaptor are expected to be identical in their
+	functionality.
+	    </para></listitem></varlistentry>
+
+
+	<varlistentry>
+	  <term><structfield>nAttributes</structfield>
+	    <structfield>pAttributes</structfield></term>
+	  <listitem><para>
+	The number of attributes recognized by the adaptor and a pointer to
+	the array of <structname>XF86AttributeRecs</structname>.  The
+	<structname>XF86AttributeRec</structname> is described later on.
+	    </para></listitem></varlistentry>
+
+
+	<varlistentry>
+	  <term><structfield>nImages</structfield>
+	    <structfield>pImages</structfield></term>
+	  <listitem><para>
+	The number of <structname>XF86ImageRecs</structname> supported by the adaptor
+	and a pointer to the array of <structname>XF86ImageRecs</structname>. The
+	<structname>XF86ImageRec</structname> is described later on.
+	    </para></listitem></varlistentry>
+
+
+	<varlistentry>
+	  <term><structfield>
+     PutVideo PutStill GetVideo GetStill StopVideo
+     SetPortAttribute GetPortAttribute QueryBestSize PutImage
+     QueryImageAttributes
+	    </structfield></term>
+	  <listitem><para>
+	These functions define the DDX->driver interface.  In each
+	case, the pointer <parameter>data</parameter> is passed to the driver.
+	This is the port private for that port as described above.  All
+	fields are required except under the following conditions:
+
+	      <orderedlist>
+		<listitem><para>
+	     <structfield>PutVideo</structfield>, <structfield>PutStill</structfield> and
+	     the image routines <structfield>PutImage</structfield> and
+	     <structfield>QueryImageAttributes</structfield> are not required when the
+	     adaptor type does not contain <constant>XvInputMask</constant>.
+		  </para></listitem>
+
+		<listitem><para>
+	     <structfield>GetVideo</structfield> and <structfield>GetStill</structfield>
+	     are not required when the adaptor type does not contain
+	     <constant>XvOutputMask</constant>.
+		  </para></listitem>
+
+		<listitem><para>
+	     <structfield>GetVideo</structfield> and <structfield>PutVideo</structfield>
+	     are not required when the adaptor type does not contain
+	     <constant>XvVideoMask</constant>.
+		  </para></listitem>
+
+		<listitem><para>
+	     <structfield>GetStill</structfield> and <structfield>PutStill</structfield>
+	     are not required when the adaptor type does not contain
+	     <constant>XvStillMask</constant>.
+		  </para></listitem>
+
+		<listitem><para>
+	     <structfield>PutImage</structfield> and <structfield>QueryImageAttributes</structfield>
+	     are not required when the adaptor type does not contain
+	     <constant>XvImageMask</constant>.
+		  </para></listitem>
+
+	      </orderedlist>
+
+	    </para>
+
+	    <para>
+	With the exception of <structfield>QueryImageAttributes</structfield>, these
+	functions should return <constant>Success</constant> if the operation was
+	completed successfully.  They can return <constant>XvBadAlloc</constant>
+	otherwise. <structfield>QueryImageAttributes</structfield> returns the size
+	of the XvImage queried.
+	    </para>
+
+	    <para>
+	If the <constant>VIDEO_NO_CLIPPING</constant>
+	flag is set, the <literal remap="tt">clipBoxes</literal> may be ignored by
+	the driver.  <literal remap="tt">ClipBoxes</literal> is an <literal remap="tt">X-Y</literal>
+	banded region identical to those used throughout the server.
+	The clipBoxes represent the visible portions of the area determined
+	by <literal remap="tt">drw_x</literal>, <literal remap="tt">drw_y</literal>,
+	<literal remap="tt">drw_w</literal> and <literal remap="tt">drw_h</literal> in the Get/Put
+	function.  The boxes are in screen coordinates, are guaranteed
+	not to overlap and an empty region will never be passed.
+	If the driver has specified <constant>VIDEO_INVERT_CLIPLIST</constant>,
+	<literal remap="tt">clipBoxes</literal> will indicate the areas of the primitive
+	which are obscured rather than the areas visible.
+
+	    </para></listitem></varlistentry>
+      </variablelist>
+
+      <blockquote><para>
+	  <programlisting>
+    typedef  int (* PutVideoFuncPtr)( ScrnInfoPtr pScrn,
+                   short vid_x, short vid_y, short drw_x, short drw_y,
+                   short vid_w, short vid_h, short drw_w, short drw_h,
+                   RegionPtr clipBoxes, pointer data );
+	  </programlisting>
+	      <blockquote><para>
+	  This indicates that the driver should take a subsection
+	  <parameter>vid_w</parameter> by <parameter>vid_h</parameter> at location
+	  <parameter>(vid_x,vid_y)</parameter> from the video stream and direct
+	  it into the rectangle <parameter>drw_w</parameter> by <parameter>drw_h</parameter>
+	  at location <parameter>(drw_x,drw_y)</parameter> on the screen, scaling as
+	  necessary.  Due to the large variations in capabilities of
+	  the various hardware expected to be used with this extension,
+	  it is not expected that all hardware will be able to do this
+	  exactly as described.  In that case the driver should just do
+	  <quote>the best it can,</quote> scaling as closely to the target rectangle
+	  as it can without rendering outside of it.  In the worst case,
+	  the driver can opt to just not turn on the video.
+	      </para>
+
+	    </blockquote></para></blockquote>
+
+	  <blockquote><para>
+	      <programlisting>
+    typedef  int (* PutStillFuncPtr)( ScrnInfoPtr pScrn,
+                   short vid_x, short vid_y, short drw_x, short drw_y,
+                   short vid_w, short vid_h, short drw_w, short drw_h,
+                   RegionPtr clipBoxes, pointer data );
+	      </programlisting>
+	      <blockquote><para>
+	  This is same as <structfield>PutVideo</structfield> except that the driver
+	  should place only one frame from the stream on the screen.
+	      </para>
+
+	    </blockquote></para></blockquote>
+
+	  <blockquote><para>
+	      <programlisting>
+    typedef int (* GetVideoFuncPtr)( ScrnInfoPtr pScrn,
+                  short vid_x, short vid_y, short drw_x, short drw_y,
+                  short vid_w, short vid_h, short drw_w, short drw_h,
+                  RegionPtr clipBoxes, pointer data );
+	      </programlisting>
+	      <blockquote><para>
+	  This is same as <structfield>PutVideo</structfield> except that the driver
+	  gets video from the screen and outputs it.  The driver should
+	  do the best it can to get the requested dimensions correct
+	  without reading from an area larger than requested.
+	      </para>
+
+	    </blockquote></para></blockquote>
+
+	  <blockquote><para>
+	      <programlisting>
+    typedef int (* GetStillFuncPtr)( ScrnInfoPtr pScrn,
+                  short vid_x, short vid_y, short drw_x, short drw_y,
+                  short vid_w, short vid_h, short drw_w, short drw_h,
+                  RegionPtr clipBoxes, pointer data );
+	      </programlisting>
+	      <blockquote><para>
+	  This is the same as <literal remap="tt">GetVideo</literal> except that the
+	  driver should place only one frame from the screen into the
+	  output stream.
+	      </para>
+
+	    </blockquote></para></blockquote>
+
+	  <blockquote><para>
+	      <programlisting>
+    typedef void (* StopVideoFuncPtr)(ScrnInfoPtr pScrn,
+                                      pointer data, Bool cleanup);
+	      </programlisting>
+	      <blockquote><para>
+	  This indicates the driver should stop displaying the video.
+	  This is used to stop both input and output video.  The
+	  <parameter>cleanup</parameter> field indicates that the video is
+	  being stopped because the client requested it to stop or
+	  because the server is exiting the current VT.  In that case
+	  the driver should deallocate any offscreen memory areas (if
+	  there are any) being used to put the video to the screen.  If
+	  <parameter>cleanup</parameter> is not set, the video is being stopped
+	  temporarily due to clipping or moving of the window, etc...
+	  and video will likely be restarted soon so the driver should
+	  not deallocate any offscreen areas associated with that port.
+	      </para>
+
+	    </blockquote></para></blockquote>
+	  <blockquote><para>
+	      <programlisting>
+    typedef int (* SetPortAttributeFuncPtr)(ScrnInfoPtr pScrn,
+                                Atom attribute,INT32 value, pointer data);
+	      </programlisting>
+
+	      <programlisting>
+    typedef int (* GetPortAttributeFuncPtr)(ScrnInfoPtr pScrn,
+                                Atom attribute,INT32 *value, pointer data);
+	      </programlisting>
+	      <blockquote><para>
+	  A port may have particular attributes such as hue,
+	  saturation, brightness or contrast.  Xv clients set and
+	  get these attribute values by sending attribute strings
+	  (Atoms) to the server.  Such requests end up at these
+	  driver functions.  It is recommended that the driver provide
+	  at least the following attributes mentioned in the Xv client
+	  library docs:
+		<literallayout><constant>
+		XV_ENCODING
+		XV_HUE
+		XV_SATURATION
+		XV_BRIGHTNESS
+		XV_CONTRAST
+		  </constant></literallayout>
+	  but the driver may recognize as many atoms as it wishes.  If
+	  a requested attribute is unknown by the driver it should return
+	  <constant>BadMatch</constant>.  <constant>XV_ENCODING</constant> is the
+	  attribute intended to let the client specify which video
+	  encoding the particular port should be using (see the description
+	  of <structname>XF86VideoEncodingRec</structname> below).  If the
+	  requested encoding is unsupported, the driver should return
+	  <constant>XvBadEncoding</constant>.  If the value lies outside the
+	  advertised range <constant>BadValue</constant> may be returned.
+	  <constant>Success</constant> should be returned otherwise.
+	      </para>
+
+	    </blockquote></para></blockquote>
+
+	  <blockquote><para>
+	    <programlisting>
+    typedef void (* QueryBestSizeFuncPtr)(ScrnInfoPtr pScrn,
+                   Bool motion, short vid_w, short vid_h,
+                   short drw_w, short drw_h,
+                   unsigned int *p_w, unsigned int *p_h, pointer data);
+	    </programlisting>
+	    <blockquote><para>
+	   <function>QueryBestSize</function> provides the client with a way
+	   to query what the destination dimensions would end up being
+	   if they were to request that an area
+	   <parameter>vid_w</parameter> by <parameter>vid_h</parameter> from the video
+	   stream be scaled to rectangle of
+	   <parameter>drw_w</parameter> by <parameter>drw_h</parameter> on the screen.
+	   Since it is not expected that all hardware will be able to
+	   get the target dimensions exactly, it is important that the
+	   driver provide this function.
+	      </para>
+
+	    </blockquote></para></blockquote>
+
+	<blockquote><para>
+	    <programlisting>
+    typedef  int (* PutImageFuncPtr)( ScrnInfoPtr pScrn,
+                   short src_x, short src_y, short drw_x, short drw_y,
+                   short src_w, short src_h, short drw_w, short drw_h,
+                   int image, char *buf, short width, short height,
+                   Bool sync, RegionPtr clipBoxes, pointer data );
+	      </programlisting>
+	      <blockquote><para>
+	  This is similar to <structfield>PutStill</structfield> except that the
+	  source of the video is not a port but the data stored in a system
+	  memory buffer at <parameter>buf</parameter>.  The data is in the format
+	  indicated by the <parameter>image</parameter> descriptor and represents a
+	  source of size <parameter>width</parameter> by <parameter>height</parameter>.
+	  If <parameter>sync</parameter> is TRUE the driver should not return
+	  from this function until it is through reading the data
+	  from <parameter>buf</parameter>.  Returning when <parameter>sync</parameter>
+	  is TRUE indicates that it is safe for the data at <parameter>buf</parameter>
+	  to be replaced, freed, or modified.
+	      </para>
+
+	    </blockquote></para></blockquote>
+
+	<blockquote><para>
+	    <programlisting>
+    typedef  int (* QueryImageAttributesFuncPtr)( ScrnInfoPtr pScrn,
+                                int image, short *width, short *height,
+                                int *pitches, int *offsets);
+	    </programlisting>
+	    <blockquote><para>
+	  This function is called to let the driver specify how data for
+	  a particular <parameter>image</parameter> of size <parameter>width</parameter>
+	  by <parameter>height</parameter> should be stored.  Sometimes only
+	  the size and corrected width and height are needed.  In that
+	  case <parameter>pitches</parameter> and <parameter>offsets</parameter> are
+	  NULL.  The size of the memory required for the image is returned
+	  by this function.  The <parameter>width</parameter> and
+	  <parameter>height</parameter> of the requested image can be altered by
+	  the driver to reflect format limitations (such as component
+	  sampling periods that are larger than one).  If
+	  <parameter>pitches</parameter> and <parameter>offsets</parameter> are not NULL,
+	  these will be arrays with as many elements in them as there
+	  are planes in the <parameter>image</parameter> format.  The driver
+	  should specify the pitch (in bytes) of each scanline in the
+	  particular plane as well as the offset to that plane (in bytes)
+	  from the beginning of the image.
+	      </para>
+
+	  </blockquote></para></blockquote>
+    </para>
+
+    <para>
+The XF86VideoEncodingRec:
+
+      <blockquote><para>
+	  <programlisting>
+typedef struct {
+	int id;
+	char *name;
+	unsigned short width, height;
+	XvRationalRec rate;
+} XF86VideoEncodingRec, *XF86VideoEncodingPtr;
+
+	  </programlisting>
+	  <blockquote><para>
+   The <structname>XF86VideoEncodingRec</structname> specifies what encodings
+   the adaptor can support.  Most of this data is just informational
+   and for the client's benefit, and is what will be reported by
+   <function>XvQueryEncodings</function>.  The <parameter>id</parameter> field is
+   expected to be a unique identifier to allow the client to request a
+   certain encoding via the <constant>XV_ENCODING</constant> attribute string.
+
+	    </para>
+	  </blockquote></para></blockquote>
+    </para>
+
+    <para>
+The XF86VideoFormatRec:
+
+      <blockquote><para>
+	  <programlisting>
+typedef struct {
+	char  depth;
+	short class;
+} XF86VideoFormatRec, *XF86VideoFormatPtr;
+
+	  </programlisting>
+	  <blockquote><para>
+    This specifies what visuals the video is viewable in.
+    <parameter>depth</parameter> is the depth of the visual (not bpp).
+    <parameter>class</parameter> is the visual class such as
+    <constant>TrueColor</constant>, <constant>DirectColor</constant> or
+    <constant>PseudoColor</constant>.  Initialization of an adaptor will fail
+    if none of the visuals on that screen are supported.
+	    </para>
+
+	  </blockquote></para></blockquote>
+    </para>
+
+    <para>
+The XF86AttributeRec:
+
+      <blockquote><para>
+	  <programlisting>
+typedef struct {
+	int   flags;
+	int   min_value;
+	int   max_value;
+	char  *name;
+} XF86AttributeListRec, *XF86AttributeListPtr;
+
+	  </programlisting>
+	  <blockquote><para>
+   Each adaptor may have an array of these advertising the attributes
+   for its ports.  Currently defined flags are <literal remap="tt">XvGettable</literal>
+   and <literal remap="tt">XvSettable</literal> which may be OR'd together indicating that
+   attribute is <quote>gettable</quote> or <quote>settable</quote> by the client.  The
+   <literal remap="tt">min</literal> and <literal remap="tt">max</literal> field specify the valid range
+   for the value.  <literal remap="tt">Name</literal> is a text string describing the
+   attribute by name.
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+    </para>
+
+    <para>
+The XF86ImageRec:
+
+	<blockquote><para>
+	    <programlisting>
+typedef struct {
+	int id;
+	int type;
+	int byte_order;
+	char guid[16];
+	int bits_per_pixel;
+	int format;
+	int num_planes;
+
+	/* for RGB formats */
+	int depth;
+	unsigned int red_mask;
+	unsigned int green_mask;
+	unsigned int blue_mask;
+
+	/* for YUV formats */
+	unsigned int y_sample_bits;
+	unsigned int u_sample_bits;
+	unsigned int v_sample_bits;
+	unsigned int horz_y_period;
+	unsigned int horz_u_period;
+	unsigned int horz_v_period;
+	unsigned int vert_y_period;
+	unsigned int vert_u_period;
+	unsigned int vert_v_period;
+	char component_order[32];
+	int scanline_order;
+} XF86ImageRec, *XF86ImagePtr;
+
+	    </programlisting>
+	    <blockquote><para>
+   XF86ImageRec describes how video source data is laid out in memory.
+   The fields are as follows:
+
+		<variablelist>
+		  <varlistentry>
+		    <term><structfield>id</structfield></term>
+		    <listitem><para>
+	This is a unique descriptor for the format.  It is often good to
+        set this value to the FOURCC for the format when applicable.
+		      </para></listitem></varlistentry>
+
+		  <varlistentry>
+		    <term><structfield>type</structfield></term>
+		    <listitem><para>
+	This is <constant>XvRGB</constant> or <constant>XvYUV</constant>.
+		      </para></listitem></varlistentry>
+
+		  <varlistentry>
+		    <term><structfield>byte_order</structfield></term>
+		    <listitem><para>
+	This is <constant>LSBFirst</constant> or <constant>MSBFirst</constant>.
+		      </para></listitem></varlistentry>
+
+		  <varlistentry>
+		    <term><structfield>guid</structfield></term>
+		    <listitem><para>
+	This is the Globally Unique IDentifier for the format.  When
+	not applicable, all characters should be NULL.
+		      </para></listitem></varlistentry>
+
+		  <varlistentry>
+		    <term><structfield>bits_per_pixel</structfield></term>
+		    <listitem><para>
+	The number of bits taken up (but not necessarily used) by each
+	pixel.  Note that for some planar formats which have fractional
+	bits per pixel (such as IF09) this number may be rounded _down_.
+		      </para></listitem></varlistentry>
+
+		  <varlistentry>
+		    <term><structfield>format</structfield></term>
+		    <listitem><para>
+	This is <constant>XvPlanar</constant> or <constant>XvPacked</constant>.
+		      </para></listitem></varlistentry>
+
+		  <varlistentry>
+		    <term><structfield>num_planes</structfield></term>
+		    <listitem><para>
+	The number of planes in planar formats.  This should be set to
+	one for packed formats.
+		      </para></listitem></varlistentry>
+
+		  <varlistentry>
+		    <term><structfield>depth</structfield></term>
+		    <listitem><para>
+	The significant bits per pixel in RGB formats (analgous to the
+	depth of a pixmap format).
+		      </para></listitem></varlistentry>
+
+		  <varlistentry>
+		    <term><structfield>red_mask</structfield></term>
+		    <term><structfield>green_mask</structfield></term>
+		    <term><structfield>blue_mask</structfield></term>
+		    <listitem><para>
+	The red, green and blue bitmasks for packed RGB formats.
+		      </para></listitem></varlistentry>
+
+		  <varlistentry>
+		    <term><structfield>y_sample_bits</structfield></term>
+		    <term><structfield>u_sample_bits</structfield></term>
+		    <term><structfield>v_sample_bits</structfield></term>
+		    <listitem><para>
+	The y, u and v sample sizes (in bits).
+		      </para></listitem></varlistentry>
+
+		  <varlistentry>
+		    <term><structfield>horz_y_period</structfield></term>
+		    <term><structfield>horz_u_period</structfield></term>
+		    <term><structfield>horz_v_period</structfield></term>
+		    <listitem><para>
+	The y, u and v sampling periods in the horizontal direction.
+		      </para></listitem></varlistentry>
+
+		  <varlistentry>
+		    <term><structfield>vert_y_period</structfield></term>
+		    <term><structfield>vert_u_period</structfield></term>
+		    <term><structfield>vert_v_period</structfield></term>
+		    <listitem><para>
+	The y, u and v sampling periods in the vertical direction.
+		      </para></listitem></varlistentry>
+
+		  <varlistentry>
+		    <term><structfield>component_order</structfield></term>
+		    <listitem><para>
+	Uppercase ascii characters representing the order that
+	samples are stored within packed formats.  For planar formats
+	this represents the ordering of the planes.  Unused characters
+	in the 32 byte string should be set to NULL.
+		      </para></listitem></varlistentry>
+
+		  <varlistentry>
+		    <term><structfield>scanline_order</structfield></term>
+		    <listitem><para>
+	This is <constant>XvTopToBottom</constant> or <constant>XvBottomToTop</constant>.
+		      </para></listitem></varlistentry>
+
+		  </variablelist>
+	    </para>
+
+	    <para>
+  Since some formats (particular some planar YUV formats) may not
+be completely defined by the parameters above, the guid, when
+available, should provide the most accurate description of the
+format.
+	    </para>
+
+	  </blockquote></para></blockquote>
+    </para>
+  </sect1>
+
+  <sect1>
+    <title>The Loader</title>
+
+    <para>
+This section describes the interfaces to the module loader.  The loader
+interfaces can be divided into two groups: those that are only available to
+the XFree86 common layer, and those that are also available to modules.
+    </para>
+
+    <sect2>
+      <title>Loader Overview</title>
+
+      <para>
+The loader is capable of loading modules in a range of object formats,
+and knowledge of these formats is built in to the loader.  Knowledge of
+new object formats can be added to the loader in a straightforward
+manner.  This makes it possible to provide OS-independent modules (for
+a given CPU architecture type).  In addition to this, the loader can
+load modules via the OS-provided <function>dlopen(3)</function> service where
+available.  Such modules are not platform independent, and the semantics
+of <function>dlopen()</function> on most systems results in significant
+limitations in the use of modules of this type.  Support for
+<function>dlopen()</function> modules in the loader is primarily for
+experimental and development purposes.
+      </para>
+
+      <para>
+Symbols exported by the loader (on behalf of the core X server) to
+modules are determined at compile time.  Only those symbols explicitly
+exported are available to modules.  All external symbols of loaded
+modules are exported to other modules, and to the core X server.  The
+loader can be requested to check for unresolved symbols at any time,
+and the action to be taken for unresolved symbols can be controlled by
+the caller of the loader.  Typically the caller identifies which symbols
+can safely remain unresolved and which cannot.
+      </para>
+
+      <para>
+NOTE:  Now that ISO-C allows pointers to functions and pointers to data to
+have different internal representations, some of the following interfaces
+will need to be revisited.
+      </para>
+    </sect2>
+
+    <sect2>
+      <title>Semi-private Loader Interface</title>
+
+      <para>
+The following is the semi-private loader interface that is available to the
+XFree86 common layer.
+      </para>
+
+      <blockquote><para>
+	  <programlisting>
+    void LoaderInit(void);
+	  </programlisting>
+	  <blockquote><para>
+    The <function>LoaderInit()</function> function initialises the loader,
+    and it must be called once before calling any other loader functions.
+    This function initialises the tables of exported symbols, and anything
+    else that might need to be initialised.
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    void LoaderSetPath(const char *path);
+	  </programlisting>
+	  <blockquote><para>
+    The <function>LoaderSetPath()</function> function initialises a default
+    module search path.  This must be called if calls to other functions
+    are to be made without explicitly specifying a module search path.
+    The search path <parameter>path</parameter> must be a string of one or more
+    comma separated absolute paths.  Modules are expected to be located
+    below these paths, possibly in subdirectories of these paths.
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    pointer LoadModule(const char *module, const char *path,
+                       const char **subdirlist, const char **patternlist,
+                       pointer options, const XF86ModReqInfo * modreq,
+                       int *errmaj, int *errmin);
+	  </programlisting>
+	  <blockquote><para>
+    The <function>LoadModule()</function> function loads the module called
+    <parameter>module</parameter>.  The return value is a module handle, and
+    may be used in future calls to the loader that require a reference
+    to a loaded module.  The module name <parameter>module</parameter> is
+    normally the module's canonical name, which doesn't contain any
+    directory path information, or any object/library file prefixes of
+    suffixes.  Currently a full pathname and/or filename is also accepted.
+    This might change.  The other parameters are:
+
+	      <variablelist>
+		<varlistentry>
+		  <term><parameter>path</parameter></term>
+		  <listitem><para>
+		  An optional comma-separated list of module search paths.
+		  When <constant>NULL</constant>, the default search path is used.
+		    </para></listitem></varlistentry>
+
+
+		<varlistentry>
+		  <term><parameter>subdirlist</parameter></term>
+		  <listitem><para>
+		  An optional <constant>NULL</constant> terminated list of
+		  subdirectories to search.  When <constant>NULL</constant>,
+		  the default built-in list is used (refer to
+		  <varname>stdSubdirs</varname> in <filename>loadmod.c</filename>).
+		  The default list is also substituted for entries in
+		  <parameter>subdirlist</parameter> with the value
+		  <constant>DEFAULT_LIST</constant>.  This makes is possible
+		  to augment the default list instead of replacing it.
+		  Subdir elements must be relative, and must not contain
+		  <literal remap="tt">".."</literal>.  If any violate this requirement,
+		  the load fails.
+		    </para></listitem></varlistentry>
+
+
+		<varlistentry>
+		  <term><parameter>patternlist</parameter></term>
+		  <listitem><para>
+		  An optional <constant>NULL</constant> terminated list of
+		  POSIX regular expressions used to connect module
+		  filenames with canonical module names.  Each regex
+		  should contain exactly one subexpression that corresponds
+		  to the canonical module name.  When <constant>NULL</constant>,
+		  the default built-in list is used (refer to
+		  <varname>stdPatterns</varname> in
+		  <filename>loadmod.c</filename>).  The default list is also
+		  substituted for entries in <parameter>patternlist</parameter>
+		  with the value <constant>DEFAULT_LIST</constant>.  This
+		  makes it possible to augment the default list instead
+		  of replacing it.
+		    </para></listitem></varlistentry>
+
+
+		<varlistentry>
+		  <term><parameter>options</parameter></term>
+		  <listitem><para>
+		  An optional parameter that is passed to the newly
+		  loaded module's <literal remap="tt">SetupProc</literal> function
+		  (if it has one).  This argument is normally a
+		  <constant>NULL</constant> terminated list of
+		  <structname>Options</structname>, and must be interpreted that
+		  way by modules loaded directly by the XFree86 common
+		  layer.  However, it may be used for application-specific
+		  parameter passing in other situations.
+		    </para>
+
+		    <para>
+		  When loading <quote>external</quote> modules (modules that don't
+		  have the standard entry point, for example a
+		  special shared library) the options parameter can be
+		  set to <constant>EXTERN_MODULE</constant> to tell the
+		  loader not to reject the module when it doesn't find
+		  the standard entry point.
+		    </para></listitem></varlistentry>
+
+
+		<varlistentry>
+		  <term><parameter>modreq</parameter></term>
+		  <listitem><para>
+		  An optional <structname>XF86ModReqInfo*</structname> containing
+		  version/ABI/vendor information to requirements to
+		  check the newly loaded module against.  The main
+		  purpose of this is to allow the loader to verify that
+		  a module of the correct type/version before running
+		  its <function>SetupProc</function> function.
+		      </para>
+
+		    <para>
+		  The <literal remap="tt">XF86ModReqInfo</literal> struct is defined
+		  as follows:
+		      <programlisting>
+typedef struct {
+	CARD8        majorversion;  /* MAJOR_UNSPEC */
+	CARD8        minorversion;  /* MINOR_UNSPEC */
+	CARD16       patchlevel;    /* PATCH_UNSPEC */
+	const char * abiclass;      /* ABI_CLASS_NONE */
+	CARD32       abiversion;    /* ABI_VERS_UNSPEC */
+	const char * moduleclass;   /* MOD_CLASS_NONE */
+} XF86ModReqInfo;
+			</programlisting>
+
+		  The information here is compared against the equivalent
+		  information in the module's
+		  <structname>XF86ModuleVersionInfo</structname> record (which
+		  is described below).  The values in comments above
+		  indicate <quote>don't care</quote> settings for each of the fields.
+		  The comparisons made are as follows:
+
+		      <variablelist>
+			<varlistentry>
+			  <term><structfield>majorversion</structfield></term>
+			  <listitem><para>
+				   Must match the module's majorversion
+				   exactly.
+			    </para></listitem></varlistentry>
+
+			<varlistentry>
+			  <term><structfield>minorversion</structfield></term>
+			  <listitem><para>
+				   The module's minor version must be
+				   no less than this value.  This
+				   comparison is only made if
+				   <structfield>majorversion</structfield> is
+				   specified and matches.
+			    </para></listitem></varlistentry>
+
+			<varlistentry>
+			  <term><structfield>patchlevel</structfield></term>
+			  <listitem><para>
+				   The module's patchlevel must be no
+				   less than this value.  This comparison
+				   is only made if
+				   <structfield>minorversion</structfield> is
+				   specified and matches.
+			    </para></listitem></varlistentry>
+
+			<varlistentry>
+			  <term><structfield>abiclass</structfield></term>
+			  <listitem><para>
+				   String must match the module's abiclass
+				   string.
+			    </para></listitem></varlistentry>
+
+			<varlistentry>
+			  <term><structfield>abiversion</structfield></term>
+			  <listitem><para>
+				   Must be consistent with the module's
+				   abiversion (major equal, minor no
+				   older).
+			    </para></listitem></varlistentry>
+
+			<varlistentry>
+			  <term><structfield>moduleclass</structfield></term>
+			  <listitem><para>
+				   String must match the module's
+				   moduleclass string.
+			    </para></listitem></varlistentry>
+
+		      </variablelist>
+		    </para></listitem></varlistentry>
+
+		<varlistentry>
+		  <term><parameter>errmaj</parameter></term>
+		  <listitem><para>
+		  An optional pointer to a variable holding the major
+		  part or the error code.  When provided,
+		  <parameter>*errmaj</parameter> is filled in when
+		  <function>LoadModule()</function> fails.
+		    </para></listitem></varlistentry>
+
+		<varlistentry>
+		  <term><parameter>errmin</parameter></term>
+		  <listitem><para>
+		  Like <parameter>errmaj</parameter>, but for the minor part
+		  of the error code.
+		    </para></listitem></varlistentry>
+
+	      </variablelist>
+
+	    </para></blockquote>
+	</para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    void UnloadModule(pointer mod);
+	  </programlisting>
+	  <blockquote><para>
+    This function unloads the module referred to by the handle mod.
+    All child modules are also unloaded recursively.  This function must
+    not be used to directly unload modules that are child modules (i.e.,
+    those that have been loaded with the <function>LoadSubModule()</function>
+    described below).
+	    </para>
+
+	  </blockquote></para></blockquote>
+    </sect2>
+
+    <sect2>
+      <title>Module Requirements</title>
+
+      <para>
+Modules must provide information about themselves to the loader, and
+may optionally provide entry points for "setup" and "teardown" functions
+(those two functions are referred to here as <function>SetupProc</function>
+and <function>TearDownProc</function>).
+      </para>
+
+      <para>
+The module information is contained in the
+<structname>XF86ModuleVersionInfo</structname> struct, which is defined as follows:
+
+	<programlisting>
+typedef struct {
+    const char * modname;      /* name of module, e.g. "foo" */
+    const char * vendor;       /* vendor specific string */
+    CARD32       _modinfo1_;   /* constant MODINFOSTRING1/2 to find */
+    CARD32       _modinfo2_;   /* infoarea with a binary editor/sign tool */
+    CARD32       xf86version;  /* contains XF86_VERSION_CURRENT */
+    CARD8        majorversion; /* module-specific major version */
+    CARD8        minorversion; /* module-specific minor version */
+    CARD16       patchlevel;   /* module-specific patch level */
+    const char * abiclass;     /* ABI class that the module uses */
+    CARD32       abiversion;   /* ABI version */
+    const char * moduleclass;  /* module class */
+    CARD32       checksum[4];  /* contains a digital signature of the */
+                               /* version info structure */
+} XF86ModuleVersionInfo;
+	</programlisting>
+
+The fields are used as follows:
+
+	<variablelist>
+	  <varlistentry>
+	    <term><structfield>modname</structfield></term>
+	    <listitem><para>
+		The module's name.  This field is currently only for
+		informational purposes, but the loader may be modified
+		in future to require it to match the module's canonical
+                name.
+	      </para></listitem></varlistentry>
+
+
+	  <varlistentry>
+	    <term><structfield>vendor</structfield></term>
+	    <listitem><para>
+		The module vendor.  This field is for informational purposes
+                only.
+	      </para></listitem></varlistentry>
+
+
+	  <varlistentry>
+	    <term><structfield>_modinfo1_</structfield></term>
+	    <listitem><para>
+		This field holds the first part of a signature that can
+                be used to locate this structure in the binary.  It should
+		always be initialised to <constant>MODINFOSTRING1</constant>.
+	      </para></listitem></varlistentry>
+
+
+	  <varlistentry>
+	    <term><structfield>_modinfo2_</structfield></term>
+	    <listitem><para>
+		This field holds the second part of a signature that can
+                be used to locate this structure in the binary.  It should
+		always be initialised to <constant>MODINFOSTRING2</constant>.
+	      </para></listitem></varlistentry>
+
+
+	  <varlistentry>
+	    <term><structfield>xf86version</structfield></term>
+	    <listitem><para>
+		The XFree86 version against which the module was compiled.
+                This is mostly for informational/diagnostic purposes.  It
+		should be initialised to <constant>XF86_VERSION_CURRENT</constant>, which is
+		defined in <filename>xf86Version.h</filename>.
+	      </para></listitem></varlistentry>
+
+
+	  <varlistentry>
+	    <term><structfield>majorversion</structfield></term>
+	    <listitem><para>
+		The module-specific major version.  For modules where this
+		version is used for more than simply informational
+		purposes, the major version should only change (be
+		incremented) when ABI incompatibilities are introduced,
+		or ABI components are removed.
+	      </para></listitem></varlistentry>
+
+
+	  <varlistentry>
+	    <term><structfield>minorversion</structfield></term>
+	    <listitem><para>
+		The module-specific minor version.  For modules where this
+		version is used for more than simply informational
+		purposes, the minor version should only change (be
+		incremented) when ABI additions are made in a backward
+		compatible way.  It should be reset to zero when the major
+                version is increased.
+	      </para></listitem></varlistentry>
+
+
+	  <varlistentry>
+	    <term><structfield>patchlevel</structfield></term>
+	    <listitem><para>
+		The module-specific patch level.  The patch level should
+		increase with new revisions of the module where there
+		are no ABI changes, and it should be reset to zero when
+		the minor version is increased.
+	      </para></listitem></varlistentry>
+
+
+	  <varlistentry>
+	    <term><structfield>abiclass</structfield></term>
+	    <listitem><para>
+		The ABI class that the module requires.  The class is
+                specified as a string for easy extensibility.  It should
+		indicate which (if any) of the X server's built-in ABI
+		classes that the module relies on, or a third-party ABI
+                if appropriate.  Built-in ABI classes currently defined are:
+
+		<variablelist>
+		  <varlistentry>
+		    <term><constant>ABI_CLASS_NONE</constant></term>
+		    <listitem><para>no class
+		      </para></listitem></varlistentry>
+		  <varlistentry>
+		    <term><constant>ABI_CLASS_ANSIC</constant></term>
+		    <listitem><para>only requires the ANSI C interfaces
+		      </para></listitem></varlistentry>
+		  <varlistentry>
+		    <term><constant>ABI_CLASS_VIDEODRV</constant></term>
+		    <listitem><para>requires the video driver ABI
+		      </para></listitem></varlistentry>
+		  <varlistentry>
+		    <term><constant>ABI_CLASS_XINPUT</constant></term>
+		    <listitem><para>requires the XInput driver ABI
+		      </para></listitem></varlistentry>
+		  <varlistentry>
+		    <term><constant>ABI_CLASS_EXTENSION</constant></term>
+		    <listitem><para>requires the extension module ABI
+		      </para></listitem></varlistentry>
+		  <varlistentry>
+		    <term><constant>ABI_CLASS_FONT</constant></term>
+		    <listitem><para>requires the font module ABI
+		      </para></listitem></varlistentry>
+		</variablelist>
+
+	      </para></listitem></varlistentry>
+
+	  <varlistentry>
+	    <term><structfield>abiversion</structfield></term>
+	    <listitem><para>
+		The version of abiclass that the module requires.  The
+		version consists of major and minor components.  The
+		major version must match and the minor version must be
+		no newer than that provided by the server or parent
+		module.  Version identifiers for the built-in classes
+		currently defined are:
+
+		<literallayout><constant>
+                   ABI_ANSIC_VERSION
+                   ABI_VIDEODRV_VERSION
+                   ABI_XINPUT_VERSION
+                   ABI_EXTENSION_VERSION
+                   ABI_FONT_VERSION
+		  </constant></literallayout>
+
+	      </para></listitem></varlistentry>
+
+	  <varlistentry>
+	    <term><structfield>moduleclass</structfield></term>
+	    <listitem><para>
+		This is similar to the abiclass field, except that it
+		defines the type of module rather than the ABI it
+		requires.  For example, although all video drivers require
+		the video driver ABI, not all modules that require the
+		video driver ABI are video drivers.  This distinction
+		can be made with the moduleclass.  Currently pre-defined
+		module classes are:
+
+		<literallayout><constant>
+                   MOD_CLASS_NONE
+                   MOD_CLASS_VIDEODRV
+                   MOD_CLASS_XINPUT
+                   MOD_CLASS_FONT
+                   MOD_CLASS_EXTENSION
+		  </constant></literallayout>
+
+	      </para></listitem></varlistentry>
+
+	  <varlistentry>
+	    <term><structfield>checksum</structfield></term>
+	    <listitem><para>
+		Not currently used.
+	      </para></listitem></varlistentry>
+
+	</variablelist>
+      </para>
+
+      <para>
+The module version information, and the optional <function>SetupProc</function>
+and <function>TearDownProc</function> entry points are found by the loader
+by locating a data object in the module called "modnameModuleData",
+where "modname" is the canonical name of the module.  Modules must
+contain such a data object, and it must be declared with global scope,
+be compile-time initialised, and is of the following type:
+
+	<programlisting>
+typedef struct {
+    XF86ModuleVersionInfo *     vers;
+    ModuleSetupProc             setup;
+    ModuleTearDownProc          teardown;
+} XF86ModuleData;
+	</programlisting>
+      </para>
+
+      <para>
+The vers parameter must be initialised to a pointer to a correctly
+initialised <structname>XF86ModuleVersionInfo</structname> struct.  The other
+two parameter are optional, and should be initialised to
+<constant>NULL</constant> when not required.  The other parameters are defined
+as
+
+	<blockquote><para>
+	    <programlisting>
+    typedef pointer (*ModuleSetupProc)(pointer, pointer, int *, int *);
+
+    typedef void (*ModuleTearDownProc)(pointer);
+
+    pointer SetupProc(pointer module, pointer options,
+                      int *errmaj, int *errmin);
+	    </programlisting>
+	    <blockquote><para>
+    When defined, this function is called by the loader after successfully
+    loading a module.  module is a handle for the newly loaded module,
+    and maybe used by the <function>SetupProc</function> if it calls other
+    loader functions that require a reference to it.   The remaining
+    arguments are those that were passed to the
+    <function>LoadModule()</function> (or <function>LoadSubModule()</function>),
+    and are described above. When the <function>SetupProc</function> is
+    successful it must return a non-<constant>NULL</constant> value.  The
+    loader checks this, and if it is <constant>NULL</constant> it unloads
+    the module and reports the failure to the caller of
+    <function>LoadModule()</function>.  If the <function>SetupProc</function>
+    does things that need to be undone when the module is unloaded,
+    it should define a <function>TearDownProc</function>, and return a
+    pointer that the <function>TearDownProc</function> can use to undo what
+    has been done.
+	      </para>
+
+	      <para>
+    When a module is loaded multiple times, the <function>SetupProc</function>
+    is called once for each time it is loaded.
+	      </para>
+
+	    </blockquote></para></blockquote>
+
+	<blockquote><para>
+	    <programlisting>
+    void TearDownProc(pointer tearDownData);
+	    </programlisting>
+	    <blockquote><para>
+    When defined, this function is called when the loader unloads a
+    module.  The <parameter>tearDownData</parameter> parameter is the return
+    value of the <function>SetupProc()</function> that was called when the
+    module was loaded.  The purpose of this function is to clean up
+    before the module is unloaded (for example, by freeing allocated
+    resources).
+	      </para>
+
+	    </blockquote></para></blockquote>
+      </para>
+    </sect2>
+
+    <sect2>
+      <title>Public Loader Interface</title>
+
+      <para>
+The following is the Loader interface that is available to any part of
+the server, and may also be used from within modules.
+      </para>
+
+      <blockquote><para>
+	  <programlisting>
+    pointer LoadSubModule(pointer parent, const char *module,
+                          const char **subdirlist, const char **patternlist,
+                          pointer options, const XF86ModReqInfo * modreq,
+                          int *errmaj, int *errmin);
+	  </programlisting>
+	  <blockquote><para>
+    This function is like the <function>LoadModule()</function> function
+    described above, except that the module loaded is registered as a
+    child of the calling module.  The <parameter>parent</parameter> parameter
+    is the calling module's handle.  Modules loaded with this function
+    are automatically unloaded when the parent module is unloaded.  The
+    other difference is that the path parameter may not be specified.
+    The module search path used for modules loaded with this function
+    is the default search path as initialised with
+    <function>LoaderSetPath()</function>.
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    void UnloadSubModule(pointer module);
+	  </programlisting>
+	  <blockquote><para>
+    This function unloads the module with handle <parameter>module</parameter>.
+    If that module itself has children, they are also unloaded.  It is
+    like <function>UnloadModule()</function>, except that it is safe to use
+    for unloading child modules.
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    pointer LoaderSymbol(const char *symbol);
+	  </programlisting>
+	<blockquote><para>
+    This function returns the address of the symbol with name
+    <parameter>symbol</parameter>.  This may be used to locate a module entry
+    point with a known name.
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    char **LoaderlistDirs(const char **subdirlist,
+                          const char **patternlist);
+	  </programlisting>
+	  <blockquote><para>
+    This function returns a <constant>NULL</constant> terminated list of
+    canonical modules names for modules found in the default module
+    search path.  The <parameter>subdirlist</parameter> and
+    <parameter>patternlist</parameter> parameters are as described above, and
+    can be used to control the locations and names that are searched.
+    If no modules are found, the return value is <constant>NULL</constant>.
+    The returned list should be freed by calling
+    <function>LoaderFreeDirList()</function> when it is no longer needed.
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    void LoaderFreeDirList(char **list);
+	  </programlisting>
+	  <blockquote><para>
+    This function frees a module list created by
+    <function>LoaderlistDirs()</function>.
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    void LoaderReqSymLists(const char **list0, ...);
+	  </programlisting>
+	  <blockquote><para>
+    This function allows the registration of required symbols with the
+    loader.  It is normally used by a caller of
+    <function>LoadSubModule()</function>.  If any symbols registered in this
+    way are found to be unresolved when
+    <function>LoaderCheckUnresolved()</function> is called then
+    <function>LoaderCheckUnresolved()</function> will report a failure.
+    The function takes one or more <constant>NULL</constant> terminated
+    lists of symbols.  The end of the argument list is indicated by a
+    <constant>NULL</constant> argument.
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    void LoaderReqSymbols(const char *sym0, ...);
+	  </programlisting>
+	<blockquote><para>
+    This function is like <function>LoaderReqSymLists()</function> except
+    that its arguments are symbols rather than lists of symbols.  This
+    function is more convenient when single functions are to be registered,
+    especially when the single function might depend on runtime factors.
+    The end of the argument list is indicated by a <constant>NULL</constant>
+    argument.
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    void LoaderRefSymLists(const char **list0, ...);
+	  </programlisting>
+	  <blockquote><para>
+    This function allows the registration of possibly unresolved symbols
+    with the loader.  When <function>LoaderCheckUnresolved()</function> is
+    run it won't generate warnings for symbols registered in this way
+    unless they were also registered as required symbols.
+    The function takes one or more <constant>NULL</constant> terminated
+    lists of symbols.  The end of the argument list is indicated by a
+    <constant>NULL</constant> argument.
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    void LoaderRefSymbols(const char *sym0, ...);
+	  </programlisting>
+	  <blockquote><para>
+    This function is like <function>LoaderRefSymLists()</function> except
+    that its arguments are symbols rather than lists of symbols.  This
+    function is more convenient when single functions are to be registered,
+    especially when the single function might depend on runtime factors.
+    The end of the argument list is indicated by a <constant>NULL</constant>
+    argument.
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    int LoaderCheckUnresolved(int delayflag);
+	  </programlisting>
+	  <blockquote><para>
+    This function checks for unresolved symbols.  It generates warnings
+    for unresolved symbols that have not been registered with
+    <function>LoaderRefSymLists()</function>, and maps them to a dummy
+    function.  This behaviour may change in future.  If unresolved
+    symbols are found that have been registered with
+    <function>LoaderReqSymLists()</function> or
+    <function>LoaderReqSymbols()</function> then this function returns a
+    non-zero value.  If none of these symbols are unresolved the return
+    value is zero, indicating success.
+	    </para>
+
+	    <para>
+    The <parameter>delayflag</parameter> parameter should normally be set to
+    <constant>LD_RESOLV_IFDONE</constant>.
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    LoaderErrorMsg(const char *name, const char *modname,
+                   int errmaj, int errmin);
+	  </programlisting>
+	  <blockquote><para>
+    This function prints an error message that includes the text <quote>Failed
+    to load module</quote>, the module name <parameter>modname</parameter>, a message
+    specific to the <parameter>errmaj</parameter> value, and the value if
+    <parameter>errmin</parameter>.  If <parameter>name</parameter> is
+    non-<constant>NULL</constant>, it is printed as an identifying prefix
+    to the message (followed by a <quote>:</quote>).
+	    </para>
+
+	  </blockquote></para></blockquote>
+    </sect2>
+
+    <sect2>
+      <title>Special Registration Functions</title>
+
+      <para>
+The loader contains some functions for registering some classes of modules.
+These may be moved out of the loader at some point.
+      </para>
+
+      <blockquote><para>
+	  <programlisting>
+    void LoadExtension(ExtensionModule *ext);
+	  </programlisting>
+	  <blockquote><para>
+    This registers the entry points for the extension identified by
+    <parameter>ext</parameter>.  The <structname>ExtensionModule</structname> struct is
+    defined as:
+
+	      <programlisting>
+typedef struct {
+    InitExtension       initFunc;
+    char *              name;
+    Bool                *disablePtr;
+    InitExtension       setupFunc;
+} ExtensionModule;
+	      </programlisting>
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    void LoadFont(FontModule *font);
+	  </programlisting>
+	  <blockquote><para>
+    This registers the entry points for the font rasteriser module
+    identified by <parameter>font</parameter>.  The <structname>FontModule</structname>
+    struct is defined as:
+
+	      <programlisting>
+ typedef struct {
+    InitFont    initFunc;
+    char *      name;
+    pointer     module;
+} FontModule;
+	      </programlisting>
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+    </sect2>
+
+  </sect1>
+
+  <sect1>
+    <title>Helper Functions</title>
+
+    <para>
+This section describe <quote>helper</quote> functions that video driver
+might find useful.  While video drivers are not required to use any of
+these to be considered <quote>compliant</quote>, the use of appropriate helpers is
+strongly encouraged to improve the consistency of driver behaviour.
+    </para>
+
+    <sect2>
+      <title>Functions for printing messages</title>
+
+      <blockquote><para>
+	  <programlisting>
+    ErrorF(const char *format, ...);
+	  </programlisting>
+	  <blockquote><para>
+      This is the basic function for writing to the error log (typically
+      stderr and/or a log file).  Video drivers should usually avoid
+      using this directly in favour of the more specialised functions
+      described below.  This function is useful for printing messages
+      while debugging a driver.
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    FatalError(const char *format, ...);
+	  </programlisting>
+	  <blockquote><para>
+      This prints a message and causes the Xserver to abort.  It should
+      rarely be used within a video driver, as most error conditions
+      should be flagged by the return values of the driver functions.
+      This allows the higher layers to decide how to proceed.  In rare
+      cases, this can be used within a driver if a fatal unexpected
+      condition is found.
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    xf86ErrorF(const char *format, ...);
+	  </programlisting>
+	  <blockquote><para>
+      This is like <function>ErrorF()</function>, except that the message is
+      only printed when the Xserver's verbosity level is set to the
+      default (<constant>1</constant>) or higher.  It means that the messages
+      are not printed when the server is started with the
+      <option>-quiet</option> flag.  Typically this function would only be
+      used for continuing messages started with one of the more specialised
+      functions described below.
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    xf86ErrorFVerb(int verb, const char *format, ...);
+	  </programlisting>
+	  <blockquote><para>
+      Like <function>xf86ErrorF()</function>, except the minimum verbosity
+      level for which the message is to be printed is given explicitly.
+      Passing a <parameter>verb</parameter> value of zero means the message
+      is always printed.  A value higher than <constant>1</constant> can be
+      used for information would normally not be needed, but which might
+      be useful when diagnosing problems.
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+
+      <blockquote><para>
+	  <programlisting>
+    xf86Msg(MessageType type, const char *format, ...);
+	  </programlisting>
+	  <blockquote><para>
+      This is like <function>xf86ErrorF()</function>, except that the message
+      is prefixed with a marker determined by the value of
+      <parameter>type</parameter>.  The marker is used to indicate the type of
+      message (warning, error, probed value, config value, etc).  Note
+      the <varname>xf86Verbose</varname> value is ignored for messages of
+      type <constant>X_ERROR</constant>.
+	    </para>
+
+	    <para>
+      The marker values are:
+
+	      <variablelist>
+		<varlistentry>
+		  <term><constant>X_PROBED</constant></term>
+		  <listitem><para>Value was probed.
+		    </para></listitem></varlistentry>
+		<varlistentry>
+		  <term><constant>X_CONFIG</constant></term>
+		  <listitem><para>Value was given in the config file.
+		    </para></listitem></varlistentry>
+		<varlistentry>
+		  <term><constant>X_DEFAULT</constant></term>
+		  <listitem><para>Value is a default.
+		    </para></listitem></varlistentry>
+		<varlistentry>
+		  <term><constant>X_CMDLINE</constant></term>
+		  <listitem><para>Value was given on the command line.
+		    </para></listitem></varlistentry>
+		<varlistentry>
+		  <term><constant>X_NOTICE</constant></term>
+		  <listitem><para>Notice.
+		    </para></listitem></varlistentry>
+		<varlistentry>
+		  <term><constant>X_ERROR</constant></term>
+		  <listitem><para>Error message.
+		    </para></listitem></varlistentry>
+		<varlistentry>
+		  <term><constant>X_WARNING</constant></term>
+		  <listitem><para>Warning message.
+		    </para></listitem></varlistentry>
+		<varlistentry>
+		  <term><constant>X_INFO</constant></term>
+		  <listitem><para>Informational message.
+		    </para></listitem></varlistentry>
+		<varlistentry>
+		  <term><constant>X_NONE</constant></term>
+		  <listitem><para>No prefix.
+		    </para></listitem></varlistentry>
+		<varlistentry>
+		  <term><constant>X_NOT_IMPLEMENTED</constant></term>
+		  <listitem><para>The message relates to functionality
+		      that is not yetimplemented.
+		    </para></listitem></varlistentry>
+		</variablelist>
+
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    xf86MsgVerb(MessageType type, int verb, const char *format, ...);
+	  </programlisting>
+	  <blockquote><para>
+      Like <function>xf86Msg()</function>, but with the verbosity level given
+      explicitly.
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    xf86DrvMsg(int scrnIndex, MessageType type, const char *format, ...);
+	  </programlisting>
+	  <blockquote><para>
+      This is like <function>xf86Msg()</function> except that the driver's
+      name (the <structfield>name</structfield> field of the
+      <structname>ScrnInfoRec</structname>) followed by the
+      <parameter>scrnIndex</parameter> in parentheses is printed following the
+      prefix.  This should be used by video drivers in most cases as it
+      clearly indicates which driver/screen the message is for.  If
+      <parameter>scrnIndex</parameter> is negative, this function behaves
+      exactly like <function>xf86Msg()</function>.
+	    </para>
+
+	    <para>
+      NOTE: This function can only be used after the
+      <structname>ScrnInfoRec</structname> and its <structfield>name</structfield> field
+      have been allocated.  Normally, this means that it can not be
+      used before the END of the <function>ChipProbe()</function> function.
+      Prior to that, use <function>xf86Msg()</function>, providing the
+      driver's name explicitly.  No screen number can be supplied at
+      that point.
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    xf86DrvMsgVerb(int scrnIndex, MessageType type, int verb,
+                                const char *format, ...);
+	  </programlisting>
+	  <blockquote><para>
+      Like <function>xf86DrvMsg()</function>, but with the verbosity level
+      given explicitly.
+	    </para>
+
+	  </blockquote></para></blockquote>
+    </sect2>
+
+
+    <sect2>
+      <title>Functions for setting values based on command line and config file</title>
+
+      <blockquote><para>
+	  <programlisting>
+    Bool xf86SetDepthBpp(ScrnInfoPtr scrp, int depth, int bpp,
+
+                                int fbbpp, int depth24flags);
+	  </programlisting>
+	  <blockquote><para>
+      This function sets the <structfield>depth</structfield>, <structfield>pixmapBPP</structfield> and <structfield>bitsPerPixel</structfield> fields
+      of the <structname>ScrnInfoRec</structname>.  It also determines the defaults for display-wide
+      attributes and pixmap formats the screen will support, and finds
+      the Display subsection that matches the depth/bpp.  This function
+      should normally be called very early from the
+      <function>ChipPreInit()</function> function.
+	    </para>
+
+	    <para>
+      It requires that the <structfield>confScreen</structfield> field of the <structname>ScrnInfoRec</structname> be
+      initialised prior to calling it.  This is done by the XFree86
+      common layer prior to calling <function>ChipPreInit()</function>.
+	    </para>
+
+	    <para>
+      The parameters passed are:
+
+	      <variablelist>
+		<varlistentry>
+		  <term><parameter>depth</parameter></term>
+		  <listitem><para>
+		driver's preferred default depth if no other is given.
+                If zero, use the overall server default.
+		    </para></listitem></varlistentry>
+
+		<varlistentry>
+		  <term><parameter>bpp</parameter></term>
+		  <listitem><para>
+		Same, but for the pixmap bpp.
+		    </para></listitem></varlistentry>
+
+		<varlistentry>
+		  <term><parameter>fbbpp</parameter></term>
+		  <listitem><para>
+		Same, but for the framebuffer bpp.
+		    </para></listitem></varlistentry>
+
+		<varlistentry>
+		  <term><parameter>depth24flags</parameter></term>
+		  <listitem><para>
+		Flags that indicate the level of 24/32bpp support
+                and whether conversion between different framebuffer
+                and pixmap formats is supported.  The flags for this
+                argument are defined as follows, and multiple flags
+                may be ORed together:
+
+		      <variablelist>
+			<varlistentry>
+			  <term><constant>NoDepth24Support</constant></term>
+			  <listitem><para>No depth 24 formats supported
+			    </para></listitem></varlistentry>
+			<varlistentry>
+			  <term><constant>Support24bppFb</constant></term>
+			  <listitem><para>24bpp framebuffer supported
+			    </para></listitem></varlistentry>
+			<varlistentry>
+			  <term><constant>Support32bppFb</constant></term>
+			  <listitem><para>32bpp framebuffer supported
+			    </para></listitem></varlistentry>
+			<varlistentry>
+			  <term><constant>SupportConvert24to32</constant></term>
+			  <listitem><para>Can convert 24bpp pixmap to 32bpp fb
+			    </para></listitem></varlistentry>
+			<varlistentry>
+			  <term><constant>SupportConvert32to24</constant></term>
+			  <listitem><para>Can convert 32bpp pixmap to 24bpp fb
+			    </para></listitem></varlistentry>
+			<varlistentry>
+			  <term><constant>ForceConvert24to32</constant></term>
+			  <listitem><para>Force 24bpp pixmap to 32bpp fb conversion
+			    </para></listitem></varlistentry>
+			<varlistentry>
+			  <term><constant>ForceConvert32to24</constant></term>
+			  <listitem><para>Force 32bpp pixmap to 24bpp fb conversion
+			    </para></listitem></varlistentry>
+		      </variablelist>
+		    </para></listitem></varlistentry>
+
+	      </variablelist>
+	    </para>
+
+	    <para>
+      It uses the command line, config file, and default values in the
+      correct order of precedence to determine the depth and bpp values.
+      It is up to the driver to check the results to see that it supports
+      them.  If not the <function>ChipPreInit()</function> function should
+      return <constant>FALSE</constant>.
+	    </para>
+
+	    <para>
+      If only one of depth/bpp is given, the other is set to a reasonable
+      (and consistent) default.
+	    </para>
+
+	    <para>
+      If a driver finds that the initial <parameter>depth24flags</parameter>
+      it uses later results in a fb format that requires more video
+      memory than is available it may call this function a second time
+      with a different <parameter>depth24flags</parameter> setting.
+	    </para>
+
+	    <para>
+      On success, the return value is <constant>TRUE</constant>.  On failure
+      it prints an error message and returns <constant>FALSE</constant>.
+	    </para>
+
+	    <para>
+      The following fields of the <structname>ScrnInfoRec</structname> are
+      initialised by this function:
+
+	      <blockquote><para>
+<structfield>depth</structfield>, <structfield>bitsPerPixel</structfield>,
+<structfield>display</structfield>, <structfield>imageByteOrder</structfield>,
+<structfield>bitmapScanlinePad</structfield>,
+<structfield>bitmapScanlineUnit</structfield>, <structfield>bitmapBitOrder</structfield>,
+<structfield>numFormats</structfield>, <structfield>formats</structfield>,
+<structfield>fbFormat</structfield>.
+		</para></blockquote>
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    void xf86PrintDepthBpp(scrnInfoPtr scrp);
+	  </programlisting>
+	  <blockquote><para>
+      This function can be used to print out the depth and bpp settings.
+      It should be called after the final call to
+      <function>xf86SetDepthBpp()</function>.
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    Bool xf86SetWeight(ScrnInfoPtr scrp, rgb weight, rgb mask);
+	  </programlisting>
+	  <blockquote><para>
+      This function sets the <structfield>weight</structfield>, <structfield>mask</structfield>,
+      <structfield>offset</structfield> and <structfield>rgbBits</structfield> fields of the
+      <structname>ScrnInfoRec</structname>.  It would normally be called fairly
+      early in the <function>ChipPreInit()</function> function for
+      depths > 8bpp.
+	    </para>
+
+	    <para>
+      It requires that the <structfield>depth</structfield> and
+      <structfield>display</structfield> fields of the <structname>ScrnInfoRec</structname>
+      be initialised prior to calling it.
+	    </para>
+
+	    <para>
+      The parameters passed are:
+
+	      <variablelist>
+		<varlistentry>
+		  <term><parameter>weight</parameter></term>
+		  <listitem><para>
+		driver's preferred default weight if no other is given.
+                If zero, use the overall server default.
+
+		    </para></listitem></varlistentry>
+
+		<varlistentry>
+		  <term><parameter>mask</parameter></term>
+		  <listitem><para>
+		Same, but for mask.
+
+		    </para></listitem></varlistentry>
+	      </variablelist>
+	    </para>
+
+	    <para>
+      It uses the command line, config file, and default values in the
+      correct order of precedence to determine the weight value.  It
+      derives the mask and offset values from the weight and the defaults.
+      It is up to the driver to check the results to see that it supports
+      them.  If not the <function>ChipPreInit()</function> function should
+      return <constant>FALSE</constant>.
+	    </para>
+
+	    <para>
+      On success, this function prints a message showing the weight
+      values selected, and returns <constant>TRUE</constant>.
+	    </para>
+
+	    <para>
+      On failure it prints an error message and returns <constant>FALSE</constant>.
+	    </para>
+
+	    <para>
+      The following fields of the <structname>ScrnInfoRec</structname> are
+      initialised by this function:
+
+	      <blockquote><para>
+		  <structfield>weight</structfield>,
+		  <structfield>mask</structfield>,
+		  <structfield>offset</structfield>.
+		</para></blockquote>
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    Bool xf86SetDefaultVisual(ScrnInfoPtr scrp, int visual);
+	  </programlisting>
+	  <blockquote><para>
+      This function sets the <structfield>defaultVisual</structfield> field of the
+      <structname>ScrnInfoRec</structname>.  It would normally be called fairly
+      early from the <function>ChipPreInit()</function> function.
+	    </para>
+
+	    <para>
+      It requires that the <structfield>depth</structfield> and
+      <structfield>display</structfield> fields of the <structname>ScrnInfoRec</structname>
+      be initialised prior to calling it.
+	    </para>
+
+	    <para>
+      The parameters passed are:
+
+	      <variablelist>
+		<varlistentry>
+		  <term><parameter>visual</parameter></term>
+		  <listitem><para>
+		driver's preferred default visual if no other is given.
+		If <constant>-1</constant>, use the overall server default.
+		    </para></listitem></varlistentry>
+
+	      </variablelist>
+	    </para>
+
+	    <para>
+      It uses the command line, config file, and default values in the
+      correct order of precedence to determine the default visual value.
+      It is up to the driver to check the result to see that it supports
+      it.  If not the <function>ChipPreInit()</function> function should
+      return <constant>FALSE</constant>.
+	    </para>
+
+	    <para>
+      On success, this function prints a message showing the default visual
+      selected, and returns <constant>TRUE</constant>.
+	    </para>
+
+	    <para>
+      On failure it prints an error message and returns <constant>FALSE</constant>.
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    Bool xf86SetGamma(ScrnInfoPtr scrp, Gamma gamma);
+	  </programlisting>
+	  <blockquote><para>
+      This function sets the <structfield>gamma</structfield> field of the
+      <structname>ScrnInfoRec</structname>.  It would normally be called fairly
+      early from the <function>ChipPreInit()</function> function in cases
+      where the driver supports gamma correction.
+	    </para>
+
+	    <para>
+      It requires that the <structfield>monitor</structfield> field of the
+      <structname>ScrnInfoRec</structname> be initialised prior to calling it.
+	    </para>
+
+	    <para>
+      The parameters passed are:
+
+	      <variablelist>
+		<varlistentry>
+		  <term><parameter>gamma</parameter></term>
+		  <listitem><para>
+		driver's preferred default gamma if no other is given.
+		If zero (<code>< 0.01</code>), use the overall server
+		default.
+		    </para></listitem></varlistentry>
+
+	      </variablelist>
+	    </para>
+
+	    <para>
+      It uses the command line, config file, and default values in the
+      correct order of precedence to determine the gamma value.  It is
+      up to the driver to check the results to see that it supports
+      them.  If not the <function>ChipPreInit()</function> function should
+      return <constant>FALSE</constant>.
+	    </para>
+
+	    <para>
+      On success, this function prints a message showing the gamma
+      value selected, and returns <constant>TRUE</constant>.
+	    </para>
+
+	    <para>
+      On failure it prints an error message and returns <constant>FALSE</constant>.
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+
+      <blockquote><para>
+	  <programlisting>
+    void xf86SetDpi(ScrnInfoPtr pScrn, int x, int y);
+	  </programlisting>
+	  <blockquote><para>
+      This function sets the <structfield>xDpi</structfield> and <structfield>yDpi</structfield>
+      fields of the <structname>ScrnInfoRec</structname>.  The driver can specify
+      preferred defaults by setting <parameter>x</parameter> and <parameter>y</parameter>
+      to non-zero values.  The <option>-dpi</option> command line option
+      overrides all other settings.  Otherwise, if the
+      <emphasis>DisplaySize</emphasis> entry is present in the screen's &k.monitor;
+      config file section, it is used together with the virtual size to
+      calculate the dpi values.  This function should be called after
+      all the mode resolution has been done.
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    void xf86SetBlackWhitePixels(ScrnInfoPtr pScrn);
+	  </programlisting>
+	  <blockquote><para>
+      This functions sets the <structfield>blackPixel</structfield> and
+      <structfield>whitePixel</structfield> fields of the <structname>ScrnInfoRec</structname>
+      according to whether or not the <option>-flipPixels</option> command
+      line options is present.
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    const char *xf86GetVisualName(int visual);
+	  </programlisting>
+	  <blockquote><para>
+      Returns a printable string with the visual name matching the
+      numerical visual class provided.  If the value is outside the
+      range of valid visual classes, <constant>NULL</constant> is returned.
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+    </sect2>
+
+    <sect2>
+      <title>Primary Mode functions</title>
+
+      <para>
+The primary mode helper functions are those which would normally be
+used by a driver, unless it has unusual requirements which cannot
+be catered for the by the helpers.
+      </para>
+
+      <blockquote><para>
+	  <programlisting>
+    int xf86ValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes,
+                          char **modeNames, ClockRangePtr clockRanges,
+                          int *linePitches, int minPitch, int maxPitch,
+                          int pitchInc, int minHeight, int maxHeight,
+                          int virtualX, int virtualY,
+                          unsigned long apertureSize,
+                          LookupModeFlags strategy);
+	  </programlisting>
+	  <blockquote><para>
+      This function basically selects the set of modes to use based on
+      those available and the various constraints.  It also sets some
+      other related parameters.  It is normally called near the end of
+      the <function>ChipPreInit()</function> function.
+	    </para>
+
+	    <para>
+      The parameters passed to the function are:
+
+	      <variablelist>
+		<varlistentry>
+		  <term><parameter>availModes</parameter></term>
+		  <listitem><para>
+		List of modes available for the monitor.
+		    </para></listitem></varlistentry>
+
+		<varlistentry>
+		  <term><parameter>modeNames</parameter></term>
+		  <listitem><para>
+		List of mode names that the screen is requesting.
+		    </para></listitem></varlistentry>
+
+		<varlistentry>
+		  <term><parameter>clockRanges</parameter></term>
+		  <listitem><para>
+		A list of clock ranges allowed by the driver.  Each
+		range includes whether interlaced or multiscan modes
+		are supported for that range.  See below for more on
+		<parameter>clockRanges</parameter>.
+		    </para></listitem></varlistentry>
+
+		<varlistentry>
+		  <term><parameter>linePitches</parameter></term>
+		  <listitem><para>
+		List of line pitches supported by the driver.
+		This is optional and should be <constant>NULL</constant> when
+		not used.
+		    </para></listitem></varlistentry>
+
+		<varlistentry>
+		  <term><parameter>minPitch</parameter></term>
+		  <listitem><para>
+		Minimum line pitch supported by the driver.  This must
+		be supplied when <parameter>linePitches</parameter> is
+		<constant>NULL</constant>, and is ignored otherwise.
+		    </para></listitem></varlistentry>
+
+		<varlistentry>
+		  <term><parameter>maxPitch</parameter></term>
+		  <listitem><para>
+		Maximum line pitch supported by the driver.  This is
+		required when <parameter>minPitch</parameter> is required.
+		    </para></listitem></varlistentry>
+
+		<varlistentry>
+		  <term><parameter>pitchInc</parameter></term>
+		  <listitem><para>
+		Granularity of horizontal pitch values as supported by
+		the chipset.  This is expressed in bits.  This must be
+		supplied.
+		    </para></listitem></varlistentry>
+
+		<varlistentry>
+		  <term><parameter>minHeight</parameter></term>
+		  <listitem><para>
+		minimum virtual height allowed.  If zero, no limit is
+		imposed.
+		    </para></listitem></varlistentry>
+
+		<varlistentry>
+		  <term><parameter>maxHeight</parameter></term>
+		  <listitem><para>
+		maximum virtual height allowed.  If zero, no limit is
+		imposed.
+		    </para></listitem></varlistentry>
+
+		<varlistentry>
+		  <term><parameter>virtualX</parameter></term>
+		  <listitem><para>
+		If greater than zero, this is the virtual width value
+		that will be used.  Otherwise, the virtual width is
+		chosen to be the smallest that can accommodate the modes
+		selected.
+		    </para></listitem></varlistentry>
+
+		<varlistentry>
+		  <term><parameter>virtualY</parameter></term>
+		  <listitem><para>
+		If greater than zero, this is the virtual height value
+		that will be used.  Otherwise, the virtual height is
+		chosen to be the smallest that can accommodate the modes
+		selected.
+		    </para></listitem></varlistentry>
+
+		<varlistentry>
+		  <term><parameter>apertureSize</parameter></term>
+		  <listitem><para>
+		The size (in bytes) of the aperture used to access video
+		memory.
+		    </para></listitem></varlistentry>
+
+		<varlistentry>
+		  <term><parameter>strategy</parameter></term>
+		  <listitem><para>
+		The strategy to use when choosing from multiple modes
+		with the same name.  The options are:
+
+		      <variablelist>
+			<varlistentry>
+			  <term><constant>LOOKUP_DEFAULT</constant></term>
+			  <listitem><para>???
+			    </para></listitem></varlistentry>
+			<varlistentry>
+			  <term><constant>LOOKUP_BEST_REFRESH</constant></term>
+			  <listitem><para>mode with best refresh rate
+			    </para></listitem></varlistentry>
+			<varlistentry>
+			  <term><constant>LOOKUP_CLOSEST_CLOCK</constant></term>
+			  <listitem><para>mode with closest matching clock
+			    </para></listitem></varlistentry>
+			<varlistentry>
+			  <term><constant>LOOKUP_LIST_ORDER</constant></term>
+			  <listitem><para>first usable mode in list
+			    </para></listitem></varlistentry>
+		      </variablelist>
+
+		The following options can also be combined (OR'ed) with
+		one of the above:
+
+		      <variablelist>
+			<varlistentry>
+			  <term><constant>LOOKUP_CLKDIV2</constant></term>
+			  <listitem><para>Allow halved clocks
+			    </para></listitem></varlistentry>
+			<varlistentry>
+			  <term><constant>LOOKUP_OPTIONAL_TOLERANCES</constant></term>
+			  <listitem><para>
+		      Allow missing horizontal sync and/or vertical refresh
+		      ranges in the xorg.conf Monitor section
+			    </para></listitem></varlistentry>
+		      </variablelist>
+
+		<constant>LOOKUP_OPTIONAL_TOLERANCES</constant> should only be
+		specified when the driver can ensure all modes it generates
+		can sync on, or at least not damage, the monitor or digital
+		flat panel.  Horizontal sync and/or vertical refresh ranges
+		specified by the user will still be honoured (and acted upon).
+
+		    </para></listitem></varlistentry>
+	      </variablelist>
+	    </para>
+
+	    <para>
+      This function requires that the following fields of the
+      <structname>ScrnInfoRec</structname> are initialised prior to calling it:
+
+	      <variablelist>
+		<varlistentry>
+		  <term><structfield>clock[]</structfield></term>
+		  <listitem><para>
+		      List of discrete clocks (when non-programmable)
+		    </para></listitem></varlistentry>
+		<varlistentry>
+		  <term><structfield>numClocks</structfield></term>
+		  <listitem><para>
+		      Number of discrete clocks (when non-programmable)
+		    </para></listitem></varlistentry>
+		<varlistentry>
+		  <term><structfield>progClock</structfield></term>
+		  <listitem><para>
+		      Whether the clock is programmable or not
+		    </para></listitem></varlistentry>
+		<varlistentry>
+		  <term><structfield>monitor</structfield></term>
+		  <listitem><para>
+		      Pointer to the applicable xorg.conf monitor section
+		    </para></listitem></varlistentry>
+		<varlistentry>
+		  <term><structfield>fdFormat</structfield></term>
+		  <listitem><para>
+		      Format of the screen buffer
+		    </para></listitem></varlistentry>
+		<varlistentry>
+		  <term><structfield>videoRam</structfield></term>
+		  <listitem><para>
+		      total video memory size (in bytes)
+		    </para></listitem></varlistentry>
+		<varlistentry>
+		  <term><structfield>maxHValue</structfield></term>
+		  <listitem><para>
+		      Maximum horizontal timing value allowed
+		    </para></listitem></varlistentry>
+		<varlistentry>
+		  <term><structfield>maxVValue</structfield></term>
+		  <listitem><para>
+		      Maximum vertical timing value allowed
+		    </para></listitem></varlistentry>
+		<varlistentry>
+		  <term><structfield>xInc</structfield></term>
+		  <listitem><para>
+		      Horizontal timing increment in pixels (defaults to 8)
+		    </para></listitem></varlistentry>
+	      </variablelist>
+	    </para>
+
+	    <para>
+      This function fills in the following <structname>ScrnInfoRec</structname>
+      fields:
+
+	      <variablelist>
+		<varlistentry>
+		  <term><structfield>modePool</structfield></term>
+		  <listitem><para>
+		A subset of the modes available to the monitor which
+                are compatible with the driver.
+		    </para></listitem></varlistentry>
+
+		<varlistentry>
+		  <term><structfield>modes</structfield></term>
+		  <listitem><para>
+		One mode entry for each of the requested modes, with
+                the status field of each filled in to indicate if
+                the mode has been accepted or not.  This list of
+                modes is a circular list.
+		    </para></listitem></varlistentry>
+
+		<varlistentry>
+		  <term><structfield>virtualX</structfield></term>
+		  <listitem><para>
+		The resulting virtual width.
+		    </para></listitem></varlistentry>
+
+		<varlistentry>
+		  <term><structfield>virtualY</structfield></term>
+		  <listitem><para>
+		The resulting virtual height.
+		    </para></listitem></varlistentry>
+
+		<varlistentry>
+		  <term><structfield>displayWidth</structfield></term>
+		  <listitem><para>
+		The resulting line pitch.
+		    </para></listitem></varlistentry>
+
+		<varlistentry>
+		  <term><structfield>virtualFrom</structfield></term>
+		  <listitem><para>
+		Where the virtual size was determined from.
+		    </para></listitem></varlistentry>
+
+	      </variablelist>
+	    </para>
+
+	    <para>
+      The first stage of this function checks that the
+      <parameter>virtualX</parameter> and <parameter>virtualY</parameter> values
+      supplied (if greater than zero) are consistent with the line pitch
+      and <parameter>maxHeight</parameter> limitations.  If not, an error
+      message is printed, and the return value is <constant>-1</constant>.
+	    </para>
+
+	    <para>
+      The second stage sets up the mode pool, eliminating immediately
+      any modes that exceed the driver's line pitch limits, and also
+      the virtual width and height limits (if greater than zero).  For
+      each mode removed an informational message is printed at verbosity
+      level <constant>2</constant>.  If the mode pool ends up being empty,
+      a warning message is printed, and the return value is
+      <constant>0</constant>.
+	    </para>
+
+	    <para>
+      The final stage is to lookup each mode name, and fill in the remaining
+      parameters.  If an error condition is encountered, a message is
+      printed, and the return value is <constant>-1</constant>.  Otherwise,
+      the return value is the number of valid modes found
+      (<constant>0</constant> if none are found).
+	    </para>
+
+	    <para>
+      Even if the supplied mode names include duplicates, no two names will
+      ever match the same mode.  Furthermore, if the supplied mode names do not
+      yield a valid mode (including the case where no names are passed at all),
+      the function will continue looking through the mode pool until it finds
+      a mode that survives all checks, or until the mode pool is exhausted.
+	    </para>
+
+	    <para>
+      A message is only printed by this function when a fundamental
+      problem is found.  It is intended that this function may be called
+      more than once if there is more than one set of constraints that
+      the driver can work within.
+	    </para>
+
+	    <para>
+      If this function returns <constant>-1</constant>, the
+      <function>ChipPreInit()</function> function should return
+      <constant>FALSE</constant>.
+	    </para>
+
+	    <para>
+      <parameter>clockRanges</parameter> is a linked list of clock ranges
+      allowed by the driver.  If a mode doesn't fit in any of the defined
+      <parameter>clockRanges</parameter>, it is rejected.  The first
+      <literal remap="tt">clockRange</literal> that matches all requirements is used.
+      This structure needs to be initialized to NULL when allocated.
+	    </para>
+
+	    <para>
+      <parameter>clockRanges</parameter> contains the following fields:
+
+	      <variablelist>
+		<varlistentry>
+		  <term><structfield>minClock</structfield></term>
+		  <term><structfield>maxClock</structfield></term>
+		  <listitem><para>
+		The lower and upper mode clock bounds for which the rest
+		of the <structname>clockRange</structname> parameters apply.
+		Since these are the mode clocks, they are not scaled
+		with the <structfield>ClockMulFactor</structfield> and
+		<structfield>ClockDivFactor</structfield>.  It is up to the driver
+		to adjust these values if they depend on the clock
+		scaling factors.
+		    </para></listitem></varlistentry>
+
+		<varlistentry>
+		  <term><structfield>clockIndex</structfield></term>
+		  <listitem><para>
+		(not used yet) <constant>-1</constant> for programmable clocks
+		    </para></listitem></varlistentry>
+
+		<varlistentry>
+		  <term><structfield>interlaceAllowed</structfield></term>
+		  <listitem><para>
+		<constant>TRUE</constant> if interlacing is allowed for this
+		range
+		    </para></listitem></varlistentry>
+
+		<varlistentry>
+		  <term><structfield>doubleScanAllowed</structfield></term>
+		  <listitem><para>
+		<constant>TRUE</constant> if doublescan or multiscan is allowed
+		for this range
+		    </para></listitem></varlistentry>
+
+		<varlistentry>
+		  <term><structfield>ClockMulFactor</structfield></term>
+		  <term><structfield>ClockDivFactor</structfield></term>
+		  <listitem><para>
+		Scaling factors that are applied to the mode clocks ONLY
+		before selecting a clock index (when there is no
+		programmable clock) or a <structfield>SynthClock</structfield>
+		value.  This is useful for drivers that support pixel
+		multiplexing or that need to scale the clocks because
+		of hardware restrictions (like sending 24bpp data to an
+		8 bit RAMDAC using a tripled clock).
+		    </para>
+
+		    <para>
+		Note that these parameters describe what must be done
+		to the mode clock to achieve the data transport clock
+		between graphics controller and RAMDAC.  For example
+		for <literal remap="tt">2:1</literal> pixel multiplexing, two pixels
+		are sent to the RAMDAC on each clock.  This allows the
+		RAMDAC clock to be half of the actual pixel clock.
+		Hence, <code>ClockMulFactor=1</code> and
+		<code>ClockDivFactor=2</code>.  This means that the
+		clock used for clock selection (ie, determining the
+		correct clock index from the list of discrete clocks)
+		or for the <structfield>SynthClock</structfield> field in case of
+		a programmable clock is:  (<code>mode->Clock *
+		ClockMulFactor) / ClockDivFactor</code>.
+		    </para></listitem></varlistentry>
+
+		<varlistentry>
+		  <term><structfield>PrivFlags</structfield></term>
+		  <listitem><para>
+		This field is copied into the
+		<literal remap="tt">mode->PrivFlags</literal> field when this
+		<literal remap="tt">clockRange</literal> is selected by
+		<function>xf86ValidateModes()</function>.  It allows the
+		driver to find out what clock range was selected, so it
+		knows it needs to set up pixel multiplexing or any other
+		range-dependent feature.  This field is purely
+		driver-defined: it may contain flag bits, an index or
+		anything else (as long as it is an <literal remap="tt">INT</literal>).
+		    </para></listitem></varlistentry>
+	      </variablelist>
+	    </para>
+
+	    <para>
+      Note that the <structfield>mode->SynthClock</structfield> field is always
+      filled in by <function>xf86ValidateModes()</function>: it will contain
+      the <quote>data transport clock</quote>, which is the clock that will have
+      to be programmed in the chip when it has a programmable clock, or
+      the clock that will be picked from the clocks list when it is not
+      a programmable one.  Thus:
+
+	      <programlisting>
+    mode->SynthClock = (mode->Clock * ClockMulFactor) / ClockDivFactor
+	      </programlisting>
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    void xf86PruneDriverModes(ScrnInfoPtr scrp);
+	  </programlisting>
+	  <blockquote><para>
+      This function deletes modes in the modes field of the
+      <structname>ScrnInfoRec</structname> that have been marked as invalid.
+      This is normally run after having run
+      <function>xf86ValidateModes()</function> for the last time.  For each
+      mode that is deleted, a warning message is printed out indicating
+      the reason for it being deleted.
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    void xf86SetCrtcForModes(ScrnInfoPtr scrp, int adjustFlags);
+	  </programlisting>
+	  <blockquote><para>
+      This function fills in the <structname>Crtc*</structname> fields for all
+      the modes in the <structfield>modes</structfield> field of the
+      <structname>ScrnInfoRec</structname>.  The <parameter>adjustFlags</parameter>
+      parameter determines how the vertical CRTC values are scaled for
+      interlaced modes.  They are halved if it is
+      <constant>INTERLACE_HALVE_V</constant>.  The vertical CRTC values are
+      doubled for doublescan modes, and are further multiplied by the
+      <literal remap="tt">VScan</literal> value.
+	    </para>
+
+	    <para>
+      This function is normally called after calling
+      <function>xf86PruneDriverModes()</function>.
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    void xf86PrintModes(ScrnInfoPtr scrp);
+	  </programlisting>
+	  <blockquote><para>
+      This function prints out the virtual size setting, and the line
+      pitch being used.  It also prints out two lines for each mode being
+      used.  The first line includes the mode's pixel clock, horizontal sync
+      rate, refresh rate, and whether it is interlaced, doublescanned and/or
+      multi-scanned.  The second line is the mode's Modeline.
+	    </para>
+
+	    <para>
+      This function is normally called after calling
+      <function>xf86SetCrtcForModes()</function>.
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+    </sect2>
+
+    <sect2>
+      <title>Secondary Mode functions</title>
+
+      <para>
+The secondary mode helper functions are functions which are normally
+used by the primary mode helper functions, and which are not normally
+called directly by a driver.  If a driver has unusual requirements
+and needs to do its own mode validation, it might be able to make
+use of some of these secondary mode helper functions.
+      </para>
+
+      <blockquote><para>
+	  <programlisting>
+    int xf86GetNearestClock(ScrnInfoPtr scrp, int freq, Bool allowDiv2,
+                            int *divider);
+	  </programlisting>
+	  <blockquote><para>
+      This function returns the index of the closest clock to the
+      frequency <parameter>freq</parameter> given (in kHz).  It assumes that
+      the number of clocks is greater than zero.  It requires that the
+      <structfield>numClocks</structfield> and <structfield>clock</structfield> fields of the
+      <structname>ScrnInfoRec</structname> are initialised.  The
+      <structfield>allowDiv2</structfield> field determines if the clocks can be
+      halved.  The <parameter>*divider</parameter> return value indicates
+      whether clock division is used when determining the clock returned.
+	    </para>
+
+	    <para>
+      This function is only for non-programmable clocks.
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    const char *xf86ModeStatusToString(ModeStatus status);
+	  </programlisting>
+	  <blockquote><para>
+      This function converts the <parameter>status</parameter> value to a
+      descriptive printable string.
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    ModeStatus xf86LookupMode(ScrnInfoPtr scrp, DisplayModePtr modep,
+                     ClockRangePtr clockRanges, LookupModeFlags strategy);
+	  </programlisting>
+	  <blockquote><para>
+      This function takes a pointer to a mode with the name filled in,
+      and looks for a mode in the <structfield>modePool</structfield> list which
+      matches.  The parameters of the matching mode are filled in to
+      <parameter>*modep</parameter>.  The <parameter>clockRanges</parameter> and
+      <parameter>strategy</parameter> parameters are as for the
+      <function>xf86ValidateModes()</function> function above.
+	    </para>
+
+	    <para>
+      This function requires the <structfield>modePool</structfield>,
+      <structfield>clock[]</structfield>, <structfield>numClocks</structfield> and
+      <structfield>progClock</structfield> fields of the <structname>ScrnInfoRec</structname>
+      to be initialised before being called.
+	    </para>
+
+	    <para>
+      The return value is <constant>MODE_OK</constant> if a mode was found.
+      Otherwise it indicates why a matching mode could not be found.
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    ModeStatus xf86InitialCheckModeForDriver(ScrnInfoPtr scrp,
+                                DisplayModePtr mode, ClockRangePtr clockRanges,
+                                LookupModeFlags strategy, int maxPitch,
+                                int virtualX, int virtualY);
+	  </programlisting>
+	  <blockquote><para>
+      This function checks the passed mode against some basic driver
+      constraints.  Apart from the ones passed explicitly, the
+      <structfield>maxHValue</structfield> and <structfield>maxVValue</structfield> fields of
+      the <structname>ScrnInfoRec</structname> are also used.  If the
+      <structfield>ValidMode</structfield> field of the <structname>ScrnInfoRec</structname>
+      is set, that function is also called to check the mode.  Next, the
+      mode is checked against the monitor's constraints.
+	    </para>
+
+	    <para>
+      If the mode is consistent with all constraints, the return value
+      is <constant>MODE_OK</constant>.  Otherwise the return value indicates
+      which constraint wasn't met.
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    void xf86DeleteMode(DisplayModePtr *modeList, DisplayModePtr mode);
+	  </programlisting>
+	  <blockquote><para>
+      This function deletes the <parameter>mode</parameter> given from the
+      <parameter>modeList</parameter>.  It never prints any messages, so it is
+      up to the caller to print a message if required.
+	    </para>
+
+	  </blockquote></para></blockquote>
+    </sect2>
+
+    <sect2>
+      <title>Functions for handling strings and tokens</title>
+
+      <para>
+    Tables associating strings and numerical tokens combined with the
+    following functions provide a compact way of handling strings from
+    the config file, and for converting tokens into printable strings.
+    The table data structure is:
+
+	<programlisting>
+typedef struct {
+    int                 token;
+    const char *        name;
+} SymTabRec, *SymTabPtr;
+	</programlisting>
+      </para>
+
+      <para>
+    A table is an initialised array of <structname>SymTabRec</structname>.  The
+    tokens must be non-negative integers.  Multiple names may be mapped
+    to a single token.  The table is terminated with an element with a
+    <structfield>token</structfield> value of <constant>-1</constant> and
+    <constant>NULL</constant> for the <structfield>name</structfield>.
+      </para>
+
+      <blockquote><para>
+	  <programlisting>
+    const char *xf86TokenToString(SymTabPtr table, int token);
+	  </programlisting>
+	  <blockquote><para>
+      This function returns the first string in <parameter>table</parameter>
+      that matches <parameter>token</parameter>.  If no match is found,
+      <constant>NULL</constant> is returned (NOTE, older versions of this
+      function would return the string "unknown" when no match is found).
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    int xf86StringToToken(SymTabPtr table, const char *string);
+	  </programlisting>
+	  <blockquote><para>
+      This function returns the first token in <parameter>table</parameter>
+      that matches <parameter>string</parameter>.  The
+      <function>xf86NameCmp()</function> function is used to determine the
+      match.  If no match is found, <constant>-1</constant> is returned.
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+    </sect2>
+
+    <sect2>
+      <title>Functions for finding which config file entries to use</title>
+
+      <para>
+    These functions can be used to select the appropriate config file
+    entries that match the detected hardware.  They are described above
+    in the <link linkend="probe">Probe</link> and
+    <link linkend="avail">Available Functions</link> sections.
+      </para>
+
+    </sect2>
+
+    <sect2>
+      <title>Probing discrete clocks on old hardware</title>
+
+      <para>
+    The <function>xf86GetClocks()</function> function may be used to assist
+    in finding the discrete pixel clock values on older hardware.
+      </para>
+
+      <blockquote><para>
+	  <programlisting>
+    void xf86GetClocks(ScrnInfoPtr pScrn, int num,
+                       Bool (*ClockFunc)(ScrnInfoPtr, int),
+                       void (*ProtectRegs)(ScrnInfoPtr, Bool),
+                       void (*BlankScreen)(ScrnInfoPtr, Bool),
+                       int vertsyncreg, int maskval, int knownclkindex,
+                       int knownclkvalue);
+	  </programlisting>
+	  <blockquote><para>
+      This function uses a comparative sampling method to measure the
+      discrete pixel clock values.  The number of discrete clocks to
+      measure is given by <parameter>num</parameter>.  <parameter>clockFunc</parameter>
+      is a function that selects the <parameter>n</parameter>'th clock.  It
+      should also save or restore any state affected by programming the
+      clocks when the index passed is <constant>CLK_REG_SAVE</constant> or
+      <constant>CLK_REG_RESTORE</constant>.  <parameter>ProtectRegs</parameter> is
+      a function that does whatever is required to protect the hardware
+      state while selecting a new clock.  <parameter>BlankScreen</parameter>
+      is a function that blanks the screen.  <parameter>vertsyncreg</parameter>
+      and <parameter>maskval</parameter> are the register and bitmask to
+      check for the presence of vertical sync pulses.
+      <parameter>knownclkindex</parameter> and <parameter>knownclkvalue</parameter>
+      are the index and value of a known clock.  These are the known
+      references on which the comparative measurements are based.  The
+      number of clocks probed is set in <structfield>pScrn->numClocks</structfield>,
+      and the probed clocks are set in the <structfield>pScrn->clock[]</structfield>
+      array.  All of the clock values are in units of kHz.
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    void xf86ShowClocks(ScrnInfoPtr scrp, MessageType from);
+	  </programlisting>
+	  <blockquote><para>
+      Print out the pixel clocks <parameter>scrp->clock[]</parameter>.
+      <parameter>from</parameter> indicates whether the clocks were probed
+      or from the config file.
+	    </para>
+
+	  </blockquote></para></blockquote>
+    </sect2>
+
+    <sect2>
+      <title>Other helper functions</title>
+
+      <blockquote><para>
+	  <programlisting>
+    Bool xf86IsUnblank(int mode);
+	  </programlisting>
+	  <blockquote><para>
+      Returns <constant>TRUE</constant> when the screen saver mode specified
+      by <parameter>mode</parameter> requires the screen be unblanked,
+      and <constant>FALSE</constant> otherwise.  The screen saver modes that
+      require blanking are <constant>SCREEN_SAVER_ON</constant> and
+      <constant>SCREEN_SAVER_CYCLE</constant>, and the screen saver modes that
+      require unblanking are <constant>SCREEN_SAVER_OFF</constant> and
+      <constant>SCREEN_SAVER_FORCER</constant>.  Drivers may call this helper
+      from their <function>SaveScreen()</function> function to interpret the
+      screen saver modes.
+	    </para>
+
+	  </blockquote></para></blockquote>
+    </sect2>
+  </sect1>
+
+  <sect1>
+    <title>The vgahw module</title>
+
+    <para>
+The vgahw modules provides an interface for saving, restoring and
+programming the standard VGA registers, and for handling VGA colourmaps.
+    </para>
+
+    <sect2>
+      <title>Data Structures</title>
+
+      <para>
+    The public data structures used by the vgahw module are
+    <structname>vgaRegRec</structname> and <structname>vgaHWRec</structname>.  They are
+    defined in <filename>vgaHW.h.</filename>
+      </para>
+
+    </sect2>
+
+    <sect2>
+      <title>General vgahw Functions</title>
+
+      <blockquote><para>
+	  <programlisting>
+    Bool vgaHWGetHWRec(ScrnInfoPtr pScrn);
+	  </programlisting>
+	  <blockquote><para>
+      This function allocates a <structname>vgaHWRec</structname> structure, and
+      hooks it into the <structname>ScrnInfoRec</structname>'s
+      <structfield>privates</structfield>.  Like all information hooked into the
+      <structfield>privates</structfield>, it is persistent, and only needs to be
+      allocated once per screen.  This function should normally be called
+      from the driver's <function>ChipPreInit()</function> function.  The
+      <structname>vgaHWRec</structname> is zero-allocated, and the following
+      fields are explicitly initialised:
+
+	      <variablelist>
+		<varlistentry>
+		  <term><structfield>ModeReg.DAC[]</structfield></term>
+		  <listitem><para>initialised with a default colourmap
+		    </para></listitem></varlistentry>
+		<varlistentry>
+		  <term><structfield>ModeReg.Attribute[0x11]</structfield></term>
+		  <listitem><para>initialised with the default overscan index
+		    </para></listitem></varlistentry>
+		<varlistentry>
+		  <term><structfield>ShowOverscan</structfield></term>
+		  <listitem><para>initialised according to the "ShowOverscan" option
+		    </para></listitem></varlistentry>
+		<varlistentry>
+		  <term><structfield>paletteEnabled</structfield></term>
+		  <listitem><para>initialised to FALSE
+		    </para></listitem></varlistentry>
+		<varlistentry>
+		  <term><structfield>cmapSaved</structfield></term>
+		  <listitem><para>initialised to FALSE
+		    </para></listitem></varlistentry>
+		<varlistentry>
+		  <term><structfield>pScrn</structfield></term>
+		  <listitem><para>initialised to pScrn
+		    </para></listitem></varlistentry>
+	      </variablelist>
+	    </para>
+
+	    <para>
+      In addition to the above, <function>vgaHWSetStdFuncs()</function> is
+      called to initialise the register access function fields with the
+      standard VGA set of functions.
+	    </para>
+
+	    <para>
+      Once allocated, a pointer to the <structname>vgaHWRec</structname> can be
+      obtained from the <literal remap="tt">ScrnInfoPtr</literal> with the
+      <literal remap="tt">VGAHWPTR(pScrn)</literal> macro.
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    void vgaHWFreeHWRec(ScrnInfoPtr pScrn);
+	  </programlisting>
+	  <blockquote><para>
+      This function frees a <structname>vgaHWRec</structname> structure.  It
+      should be called from a driver's <function>ChipFreeScreen()</function>
+      function.
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    Bool vgaHWSetRegCounts(ScrnInfoPtr pScrn, int numCRTC,
+                          int numSequencer, int numGraphics, int numAttribute);
+	  </programlisting>
+	  <blockquote><para>
+      This function allows the number of CRTC, Sequencer, Graphics and
+      Attribute registers to be changed.  This makes it possible for
+      extended registers to be saved and restored with
+      <function>vgaHWSave()</function> and <function>vgaHWRestore()</function>.
+      This function should be called after a <structname>vgaHWRec</structname>
+      has been allocated with <function>vgaHWGetHWRec()</function>.  The
+      default values are defined in <filename>vgaHW.h</filename> as follows:
+
+	      <programlisting>
+#define VGA_NUM_CRTC 25
+#define VGA_NUM_SEQ   5
+#define VGA_NUM_GFX   9
+#define VGA_NUM_ATTR 21
+	      </programlisting>
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    Bool vgaHWCopyReg(vgaRegPtr dst, vgaRegPtr src);
+	  </programlisting>
+	  <blockquote><para>
+      This function copies the contents of the VGA saved registers in
+      <parameter>src</parameter> to <parameter>dst</parameter>.  Note that it isn't
+      possible to simply do this with <function>memcpy()</function> (or
+      similar).  This function returns <constant>TRUE</constant> unless there
+      is a problem allocating space for the <structfield>CRTC</structfield> and
+      related fields in <parameter>dst</parameter>.
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    void vgaHWSetStdFuncs(vgaHWPtr hwp);
+	  </programlisting>
+	  <blockquote><para>
+      This function initialises the register access function fields of
+      <parameter>hwp</parameter> with the standard VGA set of functions.  This
+      is called by <function>vgaHWGetHWRec()</function>, so there is usually
+      no need to call this explicitly.  The register access functions
+      are described below.  If the registers are shadowed in some other
+      port I/O space (for example a PCI I/O region), these functions
+      can be used to access the shadowed registers if
+      <structfield>hwp->PIOOffset</structfield> is initialised with
+      <literal remap="tt">offset</literal>, calculated in such a way that when the
+      standard VGA I/O port value is added to it the correct offset into
+      the PIO area results.  This value is initialised to zero in
+      <function>vgaHWGetHWRec()</function>.  (Note: the PIOOffset functionality
+      is present in XFree86 4.1.0 and later.)
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    void vgaHWSetMmioFuncs(vgaHWPtr hwp, CARD8 *base, int offset);
+	  </programlisting>
+	  <blockquote><para>
+      This function initialised the register access function fields of
+      hwp with a generic MMIO set of functions.
+      <structfield>hwp->MMIOBase</structfield> is initialised with
+      <parameter>base</parameter>, which must be the virtual address that the
+      start of MMIO area is mapped to.  <structfield>hwp->MMIOOffset</structfield>
+      is initialised with <parameter>offset</parameter>, which must be calculated
+      in such a way that when the standard VGA I/O port value is added
+      to it the correct offset into the MMIO area results.  That means
+      that these functions are only suitable when the VGA I/O ports are
+      made available in a direct mapping to the MMIO space.  If that is
+      not the case, the driver will need to provide its own register
+      access functions.  The register access functions are described
+      below.
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    Bool vgaHWMapMem(ScrnInfoPtr pScrn);
+	  </programlisting>
+	  <blockquote><para>
+      This function maps the VGA memory window.  It requires that the
+      <structname>vgaHWRec</structname> be allocated.  If a driver requires
+      non-default <structfield>MapPhys</structfield> or <structfield>MapSize</structfield>
+      settings (the physical location and size of the VGA memory window)
+      then those fields of the <structname>vgaHWRec</structname> must be initialised
+      before calling this function.  Otherwise, this function initialiases
+      the default values of <constant>0xA0000</constant> for
+      <structfield>MapPhys</structfield> and <code>(64 * 1024)</code> for
+      <structfield>MapSize</structfield>.  This function must be called before
+      attempting to save or restore the VGA state.  If the driver doesn't
+      call it explicitly, the <function>vgaHWSave()</function> and
+      <function>vgaHWRestore()</function> functions may call it if they need
+      to access the VGA memory (in which case they will also call
+      <function>vgaHWUnmapMem()</function> to unmap the VGA memory before
+      exiting).
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    void vgaHWUnmapMem(ScrnInfoPtr pScrn);
+	  </programlisting>
+	  <blockquote><para>
+      This function unmaps the VGA memory window.  It must only be called
+      after the memory has been mapped.  The <structfield>Base</structfield> field
+      of the <structname>vgaHWRec</structname> field is set to <constant>NULL</constant>
+      to indicate that the memory is no longer mapped.
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    void vgaHWGetIOBase(vgaHWPtr hwp);
+	  </programlisting>
+	  <blockquote><para>
+      This function initialises the <structfield>IOBase</structfield> field of the
+      <structname>vgaHWRec</structname>.  This function must be called before
+      using any other functions that access the video hardware.
+	    </para>
+
+	    <para>
+      A macro <function>VGAHW_GET_IOBASE()</function> is also available in
+      <filename>vgaHW.h</filename> that returns the I/O base, and this may
+      be used when the vgahw module is not loaded (for example, in the
+      <function>ChipProbe()</function> function).
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    void vgaHWUnlock(vgaHWPtr hwp);
+	  </programlisting>
+	  <blockquote><para>
+      This function unlocks the VGA <literal remap="tt">CRTC[0-7]</literal> registers,
+      and must be called before attempting to write to those registers.
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    void vgaHWLock(vgaHWPtr hwp);
+	  </programlisting>
+	  <blockquote><para>
+      This function locks the VGA <literal remap="tt">CRTC[0-7]</literal> registers.
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    void vgaHWEnable(vgaHWPtr hwp);
+	  </programlisting>
+	  <blockquote><para>
+      This function enables the VGA subsystem.  (Note, this function is
+      present in XFree86 4.1.0 and later.).
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    void vgaHWDisable(vgaHWPtr hwp);
+	  </programlisting>
+	  <blockquote><para>
+      This function disables the VGA subsystem.  (Note, this function is
+      present in XFree86 4.1.0 and later.).
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    void vgaHWSave(ScrnInfoPtr pScrn, vgaRegPtr save, int flags);
+	  </programlisting>
+	  <blockquote><para>
+      This function saves the VGA state.  The state is written to the
+      <structname>vgaRegRec</structname> pointed to by <parameter>save</parameter>.
+      <parameter>flags</parameter> is set to one or more of the following flags
+      ORed together:
+
+	      <variablelist>
+		<varlistentry>
+		  <term><constant>VGA_SR_MODE</constant></term>
+		  <listitem><para>the mode setting registers are saved
+		    </para></listitem></varlistentry>
+		<varlistentry>
+		  <term><constant>VGA_SR_FONTS</constant></term>
+		  <listitem><para>the text mode font/text data is saved
+		    </para></listitem></varlistentry>
+		<varlistentry>
+		  <term><constant>VGA_SR_CMAP</constant></term>
+		  <listitem><para>the colourmap (LUT) is saved
+		    </para></listitem></varlistentry>
+		<varlistentry>
+		  <term><constant>VGA_SR_ALL</constant></term>
+		  <listitem><para>all of the above are saved
+		    </para></listitem></varlistentry>
+	      </variablelist>
+	    </para>
+
+	    <para>
+      The <structname>vgaHWRec</structname> and its <structfield>IOBase</structfield> fields
+      must be initialised before this function is called.  If
+      <constant>VGA_SR_FONTS</constant> is set in <parameter>flags</parameter>, the
+      VGA memory window must be mapped.  If it isn't then
+      <function>vgaHWMapMem()</function> will be called to map it, and
+      <function>vgaHWUnmapMem()</function> will be called to unmap it
+      afterwards.  <function>vgaHWSave()</function> uses the three functions
+      below in the order <function>vgaHWSaveColormap()</function>,
+      <function>vgaHWSaveMode()</function>, <function>vgaHWSaveFonts()</function> to
+      carry out the different save phases.  It is undecided at this
+      stage whether they will remain part of the vgahw module's public
+      interface or not.
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    void vgaHWSaveMode(ScrnInfoPtr pScrn, vgaRegPtr save);
+	  </programlisting>
+	  <blockquote><para>
+      This function saves the VGA mode registers.  They are saved to
+      the <structname>vgaRegRec</structname> pointed to by <parameter>save</parameter>.
+      The registers saved are:
+
+	      <literallayout>
+        MiscOut
+        CRTC[0-0x18]
+        Attribute[0-0x14]
+        Graphics[0-8]
+        Sequencer[0-4]
+	      </literallayout>
+	    </para>
+
+	    <para>
+    The number of registers actually saved may be modified by a prior call
+    to <function>vgaHWSetRegCounts()</function>.
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    void vgaHWSaveFonts(ScrnInfoPtr pScrn, vgaRegPtr save);
+	  </programlisting>
+	  <blockquote><para>
+      This function saves the text mode font and text data held in the
+      video memory.  If called while in a graphics mode, no save is
+      done.  The VGA memory window must be mapped with
+      <function>vgaHWMapMem()</function> before to calling this function.
+	    </para>
+
+	    <para>
+      On some platforms, one or more of the font/text plane saves may be
+      no-ops.  This is the case when the platform's VC driver already
+      takes care of this.
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    void vgaHWSaveColormap(ScrnInfoPtr pScrn, vgaRegPtr save);
+	  </programlisting>
+	  <blockquote><para>
+      This function saves the VGA colourmap (LUT).  Before saving it, it
+      attempts to verify that the colourmap is readable.  In rare cases
+      where it isn't readable, a default colourmap is saved instead.
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    void vgaHWRestore(ScrnInfoPtr pScrn, vgaRegPtr restore, int flags);
+	  </programlisting>
+	  <blockquote><para>
+      This function programs the VGA state.  The state programmed is
+      that contained in the <structname>vgaRegRec</structname> pointed to by
+      <parameter>restore</parameter>.  <parameter>flags</parameter> is the same
+      as described above for the <function>vgaHWSave()</function> function.
+	    </para>
+
+	    <para>
+      The <structname>vgaHWRec</structname> and its <structfield>IOBase</structfield> fields
+      must be initialised before this function is called.  If
+      <constant>VGA_SR_FONTS</constant> is set in <parameter>flags</parameter>, the
+      VGA memory window must be mapped.  If it isn't then
+      <function>vgaHWMapMem()</function> will be called to map it, and
+      <function>vgaHWUnmapMem()</function> will be called to unmap it
+      afterwards.  <function>vgaHWRestore()</function> uses the three functions
+      below in the order <function>vgaHWRestoreFonts()</function>,
+      <function>vgaHWRestoreMode()</function>,
+      <function>vgaHWRestoreColormap()</function> to carry out the different
+      restore phases.  It is undecided at this stage whether they will
+      remain part of the vgahw module's public interface or not.
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    void vgaHWRestoreMode(ScrnInfoPtr pScrn, vgaRegPtr restore);
+	  </programlisting>
+	  <blockquote><para>
+      This function restores the VGA mode registers.  They are restored
+      from the data in the <structname>vgaRegRec</structname> pointed to by
+      <parameter>restore</parameter>.  The registers restored are:
+
+	      <literallayout>
+        MiscOut
+        CRTC[0-0x18]
+        Attribute[0-0x14]
+        Graphics[0-8]
+        Sequencer[0-4]
+	      </literallayout>
+	    </para>
+
+	    <para>
+    The number of registers actually restored may be modified by a prior call
+    to <function>vgaHWSetRegCounts()</function>.
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    void vgaHWRestoreFonts(ScrnInfoPtr pScrn, vgaRegPtr restore);
+	  </programlisting>
+	  <blockquote><para>
+      This function restores the text mode font and text data to the
+      video memory.  The VGA memory window must be mapped with
+      <function>vgaHWMapMem()</function> before to calling this function.
+	    </para>
+
+	    <para>
+      On some platforms, one or more of the font/text plane restores
+      may be no-ops.  This is the case when the platform's VC driver
+      already takes care of this.
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    void vgaHWRestoreColormap(ScrnInfoPtr pScrn, vgaRegPtr restore);
+	  </programlisting>
+	  <blockquote><para>
+      This function restores the VGA colourmap (LUT).
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    void vgaHWInit(ScrnInfoPtr pScrn, DisplayModePtr mode);
+	  </programlisting>
+	  <blockquote><para>
+      This function fills in the <structname>vgaHWRec</structname>'s
+      <structfield>ModeReg</structfield> field with the values appropriate for
+      programming the given video mode.  It requires that the
+      <structname>ScrnInfoRec</structname>'s <structfield>depth</structfield> field is
+      initialised, which determines how the registers are programmed.
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    void vgaHWSeqReset(vgaHWPtr hwp, Bool start);
+	  </programlisting>
+	  <blockquote><para>
+      Do a VGA sequencer reset.  If start is <constant>TRUE</constant>, the
+      reset is started.  If start is <constant>FALSE</constant>, the reset
+      is ended.
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    void vgaHWProtect(ScrnInfoPtr pScrn, Bool on);
+	  </programlisting>
+	  <blockquote><para>
+      This function protects VGA registers and memory from corruption
+      during loads.  It is typically called with on set to
+      <constant>TRUE</constant> before programming, and with on set to
+      <constant>FALSE</constant> after programming.
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    Bool vgaHWSaveScreen(ScreenPtr pScreen, int mode);
+	  </programlisting>
+	  <blockquote><para>
+      This function blanks and unblanks the screen.  It is blanked when
+      <parameter>mode</parameter> is <constant>SCREEN_SAVER_ON</constant> or
+      <constant>SCREEN_SAVER_CYCLE</constant>, and unblanked when
+      <parameter>mode</parameter> is <constant>SCREEN_SAVER_OFF</constant> or
+      <constant>SCREEN_SAVER_FORCER</constant>.
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    void vgaHWBlankScreen(ScrnInfoPtr pScrn, Bool on);
+	  </programlisting>
+	  <blockquote><para>
+      This function blanks and unblanks the screen.  It is blanked when
+      <parameter>on</parameter> is <constant>FALSE</constant>, and unblanked when
+      <parameter>on</parameter> is <constant>TRUE</constant>.  This function is
+      provided for use in cases where the <structname>ScrnInfoRec</structname>
+      can't be derived from the <structname>ScreenRec</structname> (while probing
+      for clocks, for example).
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+    </sect2>
+
+    <sect2>
+      <title>VGA Colormap Functions</title>
+
+      <para>
+    The vgahw module uses the standard colormap support (see the
+    <link linkend="cmap">Colormap Handling</link> section.  This is initialised
+    with the following function:
+
+	<blockquote><para>
+	  <programlisting>
+    Bool vgaHWHandleColormaps(ScreenPtr pScreen);
+	    </programlisting>
+	  </para></blockquote>
+      </para>
+
+    </sect2>
+
+    <sect2>
+      <title>VGA Register Access Functions</title>
+
+      <para>
+    The vgahw module abstracts access to the standard VGA registers by
+    using a set of functions held in the <structname>vgaHWRec</structname>.  When
+    the <structname>vgaHWRec</structname> is created these function pointers are
+    initialised with the set of standard VGA I/O register access functions.
+    In addition to these, the vgahw module includes a basic set of MMIO
+    register access functions, and the <structname>vgaHWRec</structname> function
+    pointers can be initialised to these by calling the
+    <function>vgaHWSetMmioFuncs()</function> function described above.  Some
+    drivers/platforms may require a different set of functions for VGA
+    access.  The access functions are described here.
+      </para>
+
+
+      <blockquote><para>
+	  <programlisting>
+    void writeCrtc(vgaHWPtr hwp, CARD8 index, CARD8 value);
+	  </programlisting>
+	  <blockquote><para>
+      Write <parameter>value</parameter> to CRTC register <parameter>index</parameter>.
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    CARD8 readCrtc(vgaHWPtr hwp, CARD8 index);
+	  </programlisting>
+	  <blockquote><para>
+      Return the value read from CRTC register <parameter>index</parameter>.
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    void writeGr(vgaHWPtr hwp, CARD8 index, CARD8 value);
+	  </programlisting>
+	  <blockquote><para>
+      Write <parameter>value</parameter> to Graphics Controller register
+      <parameter>index</parameter>.
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    CARD8 readGR(vgaHWPtr hwp, CARD8 index);
+	  </programlisting>
+	  <blockquote><para>
+      Return the value read from Graphics Controller register
+      <parameter>index</parameter>.
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    void writeSeq(vgaHWPtr hwp, CARD8 index, CARD8, value);
+	  </programlisting>
+	  <blockquote><para>
+      Write <parameter>value</parameter> to Sequencer register
+      <parameter>index</parameter>.
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    CARD8 readSeq(vgaHWPtr hwp, CARD8 index);
+	  </programlisting>
+	  <blockquote><para>
+      Return the value read from Sequencer register <parameter>index</parameter>.
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    void writeAttr(vgaHWPtr hwp, CARD8 index, CARD8, value);
+	  </programlisting>
+	  <blockquote><para>
+      Write <parameter>value</parameter> to Attribute Controller register
+      <parameter>index</parameter>.  When writing out the index value this
+      function should set bit 5 (<constant>0x20</constant>) according to the
+      setting of <structfield>hwp->paletteEnabled</structfield> in order to
+      preserve the palette access state.  It should be cleared when
+      <structfield>hwp->paletteEnabled</structfield> is <constant>TRUE</constant>
+      and set when it is <constant>FALSE</constant>.
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    CARD8 readAttr(vgaHWPtr hwp, CARD8 index);
+	  </programlisting>
+	  <blockquote><para>
+      Return the value read from Attribute Controller register
+      <parameter>index</parameter>.  When writing out the index value this
+      function should set bit 5 (<constant>0x20</constant>) according to the
+      setting of <structfield>hwp->paletteEnabled</structfield> in order to
+      preserve the palette access state.  It should be cleared when
+      <structfield>hwp->paletteEnabled</structfield> is <constant>TRUE</constant>
+      and set when it is <constant>FALSE</constant>.
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    void writeMiscOut(vgaHWPtr hwp, CARD8 value);
+	  </programlisting>
+	  <blockquote><para>
+      Write <quote><parameter>value</parameter></quote> to the Miscellaneous Output register.
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    CARD8 readMiscOut(vgwHWPtr hwp);
+	  </programlisting>
+	  <blockquote><para>
+      Return the value read from the Miscellaneous Output register.
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    void enablePalette(vgaHWPtr hwp);
+	  </programlisting>
+	  <blockquote><para>
+      Clear the palette address source bit in the Attribute Controller
+      index register and set <literal remap="tt">hwp->paletteEnabled</literal> to
+      <constant>TRUE</constant>.
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    void disablePalette(vgaHWPtr hwp);
+	  </programlisting>
+	  <blockquote><para>
+      Set the palette address source bit in the Attribute Controller
+      index register and set <literal remap="tt">hwp->paletteEnabled</literal> to
+      <constant>FALSE</constant>.
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    void writeDacMask(vgaHWPtr hwp, CARD8 value);
+	  </programlisting>
+	  <blockquote><para>
+      Write <parameter>value</parameter> to the DAC Mask register.
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    CARD8 readDacMask(vgaHWptr hwp);
+	  </programlisting>
+	  <blockquote><para>
+      Return the value read from the DAC Mask register.
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    void writeDacReadAddress(vgaHWPtr hwp, CARD8 value);
+	  </programlisting>
+	  <blockquote><para>
+      Write <parameter>value</parameter> to the DAC Read Address register.
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    void writeDacWriteAddress(vgaHWPtr hwp, CARD8 value);
+	  </programlisting>
+	  <blockquote><para>
+      Write <parameter>value</parameter> to the DAC Write Address register.
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    void writeDacData(vgaHWPtr hwp, CARD8 value);
+	  </programlisting>
+	  <blockquote><para>
+      Write <parameter>value</parameter> to the DAC Data register.
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    CARD8 readDacData(vgaHWptr hwp);
+	  </programlisting>
+	  <blockquote><para>
+      Return the value read from the DAC Data register.
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    CARD8 readEnable(vgaHWptr hwp);
+	  </programlisting>
+	  <blockquote><para>
+      Return the value read from the VGA Enable register.  (Note: This
+      function is present in XFree86 4.1.0 and later.)
+	    </para>
+
+	  </blockquote></para></blockquote>
+
+      <blockquote><para>
+	  <programlisting>
+    void writeEnable(vgaHWPtr hwp, CARD8 value);
+	  </programlisting>
+	  <blockquote><para>
+      Write <parameter>value</parameter> to the VGA Enable register.  (Note: This
+      function is present in XFree86 4.1.0 and later.)
+	    </para>
+
+	  </blockquote></para></blockquote>
+    </sect2>
+  </sect1>
+
+  <sect1 id="sample">
+    <title>Some notes about writing a driver</title>
+
+    <note><para>NOTE: some parts of this are not up to date</para></note>
+
+    <para>
+The following is an outline for writing a basic unaccelerated driver
+for a PCI video card with a linear mapped framebuffer, and which has a
+VGA core.  It is includes some general information that is relevant to
+most drivers (even those which don't fit that basic description).
+    </para>
+
+    <para>
+The information here is based on the initial conversion of the Matrox
+Millennium driver to the <quote>new design</quote>.  For a fleshing out and sample
+implementation of some of the bits outlined here, refer to that driver.
+Note that this is an example only.  The approach used here will not be
+appropriate for all drivers.
+    </para>
+
+    <para>
+Each driver must reserve a unique driver name, and a string that is used
+to prefix all of its externally visible symbols.  This is to avoid name
+space clashes when loading multiple drivers.  The examples here are for
+the <quote>ZZZ</quote> driver, which uses the <quote>ZZZ</quote> or <quote>zzz</quote> prefix for its externally
+visible symbols.
+    </para>
+
+    <sect2>
+      <title>Include files</title>
+
+      <para>
+  All drivers normally include the following headers:
+	<literallayout><filename>
+    "xf86.h"
+    "xf86_OSproc.h"
+    "xf86_ansic.h"
+    "xf86Resources.h"
+	  </filename></literallayout>
+  Wherever inb/outb (and related things) are used the following should be
+  included:
+	<literallayout><filename>
+    "compiler.h"
+	  </filename></literallayout>
+  Note: in drivers, this must be included after <filename>"xf86_ansic.h"</filename>.
+      </para>
+
+      <para>
+  Drivers that need to access PCI vendor/device definitions need this:
+	<literallayout><filename>
+    "xf86PciInfo.h"
+	  </filename></literallayout>
+      </para>
+
+      <para>
+  Drivers that need to access the PCI config space need this:
+	<literallayout><filename>
+    "xf86Pci.h"
+	  </filename></literallayout>
+      </para>
+
+      <para>
+  Drivers using the mi banking wrapper need:
+
+	<literallayout><filename>
+    "mibank.h"
+	  </filename></literallayout>
+      </para>
+
+      <para>
+  Drivers that initialise a SW cursor need this:
+	<literallayout><filename>
+    "mipointer.h"
+	  </filename></literallayout>
+      </para>
+
+      <para>
+  All drivers implementing backing store need this:
+	<literallayout><filename>
+    "mibstore.h"
+	  </filename></literallayout>
+      </para>
+
+      <para>
+  All drivers using the mi colourmap code need this:
+	<literallayout><filename>
+    "micmap.h"
+	  </filename></literallayout>
+      </para>
+
+      <para>
+  If a driver uses the vgahw module, it needs this:
+	<literallayout><filename>
+    "vgaHW.h"
+	  </filename></literallayout>
+      </para>
+
+      <para>
+  Drivers supporting VGA or Hercules monochrome screens need:
+	<literallayout><filename>
+    "xf1bpp.h"
+	  </filename></literallayout>
+      </para>
+
+      <para>
+  Drivers supporting VGA or EGC 16-colour screens need:
+	<literallayout><filename>
+    "xf4bpp.h"
+	  </filename></literallayout>
+      </para>
+
+      <para>
+  Drivers using cfb need:
+	<programlisting>
+    #define PSZ 8
+    #include "cfb.h"
+    #undef PSZ
+	</programlisting>
+      </para>
+
+      <para>
+  Drivers supporting bpp 16, 24 or 32 with cfb need one or more of:
+	<literallayout><filename>
+    "cfb16.h"
+    "cfb24.h"
+    "cfb32.h"
+	  </filename></literallayout>
+      </para>
+
+      <para>
+  The driver's own header file:
+	<literallayout><filename>
+    "zzz.h"
+	  </filename></literallayout>
+      </para>
+
+      <para>
+  Drivers must NOT include the following:
+
+	<literallayout><filename>
+    "xf86Priv.h"
+    "xf86Privstr.h"
+    "xf86_libc.h"
+    "xf86_OSlib.h"
+    "Xos.h"</filename>
+    any OS header
+	</literallayout>
+      </para>
+
+    </sect2>
+
+    <sect2>
+      <title>Data structures and initialisation</title>
+
+      <itemizedlist>
+	<listitem>
+	  <para>The following macros should be defined:
+	    <programlisting>
+#define VERSION <version-as-an-int>
+#define ZZZ_NAME "ZZZ"         /* the name used to prefix messages */
+#define ZZZ_DRIVER_NAME "zzz"  /* the driver name as used in config file */
+#define ZZZ_MAJOR_VERSION <int>
+#define ZZZ_MINOR_VERSION <int>
+#define ZZZ_PATCHLEVEL    <int>
+	    </programlisting>
+	  </para>
+	  <para>
+    NOTE: <constant>ZZZ_DRIVER_NAME</constant> should match the name of the
+    driver module without things like the "lib" prefix, the "_drv" suffix
+    or filename extensions.
+	  </para>
+	</listitem>
+
+	<listitem>
+	  <para>
+    A DriverRec must be defined, which includes the functions required
+    at the pre-probe phase.  The name of this DriverRec must be an
+    upper-case version of ZZZ_DRIVER_NAME (for the purposes of static
+    linking).
+	    <programlisting>
+DriverRec ZZZ = {
+    VERSION,
+    ZZZ_DRIVER_NAME,
+    ZZZIdentify,
+    ZZZProbe,
+    ZZZAvailableOptions,
+    NULL,
+    0
+};
+	    </programlisting>
+	  </para>
+	</listitem>
+
+	<listitem>
+	  <para>Define list of supported chips and their matching ID:
+	    <programlisting>
+static SymTabRec ZZZChipsets[] = {
+    { PCI_CHIP_ZZZ1234, "zzz1234a" },
+    { PCI_CHIP_ZZZ5678, "zzz5678a" },
+    { -1,               NULL }
+};
+	    </programlisting>
+	  </para>
+	  <para>
+    The token field may be any integer value that the driver may use to
+    uniquely identify the supported chipsets.  For drivers that support
+    only PCI devices using the PCI device IDs might be a natural choice,
+    but this isn't mandatory.  For drivers that support both PCI and other
+    devices (like ISA), some other ID should probably used.  When other
+    IDs are used as the tokens it is recommended that the names be
+    defined as an <type>enum</type> type.
+	  </para>
+	</listitem>
+
+	<listitem>
+	  <para>
+    If the driver uses the <function>xf86MatchPciInstances()</function>
+    helper (recommended for drivers that support PCI cards) a list that
+    maps PCI IDs to chip IDs and fixed resources must be defined:
+	    <programlisting>
+static PciChipsets ZZZPciChipsets[] = {
+    { PCI_CHIP_ZZZ1234, PCI_CHIP_ZZZ1234, RES_SHARED_VGA },
+    { PCI_CHIP_ZZZ5678, PCI_CHIP_ZZZ5678, RES_SHARED_VGA },
+    { -1,               -1,               RES_UNDEFINED }
+}
+	    </programlisting>
+	  </para>
+	</listitem>
+
+	<listitem>
+	  <para>
+    Define the <structname>XF86ModuleVersionInfo</structname> struct for the
+    driver.  This is required for the dynamically loaded version:
+	    <programlisting>
+static XF86ModuleVersionInfo zzzVersRec =
+{
+    "zzz",
+    MODULEVENDORSTRING,
+    MODINFOSTRING1,
+    MODINFOSTRING2,
+    XF86_VERSION_CURRENT,
+    ZZZ_MAJOR_VERSION, ZZZ_MINOR_VERSION, ZZZ_PATCHLEVEL,
+    ABI_CLASS_VIDEODRV,
+    ABI_VIDEODRV_VERSION,
+    MOD_CLASS_VIDEODRV,
+    {0,0,0,0}
+};
+	    </programlisting>
+	  </para>
+	</listitem>
+
+	<listitem>
+	  <para>
+    Define a data structure to hold the driver's screen-specific data.
+    This must be used instead of global variables.  This would be defined
+    in the <filename>"zzz.h"</filename> file, something like:
+	    <programlisting>
+typedef struct {
+    type1  field1;
+    type2  field2;
+    int    fooHack;
+    Bool   pciRetry;
+    Bool   noAccel;
+    Bool   hwCursor;
+    CloseScreenProcPtr CloseScreen;
+    OptionInfoPtr Options;
+    ...
+} ZZZRec, *ZZZPtr;
+	    </programlisting>
+	  </para>
+	</listitem>
+
+	<listitem>
+	  <para>
+    Define the list of config file Options that the driver accepts.  For
+    consistency between drivers those in the list of <quote>standard</quote> options
+    should be used where appropriate before inventing new options.
+
+	    <programlisting>
+typedef enum {
+    OPTION_FOO_HACK,
+    OPTION_PCI_RETRY,
+    OPTION_HW_CURSOR,
+    OPTION_NOACCEL
+} ZZZOpts;
+
+static const OptionInfoRec ZZZOptions[] = {
+  { OPTION_FOO_HACK,  "FooHack",   OPTV_INTEGER, {0}, FALSE },
+  { OPTION_PCI_RETRY, "PciRetry",  OPTV_BOOLEAN, {0}, FALSE },
+  { OPTION_HW_CURSOR, "HWcursor",  OPTV_BOOLEAN, {0}, FALSE },
+  { OPTION_NOACCEL,   "NoAccel",   OPTV_BOOLEAN, {0}, FALSE },
+  { -1,               NULL,        OPTV_NONE,    {0}, FALSE }
+};
+	    </programlisting>
+	  </para>
+	</listitem>
+      </itemizedlist>
+    </sect2>
+
+    <sect2>
+      <title>Functions</title>
+
+
+      <sect3>
+	<title>SetupProc</title>
+
+	<para>
+    For dynamically loaded modules, a <varname>ModuleData</varname>
+    variable is required.  It is should be the name of the driver
+    prepended to "ModuleData".  A <function>Setup()</function> function is
+    also required, which calls <function>xf86AddDriver()</function> to add
+    the driver to the main list of drivers.
+	</para>
+
+	<programlisting>
+static MODULESETUPPROTO(zzzSetup);
+
+XF86ModuleData zzzModuleData = { &zzzVersRec, zzzSetup, NULL };
+
+static pointer
+zzzSetup(pointer module, pointer opts, int *errmaj, int *errmin)
+{
+    static Bool setupDone = FALSE;
+
+    /* This module should be loaded only once, but check to be sure. */
+
+    if (!setupDone) {
+        /*
+         * Modules that this driver always requires may be loaded
+         * here  by calling LoadSubModule().
+         */
+
+        setupDone = TRUE;
+        xf86AddDriver(&MGA, module, 0);
+
+        /*
+         * The return value must be non-NULL on success even though
+         * there is no TearDownProc.
+         */
+        return (pointer)1;
+    } else {
+        if (errmaj) *errmaj = LDR_ONCEONLY;
+        return NULL;
+    }
+}
+	</programlisting>
+      </sect3>
+
+      <sect3>
+	<title>GetRec, FreeRec</title>
+
+	<para>
+    A function is usually required to allocate the driver's
+    screen-specific data structure and hook it into the
+    <structname>ScrnInfoRec</structname>'s <structfield>driverPrivate</structfield> field.
+    The <structname>ScrnInfoRec</structname>'s <structfield>driverPrivate</structfield> is
+    initialised to <constant>NULL</constant>, so it is easy to check if the
+    initialisation has already been done.  After allocating it, initialise
+    the fields.  By using <function>xnfcalloc()</function> to do the allocation
+    it is zeroed, and if the allocation fails the server exits.
+	</para>
+
+	<para>
+    NOTE:
+    When allocating structures from inside the driver which are defined
+    on the common level it is important to initialize the structure to
+    zero.
+    Only this guarantees that the server remains source compatible to
+    future changes in common level structures.
+	</para>
+
+	<programlisting>
+static Bool
+ZZZGetRec(ScrnInfoPtr pScrn)
+{
+    if (pScrn->driverPrivate != NULL)
+        return TRUE;
+    pScrn->driverPrivate = xnfcalloc(sizeof(ZZZRec), 1);
+    /* Initialise as required */
+    ...
+    return TRUE;
+}
+	</programlisting>
+
+	<para>
+    Define a macro in <filename>"zzz.h"</filename> which gets a pointer to
+    the <structname>ZZZRec</structname> when given <parameter>pScrn</parameter>:
+
+	  <programlisting>
+#define ZZZPTR(p) ((ZZZPtr)((p)->driverPrivate))
+	  </programlisting>
+	</para>
+
+	<para>
+    Define a function to free the above, setting it to <constant>NULL</constant>
+    once it has been freed:
+
+	  <programlisting>
+static void
+ZZZFreeRec(ScrnInfoPtr pScrn)
+{
+    if (pScrn->driverPrivate == NULL)
+        return;
+    xfree(pScrn->driverPrivate);
+    pScrn->driverPrivate = NULL;
+}
+	  </programlisting>
+	</para>
+      </sect3>
+
+      <sect3>
+	<title>Identify</title>
+
+	<para>
+    Define the <function>Identify()</function> function.  It is run before
+    the Probe, and typically prints out an identifying message, which
+    might include the chipsets it supports.  This function is mandatory:
+
+	  <programlisting>
+static void
+ZZZIdentify(int flags)
+{
+    xf86PrintChipsets(ZZZ_NAME, "driver for ZZZ Tech chipsets",
+                      ZZZChipsets);
+}
+	  </programlisting>
+	</para>
+      </sect3>
+
+      <sect3>
+	<title>Probe</title>
+
+	<para>
+    Define the <function>Probe()</function> function.  The purpose of this
+    is to find all instances of the hardware that the driver supports,
+    and for the ones not already claimed by another driver, claim the
+    slot, and allocate a <structname>ScrnInfoRec</structname>.  This should be
+    a minimal probe, and it should under no circumstances leave the
+    state of the hardware changed.  Because a device is found, don't
+    assume that it will be used.  Don't do any initialisations other
+    than the required <structname>ScrnInfoRec</structname> initialisations.
+    Don't allocate any new data structures.
+	</para>
+
+	<para>
+    This function is mandatory.
+	</para>
+
+	<para>
+    NOTE: The <function>xf86DrvMsg()</function> functions cannot be used from
+    the Probe.
+	</para>
+
+	<programlisting>
+static Bool
+ZZZProbe(DriverPtr drv, int flags)
+{
+    Bool foundScreen = FALSE;
+    int numDevSections, numUsed;
+    GDevPtr *devSections;
+    int *usedChips;
+    int i;
+
+    /*
+     * Find the config file Device sections that match this
+     * driver, and return if there are none.
+     */
+    if ((numDevSections = xf86MatchDevice(ZZZ_DRIVER_NAME,
+                                          &devSections)) <= 0) {
+        return FALSE;
+    }
+
+    /*
+     * Since this is a PCI card, "probing" just amounts to checking
+     * the PCI data that the server has already collected.  If there
+     * is none, return.
+     *
+     * Although the config file is allowed to override things, it
+     * is reasonable to not allow it to override the detection
+     * of no PCI video cards.
+     *
+     * The provided xf86MatchPciInstances() helper takes care of
+     * the details.
+     */
+    /* test if PCI bus present */
+    if (xf86GetPciVideoInfo()) {
+
+        numUsed = xf86MatchPciInstances(ZZZ_NAME, PCI_VENDOR_ZZZ,
+                            ZZZChipsets, ZZZPciChipsets, devSections,
+                            numDevSections, drv, &usedChips);
+
+        for (i = 0; i < numUsed; i++) {
+            ScrnInfoPtr pScrn = NULL;
+            if ((pScrn = xf86ConfigPciEntity(pScrn, flags, usedChips[i],
+                                             ZZZPciChipsets, NULL, NULL,
+                                             NULL, NULL, NULL))) {
+               /* Allocate a ScrnInfoRec */
+               pScrn->driverVersion = VERSION;
+               pScrn->driverName    = ZZZ_DRIVER_NAME;
+               pScrn->name          = ZZZ_NAME;
+               pScrn->Probe         = ZZZProbe;
+               pScrn->PreInit       = ZZZPreInit;
+               pScrn->ScreenInit    = ZZZScreenInit;
+               pScrn->SwitchMode    = ZZZSwitchMode;
+               pScrn->AdjustFrame   = ZZZAdjustFrame;
+               pScrn->EnterVT       = ZZZEnterVT;
+               pScrn->LeaveVT       = ZZZLeaveVT;
+               pScrn->FreeScreen    = ZZZFreeScreen;
+               pScrn->ValidMode     = ZZZValidMode;
+               foundScreen = TRUE;
+               /* add screen to entity */
+           }
+        }
+        xfree(usedChips);
+    }
+
+#ifdef HAS_ISA_DEVS
+    /*
+     * If the driver supports ISA hardware, the following block
+     * can be included too.
+     */
+    numUsed = xf86MatchIsaInstances(ZZZ_NAME, ZZZChipsets,
+                             ZZZIsaChipsets, drv, ZZZFindIsaDevice,
+                             devSections, numDevSections, &usedChips);
+    for (i = 0; i < numUsed; i++) {
+        ScrnInfoPtr pScrn = NULL;
+	if ((pScrn = xf86ConfigIsaEntity(pScrn, flags, usedChips[i],
+					 ZZZIsaChipsets, NULL, NULL, NULL,
+					 NULL, NULL))) {
+            pScrn->driverVersion = VERSION;
+            pScrn->driverName    = ZZZ_DRIVER_NAME;
+            pScrn->name          = ZZZ_NAME;
+            pScrn->Probe         = ZZZProbe;
+            pScrn->PreInit       = ZZZPreInit;
+            pScrn->ScreenInit    = ZZZScreenInit;
+            pScrn->SwitchMode    = ZZZSwitchMode;
+            pScrn->AdjustFrame   = ZZZAdjustFrame;
+            pScrn->EnterVT       = ZZZEnterVT;
+            pScrn->LeaveVT       = ZZZLeaveVT;
+            pScrn->FreeScreen    = ZZZFreeScreen;
+            pScrn->ValidMode     = ZZZValidMode;
+            foundScreen = TRUE;
+        }
+    }
+    xfree(usedChips);
+#endif /* HAS_ISA_DEVS */
+
+    xfree(devSections);
+    return foundScreen;
+	</programlisting>
+      </sect3>
+
+      <sect3>
+	<title>AvailableOptions</title>
+
+	<para>
+    Define the <function>AvailableOptions()</function> function. The purpose
+    of this is to return the available driver options back to the
+    -configure option, so that an xorg.conf file can be built and the
+    user can see which options are available for them to use.
+	</para>
+      </sect3>
+
+      <sect3>
+	<title>PreInit</title>
+
+	<para>
+    Define the <function>PreInit()</function> function.  The purpose of
+    this is to find all the information required to determine if the
+    configuration is usable, and to initialise those parts of the
+    <structname>ScrnInfoRec</structname> that can be set once at the beginning
+    of the first server generation.  The information should be found in
+    the least intrusive way possible.
+	</para>
+
+	<para>
+    This function is mandatory.
+	</para>
+
+	<para>
+    NOTES:
+	  <orderedlist>
+	    <listitem><para>
+	 The <function>PreInit()</function> function is only called once
+	 during the life of the X server (at the start of the first
+	 generation).
+	      </para></listitem>
+
+	    <listitem><para>
+	 Data allocated here must be of the type that persists for
+	 the life of the X server.  This means that data that hooks into
+	 the <structname>ScrnInfoRec</structname>'s <structfield>privates</structfield>
+	 field should be allocated here, but data that hooks into the
+	 <structname>ScreenRec</structname>'s <structfield>devPrivates</structfield> field
+	 should not be allocated here.  The <structfield>driverPrivate</structfield>
+	 field should also be allocated here.
+	      </para></listitem>
+
+	    <listitem><para>
+	 Although the <structname>ScrnInfoRec</structname> has been allocated
+	 before this function is called, the <structname>ScreenRec</structname>
+	 has not been allocated.  That means that things requiring it
+	 cannot be used in this function.
+	      </para></listitem>
+
+	    <listitem><para>
+	 Very little of the <structname>ScrnInfoRec</structname> has been
+	 initialised when this function is called.  It is important to
+	 get the order of doing things right in this function.
+	      </para></listitem>
+
+	  </orderedlist>
+	</para>
+
+	<programlisting>
+static Bool
+ZZZPreInit(ScrnInfoPtr pScrn, int flags)
+{
+    /* Fill in the monitor field */
+    pScrn->monitor = pScrn->confScreen->monitor;
+
+    /*
+     * If using the vgahw module, it will typically be loaded
+     * here by calling xf86LoadSubModule(pScrn, "vgahw");
+     */
+
+    /*
+     * Set the depth/bpp.  Use the globally preferred depth/bpp.  If the
+     * driver has special default depth/bpp requirements, the defaults should
+     * be specified here explicitly.
+     * We support both 24bpp and 32bpp framebuffer layouts.
+     * This sets pScrn->display also.
+     */
+    if (!xf86SetDepthBpp(pScrn, 0, 0, 0,
+                         Support24bppFb | Support32bppFb)) {
+        return FALSE;
+    } else {
+        if (depth/bpp isn't one we support) {
+            print error message;
+            return FALSE;
+        }
+    }
+    /* Print out the depth/bpp that was set */
+    xf86PrintDepthBpp(pScrn);
+
+    /* Set bits per RGB for 8bpp */
+    if (pScrn->depth <= 8) {
+        /* Take into account a dac_6_bit option here */
+        pScrn->rgbBits = 6 or 8;
+    }
+
+    /*
+     * xf86SetWeight() and xf86SetDefaultVisual() must be called
+     * after pScrn->display is initialised.
+     */
+
+    /* Set weight/mask/offset for depth > 8 */
+    if (pScrn->depth > 8) {
+        if (!xf86SetWeight(pScrn, defaultWeight, defaultMask)) {
+            return FALSE;
+        } else {
+            if (weight isn't one we support) {
+                print error message;
+                return FALSE;
+            }
+        }
+    }
+
+    /* Set the default visual. */
+    if (!xf86SetDefaultVisual(pScrn, -1)) {
+        return FALSE;
+    } else {
+        if (visual isn't one we support) {
+            print error message;
+            return FALSE;
+        }
+    }
+
+    /* If the driver supports gamma correction, set the gamma. */
+    if (!xf86SetGamma(pScrn, default_gamma)) {
+        return FALSE;
+    }
+
+    /* This driver uses a programmable clock */
+    pScrn->progClock = TRUE;
+
+    /* Allocate the ZZZRec driverPrivate */
+    if (!ZZZGetRec(pScrn)) {
+        return FALSE;
+    }
+
+    pZzz = ZZZPTR(pScrn);
+
+    /* Collect all of the option flags (fill in pScrn->options) */
+    xf86CollectOptions(pScrn, NULL);
+
+    /*
+     * Process the options based on the information in ZZZOptions.
+     * The results are written to pZzz->Options.  If all of the options
+     * processing is done within this function a local variable "options"
+     * can be used instead of pZzz->Options.
+     */
+    if (!(pZzz->Options = xalloc(sizeof(ZZZOptions))))
+        return FALSE;
+    (void)memcpy(pZzz->Options, ZZZOptions, sizeof(ZZZOptions));
+    xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, pZzz->Options);
+
+    /*
+     * Set various fields of ScrnInfoRec and/or ZZZRec based on
+     * the options found.
+     */
+    from = X_DEFAULT;
+    pZzz->hwCursor = FALSE;
+    if (xf86IsOptionSet(pZzz->Options, OPTION_HW_CURSOR)) {
+        from = X_CONFIG;
+        pZzz->hwCursor = TRUE;
+    }
+    xf86DrvMsg(pScrn->scrnIndex, from, "Using %s cursor\n",
+               pZzz->hwCursor ? "HW" : "SW");
+    if (xf86IsOptionSet(pZzz->Options, OPTION_NOACCEL)) {
+        pZzz->noAccel = TRUE;
+        xf86DrvMsg(pScrn->scrnIndex, X_CONFIG,
+                   "Acceleration disabled\n");
+    } else {
+        pZzz->noAccel = FALSE;
+    }
+    if (xf86IsOptionSet(pZzz->Options, OPTION_PCI_RETRY)) {
+        pZzz->UsePCIRetry = TRUE;
+        xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "PCI retry enabled\n");
+    }
+    pZzz->fooHack = 0;
+    if (xf86GetOptValInteger(pZzz->Options, OPTION_FOO_HACK,
+                             &pZzz->fooHack)) {
+        xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Foo Hack set to %d\n",
+                   pZzz->fooHack);
+    }
+
+    /*
+     * Find the PCI slot(s) that this screen claimed in the probe.
+     * In this case, exactly one is expected, so complain otherwise.
+     * Note in this case we're not interested in the card types so
+     * that parameter is set to NULL.
+     */
+    if ((i = xf86GetPciInfoForScreen(pScrn->scrnIndex, &pciList, NULL))
+        != 1) {
+        print error message;
+        ZZZFreeRec(pScrn);
+        if (i > 0)
+            xfree(pciList);
+        return FALSE;
+    }
+    /* Note that pciList should be freed below when no longer needed */
+
+    /*
+     * Determine the chipset, allowing config file chipset and
+     * chipid values to override the probed information.  The config
+     * chipset value has precedence over its chipid value if both
+     * are present.
+     *
+     * It isn't necessary to fill in pScrn->chipset if the driver
+     * keeps track of the chipset in its ZZZRec.
+     */
+
+    ...
+
+    /*
+     * Determine video memory, fb base address, I/O addresses, etc,
+     * allowing the config file to override probed values.
+     *
+     * Set the appropriate pScrn fields (videoRam is probably the
+     * most important one that other code might require), and
+     * print out the settings.
+     */
+
+    ...
+
+    /* Initialise a clockRanges list. */
+
+    ...
+
+    /* Set any other chipset specific things in the ZZZRec */
+
+    ...
+
+    /* Select valid modes from those available */
+
+    i = xf86ValidateModes(pScrn, pScrn->monitor->Modes,
+                          pScrn->display->modes, clockRanges,
+                          NULL, minPitch, maxPitch, rounding,
+                          minHeight, maxHeight,
+                          pScrn->display->virtualX,
+                          pScrn->display->virtualY,
+                          pScrn->videoRam * 1024,
+                          LOOKUP_BEST_REFRESH);
+    if (i == -1) {
+        ZZZFreeRec(pScrn);
+        return FALSE;
+    }
+
+    /* Prune the modes marked as invalid */
+
+    xf86PruneDriverModes(pScrn);
+
+    /* If no valid modes, return */
+
+    if (i == 0 || pScrn->modes == NULL) {
+        print error message;
+        ZZZFreeRec(pScrn);
+        return FALSE;
+    }
+
+    /*
+     * Initialise the CRTC fields for the modes.  This driver expects
+     * vertical values to be halved for interlaced modes.
+     */
+    xf86SetCrtcForModes(pScrn, INTERLACE_HALVE_V);
+
+    /* Set the current mode to the first in the list. */
+    pScrn->currentMode = pScrn->modes;
+
+    /* Print the list of modes being used. */
+    xf86PrintModes(pScrn);
+
+    /* Set the DPI */
+    xf86SetDpi(pScrn, 0, 0);
+
+    /* Load bpp-specific modules */
+    switch (pScrn->bitsPerPixel) {
+    case 1:
+        mod = "xf1bpp";
+        break;
+    case 4:
+        mod = "xf4bpp";
+        break;
+    case 8:
+        mod = "cfb";
+        break;
+    case 16:
+        mod = "cfb16";
+        break;
+    case 24:
+        mod = "cfb24";
+        break;
+    case 32:
+        mod = "cfb32";
+        break;
+    }
+    if (mod && !xf86LoadSubModule(pScrn, mod))
+        ZZZFreeRec(pScrn);
+        return FALSE;
+
+    /* Load XAA if needed */
+    if (!pZzz->noAccel || pZzz->hwCursor)
+        if (!xf86LoadSubModule(pScrn, "xaa")) {
+            ZZZFreeRec(pScrn);
+            return FALSE;
+        }
+
+    /* Done */
+    return TRUE;
+}
+	</programlisting>
+      </sect3>
+
+      <sect3>
+	<title>MapMem, UnmapMem</title>
+
+	<para>
+    Define functions to map and unmap the video memory and any other
+    memory apertures required.  These functions are not mandatory, but
+    it is often useful to have such functions.
+	</para>
+
+	<programlisting>
+static Bool
+ZZZMapMem(ScrnInfoPtr pScrn)
+{
+    /* Call xf86MapPciMem() to map each PCI memory area */
+    ...
+    return TRUE or FALSE;
+}
+
+static Bool
+ZZZUnmapMem(ScrnInfoPtr pScrn)
+{
+    /* Call xf86UnMapVidMem() to unmap each memory area */
+    ...
+    return TRUE or FALSE;
+}
+	</programlisting>
+      </sect3>
+
+      <sect3>
+	<title>Save, Restore</title>
+
+	<para>
+    Define functions to save and restore the original video state.  These
+    functions are not mandatory, but are often useful.
+	</para>
+
+	<programlisting>
+static void
+ZZZSave(ScrnInfoPtr pScrn)
+{
+    /*
+     * Save state into per-screen data structures.
+     * If using the vgahw module, vgaHWSave will typically be
+     * called here.
+     */
+    ...
+}
+
+static void
+ZZZRestore(ScrnInfoPtr pScrn)
+{
+    /*
+     * Restore state from per-screen data structures.
+     * If using the vgahw module, vgaHWRestore will typically be
+     * called here.
+     */
+    ...
+}
+	</programlisting>
+      </sect3>
+
+      <sect3>
+	<title>ModeInit</title>
+
+	<para>
+    Define a function to initialise a new video mode.  This function isn't
+    mandatory, but is often useful.
+	</para>
+
+	<programlisting>
+static Bool
+ZZZModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
+{
+    /*
+     * Program a video mode.  If using the vgahw module,
+     * vgaHWInit and vgaRestore will typically be called here.
+     * Once up to the point where there can't be a failure
+     * set pScrn->vtSema to TRUE.
+     */
+    ...
+}
+	</programlisting>
+      </sect3>
+
+      <sect3>
+	<title>ScreenInit</title>
+
+	<para>
+    Define the <function>ScreenInit()</function> function.  This is called
+    at the start of each server generation, and should fill in as much
+    of the <structname>ScreenRec</structname> as possible as well as any other
+    data that is initialised once per generation.  It should initialise
+    the framebuffer layers it is using, and initialise the initial video
+    mode.
+	</para>
+
+	<para>
+    This function is mandatory.
+	</para>
+
+	<para>
+    NOTE: The <structname>ScreenRec</structname> (<parameter>pScreen</parameter>) is
+	  passed to this driver, but it and the
+	  <varname>ScrnInfoRecs</varname> are not yet hooked into each
+	  other.  This means that in this function, and functions it
+	  calls, one cannot be found from the other.
+	</para>
+
+	<programlisting>
+static Bool
+ZZZScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
+{
+    /* Get the ScrnInfoRec */
+    pScrn = xf86Screens[pScreen->myNum];
+
+    /*
+     * If using the vgahw module, its data structures and related
+     * things are typically initialised/mapped here.
+     */
+
+    /* Save the current video state */
+    ZZZSave(pScrn);
+
+    /* Initialise the first mode */
+    ZZZModeInit(pScrn, pScrn->currentMode);
+
+    /* Set the viewport if supported */
+
+    ZZZAdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0);
+
+    /*
+     * Setup the screen's visuals, and initialise the framebuffer
+     * code.
+     */
+
+    /* Reset the visual list */
+    miClearVisualTypes();
+
+    /*
+     * Setup the visuals supported.  This driver only supports
+     * TrueColor for bpp > 8, so the default set of visuals isn't
+     * acceptable.  To deal with this, call miSetVisualTypes with
+     * the appropriate visual mask.
+     */
+
+    if (pScrn->bitsPerPixel > 8) {
+        if (!miSetVisualTypes(pScrn->depth, TrueColorMask,
+                              pScrn->rgbBits, pScrn->defaultVisual))
+            return FALSE;
+    } else {
+        if (!miSetVisualTypes(pScrn->depth,
+                              miGetDefaultVisualMask(pScrn->depth),
+                              pScrn->rgbBits, pScrn->defaultVisual))
+            return FALSE;
+    }
+
+    /*
+     * Initialise the framebuffer.
+     */
+
+    switch (pScrn->bitsPerPixel) {
+    case 1:
+        ret = xf1bppScreenInit(pScreen, FbBase,
+                               pScrn->virtualX, pScrn->virtualY,
+                               pScrn->xDpi, pScrn->yDpi,
+                               pScrn->displayWidth);
+        break;
+    case 4:
+        ret = xf4bppScreenInit(pScreen, FbBase,
+                               pScrn->virtualX, pScrn->virtualY,
+                               pScrn->xDpi, pScrn->yDpi,
+                               pScrn->displayWidth);
+        break;
+    case 8:
+        ret = cfbScreenInit(pScreen, FbBase,
+                            pScrn->virtualX, pScrn->virtualY,
+                            pScrn->xDpi, pScrn->yDpi,
+                            pScrn->displayWidth);
+        break;
+    case 16:
+        ret = cfb16ScreenInit(pScreen, FbBase,
+                              pScrn->virtualX, pScrn->virtualY,
+                              pScrn->xDpi, pScrn->yDpi,
+                              pScrn->displayWidth);
+        break;
+    case 24:
+        ret = cfb24ScreenInit(pScreen, FbBase,
+                              pScrn->virtualX, pScrn->virtualY,
+                              pScrn->xDpi, pScrn->yDpi,
+                              pScrn->displayWidth);
+        break;
+    case 32:
+        ret = cfb32ScreenInit(pScreen, FbBase,
+                              pScrn->virtualX, pScrn->virtualY,
+                              pScrn->xDpi, pScrn->yDpi,
+                              pScrn->displayWidth);
+        break;
+    default:
+        print a message about an internal error;
+        ret = FALSE;
+        break;
+    }
+
+    if (!ret)
+        return FALSE;
+
+    /* Override the default mask/offset settings */
+    if (pScrn->bitsPerPixel > 8) {
+        for (i = 0, visual = pScreen->visuals;
+             i < pScreen->numVisuals; i++, visual++) {
+            if ((visual->class | DynamicClass) == DirectColor) {
+                visual->offsetRed = pScrn->offset.red;
+                visual->offsetGreen = pScrn->offset.green;
+                visual->offsetBlue = pScrn->offset.blue;
+                visual->redMask = pScrn->mask.red;
+                visual->greenMask = pScrn->mask.green;
+                visual->blueMask = pScrn->mask.blue;
+            }
+        }
+    }
+
+    /*
+     * If banking is needed, initialise an miBankInfoRec (defined in
+     * "mibank.h"), and call miInitializeBanking().
+     */
+    if (!miInitializeBanking(pScreen, pScrn->virtualX, pScrn->virtualY,
+                                     pScrn->displayWidth, pBankInfo))
+        return FALSE;
+
+    /*
+     * If backing store is to be supported (as is usually the case),
+     * initialise it.
+     */
+    miInitializeBackingStore(pScreen);
+
+    /*
+     * Set initial black & white colourmap indices.
+     */
+    xf86SetBlackWhitePixels(pScreen);
+
+    /*
+     * Install colourmap functions.  If using the vgahw module,
+     * vgaHandleColormaps would usually be called here.
+     */
+
+    ...
+
+    /*
+     * Initialise cursor functions.  This example is for the mi
+     * software cursor.
+     */
+    miDCInitialize(pScreen, xf86GetPointerScreenFuncs());
+
+    /* Initialise the default colourmap */
+    switch (pScrn->depth) {
+    case 1:
+        if (!xf1bppCreateDefColormap(pScreen))
+            return FALSE;
+        break;
+    case 4:
+        if (!xf4bppCreateDefColormap(pScreen))
+            return FALSE;
+        break;
+    default:
+        if (!cfbCreateDefColormap(pScreen))
+            return FALSE;
+        break;
+    }
+
+    /*
+     * Wrap the CloseScreen vector and set SaveScreen.
+     */
+    ZZZPTR(pScrn)->CloseScreen = pScreen->CloseScreen;
+    pScreen->CloseScreen = ZZZCloseScreen;
+    pScreen->SaveScreen = ZZZSaveScreen;
+
+    /* Report any unused options (only for the first generation) */
+    if (serverGeneration == 1) {
+        xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options);
+    }
+
+    /* Done */
+    return TRUE;
+}
+	</programlisting>
+      </sect3>
+
+      <sect3>
+	<title>SwitchMode</title>
+
+	<para>
+    Define the <function>SwitchMode()</function> function if mode switching
+    is supported by the driver.
+	</para>
+
+	<programlisting>
+static Bool
+ZZZSwitchMode(int scrnIndex, DisplayModePtr mode, int flags)
+{
+    return ZZZModeInit(xf86Screens[scrnIndex], mode);
+}
+	</programlisting>
+      </sect3>
+
+      <sect3>
+	<title>AdjustFrame</title>
+
+	<para>
+    Define the <function>AdjustFrame()</function> function if the driver
+    supports this.
+	</para>
+
+	<programlisting>
+static void
+ZZZAdjustFrame(int scrnIndex, int x, int y, int flags)
+{
+    /* Adjust the viewport */
+}
+	</programlisting>
+      </sect3>
+
+      <sect3>
+	<title>EnterVT, LeaveVT</title>
+
+	<para>
+    Define the <function>EnterVT()</function> and <function>LeaveVT()</function>
+    functions.
+	</para>
+
+	<para>
+    These functions are mandatory.
+	</para>
+
+	<programlisting>
+static Bool
+ZZZEnterVT(int scrnIndex, int flags)
+{
+    ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+    return ZZZModeInit(pScrn, pScrn->currentMode);
+}
+
+static void
+ZZZLeaveVT(int scrnIndex, int flags)
+{
+    ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+    ZZZRestore(pScrn);
+}
+	</programlisting>
+      </sect3>
+
+      <sect3>
+	<title>CloseScreen</title>
+
+	<para>
+    Define the <function>CloseScreen()</function> function:
+	</para>
+
+	<para>
+    This function is mandatory.  Note that it unwraps the previously
+    wrapped <structfield>pScreen->CloseScreen</structfield>, and finishes by
+    calling it.
+	</para>
+
+	<programlisting>
+static Bool
+ZZZCloseScreen(int scrnIndex, ScreenPtr pScreen)
+{
+    ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+    if (pScrn->vtSema) {
+        ZZZRestore(pScrn);
+        ZZZUnmapMem(pScrn);
+    }
+    pScrn->vtSema = FALSE;
+    pScreen->CloseScreen = ZZZPTR(pScrn)->CloseScreen;
+    return (*pScreen->CloseScreen)(scrnIndex, pScreen);
+}
+	</programlisting>
+      </sect3>
+
+      <sect3>
+	<title>SaveScreen</title>
+
+	<para>
+    Define the <function>SaveScreen()</function> function (the screen
+    blanking function).  When using the vgahw module, this will typically
+    be:
+
+	  <programlisting>
+static Bool
+ZZZSaveScreen(ScreenPtr pScreen, int mode)
+{
+    return vgaHWSaveScreen(pScreen, mode);
+}
+	  </programlisting>
+	</para>
+
+	<para>
+    This function is mandatory.  Before modifying any hardware register
+    directly this function needs to make sure that the Xserver is active
+    by checking if <parameter>pScrn</parameter> is non-NULL and for
+    <literal remap="tt">pScrn->vtSema == TRUE</literal>.
+	</para>
+      </sect3>
+
+      <sect3>
+	<title>FreeScreen</title>
+
+	<para>
+    Define the <function>FreeScreen()</function> function.  This function
+    is optional.  It should be defined if the <structname>ScrnInfoRec</structname>
+    <structfield>driverPrivate</structfield> field is used so that it can be freed
+    when a screen is deleted by the common layer for reasons possibly
+    beyond the driver's control.  This function is not used in during
+    normal (error free) operation.  The per-generation data is freed by
+    the <function>CloseScreen()</function> function.
+	</para>
+
+	<programlisting>
+static void
+ZZZFreeScreen(int scrnIndex, int flags)
+{
+    /*
+     * If the vgahw module is used vgaHWFreeHWRec() would be called
+     * here.
+     */
+    ZZZFreeRec(xf86Screens[scrnIndex]);
+}
+
+	</programlisting>
+
+      </sect3>
+
+    </sect2>
+
+  </sect1>
+
+</article>
diff --git a/hw/xfree86/doc/devel/Makefile.am b/hw/xfree86/doc/devel/Makefile.am
deleted file mode 100644
index c9eca5e..0000000
--- a/hw/xfree86/doc/devel/Makefile.am
+++ /dev/null
@@ -1,7 +0,0 @@
-# Documentation for developers that is distributed with the source but
-# not installed on the system for end-users
-
-EXTRA_DIST = \
-	Registry \
-	exa-driver.txt \
-	README.DRIcomp
diff --git a/hw/xfree86/doc/devel/README.DRIcomp b/hw/xfree86/doc/devel/README.DRIcomp
deleted file mode 100644
index 89f40a7..0000000
--- a/hw/xfree86/doc/devel/README.DRIcomp
+++ /dev/null
@@ -1,556 +0,0 @@
-                            DRI Compilation Guide
-
-          VA Linux Systems, Inc. Professional Services - Graphics.
-
-                                21 April 2001
-
-1.  Preamble
-
-1.1  Copyright
-
-Copyright 2000-2001 by VA Linux Systems, Inc.  All Rights Reserved.
-
-Permission is granted to make and distribute verbatim copies of this document
-provided the copyright notice and this permission notice are preserved on all
-copies.
-
-1.2  Trademarks
-
-OpenGL is a registered trademark and SGI is a trademark of Silicon Graphics,
-Inc.  Unix is a registered trademark of The Open Group.  The `X' device and X
-Window System are trademarks of The Open Group.  XFree86 is a trademark of
-The XFree86 Project.  Linux is a registered trademark of Linus Torvalds.
-Intel is a registered trademark of Intel Corporation.  3Dlabs, GLINT, and
-Oxygen are either registered trademarks or trademarks of 3Dlabs Inc. Ltd.
-3dfx, Voodoo3, Voodoo4, and Voodoo5 are registered trademarks of 3dfx Inter-
-active, Incorporated.  Matrox is a registered trademark of Matrox Electronic
-Systems Ltd.  ATI Rage and Radeon is a registered trademark of ATI Technolo-
-gies, Inc.  All other trademarks mentioned are the property of their respec-
-tive owners.
-
-2.  Introduction
-
-This document describes how to download, compile and install the DRI.  The
-DRI provides 3D graphics hardware acceleration for the XFree86 project.  This
-information is intended for experienced Linux developers.  Beginners are
-probably better off installing precompiled packages.
-
-Edits, corrections and updates to this document may be mailed to <brian at tung-
-stengraphics.com>.
-
-Last updated on 13 February 2002 by Brian Paul.
-
-3.  Prerequisites
-
-You'll need the following:
-
-   o An installation of XFree86 4.1 or later.  The DRI tree has been pruned
-     down to minimize its size.  But in order to build the DRI tree you need
-     to have recent X header files, etc. already installed.  If you don't
-     have XFree86 4.1 (or later) installed you can probably install it from
-     RPMs (or another package format).  Or, you can download XFree86 as
-     sources and compile/install it yourself.
-
-   o At least 200MB of free disk space.  If you compile for debugging (the -g
-     option) then you'll need about 600MB.
-
-   o GCC compiler and related tools.
-
-   o ssh (secure shell) if you're a DRI developer and don't want to use
-     anonymous CVS download.
-
-   o A 2.4.x Linux Kernel.  See below for details.
-
-   o FreeBSD support is not currently being maintained and may not work.
-
-The DRI 3D drivers generally work on systems with Intel or AMD CPUs.  How-
-ever, limited support for Alpha and PowerPC support is underway.
-
-For 3dfx Voodoo hardware, you'll also need the Glide3 runtime library
-(libglide3-v3.so for Voodoo3 or libglide3-v5.so for Voodoo4/5).  These can be
-downloaded from the DRI website.  You can compile them yourself, but it's
-often a painful process.
-
-For Matrox G200/G400, Intel i810/i830 or ATI Rage128/Radeon hardware, you'll
-also need AGP support in your Linux kernel, either built-in or as a loadable
-module.
-
-4.  Linux Kernel Preparation
-
-Only the Linux 2.4.x kernels are currently supported by the DRI hardware
-drivers.  2.5.x kernels may work, but aren't tested.
-
-Most of the DRI drivers require AGP support and using Intel Pentium III SSE
-optimizations also requires an up-to-date Linux kernel.  Configuring your
-kernel correctly is very important, as features such as SSE optimizations
-will be disabled if your kernel does not support them.  Thus, if you have a
-Pentium III processor, you must configure your kernel for the Pentium III
-processor family.
-
-Building a new Linux kernel can be difficult for beginners but there are
-resources on the Internet to help.  This document assumes experience with
-configuring, building and installing Linux kernels.
-
-Linux kernels can be downloaded from www.kernel.org
-
-Here are the basic steps for kernel setup.
-
-   o Download the needed kernel and put it in /usr/src.  Create a directory
-     for the source and unpack it.  For example:
-
-                    cd /usr/src
-                    rm -f linux
-                    mkdir linux-2.4.x
-                    ln -s linux-2.4.x linux
-                    bzcat linux-2.4.x.tar.bz2 | tar xf -
-
-     It is critical that /usr/src/linux point to your new kernel sources,
-     otherwise the kernel headers will not be used when building the DRI.
-     This will almost certainly cause compilation problems.
-
-   o Read /usr/src/linux/Documentation/Changes.  This file lists the minimum
-     requirements for all software packages required to build the kernel.
-     You must upgrade at least gcc, make, binutils and modutils to at least
-     the versions specified in this file.  The other packages may not be
-     needed.  If you are upgrading from Linux 2.2.x you must upgrade your
-     modutils package for Linux 2.4.x.
-
-   o Configure your kernel.  You might, for example, use make menuconfig and
-     do the following:
-
-        o Go to Code maturity level options
-
-        o Enable Prompt for development and/or incomplete code/drivers
-
-        o hit ESC to return to the top-level menu
-
-        o Go to Processor type and features
-
-        o Select your processor type from Processor Family
-
-        o hit ESC to return to the top-level menu
-
-        o Go to Character devices
-
-        o Disable Direct Rendering Manager (XFree86 DRI support) since we'll
-          use the DRI code from the XFree86/DRI tree and will compile it
-          there.
-
-        o Go to /dev/agpgart (AGP Support) (EXPERIMENTAL) (NEW)
-
-        o Hit SPACE twice to build AGP support into the kernel
-
-        o Enable all chipsets' support for AGP
-
-        o It's recommended that you turn on MTRRs under Processor type and
-          Features, but not required.
-
-   o Configure the rest of the kernel as required for your system (i.e. Eth-
-     ernet, SCSI, etc)
-
-   o Exit, saving your kernel configuration.
-
-   o Edit your /etc/lilo.conf file.  Make sure you have an image entry as
-     follows (or similar):
-
-                      image=/boot/vmlinuz
-                            label=linux.2.4.x
-                            read-only
-                            root=/dev/hda1
-
-     The important part is that you have /boot/vmlinuz without a trailing
-     version number.  If this is the first entry in your /etc/lilo.conf AND
-     you haven't set a default, then this will be your default kernel.
-
-   o Compile the new kernel.
-
-                    cd /usr/src/linux-2.4.x
-                    make dep
-                    make bzImage
-                    make modules
-                    make modules_install
-                    make install
-
-     Note that last make command will automatically run lilo for you.
-
-   o Now reboot to use the new kernel.
-
-5.  CPU Architectures
-
-In general, nothing special has to be done to use the DRI on different CPU
-architectures.  There are, however, a few optimizations that are CPU-depen-
-dent.  Mesa will determine at runtime which CPU-dependent optimizations
-should be used and enable them where appropriate.
-
-5.1  Intel Pentium III Features
-
-The Pentium III SSE instructions are used in optimized vertex transformation
-functions in the Mesa-based DRI drivers.  On Linux, SSE requires a recent
-kernel (such as 2.4.0-test11 or later) both at compile time and runtime.
-
-5.2  AMD 3DNow! Features
-
-AMD's 3DNow! instructions are used in optimized vertex transformation func-
-tions in the Mesa-based DRI drivers.  3DNow! is supported in most versions of
-Linux.
-
-5.3  Alpha Features
-
-On newer Alpha processors a significant performance increase can be seen with
-the addition of the -mcpu= option to GCC.  This option is dependent on the
-architecture of the processor.  For example, -mcpu=ev6 will build specifi-
-cally for the EV6 based AXP's, giving both byte and word alignment access to
-the DRI/Mesa drivers.
-
-To enable this optimization edit your xc/config/host.def file and add the
-line:
-
-#define DefaultGcc2AxpOpt -O2 -mcpu=ev6
-
-Additional speed improvements to 3D rendering can be achieved by installing
-Compaq's Math Libraries (CPML) which can be obtained from http://www.sup-
-port.compaq.com/alpha-tools/software/index.html
-
-Once installed, you can add this line to your host.def to build with the CPML
-libraries:
-
-#define UseCompaqMathLibrary YES
-
-The host.def file is explained below.
-
-6.  Downloading the XFree86/DRI CVS Sources
-
-The DRI project is hosted by SourceForge.  The DRI source code, which is a
-subset of the XFree86 source tree, is kept in a CVS repository there.
-
-The DRI CVS sources may be accessed either anonymously or as a registered
-SourceForge user.  It's recommended that you become a registered SourceForge
-user so that you may submit non-anonymous bug reports and can participate in
-the mailing lists.
-
-6.1  Anonymous CVS download:
-
-  1.  Create a directory to store the CVS files:
-
-                       cd ~
-                       mkdir DRI-CVS
-
-      You could put your CVS directory in a different place but we'll use
-      ~/DRI-CVS/ here.
-
-  2.  Check out the CVS sources:
-
-                       cd ~/DRI-CVS
-                       cvs -d:pserver:anonymous at cvs.dri.sourceforge.net:/cvsroot/dri login
-                         (hit ENTER when prompted for a password)
-                       cvs -z3 -d:pserver:anonymous at cvs.dri.sourceforge.net:/cvsroot/dri co xc
-
-      The -z3 flag causes compression to be used in order to reduce the down-
-      load time.
-
-6.2  Registered CVS download:
-
-  1.  Create a directory to store the CVS files:
-
-                       cd ~
-                       mkdir DRI-CVS
-
-      You could put your CVS directory in a different place but we'll use
-      ~/DRI-CVS/ here.
-
-  2.  Set the CVS_RSH environment variable:
-
-                       setenv CVS_RSH ssh      // if using csh or tcsh
-                       export CVS_RSH=ssh      // if using sh or bash
-
-  3.  Check out the CVS sources:
-
-                       cd ~/DRI-CVS
-                       cvs -z3 -d:ext:YOURID at cvs.dri.sourceforge.net:/cvsroot/dri co xc
-
-      Replace YOURID with your CVS login name.  You'll be prompted to enter
-      your sourceforge password.
-
-      The -z3 flag causes compression to be used in order to reduce the down-
-      load time.
-
-6.3  Updating your CVS sources
-
-In the future you'll want to occasionally update your local copy of the DRI
-source code to get the latest changes.  This can be done with:
-
-                cd ~/DRI-CVS
-                cvs -z3 update -dA xc
-
-The -d flag causes any new subdirectories to be created and -A causes most
-recent trunk sources to be fetched, not branch sources.
-
-7.  Mesa
-
-Most of the DRI 3D drivers are based on Mesa (the free implementation of the
-OpenGL API).  The relevant files from Mesa are already included in the
-XFree86/DRI source tree.  There is no need to download or install the Mesa
-source files separately.
-
-Sometimes a newer version of Mesa will be available than the version included
-in XFree86/DRI.  Upgrading Mesa within XFree86/DRI is not always straightfor-
-ward.  It can be an error-prone undertaking, especially for beginners, and is
-not generally recommended.  The DRI developers will upgrade Mesa when appro-
-priate.
-
-8.  Compiling the XFree86/DRI tree
-
-8.1  Make a build tree
-
-Rather than placing object files and library files right in the source tree,
-they're instead put into a parallel build tree.  The build tree is made with
-the lndir command:
-
-                 cd ~/DRI-CVS
-                 ln -s xc XFree40
-                 mkdir build
-                 cd build
-                 lndir -silent -ignorelinks ../XFree40
-
-The build tree will be populated with symbolic links which point back into
-the CVS source tree.
-
-Advanced users may have several build trees for compiling and testing with
-different options.
-
-8.2  Edit the host.def file
-
-The ~/DRI-CVS/build/xc/config/cf/host.def file is used to configure the
-XFree86 build process.  You can change it to customize your build options or
-make adjustments for your particular system configuration
-
-The default host.def file will look something like this:
-
-                 #define DefaultCCOptions -Wall
-     (i386)      #define DefaultGcc2i386Opt -O2
-     (Alpha)     #define DefaultGcc2AxpOpt -O2 -mcpu=ev6 (or similar)
-                 #define LibraryCDebugFlags -O2
-                 #define BuildServersOnly YES
-                 #define XF86CardDrivers vga tdfx mga ati i810
-                 #define LinuxDistribution LinuxRedHat
-                 #define DefaultCCOptions -ansi GccWarningOptions -pipe
-                 #define BuildXF86DRI YES
-                 /* Optionally turn these on for debugging */
-                 /* #define GlxBuiltInTdfx YES */
-                 /* #define GlxBuiltInMga YES */
-                 /* #define GlxBuiltInR128 YES */
-                 /* #define GlxBuiltInRadeon YES */
-                 /* #define DoLoadableServer NO */
-                 #define SharedLibFont NO
-
-The ProjectRoot variable specifies where the XFree86 files will be installed.
-We recommend installing the DRI files over your existing XFree86 installation
-- it's generally safe to do and less error-prone.  This policy is different
-than what we used to recommend.
-
-If XFree86 4.x is not installed in /usr/X11R6/ you'll have to add the follow-
-ing to the host.def file:
-
-                 #define ProjectRoot pathToYourXFree86installation
-
-Note the XF86CardDrivers line to be sure your card's driver is listed.
-
-If you want to enable 3DNow! optimizations in Mesa and the DRI drivers, you
-should add the following:
-
-                 #define MesaUse3DNow YES
-
-You don't have to be using an AMD processor in order to enable this option.
-The DRI will look for 3DNow! support and runtime and only enable it if appli-
-cable.
-
-If you want to enable SSE optimizations in Mesa and the DRI drivers, you must
-upgrade to a Linux 2.4.x kernel.  Mesa will verify that SSE is supported by
-both your processor and your operating system, but to build Mesa inside the
-DRI you need to have the Linux 2.4.x kernel headers in /usr/src/linux.  If
-you enable SSE optimizations with an earlier version of the Linux kernel in
-/usr/src/linux, Mesa will not compile.  You have been warned.  If you do have
-a 2.4.x kernel, you should add the following:
-
-                 #define MesaUseSSE YES
-
-If you want to build the DRM kernel modules as part of the full build pro-
-cess, add the following:
-
-                 #define BuildXF86DRM YES
-
-Otherwise, you'll need to build them separately as described below.
-
-8.3  Compilation
-
-To compile the complete DRI tree:
-
-                 cd ~/DRI-CVS/build/xc/
-                 make World >& world.log
-
-Or if you want to watch the compilation progress:
-
-                 cd ~/DRI-CVS/build/xc/
-                 make World >& world.log &
-                 tail -f world.log
-
-With the default compilation flags it's normal to get a lot of warnings dur-
-ing compilation.
-
-Building will take some time so you may want to go check your email or visit
-slashdot.
-
-WARNING: do not use the -j option with make.  It's reported that it does not
-work with XFree86/DRI.
-
-8.4  Check for compilation errors
-
-Using your text editor, examine world.log for errors by searching for the
-pattern ***.
-
-After fixing the errors, run make World again.  Later, you might just compile
-parts of the source tree but it's important that the whole tree will build
-first.
-
-If you edited your host.def file to enable automatic building of the DRI ker-
-nel module(s), verify that they were built:
-
-               cd ~/DRI-CVS/build/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel
-               ls
-
-Otherwise, build them now by running
-
-               cd ~/DRI-CVS/build/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel
-               make -f Makefile.linux
-
-For the 3dfx Voodoo, you should see tdfx.o.  For the Matrox G200/G400, you
-should see mga.o.  For the ATI Rage 128, you should see r128.o.  For the ATI
-Radeon, you should see radeon.o.  For the Intel i810, you should see i810.o.
-
-If the DRI kernel module(s) failed to build you should verify that you're
-using the right version of the Linux kernel.  The most recent kernels are not
-always supported.
-
-If your build machine is running a different version of the kernel than your
-target machine (i.e. 2.2.x vs. 2.4.x), make will select the wrong kernel
-source tree. This can be fixed by explicitly setting the value of LINUXDIR.
-If the path to your kernel source is /usr/src/linux-2.4.x,
-
-               cd ~/DRI-CVS/build/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel
-               make -f Makefile.linux LINUXDIR=/usr/src/linux-2.4.x
-
-or alternatively, edit Makefile.linux to set LINUXDIR before the ifndef LIN-
-UXDIR line.
-
-8.5  DRI kernel module installation
-
-The DRI kernel modules will be in ~/DRI-CVS/build/xc/pro-
-grams/Xserver/hw/xfree86/os-support/linux/drm/kernel/.
-
-To load the appropriate DRM module in your running kernel you can either use
-ismod and restart your X server or copy the kernel module to /lib/mod-
-ules/2.4.x/kernel/drivers/char/drm/ then run depmod and restart your X
-server.
-
-Make sure you first unload any older DRI kernel modules that might be already
-loaded.
-
-Note that some DRM modules require that the agpgart module be loaded first.
-
-9.  Normal Installation and Configuration
-
-Most users will want to install the new X server and use it in place of their
-old X server.  This section explains how to do that.
-
-Developers, on the other hand, may just want to test the X server without
-actually installing it as their default server.  If you want to do that, skip
-to the next section.
-
-9.1  Installation
-
-Here are the installation commands:
-
-                su
-                cd ~/DRI-CVS/build/xc
-                make install
-
-9.2  Update the XF86Config File
-
-You may need to edit your XF86Config file to enable the DRI.  The config file
-is usually installed as /etc/X11/XF86Config-4.  See the DRI User Guide for
-details, but basically, you need to load the "glx" and "dri" modules and add
-a "DRI" section.
-
-On the DRI web site, in the resources section, you'll find example XF86Config
-files for a number of graphics cards.  These configuration files also setup
-DRI options so it's highly recommended that you look at these examples.
-
-The XFree86 4.x server can generate a basic configuration file itself.  Sim-
-ply do this:
-
-                  cd /usr/X11R6/bin
-                  ./XFree86 -configure
-
-A file named /root/XF86Config.new will be created.  It should allow you to
-try your X server but you'll almost certainly have to edit it.  For example,
-you should add HorizSync and VertRefresh options to the Monitor section and
-Modes options to the Screen section.  Also, the ModulePath option in the
-Files section should be set to /usr/X11R6/lib/modules.
-
-9.3  Start the New X Server
-
-The new X server should be ready to use now.  Start your X server in your
-usual manner.  Often times the startx command is used:
-
-                  startx
-
-10.  Testing the Server Without Installing It
-
-As mentioned at the start of section 9, developers may want to simply run the
-X server without installing it.  This can save some time and allow you to
-keep a number of X servers available for testing.
-
-10.1  Configuration
-
-As described in the preceding section, you'll need to create a configuration
-file for the new server.  Put the XF86Config file in your ~/DRI-
-CVS/build/xc/programs/Xserver directory.
-
-Be sure the ModulePath option in your XF86Config file is set correctly.
-
-10.2  A Startup Script
-
-A simple shell script can be used to start the X server.  Here's an example.
-
-             #!/bin/sh
-             export DISPLAY=:0
-             ./XFree86 -xf86config XF86Config & \
-             sleep 2
-             fvwm2 &
-             xset b off
-             xmodmap -e "clear mod4"
-             xsetroot -solid "#00306f"
-             xterm -geometry 80x40+0+0
-
-You might name this script start-dri.  Put it in your ~/DRI-CVS/build/xc/pro-
-grams/Xserver directory.
-
-To test the server run the script:
-
-                  cd ~/DRI-CVS/build/xc/programs/Xserver
-                  ./start-dri
-
-For debugging, you may also want to capture the log messages printed by the
-server in a file.  If you're using the C-shell:
-
-                  ./start-dri >& log
-
-11.  Where To Go From Here
-
-At this point your X server should be up and running with hardware-acceler-
-ated direct rendering.  Please read the DRI User Guide for information about
-trouble shooting and how to use the DRI-enabled X server for 3D applications.
-
-     Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/DRIcomp.sgml,v 1.19 dawes Exp $
-
-
diff --git a/hw/xfree86/doc/devel/Registry b/hw/xfree86/doc/devel/Registry
deleted file mode 100644
index 48e24a2..0000000
--- a/hw/xfree86/doc/devel/Registry
+++ /dev/null
@@ -1,409 +0,0 @@
-This is the XFree86 driver/module registry.  To avoid name space clashes and
-to maintain some consistency between drivers the important name spaces are
-maintained here.
-
-1. Module Names.
-
-Each module is required to have a unique name.  Registered names are:
-
-GLcore
-acecad
-afb
-apm
-ark
-ati
-atimisc
-bitmap
-bt8xx
-calcomp
-cfb
-cfb16
-cfb24
-cfb32
-chips
-cirrus
-citron
-cyrix
-dbe
-ddc
-digitaledge
-dmc
-dri
-drm
-dynapro
-elo2300
-elographics
-extmod
-fb
-fbdev
-fbdevhw
-fi12x6
-freetype
-glide
-glint
-glx
-hyperpen
-i128
-i2c
-i740
-i810
-imstt
-int10
-joystick
-keyboard
-layer
-magellan
-magictouch
-mfb
-mga
-microtouch
-mouse
-msp34xx
-mutouch
-neomagic
-newport
-nv
-pcidata
-penmount
-pex5
-r128
-radeon
-rac
-ramdac
-record
-rendition
-s3
-s3virge
-savage
-shadow
-shadowfb
-siliconmotion
-sis
-spaceorb
-speedo
-summa
-sunbw2
-suncg14
-suncg3
-suncg6
-sunffb
-sunleo
-suntcx
-tdfx
-tga
-trident
-tseng
-type1
-v4l
-vbe
-vesa
-vga
-vgahw
-vmware
-void
-wacom
-xaa
-xf1bpp
-xf24_32bpp
-xf4bpp
-xf8_16bpp
-xf8_32bpp
-xf8_32wid
-xie
-xtrap
-xtt
-
-2. External Module Object Symbols.
-
-Each module is required to use a unique prefix or prefixes for all of
-its externally visible symbols. They should be unique without regard to
-case.  Registered prefixes are:
-
-ati
-bt8xx
-cfb
-chips
-fi12x6
-glide
-glint
-mfb
-mga
-msp34xx
-neo
-permedia
-tseng
-vga
-vgahw
-vmware
-xaa
-xf1bpp
-xf4bpp
-
-3. Chipset Names.
-
-Each video driver is required to use a unique set of chipset names.  Case,
-white space and underscore characters are ignored when comparing chipset
-names.  All names listed here are in lower case with all white space and
-underscores removed.  Registered chipset names are:
-
-ati
-ativga
-ct64200
-ct64300
-ct65520
-ct65525
-ct65530
-ct65535
-ct65540
-ct65545
-ct65546
-ct65548
-ct65550
-ct65554
-ct65555
-ct68554
-ct69000
-et4000
-et4000w32
-et4000w32i
-et4000w32p
-et6000
-et6100
-generic
-ibmvga
-ibm8514
-mach32
-mach64
-mach8
-mga2064w
-mga1064sg
-mga2164w
-mga2164wagp
-neo2070
-neo2090
-neo2093
-neo2097
-neo2160
-neo2200
-tipm2
-vgawonder
-voodoo
-
-4. Option Names.
-
-Option names and their usage should be consistent between drivers.
-Case, white space and underscore characters are ignored when comparing
-option names.  The prefix "no" may be added or removed from boolean
-option names.  All names listed here are in their preferred user-visible
-form.  Some registered option names are:
-
-Types are:  B = boolean, O = set/unset (no value), I = integer, S = string,
-            A = optional string, F = floating point number Q = frequency
-
-Scopes are: F = global flags, V = video driver, C = common (per screen),
-            I = input drivers, X = XAA, Xv = Xv extension, M = misc.
-
-Names currently in use:
-
-Name                    Type  Scope      Description
-----------------------------------------------------------------------------
-AllowMouseOpenFail        B     F    ignore mouse dev open failure
-AllowNonLocalModInDev     B     F    allow non-local mod of input devs
-AllowNonLocalXvidtune     B     F    allow non-local VidMode connections
-BlankTime                 I     F    Screen saver timeout (min)
-DisableModInDev           B     F    disallow changing input devs
-DisableVidModeExtension   B     F    disable VidMode extension
-DontVTSwitch              B     F    disable Ctrl-Alt-Fn
-DontZap                   B     F    disable Ctrl-Alt-BS sequence
-DontZoom                  B     F    disable Ctrl-Alt-+/-
-NoTrapSignals             B     F    don't trap signals
-OffTime                   I     F    Time before DPMS off mode active (min)
-PciProbe1                 O     F    use PCI probe algorithm 1
-PciProbe2                 O     F    use PCI probe algorithm 2
-PciForceConfig1           O     F    force PCI config type 1
-PciForceConfig2           O     F    force PCI config type 2
-Pixmap                    I     F    depth 24 pixmap size (24 or 32)
-StandbyTime               I     F    Time before DPMS standby active (min)
-SuspendTime               I     F    Time before DPMS suspend mode active (min)
-
-BackingStore              B     C    Enable backing store
-DDC                       B     C    Enable/disable DDC
-DDC1                      B     C    Enable/disable DDC1
-DDC2                      B     C    Enable/disable DDC2
-DPMS                      O     C    Enable DPMS
-MTRR                      B     C    Enable/disable setting MTRRs
-
-BaudRate                  I     I    Serial port baud rate
-ButtonNumber              I     I    Button number (for touch screen?)
-ButtonThreshold           I     I    ??
-ClearDTR                  O     I    Clear serial port DTR
-ClearRTS                  O     I    Clear serial port RTS
-DataBits                  I     I    Serial port data bits
-DemandLoad                O     I    ??
-Device                    S     I    Device file name
-DeviceName                S     I    Input device name
-FlowControl               S     I    Serial flow control ("xon", "none")
-Floating                  B     I    Device initialised as floating
-HistorySize               I     I    ??
-MaxX                      I     I    Maximum X coordinate
-MaxY                      I     I    Maximum Y coordinate
-MinX                      I     I    Minimum X coordinate
-MinY                      I     I    Minimum Y coordinate
-Parity                    S     I    Serial port parity ("odd", "even", "none")
-ReportDelay               I     I    ??
-ReportingMode             S     I    may be "raw" or "scaled"
-ScreenNumber              I     I    Screen number (for touch screen)
-SendCoreEvents            B     I    Send core events
-StopBits                  I     I    Serial port stop bits
-SwapXY                    B     I    Swap the X and Y axes
-UntouchDelay              I     I    ??
-Vmin                      I     I    Tty VMIN
-Vtime                     I     I    Tty VTIME
-
-
-18BitBus                  B     V    ??
-8Plus16                   B     V    Enable depth 8 + depth 16 with overlay
-8Plus24                   B     V    Enable depth 8 + depth 24 with overlay
-BlockWrite                B     V    Enable/disable block write
-ColorKey                  I     V    Set the color key for overlay modes
-CompositeSync             B     V    Composite sync
-CRTDisplay                B     V    Force display on CRT, not LCD
-CRTScreen                 B     V    Display on CRT, not LCD (Obsolete)
-EarlyRasPrecharge         O     V    Early RAS pre-charge
-FastDRAM                  O     V    Fast DRAM
-FifoAggressive            O     V    Aggressive FIFO setting
-FifoConservative          O     V    Conservative FIFO setting
-FifoModerate              O     V    Moderate FIFO setting
-FireGL3000                B     V    Card is Diamond FireGL3000
-FixPanelSize              B     V    ??
-FPClock8                  Q     V    Flat panel clock for 8bpp fb (MHz)
-FPClock16                 Q     V    Flat panel clock for 16bpp fb (MHz)
-FPClock24                 Q     V    Flat panel clock for 24bpp fb (MHz)
-FPClock32                 Q     V    Flat panel clock for 32bpp fb (MHz)
-FPMVRAM                   O     V    Fast page mode VRAM
-FramebufferWC             B     V    Enable/disable WC for the framebuffer
-GlideDevice               I     V    Selects which Voodoo board to use
-HiBitHigh                 O     V    High clock bit default to set
-HiBitLow                  O     V    High clock bit default to cleared
-HWClocks                  B     V    Enable/disable HW clocks
-HWCursor                  B     V    Enable/disable HW cursor
-LateRasPrecharge          O     V    Late RAS pre-charge
-Legend                    O     V    Card is Legend ET4000
-LCDCenter                 B     V    Enable/disable centering for LCD displays
-Linear                    B     V    Enable/disable linear framebuffer
-MCLK                      Q     V    Specify the current MCLK value (MHz)
-MedDRAM                   B     V    Medium speed DRAM
-MemCfg1                   I     V    ??
-MemCfg2                   I     V    ??
-MGASDRAM                  B     V    Mga card has SDRAM
-MMIO                      B     V    Enable/disable memory mapped I/O
-MMIOCache                 B     V    Enable/Disable MMIO cache
-MuxThreshold              I     V    Multiplexing threshold (kHz)
-NoAccel                   B     V    Disable/enable acceleration
-NoClockChip               B     V    ??
-NoStretch                 B     V    Disable/enable stretching for LCD displays
-OnAtExit                  B     V    Leave video signal on when exiting server
-OverclockMem              B     V    Enable memory overclocking
-Overlay                   A     V    Enable multi-depth/overlay.  An optional
-                                     string "M,N" may be specified, where
-                                     M, N are the depths.
-PanelDisplay              B     V    Force display on LCD
-PciBurst                  B     V    Enable/disable PCI burst mode
-PciRetry                  B     V    Enable/disable PCI retries
-ProbeClocks               B     V    Force probe for non-programmable clocks
-ReferenceClock            Q     V    Clock generator reference frequency
-RGBbits                   I     V    Number of significant bits per rgb
-Rotate                    S     V    Rotate the virtual display (CW or CCW)
-SetLCDClk                 Q     V    Set LCD clock (MHz)
-SetMclk                   Q     V    Set Memory Clock (MHz)
-ShadowFB                  B     V    Enable shadow framebuffer layer
-ShowCache                 B     V    Enable viewing of offscreen memory
-ShowOverscan              O     V    Set the overscan area to a visible colour
-SlowDRAM                  O     V    Slow DRAM
-SlowEDODRAM               O     V    Slow EDO DRAM
-STN                       B     V    STN screen type (??)
-SWCursor                  B     V    Enable/disable SW cursor
-SuspendHack               B     V    ??
-SyncOnGreen               B     V    Enable/disable sync on green
-TurboQueue                B     V    Enable/disable turbo queue
-UseFBDev                  B     V    Use the fbdev driver interface
-UseModeLine               B     V    Use Modeline (??)
-W32Interleave             B     V    ??
-
-Buffers			  I	Xv   Number of buffers
-Device			  S	Xv   Device file name
-Expose                    B     Xv   Disable occlusion clipping (see DESIGN)
-FramesPerSec		  I	Xv   Max. refresh frequency
-
-XAA options.  All are of type "O" and scope "X", and are self-explanatory
-
-XaaNoColor8x8PatternFillRect
-XaaNoColor8x8PatternFillTrap
-XaaNoCPUToScreenColorExpandFill
-XaaNoDashedBresenhamLine
-XaaNoDashedTwoPointLine
-XaaNoScreenToScreenCopy
-XaaNoImageReadRect
-XaaNoImageWriteRect
-XaaNoMono8x8PatternFillRect
-XaaNoMono8x8PatternFillTrap
-XaaNoOffscreenPixmaps
-XaaNoPixmapCache
-XaaNoScanlineCPUToScreenColorExpandFill
-XaaNoScanlineImageWriteRect
-XaaNoScreenToScreenColorExpandFill
-XaaNoSolidBresenhamLine
-XaaNoSolidFillRect
-XaaNoSolidFillTrap
-XaaNoSolidHorVertLine
-XaaNoSolidTwoPointLine
-
-
-Names used in previous versions:
-
-16Clocks
-8Clocks
-ClkDiv2
-EDO VRAM
-ExternDisp
-ExtFramBuf
-FastVRAM
-FavorBitBlt
-InternDisp
-NoBitBlt
-NoFontCache
-NoImageBlt
-NoMemAccess
-NoPciDisconnect
-NoPixmapCache
-NoProgramClocks
-NoSplitXfer
-OverrideBIOS
-OverrideValidateMode
-ProgLcdModeRegs
-ProgLcdModeStretch
-SlowDRAMrefresh
-SlowVRAM
-SwapHiBit
-
-
-5. Ramdac Names.
-
-Ramdac names should be consistent between drivers.  Case, white space
-and underscore characters are ignored when comparing ramdac names.  All
-names listed here are in lower case with all white space and underscores
-removed.
-
-
-6. Clock Chip Names.
-
-Clock chip names should be consistent between drivers.  Case, white
-space and underscore characters are ignored when comparing clock chip
-names.  All names listed here are in lower case with all white space
-and underscores removed.
-
-
-
-
-
-$XFree86: xc/programs/Xserver/hw/xfree86/Registry,v 1.18 2002/04/06 18:31:09 tsi Exp $
diff --git a/hw/xfree86/doc/devel/exa-driver.txt b/hw/xfree86/doc/devel/exa-driver.txt
deleted file mode 100644
index 048307e..0000000
--- a/hw/xfree86/doc/devel/exa-driver.txt
+++ /dev/null
@@ -1,94 +0,0 @@
-Adding EXA support to your X.Org video driver
----------------------------------------------
-EXA (for EXcellent Architecture or Ex-kaa aXeleration Architecture or
-whatever) aims to extend the life of the venerable XFree86 video drivers by
-introducing a new set of acceleration hooks that efficiently accelerate the X
-Render extension, including solid fills, blits within screen memory and to and
-from system memory, and Porter-Duff compositing and transform operations.
-
-Configuration
--------------
-A new config file option, AccelMethod, should be added to your driver, to allow
-the user to select between the EXA and XAA acceleration APIs.
-
-Some drivers implement a per-instance useEXA flag to track whether EXA is
-active or not.  It can be helpful to also conditionalize XAA support with an
-ifdef so that it can easily be turned off/removed in the future.
-
-Setting the flag and checking for AccelMethod can be done in the driver's
-Options parsing routine.
-
-Loading EXA
-------------
-EXA drivers in the XFree86 DDX should use the loadable module loader to load
-the EXA core.  Careful versioning allows the EXA API to be extended without
-breaking the ABI for older versions of drivers.  Example code for loading EXA:
-
-static const char *exaSymbols[] = {
-    "exaDriverAlloc",
-    "exaDriverInit",
-    "exaDriverFini",
-    "exaOffscreenAlloc",
-    "exaOffscreenFree",
-    "exaGetPixmapOffset",
-    "exaGetPixmapPitch",
-    "exaGetPixmapSize",
-    "exaMarkSync",
-    "exaWaitSync",
-    NULL
-};
-
-	if (info->useEXA) {
-	    info->exaReq.majorversion = 2;
-	    info->exaReq.minorversion = 0;
-
-	    if (!LoadSubModule(pScrn->module, "exa", NULL, NULL, NULL,
-			       &info->exaReq, &errmaj, &errmin)) {
-		LoaderErrorMsg(NULL, "exa", errmaj, errmin);
-		return FALSE;
-	    }
-	    xf86LoaderReqSymLists(exaSymbols, NULL);
-	}
-
-EXA is then initialized using exaDriverAlloc and exaDriverInit.  See doxygen
-documentation for getting started there.
-
-Further documentation
-------------
-The EXA driver interface and public API is documented using doxygen in
-xserver/xorg/exa/.  To build the documentation, run:
-  doxygen -g
-  doxygen Doxyfile
-The resulting documentation will appear an html/index.html under the current
-directory.
-
-EXA initialization
-------------------
-Your driver's AccelInit routine must initialize an ExaDriverRec structure if
-EXA support is enabled, with appropriate error handling (i.e.  NoAccel and
-NoXvideo should be set to true if EXA fails to initialize for whatever
-reason).
-
-The AccelInit routine also needs to make sure that there's enough offscreen
-memory for certain operations to function, like Xvideo, which should advertise
-a maximum size no larger than can be dealt with given the amount of offscreen
-memory available.
-
-EXA and Xv
-----------
-Video support becomes easier with EXA since AllocateFBMemory can use
-exaOffscreenAlloc directly, freeing a previous area if necessary and
-allocating a new one.  Likewise, FreeFBMemory can call exaOffscreenFree.
-
-EXA teardown
-------------
-At screen close time, EXA drivers should call exaDriverFini with their screen
-pointer, free their EXADriver structure, and do any other necessary teardown.
-
-EXA misc.
----------
-In many drivers, DGA support will need to be changed to be aware of the new
-EXA support.
-
-Send updates and corrections to Jesse Barnes <jbarnes at virtuousgeek.org> or
-just check them in if you have permission.
diff --git a/hw/xfree86/doc/exa-driver.txt b/hw/xfree86/doc/exa-driver.txt
new file mode 100644
index 0000000..048307e
--- /dev/null
+++ b/hw/xfree86/doc/exa-driver.txt
@@ -0,0 +1,94 @@
+Adding EXA support to your X.Org video driver
+---------------------------------------------
+EXA (for EXcellent Architecture or Ex-kaa aXeleration Architecture or
+whatever) aims to extend the life of the venerable XFree86 video drivers by
+introducing a new set of acceleration hooks that efficiently accelerate the X
+Render extension, including solid fills, blits within screen memory and to and
+from system memory, and Porter-Duff compositing and transform operations.
+
+Configuration
+-------------
+A new config file option, AccelMethod, should be added to your driver, to allow
+the user to select between the EXA and XAA acceleration APIs.
+
+Some drivers implement a per-instance useEXA flag to track whether EXA is
+active or not.  It can be helpful to also conditionalize XAA support with an
+ifdef so that it can easily be turned off/removed in the future.
+
+Setting the flag and checking for AccelMethod can be done in the driver's
+Options parsing routine.
+
+Loading EXA
+------------
+EXA drivers in the XFree86 DDX should use the loadable module loader to load
+the EXA core.  Careful versioning allows the EXA API to be extended without
+breaking the ABI for older versions of drivers.  Example code for loading EXA:
+
+static const char *exaSymbols[] = {
+    "exaDriverAlloc",
+    "exaDriverInit",
+    "exaDriverFini",
+    "exaOffscreenAlloc",
+    "exaOffscreenFree",
+    "exaGetPixmapOffset",
+    "exaGetPixmapPitch",
+    "exaGetPixmapSize",
+    "exaMarkSync",
+    "exaWaitSync",
+    NULL
+};
+
+	if (info->useEXA) {
+	    info->exaReq.majorversion = 2;
+	    info->exaReq.minorversion = 0;
+
+	    if (!LoadSubModule(pScrn->module, "exa", NULL, NULL, NULL,
+			       &info->exaReq, &errmaj, &errmin)) {
+		LoaderErrorMsg(NULL, "exa", errmaj, errmin);
+		return FALSE;
+	    }
+	    xf86LoaderReqSymLists(exaSymbols, NULL);
+	}
+
+EXA is then initialized using exaDriverAlloc and exaDriverInit.  See doxygen
+documentation for getting started there.
+
+Further documentation
+------------
+The EXA driver interface and public API is documented using doxygen in
+xserver/xorg/exa/.  To build the documentation, run:
+  doxygen -g
+  doxygen Doxyfile
+The resulting documentation will appear an html/index.html under the current
+directory.
+
+EXA initialization
+------------------
+Your driver's AccelInit routine must initialize an ExaDriverRec structure if
+EXA support is enabled, with appropriate error handling (i.e.  NoAccel and
+NoXvideo should be set to true if EXA fails to initialize for whatever
+reason).
+
+The AccelInit routine also needs to make sure that there's enough offscreen
+memory for certain operations to function, like Xvideo, which should advertise
+a maximum size no larger than can be dealt with given the amount of offscreen
+memory available.
+
+EXA and Xv
+----------
+Video support becomes easier with EXA since AllocateFBMemory can use
+exaOffscreenAlloc directly, freeing a previous area if necessary and
+allocating a new one.  Likewise, FreeFBMemory can call exaOffscreenFree.
+
+EXA teardown
+------------
+At screen close time, EXA drivers should call exaDriverFini with their screen
+pointer, free their EXADriver structure, and do any other necessary teardown.
+
+EXA misc.
+---------
+In many drivers, DGA support will need to be changed to be aware of the new
+EXA support.
+
+Send updates and corrections to Jesse Barnes <jbarnes at virtuousgeek.org> or
+just check them in if you have permission.
diff --git a/hw/xfree86/doc/sgml/.gitignore b/hw/xfree86/doc/sgml/.gitignore
deleted file mode 100644
index b0b2d05..0000000
--- a/hw/xfree86/doc/sgml/.gitignore
+++ /dev/null
@@ -1,6 +0,0 @@
-#		Add & Override for this directory and it's subdirectories
-DESIGN.html
-DESIGN.pdf
-DESIGN.ps
-DESIGN.txt
-xorg.css
diff --git a/hw/xfree86/doc/sgml/DESIGN.xml b/hw/xfree86/doc/sgml/DESIGN.xml
deleted file mode 100644
index 08f8bc8..0000000
--- a/hw/xfree86/doc/sgml/DESIGN.xml
+++ /dev/null
@@ -1,9394 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
- "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
- <!ENTITY % defs SYSTEM "/xserver/doc/xml/xserver.ent"> %defs;
- <!-- config file keyword markup -->
- <!-- specific config file keywords -->
- <!ENTITY k.device "<emphasis>Device</emphasis>">
- <!ENTITY k.monitor "<emphasis>Monitor</emphasis>">
- <!ENTITY k.display "<emphasis>Display</emphasis>">
- <!ENTITY k.inputdevice "<emphasis>InputDevice</emphasis>">
- <!ENTITY k.screen "<emphasis>Screen</emphasis>">
- <!ENTITY k.serverlayout "<emphasis>ServerLayout</emphasis>">
- <!ENTITY k.driver "<emphasis>Driver</emphasis>">
- <!ENTITY k.module "<emphasis>Module</emphasis>">
- <!ENTITY k.identifier "<emphasis>Identifier</emphasis>">
- <!ENTITY k.serverflags "<emphasis>ServerFlags</emphasis>">
-] >
-
-<article>
-  <articleinfo>
-
-    <title>XFree86 DDX Design (Xorg server version &xserver.version;)</title>
-
-    <authorgroup>
-      <corpauthor><ulink url="http://www.xfree86.org/">
-	The XFree86 Project, Inc.</ulink></corpauthor>
-      <corpauthor><ulink url="http://www.x.org/">
-	The X.Org Foundation, Inc.</ulink></corpauthor>
-
-      <othercredit>
-	<firstname>Jim</firstname><surname>Gettys</surname>
-	<contrib>Updates for X11R6.7</contrib>
-      </othercredit>
-    </authorgroup>
-
-    <pubdate>&xserver.reldate;</pubdate>
-    <releaseinfo>Xorg server version &xserver.version;</releaseinfo>
-
-  </articleinfo>
-
-  <note><para>
-This document describes software undergoing continual evolution, and
-the interfaces described here are subject to change without notice.
-This document is intended to cover the interfaces as found in the
-xorg-server-&xserver.version; release, but is probably not completely
-in sync with the code base.
-    </para></note>
-
-
-  <sect1>
-    <title>Preface</title>
-
-    <para>
-This document was originally the design spec for the DDX layer of the
-XFree86 4.0 X server.  The X.Org Foundation adopted the XFree86 4.4rc2
-version of that server as the basis of the Xorg server project, and has
-evolved the XFree86 DDX layer greatly since forking.   This document thus
-covers only the current implementation of the XFree86 DDX as found in the
-Xorg server &xserver.version; release, and no longer matches the XFree86
-server itself.
-      </para>
-
-    <para>
-The XFree86 Project's broad design principles for XFree86 4.0 were:
-      <itemizedlist>
-	<listitem><para>keep it reasonable
-	    <itemizedlist>
-	      <listitem><para>We cannot rewrite the complete server
-		</para></listitem>
-	      <listitem><para>We don't want to re-invent the wheel
-		</para></listitem>
-	    </itemizedlist></para></listitem>
-	<listitem><para>keep it modular
-	    <itemizedlist>
-	      <listitem><para>As many things as possible should go into modules
-		</para></listitem>
-	      <listitem><para>The basic loader binary should be minimal
-		</para></listitem>
-	      <listitem><para>A clean design with well defined layering is
-		  important</para></listitem>
-	      <listitem><para>DDX specific global variables are a nono
-		</para></listitem>
-	      <listitem><para>The structure should be flexible enough to allow
-		  future extensions</para></listitem>
-	      <listitem><para>The structure should minimize duplication of
-		  common code</para></listitem>
-	    </itemizedlist></para></listitem>
-	<listitem><para>keep important features in mind
-	    <itemizedlist>
-	      <listitem><para>multiple screens, including multiple instances
-		  of drivers</para></listitem>
-	      <listitem><para>mixing different color depths and visuals on
-		  different and ideally even on the same screen
-		</para></listitem>
-	      <listitem><para>better control of the PCI device used
-		</para></listitem>
-	      <listitem><para>better config file parser</para></listitem>
-	      <listitem><para>get rid of all VGA compatibility assumptions
-		</para></listitem>
-	    </itemizedlist></para></listitem>
-      </itemizedlist>
-    </para>
-
-    <para>
-While the XFree86 project had a goal of avoiding changes to the DIX
-layer unless they found major deficiencies there, to avoid divergence from
-the X.Org sample implementation they were integrating changes from, the
-X.Org developers now maintain both sides, and make changes where they are
-most appropriate.   This document concentrates on the XFree86 DDX layer used
-in the Xorg server itself (the code found in <filename>hw/xfree86</filename>
-in the source tree), and developers will also want to refer to the
-<filename>Xserver-spec</filename> documentation that covers the DIX layer
-routines common to all the X servers in the sample implementation.
-    </para>
-  </sect1>
-
-  <sect1>
-    <title>The xorg.conf File</title>
-
-    <para>
-The xorg.conf file format is based on the XF86Config format from XFree86 4.4,
-which is in turn similar to the old XFree86 3.x XF86Config format, with the
-following changes:
-    </para>
-
-    <sect2>
-      <title>&k.device; section</title>
-
-      <para>
-    The &k.device; sections are similar to what they used to be, and
-    describe hardware-specific information for a single video card.
-    &k.device;
-    Some new keywords are added:
-
-
-	<variablelist>
-	  <varlistentry><term>Driver "drivername"</term>
-	    <listitem><para>
-        Specifies the name of the driver to be used for the card.  This
-        is mandatory.
-	      </para></listitem></varlistentry>
-	  <varlistentry><term>BusID "busslot"</term>
-	    <listitem><para>
-        Specifies uniquely the location of the card on the bus.  The
-        purpose is to identify particular cards in a multi-headed
-        configuration.  The format of the argument is intentionally
-        vague, and may be architecture dependent.  For a PCI bus, it
-        is something like "bus:slot:func".
-	      </para></listitem></varlistentry>
-	</variablelist>
-      </para>
-
-      <para>
-    A &k.device; section is considered <quote>active</quote> if there is a reference
-    to it in an active &k.screen; section.
-      </para>
-    </sect2>
-
-    <sect2>
-      <title>&k.screen; section</title>
-
-      <para>
-    The &k.screen; sections are similar to what they used to be.  They
-    no longer have a &k.driver; keyword, but an &k.identifier; keyword
-    is added.  (The &k.driver; keyword may be accepted in place of the
-    &k.identifier; keyword for compatibility purposes.)  The identifier
-    can be used to identify which screen is to be active when multiple
-    &k.screen; sections are present.  It is possible to specify the active
-    screen from the command line.  A default is chosen in the absence
-    of one being specified.  A &k.screen; section is considered <quote>active</quote>
-    if there is a reference to it either from the command line, or from
-    an active &k.serverlayout; section.
-      </para>
-    </sect2>
-
-    <sect2>
-      <title>&k.inputdevice; section</title>
-
-      <para>
-    The &k.inputdevice; section is a new section that describes
-    configuration information for input devices.  It replaces the old
-    <emphasis>Keyboard</emphasis>, <emphasis>Pointer</emphasis> and <emphasis>XInput</emphasis>
-    sections.  Like the &k.device; section, it has two mandatory keywords:
-    &k.identifier; and &k.driver;.  For compatibility purposes the old
-    <emphasis>Keyboard</emphasis> and <emphasis>Pointer</emphasis> sections are
-    converted by the parser into &k.inputdevice; sections as follows:
-
-	<variablelist>
-	  <varlistentry><term><emphasis>Keyboard</emphasis></term>
-	    <listitem><literallayout>
-             &k.identifier; "Implicit Core Keyboard"
-             &k.driver; "keyboard"
-	      </literallayout></listitem></varlistentry>
-	  <varlistentry><term><emphasis>Pointer</emphasis></term>
-	    <listitem><literallayout>
-             &k.identifier; "Implicit Core Pointer"
-             &k.driver; "mouse"
-	      </literallayout></listitem></varlistentry>
-	</variablelist>
-      </para>
-
-      <para>
-    An &k.inputdevice; section is considered active if there is a
-    reference to it in an active &k.serverlayout; section.  An
-    &k.inputdevice; section may also be referenced implicitly if there
-    is no &k.serverlayout; section, if the <option>-screen</option> command
-    line options is used, or if the &k.serverlayout; section doesn't
-    reference any &k.inputdevice; sections.  In this case, the first
-    sections with drivers "keyboard" and "mouse" are used as the core
-    keyboard and pointer respectively.
-      </para>
-    </sect2>
-
-    <sect2>
-      <title>&k.serverlayout; section</title>
-
-      <para>
-    The &k.serverlayout; section is a new section that is used to identify
-    which &k.screen; sections are to be used in a multi-headed configuration,
-    and the relative layout of those screens.  It also identifies which
-    &k.inputdevice; sections are to be used.  Each &k.serverlayout; section
-    has an identifier, a list of &k.screen; section identifiers, and a list of
-    &k.inputdevice; section identifiers.  &k.serverflags; options may also be
-    included in a &k.serverlayout; section, making it possible to override
-    the global values in the &k.serverflags; section.
-      </para>
-
-      <para>
-    A &k.serverlayout; section can be made active by being referenced on
-    the command line.  In the absence of this, a default will be chosen
-    (the first one found).  The screen names may optionally be followed
-    by a number specifying the preferred screen number, and optionally
-    by information specifying the physical positioning of the screen,
-    either in absolute terms or relative to another screen (or screens).
-    When no screen number is specified, they are numbered according to
-    the order in which they are listed.  The old (now obsolete) method
-    of providing the positioning information is to give the names of
-    the four adjacent screens.  The order of these is top, bottom, left,
-    right.  Here is an example of a &k.serverlayout; section for two
-    screens using the old method, with the second located to the right
-    of the first:
-
-	<programlisting>
-      Section "ServerLayout"
-        Identifier "Main Layout"
-        Screen     0 "Screen 1" ""  ""  ""  "Screen 2"
-        Screen     1 "Screen 2"
-        Screen     "Screen 3"
-      EndSection
-	</programlisting>
-      </para>
-
-      <para>
-    The preferred way of specifying the layout is to explicitly specify
-    the screen's location in absolute terms or relative to another
-    screen.
-      </para>
-
-      <para>
-    In the absolute case, the upper left corner's coordinates are given
-    after the <emphasis>Absolute</emphasis> keyword.  If the coordinates are
-    omitted, a value of <code>(0,0)</code> is assumed.  An example
-    of absolute positioning follows:
-
-	<programlisting>
-      Section "ServerLayout"
-        Identifier "Main Layout"
-        Screen     0 "Screen 1" Absolute 0 0
-        Screen     1 "Screen 2" Absolute 1024 0
-        Screen     "Screen 3" Absolute 2048 0
-      EndSection
-	</programlisting>
-      </para>
-
-      <para>
-    In the relative case, the position is specified by either using one of
-    the following keywords followed by the name of the reference screen:
-
-	<simplelist type='vert' columns='1'>
-	  <member><emphasis>RightOf</emphasis></member>
-	  <member><emphasis>LeftOf</emphasis></member>
-	  <member><emphasis>Above</emphasis></member>
-	  <member><emphasis>Below</emphasis></member>
-	  <member><emphasis>Relative</emphasis></member>
-	</simplelist>
-      </para>
-
-      <para>
-    When the <emphasis>Relative</emphasis> keyword is used, the reference screen
-    name is followed by the coordinates of the new screen's origin
-    relative to reference screen.  The following example shows how to use
-    some of the relative positioning options.
-
-	<programlisting>
-      Section "ServerLayout"
-        Identifier "Main Layout"
-        Screen     0 "Screen 1"
-        Screen     1 "Screen 2" RightOf "Screen 1"
-        Screen     "Screen 3" Relative "Screen 1" 2048 0
-      EndSection
-	</programlisting>
-      </para>
-    </sect2>
-
-    <sect2>
-      <title>Options</title>
-
-      <para>
-    Options are used more extensively.  They may appear in most sections
-    now.  Options related to drivers can be present in the &k.screen;,
-    &k.device; and &k.monitor; sections and the &k.display; subsections.
-    The order of precedence is &k.display;, &k.screen;, &k.monitor;,
-    &k.device;.  Options have been extended to allow an optional value
-    to be specified in addition to the option name.  For more details
-    about options, see the <link linkend="options">Options</link> section
-    for details.
-      </para>
-    </sect2>
-  </sect1>
-
-  <sect1>
-    <title>Driver Interface</title>
-
-    <para>
-The driver interface consists of a minimal set of entry points that are
-required based on the external events that the driver must react to.
-No non-essential structure is imposed on the way they are used beyond
-that.  This is a significant difference compared with the old design.
-    </para>
-
-    <para>
-The entry points for drawing operations are already taken care of by
-the framebuffer code (including, XAA).  Extensions and enhancements to
-framebuffer code are outside the scope of this document.
-    </para>
-
-    <para>
-This approach to the driver interface provides good flexibility, but does
-increase the complexity of drivers.  To help address this, the XFree86
-common layer provides a set of <quote>helper</quote> functions to take care of things
-that most drivers need.  These helpers help minimise the amount of code
-duplication between drivers.  The use of helper functions by drivers is
-however optional, though encouraged.  The basic philosophy behind the
-helper functions is that they should be useful to many drivers, that
-they should balance this against the complexity of their interface.  It
-is inevitable that some drivers may find some helpers unsuitable and
-need to provide their own code.
-    </para>
-
-    <para>
-Events that a driver needs to react to are:
-
-      <variablelist>
-	<varlistentry><term>ScreenInit</term>
-
-	  <listitem><para>
-     An initialisation function is called from the DIX layer for each
-     screen at the start of each server generation.
-	    </para></listitem></varlistentry>
-
-	<varlistentry><term>Enter VT</term>
-
-	  <listitem><para>
-     The server takes control of the console.
-	    </para></listitem></varlistentry>
-
-	<varlistentry><term>Leave VT</term>
-
-	  <listitem><para>
-     The server releases control of the console.
-	    </para></listitem></varlistentry>
-
-	<varlistentry><term>Mode Switch</term>
-
-	  <listitem><para>
-     Change video mode.
-	    </para></listitem></varlistentry>
-
-	<varlistentry><term>ViewPort change</term>
-
-	  <listitem><para>
-     Change the origin of the physical view port.
-	    </para></listitem></varlistentry>
-
-	<varlistentry><term>ScreenSaver state change</term>
-
-	  <listitem><para>
-     Screen saver activation/deactivation.
-	    </para></listitem></varlistentry>
-
-	<varlistentry><term>CloseScreen</term>
-
-	  <listitem><para>
-     A close screen function is called from the DIX layer for each screen
-     at the end of each server generation.
-	    </para></listitem></varlistentry>
-      </variablelist>
-    </para>
-
-
-    <para>
-In addition to these events, the following functions are required by
-the XFree86 common layer:
-
-      <variablelist>
-	<varlistentry><term>Identify</term>
-
-	  <listitem><para>
-     Print a driver identifying message.
-	    </para></listitem></varlistentry>
-
-	<varlistentry><term>Probe</term>
-
-	  <listitem><para>
-     This is how a driver identifies if there is any hardware present that
-     it knows how to drive.
-	    </para></listitem></varlistentry>
-
-	<varlistentry><term>PreInit</term>
-
-	  <listitem><para>
-     Process information from the xorg.conf file, determine the
-     full characteristics of the hardware, and determine if a valid
-     configuration is present.
-	    </para></listitem></varlistentry>
-      </variablelist>
-    </para>
-
-    <para>
-The VidMode extension also requires:
-
-      <variablelist>
-	<varlistentry><term>ValidMode</term>
-
-	  <listitem><para>
-     Identify if a new mode is usable with the current configuration.
-     The PreInit function (and/or helpers it calls) may also make use
-     of the ValidMode function or something similar.
-	    </para></listitem></varlistentry>
-      </variablelist>
-    </para>
-
-
-    <para>
-Other extensions may require other entry points.  The drivers will
-inform the common layer of these in such cases.
-    </para>
-  </sect1>
-
-  <sect1>
-    <title>Resource Access Control Introduction</title>
-
-    <para>
-Graphics devices are accessed through ranges in I/O or memory space.
-While most modern graphics devices allow relocation of such ranges many
-of them still require the use of well established interfaces such as
-VGA memory and IO ranges or 8514/A IO ranges.  With modern buses (like
-PCI) it is possible for multiple video devices to share access to these
-resources.  The RAC (Resource Access Control) subsystem provides a
-mechanism for this.
-    </para>
-
-    <sect2>
-      <title>Terms and Definitions</title>
-
-      <sect3>
-	<title>Bus</title>
-
-	<para>
-    <quote>Bus</quote> is ambiguous as it is used for different things: it may refer
-    to physical incompatible extension connectors in a computer system.
-    The RAC system knows two such systems: The ISA bus and the PCI bus.
-    (On the software level EISA, MCA and VL buses are currently treated
-    like ISA buses).  <quote>Bus</quote> may also refer to logically different
-    entities on a single bus system which are connected via bridges.  A
-    PCI system may have several distinct PCI buses connecting each other
-    by PCI-PCI bridges or to the host CPU by HOST-PCI bridges.
-	</para>
-
-	<para>
-    Systems that host more than one bus system link these together using
-    bridges.  Bridges are a concern to RAC as they might block or pass
-    specific resources.  PCI-PCI bridges may be set up to pass VGA
-    resources to the secondary bus.  PCI-ISA buses pass any resources not
-    decoded on the primary PCI bus to the ISA bus.  This way VGA resources
-    (although exclusive on the ISA bus) can be shared by ISA and PCI
-    cards.  Currently HOST-PCI bridges are not yet handled by RAC as they
-    require specific drivers.
-	</para>
-      </sect3>
-
-      <sect3>
-	<title>Entity</title>
-
-	<para>
-    The smallest independently addressable unit on a system bus is
-    referred to as an entity.  So far we know ISA and PCI entities.  PCI
-    entities can be located on the PCI bus by an unique ID consisting of
-    the bus, card and function number.
-	</para>
-      </sect3>
-
-      <sect3>
-	<title>Resource</title>
-
-	<para>
-    <quote>Resource</quote> refers to a range of memory or I/O addresses an entity
-    can decode.
-	</para>
-
-	<para>
-    If a device is capable of disabling this decoding the resource is
-    called sharable.  For PCI devices a generic method is provided to
-    control resource decoding.  Other devices will have to provide a
-    device specific function to control decoding.
-	</para>
-
-	<para>
-    If the entity is capable of decoding this range at a different
-    location this resource is considered relocatable.
-	</para>
-
-	<para>
-    Resources which start at a specific address and occupy a single
-    continuous range are called block resources.
-	</para>
-
-	<para>
-    Alternatively resource addresses can be decoded in a way that they
-    satisfy the conditions:
-	  <programlisting>
-                    address & mask == base
-	  </programlisting>
-    and
-	  <programlisting>
-                       base & mask == base
-	  </programlisting>
-    Resources addressed in such a way are called sparse resources.
-	</para>
-
-      </sect3>
-
-      <sect3>
-	<title>Server States</title>
-
-	<para>
-    The resource access control system knows two server states: the
-    SETUP and the OPERATING state.  The SETUP state is entered whenever
-    a mode change takes place or the server exits or does VT switching.
-    During this state all entity resources are under resource access
-    control.  During OPERATING state only those entities are controlled
-    which actually have shared resources that conflict with others.
-	</para>
-      </sect3>
-    </sect2>
-  </sect1>
-
-  <sect1>
-    <title>Control Flow in the Server and Mandatory Driver Functions</title>
-
-    <para>
-At the start of each server generation, <function>main()</function>
-(<filename>dix/main.c</filename>) calls the DDX function
-<function>InitOutput()</function>.  This is the first place that the DDX gets
-control.  <function>InitOutput()</function> is expected to fill in the global
-<structname>screenInfo</structname> struct, and one
-<structfield>screenInfo.screen[]</structfield> entry for each screen present.
-Here is what <function>InitOutput()</function> does:
-    </para>
-
-    <sect2>
-      <title>Parse the xorg.conf file</title>
-
-      <para>
-    This is done at the start of the first server generation only.
-      </para>
-
-      <para>
-    The xorg.conf file is read in full, and the resulting information
-    stored in data structures.  None of the parsed information is
-    processed at this point.  The parser data structures are opaque to
-    the video drivers and to most of the common layer code.
-      </para>
-
-      <para>
-    The entire file is parsed first to remove any section ordering
-    requirements.
-      </para>
-    </sect2>
-
-
-    <sect2>
-      <title>Initial processing of parsed information and command line options
-      </title>
-
-      <para>
-    This is done at the start of the first server generation only.
-      </para>
-
-      <para>
-    The initial processing is to determine paths like the
-    <emphasis>ModulePath</emphasis>, etc, and to determine which &k.serverlayout;,
-    &k.screen; and &k.device; sections are active.
-      </para>
-    </sect2>
-
-
-    <sect2>
-      <title>Enable port I/O access</title>
-
-      <para>
-    Port I/O access is controlled from the XFree86 common layer, and is
-    <quote>all or nothing</quote>.  It is enabled prior to calling driver probes, at
-    the start of subsequent server generations, and when VT switching
-    back to the Xserver.  It is disabled at the end of server generations,
-    and when VT switching away from the Xserver.
-      </para>
-
-      <para>
-    The implementation details of this may vary on different platforms.
-      </para>
-    </sect2>
-
-
-    <sect2>
-      <title>General bus probe</title>
-
-      <para>
-    This is done at the start of the first server generation only.
-      </para>
-
-      <para>
-    In the case of ix86 machines, this will be a general PCI probe.
-    The full information obtained here will be available to the drivers.
-    This information persists for the life of the Xserver.  In the PCI
-    case, the PCI information for all video cards found is available by
-    calling <function>xf86GetPciVideoInfo()</function>.
-      </para>
-
-      <blockquote><para>
-	  <programlisting>
-    pciVideoPtr *xf86GetPciVideoInfo(void);
-	  </programlisting>
-	  <blockquote><para>
-	returns a pointer to a list of pointers to
-	<structname>pciVideoRec</structname> entries, of which there is one for
-	each detected PCI video card.  The list is terminated with a
-	<constant>NULL</constant> pointer.  If no PCI video cards were
-	detected, the return value is <constant>NULL</constant>.
-
-	    </para></blockquote>
-	</para></blockquote>
-
-      <para>
-    After the bus probe, the resource broker is initialised.
-      </para>
-    </sect2>
-
-
-    <sect2>
-      <title>Load initial set of modules</title>
-
-      <para>
-    This is done at the start of the first server generation only.
-      </para>
-
-      <para>
-    The core server contains a list of mandatory modules.  These are loaded
-    first.  Currently the only module on this list is the bitmap font module.
-      </para>
-
-      <para>
-    The next set of modules loaded are those specified explicitly in the
-    &k.module; section of the config file.
-      </para>
-
-      <para>
-    The final set of initial modules are the driver modules referenced
-    by the active &k.device; and &k.inputdevice; sections in the config
-    file.  Each of these modules is loaded exactly once.
-      </para>
-    </sect2>
-
-
-    <sect2>
-      <title>Register Video and Input Drivers</title>
-
-      <para>
-    This is done at the start of the first server generation only.
-      </para>
-
-      <para>
-    When a driver module is loaded, the loader calls its
-    <function>Setup</function> function.  For video drivers, this function
-    calls <function>xf86AddDriver()</function> to register the driver's
-    <structname>DriverRec</structname>, which contains a small set of essential
-    details and driver entry points required during the early phase of
-    <function>InitOutput()</function>.  <function>xf86AddDriver()</function>
-    adds it to the global <varname>xf86DriverList[]</varname> array.
-      </para>
-
-      <para>
-    The <structname>DriverRec</structname> contains the driver canonical name,
-    the <function>Identify()</function>,
-    <function>Probe()</function> and <function>AvailableOptions()</function>
-    function entry points as well as a pointer
-    to the driver's module (as returned from the loader when the driver
-    was loaded) and a reference count which keeps track of how many
-    screens are using the driver.  The entry driver entry points are
-    those required prior to the driver allocating and filling in its
-    <structname>ScrnInfoRec</structname>.
-      </para>
-
-      <para>
-    For a static server, the <varname>xf86DriverList[]</varname> array is
-    initialised at build time, and the loading of modules is not done.
-      </para>
-
-      <para>
-    A similar procedure is used for input drivers.  The input driver's
-    <function>Setup</function> function calls
-    <function>xf86AddInputDriver()</function> to register the driver's
-    <structname>InputDriverRec</structname>, which contains a small set of
-    essential details and driver entry points required during the early
-    phase of <function>InitInput()</function>.
-    <function>xf86AddInputDriver()</function> adds it to the global
-    <varname>xf86InputDriverList[]</varname> array.  For a static server,
-    the <varname>xf86InputDriverList[]</varname> array is initialised at
-    build time.
-      </para>
-
-      <para>
-    Both the <varname>xf86DriverList[]</varname> and
-    <varname>xf86InputDriverList[]</varname> arrays have been initialised
-    by the end of this stage.
-      </para>
-
-      <para>
-    Once all the drivers are registered, their
-    <function>ChipIdentify()</function> functions are called.
-      </para>
-
-      <blockquote><para>
-	  <programlisting>
-    void ChipIdentify(int flags);
-	  </programlisting>
-	  <blockquote><para>
-      This is expected to print a message indicating the driver name,
-      a short summary of what it supports, and a list of the chipset
-      names that it supports.  It may use the xf86PrintChipsets() helper
-      to do this.
-	    </para></blockquote>
-	</para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    void xf86PrintChipsets(const char *drvname, const char *drvmsg,
-                           SymTabPtr chips);
-	  </programlisting>
-	  <blockquote><para>
-      This function provides an easy way for a driver's ChipIdentify
-      function to format the identification message.
-	    </para></blockquote>
-	</para></blockquote>
-    </sect2>
-
-    <sect2>
-      <title>Initialise Access Control</title>
-
-      <para>
-    This is done at the start of the first server generation only.
-      </para>
-
-      <para>
-    The Resource Access Control (RAC) subsystem is initialised before
-    calling any driver functions that may access hardware.  All generic
-    bus information is probed and saved (for restoration later).  All
-    (shared resource) video devices are disabled at the generic bus
-    level, and a probe is done to find the <quote>primary</quote> video device.  These
-    devices remain disabled for the next step.
-      </para>
-    </sect2>
-
-
-    <sect2 id="probe">
-      <title>Video Driver Probe</title>
-
-      <para>
-    This is done at the start of the first server generation only.  The
-    <function>ChipProbe()</function> function of each registered video driver
-    is called.
-      </para>
-
-      <blockquote><para>
-	  <programlisting>
-    Bool ChipProbe(DriverPtr drv, int flags);
-	  </programlisting>
-	  <blockquote><para>
-      The purpose of this is to identify all instances of hardware
-      supported by the driver.  The flags value is currently either 0,
-      <constant>PROBE_DEFAULT</constant> or <constant>PROBE_DETECT</constant>.
-      <constant>PROBE_DETECT</constant> is used if "-configure" or "-probe"
-      command line arguments are given and indicates to the
-      <function>Probe()</function> function that it should not configure the
-      bus entities and that no xorg.conf information is available.
-	    </para>
-
-	  <para>
-      The probe must find the active device sections that match the
-      driver by calling <function>xf86MatchDevice()</function>.  The number
-      of matches found limits the maximum number of instances for this
-      driver.  If no matches are found, the function should return
-      <constant>FALSE</constant> immediately.
-	  </para>
-
-	<para>
-      Devices that cannot be identified by using device-independent
-      methods should be probed at this stage (keeping in mind that access
-      to all resources that can be disabled in a device-independent way
-      are disabled during this phase).  The probe must be a minimal
-      probe.  It should just determine if there is a card present that
-      the driver can drive.  It should use the least intrusive probe
-      methods possible.  It must not do anything that is not essential,
-      like probing for other details such as the amount of memory
-      installed, etc.  It is recommended that the
-      <function>xf86MatchPciInstances()</function> helper function be used
-      for identifying matching PCI devices, and similarly the
-      <function>xf86MatchIsaInstances()</function> for ISA (non-PCI) devices
-      (see the <link linkend="rac">RAC</link> section).  These helpers also
-      checks and claims the appropriate entity.  When not using the
-      helper, that should be done with <function>xf86CheckPciSlot()</function>
-      and <function>xf86ClaimPciSlot()</function> for PCI devices and
-      <function>xf86ClaimIsaSlot()</function> for ISA devices (see the
-      <link linkend="rac">RAC</link> section).
-	</para>
-
-	<para>
-      The probe must register all non-relocatable resources at this
-      stage.  If a resource conflict is found between exclusive resources
-      the driver will fail immediately.  This is usually best done with
-      the <function>xf86ConfigPciEntity()</function> helper function
-      for PCI and <function>xf86ConfigIsaEntity()</function> for ISA
-      (see the <link linkend="rac">RAC</link> section).  It is possible to
-      register some entity specific functions with those helpers.  When
-      not using the helpers, the <function>xf86AddEntityToScreen()</function>
-      <function>xf86ClaimFixedResources()</function> and
-      <function>xf86SetEntityFuncs()</function> should be used instead (see
-      the <link linkend="rac">RAC</link> section).
-	</para>
-
-	<para>
-      If a chipset is specified in an active device section which the
-      driver considers relevant (ie it has no driver specified, or the
-      driver specified matches the driver doing the probe), the Probe
-      must return <constant>FALSE</constant> if the chipset doesn't match
-      one supported by the driver.
-	</para>
-
-	<para>
-      If there are no active device sections that the driver considers
-      relevant, it must return <constant>FALSE</constant>.
-	</para>
-
-	<para>
-      Allocate a <structname>ScrnInfoRec</structname> for each active instance of the
-      hardware found, and fill in the basic information, including the
-      other driver entry points.   This is best done with the
-      <function>xf86ConfigIsaEntity()</function> helper function for ISA
-      instances or <function>xf86ConfigPciEntity()</function> for PCI instances.
-      These functions allocate a <structname>ScrnInfoRec</structname> for active
-      entities. Optionally <function>xf86AllocateScreen()</function>
-      function may also be used to allocate the <structname>ScrnInfoRec</structname>.
-      Any of these functions take care of initialising fields to defined
-      <quote>unused</quote> values.
-	</para>
-
-	<para>
-      Claim the entities for each instance of the hardware found.  This
-      prevents other drivers from claiming the same hardware.
-	</para>
-
-	<para>
-      Must leave hardware in the same state it found it in, and must not
-      do any hardware initialisation.
-	</para>
-
-	<para>
-      All detection can be overridden via the config file, and that
-      parsed information is available to the driver at this stage.
-	</para>
-
-	<para>
-      Returns <constant>TRUE</constant> if one or more instances are found,
-      and <constant>FALSE</constant> otherwise.
-	</para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    int xf86MatchDevice(const char *drivername,
-                        GDevPtr **driversectlist)
-	  </programlisting>
-	  <blockquote><para>
-      This function takes the name of the driver and returns via
-      <parameter>driversectlist</parameter> a list of device sections that
-      match the driver name.  The function return value is the number
-      of matches found.  If a fatal error is encountered the return
-      value is <literal>-1</literal>.
-	    </para>
-
-	    <para>
-      The caller should use <function>xfree()</function> to free
-      <parameter>*driversectlist</parameter> when it is no longer needed.
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    ScrnInfoPtr xf86AllocateScreen(DriverPtr drv, int flags)
-	  </programlisting>
-	  <blockquote><para>
-      This function allocates a new <structname>ScrnInfoRec</structname> in the
-      <varname>xf86Screens[]</varname> array.  This function is normally
-      called by the video driver <function>ChipProbe()</function> functions.
-      The return value is a pointer to the newly allocated
-      <structname>ScrnInfoRec</structname>.  The <structfield>scrnIndex</structfield>,
-      <structfield>origIndex</structfield>, <structfield>module</structfield> and
-      <structfield>drv</structfield> fields are initialised.  The reference count
-      in <parameter>drv</parameter> is incremented.  The storage for any
-      currently allocated <quote>privates</quote> pointers is also allocated and
-      the <structfield>privates</structfield> field initialised (the privates data
-      is of course not allocated or initialised).  This function never
-      returns on failure.  If the allocation fails, the server exits
-      with a fatal error.  The flags value is not currently used, and
-      should be set to zero.
-	    </para></blockquote>
-	</para></blockquote>
-
-      <para>
-    At the completion of this, a list of <structname>ScrnInfoRecs</structname>
-    have been allocated in the <varname>xf86Screens[]</varname> array, and
-    the associated entities and fixed resources have been claimed.  The
-    following <structname>ScrnInfoRec</structname> fields must be initialised at
-    this point:
-
-	<literallayout>
-          driverVersion
-          driverName
-          scrnIndex(*)
-          origIndex(*)
-          drv(*)
-          module(*)
-          name
-          Probe
-          PreInit
-          ScreenInit
-          EnterVT
-          LeaveVT
-          numEntities
-          entityList
-          access
-	</literallayout>
-
-    <literal>(*)</literal> These are initialised when the <structname>ScrnInfoRec</structname>
-    is allocated, and not explicitly by the driver.
-      </para>
-
-      <para>
-    The following <structname>ScrnInfoRec</structname> fields must be initialised
-    if the driver is going to use them:
-
-	<literallayout>
-          SwitchMode
-          AdjustFrame
-          FreeScreen
-          ValidMode
-	</literallayout>
-      </para>
-    </sect2>
-
-    <sect2>
-      <title>Matching Screens</title>
-
-      <para>
-    This is done at the start of the first server generation only.
-      </para>
-
-      <para>
-    After the Probe phase is finished, there will be some number of
-    <structname>ScrnInfoRec</structname>s.  These are then matched with the active
-    &k.screen; sections in the xorg.conf, and those not having an active
-    &k.screen; section are deleted.  If the number of remaining screens
-    is 0, <function>InitOutput()</function> sets
-    <structfield>screenInfo.numScreens</structfield> to <constant>0</constant> and
-    returns.
-      </para>
-
-      <para>
-    At this point the following fields of the <structname>ScrnInfoRec</structname>s
-    must be initialised:
-
-	<literallayout>
-          confScreen
-	</literallayout>
-      </para>
-
-    </sect2>
-
-    <sect2>
-      <title>Allocate non-conflicting resources</title>
-
-      <para>
-    This is done at the start of the first server generation only.
-      </para>
-
-      <para>
-    Before calling the drivers again, the resource information collected
-    from the Probe phase is processed.  This includes checking the extent
-    of PCI resources for the probed devices, and resolving any conflicts
-    in the relocatable PCI resources.  It also reports conflicts, checks
-    bus routing issues, and anything else that is needed to enable the
-    entities for the next phase.
-      </para>
-
-      <para>
-    If any drivers registered an <function>EntityInit()</function> function
-    during the Probe phase, then they are called here.
-      </para>
-
-    </sect2>
-
-    <sect2>
-      <title>Sort the Screens and pre-check Monitor Information</title>
-
-      <para>
-    This is done at the start of the first server generation only.
-      </para>
-
-      <para>
-    The list of screens is sorted to match the ordering requested in the
-    config file.
-      </para>
-
-      <para>
-    The list of modes for each active monitor is checked against the
-    monitor's parameters.  Invalid modes are pruned.
-      </para>
-
-    </sect2>
-
-    <sect2>
-      <title>PreInit</title>
-
-      <para>
-    This is done at the start of the first server generation only.
-      </para>
-
-      <para>
-    For each <structname>ScrnInfoRec</structname>, enable access to the screens entities and call
-    the <function>ChipPreInit()</function> function.
-      </para>
-
-      <blockquote><para>
-	  <programlisting>
-    Bool ChipPreInit(ScrnInfoRec screen, int flags);
-	  </programlisting>
-	  <blockquote><para>
-      The purpose of this function is to find out all the information
-      required to determine if the configuration is usable, and to
-      initialise those parts of the <structname>ScrnInfoRec</structname> that
-      can be set once at the beginning of the first server generation.
-	    </para>
-
-	    <para>
-      The number of entities registered for the screen should be checked
-      against the expected number (most drivers expect only one).  The
-      entity information for each of them should be retrieved (with
-      <function>xf86GetEntityInfo()</function>) and checked for the correct
-      bus type and that none of the sharable resources registered during
-      the Probe phase was rejected.
-	    </para>
-
-	    <para>
-      Access to resources for the entities that can be controlled in a
-      device-independent way are enabled before this function is called.
-      If the driver needs to access any resources that it has disabled
-      in an <function>EntityInit()</function> function that it registered,
-      then it may enable them here providing that it disables them before
-      this function returns.
-	    </para>
-
-	    <para>
-      This includes probing for video memory, clocks, ramdac, and all
-      other HW info that is needed.  It includes determining the
-      depth/bpp/visual and related info.  It includes validating and
-      determining the set of video modes that will be used (and anything
-      that is required to determine that).
-	    </para>
-
-	    <para>
-      This information should be determined in the least intrusive way
-      possible.  The state of the HW must remain unchanged by this
-      function.  Although video memory (including MMIO) may be mapped
-      within this function, it must be unmapped before returning.  Driver
-      specific information should be stored in a structure hooked into
-      the <structname>ScrnInfoRec</structname>'s <structfield>driverPrivate</structfield>
-      field.  Any other modules which require persistent data (ie data
-      that persists across server generations) should be initialised in
-      this function, and they should allocate a <quote>privates</quote> index to
-      hook their data into by calling
-      <function>xf86AllocateScrnInfoPrivateIndex()</function>.  The <quote>privates</quote>
-      data is persistent.
-	    </para>
-
-	    <para>
-      Helper functions for some of these things are provided at the
-      XFree86 common level, and the driver can choose to make use of
-      them.
-	    </para>
-
-	    <para>
-      All additional resources that the screen needs must be registered
-      here.  This should be done with
-      <function>xf86RegisterResources()</function>.  If some of the fixed
-      resources registered in the Probe phase are not needed or not
-      decoded by the hardware when in the OPERATING server state, their
-      status should be updated with
-      <function>xf86SetOperatingState()</function>.
-	    </para>
-
-	    <para>
-      Modules may be loaded at any point in this function, and all
-      modules that the driver will need must be loaded before the end
-      of this function.  Either the  <function>xf86LoadSubModule()</function>
-      or the <function>xf86LoadDrvSubModule()</function> function should be
-      used to load modules depending on whether a
-      <structname>ScrnInfoRec</structname> has been set up. A driver may unload
-      a module within this function if it was only needed temporarily,
-      and the <function>xf86UnloadSubModule()</function> function should be used
-      to do that.  Otherwise there is no need to explicitly unload modules
-      because the loader takes care of module dependencies and will
-      unload submodules automatically if/when the driver module is
-      unloaded.
-	    </para>
-
-	    <para>
-      The bulk of the <structname>ScrnInfoRec</structname> fields should be filled
-      out in this function.
-	    </para>
-
-	    <para>
-      <function>ChipPreInit()</function> returns <constant>FALSE</constant> when
-      the configuration is unusable in some way (unsupported depth, no
-      valid modes, not enough video memory, etc), and <constant>TRUE</constant>
-      if it is usable.
-	    </para>
-
-	    <para>
-      It is expected that if the <function>ChipPreInit()</function> function
-      returns <constant>TRUE</constant>, then the only reasons that subsequent
-      stages in the driver might fail are lack or resources (like xalloc
-      failures).  All other possible reasons for failure should be
-      determined by the <function>ChipPreInit()</function> function.
-	    </para></blockquote>
-	</para></blockquote>
-
-      <para>
-    The <structname>ScrnInfoRec</structname>s for screens where the <function>ChipPreInit()</function> fails are removed.
-    If none remain, <function>InitOutput()</function> sets <structfield>screenInfo.numScreens</structfield> to <constant>0</constant> and returns.
-      </para>
-
-      <para>
-    At this point, further fields of the <structname>ScrnInfoRec</structname>s would normally be
-    filled in.  Most are not strictly mandatory, but many are required
-    by other layers and/or helper functions that the driver may choose
-    to use.  The documentation for those layers and helper functions
-    indicates which they require.
-      </para>
-
-      <para>
-    The following fields of the <structname>ScrnInfoRec</structname>s should be filled in if the
-    driver is going to use them:
-
-	<literallayout>
-          monitor
-          display
-          depth
-          pixmapBPP
-          bitsPerPixel
-          weight                (>8bpp only)
-          mask                  (>8bpp only)
-          offset                (>8bpp only)
-          rgbBits               (8bpp only)
-          gamma
-          defaultVisual
-          maxHValue
-          maxVValue
-          virtualX
-          virtualY
-          displayWidth
-          frameX0
-          frameY0
-          frameX1
-          frameY1
-          zoomLocked
-          modePool
-          modes
-          currentMode
-          progClock             (TRUE if clock is programmable)
-          chipset
-          ramdac
-          clockchip
-          numClocks             (if not programmable)
-          clock[]               (if not programmable)
-          videoRam
-          biosBase
-          memBase
-          memClk
-          driverPrivate
-          chipID
-          chipRev
-	</literallayout>
-      </para>
-
-      <blockquote><para>
-	  <programlisting>
-    pointer xf86LoadSubModule(ScrnInfoPtr pScrn, const char *name);
-      and
-    pointer xf86LoadDrvSubModule(DriverPtr drv, const char *name);
-	  </programlisting>
-	  <blockquote><para>
-      Load a module that a driver depends on.  This function loads the
-      module <parameter>name</parameter> as a sub module of the driver.  The
-      return value is a handle identifying the new module.  If the load
-      fails, the return value will be <constant>NULL</constant>.  If a driver
-      needs to explicitly unload a module it has loaded in this way,
-      the return value must be saved and passed to
-      <function>xf86UnloadSubModule()</function> when unloading.
-
-	    </para></blockquote>
-	</para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    void xf86UnloadSubModule(pointer module);
-	  </programlisting>
-	  <blockquote><para>
-      Unloads the module referenced by <parameter>module</parameter>.
-      <parameter>module</parameter> should be a pointer returned previously
-      by <function>xf86LoadSubModule()</function> or
-      <function>xf86LoadDrvSubModule()</function> .
-
-	    </para></blockquote>
-	</para></blockquote>
-    </sect2>
-
-    <sect2>
-      <title>Cleaning up Unused Drivers</title>
-
-      <para>
-    At this point it is known which screens will be in use, and which
-    drivers are being used.  Unreferenced drivers (and modules they
-    may have loaded) are unloaded here.
-      </para>
-
-    </sect2>
-
-    <sect2>
-      <title>Consistency Checks</title>
-
-      <para>
-    The parameters that must be global to the server, like pixmap formats,
-    bitmap bit order, bitmap scanline unit and image byte order are
-    compared for each of the screens.  If a mismatch is found, the server
-    exits with an appropriate message.
-      </para>
-
-    </sect2>
-
-    <sect2>
-      <title>Check if Resource Control is Needed</title>
-
-      <para>
-    Determine if resource access control is needed.  This is the case
-    if more than one screen is used.  If necessary the RAC wrapper module
-    is loaded.
-      </para>
-    </sect2>
-
-    <sect2>
-      <title>AddScreen (ScreenInit)</title>
-
-      <para>
-    At this point, the valid screens are known.
-    <function>AddScreen()</function> is called for each of them, passing
-    <function>ChipScreenInit()</function> as the argument.
-    <function>AddScreen()</function> is a DIX function that allocates a new
-    <structfield>screenInfo.screen[]</structfield> entry (aka
-    <varname>pScreen</varname>), and does some basic initialisation of it.
-    It then calls the <function>ChipScreenInit()</function> function, with
-    <parameter>pScreen</parameter> as one of its arguments.  If
-    <function>ChipScreenInit()</function> returns <constant>FALSE</constant>,
-    <function>AddScreen()</function> returns <constant>-1</constant>.  Otherwise
-    it returns the index of the screen.  <function>AddScreen()</function>
-    should only fail because of programming errors or failure to allocate
-    resources (like memory).  All configuration problems should be
-    detected BEFORE this point.
-      </para>
-
-      <blockquote><para>
-	  <programlisting>
-    Bool ChipScreenInit(int index, ScreenPtr pScreen,
-                        int argc, char **argv);
-	  </programlisting>
-	  <blockquote><para>
-      This is called at the start of each server generation.
-	    </para>
-
-	    <para>
-      Fill in all of <parameter>pScreen</parameter>, possibly doing some of
-      this by calling ScreenInit functions from other layers like mi,
-      framebuffers (cfb, etc), and extensions.
-	    </para>
-
-	    <para>
-      Decide which operations need to be placed under resource access
-      control.  The classes of operations are the frame buffer operations
-      (<constant>RAC_FB</constant>), the pointer operations
-      (<constant>RAC_CURSOR</constant>), the viewport change operations
-      (<constant>RAC_VIEWPORT</constant>) and the colormap operations
-      (<constant>RAC_COLORMAP</constant>).  Any operation that requires
-      resources which might be disabled during OPERATING state should
-      be set to use RAC.  This can be specified separately for memory
-      and IO resources (the <structfield>racMemFlags</structfield> and
-      <structfield>racIoFlags</structfield> fields of the <structname>ScrnInfoRec</structname>
-      respectively).
-	    </para>
-
-	    <para>
-      Map any video memory or other memory regions.
-	    </para>
-
-	    <para>
-      Save the video card state.  Enough state must be saved so that
-      the original state can later be restored.
-	    </para>
-
-	    <para>
-      Initialise the initial video mode.  The <structname>ScrnInfoRec</structname>'s
-      <structfield>vtSema</structfield> field should be set to <constant>TRUE</constant>
-      just prior to changing the video hardware's state.
-
-	    </para></blockquote>
-	</para></blockquote>
-
-
-      <para>
-    The <function>ChipScreenInit()</function> function (or functions from other
-    layers that it calls) should allocate entries in the
-    <structname>ScreenRec</structname>'s <structfield>devPrivates</structfield> area by
-    calling <function>AllocateScreenPrivateIndex()</function> if it needs
-    per-generation storage.  Since the <structname>ScreenRec</structname>'s
-    <structfield>devPrivates</structfield> information is cleared for each server
-    generation, this is the correct place to initialise it.
-      </para>
-
-      <para>
-    After <function>AddScreen()</function> has successfully returned, the
-    following <structname>ScrnInfoRec</structname> fields are initialised:
-
-	<literallayout>
-          pScreen
-          racMemFlags
-          racIoFlags
-	</literallayout>
-      </para>
-
-      <para>
-    The <function>ChipScreenInit()</function> function should initialise the
-    <structfield>CloseScreen</structfield> and <structfield>SaveScreen</structfield> fields
-    of <parameter>pScreen</parameter>.  The old value of
-    <structfield>pScreen->CloseScreen</structfield> should be saved as part of
-    the driver's per-screen private data, allowing it to be called from
-    <function>ChipCloseScreen()</function>.  This means that the existing
-    <function>CloseScreen()</function> function is wrapped.
-      </para>
-    </sect2>
-
-    <sect2>
-      <title>Finalising RAC Initialisation</title>
-
-      <para>
-    After all the <function>ChipScreenInit()</function> functions have been
-    called, each screen has registered its RAC requirements.  This
-    information is used to determine which shared resources are requested
-    by more than one driver and set the access functions accordingly.
-    This is done following these rules:
-
-	<orderedlist>
-	  <listitem><para>
-	The sharable resources registered by each entity are compared.
-	If a resource is registered by more than one entity the entity
-	will be marked to indicate that it needs to share this resources
-	type (IO or MEM).
-	    </para></listitem>
-
-	  <listitem><para>
-        A resource marked <quote>disabled</quote> during OPERATING state will be
-        ignored entirely.
-	    </para></listitem>
-
-	  <listitem><para>
-	A resource marked <quote>unused</quote> will only conflict with an overlapping
-	resource of an other entity if the second is actually in use
-	during OPERATING state.
-	    </para></listitem>
-
-	  <listitem><para>
-	If an <quote>unused</quote> resource was found to conflict but the entity
-	does not use any other resource of this type the entire resource
-	type will be disabled for that entity.
-	    </para></listitem>
-	</orderedlist>
-      </para>
-
-    </sect2>
-
-    <sect2>
-      <title>Finishing InitOutput()</title>
-
-      <para>
-    At this point <function>InitOutput()</function> is finished, and all the
-    screens have been setup in their initial video mode.
-      </para>
-
-    </sect2>
-
-    <sect2>
-      <title>Mode Switching</title>
-
-      <para>
-    When a SwitchMode event is received, <function>ChipSwitchMode()</function>
-    is called (when it exists):
-      </para>
-
-      <blockquote><para>
-	  <programlisting>
-    Bool ChipSwitchMode(int index, DisplayModePtr mode, int flags);
-	  </programlisting>
-	  <blockquote><para>
-      Initialises the new mode for the screen identified by
-      <parameter>index;</parameter>.  The viewport may need to be adjusted
-      also.
-
-	    </para></blockquote>
-	</para></blockquote>
-
-    </sect2>
-
-    <sect2>
-      <title>Changing Viewport</title>
-
-      <para>
-    When a Change Viewport event is received,
-    <function>ChipAdjustFrame()</function> is called (when it exists):
-      </para>
-
-      <blockquote><para>
-	  <programlisting>
-    void ChipAdjustFrame(int index, int x, int y, int flags);
-	  </programlisting>
-	  <blockquote><para>
-      Changes the viewport for the screen identified by
-      <parameter>index;</parameter>.
-	    </para>
-
-	    <para>
-      It should be noted that many chipsets impose restrictions on where the
-      viewport may be placed in the virtual resolution, either for alignment
-      reasons, or to prevent the start of the viewport from being positioned
-      within a pixel (as can happen in a 24bpp mode).  After calculating the
-      value the chipset's panning registers need to be set to for non-DGA
-      modes, this function should recalculate the ScrnInfoRec's
-      <structfield>frameX0</structfield>, <structfield>frameY0</structfield>, <structfield>frameX1</structfield>
-      and <structfield>frameY1</structfield> fields to correspond to that value.  If
-      this is not done, switching to another mode might cause the position
-      of a hardware cursor to change.
-
-	    </para></blockquote>
-	</para></blockquote>
-
-    </sect2>
-
-    <sect2>
-      <title>VT Switching</title>
-
-      <para>
-    When a VT switch event is received, <function>xf86VTSwitch()</function>
-    is called.  <function>xf86VTSwitch()</function> does the following:
-
-	<variablelist>
-	  <varlistentry><term>On ENTER:</term>
-	    <listitem>
-	      <itemizedlist>
-		<listitem><para>
-		    enable port I/O access
-		  </para></listitem>
-
-		<listitem><para>
-		    save and initialise the bus/resource state
-		  </para></listitem>
-
-		<listitem><para>
-		    enter the SETUP server state
-		  </para></listitem>
-
-		<listitem><para>
-		    calls <function>ChipEnterVT()</function> for each screen
-		  </para></listitem>
-
-		<listitem><para>
-		    enter the OPERATING server state
-		  </para></listitem>
-
-		<listitem><para>
-		    validate GCs
-		  </para></listitem>
-
-		<listitem><para>
-		    Restore fb from saved pixmap for each screen
-		  </para></listitem>
-
-		<listitem><para>
-		    Enable all input devices
-		  </para></listitem>
-	      </itemizedlist>
-	    </listitem>
-	  </varlistentry>
-	  <varlistentry>
-	    <term>On LEAVE:</term>
-	    <listitem>
-	      <itemizedlist>
-		<listitem><para>
-		    Save fb to pixmap for each screen
-		  </para></listitem>
-
-		<listitem><para>
-		    validate GCs
-		  </para></listitem>
-
-		<listitem><para>
-		    enter the SETUP server state
-		  </para></listitem>
-
-		<listitem><para>
-		    calls <function>ChipLeaveVT()</function> for each screen
-		  </para></listitem>
-
-		<listitem><para>
-		    disable all input devices
-		  </para></listitem>
-
-		<listitem><para>
-		    restore bus/resource state
-		  </para></listitem>
-
-		<listitem><para>
-		    disables port I/O access
-		  </para></listitem>
-	      </itemizedlist>
-	    </listitem>
-	  </varlistentry>
-	</variablelist>
-      </para>
-
-      <blockquote><para>
-	  <programlisting>
-    Bool ChipEnterVT(int index, int flags);
-	  </programlisting>
-	  <blockquote><para>
-      This function should initialise the current video mode and
-      initialise the viewport, turn on the HW cursor if appropriate,
-      etc.
-	    </para>
-
-	    <para>
-      Should it re-save the video state before initialising the video
-      mode?
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    void ChipLeaveVT(int index, int flags);
-	  </programlisting>
-	  <blockquote><para>
-      This function should restore the saved video state.  If
-      appropriate it should also turn off the HW cursor, and invalidate
-      any pixmap/font caches.
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <para>
-    Optionally, <function>ChipLeaveVT()</function> may also unmap memory
-    regions.  If so, <function>ChipEnterVT()</function> will need to remap
-    them.  Additionally, if an aperture used to access video memory is
-    unmapped and remapped in this fashion, <function>ChipEnterVT()</function>
-    will also need to notify the framebuffer layers of the aperture's new
-    location in virtual memory.  This is done with a call to the screen's
-    <function>ModifyPixmapHeader()</function> function, as follows
-      </para>
-
-      <blockquote><para>
-	  <programlisting>
-    (*pScreen->ModifyPixmapHeader)(pScrn->ppix,
-                                   -1, -1, -1, -1, -1, NewApertureAddress);
-	  </programlisting>
-	  <blockquote><para>
-        where the <structfield>ppix</structfield> field in a ScrnInfoRec
-        points to the pixmap used by the screen's
-        <function>SaveRestoreImage()</function> function to hold the screen's
-        contents while switched out.
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <para>
-    Other layers may wrap the <function>ChipEnterVT()</function> and
-    <function>ChipLeaveVT()</function> functions if they need to take some
-    action when these events are received.
-      </para>
-    </sect2>
-
-    <sect2>
-      <title>End of server generation</title>
-
-      <para>
-    At the end of each server generation, the DIX layer calls
-    <function>ChipCloseScreen()</function> for each screen:
-      </para>
-
-      <blockquote><para>
-	  <programlisting>
-    Bool ChipCloseScreen(int index, ScreenPtr pScreen);
-	  </programlisting>
-	  <blockquote><para>
-      This function should restore the saved video state and unmap the
-      memory regions.
-	    </para>
-
-	    <para>
-      It should also free per-screen data structures allocated by the
-      driver.  Note that the persistent data held in the
-      <structname>ScrnInfoRec</structname>'s <structfield>driverPrivate</structfield> field
-      should not be freed here because it is needed by subsequent server
-      generations.
-	    </para>
-
-	    <para>
-      The <structname>ScrnInfoRec</structname>'s <structfield>vtSema</structfield> field
-      should be set to <constant>FALSE</constant> once the video HW state
-      has been restored.
-	    </para>
-
-	    <para>
-      Before freeing the per-screen driver data the saved
-      <structfield>CloseScreen</structfield> value should be restored to
-      <structfield>pScreen->CloseScreen</structfield>, and that function should
-      be called after freeing the data.
-
-	    </para></blockquote>
-	</para></blockquote>
-    </sect2>
-  </sect1>
-
-  <sect1>
-    <title>Optional Driver Functions</title>
-
-    <para>
-The functions outlined here can be called from the XFree86 common layer,
-but their presence is optional.
-    </para>
-
-    <sect2>
-      <title>Mode Validation</title>
-
-      <para>
-    When a mode validation helper supplied by the XFree86-common layer is
-    being used, it can be useful to provide a function to check for hw
-    specific mode constraints:
-      </para>
-
-      <blockquote><para>
-	  <programlisting>
-    ModeStatus ChipValidMode(int index, DisplayModePtr mode,
-                             Bool verbose, int flags);
-	  </programlisting>
-	  <blockquote><para>
-      Check the passed mode for hw-specific constraints, and return the
-      appropriate status value.
-
-	    </para></blockquote>
-	</para></blockquote>
-
-      <para>
-This function may also modify the effective timings and clock of the passed
-mode.  These have been stored in the mode's <structfield>Crtc*</structfield> and
-<structfield>SynthClock</structfield> elements, and have already been adjusted for
-interlacing, doublescanning, multiscanning and clock multipliers and dividers.
-The function should not modify any other mode field, unless it wants to modify
-the mode timings reported to the user by <function>xf86PrintModes()</function>.
-      </para>
-
-      <para>
-The function is called once for every mode in the xorg.conf Monitor section
-assigned to the screen, with <parameter>flags</parameter> set to
-<constant>MODECHECK_INITIAL</constant>.  It is subsequently called for every mode
-in the xorg.conf Display subsection assigned to the screen, with
-<parameter>flags</parameter> set to <constant>MODECHECK_FINAL</constant>.  In the second
-case, the mode will have successfully passed all other tests.  In addition,
-the <structname>ScrnInfoRec</structname>'s <structfield>virtualX</structfield>,
-<structfield>virtualY</structfield> and <structfield>displayWidth</structfield> fields will have been
-set as if the mode to be validated were to be the last mode accepted.
-      </para>
-
-      <para>
-In effect, calls with MODECHECK_INITIAL are intended for checks that do not
-depend on any mode other than the one being validated, while calls with
-MODECHECK_FINAL are intended for checks that may involve more than one mode.
-      </para>
-    </sect2>
-
-    <sect2>
-      <title>Free screen data</title>
-
-      <para>
-    When a screen is deleted prior to the completion of the ScreenInit
-    phase the <function>ChipFreeScreen()</function> function is called when defined.
-      </para>
-
-      <blockquote><para>
-	  <programlisting>
-    void ChipFreeScreen(int scrnindex, int flags);
-	  </programlisting>
-	  <blockquote><para>
-      Free any driver-allocated data that may have been allocated up to
-      and including an unsuccessful <function>ChipScreenInit()</function>
-      call.  This would predominantly be data allocated by
-      <function>ChipPreInit()</function> that persists across server
-      generations.  It would include the <structfield>driverPrivate</structfield>,
-      and any <quote>privates</quote> entries that modules may have allocated.
-
-	    </para></blockquote>
-	</para></blockquote>
-
-    </sect2>
-</sect1>
-
-  <sect1>
-    <title>Recommended driver functions</title>
-
-    <para>
-The functions outlined here are for internal use by the driver only.
-They are entirely optional, and are never accessed directly from higher
-layers.  The sample function declarations shown here are just examples.
-The interface (if any) used is up to the driver.
-    </para>
-
-    <sect2>
-      <title>Save</title>
-
-      <para>
-    Save the video state.  This could be called from <function>ChipScreenInit()</function> and
-    (possibly) <function>ChipEnterVT()</function>.
-      </para>
-
-      <blockquote><para>
-	  <programlisting>
-    void ChipSave(ScrnInfoPtr pScrn);
-	  </programlisting>
-	  <blockquote><para>
-      Saves the current state.  This will only be saving pre-server
-      states or states before returning to the server.  There is only
-      one current saved state per screen and it is stored in private
-      storage in the screen.
-
-	    </para></blockquote>
-	</para></blockquote>
-    </sect2>
-
-    <sect2>
-      <title>Restore</title>
-
-      <para>
-    Restore the original video state.  This could be called from the
-    <function>ChipLeaveVT()</function> and <function>ChipCloseScreen()</function>
-    functions.
-      </para>
-
-      <blockquote><para>
-	  <programlisting>
-    void ChipRestore(ScrnInfoPtr pScrn);
-	  </programlisting>
-	  <blockquote><para>
-      Restores the saved state from the private storage.  Usually only
-      used for restoring text modes.
-
-	    </para></blockquote>
-	</para></blockquote>
-
-    </sect2>
-
-    <sect2>
-      <title>Initialise Mode</title>
-
-      <para>
-    Initialise a video mode.  This could be called from the
-    <function>ChipScreenInit()</function>, <function>ChipSwitchMode()</function>
-    and <function>ChipEnterVT()</function> functions.
-      </para>
-
-      <blockquote><para>
-	  <programlisting>
-    Bool ChipModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode);
-	  </programlisting>
-	  <blockquote><para>
-      Programs the hardware for the given video mode.
-
-	    </para></blockquote>
-	</para></blockquote>
-
-    </sect2>
-  </sect1>
-
-  <sect1>
-    <title>Data and Data Structures</title>
-
-    <sect2>
-      <title>Command line data</title>
-
-      <para>
-Command line options are typically global, and are stored in global
-variables.  These variables are read-only and are available to drivers
-via a function call interface.  Most of these command line values are
-processed via helper functions to ensure that they are treated consistently
-by all drivers.  The other means of access is provided for cases where
-the supplied helper functions might not be appropriate.
-      </para>
-
-      <para>
-Some of them are:
-
-	<literallayout>
-    xf86Verbose               verbosity level
-    xf86Bpp                   -bpp from the command line
-    xf86Depth                 -depth from the command line
-    xf86Weight                -weight from the command line
-    xf86Gamma                 -{r,g,b,}gamma from the command line
-    xf86FlipPixels            -flippixels from the command line
-    xf86ProbeOnly             -probeonly from the command line
-    defaultColorVisualClass   -cc from the command line
-	</literallayout>
-      </para>
-
-      <para>
-If we ever do allow for screen-specific command line options, we may
-need to rethink this.
-      </para>
-
-      <para>
-These can be accessed in a read-only manner by drivers with the following
-functions:
-      </para>
-
-     <blockquote><para>
-	  <programlisting>
-    int xf86GetVerbosity();
-	  </programlisting>
-	  <blockquote><para>
-      Returns the value of <varname>xf86Verbose</varname>.
-	    </para></blockquote>
-
-	</para></blockquote>
-
-     <blockquote><para>
-	  <programlisting>
-    int xf86GetDepth();
-	  </programlisting>
-	  <blockquote><para>
-      Returns the <option>-depth</option> command line setting.  If not
-      set on the command line, <constant>-1</constant> is returned.
-	    </para></blockquote>
-
-	</para></blockquote>
-
-     <blockquote><para>
-	  <programlisting>
-    rgb xf86GetWeight();
-	  </programlisting>
-	  <blockquote><para>
-      Returns the <option>-weight</option> command line setting.  If not
-      set on the command line, <literal remap="tt">{0, 0, 0}</literal> is returned.
-	    </para></blockquote>
-
-	</para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    Gamma xf86GetGamma();
-	  </programlisting>
-	  <blockquote><para>
-      Returns the <option>-gamma</option> or <option>-rgamma</option>,
-      <option>-ggamma</option>, <option>-bgamma</option> command line settings.
-      If not set on the command line, <literal remap="tt">{0.0, 0.0, 0.0}</literal>
-      is returned.
-	    </para></blockquote>
-
-	</para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    Bool xf86GetFlipPixels();
-	  </programlisting>
-	  <blockquote><para>
-      Returns <constant>TRUE</constant> if <option>-flippixels</option> is
-      present on the command line, and <constant>FALSE</constant> otherwise.
-	    </para></blockquote>
-
-	</para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    const char *xf86GetServerName();
-	  </programlisting>
-	  <blockquote><para>
-      Returns the name of the X server from the command line.
-	    </para></blockquote>
-
-	</para></blockquote>
-    </sect2>
-
-    <sect2>
-      <title>Data handling</title>
-
-      <para>
-Config file data contains parts that are global, and parts that are
-Screen specific.  All of it is parsed into data structures that neither
-the drivers or most other parts of the server need to know about.
-      </para>
-
-      <para>
-The global data is typically not required by drivers, and as such, most
-of it is stored in the private <structname>xf86InfoRec</structname>.
-      </para>
-
-      <para>
-The screen-specific data collected from the config file is stored in
-screen, device, display, monitor-specific data structures that are separate
-from the <varname>ScrnInfoRecs</varname>, with the appropriate elements/fields
-hooked into the <varname>ScrnInfoRecs</varname> as required.  The screen
-config data is held in <structname>confScreenRec</structname>, device data in
-the <structname>GDevRec</structname>, monitor data in the <structname>MonRec</structname>,
-and display data in the <structname>DispRec</structname>.
-      </para>
-
-      <para>
-The XFree86 common layer's screen specific data (the actual data in use
-for each screen) is held in the <varname>ScrnInfoRecs</varname>.  As has
-been outlined above, the <varname>ScrnInfoRecs</varname> are allocated at probe
-time, and it is the responsibility of the Drivers' <function>Probe()</function>
-and <function>PreInit()</function> functions to finish filling them in based
-on both data provided on the command line and data provided from the
-Config file.  The precedence for this is:
-
-	<blockquote><para>
-    command line  ->  config file  ->  probed/default data
-	</para></blockquote>
-      </para>
-
-      <para>
-For most things in this category there are helper functions that the
-drivers can use to ensure that the above precedence is consistently
-used.
-      </para>
-
-      <para>
-As well as containing screen-specific data that the XFree86 common layer
-(including essential parts of the server infrastructure as well as helper
-functions) needs to access, it also contains some data that drivers use
-internally.  When considering whether to add a new field to the
-<structname>ScrnInfoRec</structname>, consider the balance between the convenience
-of things that lots of drivers need and the size/obscurity of the
-<structname>ScrnInfoRec</structname>.
-      </para>
-
-      <para>
-Per-screen driver specific data that cannot be accommodated with the
-static <structname>ScrnInfoRec</structname> fields is held in a driver-defined
-data structure, a pointer to which is assigned to the
-<structname>ScrnInfoRec</structname>'s <structfield>driverPrivate</structfield> field.  This
-is per-screen data that persists across server generations (as does the
-bulk of the static <structname>ScrnInfoRec</structname> data).  It would typically
-also include the video card's saved state.
-      </para>
-
-      <para>
-Per-screen data for other modules that the driver uses (for example,
-the XAA module) that is reset for each server generation is hooked into
-the <structname>ScrnInfoRec</structname> through it's <structfield>privates</structfield>
-field.
-      </para>
-
-      <para>
-Once it has stabilised, the data structures and variables accessible to
-video drivers will be documented here.  In the meantime, those things
-defined in the <filename>xf86.h</filename> and <filename>xf86str.h</filename>
-files are visible to video drivers.  Things defined in
-<filename>xf86Priv.h</filename> and <filename>xf86Privstr.h</filename> are NOT
-intended to be visible to video drivers, and it is an error for a driver
-to include those files.
-      </para>
-
-    </sect2>
-
-    <sect2>
-      <title>Accessing global data</title>
-
-      <para>
-Some other global state information that the drivers may access via
-functions is as follows:
-      </para>
-
-      <blockquote><para>
-	  <programlisting>
-    Bool xf86ServerIsExiting();
-	  </programlisting>
-	  <blockquote><para>
-      Returns <constant>TRUE</constant> if the server is at the end of a
-      generation and is in the process of exiting, and
-      <constant>FALSE</constant> otherwise.
-	    </para></blockquote>
-
-	</para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    Bool xf86ServerIsResetting();
-	  </programlisting>
-	  <blockquote><para>
-      Returns <constant>TRUE</constant> if the server is at the end of a
-      generation and is in the process of resetting, and
-      <constant>FALSE</constant> otherwise.
-	    </para></blockquote>
-
-	</para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    Bool xf86ServerIsInitialising();
-	  </programlisting>
-	  <blockquote><para>
-      Returns <constant>TRUE</constant> if the server is at the beginning of
-      a generation and is in the process of initialising, and
-      <constant>FALSE</constant> otherwise.
-	    </para></blockquote>
-
-	</para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    Bool xf86ServerIsOnlyProbing();
-	  </programlisting>
-	  <blockquote><para>
-      Returns <constant>TRUE</constant> if the -probeonly command line flag
-      was specified, and <constant>FALSE</constant> otherwise.
-	    </para></blockquote>
-
-	</para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    Bool xf86CaughtSignal();
-	  </programlisting>
-	  <blockquote><para>
-      Returns <constant>TRUE</constant> if the server has caught a signal,
-      and <constant>FALSE</constant> otherwise.
-	    </para></blockquote>
-
-	</para></blockquote>
-    </sect2>
-
-    <sect2>
-      <title>Allocating private data</title>
-
-      <para>
-A driver and any module it uses may allocate per-screen private storage
-in either the <structname>ScreenRec</structname> (DIX level) or
-<structname>ScrnInfoRec</structname> (XFree86 common layer level).
-<structname>ScreenRec</structname> storage persists only for a single server
-generation, and <structname>ScrnInfoRec</structname> storage persists across
-generations for the lifetime of the server.
-      </para>
-
-      <para>
-The <structname>ScreenRec</structname> <structfield>devPrivates</structfield> data must be
-reallocated/initialised at the start of each new generation.  This is
-normally done from the <function>ChipScreenInit()</function> function, and
-Init functions for other modules that it calls.  Data allocated in this
-way should be freed by the driver's <function>ChipCloseScreen()</function>
-functions, and Close functions for other modules that it calls.  A new
-<structfield>devPrivates</structfield> entry is allocated by calling the
-<function>AllocateScreenPrivateIndex()</function> function.
-      </para>
-
-      <blockquote><para>
-	  <programlisting>
-    int AllocateScreenPrivateIndex();
-	  </programlisting>
-	  <blockquote><para>
-      This function allocates a new element in the
-      <structfield>devPrivates</structfield> field of all currently existing
-      <literal remap="tt">ScreenRecs</literal>.  The return value is the index of this
-      new element in the <structfield>devPrivates</structfield> array.  The
-      <structfield>devPrivates</structfield> field is of type
-      <structname>DevUnion</structname>:
-
-	      <programlisting>
-        typedef union _DevUnion {
-            pointer             ptr;
-            long                val;
-            unsigned long       uval;
-            pointer             (*fptr)(void);
-        } DevUnion;
-	      </programlisting>
-
-      which allows the element to be used for any of the above types.
-      It is commonly used as a pointer to data that the caller allocates
-      after the new index has been allocated.
-	    </para>
-
-	    <para>
-      This function will return <constant>-1</constant> when there is an
-      error allocating the new index.
-	    </para>
-
-	  </blockquote>
-	</para></blockquote>
-
-      <para>
-The <structname>ScrnInfoRec</structname> <structfield>privates</structfield> data persists
-for the life of the server, so only needs to be allocated once.  This
-should be done from the <function>ChipPreInit()</function> function, and Init
-functions for other modules that it calls.  Data allocated in this way
-should be freed by the driver's <function>ChipFreeScreen()</function> functions,
-and Free functions for other modules that it calls.  A new
-<structfield>privates</structfield> entry is allocated by calling the
-<function>xf86AllocateScrnInfoPrivateIndex()</function> function.
-      </para>
-
-      <blockquote><para>
-	  <programlisting>
-    int xf86AllocateScrnInfoPrivateIndex();
-	  </programlisting>
-	  <blockquote><para>
-      This function allocates a new element in the <structfield>privates</structfield>
-      field of all currently existing <varname>ScrnInfoRecs</varname>.
-      The return value is the index of this new element in the
-      <structfield>privates</structfield> array.  The <structfield>privates</structfield>
-      field is of type <structfield>DevUnion</structfield>:
-
-	      <programlisting>
-        typedef union _DevUnion {
-            pointer             ptr;
-            long                val;
-            unsigned long       uval;
-            pointer             (*fptr)(void);
-        } DevUnion;
-	      </programlisting>
-
-      which allows the element to be used for any of the above types.
-      It is commonly used as a pointer to data that the caller allocates
-      after the new index has been allocated.
-	    </para>
-
-	    <para>
-      This function will not return when there is an error allocating
-      the new index.  When there is an error it will cause the server
-      to exit with a fatal error.  The similar function for allocation
-      privates in the <structname>ScreenRec</structname>
-      (<function>AllocateScreenPrivateIndex()</function>) differs in this
-      respect by returning <constant>-1</constant> when the allocation fails.
-	    </para>
-
-	  </blockquote>
-	</para></blockquote>
-    </sect2>
-  </sect1>
-
-  <sect1 id="rac">
-    <title>Keeping Track of Bus Resources</title>
-
-    <sect2>
-      <title>Theory of Operation</title>
-
-      <para>
-The XFree86 common layer has knowledge of generic access control mechanisms
-for devices on certain bus systems (currently the PCI bus) as well as
-of methods to enable or disable access to the buses itself.  Furthermore
-it can access information on resources decoded by these devices and if
-necessary modify it.
-      </para>
-
-      <para>
-When first starting the Xserver collects all this information, saves it
-for restoration, checks it for consistency, and if necessary, corrects
-it.  Finally it disables all resources on a generic level prior to
-calling any driver function.
-      </para>
-
-      <para>
-When the <function>Probe()</function> function of each driver is called the
-device sections are matched against the devices found in the system.
-The driver may probe devices at this stage that cannot be identified by
-using device independent methods.  Access to all resources that can be
-controlled in a device independent way is disabled.  The
-<function>Probe()</function> function should register all non-relocatable
-resources at this stage.  If a resource conflict is found between
-exclusive resources the driver will fail immediately.  Optionally the
-driver might specify an <function>EntityInit()</function>,
-<function>EntityLeave()</function> and <function>EntityEnter()</function> function.
-      </para>
-
-      <para>
-<function>EntityInit()</function> can be used to disable any shared resources
-that are not controlled by the generic access control functions.  It is
-called prior to the PreInit phase regardless if an entity is active or
-not.  When calling the <function>EntityInit()</function>,
-<function>EntityEnter()</function> and <function>EntityLeave()</function> functions
-the common level will disable access to all other entities on a generic
-level.  Since the common level has no knowledge of device specific
-methods to disable access to resources it cannot be guaranteed that
-certain resources are not decoded by any other entity until the
-<function>EntityInit()</function> or <function>EntityEnter()</function> phase is
-finished.  Device drivers should therefore register all those resources
-which they are going to disable.  If these resources are never to be
-used by any driver function they may be flagged <constant>ResInit</constant>
-so that they can be removed from the resource list after processing all
-<function>EntityInit()</function> functions.  <function>EntityEnter()</function>
-should disable decoding of all resources which are not registered as
-exclusive and which are not handled by the generic access control in
-the common level.  The difference to <function>EntityInit()</function> is
-that the latter one is only called once during lifetime of the server.
-It can therefore be used to set up variables prior to disabling resources.
-<function>EntityLeave()</function> should restore the original state when
-exiting the server or switching to a different VT.  It also needs to
-disable device specific access functions if they need to be disabled on
-server exit or VT switch.  The default state is to enable them before
-giving up the VT.
-      </para>
-
-      <para>
-In <function>PreInit()</function> phase each driver should check if any
-sharable resources it has registered during <function>Probe()</function> has
-been denied and take appropriate action which could simply be to fail.
-If it needs to access resources it has disabled during
-<function>EntitySetup()</function> it can do so provided it has registered
-these and will disable them before returning from
-<function>PreInit()</function>.  This also applies to all other driver
-functions.  Several functions are provided to request resource ranges,
-register these, correct PCI config space and add replacements for the
-generic access functions.  Resources may be marked <quote>disabled</quote> or
-<quote>unused</quote> during OPERATING stage.  Although these steps could also be
-performed in <function>ScreenInit()</function>, this is not desirable.
-      </para>
-
-      <para>
-Following <function>PreInit()</function> phase the common level determines
-if resource access control is needed.  This is the case if more than
-one screen is used.  If necessary the RAC wrapper module is loaded.  In
-<function>ScreenInit()</function> the drivers can decide which operations
-need to be placed under RAC.  Available are the frame buffer operations,
-the pointer operations and the colormap operations.  Any operation that
-requires resources which might be disabled during OPERATING state should
-be set to use RAC.  This can be specified separately for memory and IO
-resources.
-      </para>
-
-      <para>
-When <function>ScreenInit()</function> phase is done the common level will
-determine which shared resources are requested by more than one driver
-and set the access functions accordingly.  This is done following these
-rules:
-
-	<orderedlist>
-	  <listitem><para>
-   The sharable resources registered by each entity are compared.  If
-   a resource is registered by more than one entity the entity will be
-   marked to need to share this resources type (<constant>IO</constant> or
-   <constant>MEM</constant>).
-	    </para></listitem>
-
-	  <listitem><para>
-   A resource marked <quote>disabled</quote> during OPERATING state will be ignored
-   entirely.
-	    </para></listitem>
-
-	  <listitem><para>
-   A resource marked <quote>unused</quote> will only conflicts with an overlapping
-   resource of an other entity if the second is actually in use during
-   OPERATING state.
-	    </para></listitem>
-
-	  <listitem><para>
-   If an <quote>unused</quote> resource was found to conflict however the entity
-   does not use any other resource of this type the entire resource type
-   will be disabled for that entity.
-	    </para></listitem>
-	</orderedlist>
-      </para>
-
-      <para>
-The driver has the choice among different ways to control access to
-certain resources:
-
-	<orderedlist>
-	  <listitem><para>
-   It can rely on the generic access functions.  This is probably the
-   most common case.  Here the driver only needs to register any resource
-   it is going to use.
-	    </para></listitem>
-
-	  <listitem><para>
-   It can replace the generic access functions by driver specific
-   ones.  This will mostly be used in cases where no generic access
-   functions are available.  In this case the driver has to make sure
-   these resources are disabled when entering the <function>PreInit()</function>
-   stage.  Since the replacement functions are registered in
-   <function>PreInit()</function> the driver will have to enable these
-   resources itself if it needs to access them during this state.  The
-   driver can specify if the replacement functions can control memory
-   and/or I/O resources separately.
-	    </para></listitem>
-
-	  <listitem><para>
-   The driver can enable resources itself when it needs them.  Each
-   driver function enabling them needs to disable them before it will
-   return.  This should be used if a resource which can be controlled
-   in a device dependent way is only required during SETUP state.  This
-   way it can be marked <quote>unused</quote> during OPERATING state.
-	    </para></listitem>
-	</orderedlist>
-      </para>
-
-      <para>
-A resource which is decoded during OPERATING state however never accessed
-by the driver should be marked unused.
-      </para>
-
-      <para>
-Since access switching latencies are an issue during Xserver operation,
-the common level attempts to minimize the number of entities that need
-to be placed under RAC control.  When a wrapped operation is called,
-the <function>EnableAccess()</function> function is called before control is
-passed on.  <function>EnableAccess()</function> checks if a screen is under
-access control.  If not it just establishes bus routing and returns.
-If the screen needs to be under access control,
-<function>EnableAccess()</function> determines which resource types
-(<literal remap="tt">MEM</literal>, <literal remap="tt">IO</literal>) are required.  Then it tests
-if this access is already established.  If so it simply returns.  If
-not it disables the currently established access, fixes bus routing and
-enables access to all entities registered for this screen.
-      </para>
-
-      <para>
-Whenever a mode switch or a VT-switch is performed the common level will
-return to SETUP state.
-      </para>
-    </sect2>
-
-    <sect2>
-      <title>Resource Types</title>
-
-      <para>
-Resource have certain properties.  When registering resources each range
-is accompanied by a flag consisting of the ORed flags of the different
-properties the resource has.  Each resource range may be classified
-according to
-
-	<itemizedlist>
-	  <listitem><para>
-       its physical properties i.e., if it addresses
-       memory (<constant>ResMem</constant>)  or
-       I/O space (<constant>ResIo</constant>),
-	    </para></listitem>
-	  <listitem><para>
-       if it addresses a
-       block (<constant>ResBlock</constant>) or
-       sparse (<constant>ResSparse</constant>)
-       range,
-	    </para></listitem>
-	  <listitem><para>
-       its access properties.
-	    </para></listitem>
-	</itemizedlist>
-      </para>
-
-      <para>
-There are two known access properties:
-
-	<itemizedlist>
-	  <listitem><para>
-  <constant>ResExclusive</constant>
-    for resources which may not be shared with any other device and
-	    </para></listitem>
-	  <listitem><para>
-  <constant>ResShared</constant>
-    for resources which can be disabled and therefore can be shared.
-	    </para></listitem>
-	</itemizedlist>
-      </para>
-
-      <para>
-If it is necessary to test a resource against any type a generic access
-type <constant>ResAny</constant> is provided.  If this is set the resource
-will conflict with any resource of a different entity intersecting its
-range.  Further it can be specified that a resource is decoded however
-never used during any stage (<constant>ResUnused</constant>) or during
-OPERATING state (<constant>ResUnusedOpr</constant>).  A resource only visible
-during the init functions (ie.  <function>EntityInit()</function>,
-<function>EntityEnter()</function> and <function>EntityLeave()</function> should
-be registered with the flag <constant>ResInit</constant>.  A resource that
-might conflict with background resource ranges may be flagged with
-<constant>ResBios</constant>.  This might be useful when registering resources
-ranges that were assigned by the system Bios.
-      </para>
-
-      <para>
-Several predefined resource lists are available for VGA and 8514/A
-resources in <filename>common/xf86Resources.h</filename>.
-      </para>
-    </sect2>
-
-    <sect2 id="avail">
-      <title>Available Functions</title>
-
-      <para>
-The functions provided for resource management are listed in their order
-of use in the driver.
-      </para>
-
-      <sect3>
-	<title>Probe Phase</title>
-
-	<para>
-In this phase each driver detects those resources it is able to drive,
-creates an entity record for each of them, registers non-relocatable
-resources and allocates screens and adds the resources to screens.
-	</para>
-
-	<para>
-Two helper functions are provided for matching device sections in the
-xorg.conf file to the devices:
-	</para>
-
-	<blockquote><para>
-	    <programlisting>
-    int xf86MatchPciInstances(const char *driverName, int vendorID,
-                              SymTabPtr chipsets, PciChipsets *PCIchipsets,
-                              GDevPtr *devList, int numDevs, DriverPtr drvp,
-                              int **foundEntities);
-	    </programlisting>
-	    <blockquote><para>
-      This function finds matches between PCI cards that a driver supports
-      and config file device sections.  It is intended for use in the
-      <function>ChipProbe()</function> function of drivers for PCI cards.
-      Only probed PCI devices with a vendor ID matching
-      <parameter>vendorID</parameter> are considered.  <parameter>devList</parameter>
-      and <parameter>numDevs</parameter> are typically those found from
-      calling <function>xf86MatchDevice()</function>, and represent the active
-      config file device sections relevant to the driver.
-      <parameter>PCIchipsets</parameter> is a table that provides a mapping
-      between the PCI device IDs, the driver's internal chipset tokens
-      and a list of fixed resources.
-	      </para>
-
-	      <para>
-      When a device section doesn't have a <emphasis>BusID</emphasis> entry it
-      can only match the primary video device.  Secondary devices are
-      only matched with device sections that have a matching
-      <emphasis>BusID</emphasis> entry.
-	      </para>
-
-	      <para>
-      Once the preliminary matches have been found, a final match is
-      confirmed by checking if the chipset override, ChipID override or
-      probed PCI chipset type match one of those given in the
-      <parameter>chipsets</parameter> and <parameter>PCIchipsets</parameter> lists.
-      The <parameter>PCIchipsets</parameter> list includes a list of the PCI
-      device IDs supported by the driver.  The list should be terminated
-      with an entry with PCI ID <constant>-1</constant>".  The
-      <parameter>chipsets</parameter> list is a table mapping the driver's
-      internal chipset tokens to names, and should be terminated with
-      a <constant>NULL</constant> entry.  Only those entries with a
-      corresponding entry in the <parameter>PCIchipsets</parameter> list are
-      considered.  The order of precedence is: config file chipset,
-      config file ChipID, probed PCI device ID.
-	      </para>
-
-	      <para>
-      In cases where a driver handles PCI chipsets with more than one
-      vendor ID, it may set <parameter>vendorID</parameter> to
-      <constant>0</constant>, and OR each devID in the list with (the
-      vendor ID << 16).
-	      </para>
-
-	      <para>
-      Entity index numbers for confirmed matches are returned as an
-      array via <parameter>foundEntities</parameter>.  The PCI information,
-      chipset token and device section for each match are found in the
-      <structname>EntityInfoRec</structname> referenced by the indices.
-	      </para>
-
-	      <para>
-      The function return value is the number of confirmed matches.  A
-      return value of <constant>-1</constant> indicates an internal error.
-      The returned <parameter>foundEntities</parameter> array should be freed
-      by the driver with <function>xfree()</function> when it is no longer
-      needed in cases where the return value is greater than zero.
-	      </para>
-
-	    </blockquote></para></blockquote>
-
-	<blockquote><para>
-	    <programlisting>
-    int xf86MatchIsaInstances(const char *driverName,
-                              SymTabPtr chipsets, IsaChipsets *ISAchipsets,
-                              DriverPtr drvp, FindIsaDevProc FindIsaDevice,
-                              GDevPtr *devList, int numDevs,
-                              int **foundEntities);
-	    </programlisting>
-	    <blockquote><para>
-      This function finds matches between ISA cards that a driver supports
-      and config file device sections.  It is intended for use in the
-      <function>ChipProbe()</function> function of drivers for ISA cards.
-      <parameter>devList</parameter> and <parameter>numDevs</parameter> are
-      typically those found from calling <function>xf86MatchDevice()</function>,
-      and represent the active config file device sections relevant to
-      the driver.  <parameter>ISAchipsets</parameter> is a table that provides
-      a mapping between the driver's internal chipset tokens and the
-      resource classes.  <parameter>FindIsaDevice</parameter> is a
-      driver-provided function that probes the hardware and returns the
-      chipset token corresponding to what was detected, and
-      <constant>-1</constant> if nothing was detected.
-	      </para>
-
-	      <para>
-      If the config file device section contains a chipset entry, then
-      it is checked against the <parameter>chipsets</parameter> list.  When
-      no chipset entry is present, the <parameter>FindIsaDevice</parameter>
-      function is called instead.
-	      </para>
-
-	      <para>
-      Entity index numbers for confirmed matches are returned as an
-      array via <parameter>foundEntities</parameter>.  The chipset token and
-      device section for each match are found in the
-      <structname>EntityInfoRec</structname> referenced by the indices.
-	      </para>
-
-	      <para>
-      The function return value is the number of confirmed matches.  A
-      return value of <constant>-1</constant> indicates an internal error.
-      The returned <parameter>foundEntities</parameter> array should be freed
-      by the driver with <function>xfree()</function> when it is no longer
-      needed in cases where the return value is greater than zero.
-	      </para>
-
-	    </blockquote></para></blockquote>
-
-	<para>
-These two helper functions make use of several core functions that are
-available at the driver level:
-	</para>
-
-	<blockquote><para>
-	    <programlisting>
-    Bool xf86ParsePciBusString(const char *busID, int *bus,
-                               int *device, int *func);
-	    </programlisting>
-	    <blockquote><para>
-      Takes a <parameter>BusID</parameter> string, and if it is in the correct
-      format, returns the PCI <parameter>bus</parameter>, <parameter>device</parameter>,
-      <parameter>func</parameter> values that it indicates.  The format of the
-      string is expected to be "PCI:bus:device:func" where each of <quote>bus</quote>,
-      <quote>device</quote> and <quote>func</quote> are decimal integers.  The ":func" part may
-      be omitted, and the func value assumed to be zero, but this isn't
-      encouraged.  The "PCI" prefix may also be omitted.  The prefix
-      "AGP" is currently equivalent to the "PCI" prefix.  If the string
-      isn't a valid PCI BusID, the return value is <constant>FALSE</constant>.
-	      </para>
-
-	    </blockquote></para></blockquote>
-
-	<blockquote><para>
-	    <programlisting>
-    Bool xf86ComparePciBusString(const char *busID, int bus,
-                                 int device, int func);
-	    </programlisting>
-	    <blockquote><para>
-      Compares a <parameter>BusID</parameter> string with PCI <parameter>bus</parameter>,
-      <parameter>device</parameter>, <parameter>func</parameter> values.  If they
-      match <constant>TRUE</constant> is returned, and <constant>FALSE</constant>
-      if they don't.
-	      </para>
-
-	    </blockquote></para></blockquote>
-
-	<blockquote><para>
-	    <programlisting>
-    Bool xf86ParseIsaBusString(const char *busID);
-	    </programlisting>
-	    <blockquote><para>
-      Compares a <parameter>BusID</parameter> string with the ISA bus ID string
-      ("ISA" or "ISA:").  If they match <constant>TRUE</constant> is returned,
-      and <constant>FALSE</constant> if they don't.
-	      </para>
-
-	    </blockquote></para></blockquote>
-
-	<blockquote><para>
-	    <programlisting>
-    Bool xf86CheckPciSlot(int bus, int device, int func);
-	    </programlisting>
-	    <blockquote><para>
-      Checks if the PCI slot <literal remap="tt">bus:device:func</literal> has been
-      claimed.  If so, it returns <constant>FALSE</constant>, and otherwise
-      <constant>TRUE</constant>.
-	      </para>
-
-	    </blockquote></para></blockquote>
-
-	<blockquote><para>
-	    <programlisting>
-    int xf86ClaimPciSlot(int bus, int device, int func, DriverPtr drvp,
-                         int chipset, GDevPtr dev, Bool active);
-	    </programlisting>
-	    <blockquote><para>
-      This function is used to claim a PCI slot, allocate the associated
-      entity record and initialise their data structures.  The return
-      value is the index of the newly allocated entity record, or
-      <constant>-1</constant> if the claim fails.  This function should always
-      succeed if <function>xf86CheckPciSlot()</function> returned
-      <constant>TRUE</constant> for the same PCI slot.
-	      </para>
-
-	    </blockquote></para></blockquote>
-
-	<blockquote><para>
-	    <programlisting>
-    Bool xf86IsPrimaryPci(void);
-	    </programlisting>
-	    <blockquote><para>
-      This function returns <constant>TRUE</constant> if the primary card is
-      a PCI device, and <constant>FALSE</constant> otherwise.
-	      </para>
-
-	    </blockquote></para></blockquote>
-
-	<blockquote><para>
-	    <programlisting>
-    int xf86ClaimIsaSlot(DriverPtr drvp, int chipset,
-                         GDevPtr dev, Bool active);
-	    </programlisting>
-	    <blockquote><para>
-      This allocates an entity record entity and initialise the data
-      structures.  The return value is the index of the newly allocated
-      entity record.
-	      </para>
-
-	    </blockquote></para></blockquote>
-
-	<blockquote><para>
-	    <programlisting>
-    Bool xf86IsPrimaryIsa(void);
-	    </programlisting>
-	    <blockquote><para>
-      This function returns <constant>TRUE</constant> if the primary card is
-      an ISA (non-PCI) device, and <constant>FALSE</constant> otherwise.
-	      </para>
-
-	    </blockquote></para></blockquote>
-
-	<para>
-Two helper functions are provided to aid configuring entities:
-	</para>
-
-	<blockquote><para>
-	    <programlisting>
-    ScrnInfoPtr xf86ConfigPciEntity(ScrnInfoPtr pScrn,
-                                    int scrnFlag, int entityIndex,
-                                    PciChipsets *p_chip,
-                                    resList res, EntityProc init,
-                                    EntityProc enter, EntityProc leave,
-                                    pointer private);
-
-    ScrnInfoPtr xf86ConfigIsaEntity(ScrnInfoPtr pScrn,
-                                    int scrnFlag, int entityIndex,
-                                    IsaChipsets *i_chip,
-                                    resList res, EntityProc init,
-                                    EntityProc enter, EntityProc leave,
-                                    pointer private);
-	    </programlisting>
-	    <blockquote><para>
-      These functions are used to register the non-relocatable resources
-      for an entity, and the optional entity-specific <parameter>Init</parameter>, <parameter>Enter</parameter> and
-      <parameter>Leave</parameter> functions.  Usually the list of fixed resources is obtained
-      from the Isa/PciChipsets lists.  However an additional list of
-      resources may be passed.  Generally this is not required.
-      For active entities a <structname>ScrnInfoRec</structname> is allocated
-      if the <parameter>pScrn</parameter> argument is <constant>NULL</constant>.
-The
-      return value is <constant>TRUE</constant> when successful.  The init, enter, leave
-      functions are defined as follows:
-
-		<blockquote><para>
-		    <programlisting>
-        typedef void (*EntityProc)(int entityIndex,
-                                   pointer private);
-		    </programlisting>
-		  </para></blockquote>
-
-      They are passed the entity index and a pointer to a private scratch
-      area.  This can be set up during <function>Probe()</function> and
-      its address can be passed to
-      <function>xf86ConfigIsaEntity()</function> and
-      <function>xf86ConfigPciEntity()</function> as the last argument.
-	      </para>
-
-	    </blockquote></para></blockquote>
-
-	<para>
-These two helper functions make use of several core functions that are
-available at the driver level:
-
-	  <blockquote><para>
-	      <programlisting>
-    void xf86ClaimFixedResources(resList list, int entityIndex);
-	      </programlisting>
-	      <blockquote><para>
-      This function registers the non-relocatable resources which cannot
-      be disabled and which therefore would cause the server to fail
-      immediately if they were found to conflict.  It also records
-      non-relocatable but sharable resources for processing after the
-      <function>Probe()</function> phase.
-		</para>
-
-	      </blockquote></para></blockquote>
-
-	  <blockquote><para>
-	      <programlisting>
-    Bool xf86SetEntityFuncs(int entityIndex, EntityProc init,
-                            EntityProc enter, EntityProc leave, pointer);
-	      </programlisting>
-	      <blockquote><para>
-      This function registers with an entity the <parameter>init</parameter>,
-      <parameter>enter</parameter>, <parameter>leave</parameter> functions along
-      with the pointer to their private area.
-		</para>
-
-	    </blockquote></para></blockquote>
-
-	  <blockquote><para>
-	      <programlisting>
-    void xf86AddEntityToScreen(ScrnInfoPtr pScrn, int entityIndex);
-	      </programlisting>
-	      <blockquote><para>
-      This function associates the entity referenced by
-      <parameter>entityIndex</parameter> with the screen.
-		</para>
-
-	      </blockquote></para></blockquote>
-	</para>
-      </sect3>
-
-      <sect3>
-	<title>PreInit Phase</title>
-
-	<para>
-During this phase the remaining resources should be registered.
-<function>PreInit()</function> should call <function>xf86GetEntityInfo()</function>
-to obtain a pointer to an <structname>EntityInfoRec</structname> for each entity
-it is able to drive and check if any resource are listed in its
-<structfield>resources</structfield> field.  If resources registered in the Probe
-phase have been rejected in the post-Probe phase
-(<structfield>resources</structfield> is non-<constant>NULL</constant>), then the driver should
-decide if it can continue without using these or if it should fail.
-	</para>
-
-	<blockquote><para>
-	    <programlisting>
-    EntityInfoPtr xf86GetEntityInfo(int entityIndex);
-	    </programlisting>
-	    <blockquote><para>
-      This function returns a pointer to the <structname>EntityInfoRec</structname>
-      referenced by <parameter>entityIndex</parameter>.  The returned
-      <structname>EntityInfoRec</structname> should be freed with
-      <function>xfree()</function> when no longer needed.
-	      </para>
-
-	    </blockquote></para></blockquote>
-
-	<para>
-Several functions are provided to simplify resource registration:
-	  <blockquote><para>
-	      <programlisting>
-    Bool xf86IsEntityPrimary(int entityIndex);
-	      </programlisting>
-	      <blockquote><para>
-      This function returns <constant>TRUE</constant> if the entity referenced
-      by <parameter>entityIndex</parameter> is the primary display device (i.e.,
-      the one initialised at boot time and used in text mode).
-		</para>
-
-	      </blockquote></para></blockquote>
-
-	  <blockquote><para>
-	      <programlisting>
-    Bool xf86IsScreenPrimary(int scrnIndex);
-	      </programlisting>
-	      <blockquote><para>
-      This function returns <constant>TRUE</constant> if the primary entity
-      is registered with the screen referenced by
-      <parameter>scrnIndex</parameter>.
-		</para>
-
-	      </blockquote></para></blockquote>
-
-	  <blockquote><para>
-	      <programlisting>
-    pciVideoPtr xf86GetPciInfoForEntity(int entityIndex);
-	      </programlisting>
-	      <blockquote><para>
-      This function returns a pointer to the <structname>pciVideoRec</structname>
-      for the specified entity.  If the entity is not a PCI device,
-      <constant>NULL</constant> is returned.
-		</para>
-
-	      </blockquote></para></blockquote>
-	</para>
-
-	<para>
-The primary function for registration of resources is:
-	  <blockquote><para>
-	      <programlisting>
-    resPtr xf86RegisterResources(int entityIndex, resList list,
-                                 int access);
-	      </programlisting>
-	      <blockquote><para>
-      This function tries to register the resources in
-      <parameter>list</parameter>.  If list is <constant>NULL</constant> it tries
-      to determine the resources automatically.  This only works for
-      entities that provide a generic way to read out the resource ranges
-      they decode.  So far this is only the case for PCI devices.  By
-      default the PCI resources are registered as shared
-      (<constant>ResShared</constant>) if the driver wants to set a different
-      access type it can do so by specifying the access flags in the
-      third argument.  A value of <constant>0</constant> means to use the
-      default settings.  If for any reason the resource broker is not
-      able to register some of the requested resources the function will
-      return a pointer to a list of the failed ones.  In this case the
-      driver may be able to move the resource to different locations.
-      In case of PCI bus entities this is done by passing the list of
-      failed resources to <function>xf86ReallocatePciResources()</function>.
-      When the registration succeeds, the return value is
-      <constant>NULL</constant>.
-		</para>
-
-	      </blockquote></para></blockquote>
-	  </para>
-
-	<blockquote><para>
-	    <programlisting>
-    resPtr xf86ReallocatePciResources(int entityIndex, resPtr pRes);
-	    </programlisting>
-	    <blockquote><para>
-      This function takes a list of PCI resources that need to be
-      reallocated and returns <constant>NULL</constant> when all relocations are
-      successful.
-      <function>xf86RegisterResources()</function> should be called again to
-      register the relocated resources with the broker.
-      If the reallocation fails, a list of the resources that could not be
-      relocated is returned.
-	      </para>
-
-	    </blockquote></para></blockquote>
-
-<para>
-Two functions are provided to obtain a resource range of a given type:
-	  <blockquote><para>
-	      <programlisting>
-    resRange xf86GetBlock(long type, memType size,
-                          memType window_start, memType window_end,
-                          memType align_mask, resPtr avoid);
-	      </programlisting>
-	      <blockquote><para>
-      This function tries to find a block range of size
-      <parameter>size</parameter> and type <parameter>type</parameter> in a window
-      bound by <parameter>window_start</parameter> and <parameter>window_end</parameter>
-      with the alignment specified in <parameter>align_mask</parameter>.
-      Optionally a list of resource ranges which should be avoided within
-      the window can be supplied.  On failure a zero-length range of
-      type <constant>ResEnd</constant> will be returned.
-		</para>
-	      </blockquote></para></blockquote>
-
-	  <blockquote><para>
-	      <programlisting>
-    resRange xf86GetSparse(long type, memType fixed_bits,
-                           memType decode_mask, memType address_mask,
-                           resPtr avoid);
-	      </programlisting>
-	      <blockquote><para>
-      This function is like the previous one, but attempts to find a
-      sparse range instead of a block range.  Here three values have to
-      be specified: the <parameter>address_mask</parameter> which marks all
-      bits of the mask part of the address, the <parameter>decode_mask</parameter>
-      which masks out the bits which are hardcoded and are therefore
-      not available for relocation and the values of the fixed bits.
-      The function tries to find a base that satisfies the given condition.
-      If the function fails it will return a zero range of type
-      <constant>ResEnd</constant>.  Optionally it might be passed a list of
-      resource ranges to avoid.
-		</para>
-
-	      </blockquote></para></blockquote>
-	</para>
-
-	<para>
-Some PCI devices are broken in the sense that they return invalid size
-information for a certain resource.  In this case the driver can supply
-the correct size and make sure that the resource range allocated for
-the card is large enough to hold the address range decoded by the card.
-The function <function>xf86FixPciResource()</function> can be used to do this:
-	  <blockquote><para>
-	      <programlisting>
-    Bool xf86FixPciResource(int entityIndex, unsigned int prt,
-                            CARD32 alignment, long type);
-	      </programlisting>
-	      <blockquote><para>
-      This function fixes a PCI resource allocation.  The
-      <parameter>prt</parameter> parameter contains the number of the PCI base
-      register that needs to be fixed (<constant>0-5</constant>, and
-      <constant>6</constant> for the BIOS base register).  The size is
-      specified by the alignment.  Since PCI resources need to span an
-      integral range of size <literal remap="tt">2ˆn</literal>, the alignm      ent also
-      specifies the number of addresses that will be decoded.  If the
-      driver specifies a type mask it can override the default type for
-      PCI resources which is <constant>ResShared</constant>.  The resource
-      broker needs to know that to find a matching resource range.  This
-      function should be called before calling
-      <function>xf86RegisterResources()</function>.  The return value is
-      <constant>TRUE</constant> when the function succeeds.
-		</para>
-
-	      </blockquote></para></blockquote>
-
-	  <blockquote><para>
-	      <programlisting>
-    Bool xf86CheckPciMemBase(pciVideoPtr pPci, memType base);
-	      </programlisting>
-	      <blockquote><para>
-      This function checks that the memory base address specified matches
-      one of the PCI base address register values for the given PCI
-      device.  This is mostly used to check that an externally provided
-      base address (e.g., from a config file) matches an actual value
-      allocated to a device.
-		</para>
-
-	      </blockquote></para></blockquote>
-	</para>
-
-	<para>
-The driver may replace the generic access control functions for an entity.
-This is done with the <function>xf86SetAccessFuncs()</function>:
-	  <blockquote><para>
-	      <programlisting>
-    void xf86SetAccessFuncs(EntityInfoPtr pEnt,
-                            xf86SetAccessFuncPtr funcs,
-                            xf86SetAccessFuncPtr oldFuncs);
-	      </programlisting>
-     with:
-	      <programlisting>
-      typedef struct {
-          xf86AccessPtr mem;
-          xf86AccessPtr io;
-          xf86AccessPtr io_mem;
-      } xf86SetAccessFuncRec, *xf86SetAccessFuncPtr;
-	      </programlisting>
-	      <blockquote><para>
-      The driver can pass three functions: one for I/O access, one for
-      memory access and one for combined memory and I/O access.  If the
-      memory access and combined access functions are identical the
-      common level assumes that the memory access cannot be controlled
-      independently of I/O access, if the I/O access function and the
-      combined access functions are the same it is assumed that I/O can
-      not be controlled independently.  If memory and I/O have to be
-      controlled together all three values should be the same.  If a
-      non <constant>NULL</constant> value is passed as third argument it is
-      interpreted as an address where to store the old access record.
-      If the third argument is <constant>NULL</constant> it will be assumed
-      that the generic access should be enabled before replacing the
-      access functions.  Otherwise it will be disabled.  The driver may
-      enable them itself using the returned values.  It should do this
-      from its replacement access functions as the generic access may
-      be disabled by the common level on certain occasions.  If replacement
-      functions are specified they must control all resources of the
-      specific type registered for the entity.
-		</para>
-
-	      </blockquote></para></blockquote>
-	</para>
-
-	<para>
-To find out if a specific resource range conflicts with another
-resource the <function>xf86ChkConflict()</function> function may be used:
-	  <blockquote><para>
-	      <programlisting>
-    memType xf86ChkConflict(resRange *rgp, int entityIndex);
-	      </programlisting>
-	      <blockquote><para>
-      This function checks if the resource range <parameter>rgp</parameter> of
-      for the specified entity conflicts with with another resource.
-      If a conflict is found, the address of the start of the conflict
-      is returned.  The return value is zero when there is no conflict.
-		</para>
-
-	      </blockquote></para></blockquote>
-	</para>
-
-	<para>
-The OPERATING state properties of previously registered fixed resources
-can be set with the <function>xf86SetOperatingState()</function> function:
-	  <blockquote><para>
-	      <programlisting>
-    resPtr xf86SetOperatingState(resList list, int entityIndex,
-                                 int mask);
-	      </programlisting>
-	      <blockquote><para>
-      This function is used to set the status of a resource during
-      OPERATING state.  <parameter>list</parameter> holds a list to which
-      <parameter>mask</parameter> is to be applied.  The parameter
-      <parameter>mask</parameter> may have the value <constant>ResUnusedOpr</constant>
-      and <constant>ResDisableOpr</constant>.  The first one should be used
-      if a resource isn't used by the driver during OPERATING state
-      although it is decoded by the device, while the latter one indicates
-      that the resource is not decoded during OPERATING state.  Note
-      that the resource ranges have to match those specified during
-      registration.  If a range has been specified starting at
-      <literal remap="tt">A</literal> and ending at <literal remap="tt">B</literal> and suppose
-      <literal remap="tt">C</literal> us a value satisfying
-      <literal remap="tt">A < C < B</literal> one may not
-      specify the resource range <literal remap="tt">(A,B)</literal> by splitting it
-      into two ranges <literal remap="tt">(A,C)</literal> and <literal remap="tt">(C,B)</literal>.
-		</para>
-
-	      </blockquote></para></blockquote>
-	</para>
-
-	<para>
-The following two functions are provided for special cases:
-	  <blockquote><para>
-	      <programlisting>
-    void xf86RemoveEntityFromScreen(ScrnInfoPtr pScrn, int entityIndex);
-	      </programlisting>
-	      <blockquote><para>
-      This function may be used to remove an entity from a screen.  This
-      only makes sense if a screen has more than one entity assigned or
-      the screen is to be deleted.  No test is made if the screen has
-      any entities left.
-		</para>
-
-	      </blockquote></para></blockquote>
-
-	  <blockquote><para>
-	      <programlisting>
-    void xf86DeallocateResourcesForEntity(int entityIndex, long type);
-	      </programlisting>
-	      <blockquote><para>
-      This function deallocates all resources of a given type registered
-      for a certain entity from the resource broker list.
-		</para>
-
-	      </blockquote></para></blockquote>
-	</para>
-
-      </sect3>
-
-      <sect3>
-	<title>ScreenInit Phase</title>
-
-	<para>
-All that is required in this phase is to setup the RAC flags.  Note that
-it is also permissible to set these flags up in the PreInit phase.  The
-RAC flags are held in the <structfield>racIoFlags</structfield> and <structfield>racMemFlags</structfield> fields of the
-<structname>ScrnInfoRec</structname> for each screen.  They specify which graphics operations
-might require the use of shared resources.  This can be specified
-separately for memory and I/O resources.  The available flags are defined
-in <filename>rac/xf86RAC.h</filename>.  They are:
-
-	  <variablelist>
-	    <varlistentry><term><constant>RAC_FB</constant></term>
-	      <listitem><para>
-	for framebuffer operations (including hw acceleration)
-		</para></listitem></varlistentry>
-	    <varlistentry><term><constant>RAC_CURSOR</constant></term>
-	      <listitem><para>
-	for Cursor operations
-        (??? I'm not sure if we need this for SW cursor it depends
-         on which level the sw cursor is drawn)
-		</para></listitem></varlistentry>
-	    <varlistentry><term><constant>RAC_COLORMAP</constant></term>
-	      <listitem><para>
-	for colormap operations
-		</para></listitem></varlistentry>
-	    <varlistentry><term><constant>RAC_VIEWPORT</constant></term>
-	      <listitem><para>
-	for the call to <function>ChipAdjustFrame()</function>
-		</para></listitem></varlistentry>
-	    </variablelist>
-
-
-The flags are ORed together.
-	</para>
-      </sect3>
-    </sect2>
-  </sect1>
-
-  <sect1 id="options">
-    <title>Config file <quote>Option</quote> entries</title>
-
-    <para>
-Option entries are permitted in most sections and subsections of the
-config file.  There are two forms of option entries:
-
-      <variablelist>
-	<varlistentry><term>Option "option-name"</term>
-	  <listitem><para>
-	A boolean option.
-	    </para></listitem></varlistentry>
-	<varlistentry><term>Option "option-name" "option-value"</term>
-	  <listitem><para>
-	An option with an arbitrary value.
-	    </para></listitem></varlistentry>
-      </variablelist>
-    </para>
-
-    <para>
-The option entries are handled by the parser, and a list of the parsed
-options is included with each of the appropriate data structures that
-the drivers have access to.  The data structures used to hold the option
-information are opaque to the driver, and a driver must not access the
-option data directly.  Instead, the common layer provides a set of
-functions that may be used to access, check and manipulate the option
-data.
-    </para>
-
-    <para>
-First, the low level option handling functions.  In most cases drivers
-would not need to use these directly.
-    </para>
-
-    <blockquote><para>
-	<programlisting>
-    pointer xf86FindOption(pointer options, const char *name);
-	</programlisting>
-	<blockquote><para>
-      Takes a list of options and an option name, and returns a handle
-      for the first option entry in the list matching the name.  Returns
-      <constant>NULL</constant> if no match is found.
-	  </para>
-
-	</blockquote></para></blockquote>
-
-    <blockquote><para>
-	<programlisting>
-    char *xf86FindOptionValue(pointer options, const char *name);
-	</programlisting>
-	<blockquote><para>
-      Takes a list of options and an option name, and returns the value
-      associated with the first option entry in the list matching the
-      name.  If the matching option has no value, an empty string
-      (<constant>""</constant>) is returned.  Returns <constant>NULL</constant>
-      if no match is found.
-	  </para>
-
-	</blockquote></para></blockquote>
-
-    <blockquote><para>
-	<programlisting>
-    void xf86MarkOptionUsed(pointer option);
-	</programlisting>
-	<blockquote><para>
-      Takes a handle for an option, and marks that option as used.
-	  </para>
-
-	</blockquote></para></blockquote>
-
-    <blockquote><para>
-	<programlisting>
-    void xf86MarkOptionUsedByName(pointer options, const char *name);
-	</programlisting>
-	<blockquote><para>
-      Takes a list of options and an option name and marks the first
-      option entry in the list matching the name as used.
-	  </para>
-
-	</blockquote></para></blockquote>
-
-    <para>
-Next, the higher level functions that most drivers would use.
-    </para>
-    <blockquote><para>
-	<programlisting>
-    void xf86CollectOptions(ScrnInfoPtr pScrn, pointer extraOpts);
-	</programlisting>
-	<blockquote><para>
-      Collect the options from each of the config file sections used by
-      the screen (<parameter>pScrn</parameter>) and return the merged list as
-      <structfield>pScrn->options</structfield>.  This function requires that
-      <structfield>pScrn->confScreen</structfield>, <structfield>pScrn->display</structfield>,
-      <structfield>pScrn->monitor</structfield>,
-      <structfield>pScrn->numEntities</structfield>, and
-      <structfield>pScrn->entityList</structfield> are initialised.
-      <parameter>extraOpts</parameter> may optionally be set to an additional
-      list of options to be combined with the others.  The order of
-      precedence for options is <parameter>extraOpts</parameter>, display,
-      confScreen, monitor, device.
-	  </para>
-
-	</blockquote></para></blockquote>
-
-    <blockquote><para>
-	<programlisting>
-    void xf86ProcessOptions(int scrnIndex, pointer options,
-                            OptionInfoPtr optinfo);
-	</programlisting>
-	<blockquote><para>
-      Processes a list of options according to the information in the
-      array of <structname>OptionInfoRecs</structname> (<parameter>optinfo</parameter>).
-      The resulting information is stored in the <structfield>value</structfield>
-      fields of the appropriate <parameter>optinfo</parameter> entries.  The
-      <structfield>found</structfield> fields are set to <constant>TRUE</constant>
-      when an option with a value of the correct type if found, and
-      <constant>FALSE</constant> otherwise.  The <structfield>type</structfield> field
-      is used to determine the expected value type for each option.
-      Each option in the list of options for which there is a name match
-      (but not necessarily a value type match) is marked as used.
-      Warning messages are printed when option values don't match the
-      types specified in the optinfo data.
-	  </para>
-
-	  <para>
-      NOTE: If this function is called before a driver's screen number
-      is known (e.g., from the <function>ChipProbe()</function> function) a
-      <parameter>scrnIndex</parameter> value of <constant>-1</constant> should be
-      used.
-	  </para>
-
-	  <para>
-      NOTE 2: Given that this function stores into the
-      <literal remap="tt">OptionInfoRecs</literal> pointed to by <parameter>optinfo</parameter>,
-      the caller should ensure the <literal remap="tt">OptionInfoRecs</literal> are
-      (re-)initialised before the call, especially if the caller expects
-      to use the predefined option values as defaults.
-	  </para>
-
-	  <para>
-      The <structname>OptionInfoRec</structname> is defined as follows:
-
-	    <programlisting>
-      typedef struct {
-          double freq;
-          int units;
-      } OptFrequency;
-
-      typedef union {
-          unsigned long       num;
-          char *              str;
-          double              realnum;
-          Bool                bool;
-          OptFrequency        freq;
-      } ValueUnion;
-
-      typedef enum {
-          OPTV_NONE = 0,
-          OPTV_INTEGER,
-          OPTV_STRING,  /* a non-empty string */
-          OPTV_ANYSTR,  /* Any string, including an empty one */
-          OPTV_REAL,
-          OPTV_BOOLEAN,
-          OPTV_PERCENT,
-          OPTV_FREQ
-      } OptionValueType;
-
-      typedef enum {
-          OPTUNITS_HZ = 1,
-          OPTUNITS_KHZ,
-          OPTUNITS_MHZ
-      } OptFreqUnits;
-
-      typedef struct {
-          int                 token;
-          const char*         name;
-          OptionValueType     type;
-          ValueUnion          value;
-          Bool                found;
-      } OptionInfoRec, *OptionInfoPtr;
-	    </programlisting>
-	  </para>
-	  <para>
-      <constant>OPTV_FREQ</constant> can be used for options values that are
-      frequencies.  These values are a floating point number with an
-      optional unit name appended.  The unit name can be one of "Hz",
-      "kHz", "k", "MHz", "M".  The multiplier associated with the unit
-      is stored in <structfield>freq.units</structfield>, and the scaled frequency
-      is stored in <structfield>freq.freq</structfield>.  When no unit is specified,
-      <structfield>freq.units</structfield> is set to <constant>0</constant>, and
-      <structfield>freq.freq</structfield> is unscaled.
-	  </para>
-
-	  <para>
-      <constant>OPTV_PERCENT</constant> can be used for option values that are
-      specified in percent (e.g. "20%"). These values are a floating point
-      number with a percent sign appended. If the percent sign is missing,
-      the parser will fail to match the value.
-	  </para>
-
-	  <para>
-      Typical usage is to setup an array of
-      <structname>OptionInfoRec</structname>s with all fields initialised.
-      The <structfield>value</structfield> and <structfield>found</structfield> fields get
-      set by <function>xf86ProcessOptions()</function>.  For cases where the
-      value parsing is more complex, the driver should specify
-      <constant>OPTV_STRING</constant>, and parse the string itself.  An
-      example of using this option handling is included in the
-      <link linkend="sample">Sample Driver</link> section.
-	  </para>
-
-	</blockquote></para></blockquote>
-
-    <blockquote><para>
-	<programlisting>
-    void xf86ShowUnusedOptions(int scrnIndex, pointer options);
-	</programlisting>
-	<blockquote><para>
-      Prints out warning messages for each option in the list of options
-      that isn't marked as used.  This is intended to show options that
-      the driver hasn't recognised.  It would normally be called near
-      the end of the <function>ChipScreenInit()</function> function, but only
-      when <code>serverGeneration == 1</code>
-	  </para>
-	</blockquote></para></blockquote>
-
-    <blockquote><para>
-	<programlisting>
-    OptionInfoPtr xf86TokenToOptinfo(const OptionInfoRec *table,
-                                     int token);
-	</programlisting>
-	<blockquote><para>
-      Returns a pointer to the <structname>OptionInfoRec</structname> in
-      <parameter>table</parameter> with a token field matching
-      <parameter>token</parameter>.  Returns <constant>NULL</constant> if no match
-      is found.
-	  </para>
-
-	</blockquote></para></blockquote>
-
-    <blockquote><para>
-	<programlisting>
-    Bool xf86IsOptionSet(const OptionInfoRec *table, int token);
-	</programlisting>
-	<blockquote><para>
-      Returns the <literal remap="tt">found</literal> field of the
-      <structname>OptionInfoRec</structname> in <parameter>table</parameter> with a
-      <structfield>token</structfield> field matching <parameter>token</parameter>.  This
-      can be used for options of all types.  Note that for options of
-      type <constant>OPTV_BOOLEAN</constant>, it isn't sufficient to check
-      this to determine the value of the option.  Returns
-      <constant>FALSE</constant> if no match is found.
-	  </para>
-
-	</blockquote></para></blockquote>
-
-    <blockquote><para>
-	<programlisting>
-    char *xf86GetOptValString(const OptionInfoRec *table, int token);
-	</programlisting>
-	<blockquote><para>
-      Returns the <structfield>value.str</structfield> field of the
-      <structname>OptionInfoRec</structname> in <parameter>table</parameter> with a
-      token field matching <parameter>token</parameter>.  Returns
-      <constant>NULL</constant> if no match is found.
-	  </para>
-
-	</blockquote></para></blockquote>
-
-	  <blockquote><para>
-	      <programlisting>
-    Bool xf86GetOptValInteger(const OptionInfoRec *table, int token,
-
-                                int *value);
-	      </programlisting>
-	      <blockquote><para>
-      Returns via <parameter>*value</parameter> the <structfield>value.num</structfield>
-      field of the <structname>OptionInfoRec</structname> in <parameter>table</parameter>
-      with a <structfield>token</structfield> field matching <parameter>token</parameter>.
-      <parameter>*value</parameter> is only changed when a match is found so
-      it can be safely initialised with a default prior to calling this
-      function.  The function return value is as for
-      <function>xf86IsOptionSet()</function>.
-	  </para>
-
-	</blockquote></para></blockquote>
-
-    <blockquote><para>
-	<programlisting>
-    Bool xf86GetOptValULong(const OptionInfoRec *table, int token,
-                            unsigned long *value);
-	</programlisting>
-	<blockquote><para>
-      Like <function>xf86GetOptValInteger()</function>, except the value is
-      treated as an <type>unsigned long</type>.
-	  </para>
-
-	</blockquote></para></blockquote>
-
-    <blockquote><para>
-	<programlisting>
-    Bool xf86GetOptValReal(const OptionInfoRec *table, int token,
-                           double *value);
-	</programlisting>
-	<blockquote><para>
-      Like <function>xf86GetOptValInteger()</function>, except that
-      <structfield>value.realnum</structfield> is used.
-	  </para>
-
-	</blockquote></para></blockquote>
-
-    <blockquote><para>
-	<programlisting>
-    Bool xf86GetOptValFreq(const OptionInfoRec *table, int token,
-                           OptFreqUnits expectedUnits, double *value);
-	</programlisting>
-	<blockquote><para>
-      Like <function>xf86GetOptValInteger()</function>, except that the
-      <structfield>value.freq</structfield> data is returned.  The frequency value
-      is scaled to the units indicated by <parameter>expectedUnits</parameter>.
-      The scaling is exact when the units were specified explicitly in
-      the option's value.  Otherwise, the <parameter>expectedUnits</parameter>
-      field is used as a hint when doing the scaling.  In this case,
-      values larger than <constant>1000</constant> are assumed to have be
-      specified in the next smallest units.  For example, if the Option
-      value is "10000" and expectedUnits is <constant>OPTUNITS_MHZ</constant>,
-      the value returned is <constant>10</constant>.
-	  </para>
-
-	</blockquote></para></blockquote>
-
-    <blockquote><para>
-      <programlisting>
-    Bool xf86GetOptValBool(const OptionInfoRec *table, int token, Bool *value);
-      </programlisting>
-	<blockquote><para>
-      This function is used to check boolean options
-      (<constant>OPTV_BOOLEAN</constant>).  If the function return value is
-      <constant>FALSE</constant>, it means the option wasn't set.  Otherwise
-      <parameter>*value</parameter> is set to the boolean value indicated by
-      the option's value.  No option <parameter>value</parameter> is interpreted
-      as <constant>TRUE</constant>.  Option values meaning <constant>TRUE</constant>
-      are "1", "yes", "on", "true", and option values meaning
-      <constant>FALSE</constant> are "0", "no", "off", "false".  Option names
-      both with the "no" prefix in their names, and with that prefix
-      removed are also checked and handled in the obvious way.
-      <parameter>*value</parameter> is not changed when the option isn't present.
-      It should normally be set to a default value before calling this
-      function.
-	  </para>
-
-	</blockquote></para></blockquote>
-
-    <blockquote><para>
-	<programlisting>
-    Bool xf86ReturnOptValBool(const OptionInfoRec *table, int token, Bool def);
-	</programlisting>
-	<blockquote><para>
-      This function is used to check boolean options
-      (<constant>OPTV_BOOLEAN</constant>).  If the option is set, its value
-      is returned.  If the options is not set, the default value specified
-      by <parameter>def</parameter> is returned.  The option interpretation is
-      the same as for <function>xf86GetOptValBool()</function>.
-	  </para>
-
-	</blockquote></para></blockquote>
-
-    <blockquote><para>
-	<programlisting>
-    int xf86NameCmp(const char *s1, const char *s2);
-	</programlisting>
-	<blockquote><para>
-      This function should be used when comparing strings from the config
-      file with expected values.  It works like <function>strcmp()</function>,
-      but is not case sensitive and space, tab, and <quote><literal>_</literal></quote> characters
-      are ignored in the comparison.  The use of this function isn't
-      restricted to parsing option values.  It may be used anywhere
-      where this functionality required.
-	  </para>
-
-	</blockquote></para></blockquote>
-  </sect1>
-
-  <sect1>
-    <title>Modules, Drivers, Include Files and Interface Issues</title>
-
-    <para>
-NOTE: this section is incomplete.
-    </para>
-
-
-    <sect2>
-      <title>Include files</title>
-
-      <para>
-The following include files are typically required by video drivers:
-
-	<blockquote><para>
-  All drivers should include these:
-	    <literallayout><filename>
-    "xf86.h"
-    "xf86_OSproc.h"
-    "xf86_ansic.h"
-    "xf86Resources.h"
-	    </filename></literallayout>
-  Wherever inb/outb (and related things) are used the following should be
-  included:
-	    <literallayout><filename>
-    "compiler.h"
-	      </filename></literallayout>
-  Note: in drivers, this must be included after <filename>"xf86_ansic.h"</filename>.
-	  </para>
-
-	  <para>
-  Drivers that need to access PCI vendor/device definitions need this:
-	    <literallayout><filename>
-    "xf86PciInfo.h"
-	      </filename></literallayout>
-	  </para>
-
-	  <para>
-  Drivers that need to access the PCI config space need this:
-	    <literallayout><filename>
-    "xf86Pci.h"
-	      </filename></literallayout>
-	  </para>
-
-	  <para>
-  Drivers that initialise a SW cursor need this:
-	    <literallayout><filename>
-    "mipointer.h"
-	      </filename></literallayout>
-	  </para>
-
-	  <para>
-  All drivers implementing backing store need this:
-	    <literallayout><filename>
-    "mibstore.h"
-	      </filename></literallayout>
-	  </para>
-
-	  <para>
-  All drivers using the mi colourmap code need this:
-	    <literallayout><filename>
-    "micmap.h"
-	      </filename></literallayout>
-	  </para>
-
-	  <para>
-  If a driver uses the vgahw module, it needs this:
-	    <literallayout><filename>
-    "vgaHW.h"
-	      </filename></literallayout>
-	  </para>
-
-	  <para>
-  Drivers supporting VGA or Hercules monochrome screens need:
-	    <literallayout><filename>
-    "xf1bpp.h"
-	      </filename></literallayout>
-	  </para>
-
-	  <para>
-  Drivers supporting VGA or EGC 16-colour screens need:
-	    <literallayout><filename>
-    "xf4bpp.h"
-	      </filename></literallayout>
-	  </para>
-
-	  <para>
-  Drivers using cfb need:
-	    <programlisting>
-    #define PSZ 8
-    #include "cfb.h"
-    #undef PSZ
-	    </programlisting>
-	  </para>
-
-	  <para>
-  Drivers supporting bpp 16, 24 or 32 with cfb need one or more of:
-	    <literallayout><filename>
-    "cfb16.h"
-    "cfb24.h"
-    "cfb32.h"
-	      </filename></literallayout>
-	  </para>
-
-	  <para>
-  If a driver uses XAA, it needs these:
-	    <literallayout><filename>
-    "xaa.h"
-    "xaalocal.h"
-	      </filename></literallayout>
-	  </para>
-
-	  <para>
-  If a driver uses the fb manager, it needs this:
-	    <literallayout><filename>
-    "xf86fbman.h"
-	      </filename></literallayout>
-	  </para>
-	</blockquote>
-      </para>
-
-      <para>
-Non-driver modules should include <filename>"xf86_ansic.h"</filename> to get the correct
-wrapping of ANSI C/libc functions.
-      </para>
-
-      <para>
-All modules must NOT include any system include files, or the following:
-
-	<literallayout><filename>
-    "xf86Priv.h"
-    "xf86Privstr.h"
-    "xf86_OSlib.h"
-    "Xos.h"
-	  </filename></literallayout>
-      </para>
-
-      <para>
-In addition, "xf86_libc.h" must not be included explicitly.  It is
-included implicitly by "xf86_ansic.h".
-      </para>
-
-    </sect2>
-  </sect1>
-
-  <sect1>
-    <title>Offscreen Memory Manager</title>
-
-    <para>
-Management of offscreen video memory may be handled by the XFree86
-framebuffer manager.  Once the offscreen memory manager is running,
-drivers or extensions may allocate, free or resize areas of offscreen
-video memory using the following functions (definitions taken from
-<filename>xf86fbman.h</filename>):
-
-      <programlisting>
-    typedef struct _FBArea {
-        ScreenPtr    pScreen;
-        BoxRec       box;
-        int          granularity;
-        void         (*MoveAreaCallback)(struct _FBArea*, struct _FBArea*)
-        void         (*RemoveAreaCallback)(struct _FBArea*)
-        DevUnion     devPrivate;
-    } FBArea, *FBAreaPtr;
-
-    typedef void (*MoveAreaCallbackProcPtr)(FBAreaPtr from, FBAreaPtr to)
-    typedef void (*RemoveAreaCallbackProcPtr)(FBAreaPtr)
-
-    FBAreaPtr xf86AllocateOffscreenArea (
-        ScreenPtr pScreen,
-        int width, int height,
-        int granularity,
-        MoveAreaCallbackProcPtr MoveAreaCallback,
-        RemoveAreaCallbackProcPtr RemoveAreaCallback,
-        pointer privData
-    )
-
-    void xf86FreeOffscreenArea (FBAreaPtr area)
-
-    Bool xf86ResizeOffscreenArea (
-	FBAreaPtr area
-	int w, int h
-    )
-      </programlisting>
-    </para>
-
-    <para>
-The function:
-      <programlisting>
-    Bool xf86FBManagerRunning(ScreenPtr pScreen);
-      </programlisting>
-
-can be used by an extension to check if the driver has initialized
-the memory manager.  The manager is not available if this returns
-<constant>FALSE</constant> and the functions above will all fail.
-    </para>
-
-
-    <para>
-<function>xf86AllocateOffscreenArea()</function> can be used to request a
-rectangle of dimensions <parameter>width</parameter> × <parameter>height</parameter>
-(in pixels) from unused offscreen memory.  <parameter>granularity</parameter>
-specifies that the leftmost edge of the rectangle must lie on some
-multiple of <parameter>granularity</parameter> pixels.  A granularity of zero
-means the same thing as a granularity of one - no alignment preference.
-A <parameter>MoveAreaCallback</parameter> can be provided to notify the requester
-when the offscreen area is moved.  If no <parameter>MoveAreaCallback</parameter>
-is supplied then the area is considered to be immovable.  The
-<parameter>privData</parameter> field will be stored in the manager's internal
-structure for that allocated area and will be returned to the requester
-in the <parameter>FBArea</parameter> passed via the
-<parameter>MoveAreaCallback</parameter>.  An optional
-<parameter>RemoveAreaCallback</parameter> is provided.  If the driver provides
-this it indicates that the area should be allocated with a lower priority.
-Such an area may be removed when a higher priority request (one that
-doesn't have a <parameter>RemoveAreaCallback</parameter>) is made.  When this
-function is called, the driver will have an opportunity to do whatever
-cleanup it needs to do to deal with the loss of the area, but it must
-finish its cleanup before the function exits since the offscreen memory
-manager will free the area immediately after.
-    </para>
-
-    <para>
-<function>xf86AllocateOffscreenArea()</function> returns <constant>NULL</constant>
-if it was unable to allocate the requested area.  When no longer needed,
-areas should be freed with <function>xf86FreeOffscreenArea()</function>.
-    </para>
-
-    <para>
-<function>xf86ResizeOffscreenArea()</function> resizes an existing
-<literal remap="tt">FBArea</literal>.  <function>xf86ResizeOffscreenArea()</function>
-returns <constant>TRUE</constant> if the resize was successful.  If
-<function>xf86ResizeOffscreenArea()</function> returns <constant>FALSE</constant>,
-the original <literal remap="tt">FBArea</literal> is left unmodified.  Resizing an
-area maintains the area's original <literal remap="tt">granularity</literal>,
-<literal remap="tt">devPrivate</literal>, and <literal remap="tt">MoveAreaCallback</literal>.
-<function>xf86ResizeOffscreenArea()</function> has considerably less overhead
-than freeing the old area then reallocating the new size, so it should
-be used whenever possible.
-    </para>
-
-    <para>
-The function:
-      <programlisting>
-    Bool xf86QueryLargestOffscreenArea(
-      ScreenPtr pScreen,
-      int *width, int *height,
-      int granularity,
-      int preferences,
-      int priority
-    );
-	</programlisting>
-
-is provided to query the width and height of the largest single
-<structname>FBArea</structname> allocatable given a particular priority.
-<parameter>preferences</parameter> can be one of the following to indicate
-whether width, height or area should be considered when determining
-which is the largest single <structname>FBArea</structname> available.
-
-      <programlisting>
-  FAVOR_AREA_THEN_WIDTH
-  FAVOR_AREA_THEN_HEIGHT
-  FAVOR_WIDTH_THEN_AREA
-  FAVOR_HEIGHT_THEN_AREA
-      </programlisting>
-    </para>
-
-    <para>
-<parameter>priority</parameter> is one of the following:
-
-      <blockquote>
-	<para>
-  <constant>PRIORITY_LOW</constant>
-	  <blockquote><para>
-     Return the largest block available without stealing anyone else's
-     space.  This corresponds to the priority of allocating a
-     <structname>FBArea</structname> when a <function>RemoveAreaCallback</function>
-     is provided.
-	    </para></blockquote>
-	</para>
-
-	<para>
-   <constant>PRIORITY_NORMAL</constant>
-	  <blockquote><para>
-     Return the largest block available if it is acceptable to steal a
-     lower priority area from someone.  This corresponds to the priority
-     of allocating a <structname>FBArea</structname> without providing a
-     <function>RemoveAreaCallback</function>.
-	    </para></blockquote>
-	</para>
-
-	<para>
-    <constant>PRIORITY_EXTREME</constant>
-	  <blockquote><para>
-     Return the largest block available if all <structname>FBArea</structname>s
-     that aren't locked down were expunged from memory first.  This
-     corresponds to any allocation made directly after a call to
-     <function>xf86PurgeUnlockedOffscreenAreas()</function>.
-	    </para></blockquote>
-	</para>
-
-      </blockquote>
-    </para>
-
-
-    <para>
-The function:
-
-      <programlisting>
-    Bool xf86PurgeUnlockedOffscreenAreas(ScreenPtr pScreen);
-      </programlisting>
-
-is provided as an extreme method to free up offscreen memory.  This
-will remove all removable <structname>FBArea</structname> allocations.
-    </para>
-
-
-    <para>
-Initialization of the XFree86 framebuffer manager is done via
-
-      <programlisting>
-    Bool xf86InitFBManager(ScreenPtr pScreen, BoxPtr FullBox);
-      </programlisting>
-
-<parameter>FullBox</parameter> represents the area of the framebuffer that the
-manager is allowed to manage.  This is typically a box with a width of
-<structfield>pScrn->displayWidth</structfield> and a height of as many lines as
-can be fit within the total video memory, however, the driver can reserve
-areas at the extremities by passing a smaller area to the manager.
-    </para>
-
-    <para>
-<function>xf86InitFBManager()</function> must be called before XAA is
-initialized since XAA uses the manager for it's pixmap cache.
-    </para>
-
-    <para>
-An alternative function is provided to allow the driver to initialize
-the framebuffer manager with a Region rather than a box.
-
-    <programlisting>
-    Bool xf86InitFBManagerRegion(ScreenPtr pScreen,
-                                 RegionPtr FullRegion);
-    </programlisting>
-
-<function>xf86InitFBManagerRegion()</function>, unlike
-<function>xf86InitFBManager()</function>, does not remove the area used for
-the visible screen so that area should not be included in the region
-passed to the function.  <function>xf86InitFBManagerRegion()</function> is
-useful when non-contiguous areas are available to be managed, and is
-required when multiple framebuffers are stored in video memory (as in
-the case where an overlay of a different depth is stored as a second
-framebuffer in offscreen memory).
-    </para>
-
-  </sect1>
-
-  <sect1 id="cmap">
-    <title>Colormap Handling</title>
-
-    <para>
-A generic colormap handling layer is provided within the XFree86 common
-layer.  This layer takes care of most of the details, and only requires
-a function from the driver that loads the hardware palette when required.
-To use the colormap layer, a driver calls the
-<function>xf86HandleColormaps()</function> function.
-
-      <blockquote><para>
-	  <programlisting>
-    Bool xf86HandleColormaps(ScreenPtr pScreen, int maxColors,
-                             int sigRGBbits, LoadPaletteFuncPtr loadPalette,
-                             SetOverscanFuncPtr setOverscan,
-                             unsigned int flags);
-	  </programlisting>
-	  <blockquote><para>
-      This function must be called after the default colormap has been
-      initialised.  The <structfield>pScrn->gamma</structfield> field must also
-      be initialised, preferably by calling <function>xf86SetGamma()</function>.
-      <parameter>maxColors</parameter> is the number of entries in the palette.
-      <parameter>sigRGBbits</parameter> is the size in bits of each color
-      component in the DAC's palette.  <parameter>loadPalette</parameter>
-      is a driver-provided function for loading a colormap into the
-      hardware, and is described below.  <parameter>setOverscan</parameter> is
-      an optional function that may be provided when the overscan color
-      is an index from the standard LUT and when it needs to be adjusted
-      to keep it as close to black as possible.  The
-      <parameter>setOverscan</parameter> function programs the overscan index.
-      It shouldn't normally be used for depths other than 8.
-      <parameter>setOverscan</parameter> should be set to <constant>NULL</constant>
-      when it isn't needed.  <parameter>flags</parameter> may be set to the
-      following (which may be ORed together):
-
-	      <variablelist>
-		<varlistentry>
-		  <term><constant>CMAP_PALETTED_TRUECOLOR</constant></term>
-		  <listitem><para>
-				    the TrueColor visual is paletted and is
-				    just a special case of DirectColor.
-				    This flag is only valid for
-				    <code>bpp > 8</code>.
-
-		    </para></listitem></varlistentry>
-		<varlistentry>
-		  <term><constant>CMAP_RELOAD_ON_MODE_SWITCH</constant></term>
-		  <listitem><para>
-				    reload the colormap automatically
-                                    after mode switches.  This is useful
-                                    for when the driver is resetting the
-                                    hardware during mode switches and
-                                    corrupting or erasing the hardware
-                                    palette.
-
-		    </para></listitem></varlistentry>
-		<varlistentry>
-		  <term><constant>CMAP_LOAD_EVEN_IF_OFFSCREEN</constant></term>
-		  <listitem><para>
-				    reload the colormap even if the screen
-				    is switched out of the server's VC.
-				    The palette is <emphasis>not</emphasis> reloaded when
-				    the screen is switched back in, nor after
-				    mode switches.  This is useful when the
-				    driver needs to keep track of palette
-				    changes.
-
-		    </para></listitem></varlistentry>
-	      </variablelist>
-	    </para>
-
-	    <para>
-      The colormap layer normally reloads the palette after VT enters so it
-      is not necessary for the driver to save and restore the palette
-      when switching VTs.  The driver must, however, still save the
-      initial palette during server start up and restore it during
-      server exit.
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    void LoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices,
-                     LOCO *colors, VisualPtr pVisual);
-	  </programlisting>
-	  <blockquote><para>
-      <function>LoadPalette()</function> is a driver-provided function for
-      loading a colormap into hardware.  <parameter>colors</parameter> is the
-      array of RGB values that represent the full colormap.
-      <parameter>indices</parameter> is a list of index values into the colors
-      array.  These indices indicate the entries that need to be updated.
-      <parameter>numColors</parameter> is the number of the indices to be
-      updated.
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    void SetOverscan(ScrnInfoPtr pScrn, int overscan);
-	  </programlisting>
-	  <blockquote><para>
-      <function>SetOverscan()</function> is a driver-provided function for
-      programming the <parameter>overscan</parameter> index.  As described
-      above, it is normally only appropriate for LUT modes where all
-      colormap entries are available for the display, but where one of
-      them is also used for the overscan (typically 8bpp for VGA compatible
-      LUTs).  It isn't required in cases where the overscan area is
-      never visible.
-	    </para>
-
-	  </blockquote></para>
-      </blockquote></para>
-
-  </sect1>
-
-  <sect1>
-    <title>DPMS Extension</title>
-
-    <para>
-Support code for the DPMS extension is included in the XFree86 common layer.
-This code provides an interface between the main extension code, and a means
-for drivers to initialise DPMS when they support it.  One function is
-available to drivers to do this initialisation, and it is always available,
-even when the DPMS extension is not supported by the core server (in
-which case it returns a failure result).
-    </para>
-
-    <blockquote><para>
-	<programlisting>
-    Bool xf86DPMSInit(ScreenPtr pScreen, DPMSSetProcPtr set, int flags);
-	</programlisting>
-	<blockquote><para>
-      This function registers a driver's DPMS level programming function
-      <parameter>set</parameter>.  It also checks
-      <structfield>pScrn->options</structfield> for the "dpms" option, and when
-      present marks DPMS as being enabled for that screen.  The
-      <parameter>set</parameter> function is called whenever the DPMS level
-      changes, and is used to program the requested level.
-      <parameter>flags</parameter> is currently not used, and should be
-      <constant>0</constant>.  If the initialisation fails for any reason,
-      including when there is no DPMS support in the core server, the
-      function returns <constant>FALSE</constant>.
-	  </para>
-
-	</blockquote></para></blockquote>
-
-
-    <para>
-Drivers that implement DPMS support must provide the following function,
-that gets called when the DPMS level is changed:
-
-
-      <blockquote><para>
-	  <programlisting>
-    void ChipDPMSSet(ScrnInfoPtr pScrn, int level, int flags);
-	  </programlisting>
-	  <blockquote><para>
-      Program the DPMS level specified by <parameter>level</parameter>.  Valid
-      values of <parameter>level</parameter> are <constant>DPMSModeOn</constant>,
-      <constant>DPMSModeStandby</constant>, <constant>DPMSModeSuspend</constant>,
-      <constant>DPMSModeOff</constant>.  These values are defined in
-      <filename>"extensions/dpms.h"</filename>.
-	    </para>
-
-	  </blockquote></para></blockquote>
-    </para>
-
-  </sect1>
-
-  <sect1>
-    <title>DGA Extension</title>
-
-    <para>
-Drivers can support the XFree86 Direct Graphics Architecture (DGA) by
-filling out a structure of function pointers and a list of modes and
-passing them to DGAInit.
-    </para>
-
-    <blockquote><para>
-	<programlisting>
-    Bool DGAInit(ScreenPtr pScreen, DGAFunctionPtr funcs,
-                 DGAModePtr modes, int num);
-
-/** The DGAModeRec **/
-
-typedef struct {
-  int num;
-  DisplayModePtr mode;
-  int flags;
-  int imageWidth;
-  int imageHeight;
-  int pixmapWidth;
-  int pixmapHeight;
-  int bytesPerScanline;
-  int byteOrder;
-  int depth;
-  int bitsPerPixel;
-  unsigned long red_mask;
-  unsigned long green_mask;
-  unsigned long blue_mask;
-  int viewportWidth;
-  int viewportHeight;
-  int xViewportStep;
-  int yViewportStep;
-  int maxViewportX;
-  int maxViewportY;
-  int viewportFlags;
-  int offset;
-  unsigned char *address;
-  int reserved1;
-  int reserved2;
-} DGAModeRec, *DGAModePtr;
-	</programlisting>
-
-	<variablelist>
-	  <varlistentry>
-	    <term><structfield>num</structfield></term>
-	    <listitem><para>
-	 Can be ignored.  The DGA DDX will assign these numbers.
-	      </para></listitem></varlistentry>
-
-	  <varlistentry>
-	    <term><structfield>mode</structfield></term>
-	    <listitem><para>
-	A pointer to the <structname>DisplayModeRec</structname> for this mode.
-	      </para></listitem></varlistentry>
-
-	  <varlistentry>
-	    <term><structfield>flags</structfield></term>
-	      <listitem><para>
-	The following flags are defined and may be OR'd together:
-
-		  <variablelist>
-		    <varlistentry>
-		      <term><constant>DGA_CONCURRENT_ACCESS</constant></term>
-		      <listitem><para>
-            Indicates that the driver supports concurrent graphics
-            accelerator and linear framebuffer access.
-
-			</para></listitem></varlistentry>
-
-		    <varlistentry>
-		      <term><constant>DGA_FILL_RECT
-			  DGA_BLIT_RECT
-			  DGA_BLIT_RECT_TRANS</constant></term>
-		      <listitem><para>
-	    Indicates that the driver supports the FillRect, BlitRect
-            or BlitTransRect functions in this mode.
-
-			</para></listitem></varlistentry>
-
-		    <varlistentry>
-		      <term><constant>DGA_PIXMAP_AVAILABLE</constant></term>
-		      <listitem><para>
-	    Indicates that Xlib may be used on the framebuffer.
-            This flag will usually be set unless the driver wishes
-            to prohibit this for some reason.
-
-			</para></listitem></varlistentry>
-
-		    <varlistentry>
-		      <term><constant>DGA_INTERLACED
-			  DGA_DOUBLESCAN</constant></term>
-		      <listitem><para>
-            Indicates that these are interlaced or double scan modes.
-
-			</para></listitem></varlistentry>
-		  </variablelist>
-		</para></listitem></varlistentry>
-
-	  <varlistentry>
-	    <term><structfield>imageWidth
-		imageHeight</structfield></term>
-	    <listitem><para>
-		    These are the dimensions of the linear framebuffer
-                     accessible by the client.
-
-	      </para></listitem></varlistentry>
-
-	  <varlistentry>
-	    <term><structfield>pixmapWidth
-		pixmapHeight</structfield></term>
-	    <listitem><para>
-		     These are the dimensions of the area of the
-                     framebuffer accessible by the graphics accelerator.
-
-	      </para></listitem></varlistentry>
-
-	  <varlistentry>
-	    <term><structfield>bytesPerScanline</structfield></term>
-	    <listitem><para>
-		      Pitch of the framebuffer in bytes.
-
-	      </para></listitem></varlistentry>
-
-	  <varlistentry>
-	    <term><structfield>byteOrder</structfield></term>
-	    <listitem><para>
-		     Usually the same as
-		     <structfield>pScrn->imageByteOrder</structfield>.
-
-	      </para></listitem></varlistentry>
-
-	  <varlistentry>
-	    <term><structfield>depth</structfield></term>
-	    <listitem><para>
-		     The depth of the framebuffer in this mode.
-
-	      </para></listitem></varlistentry>
-
-	  <varlistentry>
-	    <term><structfield>bitsPerPixel</structfield></term>
-	    <listitem><para>
-		      The number of bits per pixel in this mode.
-
-	      </para></listitem></varlistentry>
-
-	  <varlistentry>
-	    <term><structfield>red_mask</structfield></term>
-	    <term><structfield>green_mask</structfield></term>
-	    <term><structfield>blue_mask</structfield></term>
-	    <listitem><para>
-		      The RGB masks for this mode, if applicable.
-
-	      </para></listitem></varlistentry>
-
-	  <varlistentry>
-	    <term><structfield>viewportWidth</structfield></term>
-	    <term><structfield>viewportHeight</structfield></term>
-	    <listitem><para>
-		      Dimensions of the visible part of the framebuffer.
-		      Usually <structfield>mode->HDisplay</structfield> and
-		      <structfield>mode->VDisplay</structfield>.
-
-	      </para></listitem></varlistentry>
-
-	  <varlistentry>
-	    <term><structfield>xViewportStep
-		yViewportStep</structfield></term>
-	    <listitem><para>
-		     The granularity of x and y viewport positions that
-                     the driver supports in this mode.
-
-	      </para></listitem></varlistentry>
-
-	  <varlistentry>
-	    <term><structfield>maxViewportX
-		maxViewportY</structfield></term>
-	    <listitem><para>
-		      The maximum viewport position supported by the
-                       driver in this mode.
-	      </para></listitem></varlistentry>
-
-	  <varlistentry>
-	    <term><structfield>viewportFlags</structfield></term>
-	    <listitem><para>
-		     The following may be OR'd together:
-
-		<variablelist>
-		  <varlistentry>
-		    <term><constant>DGA_FLIP_IMMEDIATE</constant></term>
-		    <listitem><para>
-		The driver supports immediate viewport changes.
-		      </para></listitem></varlistentry>
-
-		  <varlistentry>
-		    <term><constant>DGA_FLIP_RETRACE</constant></term>
-
-		    <listitem><para>
-		The driver supports viewport changes at retrace.
-		      </para></listitem></varlistentry>
-		  </variablelist>
-	      </para></listitem></varlistentry>
-
-	  <varlistentry>
-	    <term><structfield>offset</structfield></term>
-	    <listitem><para>
-	        The offset into the linear framebuffer that corresponds to
-                pixel (0,0) for this mode.
-	      </para></listitem></varlistentry>
-
-	  <varlistentry>
-	    <term><structfield>address</structfield></term>
-	    <listitem><para>
-                The virtual address of the framebuffer as mapped by the driver.
-                This is needed when DGA_PIXMAP_AVAILABLE is set.
-	      </para></listitem></varlistentry>
-
-	</variablelist>
-
-	<programlisting>
-/** The DGAFunctionRec **/
-
-typedef struct {
-  Bool (*OpenFramebuffer)(
-       ScrnInfoPtr pScrn,
-       char **name,
-       unsigned char **mem,
-       int *size,
-       int *offset,
-       int *extra
-  );
-  void (*CloseFramebuffer)(ScrnInfoPtr pScrn);
-  Bool (*SetMode)(ScrnInfoPtr pScrn, DGAModePtr pMode);
-  void (*SetViewport)(ScrnInfoPtr pScrn, int x, int y, int flags);
-  int  (*GetViewport)(ScrnInfoPtr pScrn);
-  void (*Sync)(ScrnInfoPtr);
-  void (*FillRect)(
-       ScrnInfoPtr pScrn,
-       int x, int y, int w, int h,
-       unsigned long color
-  );
-  void (*BlitRect)(
-       ScrnInfoPtr pScrn,
-       int srcx, int srcy,
-       int w, int h,
-       int dstx, int dsty
-  );
-  void (*BlitTransRect)(
-       ScrnInfoPtr pScrn,
-       int srcx, int srcy,
-       int w, int h,
-       int dstx, int dsty,
-       unsigned long color
-  );
-} DGAFunctionRec, *DGAFunctionPtr;
-	</programlisting>
-
-
-	<blockquote><para>
-	    <programlisting>
-    Bool OpenFramebuffer (pScrn, name, mem, size, offset, extra);
-	    </programlisting>
-	    <blockquote><para>
-      <function>OpenFramebuffer()</function> should pass the client everything
-      it needs to know to be able to open the framebuffer.  These
-      parameters are OS specific and their meanings are to be interpreted
-      by an OS specific client library.
-
-		<variablelist>
-		  <varlistentry>
-		    <term><parameter>name</parameter></term>
-		    <listitem><para>
-	      The name of the device to open or <constant>NULL</constant> if
-	      there is no special device to open.  A <constant>NULL</constant>
-	      name tells the client that it should open whatever device
-	      one would usually open to access physical memory.
-		      </para></listitem></varlistentry>
-
-		  <varlistentry>
-		    <term><parameter>mem</parameter></term>
-		    <listitem><para>
-	      The physical address of the start of the framebuffer.
-		      </para></listitem></varlistentry>
-
-		  <varlistentry>
-		    <term><parameter>size</parameter></term>
-		    <listitem><para>
-	      The size of the framebuffer in bytes.
-		      </para></listitem></varlistentry>
-
-		  <varlistentry>
-		    <term><parameter>offset</parameter></term>
-		    <listitem><para>
-	      Any offset into the device, if applicable.
-		      </para></listitem></varlistentry>
-
-		  <varlistentry>
-		    <term><parameter>flags</parameter></term>
-		    <listitem><para>
-	      Any additional information that the client may need.
-	      Currently, only the <constant>DGA_NEED_ROOT</constant> flag is
-	      defined.
-		      </para></listitem></varlistentry>
-
-		</variablelist>
-	      </para></blockquote>
-	  </para></blockquote>
-
-	<blockquote><para>
-	    <programlisting>
-    void CloseFramebuffer (pScrn);
-	    </programlisting>
-	    <blockquote><para>
-      <function>CloseFramebuffer()</function> merely informs the driver (if it
-      even cares) that client no longer needs to access the framebuffer
-      directly.  This function is optional.
-	      </para>
-
-	    </blockquote></para></blockquote>
-
-	<blockquote><para>
-	    <programlisting>
-    Bool SetMode (pScrn, pMode);
-	    </programlisting>
-	    <blockquote><para>
-      <function>SetMode()</function> tells the driver to initialize the mode
-      passed to it.  If <parameter>pMode</parameter> is <constant>NULL</constant>,
-      then the driver should restore the original pre-DGA mode.
-	      </para>
-
-	    </blockquote></para></blockquote>
-
-	<blockquote><para>
-	    <programlisting>
-    void SetViewport (pScrn, x, y, flags);
-	    </programlisting>
-	    <blockquote><para>
-      <function>SetViewport()</function> tells the driver to make the upper
-      left-hand corner of the visible screen correspond to coordinate
-      <literal remap="tt">(x,y)</literal> on the framebuffer.  <parameter>flags</parameter>
-      currently defined are:
-
-		<variablelist>
-		  <varlistentry>
-		    <term><constant>DGA_FLIP_IMMEDIATE</constant></term>
-		    <listitem><para>
-	    The viewport change should occur immediately.
-		      </para></listitem></varlistentry>
-
-		  <varlistentry>
-		    <term><constant>DGA_FLIP_RETRACE</constant></term>
-		    <listitem><para>
-	    The viewport change should occur at the
-            vertical retrace, but this function should
-            return sooner if possible.
-			</para></listitem></varlistentry>
-		</variablelist>
-	      </para>
-
-	      <para>
-      The <literal remap="tt">(x,y)</literal> locations will be passed as the client
-      specified them, however, the driver is expected to round these
-      locations down to the next supported location as specified by the
-      <structfield>xViewportStep</structfield> and <structfield>yViewportStep</structfield>
-      for the current mode.
-	      </para>
-	    </blockquote></para></blockquote>
-
-	<blockquote><para>
-	    <programlisting>
-    int GetViewport (pScrn);
-	    </programlisting>
-	    <blockquote><para>
-      <function>GetViewport()</function> gets the current page flip status.
-      Set bits in the returned int correspond to viewport change requests
-      still pending.  For instance, set bit zero if the last SetViewport
-      request is still pending, bit one if the one before that is still
-      pending, etc.
-	      </para>
-
-	    </blockquote></para></blockquote>
-
-	<blockquote><para>
-	    <programlisting>
-    void Sync (pScrn);
-	    </programlisting>
-	    <blockquote><para>
-      This function should ensure that any graphics accelerator operations
-      have finished.  This function should not return until the graphics
-      accelerator is idle.
-	      </para>
-
-	    </blockquote></para></blockquote>
-
-	<blockquote><para>
-	    <programlisting>
-    void FillRect (pScrn, x, y, w, h, color);
-	    </programlisting>
-	    <blockquote><para>
-      This optional function should fill a rectangle
-      <parameter>w × h</parameter> located at
-      <parameter>(x,y)</parameter> in the given color.
-	      </para>
-
-	    </blockquote></para></blockquote>
-
-	<blockquote><para>
-	    <programlisting>
-    void BlitRect (pScrn, srcx, srcy, w, h, dstx, dsty);
-	    </programlisting>
-	    <blockquote><para>
-      This optional function should copy an area
-      <parameter>w × h</parameter> located at
-      <parameter>(srcx,srcy)</parameter> to location <parameter>(dstx,dsty)</parameter>.
-      This function will need to handle copy directions as appropriate.
-	      </para>
-
-	    </blockquote></para></blockquote>
-
-	<blockquote><para>
-	    <programlisting>
-    void BlitTransRect (pScrn, srcx, srcy, w, h, dstx, dsty, color);
-	    </programlisting>
-	    <blockquote><para>
-      This optional function is the same as BlitRect except that pixels
-      in the source corresponding to the color key <parameter>color</parameter>
-      should be skipped.
-	      </para>
-
-	    </blockquote></para></blockquote>
-    </para></blockquote>
-
-  </sect1>
-
-  <sect1>
-    <title>The XFree86 X Video Extension (Xv) Device Dependent Layer</title>
-
-    <para>
-XFree86 offers the X Video Extension which allows clients to treat video
-as any another primitive and <quote>Put</quote> video into drawables.  By default,
-the extension reports no video adaptors as being available since the
-DDX layer has not been initialized.  The driver can initialize the DDX
-layer by filling out one or more <literal remap="tt">XF86VideoAdaptorRecs</literal>
-as described later in this document and passing a list of
-<literal remap="tt">XF86VideoAdaptorPtr</literal> pointers to the following function:
-
-      <programlisting>
-    Bool xf86XVScreenInit(ScreenPtr pScreen,
-                          XF86VideoAdaptorPtr *adaptPtrs,
-                          int num);
-      </programlisting>
-    </para>
-
-    <para>
-After doing this, the extension will report video adaptors as being
-available, providing the data in their respective
-<literal remap="tt">XF86VideoAdaptorRecs</literal> was valid.
-<function>xf86XVScreenInit()</function> <emphasis>copies</emphasis> data from the structure
-passed to it so the driver may free it after the initialization.  At
-the moment, the DDX only supports rendering into Window drawables.
-Pixmap rendering will be supported after a sufficient survey of suitable
-hardware is completed.
-    </para>
-
-    <para>
-The <structname>XF86VideoAdaptorRec</structname>:
-
-      <programlisting>
-typedef struct {
-	unsigned int type;
-	int flags;
-	char *name;
-	int nEncodings;
-	XF86VideoEncodingPtr pEncodings;
-	int nFormats;
-	XF86VideoFormatPtr pFormats;
-	int nPorts;
-	DevUnion *pPortPrivates;
-	int nAttributes;
-	XF86AttributePtr pAttributes;
-	int nImages;
-	XF86ImagePtr pImages;
-	PutVideoFuncPtr PutVideo;
-	PutStillFuncPtr PutStill;
-	GetVideoFuncPtr GetVideo;
-	GetStillFuncPtr GetStill;
-	StopVideoFuncPtr StopVideo;
-	SetPortAttributeFuncPtr SetPortAttribute;
-	GetPortAttributeFuncPtr GetPortAttribute;
-	QueryBestSizeFuncPtr QueryBestSize;
-	PutImageFuncPtr PutImage;
-	QueryImageAttributesFuncPtr QueryImageAttributes;
-} XF86VideoAdaptorRec, *XF86VideoAdaptorPtr;
-      </programlisting></para>
-
-    <para>
-Each adaptor will have its own XF86VideoAdaptorRec.  The fields are
-as follows:
-
-      <variablelist>
-	<varlistentry>
-	  <term><structfield>type</structfield></term>
-	  <listitem><para>
-	This can be any of the following flags OR'd together.
-
-	      <variablelist>
-		<varlistentry>
-		  <term><constant>XvInputMask</constant>
-		    <constant>XvOutputMask</constant></term>
-		  <listitem><para>
-	    These refer to the target drawable and are similar to a Window's
-	    class. <literal remap="tt">XvInputMask</literal> indicates that the adaptor
-	    can put video into a drawable.  <literal remap="tt">XvOutputMask</literal>
-	    indicates that the adaptor can get video from a drawable.
-		    </para></listitem></varlistentry>
-
-		<varlistentry>
-		  <term><constant>XvVideoMask</constant>
-		    <constant>XvStillMask</constant>
-		    <constant>XvImageMask</constant></term>
-		  <listitem><para>
-	    These indicate that the adaptor supports video, still or
-	    image primitives respectively.
-		    </para></listitem></varlistentry>
-
-		<varlistentry>
-		  <term><constant>XvWindowMask</constant>
-		    <constant>XvPixmapMask</constant></term>
-		  <listitem><para>
-	    These indicate the types of drawables the adaptor is capable
-	    of rendering into.  At the moment, Pixmap rendering is not
-	    supported and the <constant>XvPixmapMask</constant> flag is ignored.
-		    </para></listitem></varlistentry>
-	      </variablelist>
-
-	    </para></listitem></varlistentry>
-
-	<varlistentry>
-	  <term><structfield>flags</structfield></term>
-	  <listitem><para>
-	Currently, the following flags are defined:
-
-	      <variablelist>
-		<varlistentry>
-		  <term><constant>VIDEO_NO_CLIPPING</constant></term>
-		  <listitem><para>
-	   This indicates that the video adaptor does not support
-	   clipping.  The driver will never receive <quote>Put</quote> requests
-	   where less than the entire area determined by
-	   <parameter>drw_x</parameter>, <parameter>drw_y</parameter>,
-	   <parameter>drw_w</parameter> and <parameter>drw_h</parameter> is visible.
-	   This flag does not apply to <quote>Get</quote> requests.  Hardware
-	   that is incapable of clipping <quote>Gets</quote> may punt or get
-	   the extents of the clipping region passed to it.
-		    </para></listitem>
-
-		</varlistentry>
-
-		<varlistentry>
-		  <term><constant>VIDEO_INVERT_CLIPLIST</constant></term>
-		  <listitem><para>
-	   This indicates that the video driver requires the clip
-	   list to contain the regions which are obscured rather
-	   than the regions which are are visible.
-		    </para></listitem>
-
-		</varlistentry>
-
-		<varlistentry>
-		  <term><constant>VIDEO_OVERLAID_STILLS</constant></term>
-		  <listitem><para>
-	   Implementing PutStill for hardware that does video as an
-	   overlay can be awkward since it's unclear how long to leave
-	   the video up for.  When this flag is set, StopVideo will be
-	   called whenever the destination gets clipped or moved so that
-	   the still can be left up until then.
-		    </para></listitem>
-
-		</varlistentry>
-
-		<varlistentry>
-		  <term><constant>VIDEO_OVERLAID_IMAGES</constant></term>
-		  <listitem><para>
-	   Same as <constant>VIDEO_OVERLAID_STILLS</constant> but for images.
-		    </para></listitem>
-		</varlistentry>
-
-		<varlistentry>
-		  <term><constant>VIDEO_CLIP_TO_VIEWPORT</constant></term>
-		  <listitem><para>
-	    Indicates that the clip region passed to the driver functions
-	    should be clipped to the visible portion of the screen in the
-	    case where the viewport is smaller than the virtual desktop.
-		    </para></listitem></varlistentry>
-
-	      </variablelist>
-	    </para></listitem></varlistentry>
-
-	<varlistentry>
-	  <term><structfield>name</structfield></term>
-	  <listitem><para>
-	The name of the adaptor.
-	    </para></listitem></varlistentry>
-
-
-	<varlistentry>
-	  <term><structfield>nEncodings</structfield>
-	    <structfield>pEncodings</structfield></term>
-	  <listitem><para>
-	The number of encodings the adaptor is capable of and pointer
-	to the <structname>XF86VideoEncodingRec</structname> array.  The
-	<structname>XF86VideoEncodingRec</structname> is described later on.
-	For drivers that only support XvImages there should be an encoding
-	named "XV_IMAGE" and the width and height should specify
-	the maximum size source image supported.
-	  </para></listitem></varlistentry>
-
-
-	<varlistentry>
-	  <term><structfield>nFormats</structfield>
-	      <structfield>pFormats</structfield></term>
-	  <listitem><para>
-	The number of formats the adaptor is capable of and pointer to
-	the <structname>XF86VideoFormatRec</structname> array.  The
-	<structname>XF86VideoFormatRec</structname> is described later on.
-	    </para></listitem></varlistentry>
-
-
-	<varlistentry>
-	  <term><structfield>nPorts</structfield>
-	    <structfield>pPortPrivates</structfield></term>
-	  <listitem><para>
-	The number of ports is the number of separate data streams which
-	the adaptor can handle simultaneously.  If you have more than
-	one port, the adaptor is expected to be able to render into more
-	than one window at a time.  <structfield>pPortPrivates</structfield> is
-	an array of pointers or ints - one for each port.  A port's
-	private data will be passed to the driver any time the port is
-	requested to do something like put the video or stop the video.
-	In the case where there may be many ports, this enables the
-	driver to know which port the request is intended for.  Most
-	commonly, this will contain a pointer to the data structure
-	containing information about the port.  In Xv, all ports on
-	a particular adaptor are expected to be identical in their
-	functionality.
-	    </para></listitem></varlistentry>
-
-
-	<varlistentry>
-	  <term><structfield>nAttributes</structfield>
-	    <structfield>pAttributes</structfield></term>
-	  <listitem><para>
-	The number of attributes recognized by the adaptor and a pointer to
-	the array of <structname>XF86AttributeRecs</structname>.  The
-	<structname>XF86AttributeRec</structname> is described later on.
-	    </para></listitem></varlistentry>
-
-
-	<varlistentry>
-	  <term><structfield>nImages</structfield>
-	    <structfield>pImages</structfield></term>
-	  <listitem><para>
-	The number of <structname>XF86ImageRecs</structname> supported by the adaptor
-	and a pointer to the array of <structname>XF86ImageRecs</structname>. The
-	<structname>XF86ImageRec</structname> is described later on.
-	    </para></listitem></varlistentry>
-
-
-	<varlistentry>
-	  <term><structfield>
-     PutVideo PutStill GetVideo GetStill StopVideo
-     SetPortAttribute GetPortAttribute QueryBestSize PutImage
-     QueryImageAttributes
-	    </structfield></term>
-	  <listitem><para>
-	These functions define the DDX->driver interface.  In each
-	case, the pointer <parameter>data</parameter> is passed to the driver.
-	This is the port private for that port as described above.  All
-	fields are required except under the following conditions:
-
-	      <orderedlist>
-		<listitem><para>
-	     <structfield>PutVideo</structfield>, <structfield>PutStill</structfield> and
-	     the image routines <structfield>PutImage</structfield> and
-	     <structfield>QueryImageAttributes</structfield> are not required when the
-	     adaptor type does not contain <constant>XvInputMask</constant>.
-		  </para></listitem>
-
-		<listitem><para>
-	     <structfield>GetVideo</structfield> and <structfield>GetStill</structfield>
-	     are not required when the adaptor type does not contain
-	     <constant>XvOutputMask</constant>.
-		  </para></listitem>
-
-		<listitem><para>
-	     <structfield>GetVideo</structfield> and <structfield>PutVideo</structfield>
-	     are not required when the adaptor type does not contain
-	     <constant>XvVideoMask</constant>.
-		  </para></listitem>
-
-		<listitem><para>
-	     <structfield>GetStill</structfield> and <structfield>PutStill</structfield>
-	     are not required when the adaptor type does not contain
-	     <constant>XvStillMask</constant>.
-		  </para></listitem>
-
-		<listitem><para>
-	     <structfield>PutImage</structfield> and <structfield>QueryImageAttributes</structfield>
-	     are not required when the adaptor type does not contain
-	     <constant>XvImageMask</constant>.
-		  </para></listitem>
-
-	      </orderedlist>
-
-	    </para>
-
-	    <para>
-	With the exception of <structfield>QueryImageAttributes</structfield>, these
-	functions should return <constant>Success</constant> if the operation was
-	completed successfully.  They can return <constant>XvBadAlloc</constant>
-	otherwise. <structfield>QueryImageAttributes</structfield> returns the size
-	of the XvImage queried.
-	    </para>
-
-	    <para>
-	If the <constant>VIDEO_NO_CLIPPING</constant>
-	flag is set, the <literal remap="tt">clipBoxes</literal> may be ignored by
-	the driver.  <literal remap="tt">ClipBoxes</literal> is an <literal remap="tt">X-Y</literal>
-	banded region identical to those used throughout the server.
-	The clipBoxes represent the visible portions of the area determined
-	by <literal remap="tt">drw_x</literal>, <literal remap="tt">drw_y</literal>,
-	<literal remap="tt">drw_w</literal> and <literal remap="tt">drw_h</literal> in the Get/Put
-	function.  The boxes are in screen coordinates, are guaranteed
-	not to overlap and an empty region will never be passed.
-	If the driver has specified <constant>VIDEO_INVERT_CLIPLIST</constant>,
-	<literal remap="tt">clipBoxes</literal> will indicate the areas of the primitive
-	which are obscured rather than the areas visible.
-
-	    </para></listitem></varlistentry>
-      </variablelist>
-
-      <blockquote><para>
-	  <programlisting>
-    typedef  int (* PutVideoFuncPtr)( ScrnInfoPtr pScrn,
-                   short vid_x, short vid_y, short drw_x, short drw_y,
-                   short vid_w, short vid_h, short drw_w, short drw_h,
-                   RegionPtr clipBoxes, pointer data );
-	  </programlisting>
-	      <blockquote><para>
-	  This indicates that the driver should take a subsection
-	  <parameter>vid_w</parameter> by <parameter>vid_h</parameter> at location
-	  <parameter>(vid_x,vid_y)</parameter> from the video stream and direct
-	  it into the rectangle <parameter>drw_w</parameter> by <parameter>drw_h</parameter>
-	  at location <parameter>(drw_x,drw_y)</parameter> on the screen, scaling as
-	  necessary.  Due to the large variations in capabilities of
-	  the various hardware expected to be used with this extension,
-	  it is not expected that all hardware will be able to do this
-	  exactly as described.  In that case the driver should just do
-	  <quote>the best it can,</quote> scaling as closely to the target rectangle
-	  as it can without rendering outside of it.  In the worst case,
-	  the driver can opt to just not turn on the video.
-	      </para>
-
-	    </blockquote></para></blockquote>
-
-	  <blockquote><para>
-	      <programlisting>
-    typedef  int (* PutStillFuncPtr)( ScrnInfoPtr pScrn,
-                   short vid_x, short vid_y, short drw_x, short drw_y,
-                   short vid_w, short vid_h, short drw_w, short drw_h,
-                   RegionPtr clipBoxes, pointer data );
-	      </programlisting>
-	      <blockquote><para>
-	  This is same as <structfield>PutVideo</structfield> except that the driver
-	  should place only one frame from the stream on the screen.
-	      </para>
-
-	    </blockquote></para></blockquote>
-
-	  <blockquote><para>
-	      <programlisting>
-    typedef int (* GetVideoFuncPtr)( ScrnInfoPtr pScrn,
-                  short vid_x, short vid_y, short drw_x, short drw_y,
-                  short vid_w, short vid_h, short drw_w, short drw_h,
-                  RegionPtr clipBoxes, pointer data );
-	      </programlisting>
-	      <blockquote><para>
-	  This is same as <structfield>PutVideo</structfield> except that the driver
-	  gets video from the screen and outputs it.  The driver should
-	  do the best it can to get the requested dimensions correct
-	  without reading from an area larger than requested.
-	      </para>
-
-	    </blockquote></para></blockquote>
-
-	  <blockquote><para>
-	      <programlisting>
-    typedef int (* GetStillFuncPtr)( ScrnInfoPtr pScrn,
-                  short vid_x, short vid_y, short drw_x, short drw_y,
-                  short vid_w, short vid_h, short drw_w, short drw_h,
-                  RegionPtr clipBoxes, pointer data );
-	      </programlisting>
-	      <blockquote><para>
-	  This is the same as <literal remap="tt">GetVideo</literal> except that the
-	  driver should place only one frame from the screen into the
-	  output stream.
-	      </para>
-
-	    </blockquote></para></blockquote>
-
-	  <blockquote><para>
-	      <programlisting>
-    typedef void (* StopVideoFuncPtr)(ScrnInfoPtr pScrn,
-                                      pointer data, Bool cleanup);
-	      </programlisting>
-	      <blockquote><para>
-	  This indicates the driver should stop displaying the video.
-	  This is used to stop both input and output video.  The
-	  <parameter>cleanup</parameter> field indicates that the video is
-	  being stopped because the client requested it to stop or
-	  because the server is exiting the current VT.  In that case
-	  the driver should deallocate any offscreen memory areas (if
-	  there are any) being used to put the video to the screen.  If
-	  <parameter>cleanup</parameter> is not set, the video is being stopped
-	  temporarily due to clipping or moving of the window, etc...
-	  and video will likely be restarted soon so the driver should
-	  not deallocate any offscreen areas associated with that port.
-	      </para>
-
-	    </blockquote></para></blockquote>
-	  <blockquote><para>
-	      <programlisting>
-    typedef int (* SetPortAttributeFuncPtr)(ScrnInfoPtr pScrn,
-                                Atom attribute,INT32 value, pointer data);
-	      </programlisting>
-
-	      <programlisting>
-    typedef int (* GetPortAttributeFuncPtr)(ScrnInfoPtr pScrn,
-                                Atom attribute,INT32 *value, pointer data);
-	      </programlisting>
-	      <blockquote><para>
-	  A port may have particular attributes such as hue,
-	  saturation, brightness or contrast.  Xv clients set and
-	  get these attribute values by sending attribute strings
-	  (Atoms) to the server.  Such requests end up at these
-	  driver functions.  It is recommended that the driver provide
-	  at least the following attributes mentioned in the Xv client
-	  library docs:
-		<literallayout><constant>
-		XV_ENCODING
-		XV_HUE
-		XV_SATURATION
-		XV_BRIGHTNESS
-  		XV_CONTRAST
-		  </constant></literallayout>
-	  but the driver may recognize as many atoms as it wishes.  If
-	  a requested attribute is unknown by the driver it should return
-	  <constant>BadMatch</constant>.  <constant>XV_ENCODING</constant> is the
-	  attribute intended to let the client specify which video
-	  encoding the particular port should be using (see the description
-	  of <structname>XF86VideoEncodingRec</structname> below).  If the
-	  requested encoding is unsupported, the driver should return
-	  <constant>XvBadEncoding</constant>.  If the value lies outside the
-	  advertised range <constant>BadValue</constant> may be returned.
-	  <constant>Success</constant> should be returned otherwise.
-	      </para>
-
-	    </blockquote></para></blockquote>
-
-	  <blockquote><para>
-	    <programlisting>
-    typedef void (* QueryBestSizeFuncPtr)(ScrnInfoPtr pScrn,
-                   Bool motion, short vid_w, short vid_h,
-                   short drw_w, short drw_h,
-                   unsigned int *p_w, unsigned int *p_h, pointer data);
-	    </programlisting>
-	    <blockquote><para>
-	   <function>QueryBestSize</function> provides the client with a way
-	   to query what the destination dimensions would end up being
-	   if they were to request that an area
-	   <parameter>vid_w</parameter> by <parameter>vid_h</parameter> from the video
-	   stream be scaled to rectangle of
-	   <parameter>drw_w</parameter> by <parameter>drw_h</parameter> on the screen.
-	   Since it is not expected that all hardware will be able to
-	   get the target dimensions exactly, it is important that the
-	   driver provide this function.
-	      </para>
-
-	    </blockquote></para></blockquote>
-
-	<blockquote><para>
-	    <programlisting>
-    typedef  int (* PutImageFuncPtr)( ScrnInfoPtr pScrn,
-                   short src_x, short src_y, short drw_x, short drw_y,
-                   short src_w, short src_h, short drw_w, short drw_h,
-                   int image, char *buf, short width, short height,
-                   Bool sync, RegionPtr clipBoxes, pointer data );
-	      </programlisting>
-	      <blockquote><para>
-	  This is similar to <structfield>PutStill</structfield> except that the
-	  source of the video is not a port but the data stored in a system
-	  memory buffer at <parameter>buf</parameter>.  The data is in the format
-	  indicated by the <parameter>image</parameter> descriptor and represents a
-	  source of size <parameter>width</parameter> by <parameter>height</parameter>.
-	  If <parameter>sync</parameter> is TRUE the driver should not return
-	  from this function until it is through reading the data
-	  from <parameter>buf</parameter>.  Returning when <parameter>sync</parameter>
-	  is TRUE indicates that it is safe for the data at <parameter>buf</parameter>
-	  to be replaced, freed, or modified.
-	      </para>
-
-	    </blockquote></para></blockquote>
-
-	<blockquote><para>
-	    <programlisting>
-    typedef  int (* QueryImageAttributesFuncPtr)( ScrnInfoPtr pScrn,
-                                int image, short *width, short *height,
-                                int *pitches, int *offsets);
-	    </programlisting>
-	    <blockquote><para>
-	  This function is called to let the driver specify how data for
-	  a particular <parameter>image</parameter> of size <parameter>width</parameter>
-	  by <parameter>height</parameter> should be stored.  Sometimes only
-	  the size and corrected width and height are needed.  In that
-	  case <parameter>pitches</parameter> and <parameter>offsets</parameter> are
-	  NULL.  The size of the memory required for the image is returned
-	  by this function.  The <parameter>width</parameter> and
-	  <parameter>height</parameter> of the requested image can be altered by
-	  the driver to reflect format limitations (such as component
-	  sampling periods that are larger than one).  If
-	  <parameter>pitches</parameter> and <parameter>offsets</parameter> are not NULL,
-	  these will be arrays with as many elements in them as there
-	  are planes in the <parameter>image</parameter> format.  The driver
-	  should specify the pitch (in bytes) of each scanline in the
-	  particular plane as well as the offset to that plane (in bytes)
-	  from the beginning of the image.
-	      </para>
-
-	  </blockquote></para></blockquote>
-    </para>
-
-    <para>
-The XF86VideoEncodingRec:
-
-      <blockquote><para>
-	  <programlisting>
-typedef struct {
-	int id;
-	char *name;
-	unsigned short width, height;
-	XvRationalRec rate;
-} XF86VideoEncodingRec, *XF86VideoEncodingPtr;
-
-	  </programlisting>
-	  <blockquote><para>
-   The <structname>XF86VideoEncodingRec</structname> specifies what encodings
-   the adaptor can support.  Most of this data is just informational
-   and for the client's benefit, and is what will be reported by
-   <function>XvQueryEncodings</function>.  The <parameter>id</parameter> field is
-   expected to be a unique identifier to allow the client to request a
-   certain encoding via the <constant>XV_ENCODING</constant> attribute string.
-
-	    </para>
-	  </blockquote></para></blockquote>
-    </para>
-
-    <para>
-The XF86VideoFormatRec:
-
-      <blockquote><para>
-	  <programlisting>
-typedef struct {
-	char  depth;
-	short class;
-} XF86VideoFormatRec, *XF86VideoFormatPtr;
-
-	  </programlisting>
-	  <blockquote><para>
-    This specifies what visuals the video is viewable in.
-    <parameter>depth</parameter> is the depth of the visual (not bpp).
-    <parameter>class</parameter> is the visual class such as
-    <constant>TrueColor</constant>, <constant>DirectColor</constant> or
-    <constant>PseudoColor</constant>.  Initialization of an adaptor will fail
-    if none of the visuals on that screen are supported.
-	    </para>
-
-	  </blockquote></para></blockquote>
-    </para>
-
-    <para>
-The XF86AttributeRec:
-
-      <blockquote><para>
-	  <programlisting>
-typedef struct {
-	int   flags;
-	int   min_value;
-	int   max_value;
-	char  *name;
-} XF86AttributeListRec, *XF86AttributeListPtr;
-
-	  </programlisting>
-	  <blockquote><para>
-   Each adaptor may have an array of these advertising the attributes
-   for its ports.  Currently defined flags are <literal remap="tt">XvGettable</literal>
-   and <literal remap="tt">XvSettable</literal> which may be OR'd together indicating that
-   attribute is <quote>gettable</quote> or <quote>settable</quote> by the client.  The
-   <literal remap="tt">min</literal> and <literal remap="tt">max</literal> field specify the valid range
-   for the value.  <literal remap="tt">Name</literal> is a text string describing the
-   attribute by name.
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-    </para>
-
-    <para>
-The XF86ImageRec:
-
-	<blockquote><para>
-	    <programlisting>
-typedef struct {
-	int id;
-	int type;
-	int byte_order;
-	char guid[16];
-	int bits_per_pixel;
-	int format;
-	int num_planes;
-
-	/* for RGB formats */
-	int depth;
-	unsigned int red_mask;
-	unsigned int green_mask;
-	unsigned int blue_mask;
-
-	/* for YUV formats */
-	unsigned int y_sample_bits;
-	unsigned int u_sample_bits;
-	unsigned int v_sample_bits;
-	unsigned int horz_y_period;
-	unsigned int horz_u_period;
-	unsigned int horz_v_period;
-	unsigned int vert_y_period;
-	unsigned int vert_u_period;
-	unsigned int vert_v_period;
-	char component_order[32];
-	int scanline_order;
-} XF86ImageRec, *XF86ImagePtr;
-
-	    </programlisting>
-	    <blockquote><para>
-   XF86ImageRec describes how video source data is laid out in memory.
-   The fields are as follows:
-
-		<variablelist>
-		  <varlistentry>
-		    <term><structfield>id</structfield></term>
-		    <listitem><para>
-	This is a unique descriptor for the format.  It is often good to
-        set this value to the FOURCC for the format when applicable.
-		      </para></listitem></varlistentry>
-
-		  <varlistentry>
-		    <term><structfield>type</structfield></term>
-		    <listitem><para>
-	This is <constant>XvRGB</constant> or <constant>XvYUV</constant>.
-		      </para></listitem></varlistentry>
-
-		  <varlistentry>
-		    <term><structfield>byte_order</structfield></term>
-		    <listitem><para>
-	This is <constant>LSBFirst</constant> or <constant>MSBFirst</constant>.
-		      </para></listitem></varlistentry>
-
-		  <varlistentry>
-		    <term><structfield>guid</structfield></term>
-		    <listitem><para>
-	This is the Globally Unique IDentifier for the format.  When
-	not applicable, all characters should be NULL.
-		      </para></listitem></varlistentry>
-
-		  <varlistentry>
-		    <term><structfield>bits_per_pixel</structfield></term>
-		    <listitem><para>
-	The number of bits taken up (but not necessarily used) by each
-	pixel.  Note that for some planar formats which have fractional
-	bits per pixel (such as IF09) this number may be rounded _down_.
-		      </para></listitem></varlistentry>
-
-		  <varlistentry>
-		    <term><structfield>format</structfield></term>
-		    <listitem><para>
-	This is <constant>XvPlanar</constant> or <constant>XvPacked</constant>.
-		      </para></listitem></varlistentry>
-
-		  <varlistentry>
-		    <term><structfield>num_planes</structfield></term>
-		    <listitem><para>
-	The number of planes in planar formats.  This should be set to
-	one for packed formats.
-		      </para></listitem></varlistentry>
-
-		  <varlistentry>
-		    <term><structfield>depth</structfield></term>
-		    <listitem><para>
-	The significant bits per pixel in RGB formats (analgous to the
-	depth of a pixmap format).
-		      </para></listitem></varlistentry>
-
-		  <varlistentry>
-		    <term><structfield>red_mask</structfield></term>
-		    <term><structfield>green_mask</structfield></term>
-		    <term><structfield>blue_mask</structfield></term>
-		    <listitem><para>
-	The red, green and blue bitmasks for packed RGB formats.
-		      </para></listitem></varlistentry>
-
-		  <varlistentry>
-		    <term><structfield>y_sample_bits</structfield></term>
-		    <term><structfield>u_sample_bits</structfield></term>
-		    <term><structfield>v_sample_bits</structfield></term>
-		    <listitem><para>
-	The y, u and v sample sizes (in bits).
-		      </para></listitem></varlistentry>
-
-		  <varlistentry>
-		    <term><structfield>horz_y_period</structfield></term>
-		    <term><structfield>horz_u_period</structfield></term>
-		    <term><structfield>horz_v_period</structfield></term>
-		    <listitem><para>
-	The y, u and v sampling periods in the horizontal direction.
-		      </para></listitem></varlistentry>
-
-		  <varlistentry>
-		    <term><structfield>vert_y_period</structfield></term>
-		    <term><structfield>vert_u_period</structfield></term>
-		    <term><structfield>vert_v_period</structfield></term>
-		    <listitem><para>
-	The y, u and v sampling periods in the vertical direction.
-		      </para></listitem></varlistentry>
-
-		  <varlistentry>
-		    <term><structfield>component_order</structfield></term>
-		    <listitem><para>
-	Uppercase ascii characters representing the order that
-	samples are stored within packed formats.  For planar formats
-	this represents the ordering of the planes.  Unused characters
-	in the 32 byte string should be set to NULL.
-		      </para></listitem></varlistentry>
-
-		  <varlistentry>
-		    <term><structfield>scanline_order</structfield></term>
-		    <listitem><para>
-	This is <constant>XvTopToBottom</constant> or <constant>XvBottomToTop</constant>.
-		      </para></listitem></varlistentry>
-
-		  </variablelist>
-	    </para>
-
-	    <para>
-  Since some formats (particular some planar YUV formats) may not
-be completely defined by the parameters above, the guid, when
-available, should provide the most accurate description of the
-format.
-	    </para>
-
-	  </blockquote></para></blockquote>
-    </para>
-  </sect1>
-
-  <sect1>
-    <title>The Loader</title>
-
-    <para>
-This section describes the interfaces to the module loader.  The loader
-interfaces can be divided into two groups: those that are only available to
-the XFree86 common layer, and those that are also available to modules.
-    </para>
-
-    <sect2>
-      <title>Loader Overview</title>
-
-      <para>
-The loader is capable of loading modules in a range of object formats,
-and knowledge of these formats is built in to the loader.  Knowledge of
-new object formats can be added to the loader in a straightforward
-manner.  This makes it possible to provide OS-independent modules (for
-a given CPU architecture type).  In addition to this, the loader can
-load modules via the OS-provided <function>dlopen(3)</function> service where
-available.  Such modules are not platform independent, and the semantics
-of <function>dlopen()</function> on most systems results in significant
-limitations in the use of modules of this type.  Support for
-<function>dlopen()</function> modules in the loader is primarily for
-experimental and development purposes.
-      </para>
-
-      <para>
-Symbols exported by the loader (on behalf of the core X server) to
-modules are determined at compile time.  Only those symbols explicitly
-exported are available to modules.  All external symbols of loaded
-modules are exported to other modules, and to the core X server.  The
-loader can be requested to check for unresolved symbols at any time,
-and the action to be taken for unresolved symbols can be controlled by
-the caller of the loader.  Typically the caller identifies which symbols
-can safely remain unresolved and which cannot.
-      </para>
-
-      <para>
-NOTE:  Now that ISO-C allows pointers to functions and pointers to data to
-have different internal representations, some of the following interfaces
-will need to be revisited.
-      </para>
-    </sect2>
-
-    <sect2>
-      <title>Semi-private Loader Interface</title>
-
-      <para>
-The following is the semi-private loader interface that is available to the
-XFree86 common layer.
-      </para>
-
-      <blockquote><para>
-	  <programlisting>
-    void LoaderInit(void);
-	  </programlisting>
-	  <blockquote><para>
-    The <function>LoaderInit()</function> function initialises the loader,
-    and it must be called once before calling any other loader functions.
-    This function initialises the tables of exported symbols, and anything
-    else that might need to be initialised.
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    void LoaderSetPath(const char *path);
-	  </programlisting>
-	  <blockquote><para>
-    The <function>LoaderSetPath()</function> function initialises a default
-    module search path.  This must be called if calls to other functions
-    are to be made without explicitly specifying a module search path.
-    The search path <parameter>path</parameter> must be a string of one or more
-    comma separated absolute paths.  Modules are expected to be located
-    below these paths, possibly in subdirectories of these paths.
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    pointer LoadModule(const char *module, const char *path,
-                       const char **subdirlist, const char **patternlist,
-                       pointer options, const XF86ModReqInfo * modreq,
-                       int *errmaj, int *errmin);
-	  </programlisting>
-	  <blockquote><para>
-    The <function>LoadModule()</function> function loads the module called
-    <parameter>module</parameter>.  The return value is a module handle, and
-    may be used in future calls to the loader that require a reference
-    to a loaded module.  The module name <parameter>module</parameter> is
-    normally the module's canonical name, which doesn't contain any
-    directory path information, or any object/library file prefixes of
-    suffixes.  Currently a full pathname and/or filename is also accepted.
-    This might change.  The other parameters are:
-
-	      <variablelist>
-		<varlistentry>
-		  <term><parameter>path</parameter></term>
-		  <listitem><para>
-		  An optional comma-separated list of module search paths.
-		  When <constant>NULL</constant>, the default search path is used.
-		    </para></listitem></varlistentry>
-
-
-		<varlistentry>
-		  <term><parameter>subdirlist</parameter></term>
-		  <listitem><para>
-		  An optional <constant>NULL</constant> terminated list of
-		  subdirectories to search.  When <constant>NULL</constant>,
-		  the default built-in list is used (refer to
-		  <varname>stdSubdirs</varname> in <filename>loadmod.c</filename>).
-		  The default list is also substituted for entries in
-		  <parameter>subdirlist</parameter> with the value
-		  <constant>DEFAULT_LIST</constant>.  This makes is possible
-		  to augment the default list instead of replacing it.
-		  Subdir elements must be relative, and must not contain
-		  <literal remap="tt">".."</literal>.  If any violate this requirement,
-		  the load fails.
-		    </para></listitem></varlistentry>
-
-
-		<varlistentry>
-		  <term><parameter>patternlist</parameter></term>
-		  <listitem><para>
-		  An optional <constant>NULL</constant> terminated list of
-		  POSIX regular expressions used to connect module
-		  filenames with canonical module names.  Each regex
-		  should contain exactly one subexpression that corresponds
-		  to the canonical module name.  When <constant>NULL</constant>,
-		  the default built-in list is used (refer to
-		  <varname>stdPatterns</varname> in
-		  <filename>loadmod.c</filename>).  The default list is also
-		  substituted for entries in <parameter>patternlist</parameter>
-		  with the value <constant>DEFAULT_LIST</constant>.  This
-		  makes it possible to augment the default list instead
-		  of replacing it.
-		    </para></listitem></varlistentry>
-
-
-		<varlistentry>
-		  <term><parameter>options</parameter></term>
-		  <listitem><para>
-		  An optional parameter that is passed to the newly
-		  loaded module's <literal remap="tt">SetupProc</literal> function
-		  (if it has one).  This argument is normally a
-		  <constant>NULL</constant> terminated list of
-		  <structname>Options</structname>, and must be interpreted that
-		  way by modules loaded directly by the XFree86 common
-		  layer.  However, it may be used for application-specific
-		  parameter passing in other situations.
-		    </para>
-
-		    <para>
-		  When loading <quote>external</quote> modules (modules that don't
-		  have the standard entry point, for example a
-		  special shared library) the options parameter can be
-		  set to <constant>EXTERN_MODULE</constant> to tell the
-		  loader not to reject the module when it doesn't find
-		  the standard entry point.
-		    </para></listitem></varlistentry>
-
-
-		<varlistentry>
-		  <term><parameter>modreq</parameter></term>
-		  <listitem><para>
-		  An optional <structname>XF86ModReqInfo*</structname> containing
-		  version/ABI/vendor information to requirements to
-		  check the newly loaded module against.  The main
-		  purpose of this is to allow the loader to verify that
-		  a module of the correct type/version before running
-		  its <function>SetupProc</function> function.
-		      </para>
-
-		    <para>
-		  The <literal remap="tt">XF86ModReqInfo</literal> struct is defined
-		  as follows:
-		      <programlisting>
-typedef struct {
-	CARD8        majorversion;  /* MAJOR_UNSPEC */
-	CARD8        minorversion;  /* MINOR_UNSPEC */
-	CARD16       patchlevel;    /* PATCH_UNSPEC */
-	const char * abiclass;      /* ABI_CLASS_NONE */
-	CARD32       abiversion;    /* ABI_VERS_UNSPEC */
-	const char * moduleclass;   /* MOD_CLASS_NONE */
-} XF86ModReqInfo;
-			</programlisting>
-
-		  The information here is compared against the equivalent
-		  information in the module's
-		  <structname>XF86ModuleVersionInfo</structname> record (which
-		  is described below).  The values in comments above
-		  indicate <quote>don't care</quote> settings for each of the fields.
-		  The comparisons made are as follows:
-
-		      <variablelist>
-			<varlistentry>
-			  <term><structfield>majorversion</structfield></term>
-			  <listitem><para>
-				   Must match the module's majorversion
-				   exactly.
-			    </para></listitem></varlistentry>
-
-			<varlistentry>
-			  <term><structfield>minorversion</structfield></term>
-			  <listitem><para>
-				   The module's minor version must be
-				   no less than this value.  This
-				   comparison is only made if
-				   <structfield>majorversion</structfield> is
-				   specified and matches.
-			    </para></listitem></varlistentry>
-
-			<varlistentry>
-			  <term><structfield>patchlevel</structfield></term>
-			  <listitem><para>
-				   The module's patchlevel must be no
-				   less than this value.  This comparison
-				   is only made if
-				   <structfield>minorversion</structfield> is
-				   specified and matches.
-			    </para></listitem></varlistentry>
-
-			<varlistentry>
-			  <term><structfield>abiclass</structfield></term>
-			  <listitem><para>
-				   String must match the module's abiclass
-				   string.
-			    </para></listitem></varlistentry>
-
-			<varlistentry>
-			  <term><structfield>abiversion</structfield></term>
-			  <listitem><para>
-				   Must be consistent with the module's
-				   abiversion (major equal, minor no
-				   older).
-			    </para></listitem></varlistentry>
-
-			<varlistentry>
-			  <term><structfield>moduleclass</structfield></term>
-			  <listitem><para>
-				   String must match the module's
-				   moduleclass string.
-			    </para></listitem></varlistentry>
-
-		      </variablelist>
-		    </para></listitem></varlistentry>
-
-		<varlistentry>
-		  <term><parameter>errmaj</parameter></term>
-		  <listitem><para>
-		  An optional pointer to a variable holding the major
-		  part or the error code.  When provided,
-		  <parameter>*errmaj</parameter> is filled in when
-		  <function>LoadModule()</function> fails.
-		    </para></listitem></varlistentry>
-
-		<varlistentry>
-		  <term><parameter>errmin</parameter></term>
-		  <listitem><para>
-		  Like <parameter>errmaj</parameter>, but for the minor part
-		  of the error code.
-		    </para></listitem></varlistentry>
-
-	      </variablelist>
-
-	    </para></blockquote>
-	</para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    void UnloadModule(pointer mod);
-	  </programlisting>
-	  <blockquote><para>
-    This function unloads the module referred to by the handle mod.
-    All child modules are also unloaded recursively.  This function must
-    not be used to directly unload modules that are child modules (i.e.,
-    those that have been loaded with the <function>LoadSubModule()</function>
-    described below).
-	    </para>
-
-	  </blockquote></para></blockquote>
-    </sect2>
-
-    <sect2>
-      <title>Module Requirements</title>
-
-      <para>
-Modules must provide information about themselves to the loader, and
-may optionally provide entry points for "setup" and "teardown" functions
-(those two functions are referred to here as <function>SetupProc</function>
-and <function>TearDownProc</function>).
-      </para>
-
-      <para>
-The module information is contained in the
-<structname>XF86ModuleVersionInfo</structname> struct, which is defined as follows:
-
-	<programlisting>
-typedef struct {
-    const char * modname;      /* name of module, e.g. "foo" */
-    const char * vendor;       /* vendor specific string */
-    CARD32       _modinfo1_;   /* constant MODINFOSTRING1/2 to find */
-    CARD32       _modinfo2_;   /* infoarea with a binary editor/sign tool */
-    CARD32       xf86version;  /* contains XF86_VERSION_CURRENT */
-    CARD8        majorversion; /* module-specific major version */
-    CARD8        minorversion; /* module-specific minor version */
-    CARD16       patchlevel;   /* module-specific patch level */
-    const char * abiclass;     /* ABI class that the module uses */
-    CARD32       abiversion;   /* ABI version */
-    const char * moduleclass;  /* module class */
-    CARD32       checksum[4];  /* contains a digital signature of the */
-                               /* version info structure */
-} XF86ModuleVersionInfo;
-	</programlisting>
-
-The fields are used as follows:
-
-	<variablelist>
-	  <varlistentry>
-	    <term><structfield>modname</structfield></term>
-	    <listitem><para>
-		The module's name.  This field is currently only for
-		informational purposes, but the loader may be modified
-		in future to require it to match the module's canonical
-                name.
-	      </para></listitem></varlistentry>
-
-
-	  <varlistentry>
-	    <term><structfield>vendor</structfield></term>
-	    <listitem><para>
-		The module vendor.  This field is for informational purposes
-                only.
-	      </para></listitem></varlistentry>
-
-
-	  <varlistentry>
-	    <term><structfield>_modinfo1_</structfield></term>
-	    <listitem><para>
-		This field holds the first part of a signature that can
-                be used to locate this structure in the binary.  It should
-		always be initialised to <constant>MODINFOSTRING1</constant>.
-	      </para></listitem></varlistentry>
-
-
-	  <varlistentry>
-	    <term><structfield>_modinfo2_</structfield></term>
-	    <listitem><para>
-		This field holds the second part of a signature that can
-                be used to locate this structure in the binary.  It should
-		always be initialised to <constant>MODINFOSTRING2</constant>.
-	      </para></listitem></varlistentry>
-
-
-	  <varlistentry>
-	    <term><structfield>xf86version</structfield></term>
-	    <listitem><para>
-		The XFree86 version against which the module was compiled.
-                This is mostly for informational/diagnostic purposes.  It
-		should be initialised to <constant>XF86_VERSION_CURRENT</constant>, which is
-		defined in <filename>xf86Version.h</filename>.
-	      </para></listitem></varlistentry>
-
-
-	  <varlistentry>
-	    <term><structfield>majorversion</structfield></term>
-	    <listitem><para>
-		The module-specific major version.  For modules where this
-		version is used for more than simply informational
-		purposes, the major version should only change (be
-		incremented) when ABI incompatibilities are introduced,
-		or ABI components are removed.
-	      </para></listitem></varlistentry>
-
-
-	  <varlistentry>
-	    <term><structfield>minorversion</structfield></term>
-	    <listitem><para>
-		The module-specific minor version.  For modules where this
-		version is used for more than simply informational
-		purposes, the minor version should only change (be
-		incremented) when ABI additions are made in a backward
-		compatible way.  It should be reset to zero when the major
-                version is increased.
-	      </para></listitem></varlistentry>
-
-
-	  <varlistentry>
-	    <term><structfield>patchlevel</structfield></term>
-	    <listitem><para>
-		The module-specific patch level.  The patch level should
-		increase with new revisions of the module where there
-		are no ABI changes, and it should be reset to zero when
-		the minor version is increased.
-	      </para></listitem></varlistentry>
-
-
-	  <varlistentry>
-	    <term><structfield>abiclass</structfield></term>
-	    <listitem><para>
-		The ABI class that the module requires.  The class is
-                specified as a string for easy extensibility.  It should
-		indicate which (if any) of the X server's built-in ABI
-		classes that the module relies on, or a third-party ABI
-                if appropriate.  Built-in ABI classes currently defined are:
-
-		<variablelist>
-		  <varlistentry>
-		    <term><constant>ABI_CLASS_NONE</constant></term>
-		    <listitem><para>no class
-		      </para></listitem></varlistentry>
-		  <varlistentry>
-		    <term><constant>ABI_CLASS_ANSIC</constant></term>
-		    <listitem><para>only requires the ANSI C interfaces
-		      </para></listitem></varlistentry>
-		  <varlistentry>
-		    <term><constant>ABI_CLASS_VIDEODRV</constant></term>
-		    <listitem><para>requires the video driver ABI
-		      </para></listitem></varlistentry>
-		  <varlistentry>
-		    <term><constant>ABI_CLASS_XINPUT</constant></term>
-		    <listitem><para>requires the XInput driver ABI
-		      </para></listitem></varlistentry>
-		  <varlistentry>
-		    <term><constant>ABI_CLASS_EXTENSION</constant></term>
-		    <listitem><para>requires the extension module ABI
-		      </para></listitem></varlistentry>
-		  <varlistentry>
-		    <term><constant>ABI_CLASS_FONT</constant></term>
-		    <listitem><para>requires the font module ABI
-		      </para></listitem></varlistentry>
-		</variablelist>
-
-	      </para></listitem></varlistentry>
-
-	  <varlistentry>
-	    <term><structfield>abiversion</structfield></term>
-	    <listitem><para>
-		The version of abiclass that the module requires.  The
-		version consists of major and minor components.  The
-		major version must match and the minor version must be
-		no newer than that provided by the server or parent
-		module.  Version identifiers for the built-in classes
-		currently defined are:
-
-		<literallayout><constant>
-                   ABI_ANSIC_VERSION
-                   ABI_VIDEODRV_VERSION
-                   ABI_XINPUT_VERSION
-                   ABI_EXTENSION_VERSION
-                   ABI_FONT_VERSION
-		  </constant></literallayout>
-
-	      </para></listitem></varlistentry>
-
-	  <varlistentry>
-	    <term><structfield>moduleclass</structfield></term>
-	    <listitem><para>
-		This is similar to the abiclass field, except that it
-		defines the type of module rather than the ABI it
-		requires.  For example, although all video drivers require
-		the video driver ABI, not all modules that require the
-		video driver ABI are video drivers.  This distinction
-		can be made with the moduleclass.  Currently pre-defined
-		module classes are:
-
-		<literallayout><constant>
-                   MOD_CLASS_NONE
-                   MOD_CLASS_VIDEODRV
-                   MOD_CLASS_XINPUT
-                   MOD_CLASS_FONT
-                   MOD_CLASS_EXTENSION
-		  </constant></literallayout>
-
-	      </para></listitem></varlistentry>
-
-	  <varlistentry>
-	    <term><structfield>checksum</structfield></term>
-	    <listitem><para>
-		Not currently used.
-	      </para></listitem></varlistentry>
-
-	</variablelist>
-      </para>
-
-      <para>
-The module version information, and the optional <function>SetupProc</function>
-and <function>TearDownProc</function> entry points are found by the loader
-by locating a data object in the module called "modnameModuleData",
-where "modname" is the canonical name of the module.  Modules must
-contain such a data object, and it must be declared with global scope,
-be compile-time initialised, and is of the following type:
-
-	<programlisting>
-typedef struct {
-    XF86ModuleVersionInfo *     vers;
-    ModuleSetupProc             setup;
-    ModuleTearDownProc          teardown;
-} XF86ModuleData;
-	</programlisting>
-      </para>
-
-      <para>
-The vers parameter must be initialised to a pointer to a correctly
-initialised <structname>XF86ModuleVersionInfo</structname> struct.  The other
-two parameter are optional, and should be initialised to
-<constant>NULL</constant> when not required.  The other parameters are defined
-as
-
-	<blockquote><para>
-	    <programlisting>
-    typedef pointer (*ModuleSetupProc)(pointer, pointer, int *, int *);
-
-    typedef void (*ModuleTearDownProc)(pointer);
-
-    pointer SetupProc(pointer module, pointer options,
-                      int *errmaj, int *errmin);
-	    </programlisting>
-	    <blockquote><para>
-    When defined, this function is called by the loader after successfully
-    loading a module.  module is a handle for the newly loaded module,
-    and maybe used by the <function>SetupProc</function> if it calls other
-    loader functions that require a reference to it.   The remaining
-    arguments are those that were passed to the
-    <function>LoadModule()</function> (or <function>LoadSubModule()</function>),
-    and are described above. When the <function>SetupProc</function> is
-    successful it must return a non-<constant>NULL</constant> value.  The
-    loader checks this, and if it is <constant>NULL</constant> it unloads
-    the module and reports the failure to the caller of
-    <function>LoadModule()</function>.  If the <function>SetupProc</function>
-    does things that need to be undone when the module is unloaded,
-    it should define a <function>TearDownProc</function>, and return a
-    pointer that the <function>TearDownProc</function> can use to undo what
-    has been done.
-	      </para>
-
-	      <para>
-    When a module is loaded multiple times, the <function>SetupProc</function>
-    is called once for each time it is loaded.
-	      </para>
-
-	    </blockquote></para></blockquote>
-
-	<blockquote><para>
-	    <programlisting>
-    void TearDownProc(pointer tearDownData);
-	    </programlisting>
-	    <blockquote><para>
-    When defined, this function is called when the loader unloads a
-    module.  The <parameter>tearDownData</parameter> parameter is the return
-    value of the <function>SetupProc()</function> that was called when the
-    module was loaded.  The purpose of this function is to clean up
-    before the module is unloaded (for example, by freeing allocated
-    resources).
-	      </para>
-
-	    </blockquote></para></blockquote>
-      </para>
-    </sect2>
-
-    <sect2>
-      <title>Public Loader Interface</title>
-
-      <para>
-The following is the Loader interface that is available to any part of
-the server, and may also be used from within modules.
-      </para>
-
-      <blockquote><para>
-	  <programlisting>
-    pointer LoadSubModule(pointer parent, const char *module,
-                          const char **subdirlist, const char **patternlist,
-                          pointer options, const XF86ModReqInfo * modreq,
-                          int *errmaj, int *errmin);
-	  </programlisting>
-	  <blockquote><para>
-    This function is like the <function>LoadModule()</function> function
-    described above, except that the module loaded is registered as a
-    child of the calling module.  The <parameter>parent</parameter> parameter
-    is the calling module's handle.  Modules loaded with this function
-    are automatically unloaded when the parent module is unloaded.  The
-    other difference is that the path parameter may not be specified.
-    The module search path used for modules loaded with this function
-    is the default search path as initialised with
-    <function>LoaderSetPath()</function>.
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    void UnloadSubModule(pointer module);
-	  </programlisting>
-	  <blockquote><para>
-    This function unloads the module with handle <parameter>module</parameter>.
-    If that module itself has children, they are also unloaded.  It is
-    like <function>UnloadModule()</function>, except that it is safe to use
-    for unloading child modules.
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    pointer LoaderSymbol(const char *symbol);
-	  </programlisting>
-	<blockquote><para>
-    This function returns the address of the symbol with name
-    <parameter>symbol</parameter>.  This may be used to locate a module entry
-    point with a known name.
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    char **LoaderlistDirs(const char **subdirlist,
-                          const char **patternlist);
-	  </programlisting>
-	  <blockquote><para>
-    This function returns a <constant>NULL</constant> terminated list of
-    canonical modules names for modules found in the default module
-    search path.  The <parameter>subdirlist</parameter> and
-    <parameter>patternlist</parameter> parameters are as described above, and
-    can be used to control the locations and names that are searched.
-    If no modules are found, the return value is <constant>NULL</constant>.
-    The returned list should be freed by calling
-    <function>LoaderFreeDirList()</function> when it is no longer needed.
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    void LoaderFreeDirList(char **list);
-	  </programlisting>
-	  <blockquote><para>
-    This function frees a module list created by
-    <function>LoaderlistDirs()</function>.
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    void LoaderReqSymLists(const char **list0, ...);
-	  </programlisting>
-	  <blockquote><para>
-    This function allows the registration of required symbols with the
-    loader.  It is normally used by a caller of
-    <function>LoadSubModule()</function>.  If any symbols registered in this
-    way are found to be unresolved when
-    <function>LoaderCheckUnresolved()</function> is called then
-    <function>LoaderCheckUnresolved()</function> will report a failure.
-    The function takes one or more <constant>NULL</constant> terminated
-    lists of symbols.  The end of the argument list is indicated by a
-    <constant>NULL</constant> argument.
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    void LoaderReqSymbols(const char *sym0, ...);
-	  </programlisting>
-	<blockquote><para>
-    This function is like <function>LoaderReqSymLists()</function> except
-    that its arguments are symbols rather than lists of symbols.  This
-    function is more convenient when single functions are to be registered,
-    especially when the single function might depend on runtime factors.
-    The end of the argument list is indicated by a <constant>NULL</constant>
-    argument.
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    void LoaderRefSymLists(const char **list0, ...);
-	  </programlisting>
-	  <blockquote><para>
-    This function allows the registration of possibly unresolved symbols
-    with the loader.  When <function>LoaderCheckUnresolved()</function> is
-    run it won't generate warnings for symbols registered in this way
-    unless they were also registered as required symbols.
-    The function takes one or more <constant>NULL</constant> terminated
-    lists of symbols.  The end of the argument list is indicated by a
-    <constant>NULL</constant> argument.
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    void LoaderRefSymbols(const char *sym0, ...);
-	  </programlisting>
-	  <blockquote><para>
-    This function is like <function>LoaderRefSymLists()</function> except
-    that its arguments are symbols rather than lists of symbols.  This
-    function is more convenient when single functions are to be registered,
-    especially when the single function might depend on runtime factors.
-    The end of the argument list is indicated by a <constant>NULL</constant>
-    argument.
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    int LoaderCheckUnresolved(int delayflag);
-	  </programlisting>
-	  <blockquote><para>
-    This function checks for unresolved symbols.  It generates warnings
-    for unresolved symbols that have not been registered with
-    <function>LoaderRefSymLists()</function>, and maps them to a dummy
-    function.  This behaviour may change in future.  If unresolved
-    symbols are found that have been registered with
-    <function>LoaderReqSymLists()</function> or
-    <function>LoaderReqSymbols()</function> then this function returns a
-    non-zero value.  If none of these symbols are unresolved the return
-    value is zero, indicating success.
-	    </para>
-
-	    <para>
-    The <parameter>delayflag</parameter> parameter should normally be set to
-    <constant>LD_RESOLV_IFDONE</constant>.
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    LoaderErrorMsg(const char *name, const char *modname,
-                   int errmaj, int errmin);
-	  </programlisting>
-	  <blockquote><para>
-    This function prints an error message that includes the text <quote>Failed
-    to load module</quote>, the module name <parameter>modname</parameter>, a message
-    specific to the <parameter>errmaj</parameter> value, and the value if
-    <parameter>errmin</parameter>.  If <parameter>name</parameter> is
-    non-<constant>NULL</constant>, it is printed as an identifying prefix
-    to the message (followed by a <quote>:</quote>).
-	    </para>
-
-	  </blockquote></para></blockquote>
-    </sect2>
-
-    <sect2>
-      <title>Special Registration Functions</title>
-
-      <para>
-The loader contains some functions for registering some classes of modules.
-These may be moved out of the loader at some point.
-      </para>
-
-      <blockquote><para>
-	  <programlisting>
-    void LoadExtension(ExtensionModule *ext);
-	  </programlisting>
-	  <blockquote><para>
-    This registers the entry points for the extension identified by
-    <parameter>ext</parameter>.  The <structname>ExtensionModule</structname> struct is
-    defined as:
-
-	      <programlisting>
-typedef struct {
-    InitExtension       initFunc;
-    char *              name;
-    Bool                *disablePtr;
-    InitExtension       setupFunc;
-} ExtensionModule;
-	      </programlisting>
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    void LoadFont(FontModule *font);
-	  </programlisting>
-	  <blockquote><para>
-    This registers the entry points for the font rasteriser module
-    identified by <parameter>font</parameter>.  The <structname>FontModule</structname>
-    struct is defined as:
-
-	      <programlisting>
- typedef struct {
-    InitFont    initFunc;
-    char *      name;
-    pointer     module;
-} FontModule;
-	      </programlisting>
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-    </sect2>
-
-  </sect1>
-
-  <sect1>
-    <title>Helper Functions</title>
-
-    <para>
-This section describe <quote>helper</quote> functions that video driver
-might find useful.  While video drivers are not required to use any of
-these to be considered <quote>compliant</quote>, the use of appropriate helpers is
-strongly encouraged to improve the consistency of driver behaviour.
-    </para>
-
-    <sect2>
-      <title>Functions for printing messages</title>
-
-      <blockquote><para>
-	  <programlisting>
-    ErrorF(const char *format, ...);
-	  </programlisting>
-	  <blockquote><para>
-      This is the basic function for writing to the error log (typically
-      stderr and/or a log file).  Video drivers should usually avoid
-      using this directly in favour of the more specialised functions
-      described below.  This function is useful for printing messages
-      while debugging a driver.
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    FatalError(const char *format, ...);
-	  </programlisting>
-	  <blockquote><para>
-      This prints a message and causes the Xserver to abort.  It should
-      rarely be used within a video driver, as most error conditions
-      should be flagged by the return values of the driver functions.
-      This allows the higher layers to decide how to proceed.  In rare
-      cases, this can be used within a driver if a fatal unexpected
-      condition is found.
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    xf86ErrorF(const char *format, ...);
-	  </programlisting>
-	  <blockquote><para>
-      This is like <function>ErrorF()</function>, except that the message is
-      only printed when the Xserver's verbosity level is set to the
-      default (<constant>1</constant>) or higher.  It means that the messages
-      are not printed when the server is started with the
-      <option>-quiet</option> flag.  Typically this function would only be
-      used for continuing messages started with one of the more specialised
-      functions described below.
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    xf86ErrorFVerb(int verb, const char *format, ...);
-	  </programlisting>
-	  <blockquote><para>
-      Like <function>xf86ErrorF()</function>, except the minimum verbosity
-      level for which the message is to be printed is given explicitly.
-      Passing a <parameter>verb</parameter> value of zero means the message
-      is always printed.  A value higher than <constant>1</constant> can be
-      used for information would normally not be needed, but which might
-      be useful when diagnosing problems.
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-
-      <blockquote><para>
-	  <programlisting>
-    xf86Msg(MessageType type, const char *format, ...);
-	  </programlisting>
-	  <blockquote><para>
-      This is like <function>xf86ErrorF()</function>, except that the message
-      is prefixed with a marker determined by the value of
-      <parameter>type</parameter>.  The marker is used to indicate the type of
-      message (warning, error, probed value, config value, etc).  Note
-      the <varname>xf86Verbose</varname> value is ignored for messages of
-      type <constant>X_ERROR</constant>.
-	    </para>
-
-	    <para>
-      The marker values are:
-
-	      <variablelist>
-		<varlistentry>
-		  <term><constant>X_PROBED</constant></term>
-		  <listitem><para>Value was probed.
-		    </para></listitem></varlistentry>
-		<varlistentry>
-		  <term><constant>X_CONFIG</constant></term>
-		  <listitem><para>Value was given in the config file.
-		    </para></listitem></varlistentry>
-		<varlistentry>
-		  <term><constant>X_DEFAULT</constant></term>
-		  <listitem><para>Value is a default.
-		    </para></listitem></varlistentry>
-		<varlistentry>
-		  <term><constant>X_CMDLINE</constant></term>
-		  <listitem><para>Value was given on the command line.
-		    </para></listitem></varlistentry>
-		<varlistentry>
-		  <term><constant>X_NOTICE</constant></term>
-		  <listitem><para>Notice.
-		    </para></listitem></varlistentry>
-		<varlistentry>
-		  <term><constant>X_ERROR</constant></term>
-		  <listitem><para>Error message.
-		    </para></listitem></varlistentry>
-		<varlistentry>
-		  <term><constant>X_WARNING</constant></term>
-		  <listitem><para>Warning message.
-		    </para></listitem></varlistentry>
-		<varlistentry>
-		  <term><constant>X_INFO</constant></term>
-		  <listitem><para>Informational message.
-		    </para></listitem></varlistentry>
-		<varlistentry>
-		  <term><constant>X_NONE</constant></term>
-		  <listitem><para>No prefix.
-		    </para></listitem></varlistentry>
-		<varlistentry>
-		  <term><constant>X_NOT_IMPLEMENTED</constant></term>
-		  <listitem><para>The message relates to functionality
-		      that is not yetimplemented.
-		    </para></listitem></varlistentry>
-		</variablelist>
-
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    xf86MsgVerb(MessageType type, int verb, const char *format, ...);
-	  </programlisting>
-	  <blockquote><para>
-      Like <function>xf86Msg()</function>, but with the verbosity level given
-      explicitly.
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    xf86DrvMsg(int scrnIndex, MessageType type, const char *format, ...);
-	  </programlisting>
-	  <blockquote><para>
-      This is like <function>xf86Msg()</function> except that the driver's
-      name (the <structfield>name</structfield> field of the
-      <structname>ScrnInfoRec</structname>) followed by the
-      <parameter>scrnIndex</parameter> in parentheses is printed following the
-      prefix.  This should be used by video drivers in most cases as it
-      clearly indicates which driver/screen the message is for.  If
-      <parameter>scrnIndex</parameter> is negative, this function behaves
-      exactly like <function>xf86Msg()</function>.
-	    </para>
-
-	    <para>
-      NOTE: This function can only be used after the
-      <structname>ScrnInfoRec</structname> and its <structfield>name</structfield> field
-      have been allocated.  Normally, this means that it can not be
-      used before the END of the <function>ChipProbe()</function> function.
-      Prior to that, use <function>xf86Msg()</function>, providing the
-      driver's name explicitly.  No screen number can be supplied at
-      that point.
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    xf86DrvMsgVerb(int scrnIndex, MessageType type, int verb,
-                                const char *format, ...);
-	  </programlisting>
-	  <blockquote><para>
-      Like <function>xf86DrvMsg()</function>, but with the verbosity level
-      given explicitly.
-	    </para>
-
-	  </blockquote></para></blockquote>
-    </sect2>
-
-
-    <sect2>
-      <title>Functions for setting values based on command line and config file</title>
-
-      <blockquote><para>
-	  <programlisting>
-    Bool xf86SetDepthBpp(ScrnInfoPtr scrp, int depth, int bpp,
-
-                                int fbbpp, int depth24flags);
-	  </programlisting>
-	  <blockquote><para>
-      This function sets the <structfield>depth</structfield>, <structfield>pixmapBPP</structfield> and <structfield>bitsPerPixel</structfield> fields
-      of the <structname>ScrnInfoRec</structname>.  It also determines the defaults for display-wide
-      attributes and pixmap formats the screen will support, and finds
-      the Display subsection that matches the depth/bpp.  This function
-      should normally be called very early from the
-      <function>ChipPreInit()</function> function.
-	    </para>
-
-	    <para>
-      It requires that the <structfield>confScreen</structfield> field of the <structname>ScrnInfoRec</structname> be
-      initialised prior to calling it.  This is done by the XFree86
-      common layer prior to calling <function>ChipPreInit()</function>.
-	    </para>
-
-	    <para>
-      The parameters passed are:
-
-	      <variablelist>
-		<varlistentry>
-		  <term><parameter>depth</parameter></term>
-		  <listitem><para>
-		driver's preferred default depth if no other is given.
-                If zero, use the overall server default.
-		    </para></listitem></varlistentry>
-
-		<varlistentry>
-		  <term><parameter>bpp</parameter></term>
-		  <listitem><para>
-		Same, but for the pixmap bpp.
-		    </para></listitem></varlistentry>
-
-		<varlistentry>
-		  <term><parameter>fbbpp</parameter></term>
-		  <listitem><para>
-		Same, but for the framebuffer bpp.
-		    </para></listitem></varlistentry>
-
-		<varlistentry>
-		  <term><parameter>depth24flags</parameter></term>
-		  <listitem><para>
-		Flags that indicate the level of 24/32bpp support
-                and whether conversion between different framebuffer
-                and pixmap formats is supported.  The flags for this
-                argument are defined as follows, and multiple flags
-                may be ORed together:
-
-		      <variablelist>
-			<varlistentry>
-			  <term><constant>NoDepth24Support</constant></term>
-			  <listitem><para>No depth 24 formats supported
-			    </para></listitem></varlistentry>
-			<varlistentry>
-			  <term><constant>Support24bppFb</constant></term>
-			  <listitem><para>24bpp framebuffer supported
-			    </para></listitem></varlistentry>
-			<varlistentry>
-			  <term><constant>Support32bppFb</constant></term>
-			  <listitem><para>32bpp framebuffer supported
-			    </para></listitem></varlistentry>
-			<varlistentry>
-			  <term><constant>SupportConvert24to32</constant></term>
-			  <listitem><para>Can convert 24bpp pixmap to 32bpp fb
-			    </para></listitem></varlistentry>
-			<varlistentry>
-			  <term><constant>SupportConvert32to24</constant></term>
-			  <listitem><para>Can convert 32bpp pixmap to 24bpp fb
-			    </para></listitem></varlistentry>
-			<varlistentry>
-			  <term><constant>ForceConvert24to32</constant></term>
-			  <listitem><para>Force 24bpp pixmap to 32bpp fb conversion
-			    </para></listitem></varlistentry>
-			<varlistentry>
-			  <term><constant>ForceConvert32to24</constant></term>
-			  <listitem><para>Force 32bpp pixmap to 24bpp fb conversion
-			    </para></listitem></varlistentry>
-		      </variablelist>
-		    </para></listitem></varlistentry>
-
-	      </variablelist>
-	    </para>
-
-	    <para>
-      It uses the command line, config file, and default values in the
-      correct order of precedence to determine the depth and bpp values.
-      It is up to the driver to check the results to see that it supports
-      them.  If not the <function>ChipPreInit()</function> function should
-      return <constant>FALSE</constant>.
-	    </para>
-
-	    <para>
-      If only one of depth/bpp is given, the other is set to a reasonable
-      (and consistent) default.
-	    </para>
-
-	    <para>
-      If a driver finds that the initial <parameter>depth24flags</parameter>
-      it uses later results in a fb format that requires more video
-      memory than is available it may call this function a second time
-      with a different <parameter>depth24flags</parameter> setting.
-	    </para>
-
-	    <para>
-      On success, the return value is <constant>TRUE</constant>.  On failure
-      it prints an error message and returns <constant>FALSE</constant>.
-	    </para>
-
-	    <para>
-      The following fields of the <structname>ScrnInfoRec</structname> are
-      initialised by this function:
-
-	      <blockquote><para>
-<structfield>depth</structfield>, <structfield>bitsPerPixel</structfield>,
-<structfield>display</structfield>, <structfield>imageByteOrder</structfield>,
-<structfield>bitmapScanlinePad</structfield>,
-<structfield>bitmapScanlineUnit</structfield>, <structfield>bitmapBitOrder</structfield>,
-<structfield>numFormats</structfield>, <structfield>formats</structfield>,
-<structfield>fbFormat</structfield>.
-		</para></blockquote>
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    void xf86PrintDepthBpp(scrnInfoPtr scrp);
-	  </programlisting>
-	  <blockquote><para>
-      This function can be used to print out the depth and bpp settings.
-      It should be called after the final call to
-      <function>xf86SetDepthBpp()</function>.
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    Bool xf86SetWeight(ScrnInfoPtr scrp, rgb weight, rgb mask);
-	  </programlisting>
-	  <blockquote><para>
-      This function sets the <structfield>weight</structfield>, <structfield>mask</structfield>,
-      <structfield>offset</structfield> and <structfield>rgbBits</structfield> fields of the
-      <structname>ScrnInfoRec</structname>.  It would normally be called fairly
-      early in the <function>ChipPreInit()</function> function for
-      depths > 8bpp.
-	    </para>
-
-	    <para>
-      It requires that the <structfield>depth</structfield> and
-      <structfield>display</structfield> fields of the <structname>ScrnInfoRec</structname>
-      be initialised prior to calling it.
-	    </para>
-
-	    <para>
-      The parameters passed are:
-
-	      <variablelist>
-		<varlistentry>
-		  <term><parameter>weight</parameter></term>
-		  <listitem><para>
-		driver's preferred default weight if no other is given.
-                If zero, use the overall server default.
-
-		    </para></listitem></varlistentry>
-
-		<varlistentry>
-		  <term><parameter>mask</parameter></term>
-		  <listitem><para>
-		Same, but for mask.
-
-		    </para></listitem></varlistentry>
-	      </variablelist>
-	    </para>
-
-	    <para>
-      It uses the command line, config file, and default values in the
-      correct order of precedence to determine the weight value.  It
-      derives the mask and offset values from the weight and the defaults.
-      It is up to the driver to check the results to see that it supports
-      them.  If not the <function>ChipPreInit()</function> function should
-      return <constant>FALSE</constant>.
-	    </para>
-
-	    <para>
-      On success, this function prints a message showing the weight
-      values selected, and returns <constant>TRUE</constant>.
-	    </para>
-
-	    <para>
-      On failure it prints an error message and returns <constant>FALSE</constant>.
-	    </para>
-
-	    <para>
-      The following fields of the <structname>ScrnInfoRec</structname> are
-      initialised by this function:
-
-	      <blockquote><para>
-		  <structfield>weight</structfield>,
-		  <structfield>mask</structfield>,
-		  <structfield>offset</structfield>.
-		</para></blockquote>
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    Bool xf86SetDefaultVisual(ScrnInfoPtr scrp, int visual);
-	  </programlisting>
-	  <blockquote><para>
-      This function sets the <structfield>defaultVisual</structfield> field of the
-      <structname>ScrnInfoRec</structname>.  It would normally be called fairly
-      early from the <function>ChipPreInit()</function> function.
-	    </para>
-
-	    <para>
-      It requires that the <structfield>depth</structfield> and
-      <structfield>display</structfield> fields of the <structname>ScrnInfoRec</structname>
-      be initialised prior to calling it.
-	    </para>
-
-	    <para>
-      The parameters passed are:
-
-	      <variablelist>
-		<varlistentry>
-		  <term><parameter>visual</parameter></term>
-		  <listitem><para>
-		driver's preferred default visual if no other is given.
-		If <constant>-1</constant>, use the overall server default.
-		    </para></listitem></varlistentry>
-
-	      </variablelist>
-	    </para>
-
-	    <para>
-      It uses the command line, config file, and default values in the
-      correct order of precedence to determine the default visual value.
-      It is up to the driver to check the result to see that it supports
-      it.  If not the <function>ChipPreInit()</function> function should
-      return <constant>FALSE</constant>.
-	    </para>
-
-	    <para>
-      On success, this function prints a message showing the default visual
-      selected, and returns <constant>TRUE</constant>.
-	    </para>
-
-	    <para>
-      On failure it prints an error message and returns <constant>FALSE</constant>.
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    Bool xf86SetGamma(ScrnInfoPtr scrp, Gamma gamma);
-	  </programlisting>
-	  <blockquote><para>
-      This function sets the <structfield>gamma</structfield> field of the
-      <structname>ScrnInfoRec</structname>.  It would normally be called fairly
-      early from the <function>ChipPreInit()</function> function in cases
-      where the driver supports gamma correction.
-	    </para>
-
-	    <para>
-      It requires that the <structfield>monitor</structfield> field of the
-      <structname>ScrnInfoRec</structname> be initialised prior to calling it.
-	    </para>
-
-	    <para>
-      The parameters passed are:
-
-	      <variablelist>
-		<varlistentry>
-		  <term><parameter>gamma</parameter></term>
-		  <listitem><para>
-		driver's preferred default gamma if no other is given.
-		If zero (<code>< 0.01</code>), use the overall server
-		default.
-		    </para></listitem></varlistentry>
-
-	      </variablelist>
-	    </para>
-
-	    <para>
-      It uses the command line, config file, and default values in the
-      correct order of precedence to determine the gamma value.  It is
-      up to the driver to check the results to see that it supports
-      them.  If not the <function>ChipPreInit()</function> function should
-      return <constant>FALSE</constant>.
-	    </para>
-
-	    <para>
-      On success, this function prints a message showing the gamma
-      value selected, and returns <constant>TRUE</constant>.
-	    </para>
-
-	    <para>
-      On failure it prints an error message and returns <constant>FALSE</constant>.
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-
-      <blockquote><para>
-	  <programlisting>
-    void xf86SetDpi(ScrnInfoPtr pScrn, int x, int y);
-	  </programlisting>
-	  <blockquote><para>
-      This function sets the <structfield>xDpi</structfield> and <structfield>yDpi</structfield>
-      fields of the <structname>ScrnInfoRec</structname>.  The driver can specify
-      preferred defaults by setting <parameter>x</parameter> and <parameter>y</parameter>
-      to non-zero values.  The <option>-dpi</option> command line option
-      overrides all other settings.  Otherwise, if the
-      <emphasis>DisplaySize</emphasis> entry is present in the screen's &k.monitor;
-      config file section, it is used together with the virtual size to
-      calculate the dpi values.  This function should be called after
-      all the mode resolution has been done.
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    void xf86SetBlackWhitePixels(ScrnInfoPtr pScrn);
-	  </programlisting>
-	  <blockquote><para>
-      This functions sets the <structfield>blackPixel</structfield> and
-      <structfield>whitePixel</structfield> fields of the <structname>ScrnInfoRec</structname>
-      according to whether or not the <option>-flipPixels</option> command
-      line options is present.
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    const char *xf86GetVisualName(int visual);
-	  </programlisting>
-	  <blockquote><para>
-      Returns a printable string with the visual name matching the
-      numerical visual class provided.  If the value is outside the
-      range of valid visual classes, <constant>NULL</constant> is returned.
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-    </sect2>
-
-    <sect2>
-      <title>Primary Mode functions</title>
-
-      <para>
-The primary mode helper functions are those which would normally be
-used by a driver, unless it has unusual requirements which cannot
-be catered for the by the helpers.
-      </para>
-
-      <blockquote><para>
-	  <programlisting>
-    int xf86ValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes,
-                          char **modeNames, ClockRangePtr clockRanges,
-                          int *linePitches, int minPitch, int maxPitch,
-                          int pitchInc, int minHeight, int maxHeight,
-                          int virtualX, int virtualY,
-                          unsigned long apertureSize,
-                          LookupModeFlags strategy);
-	  </programlisting>
-	  <blockquote><para>
-      This function basically selects the set of modes to use based on
-      those available and the various constraints.  It also sets some
-      other related parameters.  It is normally called near the end of
-      the <function>ChipPreInit()</function> function.
-	    </para>
-
-	    <para>
-      The parameters passed to the function are:
-
-	      <variablelist>
-		<varlistentry>
-		  <term><parameter>availModes</parameter></term>
-		  <listitem><para>
-		List of modes available for the monitor.
-		    </para></listitem></varlistentry>
-
-		<varlistentry>
-		  <term><parameter>modeNames</parameter></term>
-		  <listitem><para>
-		List of mode names that the screen is requesting.
-		    </para></listitem></varlistentry>
-
-		<varlistentry>
-		  <term><parameter>clockRanges</parameter></term>
-		  <listitem><para>
-		A list of clock ranges allowed by the driver.  Each
-		range includes whether interlaced or multiscan modes
-		are supported for that range.  See below for more on
-		<parameter>clockRanges</parameter>.
-		    </para></listitem></varlistentry>
-
-		<varlistentry>
-		  <term><parameter>linePitches</parameter></term>
-		  <listitem><para>
-		List of line pitches supported by the driver.
-		This is optional and should be <constant>NULL</constant> when
-		not used.
-		    </para></listitem></varlistentry>
-
-		<varlistentry>
-		  <term><parameter>minPitch</parameter></term>
-		  <listitem><para>
-		Minimum line pitch supported by the driver.  This must
-		be supplied when <parameter>linePitches</parameter> is
-		<constant>NULL</constant>, and is ignored otherwise.
-		    </para></listitem></varlistentry>
-
-		<varlistentry>
-		  <term><parameter>maxPitch</parameter></term>
-		  <listitem><para>
-		Maximum line pitch supported by the driver.  This is
-		required when <parameter>minPitch</parameter> is required.
-		    </para></listitem></varlistentry>
-
-		<varlistentry>
-		  <term><parameter>pitchInc</parameter></term>
-		  <listitem><para>
-		Granularity of horizontal pitch values as supported by
-		the chipset.  This is expressed in bits.  This must be
-		supplied.
-		    </para></listitem></varlistentry>
-
-		<varlistentry>
-		  <term><parameter>minHeight</parameter></term>
-		  <listitem><para>
-		minimum virtual height allowed.  If zero, no limit is
-		imposed.
-		    </para></listitem></varlistentry>
-
-		<varlistentry>
-		  <term><parameter>maxHeight</parameter></term>
-		  <listitem><para>
-		maximum virtual height allowed.  If zero, no limit is
-		imposed.
-		    </para></listitem></varlistentry>
-
-		<varlistentry>
-		  <term><parameter>virtualX</parameter></term>
-		  <listitem><para>
-		If greater than zero, this is the virtual width value
-		that will be used.  Otherwise, the virtual width is
-		chosen to be the smallest that can accommodate the modes
-		selected.
-		    </para></listitem></varlistentry>
-
-		<varlistentry>
-		  <term><parameter>virtualY</parameter></term>
-		  <listitem><para>
-		If greater than zero, this is the virtual height value
-		that will be used.  Otherwise, the virtual height is
-		chosen to be the smallest that can accommodate the modes
-		selected.
-		    </para></listitem></varlistentry>
-
-		<varlistentry>
-		  <term><parameter>apertureSize</parameter></term>
-		  <listitem><para>
-		The size (in bytes) of the aperture used to access video
-		memory.
-		    </para></listitem></varlistentry>
-
-		<varlistentry>
-		  <term><parameter>strategy</parameter></term>
-		  <listitem><para>
-		The strategy to use when choosing from multiple modes
-		with the same name.  The options are:
-
-		      <variablelist>
-			<varlistentry>
-			  <term><constant>LOOKUP_DEFAULT</constant></term>
-			  <listitem><para>???
-			    </para></listitem></varlistentry>
-			<varlistentry>
-			  <term><constant>LOOKUP_BEST_REFRESH</constant></term>
-			  <listitem><para>mode with best refresh rate
-			    </para></listitem></varlistentry>
-			<varlistentry>
-			  <term><constant>LOOKUP_CLOSEST_CLOCK</constant></term>
-			  <listitem><para>mode with closest matching clock
-			    </para></listitem></varlistentry>
-			<varlistentry>
-			  <term><constant>LOOKUP_LIST_ORDER</constant></term>
-			  <listitem><para>first usable mode in list
-			    </para></listitem></varlistentry>
-		      </variablelist>
-
-		The following options can also be combined (OR'ed) with
-		one of the above:
-
-		      <variablelist>
-			<varlistentry>
-			  <term><constant>LOOKUP_CLKDIV2</constant></term>
-			  <listitem><para>Allow halved clocks
-			    </para></listitem></varlistentry>
-			<varlistentry>
-			  <term><constant>LOOKUP_OPTIONAL_TOLERANCES</constant></term>
-			  <listitem><para>
-		      Allow missing horizontal sync and/or vertical refresh
-		      ranges in the xorg.conf Monitor section
-			    </para></listitem></varlistentry>
-		      </variablelist>
-
-		<constant>LOOKUP_OPTIONAL_TOLERANCES</constant> should only be
-		specified when the driver can ensure all modes it generates
-		can sync on, or at least not damage, the monitor or digital
-		flat panel.  Horizontal sync and/or vertical refresh ranges
-		specified by the user will still be honoured (and acted upon).
-
-		    </para></listitem></varlistentry>
-	      </variablelist>
-	    </para>
-
-	    <para>
-      This function requires that the following fields of the
-      <structname>ScrnInfoRec</structname> are initialised prior to calling it:
-
-	      <variablelist>
-		<varlistentry>
-		  <term><structfield>clock[]</structfield></term>
-		  <listitem><para>
-		      List of discrete clocks (when non-programmable)
-		    </para></listitem></varlistentry>
-		<varlistentry>
-		  <term><structfield>numClocks</structfield></term>
-		  <listitem><para>
-		      Number of discrete clocks (when non-programmable)
-		    </para></listitem></varlistentry>
-		<varlistentry>
-		  <term><structfield>progClock</structfield></term>
-		  <listitem><para>
-		      Whether the clock is programmable or not
-		    </para></listitem></varlistentry>
-		<varlistentry>
-		  <term><structfield>monitor</structfield></term>
-		  <listitem><para>
-		      Pointer to the applicable xorg.conf monitor section
-		    </para></listitem></varlistentry>
-		<varlistentry>
-		  <term><structfield>fdFormat</structfield></term>
-		  <listitem><para>
-		      Format of the screen buffer
-		    </para></listitem></varlistentry>
-		<varlistentry>
-		  <term><structfield>videoRam</structfield></term>
-		  <listitem><para>
-		      total video memory size (in bytes)
-		    </para></listitem></varlistentry>
-		<varlistentry>
-		  <term><structfield>maxHValue</structfield></term>
-		  <listitem><para>
-		      Maximum horizontal timing value allowed
-		    </para></listitem></varlistentry>
-		<varlistentry>
-		  <term><structfield>maxVValue</structfield></term>
-		  <listitem><para>
-		      Maximum vertical timing value allowed
-		    </para></listitem></varlistentry>
-		<varlistentry>
-		  <term><structfield>xInc</structfield></term>
-		  <listitem><para>
-		      Horizontal timing increment in pixels (defaults to 8)
-		    </para></listitem></varlistentry>
-	      </variablelist>
-	    </para>
-
-	    <para>
-      This function fills in the following <structname>ScrnInfoRec</structname>
-      fields:
-
-	      <variablelist>
-		<varlistentry>
-		  <term><structfield>modePool</structfield></term>
-		  <listitem><para>
-		A subset of the modes available to the monitor which
-                are compatible with the driver.
-		    </para></listitem></varlistentry>
-
-		<varlistentry>
-		  <term><structfield>modes</structfield></term>
-		  <listitem><para>
-		One mode entry for each of the requested modes, with
-                the status field of each filled in to indicate if
-                the mode has been accepted or not.  This list of
-                modes is a circular list.
-		    </para></listitem></varlistentry>
-
-		<varlistentry>
-		  <term><structfield>virtualX</structfield></term>
-		  <listitem><para>
-		The resulting virtual width.
-		    </para></listitem></varlistentry>
-
-		<varlistentry>
-		  <term><structfield>virtualY</structfield></term>
-		  <listitem><para>
-		The resulting virtual height.
-		    </para></listitem></varlistentry>
-
-		<varlistentry>
-		  <term><structfield>displayWidth</structfield></term>
-		  <listitem><para>
-		The resulting line pitch.
-		    </para></listitem></varlistentry>
-
-		<varlistentry>
-		  <term><structfield>virtualFrom</structfield></term>
-		  <listitem><para>
-		Where the virtual size was determined from.
-		    </para></listitem></varlistentry>
-
-	      </variablelist>
-	    </para>
-
-	    <para>
-      The first stage of this function checks that the
-      <parameter>virtualX</parameter> and <parameter>virtualY</parameter> values
-      supplied (if greater than zero) are consistent with the line pitch
-      and <parameter>maxHeight</parameter> limitations.  If not, an error
-      message is printed, and the return value is <constant>-1</constant>.
-	    </para>
-
-	    <para>
-      The second stage sets up the mode pool, eliminating immediately
-      any modes that exceed the driver's line pitch limits, and also
-      the virtual width and height limits (if greater than zero).  For
-      each mode removed an informational message is printed at verbosity
-      level <constant>2</constant>.  If the mode pool ends up being empty,
-      a warning message is printed, and the return value is
-      <constant>0</constant>.
-	    </para>
-
-	    <para>
-      The final stage is to lookup each mode name, and fill in the remaining
-      parameters.  If an error condition is encountered, a message is
-      printed, and the return value is <constant>-1</constant>.  Otherwise,
-      the return value is the number of valid modes found
-      (<constant>0</constant> if none are found).
-	    </para>
-
-	    <para>
-      Even if the supplied mode names include duplicates, no two names will
-      ever match the same mode.  Furthermore, if the supplied mode names do not
-      yield a valid mode (including the case where no names are passed at all),
-      the function will continue looking through the mode pool until it finds
-      a mode that survives all checks, or until the mode pool is exhausted.
-	    </para>
-
-	    <para>
-      A message is only printed by this function when a fundamental
-      problem is found.  It is intended that this function may be called
-      more than once if there is more than one set of constraints that
-      the driver can work within.
-	    </para>
-
-	    <para>
-      If this function returns <constant>-1</constant>, the
-      <function>ChipPreInit()</function> function should return
-      <constant>FALSE</constant>.
-	    </para>
-
-	    <para>
-      <parameter>clockRanges</parameter> is a linked list of clock ranges
-      allowed by the driver.  If a mode doesn't fit in any of the defined
-      <parameter>clockRanges</parameter>, it is rejected.  The first
-      <literal remap="tt">clockRange</literal> that matches all requirements is used.
-      This structure needs to be initialized to NULL when allocated.
-	    </para>
-
-	    <para>
-      <parameter>clockRanges</parameter> contains the following fields:
-
-	      <variablelist>
-		<varlistentry>
-		  <term><structfield>minClock</structfield></term>
-		  <term><structfield>maxClock</structfield></term>
-		  <listitem><para>
-		The lower and upper mode clock bounds for which the rest
-		of the <structname>clockRange</structname> parameters apply.
-		Since these are the mode clocks, they are not scaled
-		with the <structfield>ClockMulFactor</structfield> and
-		<structfield>ClockDivFactor</structfield>.  It is up to the driver
-		to adjust these values if they depend on the clock
-		scaling factors.
-		    </para></listitem></varlistentry>
-
-		<varlistentry>
-		  <term><structfield>clockIndex</structfield></term>
-		  <listitem><para>
-		(not used yet) <constant>-1</constant> for programmable clocks
-		    </para></listitem></varlistentry>
-
-		<varlistentry>
-		  <term><structfield>interlaceAllowed</structfield></term>
-		  <listitem><para>
-		<constant>TRUE</constant> if interlacing is allowed for this
-		range
-		    </para></listitem></varlistentry>
-
-		<varlistentry>
-		  <term><structfield>doubleScanAllowed</structfield></term>
-		  <listitem><para>
-		<constant>TRUE</constant> if doublescan or multiscan is allowed
-		for this range
-		    </para></listitem></varlistentry>
-
-		<varlistentry>
-		  <term><structfield>ClockMulFactor</structfield></term>
-		  <term><structfield>ClockDivFactor</structfield></term>
-		  <listitem><para>
-		Scaling factors that are applied to the mode clocks ONLY
-		before selecting a clock index (when there is no
-		programmable clock) or a <structfield>SynthClock</structfield>
-		value.  This is useful for drivers that support pixel
-		multiplexing or that need to scale the clocks because
-		of hardware restrictions (like sending 24bpp data to an
-		8 bit RAMDAC using a tripled clock).
-		    </para>
-
-		    <para>
-		Note that these parameters describe what must be done
-		to the mode clock to achieve the data transport clock
-		between graphics controller and RAMDAC.  For example
-		for <literal remap="tt">2:1</literal> pixel multiplexing, two pixels
-		are sent to the RAMDAC on each clock.  This allows the
-		RAMDAC clock to be half of the actual pixel clock.
-		Hence, <code>ClockMulFactor=1</code> and
-		<code>ClockDivFactor=2</code>.  This means that the
-		clock used for clock selection (ie, determining the
-		correct clock index from the list of discrete clocks)
-		or for the <structfield>SynthClock</structfield> field in case of
-		a programmable clock is:  (<code>mode->Clock *
-		ClockMulFactor) / ClockDivFactor</code>.
-		    </para></listitem></varlistentry>
-
-		<varlistentry>
-		  <term><structfield>PrivFlags</structfield></term>
-		  <listitem><para>
-		This field is copied into the
-		<literal remap="tt">mode->PrivFlags</literal> field when this
-		<literal remap="tt">clockRange</literal> is selected by
-		<function>xf86ValidateModes()</function>.  It allows the
-		driver to find out what clock range was selected, so it
-		knows it needs to set up pixel multiplexing or any other
-		range-dependent feature.  This field is purely
-		driver-defined: it may contain flag bits, an index or
-		anything else (as long as it is an <literal remap="tt">INT</literal>).
-		    </para></listitem></varlistentry>
-	      </variablelist>
-	    </para>
-
-	    <para>
-      Note that the <structfield>mode->SynthClock</structfield> field is always
-      filled in by <function>xf86ValidateModes()</function>: it will contain
-      the <quote>data transport clock</quote>, which is the clock that will have
-      to be programmed in the chip when it has a programmable clock, or
-      the clock that will be picked from the clocks list when it is not
-      a programmable one.  Thus:
-
-	      <programlisting>
-    mode->SynthClock = (mode->Clock * ClockMulFactor) / ClockDivFactor
-	      </programlisting>
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    void xf86PruneDriverModes(ScrnInfoPtr scrp);
-	  </programlisting>
-	  <blockquote><para>
-      This function deletes modes in the modes field of the
-      <structname>ScrnInfoRec</structname> that have been marked as invalid.
-      This is normally run after having run
-      <function>xf86ValidateModes()</function> for the last time.  For each
-      mode that is deleted, a warning message is printed out indicating
-      the reason for it being deleted.
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    void xf86SetCrtcForModes(ScrnInfoPtr scrp, int adjustFlags);
-	  </programlisting>
-	  <blockquote><para>
-      This function fills in the <structname>Crtc*</structname> fields for all
-      the modes in the <structfield>modes</structfield> field of the
-      <structname>ScrnInfoRec</structname>.  The <parameter>adjustFlags</parameter>
-      parameter determines how the vertical CRTC values are scaled for
-      interlaced modes.  They are halved if it is
-      <constant>INTERLACE_HALVE_V</constant>.  The vertical CRTC values are
-      doubled for doublescan modes, and are further multiplied by the
-      <literal remap="tt">VScan</literal> value.
-	    </para>
-
-	    <para>
-      This function is normally called after calling
-      <function>xf86PruneDriverModes()</function>.
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    void xf86PrintModes(ScrnInfoPtr scrp);
-	  </programlisting>
-	  <blockquote><para>
-      This function prints out the virtual size setting, and the line
-      pitch being used.  It also prints out two lines for each mode being
-      used.  The first line includes the mode's pixel clock, horizontal sync
-      rate, refresh rate, and whether it is interlaced, doublescanned and/or
-      multi-scanned.  The second line is the mode's Modeline.
-	    </para>
-
-	    <para>
-      This function is normally called after calling
-      <function>xf86SetCrtcForModes()</function>.
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-    </sect2>
-
-    <sect2>
-      <title>Secondary Mode functions</title>
-
-      <para>
-The secondary mode helper functions are functions which are normally
-used by the primary mode helper functions, and which are not normally
-called directly by a driver.  If a driver has unusual requirements
-and needs to do its own mode validation, it might be able to make
-use of some of these secondary mode helper functions.
-      </para>
-
-      <blockquote><para>
-	  <programlisting>
-    int xf86GetNearestClock(ScrnInfoPtr scrp, int freq, Bool allowDiv2,
-                            int *divider);
-	  </programlisting>
-	  <blockquote><para>
-      This function returns the index of the closest clock to the
-      frequency <parameter>freq</parameter> given (in kHz).  It assumes that
-      the number of clocks is greater than zero.  It requires that the
-      <structfield>numClocks</structfield> and <structfield>clock</structfield> fields of the
-      <structname>ScrnInfoRec</structname> are initialised.  The
-      <structfield>allowDiv2</structfield> field determines if the clocks can be
-      halved.  The <parameter>*divider</parameter> return value indicates
-      whether clock division is used when determining the clock returned.
-	    </para>
-
-	    <para>
-      This function is only for non-programmable clocks.
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    const char *xf86ModeStatusToString(ModeStatus status);
-	  </programlisting>
-	  <blockquote><para>
-      This function converts the <parameter>status</parameter> value to a
-      descriptive printable string.
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    ModeStatus xf86LookupMode(ScrnInfoPtr scrp, DisplayModePtr modep,
-                     ClockRangePtr clockRanges, LookupModeFlags strategy);
-	  </programlisting>
-	  <blockquote><para>
-      This function takes a pointer to a mode with the name filled in,
-      and looks for a mode in the <structfield>modePool</structfield> list which
-      matches.  The parameters of the matching mode are filled in to
-      <parameter>*modep</parameter>.  The <parameter>clockRanges</parameter> and
-      <parameter>strategy</parameter> parameters are as for the
-      <function>xf86ValidateModes()</function> function above.
-	    </para>
-
-	    <para>
-      This function requires the <structfield>modePool</structfield>,
-      <structfield>clock[]</structfield>, <structfield>numClocks</structfield> and
-      <structfield>progClock</structfield> fields of the <structname>ScrnInfoRec</structname>
-      to be initialised before being called.
-	    </para>
-
-	    <para>
-      The return value is <constant>MODE_OK</constant> if a mode was found.
-      Otherwise it indicates why a matching mode could not be found.
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    ModeStatus xf86InitialCheckModeForDriver(ScrnInfoPtr scrp,
-                                DisplayModePtr mode, ClockRangePtr clockRanges,
-                                LookupModeFlags strategy, int maxPitch,
-                                int virtualX, int virtualY);
-	  </programlisting>
-	  <blockquote><para>
-      This function checks the passed mode against some basic driver
-      constraints.  Apart from the ones passed explicitly, the
-      <structfield>maxHValue</structfield> and <structfield>maxVValue</structfield> fields of
-      the <structname>ScrnInfoRec</structname> are also used.  If the
-      <structfield>ValidMode</structfield> field of the <structname>ScrnInfoRec</structname>
-      is set, that function is also called to check the mode.  Next, the
-      mode is checked against the monitor's constraints.
-	    </para>
-
-	    <para>
-      If the mode is consistent with all constraints, the return value
-      is <constant>MODE_OK</constant>.  Otherwise the return value indicates
-      which constraint wasn't met.
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    void xf86DeleteMode(DisplayModePtr *modeList, DisplayModePtr mode);
-	  </programlisting>
-	  <blockquote><para>
-      This function deletes the <parameter>mode</parameter> given from the
-      <parameter>modeList</parameter>.  It never prints any messages, so it is
-      up to the caller to print a message if required.
-	    </para>
-
-	  </blockquote></para></blockquote>
-    </sect2>
-
-    <sect2>
-      <title>Functions for handling strings and tokens</title>
-
-      <para>
-    Tables associating strings and numerical tokens combined with the
-    following functions provide a compact way of handling strings from
-    the config file, and for converting tokens into printable strings.
-    The table data structure is:
-
-	<programlisting>
-typedef struct {
-    int                 token;
-    const char *        name;
-} SymTabRec, *SymTabPtr;
-	</programlisting>
-      </para>
-
-      <para>
-    A table is an initialised array of <structname>SymTabRec</structname>.  The
-    tokens must be non-negative integers.  Multiple names may be mapped
-    to a single token.  The table is terminated with an element with a
-    <structfield>token</structfield> value of <constant>-1</constant> and
-    <constant>NULL</constant> for the <structfield>name</structfield>.
-      </para>
-
-      <blockquote><para>
-	  <programlisting>
-    const char *xf86TokenToString(SymTabPtr table, int token);
-	  </programlisting>
-	  <blockquote><para>
-      This function returns the first string in <parameter>table</parameter>
-      that matches <parameter>token</parameter>.  If no match is found,
-      <constant>NULL</constant> is returned (NOTE, older versions of this
-      function would return the string "unknown" when no match is found).
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    int xf86StringToToken(SymTabPtr table, const char *string);
-	  </programlisting>
-	  <blockquote><para>
-      This function returns the first token in <parameter>table</parameter>
-      that matches <parameter>string</parameter>.  The
-      <function>xf86NameCmp()</function> function is used to determine the
-      match.  If no match is found, <constant>-1</constant> is returned.
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-    </sect2>
-
-    <sect2>
-      <title>Functions for finding which config file entries to use</title>
-
-      <para>
-    These functions can be used to select the appropriate config file
-    entries that match the detected hardware.  They are described above
-    in the <link linkend="probe">Probe</link> and
-    <link linkend="avail">Available Functions</link> sections.
-      </para>
-
-    </sect2>
-
-    <sect2>
-      <title>Probing discrete clocks on old hardware</title>
-
-      <para>
-    The <function>xf86GetClocks()</function> function may be used to assist
-    in finding the discrete pixel clock values on older hardware.
-      </para>
-
-      <blockquote><para>
-	  <programlisting>
-    void xf86GetClocks(ScrnInfoPtr pScrn, int num,
-                       Bool (*ClockFunc)(ScrnInfoPtr, int),
-                       void (*ProtectRegs)(ScrnInfoPtr, Bool),
-                       void (*BlankScreen)(ScrnInfoPtr, Bool),
-                       int vertsyncreg, int maskval, int knownclkindex,
-                       int knownclkvalue);
-	  </programlisting>
-	  <blockquote><para>
-      This function uses a comparative sampling method to measure the
-      discrete pixel clock values.  The number of discrete clocks to
-      measure is given by <parameter>num</parameter>.  <parameter>clockFunc</parameter>
-      is a function that selects the <parameter>n</parameter>'th clock.  It
-      should also save or restore any state affected by programming the
-      clocks when the index passed is <constant>CLK_REG_SAVE</constant> or
-      <constant>CLK_REG_RESTORE</constant>.  <parameter>ProtectRegs</parameter> is
-      a function that does whatever is required to protect the hardware
-      state while selecting a new clock.  <parameter>BlankScreen</parameter>
-      is a function that blanks the screen.  <parameter>vertsyncreg</parameter>
-      and <parameter>maskval</parameter> are the register and bitmask to
-      check for the presence of vertical sync pulses.
-      <parameter>knownclkindex</parameter> and <parameter>knownclkvalue</parameter>
-      are the index and value of a known clock.  These are the known
-      references on which the comparative measurements are based.  The
-      number of clocks probed is set in <structfield>pScrn->numClocks</structfield>,
-      and the probed clocks are set in the <structfield>pScrn->clock[]</structfield>
-      array.  All of the clock values are in units of kHz.
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    void xf86ShowClocks(ScrnInfoPtr scrp, MessageType from);
-	  </programlisting>
-	  <blockquote><para>
-      Print out the pixel clocks <parameter>scrp->clock[]</parameter>.
-      <parameter>from</parameter> indicates whether the clocks were probed
-      or from the config file.
-	    </para>
-
-	  </blockquote></para></blockquote>
-    </sect2>
-
-    <sect2>
-      <title>Other helper functions</title>
-
-      <blockquote><para>
-	  <programlisting>
-    Bool xf86IsUnblank(int mode);
-	  </programlisting>
-	  <blockquote><para>
-      Returns <constant>TRUE</constant> when the screen saver mode specified
-      by <parameter>mode</parameter> requires the screen be unblanked,
-      and <constant>FALSE</constant> otherwise.  The screen saver modes that
-      require blanking are <constant>SCREEN_SAVER_ON</constant> and
-      <constant>SCREEN_SAVER_CYCLE</constant>, and the screen saver modes that
-      require unblanking are <constant>SCREEN_SAVER_OFF</constant> and
-      <constant>SCREEN_SAVER_FORCER</constant>.  Drivers may call this helper
-      from their <function>SaveScreen()</function> function to interpret the
-      screen saver modes.
-	    </para>
-
-	  </blockquote></para></blockquote>
-    </sect2>
-  </sect1>
-
-  <sect1>
-    <title>The vgahw module</title>
-
-    <para>
-The vgahw modules provides an interface for saving, restoring and
-programming the standard VGA registers, and for handling VGA colourmaps.
-    </para>
-
-    <sect2>
-      <title>Data Structures</title>
-
-      <para>
-    The public data structures used by the vgahw module are
-    <structname>vgaRegRec</structname> and <structname>vgaHWRec</structname>.  They are
-    defined in <filename>vgaHW.h.</filename>
-      </para>
-
-    </sect2>
-
-    <sect2>
-      <title>General vgahw Functions</title>
-
-      <blockquote><para>
-	  <programlisting>
-    Bool vgaHWGetHWRec(ScrnInfoPtr pScrn);
-	  </programlisting>
-	  <blockquote><para>
-      This function allocates a <structname>vgaHWRec</structname> structure, and
-      hooks it into the <structname>ScrnInfoRec</structname>'s
-      <structfield>privates</structfield>.  Like all information hooked into the
-      <structfield>privates</structfield>, it is persistent, and only needs to be
-      allocated once per screen.  This function should normally be called
-      from the driver's <function>ChipPreInit()</function> function.  The
-      <structname>vgaHWRec</structname> is zero-allocated, and the following
-      fields are explicitly initialised:
-
-	      <variablelist>
-		<varlistentry>
-		  <term><structfield>ModeReg.DAC[]</structfield></term>
-		  <listitem><para>initialised with a default colourmap
-		    </para></listitem></varlistentry>
-		<varlistentry>
-		  <term><structfield>ModeReg.Attribute[0x11]</structfield></term>
-		  <listitem><para>initialised with the default overscan index
-		    </para></listitem></varlistentry>
-		<varlistentry>
-		  <term><structfield>ShowOverscan</structfield></term>
-		  <listitem><para>initialised according to the "ShowOverscan" option
-		    </para></listitem></varlistentry>
-		<varlistentry>
-		  <term><structfield>paletteEnabled</structfield></term>
-		  <listitem><para>initialised to FALSE
-		    </para></listitem></varlistentry>
-		<varlistentry>
-		  <term><structfield>cmapSaved</structfield></term>
-		  <listitem><para>initialised to FALSE
-		    </para></listitem></varlistentry>
-		<varlistentry>
-		  <term><structfield>pScrn</structfield></term>
-		  <listitem><para>initialised to pScrn
-		    </para></listitem></varlistentry>
-	      </variablelist>
-	    </para>
-
-	    <para>
-      In addition to the above, <function>vgaHWSetStdFuncs()</function> is
-      called to initialise the register access function fields with the
-      standard VGA set of functions.
-	    </para>
-
-	    <para>
-      Once allocated, a pointer to the <structname>vgaHWRec</structname> can be
-      obtained from the <literal remap="tt">ScrnInfoPtr</literal> with the
-      <literal remap="tt">VGAHWPTR(pScrn)</literal> macro.
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    void vgaHWFreeHWRec(ScrnInfoPtr pScrn);
-	  </programlisting>
-	  <blockquote><para>
-      This function frees a <structname>vgaHWRec</structname> structure.  It
-      should be called from a driver's <function>ChipFreeScreen()</function>
-      function.
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    Bool vgaHWSetRegCounts(ScrnInfoPtr pScrn, int numCRTC,
-                          int numSequencer, int numGraphics, int numAttribute);
-	  </programlisting>
-	  <blockquote><para>
-      This function allows the number of CRTC, Sequencer, Graphics and
-      Attribute registers to be changed.  This makes it possible for
-      extended registers to be saved and restored with
-      <function>vgaHWSave()</function> and <function>vgaHWRestore()</function>.
-      This function should be called after a <structname>vgaHWRec</structname>
-      has been allocated with <function>vgaHWGetHWRec()</function>.  The
-      default values are defined in <filename>vgaHW.h</filename> as follows:
-
-	      <programlisting>
-#define VGA_NUM_CRTC 25
-#define VGA_NUM_SEQ   5
-#define VGA_NUM_GFX   9
-#define VGA_NUM_ATTR 21
-	      </programlisting>
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    Bool vgaHWCopyReg(vgaRegPtr dst, vgaRegPtr src);
-	  </programlisting>
-	  <blockquote><para>
-      This function copies the contents of the VGA saved registers in
-      <parameter>src</parameter> to <parameter>dst</parameter>.  Note that it isn't
-      possible to simply do this with <function>memcpy()</function> (or
-      similar).  This function returns <constant>TRUE</constant> unless there
-      is a problem allocating space for the <structfield>CRTC</structfield> and
-      related fields in <parameter>dst</parameter>.
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    void vgaHWSetStdFuncs(vgaHWPtr hwp);
-	  </programlisting>
-	  <blockquote><para>
-      This function initialises the register access function fields of
-      <parameter>hwp</parameter> with the standard VGA set of functions.  This
-      is called by <function>vgaHWGetHWRec()</function>, so there is usually
-      no need to call this explicitly.  The register access functions
-      are described below.  If the registers are shadowed in some other
-      port I/O space (for example a PCI I/O region), these functions
-      can be used to access the shadowed registers if
-      <structfield>hwp->PIOOffset</structfield> is initialised with
-      <literal remap="tt">offset</literal>, calculated in such a way that when the
-      standard VGA I/O port value is added to it the correct offset into
-      the PIO area results.  This value is initialised to zero in
-      <function>vgaHWGetHWRec()</function>.  (Note: the PIOOffset functionality
-      is present in XFree86 4.1.0 and later.)
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    void vgaHWSetMmioFuncs(vgaHWPtr hwp, CARD8 *base, int offset);
-	  </programlisting>
-	  <blockquote><para>
-      This function initialised the register access function fields of
-      hwp with a generic MMIO set of functions.
-      <structfield>hwp->MMIOBase</structfield> is initialised with
-      <parameter>base</parameter>, which must be the virtual address that the
-      start of MMIO area is mapped to.  <structfield>hwp->MMIOOffset</structfield>
-      is initialised with <parameter>offset</parameter>, which must be calculated
-      in such a way that when the standard VGA I/O port value is added
-      to it the correct offset into the MMIO area results.  That means
-      that these functions are only suitable when the VGA I/O ports are
-      made available in a direct mapping to the MMIO space.  If that is
-      not the case, the driver will need to provide its own register
-      access functions.  The register access functions are described
-      below.
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    Bool vgaHWMapMem(ScrnInfoPtr pScrn);
-	  </programlisting>
-	  <blockquote><para>
-      This function maps the VGA memory window.  It requires that the
-      <structname>vgaHWRec</structname> be allocated.  If a driver requires
-      non-default <structfield>MapPhys</structfield> or <structfield>MapSize</structfield>
-      settings (the physical location and size of the VGA memory window)
-      then those fields of the <structname>vgaHWRec</structname> must be initialised
-      before calling this function.  Otherwise, this function initialiases
-      the default values of <constant>0xA0000</constant> for
-      <structfield>MapPhys</structfield> and <code>(64 * 1024)</code> for
-      <structfield>MapSize</structfield>.  This function must be called before
-      attempting to save or restore the VGA state.  If the driver doesn't
-      call it explicitly, the <function>vgaHWSave()</function> and
-      <function>vgaHWRestore()</function> functions may call it if they need
-      to access the VGA memory (in which case they will also call
-      <function>vgaHWUnmapMem()</function> to unmap the VGA memory before
-      exiting).
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    void vgaHWUnmapMem(ScrnInfoPtr pScrn);
-	  </programlisting>
-	  <blockquote><para>
-      This function unmaps the VGA memory window.  It must only be called
-      after the memory has been mapped.  The <structfield>Base</structfield> field
-      of the <structname>vgaHWRec</structname> field is set to <constant>NULL</constant>
-      to indicate that the memory is no longer mapped.
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    void vgaHWGetIOBase(vgaHWPtr hwp);
-	  </programlisting>
-	  <blockquote><para>
-      This function initialises the <structfield>IOBase</structfield> field of the
-      <structname>vgaHWRec</structname>.  This function must be called before
-      using any other functions that access the video hardware.
-	    </para>
-
-	    <para>
-      A macro <function>VGAHW_GET_IOBASE()</function> is also available in
-      <filename>vgaHW.h</filename> that returns the I/O base, and this may
-      be used when the vgahw module is not loaded (for example, in the
-      <function>ChipProbe()</function> function).
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    void vgaHWUnlock(vgaHWPtr hwp);
-	  </programlisting>
-	  <blockquote><para>
-      This function unlocks the VGA <literal remap="tt">CRTC[0-7]</literal> registers,
-      and must be called before attempting to write to those registers.
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    void vgaHWLock(vgaHWPtr hwp);
-	  </programlisting>
-	  <blockquote><para>
-      This function locks the VGA <literal remap="tt">CRTC[0-7]</literal> registers.
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    void vgaHWEnable(vgaHWPtr hwp);
-	  </programlisting>
-	  <blockquote><para>
-      This function enables the VGA subsystem.  (Note, this function is
-      present in XFree86 4.1.0 and later.).
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    void vgaHWDisable(vgaHWPtr hwp);
-	  </programlisting>
-	  <blockquote><para>
-      This function disables the VGA subsystem.  (Note, this function is
-      present in XFree86 4.1.0 and later.).
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    void vgaHWSave(ScrnInfoPtr pScrn, vgaRegPtr save, int flags);
-	  </programlisting>
-	  <blockquote><para>
-      This function saves the VGA state.  The state is written to the
-      <structname>vgaRegRec</structname> pointed to by <parameter>save</parameter>.
-      <parameter>flags</parameter> is set to one or more of the following flags
-      ORed together:
-
-	      <variablelist>
-		<varlistentry>
-		  <term><constant>VGA_SR_MODE</constant></term>
-		  <listitem><para>the mode setting registers are saved
-		    </para></listitem></varlistentry>
-		<varlistentry>
-		  <term><constant>VGA_SR_FONTS</constant></term>
-		  <listitem><para>the text mode font/text data is saved
-		    </para></listitem></varlistentry>
-		<varlistentry>
-		  <term><constant>VGA_SR_CMAP</constant></term>
-		  <listitem><para>the colourmap (LUT) is saved
-		    </para></listitem></varlistentry>
-		<varlistentry>
-		  <term><constant>VGA_SR_ALL</constant></term>
-		  <listitem><para>all of the above are saved
-		    </para></listitem></varlistentry>
-	      </variablelist>
-	    </para>
-
-	    <para>
-      The <structname>vgaHWRec</structname> and its <structfield>IOBase</structfield> fields
-      must be initialised before this function is called.  If
-      <constant>VGA_SR_FONTS</constant> is set in <parameter>flags</parameter>, the
-      VGA memory window must be mapped.  If it isn't then
-      <function>vgaHWMapMem()</function> will be called to map it, and
-      <function>vgaHWUnmapMem()</function> will be called to unmap it
-      afterwards.  <function>vgaHWSave()</function> uses the three functions
-      below in the order <function>vgaHWSaveColormap()</function>,
-      <function>vgaHWSaveMode()</function>, <function>vgaHWSaveFonts()</function> to
-      carry out the different save phases.  It is undecided at this
-      stage whether they will remain part of the vgahw module's public
-      interface or not.
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    void vgaHWSaveMode(ScrnInfoPtr pScrn, vgaRegPtr save);
-	  </programlisting>
-	  <blockquote><para>
-      This function saves the VGA mode registers.  They are saved to
-      the <structname>vgaRegRec</structname> pointed to by <parameter>save</parameter>.
-      The registers saved are:
-
-	      <literallayout>
-        MiscOut
-        CRTC[0-0x18]
-        Attribute[0-0x14]
-        Graphics[0-8]
-        Sequencer[0-4]
-	      </literallayout>
-	    </para>
-
-	    <para>
-    The number of registers actually saved may be modified by a prior call
-    to <function>vgaHWSetRegCounts()</function>.
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    void vgaHWSaveFonts(ScrnInfoPtr pScrn, vgaRegPtr save);
-	  </programlisting>
-	  <blockquote><para>
-      This function saves the text mode font and text data held in the
-      video memory.  If called while in a graphics mode, no save is
-      done.  The VGA memory window must be mapped with
-      <function>vgaHWMapMem()</function> before to calling this function.
-	    </para>
-
-	    <para>
-      On some platforms, one or more of the font/text plane saves may be
-      no-ops.  This is the case when the platform's VC driver already
-      takes care of this.
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    void vgaHWSaveColormap(ScrnInfoPtr pScrn, vgaRegPtr save);
-	  </programlisting>
-	  <blockquote><para>
-      This function saves the VGA colourmap (LUT).  Before saving it, it
-      attempts to verify that the colourmap is readable.  In rare cases
-      where it isn't readable, a default colourmap is saved instead.
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    void vgaHWRestore(ScrnInfoPtr pScrn, vgaRegPtr restore, int flags);
-	  </programlisting>
-	  <blockquote><para>
-      This function programs the VGA state.  The state programmed is
-      that contained in the <structname>vgaRegRec</structname> pointed to by
-      <parameter>restore</parameter>.  <parameter>flags</parameter> is the same
-      as described above for the <function>vgaHWSave()</function> function.
-	    </para>
-
-	    <para>
-      The <structname>vgaHWRec</structname> and its <structfield>IOBase</structfield> fields
-      must be initialised before this function is called.  If
-      <constant>VGA_SR_FONTS</constant> is set in <parameter>flags</parameter>, the
-      VGA memory window must be mapped.  If it isn't then
-      <function>vgaHWMapMem()</function> will be called to map it, and
-      <function>vgaHWUnmapMem()</function> will be called to unmap it
-      afterwards.  <function>vgaHWRestore()</function> uses the three functions
-      below in the order <function>vgaHWRestoreFonts()</function>,
-      <function>vgaHWRestoreMode()</function>,
-      <function>vgaHWRestoreColormap()</function> to carry out the different
-      restore phases.  It is undecided at this stage whether they will
-      remain part of the vgahw module's public interface or not.
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    void vgaHWRestoreMode(ScrnInfoPtr pScrn, vgaRegPtr restore);
-	  </programlisting>
-	  <blockquote><para>
-      This function restores the VGA mode registers.  They are restored
-      from the data in the <structname>vgaRegRec</structname> pointed to by
-      <parameter>restore</parameter>.  The registers restored are:
-
-	      <literallayout>
-        MiscOut
-        CRTC[0-0x18]
-        Attribute[0-0x14]
-        Graphics[0-8]
-        Sequencer[0-4]
-	      </literallayout>
-	    </para>
-
-	    <para>
-    The number of registers actually restored may be modified by a prior call
-    to <function>vgaHWSetRegCounts()</function>.
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    void vgaHWRestoreFonts(ScrnInfoPtr pScrn, vgaRegPtr restore);
-	  </programlisting>
-	  <blockquote><para>
-      This function restores the text mode font and text data to the
-      video memory.  The VGA memory window must be mapped with
-      <function>vgaHWMapMem()</function> before to calling this function.
-	    </para>
-
-	    <para>
-      On some platforms, one or more of the font/text plane restores
-      may be no-ops.  This is the case when the platform's VC driver
-      already takes care of this.
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    void vgaHWRestoreColormap(ScrnInfoPtr pScrn, vgaRegPtr restore);
-	  </programlisting>
-	  <blockquote><para>
-      This function restores the VGA colourmap (LUT).
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    void vgaHWInit(ScrnInfoPtr pScrn, DisplayModePtr mode);
-	  </programlisting>
-	  <blockquote><para>
-      This function fills in the <structname>vgaHWRec</structname>'s
-      <structfield>ModeReg</structfield> field with the values appropriate for
-      programming the given video mode.  It requires that the
-      <structname>ScrnInfoRec</structname>'s <structfield>depth</structfield> field is
-      initialised, which determines how the registers are programmed.
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    void vgaHWSeqReset(vgaHWPtr hwp, Bool start);
-	  </programlisting>
-	  <blockquote><para>
-      Do a VGA sequencer reset.  If start is <constant>TRUE</constant>, the
-      reset is started.  If start is <constant>FALSE</constant>, the reset
-      is ended.
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    void vgaHWProtect(ScrnInfoPtr pScrn, Bool on);
-	  </programlisting>
-	  <blockquote><para>
-      This function protects VGA registers and memory from corruption
-      during loads.  It is typically called with on set to
-      <constant>TRUE</constant> before programming, and with on set to
-      <constant>FALSE</constant> after programming.
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    Bool vgaHWSaveScreen(ScreenPtr pScreen, int mode);
-	  </programlisting>
-	  <blockquote><para>
-      This function blanks and unblanks the screen.  It is blanked when
-      <parameter>mode</parameter> is <constant>SCREEN_SAVER_ON</constant> or
-      <constant>SCREEN_SAVER_CYCLE</constant>, and unblanked when
-      <parameter>mode</parameter> is <constant>SCREEN_SAVER_OFF</constant> or
-      <constant>SCREEN_SAVER_FORCER</constant>.
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    void vgaHWBlankScreen(ScrnInfoPtr pScrn, Bool on);
-	  </programlisting>
-	  <blockquote><para>
-      This function blanks and unblanks the screen.  It is blanked when
-      <parameter>on</parameter> is <constant>FALSE</constant>, and unblanked when
-      <parameter>on</parameter> is <constant>TRUE</constant>.  This function is
-      provided for use in cases where the <structname>ScrnInfoRec</structname>
-      can't be derived from the <structname>ScreenRec</structname> (while probing
-      for clocks, for example).
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-    </sect2>
-
-    <sect2>
-      <title>VGA Colormap Functions</title>
-
-      <para>
-    The vgahw module uses the standard colormap support (see the
-    <link linkend="cmap">Colormap Handling</link> section.  This is initialised
-    with the following function:
-
-	<blockquote><para>
-	  <programlisting>
-    Bool vgaHWHandleColormaps(ScreenPtr pScreen);
-	    </programlisting>
-	  </para></blockquote>
-      </para>
-
-    </sect2>
-
-    <sect2>
-      <title>VGA Register Access Functions</title>
-
-      <para>
-    The vgahw module abstracts access to the standard VGA registers by
-    using a set of functions held in the <structname>vgaHWRec</structname>.  When
-    the <structname>vgaHWRec</structname> is created these function pointers are
-    initialised with the set of standard VGA I/O register access functions.
-    In addition to these, the vgahw module includes a basic set of MMIO
-    register access functions, and the <structname>vgaHWRec</structname> function
-    pointers can be initialised to these by calling the
-    <function>vgaHWSetMmioFuncs()</function> function described above.  Some
-    drivers/platforms may require a different set of functions for VGA
-    access.  The access functions are described here.
-      </para>
-
-
-      <blockquote><para>
-	  <programlisting>
-    void writeCrtc(vgaHWPtr hwp, CARD8 index, CARD8 value);
-	  </programlisting>
-	  <blockquote><para>
-      Write <parameter>value</parameter> to CRTC register <parameter>index</parameter>.
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    CARD8 readCrtc(vgaHWPtr hwp, CARD8 index);
-	  </programlisting>
-	  <blockquote><para>
-      Return the value read from CRTC register <parameter>index</parameter>.
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    void writeGr(vgaHWPtr hwp, CARD8 index, CARD8 value);
-	  </programlisting>
-	  <blockquote><para>
-      Write <parameter>value</parameter> to Graphics Controller register
-      <parameter>index</parameter>.
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    CARD8 readGR(vgaHWPtr hwp, CARD8 index);
-	  </programlisting>
-	  <blockquote><para>
-      Return the value read from Graphics Controller register
-      <parameter>index</parameter>.
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    void writeSeq(vgaHWPtr hwp, CARD8 index, CARD8, value);
-	  </programlisting>
-	  <blockquote><para>
-      Write <parameter>value</parameter> to Sequencer register
-      <parameter>index</parameter>.
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    CARD8 readSeq(vgaHWPtr hwp, CARD8 index);
-	  </programlisting>
-	  <blockquote><para>
-      Return the value read from Sequencer register <parameter>index</parameter>.
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    void writeAttr(vgaHWPtr hwp, CARD8 index, CARD8, value);
-	  </programlisting>
-	  <blockquote><para>
-      Write <parameter>value</parameter> to Attribute Controller register
-      <parameter>index</parameter>.  When writing out the index value this
-      function should set bit 5 (<constant>0x20</constant>) according to the
-      setting of <structfield>hwp->paletteEnabled</structfield> in order to
-      preserve the palette access state.  It should be cleared when
-      <structfield>hwp->paletteEnabled</structfield> is <constant>TRUE</constant>
-      and set when it is <constant>FALSE</constant>.
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    CARD8 readAttr(vgaHWPtr hwp, CARD8 index);
-	  </programlisting>
-	  <blockquote><para>
-      Return the value read from Attribute Controller register
-      <parameter>index</parameter>.  When writing out the index value this
-      function should set bit 5 (<constant>0x20</constant>) according to the
-      setting of <structfield>hwp->paletteEnabled</structfield> in order to
-      preserve the palette access state.  It should be cleared when
-      <structfield>hwp->paletteEnabled</structfield> is <constant>TRUE</constant>
-      and set when it is <constant>FALSE</constant>.
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    void writeMiscOut(vgaHWPtr hwp, CARD8 value);
-	  </programlisting>
-	  <blockquote><para>
-      Write <quote><parameter>value</parameter></quote> to the Miscellaneous Output register.
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    CARD8 readMiscOut(vgwHWPtr hwp);
-	  </programlisting>
-	  <blockquote><para>
-      Return the value read from the Miscellaneous Output register.
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    void enablePalette(vgaHWPtr hwp);
-	  </programlisting>
-	  <blockquote><para>
-      Clear the palette address source bit in the Attribute Controller
-      index register and set <literal remap="tt">hwp->paletteEnabled</literal> to
-      <constant>TRUE</constant>.
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    void disablePalette(vgaHWPtr hwp);
-	  </programlisting>
-	  <blockquote><para>
-      Set the palette address source bit in the Attribute Controller
-      index register and set <literal remap="tt">hwp->paletteEnabled</literal> to
-      <constant>FALSE</constant>.
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    void writeDacMask(vgaHWPtr hwp, CARD8 value);
-	  </programlisting>
-	  <blockquote><para>
-      Write <parameter>value</parameter> to the DAC Mask register.
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    CARD8 readDacMask(vgaHWptr hwp);
-	  </programlisting>
-	  <blockquote><para>
-      Return the value read from the DAC Mask register.
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    void writeDacReadAddress(vgaHWPtr hwp, CARD8 value);
-	  </programlisting>
-	  <blockquote><para>
-      Write <parameter>value</parameter> to the DAC Read Address register.
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    void writeDacWriteAddress(vgaHWPtr hwp, CARD8 value);
-	  </programlisting>
-	  <blockquote><para>
-      Write <parameter>value</parameter> to the DAC Write Address register.
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    void writeDacData(vgaHWPtr hwp, CARD8 value);
-	  </programlisting>
-	  <blockquote><para>
-      Write <parameter>value</parameter> to the DAC Data register.
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    CARD8 readDacData(vgaHWptr hwp);
-	  </programlisting>
-	  <blockquote><para>
-      Return the value read from the DAC Data register.
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    CARD8 readEnable(vgaHWptr hwp);
-	  </programlisting>
-	  <blockquote><para>
-      Return the value read from the VGA Enable register.  (Note: This
-      function is present in XFree86 4.1.0 and later.)
-	    </para>
-
-	  </blockquote></para></blockquote>
-
-      <blockquote><para>
-	  <programlisting>
-    void writeEnable(vgaHWPtr hwp, CARD8 value);
-	  </programlisting>
-	  <blockquote><para>
-      Write <parameter>value</parameter> to the VGA Enable register.  (Note: This
-      function is present in XFree86 4.1.0 and later.)
-	    </para>
-
-	  </blockquote></para></blockquote>
-    </sect2>
-  </sect1>
-
-  <sect1 id="sample">
-    <title>Some notes about writing a driver</title>
-
-    <note><para>NOTE: some parts of this are not up to date</para></note>
-
-    <para>
-The following is an outline for writing a basic unaccelerated driver
-for a PCI video card with a linear mapped framebuffer, and which has a
-VGA core.  It is includes some general information that is relevant to
-most drivers (even those which don't fit that basic description).
-    </para>
-
-    <para>
-The information here is based on the initial conversion of the Matrox
-Millennium driver to the <quote>new design</quote>.  For a fleshing out and sample
-implementation of some of the bits outlined here, refer to that driver.
-Note that this is an example only.  The approach used here will not be
-appropriate for all drivers.
-    </para>
-
-    <para>
-Each driver must reserve a unique driver name, and a string that is used
-to prefix all of its externally visible symbols.  This is to avoid name
-space clashes when loading multiple drivers.  The examples here are for
-the <quote>ZZZ</quote> driver, which uses the <quote>ZZZ</quote> or <quote>zzz</quote> prefix for its externally
-visible symbols.
-    </para>
-
-    <sect2>
-      <title>Include files</title>
-
-      <para>
-  All drivers normally include the following headers:
-	<literallayout><filename>
-    "xf86.h"
-    "xf86_OSproc.h"
-    "xf86_ansic.h"
-    "xf86Resources.h"
-	  </filename></literallayout>
-  Wherever inb/outb (and related things) are used the following should be
-  included:
-	<literallayout><filename>
-    "compiler.h"
-	  </filename></literallayout>
-  Note: in drivers, this must be included after <filename>"xf86_ansic.h"</filename>.
-      </para>
-
-      <para>
-  Drivers that need to access PCI vendor/device definitions need this:
-	<literallayout><filename>
-    "xf86PciInfo.h"
-	  </filename></literallayout>
-      </para>
-
-      <para>
-  Drivers that need to access the PCI config space need this:
-	<literallayout><filename>
-    "xf86Pci.h"
-	  </filename></literallayout>
-      </para>
-
-      <para>
-  Drivers using the mi banking wrapper need:
-
-	<literallayout><filename>
-    "mibank.h"
-	  </filename></literallayout>
-      </para>
-
-      <para>
-  Drivers that initialise a SW cursor need this:
-	<literallayout><filename>
-    "mipointer.h"
-	  </filename></literallayout>
-      </para>
-
-      <para>
-  All drivers implementing backing store need this:
-	<literallayout><filename>
-    "mibstore.h"
-	  </filename></literallayout>
-      </para>
-
-      <para>
-  All drivers using the mi colourmap code need this:
-	<literallayout><filename>
-    "micmap.h"
-	  </filename></literallayout>
-      </para>
-
-      <para>
-  If a driver uses the vgahw module, it needs this:
-	<literallayout><filename>
-    "vgaHW.h"
-	  </filename></literallayout>
-      </para>
-
-      <para>
-  Drivers supporting VGA or Hercules monochrome screens need:
-	<literallayout><filename>
-    "xf1bpp.h"
-	  </filename></literallayout>
-      </para>
-
-      <para>
-  Drivers supporting VGA or EGC 16-colour screens need:
-	<literallayout><filename>
-    "xf4bpp.h"
-	  </filename></literallayout>
-      </para>
-
-      <para>
-  Drivers using cfb need:
-	<programlisting>
-    #define PSZ 8
-    #include "cfb.h"
-    #undef PSZ
-	</programlisting>
-      </para>
-
-      <para>
-  Drivers supporting bpp 16, 24 or 32 with cfb need one or more of:
-	<literallayout><filename>
-    "cfb16.h"
-    "cfb24.h"
-    "cfb32.h"
-	  </filename></literallayout>
-      </para>
-
-      <para>
-  The driver's own header file:
-	<literallayout><filename>
-    "zzz.h"
-	  </filename></literallayout>
-      </para>
-
-      <para>
-  Drivers must NOT include the following:
-
-	<literallayout><filename>
-    "xf86Priv.h"
-    "xf86Privstr.h"
-    "xf86_libc.h"
-    "xf86_OSlib.h"
-    "Xos.h"</filename>
-    any OS header
-	</literallayout>
-      </para>
-
-    </sect2>
-
-    <sect2>
-      <title>Data structures and initialisation</title>
-
-      <itemizedlist>
-	<listitem>
-	  <para>The following macros should be defined:
-	    <programlisting>
-#define VERSION <version-as-an-int>
-#define ZZZ_NAME "ZZZ"         /* the name used to prefix messages */
-#define ZZZ_DRIVER_NAME "zzz"  /* the driver name as used in config file */
-#define ZZZ_MAJOR_VERSION <int>
-#define ZZZ_MINOR_VERSION <int>
-#define ZZZ_PATCHLEVEL    <int>
-	    </programlisting>
-	  </para>
-	  <para>
-    NOTE: <constant>ZZZ_DRIVER_NAME</constant> should match the name of the
-    driver module without things like the "lib" prefix, the "_drv" suffix
-    or filename extensions.
-	  </para>
-	</listitem>
-
-	<listitem>
-	  <para>
-    A DriverRec must be defined, which includes the functions required
-    at the pre-probe phase.  The name of this DriverRec must be an
-    upper-case version of ZZZ_DRIVER_NAME (for the purposes of static
-    linking).
-	    <programlisting>
-DriverRec ZZZ = {
-    VERSION,
-    ZZZ_DRIVER_NAME,
-    ZZZIdentify,
-    ZZZProbe,
-    ZZZAvailableOptions,
-    NULL,
-    0
-};
-	    </programlisting>
-	  </para>
-	</listitem>
-
-	<listitem>
-	  <para>Define list of supported chips and their matching ID:
-	    <programlisting>
-static SymTabRec ZZZChipsets[] = {
-    { PCI_CHIP_ZZZ1234, "zzz1234a" },
-    { PCI_CHIP_ZZZ5678, "zzz5678a" },
-    { -1,               NULL }
-};
-	    </programlisting>
-	  </para>
-	  <para>
-    The token field may be any integer value that the driver may use to
-    uniquely identify the supported chipsets.  For drivers that support
-    only PCI devices using the PCI device IDs might be a natural choice,
-    but this isn't mandatory.  For drivers that support both PCI and other
-    devices (like ISA), some other ID should probably used.  When other
-    IDs are used as the tokens it is recommended that the names be
-    defined as an <type>enum</type> type.
-	  </para>
-	</listitem>
-
-	<listitem>
-	  <para>
-    If the driver uses the <function>xf86MatchPciInstances()</function>
-    helper (recommended for drivers that support PCI cards) a list that
-    maps PCI IDs to chip IDs and fixed resources must be defined:
-	    <programlisting>
-static PciChipsets ZZZPciChipsets[] = {
-    { PCI_CHIP_ZZZ1234, PCI_CHIP_ZZZ1234, RES_SHARED_VGA },
-    { PCI_CHIP_ZZZ5678, PCI_CHIP_ZZZ5678, RES_SHARED_VGA },
-    { -1,               -1,               RES_UNDEFINED }
-}
-	    </programlisting>
-	  </para>
-	</listitem>
-
-	<listitem>
-	  <para>
-    Define the <structname>XF86ModuleVersionInfo</structname> struct for the
-    driver.  This is required for the dynamically loaded version:
-	    <programlisting>
-static XF86ModuleVersionInfo zzzVersRec =
-{
-    "zzz",
-    MODULEVENDORSTRING,
-    MODINFOSTRING1,
-    MODINFOSTRING2,
-    XF86_VERSION_CURRENT,
-    ZZZ_MAJOR_VERSION, ZZZ_MINOR_VERSION, ZZZ_PATCHLEVEL,
-    ABI_CLASS_VIDEODRV,
-    ABI_VIDEODRV_VERSION,
-    MOD_CLASS_VIDEODRV,
-    {0,0,0,0}
-};
-	    </programlisting>
-	  </para>
-	</listitem>
-
-	<listitem>
-	  <para>
-    Define a data structure to hold the driver's screen-specific data.
-    This must be used instead of global variables.  This would be defined
-    in the <filename>"zzz.h"</filename> file, something like:
-	    <programlisting>
-typedef struct {
-    type1  field1;
-    type2  field2;
-    int    fooHack;
-    Bool   pciRetry;
-    Bool   noAccel;
-    Bool   hwCursor;
-    CloseScreenProcPtr CloseScreen;
-    OptionInfoPtr Options;
-    ...
-} ZZZRec, *ZZZPtr;
-	    </programlisting>
-	  </para>
-	</listitem>
-
-	<listitem>
-	  <para>
-    Define the list of config file Options that the driver accepts.  For
-    consistency between drivers those in the list of <quote>standard</quote> options
-    should be used where appropriate before inventing new options.
-
-	    <programlisting>
-typedef enum {
-    OPTION_FOO_HACK,
-    OPTION_PCI_RETRY,
-    OPTION_HW_CURSOR,
-    OPTION_NOACCEL
-} ZZZOpts;
-
-static const OptionInfoRec ZZZOptions[] = {
-  { OPTION_FOO_HACK,  "FooHack",   OPTV_INTEGER, {0}, FALSE },
-  { OPTION_PCI_RETRY, "PciRetry",  OPTV_BOOLEAN, {0}, FALSE },
-  { OPTION_HW_CURSOR, "HWcursor",  OPTV_BOOLEAN, {0}, FALSE },
-  { OPTION_NOACCEL,   "NoAccel",   OPTV_BOOLEAN, {0}, FALSE },
-  { -1,               NULL,        OPTV_NONE,    {0}, FALSE }
-};
-	    </programlisting>
-	  </para>
-	</listitem>
-      </itemizedlist>
-    </sect2>
-
-    <sect2>
-      <title>Functions</title>
-
-
-      <sect3>
-	<title>SetupProc</title>
-
-	<para>
-    For dynamically loaded modules, a <varname>ModuleData</varname>
-    variable is required.  It is should be the name of the driver
-    prepended to "ModuleData".  A <function>Setup()</function> function is
-    also required, which calls <function>xf86AddDriver()</function> to add
-    the driver to the main list of drivers.
-	</para>
-
-	<programlisting>
-static MODULESETUPPROTO(zzzSetup);
-
-XF86ModuleData zzzModuleData = { &zzzVersRec, zzzSetup, NULL };
-
-static pointer
-zzzSetup(pointer module, pointer opts, int *errmaj, int *errmin)
-{
-    static Bool setupDone = FALSE;
-
-    /* This module should be loaded only once, but check to be sure. */
-
-    if (!setupDone) {
-        /*
-         * Modules that this driver always requires may be loaded
-         * here  by calling LoadSubModule().
-         */
-
-        setupDone = TRUE;
-        xf86AddDriver(&MGA, module, 0);
-
-        /*
-         * The return value must be non-NULL on success even though
-         * there is no TearDownProc.
-         */
-        return (pointer)1;
-    } else {
-        if (errmaj) *errmaj = LDR_ONCEONLY;
-        return NULL;
-    }
-}
-	</programlisting>
-      </sect3>
-
-      <sect3>
-	<title>GetRec, FreeRec</title>
-
-	<para>
-    A function is usually required to allocate the driver's
-    screen-specific data structure and hook it into the
-    <structname>ScrnInfoRec</structname>'s <structfield>driverPrivate</structfield> field.
-    The <structname>ScrnInfoRec</structname>'s <structfield>driverPrivate</structfield> is
-    initialised to <constant>NULL</constant>, so it is easy to check if the
-    initialisation has already been done.  After allocating it, initialise
-    the fields.  By using <function>xnfcalloc()</function> to do the allocation
-    it is zeroed, and if the allocation fails the server exits.
-	</para>
-
-	<para>
-    NOTE:
-    When allocating structures from inside the driver which are defined
-    on the common level it is important to initialize the structure to
-    zero.
-    Only this guarantees that the server remains source compatible to
-    future changes in common level structures.
-	</para>
-
-	<programlisting>
-static Bool
-ZZZGetRec(ScrnInfoPtr pScrn)
-{
-    if (pScrn->driverPrivate != NULL)
-        return TRUE;
-    pScrn->driverPrivate = xnfcalloc(sizeof(ZZZRec), 1);
-    /* Initialise as required */
-    ...
-    return TRUE;
-}
-	</programlisting>
-
-	<para>
-    Define a macro in <filename>"zzz.h"</filename> which gets a pointer to
-    the <structname>ZZZRec</structname> when given <parameter>pScrn</parameter>:
-
-	  <programlisting>
-#define ZZZPTR(p) ((ZZZPtr)((p)->driverPrivate))
-	  </programlisting>
-	</para>
-
-	<para>
-    Define a function to free the above, setting it to <constant>NULL</constant>
-    once it has been freed:
-
-	  <programlisting>
-static void
-ZZZFreeRec(ScrnInfoPtr pScrn)
-{
-    if (pScrn->driverPrivate == NULL)
-        return;
-    xfree(pScrn->driverPrivate);
-    pScrn->driverPrivate = NULL;
-}
-	  </programlisting>
-	</para>
-      </sect3>
-
-      <sect3>
-	<title>Identify</title>
-
-	<para>
-    Define the <function>Identify()</function> function.  It is run before
-    the Probe, and typically prints out an identifying message, which
-    might include the chipsets it supports.  This function is mandatory:
-
-	  <programlisting>
-static void
-ZZZIdentify(int flags)
-{
-    xf86PrintChipsets(ZZZ_NAME, "driver for ZZZ Tech chipsets",
-                      ZZZChipsets);
-}
-	  </programlisting>
-	</para>
-      </sect3>
-
-      <sect3>
-	<title>Probe</title>
-
-	<para>
-    Define the <function>Probe()</function> function.  The purpose of this
-    is to find all instances of the hardware that the driver supports,
-    and for the ones not already claimed by another driver, claim the
-    slot, and allocate a <structname>ScrnInfoRec</structname>.  This should be
-    a minimal probe, and it should under no circumstances leave the
-    state of the hardware changed.  Because a device is found, don't
-    assume that it will be used.  Don't do any initialisations other
-    than the required <structname>ScrnInfoRec</structname> initialisations.
-    Don't allocate any new data structures.
-	</para>
-
-	<para>
-    This function is mandatory.
-	</para>
-
-	<para>
-    NOTE: The <function>xf86DrvMsg()</function> functions cannot be used from
-    the Probe.
-	</para>
-
-	<programlisting>
-static Bool
-ZZZProbe(DriverPtr drv, int flags)
-{
-    Bool foundScreen = FALSE;
-    int numDevSections, numUsed;
-    GDevPtr *devSections;
-    int *usedChips;
-    int i;
-
-    /*
-     * Find the config file Device sections that match this
-     * driver, and return if there are none.
-     */
-    if ((numDevSections = xf86MatchDevice(ZZZ_DRIVER_NAME,
-                                          &devSections)) <= 0) {
-        return FALSE;
-    }
-
-    /*
-     * Since this is a PCI card, "probing" just amounts to checking
-     * the PCI data that the server has already collected.  If there
-     * is none, return.
-     *
-     * Although the config file is allowed to override things, it
-     * is reasonable to not allow it to override the detection
-     * of no PCI video cards.
-     *
-     * The provided xf86MatchPciInstances() helper takes care of
-     * the details.
-     */
-    /* test if PCI bus present */
-    if (xf86GetPciVideoInfo()) {
-
-        numUsed = xf86MatchPciInstances(ZZZ_NAME, PCI_VENDOR_ZZZ,
-                            ZZZChipsets, ZZZPciChipsets, devSections,
-                            numDevSections, drv, &usedChips);
-
-        for (i = 0; i < numUsed; i++) {
-            ScrnInfoPtr pScrn = NULL;
-            if ((pScrn = xf86ConfigPciEntity(pScrn, flags, usedChips[i],
-                                             ZZZPciChipsets, NULL, NULL,
-                                             NULL, NULL, NULL))) {
-               /* Allocate a ScrnInfoRec */
-               pScrn->driverVersion = VERSION;
-               pScrn->driverName    = ZZZ_DRIVER_NAME;
-               pScrn->name          = ZZZ_NAME;
-               pScrn->Probe         = ZZZProbe;
-               pScrn->PreInit       = ZZZPreInit;
-               pScrn->ScreenInit    = ZZZScreenInit;
-               pScrn->SwitchMode    = ZZZSwitchMode;
-               pScrn->AdjustFrame   = ZZZAdjustFrame;
-               pScrn->EnterVT       = ZZZEnterVT;
-               pScrn->LeaveVT       = ZZZLeaveVT;
-               pScrn->FreeScreen    = ZZZFreeScreen;
-               pScrn->ValidMode     = ZZZValidMode;
-               foundScreen = TRUE;
-               /* add screen to entity */
-           }
-        }
-        xfree(usedChips);
-    }
-
-#ifdef HAS_ISA_DEVS
-    /*
-     * If the driver supports ISA hardware, the following block
-     * can be included too.
-     */
-    numUsed = xf86MatchIsaInstances(ZZZ_NAME, ZZZChipsets,
-                             ZZZIsaChipsets, drv, ZZZFindIsaDevice,
-                             devSections, numDevSections, &usedChips);
-    for (i = 0; i < numUsed; i++) {
-        ScrnInfoPtr pScrn = NULL;
-	if ((pScrn = xf86ConfigIsaEntity(pScrn, flags, usedChips[i],
-					 ZZZIsaChipsets, NULL, NULL, NULL,
-					 NULL, NULL))) {
-            pScrn->driverVersion = VERSION;
-            pScrn->driverName    = ZZZ_DRIVER_NAME;
-            pScrn->name          = ZZZ_NAME;
-            pScrn->Probe         = ZZZProbe;
-            pScrn->PreInit       = ZZZPreInit;
-            pScrn->ScreenInit    = ZZZScreenInit;
-            pScrn->SwitchMode    = ZZZSwitchMode;
-            pScrn->AdjustFrame   = ZZZAdjustFrame;
-            pScrn->EnterVT       = ZZZEnterVT;
-            pScrn->LeaveVT       = ZZZLeaveVT;
-            pScrn->FreeScreen    = ZZZFreeScreen;
-            pScrn->ValidMode     = ZZZValidMode;
-            foundScreen = TRUE;
-        }
-    }
-    xfree(usedChips);
-#endif /* HAS_ISA_DEVS */
-
-    xfree(devSections);
-    return foundScreen;
-	</programlisting>
-      </sect3>
-
-      <sect3>
-	<title>AvailableOptions</title>
-
-	<para>
-    Define the <function>AvailableOptions()</function> function. The purpose
-    of this is to return the available driver options back to the
-    -configure option, so that an xorg.conf file can be built and the
-    user can see which options are available for them to use.
-	</para>
-      </sect3>
-
-      <sect3>
-	<title>PreInit</title>
-
-	<para>
-    Define the <function>PreInit()</function> function.  The purpose of
-    this is to find all the information required to determine if the
-    configuration is usable, and to initialise those parts of the
-    <structname>ScrnInfoRec</structname> that can be set once at the beginning
-    of the first server generation.  The information should be found in
-    the least intrusive way possible.
-	</para>
-
-	<para>
-    This function is mandatory.
-	</para>
-
-	<para>
-    NOTES:
-	  <orderedlist>
-	    <listitem><para>
-	 The <function>PreInit()</function> function is only called once
-	 during the life of the X server (at the start of the first
-	 generation).
-	      </para></listitem>
-
-	    <listitem><para>
-	 Data allocated here must be of the type that persists for
-	 the life of the X server.  This means that data that hooks into
-	 the <structname>ScrnInfoRec</structname>'s <structfield>privates</structfield>
-	 field should be allocated here, but data that hooks into the
-	 <structname>ScreenRec</structname>'s <structfield>devPrivates</structfield> field
-	 should not be allocated here.  The <structfield>driverPrivate</structfield>
-	 field should also be allocated here.
-	      </para></listitem>
-
-	    <listitem><para>
-	 Although the <structname>ScrnInfoRec</structname> has been allocated
-	 before this function is called, the <structname>ScreenRec</structname>
-	 has not been allocated.  That means that things requiring it
-	 cannot be used in this function.
-	      </para></listitem>
-
-	    <listitem><para>
-	 Very little of the <structname>ScrnInfoRec</structname> has been
-	 initialised when this function is called.  It is important to
-	 get the order of doing things right in this function.
-	      </para></listitem>
-
-	  </orderedlist>
-	</para>
-
-	<programlisting>
-static Bool
-ZZZPreInit(ScrnInfoPtr pScrn, int flags)
-{
-    /* Fill in the monitor field */
-    pScrn->monitor = pScrn->confScreen->monitor;
-
-    /*
-     * If using the vgahw module, it will typically be loaded
-     * here by calling xf86LoadSubModule(pScrn, "vgahw");
-     */
-
-    /*
-     * Set the depth/bpp.  Use the globally preferred depth/bpp.  If the
-     * driver has special default depth/bpp requirements, the defaults should
-     * be specified here explicitly.
-     * We support both 24bpp and 32bpp framebuffer layouts.
-     * This sets pScrn->display also.
-     */
-    if (!xf86SetDepthBpp(pScrn, 0, 0, 0,
-                         Support24bppFb | Support32bppFb)) {
-        return FALSE;
-    } else {
-        if (depth/bpp isn't one we support) {
-            print error message;
-            return FALSE;
-        }
-    }
-    /* Print out the depth/bpp that was set */
-    xf86PrintDepthBpp(pScrn);
-
-    /* Set bits per RGB for 8bpp */
-    if (pScrn->depth <= 8) {
-        /* Take into account a dac_6_bit option here */
-        pScrn->rgbBits = 6 or 8;
-    }
-
-    /*
-     * xf86SetWeight() and xf86SetDefaultVisual() must be called
-     * after pScrn->display is initialised.
-     */
-
-    /* Set weight/mask/offset for depth > 8 */
-    if (pScrn->depth > 8) {
-        if (!xf86SetWeight(pScrn, defaultWeight, defaultMask)) {
-            return FALSE;
-        } else {
-            if (weight isn't one we support) {
-                print error message;
-                return FALSE;
-            }
-        }
-    }
-
-    /* Set the default visual. */
-    if (!xf86SetDefaultVisual(pScrn, -1)) {
-        return FALSE;
-    } else {
-        if (visual isn't one we support) {
-            print error message;
-            return FALSE;
-        }
-    }
-
-    /* If the driver supports gamma correction, set the gamma. */
-    if (!xf86SetGamma(pScrn, default_gamma)) {
-        return FALSE;
-    }
-
-    /* This driver uses a programmable clock */
-    pScrn->progClock = TRUE;
-
-    /* Allocate the ZZZRec driverPrivate */
-    if (!ZZZGetRec(pScrn)) {
-        return FALSE;
-    }
-
-    pZzz = ZZZPTR(pScrn);
-
-    /* Collect all of the option flags (fill in pScrn->options) */
-    xf86CollectOptions(pScrn, NULL);
-
-    /*
-     * Process the options based on the information in ZZZOptions.
-     * The results are written to pZzz->Options.  If all of the options
-     * processing is done within this function a local variable "options"
-     * can be used instead of pZzz->Options.
-     */
-    if (!(pZzz->Options = xalloc(sizeof(ZZZOptions))))
-        return FALSE;
-    (void)memcpy(pZzz->Options, ZZZOptions, sizeof(ZZZOptions));
-    xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, pZzz->Options);
-
-    /*
-     * Set various fields of ScrnInfoRec and/or ZZZRec based on
-     * the options found.
-     */
-    from = X_DEFAULT;
-    pZzz->hwCursor = FALSE;
-    if (xf86IsOptionSet(pZzz->Options, OPTION_HW_CURSOR)) {
-        from = X_CONFIG;
-        pZzz->hwCursor = TRUE;
-    }
-    xf86DrvMsg(pScrn->scrnIndex, from, "Using %s cursor\n",
-               pZzz->hwCursor ? "HW" : "SW");
-    if (xf86IsOptionSet(pZzz->Options, OPTION_NOACCEL)) {
-        pZzz->noAccel = TRUE;
-        xf86DrvMsg(pScrn->scrnIndex, X_CONFIG,
-                   "Acceleration disabled\n");
-    } else {
-        pZzz->noAccel = FALSE;
-    }
-    if (xf86IsOptionSet(pZzz->Options, OPTION_PCI_RETRY)) {
-        pZzz->UsePCIRetry = TRUE;
-        xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "PCI retry enabled\n");
-    }
-    pZzz->fooHack = 0;
-    if (xf86GetOptValInteger(pZzz->Options, OPTION_FOO_HACK,
-                             &pZzz->fooHack)) {
-        xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Foo Hack set to %d\n",
-                   pZzz->fooHack);
-    }
-
-    /*
-     * Find the PCI slot(s) that this screen claimed in the probe.
-     * In this case, exactly one is expected, so complain otherwise.
-     * Note in this case we're not interested in the card types so
-     * that parameter is set to NULL.
-     */
-    if ((i = xf86GetPciInfoForScreen(pScrn->scrnIndex, &pciList, NULL))
-        != 1) {
-        print error message;
-        ZZZFreeRec(pScrn);
-        if (i > 0)
-            xfree(pciList);
-        return FALSE;
-    }
-    /* Note that pciList should be freed below when no longer needed */
-
-    /*
-     * Determine the chipset, allowing config file chipset and
-     * chipid values to override the probed information.  The config
-     * chipset value has precedence over its chipid value if both
-     * are present.
-     *
-     * It isn't necessary to fill in pScrn->chipset if the driver
-     * keeps track of the chipset in its ZZZRec.
-     */
-
-    ...
-
-    /*
-     * Determine video memory, fb base address, I/O addresses, etc,
-     * allowing the config file to override probed values.
-     *
-     * Set the appropriate pScrn fields (videoRam is probably the
-     * most important one that other code might require), and
-     * print out the settings.
-     */
-
-    ...
-
-    /* Initialise a clockRanges list. */
-
-    ...
-
-    /* Set any other chipset specific things in the ZZZRec */
-
-    ...
-
-    /* Select valid modes from those available */
-
-    i = xf86ValidateModes(pScrn, pScrn->monitor->Modes,
-                          pScrn->display->modes, clockRanges,
-                          NULL, minPitch, maxPitch, rounding,
-                          minHeight, maxHeight,
-                          pScrn->display->virtualX,
-                          pScrn->display->virtualY,
-                          pScrn->videoRam * 1024,
-                          LOOKUP_BEST_REFRESH);
-    if (i == -1) {
-        ZZZFreeRec(pScrn);
-        return FALSE;
-    }
-
-    /* Prune the modes marked as invalid */
-
-    xf86PruneDriverModes(pScrn);
-
-    /* If no valid modes, return */
-
-    if (i == 0 || pScrn->modes == NULL) {
-        print error message;
-        ZZZFreeRec(pScrn);
-        return FALSE;
-    }
-
-    /*
-     * Initialise the CRTC fields for the modes.  This driver expects
-     * vertical values to be halved for interlaced modes.
-     */
-    xf86SetCrtcForModes(pScrn, INTERLACE_HALVE_V);
-
-    /* Set the current mode to the first in the list. */
-    pScrn->currentMode = pScrn->modes;
-
-    /* Print the list of modes being used. */
-    xf86PrintModes(pScrn);
-
-    /* Set the DPI */
-    xf86SetDpi(pScrn, 0, 0);
-
-    /* Load bpp-specific modules */
-    switch (pScrn->bitsPerPixel) {
-    case 1:
-        mod = "xf1bpp";
-        break;
-    case 4:
-        mod = "xf4bpp";
-        break;
-    case 8:
-        mod = "cfb";
-        break;
-    case 16:
-        mod = "cfb16";
-        break;
-    case 24:
-        mod = "cfb24";
-        break;
-    case 32:
-        mod = "cfb32";
-        break;
-    }
-    if (mod && !xf86LoadSubModule(pScrn, mod))
-        ZZZFreeRec(pScrn);
-        return FALSE;
-
-    /* Load XAA if needed */
-    if (!pZzz->noAccel || pZzz->hwCursor)
-        if (!xf86LoadSubModule(pScrn, "xaa")) {
-            ZZZFreeRec(pScrn);
-            return FALSE;
-        }
-
-    /* Done */
-    return TRUE;
-}
-	</programlisting>
-      </sect3>
-
-      <sect3>
-	<title>MapMem, UnmapMem</title>
-
-	<para>
-    Define functions to map and unmap the video memory and any other
-    memory apertures required.  These functions are not mandatory, but
-    it is often useful to have such functions.
-	</para>
-
-	<programlisting>
-static Bool
-ZZZMapMem(ScrnInfoPtr pScrn)
-{
-    /* Call xf86MapPciMem() to map each PCI memory area */
-    ...
-    return TRUE or FALSE;
-}
-
-static Bool
-ZZZUnmapMem(ScrnInfoPtr pScrn)
-{
-    /* Call xf86UnMapVidMem() to unmap each memory area */
-    ...
-    return TRUE or FALSE;
-}
-	</programlisting>
-      </sect3>
-
-      <sect3>
-	<title>Save, Restore</title>
-
-	<para>
-    Define functions to save and restore the original video state.  These
-    functions are not mandatory, but are often useful.
-	</para>
-
-	<programlisting>
-static void
-ZZZSave(ScrnInfoPtr pScrn)
-{
-    /*
-     * Save state into per-screen data structures.
-     * If using the vgahw module, vgaHWSave will typically be
-     * called here.
-     */
-    ...
-}
-
-static void
-ZZZRestore(ScrnInfoPtr pScrn)
-{
-    /*
-     * Restore state from per-screen data structures.
-     * If using the vgahw module, vgaHWRestore will typically be
-     * called here.
-     */
-    ...
-}
-	</programlisting>
-      </sect3>
-
-      <sect3>
-	<title>ModeInit</title>
-
-	<para>
-    Define a function to initialise a new video mode.  This function isn't
-    mandatory, but is often useful.
-	</para>
-
-	<programlisting>
-static Bool
-ZZZModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
-{
-    /*
-     * Program a video mode.  If using the vgahw module,
-     * vgaHWInit and vgaRestore will typically be called here.
-     * Once up to the point where there can't be a failure
-     * set pScrn->vtSema to TRUE.
-     */
-    ...
-}
-	</programlisting>
-      </sect3>
-
-      <sect3>
-	<title>ScreenInit</title>
-
-	<para>
-    Define the <function>ScreenInit()</function> function.  This is called
-    at the start of each server generation, and should fill in as much
-    of the <structname>ScreenRec</structname> as possible as well as any other
-    data that is initialised once per generation.  It should initialise
-    the framebuffer layers it is using, and initialise the initial video
-    mode.
-	</para>
-
-	<para>
-    This function is mandatory.
-	</para>
-
-	<para>
-    NOTE: The <structname>ScreenRec</structname> (<parameter>pScreen</parameter>) is
-	  passed to this driver, but it and the
-	  <varname>ScrnInfoRecs</varname> are not yet hooked into each
-	  other.  This means that in this function, and functions it
-	  calls, one cannot be found from the other.
-	</para>
-
-	<programlisting>
-static Bool
-ZZZScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
-{
-    /* Get the ScrnInfoRec */
-    pScrn = xf86Screens[pScreen->myNum];
-
-    /*
-     * If using the vgahw module, its data structures and related
-     * things are typically initialised/mapped here.
-     */
-
-    /* Save the current video state */
-    ZZZSave(pScrn);
-
-    /* Initialise the first mode */
-    ZZZModeInit(pScrn, pScrn->currentMode);
-
-    /* Set the viewport if supported */
-
-    ZZZAdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0);
-
-    /*
-     * Setup the screen's visuals, and initialise the framebuffer
-     * code.
-     */
-
-    /* Reset the visual list */
-    miClearVisualTypes();
-
-    /*
-     * Setup the visuals supported.  This driver only supports
-     * TrueColor for bpp > 8, so the default set of visuals isn't
-     * acceptable.  To deal with this, call miSetVisualTypes with
-     * the appropriate visual mask.
-     */
-
-    if (pScrn->bitsPerPixel > 8) {
-        if (!miSetVisualTypes(pScrn->depth, TrueColorMask,
-                              pScrn->rgbBits, pScrn->defaultVisual))
-            return FALSE;
-    } else {
-        if (!miSetVisualTypes(pScrn->depth,
-                              miGetDefaultVisualMask(pScrn->depth),
-                              pScrn->rgbBits, pScrn->defaultVisual))
-            return FALSE;
-    }
-
-    /*
-     * Initialise the framebuffer.
-     */
-
-    switch (pScrn->bitsPerPixel) {
-    case 1:
-        ret = xf1bppScreenInit(pScreen, FbBase,
-                               pScrn->virtualX, pScrn->virtualY,
-                               pScrn->xDpi, pScrn->yDpi,
-                               pScrn->displayWidth);
-        break;
-    case 4:
-        ret = xf4bppScreenInit(pScreen, FbBase,
-                               pScrn->virtualX, pScrn->virtualY,
-                               pScrn->xDpi, pScrn->yDpi,
-                               pScrn->displayWidth);
-        break;
-    case 8:
-        ret = cfbScreenInit(pScreen, FbBase,
-                            pScrn->virtualX, pScrn->virtualY,
-                            pScrn->xDpi, pScrn->yDpi,
-                            pScrn->displayWidth);
-        break;
-    case 16:
-        ret = cfb16ScreenInit(pScreen, FbBase,
-                              pScrn->virtualX, pScrn->virtualY,
-                              pScrn->xDpi, pScrn->yDpi,
-                              pScrn->displayWidth);
-        break;
-    case 24:
-        ret = cfb24ScreenInit(pScreen, FbBase,
-                              pScrn->virtualX, pScrn->virtualY,
-                              pScrn->xDpi, pScrn->yDpi,
-                              pScrn->displayWidth);
-        break;
-    case 32:
-        ret = cfb32ScreenInit(pScreen, FbBase,
-                              pScrn->virtualX, pScrn->virtualY,
-                              pScrn->xDpi, pScrn->yDpi,
-                              pScrn->displayWidth);
-        break;
-    default:
-        print a message about an internal error;
-        ret = FALSE;
-        break;
-    }
-
-    if (!ret)
-        return FALSE;
-
-    /* Override the default mask/offset settings */
-    if (pScrn->bitsPerPixel > 8) {
-        for (i = 0, visual = pScreen->visuals;
-             i < pScreen->numVisuals; i++, visual++) {
-            if ((visual->class | DynamicClass) == DirectColor) {
-                visual->offsetRed = pScrn->offset.red;
-                visual->offsetGreen = pScrn->offset.green;
-                visual->offsetBlue = pScrn->offset.blue;
-                visual->redMask = pScrn->mask.red;
-                visual->greenMask = pScrn->mask.green;
-                visual->blueMask = pScrn->mask.blue;
-            }
-        }
-    }
-
-    /*
-     * If banking is needed, initialise an miBankInfoRec (defined in
-     * "mibank.h"), and call miInitializeBanking().
-     */
-    if (!miInitializeBanking(pScreen, pScrn->virtualX, pScrn->virtualY,
-                                     pScrn->displayWidth, pBankInfo))
-        return FALSE;
-
-    /*
-     * If backing store is to be supported (as is usually the case),
-     * initialise it.
-     */
-    miInitializeBackingStore(pScreen);
-
-    /*
-     * Set initial black & white colourmap indices.
-     */
-    xf86SetBlackWhitePixels(pScreen);
-
-    /*
-     * Install colourmap functions.  If using the vgahw module,
-     * vgaHandleColormaps would usually be called here.
-     */
-
-    ...
-
-    /*
-     * Initialise cursor functions.  This example is for the mi
-     * software cursor.
-     */
-    miDCInitialize(pScreen, xf86GetPointerScreenFuncs());
-
-    /* Initialise the default colourmap */
-    switch (pScrn->depth) {
-    case 1:
-        if (!xf1bppCreateDefColormap(pScreen))
-            return FALSE;
-        break;
-    case 4:
-        if (!xf4bppCreateDefColormap(pScreen))
-            return FALSE;
-        break;
-    default:
-        if (!cfbCreateDefColormap(pScreen))
-            return FALSE;
-        break;
-    }
-
-    /*
-     * Wrap the CloseScreen vector and set SaveScreen.
-     */
-    ZZZPTR(pScrn)->CloseScreen = pScreen->CloseScreen;
-    pScreen->CloseScreen = ZZZCloseScreen;
-    pScreen->SaveScreen = ZZZSaveScreen;
-
-    /* Report any unused options (only for the first generation) */
-    if (serverGeneration == 1) {
-        xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options);
-    }
-
-    /* Done */
-    return TRUE;
-}
-	</programlisting>
-      </sect3>
-
-      <sect3>
-	<title>SwitchMode</title>
-
-	<para>
-    Define the <function>SwitchMode()</function> function if mode switching
-    is supported by the driver.
-	</para>
-
-	<programlisting>
-static Bool
-ZZZSwitchMode(int scrnIndex, DisplayModePtr mode, int flags)
-{
-    return ZZZModeInit(xf86Screens[scrnIndex], mode);
-}
-	</programlisting>
-      </sect3>
-
-      <sect3>
-	<title>AdjustFrame</title>
-
-	<para>
-    Define the <function>AdjustFrame()</function> function if the driver
-    supports this.
-	</para>
-
-	<programlisting>
-static void
-ZZZAdjustFrame(int scrnIndex, int x, int y, int flags)
-{
-    /* Adjust the viewport */
-}
-	</programlisting>
-      </sect3>
-
-      <sect3>
-	<title>EnterVT, LeaveVT</title>
-
-	<para>
-    Define the <function>EnterVT()</function> and <function>LeaveVT()</function>
-    functions.
-	</para>
-
-	<para>
-    These functions are mandatory.
-	</para>
-
-	<programlisting>
-static Bool
-ZZZEnterVT(int scrnIndex, int flags)
-{
-    ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
-    return ZZZModeInit(pScrn, pScrn->currentMode);
-}
-
-static void
-ZZZLeaveVT(int scrnIndex, int flags)
-{
-    ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
-    ZZZRestore(pScrn);
-}
-	</programlisting>
-      </sect3>
-
-      <sect3>
-	<title>CloseScreen</title>
-
-	<para>
-    Define the <function>CloseScreen()</function> function:
-	</para>
-
-	<para>
-    This function is mandatory.  Note that it unwraps the previously
-    wrapped <structfield>pScreen->CloseScreen</structfield>, and finishes by
-    calling it.
-	</para>
-
-	<programlisting>
-static Bool
-ZZZCloseScreen(int scrnIndex, ScreenPtr pScreen)
-{
-    ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
-    if (pScrn->vtSema) {
-        ZZZRestore(pScrn);
-        ZZZUnmapMem(pScrn);
-    }
-    pScrn->vtSema = FALSE;
-    pScreen->CloseScreen = ZZZPTR(pScrn)->CloseScreen;
-    return (*pScreen->CloseScreen)(scrnIndex, pScreen);
-}
-	</programlisting>
-      </sect3>
-
-      <sect3>
-	<title>SaveScreen</title>
-
-	<para>
-    Define the <function>SaveScreen()</function> function (the screen
-    blanking function).  When using the vgahw module, this will typically
-    be:
-
-	  <programlisting>
-static Bool
-ZZZSaveScreen(ScreenPtr pScreen, int mode)
-{
-    return vgaHWSaveScreen(pScreen, mode);
-}
-	  </programlisting>
-	</para>
-
-	<para>
-    This function is mandatory.  Before modifying any hardware register
-    directly this function needs to make sure that the Xserver is active
-    by checking if <parameter>pScrn</parameter> is non-NULL and for
-    <literal remap="tt">pScrn->vtSema == TRUE</literal>.
-	</para>
-      </sect3>
-
-      <sect3>
-	<title>FreeScreen</title>
-
-	<para>
-    Define the <function>FreeScreen()</function> function.  This function
-    is optional.  It should be defined if the <structname>ScrnInfoRec</structname>
-    <structfield>driverPrivate</structfield> field is used so that it can be freed
-    when a screen is deleted by the common layer for reasons possibly
-    beyond the driver's control.  This function is not used in during
-    normal (error free) operation.  The per-generation data is freed by
-    the <function>CloseScreen()</function> function.
-	</para>
-
-	<programlisting>
-static void
-ZZZFreeScreen(int scrnIndex, int flags)
-{
-    /*
-     * If the vgahw module is used vgaHWFreeHWRec() would be called
-     * here.
-     */
-    ZZZFreeRec(xf86Screens[scrnIndex]);
-}
-
-	</programlisting>
-
-      </sect3>
-
-    </sect2>
-
-  </sect1>
-
-</article>
diff --git a/hw/xfree86/doc/sgml/Makefile.am b/hw/xfree86/doc/sgml/Makefile.am
deleted file mode 100644
index 10eca86..0000000
--- a/hw/xfree86/doc/sgml/Makefile.am
+++ /dev/null
@@ -1,27 +0,0 @@
-#  Copyright 2005 Red Hat, Inc.
-#
-#  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 Red Hat
-#  not be used in advertising or publicity pertaining to distribution
-#  of the software without specific, written prior permission.  Red
-#  Hat makes no representations about the suitability of this software
-#  for any purpose.  It is provided "as is" without express or implied
-#  warranty.
-#
-#  RED HAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
-#  INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
-#  NO EVENT SHALL RED HAT 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.
-
-doc_sources = DESIGN.xml
-
-# Developer's documentation is not installed
-if ENABLE_DEVEL_DOCS
-include $(top_srcdir)/doc/xml/xmlrules-noinst.in
-endif
commit 531869448d07e00ae241120b59f3aaaa5709d59c
Author: Ville Syrjälä <ville.syrjala at nokia.com>
Date:   Fri May 6 18:18:15 2011 +0300

    dri2: Don't send so many needless invalidate events
    
    Only send invalidate events for drawables if some client has requested
    some buffers.
    
    Signed-off-by: Ville Syrjälä <ville.syrjala at nokia.com>
    Reviewed-by: Michel Dänzer <michel at daenzer.net>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
index 5c42a51..bf7ebb9 100644
--- a/hw/xfree86/dri2/dri2.c
+++ b/hw/xfree86/dri2/dri2.c
@@ -83,6 +83,7 @@ typedef struct _DRI2Drawable {
     CARD64		 last_swap_ust; /* ust at completion of most recent swap */
     int			 swap_limit; /* for N-buffering */
     unsigned long	 serialNumber;
+    Bool		 needInvalidate;
 } DRI2DrawableRec, *DRI2DrawablePtr;
 
 typedef struct _DRI2Screen {
@@ -497,6 +498,8 @@ do_get_buffers(DrawablePtr pDraw, int *width, int *height,
 		       DRI2BufferFrontLeft);
     }
 
+    pPriv->needInvalidate = TRUE;
+
     return pPriv->buffers;
 
 err_out:
@@ -540,9 +543,11 @@ DRI2InvalidateDrawable(DrawablePtr pDraw)
     DRI2DrawablePtr pPriv = DRI2GetDrawable(pDraw);
     DRI2DrawableRefPtr ref;
 
-    if (!pPriv)
+    if (!pPriv || !pPriv->needInvalidate)
         return;
 
+    pPriv->needInvalidate = FALSE;
+
     list_for_each_entry(ref, &pPriv->reference_list, link)
 	ref->invalidate(pDraw, ref->priv);
 }
commit ba5540221f2a46133371b4ff0d527b1a0a1443b1
Merge: 6347a0b... 728d0bf...
Author: Keith Packard <keithp at keithp.com>
Date:   Fri May 13 13:59:36 2011 -0700

    Merge remote-tracking branch 'whot/for-keith'

commit 6347a0b802812bb185ada1bf0951add306935184
Merge: 4d02c53... f144fb7...
Author: Keith Packard <keithp at keithp.com>
Date:   Fri May 13 13:54:29 2011 -0700

    Merge remote-tracking branch 'jeremyhu/master'

commit 4d02c5397114ac4d15e794908f0708427e258261
Merge: 043c175... eac37f3...
Author: Keith Packard <keithp at keithp.com>
Date:   Fri May 13 13:52:18 2011 -0700

    Merge remote-tracking branch 'vsyrjala/composite_validatetree_2'

commit f144fb771f2e0665677aa88d08778899f666a1d5
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Fri May 13 09:10:42 2011 -0700

    XQuartz: Don't circumvent NDEBUG
    
    If someone wants to turn off asserts with NDEBUG, let them.
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/hw/xquartz/quartzKeyboard.c b/hw/xquartz/quartzKeyboard.c
index c540114..e682f08 100644
--- a/hw/xquartz/quartzKeyboard.c
+++ b/hw/xquartz/quartzKeyboard.c
@@ -56,13 +56,7 @@
 
 #include "X11Application.h"
 
-#ifdef NDEBUG
-#undef NDEBUG
 #include <assert.h>
-#define NDEBUG 1
-#else
-#include <assert.h>
-#endif
 #include <pthread.h>
 
 #include "xkbsrv.h"
commit 728d0bf20ed8e2612b100fca6526705fa6e1eef4
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Wed May 11 13:35:39 2011 +1000

    dix: replace CORE_EVENT and XI2_EVENT macros with inline functions.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Jamey Sharp <jamey at minilop.net>

diff --git a/dix/events.c b/dix/events.c
index e67c3a2..14f6f90 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -176,12 +176,23 @@ typedef const char *string;
 #define AllEventMasks (LastEventMask|(LastEventMask-1))
 
 
-#define CORE_EVENT(event) \
-    (!((event)->u.u.type & EXTENSION_EVENT_BASE) && \
-      (event)->u.u.type != GenericEvent)
-#define XI2_EVENT(event) \
-    (((event)->u.u.type == GenericEvent) && \
-    ((xGenericEvent*)(event))->extension == IReqCode)
+/* @return the core event type or 0 if the event is not a core event */
+static inline int
+core_get_type(const xEvent *event)
+{
+    int type = event->u.u.type;
+
+    return ((type & EXTENSION_EVENT_BASE) || type == GenericEvent) ? 0 : type;
+}
+
+/* @return the XI2 event type or 0 if the event is not a XI2 event */
+static inline int
+xi2_get_type(const xEvent *event)
+{
+    xGenericEvent* e = (xGenericEvent*)event;
+
+    return (e->type != GenericEvent || e->extension != IReqCode) ? 0 : e->evtype;
+}
 
 /**
  * Used to indicate a implicit passive grab created by a ButtonPress event.
@@ -414,10 +425,12 @@ static const Mask default_filter[128] =
 Mask
 GetEventFilter(DeviceIntPtr dev, xEvent *event)
 {
+    int evtype = 0;
+
     if (event->u.u.type != GenericEvent)
         return filters[dev ? dev->id : 0][event->u.u.type];
-    else if (XI2_EVENT(event))
-        return (1 << (((xXIDeviceEvent*)event)->evtype % 8));
+    else if ((evtype = xi2_get_type(event)))
+        return (1 << (evtype % 8));
     ErrorF("[dix] Unknown device type %d. No filter\n", event->u.u.type);
     return 0;
 }
@@ -432,7 +445,7 @@ GetWindowXI2Mask(DeviceIntPtr dev, WindowPtr win, xEvent* ev)
     int filter;
     int evtype;
 
-    if (!inputMasks || !XI2_EVENT(ev))
+    if (!inputMasks || xi2_get_type(ev) == 0)
         return 0;
 
     evtype = ((xGenericEvent*)ev)->evtype;
@@ -446,14 +459,16 @@ GetWindowXI2Mask(DeviceIntPtr dev, WindowPtr win, xEvent* ev)
 Mask
 GetEventMask(DeviceIntPtr dev, xEvent *event, InputClients* other)
 {
+    int evtype;
+
     /* XI2 filters are only ever 8 bit, so let's return a 8 bit mask */
-    if (XI2_EVENT(event))
+    if ((evtype = xi2_get_type(event)))
     {
-        int byte = ((xGenericEvent*)event)->evtype / 8;
+        int byte = evtype / 8;
         return (other->xi2mask[dev->id][byte] |
                 other->xi2mask[XIAllDevices][byte] |
                 (IsMaster(dev)? other->xi2mask[XIAllMasterDevices][byte] : 0));
-    } else if (CORE_EVENT(event))
+    } else if (core_get_type(event) != 0)
         return other->mask[XIAllDevices];
     else
         return other->mask[dev->id];
@@ -1952,11 +1967,8 @@ ActivateImplicitGrab(DeviceIntPtr dev, ClientPtr client, WindowPtr win,
         grabtype = GRABTYPE_CORE;
     else if (type == DeviceButtonPress)
         grabtype = GRABTYPE_XI;
-    else if (XI2_EVENT(event) && ((xGenericEvent*)event)->evtype == XI_ButtonPress)
-    {
-        type = ((xGenericEvent*)event)->evtype;
+    else if ((type = xi2_get_type(event)) == XI_ButtonPress)
         grabtype = GRABTYPE_XI2;
-    }
     else
         return FALSE;
 
@@ -2040,9 +2052,9 @@ DeliverEventToClients(DeviceIntPtr dev, WindowPtr win, xEvent *events,
     enum EventDeliveryState rc = EVENT_SKIP;
     InputClients *other;
 
-    if (CORE_EVENT(events))
+    if (core_get_type(events) != 0)
         other = (InputClients *)wOtherClients(win);
-    else if (XI2_EVENT(events))
+    else if (xi2_get_type(events) != 0)
     {
         OtherInputMasks *inputMasks = wOtherInputMasks(win);
         /* Has any client selected for the event? */
@@ -2094,6 +2106,7 @@ out:
     return rc;
 }
 
+
 /**
  * Deliver events to a window. At this point, we do not yet know if the event
  * actually needs to be delivered. May activate a grab if the event is a
@@ -2127,7 +2140,7 @@ DeliverEventsToWindow(DeviceIntPtr pDev, WindowPtr pWin, xEvent
     int type = pEvents->u.u.type;
 
     /* Deliver to window owner */
-    if ((filter == CantBeFiltered) || CORE_EVENT(pEvents))
+    if ((filter == CantBeFiltered) || core_get_type(pEvents) != 0)
     {
         enum EventDeliveryState rc;
 
@@ -2313,22 +2326,29 @@ FixUpEventFromWindow(
     Window child,
     Bool calcChild)
 {
+    int evtype;
+
     if (calcChild)
         child = FindChildForEvent(pSprite, pWin);
 
-    if (XI2_EVENT(xE))
+    if ((evtype = xi2_get_type(xE)))
     {
         xXIDeviceEvent* event = (xXIDeviceEvent*)xE;
 
-        if (event->evtype == XI_RawKeyPress ||
-            event->evtype == XI_RawKeyRelease ||
-            event->evtype == XI_RawButtonPress ||
-            event->evtype == XI_RawButtonRelease ||
-            event->evtype == XI_RawMotion ||
-            event->evtype == XI_DeviceChanged ||
-            event->evtype == XI_HierarchyChanged ||
-            event->evtype == XI_PropertyEvent)
-            return;
+        switch (evtype)
+        {
+            case XI_RawKeyPress:
+            case XI_RawKeyRelease:
+            case XI_RawButtonPress:
+            case XI_RawButtonRelease:
+            case XI_RawMotion:
+            case XI_DeviceChanged:
+            case XI_HierarchyChanged:
+            case XI_PropertyEvent:
+                return;
+            default:
+                break;
+        }
 
         event->root = RootWindow(pSprite)->drawable.id;
         event->event = pWin->drawable.id;
commit ffd4874798ba54f86acac75779a15b4babeaa5f3
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Wed May 11 12:20:50 2011 +1000

    include: add version_compare helper function
    
    Compare two version numbers in the major.minor form.
    Switch the few users of manual version switching over to the new function.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Jamey Sharp <jamey at minilop.net>

diff --git a/Xi/xiqueryversion.c b/Xi/xiqueryversion.c
index ae63297..f647f98 100644
--- a/Xi/xiqueryversion.c
+++ b/Xi/xiqueryversion.c
@@ -58,7 +58,6 @@ ProcXIQueryVersion(ClientPtr client)
     xXIQueryVersionReply rep;
     XIClientPtr pXIClient;
     int major, minor;
-    unsigned int sversion, cversion;
 
     REQUEST(xXIQueryVersionReq);
     REQUEST_SIZE_MATCH(xXIQueryVersionReq);
@@ -72,10 +71,8 @@ ProcXIQueryVersion(ClientPtr client)
 
     pXIClient = dixLookupPrivate(&client->devPrivates, XIClientPrivateKey);
 
-    sversion = XIVersion.major_version * 1000 + XIVersion.minor_version;
-    cversion = stuff->major_version * 1000 + stuff->minor_version;
-
-    if (sversion > cversion)
+    if (version_compare(XIVersion.major_version, XIVersion.minor_version,
+                        stuff->major_version, stuff->minor_version) > 0)
     {
         major = stuff->major_version;
         minor = stuff->minor_version;
diff --git a/include/misc.h b/include/misc.h
index 803f5ba..bdcc8cc 100644
--- a/include/misc.h
+++ b/include/misc.h
@@ -223,6 +223,24 @@ pad_to_int32(const int bytes) {
 extern char**
 xstrtokenize(const char *str, const char* separators);
 
+/**
+ * Compare the two version numbers comprising of major.minor.
+ *
+ * @return A value less than 0 if a is less than b, 0 if a is equal to b,
+ * or a value greater than 0
+ */
+static inline int
+version_compare(uint16_t a_major, uint16_t a_minor,
+                uint16_t b_major, uint16_t b_minor)
+{
+    int a, b;
+
+    a = a_major << 16 | a_minor;
+    b = b_major << 16 | b_minor;
+
+    return (a - b);
+}
+
 /* some macros to help swap requests, replies, and events */
 
 #define LengthRestB(stuff) \
diff --git a/randr/rrdispatch.c b/randr/rrdispatch.c
index 2135504..d1c99c2 100644
--- a/randr/rrdispatch.c
+++ b/randr/rrdispatch.c
@@ -28,8 +28,8 @@ RRClientKnowsRates (ClientPtr	pClient)
 {
     rrClientPriv(pClient);
 
-    return (pRRClient->major_version > 1 ||
-	    (pRRClient->major_version == 1 && pRRClient->minor_version >= 1));
+    return version_compare(pRRClient->major_version, pRRClient->minor_version,
+                           1, 1) >= 0;
 }
 
 static int
@@ -47,8 +47,8 @@ ProcRRQueryVersion (ClientPtr client)
     rep.length = 0;
     rep.sequenceNumber = client->sequence;
 
-    if ((stuff->majorVersion * 1000 + stuff->minorVersion) <
-        (SERVER_RANDR_MAJOR_VERSION * 1000 + SERVER_RANDR_MINOR_VERSION))
+    if (version_compare(stuff->majorVersion, stuff->minorVersion,
+                        SERVER_RANDR_MAJOR_VERSION, SERVER_RANDR_MINOR_VERSION) < 0)
     {
 	rep.majorVersion = stuff->majorVersion;
 	rep.minorVersion = stuff->minorVersion;
diff --git a/test/Makefile.am b/test/Makefile.am
index fe9bc1f..b7ee070 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -1,7 +1,7 @@
 if ENABLE_UNIT_TESTS
 if HAVE_LD_WRAP
 SUBDIRS= . xi2
-noinst_PROGRAMS = xkb input xtest list
+noinst_PROGRAMS = xkb input xtest list misc
 check_LTLIBRARIES = libxservertest.la
 
 TESTS=$(noinst_PROGRAMS)
@@ -18,6 +18,7 @@ xkb_LDADD=$(TEST_LDADD)
 input_LDADD=$(TEST_LDADD)
 xtest_LDADD=$(TEST_LDADD)
 list_LDADD=$(TEST_LDADD)
+misc_LDADD=$(TEST_LDADD)
 
 libxservertest_la_LIBADD = \
             $(XSERVER_LIBS) \
diff --git a/test/misc.c b/test/misc.c
new file mode 100644
index 0000000..3d3b1a1
--- /dev/null
+++ b/test/misc.c
@@ -0,0 +1,62 @@
+/**
+ * Copyright © 2011 Red Hat, Inc.
+ *
+ *  Permission is hereby granted, free of charge, to any person obtaining a
+ *  copy of this software and associated documentation files (the "Software"),
+ *  to deal in the Software without restriction, including without limitation
+ *  the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ *  and/or sell copies of the Software, and to permit persons to whom the
+ *  Software is furnished to do so, subject to the following conditions:
+ *
+ *  The above copyright notice and this permission notice (including the next
+ *  paragraph) shall be included in all copies or substantial portions of the
+ *  Software.
+ *
+ *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ *  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ *  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ *  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ *  DEALINGS IN THE SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <stdint.h>
+#include "misc.h"
+
+static void dix_version_compare(void)
+{
+    int rc;
+
+    rc = version_compare(0, 0, 1, 0);
+    assert(rc < 0);
+    rc = version_compare(1, 0, 0, 0);
+    assert(rc > 0);
+    rc = version_compare(0, 0, 0, 0);
+    assert(rc == 0);
+    rc = version_compare(1, 0, 1, 0);
+    assert(rc == 0);
+    rc = version_compare(1, 0, 0, 9);
+    assert(rc > 0);
+    rc = version_compare(0, 9, 1, 0);
+    assert(rc < 0);
+    rc = version_compare(1, 0, 1, 9);
+    assert(rc < 0);
+    rc = version_compare(1, 9, 1, 0);
+    assert(rc > 0);
+    rc = version_compare(2, 0, 1, 9);
+    assert(rc > 0);
+    rc = version_compare(1, 9, 2, 0);
+    assert(rc < 0);
+}
+
+int main(int argc, char** argv)
+{
+    dix_version_compare();
+
+    return 0;
+}
diff --git a/xfixes/xfixes.c b/xfixes/xfixes.c
index e8c7bf1..54f0df3 100644
--- a/xfixes/xfixes.c
+++ b/xfixes/xfixes.c
@@ -72,17 +72,17 @@ ProcXFixesQueryVersion(ClientPtr client)
     rep.type = X_Reply;
     rep.length = 0;
     rep.sequenceNumber = client->sequence;
-    if (stuff->majorVersion < SERVER_XFIXES_MAJOR_VERSION) {
+
+    if (version_compare(stuff->majorVersion, stuff->minorVersion,
+                        SERVER_XFIXES_MAJOR_VERSION, SERVER_XFIXES_MAJOR_VERSION) < 0)
+    {
 	rep.majorVersion = stuff->majorVersion;
 	rep.minorVersion = stuff->minorVersion;
     } else {
 	rep.majorVersion = SERVER_XFIXES_MAJOR_VERSION;
-	if (stuff->majorVersion == SERVER_XFIXES_MAJOR_VERSION &&
-	    stuff->minorVersion < SERVER_XFIXES_MINOR_VERSION)
-	    rep.minorVersion = stuff->minorVersion;
-	else
-	    rep.minorVersion = SERVER_XFIXES_MINOR_VERSION;
+        rep.minorVersion = SERVER_XFIXES_MINOR_VERSION;
     }
+
     pXFixesClient->major_version = rep.majorVersion;
     pXFixesClient->minor_version = rep.minorVersion;
     if (client->swapped) {
commit c4f9c3a07dbb05b81c8e2193a083102f710ebb27
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Wed May 11 11:43:16 2011 +1000

    dix: use a tmp variable instead of multiple rClient(other).
    
    no functional changes.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Jamey Sharp <jamey at minilop.net>

diff --git a/dix/events.c b/dix/events.c
index 30b689a..e67c3a2 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -2064,23 +2064,24 @@ DeliverEventToClients(DeviceIntPtr dev, WindowPtr win, xEvent *events,
     for (; other; other = other->next)
     {
         Mask mask;
+        ClientPtr client = rClient(other);
 
-        if (IsInterferingGrab(rClient(other), dev, events))
+        if (IsInterferingGrab(client, dev, events))
             continue;
 
         mask = GetEventMask(dev, events, other);
 
-        if (XaceHook(XACE_RECEIVE_ACCESS, rClient(other), win,
+        if (XaceHook(XACE_RECEIVE_ACCESS, client, win,
                     events, count))
             /* do nothing */;
-        else if ( (attempt = TryClientEvents(rClient(other), dev,
+        else if ( (attempt = TryClientEvents(client, dev,
                         events, count,
                         mask, filter, grab)) )
         {
             if (attempt > 0)
             {
                 rc = EVENT_DELIVERED;
-                *client_return = rClient(other);
+                *client_return = client;
                 *mask_return = mask;
                 /* Success overrides non-success, so if we've been
                  * successful on one client, return that */
commit dc45d5816dd65168645f0017394eebfc5599d698
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Thu Apr 14 15:59:08 2011 +1000

    Xi: split DeviceStateNotify delivery into a separate function
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Jamey Sharp <jamey at minilop.net>

diff --git a/Xi/exevents.c b/Xi/exevents.c
index d48d397..c6f9d46 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -1189,6 +1189,108 @@ FixDeviceValuator(DeviceIntPtr dev, deviceValuator * ev, ValuatorClassPtr v,
     first += ev->num_valuators;
 }
 
+static void
+DeliverStateNotifyEvent(DeviceIntPtr dev, WindowPtr win)
+{
+    int evcount = 1;
+    deviceStateNotify *ev, *sev;
+    deviceKeyStateNotify *kev;
+    deviceButtonStateNotify *bev;
+
+    KeyClassPtr k;
+    ButtonClassPtr b;
+    ValuatorClassPtr v;
+    int nval = 0, nkeys = 0, nbuttons = 0, first = 0;
+
+    if (!(wOtherInputMasks(win)) ||
+        !(wOtherInputMasks(win)->inputEvents[dev->id] & DeviceStateNotifyMask))
+        return;
+
+    if ((b = dev->button) != NULL) {
+        nbuttons = b->numButtons;
+        if (nbuttons > 32)
+            evcount++;
+    }
+    if ((k = dev->key) != NULL) {
+        nkeys = k->xkbInfo->desc->max_key_code -
+            k->xkbInfo->desc->min_key_code;
+        if (nkeys > 32)
+            evcount++;
+        if (nbuttons > 0) {
+            evcount++;
+        }
+    }
+    if ((v = dev->valuator) != NULL) {
+        nval = v->numAxes;
+
+        if (nval > 3)
+            evcount++;
+        if (nval > 6) {
+            if (!(k && b))
+                evcount++;
+            if (nval > 9)
+                evcount += ((nval - 7) / 3);
+        }
+    }
+
+    sev = ev = (deviceStateNotify *) malloc(evcount * sizeof(xEvent));
+    FixDeviceStateNotify(dev, ev, NULL, NULL, NULL, first);
+
+    if (b != NULL) {
+        FixDeviceStateNotify(dev, ev++, NULL, b, v, first);
+        first += 3;
+        nval -= 3;
+        if (nbuttons > 32) {
+            (ev - 1)->deviceid |= MORE_EVENTS;
+            bev = (deviceButtonStateNotify *) ev++;
+            bev->type = DeviceButtonStateNotify;
+            bev->deviceid = dev->id;
+            memcpy((char*)&bev->buttons[4], (char*)&b->down[4], DOWN_LENGTH - 4);
+        }
+        if (nval > 0) {
+            (ev - 1)->deviceid |= MORE_EVENTS;
+            FixDeviceValuator(dev, (deviceValuator *) ev++, v, first);
+            first += 3;
+            nval -= 3;
+        }
+    }
+
+    if (k != NULL) {
+        FixDeviceStateNotify(dev, ev++, k, NULL, v, first);
+        first += 3;
+        nval -= 3;
+        if (nkeys > 32) {
+            (ev - 1)->deviceid |= MORE_EVENTS;
+            kev = (deviceKeyStateNotify *) ev++;
+            kev->type = DeviceKeyStateNotify;
+            kev->deviceid = dev->id;
+            memmove((char *)&kev->keys[0], (char *)&k->down[4], 28);
+        }
+        if (nval > 0) {
+            (ev - 1)->deviceid |= MORE_EVENTS;
+            FixDeviceValuator(dev, (deviceValuator *) ev++, v, first);
+            first += 3;
+            nval -= 3;
+        }
+    }
+
+    while (nval > 0) {
+        FixDeviceStateNotify(dev, ev++, NULL, NULL, v, first);
+        first += 3;
+        nval -= 3;
+        if (nval > 0) {
+            (ev - 1)->deviceid |= MORE_EVENTS;
+            FixDeviceValuator(dev, (deviceValuator *) ev++, v, first);
+            first += 3;
+            nval -= 3;
+        }
+    }
+
+    DeliverEventsToWindow(dev, win, (xEvent *) sev, evcount,
+                          DeviceStateNotifyMask, NullGrab);
+    free(sev);
+}
+
 void
 DeviceFocusEvent(DeviceIntPtr dev, int type, int mode, int detail,
 		 WindowPtr pWin)
@@ -1255,104 +1357,8 @@ DeviceFocusEvent(DeviceIntPtr dev, int type, int mode, int detail,
     DeliverEventsToWindow(dev, pWin, (xEvent *) & event, 1,
 				DeviceFocusChangeMask, NullGrab);
 
-    if ((event.type == DeviceFocusIn) &&
-	(wOtherInputMasks(pWin)) &&
-	(wOtherInputMasks(pWin)->inputEvents[dev->id] & DeviceStateNotifyMask))
-    {
-	int evcount = 1;
-	deviceStateNotify *ev, *sev;
-	deviceKeyStateNotify *kev;
-	deviceButtonStateNotify *bev;
-
-	KeyClassPtr k;
-	ButtonClassPtr b;
-	ValuatorClassPtr v;
-	int nval = 0, nkeys = 0, nbuttons = 0, first = 0;
-
-	if ((b = dev->button) != NULL) {
-	    nbuttons = b->numButtons;
-	    if (nbuttons > 32)
-		evcount++;
-	}
-	if ((k = dev->key) != NULL) {
-	    nkeys = k->xkbInfo->desc->max_key_code -
-                    k->xkbInfo->desc->min_key_code;
-	    if (nkeys > 32)
-		evcount++;
-	    if (nbuttons > 0) {
-		evcount++;
-	    }
-	}
-	if ((v = dev->valuator) != NULL) {
-	    nval = v->numAxes;
-
-	    if (nval > 3)
-		evcount++;
-	    if (nval > 6) {
-		if (!(k && b))
-		    evcount++;
-		if (nval > 9)
-		    evcount += ((nval - 7) / 3);
-	    }
-	}
-
-	sev = ev = (deviceStateNotify *) malloc(evcount * sizeof(xEvent));
-	FixDeviceStateNotify(dev, ev, NULL, NULL, NULL, first);
-
-	if (b != NULL) {
-	    FixDeviceStateNotify(dev, ev++, NULL, b, v, first);
-	    first += 3;
-	    nval -= 3;
-	    if (nbuttons > 32) {
-		(ev - 1)->deviceid |= MORE_EVENTS;
-		bev = (deviceButtonStateNotify *) ev++;
-		bev->type = DeviceButtonStateNotify;
-		bev->deviceid = dev->id;
-		memcpy((char*)&bev->buttons[4], (char*)&b->down[4], DOWN_LENGTH - 4);
-	    }
-	    if (nval > 0) {
-		(ev - 1)->deviceid |= MORE_EVENTS;
-		FixDeviceValuator(dev, (deviceValuator *) ev++, v, first);
-		first += 3;
-		nval -= 3;
-	    }
-	}
-
-	if (k != NULL) {
-	    FixDeviceStateNotify(dev, ev++, k, NULL, v, first);
-	    first += 3;
-	    nval -= 3;
-	    if (nkeys > 32) {
-		(ev - 1)->deviceid |= MORE_EVENTS;
-		kev = (deviceKeyStateNotify *) ev++;
-		kev->type = DeviceKeyStateNotify;
-		kev->deviceid = dev->id;
-		memmove((char *)&kev->keys[0], (char *)&k->down[4], 28);
-	    }
-	    if (nval > 0) {
-		(ev - 1)->deviceid |= MORE_EVENTS;
-		FixDeviceValuator(dev, (deviceValuator *) ev++, v, first);
-		first += 3;
-		nval -= 3;
-	    }
-	}
-
-	while (nval > 0) {
-	    FixDeviceStateNotify(dev, ev++, NULL, NULL, v, first);
-	    first += 3;
-	    nval -= 3;
-	    if (nval > 0) {
-		(ev - 1)->deviceid |= MORE_EVENTS;
-		FixDeviceValuator(dev, (deviceValuator *) ev++, v, first);
-		first += 3;
-		nval -= 3;
-	    }
-	}
-
-	DeliverEventsToWindow(dev, pWin, (xEvent *) sev, evcount,
-				    DeviceStateNotifyMask, NullGrab);
-	free(sev);
-    }
+    if (event.type == DeviceFocusIn)
+        DeliverStateNotifyEvent(dev, pWin);
 }
 
 int
commit 5bcc22757e6e1f24ee2bfec65f68a5f567300532
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Thu Apr 14 15:43:56 2011 +1000

    dix: return deliveries from DeliverGrabbedEvent
    
    This isn't currently used by any of the callers but it will likely be in the
    future.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Jamey Sharp <jamey at minilop.net>

diff --git a/dix/events.c b/dix/events.c
index aeb37aa..30b689a 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -3884,8 +3884,10 @@ unwind:
  * grab. If not, TryClientEvents() is used.
  *
  * @param deactivateGrab True if the device's grab should be deactivated.
+ *
+ * @return The number of events delivered.
  */
-void
+int
 DeliverGrabbedEvent(InternalEvent *event, DeviceIntPtr thisDev,
                     Bool deactivateGrab)
 {
@@ -4053,6 +4055,8 @@ DeliverGrabbedEvent(InternalEvent *event, DeviceIntPtr thisDev,
     free(core);
     free(xi);
     free(xi2);
+
+    return deliveries;
 }
 
 /* This function is used to set the key pressed or key released state -
diff --git a/include/dix.h b/include/dix.h
index fb9be43..9a111e8 100644
--- a/include/dix.h
+++ b/include/dix.h
@@ -415,7 +415,7 @@ extern void DeliverFocusedEvent(
     InternalEvent* /* event */,
     WindowPtr /* window */);
 
-extern void DeliverGrabbedEvent(
+extern int DeliverGrabbedEvent(
     InternalEvent* /* event */,
     DeviceIntPtr /* thisDev */,
     Bool /* deactivateGrab */);
commit 2054ca73060a20b5a3025e8d5ef68182149484d3
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Thu Apr 14 15:09:39 2011 +1000

    dix: move the grab activation condition into a if block.
    
    Rather than 3 conditions with if (deliveries && ...), have one block with
    the three in them.
    No functional changes.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Jamey Sharp <jamey at minilop.net>

diff --git a/dix/events.c b/dix/events.c
index 77f8715..aeb37aa 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -2173,24 +2173,22 @@ DeliverEventsToWindow(DeviceIntPtr pDev, WindowPtr pWin, xEvent
         }
     }
 
-    /*
-     * Note that since core events are delivered first, an implicit grab may
-     * be activated on a core grab, stopping the XI events.
-     */
-    if (deliveries && !grab && ActivateImplicitGrab(pDev, client, pWin, pEvents, deliveryMask))
-        /* grab activated */;
-    else if ((type == MotionNotify) && deliveries)
-	pDev->valuator->motionHintWindow = pWin;
-    else
-    {
-	if ((type == DeviceMotionNotify || type == DeviceButtonPress) &&
-	    deliveries)
-	    CheckDeviceGrabAndHintWindow (pWin, type,
-					  (deviceKeyButtonPointer*) pEvents,
-					  grab, client, deliveryMask);
-    }
     if (deliveries)
+    {
+        /*
+         * Note that since core events are delivered first, an implicit grab may
+         * be activated on a core grab, stopping the XI events.
+         */
+        if (!grab && ActivateImplicitGrab(pDev, client, pWin, pEvents, deliveryMask))
+            /* grab activated */;
+        else if ((type == MotionNotify))
+            pDev->valuator->motionHintWindow = pWin;
+        else if (type == DeviceMotionNotify || type == DeviceButtonPress)
+                CheckDeviceGrabAndHintWindow (pWin, type,
+                                              (deviceKeyButtonPointer*) pEvents,
+                                              grab, client, deliveryMask);
 	return deliveries;
+    }
     return nondeliveries;
 }
 
commit 236ed6f50675dc0303a505ac6f0418c515438fe1
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Tue Apr 12 14:04:37 2011 +1000

    dix: split out client delivery from DeliverEventsToWindow
    
    No real functional changes, this is just for improved readability.
    
    DeliverEventsToWindow used to return an int to specify the number of
    deliveries (or rejected deliveries if negative). The number wasn't used by
    any caller other than for > 0 comparison.
    
    This patch also changes the return value to be -1 or 1 even in case of
    multiple deliveries/rejections. The comment was updated accordingly.
    
    A future patch should probably use the enum EventDeliveryState for
    DeliverEventsToWindow.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Jamey Sharp <jamey at minilop.net>

diff --git a/dix/events.c b/dix/events.c
index 4e9af8d..77f8715 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -2025,6 +2025,75 @@ DeliverToWindowOwner(DeviceIntPtr dev, WindowPtr win,
 }
 
 /**
+ * Deliver events to clients registered on the window.
+ *
+ * @param client_return On successful delivery, set to the recipient.
+ * @param mask_return On successful delivery, set to the recipient's event
+ * mask for this event.
+ */
+static enum EventDeliveryState
+DeliverEventToClients(DeviceIntPtr dev, WindowPtr win, xEvent *events,
+                      int count, Mask filter, GrabPtr grab,
+                      ClientPtr *client_return, Mask *mask_return)
+{
+    int attempt;
+    enum EventDeliveryState rc = EVENT_SKIP;
+    InputClients *other;
+
+    if (CORE_EVENT(events))
+        other = (InputClients *)wOtherClients(win);
+    else if (XI2_EVENT(events))
+    {
+        OtherInputMasks *inputMasks = wOtherInputMasks(win);
+        /* Has any client selected for the event? */
+        if (!GetWindowXI2Mask(dev, win, events))
+            goto out;
+        other = inputMasks->inputClients;
+    } else {
+        OtherInputMasks *inputMasks = wOtherInputMasks(win);
+        /* Has any client selected for the event? */
+        if (!inputMasks ||
+            !(inputMasks->inputEvents[dev->id] & filter))
+            goto out;
+
+        other = inputMasks->inputClients;
+    }
+
+    rc = EVENT_NOT_DELIVERED;
+
+    for (; other; other = other->next)
+    {
+        Mask mask;
+
+        if (IsInterferingGrab(rClient(other), dev, events))
+            continue;
+
+        mask = GetEventMask(dev, events, other);
+
+        if (XaceHook(XACE_RECEIVE_ACCESS, rClient(other), win,
+                    events, count))
+            /* do nothing */;
+        else if ( (attempt = TryClientEvents(rClient(other), dev,
+                        events, count,
+                        mask, filter, grab)) )
+        {
+            if (attempt > 0)
+            {
+                rc = EVENT_DELIVERED;
+                *client_return = rClient(other);
+                *mask_return = mask;
+                /* Success overrides non-success, so if we've been
+                 * successful on one client, return that */
+            } else if (rc == EVENT_NOT_DELIVERED)
+                rc = EVENT_REJECTED;
+        }
+    }
+
+out:
+    return rc;
+}
+
+/**
  * Deliver events to a window. At this point, we do not yet know if the event
  * actually needs to be delivered. May activate a grab if the event is a
  * button press.
@@ -2042,21 +2111,20 @@ DeliverToWindowOwner(DeviceIntPtr dev, WindowPtr win,
  * @param filter Mask based on event type.
  * @param grab Possible grab on the device that caused the event.
  *
- * @return Number of events delivered to various clients.
+ * @return a positive number if at least one successful delivery has been
+ * made, 0 if no events were delivered, or a negative number if the event
+ * has not been delivered _and_ rejected by at least one client.
  */
 int
 DeliverEventsToWindow(DeviceIntPtr pDev, WindowPtr pWin, xEvent
         *pEvents, int count, Mask filter, GrabPtr grab)
 {
     int deliveries = 0, nondeliveries = 0;
-    int attempt;
-    InputClients *other;
     ClientPtr client = NullClient;
     Mask deliveryMask = 0; /* If a grab occurs due to a button press, then
 		              this mask is the mask of the grab. */
     int type = pEvents->u.u.type;
 
-
     /* Deliver to window owner */
     if ((filter == CantBeFiltered) || CORE_EVENT(pEvents))
     {
@@ -2085,50 +2153,26 @@ DeliverEventsToWindow(DeviceIntPtr pDev, WindowPtr pWin, xEvent
     /* CantBeFiltered means only window owner gets the event */
     if (filter != CantBeFiltered)
     {
-        if (CORE_EVENT(pEvents))
-            other = (InputClients *)wOtherClients(pWin);
-        else if (XI2_EVENT(pEvents))
-        {
-            OtherInputMasks *inputMasks = wOtherInputMasks(pWin);
-            /* Has any client selected for the event? */
-            if (!GetWindowXI2Mask(pDev, pWin, pEvents))
-                return 0;
-            other = inputMasks->inputClients;
-        } else {
-            OtherInputMasks *inputMasks = wOtherInputMasks(pWin);
-            /* Has any client selected for the event? */
-            if (!inputMasks ||
-                !(inputMasks->inputEvents[pDev->id] & filter))
-                return 0;
+        enum EventDeliveryState rc;
 
-            other = inputMasks->inputClients;
-        }
+        rc = DeliverEventToClients(pDev, pWin, pEvents, count, filter, grab,
+                                   &client, &deliveryMask);
 
-        for (; other; other = other->next)
+        switch(rc)
         {
-            Mask mask;
-            if (IsInterferingGrab(rClient(other), pDev, pEvents))
-                continue;
-
-            mask = GetEventMask(pDev, pEvents, other);
-
-            if (XaceHook(XACE_RECEIVE_ACCESS, rClient(other), pWin,
-                        pEvents, count))
-                /* do nothing */;
-            else if ( (attempt = TryClientEvents(rClient(other), pDev,
-                            pEvents, count,
-                            mask, filter, grab)) )
-            {
-                if (attempt > 0)
-                {
-                    deliveries++;
-                    client = rClient(other);
-                    deliveryMask = mask;
-                } else
-                    nondeliveries--;
-            }
+            case EVENT_SKIP:
+                return 0;
+            case EVENT_REJECTED:
+                nondeliveries--;
+                break;
+            case EVENT_DELIVERED:
+                deliveries++;
+                break;
+            case EVENT_NOT_DELIVERED:
+                break;
         }
     }
+
     /*
      * Note that since core events are delivered first, an implicit grab may
      * be activated on a core grab, stopping the XI events.
commit 536ca28f1b0b4d8715a41b8acc5f30364c833f9b
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Tue Apr 12 13:44:30 2011 +1000

    dix: split out window owner event delivery from DeliverEventsToWindow
    
    No functional changes, just for readability.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Jamey Sharp <jamey at minilop.net>

diff --git a/dix/events.c b/dix/events.c
index fb114a7..4e9af8d 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -1987,6 +1987,43 @@ ActivateImplicitGrab(DeviceIntPtr dev, ClientPtr client, WindowPtr win,
     return TRUE;
 }
 
+enum EventDeliveryState {
+    EVENT_DELIVERED,     /**< Event has been delivered to a client  */
+    EVENT_NOT_DELIVERED, /**< Event was not delivered to any client */
+    EVENT_SKIP,          /**< Event can be discarded by the caller  */
+    EVENT_REJECTED,      /**< Event was rejected for delivery to the client */
+};
+
+/**
+ * Attempt event delivery to the client owning the window.
+ */
+static enum EventDeliveryState
+DeliverToWindowOwner(DeviceIntPtr dev, WindowPtr win,
+                     xEvent *events, int count, Mask filter,
+                     GrabPtr grab)
+{
+    /* if nobody ever wants to see this event, skip some work */
+    if (filter != CantBeFiltered &&
+            !((wOtherEventMasks(win)|win->eventMask) & filter))
+        return EVENT_SKIP;
+
+    if (IsInterferingGrab(wClient(win), dev, events))
+        return EVENT_SKIP;
+
+    if (!XaceHook(XACE_RECEIVE_ACCESS, wClient(win), win, events, count))
+    {
+        int attempt = TryClientEvents(wClient(win), dev, events,
+                                      count, win->eventMask,
+                                      filter, grab);
+        if (attempt > 0)
+            return EVENT_DELIVERED;
+        if (attempt < 0)
+            return EVENT_REJECTED;
+    }
+
+    return EVENT_NOT_DELIVERED;
+}
+
 /**
  * Deliver events to a window. At this point, we do not yet know if the event
  * actually needs to be delivered. May activate a grab if the event is a
@@ -2023,28 +2060,26 @@ DeliverEventsToWindow(DeviceIntPtr pDev, WindowPtr pWin, xEvent
     /* Deliver to window owner */
     if ((filter == CantBeFiltered) || CORE_EVENT(pEvents))
     {
-	/* if nobody ever wants to see this event, skip some work */
-	if (filter != CantBeFiltered &&
-	    !((wOtherEventMasks(pWin)|pWin->eventMask) & filter))
-	    return 0;
+        enum EventDeliveryState rc;
 
-        if (IsInterferingGrab(wClient(pWin), pDev, pEvents))
-                return 0;
+        rc = DeliverToWindowOwner(pDev, pWin, pEvents, count, filter, grab);
 
-	if (XaceHook(XACE_RECEIVE_ACCESS, wClient(pWin), pWin, pEvents, count))
-	    /* do nothing */;
-        else if ( (attempt = TryClientEvents(wClient(pWin), pDev, pEvents,
-                                             count, pWin->eventMask,
-                                             filter, grab)) )
-	{
-	    if (attempt > 0)
-	    {
-		deliveries++;
-		client = wClient(pWin);
-		deliveryMask = pWin->eventMask;
-	    } else
-		nondeliveries--;
-	}
+        switch(rc)
+        {
+            case EVENT_SKIP:
+                return 0;
+            case EVENT_REJECTED:
+                nondeliveries--;
+                break;
+            case EVENT_DELIVERED:
+                /* We delivered to the owner, with our event mask */
+                deliveries++;
+                client = wClient(pWin);
+                deliveryMask = pWin->eventMask;
+                break;
+            case EVENT_NOT_DELIVERED:
+                break;
+        }
     }
 
     /* CantBeFiltered means only window owner gets the event */
commit a311a03135f9734aa4f7dc0f2fa0e4c91768343b
Author: Jamey Sharp <jamey at minilop.net>
Date:   Wed May 11 14:08:28 2011 -0700

    dix: split implicit grab activation into a separate function.
    
    I'm not sure I like splitting the check for button-press event from the
    code which makes assumptions about that check. How about replacing
    patches 3 and 4 with this patch instead?
    
    Signed-off-by: Jamey Sharp <jamey at minilop.net>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/dix/events.c b/dix/events.c
index 276bc75..fb114a7 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -1939,6 +1939,54 @@ TryClientEvents (ClientPtr client, DeviceIntPtr dev, xEvent *pEvents,
     return 1;
 }
 
+static BOOL
+ActivateImplicitGrab(DeviceIntPtr dev, ClientPtr client, WindowPtr win,
+                     xEvent *event, Mask deliveryMask)
+{
+    GrabRec tempGrab;
+    OtherInputMasks *inputMasks;
+    CARD8 type = event->u.u.type;
+    GrabType grabtype;
+
+    if (type == ButtonPress)
+        grabtype = GRABTYPE_CORE;
+    else if (type == DeviceButtonPress)
+        grabtype = GRABTYPE_XI;
+    else if (XI2_EVENT(event) && ((xGenericEvent*)event)->evtype == XI_ButtonPress)
+    {
+        type = ((xGenericEvent*)event)->evtype;
+        grabtype = GRABTYPE_XI2;
+    }
+    else
+        return FALSE;
+
+    memset(&tempGrab, 0, sizeof(GrabRec));
+    tempGrab.next = NULL;
+    tempGrab.device = dev;
+    tempGrab.resource = client->clientAsMask;
+    tempGrab.window = win;
+    tempGrab.ownerEvents = (deliveryMask & OwnerGrabButtonMask) ? TRUE : FALSE;
+    tempGrab.eventMask = deliveryMask;
+    tempGrab.keyboardMode = GrabModeAsync;
+    tempGrab.pointerMode = GrabModeAsync;
+    tempGrab.confineTo = NullWindow;
+    tempGrab.cursor = NullCursor;
+    tempGrab.type = type;
+    tempGrab.grabtype = grabtype;
+
+    /* get the XI and XI2 device mask */
+    inputMasks = wOtherInputMasks(win);
+    tempGrab.deviceMask = (inputMasks) ? inputMasks->inputEvents[dev->id]: 0;
+
+    if (inputMasks)
+        memcpy(tempGrab.xi2mask, inputMasks->xi2mask,
+               sizeof(tempGrab.xi2mask));
+
+    (*dev->deviceGrab.ActivateGrab)(dev, &tempGrab,
+                                    currentTime, TRUE | ImplicitGrabMask);
+    return TRUE;
+}
+
 /**
  * Deliver events to a window. At this point, we do not yet know if the event
  * actually needs to be delivered. May activate a grab if the event is a
@@ -2050,47 +2098,8 @@ DeliverEventsToWindow(DeviceIntPtr pDev, WindowPtr pWin, xEvent
      * Note that since core events are delivered first, an implicit grab may
      * be activated on a core grab, stopping the XI events.
      */
-    if ((type == DeviceButtonPress || type == ButtonPress ||
-        ((XI2_EVENT(pEvents) && ((xGenericEvent*)pEvents)->evtype == XI_ButtonPress)))
-            && deliveries
-            && (!grab))
-    {
-	GrabRec tempGrab;
-        OtherInputMasks *inputMasks;
-
-        memset(&tempGrab, 0, sizeof(GrabRec));
-        tempGrab.next = NULL;
-	tempGrab.device = pDev;
-	tempGrab.resource = client->clientAsMask;
-	tempGrab.window = pWin;
-	tempGrab.ownerEvents = (deliveryMask & OwnerGrabButtonMask) ? TRUE : FALSE;
-	tempGrab.eventMask = deliveryMask;
-	tempGrab.keyboardMode = GrabModeAsync;
-	tempGrab.pointerMode = GrabModeAsync;
-	tempGrab.confineTo = NullWindow;
-	tempGrab.cursor = NullCursor;
-        tempGrab.type = type;
-        if (type == ButtonPress)
-            tempGrab.grabtype = GRABTYPE_CORE;
-        else if (type == DeviceButtonPress)
-            tempGrab.grabtype = GRABTYPE_XI;
-        else
-        {
-            tempGrab.type = ((xGenericEvent*)pEvents)->evtype;
-            tempGrab.grabtype = GRABTYPE_XI2;
-        }
-
-        /* get the XI and XI2 device mask */
-        inputMasks = wOtherInputMasks(pWin);
-        tempGrab.deviceMask = (inputMasks) ? inputMasks->inputEvents[pDev->id]: 0;
-
-        if (inputMasks)
-            memcpy(tempGrab.xi2mask, inputMasks->xi2mask,
-                    sizeof(tempGrab.xi2mask));
-
-	(*pDev->deviceGrab.ActivateGrab)(pDev, &tempGrab,
-                                        currentTime, TRUE | ImplicitGrabMask);
-    }
+    if (deliveries && !grab && ActivateImplicitGrab(pDev, client, pWin, pEvents, deliveryMask))
+        /* grab activated */;
     else if ((type == MotionNotify) && deliveries)
 	pDev->valuator->motionHintWindow = pWin;
     else
commit c8674a328c68f03de6e4fad7790a595cdfc18736
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Thu Apr 14 16:45:56 2011 +1000

    dix: replace unneded goto with break.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>

diff --git a/dix/eventconvert.c b/dix/eventconvert.c
index 14731f4..024f2e8 100644
--- a/dix/eventconvert.c
+++ b/dix/eventconvert.c
@@ -156,7 +156,7 @@ EventToCore(InternalEvent *event, xEvent **core_out, int *count_out)
         case ET_RawButtonRelease:
         case ET_RawMotion:
             ret = BadMatch;
-            goto out;
+            break;
         default:
             /* XXX: */
             ErrorF("[dix] EventToCore: Not implemented yet \n");
commit 20fb07f436f7d4a0f330b2067a93a5a4829fccf5
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Fri Apr 15 10:07:10 2011 +1000

    input: remove DDX event list handling
    
    The current approach to event posting required the DDX to request the event
    list (allocated by the DIX) and then pass that list into QueuePointerEvent
    and friends.
    
    Remove this step and use the DIX event list directly. This means that
    QueuePointerEvent is not reentrant but it wasn't before anyway.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/dix/events.c b/dix/events.c
index 895ab40..276bc75 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -5035,8 +5035,7 @@ InitEvents(void)
 	DontPropagateRefCnts[i] = 0;
     }
 
-    InputEventListLen = GetMaximumEventsNum();
-    InputEventList = InitEventList(InputEventListLen);
+    InputEventList = InitEventList(GetMaximumEventsNum());
     if (!InputEventList)
         FatalError("[dix] Failed to allocate input event list.\n");
 }
@@ -5044,8 +5043,7 @@ InitEvents(void)
 void
 CloseDownEvents(void)
 {
-    FreeEventList(InputEventList, InputEventListLen);
-    InputEventListLen = 0;
+    FreeEventList(InputEventList, GetMaximumEventsNum());
     InputEventList = NULL;
 }
 
diff --git a/dix/getevents.c b/dix/getevents.c
index e8c2f45..13789f6 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -68,19 +68,12 @@
 /* Number of motion history events to store. */
 #define MOTION_HISTORY_SIZE 256
 
-/* InputEventList is the storage for input events generated by the
- * DDX. The DDX is expected to call GetEventList() and then pass the list into
- * Get{Pointer|Keyboard}Events.
+/**
+ * InputEventList is the storage for input events generated by
+ * QueuePointerEvents, QueueKeyboardEvents, and QueueProximityEvents.
+ * This list is allocated on startup by the DIX.
  */
 InternalEvent* InputEventList = NULL;
-int InputEventListLen = 0;
-
-int
-GetEventList(InternalEvent** list)
-{
-    *list = InputEventList;
-    return InputEventListLen;
-}
 
 /**
  * Pick some arbitrary size for Xi motion history.
@@ -937,10 +930,10 @@ queueEventList(DeviceIntPtr device, InternalEvent *events, int nevents)
  * Generate internal events representing this keyboard event and enqueue
  * them on the event queue.
  *
- * FIXME: don't require the event list to be passed in.
+ * This function is not reentrant. Disable signals before calling.
+ *
  * FIXME: flags for relative/abs motion?
  *
- * @param events Event list used as temporary storage
  * @param device The device to generate the event for
  * @param type Event type, one of KeyPress or KeyRelease
  * @param keycode Key code of the pressed/released key
@@ -948,13 +941,13 @@ queueEventList(DeviceIntPtr device, InternalEvent *events, int nevents)
  *
  */
 void
-QueueKeyboardEvents(InternalEvent *events, DeviceIntPtr device, int type,
+QueueKeyboardEvents(DeviceIntPtr device, int type,
                     int keycode, const ValuatorMask *mask)
 {
     int nevents;
 
-    nevents = GetKeyboardEvents(events, device, type, keycode, mask);
-    queueEventList(device, events, nevents);
+    nevents = GetKeyboardEvents(InputEventList, device, type, keycode, mask);
+    queueEventList(device, InputEventList, nevents);
 }
 
 /**
@@ -1074,9 +1067,8 @@ transformAbsolute(DeviceIntPtr dev, ValuatorMask *mask, int *x, int *y)
  * Generate internal events representing this pointer event and enqueue them
  * on the event queue.
  *
- * FIXME: don't require the event list to be passed in.
+ * This function is not reentrant. Disable signals before calling.
  *
- * @param events Set of events list used as temporary storage
  * @param device The device to generate the event for
  * @param type Event type, one of ButtonPress, ButtonRelease, MotionNotify
  * @param buttons Button number of the buttons modified. Must be 0 for
@@ -1085,13 +1077,13 @@ transformAbsolute(DeviceIntPtr dev, ValuatorMask *mask, int *x, int *y)
  * @param mask Valuator mask for valuators present for this event.
  */
 void
-QueuePointerEvents(InternalEvent *events, DeviceIntPtr device, int type,
+QueuePointerEvents(DeviceIntPtr device, int type,
                    int buttons, int flags, const ValuatorMask *mask)
 {
     int nevents;
 
-    nevents = GetPointerEvents(events, device, type, buttons, flags, mask);
-    queueEventList(device, events, nevents);
+    nevents = GetPointerEvents(InputEventList, device, type, buttons, flags, mask);
+    queueEventList(device, InputEventList, nevents);
 }
 
 /**
@@ -1252,9 +1244,8 @@ GetPointerEvents(InternalEvent *events, DeviceIntPtr pDev, int type, int buttons
  * Generate internal events representing this proximity event and enqueue
  * them on the event queue.
  *
- * FIXME: don't require the event list to be passed in.
+ * This function is not reentrant. Disable signals before calling.
  *
- * @param events Event list used as temporary storage
  * @param device The device to generate the event for
  * @param type Event type, one of ProximityIn or ProximityOut
  * @param keycode Key code of the pressed/released key
@@ -1262,13 +1253,13 @@ GetPointerEvents(InternalEvent *events, DeviceIntPtr pDev, int type, int buttons
  *
  */
 void
-QueueProximityEvents(InternalEvent *events, DeviceIntPtr device, int type,
+QueueProximityEvents(DeviceIntPtr device, int type,
                      const ValuatorMask *mask)
 {
     int nevents;
 
-    nevents = GetProximityEvents(events, device, type, mask);
-    queueEventList(device, events, nevents);
+    nevents = GetProximityEvents(InputEventList, device, type, mask);
+    queueEventList(device, InputEventList, nevents);
 }
 
 /**
diff --git a/hw/dmx/input/dmxevents.c b/hw/dmx/input/dmxevents.c
index 8aa1b80..41bc4bf 100644
--- a/hw/dmx/input/dmxevents.c
+++ b/hw/dmx/input/dmxevents.c
@@ -177,15 +177,13 @@ static void enqueueMotion(DevicePtr pDev, int x, int y)
     GETDMXLOCALFROMPDEV;
     DeviceIntPtr p = dmxLocal->pDevice;
     int valuators[3];
-    InternalEvent* events;
     int detail = 0;  /* XXX should this be mask of pressed buttons? */
     ValuatorMask mask;
     valuators[0] = x;
     valuators[1] = y;
 
     valuator_mask_set_range(&mask, 0, 2, valuators);
-    GetEventList(&events);
-    QueuePointerEvents(events, p, MotionNotify, detail,
+    QueuePointerEvents(p, MotionNotify, detail,
                        POINTER_ABSOLUTE | POINTER_SCREEN, &mask);
     return;
 }
@@ -290,7 +288,6 @@ static void dmxExtMotion(DMXLocalInputInfoPtr dmxLocal,
     int                    thisX   = 0;
     int                    thisY   = 0;
     int                    count;
-    InternalEvent*         events;
     ValuatorMask           mask;
 
     memset(xE, 0, sizeof(xE));
@@ -372,8 +369,7 @@ static void dmxExtMotion(DMXLocalInputInfoPtr dmxLocal,
     if (block)
         dmxSigioBlock();
     valuator_mask_set_range(&mask, firstAxis, axesCount, v);
-    GetEventList(&events);
-    QueuePointerEvents(events, pDevice, MotionNotify, 0,
+    QueuePointerEvents(pDevice, MotionNotify, 0,
                        POINTER_ABSOLUTE, &mask);
 
     if (block)
@@ -389,7 +385,6 @@ static int dmxTranslateAndEnqueueExtEvent(DMXLocalInputInfoPtr dmxLocal,
     XDeviceMotionEvent     *me     = (XDeviceMotionEvent *)e;
     DeviceIntPtr           pDevice = dmxLocal->pDevice;
     int                    valuators[MAX_VALUATORS];
-    InternalEvent*         events;
     ValuatorMask           mask;
 
     if (!e)
@@ -446,8 +441,7 @@ static int dmxTranslateAndEnqueueExtEvent(DMXLocalInputInfoPtr dmxLocal,
         valuator_mask_set_range(&mask, ke->first_axis, ke->axes_count, valuators);
         if (block)
             dmxSigioBlock();
-        GetEventList(&events);
-        QueueKeyboardEvents(events, pDevice, event, ke->keycode, &mask);
+        QueueKeyboardEvents(pDevice, event, ke->keycode, &mask);
         if (block)
             dmxSigioUnblock();
         break;
@@ -457,8 +451,7 @@ static int dmxTranslateAndEnqueueExtEvent(DMXLocalInputInfoPtr dmxLocal,
         valuator_mask_set_range(&mask, ke->first_axis, ke->axes_count, valuators);
         if (block)
             dmxSigioBlock();
-        GetEventList(&events);
-        QueuePointerEvents(events, pDevice, event, ke->keycode,
+        QueuePointerEvents(pDevice, event, ke->keycode,
                            POINTER_ABSOLUTE, &mask);
         if (block)
             dmxSigioUnblock();
@@ -469,8 +462,7 @@ static int dmxTranslateAndEnqueueExtEvent(DMXLocalInputInfoPtr dmxLocal,
         valuator_mask_set_range(&mask, ke->first_axis, ke->axes_count, valuators);
         if (block)
             dmxSigioBlock();
-        GetEventList(&events);
-        QueueProximityEvents(events, pDevice, event, &mask);
+        QueueProximityEvents(pDevice, event, &mask);
         if (block)
             dmxSigioUnblock();
         break;
@@ -652,7 +644,6 @@ void dmxEnqueue(DevicePtr pDev, int type, int detail, KeySym keySym,
     xEvent xE;
     DeviceIntPtr p = dmxLocal->pDevice;
     int valuators[3];
-    InternalEvent* events;
     ValuatorMask mask;
 
     DMXDBG2("dmxEnqueue: Enqueuing type=%d detail=0x%0x\n", type, detail);
@@ -667,27 +658,24 @@ void dmxEnqueue(DevicePtr pDev, int type, int detail, KeySym keySym,
         if (dmxLocal->sendsCore && dmxLocal != dmxLocalCoreKeyboard)
             xE.u.u.detail = dmxFixup(pDev, detail, keySym);
 
-        GetEventList(&events);
         /*ErrorF("KEY %d  sym %d\n", detail, (int) keySym);*/
-        QueueKeyboardEvents(events, p, type, detail, NULL);
+        QueueKeyboardEvents(p, type, detail, NULL);
         return;
 
     case ButtonPress:
     case ButtonRelease:
         detail = dmxGetButtonMapping(dmxLocal, detail);
         valuator_mask_zero(&mask);
-        GetEventList(&events);
-        QueuePointerEvents(events, p, type, detail,
+        QueuePointerEvents(p, type, detail,
                            POINTER_ABSOLUTE | POINTER_SCREEN, &mask);
         return;
 
     case MotionNotify:
-        GetEventList(&events);
         valuators[0] = e->xmotion.x;
         valuators[1] = e->xmotion.y;
         valuators[2] = e->xmotion.state; /* FIXME: WTF?? */
         valuator_mask_set_range(&mask, 0, 3, valuators);
-        QueuePointerEvents(events, p, type, detail,
+        QueuePointerEvents(p, type, detail,
                            POINTER_ABSOLUTE | POINTER_SCREEN, &mask);
         return;
 
diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c
index 62e8f78..cdf55d7 100644
--- a/hw/kdrive/src/kinput.c
+++ b/hw/kdrive/src/kinput.c
@@ -66,8 +66,6 @@ static struct KdConfigDevice *kdConfigPointers    = NULL;
 static KdKeyboardDriver *kdKeyboardDrivers = NULL;
 static KdPointerDriver  *kdPointerDrivers  = NULL;
 
-static InternalEvent*   kdEvents = NULL;
-
 static Bool		kdInputEnabled;
 static Bool		kdOffScreen;
 static unsigned long	kdOffScreenTime;
@@ -1803,8 +1801,7 @@ KdReleaseAllKeys (void)
              key++) {
             if (key_is_down(ki->dixdev, key, KEY_POSTED | KEY_PROCESSED)) {
                 KdHandleKeyboardEvent(ki, KeyRelease, key);
-                GetEventList(&kdEvents);
-                QueueGetKeyboardEvents(kdEvents, ki->dixdev, KeyRelease, key, NULL);
+                QueueGetKeyboardEvents(ki->dixdev, KeyRelease, key, NULL);
             }
         }
     }
@@ -1860,8 +1857,7 @@ KdEnqueueKeyboardEvent(KdKeyboardInfo   *ki,
 	else
 	    type = KeyPress;
 
-        GetEventList(&kdEvents);
-        QueueKeyboardEvents(kdEvents, ki->dixdev, type, key_code, NULL);
+        QueueKeyboardEvents(ki->dixdev, type, key_code, NULL);
     }
     else {
         ErrorF("driver %s wanted to post scancode %d outside of [%d, %d]!\n",
@@ -1969,8 +1965,7 @@ _KdEnqueuePointerEvent (KdPointerInfo *pi, int type, int x, int y, int z,
 
     valuator_mask_set_range(&mask, 0, 3, valuators);
 
-    GetEventList(&kdEvents);
-    QueuePointerEvents(kdEvents, pi->dixdev, type, b, absrel, &mask);
+    QueuePointerEvents(pi->dixdev, type, b, absrel, &mask);
 }
 
 void
diff --git a/hw/xfree86/common/xf86Events.c b/hw/xfree86/common/xf86Events.c
index 6402d72..c4a4db9 100644
--- a/hw/xfree86/common/xf86Events.c
+++ b/hw/xfree86/common/xf86Events.c
@@ -399,7 +399,7 @@ xf86ReleaseKeys(DeviceIntPtr pDev)
          i++) {
         if (key_is_down(pDev, i, KEY_POSTED)) {
             sigstate = xf86BlockSIGIO ();
-            QueueKeyboardEvents(xf86Events, pDev, KeyRelease, i, NULL);
+            QueueKeyboardEvents(pDev, KeyRelease, i, NULL);
             xf86UnblockSIGIO(sigstate);
         }
     }
diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
index 0b36163..53f763a 100644
--- a/hw/xfree86/common/xf86Init.c
+++ b/hw/xfree86/common/xf86Init.c
@@ -806,8 +806,6 @@ InitInput(int argc, char **argv)
 
     mieqInit();
 
-    GetEventList(&xf86Events);
-
     /* Initialize all configured input devices */
     for (pDev = xf86ConfigLayout.inputs; pDev && *pDev; pDev++) {
         /* Replace obsolete keyboard driver with kbd */
diff --git a/hw/xfree86/common/xf86Priv.h b/hw/xfree86/common/xf86Priv.h
index 015e12c..5d91ab3 100644
--- a/hw/xfree86/common/xf86Priv.h
+++ b/hw/xfree86/common/xf86Priv.h
@@ -148,9 +148,6 @@ extern _X_EXPORT int xf86SetVerbosity(int verb);
 extern _X_EXPORT int xf86SetLogVerbosity(int verb);
 extern _X_EXPORT Bool xf86CallDriverProbe( struct _DriverRec * drv, Bool detect_only );
 
-/* xf86Xinput.c */
-extern _X_EXPORT InternalEvent *xf86Events;
-
 #endif /* _NO_XF86_PROTOTYPES */
 
 
diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index 9827661..e7e1ce1 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -99,8 +99,6 @@
 		return;								\
 	}
 
-InternalEvent* xf86Events = NULL;
-
 static int
 xf86InputDevicePostInit(DeviceIntPtr dev);
 
@@ -1049,7 +1047,7 @@ xf86PostMotionEventM(DeviceIntPtr	device,
         }
 #endif
 
-    QueuePointerEvents(xf86Events, device, MotionNotify, 0, flags, mask);
+    QueuePointerEvents(device, MotionNotify, 0, flags, mask);
 }
 
 void
@@ -1094,8 +1092,7 @@ xf86PostProximityEventM(DeviceIntPtr	device,
                         int		is_in,
                         const ValuatorMask *mask)
 {
-    QueueProximityEvents(xf86Events, device,
-                         is_in ? ProximityIn : ProximityOut, mask);
+    QueueProximityEvents(device, is_in ? ProximityIn : ProximityOut, mask);
 }
 
 void
@@ -1166,7 +1163,7 @@ xf86PostButtonEventM(DeviceIntPtr	device,
     }
 #endif
 
-    QueuePointerEvents(xf86Events, device,
+    QueuePointerEvents(device,
                        is_down ? ButtonPress : ButtonRelease, button,
                        flags, mask);
 }
@@ -1233,7 +1230,7 @@ xf86PostKeyEventM(DeviceIntPtr	device,
     }
 #endif
 
-    QueueKeyboardEvents(xf86Events, device,
+    QueueKeyboardEvents(device,
                         is_down ? KeyPress : KeyRelease,
                         key_code, mask);
 }
diff --git a/hw/xnest/Events.c b/hw/xnest/Events.c
index bbd70bf..619427d 100644
--- a/hw/xnest/Events.c
+++ b/hw/xnest/Events.c
@@ -43,8 +43,6 @@ is" without express or implied warranty.
 
 CARD32 lastEventTime = 0;
 
-extern InternalEvent *xnestEvents;
-
 void
 ProcessInputEvents(void)
 {
@@ -104,9 +102,8 @@ xnestCollectExposures(void)
 void
 xnestQueueKeyEvent(int type, unsigned int keycode)
 {
-  GetEventList(&xnestEvents);
   lastEventTime = GetTimeInMillis();
-  QueueKeyboardEvents(xnestEvents, xnestKeyboardDevice, type, keycode, NULL);
+  QueueKeyboardEvents(xnestKeyboardDevice, type, keycode, NULL);
 }
 
 void
@@ -116,7 +113,6 @@ xnestCollectEvents(void)
   int valuators[2];
   ValuatorMask mask;
   ScreenPtr pScreen;
-  GetEventList(&xnestEvents);
 
   while (XCheckIfEvent(xnestDisplay, &X, xnestNotExposurePredicate, NULL)) {
     switch (X.type) {
@@ -134,7 +130,7 @@ xnestCollectEvents(void)
       valuator_mask_set_range(&mask, 0, 0, NULL);
       xnestUpdateModifierState(X.xkey.state);
       lastEventTime = GetTimeInMillis();
-      QueuePointerEvents(xnestEvents, xnestPointerDevice, ButtonPress,
+      QueuePointerEvents(xnestPointerDevice, ButtonPress,
                          X.xbutton.button, POINTER_RELATIVE, &mask);
       break;
       
@@ -142,7 +138,7 @@ xnestCollectEvents(void)
       valuator_mask_set_range(&mask, 0, 0, NULL);
       xnestUpdateModifierState(X.xkey.state);
       lastEventTime = GetTimeInMillis();
-      QueuePointerEvents(xnestEvents, xnestPointerDevice, ButtonRelease,
+      QueuePointerEvents(xnestPointerDevice, ButtonRelease,
                          X.xbutton.button, POINTER_RELATIVE, &mask);
       break;
       
@@ -151,7 +147,7 @@ xnestCollectEvents(void)
       valuators[1] = X.xmotion.y;
       valuator_mask_set_range(&mask, 0, 2, valuators);
       lastEventTime = GetTimeInMillis();
-      QueuePointerEvents(xnestEvents, xnestPointerDevice, MotionNotify,
+      QueuePointerEvents(xnestPointerDevice, MotionNotify,
                          0, POINTER_ABSOLUTE, &mask);
       break;
       
@@ -183,7 +179,7 @@ xnestCollectEvents(void)
           valuators[1] = X.xcrossing.y;
           valuator_mask_set_range(&mask, 0, 2, valuators);
           lastEventTime = GetTimeInMillis();
-          QueuePointerEvents(xnestEvents, xnestPointerDevice, MotionNotify,
+          QueuePointerEvents(xnestPointerDevice, MotionNotify,
                              0, POINTER_ABSOLUTE, &mask);
 	  xnestDirectInstallColormaps(pScreen);
 	}
diff --git a/hw/xnest/Init.c b/hw/xnest/Init.c
index f8637f2..ee74101 100644
--- a/hw/xnest/Init.c
+++ b/hw/xnest/Init.c
@@ -45,8 +45,6 @@ is" without express or implied warranty.
 
 Bool xnestDoFullGeneration = True;
 
-InternalEvent *xnestEvents = NULL;
-
 void
 InitOutput(ScreenInfo *screenInfo, int argc, char *argv[])
 {
@@ -100,8 +98,6 @@ InitInput(int argc, char *argv[])
   if (rc != Success)
       FatalError("Failed to init Xnest default devices.\n");
 
-  GetEventList(&xnestEvents);
-
   mieqInit();
 
   AddEnabledDevice(XConnectionNumber(xnestDisplay));
diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c
index 6736e3d..fe744b7 100644
--- a/hw/xquartz/darwinEvents.c
+++ b/hw/xquartz/darwinEvents.c
@@ -485,8 +485,7 @@ void DarwinSendPointerEvents(DeviceIntPtr pDev, int ev_type, int ev_button, floa
     darwinEvents_lock(); {
         ValuatorMask mask;
         valuator_mask_set_range(&mask, 0, (pDev == darwinPointer) ? 2 : 5, valuators);
-        QueuePointerEvents(darwinEvents, pDev, ev_type, ev_button,
-                           POINTER_ABSOLUTE, &mask);
+        QueuePointerEvents(pDev, ev_type, ev_button, POINTER_ABSOLUTE, &mask);
         DarwinPokeEQ();
     } darwinEvents_unlock();
 }
@@ -499,7 +498,7 @@ void DarwinSendKeyboardEvents(int ev_type, int keycode) {
 	}
 
     darwinEvents_lock(); {
-        QueueKeyboardEvents(darwinEvents, darwinKeyboard, ev_type, keycode + MIN_KEYCODE, NULL);
+        QueueKeyboardEvents(darwinKeyboard, ev_type, keycode + MIN_KEYCODE, NULL);
         DarwinPokeEQ();
     } darwinEvents_unlock();
 }
@@ -526,7 +525,7 @@ void DarwinSendProximityEvents(DeviceIntPtr pDev, int ev_type, float pointer_x,
     darwinEvents_lock(); {
         ValuatorMask mask;
         valuator_mask_set_range(&mask, 0, 5, valuators);
-        QueueProximityEvents(darwinEvents, pDev, ev_type, &mask);
+        QueueProximityEvents(pDev, ev_type, &mask);
         DarwinPokeEQ();
     } darwinEvents_unlock();
 }
diff --git a/hw/xwin/winkeybd.c b/hw/xwin/winkeybd.c
index 8b6be02..2fa6b3f 100644
--- a/hw/xwin/winkeybd.c
+++ b/hw/xwin/winkeybd.c
@@ -483,8 +483,7 @@ winSendKeyEvent (DWORD dwKey, Bool fDown)
   /* Update the keyState map */
   g_winKeyState[dwKey] = fDown;
 
-  GetEventList(&events);
-  QueueKeyboardEvents(events, g_pwinKeyboard, fDown ? KeyPress : KeyRelease, dwKey + MIN_KEYCODE, NULL);
+  QueueKeyboardEvents(g_pwinKeyboard, fDown ? KeyPress : KeyRelease, dwKey + MIN_KEYCODE, NULL);
 
   winDebug("winSendKeyEvent: dwKey: %d, fDown: %d, nEvents %d\n",
            dwKey, fDown, nevents);
diff --git a/hw/xwin/winmouse.c b/hw/xwin/winmouse.c
index aaa4d4b..b1b0657 100644
--- a/hw/xwin/winmouse.c
+++ b/hw/xwin/winmouse.c
@@ -234,15 +234,13 @@ winMouseWheel (ScreenPtr pScreen, int iDeltaZ)
 void
 winMouseButtonsSendEvent (int iEventType, int iButton)
 {
-  InternalEvent* events;
   ValuatorMask mask;
 
   if (g_winMouseButtonMap)
     iButton = g_winMouseButtonMap[iButton];
 
   valuator_mask_zero(&mask);
-  GetEventList(&events);
-  QueuePointerEvents(events, g_pwinPointer, iEventType, iButton,
+  QueuePointerEvents(g_pwinPointer, iEventType, iButton,
 		     POINTER_RELATIVE, &mask);
 
 #if CYGDEBUG
@@ -365,15 +363,13 @@ void winEnqueueMotion(int x, int y)
 {
   int valuators[2];
   ValuatorMask mask;
-  InternalEvent* events;
 
   miPointerSetPosition(g_pwinPointer, POINTER_RELATIVE, &x, &y);
   valuators[0] = x;
   valuators[1] = y;
 
   valuator_mask_set_range(&mask, 0, 2, valuators);
-  GetEventList(&events);
-  QueuePointerEvents(events, g_pwinPointer, MotionNotify, 0,
+  QueuePointerEvents(g_pwinPointer, MotionNotify, 0,
 		     POINTER_ABSOLUTE | POINTER_SCREEN, &mask);
 
 }
diff --git a/include/input.h b/include/input.h
index 3c7740d..4de4ff5 100644
--- a/include/input.h
+++ b/include/input.h
@@ -111,7 +111,6 @@ typedef struct _ValuatorMask ValuatorMask;
 
 /* The DIX stores incoming input events in this list */
 extern InternalEvent* InputEventList;
-extern int InputEventListLen;
 
 typedef int (*DeviceProc)(
     DeviceIntPtr /*device*/,
@@ -429,7 +428,6 @@ extern _X_EXPORT void CloseInput(void);
 
 extern _X_EXPORT int GetMaximumEventsNum(void);
 
-extern _X_EXPORT int GetEventList(InternalEvent** list);
 extern _X_EXPORT InternalEvent *InitEventList(int num_events);
 extern _X_EXPORT void FreeEventList(InternalEvent *list, int num_events);
 
@@ -452,7 +450,6 @@ extern _X_EXPORT int GetPointerEvents(
     const ValuatorMask *mask);
 
 extern _X_EXPORT void QueuePointerEvents(
-    InternalEvent *events,
     DeviceIntPtr pDev,
     int type,
     int buttons,
@@ -467,7 +464,6 @@ extern _X_EXPORT int GetKeyboardEvents(
     const ValuatorMask *mask);
 
 extern _X_EXPORT void QueueKeyboardEvents(
-    InternalEvent *events,
     DeviceIntPtr pDev,
     int type,
     int key_code,
@@ -480,7 +476,6 @@ extern int GetProximityEvents(
     const ValuatorMask *mask);
 
 extern void QueueProximityEvents(
-    InternalEvent *events,
     DeviceIntPtr pDev,
     int type,
     const ValuatorMask *mask);
commit 8670c46bdfdade64e63119d2ebbd5ef63b6fa2c3
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Thu Apr 14 22:05:41 2011 +1000

    input: replace EventListPtr with InternalEvent array
    
    EventListPtr is a relic from pre-1.6, when we had protocol events in the
    event queue and thus events of varying size.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/Xext/xtest.c b/Xext/xtest.c
index 18e1ef7..daa6430 100644
--- a/Xext/xtest.c
+++ b/Xext/xtest.c
@@ -52,6 +52,7 @@
 #include "mipointer.h"
 #include "xserver-properties.h"
 #include "exevents.h"
+#include "eventstr.h"
 #include "inpututils.h"
 
 #include "modinit.h"
@@ -61,7 +62,7 @@ extern int DeviceValuator;
 /* XTest events are sent during request processing and may be interruped by
  * a SIGIO. We need a separate event list to avoid events overwriting each
  * other's memory */
-static EventListPtr xtest_evlist;
+static InternalEvent* xtest_evlist;
 
 /**
  * xtestpointer
@@ -428,7 +429,7 @@ ProcXTestFakeInput(ClientPtr client)
     }
 
     for (i = 0; i < nevents; i++)
-        mieqProcessDeviceEvent(dev, (InternalEvent*)(xtest_evlist+i)->event, NULL);
+        mieqProcessDeviceEvent(dev, &xtest_evlist[i], NULL);
 
     if (need_ptr_update)
         miPointerUpdateSprite(dev);
diff --git a/dix/devices.c b/dix/devices.c
index 7968c73..9a4498b 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -2368,7 +2368,7 @@ RecalculateMasterButtons(DeviceIntPtr slave)
 void
 ReleaseButtonsAndKeys(DeviceIntPtr dev)
 {
-    EventListPtr        eventlist = InitEventList(GetMaximumEventsNum());
+    InternalEvent*      eventlist = InitEventList(GetMaximumEventsNum());
     ButtonClassPtr      b = dev->button;
     KeyClassPtr         k = dev->key;
     int                 i, j, nevents;
@@ -2383,7 +2383,7 @@ ReleaseButtonsAndKeys(DeviceIntPtr dev)
         {
             nevents = GetPointerEvents(eventlist, dev, ButtonRelease, i, 0, NULL);
             for (j = 0; j < nevents; j++)
-                mieqProcessDeviceEvent(dev, (InternalEvent*)(eventlist+j)->event, NULL);
+                mieqProcessDeviceEvent(dev, &eventlist[j], NULL);
         }
     }
 
@@ -2394,7 +2394,7 @@ ReleaseButtonsAndKeys(DeviceIntPtr dev)
         {
             nevents = GetKeyboardEvents(eventlist, dev, KeyRelease, i, NULL);
             for (j = 0; j < nevents; j++)
-                mieqProcessDeviceEvent(dev, (InternalEvent*)(eventlist+j)->event, NULL);
+                mieqProcessDeviceEvent(dev, &eventlist[j], NULL);
         }
     }
 
diff --git a/dix/getevents.c b/dix/getevents.c
index 68a5224..e8c2f45 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -68,15 +68,15 @@
 /* Number of motion history events to store. */
 #define MOTION_HISTORY_SIZE 256
 
-/* InputEventList is the container list for all input events generated by the
+/* InputEventList is the storage for input events generated by the
  * DDX. The DDX is expected to call GetEventList() and then pass the list into
  * Get{Pointer|Keyboard}Events.
  */
-EventListPtr InputEventList = NULL;
+InternalEvent* InputEventList = NULL;
 int InputEventListLen = 0;
 
 int
-GetEventList(EventListPtr* list)
+GetEventList(InternalEvent** list)
 {
     *list = InputEventList;
     return InputEventListLen;
@@ -224,7 +224,7 @@ set_valuators(DeviceIntPtr dev, DeviceEvent* event, ValuatorMask *mask)
 }
 
 void
-CreateClassesChangedEvent(EventList* event,
+CreateClassesChangedEvent(InternalEvent* event,
                           DeviceIntPtr master,
                           DeviceIntPtr slave,
                           int type)
@@ -233,7 +233,7 @@ CreateClassesChangedEvent(EventList* event,
     DeviceChangedEvent *dce;
     CARD32 ms = GetTimeInMillis();
 
-    dce = (DeviceChangedEvent*)event->event;
+    dce = &event->changed_event;
     memset(dce, 0, sizeof(DeviceChangedEvent));
     dce->deviceid = slave->id;
     dce->masterid = master->id;
@@ -677,15 +677,15 @@ clipValuators(DeviceIntPtr pDev, ValuatorMask *mask)
  * is done in the event processing).
  * Pull in the coordinates from the MD if necessary.
  *
- * @param events Pointer to a pre-allocated event list.
+ * @param events Pointer to a pre-allocated event array.
  * @param dev The slave device that generated an event.
  * @param type Either DEVCHANGE_POINTER_EVENT and/or DEVCHANGE_KEYBOARD_EVENT
  * @param num_events The current number of events, returns the number of
  *        events if a DCCE was generated.
  * @return The updated @events pointer.
  */
-EventListPtr
-UpdateFromMaster(EventListPtr events, DeviceIntPtr dev, int type, int *num_events)
+InternalEvent*
+UpdateFromMaster(InternalEvent* events, DeviceIntPtr dev, int type, int *num_events)
 {
     DeviceIntPtr master;
 
@@ -926,12 +926,11 @@ updateHistory(DeviceIntPtr dev, ValuatorMask *mask, CARD32 ms)
 }
 
 static void
-queueEventList(DeviceIntPtr device, EventList *events, int nevents)
+queueEventList(DeviceIntPtr device, InternalEvent *events, int nevents)
 {
     int i;
-
     for (i = 0; i < nevents; i++)
-        mieqEnqueue(device, (InternalEvent*)((events + i)->event));
+        mieqEnqueue(device, &events[i]);
 }
 
 /**
@@ -949,7 +948,7 @@ queueEventList(DeviceIntPtr device, EventList *events, int nevents)
  *
  */
 void
-QueueKeyboardEvents(EventList *events, DeviceIntPtr device, int type,
+QueueKeyboardEvents(InternalEvent *events, DeviceIntPtr device, int type,
                     int keycode, const ValuatorMask *mask)
 {
     int nevents;
@@ -962,12 +961,13 @@ QueueKeyboardEvents(EventList *events, DeviceIntPtr device, int type,
  * Returns a set of InternalEvents for KeyPress/KeyRelease, optionally
  * also with valuator events.
  *
- * events is not NULL-terminated; the return value is the number of events.
- * The DDX is responsible for allocating the event structure in the first
- * place via GetMaximumEventsNum(), and for freeing it.
+ * The DDX is responsible for allocating the event list in the first
+ * place via InitEventList(), and for freeing it.
+ *
+ * @return the number of events written into events.
  */
 int
-GetKeyboardEvents(EventList *events, DeviceIntPtr pDev, int type,
+GetKeyboardEvents(InternalEvent *events, DeviceIntPtr pDev, int type,
                   int key_code, const ValuatorMask *mask_in) {
     int num_events = 0;
     CARD32 ms = 0;
@@ -1000,7 +1000,7 @@ GetKeyboardEvents(EventList *events, DeviceIntPtr pDev, int type,
 
     ms = GetTimeInMillis();
 
-    raw = (RawDeviceEvent*)events->event;
+    raw = &events->raw_event;
     events++;
     num_events++;
 
@@ -1013,7 +1013,7 @@ GetKeyboardEvents(EventList *events, DeviceIntPtr pDev, int type,
 
     set_raw_valuators(raw, &mask, raw->valuators.data);
 
-    event = (DeviceEvent*) events->event;
+    event = &events->device_event;
     init_event(pDev, event, ms);
     event->detail.key = key_code;
 
@@ -1034,37 +1034,16 @@ GetKeyboardEvents(EventList *events, DeviceIntPtr pDev, int type,
 }
 
 /**
- * Initialize an event list and fill with 32 byte sized events.
+ * Initialize an event array large enough for num_events arrays.
  * This event list is to be passed into GetPointerEvents() and
  * GetKeyboardEvents().
  *
  * @param num_events Number of elements in list.
  */
-EventListPtr
+InternalEvent*
 InitEventList(int num_events)
 {
-    EventListPtr events;
-    int i;
-
-    events = (EventListPtr)calloc(num_events, sizeof(EventList));
-    if (!events)
-        return NULL;
-
-    for (i = 0; i < num_events; i++)
-    {
-        events[i].evlen = sizeof(InternalEvent);
-        events[i].event = calloc(1, sizeof(InternalEvent));
-        if (!events[i].event)
-        {
-            /* rollback */
-            while(i--)
-                free(events[i].event);
-            free(events);
-            events = NULL;
-            break;
-        }
-    }
-
+    InternalEvent *events = calloc(num_events, sizeof(InternalEvent));
     return events;
 }
 
@@ -1075,12 +1054,8 @@ InitEventList(int num_events)
  * @param num_events Number of elements in list.
  */
 void
-FreeEventList(EventListPtr list, int num_events)
+FreeEventList(InternalEvent *list, int num_events)
 {
-    if (!list)
-        return;
-    while(num_events--)
-        free(list[num_events].event);
     free(list);
 }
 
@@ -1101,7 +1076,7 @@ transformAbsolute(DeviceIntPtr dev, ValuatorMask *mask, int *x, int *y)
  *
  * FIXME: don't require the event list to be passed in.
  *
- * @param events Event list used as temporary storage
+ * @param events Set of events list used as temporary storage
  * @param device The device to generate the event for
  * @param type Event type, one of ButtonPress, ButtonRelease, MotionNotify
  * @param buttons Button number of the buttons modified. Must be 0 for
@@ -1110,7 +1085,7 @@ transformAbsolute(DeviceIntPtr dev, ValuatorMask *mask, int *x, int *y)
  * @param mask Valuator mask for valuators present for this event.
  */
 void
-QueuePointerEvents(EventList *events, DeviceIntPtr device, int type,
+QueuePointerEvents(InternalEvent *events, DeviceIntPtr device, int type,
                    int buttons, int flags, const ValuatorMask *mask)
 {
     int nevents;
@@ -1120,11 +1095,10 @@ QueuePointerEvents(EventList *events, DeviceIntPtr device, int type,
 }
 
 /**
- * Generate a series of InternalEvents (filled into the EventList)
- * representing pointer motion, or button presses.
+ * Generate a series of InternalEvents representing pointer motion, or
+ * button presses.
  *
- * events is not NULL-terminated; the return value is the number of events.
- * The DDX is responsible for allocating the event structure in the first
+ * The DDX is responsible for allocating the events in the first
  * place via InitEventList() and GetMaximumEventsNum(), and for freeing it.
  *
  * In the generated events rootX/Y will be in absolute screen coords and
@@ -1134,9 +1108,11 @@ QueuePointerEvents(EventList *events, DeviceIntPtr device, int type,
  * last.valuators[x] of the master device is in absolute screen coords.
  *
  * master->last.valuators[x] for x > 2 is undefined.
+ *
+ * @return the number of events written into events.
  */
 int
-GetPointerEvents(EventList *events, DeviceIntPtr pDev, int type, int buttons,
+GetPointerEvents(InternalEvent *events, DeviceIntPtr pDev, int type, int buttons,
                  int flags, const ValuatorMask *mask_in) {
     int num_events = 1;
     CARD32 ms;
@@ -1174,7 +1150,7 @@ GetPointerEvents(EventList *events, DeviceIntPtr pDev, int type, int buttons,
 
     events = UpdateFromMaster(events, pDev, DEVCHANGE_POINTER_EVENT, &num_events);
 
-    raw = (RawDeviceEvent*)events->event;
+    raw = &events->raw_event;
     events++;
     num_events++;
 
@@ -1243,7 +1219,7 @@ GetPointerEvents(EventList *events, DeviceIntPtr pDev, int type, int buttons,
 
     clipValuators(pDev, &mask);
 
-    event = (DeviceEvent*) events->event;
+    event = &events->device_event;
     init_event(pDev, event, ms);
 
     if (type == MotionNotify) {
@@ -1286,7 +1262,7 @@ GetPointerEvents(EventList *events, DeviceIntPtr pDev, int type, int buttons,
  *
  */
 void
-QueueProximityEvents(EventList *events, DeviceIntPtr device, int type,
+QueueProximityEvents(InternalEvent *events, DeviceIntPtr device, int type,
                      const ValuatorMask *mask)
 {
     int nevents;
@@ -1299,12 +1275,13 @@ QueueProximityEvents(EventList *events, DeviceIntPtr device, int type,
  * Generate ProximityIn/ProximityOut InternalEvents, accompanied by
  * valuators.
  *
- * events is not NULL-terminated; the return value is the number of events.
- * The DDX is responsible for allocating the event structure in the first
- * place via GetMaximumEventsNum(), and for freeing it.
+ * The DDX is responsible for allocating the events in the first place via
+ * InitEventList(), and for freeing it.
+ *
+ * @return the number of events written into events.
  */
 int
-GetProximityEvents(EventList *events, DeviceIntPtr pDev, int type, const ValuatorMask *mask_in)
+GetProximityEvents(InternalEvent *events, DeviceIntPtr pDev, int type, const ValuatorMask *mask_in)
 {
     int num_events = 1, i;
     DeviceEvent *event;
@@ -1336,7 +1313,7 @@ GetProximityEvents(EventList *events, DeviceIntPtr pDev, int type, const Valuato
 
     events = UpdateFromMaster(events, pDev, DEVCHANGE_POINTER_EVENT, &num_events);
 
-    event = (DeviceEvent *) events->event;
+    event = &events->device_event;
     init_event(pDev, event, GetTimeInMillis());
     event->type = (type == ProximityIn) ? ET_ProximityIn : ET_ProximityOut;
 
diff --git a/hw/dmx/input/dmxevents.c b/hw/dmx/input/dmxevents.c
index 3f9035c..8aa1b80 100644
--- a/hw/dmx/input/dmxevents.c
+++ b/hw/dmx/input/dmxevents.c
@@ -177,7 +177,7 @@ static void enqueueMotion(DevicePtr pDev, int x, int y)
     GETDMXLOCALFROMPDEV;
     DeviceIntPtr p = dmxLocal->pDevice;
     int valuators[3];
-    EventListPtr events;
+    InternalEvent* events;
     int detail = 0;  /* XXX should this be mask of pressed buttons? */
     ValuatorMask mask;
     valuators[0] = x;
@@ -290,7 +290,7 @@ static void dmxExtMotion(DMXLocalInputInfoPtr dmxLocal,
     int                    thisX   = 0;
     int                    thisY   = 0;
     int                    count;
-    EventListPtr           events;
+    InternalEvent*         events;
     ValuatorMask           mask;
 
     memset(xE, 0, sizeof(xE));
@@ -389,7 +389,7 @@ static int dmxTranslateAndEnqueueExtEvent(DMXLocalInputInfoPtr dmxLocal,
     XDeviceMotionEvent     *me     = (XDeviceMotionEvent *)e;
     DeviceIntPtr           pDevice = dmxLocal->pDevice;
     int                    valuators[MAX_VALUATORS];
-    EventListPtr           events;
+    InternalEvent*         events;
     ValuatorMask           mask;
 
     if (!e)
@@ -652,7 +652,7 @@ void dmxEnqueue(DevicePtr pDev, int type, int detail, KeySym keySym,
     xEvent xE;
     DeviceIntPtr p = dmxLocal->pDevice;
     int valuators[3];
-    EventListPtr events;
+    InternalEvent* events;
     ValuatorMask mask;
 
     DMXDBG2("dmxEnqueue: Enqueuing type=%d detail=0x%0x\n", type, detail);
diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c
index 521542c..62e8f78 100644
--- a/hw/kdrive/src/kinput.c
+++ b/hw/kdrive/src/kinput.c
@@ -66,7 +66,7 @@ static struct KdConfigDevice *kdConfigPointers    = NULL;
 static KdKeyboardDriver *kdKeyboardDrivers = NULL;
 static KdPointerDriver  *kdPointerDrivers  = NULL;
 
-static EventListPtr     kdEvents = NULL;
+static InternalEvent*   kdEvents = NULL;
 
 static Bool		kdInputEnabled;
 static Bool		kdOffScreen;
diff --git a/hw/xfree86/common/xf86Priv.h b/hw/xfree86/common/xf86Priv.h
index 7137a53..015e12c 100644
--- a/hw/xfree86/common/xf86Priv.h
+++ b/hw/xfree86/common/xf86Priv.h
@@ -149,7 +149,7 @@ extern _X_EXPORT int xf86SetLogVerbosity(int verb);
 extern _X_EXPORT Bool xf86CallDriverProbe( struct _DriverRec * drv, Bool detect_only );
 
 /* xf86Xinput.c */
-extern _X_EXPORT EventList *xf86Events;
+extern _X_EXPORT InternalEvent *xf86Events;
 
 #endif /* _NO_XF86_PROTOTYPES */
 
diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index 111f16f..9827661 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -99,7 +99,7 @@
 		return;								\
 	}
 
-EventListPtr xf86Events = NULL;
+InternalEvent* xf86Events = NULL;
 
 static int
 xf86InputDevicePostInit(DeviceIntPtr dev);
diff --git a/hw/xnest/Events.c b/hw/xnest/Events.c
index 574e4e4..bbd70bf 100644
--- a/hw/xnest/Events.c
+++ b/hw/xnest/Events.c
@@ -43,7 +43,7 @@ is" without express or implied warranty.
 
 CARD32 lastEventTime = 0;
 
-extern EventList *xnestEvents;
+extern InternalEvent *xnestEvents;
 
 void
 ProcessInputEvents(void)
diff --git a/hw/xnest/Init.c b/hw/xnest/Init.c
index 8a90cc6..f8637f2 100644
--- a/hw/xnest/Init.c
+++ b/hw/xnest/Init.c
@@ -45,7 +45,7 @@ is" without express or implied warranty.
 
 Bool xnestDoFullGeneration = True;
 
-EventList *xnestEvents = NULL;
+InternalEvent *xnestEvents = NULL;
 
 void
 InitOutput(ScreenInfo *screenInfo, int argc, char *argv[])
diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c
index 99956e0..6736e3d 100644
--- a/hw/xquartz/darwinEvents.c
+++ b/hw/xquartz/darwinEvents.c
@@ -88,7 +88,7 @@ static pthread_mutex_t fd_add_lock = PTHREAD_MUTEX_INITIALIZER;
 static pthread_cond_t fd_add_ready_cond = PTHREAD_COND_INITIALIZER;
 static pthread_t fd_add_tid = NULL;
 
-static EventListPtr darwinEvents = NULL;
+static InternalEvent* darwinEvents = NULL;
 
 static pthread_mutex_t mieq_lock = PTHREAD_MUTEX_INITIALIZER;
 static pthread_cond_t mieq_ready_cond = PTHREAD_COND_INITIALIZER;
diff --git a/hw/xwin/winkeybd.c b/hw/xwin/winkeybd.c
index cf0dea2..8b6be02 100644
--- a/hw/xwin/winkeybd.c
+++ b/hw/xwin/winkeybd.c
@@ -472,7 +472,7 @@ winKeybdReleaseKeys (void)
 void
 winSendKeyEvent (DWORD dwKey, Bool fDown)
 {
-  EventListPtr events;
+  InternalEvent* events;
 
   /*
    * When alt-tabing between screens we can get phantom key up messages
diff --git a/hw/xwin/winmouse.c b/hw/xwin/winmouse.c
index 0e36687..aaa4d4b 100644
--- a/hw/xwin/winmouse.c
+++ b/hw/xwin/winmouse.c
@@ -234,7 +234,7 @@ winMouseWheel (ScreenPtr pScreen, int iDeltaZ)
 void
 winMouseButtonsSendEvent (int iEventType, int iButton)
 {
-  EventListPtr events;
+  InternalEvent* events;
   ValuatorMask mask;
 
   if (g_winMouseButtonMap)
@@ -365,7 +365,7 @@ void winEnqueueMotion(int x, int y)
 {
   int valuators[2];
   ValuatorMask mask;
-  EventListPtr events;
+  InternalEvent* events;
 
   miPointerSetPosition(g_pwinPointer, POINTER_RELATIVE, &x, &y);
   valuators[0] = x;
diff --git a/include/input.h b/include/input.h
index 100c00f..3c7740d 100644
--- a/include/input.h
+++ b/include/input.h
@@ -109,18 +109,8 @@ typedef union _GrabMask GrabMask;
 
 typedef struct _ValuatorMask ValuatorMask;
 
-typedef struct _EventList {
-    xEvent* event;
-    int evlen; /* length of allocated memory for event in bytes.  This is not
-                  the actual length of the event. The event's actual length is
-                  32 for standard events or 32 +
-                  ((xGenericEvent*)event)->length * 4 for GenericEvents.
-                  For events in the EQ, the length is
-                  ((InternalEvent*)event)->u.any.length */
-} EventList, *EventListPtr;
-
 /* The DIX stores incoming input events in this list */
-extern EventListPtr InputEventList;
+extern InternalEvent* InputEventList;
 extern int InputEventListLen;
 
 typedef int (*DeviceProc)(
@@ -439,22 +429,22 @@ extern _X_EXPORT void CloseInput(void);
 
 extern _X_EXPORT int GetMaximumEventsNum(void);
 
-extern _X_EXPORT int GetEventList(EventListPtr* list);
-extern _X_EXPORT EventListPtr InitEventList(int num_events);
-extern _X_EXPORT void FreeEventList(EventListPtr list, int num_events);
+extern _X_EXPORT int GetEventList(InternalEvent** list);
+extern _X_EXPORT InternalEvent *InitEventList(int num_events);
+extern _X_EXPORT void FreeEventList(InternalEvent *list, int num_events);
 
-extern void CreateClassesChangedEvent(EventListPtr event,
+extern void CreateClassesChangedEvent(InternalEvent *event,
                                       DeviceIntPtr master,
                                       DeviceIntPtr slave,
                                       int type);
-extern EventListPtr UpdateFromMaster(
-    EventListPtr events,
+extern InternalEvent * UpdateFromMaster(
+    InternalEvent *events,
     DeviceIntPtr pDev,
     int type,
     int *num_events);
 
 extern _X_EXPORT int GetPointerEvents(
-    EventListPtr events,
+    InternalEvent *events,
     DeviceIntPtr pDev,
     int type,
     int buttons,
@@ -462,7 +452,7 @@ extern _X_EXPORT int GetPointerEvents(
     const ValuatorMask *mask);
 
 extern _X_EXPORT void QueuePointerEvents(
-    EventListPtr events,
+    InternalEvent *events,
     DeviceIntPtr pDev,
     int type,
     int buttons,
@@ -470,27 +460,27 @@ extern _X_EXPORT void QueuePointerEvents(
     const ValuatorMask *mask);
 
 extern _X_EXPORT int GetKeyboardEvents(
-    EventListPtr events,
+    InternalEvent *events,
     DeviceIntPtr pDev,
     int type,
     int key_code,
     const ValuatorMask *mask);
 
 extern _X_EXPORT void QueueKeyboardEvents(
-    EventListPtr events,
+    InternalEvent *events,
     DeviceIntPtr pDev,
     int type,
     int key_code,
     const ValuatorMask *mask);
 
 extern int GetProximityEvents(
-    EventListPtr events,
+    InternalEvent *events,
     DeviceIntPtr pDev,
     int type,
     const ValuatorMask *mask);
 
 extern void QueueProximityEvents(
-    EventListPtr events,
+    InternalEvent *events,
     DeviceIntPtr pDev,
     int type,
     const ValuatorMask *mask);
diff --git a/mi/mieq.c b/mi/mieq.c
index 3e6f931..236ffcc 100644
--- a/mi/mieq.c
+++ b/mi/mieq.c
@@ -64,7 +64,7 @@ in this Software without prior written authorization from The Open Group.
 #define DequeueScreen(dev) dev->spriteInfo->sprite->pDequeueScreen
 
 typedef struct _Event {
-    EventListPtr    events;
+    InternalEvent*  events;
     ScreenPtr	    pScreen;
     DeviceIntPtr    pDev; /* device this event _originated_ from */
 } EventRec, *EventPtr;
@@ -111,7 +111,7 @@ mieqInit(void)
     for (i = 0; i < QUEUE_SIZE; i++)
     {
 	if (miEventQueue.events[i].events == NULL) {
-	    EventListPtr evlist = InitEventList(1);
+	    InternalEvent* evlist = InitEventList(1);
 	    if (!evlist)
 		FatalError("Could not allocate event queue.\n");
 	    miEventQueue.events[i].events = evlist;
@@ -146,7 +146,7 @@ void
 mieqEnqueue(DeviceIntPtr pDev, InternalEvent *e)
 {
     unsigned int           oldtail = miEventQueue.tail;
-    EventListPtr           evt;
+    InternalEvent*         evt;
     int                    isMotion = 0;
     int                    evlen;
     Time                   time;
@@ -188,21 +188,7 @@ mieqEnqueue(DeviceIntPtr pDev, InternalEvent *e)
 
     evlen = e->any.length;
     evt = miEventQueue.events[oldtail].events;
-    if (evt->evlen < evlen)
-    {
-        evt->evlen = evlen;
-        evt->event = realloc(evt->event, evt->evlen);
-        if (!evt->event)
-        {
-            ErrorF("[mi] Running out of memory. Tossing event.\n");
-#ifdef XQUARTZ
-            pthread_mutex_unlock(&miEventQueueMutex);
-#endif
-            return;
-        }
-    }
-
-    memcpy(evt->event, e, evlen);
+    memcpy(evt, e, evlen);
 
     time = e->any.time;
     /* Make sure that event times don't go backwards - this
@@ -211,7 +197,7 @@ mieqEnqueue(DeviceIntPtr pDev, InternalEvent *e)
         miEventQueue.lastEventTime - time < 10000)
         e->any.time = miEventQueue.lastEventTime;
 
-    miEventQueue.lastEventTime = ((InternalEvent*)evt->event)->any.time;
+    miEventQueue.lastEventTime = evt->any.time;
     miEventQueue.events[oldtail].pScreen = pDev ? EnqueueScreen(pDev) : NULL;
     miEventQueue.events[oldtail].pDev = pDev;
 
@@ -431,10 +417,8 @@ void
 mieqProcessInputEvents(void)
 {
     EventRec *e = NULL;
-    int evlen;
     ScreenPtr screen;
-    static InternalEvent *event = NULL;
-    static size_t event_size = 0;
+    static InternalEvent event;
     DeviceIntPtr dev = NULL,
                  master = NULL;
 
@@ -445,20 +429,7 @@ mieqProcessInputEvents(void)
     while (miEventQueue.head != miEventQueue.tail) {
         e = &miEventQueue.events[miEventQueue.head];
 
-        evlen   = e->events->evlen;
-        if(evlen > event_size)
-          {
-            event = realloc(event, evlen);
-            event_size = evlen;
-          }
-
-
-        if (!event)
-            FatalError("[mi] No memory left for event processing.\n");
-
-        memcpy(event, e->events->event, evlen);
-
-
+        event = *e->events;
         dev     = e->pDev;
         screen  = e->pScreen;
 
@@ -480,10 +451,10 @@ mieqProcessInputEvents(void)
             DPMSSet(serverClient, DPMSModeOn);
 #endif
 
-        mieqProcessDeviceEvent(dev, event, screen);
+        mieqProcessDeviceEvent(dev, &event, screen);
 
         /* Update the sprite now. Next event may be from different device. */
-        if (event->any.type == ET_Motion && master)
+        if (event.any.type == ET_Motion && master)
             miPointerUpdateSprite(dev);
 
 #ifdef XQUARTZ
diff --git a/mi/mipointer.c b/mi/mipointer.c
index db24381..322be9e 100644
--- a/mi/mipointer.c
+++ b/mi/mipointer.c
@@ -63,6 +63,7 @@ in this Software without prior written authorization from The Open Group.
 # include   "dixstruct.h"
 # include   "inputstr.h"
 # include   "inpututils.h"
+# include   "eventstr.h"
 
 DevPrivateKeyRec miPointerScreenKeyRec;
 
@@ -99,7 +100,7 @@ static void miPointerDeviceCleanup(DeviceIntPtr pDev,
                                    ScreenPtr pScreen);
 static void miPointerMoveNoEvent (DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y);
 
-static EventList* events; /* for WarpPointer MotionNotifies */
+static InternalEvent* events; /* for WarpPointer MotionNotifies */
 
 Bool
 miPointerInitialize (ScreenPtr                  pScreen,
@@ -689,7 +690,7 @@ miPointerMove (DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
     darwinEvents_lock();
 #endif
     for (i = 0; i < nevents; i++)
-        mieqEnqueue(pDev, (InternalEvent*)events[i].event);
+        mieqEnqueue(pDev, &events[i]);
 #ifdef XQUARTZ
     darwinEvents_unlock();
 #endif
diff --git a/xkb/xkbActions.c b/xkb/xkbActions.c
index c4336d7..4b5405a 100644
--- a/xkb/xkbActions.c
+++ b/xkb/xkbActions.c
@@ -1351,7 +1351,7 @@ static void
 InjectPointerKeyEvents(DeviceIntPtr dev, int type, int button, int flags, ValuatorMask *mask)
 {
     ScreenPtr           pScreen;
-    EventListPtr        events;
+    InternalEvent*      events;
     int                 nevents, i;
     DeviceIntPtr        ptr, mpointer, lastSlave = NULL;
     Bool                saveWait;
@@ -1377,7 +1377,7 @@ InjectPointerKeyEvents(DeviceIntPtr dev, int type, int button, int flags, Valuat
     OsReleaseSignals();
 
     for (i = 0; i < nevents; i++)
-        mieqProcessDeviceEvent(ptr, (InternalEvent*)events[i].event, NULL);
+        mieqProcessDeviceEvent(ptr, &events[i], NULL);
 
     FreeEventList(events, GetMaximumEventsNum());
 
commit e7150db5350bc2113ff4126019b489847a4dc217
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Mon Apr 11 15:48:15 2011 +1000

    input: Provide Queue{Button|Keyboard|Proximity}Event helpers
    
    Don't require every caller to use GPE + mieqEnqueue, provide matching
    Queue...Event functions instead.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/dix/getevents.c b/dix/getevents.c
index 5ffa1df..68a5224 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -47,6 +47,7 @@
 #include "eventstr.h"
 #include "eventconvert.h"
 #include "inpututils.h"
+#include "mi.h"
 
 #include <X11/extensions/XKBproto.h>
 #include "xkbsrv.h"
@@ -924,6 +925,39 @@ updateHistory(DeviceIntPtr dev, ValuatorMask *mask, CARD32 ms)
     }
 }
 
+static void
+queueEventList(DeviceIntPtr device, EventList *events, int nevents)
+{
+    int i;
+
+    for (i = 0; i < nevents; i++)
+        mieqEnqueue(device, (InternalEvent*)((events + i)->event));
+}
+
+/**
+ * Generate internal events representing this keyboard event and enqueue
+ * them on the event queue.
+ *
+ * FIXME: don't require the event list to be passed in.
+ * FIXME: flags for relative/abs motion?
+ *
+ * @param events Event list used as temporary storage
+ * @param device The device to generate the event for
+ * @param type Event type, one of KeyPress or KeyRelease
+ * @param keycode Key code of the pressed/released key
+ * @param mask Valuator mask for valuators present for this event.
+ *
+ */
+void
+QueueKeyboardEvents(EventList *events, DeviceIntPtr device, int type,
+                    int keycode, const ValuatorMask *mask)
+{
+    int nevents;
+
+    nevents = GetKeyboardEvents(events, device, type, keycode, mask);
+    queueEventList(device, events, nevents);
+}
+
 /**
  * Returns a set of InternalEvents for KeyPress/KeyRelease, optionally
  * also with valuator events.
@@ -1062,6 +1096,30 @@ transformAbsolute(DeviceIntPtr dev, ValuatorMask *mask, int *x, int *y)
 }
 
 /**
+ * Generate internal events representing this pointer event and enqueue them
+ * on the event queue.
+ *
+ * FIXME: don't require the event list to be passed in.
+ *
+ * @param events Event list used as temporary storage
+ * @param device The device to generate the event for
+ * @param type Event type, one of ButtonPress, ButtonRelease, MotionNotify
+ * @param buttons Button number of the buttons modified. Must be 0 for
+ * MotionNotify
+ * @param flags Event modification flags
+ * @param mask Valuator mask for valuators present for this event.
+ */
+void
+QueuePointerEvents(EventList *events, DeviceIntPtr device, int type,
+                   int buttons, int flags, const ValuatorMask *mask)
+{
+    int nevents;
+
+    nevents = GetPointerEvents(events, device, type, buttons, flags, mask);
+    queueEventList(device, events, nevents);
+}
+
+/**
  * Generate a series of InternalEvents (filled into the EventList)
  * representing pointer motion, or button presses.
  *
@@ -1214,6 +1272,28 @@ GetPointerEvents(EventList *events, DeviceIntPtr pDev, int type, int buttons,
     return num_events;
 }
 
+/**
+ * Generate internal events representing this proximity event and enqueue
+ * them on the event queue.
+ *
+ * FIXME: don't require the event list to be passed in.
+ *
+ * @param events Event list used as temporary storage
+ * @param device The device to generate the event for
+ * @param type Event type, one of ProximityIn or ProximityOut
+ * @param keycode Key code of the pressed/released key
+ * @param mask Valuator mask for valuators present for this event.
+ *
+ */
+void
+QueueProximityEvents(EventList *events, DeviceIntPtr device, int type,
+                     const ValuatorMask *mask)
+{
+    int nevents;
+
+    nevents = GetProximityEvents(events, device, type, mask);
+    queueEventList(device, events, nevents);
+}
 
 /**
  * Generate ProximityIn/ProximityOut InternalEvents, accompanied by
diff --git a/hw/dmx/input/dmxevents.c b/hw/dmx/input/dmxevents.c
index 15d80f5..3f9035c 100644
--- a/hw/dmx/input/dmxevents.c
+++ b/hw/dmx/input/dmxevents.c
@@ -176,7 +176,7 @@ static void enqueueMotion(DevicePtr pDev, int x, int y)
 {
     GETDMXLOCALFROMPDEV;
     DeviceIntPtr p = dmxLocal->pDevice;
-    int i, nevents, valuators[3];
+    int valuators[3];
     EventListPtr events;
     int detail = 0;  /* XXX should this be mask of pressed buttons? */
     ValuatorMask mask;
@@ -185,10 +185,8 @@ static void enqueueMotion(DevicePtr pDev, int x, int y)
 
     valuator_mask_set_range(&mask, 0, 2, valuators);
     GetEventList(&events);
-    nevents = GetPointerEvents(events, p, MotionNotify, detail,
-                               POINTER_ABSOLUTE | POINTER_SCREEN, &mask);
-    for (i = 0; i < nevents; i++)
-       mieqEnqueue(p, (InternalEvent*)(events + i)->event);
+    QueuePointerEvents(events, p, MotionNotify, detail,
+                       POINTER_ABSOLUTE | POINTER_SCREEN, &mask);
     return;
 }
 
@@ -291,10 +289,8 @@ static void dmxExtMotion(DMXLocalInputInfoPtr dmxLocal,
     deviceValuator         *xv     = (deviceValuator *)xev+1;
     int                    thisX   = 0;
     int                    thisY   = 0;
-    int                    i;
     int                    count;
     EventListPtr           events;
-    int                    nevents;
     ValuatorMask           mask;
 
     memset(xE, 0, sizeof(xE));
@@ -348,6 +344,7 @@ static void dmxExtMotion(DMXLocalInputInfoPtr dmxLocal,
             }
             count              = 2;
     } else {
+        int i;
         for (i = 0, count = 0; i < axesCount; i += 6) {
             xev->time          = GetTimeInMillis();
             xev->type          = DeviceMotionNotify;
@@ -376,10 +373,8 @@ static void dmxExtMotion(DMXLocalInputInfoPtr dmxLocal,
         dmxSigioBlock();
     valuator_mask_set_range(&mask, firstAxis, axesCount, v);
     GetEventList(&events);
-    nevents = GetPointerEvents(events, pDevice, MotionNotify, 0,
-                               POINTER_ABSOLUTE, &mask);
-    for (i = 0; i < nevents; i++)
-        mieqEnqueue(pDevice, (InternalEvent*)(events + i)->event);
+    QueuePointerEvents(events, pDevice, MotionNotify, 0,
+                       POINTER_ABSOLUTE, &mask);
 
     if (block)
         dmxSigioUnblock();
@@ -395,7 +390,6 @@ static int dmxTranslateAndEnqueueExtEvent(DMXLocalInputInfoPtr dmxLocal,
     DeviceIntPtr           pDevice = dmxLocal->pDevice;
     int                    valuators[MAX_VALUATORS];
     EventListPtr           events;
-    int                    nevents, i;
     ValuatorMask           mask;
 
     if (!e)
@@ -453,11 +447,7 @@ static int dmxTranslateAndEnqueueExtEvent(DMXLocalInputInfoPtr dmxLocal,
         if (block)
             dmxSigioBlock();
         GetEventList(&events);
-        nevents = GetKeyboardEvents(events, pDevice, event,
-                                    ke->keycode, &mask);
-        for (i = 0; i < nevents; i++)
-            mieqEnqueue(pDevice, (InternalEvent*)(events + i)->event);
-
+        QueueKeyboardEvents(events, pDevice, event, ke->keycode, &mask);
         if (block)
             dmxSigioUnblock();
         break;
@@ -468,11 +458,8 @@ static int dmxTranslateAndEnqueueExtEvent(DMXLocalInputInfoPtr dmxLocal,
         if (block)
             dmxSigioBlock();
         GetEventList(&events);
-        nevents = GetPointerEvents(events, pDevice, event, ke->keycode,
-                                   POINTER_ABSOLUTE, &mask);
-        for (i = 0; i < nevents; i++)
-            mieqEnqueue(pDevice, (InternalEvent*)(events + i)->event);
-
+        QueuePointerEvents(events, pDevice, event, ke->keycode,
+                           POINTER_ABSOLUTE, &mask);
         if (block)
             dmxSigioUnblock();
         break;
@@ -483,10 +470,7 @@ static int dmxTranslateAndEnqueueExtEvent(DMXLocalInputInfoPtr dmxLocal,
         if (block)
             dmxSigioBlock();
         GetEventList(&events);
-        nevents = GetProximityEvents(events, pDevice, event, &mask);
-        for (i = 0; i < nevents; i++)
-            mieqEnqueue(pDevice, (InternalEvent*)(events + i)->event);
-
+        QueueProximityEvents(events, pDevice, event, &mask);
         if (block)
             dmxSigioUnblock();
         break;
@@ -667,7 +651,7 @@ void dmxEnqueue(DevicePtr pDev, int type, int detail, KeySym keySym,
     GETDMXINPUTFROMPDEV;
     xEvent xE;
     DeviceIntPtr p = dmxLocal->pDevice;
-    int i, nevents, valuators[3];
+    int valuators[3];
     EventListPtr events;
     ValuatorMask mask;
 
@@ -685,9 +669,7 @@ void dmxEnqueue(DevicePtr pDev, int type, int detail, KeySym keySym,
 
         GetEventList(&events);
         /*ErrorF("KEY %d  sym %d\n", detail, (int) keySym);*/
-        nevents = GetKeyboardEvents(events, p, type, detail, NULL);
-        for (i = 0; i < nevents; i++)
-            mieqEnqueue(p, (InternalEvent*)(events + i)->event);
+        QueueKeyboardEvents(events, p, type, detail, NULL);
         return;
 
     case ButtonPress:
@@ -695,10 +677,8 @@ void dmxEnqueue(DevicePtr pDev, int type, int detail, KeySym keySym,
         detail = dmxGetButtonMapping(dmxLocal, detail);
         valuator_mask_zero(&mask);
         GetEventList(&events);
-        nevents = GetPointerEvents(events, p, type, detail,
-                                   POINTER_ABSOLUTE | POINTER_SCREEN, &mask);
-        for (i = 0; i < nevents; i++)
-            mieqEnqueue(p, (InternalEvent*)(events + i)->event);
+        QueuePointerEvents(events, p, type, detail,
+                           POINTER_ABSOLUTE | POINTER_SCREEN, &mask);
         return;
 
     case MotionNotify:
@@ -707,10 +687,8 @@ void dmxEnqueue(DevicePtr pDev, int type, int detail, KeySym keySym,
         valuators[1] = e->xmotion.y;
         valuators[2] = e->xmotion.state; /* FIXME: WTF?? */
         valuator_mask_set_range(&mask, 0, 3, valuators);
-        nevents = GetPointerEvents(events, p, type, detail, 
-                                   POINTER_ABSOLUTE | POINTER_SCREEN, &mask);
-        for (i = 0; i < nevents; i++)
-            mieqEnqueue(p, (InternalEvent*)(events + i)->event);
+        QueuePointerEvents(events, p, type, detail,
+                           POINTER_ABSOLUTE | POINTER_SCREEN, &mask);
         return;
 
     case EnterNotify:
diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c
index f21475f..521542c 100644
--- a/hw/kdrive/src/kinput.c
+++ b/hw/kdrive/src/kinput.c
@@ -1793,7 +1793,7 @@ void
 KdReleaseAllKeys (void)
 {
 #if 0
-    int	key, nEvents, i;
+    int	key;
     KdKeyboardInfo *ki;
 
     KdBlockSigio ();
@@ -1804,9 +1804,7 @@ KdReleaseAllKeys (void)
             if (key_is_down(ki->dixdev, key, KEY_POSTED | KEY_PROCESSED)) {
                 KdHandleKeyboardEvent(ki, KeyRelease, key);
                 GetEventList(&kdEvents);
-                nEvents = GetKeyboardEvents(kdEvents, ki->dixdev, KeyRelease, key, NULL);
-                for (i = 0; i < nEvents; i++)
-                    KdQueueEvent (ki->dixdev, (kdEvents + i)->event);
+                QueueGetKeyboardEvents(kdEvents, ki->dixdev, KeyRelease, key, NULL);
             }
         }
     }
@@ -1842,7 +1840,7 @@ KdEnqueueKeyboardEvent(KdKeyboardInfo   *ki,
     unsigned char key_code;
     KeyClassPtr	keyc = NULL;
     KeybdCtrl *ctrl = NULL;
-    int type, nEvents, i;
+    int type;
 
     if (!ki || !ki->dixdev || !ki->dixdev->kbdfeed || !ki->dixdev->key)
 	return;
@@ -1863,10 +1861,7 @@ KdEnqueueKeyboardEvent(KdKeyboardInfo   *ki,
 	    type = KeyPress;
 
         GetEventList(&kdEvents);
-
-        nEvents = GetKeyboardEvents(kdEvents, ki->dixdev, type, key_code, NULL);
-        for (i = 0; i < nEvents; i++)
-            KdQueueEvent(ki->dixdev, (InternalEvent *)((kdEvents + i)->event));
+        QueueKeyboardEvents(kdEvents, ki->dixdev, type, key_code, NULL);
     }
     else {
         ErrorF("driver %s wanted to post scancode %d outside of [%d, %d]!\n",
@@ -1965,7 +1960,6 @@ void
 _KdEnqueuePointerEvent (KdPointerInfo *pi, int type, int x, int y, int z,
                         int b, int absrel, Bool force)
 {
-    int nEvents = 0, i = 0;
     int valuators[3] = { x, y, z };
     ValuatorMask mask;
 
@@ -1976,9 +1970,7 @@ _KdEnqueuePointerEvent (KdPointerInfo *pi, int type, int x, int y, int z,
     valuator_mask_set_range(&mask, 0, 3, valuators);
 
     GetEventList(&kdEvents);
-    nEvents = GetPointerEvents(kdEvents, pi->dixdev, type, b, absrel, &mask);
-    for (i = 0; i < nEvents; i++)
-        KdQueueEvent(pi->dixdev, (InternalEvent *)((kdEvents + i)->event));
+    QueuePointerEvents(kdEvents, pi->dixdev, type, b, absrel, &mask);
 }
 
 void
diff --git a/hw/xfree86/common/xf86Events.c b/hw/xfree86/common/xf86Events.c
index 3006ad1..6402d72 100644
--- a/hw/xfree86/common/xf86Events.c
+++ b/hw/xfree86/common/xf86Events.c
@@ -376,7 +376,7 @@ static void
 xf86ReleaseKeys(DeviceIntPtr pDev)
 {
     KeyClassPtr keyc;
-    int i, j, nevents, sigstate;
+    int i, sigstate;
 
     if (!pDev || !pDev->key)
         return;
@@ -399,9 +399,7 @@ xf86ReleaseKeys(DeviceIntPtr pDev)
          i++) {
         if (key_is_down(pDev, i, KEY_POSTED)) {
             sigstate = xf86BlockSIGIO ();
-            nevents = GetKeyboardEvents(xf86Events, pDev, KeyRelease, i, NULL);
-            for (j = 0; j < nevents; j++)
-                mieqEnqueue(pDev, (InternalEvent*)(xf86Events + j)->event);
+            QueueKeyboardEvents(xf86Events, pDev, KeyRelease, i, NULL);
             xf86UnblockSIGIO(sigstate);
         }
     }
diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index aae6658..111f16f 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -1012,7 +1012,6 @@ xf86PostMotionEventM(DeviceIntPtr	device,
                      int		is_absolute,
                      const ValuatorMask	*mask)
 {
-    int i = 0, nevents = 0;
     int flags = 0;
 
     if (valuator_mask_num_valuators(mask) > 0)
@@ -1050,11 +1049,7 @@ xf86PostMotionEventM(DeviceIntPtr	device,
         }
 #endif
 
-    nevents = GetPointerEvents(xf86Events, device, MotionNotify, 0, flags, mask);
-
-    for (i = 0; i < nevents; i++) {
-        mieqEnqueue(device, (InternalEvent*)((xf86Events + i)->event));
-    }
+    QueuePointerEvents(xf86Events, device, MotionNotify, 0, flags, mask);
 }
 
 void
@@ -1099,13 +1094,8 @@ xf86PostProximityEventM(DeviceIntPtr	device,
                         int		is_in,
                         const ValuatorMask *mask)
 {
-    int i, nevents;
-
-    nevents = GetProximityEvents(xf86Events, device,
-                                 is_in ? ProximityIn : ProximityOut, mask);
-    for (i = 0; i < nevents; i++)
-        mieqEnqueue(device, (InternalEvent*)((xf86Events + i)->event));
-
+    QueueProximityEvents(xf86Events, device,
+                         is_in ? ProximityIn : ProximityOut, mask);
 }
 
 void
@@ -1157,7 +1147,6 @@ xf86PostButtonEventM(DeviceIntPtr	device,
                      int		is_down,
                      const ValuatorMask	*mask)
 {
-    int i = 0, nevents = 0;
     int flags = 0;
 
     if (valuator_mask_num_valuators(mask) > 0)
@@ -1177,13 +1166,9 @@ xf86PostButtonEventM(DeviceIntPtr	device,
     }
 #endif
 
-    nevents = GetPointerEvents(xf86Events, device,
-                               is_down ? ButtonPress : ButtonRelease, button,
-                               flags, mask);
-
-    for (i = 0; i < nevents; i++)
-        mieqEnqueue(device, (InternalEvent*)((xf86Events + i)->event));
-
+    QueuePointerEvents(xf86Events, device,
+                       is_down ? ButtonPress : ButtonRelease, button,
+                       flags, mask);
 }
 
 void
@@ -1235,8 +1220,6 @@ xf86PostKeyEventM(DeviceIntPtr	device,
                   int		is_absolute,
                   const ValuatorMask *mask)
 {
-    int i = 0, nevents = 0;
-
 #if XFreeXDGA
     DeviceIntPtr pointer;
 
@@ -1250,12 +1233,9 @@ xf86PostKeyEventM(DeviceIntPtr	device,
     }
 #endif
 
-    nevents = GetKeyboardEvents(xf86Events, device,
-                                is_down ? KeyPress : KeyRelease,
-                                key_code, mask);
-
-    for (i = 0; i < nevents; i++)
-        mieqEnqueue(device, (InternalEvent*)((xf86Events + i)->event));
+    QueueKeyboardEvents(xf86Events, device,
+                        is_down ? KeyPress : KeyRelease,
+                        key_code, mask);
 }
 
 void
diff --git a/hw/xnest/Events.c b/hw/xnest/Events.c
index 5c80086..574e4e4 100644
--- a/hw/xnest/Events.c
+++ b/hw/xnest/Events.c
@@ -104,20 +104,16 @@ xnestCollectExposures(void)
 void
 xnestQueueKeyEvent(int type, unsigned int keycode)
 {
-  int i, n;
-
   GetEventList(&xnestEvents);
   lastEventTime = GetTimeInMillis();
-  n = GetKeyboardEvents(xnestEvents, xnestKeyboardDevice, type, keycode, NULL);
-  for (i = 0; i < n; i++)
-    mieqEnqueue(xnestKeyboardDevice, (InternalEvent*)(xnestEvents + i)->event);
+  QueueKeyboardEvents(xnestEvents, xnestKeyboardDevice, type, keycode, NULL);
 }
 
 void
 xnestCollectEvents(void)
 {
   XEvent X;
-  int i, n, valuators[2];
+  int valuators[2];
   ValuatorMask mask;
   ScreenPtr pScreen;
   GetEventList(&xnestEvents);
@@ -138,20 +134,16 @@ xnestCollectEvents(void)
       valuator_mask_set_range(&mask, 0, 0, NULL);
       xnestUpdateModifierState(X.xkey.state);
       lastEventTime = GetTimeInMillis();
-      n = GetPointerEvents(xnestEvents, xnestPointerDevice, ButtonPress,
-                           X.xbutton.button, POINTER_RELATIVE, &mask);
-      for (i = 0; i < n; i++)
-        mieqEnqueue(xnestPointerDevice, (InternalEvent*)(xnestEvents + i)->event);
+      QueuePointerEvents(xnestEvents, xnestPointerDevice, ButtonPress,
+                         X.xbutton.button, POINTER_RELATIVE, &mask);
       break;
       
     case ButtonRelease:
       valuator_mask_set_range(&mask, 0, 0, NULL);
       xnestUpdateModifierState(X.xkey.state);
       lastEventTime = GetTimeInMillis();
-      n = GetPointerEvents(xnestEvents, xnestPointerDevice, ButtonRelease,
-                           X.xbutton.button, POINTER_RELATIVE, &mask);
-      for (i = 0; i < n; i++)
-        mieqEnqueue(xnestPointerDevice, (InternalEvent*)(xnestEvents + i)->event);
+      QueuePointerEvents(xnestEvents, xnestPointerDevice, ButtonRelease,
+                         X.xbutton.button, POINTER_RELATIVE, &mask);
       break;
       
     case MotionNotify:
@@ -159,10 +151,8 @@ xnestCollectEvents(void)
       valuators[1] = X.xmotion.y;
       valuator_mask_set_range(&mask, 0, 2, valuators);
       lastEventTime = GetTimeInMillis();
-      n = GetPointerEvents(xnestEvents, xnestPointerDevice, MotionNotify,
-                           0, POINTER_ABSOLUTE, &mask);
-      for (i = 0; i < n; i++)
-        mieqEnqueue(xnestPointerDevice, (InternalEvent*)(xnestEvents + i)->event);
+      QueuePointerEvents(xnestEvents, xnestPointerDevice, MotionNotify,
+                         0, POINTER_ABSOLUTE, &mask);
       break;
       
     case FocusIn:
@@ -193,10 +183,8 @@ xnestCollectEvents(void)
           valuators[1] = X.xcrossing.y;
           valuator_mask_set_range(&mask, 0, 2, valuators);
           lastEventTime = GetTimeInMillis();
-          n = GetPointerEvents(xnestEvents, xnestPointerDevice, MotionNotify,
-                               0, POINTER_ABSOLUTE, &mask);
-          for (i = 0; i < n; i++)
-            mieqEnqueue(xnestPointerDevice, (InternalEvent*)(xnestEvents + i)->event);
+          QueuePointerEvents(xnestEvents, xnestPointerDevice, MotionNotify,
+                             0, POINTER_ABSOLUTE, &mask);
 	  xnestDirectInstallColormaps(pScreen);
 	}
       }
diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c
index f3e1225..99956e0 100644
--- a/hw/xquartz/darwinEvents.c
+++ b/hw/xquartz/darwinEvents.c
@@ -433,7 +433,6 @@ static void DarwinPrepareValuators(DeviceIntPtr pDev, int *valuators, ScreenPtr
 void DarwinSendPointerEvents(DeviceIntPtr pDev, int ev_type, int ev_button, float pointer_x, float pointer_y, 
 			     float pressure, float tilt_x, float tilt_y) {
 	static int darwinFakeMouseButtonDown = 0;
-	int i, num_events;
     ScreenPtr screen;
     int valuators[5];
 	
@@ -486,15 +485,13 @@ void DarwinSendPointerEvents(DeviceIntPtr pDev, int ev_type, int ev_button, floa
     darwinEvents_lock(); {
         ValuatorMask mask;
         valuator_mask_set_range(&mask, 0, (pDev == darwinPointer) ? 2 : 5, valuators);
-        num_events = GetPointerEvents(darwinEvents, pDev, ev_type, ev_button, 
-                                      POINTER_ABSOLUTE, &mask);
-        for(i=0; i<num_events; i++) mieqEnqueue (pDev, (InternalEvent*)darwinEvents[i].event);
-        if(num_events > 0) DarwinPokeEQ();
+        QueuePointerEvents(darwinEvents, pDev, ev_type, ev_button,
+                           POINTER_ABSOLUTE, &mask);
+        DarwinPokeEQ();
     } darwinEvents_unlock();
 }
 
 void DarwinSendKeyboardEvents(int ev_type, int keycode) {
-	int i, num_events;
 
 	if(!darwinEvents) {
 		DEBUG_LOG("DarwinSendKeyboardEvents called before darwinEvents was initialized\n");
@@ -502,15 +499,13 @@ void DarwinSendKeyboardEvents(int ev_type, int keycode) {
 	}
 
     darwinEvents_lock(); {
-        num_events = GetKeyboardEvents(darwinEvents, darwinKeyboard, ev_type, keycode + MIN_KEYCODE, NULL);
-        for(i=0; i<num_events; i++) mieqEnqueue(darwinKeyboard, (InternalEvent*)darwinEvents[i].event);
-        if(num_events > 0) DarwinPokeEQ();
+        QueueKeyboardEvents(darwinEvents, darwinKeyboard, ev_type, keycode + MIN_KEYCODE, NULL);
+        DarwinPokeEQ();
     } darwinEvents_unlock();
 }
 
 void DarwinSendProximityEvents(DeviceIntPtr pDev, int ev_type, float pointer_x, float pointer_y,  
                                float pressure, float tilt_x, float tilt_y) {
-    int i, num_events;
     ScreenPtr screen;
     int valuators[5];
 
@@ -531,9 +526,8 @@ void DarwinSendProximityEvents(DeviceIntPtr pDev, int ev_type, float pointer_x,
     darwinEvents_lock(); {
         ValuatorMask mask;
         valuator_mask_set_range(&mask, 0, 5, valuators);
-        num_events = GetProximityEvents(darwinEvents, pDev, ev_type, &mask);
-        for(i=0; i<num_events; i++) mieqEnqueue (pDev, (InternalEvent*)darwinEvents[i].event);
-        if(num_events > 0) DarwinPokeEQ();
+        QueueProximityEvents(darwinEvents, pDev, ev_type, &mask);
+        DarwinPokeEQ();
     } darwinEvents_unlock();
 }
 
diff --git a/hw/xwin/winkeybd.c b/hw/xwin/winkeybd.c
index 912e2de..cf0dea2 100644
--- a/hw/xwin/winkeybd.c
+++ b/hw/xwin/winkeybd.c
@@ -473,7 +473,6 @@ void
 winSendKeyEvent (DWORD dwKey, Bool fDown)
 {
   EventListPtr events;
-  int i, nevents;
 
   /*
    * When alt-tabing between screens we can get phantom key up messages
@@ -485,10 +484,7 @@ winSendKeyEvent (DWORD dwKey, Bool fDown)
   g_winKeyState[dwKey] = fDown;
 
   GetEventList(&events);
-  nevents = GetKeyboardEvents(events, g_pwinKeyboard, fDown ? KeyPress : KeyRelease, dwKey + MIN_KEYCODE, NULL);
-
-  for (i = 0; i < nevents; i++)
-    mieqEnqueue(g_pwinKeyboard, (InternalEvent*)events[i].event);
+  QueueKeyboardEvents(events, g_pwinKeyboard, fDown ? KeyPress : KeyRelease, dwKey + MIN_KEYCODE, NULL);
 
   winDebug("winSendKeyEvent: dwKey: %d, fDown: %d, nEvents %d\n",
            dwKey, fDown, nevents);
diff --git a/hw/xwin/winmouse.c b/hw/xwin/winmouse.c
index 080e096..0e36687 100644
--- a/hw/xwin/winmouse.c
+++ b/hw/xwin/winmouse.c
@@ -235,7 +235,6 @@ void
 winMouseButtonsSendEvent (int iEventType, int iButton)
 {
   EventListPtr events;
-  int i, nevents;
   ValuatorMask mask;
 
   if (g_winMouseButtonMap)
@@ -243,11 +242,8 @@ winMouseButtonsSendEvent (int iEventType, int iButton)
 
   valuator_mask_zero(&mask);
   GetEventList(&events);
-  nevents = GetPointerEvents(events, g_pwinPointer, iEventType, iButton,
-			     POINTER_RELATIVE, &mask);
-
-  for (i = 0; i < nevents; i++)
-    mieqEnqueue(g_pwinPointer, (InternalEvent*)events[i].event);
+  QueuePointerEvents(events, g_pwinPointer, iEventType, iButton,
+		     POINTER_RELATIVE, &mask);
 
 #if CYGDEBUG
   ErrorF("winMouseButtonsSendEvent: iEventType: %d, iButton: %d, nEvents %d\n",
@@ -367,7 +363,6 @@ winMouseButtonsHandle (ScreenPtr pScreen,
  */
 void winEnqueueMotion(int x, int y)
 {
-  int i, nevents;
   int valuators[2];
   ValuatorMask mask;
   EventListPtr events;
@@ -378,9 +373,7 @@ void winEnqueueMotion(int x, int y)
 
   valuator_mask_set_range(&mask, 0, 2, valuators);
   GetEventList(&events);
-  nevents = GetPointerEvents(events, g_pwinPointer, MotionNotify, 0,
-			     POINTER_ABSOLUTE | POINTER_SCREEN, &mask);
+  QueuePointerEvents(events, g_pwinPointer, MotionNotify, 0,
+		     POINTER_ABSOLUTE | POINTER_SCREEN, &mask);
 
-  for (i = 0; i < nevents; i++)
-    mieqEnqueue(g_pwinPointer, (InternalEvent*)events[i].event);
 }
diff --git a/include/input.h b/include/input.h
index 6799a53..100c00f 100644
--- a/include/input.h
+++ b/include/input.h
@@ -461,6 +461,14 @@ extern _X_EXPORT int GetPointerEvents(
     int flags,
     const ValuatorMask *mask);
 
+extern _X_EXPORT void QueuePointerEvents(
+    EventListPtr events,
+    DeviceIntPtr pDev,
+    int type,
+    int buttons,
+    int flags,
+    const ValuatorMask *mask);
+
 extern _X_EXPORT int GetKeyboardEvents(
     EventListPtr events,
     DeviceIntPtr pDev,
@@ -468,12 +476,25 @@ extern _X_EXPORT int GetKeyboardEvents(
     int key_code,
     const ValuatorMask *mask);
 
+extern _X_EXPORT void QueueKeyboardEvents(
+    EventListPtr events,
+    DeviceIntPtr pDev,
+    int type,
+    int key_code,
+    const ValuatorMask *mask);
+
 extern int GetProximityEvents(
     EventListPtr events,
     DeviceIntPtr pDev,
     int type,
     const ValuatorMask *mask);
 
+extern void QueueProximityEvents(
+    EventListPtr events,
+    DeviceIntPtr pDev,
+    int type,
+    const ValuatorMask *mask);
+
 extern void PostSyntheticMotion(
     DeviceIntPtr pDev,
     int x,
commit 1b8593a6c12315b1071a4fa586151e12f46458f5
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Mon May 9 15:13:17 2011 +1000

    xfree86: print the device ID to the log when adding a device.
    
    Sometimes the name isn't enough, it's handy to see the device ID's from the
    log file.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index ef4542c..aae6658 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -329,8 +329,8 @@ xf86ActivateDevice(InputInfoPtr pInfo)
     dev->config_info = xf86SetStrOption(pInfo->options, "config_info", NULL);
 
     if (serverGeneration == 1)
-        xf86Msg(X_INFO, "XINPUT: Adding extended input device \"%s\" (type: %s)\n",
-                pInfo->name, pInfo->type_name);
+        xf86Msg(X_INFO, "XINPUT: Adding extended input device \"%s\" (type: %s, id %d)\n",
+                pInfo->name, pInfo->type_name, dev->id);
 
     return dev;
 }
commit 3231962db826f5efd431596a309c96e907a191d1
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Tue May 3 03:20:23 2011 +0100

    XKB: Fix sense inversion for core MapNotify events
    
    Due to an unfortunate sense inversion incident while switching from a
    if (foo) { ... } to if (!foo) continue; style in f06a9d, we punished any
    client who attempted to use XKB to restrict the MapNotify events they
    wanted by sending them exactly the events they _didn't_ want, and
    nothing else.
    
    NewKeyboardNotifies (coming from a client setting the map with an XKB
    request, when switching between master devices, etc) weren't affected,
    but this would impact anyone using xmodmap-style core requests.  Could
    explain a fair bit.
    
    Clarified the comments while I was at it.
    
    Signed-off-by: Daniel Stone <daniel at fooishbar.org>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/xkb/xkbEvents.c b/xkb/xkbEvents.c
index d342acc..dfbf7f2 100644
--- a/xkb/xkbEvents.c
+++ b/xkb/xkbEvents.c
@@ -88,11 +88,15 @@ XkbSendLegacyMapNotify(DeviceIntPtr kbd, CARD16 xkb_event, CARD16 changed,
         if (!clients[i] || clients[i]->clientState != ClientStateRunning)
             continue;
 
-        /* Ignore clients which will have already received this.
-         * Inconsistent with themselves, but consistent with previous
-         * behaviour.*/
-        if (xkb_event == XkbMapNotify && (clients[i]->mapNotifyMask & changed))
+        /* XKB allows clients to restrict the MappingNotify events sent to
+         * them.  This was broken for three years.  Sorry. */
+        if (xkb_event == XkbMapNotify &&
+            (clients[i]->xkbClientFlags & _XkbClientInitialized) &&
+            !(clients[i]->mapNotifyMask & changed))
             continue;
+        /* Emulate previous server behaviour: any client which has activated
+         * XKB will not receive core events emulated from a NewKeyboardNotify
+         * at all. */
         if (xkb_event == XkbNewKeyboardNotify &&
             (clients[i]->xkbClientFlags & _XkbClientInitialized))
             continue;
commit 460a377ef2d645d9ae38a8356fb248ccc47bed4a
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Tue May 3 03:07:50 2011 +0100

    XKB: Send XKB events for all devices to all clients
    
    We were using XIShouldNotify(client, device) as a test for whether or
    not to send XKB map/state/etc changed events, which limits it to only
    sending events for the current ClientPointer/ClientKeyboard for that
    client.  While this makes perfect sense for core events (e.g.
    MappingNotify), XKB events carry a device ID, so are safe to send to all
    clients for all devices.
    
    Signed-off-by: Daniel Stone <daniel at fooishbar.org>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/xkb/xkbEvents.c b/xkb/xkbEvents.c
index 7f91e9a..d342acc 100644
--- a/xkb/xkbEvents.c
+++ b/xkb/xkbEvents.c
@@ -164,9 +164,6 @@ XkbSendNewKeyboardNotify(DeviceIntPtr kbd,xkbNewKeyboardNotify *pNKN)
         if (!(clients[i]->newKeyboardNotifyMask & changed))
             continue;
 
-        if (!XIShouldNotify(clients[i], kbd))
-            continue;
-
         pNKN->sequenceNumber = clients[i]->sequence;
         pNKN->time = time;
         pNKN->changed = changed;
@@ -232,8 +229,7 @@ register CARD16	changed,bState;
 	if ((!interest->client->clientGone) &&
 	    (interest->client->requestVector != InitialVector) &&
 	    (interest->client->xkbClientFlags&_XkbClientInitialized) &&
-	    (interest->stateNotifyMask&changed) &&
-            XIShouldNotify(interest->client,kbd)) {
+	    (interest->stateNotifyMask&changed)) {
 	    pSN->sequenceNumber = interest->client->sequence;
 	    pSN->time = time;
 	    pSN->changed = changed;
@@ -280,9 +276,6 @@ XkbSendMapNotify(DeviceIntPtr kbd, xkbMapNotify *pMN)
         if (!(clients[i]->mapNotifyMask & changed))
             continue;
 
-        if (!XIShouldNotify(clients[i], kbd))
-            continue;
-
         pMN->time = time;
         pMN->sequenceNumber = clients[i]->sequence;
         pMN->changed = changed;
@@ -401,8 +394,7 @@ Time 		 	time = 0;
 	if ((!interest->client->clientGone) &&
 	    (interest->client->requestVector != InitialVector) &&
 	    (interest->client->xkbClientFlags&_XkbClientInitialized) &&
-	    (interest->ctrlsNotifyMask&changedControls) &&
-            XIShouldNotify(interest->client, kbd)) {
+	    (interest->ctrlsNotifyMask&changedControls)) {
 	    if (!initialized) {
 		pCN->type = XkbEventCode + XkbEventBase;
 		pCN->xkbType = XkbControlsNotify;
@@ -450,7 +442,6 @@ CARD32		state,changed;
 	if ((!interest->client->clientGone) &&
 	    (interest->client->requestVector != InitialVector) &&
 	    (interest->client->xkbClientFlags&_XkbClientInitialized) &&
-            XIShouldNotify(interest->client, kbd) &&
 	    (((xkbType==XkbIndicatorStateNotify)&&
 				(interest->iStateNotifyMask&changed))||
 	     ((xkbType==XkbIndicatorMapNotify)&&
@@ -534,8 +525,7 @@ XID		winID = 0;
 	if ((!interest->client->clientGone) &&
 	    (interest->client->requestVector != InitialVector) &&
 	    (interest->client->xkbClientFlags&_XkbClientInitialized) &&
-	    (interest->bellNotifyMask) &&
-            XIShouldNotify(interest->client,kbd)) {
+	    (interest->bellNotifyMask)) {
 	    if (!initialized) {
 		time = GetTimeInMillis();
 		bn.type = XkbEventCode + XkbEventBase;
@@ -589,8 +579,7 @@ CARD16		sk_delay,db_delay;
 	if ((!interest->client->clientGone) &&
 	    (interest->client->requestVector != InitialVector) &&
 	    (interest->client->xkbClientFlags&_XkbClientInitialized) &&
-	    (interest->accessXNotifyMask&(1<<pEv->detail)) &&
-            XIShouldNotify(interest->client, kbd)) {
+	    (interest->accessXNotifyMask&(1<<pEv->detail))) {
 	    if (!initialized) {
 		pEv->type = XkbEventCode + XkbEventBase;
 		pEv->xkbType = XkbAccessXNotify;
@@ -637,8 +626,7 @@ CARD32		changedIndicators;
 	if ((!interest->client->clientGone) &&
 	    (interest->client->requestVector != InitialVector) &&
 	    (interest->client->xkbClientFlags&_XkbClientInitialized) &&
-	    (interest->namesNotifyMask&pEv->changed) &&
-            XIShouldNotify(interest->client, kbd)) {
+	    (interest->namesNotifyMask&pEv->changed)) {
 	    if (!initialized) {
 		pEv->type = XkbEventCode + XkbEventBase;
 		pEv->xkbType = XkbNamesNotify;
@@ -683,8 +671,7 @@ CARD16		firstSI = 0, nSI = 0, nTotalSI = 0;
 	if ((!interest->client->clientGone) &&
 	    (interest->client->requestVector != InitialVector) &&
 	    (interest->client->xkbClientFlags&_XkbClientInitialized) &&
-	    (interest->compatNotifyMask) &&
-            XIShouldNotify(interest->client, kbd)) {
+	    (interest->compatNotifyMask)) {
 	    if (!initialized) {
 		pEv->type = XkbEventCode + XkbEventBase;
 		pEv->xkbType = XkbCompatMapNotify;
@@ -736,8 +723,7 @@ Time 		 time = 0;
 	if ((!interest->client->clientGone) &&
 	    (interest->client->requestVector != InitialVector) &&
 	    (interest->client->xkbClientFlags&_XkbClientInitialized) &&
-	    (interest->actionMessageMask) &&
-            XIShouldNotify(interest->client, kbd)) {
+	    (interest->actionMessageMask)) {
 	    if (!initialized) {
 		pEv->type = XkbEventCode + XkbEventBase;
 		pEv->xkbType = XkbActionMessage;
@@ -783,8 +769,7 @@ CARD16		 reason;
 	if ((!interest->client->clientGone) &&
 	    (interest->client->requestVector != InitialVector) &&
 	    (interest->client->xkbClientFlags&_XkbClientInitialized) &&
-	    (interest->extDevNotifyMask&reason) &&
-            XIShouldNotify(interest->client, dev)) {
+	    (interest->extDevNotifyMask&reason)) {
 	    if (!initialized) {
 		pEv->type = XkbEventCode + XkbEventBase;
 		pEv->xkbType = XkbExtensionDeviceNotify;
commit a79d4544fee806a25447d0147535ebc5a1cae6b9
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Tue May 3 03:03:06 2011 +0100

    XKB: Send NewKeyboardNotify for dev before its master/slaves
    
    When we change the keymap on a device, send the NewKeyboardNotify for
    that device before we copy the keymap to and notify for its attached
    master/slave devices.
    
    Signed-off-by: Daniel Stone <daniel at fooishbar.org>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/xkb/xkb.c b/xkb/xkb.c
index 4d21200..86231a8 100644
--- a/xkb/xkb.c
+++ b/xkb/xkb.c
@@ -5871,6 +5871,18 @@ ProcXkbGetKbdByName(ClientPtr client)
 	}
 	xkb->ctrls->num_groups= nTG;
 
+	nkn.deviceID= nkn.oldDeviceID= dev->id;
+	nkn.minKeyCode= new->min_key_code;
+	nkn.maxKeyCode= new->max_key_code;
+	nkn.oldMinKeyCode= xkb->min_key_code;
+	nkn.oldMaxKeyCode= xkb->max_key_code;
+	nkn.requestMajor= XkbReqCode;
+	nkn.requestMinor= X_kbGetKbdByName;
+	nkn.changed= XkbNKN_KeycodesMask;
+	if (geom_changed)
+	    nkn.changed|= XkbNKN_GeometryMask;
+	XkbSendNewKeyboardNotify(dev,&nkn);
+
         /* Update the map and LED info on the device itself, as well as
          * any slaves if it's an MD, or its MD if it's an SD and was the
          * last device used on that MD. */
@@ -5894,18 +5906,6 @@ ProcXkbGetKbdByName(ClientPtr client)
                 XkbFreeSrvLedInfo(old_sli);
             }
         }
-
-	nkn.deviceID= nkn.oldDeviceID= dev->id;
-	nkn.minKeyCode= new->min_key_code;
-	nkn.maxKeyCode= new->max_key_code;
-	nkn.oldMinKeyCode= xkb->min_key_code;
-	nkn.oldMaxKeyCode= xkb->max_key_code;
-	nkn.requestMajor= XkbReqCode;
-	nkn.requestMinor= X_kbGetKbdByName;
-	nkn.changed= XkbNKN_KeycodesMask;
-	if (geom_changed)
-	    nkn.changed|= XkbNKN_GeometryMask;
-	XkbSendNewKeyboardNotify(dev,&nkn);
     }
     if ((new!=NULL)&&(new!=xkb)) {
 	XkbFreeKeyboard(new,XkbAllComponentsMask,TRUE);
commit c7634498d4cd42c8571805122224dc2d0e44a585
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Tue May 3 02:59:53 2011 +0100

    XKB: Remove duplicate keymap-copying loop
    
    Previously we had:
        foreach (device + slaves of device) {
            XkbCopyDeviceKeymap(i, device);
            [...]
        }
        if (device was last slave of its MD) {
            XkbCopyDeviceKeymap(master, device);
        }
    and now:
        foreach (device + slaves of device + MD if device was last slave) {
            XkbCopyDeviceKeymap(i, device);
            [...]
        }
    
    As an extra bonus, when changing the keymap on a slave device, we now
    ensure the LED info on the master is kept in sync.
    
    Signed-off-by: Daniel Stone <daniel at fooishbar.org>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/xkb/xkb.c b/xkb/xkb.c
index e17e216..4d21200 100644
--- a/xkb/xkb.c
+++ b/xkb/xkb.c
@@ -5586,6 +5586,7 @@ ProcXkbGetKbdByName(ClientPtr client)
 {
     DeviceIntPtr 		dev;
     DeviceIntPtr                tmpd;
+    DeviceIntPtr                master;
     xkbGetKbdByNameReply 	rep = {0};
     xkbGetMapReply		mrep = {0};
     xkbGetCompatMapReply	crep = {0};
@@ -5611,6 +5612,7 @@ ProcXkbGetKbdByName(ClientPtr client)
 	return BadAccess;
 
     CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, access_mode);
+    master = GetMaster(dev, MASTER_KEYBOARD);
 
     xkb = dev->key->xkbInfo->desc;
     status= Success;
@@ -5869,8 +5871,12 @@ ProcXkbGetKbdByName(ClientPtr client)
 	}
 	xkb->ctrls->num_groups= nTG;
 
+        /* Update the map and LED info on the device itself, as well as
+         * any slaves if it's an MD, or its MD if it's an SD and was the
+         * last device used on that MD. */
         for (tmpd = inputInfo.devices; tmpd; tmpd = tmpd->next) {
-            if (tmpd != dev && GetMaster(tmpd, MASTER_KEYBOARD) != dev)
+            if (tmpd != dev && GetMaster(tmpd, MASTER_KEYBOARD) != dev &&
+                (tmpd != master || dev != master->lastSlave))
                 continue;
 
             if (tmpd != dev)
@@ -5900,12 +5906,6 @@ ProcXkbGetKbdByName(ClientPtr client)
 	if (geom_changed)
 	    nkn.changed|= XkbNKN_GeometryMask;
 	XkbSendNewKeyboardNotify(dev,&nkn);
-
-	if (!IsMaster(dev)) {
-	    DeviceIntPtr master = GetMaster(dev, MASTER_KEYBOARD);
-	    if (master && master->lastSlave == dev)
-		XkbCopyDeviceKeymap(master, dev);
-	}
     }
     if ((new!=NULL)&&(new!=xkb)) {
 	XkbFreeKeyboard(new,XkbAllComponentsMask,TRUE);
commit b8540d18c7d3a0f93f9e2565a410986eddedcecb
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Tue May 3 02:50:48 2011 +0100

    XKB: Simplify a loop in ProcXkbGetKbdByName
    
    Replace:
        for (stuff; things; etc) {
            if (misc || other) {
                [...]
            }
        }
    with:
        for (stuff; things; etc) {
            if (!misc && !other)
                continue;
            [...]
        }
    
    Signed-off-by: Daniel Stone <daniel at fooishbar.org>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/xkb/xkb.c b/xkb/xkb.c
index c4cb740..e17e216 100644
--- a/xkb/xkb.c
+++ b/xkb/xkb.c
@@ -5870,21 +5870,22 @@ ProcXkbGetKbdByName(ClientPtr client)
 	xkb->ctrls->num_groups= nTG;
 
         for (tmpd = inputInfo.devices; tmpd; tmpd = tmpd->next) {
-            if ((tmpd == dev) || (!IsMaster(tmpd) && GetMaster(tmpd, MASTER_KEYBOARD) == dev)) {
-                if (tmpd != dev)
-                    XkbCopyDeviceKeymap(tmpd, dev);
-
-                if (tmpd->kbdfeed && tmpd->kbdfeed->xkb_sli) {
-                    old_sli = tmpd->kbdfeed->xkb_sli;
-                    tmpd->kbdfeed->xkb_sli = NULL;
-                    sli = XkbAllocSrvLedInfo(tmpd, tmpd->kbdfeed, NULL, 0);
-                    if (sli) {
-                        sli->explicitState = old_sli->explicitState;
-                        sli->effectiveState = old_sli->effectiveState;
-                    }
-                    tmpd->kbdfeed->xkb_sli = sli;
-                    XkbFreeSrvLedInfo(old_sli);
+            if (tmpd != dev && GetMaster(tmpd, MASTER_KEYBOARD) != dev)
+                continue;
+
+            if (tmpd != dev)
+                XkbCopyDeviceKeymap(tmpd, dev);
+
+            if (tmpd->kbdfeed && tmpd->kbdfeed->xkb_sli) {
+                old_sli = tmpd->kbdfeed->xkb_sli;
+                tmpd->kbdfeed->xkb_sli = NULL;
+                sli = XkbAllocSrvLedInfo(tmpd, tmpd->kbdfeed, NULL, 0);
+                if (sli) {
+                    sli->explicitState = old_sli->explicitState;
+                    sli->effectiveState = old_sli->effectiveState;
                 }
+                tmpd->kbdfeed->xkb_sli = sli;
+                XkbFreeSrvLedInfo(old_sli);
             }
         }
 
commit 72b6639c83df74767094a5e0c2861fdc5ea03ecd
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Tue May 3 02:39:55 2011 +0100

    XKB: Don't send unnecessary NewKeyboardNotifies
    
    In the XKB GetKeyboardByName handler, we had the following pseudocode:
        if (device was last slave of its MD) {
            XkbCopyDeviceKeymap(master, slave);
            XkbSendNewKeyboardNotify(slave, &notify);
        }
    
    Even if the SendNewKeyboardNotify line nominated the correct device,
    which it didn't, it's unnecessary as XkbCopyDeviceKeymap already sends a
    NewKeyboardNotify on the destination device.
    
    Signed-off-by: Daniel Stone <daniel at fooishbar.org>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/xkb/xkb.c b/xkb/xkb.c
index 4044d33..c4cb740 100644
--- a/xkb/xkb.c
+++ b/xkb/xkb.c
@@ -5902,10 +5902,8 @@ ProcXkbGetKbdByName(ClientPtr client)
 
 	if (!IsMaster(dev)) {
 	    DeviceIntPtr master = GetMaster(dev, MASTER_KEYBOARD);
-	    if (master && master->lastSlave == dev) {
+	    if (master && master->lastSlave == dev)
 		XkbCopyDeviceKeymap(master, dev);
-		XkbSendNewKeyboardNotify(dev,&nkn);
-	    }
 	}
     }
     if ((new!=NULL)&&(new!=xkb)) {
commit 70cef8d8baf058bacaff87ef49e3851628269597
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Wed Jan 19 20:42:10 2011 +0000

    Input: Simplify CheckPassiveGrabsOnWindow loop
    
    Instead of a mega never-ending if branch with no else, just continue
    to the next iteration of the loop if the conditions aren't met - pretty
    much entirely reindentation.
    
    Signed-off-by: Daniel Stone <daniel at fooishbar.org>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/dix/events.c b/dix/events.c
index 17194b1..895ab40 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -3430,7 +3430,7 @@ CheckPassiveGrabsOnWindow(
 	DeviceIntPtr	gdev;
 	XkbSrvInfoPtr	xkbi = NULL;
 	xEvent *xE = NULL;
-	xEvent core;
+        int count, rc;
 
 	gdev= grab->modifierDevice;
         if (grab->grabtype == GRABTYPE_CORE)
@@ -3478,135 +3478,129 @@ CheckPassiveGrabsOnWindow(
                 match = CORE_MATCH;
         }
 
-        if (match && (!grab->confineTo ||
-	     (grab->confineTo->realized &&
-				BorderSizeNotEmpty(device, grab->confineTo))))
-	{
-            int rc, count = 0;
-            xEvent *xE = NULL;
+        if (!match || (grab->confineTo &&
+                       (!grab->confineTo->realized ||
+                        !BorderSizeNotEmpty(device, grab->confineTo))))
+            continue;
 
-            grabinfo = &device->deviceGrab;
-            /* In some cases a passive core grab may exist, but the client
-             * already has a core grab on some other device. In this case we
-             * must not get the grab, otherwise we may never ungrab the
-             * device.
-             */
+        grabinfo = &device->deviceGrab;
+        /* In some cases a passive core grab may exist, but the client
+         * already has a core grab on some other device. In this case we
+         * must not get the grab, otherwise we may never ungrab the
+         * device.
+         */
 
-            if (grab->grabtype == GRABTYPE_CORE)
+        if (grab->grabtype == GRABTYPE_CORE)
+        {
+            DeviceIntPtr other;
+            BOOL interfering = FALSE;
+
+            /* A passive grab may have been created for a different device
+               than it is assigned to at this point in time.
+               Update the grab's device and modifier device to reflect the
+               current state.
+               Since XGrabDeviceButton requires to specify the
+               modifierDevice explicitly, we don't override this choice.
+               */
+            if (tempGrab.type < GenericEvent)
             {
-                DeviceIntPtr other;
-                BOOL interfering = FALSE;
-
-                /* A passive grab may have been created for a different device
-                   than it is assigned to at this point in time.
-                   Update the grab's device and modifier device to reflect the
-                   current state.
-                   Since XGrabDeviceButton requires to specify the
-                   modifierDevice explicitly, we don't override this choice.
-                   */
-                if (tempGrab.type < GenericEvent)
-                {
-                    grab->device = device;
-                    grab->modifierDevice = GetPairedDevice(device);
-                }
+                grab->device = device;
+                grab->modifierDevice = GetPairedDevice(device);
+            }
 
-                for (other = inputInfo.devices; other; other = other->next)
+            for (other = inputInfo.devices; other; other = other->next)
+            {
+                GrabPtr othergrab = other->deviceGrab.grab;
+                if (othergrab && othergrab->grabtype == GRABTYPE_CORE &&
+                    SameClient(grab, rClient(othergrab)) &&
+                    ((IsPointerDevice(grab->device) &&
+                     IsPointerDevice(othergrab->device)) ||
+                     (IsKeyboardDevice(grab->device) &&
+                      IsKeyboardDevice(othergrab->device))))
                 {
-                    GrabPtr othergrab = other->deviceGrab.grab;
-                    if (othergrab && othergrab->grabtype == GRABTYPE_CORE &&
-                        SameClient(grab, rClient(othergrab)) &&
-                        ((IsPointerDevice(grab->device) &&
-                         IsPointerDevice(othergrab->device)) ||
-                         (IsKeyboardDevice(grab->device) &&
-                          IsKeyboardDevice(othergrab->device))))
-                    {
-                        interfering = TRUE;
-                        break;
-                    }
+                    interfering = TRUE;
+                    break;
                 }
-                if (interfering)
-                    continue;
             }
+            if (interfering)
+                continue;
+        }
 
-            if (!activate)
-            {
-                return grab;
-            }
-            else if (!GetXIType(event) && !GetCoreType(event))
-            {
-                ErrorF("Event type %d in CheckPassiveGrabsOnWindow is"
-                       " neither XI 1.x nor core\n", event->any.type);
-                return NULL;
-            }
+        if (!activate)
+        {
+            return grab;
+        }
+        else if (!GetXIType(event) && !GetCoreType(event))
+        {
+            ErrorF("Event type %d in CheckPassiveGrabsOnWindow is neither"
+                   " XI 1.x nor core\n", event->any.type);
+            return NULL;
+        }
 
-            /* The only consumers of corestate are Xi 1.x and core events,
-             * which are guaranteed to come from DeviceEvents. */
-            if (match & (XI_MATCH | CORE_MATCH))
-            {
-                event->device_event.corestate &= 0x1f00;
-                event->device_event.corestate |=
-                    tempGrab.modifiersDetail.exact & (~0x1f00);
-            }
+        /* The only consumers of corestate are Xi 1.x and core events, which
+         * are guaranteed to come from DeviceEvents. */
+        if (match & (XI_MATCH | CORE_MATCH))
+        {
+            event->device_event.corestate &= 0x1f00;
+            event->device_event.corestate |= tempGrab.modifiersDetail.exact &
+                                              (~0x1f00);
+        }
 
-            if (match & CORE_MATCH)
+        if (match & CORE_MATCH)
+        {
+            rc = EventToCore(event, &xE, &count);
+            if (rc != Success)
             {
-                rc = EventToCore((InternalEvent*)event, &xE, &count);
-                if (rc != Success)
-                {
-                    if (rc != BadMatch)
-                        ErrorF("[dix] %s: core conversion failed in CPGFW "
-                                "(%d, %d).\n", device->name, event->any.type,
-                                rc);
-                    continue;
-                }
-            } else if (match & XI2_MATCH)
+                if (rc != BadMatch)
+                    ErrorF("[dix] %s: core conversion failed in CPGFW "
+                            "(%d, %d).\n", device->name, event->any.type, rc);
+                continue;
+            }
+        } else if (match & XI2_MATCH)
+        {
+            rc = EventToXI2(event, &xE);
+            if (rc != Success)
             {
-                rc = EventToXI2(event, &xE);
-                if (rc != Success)
-                {
-                    if (rc != BadMatch)
-                        ErrorF("[dix] %s: XI2 conversion failed in CPGFW "
-                                "(%d, %d).\n", device->name, event->any.type,
-                                rc);
-                    continue;
-                }
-                count = 1;
-            } else
+                if (rc != BadMatch)
+                    ErrorF("[dix] %s: XI2 conversion failed in CPGFW "
+                            "(%d, %d).\n", device->name, event->any.type, rc);
+                continue;
+            }
+            count = 1;
+        } else
+        {
+            rc = EventToXI(event, &xE, &count);
+            if (rc != Success)
             {
-                rc = EventToXI(event, &xE, &count);
-                if (rc != Success)
-                {
-                    if (rc != BadMatch)
-                        ErrorF("[dix] %s: XI conversion failed in CPGFW "
-                                "(%d, %d).\n", device->name, event->any.type,
-                                rc);
-                    continue;
-                }
+                if (rc != BadMatch)
+                    ErrorF("[dix] %s: XI conversion failed in CPGFW "
+                            "(%d, %d).\n", device->name, event->any.type, rc);
+                continue;
             }
+        }
 
-	    (*grabinfo->ActivateGrab)(device, grab, currentTime, TRUE);
+        (*grabinfo->ActivateGrab)(device, grab, currentTime, TRUE);
 
-            if (xE)
-            {
-                FixUpEventFromWindow(pSprite, xE, grab->window, None, TRUE);
+        if (xE)
+        {
+            FixUpEventFromWindow(pSprite, xE, grab->window, None, TRUE);
 
-                /* XXX: XACE? */
-                TryClientEvents(rClient(grab), device, xE, count,
-                                       GetEventFilter(device, xE),
-                                       GetEventFilter(device, xE), grab);
-            }
+            /* XXX: XACE? */
+            TryClientEvents(rClient(grab), device, xE, count,
+                            GetEventFilter(device, xE),
+                            GetEventFilter(device, xE), grab);
+        }
 
-	    if (grabinfo->sync.state == FROZEN_NO_EVENT)
-	    {
-                if (!grabinfo->sync.event)
-                    grabinfo->sync.event = calloc(1, sizeof(DeviceEvent));
-                *grabinfo->sync.event = event->device_event;
-		grabinfo->sync.state = FROZEN_WITH_EVENT;
-            }
+        if (grabinfo->sync.state == FROZEN_NO_EVENT)
+        {
+            if (!grabinfo->sync.event)
+                grabinfo->sync.event = calloc(1, sizeof(DeviceEvent));
+            *grabinfo->sync.event = event->device_event;
+            grabinfo->sync.state = FROZEN_WITH_EVENT;
+        }
 
-            free(xE);
-	    return grab;
-	}
+        free(xE);
+        return grab;
     }
     return NULL;
 #undef CORE_MATCH
commit 00ba884556c675b2b25e116f5ab4eb4590b6dd56
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Wed Jan 19 20:38:44 2011 +0000

    Input: Make CheckPassiveGrabsOnWindow take InternalEvent
    
    Previously, it only took DeviceEvents, but it would be much more useful
    if it took InternalEvents.  Any event that activates a grab must still
    be a DeviceEvent, so put in a check to enforce this.
    
    Change all callers to make the appropriate casts.
    
    Signed-off-by: Daniel Stone <daniel at fooishbar.org>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/dix/events.c b/dix/events.c
index b0107a0..17194b1 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -2663,7 +2663,8 @@ ActivateFocusInGrab(DeviceIntPtr dev, WindowPtr old, WindowPtr win)
     event.deviceid = dev->id;
     event.sourceid = dev->id;
     event.detail.button = 0;
-    rc = (CheckPassiveGrabsOnWindow(win, dev, &event, FALSE, TRUE) != NULL);
+    rc = (CheckPassiveGrabsOnWindow(win, dev, (InternalEvent *) &event, FALSE,
+                                    TRUE) != NULL);
     if (rc)
         DoEnterLeaveEvents(dev, dev->id, old, win, XINotifyPassiveUngrab);
     return rc;
@@ -2700,7 +2701,8 @@ ActivateEnterGrab(DeviceIntPtr dev, WindowPtr old, WindowPtr win)
     event.deviceid = dev->id;
     event.sourceid = dev->id;
     event.detail.button = 0;
-    rc = (CheckPassiveGrabsOnWindow(win, dev, &event, FALSE, TRUE) != NULL);
+    rc = (CheckPassiveGrabsOnWindow(win, dev, (InternalEvent *) &event, FALSE,
+                                    TRUE) != NULL);
     if (rc)
         DoEnterLeaveEvents(dev, dev->id, old, win, XINotifyPassiveGrab);
     return rc;
@@ -3387,7 +3389,7 @@ GrabPtr
 CheckPassiveGrabsOnWindow(
     WindowPtr pWin,
     DeviceIntPtr device,
-    DeviceEvent *event,
+    InternalEvent *event,
     BOOL checkCore,
     BOOL activate)
 {
@@ -3404,9 +3406,22 @@ CheckPassiveGrabsOnWindow(
 	return NULL;
     /* Fill out the grab details, but leave the type for later before
      * comparing */
+    switch (event->any.type)
+    {
+        case ET_KeyPress:
+        case ET_KeyRelease:
+            tempGrab.detail.exact = event->device_event.detail.key;
+            break;
+        case ET_ButtonPress:
+        case ET_ButtonRelease:
+            tempGrab.detail.exact = event->device_event.detail.button;
+            break;
+        default:
+            tempGrab.detail.exact = 0;
+            break;
+    }
     tempGrab.window = pWin;
     tempGrab.device = device;
-    tempGrab.detail.exact = event->detail.key;
     tempGrab.detail.pMask = NULL;
     tempGrab.modifiersDetail.pMask = NULL;
     tempGrab.next = NULL;
@@ -3414,6 +3429,8 @@ CheckPassiveGrabsOnWindow(
     {
 	DeviceIntPtr	gdev;
 	XkbSrvInfoPtr	xkbi = NULL;
+	xEvent *xE = NULL;
+	xEvent core;
 
 	gdev= grab->modifierDevice;
         if (grab->grabtype == GRABTYPE_CORE)
@@ -3439,16 +3456,15 @@ CheckPassiveGrabsOnWindow(
         tempGrab.modifiersDetail.exact = xkbi ? xkbi->state.grab_mods : 0;
 
         /* Check for XI2 and XI grabs first */
-        tempGrab.type = GetXI2Type((InternalEvent*)event);
+        tempGrab.type = GetXI2Type(event);
         tempGrab.grabtype = GRABTYPE_XI2;
         if (GrabMatchesSecond(&tempGrab, grab, FALSE))
             match = XI2_MATCH;
 
-        tempGrab.detail.exact = event->detail.key;
         if (!match)
         {
             tempGrab.grabtype = GRABTYPE_XI;
-            if ((tempGrab.type = GetXIType((InternalEvent*)event)) &&
+            if ((tempGrab.type = GetXIType(event)) &&
                 (GrabMatchesSecond(&tempGrab, grab, FALSE)))
                 match = XI_MATCH;
         }
@@ -3457,7 +3473,7 @@ CheckPassiveGrabsOnWindow(
         if (!match && checkCore)
         {
             tempGrab.grabtype = GRABTYPE_CORE;
-            if ((tempGrab.type = GetCoreType((InternalEvent*)event)) &&
+            if ((tempGrab.type = GetCoreType(event)) &&
                 (GrabMatchesSecond(&tempGrab, grab, TRUE)))
                 match = CORE_MATCH;
         }
@@ -3469,8 +3485,6 @@ CheckPassiveGrabsOnWindow(
             int rc, count = 0;
             xEvent *xE = NULL;
 
-            event->corestate &= 0x1f00;
-            event->corestate |= tempGrab.modifiersDetail.exact & (~0x1f00);
             grabinfo = &device->deviceGrab;
             /* In some cases a passive core grab may exist, but the client
              * already has a core grab on some other device. In this case we
@@ -3515,7 +3529,24 @@ CheckPassiveGrabsOnWindow(
             }
 
             if (!activate)
+            {
                 return grab;
+            }
+            else if (!GetXIType(event) && !GetCoreType(event))
+            {
+                ErrorF("Event type %d in CheckPassiveGrabsOnWindow is"
+                       " neither XI 1.x nor core\n", event->any.type);
+                return NULL;
+            }
+
+            /* The only consumers of corestate are Xi 1.x and core events,
+             * which are guaranteed to come from DeviceEvents. */
+            if (match & (XI_MATCH | CORE_MATCH))
+            {
+                event->device_event.corestate &= 0x1f00;
+                event->device_event.corestate |=
+                    tempGrab.modifiersDetail.exact & (~0x1f00);
+            }
 
             if (match & CORE_MATCH)
             {
@@ -3524,28 +3555,31 @@ CheckPassiveGrabsOnWindow(
                 {
                     if (rc != BadMatch)
                         ErrorF("[dix] %s: core conversion failed in CPGFW "
-                                "(%d, %d).\n", device->name, event->type, rc);
+                                "(%d, %d).\n", device->name, event->any.type,
+                                rc);
                     continue;
                 }
             } else if (match & XI2_MATCH)
             {
-                rc = EventToXI2((InternalEvent*)event, &xE);
+                rc = EventToXI2(event, &xE);
                 if (rc != Success)
                 {
                     if (rc != BadMatch)
                         ErrorF("[dix] %s: XI2 conversion failed in CPGFW "
-                                "(%d, %d).\n", device->name, event->type, rc);
+                                "(%d, %d).\n", device->name, event->any.type,
+                                rc);
                     continue;
                 }
                 count = 1;
             } else
             {
-                rc = EventToXI((InternalEvent*)event, &xE, &count);
+                rc = EventToXI(event, &xE, &count);
                 if (rc != Success)
                 {
                     if (rc != BadMatch)
                         ErrorF("[dix] %s: XI conversion failed in CPGFW "
-                                "(%d, %d).\n", device->name, event->type, rc);
+                                "(%d, %d).\n", device->name, event->any.type,
+                                rc);
                     continue;
                 }
             }
@@ -3566,7 +3600,7 @@ CheckPassiveGrabsOnWindow(
 	    {
                 if (!grabinfo->sync.event)
                     grabinfo->sync.event = calloc(1, sizeof(DeviceEvent));
-                *grabinfo->sync.event = *event;
+                *grabinfo->sync.event = event->device_event;
 		grabinfo->sync.state = FROZEN_WITH_EVENT;
             }
 
@@ -3641,7 +3675,8 @@ CheckDeviceGrabs(DeviceIntPtr device, DeviceEvent *event, WindowPtr ancestor)
 	for (; i < focus->traceGood; i++)
 	{
 	    pWin = focus->trace[i];
-	    if (CheckPassiveGrabsOnWindow(pWin, device, event, sendCore, TRUE))
+	    if (CheckPassiveGrabsOnWindow(pWin, device, (InternalEvent *) event,
+                                          sendCore, TRUE))
 	    {
 		ret = TRUE;
 		goto out;
@@ -3657,7 +3692,8 @@ CheckDeviceGrabs(DeviceIntPtr device, DeviceEvent *event, WindowPtr ancestor)
     for (; i < device->spriteInfo->sprite->spriteTraceGood; i++)
     {
 	pWin = device->spriteInfo->sprite->spriteTrace[i];
-	if (CheckPassiveGrabsOnWindow(pWin, device, event, sendCore, TRUE))
+	if (CheckPassiveGrabsOnWindow(pWin, device, (InternalEvent *) event,
+	                              sendCore, TRUE))
 	{
 	    ret = TRUE;
 	    goto out;
diff --git a/include/dix.h b/include/dix.h
index c201e3a..fb9be43 100644
--- a/include/dix.h
+++ b/include/dix.h
@@ -375,7 +375,7 @@ extern void ReleaseActiveGrabs(
 extern GrabPtr CheckPassiveGrabsOnWindow(
     WindowPtr /* pWin */,
     DeviceIntPtr /* device */,
-    DeviceEvent * /* event */,
+    InternalEvent * /* event */,
     BOOL /* checkCore */,
     BOOL /* activate */);
 
commit 56901998020b6f443cbaa5eb303100d979e81b22
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Thu May 5 08:48:19 2011 +1000

    input: change CHECKEVENT macro to verify_internal_event function
    
    The macro is sufficient if called during a development cycle, but not
    sufficient information when triggered by a user (e.g.
    https://bugzilla.redhat.com/show_bug.cgi?id=688693).
    
    Expand what this does to print the event content and a backtrace, so at
    least we know where we're coming from. Only the first 32 bytes are printed
    since if something goes wrong, the event we have is almost certainly an
    xEvent or xError, both restricted to 32 bytes.
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>

diff --git a/Xi/exevents.c b/Xi/exevents.c
index 76d5c37..d48d397 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -77,6 +77,7 @@ SOFTWARE.
 #include "xiquerydevice.h" /* For List*Info */
 #include "eventconvert.h"
 #include "eventstr.h"
+#include "inpututils.h"
 
 #include <X11/extensions/XKBproto.h>
 #include "xkbsrv.h"
@@ -920,7 +921,7 @@ ProcessOtherEvent(InternalEvent *ev, DeviceIntPtr device)
     DeviceIntPtr mouse = NULL, kbd = NULL;
     DeviceEvent *event = &ev->device_event;
 
-    CHECKEVENT(ev);
+    verify_internal_event(ev);
 
     if (ev->any.type == ET_RawKeyPress ||
         ev->any.type == ET_RawKeyRelease ||
diff --git a/dix/events.c b/dix/events.c
index bc08f7b..b0107a0 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -2377,7 +2377,7 @@ DeliverDeviceEvents(WindowPtr pWin, InternalEvent *event, GrabPtr grab,
     xEvent *xE = NULL, *core = NULL;
     int rc, mask, count = 0;
 
-    CHECKEVENT(event);
+    verify_internal_event(event);
 
     while (pWin)
     {
@@ -2723,7 +2723,7 @@ CheckMotion(DeviceEvent *ev, DeviceIntPtr pDev)
     WindowPtr prevSpriteWin, newSpriteWin;
     SpritePtr pSprite = pDev->spriteInfo->sprite;
 
-    CHECKEVENT(ev);
+    verify_internal_event(ev);
 
     prevSpriteWin = pSprite->win;
 
diff --git a/dix/inpututils.c b/dix/inpututils.c
index 077ffce..aeace6e 100644
--- a/dix/inpututils.c
+++ b/dix/inpututils.c
@@ -36,6 +36,7 @@
 #include "xkbsrv.h"
 #include "xkbstr.h"
 #include "inpututils.h"
+#include "eventstr.h"
 
 /* Check if a button map change is okay with the device.
  * Returns -1 for BadValue, as it collides with MappingBusy. */
@@ -556,3 +557,30 @@ CountBits(const uint8_t *mask, int len)
 
     return ret;
 }
+
+/**
+ * Verifies sanity of the event. If the event is not an internal event,
+ * memdumps the first 32 bytes of event to the log, a backtrace, then kill
+ * the server.
+ */
+void verify_internal_event(const InternalEvent *ev)
+{
+    if (ev && ev->any.header != ET_Internal)
+    {
+        int i;
+        unsigned char *data = (unsigned char*)ev;
+
+        ErrorF("dix: invalid event type %d\n", ev->any.header);
+
+        for (i = 0; i < sizeof(xEvent); i++, data++)
+        {
+            ErrorF("%02hx ", *data);
+
+            if ((i % 8) == 7)
+                ErrorF("\n");
+        }
+
+        xorg_backtrace();
+        FatalError("Wrong event type %d. Aborting server\n", ev->any.header);
+    }
+}
diff --git a/include/eventstr.h b/include/eventstr.h
index 673207c..049688c 100644
--- a/include/eventstr.h
+++ b/include/eventstr.h
@@ -68,10 +68,6 @@ enum EventType {
     ET_Internal = 0xFF /* First byte */
 };
 
-#define CHECKEVENT(ev) if (ev && ((InternalEvent*)(ev))->any.header != 0xFF) \
-                          FatalError("Wrong event type %d.\n", \
-                                     ((InternalEvent*)(ev))->any.header);
-
 /**
  * Used for ALL input device events internal in the server until
  * copied into the matching protocol event.
diff --git a/include/inpututils.h b/include/inpututils.h
index b8ca6ab..92a7543 100644
--- a/include/inpututils.h
+++ b/include/inpututils.h
@@ -37,4 +37,6 @@ struct _ValuatorMask {
     int         valuators[MAX_VALUATORS]; /* valuator data */
 };
 
+extern void verify_internal_event(const InternalEvent *ev);
+
 #endif
diff --git a/mi/mieq.c b/mi/mieq.c
index 08a0c87..3e6f931 100644
--- a/mi/mieq.c
+++ b/mi/mieq.c
@@ -156,7 +156,7 @@ mieqEnqueue(DeviceIntPtr pDev, InternalEvent *e)
     pthread_mutex_lock(&miEventQueueMutex);
 #endif
 
-    CHECKEVENT(e);
+    verify_internal_event(e);
 
     /* avoid merging events from different devices */
     if (e->any.type == ET_Motion)
@@ -292,8 +292,8 @@ static void
 FixUpEventForMaster(DeviceIntPtr mdev, DeviceIntPtr sdev,
                     InternalEvent* original, InternalEvent *master)
 {
-    CHECKEVENT(original);
-    CHECKEVENT(master);
+    verify_internal_event(original);
+    verify_internal_event(master);
     /* Ensure chained button mappings, i.e. that the detail field is the
      * value of the mapped button on the SD, not the physical button */
     if (original->any.type == ET_ButtonPress ||
@@ -323,7 +323,7 @@ CopyGetMasterEvent(DeviceIntPtr sdev,
     int type = original->any.type;
     int mtype; /* which master type? */
 
-    CHECKEVENT(original);
+    verify_internal_event(original);
 
     /* ET_XQuartz has sdev == NULL */
     if (!sdev || IsMaster(sdev) || IsFloating(sdev))
@@ -376,7 +376,7 @@ mieqProcessDeviceEvent(DeviceIntPtr dev,
     DeviceIntPtr master;
     InternalEvent mevent; /* master event */
 
-    CHECKEVENT(event);
+    verify_internal_event(event);
 
     /* Custom event handler */
     handler = miEventQueue.handlers[event->any.type];
commit bf2059b07a97e5e579c13c2c9d49707093427dc2
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Fri Apr 15 14:06:20 2011 +1000

    input: Only release SD buttons for explicit floating/reattachment (#36146)
    
    Grabbing an SD device temporary floats the device but we must not release
    the buttons. Introduced in
    
        commit 9d23459415b84606ee4f38bb2d19054c432c8552
        Author: Peter Hutterer <peter.hutterer at who-t.net>
        Date:   Fri Feb 25 11:08:19 2011 +1000
    
        dix: release all buttons and keys before reattaching a device (#34182)
    
    X.Org Bug 36146 <http://bugs.freedesktop.org/show_bug.cgi?id=36146>
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/Xi/xichangehierarchy.c b/Xi/xichangehierarchy.c
index 0736a5a..96ead6f 100644
--- a/Xi/xichangehierarchy.c
+++ b/Xi/xichangehierarchy.c
@@ -355,6 +355,7 @@ detach_slave(ClientPtr client, xXIDetachSlaveInfo *c, int flags[MAXDEVICES])
         goto unwind;
     }
 
+    ReleaseButtonsAndKeys(dev);
     AttachDevice(client, dev, NULL);
     flags[dev->id] |= XISlaveDetached;
 
@@ -406,6 +407,7 @@ attach_slave(ClientPtr client, xXIAttachSlaveInfo *c,
         goto unwind;
     }
 
+    ReleaseButtonsAndKeys(dev);
     AttachDevice(client, dev, newmaster);
     flags[dev->id] |= XISlaveAttached;
 
diff --git a/dix/devices.c b/dix/devices.c
index 3f46ad6..7968c73 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -2365,7 +2365,7 @@ RecalculateMasterButtons(DeviceIntPtr slave)
  * Generate release events for all keys/button currently down on this
  * device.
  */
-static void
+void
 ReleaseButtonsAndKeys(DeviceIntPtr dev)
 {
     EventListPtr        eventlist = InitEventList(GetMaximumEventsNum());
@@ -2434,8 +2434,6 @@ AttachDevice(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr master)
         free(dev->spriteInfo->sprite);
     }
 
-    ReleaseButtonsAndKeys(dev);
-
     oldmaster = GetMaster(dev, MASTER_ATTACHED);
     dev->master = master;
 
diff --git a/include/input.h b/include/input.h
index 86078da..6799a53 100644
--- a/include/input.h
+++ b/include/input.h
@@ -495,6 +495,8 @@ extern _X_EXPORT int GetMotionHistory(
     ScreenPtr pScreen,
     BOOL core);
 
+extern void ReleaseButtonsAndKeys(DeviceIntPtr dev);
+
 extern int AttachDevice(ClientPtr client,
                         DeviceIntPtr slave,
                         DeviceIntPtr master);
commit eac37f32b85b631d94ee3ba11fa65b9d2cb72c38
Author: Ville Syrjälä <ville.syrjala at nokia.com>
Date:   Wed Apr 13 21:46:20 2011 +0300

    composite: Recompute clipping when changing between manual and automatic redirection
    
    Call compMarkWindows() when changing between manual and automatic
    redirection modes. Otherwise the window clipping won't be recomputed
    correctly.
    
    Signed-off-by: Ville Syrjälä <ville.syrjala at nokia.com>

diff --git a/composite/compalloc.c b/composite/compalloc.c
index 37d2245..5c27631 100644
--- a/composite/compalloc.c
+++ b/composite/compalloc.c
@@ -226,6 +226,10 @@ compRedirectWindow (ClientPtr pClient, WindowPtr pWin, int update)
 	}
 	cw->update = CompositeRedirectManual;
     }
+    else if (cw->update == CompositeRedirectAutomatic && !cw->damageRegistered) {
+	if (!anyMarked)
+	    anyMarked = compMarkWindows (pWin, &pLayerWin);
+    }
 
     if (!compCheckRedirect (pWin))
     {
@@ -314,6 +318,8 @@ compFreeClientWindow (WindowPtr pWin, XID id)
     else if (cw->update == CompositeRedirectAutomatic &&
 	     !cw->damageRegistered && pWin->redirectDraw != RedirectDrawNone)
     {
+	anyMarked = compMarkWindows (pWin, &pLayerWin);
+
 	DamageRegister (&pWin->drawable, cw->damage);
 	cw->damageRegistered = TRUE;
 	pWin->redirectDraw = RedirectDrawAutomatic;
commit f2001b0f6dffa0a8f05def4a86ea37c4c91db724
Author: Ville Syrjälä <ville.syrjala at nokia.com>
Date:   Wed Apr 13 21:45:43 2011 +0300

    composite: Fix pWin->redirectDraw when changing between manual and automatic redirection
    
    compAllowPixmap() is not called when changing between manual and
    automatic redirection modes. That means pWin->redirectDraw is left
    with an incorrect value, and miComputeClips() gets confused whether
    the window is supposed to be treated as transparent or not. Fix
    the issue by updating pWin->redirectDraw in compCheckRedirect()
    even when not calling compAllocPixmap().
    
    Signed-off-by: Ville Syrjälä <ville.syrjala at nokia.com>

diff --git a/composite/compwindow.c b/composite/compwindow.c
index bcbdf35..d2a866d 100644
--- a/composite/compwindow.c
+++ b/composite/compwindow.c
@@ -171,6 +171,11 @@ compCheckRedirect (WindowPtr pWin)
 	    compRestoreWindow (pWin, pPixmap);
 	    (*pScreen->DestroyPixmap) (pPixmap);
 	}
+    } else if (should) {
+	if (cw->update == CompositeRedirectAutomatic)
+	    pWin->redirectDraw = RedirectDrawAutomatic;
+	else
+	    pWin->redirectDraw = RedirectDrawManual;
     }
     return TRUE;
 }
commit 74663e61528346aeea9c11908b6980b51dcaeb68
Author: Ville Syrjälä <ville.syrjala at nokia.com>
Date:   Mon Dec 20 16:37:24 2010 +0200

    composite: Copy the window contents back from the pixmap
    
    Since extra expose events are no longer generated during window
    unredirection, the window contents must be preserved by the server.
    So copy the window contents back from the pixmap. The copy can only
    be done after the clips have been recomputed, so delay the copy and
    the pixmap destruction until ValidateTree is done. Window borders are
    restored by HandleExposures and thus don't need to be copied back.
    
    Signed-off-by: Ville Syrjälä <ville.syrjala at nokia.com>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>

diff --git a/composite/compalloc.c b/composite/compalloc.c
index 23654a7..37d2245 100644
--- a/composite/compalloc.c
+++ b/composite/compalloc.c
@@ -239,6 +239,34 @@ compRedirectWindow (ClientPtr pClient, WindowPtr pWin, int update)
     return Success;
 }
 
+void
+compRestoreWindow (WindowPtr pWin, PixmapPtr pPixmap)
+{
+    ScreenPtr pScreen = pWin->drawable.pScreen;
+    WindowPtr pParent = pWin->parent;
+
+    if (pParent->drawable.depth == pWin->drawable.depth) {
+	GCPtr pGC = GetScratchGC (pWin->drawable.depth, pScreen);
+	int bw = (int) pWin->borderWidth;
+	int x = bw;
+	int y = bw;
+	int w = pWin->drawable.width;
+	int h = pWin->drawable.height;
+
+	if (pGC) {
+	    ChangeGCVal val;
+	    val.val = IncludeInferiors;
+	    ChangeGC (NullClient, pGC, GCSubwindowMode, &val);
+	    ValidateGC(&pWin->drawable, pGC);
+	    (*pGC->ops->CopyArea) (&pPixmap->drawable,
+				   &pWin->drawable,
+				   pGC,
+				   x, y, w, h, 0, 0);
+	    FreeScratchGC (pGC);
+	}
+    }
+}
+
 /*
  * Free one of the per-client per-window resources, clearing
  * redirect and the per-window pointer as appropriate
@@ -246,10 +274,12 @@ compRedirectWindow (ClientPtr pClient, WindowPtr pWin, int update)
 void
 compFreeClientWindow (WindowPtr pWin, XID id)
 {
+    ScreenPtr		pScreen = pWin->drawable.pScreen;
     CompWindowPtr	cw = GetCompWindow (pWin);
     CompClientWindowPtr	ccw, *prev;
     Bool		anyMarked = FALSE;
     WindowPtr		pLayerWin;
+    PixmapPtr           pPixmap = NULL;
 
     if (!cw)
 	return;
@@ -268,8 +298,10 @@ compFreeClientWindow (WindowPtr pWin, XID id)
     {
 	anyMarked = compMarkWindows (pWin, &pLayerWin);
     
-	if (pWin->redirectDraw != RedirectDrawNone)
-	    compFreePixmap (pWin);
+	if (pWin->redirectDraw != RedirectDrawNone) {
+	    pPixmap = (*pScreen->GetWindowPixmap) (pWin);
+	    compSetParentPixmap (pWin);
+	}
 
 	if (cw->damage)
 	    DamageDestroy (cw->damage);
@@ -290,6 +322,11 @@ compFreeClientWindow (WindowPtr pWin, XID id)
 
     if (anyMarked)
 	compHandleMarkedWindows (pWin, pLayerWin);
+
+    if (pPixmap) {
+	compRestoreWindow (pWin, pPixmap);
+	(*pScreen->DestroyPixmap) (pPixmap);
+    }
 }
 
 /*
@@ -621,10 +658,10 @@ compAllocPixmap (WindowPtr pWin)
 }
 
 void
-compFreePixmap (WindowPtr pWin)
+compSetParentPixmap (WindowPtr pWin)
 {
     ScreenPtr	    pScreen = pWin->drawable.pScreen;
-    PixmapPtr	    pRedirectPixmap, pParentPixmap;
+    PixmapPtr	    pParentPixmap;
     CompWindowPtr   cw = GetCompWindow (pWin);
 
     if (cw->damageRegistered)
@@ -640,11 +677,9 @@ compFreePixmap (WindowPtr pWin)
      * parent exposed area; regions beyond the parent cause crashes
      */
     RegionCopy(&pWin->borderClip, &cw->borderClip);
-    pRedirectPixmap = (*pScreen->GetWindowPixmap) (pWin);
     pParentPixmap = (*pScreen->GetWindowPixmap) (pWin->parent);
     pWin->redirectDraw = RedirectDrawNone;
     compSetPixmap (pWin, pParentPixmap);
-    (*pScreen->DestroyPixmap) (pRedirectPixmap);
 }
 
 /*
diff --git a/composite/compint.h b/composite/compint.h
index 57e0b5d..bb5335d 100644
--- a/composite/compint.h
+++ b/composite/compint.h
@@ -215,7 +215,10 @@ Bool
 compAllocPixmap (WindowPtr pWin);
 
 void
-compFreePixmap (WindowPtr pWin);
+compSetParentPixmap (WindowPtr pWin);
+
+void
+compRestoreWindow (WindowPtr pWin, PixmapPtr pPixmap);
 
 Bool
 compReallocPixmap (WindowPtr pWin, int x, int y,
diff --git a/composite/compwindow.c b/composite/compwindow.c
index 2440f18..bcbdf35 100644
--- a/composite/compwindow.c
+++ b/composite/compwindow.c
@@ -164,8 +164,13 @@ compCheckRedirect (WindowPtr pWin)
     {
 	if (should)
 	    return compAllocPixmap (pWin);
-	else
-	    compFreePixmap (pWin);
+	else {
+	    ScreenPtr pScreen = pWin->drawable.pScreen;
+	    PixmapPtr pPixmap = (*pScreen->GetWindowPixmap) (pWin);
+	    compSetParentPixmap (pWin);
+	    compRestoreWindow (pWin, pPixmap);
+	    (*pScreen->DestroyPixmap) (pPixmap);
+	}
     }
     return TRUE;
 }
@@ -583,8 +588,11 @@ compDestroyWindow (WindowPtr pWin)
     while ((csw = GetCompSubwindows (pWin)))
 	FreeResource (csw->clients->id, RT_NONE);
 
-    if (pWin->redirectDraw != RedirectDrawNone)
-	compFreePixmap (pWin);
+    if (pWin->redirectDraw != RedirectDrawNone) {
+	PixmapPtr pPixmap = (*pScreen->GetWindowPixmap) (pWin);
+	compSetParentPixmap (pWin);
+	(*pScreen->DestroyPixmap) (pPixmap);
+    }
     ret = (*pScreen->DestroyWindow) (pWin);
     cs->DestroyWindow = pScreen->DestroyWindow;
     pScreen->DestroyWindow = compDestroyWindow;
commit 193ecc8b453b22b3e60248b9354c768dbd405598
Author: Ville Syrjälä <ville.syrjala at nokia.com>
Date:   Fri Dec 17 23:46:34 2010 +0200

    composite: Get rid of the internal UnmapWindow+MapWindow cycle
    
    Eliminate the internal MapWindow+UnmapWindow cycle around window
    redirection changes. Instead do the work in a single pass by marking
    the afected windows and calling ValidateTree and HandleExposures
    directly. This gets rid of unnecessary expose events, and invalid
    ClipNotify calls during rediredction changes. Now ClipNotify will only
    get called with the final clip values, and expose events are only sent
    to areas that actually got exposed.
    
    Signed-off-by: Ville Syrjälä <ville.syrjala at nokia.com>
    Reviewed-by: Adam Jackson <ajax at redhat.com>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>

diff --git a/composite/compalloc.c b/composite/compalloc.c
index 6d10b2e..23654a7 100644
--- a/composite/compalloc.c
+++ b/composite/compalloc.c
@@ -104,6 +104,35 @@ compDestroyDamage (DamagePtr pDamage, void *closure)
     cw->damage = 0;
 }
 
+static Bool
+compMarkWindows(WindowPtr pWin,
+		WindowPtr *ppLayerWin)
+{
+    ScreenPtr pScreen = pWin->drawable.pScreen;
+    WindowPtr pLayerWin = pWin;
+
+    if (!pWin->viewable)
+	return FALSE;
+
+    (*pScreen->MarkOverlappedWindows)(pWin, pWin, &pLayerWin);
+    (*pScreen->MarkWindow)(pLayerWin->parent);
+
+    *ppLayerWin = pLayerWin;
+
+    return TRUE;
+}
+
+static void
+compHandleMarkedWindows(WindowPtr pWin, WindowPtr pLayerWin)
+{
+    ScreenPtr pScreen = pWin->drawable.pScreen;
+
+    (*pScreen->ValidateTree)(pLayerWin->parent, pLayerWin, VTOther);
+    (*pScreen->HandleExposures)(pLayerWin->parent);
+    if (pScreen->PostValidateTree)
+	(*pScreen->PostValidateTree)(pLayerWin->parent, pLayerWin, VTOther);
+}
+
 /*
  * Redirect one window for one client
  */
@@ -112,8 +141,9 @@ compRedirectWindow (ClientPtr pClient, WindowPtr pWin, int update)
 {
     CompWindowPtr	cw = GetCompWindow (pWin);
     CompClientWindowPtr	ccw;
-    Bool		wasMapped = pWin->mapped;
     CompScreenPtr       cs = GetCompScreen(pWin->drawable.pScreen);
+    WindowPtr		pLayerWin;
+    Bool		anyMarked = FALSE;
     
     if (pWin == cs->pOverlayWin) {
 	return Success;
@@ -163,12 +193,8 @@ compRedirectWindow (ClientPtr pClient, WindowPtr pWin, int update)
 	    free(cw);
 	    return BadAlloc;
 	}
-	if (wasMapped)
-	{
-	    DisableMapUnmapEvents (pWin);
-	    UnmapWindow (pWin, FALSE);
-	    EnableMapUnmapEvents (pWin);
-	}
+
+	anyMarked = compMarkWindows (pWin, &pLayerWin);
 
 	/* Make sure our borderClip is correct for ValidateTree */
 	RegionNull(&cw->borderClip);
@@ -190,16 +216,9 @@ compRedirectWindow (ClientPtr pClient, WindowPtr pWin, int update)
 	return BadAlloc;
     if (ccw->update == CompositeRedirectManual)
     {
-	/* If the window was CompositeRedirectAutomatic, then
-	 * unmap the window so that the parent clip list will
-	 * be correctly recomputed.
-	 */
-	if (pWin->mapped) 
-	{
-	    DisableMapUnmapEvents (pWin);
-	    UnmapWindow (pWin, FALSE);
-	    EnableMapUnmapEvents (pWin);
-	}
+	if (!anyMarked)
+	    anyMarked = compMarkWindows (pWin, &pLayerWin);
+
 	if (cw->damageRegistered)
 	{
 	    DamageUnregister (&pWin->drawable, cw->damage);
@@ -213,15 +232,9 @@ compRedirectWindow (ClientPtr pClient, WindowPtr pWin, int update)
 	FreeResource (ccw->id, RT_NONE);
 	return BadAlloc;
     }
-    if (wasMapped && !pWin->mapped)
-    {
-	Bool	overrideRedirect = pWin->overrideRedirect;
-	pWin->overrideRedirect = TRUE;
-	DisableMapUnmapEvents (pWin);
-	MapWindow (pWin, pClient);
-	EnableMapUnmapEvents (pWin);
-	pWin->overrideRedirect = overrideRedirect;
-    }
+
+    if (anyMarked)
+	compHandleMarkedWindows (pWin, pLayerWin);
     
     return Success;
 }
@@ -235,7 +248,8 @@ compFreeClientWindow (WindowPtr pWin, XID id)
 {
     CompWindowPtr	cw = GetCompWindow (pWin);
     CompClientWindowPtr	ccw, *prev;
-    Bool		wasMapped = pWin->mapped;
+    Bool		anyMarked = FALSE;
+    WindowPtr		pLayerWin;
 
     if (!cw)
 	return;
@@ -252,12 +266,7 @@ compFreeClientWindow (WindowPtr pWin, XID id)
     }
     if (!cw->clients)
     {
-	if (wasMapped)
-	{
-	    DisableMapUnmapEvents (pWin);
-	    UnmapWindow (pWin, FALSE);
-	    EnableMapUnmapEvents (pWin);
-	}
+	anyMarked = compMarkWindows (pWin, &pLayerWin);
     
 	if (pWin->redirectDraw != RedirectDrawNone)
 	    compFreePixmap (pWin);
@@ -278,15 +287,9 @@ compFreeClientWindow (WindowPtr pWin, XID id)
 	pWin->redirectDraw = RedirectDrawAutomatic;
 	DamageDamageRegion(&pWin->drawable, &pWin->borderSize);
     }
-    if (wasMapped && !pWin->mapped)
-    {
-	Bool	overrideRedirect = pWin->overrideRedirect;
-	pWin->overrideRedirect = TRUE;
-	DisableMapUnmapEvents (pWin);
-	MapWindow (pWin, clients[CLIENT_ID(id)]);
-	EnableMapUnmapEvents (pWin);
-	pWin->overrideRedirect = overrideRedirect;
-    }
+
+    if (anyMarked)
+	compHandleMarkedWindows (pWin, pLayerWin);
 }
 
 /*
commit a6ae91746212203a19450ac955fbb7abffff1ed3
Author: Ville Syrjälä <ville.syrjala at nokia.com>
Date:   Mon Dec 20 16:30:52 2010 +0200

    composite: Initialize borderClip with current values
    
    ValidateTree needs a valid borderClip so initialize the parent
    constrained border clip with the window's current borderClip
    in compRedirectWindow.
    
    Signed-off-by: Ville Syrjälä <ville.syrjala at nokia.com>
    Reviewed-by: Adam Jackson <ajax at redhat.com>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>

diff --git a/composite/compalloc.c b/composite/compalloc.c
index 2b68645..6d10b2e 100644
--- a/composite/compalloc.c
+++ b/composite/compalloc.c
@@ -170,9 +170,11 @@ compRedirectWindow (ClientPtr pClient, WindowPtr pWin, int update)
 	    EnableMapUnmapEvents (pWin);
 	}
 
+	/* Make sure our borderClip is correct for ValidateTree */
 	RegionNull(&cw->borderClip);
-	cw->borderClipX = 0;
-	cw->borderClipY = 0;
+	RegionCopy(&cw->borderClip, &pWin->borderClip);
+	cw->borderClipX = pWin->drawable.x;
+	cw->borderClipY = pWin->drawable.y;
 	cw->update = CompositeRedirectAutomatic;
 	cw->clients = 0;
 	cw->oldx = COMP_ORIGIN_INVALID;
commit ce9eff9e4c30deb16f059ed84b436d37da45d5d5
Author: Ville Syrjälä <ville.syrjala at nokia.com>
Date:   Mon Dec 20 16:33:36 2010 +0200

    composite: Call ValidateGC after ChangeGC
    
    ChangeGC changes the GC, so ValidateGC should be called after it, not
    before.
    
    Also pass NullClient instead of serverClient to ChangeGC() since we
    know the changed values to be valid, and setting
    serverClient->errorValue seems pointless anyway.
    
    Signed-off-by: Ville Syrjälä <ville.syrjala at nokia.com>
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Reviewed-by: Adam Jackson <ajax at redhat.com>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>

diff --git a/composite/compalloc.c b/composite/compalloc.c
index 7164c0d..2b68645 100644
--- a/composite/compalloc.c
+++ b/composite/compalloc.c
@@ -536,9 +536,8 @@ compNewPixmap (WindowPtr pWin, int x, int y, int w, int h, Bool map)
 	{
 	    ChangeGCVal val;
 	    val.val = IncludeInferiors;
-	    
+	    ChangeGC (NullClient, pGC, GCSubwindowMode, &val);
 	    ValidateGC(&pPixmap->drawable, pGC);
-	    ChangeGC (serverClient, pGC, GCSubwindowMode, &val);
 	    (*pGC->ops->CopyArea) (&pParent->drawable,
 				   &pPixmap->drawable,
 				   pGC,
commit 043c1758652259fd12b88ae37720fe6e93eda76b
Author: Alan Coopersmith <alan.coopersmith at oracle.com>
Date:   Tue Apr 19 19:02:54 2011 -0700

    Clean up memory better when GetVisualInfo fails in ProcDbeGetVisualInfo
    
    Use calloc to initialize pScrVisInfo array so we don't have to check
    which ones were already initialized when freeing them all.
    
    On failure, set rc if necessary, and jump to code at end that already
    frees all the necessary allocations and return rc.
    
    Fixes parfait reported error:
    Error: Memory leak (CWE 401)
       Memory leak of pointer 'pScrVisInfo' allocated with malloc((count * 16))
            at line 724 of dbe/dbe.c in function 'ProcDbeGetVisualInfo'.
              'pScrVisInfo' allocated at line 693 with malloc((count * 16)).
              pScrVisInfo leaks when rc != 0 at line 710
                  and j >= i at line 716.
    
    [ This bug was found by the Parfait 0.3.7 bug checking tool.
      For more information see http://labs.oracle.com/projects/parfait/ ]
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
    Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/dbe/dbe.c b/dbe/dbe.c
index 77b616b..51bbdc6 100644
--- a/dbe/dbe.c
+++ b/dbe/dbe.c
@@ -690,8 +690,7 @@ ProcDbeGetVisualInfo(ClientPtr client)
     }
 
     count = (stuff->n == 0) ? screenInfo.numScreens : stuff->n;
-    if (!(pScrVisInfo = (XdbeScreenVisualInfo *)malloc(count *
-                        sizeof(XdbeScreenVisualInfo))))
+    if (!(pScrVisInfo = calloc(count, sizeof(XdbeScreenVisualInfo))))
     {
         free(pDrawables);
 
@@ -707,21 +706,16 @@ ProcDbeGetVisualInfo(ClientPtr client)
         pDbeScreenPriv = DBE_SCREEN_PRIV(pScreen);
 
 	rc = XaceHook(XACE_SCREEN_ACCESS, client, pScreen, DixGetAttrAccess);
-	if ((rc != Success) ||
-	    !(*pDbeScreenPriv->GetVisualInfo)(pScreen, &pScrVisInfo[i]))
+        if (rc != Success)
+            goto freeScrVisInfo;
+
+        if (!(*pDbeScreenPriv->GetVisualInfo)(pScreen, &pScrVisInfo[i]))
         {
             /* We failed to alloc pScrVisInfo[i].visinfo. */
+            rc = BadAlloc;
 
             /* Free visinfos that we allocated for previous screen infos.*/
-            for (j = 0; j < i; j++)
-            {
-                free(pScrVisInfo[j].visinfo);
-            }
-
-            /* Free pDrawables if we needed to allocate it above. */
-            free(pDrawables);
-
-            return (rc == Success) ? BadAlloc : rc;
+            goto freeScrVisInfo;
         }
 
         /* Account for n, number of xDbeVisInfo items in list. */
@@ -790,6 +784,9 @@ ProcDbeGetVisualInfo(ClientPtr client)
         }
     }
 
+    rc = Success;
+
+  freeScrVisInfo:
     /* Clean up memory. */
     for (i = 0; i < count; i++)
     {
@@ -799,7 +796,7 @@ ProcDbeGetVisualInfo(ClientPtr client)
 
     free(pDrawables);
 
-    return Success;
+    return rc;
 
 } /* ProcDbeGetVisualInfo() */
 
commit dadb0791ebfd05cd3bb82d4addf0fbc21aad6fbb
Author: Alan Coopersmith <alan.coopersmith at oracle.com>
Date:   Tue Apr 19 18:53:22 2011 -0700

    Only free pContext once when AddResource fails in ProcRecordCreateContext
    
    Since RecordDeleteContext frees its argument, don't fall through to free
    it again.
    
    Error: Double free (CWE 415)
       Double free of pointer 'malloc(1072)' defined by malloc
            at line 1964 of record/record.c in function 'ProcRecordCreateContext'.
              Previously freed at line 1960 with RecordDeleteContext.
              'malloc(1072)' was allocated at line 1926 with malloc.
    
    [ This bug was found by the Parfait 0.3.7 bug checking tool.
      For more information see http://labs.oracle.com/projects/parfait/ ]
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
    Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/record/record.c b/record/record.c
index 53be182..69fca72 100644
--- a/record/record.c
+++ b/record/record.c
@@ -1958,7 +1958,7 @@ ProcRecordCreateContext(ClientPtr client)
     else
     {
 	RecordDeleteContext((pointer)pContext, pContext->id);
-	err = BadAlloc;
+	return BadAlloc;
     }
 bailout:
     free(pContext);
commit 73de54210446e9eca81b96ea6775ee5ea1a31d75
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Mon Jan 24 08:40:10 2011 +1000

    Input: Fix event size confusion in CheckPassiveGrabsOnWindow
    
    We were just storing a DeviceEvent, but allocating enough space for an
    InternalEvent.
    
    Signed-off-by: Daniel Stone <daniel at fooishbar.org>
    Reviewed-by: Julien Cristau <jcristau at debian.org>
    Reviewed-by: Adam Jackson <ajax at redhat.com>
    Reviewed-by: Cyril Brulebois <kibi at debian.org>

diff --git a/dix/events.c b/dix/events.c
index 4a2815b..bc08f7b 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -3565,7 +3565,7 @@ CheckPassiveGrabsOnWindow(
 	    if (grabinfo->sync.state == FROZEN_NO_EVENT)
 	    {
                 if (!grabinfo->sync.event)
-                    grabinfo->sync.event = calloc(1, sizeof(InternalEvent));
+                    grabinfo->sync.event = calloc(1, sizeof(DeviceEvent));
                 *grabinfo->sync.event = *event;
 		grabinfo->sync.state = FROZEN_WITH_EVENT;
             }
commit 706326491011be8cecb9b56c06f7241b7cbd425f
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Tue Jan 18 20:16:36 2011 +0000

    Input: Add DeepestSpriteWin function
    
    Does what it says on the box: returns the deepest child window in a
    given sprite's trace.
    
    Signed-off-by: Daniel Stone <daniel at fooishbar.org>
    Reviewed-by: Chase Douglas <chase.douglas at canonical.com>
    Reviewed-by: Keith Packard <keithp at keithp.com>

diff --git a/dix/events.c b/dix/events.c
index 1d513eb..4a2815b 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -2182,7 +2182,7 @@ MaybeDeliverEventsToClient(WindowPtr pWin, xEvent *pEvents,
 
 static Window FindChildForEvent(SpritePtr pSprite, WindowPtr event)
 {
-    WindowPtr w = pSprite->spriteTrace[pSprite->spriteTraceGood-1];
+    WindowPtr w = DeepestSpriteWin(pSprite);
     Window child = None;
 
     /* If the search ends up past the root should the child field be
@@ -2625,7 +2625,7 @@ XYToWindow(SpritePtr pSprite, int x, int y)
 	else
 	    pWin = pWin->nextSib;
     }
-    return pSprite->spriteTrace[pSprite->spriteTraceGood-1];
+    return DeepestSpriteWin(pSprite);
 }
 
 /**
diff --git a/include/inputstr.h b/include/inputstr.h
index bd7c78d..bc0accc 100644
--- a/include/inputstr.h
+++ b/include/inputstr.h
@@ -591,4 +591,14 @@ typedef struct _EventSyncInfo {
 
 extern EventSyncInfoRec syncEvents;
 
+/**
+ * Given a sprite, returns the window at the bottom of the trace (i.e. the
+ * furthest window from the root).
+ */
+static inline WindowPtr DeepestSpriteWin(SpritePtr sprite)
+{
+    assert(sprite->spriteTraceGood > 0);
+    return sprite->spriteTrace[sprite->spriteTraceGood - 1];
+}
+
 #endif /* INPUTSTRUCT_H */
commit 65b54548dce80c8e8ff5ff91fc4f0659e9b2d921
Author: Chase Douglas <chase.douglas at canonical.com>
Date:   Tue Jan 18 20:08:09 2011 +0000

    Input: Pass co-ordinates by reference to transformAbsolute
    
    With the upcoming XI 2.1 touch work, the co-ordinate values will need to
    be passed by reference, rather than modified in-place.
    
    Signed-off-by: Chase Douglas <chase.douglas at canonical.com>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>

diff --git a/dix/getevents.c b/dix/getevents.c
index 4267b61..5ffa1df 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -1051,23 +1051,14 @@ FreeEventList(EventListPtr list, int num_events)
 }
 
 static void
-transformAbsolute(DeviceIntPtr dev, ValuatorMask *mask)
+transformAbsolute(DeviceIntPtr dev, ValuatorMask *mask, int *x, int *y)
 {
-    struct pixman_f_vector p;
-
-    /* p' = M * p in homogeneous coordinates */
-    p.v[0] = (valuator_mask_isset(mask, 0) ? valuator_mask_get(mask, 0) :
-              dev->last.valuators[0]);
-    p.v[1] = (valuator_mask_isset(mask, 1) ? valuator_mask_get(mask, 1) :
-              dev->last.valuators[1]);
-    p.v[2] = 1.0;
+    struct pixman_f_vector p = {.v = {*x, *y, 1}};
 
     pixman_f_transform_point(&dev->transform, &p);
 
-    if (lround(p.v[0]) != dev->last.valuators[0])
-        valuator_mask_set(mask, 0, lround(p.v[0]));
-    if (lround(p.v[1]) != dev->last.valuators[1])
-        valuator_mask_set(mask, 1, lround(p.v[1]));
+    *x = lround(p.v[0]);
+    *y = lround(p.v[1]);
 }
 
 /**
@@ -1158,7 +1149,16 @@ GetPointerEvents(EventList *events, DeviceIntPtr pDev, int type, int buttons,
             }
         }
 
-        transformAbsolute(pDev, &mask);
+        x = (valuator_mask_isset(&mask, 0) ? valuator_mask_get(&mask, 0) :
+             pDev->last.valuators[0]);
+        y = (valuator_mask_isset(&mask, 1) ? valuator_mask_get(&mask, 1) :
+             pDev->last.valuators[1]);
+        transformAbsolute(pDev, &mask, &x, &y);
+        if (valuator_mask_isset(&mask, 0))
+            valuator_mask_set(&mask, 0, x);
+        if (valuator_mask_isset(&mask, 1))
+            valuator_mask_set(&mask, 1, y);
+
         moveAbsolute(pDev, &x, &y, &mask);
     } else {
         if (flags & POINTER_ACCELERATE) {
commit a14a0c711397ff7ca0220946010300fc1b2a6e67
Author: Alan Coopersmith <alan.coopersmith at oracle.com>
Date:   Fri Apr 22 22:19:39 2011 -0700

    Move event filter initializer out of the structure itself
    
    When kept in the structure, it causes the entire MAXDEVICES * 128 masks
    to be stored in the data segment and loaded from the file, and also leads
    to worries about later generations inheriting changes across server reset.
    
               text    data     bss     dec     hex filename
    Before:   91837   20528      32  112397   1b70d .libs/events.o
    After:    92277      48   20512  112837   1b8c5 .libs/events.o
    Before: 3013384  122696  163156 3299236  3257a4 Xorg
    After:  3013832  102216  183636 3299684  325964 Xorg
    
    File size before:       4337008 Xorg
    File size after:        4316568 Xorg
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
    Reviewed-by: Jamey Sharp <jamey at minilop.net>
    Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com>
    Reviewed-by: Daniel Stone <daniel at fooishbar.org>

diff --git a/dix/events.c b/dix/events.c
index d70d62f..1d513eb 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -345,8 +345,8 @@ extern int DeviceMotionNotify;
 /**
  * Event masks for each event type.
  *
- * One set of filters for each device, but only the first layer
- * is initialized. The rest is memcpy'd in InitEvents.
+ * One set of filters for each device, initialized by memcpy of
+ * default_filter in InitEvents.
  *
  * Filters are used whether a given event may be delivered to a client,
  * usually in the form of if (window-event-mask & filter); then deliver event.
@@ -355,7 +355,9 @@ extern int DeviceMotionNotify;
  * time a button is pressed, the filter is modified to also contain the
  * matching ButtonXMotion mask.
  */
-static Mask filters[MAXDEVICES][128] = {
+static Mask filters[MAXDEVICES][128];
+
+static const Mask default_filter[128] =
 {
 	NoSuchEvent,		       /* 0 */
 	NoSuchEvent,		       /* 1 */
@@ -392,7 +394,7 @@ static Mask filters[MAXDEVICES][128] = {
 	ColormapChangeMask,	       /* ColormapNotify */
 	CantBeFiltered,		       /* ClientMessage */
 	CantBeFiltered		       /* MappingNotify */
-}};
+};
 
 /**
  * For the given event, return the matching event filter. This filter may then
@@ -4977,12 +4979,9 @@ InitEvents(void)
     inputInfo.off_devices = (DeviceIntPtr)NULL;
     inputInfo.keyboard = (DeviceIntPtr)NULL;
     inputInfo.pointer = (DeviceIntPtr)NULL;
-    /* The mask for pointer motion events may have changed in the last server
-     * generation. See comment above definition of filters. */
-    filters[0][PointerMotionMask] = MotionNotify;
-    for (i = 1; i < MAXDEVICES; i++)
+    for (i = 0; i < MAXDEVICES; i++)
     {
-        memcpy(&filters[i], filters[0], sizeof(filters[0]));
+        memcpy(&filters[i], default_filter, sizeof(default_filter));
     }
 
     syncEvents.replayDev = (DeviceIntPtr)NULL;
commit 8d229c4cf9e5bde78373ef3dd32708817ac97152
Author: Alan Coopersmith <alan.coopersmith at oracle.com>
Date:   Fri Mar 11 15:43:14 2011 -0800

    Make xorg.conf.example rule compatible with Solaris make
    
    Solaris make won't substitute $< in explicit rules, only implicit ones
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
    Reviewed-by: Gaetan Nadon <memsize at videotron.ca>

diff --git a/hw/xfree86/Makefile.am b/hw/xfree86/Makefile.am
index 09d875b..f1a759a 100644
--- a/hw/xfree86/Makefile.am
+++ b/hw/xfree86/Makefile.am
@@ -112,7 +112,7 @@ CONF_SUBSTS =	-e 's|__filemansuffix__|$(FILE_MAN_SUFFIX)|g' \
 		-e 's|DEFAULTFONTPATH|$(COMPILEDDEFAULTFONTPATH)|g'
 
 xorg.conf.example: xorgconf.cpp
-	$(AM_V_GEN)$(SED) $(CONF_SUBSTS) < $< > $@
+	$(AM_V_GEN)$(SED) $(CONF_SUBSTS) < $(srcdir)/xorgconf.cpp > $@
 
 relink:
 	$(AM_V_at)rm -f Xorg && $(MAKE) Xorg
commit c6029246ddcf5ead3884dbf2ab4f57e0c3586e93
Author: Alan Coopersmith <alan.coopersmith at oracle.com>
Date:   Wed Feb 2 17:00:25 2011 -0800

    Move Xinput server API documentation from libXi to doc/xml
    
    Documentation is quite out of date but still fits better here than
    in the client library.
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
    Reviewed-by:  Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/doc/xml/Makefile.am b/doc/xml/Makefile.am
index 6c8178a..b793e7b 100644
--- a/doc/xml/Makefile.am
+++ b/doc/xml/Makefile.am
@@ -22,7 +22,7 @@
 #
 
 SUBDIRS = dtrace
-doc_sources =  Xserver-spec.xml
+doc_sources =  Xserver-spec.xml Xinput.xml
 
 # Developer's documentation is not installed
 if ENABLE_DEVEL_DOCS
diff --git a/doc/xml/Xinput.xml b/doc/xml/Xinput.xml
new file mode 100644
index 0000000..1ae7afe
--- /dev/null
+++ b/doc/xml/Xinput.xml
@@ -0,0 +1,1209 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
+                   "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd">
+
+
+<!-- lifted from troff+ms+XMan by doclifter -->
+<book id="porting">
+
+<bookinfo>
+   <title>X11 Input Extension Porting Document</title>
+   <releaseinfo>X Version 11, Release 6.7</releaseinfo>
+   <authorgroup>
+      <author>
+         <firstname>George</firstname><surname>Sachs</surname>
+         <affiliation><orgname>Hewlett-Packard</orgname></affiliation>
+      </author>
+   </authorgroup>
+   <corpname>X Consortium Standard</corpname>
+   <copyright><year>1989</year><holder>Hewlett-Packard Company</holder></copyright>
+   <copyright><year>1990</year><holder>Hewlett-Packard Company</holder></copyright>
+   <copyright><year>1991</year><holder>Hewlett-Packard Company</holder></copyright>
+
+   <copyright><year>1989</year><holder>X Consortium</holder></copyright>
+   <copyright><year>1990</year><holder>X Consortium</holder></copyright>
+   <copyright><year>1991</year><holder>X Consortium</holder></copyright>
+   <affiliation><orgname>X Consortium</orgname></affiliation>
+   <productnumber>X Version 11, Release 6.7</productnumber>
+
+<legalnotice>
+
+
+<para>
+Permission to use, copy, modify, and distribute this documentation for any purpose and without fee is
+hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
+Hewlett-Packard makes no representations about the suitability for any purpose of the information in this
+document. It is provided "as is" without express or implied warranty. This document is only a draft stan-
+dard of the X Consortium and is therefore subject to change.
+</para>
+
+<para>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:</para>
+
+<para>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:</para>
+
+<para>The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.</para>
+
+<para>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 X CONSORTIUM 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.</para>
+
+<para>Except as contained in this notice, the name of the X Consortium 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 X Consortium.</para>
+
+<para>X Window System is a trademark of The Open Group.</para>
+</legalnotice>
+
+</bookinfo>
+
+<chapter id="x11_input_extension_porting_document">
+<title>X11 Input Extension Porting Document</title>
+
+<para>
+This document is intended to aid the process of integrating the 
+X11 Input Extension into an X server.
+</para>
+<para>
+<!-- .LP -->
+Most of the functionality provided by the input extension is 
+device- and implementation-independent, and should require no changes.  
+The functionality is implemented by
+routines that typically reside in the server source tree directory 
+extensions/server/xinput.
+This extension includes functions to enable and disable input extension devices,
+select input, grab and focus those device, query and change key 
+and button mappings, and others.  The only input extension requirements 
+for the device-dependent part of X are that the input devices be 
+correctly initialized and input events from those devices be correctly
+generated.  Device-dependent X is responsible for reading input data from 
+the input device hardware and if necessary, reformatting it into X events.
+</para>
+<para>
+<!-- .LP -->
+The process of initializing input extension devices is similar to that used 
+for the core devices, and is described in the following sections.  When
+multiple input devices are attached to X server, the choice of which devices
+to initially use as the core X pointer and keyboard is left 
+implementation-dependent.  It is also up to each implementation to decide
+whether all input devices will be opened by the server during its 
+initialization and kept open for the life of the server.  The alternative is
+to open only the X keyboard and X pointer during server initialization, and
+open other input devices only when requested by a client to do so.  Either
+type of implementation is supported by the input extension.
+</para>
+<para>
+<!-- .LP -->
+Input extension events generated by the X server use the same 32-byte xEvent
+wire event as do core input events.  However, additional information must be
+sent for input extension devices, requiring that multiple xEvents be generated
+each time data is received from an input extension device.  These xEvents are
+combined into a single client XEvent by the input extension library.  A later
+section of this document describes the format and generation of input extension
+events.
+</para>
+<sect1 id="Initializing_Extension_Devices">
+<title>Initializing Extension Devices</title>
+<para>
+<!-- .LP -->
+Extension input devices are initialized in the same manner as the core 
+X input devices.  Device-Independent X provides functions that can be 
+called from DDX to initialize these devices.  Which functions are called
+and when will vary by implementation, and will depend on whether the 
+implementation opens all the input devices available to X when X is initialized,
+or waits until a client requests that a device be opened.
+In the simplest case, DDX will open all input devices as part of its
+initialization, when the InitInput routine is called.
+</para>
+<sect2 id="Summary_of_Calling_Sequence">
+<title>Summary of Calling Sequence</title>
+<para>
+<!-- .LP -->
+<literallayout class="monospaced">
+Device-Independent X       |  Device-Dependent X
+--------------------       |  -------------------             
+                           |                                        
+InitInput -------------->  |  - do device-specific initialization
+                           |                                        
+                           |  - call AddInputDevice  (deviceProc,AutoStart)
+AddInputDevice             |   
+  - creates DeviceIntRec   |
+  - records deviceProc     |
+  - adds new device to     | 
+    list of off_devices.   |
+sets dev->startup=AutoStart|           
+                           |  - call one of:                       
+                           |    - RegisterPointerDevice (X pointer)
+                           |      - processInputProc = ProcessPointerEvents
+                           |    - RegisterKeyboardDevice (X keyboard)
+                           |      - processInputProc = ProcessKeyboardEvents
+                           |    - RegisterOtherDevice  (extension device)
+                           |      - processInputProc = ProcessOtherEvents
+                           |                                        
+                           |                                        
+InitAndStartDevices -----> |  - calls deviceProc with parameters
+                           |    (DEVICE_INIT, AutoStart)
+sets dev->inited = return  |
+  value from deviceProc    |    
+                           |                                        
+                           |  - in deviceProc, do one of:                       
+                           |    - call InitPointerDeviceStruct (X pointer)
+                           |    - call InitKeyboardDeviceStruct (X keybd)
+                           |    - init extension device by calling some of:
+                           |      - InitKeyClassDeviceStruct
+                           |      - InitButtonClassDeviceStruct
+                           |      - InitValuatorClassDeviceStruct
+                           |      - InitValuatorAxisStruct
+                           |      - InitFocusClassDeviceStruct
+                           |      - InitProximityClassDeviceStruct
+                           |      - InitKbdFeedbackClassDeviceStruct
+                           |      - InitPtrFeedbackClassDeviceStruct
+                           |      - InitLedFeedbackClassDeviceStruct
+                           |      - InitStringFeedbackClassDeviceStruct
+                           |      - InitIntegerFeedbackClassDeviceStruct
+                           |      - InitBellFeedbackClassDeviceStruct
+                           |    - init device name and type by:
+                           |      - calling MakeAtom with one of the 
+                           |        predefined names
+                           |      - calling AssignTypeAndName
+                           |                                        
+                           |                                        
+for each device added      |                                        
+    by AddInputDevice,     |                                        
+    InitAndStartDevices    |                                        
+    calls EnableDevice if  |  - EnableDevice calls deviceProc with 
+    dev->startup &         |    (DEVICE_ON, AutoStart)
+    dev->inited            |  
+                           |                                        
+If deviceProc returns      |  - core devices are now enabled, extension
+    Success, EnableDevice  |    devices are now available to be accessed
+    move the device from   |    through the input extension protocol
+    inputInfo.off_devices  |    requests.                           
+    to inputInfo.devices   |                                        
+</literallayout>
+</para>
+</sect2>
+<sect2 id="Initialization_Called_From_InitInput">
+<title>Initialization Called From InitInput</title>
+<para>
+<!-- .LP -->
+InitInput is the first DDX input entry point called during X server startup.
+This routine is responsible for
+device- and implementation- specific initialization, and for calling
+AddInputDevice to create and initialize the DeviceIntRec structure for each
+input device.  AddInputDevice is passed the address of a procedure to be called
+by the DIX routine InitAndStartDevices when input devices are enabled.
+This procedure is expected to perform X initialization for the input device.
+</para>
+<para>
+<!-- .LP -->
+If the device is to be used as the X pointer, DDX should then call
+RegisterPointerDevice, passing the DeviceIntRec pointer,
+to initialize the device as the X pointer.
+</para>
+<para>
+<!-- .LP -->
+If the device is to be used as the X keyboard, DDX should instead call
+RegisterKeyboardDevice to initialize the device as the X keyboard.
+</para>
+<para>
+<!-- .LP -->
+If the device is to be used as an extension device, DDX should instead
+call RegisterOtherDevice, passing the DeviceIntPtr returned by
+AddInputDevice.
+</para>
+<para>
+<!-- .LP -->
+A sample InitInput implementation is shown below.
+</para>
+<para>
+<!-- .LP -->
+<literallayout class="monospaced">
+InitInput(argc,argv)
+    {
+    int i, numdevs, ReadInput();
+    DeviceIntPtr dev;
+    LocalDevice localdevs[LOCAL_MAX_DEVS];
+    DeviceProc kbdproc, ptrproc, extproc;
+
+    /**************************************************************
+     * Open the appropriate input devices, determine which are 
+     * available, and choose an X pointer and X keyboard device
+     * in some implementation-dependent manner.
+     ***************************************************************/
+
+    open_input_devices (&numdevs, localdevs);
+
+    /**************************************************************
+     * Register a WakeupHandler to handle input when it is generated.
+     ***************************************************************/
+
+    RegisterBlockAndWakeupHandlers (NoopDDA, ReadInput, NULL);
+
+    /**************************************************************
+     * Register the input devices with DIX.
+     ***************************************************************/
+
+    for (i=0; i<numdevs; i++)
+        {
+        if (localdevs[i].use == IsXKeyboard)
+            {
+            dev = AddInputDevice (kbdproc, TRUE);
+            RegisterKeyboardDevice (dev);
+            }
+        else if (localdevs[i].use == IsXPointer)
+            {
+            dev = AddInputDevice (ptrproc, TRUE);
+            RegisterPointerDevice (dev);
+            }
+        else 
+            {
+            dev = AddInputDevice (extproc, FALSE);
+            RegisterOtherDevice (dev);
+            }
+        if (dev == NULL)
+            FatalError ("Too many input devices.");
+        dev->devicePrivate = (pointer) &localdevs[i];
+        }
+</literallayout>
+</para>
+</sect2>
+<sect2 id="Initialization_Called_From_InitAndStartDevices">
+<title>Initialization Called From InitAndStartDevices</title>
+<para>
+<!-- .LP -->
+After InitInput has returned,
+InitAndStartDevices is the DIX routine that is called to enable input devices. 
+It calls the device control routine that was passed to AddInputDevice,
+with a mode value of DEVICE_INIT.  The action taken by the device control
+routine depends on how the device is to be used.  If the device is to be
+the X pointer, the device control routine should call
+InitPointerDeviceStruct to initialize it.  If the device is to be the
+X keyboard, the device control routine should call
+InitKeyboardDeviceStruct.  Since input extension devices may support various
+combinations of keys, buttons, valuators, and feedbacks,
+each class of input that it supports must be initialized.
+Entry points are defined by DIX to initialize each of the supported classes of
+input, and are described in the following sections.
+</para>
+<para>
+<!-- .LP -->
+A sample device control routine called from InitAndStartDevices is 
+shown below.
+</para>
+<para>
+<!-- .LP -->
+<literallayout class="monospaced">
+Bool extproc (dev, mode)
+    DeviceIntPtr dev;
+    int mode;
+    {
+    LocalDevice *localdev = (LocalDevice *) dev->devicePrivate;
+
+    switch (mode)
+        {
+        case DEVICE_INIT:
+            if (strcmp(localdev->name, XI_TABLET) == 0)
+                {
+                /****************************************************
+                 * This device reports proximity, has buttons,
+                 * reports two axes of motion, and can be focused.
+                 * It also supports the same feedbacks as the X pointer
+                 * (acceleration and threshold can be set).
+                 ****************************************************/
+
+                InitButtonClassDeviceStruct (dev, button_count, button_map);
+                InitValuatorClassDeviceStruct (dev, localdev->n_axes,);
+                    motionproc, MOTION_BUF_SIZE, Absolute);
+                for (i=0; i<localdev->n_axes; i++)
+                    InitValuatorAxisStruct (dev, i, min_val, max_val, 
+                        resolution);
+                InitFocusClassDeviceStruct (dev);
+                InitProximityClassDeviceStruct (dev);
+                InitPtrFeedbackClassDeviceStruct (dev, p_controlproc);
+                }
+            else if (strcmp(localdev->name, XI_BUTTONBOX) == 0)
+                {
+                /****************************************************
+                 * This device has keys and LEDs, and can be focused.
+                 ****************************************************/
+
+                InitKeyClassDeviceStruct (dev, syms, modmap);
+                InitFocusClassDeviceStruct (dev);
+                InitLedFeedbackClassDeviceStruct (dev, ledcontrol);
+                }
+            else if (strcmp(localdev->name, XI_KNOBBOX) == 0)
+                {
+                /****************************************************
+                 * This device reports motion.
+                 * It can be focused.
+                 ****************************************************/
+
+                InitValuatorClassDeviceStruct (dev, localdev->n_axes,);
+                    motionproc, MOTION_BUF_SIZE, Absolute);
+                for (i=0; i<localdev->n_axes; i++)
+                    InitValuatorAxisStruct (dev, i, min_val, max_val, 
+                        resolution);
+                InitFocusClassDeviceStruct (dev);
+                }
+            localdev->atom = 
+                MakeAtom(localdev->name, strlen(localdev->name), FALSE);
+            AssignTypeAndName (dev, localdev->atom, localdev->name);
+            break;
+        case DEVICE_ON:
+            AddEnabledDevice (localdev->file_ds);
+            dev->on = TRUE;
+            break;
+        case DEVICE_OFF:
+            dev->on = FALSE;
+            RemoveEnabledDevice (localdev->file_ds);
+            break;
+        case DEVICE_CLOSE:
+            break;
+        }
+    }
+</literallayout>
+</para>
+<para>
+<!-- .LP -->
+The device control routine is called with a mode value of DEVICE_ON
+by the DIX routine EnableDevice, which is called from InitAndStartDevices.  
+When called with this mode, it should call AddEnabledDevice to cause the 
+server to begin checking for available input from this device.
+</para>
+<para>
+<!-- .LP -->
+>From InitAndStartDevices, EnableDevice is called for all devices that have
+the "inited" and "startup" fields in the DeviceIntRec set to TRUE.  The
+"inited" field is set by InitAndStartDevices to the value returned by
+the deviceproc when called with a mode value of DEVICE_INIT.  The "startup"
+field is set by AddInputDevice to value of the second parameter (autoStart).
+</para>
+<para>
+<!-- .LP -->
+When the server is first initialized, it should only be checking for input
+from the core X keyboard and pointer.  One way to accomplish this is to
+call AddInputDevice for the core X keyboard and pointer with an
+autoStart value equal to TRUE, while calling AddInputDevice for 
+input extension devices with an autoStart value equal to FALSE.  If this is 
+done, EnableDevice will skip all input extension devices during server
+initialization.  In this case,
+the OpenInputDevice routine should set the "startup" field to TRUE
+when called for input extension devices.  This will cause ProcXOpenInputDevice
+to call EnableDevice for those devices when a client first does an
+XOpenDevice request.
+</para>
+</sect2>
+<sect2 id="DIX_Input_Class_Initialization_Routines">
+<title>DIX Input Class Initialization Routines</title>
+<para>
+<!-- .LP -->
+DIX routines are defined to initialize each of the defined input classes.
+The defined classes are:
+<!-- .RS -->
+<!-- .in +5n -->
+</para>
+<itemizedlist>
+  <listitem>
+    <para>
+KeyClass - the device has keys.
+    </para>
+  </listitem>
+  <listitem>
+    <para>
+ButtonClass - the device has buttons.
+    </para>
+  </listitem>
+  <listitem>
+    <para>
+ValuatorClass - the device reports motion data or positional data.
+    </para>
+  </listitem>
+  <listitem>
+    <para>
+Proximitylass - the device reports proximity information.
+    </para>
+  </listitem>
+  <listitem>
+    <para>
+FocusClass - the device can be focused.
+    </para>
+  </listitem>
+  <listitem>
+    <para>
+FeedbackClass - the device supports some kind of feedback
+<!-- .in -5n -->
+<!-- .RE -->
+    </para>
+  </listitem>
+</itemizedlist>
+<para>
+<!-- .LP -->
+DIX routines are provided to initialize the X pointer and keyboard, as in
+previous releases of X.  During X initialization, InitPointerDeviceStruct 
+is called to initialize the X pointer, and InitKeyboardDeviceStruct is
+called to initialize the X keyboard.  There is no
+corresponding routine for extension input devices, since they do not all
+support the same classes of input.  Instead, DDX is responsible for the 
+initialization of the input classes supported by extension devices.  
+A description of the routines provided by DIX to perform that initialization
+follows.
+</para>
+<sect3 id="InitKeyClassDeviceStruct">
+<title>InitKeyClassDeviceStruct</title>
+<para>
+<!-- .LP -->
+This function is provided to allocate and initialize a KeyClassRec, and 
+should be called for extension devices that have keys.  It is passed a pointer
+to the device, and pointers to arrays of keysyms and modifiers reported by
+the device.  It returns FALSE if the KeyClassRec could not be allocated,
+or if the maps for the keysyms and and modifiers could not be allocated.
+Its parameters are:
+</para>
+<para>
+<!-- .LP -->
+<literallayout class="monospaced">
+Bool
+InitKeyClassDeviceStruct(dev, pKeySyms, pModifiers)
+    DeviceIntPtr dev;
+    KeySymsPtr pKeySyms;
+    CARD8 pModifiers[];
+</literallayout>
+</para>
+<para>
+<!-- .LP -->
+The DIX entry point InitKeyboardDeviceStruct calls this routine for the
+core X keyboard.  It must be called explicitly for extension devices
+that have keys.
+</para>
+</sect3>
+<sect3 id="InitButtonClassDeviceStruct">
+<title>InitButtonClassDeviceStruct</title>
+<para>
+<!-- .LP -->
+This function is provided to allocate and initialize a ButtonClassRec, and 
+should be called for extension devices that have buttons.  It is passed a 
+pointer to the device, the number of buttons supported, and a map of the 
+reported button codes.  It returns FALSE if the ButtonClassRec could not be 
+allocated.  Its parameters are:
+</para>
+<para>
+<!-- .LP -->
+<literallayout class="monospaced">
+Bool
+InitButtonClassDeviceStruct(dev, numButtons, map)
+    register DeviceIntPtr dev;
+    int numButtons;
+    CARD8 *map;
+</literallayout>
+</para>
+<para>
+<!-- .LP -->
+The DIX entry point InitPointerDeviceStruct calls this routine for the
+core X pointer.  It must be called explicitly for extension devices that
+have buttons.
+</para>
+</sect3>
+<sect3 id="InitValuatorClassDeviceStruct">
+<title>InitValuatorClassDeviceStruct</title>
+<para>
+<!-- .LP -->
+This function is provided to allocate and initialize a ValuatorClassRec, and 
+should be called for extension devices that have valuators.  It is passed the
+number of axes of motion reported by the device, the address of the motion
+history procedure for the device, the size of the motion history buffer,
+and the mode (Absolute or Relative) of the device.  It returns FALSE if 
+the ValuatorClassRec could not be allocated.  Its parameters are:
+</para>
+<para>
+<!-- .LP -->
+<literallayout class="monospaced">
+Bool
+InitValuatorClassDeviceStruct(dev, numAxes, motionProc, numMotionEvents, mode)
+    DeviceIntPtr dev;
+    int (*motionProc)();
+    int numAxes;
+    int numMotionEvents;
+    int mode;
+</literallayout>
+</para>
+<para>
+<!-- .LP -->
+The DIX entry point InitPointerDeviceStruct calls this routine for the
+core X pointer.  It must be called explicitly for extension devices that
+report motion.
+</para>
+</sect3>
+<sect3 id="InitValuatorAxisStruct">
+<title>InitValuatorAxisStruct</title>
+<para>
+<!-- .LP -->
+This function is provided to initialize an XAxisInfoRec, and 
+should be called for core and extension devices that have valuators.  
+The space for the XAxisInfoRec is allocated by 
+the InitValuatorClassDeviceStruct function, but is not initialized.
+</para>
+<para>
+<!-- .LP -->
+InitValuatorAxisStruct should be called once for each axis of motion 
+reported by the device.  Each
+invocation should be passed the axis number (starting with 0), the
+minimum value for that axis, the maximum value for that axis, and the
+resolution of the device in counts per meter.  If the device reports
+relative motion, 0 should be reported as the minimum and maximum values.
+InitValuatorAxisStruct has the following parameters:
+<literallayout class="monospaced">
+InitValuatorAxisStruct(dev, axnum, minval, maxval, resolution)
+    DeviceIntPtr dev;
+    int axnum;
+    int minval;
+    int maxval;
+    int resolution;
+</literallayout>
+</para>
+<para>
+<!-- .LP -->
+This routine is not called by InitPointerDeviceStruct for the
+core X pointer.  It must be called explicitly for core and extension devices 
+that report motion.
+</para>
+</sect3>
+<sect3 id="InitFocusClassDeviceStruct">
+<title>InitFocusClassDeviceStruct</title>
+<para>
+<!-- .LP -->
+This function is provided to allocate and initialize a FocusClassRec, and 
+should be called for extension devices that can be focused.  It is passed a
+pointer to the device, and returns FALSE if the allocation fails.
+It has the following parameter:
+<literallayout class="monospaced">
+Bool
+InitFocusClassDeviceStruct(dev)
+    DeviceIntPtr dev;
+</literallayout>
+</para>
+<para>
+<!-- .LP -->
+The DIX entry point InitKeyboardDeviceStruct calls this routine for the
+core X keyboard.  It must be called explicitly for extension devices
+that can be focused.  Whether or not a particular device can be focused
+is left implementation-dependent.
+</para>
+</sect3>
+<sect3 id="InitProximityClassDeviceStruct">
+<title>InitProximityClassDeviceStruct</title>
+<para>
+<!-- .LP -->
+This function is provided to allocate and initialize a ProximityClassRec, and 
+should be called for extension absolute pointing devices that report proximity.
+It is passed a pointer to the device, and returns FALSE if the allocation fails.
+It has the following parameter:
+<literallayout class="monospaced">
+Bool
+InitProximityClassDeviceStruct(dev)
+    DeviceIntPtr dev;
+</literallayout>
+</para>
+</sect3>
+<sect3 id="Initializing_Feedbacks">
+<title>Initializing Feedbacks</title>
+<para>
+<!-- .LP -->
+</para>
+<sect4 id="InitKbdFeedbackClassDeviceStruct">
+<title>InitKbdFeedbackClassDeviceStruct</title>
+<para>
+<!-- .LP -->
+This function is provided to allocate and initialize a KbdFeedbackClassRec, and 
+may be called for extension devices that support some or all of the 
+feedbacks that the core keyboard supports.  It is passed a
+pointer to the device, a pointer to the procedure that sounds the bell,
+and a pointer to the device control procedure.
+It returns FALSE if the allocation fails, and has the following parameters:
+<literallayout class="monospaced">
+Bool
+InitKbdFeedbackClassDeviceStruct(dev, bellProc, controlProc)
+    DeviceIntPtr dev;
+    void (*bellProc)();
+    void (*controlProc)();
+</literallayout>
+The DIX entry point InitKeyboardDeviceStruct calls this routine for the
+core X keyboard.  It must be called explicitly for extension devices
+that have the same feedbacks as a keyboard.  Some feedbacks, such as LEDs and
+bell, can be supported either with a KbdFeedbackClass or with BellFeedbackClass
+and LedFeedbackClass feedbacks.
+</para>
+</sect4>
+<sect4 id="InitPtrFeedbackClassDeviceStruct">
+<title>InitPtrFeedbackClassDeviceStruct</title>
+<para>
+<!-- .LP -->
+This function is provided to allocate and initialize a PtrFeedbackClassRec, and 
+should be called for extension devices that allow the setting of acceleration
+and threshold.  It is passed a pointer to the device,
+and a pointer to the device control procedure.
+It returns FALSE if the allocation fails, and has the following parameters:
+<literallayout class="monospaced">
+Bool
+InitPtrFeedbackClassDeviceStruct(dev, controlProc)
+    DeviceIntPtr dev;
+    void (*controlProc)();
+</literallayout>
+</para>
+<para>
+<!-- .LP -->
+The DIX entry point InitPointerDeviceStruct calls this routine for the
+core X pointer.  It must be called explicitly for extension devices
+that support the setting of acceleration and threshold.
+</para>
+</sect4>
+<sect4 id="InitLedFeedbackClassDeviceStruct">
+<title>InitLedFeedbackClassDeviceStruct</title>
+<para>
+<!-- .LP -->
+This function is provided to allocate and initialize a LedFeedbackClassRec, and 
+should be called for extension devices that have LEDs.
+It is passed a pointer to the device,
+and a pointer to the device control procedure.
+It returns FALSE if the allocation fails, and has the following parameters:
+<literallayout class="monospaced">
+Bool
+InitLedFeedbackClassDeviceStruct(dev, controlProc)
+    DeviceIntPtr dev;
+    void (*controlProc)();
+</literallayout>
+</para>
+<para>
+<!-- .LP -->
+Up to 32 LEDs per feedback can be supported, and a device may have 
+multiple feedbacks of the same type.
+</para>
+</sect4>
+<sect4 id="InitBellFeedbackClassDeviceStruct">
+<title>InitBellFeedbackClassDeviceStruct</title>
+<para>
+<!-- .LP -->
+This function is provided to allocate and initialize a BellFeedbackClassRec, 
+and should be called for extension devices that have a bell.
+It is passed a pointer to the device,
+and a pointer to the device control procedure.
+It returns FALSE if the allocation fails, and has the following parameters:
+<literallayout class="monospaced">
+Bool
+InitBellFeedbackClassDeviceStruct(dev, bellProc, controlProc)
+    DeviceIntPtr dev;
+    void (*bellProc)();
+    void (*controlProc)();
+</literallayout>
+</para>
+</sect4>
+<sect4 id="InitStringFeedbackClassDeviceStruct">
+<title>InitStringFeedbackClassDeviceStruct</title>
+<para>
+<!-- .LP -->
+This function is provided to allocate and initialize a StringFeedbackClassRec, 
+and should be called for extension devices that have a display upon which a 
+string can be displayed.
+It is passed a pointer to the device,
+and a pointer to the device control procedure.
+It returns FALSE if the allocation fails, and has the following parameters:
+<literallayout class="monospaced">
+Bool
+InitStringFeedbackClassDeviceStruct(dev, controlProc, max_symbols, 
+	num_symbols_supported, symbols)
+    DeviceIntPtr dev;
+    void (*controlProc)();
+    int max_symbols:
+    int num_symbols_supported;
+    KeySym *symbols;
+</literallayout>
+</para>
+</sect4>
+<sect4 id="InitIntegerFeedbackClassDeviceStruct">
+<title>InitIntegerFeedbackClassDeviceStruct</title>
+<para>
+<!-- .LP -->
+This function is provided to allocate and initialize an 
+IntegerFeedbackClassRec, 
+and should be called for extension devices that have a display upon which an
+integer can be displayed.
+It is passed a pointer to the device,
+and a pointer to the device control procedure.
+It returns FALSE if the allocation fails, and has the following parameters:
+<literallayout class="monospaced">
+Bool
+InitIntegerFeedbackClassDeviceStruct(dev, controlProc)
+    DeviceIntPtr dev;
+    void (*controlProc)();
+</literallayout>
+</para>
+</sect4>
+</sect3>
+</sect2>
+<sect2 id="Initializing_The_Device_Name_And_Type">
+<title>Initializing The Device Name And Type</title>
+<para>
+<!-- .LP -->
+The device name and type can be initialized by calling AssignTypeAndName
+with the following parameters:
+<literallayout class="monospaced">
+void
+AssignTypeAndName(dev, type, name)
+    DeviceIntPtr dev;
+    Atom type;
+    char *name;
+</literallayout>
+</para>
+<para>
+<!-- .LP -->
+This will allocate space for the device name and copy the name that was passed.
+The device type can be obtained by calling MakeAtom with one of the names
+defined for input devices.  MakeAtom has the following parameters:
+<literallayout class="monospaced">
+Atom
+MakeAtom(name, len, makeit)
+    char *name;
+    int len;
+    Bool makeit;
+</literallayout>
+</para>
+<para>
+<!-- .LP -->
+Since the atom was already made when the input extension was initialized, the
+value of makeit should be FALSE;
+</para>
+</sect2>
+</sect1>
+<sect1 id="Closing_Extension_Devices">
+<title>Closing Extension Devices</title>
+<para>
+<!-- .LP -->
+The DisableDevice entry point is provided by DIX to disable input devices.
+It calls the device control routine for the specified
+device with a mode value of DEVICE_OFF.  The device control routine should
+call RemoveEnabledDevice to stop the server from checking for input from
+that device.
+</para>
+<para>
+<!-- .LP -->
+DisableDevice is not called by any input extension routines.  It can be 
+called from the CloseInputDevice routine, which is called by
+ProcXCloseDevice when a client makes an XCloseDevice request.  If
+DisableDevice is called, it should only be called when the last client
+using the extension device has terminated or called XCloseDevice.
+</para>
+</sect1>
+<sect1 id="Implementation_Dependent_Routines">
+<title>Implementation-Dependent Routines</title>
+<para>
+<!-- .LP -->
+Several input extension protocol requests have 
+implementation-dependent  entry points.  Default routines
+are defined for these entry points and contained in the source
+file extensions/server/xinput/xstubs.c.  Some implementations may
+be able to use the default routines without change.
+The following sections describe each of these routines.
+</para>
+<sect2 id="AddOtherInputDevices">
+<title>AddOtherInputDevices</title>
+<para>
+<!-- .LP -->
+AddOtherInputDevice is called from ProcXListInputDevices as a result of 
+an XListInputDevices protocol request.  It may be needed by
+implementations that do not open extension input devices until requested
+to do so by some client.  These implementations may not initialize
+all devices when the X server starts up, because some of those devices
+may be in use.  Since the XListInputDevices
+function only lists those devices that have been initialized,
+AddOtherInputDevices is called to give DDX a chance to 
+initialize any previously unavailable input devices.
+</para>
+<para>
+<!-- .LP -->
+A sample AddOtherInputDevices routine might look like the following:
+<literallayout class="monospaced">
+void
+AddOtherInputDevices ()
+    {
+    DeviceIntPtr dev;
+    int i;
+
+    for (i=0; i<MAX_DEVICES; i++) 
+        {
+        if (!local_dev[i].initialized && available(local_dev[i]))
+            {
+            dev = (DeviceIntPtr) AddInputDevice (local_dev[i].deviceProc, TRUE);
+            dev->public.devicePrivate = local_dev[i];
+            RegisterOtherDevice (dev);
+            dev->inited = ((*dev->deviceProc)(dev, DEVICE_INIT) == Success);
+            }
+        }
+    }
+</literallayout>
+</para>
+<para>
+<!-- .LP -->
+The default AddOtherInputDevices routine in xstubs.c does nothing.
+If all input extension devices are initialized when the server 
+starts up, it can be left as a null routine.
+</para>
+</sect2>
+<sect2 id="OpenInputDevice">
+<title>OpenInputDevice</title>
+<para>
+<!-- .LP -->
+Some X server implementations open all input devices when the server
+is initialized and never close them.  Other implementations may open only
+the X pointer and keyboard devices during server initialization,
+and open other input devices only when some client makes an
+XOpenDevice request.  This entry point is for the latter type of 
+implementation.
+</para>
+<para>
+<!-- .LP -->
+If the physical device is not already open, it can be done in this routine.  
+In this case, the server must keep track of the fact that one or more clients 
+have the device open, and physically close it when the last client that has
+it open makes an XCloseDevice request.
+</para>
+<para>
+<!-- .LP -->
+The default implementation is to do nothing (assume all input devices
+are opened during X server initialization and kept open).
+</para>
+</sect2>
+<sect2 id="CloseInputDevice">
+<title>CloseInputDevice</title>
+<para>
+<!-- .LP -->
+Some implementations may close an input device when the last client
+using that device requests that it be closed, or terminates.
+CloseInputDevice is called from ProcXCloseDevice when a client
+makes an XCloseDevice protocol request.
+</para>
+<para>
+<!-- .LP -->
+The default implementation is to do nothing (assume all input devices
+are opened during X server initialization and kept open).
+</para>
+</sect2>
+<sect2 id="SetDeviceMode">
+<title>SetDeviceMode</title>
+<para>
+<!-- .LP -->
+Some implementations support input devices that can report 
+either absolute positional data or relative motion.  The XSetDeviceMode
+protocol request is provided to allow DDX to change the current mode of 
+such a device.
+</para>
+<para>
+<!-- .LP -->
+The default implementation is to always return a BadMatch error.  If the
+implementation does not support any input devices that are capable of 
+reporting both relative motion and absolute position information, the
+default implementation may be left unchanged.
+</para>
+</sect2>
+<sect2 id="SetDeviceValuators">
+<title>SetDeviceValuators</title>
+<para>
+<!-- .LP -->
+Some implementations support input devices that allow their valuators to be 
+set to an initial value.  The XSetDeviceValuators 
+protocol request is provided to allow DDX to set the valuators of
+such a device.
+</para>
+<para>
+<!-- .LP -->
+The default implementation is to always return a BadMatch error.  If the
+implementation does not support any input devices that are allow their
+valuators to be set, the default implementation may be left unchanged.
+</para>
+</sect2>
+<sect2 id="ChangePointerDevice">
+<title>ChangePointerDevice</title>
+<para>
+<!-- .LP -->
+The XChangePointerDevice protocol request is provided to change which device is
+used as the X pointer.  Some implementations may maintain information
+specific to the X pointer in the private data structure pointed to by
+the DeviceIntRec.  ChangePointerDevice is called to allow such 
+implementations to move that information to the new pointer device.
+The current location of the X cursor is an example of the type of 
+information that might be affected.
+</para>
+<para>
+<!-- .LP -->
+The DeviceIntRec structure that describes the X pointer device does not 
+contain a FocusRec.  If the device that has been made into the new X pointer 
+was previously a device that could be focused, ProcXChangePointerDevice will 
+free the FocusRec associated with that device.
+</para>
+<para>
+<!-- .LP -->
+If the server implementation desires to allow clients to focus the old pointer 
+device (which is now accessible through the input extension), it should call
+InitFocusClassDeviceStruct for the old pointer device.
+</para>
+<para>
+<!-- .LP -->
+The XChangePointerDevice protocol request also allows the client
+to choose which axes of the new pointer device are used to move 
+the X cursor in the X- and Y- directions.  If the axes are different
+than the default ones, the server implementation should record that fact.
+</para>
+<para>
+<!-- .LP -->
+If the server implementation supports input devices with valuators that 
+are not allowed to be used as the X pointer, they should be screened out
+by this routine and a  BadDevice error returned.
+</para>
+<para>
+<!-- .LP -->
+The default implementation is to do nothing. 
+</para>
+</sect2>
+<sect2 id="ChangeKeyboardDevice">
+<title>ChangeKeyboardDevice</title>
+<para>
+<!-- .LP -->
+The XChangeKeyboardDevice protocol request is provided to change which device is
+used as the X keyboard.  Some implementations may maintain information
+specific to the X keyboard in the private data structure pointed to by
+the DeviceIntRec.  ChangeKeyboardDevice is called to allow such 
+implementations to move that information to the new keyboard device.
+</para>
+<para>
+<!-- .LP -->
+The X keyboard device can be focused, and the DeviceIntRec that describes
+that device has a FocusRec.  If the device that has been made into the new X 
+keyboard did not previously have a FocusRec, 
+ProcXChangeKeyboardDevice will allocate one for it.
+</para>
+<para>
+<!-- .LP -->
+If the implementation does not want clients to be able to focus the old X 
+keyboard (which has now become available as an input extension device)
+it should call DeleteFocusClassDeviceStruct to free the FocusRec.
+</para>
+<para>
+<!-- .LP -->
+If the implementation supports input devices with keys that are not allowed
+to be used as the X keyboard, they should be checked for here, and a
+BadDevice error returned.
+</para>
+<para>
+<!-- .LP -->
+The default implementation is to do nothing. 
+</para>
+</sect2>
+</sect1>
+<sect1 id="Input_Extension_Events">
+<title>Input Extension Events</title>
+<para>
+<!-- .LP -->
+Events accessed through the input extension are analogous to the core input
+events, but have different event types.  They are of types 
+<function>DeviceKeyPress</function>, <function>DeviceKeyRelease</function>, <function>DeviceButtonPress</function>,
+<function>DeviceButtonRelease</function>, <function>DeviceDeviceMotionNotify</function>,
+<function>DeviceProximityIn</function>, <function>DeviceProximityOut</function>, and <function>DeviceValuator</function>.
+These event types are not constants.  Instead, they are external integers 
+defined by the input extension.  Their actual values will depend on which
+extensions are supported by a server, and the order in which they are
+initialized.
+</para>
+<para>
+<!-- .LP -->
+The data structures that define these
+events are defined in the file <function>extensions/include/XIproto.h</function>.  Other
+input extension constants needed by DDX are defined in the file
+<function>extensions/include/XI.h</function>.
+</para>
+<para>
+<!-- .LP -->
+Some events defined by the input extension contain more information than can
+be contained in the 32-byte xEvent data structure.  To send this information
+to clients, DDX must generate two or more 32-byte wire events.  The following
+sections describe the contents of these events. 
+</para>
+<sect2 id="Device_Key_Events">
+<title>Device Key Events</title>
+<para>
+<!-- .LP -->
+<function>DeviceKeyPresss</function> events contain all the information that is contained in
+a core <function>KeyPress</function> event, and also the following additional information:
+</para>
+<para>
+<!-- .LP -->
+<!-- .RS -->
+<!-- .in +5n -->
+</para>
+<itemizedlist>
+  <listitem>
+    <para>
+deviceid - the identifier of the device that generated the event.
+    </para>
+  </listitem>
+  <listitem>
+    <para>
+device_state - the state of any modifiers on the device that generated the event
+    </para>
+  </listitem>
+  <listitem>
+    <para>
+num_valuators - the number of valuators reported in this event.
+    </para>
+  </listitem>
+  <listitem>
+    <para>
+first_valuator - the first valuator reported in this event.
+    </para>
+  </listitem>
+  <listitem>
+    <para>
+valuator0 through valuator5 - the values of the valuators.
+<!-- .in -5n -->
+<!-- .RE -->
+    </para>
+  </listitem>
+</itemizedlist>
+<para>
+<!-- .LP -->
+In order to pass this information to the input extension library, two 32-byte
+wire events must be generated by DDX.  The first has an event type of 
+<function>DeviceKeyPress</function>, and the second has an event type of \fPDeviceValuator\fP.
+</para>
+<para>
+<!-- .LP -->
+The following code fragment shows how the two wire events could be initialized:
+</para>
+<para>
+<!-- .LP -->
+<literallayout class="monospaced">
+    extern int DeviceKeyPress;
+    DeviceIntPtr dev;
+    xEvent xE[2];
+    CARD8 id, num_valuators;
+    INT16 x, y, pointerx, pointery;
+    Time timestamp;
+    deviceKeyButtonPointer *xev = (deviceKeyButtonPointer *) xE;
+    deviceValuator *xv;
+
+    xev->type = DeviceKeyPress;                /* defined by input extension */
+    xev->detail = keycode;              /* key pressed on this device */
+    xev->time = timestamp;              /* same as for core events    */
+    xev->rootX = pointerx;              /* x location of core pointer */
+    xev->rootY = pointery;              /* y location of core pointer */
+
+    /******************************************************************/
+    /*                                                                */
+    /* The following field does not exist for core input events.      */
+    /* It contains the device id for the device that generated the    */
+    /* event, and also indicates whether more than one 32-byte wire   */
+    /* event is being sent.                                           */
+    /*                                                                */
+    /******************************************************************/
+
+    xev->deviceid = dev->id | MORE_EVENTS;        /* sending more than 1*/
+
+    /******************************************************************/
+    /* Fields in the second 32-byte wire event:                       */
+    /******************************************************************/
+
+    xv = (deviceValuator *) ++xev;
+    xv->type = DeviceValuator;          /* event type of second event */
+    xv->deviceid = dev->id;             /* id of this device          */
+    xv->num_valuators = 0;              /* no valuators being sent    */
+    xv->device_state  = 0;              /* will be filled in by DIX   */
+</literallayout>
+</para>
+</sect2>
+<sect2 id="Device_Button_Events">
+<title>Device Button Events</title>
+<para>
+<!-- .LP -->
+<function>DeviceButton</function> events contain all the information that is contained in
+a core button event, and also the same additional information that a 
+<function>DeviceKey</function> event contains.
+</para>
+</sect2>
+<sect2 id="Device_Motion_Events">
+<title>Device Motion Events</title>
+<para>
+<!-- .LP -->
+<function>DeviceMotion</function> events contain all the information that is contained in
+a core motion event, and also additional valuator information.  At least
+two wire events are required to contain this information.
+The following code fragment shows how the two wire events could be initialized:
+</para>
+<para>
+<!-- .LP -->
+<literallayout class="monospaced">
+    extern int DeviceMotionNotify;
+    DeviceIntPtr dev;
+    xEvent xE[2];
+    CARD8 id, num_valuators;
+    INT16 x, y, pointerx, pointery;
+    Time timestamp;
+    deviceKeyButtonPointer *xev = (deviceKeyButtonPointer *) xE;
+    deviceValuator *xv;
+
+    xev->type = DeviceMotionNotify;     /* defined by input extension */
+    xev->detail = keycode;              /* key pressed on this device */
+    xev->time = timestamp;              /* same as for core events    */
+    xev->rootX = pointerx;              /* x location of core pointer */
+    xev->rootY = pointery;              /* y location of core pointer */
+
+    /******************************************************************/
+    /*                                                                */
+    /* The following field does not exist for core input events.      */
+    /* It contains the device id for the device that generated the    */
+    /* event, and also indicates whether more than one 32-byte wire   */
+    /* event is being sent.                                           */
+    /*                                                                */
+    /******************************************************************/
+
+    xev->deviceid = dev->id | MORE_EVENTS;        /* sending more than 1*/
+
+    /******************************************************************/
+    /* Fields in the second 32-byte wire event:                       */
+    /******************************************************************/
+
+    xv = (deviceValuator *) ++xev;
+    xv->type = DeviceValuator;          /* event type of second event */
+    xv->deviceid = dev->id;             /* id of this device          */
+    xv->num_valuators = 2;              /* 2 valuators being sent     */
+    xv->first_valuator = 0;             /* first valuator being sent  */
+    xv->device_state  = 0;              /* will be filled in by DIX   */
+    xv->valuator0 = x;                  /* first axis of this device  */
+    xv->valuator1 = y;                  /* second axis of this device */
+</literallayout>
+</para>
+<para>
+<!-- .LP -->
+Up to six axes can be reported in the deviceValuator event.  If the device
+is reporting more than 6 axes, additional pairs of DeviceMotionNotify and
+DeviceValuator events should be sent,  with the first_valuator field
+set correctly.
+</para>
+</sect2>
+<sect2 id="Device_Proximity_Events">
+<title>Device Proximity Events</title>
+<para>
+<!-- .LP -->
+Some input devices that report absolute positional information, such as 
+graphics tablets and touchscreens, may report proximity events.  
+<function>ProximityIn</function>
+events are generated when a pointing device like a stylus, or in the case
+of a touchscreen, the user's finger, comes into close proximity with the
+surface of the input device.  <function>ProximityOut</function> events are generated when
+the stylus or finger leaves the proximity of the input devices surface.
+</para>
+<para>
+<!-- .LP -->
+<function>Proximity</function> events contain almost the same information as button events.
+The event type is <function>ProximityIn</function> or <function>ProximityOut</function>, and there is no
+detail information.
+<!-- .bp -->
+<!-- .\" .TC -->
+
+</para>
+</sect2>
+</sect1>
+</chapter>
+</book>


More information about the Xquartz-changes mailing list