xserver: Branch 'XACE-SELINUX' - 429 commits

Eamon Walsh ewalsh at kemper.freedesktop.org
Thu Nov 30 05:11:57 EET 2006


 .gitignore                                 |    1 
 GL/glx/Makefile.am                         |   10 
 GL/glx/glxdri.c                            |    7 
 GL/glx/glxext.c                            |    2 
 GL/glx/indirect_dispatch.c                 |  444 
 GL/glx/indirect_dispatch.h                 |   62 
 GL/glx/indirect_dispatch_swap.c            |  458 
 GL/glx/indirect_reqsize.c                  |    2 
 GL/glx/indirect_size_get.c                 | 1852 +-
 GL/glx/indirect_size_get.h                 |   11 
 GL/glx/indirect_table.c                    |  343 
 GL/glx/indirect_util.c                     |    2 
 GL/glx/singlepix.c                         |  167 
 GL/glx/singlepixswap.c                     |  142 
 GL/mesa/main/Makefile.am                   |    1 
 GL/symlink-mesa.sh                         |    6 
 Makefile.am                                |    8 
 Xext/security.c                            |   12 
 Xext/xace.c                                |    4 
 Xi/chgdctl.c                               |  146 
 Xi/chgkbd.c                                |  102 
 Xi/chgkbd.h                                |    5 
 Xi/chgptr.c                                |  132 
 Xi/chgptr.h                                |    5 
 Xi/exevents.c                              |   53 
 Xi/exglobals.h                             |    7 
 Xi/extinit.c                               |   46 
 Xi/getdctl.c                               |  128 
 Xi/getdctl.h                               |   18 
 Xi/listdev.c                               |   15 
 Xi/selectev.c                              |   54 
 Xi/stubs.c                                 |   99 
 cfb/cfbteblt8.c                            |    2 
 config/Makefile.am                         |   10 
 config/config.c                            |  351 
 config/dbus-api                            |   35 
 config/xorg-server.conf                    |   13 
 configure.ac                               |  403 
 dix/Makefile.am                            |   21 
 dix/Xserver-dtrace.h.in                    |  100 
 dix/Xserver.d                              |   59 
 dix/devices.c                              |  949 -
 dix/dispatch.c                             |  126 
 dix/dixfonts.c                             |   65 
 dix/events.c                               |   96 
 dix/extension.c                            |   14 
 dix/ffs.c                                  |    8 
 dix/getevents.c                            |  786 +
 dix/globals.c                              |    2 
 dix/main.c                                 |   45 
 dix/resource.c                             |   56 
 dix/window.c                               |   23 
 doc/Xserver.man.pre                        |    4 
 doc/c-extensions                           |   32 
 fb/fb.h                                    |    3 
 fb/fbpict.c                                |   40 
 fb/fbpict.h                                |   47 
 hw/darwin/darwinKeyboard.c                 |    2 
 hw/dmx/config/Makefile.am                  |    2 
 hw/dmx/dmxinput.c                          |    2 
 hw/dmx/glxProxy/Makefile.am                |    2 
 hw/dmx/input/Makefile.am                   |    2 
 hw/kdrive/Makefile.am                      |   14 
 hw/kdrive/ati/Makefile.am                  |   10 
 hw/kdrive/ati/ati_stub.c                   |   10 
 hw/kdrive/chips/Makefile.am                |    4 
 hw/kdrive/chips/chipsstub.c                |    3 
 hw/kdrive/ephyr/Makefile.am                |    5 
 hw/kdrive/ephyr/ephyr.c                    |  145 
 hw/kdrive/ephyr/ephyr.h                    |    9 
 hw/kdrive/ephyr/ephyrinit.c                |   19 
 hw/kdrive/ephyr/hostx.c                    |   32 
 hw/kdrive/ephyr/hostx.h                    |   17 
 hw/kdrive/ephyr/os.c                       |   30 
 hw/kdrive/epson/Makefile.am                |    2 
 hw/kdrive/epson/epson13806stub.c           |    6 
 hw/kdrive/fake/Makefile.am                 |    9 
 hw/kdrive/fake/fake.c                      |    6 
 hw/kdrive/fake/fake.h                      |    4 
 hw/kdrive/fake/fakeinit.c                  |   17 
 hw/kdrive/fake/kbd.c                       |   48 
 hw/kdrive/fake/mouse.c                     |   26 
 hw/kdrive/fbdev/Makefile.am                |   11 
 hw/kdrive/fbdev/fbdev.c                    |    6 
 hw/kdrive/fbdev/fbinit.c                   |   14 
 hw/kdrive/i810/Makefile.am                 |    2 
 hw/kdrive/i810/i810stub.c                  |    3 
 hw/kdrive/igs/igsstub.c                    |    3 
 hw/kdrive/itsy/kbd.c                       |   51 
 hw/kdrive/itsy/ts.c                        |    7 
 hw/kdrive/linux/Makefile.am                |   13 
 hw/kdrive/linux/bus.c                      |   77 
 hw/kdrive/linux/evdev.c                    |  386 
 hw/kdrive/linux/keyboard.c                 |  487 
 hw/kdrive/linux/linux.c                    |   52 
 hw/kdrive/linux/mouse.c                    |  238 
 hw/kdrive/linux/ms.c                       |   61 
 hw/kdrive/linux/ps2.c                      |   84 
 hw/kdrive/linux/ts.c                       |  138 
 hw/kdrive/linux/tslib.c                    |  351 
 hw/kdrive/mach64/Makefile.am               |    6 
 hw/kdrive/mach64/mach64stub.c              |    3 
 hw/kdrive/mga/Makefile.am                  |   11 
 hw/kdrive/mga/mgastub.c                    |    3 
 hw/kdrive/neomagic/Makefile.am             |    6 
 hw/kdrive/neomagic/neomagic.h              |    8 
 hw/kdrive/neomagic/neomagicstub.c          |    6 
 hw/kdrive/nvidia/Makefile.am               |    8 
 hw/kdrive/nvidia/nvidiastub.c              |    3 
 hw/kdrive/pcmcia/pcmciastub.c              |    3 
 hw/kdrive/pm2/Makefile.am                  |    5 
 hw/kdrive/pm2/pm2stub.c                    |    3 
 hw/kdrive/r128/Makefile.am                 |    5 
 hw/kdrive/r128/r128stub.c                  |    3 
 hw/kdrive/savage/s3stub.c                  |    8 
 hw/kdrive/sdl/Makefile.am                  |    5 
 hw/kdrive/sdl/sdl.c                        |  144 
 hw/kdrive/sis300/Makefile.am               |    6 
 hw/kdrive/sis300/sis_stub.c                |    3 
 hw/kdrive/sis530/sisstub.c                 |    3 
 hw/kdrive/smi/Makefile.am                  |    6 
 hw/kdrive/smi/smistub.c                    |    3 
 hw/kdrive/src/Makefile.am                  |    3 
 hw/kdrive/src/kdrive.c                     |  190 
 hw/kdrive/src/kdrive.h                     |  246 
 hw/kdrive/src/kinfo.c                      |   81 
 hw/kdrive/src/kinput.c                     | 1861 +-
 hw/kdrive/src/kkeymap.c                    |   66 
 hw/kdrive/src/kloadmap.c                   |    1 
 hw/kdrive/trident/tridentstub.c            |    3 
 hw/kdrive/trio/s3stub.c                    |    3 
 hw/kdrive/vesa/Makefile.am                 |    4 
 hw/kdrive/vesa/vbe.c                       |    2 
 hw/kdrive/vesa/vesa.c                      |    8 
 hw/kdrive/vesa/vesainit.c                  |   11 
 hw/kdrive/vesa/vm86.c                      |   31 
 hw/kdrive/via/Makefile.am                  |    9 
 hw/kdrive/via/viastub.c                    |    3 
 hw/kdrive/vxworks/vxkbd.c                  |    4 
 hw/kdrive/vxworks/vxworks.c                |   33 
 hw/vfb/InitInput.c                         |   13 
 hw/vfb/Makefile.am                         |    4 
 hw/xfree86/Makefile.am                     |   23 
 hw/xfree86/common/Makefile.am              |   15 
 hw/xfree86/common/vesamodes                |    6 
 hw/xfree86/common/xf86.h                   |   13 
 hw/xfree86/common/xf86AutoConfig.c         |    3 
 hw/xfree86/common/xf86Config.c             |  403 
 hw/xfree86/common/xf86Configure.c          |    6 
 hw/xfree86/common/xf86Cursor.c             |   11 
 hw/xfree86/common/xf86DGA.c                |   48 
 hw/xfree86/common/xf86Debug.c              |    2 
 hw/xfree86/common/xf86Events.c             |  951 -
 hw/xfree86/common/xf86Globals.c            |   39 
 hw/xfree86/common/xf86Helper.c             |  184 
 hw/xfree86/common/xf86InPriv.h             |    3 
 hw/xfree86/common/xf86Init.c               |  151 
 hw/xfree86/common/xf86Io.c                 |  470 
 hw/xfree86/common/xf86Kbd.c                |  394 
 hw/xfree86/common/xf86KbdBSD.c             | 1265 -
 hw/xfree86/common/xf86KbdLnx.c             |  650 -
 hw/xfree86/common/xf86KbdMach.c            |  316 
 hw/xfree86/common/xf86Keymap.h             |  454 
 hw/xfree86/common/xf86MiscExt.c            |   80 
 hw/xfree86/common/xf86Mode.c               |  694 -
 hw/xfree86/common/xf86Module.h             |    4 
 hw/xfree86/common/xf86Option.c             |    4 
 hw/xfree86/common/xf86PciInfo.h            |    4 
 hw/xfree86/common/xf86Priv.h               |   17 
 hw/xfree86/common/xf86Privstr.h            |   49 
 hw/xfree86/common/xf86Versions.c           |    3 
 hw/xfree86/common/xf86Xinput.c             | 1423 --
 hw/xfree86/common/xf86Xinput.h             |   41 
 hw/xfree86/common/xf86pciBus.c             |    6 
 hw/xfree86/common/xf86str.h                |    1 
 hw/xfree86/common/xf86xv.c                 |   66 
 hw/xfree86/common/xf86xv.h                 |    3 
 hw/xfree86/common/xf86xvpriv.h             |    1 
 hw/xfree86/ddc/Makefile.am                 |    5 
 hw/xfree86/ddc/ddcProperty.c               |  206 
 hw/xfree86/ddc/edid_modes.c                |  348 
 hw/xfree86/ddc/interpret_edid.c            |   39 
 hw/xfree86/ddc/xf86DDC.h                   |    5 
 hw/xfree86/dixmods/extmod/Makefile.am      |    2 
 hw/xfree86/doc/Makefile.am                 |    3 
 hw/xfree86/doc/changelogs/CHANGELOG        |18691 -----------------------------
 hw/xfree86/doc/changelogs/CHANGELOG.ND     |  418 
 hw/xfree86/doc/changelogs/CHANGELOG.R5     | 1249 -
 hw/xfree86/doc/man/Xorg.man.pre            |    6 
 hw/xfree86/doc/man/xorg.conf.man.pre       |    2 
 hw/xfree86/dri/Makefile.am                 |    7 
 hw/xfree86/dri/dri.c                       |   94 
 hw/xfree86/dri/dri.h                       |    2 
 hw/xfree86/dri/drimodule.c                 |   19 
 hw/xfree86/dummylib/Makefile.am            |    2 
 hw/xfree86/exa/Makefile.am                 |    2 
 hw/xfree86/fbdevhw/Makefile.am             |    2 
 hw/xfree86/i2c/Makefile.am                 |    2 
 hw/xfree86/int10/Makefile.am               |   11 
 hw/xfree86/int10/helper_exec.c             |   13 
 hw/xfree86/loader/Makefile.am              |    2 
 hw/xfree86/loader/misym.c                  |    2 
 hw/xfree86/loader/xf86sym.c                |   12 
 hw/xfree86/os-support/Makefile.am          |   15 
 hw/xfree86/os-support/bsd/Makefile.am      |    9 
 hw/xfree86/os-support/bsd/bsd_KbdMap.c     | 1087 -
 hw/xfree86/os-support/bsd/bsd_bell.c       |   86 
 hw/xfree86/os-support/bsd/bsd_io.c         |  293 
 hw/xfree86/os-support/bsd/bsd_kbd.c        |  572 
 hw/xfree86/os-support/bsd/bsd_kbd.h        |    4 
 hw/xfree86/os-support/bus/Makefile.am      |    2 
 hw/xfree86/os-support/bus/Pci.c            |    8 
 hw/xfree86/os-support/bus/Pci.h            |    4 
 hw/xfree86/os-support/bus/altixPCI.c       |    9 
 hw/xfree86/os-support/bus/linuxPci.c       |  235 
 hw/xfree86/os-support/bus/xf86Pci.h        |    1 
 hw/xfree86/os-support/drm/Makefile.am      |   19 
 hw/xfree86/os-support/drm/drmmodule.c      |   57 
 hw/xfree86/os-support/drm/xf86drm.c        | 2307 ---
 hw/xfree86/os-support/drm/xf86drmHash.c    |  432 
 hw/xfree86/os-support/drm/xf86drmRandom.c  |  216 
 hw/xfree86/os-support/drm/xf86drmSL.c      |  488 
 hw/xfree86/os-support/hurd/Makefile.am     |    4 
 hw/xfree86/os-support/hurd/hurd_bell.c     |   35 
 hw/xfree86/os-support/hurd/hurd_mouse.c    |   80 
 hw/xfree86/os-support/linux/Makefile.am    |   29 
 hw/xfree86/os-support/linux/lnx_KbdMap.c   |  606 
 hw/xfree86/os-support/linux/lnx_acpi.c     |    6 
 hw/xfree86/os-support/linux/lnx_bell.c     |   43 
 hw/xfree86/os-support/linux/lnx_io.c       |  246 
 hw/xfree86/os-support/linux/lnx_kbd.c      |  530 
 hw/xfree86/os-support/linux/lnx_kbd.h      |    4 
 hw/xfree86/os-support/linux/lnx_pci.c      |   80 
 hw/xfree86/os-support/lynxos/Makefile.am   |    1 
 hw/xfree86/os-support/lynxos/lynx_io.c     |  165 
 hw/xfree86/os-support/misc/Makefile.am     |   16 
 hw/xfree86/os-support/sco/Makefile.am      |    4 
 hw/xfree86/os-support/sco/sco_KbdMap.c     |  304 
 hw/xfree86/os-support/sco/sco_io.c         |  268 
 hw/xfree86/os-support/sco/sco_kbd.c        |  530 
 hw/xfree86/os-support/sco/sco_kbd.h        |   20 
 hw/xfree86/os-support/shared/at_scancode.c |  131 
 hw/xfree86/os-support/shared/kbd.c         |   38 
 hw/xfree86/os-support/shared/std_kbdEv.c   |   49 
 hw/xfree86/os-support/shared/sysv_kbd.c    |  105 
 hw/xfree86/os-support/solaris/Makefile.am  |   10 
 hw/xfree86/os-support/solaris/sun_bell.c   |  185 
 hw/xfree86/os-support/solaris/sun_init.c   |   31 
 hw/xfree86/os-support/solaris/sun_io.c     |  159 
 hw/xfree86/os-support/solaris/sun_kbd.c    |  660 -
 hw/xfree86/os-support/solaris/sun_kbd.h    |   72 
 hw/xfree86/os-support/solaris/sun_kbdEv.c  |  854 -
 hw/xfree86/os-support/sysv/Makefile.am     |    2 
 hw/xfree86/os-support/sysv/sysv_io.c       |   77 
 hw/xfree86/os-support/sysv/sysv_mouse.c    |    3 
 hw/xfree86/os-support/sysv/xqueue.c        |  536 
 hw/xfree86/os-support/sysv/xqueue.h        |   12 
 hw/xfree86/os-support/usl/Makefile.am      |    8 
 hw/xfree86/os-support/usl/usl_KbdMap.c     |  304 
 hw/xfree86/os-support/usl/usl_io.c         |  171 
 hw/xfree86/os-support/usl/usl_kbd.c        |  455 
 hw/xfree86/os-support/usl/usl_kbd.h        |   14 
 hw/xfree86/os-support/usl/usl_mouse.c      |    7 
 hw/xfree86/os-support/usl/usl_xqueue.c     |  360 
 hw/xfree86/os-support/usl/usl_xqueue.h     |    9 
 hw/xfree86/os-support/xf86OSKbd.h          |  132 
 hw/xfree86/os-support/xf86_OSlib.h         |    9 
 hw/xfree86/os-support/xf86_OSproc.h        |   21 
 hw/xfree86/os-support/xf86drm.h            |  640 
 hw/xfree86/os-support/xf86drmCompat.h      |  258 
 hw/xfree86/parser/Input.c                  |    5 
 hw/xfree86/parser/Keyboard.c               |  308 
 hw/xfree86/parser/Makefile.am              |    3 
 hw/xfree86/parser/configProcs.h            |    2 
 hw/xfree86/parser/read.c                   |    7 
 hw/xfree86/rac/Makefile.am                 |    2 
 hw/xfree86/ramdac/Makefile.am              |    2 
 hw/xfree86/scanpci/Makefile.am             |    2 
 hw/xfree86/shadowfb/Makefile.am            |    2 
 hw/xfree86/utils/cvt/Makefile.am           |    2 
 hw/xfree86/utils/ioport/Makefile.am        |    2 
 hw/xfree86/utils/pcitweak/Makefile.am      |    2 
 hw/xfree86/utils/scanpci/Makefile.am       |    2 
 hw/xfree86/utils/xorgcfg/Makefile.am       |   20 
 hw/xfree86/utils/xorgcfg/interface.c       |    3 
 hw/xfree86/utils/xorgcfg/keyboard-cfg.c    |    7 
 hw/xfree86/utils/xorgcfg/mouse-cfg.c       |    3 
 hw/xfree86/utils/xorgcfg/text-mode.c       |   17 
 hw/xfree86/utils/xorgconfig/Cards          |    5 
 hw/xfree86/utils/xorgconfig/xorgconfig.c   |   23 
 hw/xfree86/vbe/Makefile.am                 |    2 
 hw/xfree86/vgahw/Makefile.am               |    2 
 hw/xfree86/x86emu/Makefile.am              |    2 
 hw/xfree86/xaa/Makefile.am                 |    2 
 hw/xfree86/xf4bpp/Makefile.am              |    2 
 hw/xfree86/xf8_16bpp/Makefile.am           |    2 
 hw/xfree86/xf8_32bpp/Makefile.am           |    2 
 hw/xfree86/xorgconf.cpp                    |   19 
 hw/xgl/Makefile.am                         |    2 
 hw/xgl/egl/Makefile.am                     |    2 
 hw/xgl/egl/module/Makefile.am              |    1 
 hw/xgl/egl/module/xeglmodule.c             |    2 
 hw/xgl/egl/xegl.c                          |    2 
 hw/xgl/egl/xegl.h                          |    2 
 hw/xgl/egl/xeglinit.c                      |    2 
 hw/xgl/glx/Makefile.am                     |    2 
 hw/xgl/glx/module/Makefile.am              |    2 
 hw/xgl/glx/module/xglxmodule.c             |    2 
 hw/xgl/glx/xglx.c                          |    2 
 hw/xgl/glx/xglx.h                          |    2 
 hw/xgl/glx/xglxinit.c                      |    2 
 hw/xgl/glxext/Makefile.am                  |    2 
 hw/xgl/glxext/module/Makefile.am           |    2 
 hw/xgl/xglinit.c                           |    2 
 hw/xnest/Args.c                            |   15 
 hw/xnest/Events.c                          |   65 
 hw/xnest/Init.c                            |    9 
 hw/xnest/Keyboard.c                        |    8 
 hw/xnest/Pointer.c                         |    4 
 hw/xprint/ddxInit.c                        |    6 
 hw/xwin/InitInput.c                        |    2 
 hw/xwin/Makefile.am                        |    2 
 include/Makefile.am                        |    1 
 include/XIstubs.h                          |   12 
 include/config.h                           |   31 
 include/dix-config.h.in                    |   27 
 include/dix.h                              |    5 
 include/dixevents.h                        |    4 
 include/exevents.h                         |   13 
 include/extinit.h                          |    6 
 include/input.h                            |   94 
 include/inputstr.h                         |   73 
 include/kdrive-config.h.in                 |    6 
 include/os.h                               |   10 
 include/regionstr.h                        |    3 
 include/xorg-config.h.in                   |    3 
 mi/mi.h                                    |    4 
 mi/mieq.c                                  |  207 
 mi/miinitext.c                             |   14 
 mi/mipointer.c                             |  198 
 mi/mipointer.h                             |   65 
 mi/mipointrst.h                            |   10 
 mi/miregion.c                              |    5 
 os/Makefile.am                             |   40 
 os/WaitFor.c                               |   46 
 os/connection.c                            |   94 
 os/log.c                                   |    2 
 os/utils.c                                 |   30 
 randr/Makefile.am                          |   12 
 randr/mirandr.c                            |  165 
 randr/randr.c                              | 1298 --
 randr/randrstr.h                           |  748 +
 randr/rrcrtc.c                             |  848 +
 randr/rrdispatch.c                         |  210 
 randr/rrinfo.c                             |  342 
 randr/rrmode.c                             |  221 
 randr/rroutput.c                           |  463 
 randr/rrpointer.c                          |  137 
 randr/rrproperty.c                         |  624 
 randr/rrscreen.c                           |  913 +
 randr/rrsdispatch.c                        |  305 
 randr/rrxinerama.c                         |  431 
 xfixes/xfixes.c                            |   17 
 xkb/XKBAlloc.c                             |    5 
 xkb/ddxBeep.c                              |   32 
 xkb/ddxLoad.c                              |   24 
 xkb/xkb.c                                  |  500 
 xkb/xkb.h                                  |    5 
 xkb/xkbAccessX.c                           |   10 
 xkb/xkbActions.c                           |    4 
 xkb/xkbEvents.c                            |    2 
 xkb/xkbLEDs.c                              |   24 
 xkb/xkbUtils.c                             | 1170 +
 373 files changed, 18682 insertions(+), 47370 deletions(-)

New commits:
diff-tree 143558500a89a5c887c75c03798bae68c953cac9 (from parents)
Merge: e3d3d29db5eef057b4e8294377c9c3147436bc2f ee9bdd3f4a14a42fb0747acc420966f0f669129b
Author: Eamon Walsh <ewalsh at tycho.nsa.gov>
Date:   Wed Nov 29 20:41:41 2006 -0500

    Merge branch 'master' into my-XACE-SELINUX

diff --cc configure.ac
index 2d2f299,db2234f..3731204
@@@ -412,10 -439,9 +439,10 @@@
  AC_ARG_ENABLE(glx-tls,        AS_HELP_STRING([--enable-glx-tls], [Build GLX with TLS support (default: disabled)]), [GLX_USE_TLS=$enableval], [GLX_USE_TLS=no])
  AC_ARG_ENABLE(dri,            AS_HELP_STRING([--enable-dri], [Build DRI extension (default: auto)]), [DRI=$enableval])
  AC_ARG_ENABLE(xinerama,	      AS_HELP_STRING([--disable-xinerama], [Build Xinerama extension (default: enabled)]), [XINERAMA=$enableval], [XINERAMA=yes])
- AC_ARG_ENABLE(xf86vidmode,    AS_HELP_STRING([--disable-xf86vidmode], [Build XF86VidMode extension (default: enabled)]), [XF86VIDMODE=$enableval], [XF86VIDMODE=yes])
- AC_ARG_ENABLE(xf86misc,       AS_HELP_STRING([--disable-xf86misc], [Build XF86Misc extension (default: enabled)]), [XF86MISC=$enableval], [XF86MISC=yes])
+ AC_ARG_ENABLE(xf86vidmode,    AS_HELP_STRING([--disable-xf86vidmode], [Build XF86VidMode extension (default: auto)]), [XF86VIDMODE=$enableval], [XF86VIDMODE=auto])
+ AC_ARG_ENABLE(xf86misc,       AS_HELP_STRING([--disable-xf86misc], [Build XF86Misc extension (default: auto)]), [XF86MISC=$enableval], [XF86MISC=auto])
  AC_ARG_ENABLE(xace,     AS_HELP_STRING([--disable-xace], [Build X-ACE extension (default: enabled)]), [XACE=$enableval], [XACE=yes])
 +AC_ARG_ENABLE(xselinux,     AS_HELP_STRING([--disable-xselinux], [Build SELinux extension (default: enabled)]), [XSELINUX=$enableval], [XSELINUX=$XACE])
  AC_ARG_ENABLE(xcsecurity,     AS_HELP_STRING([--disable-xcsecurity], [Build Security extension (default: enabled)]), [XCSECURITY=$enableval], [XCSECURITY=$XACE])
  AC_ARG_ENABLE(appgroup,       AS_HELP_STRING([--disable-appgroup], [Build XC-APPGROUP extension (default: enabled)]), [APPGROUP=$enableval], [APPGROUP=$XCSECURITY])
  AC_ARG_ENABLE(xcalibrate,     AS_HELP_STRING([--enable-xcalibrate], [Build XCalibrate extension (default: disabled)]), [XCALIBRATE=$enableval], [XCALIBRATE=no])
@@@ -1105,8 -1162,39 +1176,39 @@@
  	XORG_OSINCS='-I$(top_srcdir)/hw/xfree86/os-support -I$(top_srcdir)/hw/xfree86/os-support/bus -I$(top_srcdir)/os'
  	XORG_INCS="$XORG_DDXINCS $XORG_OSINCS"
  	XORG_CFLAGS="$XORGSERVER_CFLAGS -DHAVE_XORG_CONFIG_H"
 -	XORG_LIBS="$COMPOSITE_LIB $MI_LIB $FIXES_LIB $XEXTXORG_LIB $GLX_LIBS $RENDER_LIB $RANDR_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XPSTUBS_LIB $OS_LIB"
 +	XORG_LIBS="$COMPOSITE_LIB $MI_LIB $FIXES_LIB $XEXTXORG_LIB $GLX_LIBS $RENDER_LIB $RANDR_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XPSTUBS_LIB $SELINUX_LIB $OS_LIB"
  
+ 	if test "x$DGA" = xauto; then
+ 		PKG_CHECK_MODULES(DGA, xf86dgaproto, [DGA=yes], [DGA=no])
+ 	fi
+ 	if test "x$DGA" = xyes; then
+ 		XORG_MODULES="$XORG_MODULES xf86dgaproto"
+ 		AC_DEFINE(DGA, 1, [Support DGA extension])
+ 		AC_DEFINE(XFreeXDGA, 1, [Build XDGA support])
+ 	fi
+ 
+ 	if test "x$XF86MISC" = xauto; then
+ 		PKG_CHECK_MODULES(XF86MISC, xf86miscproto, [XF86MISC=yes], [XF86MISC=no])
+ 	fi
+ 	if test "x$XF86MISC" = xyes; then
+ 		XORG_MODULES="$XORG_MODULES xf86miscproto"
+ 		AC_DEFINE(XF86MISC, 1, [Support XFree86 miscellaneous extensions])
+ 	fi
+ 
+ 	if test "x$XF86VIDMODE" = xauto; then
+ 		PKG_CHECK_MODULES(XF86VIDMODE, xf86vidmodeproto, [XF86VIDMODE=yes], [XF86VIDMODE=no])
+ 	fi
+ 	if test "x$XF86VIDMODE" = xyes; then
+ 		XORG_MODULES="$XORG_MODULES xf86vidmodeproto"
+ 		AC_DEFINE(XF86VIDMODE, 1, [Support XFree86 Video Mode extension])
+ 	fi
+ 
+ 	if test -n "$XORG_MODULES"; then
+ 	        PKG_CHECK_MODULES(XORG_MODULES, [$XORG_MODULES])
+ 	        XORG_CFLAGS="$XORG_CFLAGS $XORG_MODULES_CFLAGS"
+ 	        XORG_LIBS="$XORG_LIBS $XORG_MODULES_LIBS"
+ 	fi
+ 
  dnl Check to see if dlopen is in default libraries (like Solaris, which
  dnl has it in libc), or if libdl is needed to get it.
  	AC_CHECK_FUNC([dlopen], [], 
diff-tree ee9bdd3f4a14a42fb0747acc420966f0f669129b (from a6381e69845f58d2b3282992b1f881015190f1bc)
Author: Aaron Plattner <aplattner at nvidia.com>
Date:   Wed Nov 29 12:01:43 2006 -0800

    Add DIX_CFLAGS to util builds.
    
    Fixes a build breakage when $(top_srcdir) != $(top_builddir) because
    -I$(top_srcdir)/include is missing for the cvt, ioport, pcitweak, and scanpci
    builds.
    
    Signed-off-by: Adam Jackson <ajax at nwnk.net>

diff --git a/hw/xfree86/utils/cvt/Makefile.am b/hw/xfree86/utils/cvt/Makefile.am
index ff3c1f7..365c6cb 100644
--- a/hw/xfree86/utils/cvt/Makefile.am
+++ b/hw/xfree86/utils/cvt/Makefile.am
@@ -33,7 +33,7 @@ DUMMYLIB_SRCDIR = $(XFREE86_SRCDIR)/dumm
 
 # gah
 cvt_SOURCES = cvt.c $(top_srcdir)/hw/xfree86/common/xf86cvt.c
-cvt_CFLAGS = $(XORG_CFLAGS)
+cvt_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS)
 cvt_LDADD = $(top_builddir)/hw/xfree86/dummylib/libdummy-nonserver.a
 
 man1_MANS = cvt.man
diff --git a/hw/xfree86/utils/ioport/Makefile.am b/hw/xfree86/utils/ioport/Makefile.am
index e96681b..1839c9a 100644
--- a/hw/xfree86/utils/ioport/Makefile.am
+++ b/hw/xfree86/utils/ioport/Makefile.am
@@ -33,7 +33,7 @@ DUMMYLIB_SRCDIR	= $(XFREE86_SRCDIR)/dumm
 
 INCLUDES = $(XORG_INCS) -I$(DUMMYLIB_SRCDIR)
 
-ioport_CFLAGS = $(XORG_CFLAGS)
+ioport_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS)
 ioport_LDADD = \
 	../../os-support/libxorgos.la \
 	../../dummylib/libdummy-nonserver.a \
diff --git a/hw/xfree86/utils/pcitweak/Makefile.am b/hw/xfree86/utils/pcitweak/Makefile.am
index 9a565ad..5c2a6eb 100644
--- a/hw/xfree86/utils/pcitweak/Makefile.am
+++ b/hw/xfree86/utils/pcitweak/Makefile.am
@@ -33,7 +33,7 @@ DUMMYLIB_SRCDIR	= $(XFREE86_SRCDIR)/dumm
 
 INCLUDES = $(XORG_INCS) -I$(DUMMYLIB_SRCDIR)
 
-pcitweak_CFLAGS = $(XORG_CFLAGS)
+pcitweak_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS)
 pcitweak_LDADD = \
 	../../os-support/libxorgos.la \
 	../../dummylib/libdummy-nonserver.a \
diff --git a/hw/xfree86/utils/scanpci/Makefile.am b/hw/xfree86/utils/scanpci/Makefile.am
index f4e2cbb..6af8eae 100644
--- a/hw/xfree86/utils/scanpci/Makefile.am
+++ b/hw/xfree86/utils/scanpci/Makefile.am
@@ -34,7 +34,7 @@ DUMMYLIB_SRCDIR	= $(XFREE86_SRCDIR)/dumm
 
 INCLUDES = $(XORG_INCS) -I$(SCANPCI_SRCDIR) -I$(DUMMYLIB_SRCDIR)
 
-scanpci_CFLAGS = $(XORG_CFLAGS)
+scanpci_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS)
 scanpci_LDADD = \
 	../../scanpci/libscanpci.la \
 	../../os-support/libxorgos.la \
diff-tree a6381e69845f58d2b3282992b1f881015190f1bc (from b0c8558b9d9a9984c0067960392e28f5a7622b29)
Author: Michel Dänzer <michel at tungstengraphics.com>
Date:   Wed Nov 29 19:25:09 2006 +0100

    xfree86 DDX: Delete DDX screens in ddxGiveUp().
    
    This allows video drivers to clean up in the FreeScreen hook things they set up
    in the PreInit hook.

diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
index ff878d5..68d69c5 100644
--- a/hw/xfree86/common/xf86Init.c
+++ b/hw/xfree86/common/xf86Init.c
@@ -1119,6 +1119,9 @@ ddxGiveUp()
     DGAShutdown();
 #endif
 
+    while (xf86NumScreens)
+	xf86DeleteScreen(xf86NumScreens - 1, 0);
+
     xf86CloseConsole();
 
     xf86CloseLog();
diff-tree b0c8558b9d9a9984c0067960392e28f5a7622b29 (from 6245e9dd4719c5dc15ff45d49cf626123794038b)
Author: Keith Packard <keithp at neko.keithp.com>
Date:   Sun Nov 26 19:31:48 2006 -0800

    Ensure RandR resource types are registered before resources are created.
    
    Now that resources can be created during server initialization, make sure
    the crtc, output and mode resource types are created before attempting to
    create associated resources.
    (cherry picked from commit ec83d674167e7045d5317b179c9998e3172a26dc)

diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c
index b81c390..212352c 100644
--- a/randr/rrcrtc.c
+++ b/randr/rrcrtc.c
@@ -55,6 +55,8 @@ RRCrtcCreate (void	*devPrivate)
 {
     RRCrtcPtr	crtc;
     
+    if (!RRInit())
+	return NULL;
     crtc = xalloc (sizeof (RRCrtcRec));
     if (!crtc)
 	return NULL;
diff --git a/randr/rrmode.c b/randr/rrmode.c
index 3cd9ef2..a0696e1 100644
--- a/randr/rrmode.c
+++ b/randr/rrmode.c
@@ -67,6 +67,9 @@ RRModeGet (xRRModeInfo	*modeInfo,
 	}
     }
 
+    if (!RRInit ())
+	return NULL;
+
     mode = xalloc (sizeof (RRModeRec) + modeInfo->nameLength + 1);
     if (!mode)
 	return NULL;
diff --git a/randr/rroutput.c b/randr/rroutput.c
index 8b760ec..f38f582 100644
--- a/randr/rroutput.c
+++ b/randr/rroutput.c
@@ -51,6 +51,8 @@ RROutputCreate (const char  *name,
 {
     RROutputPtr	output;
 
+    if (!RRInit())
+	return NULL;
     output = xalloc (sizeof (RROutputRec) + nameLength + 1);
     if (!output)
 	return NULL;
diff-tree 6245e9dd4719c5dc15ff45d49cf626123794038b (from 24abce8032940e96bb2ccf9e463a7fff6f36283a)
Author: Keith Packard <keithp at neko.keithp.com>
Date:   Tue Nov 21 16:52:28 2006 -0800

    Allocate correct size for RRPropertyRec (oops).
    
    Neglected to change the allocation size from sizeof (PropertyRec) to
    sizeof (RRPropertyRec). Lots of fun crashes this way.
    (cherry picked from commit 0626eb8e5c9fa05de6bdc9aa0c654f5148bf7cff)

diff --git a/randr/rrproperty.c b/randr/rrproperty.c
index 5d4c865..a47f306 100644
--- a/randr/rrproperty.c
+++ b/randr/rrproperty.c
@@ -68,9 +68,10 @@ RRCreateOutputProperty (Atom property)
 {
     RRPropertyPtr   prop;
     
-    prop = (RRPropertyPtr)xalloc(sizeof(PropertyRec));
+    prop = (RRPropertyPtr)xalloc(sizeof(RRPropertyRec));
     if (!prop)
 	return NULL;
+    prop->next = NULL;
     prop->propertyName = property;
     prop->is_pending = FALSE;
     prop->range = FALSE;
diff-tree 24abce8032940e96bb2ccf9e463a7fff6f36283a (from f62ac3ec39c6593df476985c630e499864c19c72)
Author: Keith Packard <keithp at neko.keithp.com>
Date:   Tue Nov 21 01:15:26 2006 -0800

    Change RandR property datatype to include pending/valid values.
    
    This patch tracks the protocol changes which introduce more complex
    semantics for RandR output properties including pending and valid value
    information.
    (cherry picked from commit af55c65bea40669fdc038aa34c6a1ec9ecb33e87)

diff --git a/randr/mirandr.c b/randr/mirandr.c
index 3a99bf9..0b763e1 100644
--- a/randr/mirandr.c
+++ b/randr/mirandr.c
@@ -64,10 +64,11 @@ miRRCrtcSetGamma (ScreenPtr	pScreen,
     return TRUE;
 }
 
-static Bool
-miRROutputSetProperty (ScreenPtr	pScreen,
-		       RROutputPtr	output,
-		       Atom	property)
+Bool
+miRROutputSetProperty (ScreenPtr	    pScreen,
+		       RROutputPtr	    output,
+		       Atom		    property,
+		       RRPropertyValuePtr   value)
 {
     return TRUE;
 }
diff --git a/randr/randrstr.h b/randr/randrstr.h
index 19af9b9..27ede92 100644
--- a/randr/randrstr.h
+++ b/randr/randrstr.h
@@ -69,9 +69,11 @@ extern int (*SProcRandrVector[RRNumberRe
  */
 
 #define RRModeName(pMode) ((char *) (pMode + 1))
-typedef struct _rrMode	    RRModeRec, *RRModePtr;
-typedef struct _rrCrtc	    RRCrtcRec, *RRCrtcPtr;
-typedef struct _rrOutput    RROutputRec, *RROutputPtr;
+typedef struct _rrMode		RRModeRec, *RRModePtr;
+typedef struct _rrPropertyValue	RRPropertyValueRec, *RRPropertyValuePtr;
+typedef struct _rrProperty	RRPropertyRec, *RRPropertyPtr;
+typedef struct _rrCrtc		RRCrtcRec, *RRCrtcPtr;
+typedef struct _rrOutput	RROutputRec, *RROutputPtr;
 
 struct _rrMode {
     int		    refcnt;
@@ -81,6 +83,24 @@ struct _rrMode {
     Bool	    userDefined;
 };
 
+struct _rrPropertyValue {
+    Atom	    type;       /* ignored by server */
+    short	    format;     /* format of data for swapping - 8,16,32 */
+    long	    size;	/* size of data in (format/8) bytes */
+    pointer         data;	/* private to client */
+};
+
+struct _rrProperty {
+    RRPropertyPtr   next;
+    ATOM 	    propertyName;
+    Bool	    is_pending;
+    Bool	    range;
+    Bool	    immutable;
+    int		    num_valid;
+    INT32	    *valid_values;
+    RRPropertyValueRec	current, pending;
+};
+
 struct _rrCrtc {
     RRCrtc	    id;
     ScreenPtr	    pScreen;
@@ -116,7 +136,7 @@ struct _rrOutput {
     int		    numPreferred;
     RRModePtr	    *modes;
     Bool	    changed;
-    PropertyPtr	    properties;
+    RRPropertyPtr   properties;
     void	    *devPrivate;
 };
 
@@ -139,9 +159,10 @@ typedef Bool (*RRCrtcSetProcPtr) (Screen
 typedef Bool (*RRCrtcSetGammaProcPtr) (ScreenPtr	pScreen,
 				       RRCrtcPtr	crtc);
 
-typedef Bool (*RROutputSetPropertyProcPtr) (ScreenPtr	pScreen,
-					    RROutputPtr	output,
-					    Atom	property);
+typedef Bool (*RROutputSetPropertyProcPtr) (ScreenPtr		pScreen,
+					    RROutputPtr		output,
+					    Atom		property,
+					    RRPropertyValuePtr	value);
 
 #endif
 
@@ -363,6 +384,12 @@ miRRCrtcSet (ScreenPtr	pScreen,
 	     int	numOutput,
 	     RROutputPtr *outputs);
 
+Bool
+miRROutputSetProperty (ScreenPtr	    pScreen,
+		       RROutputPtr	    output,
+		       Atom		    property,
+		       RRPropertyValuePtr   value);
+
 /* randr.c */
 /*
  * Send all pending events
@@ -676,6 +703,12 @@ RRPointerScreenConfigured (ScreenPtr pSc
 void
 RRDeleteAllOutputProperties (RROutputPtr output);
 
+RRPropertyValuePtr
+RRGetOutputProperty (RROutputPtr output, Atom property, Bool pending);
+
+RRPropertyPtr
+RRQueryOutputProperty (RROutputPtr output, Atom property);
+		       
 void
 RRDeleteOutputProperty (RROutputPtr output, Atom property);
 
@@ -685,6 +718,10 @@ RRChangeOutputProperty (RROutputPtr outp
 			pointer value, Bool sendevent);
 
 int
+RRConfigureOutputProperty (RROutputPtr output, Atom property,
+			   Bool pending, Bool range, Bool immutable,
+			   int num_values, INT32 *values);
+int
 ProcRRChangeOutputProperty (ClientPtr client);
 
 int
@@ -694,6 +731,12 @@ int
 ProcRRListOutputProperties (ClientPtr client);
 
 int
+ProcRRQueryOutputProperty (ClientPtr client);
+
+int
+ProcRRConfigureOutputProperty (ClientPtr client);
+
+int
 ProcRRDeleteOutputProperty (ClientPtr client);
 
 /* rrxinerama.c */
diff --git a/randr/rrdispatch.c b/randr/rrdispatch.c
index 49ba10b..6b61b9c 100644
--- a/randr/rrdispatch.c
+++ b/randr/rrdispatch.c
@@ -192,17 +192,19 @@ int (*ProcRandrVector[RRNumberRequests])
     ProcRRGetScreenResources,	/* 8 */
     ProcRRGetOutputInfo,	/* 9 */
     ProcRRListOutputProperties,	/* 10 */
-    ProcRRChangeOutputProperty,	/* 11 */
-    ProcRRDeleteOutputProperty,	/* 12 */
-    ProcRRGetOutputProperty,	/* 13 */
-    ProcRRCreateMode,		/* 14 */
-    ProcRRDestroyMode,		/* 15 */
-    ProcRRAddOutputMode,	/* 16 */
-    ProcRRDeleteOutputMode,	/* 17 */
-    ProcRRGetCrtcInfo,		/* 18 */
-    ProcRRSetCrtcConfig,	/* 19 */
-    ProcRRGetCrtcGammaSize,	/* 20 */
-    ProcRRGetCrtcGamma,		/* 21 */
-    ProcRRSetCrtcGamma,		/* 22 */
+    ProcRRQueryOutputProperty,	/* 11 */
+    ProcRRConfigureOutputProperty,  /* 12 */
+    ProcRRChangeOutputProperty,	/* 13 */
+    ProcRRDeleteOutputProperty,	/* 14 */
+    ProcRRGetOutputProperty,	/* 15 */
+    ProcRRCreateMode,		/* 16 */
+    ProcRRDestroyMode,		/* 17 */
+    ProcRRAddOutputMode,	/* 18 */
+    ProcRRDeleteOutputMode,	/* 19 */
+    ProcRRGetCrtcInfo,		/* 20 */
+    ProcRRSetCrtcConfig,	/* 21 */
+    ProcRRGetCrtcGammaSize,	/* 22 */
+    ProcRRGetCrtcGamma,		/* 23 */
+    ProcRRSetCrtcGamma,		/* 24 */
 };
 
diff --git a/randr/rrproperty.c b/randr/rrproperty.c
index 44f1f0a..5d4c865 100644
--- a/randr/rrproperty.c
+++ b/randr/rrproperty.c
@@ -33,7 +33,7 @@ RRDeliverEvent (ScreenPtr pScreen, xEven
 void
 RRDeleteAllOutputProperties (RROutputPtr output)
 {
-    PropertyPtr prop, next;
+    RRPropertyPtr prop, next;
     xRROutputPropertyNotifyEvent    event;
 
     for (prop = output->properties; prop; prop = next)
@@ -46,15 +46,58 @@ RRDeleteAllOutputProperties (RROutputPtr
 	event.atom = prop->propertyName;
 	event.timestamp = currentTime.milliseconds;
 	RRDeliverEvent (output->pScreen, (xEvent *) &event, RROutputPropertyNotifyMask);
-        xfree(prop->data);
+	if (prop->current.data)
+	    xfree(prop->current.data);
+	if (prop->pending.data)
+	    xfree(prop->pending.data);
         xfree(prop);
     }
 }
 
+static void
+RRInitOutputPropertyValue (RRPropertyValuePtr property_value)
+{
+    property_value->type = None;
+    property_value->format = 0;
+    property_value->size = 0;
+    property_value->data = NULL;
+}
+
+static RRPropertyPtr
+RRCreateOutputProperty (Atom property)
+{
+    RRPropertyPtr   prop;
+    
+    prop = (RRPropertyPtr)xalloc(sizeof(PropertyRec));
+    if (!prop)
+	return NULL;
+    prop->propertyName = property;
+    prop->is_pending = FALSE;
+    prop->range = FALSE;
+    prop->immutable = FALSE;
+    prop->num_valid = 0;
+    prop->valid_values = NULL;
+    RRInitOutputPropertyValue (&prop->current);
+    RRInitOutputPropertyValue (&prop->pending);
+    return prop;
+}
+
+static void
+RRDestroyOutputProperty (RRPropertyPtr prop)
+{
+    if (prop->valid_values)
+	xfree (prop->valid_values);
+    if (prop->current.data)
+	xfree(prop->current.data);
+    if (prop->pending.data)
+	xfree(prop->pending.data);
+    xfree(prop);
+}
+
 void
 RRDeleteOutputProperty (RROutputPtr output, Atom property)
 {
-    PropertyPtr	prop, *prev;
+    RRPropertyPtr	prop, *prev;
     xRROutputPropertyNotifyEvent    event;
 
     for (prev = &output->properties; (prop = *prev); prev = &(prop->next))
@@ -70,8 +113,7 @@ RRDeleteOutputProperty (RROutputPtr outp
 	event.atom = prop->propertyName;
 	event.timestamp = currentTime.milliseconds;
 	RRDeliverEvent (output->pScreen, (xEvent *) &event, RROutputPropertyNotifyMask);
-        xfree(prop->data);
-        xfree(prop);
+	RRDestroyOutputProperty (prop);
     }
 }
 
@@ -80,96 +122,95 @@ RRChangeOutputProperty (RROutputPtr outp
 			int format, int mode, unsigned long len,
 			pointer value, Bool sendevent)
 {
-    PropertyPtr			    prop;
+    RRPropertyPtr		    prop;
     xRROutputPropertyNotifyEvent    event;
     int				    sizeInBytes;
     int				    totalSize;
     pointer			    data;
+    RRPropertyValuePtr		    prop_value;
+    Bool			    add = FALSE;
 
     sizeInBytes = format >> 3;
     totalSize = len * sizeInBytes;
 
     /* first see if property already exists */
-
-    for (prop = output->properties; prop; prop = prop->next)
-	if (prop->propertyName == property)
-	    break;
-    
+    prop = RRQueryOutputProperty (output, property);
     if (!prop)   /* just add to list */
     {
-        prop = (PropertyPtr)xalloc(sizeof(PropertyRec));
+        prop = RRCreateOutputProperty (property);
 	if (!prop)
 	    return(BadAlloc);
-        data = (pointer)xalloc(totalSize);
-	if (!data && len)
-	{
-	    xfree(prop);
-	    return(BadAlloc);
-	}
-        prop->propertyName = property;
-        prop->type = type;
-        prop->format = format;
-        prop->data = data;
-	if (len)
-	    memmove((char *)data, (char *)value, totalSize);
-	prop->size = len;
-        prop->next = output->properties;
-        output->properties = prop;
+	add = TRUE;
+	mode = PropModeReplace;
     }
+    if (prop->is_pending)
+	prop_value = &prop->pending;
     else
+	prop_value = &prop->current;
+    
+    /* To append or prepend to a property the request format and type
+	    must match those of the already defined property.  The
+	    existing format and type are irrelevant when using the mode
+	    "PropModeReplace" since they will be written over. */
+
+    if ((format != prop_value->format) && (mode != PropModeReplace))
+	return(BadMatch);
+    if ((prop_value->type != type) && (mode != PropModeReplace))
+	return(BadMatch);
+    if (mode == PropModeReplace)
     {
-	/* To append or prepend to a property the request format and type
-		must match those of the already defined property.  The
-		existing format and type are irrelevant when using the mode
-		"PropModeReplace" since they will be written over. */
-
-        if ((format != prop->format) && (mode != PropModeReplace))
-	    return(BadMatch);
-        if ((prop->type != type) && (mode != PropModeReplace))
-            return(BadMatch);
-        if (mode == PropModeReplace)
-        {
-	    if (totalSize != prop->size * (prop->format >> 3))
-	    {
-	    	data = (pointer)xrealloc(prop->data, totalSize);
-	    	if (!data && len)
-		    return(BadAlloc);
-            	prop->data = data;
-	    }
-	    if (len)
-		memmove((char *)prop->data, (char *)value, totalSize);
-	    prop->size = len;
-    	    prop->type = type;
-	    prop->format = format;
-	}
-	else if (len == 0)
+	if (totalSize != prop_value->size * (prop_value->format >> 3))
 	{
-	    /* do nothing */
-	}
-        else if (mode == PropModeAppend)
-        {
-	    data = (pointer)xrealloc(prop->data,
-				     sizeInBytes * (len + prop->size));
-	    if (!data)
-		return(BadAlloc);
-            prop->data = data;
-	    memmove(&((char *)data)[prop->size * sizeInBytes], 
-		    (char *)value,
-		  totalSize);
-            prop->size += len;
-	}
-        else if (mode == PropModePrepend)
-        {
-            data = (pointer)xalloc(sizeInBytes * (len + prop->size));
-	    if (!data)
+	    if (prop_value->data)
+		data = (pointer)xrealloc(prop_value->data, totalSize);
+	    else
+		data = (pointer)xalloc (totalSize);
+	    if (!data && len)
+	    {
+		if (add)
+		    RRDestroyOutputProperty (prop);
 		return(BadAlloc);
-	    memmove(&((char *)data)[totalSize], (char *)prop->data, 
-		  (int)(prop->size * sizeInBytes));
-            memmove((char *)data, (char *)value, totalSize);
-	    xfree(prop->data);
-            prop->data = data;
-            prop->size += len;
+	    }
+	    prop_value->data = data;
 	}
+	if (len)
+	    memmove((char *)prop_value->data, (char *)value, totalSize);
+	prop_value->size = len;
+	prop_value->type = type;
+	prop_value->format = format;
+    }
+    else if (len == 0)
+    {
+	/* do nothing */
+    }
+    else if (mode == PropModeAppend)
+    {
+	data = (pointer)xrealloc(prop_value->data,
+				 sizeInBytes * (len + prop_value->size));
+	if (!data)
+	    return(BadAlloc);
+	prop_value->data = data;
+	memmove(&((char *)data)[prop_value->size * sizeInBytes], 
+		(char *)value,
+	      totalSize);
+	prop_value->size += len;
+    }
+    else if (mode == PropModePrepend)
+    {
+	data = (pointer)xalloc(sizeInBytes * (len + prop_value->size));
+	if (!data)
+	    return(BadAlloc);
+	memmove(&((char *)data)[totalSize], (char *)prop_value->data, 
+	      (int)(prop_value->size * sizeInBytes));
+	memmove((char *)data, (char *)value, totalSize);
+	xfree(prop_value->data);
+	prop_value->data = data;
+	prop_value->size += len;
+    }
+    if (add)
+    {
+	prop->next = output->properties;
+	output->properties = prop;
     }
     if (sendevent)
     {
@@ -184,6 +225,81 @@ RRChangeOutputProperty (RROutputPtr outp
     return(Success);
 }
 
+RRPropertyPtr
+RRQueryOutputProperty (RROutputPtr output, Atom property)
+{
+    RRPropertyPtr   prop;
+    
+    for (prop = output->properties; prop; prop = prop->next)
+	if (prop->propertyName == property)
+	    return prop;
+    return NULL;
+}
+		       
+RRPropertyValuePtr
+RRGetOutputProperty (RROutputPtr output, Atom property, Bool pending)
+{
+    RRPropertyPtr   prop = RRQueryOutputProperty (output, property);
+
+    if (!prop)
+	return NULL;
+    if (pending && prop->is_pending)
+	return &prop->pending;
+    else
+	return &prop->current;
+}
+
+int
+RRConfigureOutputProperty (RROutputPtr output, Atom property,
+			   Bool pending, Bool range, Bool immutable,
+			   int num_values, INT32 *values)
+{
+    RRPropertyPtr   prop = RRQueryOutputProperty (output, property);
+    Bool	    add = FALSE;
+    INT32	    *new_values;
+
+    if (!prop)
+    {
+        prop = RRCreateOutputProperty (property);
+	if (!prop)
+	    return(BadAlloc);
+	add = TRUE;
+    } else if (prop->immutable && !immutable)
+	return(BadAccess);
+    
+    /*
+     * ranges must have even number of values
+     */
+    if (range && (num_values & 1))
+	return BadMatch;
+
+    new_values = xalloc (num_values * sizeof (INT32));
+    if (!new_values && num_values)
+	return BadAlloc;
+    if (num_values)
+	memcpy (new_values, values, num_values * sizeof (INT32));
+    
+    /*
+     * Property moving from pending to non-pending
+     * loses any pending values
+     */
+    if (prop->is_pending && !pending)
+    {
+	if (prop->pending.data)
+	    xfree (prop->pending.data);
+	RRInitOutputPropertyValue (&prop->pending);
+    }
+
+    prop->is_pending = pending;
+    prop->range = range;
+    prop->immutable = immutable;
+    prop->num_valid = num_values;
+    if (prop->valid_values)
+	xfree (prop->valid_values);
+    prop->valid_values = new_values;
+    return Success;
+}
+
 int
 ProcRRListOutputProperties (ClientPtr client)
 {
@@ -192,7 +308,7 @@ ProcRRListOutputProperties (ClientPtr cl
     xRRListOutputPropertiesReply    rep;
     int				    numProps = 0;
     RROutputPtr			    output;
-    PropertyPtr			    prop;
+    RRPropertyPtr			    prop;
     
     REQUEST_SIZE_MATCH(xRRListOutputPropertiesReq);
 
@@ -211,6 +327,12 @@ ProcRRListOutputProperties (ClientPtr cl
     rep.nProperties = numProps;
     rep.length = (numProps * sizeof(Atom)) >> 2;
     rep.sequenceNumber = client->sequence;
+    if (client->swapped) 
+    {
+	int n;
+	swaps (&rep.sequenceNumber, n);
+	swapl (&rep.length, n);
+    }
     temppAtoms = pAtoms;
     for (prop = output->properties; prop; prop = prop->next)
 	*temppAtoms++ = prop->propertyName;
@@ -226,6 +348,68 @@ ProcRRListOutputProperties (ClientPtr cl
 }
 
 int
+ProcRRQueryOutputProperty (ClientPtr client)
+{
+    REQUEST(xRRQueryOutputPropertyReq);
+    xRRQueryOutputPropertyReply	    rep;
+    RROutputPtr			    output;
+    RRPropertyPtr		    prop;
+    
+    REQUEST_SIZE_MATCH(xRRQueryOutputPropertyReq);
+
+    output = LookupOutput (client, stuff->output, SecurityReadAccess);
+    
+    if (!output)
+        return RRErrorBase + BadRROutput;
+    
+    prop = RRQueryOutputProperty (output, stuff->property);
+    if (!prop)
+	return BadName;
+    
+    rep.type = X_Reply;
+    rep.length = prop->num_valid;
+    rep.sequenceNumber = client->sequence;
+    rep.pending = prop->is_pending;
+    rep.range = prop->range;
+    rep.immutable = prop->immutable;
+    if (client->swapped) 
+    {
+	int n;
+	swaps (&rep.sequenceNumber, n);
+	swapl (&rep.length, n);
+    }
+    WriteReplyToClient (client, sizeof (xRRQueryOutputPropertyReply), &rep);
+    if (prop->num_valid)
+    {
+        client->pSwapReplyFunc = (ReplySwapPtr)Swap32Write;
+        WriteSwappedDataToClient(client, prop->num_valid * sizeof(INT32),
+				 prop->valid_values);
+    }
+    return(client->noClientException);
+}
+
+int
+ProcRRConfigureOutputProperty (ClientPtr client)
+{
+    REQUEST(xRRConfigureOutputPropertyReq);
+    RROutputPtr				output;
+    int					num_valid;
+    
+    REQUEST_SIZE_MATCH(xRRConfigureOutputPropertyReq);
+
+    output = LookupOutput (client, stuff->output, SecurityReadAccess);
+    
+    if (!output)
+        return RRErrorBase + BadRROutput;
+    
+    num_valid = stuff->length - (sizeof (xRRConfigureOutputPropertyReq) >> 2);
+    return RRConfigureOutputProperty (output, stuff->property,
+				      stuff->pending, stuff->range,
+				      FALSE, num_valid, 
+				      (INT32 *) (stuff + 1));
+}
+
+int
 ProcRRChangeOutputProperty (ClientPtr client)
 {
     REQUEST(xRRChangeOutputPropertyReq);
@@ -309,7 +493,8 @@ int
 ProcRRGetOutputProperty (ClientPtr client)
 {
     REQUEST(xRRGetOutputPropertyReq);
-    PropertyPtr			prop, *prev;
+    RRPropertyPtr			prop, *prev;
+    RRPropertyValuePtr			prop_value;
     unsigned long		n, len, ind;
     RROutputPtr			output;
     xRRGetOutputPropertyReply	reply;
@@ -356,18 +541,26 @@ ProcRRGetOutputProperty (ClientPtr clien
 	return(client->noClientException);
     }
 
+    if (prop->immutable && stuff->delete)
+	return BadAccess;
+
+    if (stuff->pending && prop->is_pending)
+	prop_value = &prop->pending;
+    else
+	prop_value = &prop->current;
+    
     /* If the request type and actual type don't match. Return the
     property information, but not the data. */
 
-    if (((stuff->type != prop->type) &&
+    if (((stuff->type != prop_value->type) &&
 	 (stuff->type != AnyPropertyType))
        )
     {
-	reply.bytesAfter = prop->size;
-	reply.format = prop->format;
+	reply.bytesAfter = prop_value->size;
+	reply.format = prop_value->format;
 	reply.length = 0;
 	reply.nItems = 0;
-	reply.propertyType = prop->type;
+	reply.propertyType = prop_value->type;
 	WriteReplyToClient(client, sizeof(xRRGetOutputPropertyReply), &reply);
 	return(client->noClientException);
     }
@@ -375,7 +568,7 @@ ProcRRGetOutputProperty (ClientPtr clien
 /*
  *  Return type, format, value to client
  */
-    n = (prop->format/8) * prop->size; /* size (bytes) of prop */
+    n = (prop_value->format/8) * prop_value->size; /* size (bytes) of prop */
     ind = stuff->longOffset << 2;        
 
    /* If longOffset is invalid such that it causes "len" to
@@ -390,10 +583,10 @@ ProcRRGetOutputProperty (ClientPtr clien
     len = min(n - ind, 4 * stuff->longLength);
 
     reply.bytesAfter = n - (ind + len);
-    reply.format = prop->format;
+    reply.format = prop_value->format;
     reply.length = (len + 3) >> 2;
-    reply.nItems = len / (prop->format / 8 );
-    reply.propertyType = prop->type;
+    reply.nItems = len / (prop_value->format / 8 );
+    reply.propertyType = prop_value->type;
 
     if (stuff->delete && (reply.bytesAfter == 0))
     {
@@ -417,14 +610,13 @@ ProcRRGetOutputProperty (ClientPtr clien
 	default: client->pSwapReplyFunc = (ReplySwapPtr)WriteToClient; break;
 	}
 	WriteSwappedDataToClient(client, len,
-				 (char *)prop->data + ind);
+				 (char *)prop_value->data + ind);
     }
 
     if (stuff->delete && (reply.bytesAfter == 0))
     { /* delete the Property */
 	*prev = prop->next;
-	xfree(prop->data);
-	xfree(prop);
+	RRDestroyOutputProperty (prop);
     }
     return(client->noClientException);
 }
diff --git a/randr/rrsdispatch.c b/randr/rrsdispatch.c
index 67af753..4a6a6e4 100644
--- a/randr/rrsdispatch.c
+++ b/randr/rrsdispatch.c
@@ -132,6 +132,26 @@ SProcRRListOutputProperties (ClientPtr c
 }
 
 static int
+SProcRRQueryOutputProperty (ClientPtr client)
+{
+    REQUEST(xRRQueryOutputPropertyReq);
+    
+    REQUEST_SIZE_MATCH(xRRQueryOutputPropertyReq);
+    (void) stuff;
+    return BadImplementation; 
+}
+
+static int
+SProcRRConfigureOutputProperty (ClientPtr client)
+{
+    REQUEST(xRRConfigureOutputPropertyReq);
+    
+    REQUEST_SIZE_MATCH(xRRConfigureOutputPropertyReq);
+    (void) stuff;
+    return BadImplementation; 
+}
+
+static int
 SProcRRChangeOutputProperty (ClientPtr client)
 {
     REQUEST(xRRChangeOutputPropertyReq);
@@ -267,17 +287,19 @@ int (*SProcRandrVector[RRNumberRequests]
     SProcRRGetScreenResources,	/* 8 */
     SProcRRGetOutputInfo,	/* 9 */
     SProcRRListOutputProperties,/* 10 */
-    SProcRRChangeOutputProperty,/* 11 */
-    SProcRRDeleteOutputProperty,/* 12 */
-    SProcRRGetOutputProperty,	/* 13 */
-    SProcRRCreateMode,		/* 14 */
-    SProcRRDestroyMode,		/* 15 */
-    SProcRRAddOutputMode,	/* 16 */
-    SProcRRDeleteOutputMode,	/* 17 */
-    SProcRRGetCrtcInfo,		/* 18 */
-    SProcRRSetCrtcConfig,	/* 19 */
-    SProcRRGetCrtcGammaSize,	/* 20 */
-    SProcRRGetCrtcGamma,	/* 21 */
-    SProcRRSetCrtcGamma,	/* 22 */
+    SProcRRQueryOutputProperty,	/* 11 */
+    SProcRRConfigureOutputProperty,  /* 12 */
+    SProcRRChangeOutputProperty,/* 13 */
+    SProcRRDeleteOutputProperty,/* 14 */
+    SProcRRGetOutputProperty,	/* 15 */
+    SProcRRCreateMode,		/* 16 */
+    SProcRRDestroyMode,		/* 17 */
+    SProcRRAddOutputMode,	/* 18 */
+    SProcRRDeleteOutputMode,	/* 19 */
+    SProcRRGetCrtcInfo,		/* 20 */
+    SProcRRSetCrtcConfig,	/* 21 */
+    SProcRRGetCrtcGammaSize,	/* 22 */
+    SProcRRGetCrtcGamma,	/* 23 */
+    SProcRRSetCrtcGamma,	/* 24 */
 };
 
diff-tree f62ac3ec39c6593df476985c630e499864c19c72 (from fbd09443385c533416fa530399d54f130afaf985)
Author: Eric Anholt <eric at anholt.net>
Date:   Tue Nov 28 10:31:40 2006 -0800

    Separate DDC mode list creation from MonPtr creation.
    
    This will be used by the intel driver, and likely other RandR 1.2 drivers.

diff --git a/hw/xfree86/ddc/edid_modes.c b/hw/xfree86/ddc/edid_modes.c
index 25f95ca..cfc8ddc 100644
--- a/hw/xfree86/ddc/edid_modes.c
+++ b/hw/xfree86/ddc/edid_modes.c
@@ -204,6 +204,46 @@ DDCGuessRangesFromModes(int scrnIndex, M
     }
 }
 
+DisplayModePtr
+xf86DDCGetModes(int scrnIndex, xf86MonPtr DDC)
+{
+    int preferred, i;
+    DisplayModePtr Modes = NULL, Mode;
+
+    preferred = PREFERRED_TIMING_MODE(DDC->features.msc);
+
+    /* Add established timings */
+    Mode = DDCModesFromEstablished(scrnIndex, &DDC->timings1);
+    Modes = xf86ModesAdd(Modes, Mode);
+
+    /* Add standard timings */
+    Mode = DDCModesFromStandardTiming(scrnIndex, DDC->timings2);
+    Modes = xf86ModesAdd(Modes, Mode);
+
+    for (i = 0; i < DET_TIMINGS; i++) {
+	struct detailed_monitor_section *det_mon = &DDC->det_mon[i];
+
+        switch (det_mon->type) {
+        case DT:
+            Mode = DDCModeFromDetailedTiming(scrnIndex,
+                                             &det_mon->section.d_timings,
+					     preferred);
+	    preferred = 0;
+            Modes = xf86ModesAdd(Modes, Mode);
+            break;
+        case DS_STD_TIMINGS:
+            Mode = DDCModesFromStandardTiming(scrnIndex,
+					      det_mon->section.std_t);
+            Modes = xf86ModesAdd(Modes, Mode);
+            break;
+        default:
+            break;
+        }
+    }
+
+    return Modes;
+}
+
 /*
  * Fill out MonPtr with xf86MonPtr information.
  */
@@ -213,15 +253,12 @@ xf86DDCMonitorSet(int scrnIndex, MonPtr 
     DisplayModePtr Modes = NULL, Mode;
     int i, clock;
     Bool have_hsync = FALSE, have_vrefresh = FALSE;
-    int preferred;
 
     if (!Monitor || !DDC)
         return;
 
     Monitor->DDC = DDC;
 
-    preferred = PREFERRED_TIMING_MODE(DDC->features.msc);
-
     Monitor->widthmm = 10 * DDC->features.hsize;
     Monitor->heightmm = 10 * DDC->features.vsize;
 
@@ -230,20 +267,14 @@ xf86DDCMonitorSet(int scrnIndex, MonPtr 
         Monitor->reducedblanking = TRUE;
     /* Allow the user to also enable this through config */
 
-    /* Add established timings */
-    Mode = DDCModesFromEstablished(scrnIndex, &DDC->timings1);
-    Modes = xf86ModesAdd(Modes, Mode);
-
-    /* Add standard timings */
-    Mode = DDCModesFromStandardTiming(scrnIndex, DDC->timings2);
-    Modes = xf86ModesAdd(Modes, Mode);
+    Modes = xf86DDCGetModes(scrnIndex, DDC);
 
     /* Skip EDID ranges if they were specified in the config file */
     have_hsync = (Monitor->nHsync != 0);
     have_vrefresh = (Monitor->nVrefresh != 0);
 
     /* Go through the detailed monitor sections */
-    for (i = 0; i < DET_TIMINGS; i++)
+    for (i = 0; i < DET_TIMINGS; i++) {
         switch (DDC->det_mon[i].type) {
         case DS_RANGES:
 	    if (!have_hsync) {
@@ -279,21 +310,10 @@ xf86DDCMonitorSet(int scrnIndex, MonPtr 
 		Monitor->maxPixClock = clock;
 
             break;
-        case DT:
-            Mode = DDCModeFromDetailedTiming(scrnIndex,
-                                             &DDC->det_mon[i].section.d_timings,
-					     preferred);
-	    preferred = 0;
-            Modes = xf86ModesAdd(Modes, Mode);
-            break;
-        case DS_STD_TIMINGS:
-            Mode = DDCModesFromStandardTiming(scrnIndex,
-                                             DDC->det_mon[i].section.std_t);
-            Modes = xf86ModesAdd(Modes, Mode);
-            break;
         default:
             break;
         }
+    }
 
     if (Modes) {
         /* Print Modes */
diff --git a/hw/xfree86/ddc/xf86DDC.h b/hw/xfree86/ddc/xf86DDC.h
index 5def97a..7799471 100644
--- a/hw/xfree86/ddc/xf86DDC.h
+++ b/hw/xfree86/ddc/xf86DDC.h
@@ -59,6 +59,8 @@ extern void xf86print_vdif(
     xf86vdifPtr v
 );
 
+DisplayModePtr xf86DDCGetModes(int scrnIndex, xf86MonPtr DDC);
+
 #endif
 
 
diff-tree fbd09443385c533416fa530399d54f130afaf985 (from 4ad0bde661be2af4a17771d66066d49736e85cbe)
Author: Eric Anholt <eric at anholt.net>
Date:   Tue Nov 28 10:15:51 2006 -0800

    Replace bad mode name-setting code with xf86SetModeDefaultName().

diff --git a/hw/xfree86/ddc/edid_modes.c b/hw/xfree86/ddc/edid_modes.c
index 9e824b1..25f95ca 100644
--- a/hw/xfree86/ddc/edid_modes.c
+++ b/hw/xfree86/ddc/edid_modes.c
@@ -124,10 +124,6 @@ DDCModeFromDetailedTiming(int scrnIndex,
     Mode = xnfalloc(sizeof(DisplayModeRec));
     memset(Mode, 0, sizeof(DisplayModeRec));
 
-    Mode->name = xnfalloc(10); /* "1234x1234" */
-    xf86snprintf(Mode->name, 20, "%dx%d", timing->h_active,
-                 timing->v_active);
-
     Mode->type = M_T_DRIVER;
     if (preferred)
 	Mode->type |= M_T_PREFERRED;
@@ -144,6 +140,8 @@ DDCModeFromDetailedTiming(int scrnIndex,
     Mode->VSyncEnd = Mode->VSyncStart + timing->v_sync_width;
     Mode->VTotal = timing->v_active + timing->v_blanking;
 
+    xf86SetModeDefaultName(Mode);
+
     /* We ignore h/v_size and h/v_border for now. */
 
     if (timing->interlaced)
diff-tree 4ad0bde661be2af4a17771d66066d49736e85cbe (from 05778432dc6e688bc0beff0c20ffd7e27b74888e)
Author: Eric Anholt <eric at anholt.net>
Date:   Tue Nov 28 10:12:02 2006 -0800

    Clean up a bunch of long lines and trailing whitespace.

diff --git a/hw/xfree86/ddc/edid_modes.c b/hw/xfree86/ddc/edid_modes.c
index 5ce86ee..9e824b1 100644
--- a/hw/xfree86/ddc/edid_modes.c
+++ b/hw/xfree86/ddc/edid_modes.c
@@ -85,14 +85,15 @@ DDCModesFromStandardTiming(int scrnIndex
 {
     DisplayModePtr Modes = NULL, Mode = NULL;
     int i;
-    
-    for (i = 0; i < STD_TIMINGS; i++)
+
+    for (i = 0; i < STD_TIMINGS; i++) {
         if (timing[i].hsize && timing[i].vsize && timing[i].refresh) {
             Mode =  xf86CVTMode(timing[i].hsize, timing[i].vsize,
                                 timing[i].refresh, FALSE, FALSE);
 	    Mode->type = M_T_DRIVER;
             Modes = xf86ModesAdd(Modes, Mode);
         }
+    }
 
     return Modes;
 }
@@ -108,55 +109,56 @@ DDCModeFromDetailedTiming(int scrnIndex,
 
     /* We don't do stereo */
     if (timing->stereo) {
-        xf86DrvMsg(scrnIndex, X_INFO, "%s: Ignoring: We don't handle stereo.\n",
-                   __func__);
+        xf86DrvMsg(scrnIndex, X_INFO,
+		   "%s: Ignoring: We don't handle stereo.\n", __func__);
         return NULL;
     }
-    
+
     /* We only do seperate sync currently */
     if (timing->sync != 0x03) {
-         xf86DrvMsg(scrnIndex, X_INFO, "%s: %dx%d Warning: We only handle seperate"
+         xf86DrvMsg(scrnIndex, X_INFO,
+		    "%s: %dx%d Warning: We only handle seperate"
                     " sync.\n", __func__, timing->h_active, timing->v_active);
     }
-    
+
     Mode = xnfalloc(sizeof(DisplayModeRec));
     memset(Mode, 0, sizeof(DisplayModeRec));
-    
+
     Mode->name = xnfalloc(10); /* "1234x1234" */
     xf86snprintf(Mode->name, 20, "%dx%d", timing->h_active,
                  timing->v_active);
-    
+
     Mode->type = M_T_DRIVER;
     if (preferred)
 	Mode->type |= M_T_PREFERRED;
-    
+
     Mode->Clock = timing->clock / 1000.0;
-    
+
     Mode->HDisplay = timing->h_active;
     Mode->HSyncStart = timing->h_active + timing->h_sync_off;
     Mode->HSyncEnd = Mode->HSyncStart + timing->h_sync_width;
     Mode->HTotal = timing->h_active + timing->h_blanking;
-    
+
     Mode->VDisplay = timing->v_active;
     Mode->VSyncStart = timing->v_active + timing->v_sync_off;
     Mode->VSyncEnd = Mode->VSyncStart + timing->v_sync_width;
     Mode->VTotal = timing->v_active + timing->v_blanking;
-    
+
     /* We ignore h/v_size and h/v_border for now. */
-    
+
     if (timing->interlaced)
         Mode->Flags |= V_INTERLACE;
-    
+
     if (timing->misc & 0x02)
         Mode->Flags |= V_PHSYNC;
     else
         Mode->Flags |= V_NHSYNC;
-    
+
     if (timing->misc & 0x01)
         Mode->Flags |= V_PVSYNC;
     else
         Mode->Flags |= V_NVSYNC;
- 
+
     return Mode;
 }
 
@@ -199,7 +201,7 @@ DDCGuessRangesFromModes(int scrnIndex, M
 
         if (Mode->VRefresh > Monitor->vrefresh[0].hi)
             Monitor->vrefresh[0].hi = Mode->VRefresh;
-        
+
         Mode = Mode->next;
     }
 }
@@ -214,7 +216,7 @@ xf86DDCMonitorSet(int scrnIndex, MonPtr 
     int i, clock;
     Bool have_hsync = FALSE, have_vrefresh = FALSE;
     int preferred;
-    
+
     if (!Monitor || !DDC)
         return;
 
@@ -224,9 +226,9 @@ xf86DDCMonitorSet(int scrnIndex, MonPtr 
 
     Monitor->widthmm = 10 * DDC->features.hsize;
     Monitor->heightmm = 10 * DDC->features.vsize;
-    
+
     /* If this is a digital display, then we can use reduced blanking */
-    if (DDC->features.input_type) 
+    if (DDC->features.input_type)
         Monitor->reducedblanking = TRUE;
     /* Allow the user to also enable this through config */
 
@@ -280,7 +282,7 @@ xf86DDCMonitorSet(int scrnIndex, MonPtr 
 
             break;
         case DT:
-            Mode = DDCModeFromDetailedTiming(scrnIndex, 
+            Mode = DDCModeFromDetailedTiming(scrnIndex,
                                              &DDC->det_mon[i].section.d_timings,
 					     preferred);
 	    preferred = 0;
@@ -314,7 +316,7 @@ xf86DDCMonitorSet(int scrnIndex, MonPtr 
 
         while (Mode->next)
             Mode = Mode->next;
-        
+
         /* add to MonPtr */
         if (Monitor->Modes) {
             Monitor->Last->next = Modes;
diff-tree 05778432dc6e688bc0beff0c20ffd7e27b74888e (from 38ecc66cd9c61346a46697bbf1d8319f4f6f9800)
Author: Eric Anholt <eric at anholt.net>
Date:   Tue Nov 28 10:07:57 2006 -0800

    Move code to get a mode list from EDID data from ddcProperty.c to edid_modes.c.

diff --git a/hw/xfree86/ddc/Makefile.am b/hw/xfree86/ddc/Makefile.am
index aff8cd3..a04b5e8 100644
--- a/hw/xfree86/ddc/Makefile.am
+++ b/hw/xfree86/ddc/Makefile.am
@@ -4,7 +4,8 @@ module_LTLIBRARIES = libddc.la
 
 libddc_la_LDFLAGS = -avoid-version
 libddc_la_SOURCES = xf86DDC.c edid.c interpret_edid.c print_edid.c \
-                   interpret_vdif.c print_vdif.c ddcProperty.c
+                   interpret_vdif.c print_vdif.c ddcProperty.c \
+		    edid_modes.c
 
 INCLUDES = $(XORG_INCS) -I$(srcdir)/../i2c
 
diff --git a/hw/xfree86/ddc/ddcProperty.c b/hw/xfree86/ddc/ddcProperty.c
index ddf580c..11b5e26 100644
--- a/hw/xfree86/ddc/ddcProperty.c
+++ b/hw/xfree86/ddc/ddcProperty.c
@@ -32,300 +32,8 @@
 #include "propertyst.h"
 #include "xf86DDC.h"
 
-/*
- * TODO:
- *  - for those with access to the VESA DMT standard; review please.
- */
-#define MODEPREFIX(name) NULL, NULL, name, 0,M_T_DRIVER
-#define MODESUFFIX   0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,FALSE,FALSE,0,NULL,0,0.0,0.0
-
-DisplayModeRec DDCEstablishedModes[17] = {
-    { MODEPREFIX("800x600"),    40000,  800,  840,  968, 1056, 0,  600,  601,  605,  628, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600 at 60Hz */
-    { MODEPREFIX("800x600"),    36000,  800,  824,  896, 1024, 0,  600,  601,  603,  625, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600 at 56Hz */
-    { MODEPREFIX("640x480"),    31500,  640,  656,  720,  840, 0,  480,  481,  484,  500, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480 at 75Hz */
-    { MODEPREFIX("640x480"),    31500,  640,  664,  704,  832, 0,  480,  489,  491,  520, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480 at 72Hz */
-    { MODEPREFIX("640x480"),    30240,  640,  704,  768,  864, 0,  480,  483,  486,  525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480 at 67Hz */
-    { MODEPREFIX("640x480"),    25200,  640,  656,  752,  800, 0,  480,  490,  492,  525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480 at 60Hz */
-    { MODEPREFIX("720x400"),    35500,  720,  738,  846,  900, 0,  400,  421,  423,  449, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 720x400 at 88Hz */
-    { MODEPREFIX("720x400"),    28320,  720,  738,  846,  900, 0,  400,  412,  414,  449, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 720x400 at 70Hz */
-    { MODEPREFIX("1280x1024"), 135000, 1280, 1296, 1440, 1688, 0, 1024, 1025, 1028, 1066, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x1024 at 75Hz */
-    { MODEPREFIX("1024x768"),   78800, 1024, 1040, 1136, 1312, 0,  768,  769,  772,  800, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1024x768 at 75Hz */
-    { MODEPREFIX("1024x768"),   75000, 1024, 1048, 1184, 1328, 0,  768,  771,  777,  806, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 1024x768 at 70Hz */
-    { MODEPREFIX("1024x768"),   65000, 1024, 1048, 1184, 1344, 0,  768,  771,  777,  806, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 1024x768 at 60Hz */
-    { MODEPREFIX("1024x768"),   44900, 1024, 1032, 1208, 1264, 0,  768,  768,  776,  817, 0, V_PHSYNC | V_PVSYNC | V_INTERLACE, MODESUFFIX }, /* 1024x768 at 43Hz */
-    { MODEPREFIX("832x624"),    57284,  832,  864,  928, 1152, 0,  624,  625,  628,  667, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 832x624 at 75Hz */
-    { MODEPREFIX("800x600"),    49500,  800,  816,  896, 1056, 0,  600,  601,  604,  625, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600 at 75Hz */
-    { MODEPREFIX("800x600"),    50000,  800,  856,  976, 1040, 0,  600,  637,  643,  666, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600 at 72Hz */
-    { MODEPREFIX("1152x864"),  108000, 1152, 1216, 1344, 1600, 0,  864,  865,  868,  900, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1152x864 at 75Hz */
-};
 
-static DisplayModePtr
-DDCModesFromEstablished(int scrnIndex, struct established_timings *timing)
-{
-    DisplayModePtr Modes = NULL, Mode = NULL;
-    CARD32 bits = (timing->t1) | (timing->t2 << 8) |
-        ((timing->t_manu & 0x80) << 9);
-    int i;
-
-    for (i = 0; i < 17; i++) {
-        if (bits & (0x01 << i)) {
-            Mode = xf86DuplicateMode(&DDCEstablishedModes[i]);
-            Modes = xf86ModesAdd(Modes, Mode);
-        }
-    }
-
-    return Modes;
-}
-
-/*
- *
- */
-static DisplayModePtr
-DDCModesFromStandardTiming(int scrnIndex, struct std_timings *timing)
-{
-    DisplayModePtr Modes = NULL, Mode = NULL;
-    int i;
-    
-    for (i = 0; i < STD_TIMINGS; i++)
-        if (timing[i].hsize && timing[i].vsize && timing[i].refresh) {
-            Mode =  xf86CVTMode(timing[i].hsize, timing[i].vsize,
-                                timing[i].refresh, FALSE, FALSE);
-	    Mode->type = M_T_DRIVER;
-            Modes = xf86ModesAdd(Modes, Mode);
-        }
-
-    return Modes;
-}
-
-/*
- *
- */
-static DisplayModePtr
-DDCModeFromDetailedTiming(int scrnIndex, struct detailed_timings *timing,
-			  int preferred)
-{
-    DisplayModePtr Mode;
-
-    /* We don't do stereo */
-    if (timing->stereo) {
-        xf86DrvMsg(scrnIndex, X_INFO, "%s: Ignoring: We don't handle stereo.\n",
-                   __func__);
-        return NULL;
-    }
-    
-    /* We only do seperate sync currently */
-    if (timing->sync != 0x03) {
-         xf86DrvMsg(scrnIndex, X_INFO, "%s: %dx%d Warning: We only handle seperate"
-                    " sync.\n", __func__, timing->h_active, timing->v_active);
-    }
-    
-    Mode = xnfalloc(sizeof(DisplayModeRec));
-    memset(Mode, 0, sizeof(DisplayModeRec));
-    
-    Mode->name = xnfalloc(10); /* "1234x1234" */
-    xf86snprintf(Mode->name, 20, "%dx%d", timing->h_active,
-                 timing->v_active);
-    
-    Mode->type = M_T_DRIVER;
-    if (preferred)
-	Mode->type |= M_T_PREFERRED;
-    
-    Mode->Clock = timing->clock / 1000.0;
-    
-    Mode->HDisplay = timing->h_active;
-    Mode->HSyncStart = timing->h_active + timing->h_sync_off;
-    Mode->HSyncEnd = Mode->HSyncStart + timing->h_sync_width;
-    Mode->HTotal = timing->h_active + timing->h_blanking;
-    
-    Mode->VDisplay = timing->v_active;
-    Mode->VSyncStart = timing->v_active + timing->v_sync_off;
-    Mode->VSyncEnd = Mode->VSyncStart + timing->v_sync_width;
-    Mode->VTotal = timing->v_active + timing->v_blanking;
-    
-    /* We ignore h/v_size and h/v_border for now. */
-    
-    if (timing->interlaced)
-        Mode->Flags |= V_INTERLACE;
-    
-    if (timing->misc & 0x02)
-        Mode->Flags |= V_PHSYNC;
-    else
-        Mode->Flags |= V_NHSYNC;
-    
-    if (timing->misc & 0x01)
-        Mode->Flags |= V_PVSYNC;
-    else
-        Mode->Flags |= V_NVSYNC;
- 
-    return Mode;
-}
-
-/*
- *
- */
-static void
-DDCGuessRangesFromModes(int scrnIndex, MonPtr Monitor, DisplayModePtr Modes)
-{
-    DisplayModePtr Mode = Modes;
-
-    if (!Monitor || !Modes)
-        return;
-
-    /* set up the ranges for scanning through the modes */
-    Monitor->nHsync = 1;
-    Monitor->hsync[0].lo = 1024.0;
-    Monitor->hsync[0].hi = 0.0;
 
-    Monitor->nVrefresh = 1;
-    Monitor->vrefresh[0].lo = 1024.0;
-    Monitor->vrefresh[0].hi = 0.0;
-
-    while (Mode) {
-        if (!Mode->HSync)
-            Mode->HSync = ((float) Mode->Clock ) / ((float) Mode->HTotal);
-
-        if (!Mode->VRefresh)
-            Mode->VRefresh = (1000.0 * ((float) Mode->Clock)) / 
-                ((float) (Mode->HTotal * Mode->VTotal));
-
-        if (Mode->HSync < Monitor->hsync[0].lo)
-            Monitor->hsync[0].lo = Mode->HSync;
-
-        if (Mode->HSync > Monitor->hsync[0].hi)
-            Monitor->hsync[0].hi = Mode->HSync;
-
-        if (Mode->VRefresh < Monitor->vrefresh[0].lo)
-            Monitor->vrefresh[0].lo = Mode->VRefresh;
-
-        if (Mode->VRefresh > Monitor->vrefresh[0].hi)
-            Monitor->vrefresh[0].hi = Mode->VRefresh;
-        
-        Mode = Mode->next;
-    }
-}
-
-/*
- * Fill out MonPtr with xf86MonPtr information.
- */
-void
-xf86DDCMonitorSet(int scrnIndex, MonPtr Monitor, xf86MonPtr DDC)
-{
-    DisplayModePtr Modes = NULL, Mode;
-    int i, clock;
-    Bool have_hsync = FALSE, have_vrefresh = FALSE;
-    int preferred;
-    
-    if (!Monitor || !DDC)
-        return;
-
-    Monitor->DDC = DDC;
-
-    preferred = PREFERRED_TIMING_MODE(DDC->features.msc);
-
-    Monitor->widthmm = 10 * DDC->features.hsize;
-    Monitor->heightmm = 10 * DDC->features.vsize;
-    
-    /* If this is a digital display, then we can use reduced blanking */
-    if (DDC->features.input_type) 
-        Monitor->reducedblanking = TRUE;
-    /* Allow the user to also enable this through config */
-
-    /* Add established timings */
-    Mode = DDCModesFromEstablished(scrnIndex, &DDC->timings1);
-    Modes = xf86ModesAdd(Modes, Mode);
-
-    /* Add standard timings */
-    Mode = DDCModesFromStandardTiming(scrnIndex, DDC->timings2);
-    Modes = xf86ModesAdd(Modes, Mode);
-
-    /* Skip EDID ranges if they were specified in the config file */
-    have_hsync = (Monitor->nHsync != 0);
-    have_vrefresh = (Monitor->nVrefresh != 0);
-
-    /* Go through the detailed monitor sections */
-    for (i = 0; i < DET_TIMINGS; i++)
-        switch (DDC->det_mon[i].type) {
-        case DS_RANGES:
-	    if (!have_hsync) {
-		if (!Monitor->nHsync)
-		    xf86DrvMsg(scrnIndex, X_INFO,
-			    "Using EDID range info for horizontal sync\n");
-		Monitor->hsync[Monitor->nHsync].lo =
-		    DDC->det_mon[i].section.ranges.min_h;
-		Monitor->hsync[Monitor->nHsync].hi =
-		    DDC->det_mon[i].section.ranges.max_h;
-		Monitor->nHsync++;
-	    } else {
-		xf86DrvMsg(scrnIndex, X_INFO,
-			"Using hsync ranges from config file\n");
-	    }
-
-	    if (!have_vrefresh) {
-		if (!Monitor->nVrefresh)
-		    xf86DrvMsg(scrnIndex, X_INFO,
-			    "Using EDID range info for vertical refresh\n");
-		Monitor->vrefresh[Monitor->nVrefresh].lo =
-		    DDC->det_mon[i].section.ranges.min_v;
-		Monitor->vrefresh[Monitor->nVrefresh].hi =
-		    DDC->det_mon[i].section.ranges.max_v;
-		Monitor->nVrefresh++;
-	    } else {
-		xf86DrvMsg(scrnIndex, X_INFO,
-			"Using vrefresh ranges from config file\n");
-	    }
-
-	    clock = DDC->det_mon[i].section.ranges.max_clock * 1000;
-	    if (clock > Monitor->maxPixClock)
-		Monitor->maxPixClock = clock;
-
-            break;
-        case DT:
-            Mode = DDCModeFromDetailedTiming(scrnIndex, 
-                                             &DDC->det_mon[i].section.d_timings,
-					     preferred);
-	    preferred = 0;
-            Modes = xf86ModesAdd(Modes, Mode);
-            break;
-        case DS_STD_TIMINGS:
-            Mode = DDCModesFromStandardTiming(scrnIndex,
-                                             DDC->det_mon[i].section.std_t);
-            Modes = xf86ModesAdd(Modes, Mode);
-            break;
-        default:
-            break;
-        }
-
-    if (Modes) {
-        /* Print Modes */
-        xf86DrvMsg(scrnIndex, X_INFO, "Printing DDC gathered Modelines:\n");
-
-        Mode = Modes;
-        while (Mode) {
-            xf86PrintModeline(scrnIndex, Mode);
-            Mode = Mode->next;
-        }
-
-        /* Do we still need ranges to be filled in? */
-        if (!Monitor->nHsync || !Monitor->nVrefresh)
-            DDCGuessRangesFromModes(scrnIndex, Monitor, Modes);
-
-        /* look for last Mode */
-        Mode = Modes;
-
-        while (Mode->next)
-            Mode = Mode->next;
-        
-        /* add to MonPtr */
-        if (Monitor->Modes) {
-            Monitor->Last->next = Modes;
-            Modes->prev = Monitor->Last;
-            Monitor->Last = Mode;
-        } else {
-            Monitor->Modes = Modes;
-            Monitor->Last = Mode;
-        }
-    }
-}
 
 #define EDID1_ATOM_NAME         "XFree86_DDC_EDID1_RAWDATA"
 #define EDID2_ATOM_NAME         "XFree86_DDC_EDID2_RAWDATA"
diff --git a/hw/xfree86/ddc/edid_modes.c b/hw/xfree86/ddc/edid_modes.c
new file mode 100644
index 0000000..5ce86ee
--- /dev/null
+++ b/hw/xfree86/ddc/edid_modes.c
@@ -0,0 +1,328 @@
+/*
+ * Copyright 2006 Luc Verhaegen.
+ *
+ * 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, sub license,
+ * 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 NON-INFRINGEMENT. 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_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86.h"
+#include "xf86DDC.h"
+#include <X11/Xatom.h>
+#include "property.h"
+#include "propertyst.h"
+#include "xf86DDC.h"
+
+/*
+ * TODO:
+ *  - for those with access to the VESA DMT standard; review please.
+ */
+#define MODEPREFIX(name) NULL, NULL, name, 0,M_T_DRIVER
+#define MODESUFFIX   0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,FALSE,FALSE,0,NULL,0,0.0,0.0
+
+DisplayModeRec DDCEstablishedModes[17] = {
+    { MODEPREFIX("800x600"),    40000,  800,  840,  968, 1056, 0,  600,  601,  605,  628, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600 at 60Hz */
+    { MODEPREFIX("800x600"),    36000,  800,  824,  896, 1024, 0,  600,  601,  603,  625, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600 at 56Hz */
+    { MODEPREFIX("640x480"),    31500,  640,  656,  720,  840, 0,  480,  481,  484,  500, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480 at 75Hz */
+    { MODEPREFIX("640x480"),    31500,  640,  664,  704,  832, 0,  480,  489,  491,  520, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480 at 72Hz */
+    { MODEPREFIX("640x480"),    30240,  640,  704,  768,  864, 0,  480,  483,  486,  525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480 at 67Hz */
+    { MODEPREFIX("640x480"),    25200,  640,  656,  752,  800, 0,  480,  490,  492,  525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480 at 60Hz */
+    { MODEPREFIX("720x400"),    35500,  720,  738,  846,  900, 0,  400,  421,  423,  449, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 720x400 at 88Hz */
+    { MODEPREFIX("720x400"),    28320,  720,  738,  846,  900, 0,  400,  412,  414,  449, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 720x400 at 70Hz */
+    { MODEPREFIX("1280x1024"), 135000, 1280, 1296, 1440, 1688, 0, 1024, 1025, 1028, 1066, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x1024 at 75Hz */
+    { MODEPREFIX("1024x768"),   78800, 1024, 1040, 1136, 1312, 0,  768,  769,  772,  800, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1024x768 at 75Hz */
+    { MODEPREFIX("1024x768"),   75000, 1024, 1048, 1184, 1328, 0,  768,  771,  777,  806, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 1024x768 at 70Hz */
+    { MODEPREFIX("1024x768"),   65000, 1024, 1048, 1184, 1344, 0,  768,  771,  777,  806, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 1024x768 at 60Hz */
+    { MODEPREFIX("1024x768"),   44900, 1024, 1032, 1208, 1264, 0,  768,  768,  776,  817, 0, V_PHSYNC | V_PVSYNC | V_INTERLACE, MODESUFFIX }, /* 1024x768 at 43Hz */
+    { MODEPREFIX("832x624"),    57284,  832,  864,  928, 1152, 0,  624,  625,  628,  667, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 832x624 at 75Hz */
+    { MODEPREFIX("800x600"),    49500,  800,  816,  896, 1056, 0,  600,  601,  604,  625, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600 at 75Hz */
+    { MODEPREFIX("800x600"),    50000,  800,  856,  976, 1040, 0,  600,  637,  643,  666, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600 at 72Hz */
+    { MODEPREFIX("1152x864"),  108000, 1152, 1216, 1344, 1600, 0,  864,  865,  868,  900, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1152x864 at 75Hz */
+};
+
+static DisplayModePtr
+DDCModesFromEstablished(int scrnIndex, struct established_timings *timing)
+{
+    DisplayModePtr Modes = NULL, Mode = NULL;
+    CARD32 bits = (timing->t1) | (timing->t2 << 8) |
+        ((timing->t_manu & 0x80) << 9);
+    int i;
+
+    for (i = 0; i < 17; i++) {
+        if (bits & (0x01 << i)) {
+            Mode = xf86DuplicateMode(&DDCEstablishedModes[i]);
+            Modes = xf86ModesAdd(Modes, Mode);
+        }
+    }
+
+    return Modes;
+}
+
+/*
+ *
+ */
+static DisplayModePtr
+DDCModesFromStandardTiming(int scrnIndex, struct std_timings *timing)
+{
+    DisplayModePtr Modes = NULL, Mode = NULL;
+    int i;
+    
+    for (i = 0; i < STD_TIMINGS; i++)
+        if (timing[i].hsize && timing[i].vsize && timing[i].refresh) {
+            Mode =  xf86CVTMode(timing[i].hsize, timing[i].vsize,
+                                timing[i].refresh, FALSE, FALSE);
+	    Mode->type = M_T_DRIVER;
+            Modes = xf86ModesAdd(Modes, Mode);
+        }
+
+    return Modes;
+}
+
+/*
+ *
+ */
+static DisplayModePtr
+DDCModeFromDetailedTiming(int scrnIndex, struct detailed_timings *timing,
+			  int preferred)
+{
+    DisplayModePtr Mode;
+
+    /* We don't do stereo */
+    if (timing->stereo) {
+        xf86DrvMsg(scrnIndex, X_INFO, "%s: Ignoring: We don't handle stereo.\n",
+                   __func__);
+        return NULL;
+    }
+    
+    /* We only do seperate sync currently */
+    if (timing->sync != 0x03) {
+         xf86DrvMsg(scrnIndex, X_INFO, "%s: %dx%d Warning: We only handle seperate"
+                    " sync.\n", __func__, timing->h_active, timing->v_active);
+    }
+    
+    Mode = xnfalloc(sizeof(DisplayModeRec));
+    memset(Mode, 0, sizeof(DisplayModeRec));
+    
+    Mode->name = xnfalloc(10); /* "1234x1234" */
+    xf86snprintf(Mode->name, 20, "%dx%d", timing->h_active,
+                 timing->v_active);
+    
+    Mode->type = M_T_DRIVER;
+    if (preferred)
+	Mode->type |= M_T_PREFERRED;
+    
+    Mode->Clock = timing->clock / 1000.0;
+    
+    Mode->HDisplay = timing->h_active;
+    Mode->HSyncStart = timing->h_active + timing->h_sync_off;
+    Mode->HSyncEnd = Mode->HSyncStart + timing->h_sync_width;
+    Mode->HTotal = timing->h_active + timing->h_blanking;
+    
+    Mode->VDisplay = timing->v_active;
+    Mode->VSyncStart = timing->v_active + timing->v_sync_off;
+    Mode->VSyncEnd = Mode->VSyncStart + timing->v_sync_width;
+    Mode->VTotal = timing->v_active + timing->v_blanking;
+    
+    /* We ignore h/v_size and h/v_border for now. */
+    
+    if (timing->interlaced)
+        Mode->Flags |= V_INTERLACE;
+    
+    if (timing->misc & 0x02)
+        Mode->Flags |= V_PHSYNC;
+    else
+        Mode->Flags |= V_NHSYNC;
+    
+    if (timing->misc & 0x01)
+        Mode->Flags |= V_PVSYNC;
+    else
+        Mode->Flags |= V_NVSYNC;
+ 
+    return Mode;
+}
+
+/*
+ *
+ */
+static void
+DDCGuessRangesFromModes(int scrnIndex, MonPtr Monitor, DisplayModePtr Modes)
+{
+    DisplayModePtr Mode = Modes;
+
+    if (!Monitor || !Modes)
+        return;
+
+    /* set up the ranges for scanning through the modes */
+    Monitor->nHsync = 1;
+    Monitor->hsync[0].lo = 1024.0;
+    Monitor->hsync[0].hi = 0.0;
+
+    Monitor->nVrefresh = 1;
+    Monitor->vrefresh[0].lo = 1024.0;
+    Monitor->vrefresh[0].hi = 0.0;
+
+    while (Mode) {
+        if (!Mode->HSync)
+            Mode->HSync = ((float) Mode->Clock ) / ((float) Mode->HTotal);
+
+        if (!Mode->VRefresh)
+            Mode->VRefresh = (1000.0 * ((float) Mode->Clock)) / 
+                ((float) (Mode->HTotal * Mode->VTotal));
+
+        if (Mode->HSync < Monitor->hsync[0].lo)
+            Monitor->hsync[0].lo = Mode->HSync;
+
+        if (Mode->HSync > Monitor->hsync[0].hi)
+            Monitor->hsync[0].hi = Mode->HSync;
+
+        if (Mode->VRefresh < Monitor->vrefresh[0].lo)
+            Monitor->vrefresh[0].lo = Mode->VRefresh;
+
+        if (Mode->VRefresh > Monitor->vrefresh[0].hi)
+            Monitor->vrefresh[0].hi = Mode->VRefresh;
+        
+        Mode = Mode->next;
+    }
+}
+
+/*
+ * Fill out MonPtr with xf86MonPtr information.
+ */
+void
+xf86DDCMonitorSet(int scrnIndex, MonPtr Monitor, xf86MonPtr DDC)
+{
+    DisplayModePtr Modes = NULL, Mode;
+    int i, clock;
+    Bool have_hsync = FALSE, have_vrefresh = FALSE;
+    int preferred;
+    
+    if (!Monitor || !DDC)
+        return;
+
+    Monitor->DDC = DDC;
+
+    preferred = PREFERRED_TIMING_MODE(DDC->features.msc);
+
+    Monitor->widthmm = 10 * DDC->features.hsize;
+    Monitor->heightmm = 10 * DDC->features.vsize;
+    
+    /* If this is a digital display, then we can use reduced blanking */
+    if (DDC->features.input_type) 
+        Monitor->reducedblanking = TRUE;
+    /* Allow the user to also enable this through config */
+
+    /* Add established timings */
+    Mode = DDCModesFromEstablished(scrnIndex, &DDC->timings1);
+    Modes = xf86ModesAdd(Modes, Mode);
+
+    /* Add standard timings */
+    Mode = DDCModesFromStandardTiming(scrnIndex, DDC->timings2);
+    Modes = xf86ModesAdd(Modes, Mode);
+
+    /* Skip EDID ranges if they were specified in the config file */
+    have_hsync = (Monitor->nHsync != 0);
+    have_vrefresh = (Monitor->nVrefresh != 0);
+
+    /* Go through the detailed monitor sections */
+    for (i = 0; i < DET_TIMINGS; i++)
+        switch (DDC->det_mon[i].type) {
+        case DS_RANGES:
+	    if (!have_hsync) {
+		if (!Monitor->nHsync)
+		    xf86DrvMsg(scrnIndex, X_INFO,
+			    "Using EDID range info for horizontal sync\n");
+		Monitor->hsync[Monitor->nHsync].lo =
+		    DDC->det_mon[i].section.ranges.min_h;
+		Monitor->hsync[Monitor->nHsync].hi =
+		    DDC->det_mon[i].section.ranges.max_h;
+		Monitor->nHsync++;
+	    } else {
+		xf86DrvMsg(scrnIndex, X_INFO,
+			"Using hsync ranges from config file\n");
+	    }
+
+	    if (!have_vrefresh) {
+		if (!Monitor->nVrefresh)
+		    xf86DrvMsg(scrnIndex, X_INFO,
+			    "Using EDID range info for vertical refresh\n");
+		Monitor->vrefresh[Monitor->nVrefresh].lo =
+		    DDC->det_mon[i].section.ranges.min_v;
+		Monitor->vrefresh[Monitor->nVrefresh].hi =
+		    DDC->det_mon[i].section.ranges.max_v;
+		Monitor->nVrefresh++;
+	    } else {
+		xf86DrvMsg(scrnIndex, X_INFO,
+			"Using vrefresh ranges from config file\n");
+	    }
+
+	    clock = DDC->det_mon[i].section.ranges.max_clock * 1000;
+	    if (clock > Monitor->maxPixClock)
+		Monitor->maxPixClock = clock;
+
+            break;
+        case DT:
+            Mode = DDCModeFromDetailedTiming(scrnIndex, 
+                                             &DDC->det_mon[i].section.d_timings,
+					     preferred);
+	    preferred = 0;
+            Modes = xf86ModesAdd(Modes, Mode);
+            break;
+        case DS_STD_TIMINGS:
+            Mode = DDCModesFromStandardTiming(scrnIndex,
+                                             DDC->det_mon[i].section.std_t);
+            Modes = xf86ModesAdd(Modes, Mode);
+            break;
+        default:
+            break;
+        }
+
+    if (Modes) {
+        /* Print Modes */
+        xf86DrvMsg(scrnIndex, X_INFO, "Printing DDC gathered Modelines:\n");
+
+        Mode = Modes;
+        while (Mode) {
+            xf86PrintModeline(scrnIndex, Mode);
+            Mode = Mode->next;
+        }
+
+        /* Do we still need ranges to be filled in? */
+        if (!Monitor->nHsync || !Monitor->nVrefresh)
+            DDCGuessRangesFromModes(scrnIndex, Monitor, Modes);
+
+        /* look for last Mode */
+        Mode = Modes;
+
+        while (Mode->next)
+            Mode = Mode->next;
+        
+        /* add to MonPtr */
+        if (Monitor->Modes) {
+            Monitor->Last->next = Modes;
+            Modes->prev = Monitor->Last;
+            Monitor->Last = Mode;
+        } else {
+            Monitor->Modes = Modes;
+            Monitor->Last = Mode;
+        }
+    }
+}
diff-tree 38ecc66cd9c61346a46697bbf1d8319f4f6f9800 (from 834e4b079866594b50be64ae79f3cb2a5baa2070)
Author: Eric Anholt <eric at anholt.net>
Date:   Tue Nov 28 10:06:15 2006 -0800

    Typo that was missed in testing.

diff --git a/hw/xfree86/ddc/ddcProperty.c b/hw/xfree86/ddc/ddcProperty.c
index 87c91b8..ddf580c 100644
--- a/hw/xfree86/ddc/ddcProperty.c
+++ b/hw/xfree86/ddc/ddcProperty.c
@@ -69,7 +69,7 @@ DDCModesFromEstablished(int scrnIndex, s
 
     for (i = 0; i < 17; i++) {
         if (bits & (0x01 << i)) {
-            Mode = xf86DusplicateMode(&DDCEstablishedModes[i]);
+            Mode = xf86DuplicateMode(&DDCEstablishedModes[i]);
             Modes = xf86ModesAdd(Modes, Mode);
         }
     }
diff-tree 834e4b079866594b50be64ae79f3cb2a5baa2070 (from 5dbcd34a0a6c0d10dbfea8fdc9d7dfe7a0261b19)
Author: Matthias Hopf <mhopf at suse.de>
Date:   Tue Nov 28 18:57:13 2006 +0100

    Fix potential NULL pointer access in timer code.
    
    https://bugzilla.novell.com/show_bug.cgi?id=223718

diff --git a/os/WaitFor.c b/os/WaitFor.c
index 6109e34..ba227a3 100644
--- a/os/WaitFor.c
+++ b/os/WaitFor.c
@@ -205,15 +205,17 @@ WaitForSomething(int *pClientsReady)
             if (timeout > 0 && timeout > timers->delta + 250) {
                 /* time has rewound.  reset the timers. */
                 CheckAllTimers(now);
-                timeout = timers->expires - now;
             }
 
-            if (timeout < 0)
-                timeout = 0;
-	    waittime.tv_sec = timeout / MILLI_PER_SECOND;
-	    waittime.tv_usec = (timeout % MILLI_PER_SECOND) *
-		               (1000000 / MILLI_PER_SECOND);
-	    wt = &waittime;
+	    if (timers) {
+		timeout = timers->expires - now;
+		if (timeout < 0)
+		    timeout = 0;
+		waittime.tv_sec = timeout / MILLI_PER_SECOND;
+		waittime.tv_usec = (timeout % MILLI_PER_SECOND) *
+				   (1000000 / MILLI_PER_SECOND);
+		wt = &waittime;
+	    }
 	}
 	XFD_COPYSET(&AllSockets, &LastSelectMask);
 #ifdef SMART_SCHEDULE
diff-tree 5dbcd34a0a6c0d10dbfea8fdc9d7dfe7a0261b19 (from 16f8f10dc2106bc6253b2d89a1f8efee8d80e2ba)
Author: Eric Anholt <eric at anholt.net>
Date:   Mon Nov 27 16:26:14 2006 -0800

    Register dependency on new RandR protocol.

diff --git a/configure.ac b/configure.ac
index e3221ed..db2234f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -545,7 +545,7 @@ XEXT_LIB='$(top_builddir)/Xext/libXext.l
 XEXTXORG_LIB='$(top_builddir)/Xext/libXextbuiltin.la'
 
 dnl Core modules for most extensions, et al.
-REQUIRED_MODULES="randrproto renderproto [fixesproto >= 4.0] damageproto xcmiscproto xextproto xproto xtrans [scrnsaverproto >= 1.1] bigreqsproto resourceproto fontsproto [inputproto >= 1.4] [kbproto >= 1.0.3]"
+REQUIRED_MODULES="[randrproto >= 1.2] renderproto [fixesproto >= 4.0] damageproto xcmiscproto xextproto xproto xtrans [scrnsaverproto >= 1.1] bigreqsproto resourceproto fontsproto [inputproto >= 1.4] [kbproto >= 1.0.3]"
 REQUIRED_LIBS="xfont xau fontenc"
 
 if test "x$DBUS" = xauto; then
diff-tree 16f8f10dc2106bc6253b2d89a1f8efee8d80e2ba (from b4b0d901d98371a8aa7b17d195e18e83e2a6a618)
Author: Eric Anholt <eric at anholt.net>
Date:   Mon Nov 27 16:21:31 2006 -0800

    Move mode handling helpers from ddcProperty.c to xf86Mode.c.

diff --git a/hw/xfree86/common/xf86.h b/hw/xfree86/common/xf86.h
index 41ad08a..aa73e7d 100644
--- a/hw/xfree86/common/xf86.h
+++ b/hw/xfree86/common/xf86.h
@@ -426,6 +426,7 @@ DisplayModePtr xf86DuplicateMode(Display
 DisplayModePtr xf86DuplicateModes(ScrnInfoPtr pScrn, DisplayModePtr modeList);
 Bool xf86ModesEqual(DisplayModePtr pMode1, DisplayModePtr pMode2);
 void xf86PrintModeline(int scrnIndex,DisplayModePtr mode);
+DisplayModePtr xf86ModesAdd(DisplayModePtr modes, DisplayModePtr new);
 
 /* xf86Option.c */
 
diff --git a/hw/xfree86/common/xf86Mode.c b/hw/xfree86/common/xf86Mode.c
index 5a51be0..3cebac7 100644
--- a/hw/xfree86/common/xf86Mode.c
+++ b/hw/xfree86/common/xf86Mode.c
@@ -2178,3 +2178,27 @@ xf86PrintModes(ScrnInfoPtr scrp)
 	p = p->next;
     } while (p != NULL && p != scrp->modes);
 }
+
+/**
+ * Adds the new mode into the mode list, and returns the new list
+ *
+ * \param modes doubly-linked mode list.
+ */
+_X_EXPORT DisplayModePtr
+xf86ModesAdd(DisplayModePtr modes, DisplayModePtr new)
+{
+    if (modes == NULL)
+	return new;
+
+    if (new) {
+        DisplayModePtr mode = modes;
+
+        while (mode->next)
+            mode = mode->next;
+
+        mode->next = new;
+        new->prev = mode;
+    }
+
+    return modes;
+}
diff --git a/hw/xfree86/ddc/ddcProperty.c b/hw/xfree86/ddc/ddcProperty.c
index a1650bc..87c91b8 100644
--- a/hw/xfree86/ddc/ddcProperty.c
+++ b/hw/xfree86/ddc/ddcProperty.c
@@ -33,98 +33,6 @@
 #include "xf86DDC.h"
 
 /*
- * xf86Mode.c should have a some more DisplayModePtr list handling.
- */
-static DisplayModePtr
-xf86ModesAdd(DisplayModePtr Modes, DisplayModePtr Additions)
-{
-    if (!Modes) {
-        if (Additions)
-            return Additions;
-        else
-            return NULL;
-    }
-
-    if (Additions) {
-        DisplayModePtr Mode = Modes;
-
-        while (Mode->next)
-            Mode = Mode->next;
-        
-        Mode->next = Additions;
-        Additions->prev = Mode;
-    }
-
-    return Modes;
-}
-
-static DisplayModePtr
-xf86ModeCopy(DisplayModePtr Mode)
-{
-    DisplayModePtr New;
-
-    if (!Mode)
-        return NULL;
-
-    New = xnfalloc(sizeof(DisplayModeRec));
-
-    memcpy(New, Mode, sizeof(DisplayModeRec));
-    
-    New->name = xnfalloc(strlen(Mode->name) + 1);
-    memcpy(New->name, Mode->name, strlen(Mode->name) + 1);
-
-    /* We ignore privates as DDC code doesn't use it currently */
-    return New;
-}
-
-/*
- * Temporary.
- */
-static void
-add(char **p, char *new)
-{
-    *p = xnfrealloc(*p, strlen(*p) + strlen(new) + 2);
-    strcat(*p, " ");
-    strcat(*p, new);
-}
-
-static void
-PrintModeline(int scrnIndex,DisplayModePtr mode)
-{
-    char tmp[256];
-    char *flags = xnfcalloc(1, 1);
-
-    if (mode->HSkew) { 
-	snprintf(tmp, 256, "hskew %i", mode->HSkew); 
-	add(&flags, tmp);
-    }
-    if (mode->VScan) { 
-	snprintf(tmp, 256, "vscan %i", mode->VScan); 
-	add(&flags, tmp);
-    }
-    if (mode->Flags & V_INTERLACE) add(&flags, "interlace");
-    if (mode->Flags & V_CSYNC) add(&flags, "composite");
-    if (mode->Flags & V_DBLSCAN) add(&flags, "doublescan");
-    if (mode->Flags & V_BCAST) add(&flags, "bcast");
-    if (mode->Flags & V_PHSYNC) add(&flags, "+hsync");
-    if (mode->Flags & V_NHSYNC) add(&flags, "-hsync");
-    if (mode->Flags & V_PVSYNC) add(&flags, "+vsync");
-    if (mode->Flags & V_NVSYNC) add(&flags, "-vsync");
-    if (mode->Flags & V_PCSYNC) add(&flags, "+csync");
-    if (mode->Flags & V_NCSYNC) add(&flags, "-csync");
-#if 0
-    if (mode->Flags & V_CLKDIV2) add(&flags, "vclk/2");
-#endif
-    xf86DrvMsgVerb(scrnIndex, X_INFO, 3,
-		   "Modeline \"%s\"  %6.2f  %i %i %i %i  %i %i %i %i%s\n",
-		   mode->name, mode->Clock/1000., mode->HDisplay,
-		   mode->HSyncStart, mode->HSyncEnd, mode->HTotal,
-		   mode->VDisplay, mode->VSyncStart, mode->VSyncEnd,
-		   mode->VTotal, flags);
-    xfree(flags);
-}
-
-/*
  * TODO:
  *  - for those with access to the VESA DMT standard; review please.
  */
@@ -159,11 +67,12 @@ DDCModesFromEstablished(int scrnIndex, s
         ((timing->t_manu & 0x80) << 9);
     int i;
 
-    for (i = 0; i < 17; i++)
+    for (i = 0; i < 17; i++) {
         if (bits & (0x01 << i)) {
-            Mode = xf86ModeCopy(&(DDCEstablishedModes[i]));
+            Mode = xf86DusplicateMode(&DDCEstablishedModes[i]);
             Modes = xf86ModesAdd(Modes, Mode);
         }
+    }
 
     return Modes;
 }
@@ -392,7 +301,7 @@ xf86DDCMonitorSet(int scrnIndex, MonPtr 
 
         Mode = Modes;
         while (Mode) {
-            PrintModeline(scrnIndex, Mode);
+            xf86PrintModeline(scrnIndex, Mode);
             Mode = Mode->next;
         }
 
diff-tree b4b0d901d98371a8aa7b17d195e18e83e2a6a618 (from parents)
Merge: 64de3baf85f6df274f71f736016f0848567cd9f6 d6cd0313c7f23f32c9c7dda00ff739e772bf7db3
Author: Eric Anholt <eric at anholt.net>
Date:   Mon Nov 27 15:43:15 2006 -0800

    Merge branch 'randr-1.2'
    
    Conflicts:
    
    	dix/events.c
    	dix/getevents.c
    	hw/xfree86/common/xf86Mode.c
    	hw/xfree86/dri/Makefile.am
    	hw/xfree86/os-support/drm/xf86drm.c
    	hw/xfree86/os-support/xf86drm.h

diff --cc configure.ac
index 590ab2a,b75caf7..e3221ed
@@@ -653,11 -654,13 +653,14 @@@
  if test "x$DRI" = xyes; then
  	AC_DEFINE(XF86DRI, 1, [Build DRI extension])
  	PKG_CHECK_MODULES([DRIPROTO], [xf86driproto])
 -	PKG_CHECK_MODULES([LIBDRM], [libdrm])
 +	PKG_CHECK_MODULES([LIBDRM], [libdrm >= 2.3.0])
  	PKG_CHECK_MODULES([GL], [glproto >= 1.4.1])
+ 	PKG_CHECK_EXISTS(libdrm >= 2.2.0,
+ 			 [AC_DEFINE([HAVE_LIBDRM_2_2], 1,
+ 			 [Has version 2.2 (or newer) of the drm library])])
  	AC_SUBST(DRIPROTO_CFLAGS)
  	AC_SUBST(LIBDRM_CFLAGS)
 +	AC_SUBST(LIBDRM_LIBS)
  	AC_SUBST(GL_CFLAGS)
  fi
  
diff --cc dix/getevents.c
index c1b8840,1d95028..be598bc
@@@ -37,8 -35,11 +37,9 @@@
  #include "inputstr.h"
  #include "scrnintstr.h"
  #include "cursorstr.h"
 -
  #include "dixstruct.h"
  #include "globals.h"
+ #include "dixevents.h"
 -
  #include "mipointer.h"
  
  #ifdef XKB
diff --cc hw/xfree86/common/xf86Mode.c
index 456331d,6dccf24..5a51be0
@@@ -475,141 -474,143 +487,141 @@@
  	cp->ClockMulFactor = max(1, cp->ClockMulFactor);
      }
  
 -    haveBuiltin = FALSE;
      /* Scan the mode pool for matching names */
 -    for (p = scrp->modePool; p != NULL; p = p->next) {
 -	if (strcmp(p->name, modep->name) == 0) {
 -	    /*
 -	     * Requested mode is a built-in mode. Don't let the user
 -	     * override it.
 -	     * Since built-in modes always come before user specified
 -	     * modes it will always be found first.  
 -	     */
 -	    if (p->type & M_T_BUILTIN) {
 -		haveBuiltin = TRUE;
 -	    }
 +    for (n = 0; n < ntypes; n++) {
 +	int type = types[n];
 +	for (p = scrp->modePool; p != NULL; p = p->next) {
  
 -	    if (haveBuiltin && !(p->type & M_T_BUILTIN))
 +	    /* scan through the modes in the sort order above */
 +	    if ((p->type & type) != type)
  		continue;
  
 -	    /* Skip over previously rejected modes */
 -	    if (p->status != MODE_OK) {
 -		if (!found)
 -		    status = p->status;
 -		continue;
 -	    }
 -		
 -	    /* Skip over previously considered modes */
 -	    if (p->prev)
 -		continue;
 +	    if (strcmp(p->name, modep->name) == 0) {
  
 -	    if (p->type & M_T_BUILTIN) {
 -		return xf86HandleBuiltinMode(scrp, p,modep, clockRanges,
 -					     allowDiv2);
 -	    }
 +		/* Skip over previously rejected modes */
 +		if (p->status != MODE_OK) {
 +		    if (!found)
 +			status = p->status;
 +		    continue;
 +		}
  
 -	    /* Check clock is in range */
 -	    cp = xf86FindClockRangeForMode(clockRanges, p);
 -	    if (cp == NULL) {
 -		/*
 -		 * XXX Could do more here to provide a more detailed
 -		 * reason for not finding a mode.
 -		 */
 -		p->status = MODE_CLOCK_RANGE;
 -		if (!found)
 -		    status = MODE_CLOCK_RANGE;
 -		continue;
 -	    }
 +		/* Skip over previously considered modes */
 +		if (p->prev)
 +		    continue;
  
 -	    /*
 -	     * If programmable clock and strategy is not LOOKUP_BEST_REFRESH,
 -	     * the required mode has been found, otherwise record the refresh
 -	     * and continue looking.
 -	     */
 -	    if (scrp->progClock) {
 -		found = TRUE;
 -		if (strategy != LOOKUP_BEST_REFRESH) {
 -		    bestMode = p;
 -		    DivFactor = cp->ClockDivFactor;
 -		    MulFactor = cp->ClockMulFactor;
 -		    ModePrivFlags = cp->PrivFlags;
 -		    break;
 +		if (p->type & M_T_BUILTIN) {
 +		    return xf86HandleBuiltinMode(scrp, p,modep, clockRanges,
 +			    allowDiv2);
  		}
 -		refresh = xf86ModeVRefresh(p);
 -		if (p->Flags & V_INTERLACE)
 -		    refresh /= INTERLACE_REFRESH_WEIGHT;
 -		if (refresh > bestRefresh) {
 -		    bestMode = p;
 -		    DivFactor = cp->ClockDivFactor;
 -		    MulFactor = cp->ClockMulFactor;
 -		    ModePrivFlags = cp->PrivFlags;
 -		    bestRefresh = refresh;
 +
 +		/* Check clock is in range */
 +		cp = xf86FindClockRangeForMode(clockRanges, p);
 +		if (cp == NULL) {
 +		    /*
 +		     * XXX Could do more here to provide a more detailed
 +		     * reason for not finding a mode.
 +		     */
 +		    p->status = MODE_CLOCK_RANGE;
 +		    if (!found)
 +			status = MODE_CLOCK_RANGE;
 +		    continue;
  		}
 -		continue;
 -	    }
  
 -	    /*
 -	     * Clock is in range, so if it is not a programmable clock, find
 -	     * a matching clock.
 -	     */
 +		/*
 +		 * If programmable clock and strategy is not
 +		 * LOOKUP_BEST_REFRESH, the required mode has been found,
 +		 * otherwise record the refresh and continue looking.
 +		 */
 +		if (scrp->progClock) {
 +		    found = TRUE;
 +		    if (strategy != LOOKUP_BEST_REFRESH) {
 +			bestMode = p;
 +			DivFactor = cp->ClockDivFactor;
 +			MulFactor = cp->ClockMulFactor;
 +			ModePrivFlags = cp->PrivFlags;
 +			break;
 +		    }
- 		    refresh = ModeVRefresh(p);
++		    refresh = xf86ModeVRefresh(p);
 +		    if (p->Flags & V_INTERLACE)
 +			refresh /= INTERLACE_REFRESH_WEIGHT;
 +		    if (refresh > bestRefresh) {
 +			bestMode = p;
 +			DivFactor = cp->ClockDivFactor;
 +			MulFactor = cp->ClockMulFactor;
 +			ModePrivFlags = cp->PrivFlags;
 +			bestRefresh = refresh;
 +		    }
 +		    continue;
 +		}
  
 -	    i = xf86GetNearestClock(scrp, p->Clock, allowDiv2,
 -		cp->ClockDivFactor, cp->ClockMulFactor, &k);
 -	    /*
 -	     * If the clock is too far from the requested clock, this
 -	     * mode is no good.
 -	     */
 -	    if (k & V_CLKDIV2)
 -		gap = abs((p->Clock * 2) -
 -		    ((scrp->clock[i] * cp->ClockDivFactor) / cp->ClockMulFactor));
 -	    else
 -		gap = abs(p->Clock -
 -		    ((scrp->clock[i] * cp->ClockDivFactor) / cp->ClockMulFactor));
 -	    if (gap > minimumGap) {
 -		p->status = MODE_NOCLOCK;
 -		if (!found)
 -		    status = MODE_NOCLOCK;
 -		continue;
 -	    }
 -	    found = TRUE;
 +		/*
 +		 * Clock is in range, so if it is not a programmable clock, find
 +		 * a matching clock.
 +		 */
  
 -	    if (strategy == LOOKUP_BEST_REFRESH) {
 -		refresh = xf86ModeVRefresh(p);
 -		if (p->Flags & V_INTERLACE)
 -		    refresh /= INTERLACE_REFRESH_WEIGHT;
 -		if (refresh > bestRefresh) {
 -		    bestMode = p;
 -		    DivFactor = cp->ClockDivFactor;
 -		    MulFactor = cp->ClockMulFactor;
 -		    ModePrivFlags = cp->PrivFlags;
 -		    extraFlags = k;
 -		    clockIndex = i;
 -		    bestRefresh = refresh;
 +		i = xf86GetNearestClock(scrp, p->Clock, allowDiv2,
 +			cp->ClockDivFactor, cp->ClockMulFactor, &k);
 +		/*
 +		 * If the clock is too far from the requested clock, this
 +		 * mode is no good.
 +		 */
 +		if (k & V_CLKDIV2)
 +		    gap = abs((p->Clock * 2) -
 +			    ((scrp->clock[i] * cp->ClockDivFactor) /
 +				cp->ClockMulFactor));
 +		else
 +		    gap = abs(p->Clock -
 +			    ((scrp->clock[i] * cp->ClockDivFactor) /
 +				cp->ClockMulFactor));
 +		if (gap > minimumGap) {
 +		    p->status = MODE_NOCLOCK;
 +		    if (!found)
 +			status = MODE_NOCLOCK;
 +		    continue;
  		}
 -		continue;
 -	    }
 -	    if (strategy == LOOKUP_CLOSEST_CLOCK) {
 -		if (gap < minimumGap) {
 -		    bestMode = p;
 -		    DivFactor = cp->ClockDivFactor;
 -		    MulFactor = cp->ClockMulFactor;
 -		    ModePrivFlags = cp->PrivFlags;
 -		    extraFlags = k;
 -		    clockIndex = i;
 -		    minimumGap = gap;
 +		found = TRUE;
 +
 +		if (strategy == LOOKUP_BEST_REFRESH) {
- 		    refresh = ModeVRefresh(p);
++		    refresh = xf86ModeVRefresh(p);
 +		    if (p->Flags & V_INTERLACE)
 +			refresh /= INTERLACE_REFRESH_WEIGHT;
 +		    if (refresh > bestRefresh) {
 +			bestMode = p;
 +			DivFactor = cp->ClockDivFactor;
 +			MulFactor = cp->ClockMulFactor;
 +			ModePrivFlags = cp->PrivFlags;
 +			extraFlags = k;
 +			clockIndex = i;
 +			bestRefresh = refresh;
 +		    }
 +		    continue;
  		}
 -		continue;
 +		if (strategy == LOOKUP_CLOSEST_CLOCK) {
 +		    if (gap < minimumGap) {
 +			bestMode = p;
 +			DivFactor = cp->ClockDivFactor;
 +			MulFactor = cp->ClockMulFactor;
 +			ModePrivFlags = cp->PrivFlags;
 +			extraFlags = k;
 +			clockIndex = i;
 +			minimumGap = gap;
 +		    }
 +		    continue;
 +		}
 +		/*
 +		 * If strategy is neither LOOKUP_BEST_REFRESH or
 +		 * LOOKUP_CLOSEST_CLOCK the required mode has been found.
 +		 */
 +		bestMode = p;
 +		DivFactor = cp->ClockDivFactor;
 +		MulFactor = cp->ClockMulFactor;
 +		ModePrivFlags = cp->PrivFlags;
 +		extraFlags = k;
 +		clockIndex = i;
 +		break;
  	    }
 -	    /*
 -	     * If strategy is neither LOOKUP_BEST_REFRESH or
 -	     * LOOKUP_CLOSEST_CLOCK the required mode has been found.
 -	     */
 -	    bestMode = p;
 -	    DivFactor = cp->ClockDivFactor;
 -	    MulFactor = cp->ClockMulFactor;
 -	    ModePrivFlags = cp->PrivFlags;
 -	    extraFlags = k;
 -	    clockIndex = i;
 -	    break;
  	}
 +	if (found) break;
      }
      if (!found || bestMode == NULL)
  	return status;
diff --cc hw/xfree86/dri/Makefile.am
index 4def387,bc7124b..68f1eae
@@@ -7,10 -7,13 +7,10 @@@
                     -I$(top_builddir)/GL/include \
  		   -I at MESA_SOURCE@/include \
                     -DHAVE_XORG_CONFIG_H \
-                    @DRIPROTO_CFLAGS@ \
 -		 \
 -		 \
 - \
+                    @DIX_CFLAGS@ @DRIPROTO_CFLAGS@ \
                     @LIBDRM_CFLAGS@ \
                     @GL_CFLAGS@
 -libdri_la_LDFLAGS = -module -avoid-version
 +libdri_la_LDFLAGS = -module -avoid-version @LIBDRM_LIBS@
  libdri_ladir = $(moduledir)/extensions
  libdri_la_SOURCES = \
  	dri.c \
diff --cc include/input.h
index e7017cb,f2fe6d1..ebb0915
@@@ -418,12 -418,6 +418,12 @@@
      int num_valuators,
      int *valuators);
  
 +extern void PostSyntheticMotion(
 +    int x,
 +    int y,
-     int screenNum,
++    ScreenPtr pScreen,
 +    unsigned long time);
 +
  extern int GetMotionHistorySize(
      void);
  
diff-tree d6cd0313c7f23f32c9c7dda00ff739e772bf7db3 (from ef47d9c3ba63e9a6243fe5c81ccc60c8246352b4)
Author: Eric Anholt <eric at anholt.net>
Date:   Mon Nov 27 14:46:50 2006 -0800

    Add some mode helper functions from the intel driver.
    
    This also removes static from some other functions that had been copied out
    to at least the intel driver, but perhaps others that were doing mode list
    handling.

diff --git a/hw/xfree86/common/xf86.h b/hw/xfree86/common/xf86.h
index 4587500..57284c1 100644
--- a/hw/xfree86/common/xf86.h
+++ b/hw/xfree86/common/xf86.h
@@ -414,6 +414,14 @@ void xf86PruneDriverModes(ScrnInfoPtr sc
 void xf86SetCrtcForModes(ScrnInfoPtr scrp, int adjustFlags);
 void xf86PrintModes(ScrnInfoPtr scrp);
 void xf86ShowClockRanges(ScrnInfoPtr scrp, ClockRangePtr clockRanges);
+double xf86ModeHSync(DisplayModePtr mode);
+double xf86ModeVRefresh(DisplayModePtr mode);
+void xf86SetModeDefaultName(DisplayModePtr mode);
+void xf86SetModeCrtc(DisplayModePtr p, int adjustFlags);
+DisplayModePtr xf86DuplicateMode(DisplayModePtr pMode);
+DisplayModePtr xf86DuplicateModes(ScrnInfoPtr pScrn, DisplayModePtr modeList);
+Bool xf86ModesEqual(DisplayModePtr pMode1, DisplayModePtr pMode2);
+void xf86PrintModeline(int scrnIndex,DisplayModePtr mode);
 
 /* xf86Option.c */
 
diff --git a/hw/xfree86/common/xf86Mode.c b/hw/xfree86/common/xf86Mode.c
index cd57e99..6dccf24 100644
--- a/hw/xfree86/common/xf86Mode.c
+++ b/hw/xfree86/common/xf86Mode.c
@@ -366,8 +366,9 @@ xf86HandleBuiltinMode(ScrnInfoPtr scrp,
     return MODE_OK;
 }
 
-static double
-ModeHSync(DisplayModePtr mode)
+/** Calculates the horizontal sync rate of a mode */
+_X_EXPORT double
+xf86ModeHSync(DisplayModePtr mode)
 {
     double hsync = 0.0;
     
@@ -379,8 +380,9 @@ ModeHSync(DisplayModePtr mode)
     return hsync;
 }
 
-static double
-ModeVRefresh(DisplayModePtr mode)
+/** Calculates the vertical refresh rate of a mode */
+_X_EXPORT double
+xf86ModeVRefresh(DisplayModePtr mode)
 {
     double refresh = 0.0;
 
@@ -398,6 +400,16 @@ ModeVRefresh(DisplayModePtr mode)
     return refresh;
 }
 
+/** Sets a default mode name of <width>x<height> on a mode. */
+_X_EXPORT void
+xf86SetModeDefaultName(DisplayModePtr mode)
+{
+    if (mode->name != NULL)
+	xfree(mode->name);
+
+    mode->name = XNFprintf("%dx%d", mode->HDisplay, mode->VDisplay);
+}
+
 /*
  * xf86LookupMode
  *
@@ -522,7 +534,7 @@ xf86LookupMode(ScrnInfoPtr scrp, Display
 		    ModePrivFlags = cp->PrivFlags;
 		    break;
 		}
-		refresh = ModeVRefresh(p);
+		refresh = xf86ModeVRefresh(p);
 		if (p->Flags & V_INTERLACE)
 		    refresh /= INTERLACE_REFRESH_WEIGHT;
 		if (refresh > bestRefresh) {
@@ -561,7 +573,7 @@ xf86LookupMode(ScrnInfoPtr scrp, Display
 	    found = TRUE;
 
 	    if (strategy == LOOKUP_BEST_REFRESH) {
-		refresh = ModeVRefresh(p);
+		refresh = xf86ModeVRefresh(p);
 		if (p->Flags & V_INTERLACE)
 		    refresh /= INTERLACE_REFRESH_WEIGHT;
 		if (refresh > bestRefresh) {
@@ -662,7 +674,7 @@ xf86LookupMode(ScrnInfoPtr scrp, Display
  * Initialises the Crtc parameters for a mode.  The initialisation includes
  * adjustments for interlaced and double scan modes.
  */
-static void
+_X_EXPORT void
 xf86SetModeCrtc(DisplayModePtr p, int adjustFlags)
 {
     if ((p == NULL) || ((p->type & M_T_CRTC_C) == M_T_BUILTIN))
@@ -744,6 +756,87 @@ xf86SetModeCrtc(DisplayModePtr p, int ad
     }
 }
 
+/**
+ * Allocates and returns a copy of pMode, including pointers within pMode.
+ */
+_X_EXPORT DisplayModePtr
+xf86DuplicateMode(DisplayModePtr pMode)
+{
+    DisplayModePtr pNew;
+
+    pNew = xnfalloc(sizeof(DisplayModeRec));
+    *pNew = *pMode;
+    pNew->next = NULL;
+    pNew->prev = NULL;
+    if (pNew->name == NULL) {
+	xf86SetModeDefaultName(pMode);
+    } else {
+	pNew->name = xnfstrdup(pMode->name);
+    }
+
+    return pNew;
+}
+
+/**
+ * Duplicates every mode in the given list and returns a pointer to the first
+ * mode.
+ *
+ * \param modeList doubly-linked mode list
+ */
+_X_EXPORT DisplayModePtr
+xf86DuplicateModes(ScrnInfoPtr pScrn, DisplayModePtr modeList)
+{
+    DisplayModePtr first = NULL, last = NULL;
+    DisplayModePtr mode;
+
+    for (mode = modeList; mode != NULL; mode = mode->next) {
+	DisplayModePtr new;
+
+	new = xf86DuplicateMode(mode);
+
+	/* Insert pNew into modeList */
+	if (last) {
+	    last->next = new;
+	    new->prev = last;
+	} else {
+	    first = new;
+	    new->prev = NULL;
+	}
+	new->next = NULL;
+	last = new;
+    }
+
+    return first;
+}
+
+/**
+ * Returns true if the given modes should program to the same timings.
+ *
+ * This doesn't use Crtc values, as it might be used on ModeRecs without the
+ * Crtc values set.  So, it's assumed that the other numbers are enough.
+ */
+_X_EXPORT Bool
+xf86ModesEqual(DisplayModePtr pMode1, DisplayModePtr pMode2)
+{
+     if (pMode1->Clock == pMode2->Clock &&
+	 pMode1->HDisplay == pMode2->HDisplay &&
+	 pMode1->HSyncStart == pMode2->HSyncStart &&
+	 pMode1->HSyncEnd == pMode2->HSyncEnd &&
+	 pMode1->HTotal == pMode2->HTotal &&
+	 pMode1->HSkew == pMode2->HSkew &&
+	 pMode1->VDisplay == pMode2->VDisplay &&
+	 pMode1->VSyncStart == pMode2->VSyncStart &&
+	 pMode1->VSyncEnd == pMode2->VSyncEnd &&
+	 pMode1->VTotal == pMode2->VTotal &&
+	 pMode1->VScan == pMode2->VScan &&
+	 pMode1->Flags == pMode2->Flags)
+     {
+	return TRUE;
+     } else {
+	return FALSE;
+     }
+}
+
 /*
  * xf86CheckModeForMonitor
  *
@@ -802,7 +895,7 @@ xf86CheckModeForMonitor(DisplayModePtr m
 
     if (monitor->nHsync > 0) {
 	/* Check hsync against the allowed ranges */
-	float hsync = ModeHSync(mode);
+	float hsync = xf86ModeHSync(mode);
 	for (i = 0; i < monitor->nHsync; i++) 
 	    if ((hsync > monitor->hsync[i].lo * (1.0 - SYNC_TOLERANCE)) &&
 		(hsync < monitor->hsync[i].hi * (1.0 + SYNC_TOLERANCE)))
@@ -815,7 +908,7 @@ xf86CheckModeForMonitor(DisplayModePtr m
 
     if (monitor->nVrefresh > 0) {
 	/* Check vrefresh against the allowed ranges */
-	float vrefrsh = ModeVRefresh(mode);
+	float vrefrsh = xf86ModeVRefresh(mode);
 	for (i = 0; i < monitor->nVrefresh; i++)
 	    if ((vrefrsh > monitor->vrefresh[i].lo * (1.0 - SYNC_TOLERANCE)) &&
 		(vrefrsh < monitor->vrefresh[i].hi * (1.0 + SYNC_TOLERANCE)))
@@ -1043,8 +1136,8 @@ xf86InitialCheckModeForDriver(ScrnInfoPt
 		/ (mode->CrtcHTotal * mode->CrtcVTotal);
     }
     
-    mode->HSync = ModeHSync(mode);
-    mode->VRefresh = ModeVRefresh(mode);
+    mode->HSync = xf86ModeHSync(mode);
+    mode->VRefresh = xf86ModeVRefresh(mode);
 
     /* Assume it is OK */
     return MODE_OK;
@@ -1683,7 +1776,7 @@ xf86ValidateModes(ScrnInfoPtr scrp, Disp
 				      "TargetRefresh", 0.0);
     if (targetRefresh > 0.0) {
 	for (p = scrp->modePool; p != NULL; p = p->next) {
-	    if (ModeVRefresh(p) > targetRefresh * (1.0 - SYNC_TOLERANCE))
+	    if (xf86ModeVRefresh(p) > targetRefresh * (1.0 - SYNC_TOLERANCE))
 		break;
 	}
 	if (!p)
@@ -1772,7 +1865,7 @@ xf86ValidateModes(ScrnInfoPtr scrp, Disp
 			 * If there is a target refresh rate, skip modes that
 			 * don't match up.
 			 */
-			if (ModeVRefresh(q) <
+			if (xf86ModeVRefresh(q) <
 			    (1.0 - SYNC_TOLERANCE) * targetRefresh)
 			    continue;
 
@@ -2068,8 +2161,8 @@ add(char **p, char *new)
     strcat(*p, new);
 }
 
-static void
-PrintModeline(int scrnIndex,DisplayModePtr mode)
+_X_EXPORT void
+xf86PrintModeline(int scrnIndex,DisplayModePtr mode)
 {
     char tmp[256];
     char *flags = xnfcalloc(1, 1);
@@ -2124,8 +2217,8 @@ xf86PrintModes(ScrnInfoPtr scrp)
 
     do {
 	desc = desc2 = "";
-	hsync = ModeHSync(p);
-	refresh = ModeVRefresh(p);
+	hsync = xf86ModeHSync(p);
+	refresh = xf86ModeVRefresh(p);
 	if (p->Flags & V_INTERLACE) {
 	    desc = " (I)";
 	}
@@ -2166,7 +2259,7 @@ xf86PrintModes(ScrnInfoPtr scrp)
 			p->SynthClock / 1000.0, hsync, refresh, desc, desc2);
 	}
 	if (hsync != 0 && refresh != 0)
-	    PrintModeline(scrp->scrnIndex,p);
+	    xf86PrintModeline(scrp->scrnIndex,p);
 	p = p->next;
     } while (p != NULL && p != scrp->modes);
 }
diff-tree 64de3baf85f6df274f71f736016f0848567cd9f6 (from 0a2a6e4070718b90af7ca0e047f028e0cabdfb9d)
Author: Aaron Plattner <aplattner at nvidia.com>
Date:   Wed Nov 22 14:46:51 2006 -0800

    Add a -showDefaultLibPath option.
    
    A corollary to the previous change, this option prints $libdir.

diff --git a/configure.ac b/configure.ac
index 2108db4..590ab2a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1383,6 +1383,7 @@ dnl has it in libc), or if libdl is need
 	AC_DEFINE_DIR(__XCONFIGFILE__, XF86CONFIGFILE, [Name of configuration file])
 	AC_DEFINE_DIR(XF86CONFIGFILE, XF86CONFIGFILE, [Name of configuration file])
 	AC_DEFINE_DIR(DEFAULT_MODULE_PATH, moduledir, [Default module search path])
+	AC_DEFINE_DIR(DEFAULT_LIBRARY_PATH, libdir, [Default library install path])
 	AC_DEFINE_DIR(DEFAULT_LOGPREFIX, LOGPREFIX, [Default log location])
 	AC_DEFINE_UNQUOTED(__VENDORDWEBSUPPORT__, ["$VENDOR_WEB"], [Vendor web address for support])
 
diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
index 5106acf..ff878d5 100644
--- a/hw/xfree86/common/xf86Init.c
+++ b/hw/xfree86/common/xf86Init.c
@@ -101,6 +101,7 @@
 static void xf86PrintBanner(void);
 static void xf86PrintMarkers(void);
 static void xf86PrintDefaultModulePath(void);
+static void xf86PrintDefaultLibraryPath(void);
 static void xf86RunVtInit(void);
 
 #ifdef __UNIXOS2__
@@ -1382,6 +1383,11 @@ ddxProcessArgument(int argc, char **argv
     xf86PrintDefaultModulePath();
     exit(0);
   }
+  if (!strcmp(argv[i],"-showDefaultLibPath"))
+  {
+    xf86PrintDefaultLibraryPath();
+    exit(0);
+  }
   /* Notice the -fp flag, but allow it to pass to the dix layer */
   if (!strcmp(argv[i], "-fp"))
   {
@@ -1632,6 +1638,7 @@ ddxUseMsg()
   ErrorF("-isolateDevice bus_id  restrict device resets to bus_id (PCI only)\n");
   ErrorF("-version               show the server version\n");
   ErrorF("-showDefaultModulePath show the server default module path\n");
+  ErrorF("-showDefaultLibPath    show the server default library path\n");
   /* OS-specific usage */
   xf86UseMsg();
   ErrorF("\n");
@@ -1761,6 +1768,12 @@ xf86PrintDefaultModulePath(void)
 }
 
 static void
+xf86PrintDefaultLibraryPath(void)
+{
+  ErrorF("%s\n", DEFAULT_LIBRARY_PATH);
+}
+
+static void
 xf86RunVtInit(void)
 {
     int i;
diff --git a/hw/xfree86/doc/man/Xorg.man.pre b/hw/xfree86/doc/man/Xorg.man.pre
index 5803100..8645732 100644
--- a/hw/xfree86/doc/man/Xorg.man.pre
+++ b/hw/xfree86/doc/man/Xorg.man.pre
@@ -429,6 +429,9 @@ support.
 .B \-showDefaultModulePath
 Print out the default module path the server was compiled with.
 .TP 8
+.B \-showDefaultLibPath
+Print out the path libraries should be installed to.
+.TP 8
 .BI \-config " file"
 Read the server configuration from
 .IR file .
diff --git a/include/xorg-config.h.in b/include/xorg-config.h.in
index 4a64522..b9643a2 100644
--- a/include/xorg-config.h.in
+++ b/include/xorg-config.h.in
@@ -45,6 +45,9 @@
 /* Path to loadable modules. */
 #undef DEFAULT_MODULE_PATH
 
+/* Path to installed libraries. */
+#undef DEFAULT_LIBRARY_PATH
+
 /* Path to server log file. */
 #undef DEFAULT_LOGPREFIX
 
diff-tree 0a2a6e4070718b90af7ca0e047f028e0cabdfb9d (from 61832cb94c8a4d62cddb92188caeed86519e9d62)
Author: Aaron Plattner <aplattner at nvidia.com>
Date:   Fri Nov 17 18:27:23 2006 -0800

    Add a -showDefaultModulePath option.
    
    As discussed on the mailing list, people would rather have an X command-line
    option to print the module path so installers can know where to put modules,
    rather than the installers using `pkg-config --variable=moduledir xorg-server`,
    since some distros choose not to install xorg-server.pc.

diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
index 33351f2..5106acf 100644
--- a/hw/xfree86/common/xf86Init.c
+++ b/hw/xfree86/common/xf86Init.c
@@ -100,6 +100,7 @@
 
 static void xf86PrintBanner(void);
 static void xf86PrintMarkers(void);
+static void xf86PrintDefaultModulePath(void);
 static void xf86RunVtInit(void);
 
 #ifdef __UNIXOS2__
@@ -1376,6 +1377,11 @@ ddxProcessArgument(int argc, char **argv
     xf86PrintBanner();
     exit(0);
   }
+  if (!strcmp(argv[i],"-showDefaultModulePath"))
+  {
+    xf86PrintDefaultModulePath();
+    exit(0);
+  }
   /* Notice the -fp flag, but allow it to pass to the dix layer */
   if (!strcmp(argv[i], "-fp"))
   {
@@ -1625,6 +1631,7 @@ ddxUseMsg()
   ErrorF("-ignoreABI             make module ABI mismatches non-fatal\n");
   ErrorF("-isolateDevice bus_id  restrict device resets to bus_id (PCI only)\n");
   ErrorF("-version               show the server version\n");
+  ErrorF("-showDefaultModulePath show the server default module path\n");
   /* OS-specific usage */
   xf86UseMsg();
   ErrorF("\n");
@@ -1748,6 +1755,12 @@ xf86PrintMarkers()
 }
 
 static void
+xf86PrintDefaultModulePath(void)
+{
+  ErrorF("%s\n", DEFAULT_MODULE_PATH);
+}
+
+static void
 xf86RunVtInit(void)
 {
     int i;
diff --git a/hw/xfree86/doc/man/Xorg.man.pre b/hw/xfree86/doc/man/Xorg.man.pre
index b7fa990..5803100 100644
--- a/hw/xfree86/doc/man/Xorg.man.pre
+++ b/hw/xfree86/doc/man/Xorg.man.pre
@@ -426,6 +426,9 @@ Print out the server version, patchlevel
 system/platform it was built on, and whether it includes module loader
 support.
 .TP 8
+.B \-showDefaultModulePath
+Print out the default module path the server was compiled with.
+.TP 8
 .BI \-config " file"
 Read the server configuration from
 .IR file .
diff-tree 61832cb94c8a4d62cddb92188caeed86519e9d62 (from 61863f09d22935406371e92bb75173d55ff9b29f)
Author: Brian <brian at i915.localnet.net>
Date:   Wed Nov 22 09:16:43 2006 -0700

    Regenerated from Mesa w/ latest gl_API.xml file

diff --git a/GL/glx/indirect_dispatch.h b/GL/glx/indirect_dispatch.h
index 9bf74eb..17a372f 100644
--- a/GL/glx/indirect_dispatch.h
+++ b/GL/glx/indirect_dispatch.h
@@ -85,8 +85,6 @@ extern HIDDEN void __glXDisp_EvalCoord2f
 extern HIDDEN void __glXDispSwap_EvalCoord2fv(GLbyte * pc);
 extern HIDDEN int __glXDisp_DestroyPixmap(struct __GLXclientStateRec *, GLbyte *);
 extern HIDDEN int __glXDispSwap_DestroyPixmap(struct __GLXclientStateRec *, GLbyte *);
-extern HIDDEN void __glXDisp_ProgramEnvParameter4dvARB(GLbyte * pc);
-extern HIDDEN void __glXDispSwap_ProgramEnvParameter4dvARB(GLbyte * pc);
 extern HIDDEN int __glXDisp_GetMapiv(struct __GLXclientStateRec *, GLbyte *);
 extern HIDDEN int __glXDispSwap_GetMapiv(struct __GLXclientStateRec *, GLbyte *);
 extern HIDDEN int __glXDisp_SwapBuffers(struct __GLXclientStateRec *, GLbyte *);
@@ -123,6 +121,8 @@ extern HIDDEN int __glXDisp_VendorPrivat
 extern HIDDEN int __glXDispSwap_VendorPrivate(struct __GLXclientStateRec *, GLbyte *);
 extern HIDDEN int __glXDisp_CreateGLXPixmapWithConfigSGIX(struct __GLXclientStateRec *, GLbyte *);
 extern HIDDEN int __glXDispSwap_CreateGLXPixmapWithConfigSGIX(struct __GLXclientStateRec *, GLbyte *);
+extern HIDDEN void __glXDisp_VertexAttrib1fvNV(GLbyte * pc);
+extern HIDDEN void __glXDispSwap_VertexAttrib1fvNV(GLbyte * pc);
 extern HIDDEN void __glXDisp_Vertex3iv(GLbyte * pc);
 extern HIDDEN void __glXDispSwap_Vertex3iv(GLbyte * pc);
 extern HIDDEN void __glXDisp_CopyConvolutionFilter1D(GLbyte * pc);
@@ -279,6 +279,8 @@ extern HIDDEN void __glXDisp_ClearStenci
 extern HIDDEN void __glXDispSwap_ClearStencil(GLbyte * pc);
 extern HIDDEN void __glXDisp_VertexAttrib3dvARB(GLbyte * pc);
 extern HIDDEN void __glXDispSwap_VertexAttrib3dvARB(GLbyte * pc);
+extern HIDDEN void __glXDisp_VertexAttribs4ubvNV(GLbyte * pc);
+extern HIDDEN void __glXDispSwap_VertexAttribs4ubvNV(GLbyte * pc);
 extern HIDDEN void __glXDisp_ConvolutionParameteriv(GLbyte * pc);
 extern HIDDEN void __glXDispSwap_ConvolutionParameteriv(GLbyte * pc);
 extern HIDDEN void __glXDisp_RasterPos2fv(GLbyte * pc);
@@ -327,6 +329,8 @@ extern HIDDEN int __glXDisp_GetVertexAtt
 extern HIDDEN int __glXDispSwap_GetVertexAttribdvNV(struct __GLXclientStateRec *, GLbyte *);
 extern HIDDEN void __glXDisp_Normal3fv(GLbyte * pc);
 extern HIDDEN void __glXDispSwap_Normal3fv(GLbyte * pc);
+extern HIDDEN void __glXDisp_ProgramEnvParameter4dvARB(GLbyte * pc);
+extern HIDDEN void __glXDispSwap_ProgramEnvParameter4dvARB(GLbyte * pc);
 extern HIDDEN void __glXDisp_VertexAttrib4ivARB(GLbyte * pc);
 extern HIDDEN void __glXDispSwap_VertexAttrib4ivARB(GLbyte * pc);
 extern HIDDEN void __glXDisp_End(GLbyte * pc);
@@ -457,8 +461,6 @@ extern HIDDEN void __glXDisp_BindFramebu
 extern HIDDEN void __glXDispSwap_BindFramebufferEXT(GLbyte * pc);
 extern HIDDEN void __glXDisp_PushAttrib(GLbyte * pc);
 extern HIDDEN void __glXDispSwap_PushAttrib(GLbyte * pc);
-extern HIDDEN void __glXDisp_VertexAttrib4usvARB(GLbyte * pc);
-extern HIDDEN void __glXDispSwap_VertexAttrib4usvARB(GLbyte * pc);
 extern HIDDEN int __glXDisp_DestroyPbuffer(struct __GLXclientStateRec *, GLbyte *);
 extern HIDDEN int __glXDispSwap_DestroyPbuffer(struct __GLXclientStateRec *, GLbyte *);
 extern HIDDEN void __glXDisp_TexParameteriv(GLbyte * pc);
@@ -615,6 +617,8 @@ extern HIDDEN void __glXDisp_PrioritizeT
 extern HIDDEN void __glXDispSwap_PrioritizeTextures(GLbyte * pc);
 extern HIDDEN int __glXDisp_PixelStorei(struct __GLXclientStateRec *, GLbyte *);
 extern HIDDEN int __glXDispSwap_PixelStorei(struct __GLXclientStateRec *, GLbyte *);
+extern HIDDEN void __glXDisp_VertexAttrib4usvARB(GLbyte * pc);
+extern HIDDEN void __glXDispSwap_VertexAttrib4usvARB(GLbyte * pc);
 extern HIDDEN void __glXDisp_Color4iv(GLbyte * pc);
 extern HIDDEN void __glXDispSwap_Color4iv(GLbyte * pc);
 extern HIDDEN void __glXDisp_EvalCoord2dv(GLbyte * pc);
@@ -783,8 +787,6 @@ extern HIDDEN void __glXDisp_VertexAttri
 extern HIDDEN void __glXDispSwap_VertexAttribs2fvNV(GLbyte * pc);
 extern HIDDEN void __glXDisp_Rectiv(GLbyte * pc);
 extern HIDDEN void __glXDispSwap_Rectiv(GLbyte * pc);
-extern HIDDEN void __glXDisp_VertexAttrib1fvNV(GLbyte * pc);
-extern HIDDEN void __glXDispSwap_VertexAttrib1fvNV(GLbyte * pc);
 extern HIDDEN void __glXDisp_SecondaryColor3dvEXT(GLbyte * pc);
 extern HIDDEN void __glXDispSwap_SecondaryColor3dvEXT(GLbyte * pc);
 extern HIDDEN void __glXDisp_Vertex2fv(GLbyte * pc);
@@ -919,8 +921,6 @@ extern HIDDEN void __glXDisp_DrawBuffers
 extern HIDDEN void __glXDispSwap_DrawBuffersARB(GLbyte * pc);
 extern HIDDEN void __glXDisp_LoadName(GLbyte * pc);
 extern HIDDEN void __glXDispSwap_LoadName(GLbyte * pc);
-extern HIDDEN void __glXDisp_VertexAttribs4ubvNV(GLbyte * pc);
-extern HIDDEN void __glXDispSwap_VertexAttribs4ubvNV(GLbyte * pc);
 extern HIDDEN void __glXDisp_CopyTexSubImage1D(GLbyte * pc);
 extern HIDDEN void __glXDispSwap_CopyTexSubImage1D(GLbyte * pc);
 extern HIDDEN void __glXDisp_CullFace(GLbyte * pc);
diff-tree 61863f09d22935406371e92bb75173d55ff9b29f (from 33ff4cec5ff7533ec725f71d357c096dfb0acb79)
Author: Brian <brian at i915.localnet.net>
Date:   Wed Nov 22 09:16:17 2006 -0700

    Regenerated from Mesa, fixes glMap* protocol problem (bug 8899)

diff --git a/GL/glx/indirect_table.c b/GL/glx/indirect_table.c
index a6fd3a3..60d6760 100644
--- a/GL/glx/indirect_table.c
+++ b/GL/glx/indirect_table.c
@@ -645,7 +645,7 @@ static const void *Render_function_table
     /* [ 302] =  4182 */ {__glXDisp_RequestResidentProgramsNV, __glXDispSwap_RequestResidentProgramsNV},
     /* [ 303] =  4183 */ {__glXDisp_LoadProgramNV, __glXDispSwap_LoadProgramNV},
     /* [ 304] =  4184 */ {__glXDisp_ProgramParameter4fvNV, __glXDispSwap_ProgramParameter4fvNV},
-    /* [ 305] =  4185 */ {__glXDisp_ProgramParameter4dvNV, __glXDispSwap_ProgramParameter4dvNV},
+    /* [ 305] =  4185 */ {__glXDisp_ProgramEnvParameter4dvARB, __glXDispSwap_ProgramEnvParameter4dvARB},
     /* [ 306] =  4186 */ {__glXDisp_ProgramParameters4fvNV, __glXDispSwap_ProgramParameters4fvNV},
     /* [ 307] =  4187 */ {__glXDisp_ProgramParameters4dvNV, __glXDispSwap_ProgramParameters4dvNV},
     /* [ 308] =  4188 */ {__glXDisp_TrackMatrixNV, __glXDispSwap_TrackMatrixNV},
@@ -886,10 +886,10 @@ static const int_fast16_t Render_size_ta
     /* [140] =   140 */ {  0, ~0},
     /* [141] =   141 */ {  4, ~0},
     /* [142] =   142 */ {  8, ~0},
-    /* [143] =   143 */ { 40, 20},
-    /* [144] =   144 */ { 28, 21},
-    /* [145] =   145 */ { 64, 22},
-    /* [146] =   146 */ { 44, 23},
+    /* [143] =   143 */ { 28, 20},
+    /* [144] =   144 */ { 20, 21},
+    /* [145] =   145 */ { 48, 22},
+    /* [146] =   146 */ { 32, 23},
     /* [147] =   147 */ { 24, ~0},
     /* [148] =   148 */ { 16, ~0},
     /* [149] =   149 */ { 44, ~0},
diff-tree 33ff4cec5ff7533ec725f71d357c096dfb0acb79 (from ca2874b273232d9f51881b1cd754ed6847bfaf47)
Author: Alan Hourihane <alanh at fairlite.demon.co.uk>
Date:   Tue Nov 21 21:23:17 2006 +0000

    Issue CloseDownDevices() in os/log.c and remove from dix/main.c.
    
    This ensures that all calls to FatalError() will shutdown the input devices.

diff --git a/dix/main.c b/dix/main.c
index bee5490..077fdea 100644
--- a/dix/main.c
+++ b/dix/main.c
@@ -415,7 +415,6 @@ main(int argc, char *argv[], char *envp[
 			defaultFontPath);
 	}
 	if (!SetDefaultFont(defaultTextFont)) {
-	    CloseDownDevices();
 	    FatalError("could not open default font '%s'", defaultTextFont);
 	}
 #ifdef NULL_ROOT_CURSOR
@@ -425,13 +424,11 @@ main(int argc, char *argv[], char *envp[
         cm.yhot = 0;
 
         if (!(rootCursor = AllocCursor(NULL, NULL, &cm, 0, 0, 0, 0, 0, 0))) {
-	    CloseDownDevices();
             FatalError("could not create empty root cursor");
 	}
         AddResource(FakeClientID(0), RT_CURSOR, (pointer)rootCursor);
 #else
 	if (!(rootCursor = CreateRootCursor(defaultCursorFont, 0))) {
-	    CloseDownDevices();
 	    FatalError("could not open default cursor font '%s'",
 		       defaultCursorFont);
 	}
@@ -459,14 +456,12 @@ main(int argc, char *argv[], char *envp[
 #ifdef PANORAMIX
 	if (!noPanoramiXExtension) {
 	    if (!PanoramiXCreateConnectionBlock()) {
-	    	CloseDownDevices();
 		FatalError("could not create connection block info");
 	    }
 	} else
 #endif
 	{
 	    if (!CreateConnectionBlock()) {
-	    	CloseDownDevices();
 	    	FatalError("could not create connection block info");
 	    }
 	}
diff --git a/os/log.c b/os/log.c
index 05e542f..b1d628c 100644
--- a/os/log.c
+++ b/os/log.c
@@ -89,6 +89,7 @@ OR PERFORMANCE OF THIS SOFTWARE.
 #include <stdlib.h>	/* for malloc() */
 #include <errno.h>
 
+#include "input.h"
 #include "site.h"
 #include "opaque.h"
 
@@ -404,6 +405,7 @@ void
 AbortServer(void)
 {
     OsCleanup(TRUE);
+    CloseDownDevices();
     AbortDDX();
     fflush(stderr);
     if (CoreDump)
diff-tree ca2874b273232d9f51881b1cd754ed6847bfaf47 (from parents)
Merge: c9a5f9d3911c2e6a8f81b0721c9eb914fb7719b5 e2f6dacc736527790ed8e304698678afc17f71c6
Author: Alan Hourihane <alanh at fairlite.demon.co.uk>
Date:   Sat Nov 18 19:56:32 2006 +0000

    Merge branch 'master' of git+ssh://git.freedesktop.org/git/xorg/xserver

diff-tree c9a5f9d3911c2e6a8f81b0721c9eb914fb7719b5 (from acb5ff4c73ac4d52201d7c421f488e2ead5c8b9c)
Author: Alan Hourihane <alanh at fairlite.demon.co.uk>
Date:   Sat Nov 18 19:55:42 2006 +0000

    Shutdown input devices if FatalError occurs during startup.
    Fixes Xdmx problems when the input device has been initialized
    and the keyboard map has been destroyed.

diff --git a/dix/main.c b/dix/main.c
index 88d7755..bee5490 100644
--- a/dix/main.c
+++ b/dix/main.c
@@ -414,21 +414,27 @@ main(int argc, char *argv[], char *envp[
 		ErrorF("failed to set default font path '%s'",
 			defaultFontPath);
 	}
-	if (!SetDefaultFont(defaultTextFont))
+	if (!SetDefaultFont(defaultTextFont)) {
+	    CloseDownDevices();
 	    FatalError("could not open default font '%s'", defaultTextFont);
+	}
 #ifdef NULL_ROOT_CURSOR
         cm.width = 0;
         cm.height = 0;
         cm.xhot = 0;
         cm.yhot = 0;
 
-        if (!(rootCursor = AllocCursor(NULL, NULL, &cm, 0, 0, 0, 0, 0, 0)))
+        if (!(rootCursor = AllocCursor(NULL, NULL, &cm, 0, 0, 0, 0, 0, 0))) {
+	    CloseDownDevices();
             FatalError("could not create empty root cursor");
+	}
         AddResource(FakeClientID(0), RT_CURSOR, (pointer)rootCursor);
 #else
-	if (!(rootCursor = CreateRootCursor(defaultCursorFont, 0)))
+	if (!(rootCursor = CreateRootCursor(defaultCursorFont, 0))) {
+	    CloseDownDevices();
 	    FatalError("could not open default cursor font '%s'",
 		       defaultCursorFont);
+	}
 #endif
 #ifdef DPMSExtension
  	/* check all screens, looking for DPMS Capabilities */
@@ -452,13 +458,17 @@ main(int argc, char *argv[], char *envp[
 
 #ifdef PANORAMIX
 	if (!noPanoramiXExtension) {
-	    if (!PanoramiXCreateConnectionBlock())
+	    if (!PanoramiXCreateConnectionBlock()) {
+	    	CloseDownDevices();
 		FatalError("could not create connection block info");
+	    }
 	} else
 #endif
 	{
-	    if (!CreateConnectionBlock())
+	    if (!CreateConnectionBlock()) {
+	    	CloseDownDevices();
 	    	FatalError("could not create connection block info");
+	    }
 	}
 
 	Dispatch();
diff-tree e2f6dacc736527790ed8e304698678afc17f71c6 (from f17e3c34dfd1f1418440bdebf45764e4dbf550f0)
Author: Dave Airlie <airlied at linux.ie>
Date:   Sat Nov 18 11:26:55 2006 +1100

    dri: setup libdrm hooks as early as possible.
    
    This is due to radeon doing drm stuff before DRI extension gets initialised

diff --git a/hw/xfree86/dri/dri.c b/hw/xfree86/dri/dri.c
index a49c632..5337f9a 100644
--- a/hw/xfree86/dri/dri.c
+++ b/hw/xfree86/dri/dri.c
@@ -84,7 +84,7 @@ static RESTYPE DRIDrawablePrivResType;
 static RESTYPE DRIContextPrivResType;
 static void    DRIDestroyDummyContext(ScreenPtr pScreen, Bool hasCtxPriv);
 
-static drmServerInfo DRIDRMServerInfo;
+drmServerInfo DRIDRMServerInfo;
 
 				/* Wrapper just like xf86DrvMsg, but
 				   without the verbosity level checking.
@@ -176,8 +176,6 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfo
     else
 	openbusid = NULL;
 
-    drmSetServerInfo(&DRIDRMServerInfo);
-
     /* Note that drmOpen will try to load the kernel module, if needed. */
     fd = drmOpen(pDRIInfo->drmDriverName, openbusid);
     if (fd < 0) {
@@ -593,7 +591,7 @@ static void dri_drm_get_perms(gid_t *gro
   *mode = xf86ConfigDRI.mode;
 }
 
-static drmServerInfo DRIDRMServerInfo =  {
+drmServerInfo DRIDRMServerInfo =  {
   dri_drm_debug_print,
   xf86LoadKernelModule,
   dri_drm_get_perms,
diff --git a/hw/xfree86/dri/drimodule.c b/hw/xfree86/dri/drimodule.c
index b39c22e..0e3d84e 100644
--- a/hw/xfree86/dri/drimodule.c
+++ b/hw/xfree86/dri/drimodule.c
@@ -39,8 +39,11 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN
 #include "xf86Module.h"
 #include "globals.h"
 
+#include "xf86drm.h"
 static MODULESETUPPROTO(driSetup);
 
+drmServerInfo DRIDRMServerInfo;
+
 static XF86ModuleVersionInfo VersRec =
 {
         "dri",
@@ -81,6 +84,9 @@ driSetup(pointer module, pointer opts, i
     } else {
 	if (errmaj) *errmaj = LDR_ONCEONLY;
     }
+
+    drmSetServerInfo(&DRIDRMServerInfo);
+
     /* Need a non-NULL return value to indicate success */
     return 1;
 }
diff-tree ef47d9c3ba63e9a6243fe5c81ccc60c8246352b4 (from 07b26e690cd9a4fc626132feed0702515cbe5a88)
Author: Keith Packard <keithp at neko.keithp.com>
Date:   Thu Nov 16 13:50:48 2006 -0800

    Reduce calls to RRGetInfo.
    
    RRGetInfo can be expensive. Don't invoke it when quering Xinerama
    information or setting a new CRTC configuration.
    (cherry picked from commit b5aa9eb8e6eda36856a075f4b008c33f6c706bad)

diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c
index c945468..b81c390 100644
--- a/randr/rrcrtc.c
+++ b/randr/rrcrtc.c
@@ -632,13 +632,6 @@ ProcRRSetCrtcConfig (ClientPtr client)
     pScreen = crtc->pScreen;
     pScrPriv = rrGetScrPriv(pScreen);
     
-    if (!RRGetInfo (pScreen))
-    {
-	if (outputs)
-	    xfree (outputs);
-	return BadAlloc;
-    }
-    
     time = ClientTimeToServerTime(stuff->timestamp);
     configTime = ClientTimeToServerTime(stuff->configTimestamp);
     
diff --git a/randr/rrxinerama.c b/randr/rrxinerama.c
index a8e4b39..771ed09 100644
--- a/randr/rrxinerama.c
+++ b/randr/rrxinerama.c
@@ -260,7 +260,11 @@ ProcRRXineramaQueryScreens(ClientPtr cli
     REQUEST_SIZE_MATCH(xXineramaQueryScreensReq);
 
     if (RRXineramaScreenActive (pScreen))
-	RRGetInfo (pScreen);
+    {
+	rrScrPriv(pScreen);
+	if (pScrPriv->numCrtcs == 0 || pScrPriv->numOutputs == 0)
+	    RRGetInfo (pScreen);
+    }
     
     rep.type = X_Reply;
     rep.sequenceNumber = client->sequence;
diff-tree 07b26e690cd9a4fc626132feed0702515cbe5a88 (from 6ff7f2ad6a5e2e769244590578e6809974b5235d)
Author: Keith Packard <keithp at neko.keithp.com>
Date:   Thu Nov 16 09:48:33 2006 -0800

    Remove RandR output options.
    
    RandR output options are now expected to be handled by properties instead.
    (cherry picked from commit 8b2a7e94a1dc2776ab2cfaaebb309be02502602a)

diff --git a/randr/mirandr.c b/randr/mirandr.c
index 3f56fe4..3a99bf9 100644
--- a/randr/mirandr.c
+++ b/randr/mirandr.c
@@ -52,7 +52,7 @@ miRRCrtcSet (ScreenPtr	pScreen,
 	     int	y,
 	     Rotation	rotation,
 	     int	numOutput,
-	     RROutputConfigPtr    outputs)
+	     RROutputPtr *outputs)
 {
     return TRUE;
 }
@@ -137,10 +137,6 @@ miRandRInit (ScreenPtr pScreen)
 	return FALSE;
     if (!RROutputSetCrtcs (output, &crtc, 1))
 	return FALSE;
-    if (!RROutputSetPossibleOptions (output, 0))
-	return FALSE;
-    if (!RROutputSetCurrentOptions (output, 0))
-	return FALSE;
     if (!RROutputSetConnection (output, RR_Connected))
 	return FALSE;
     RRCrtcNotify (crtc, mode, 0, 0, RR_Rotate_0, 1, &output);
diff --git a/randr/randrstr.h b/randr/randrstr.h
index 2c3e0e7..19af9b9 100644
--- a/randr/randrstr.h
+++ b/randr/randrstr.h
@@ -72,7 +72,6 @@ extern int (*SProcRandrVector[RRNumberRe
 typedef struct _rrMode	    RRModeRec, *RRModePtr;
 typedef struct _rrCrtc	    RRCrtcRec, *RRCrtcPtr;
 typedef struct _rrOutput    RROutputRec, *RROutputPtr;
-typedef struct _rrOutputConfig	RROutputConfigRec, *RROutputConfigPtr;
 
 struct _rrMode {
     int		    refcnt;
@@ -109,8 +108,6 @@ struct _rrOutput {
     int		    mmWidth;
     int		    mmHeight;
     RRCrtcPtr	    crtc;
-    CARD32	    currentOptions;
-    CARD32	    possibleOptions;
     int		    numCrtcs;
     RRCrtcPtr	    *crtcs;
     int		    numClones;
@@ -123,11 +120,6 @@ struct _rrOutput {
     void	    *devPrivate;
 };
 
-struct _rrOutputConfig {
-    RROutputPtr	    output;
-    CARD32	    options;
-};
-
 #if RANDR_12_INTERFACE
 typedef Bool (*RRScreenSetSizeProcPtr) (ScreenPtr	pScreen,
 					CARD16		width,
@@ -142,7 +134,7 @@ typedef Bool (*RRCrtcSetProcPtr) (Screen
 				  int			y,
 				  Rotation		rotation,
 				  int			numOutputs,
-				  RROutputConfigPtr	outputs);
+				  RROutputPtr		*outputs);
 
 typedef Bool (*RRCrtcSetGammaProcPtr) (ScreenPtr	pScreen,
 				       RRCrtcPtr	crtc);
@@ -369,7 +361,7 @@ miRRCrtcSet (ScreenPtr	pScreen,
 	     int	y,
 	     Rotation	rotation,
 	     int	numOutput,
-	     RROutputConfigPtr    outputs);
+	     RROutputPtr *outputs);
 
 /* randr.c */
 /*
@@ -490,7 +482,7 @@ RRCrtcSet (RRCrtcPtr    crtc,
 	   int		y,
 	   Rotation	rotation,
 	   int		numOutput,
-	   RROutputConfigPtr  outputs);
+	   RROutputPtr  *outputs);
 
 /*
  * Request that the Crtc gamma be changed
@@ -641,10 +633,6 @@ RROutputSetCrtcs (RROutputPtr	output,
 		  RRCrtcPtr	*crtcs,
 		  int		numCrtcs);
 
-Bool
-RROutputSetPossibleOptions (RROutputPtr	output,
-			    CARD32	possibleOptions);
-
 void
 RROutputSetCrtc (RROutputPtr output, RRCrtcPtr crtc);
     
@@ -657,10 +645,6 @@ RROutputSetSubpixelOrder (RROutputPtr ou
 			  int	      subpixelOrder);
 
 Bool
-RROutputSetCurrentOptions (RROutputPtr output,
-			   CARD32      currentOptions);
-
-Bool
 RROutputSetPhysicalSize (RROutputPtr	output,
 			 int		mmWidth,
 			 int		mmHeight);
@@ -739,8 +723,6 @@ Query state:
 		RRScreenSetSizeRange
 		RROutputSetCrtcs
 		RROutputSetCrtc
-		RROutputSetPossibleOptions
-		RRSetCurrentOptions
 		RRModeGet
 		RROutputSetModes
 		RROutputSetConnection
diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c
index 9f7177a..c945468 100644
--- a/randr/rrcrtc.c
+++ b/randr/rrcrtc.c
@@ -257,7 +257,7 @@ RRCrtcSet (RRCrtcPtr    crtc,
 	   int		y,
 	   Rotation	rotation,
 	   int		numOutputs,
-	   RROutputConfigPtr  outputs)
+	   RROutputPtr  *outputs)
 {
     ScreenPtr	pScreen = crtc->pScreen;
 
@@ -290,10 +290,10 @@ RRCrtcSet (RRCrtcPtr    crtc,
 
 	    size.width = mode->mode.width;
 	    size.height = mode->mode.height;
-	    if (outputs[0].output->mmWidth && outputs[0].output->mmHeight)
+	    if (outputs[0]->mmWidth && outputs[0]->mmHeight)
 	    {
-		size.mmWidth = outputs[0].output->mmWidth;
-		size.mmHeight = outputs[0].output->mmHeight;
+		size.mmWidth = outputs[0]->mmWidth;
+		size.mmHeight = outputs[0]->mmHeight;
 	    }
 	    else
 	    {
@@ -308,7 +308,7 @@ RRCrtcSet (RRCrtcPtr    crtc,
 	     * Old 1.0 interface tied screen size to mode size
 	     */
 	    if (ret)
-		RRCrtcNotify (crtc, mode, x, y, rotation, 1, &outputs[0].output);
+		RRCrtcNotify (crtc, mode, x, y, rotation, 1, outputs);
 	    return ret;
 	}
 #endif
@@ -554,15 +554,15 @@ ProcRRSetCrtcConfig (ClientPtr client)
     RRCrtcPtr		    crtc;
     RRModePtr		    mode;
     int			    numOutputs;
-    RROutputConfigPtr	    outputs = NULL;
-    xRROutputConfig 	    *outputConfigs;
+    RROutputPtr		    *outputs = NULL;
+    RROutput		    *outputIds;
     TimeStamp		    configTime;
     TimeStamp		    time;
     Rotation		    rotation;
     int			    i, j;
     
     REQUEST_AT_LEAST_SIZE(xRRSetCrtcConfigReq);
-    numOutputs = (stuff->length - (SIZEOF (xRRSetCrtcConfigReq) >> 2)) >> 1;
+    numOutputs = (stuff->length - (SIZEOF (xRRSetCrtcConfigReq) >> 2));
     
     crtc = LookupIDByType (stuff->crtc, RRCrtcType);
     if (!crtc)
@@ -589,47 +589,39 @@ ProcRRSetCrtcConfig (ClientPtr client)
     }
     if (numOutputs)
     {
-	outputs = xalloc (numOutputs * sizeof (RROutputConfigRec));
+	outputs = xalloc (numOutputs * sizeof (RROutputPtr));
 	if (!outputs)
 	    return BadAlloc;
     }
     else
 	outputs = NULL;
     
-    outputConfigs = (xRROutputConfig *) (stuff + 1);
+    outputIds = (RROutput *) (stuff + 1);
     for (i = 0; i < numOutputs; i++)
     {
-	outputs[i].output = LookupIDByType (outputConfigs[i].output, RROutputType);
-	if (!outputs[i].output)
+	outputs[i] = (RROutputPtr) LookupIDByType (outputIds[i], RROutputType);
+	if (!outputs[i])
 	{
-	    client->errorValue = outputConfigs[i].output;
+	    client->errorValue = outputIds[i];
 	    if (outputs)
 		xfree (outputs);
 	    return RRErrorBase + BadRROutput;
 	}
-	outputs[i].options = outputConfigs[i].options;
-	if (outputs[i].options & ~outputs[i].output->possibleOptions)
-	{
-	    client->errorValue = outputConfigs[i].options;
-	    if (outputs)
-		xfree (outputs);
-	    return BadMatch;
-	}
 	/* validate crtc for this output */
-	for (j = 0; j < outputs[i].output->numCrtcs; j++)
-	    if (outputs[i].output->crtcs[j] == crtc)
+	for (j = 0; j < outputs[i]->numCrtcs; j++)
+	    if (outputs[i]->crtcs[j] == crtc)
 		break;
-	if (j == outputs[i].output->numCrtcs)
+	if (j == outputs[i]->numCrtcs)
 	{
 	    if (outputs)
 		xfree (outputs);
 	    return BadMatch;
 	}
 	/* validate mode for this output */
-	for (j = 0; j < outputs[i].output->numModes; j++)
-	    if (outputs[i].output->modes[j] == mode)
+	for (j = 0; j < outputs[i]->numModes; j++)
+	    if (outputs[i]->modes[j] == mode)
 		break;
-	if (j == outputs[i].output->numModes)
+	if (j == outputs[i]->numModes)
 	{
 	    if (outputs)
 		xfree (outputs);
diff --git a/randr/rroutput.c b/randr/rroutput.c
index 102587b..8b760ec 100644
--- a/randr/rroutput.c
+++ b/randr/rroutput.c
@@ -65,8 +65,6 @@ RROutputCreate (const char  *name,
     output->mmWidth = 0;
     output->mmHeight = 0;
     output->crtc = NULL;
-    output->currentOptions = 0;
-    output->possibleOptions = 0;
     output->numCrtcs = 0;
     output->crtcs = NULL;
     output->numClones = 0;
@@ -223,17 +221,6 @@ RROutputSetCrtcs (RROutputPtr	output,
     return TRUE;
 }
 
-Bool
-RROutputSetPossibleOptions (RROutputPtr	output,
-			    CARD32	possibleOptions)
-{
-    if (output->possibleOptions == possibleOptions)
-	return TRUE;
-    output->possibleOptions = possibleOptions;
-    RROutputChanged (output);
-    return TRUE;
-}
-
 void
 RROutputSetCrtc (RROutputPtr output, RRCrtcPtr crtc)
 {
@@ -267,17 +254,6 @@ RROutputSetSubpixelOrder (RROutputPtr ou
 }
 
 Bool
-RROutputSetCurrentOptions (RROutputPtr output,
-			   CARD32      currentOptions)
-{
-    if (output->currentOptions == currentOptions)
-	return TRUE;
-    output->currentOptions = currentOptions;
-    RROutputChanged (output);
-    return TRUE;
-}
-
-Bool
 RROutputSetPhysicalSize (RROutputPtr	output,
 			 int		mmWidth,
 			 int		mmHeight)
@@ -413,7 +389,6 @@ ProcRRGetOutputInfo (ClientPtr client)
     rep.length = OutputInfoExtra >> 2;
     rep.timestamp = pScrPriv->lastSetTime.milliseconds;
     rep.crtc = output->crtc ? output->crtc->id : None;
-    rep.currentOptions = output->currentOptions;
     rep.mmWidth = output->mmWidth;
     rep.mmHeight = output->mmHeight;
     rep.connection = output->connection;
@@ -423,7 +398,6 @@ ProcRRGetOutputInfo (ClientPtr client)
     rep.nPreferred = output->numPreferred;
     rep.nClones = output->numClones;
     rep.nameLength = output->nameLength;
-    rep.possibleOptions = output->possibleOptions;
     
     extraLen = ((output->numCrtcs + 
 		 output->numModes + 
@@ -469,15 +443,12 @@ ProcRRGetOutputInfo (ClientPtr client)
 	swapl(&rep.length, n);
 	swapl(&rep.timestamp, n);
 	swapl(&rep.crtc, n);
-	swapl(&rep.currentOptions, n);
 	swapl(&rep.mmWidth, n);
 	swapl(&rep.mmHeight, n);
 	swaps(&rep.nCrtcs, n);
 	swaps(&rep.nModes, n);
 	swaps(&rep.nClones, n);
-	swapl(&rep.possibleOptions, n);
 	swaps(&rep.nameLength, n);
-	swapl(&rep.possibleOptions, n);
     }
     WriteToClient(client, sizeof(xRRGetOutputInfoReply), (char *)&rep);
     if (extraLen)
diff --git a/randr/rrscreen.c b/randr/rrscreen.c
index d47e9d6..76c16b0 100644
--- a/randr/rrscreen.c
+++ b/randr/rrscreen.c
@@ -712,7 +712,7 @@ ProcRRSetScreenConfig (ClientPtr client)
     Rotation		    rotation;
     int			    rate;
     Bool		    has_rate;
-    RROutputConfigRec	    output;
+    RROutputPtr		    output;
     RRModePtr		    mode;
     RR10DataPtr		    pData = NULL;
     RRScreenSizePtr    	    pSize;
@@ -749,14 +749,13 @@ ProcRRSetScreenConfig (ClientPtr client)
     if (!RRGetInfo (pScreen))
 	return BadAlloc;
     
-    output.output = RRFirstOutput (pScreen);
-    if (!output.output)
+    output = RRFirstOutput (pScreen);
+    if (!output)
     {
 	time = currentTime;
 	rep.status = RRSetConfigFailed;
 	goto sendReply;
     }
-    output.options = output.output->currentOptions;
     
     /*
      * if the client's config timestamp is not the same as the last config
@@ -769,7 +768,7 @@ ProcRRSetScreenConfig (ClientPtr client)
 	goto sendReply;
     }
     
-    pData = RR10GetData (pScreen, output.output);
+    pData = RR10GetData (pScreen, output);
     if (!pData)
 	return BadAlloc;
     
@@ -805,7 +804,7 @@ ProcRRSetScreenConfig (ClientPtr client)
 	return BadValue;
     }
 
-    if ((~output.output->crtc->rotations) & rotation)
+    if ((~output->crtc->rotations) & rotation)
     {
 	/*
 	 * requested rotation or reflection not supported by screen
@@ -878,7 +877,7 @@ ProcRRSetScreenConfig (ClientPtr client)
 	}
     }
     
-    rep.status = RRCrtcSet (output.output->crtc, mode, 0, 0, stuff->rotation,
+    rep.status = RRCrtcSet (output->crtc, mode, 0, 0, stuff->rotation,
 			    1, &output);
     
     /*
diff-tree f17e3c34dfd1f1418440bdebf45764e4dbf550f0 (from ae3c9ad4abe66784d7ee474455003d2745699286)
Author: George Sapountzis <gsap7 at yahoo.gr>
Date:   Thu Nov 16 02:18:03 2006 +0200

    Fix GL context destruction with AIGLX.
    
    The logic for freeing GL contexts introduced by "Fix AIGLX VT switching." is
    inverted. As it is now, GL context destruction is deferred for glxDRIEnterVT().

diff --git a/GL/glx/glxext.c b/GL/glx/glxext.c
index 11fb7fc..1f6c7f3 100644
--- a/GL/glx/glxext.c
+++ b/GL/glx/glxext.c
@@ -237,7 +237,7 @@ GLboolean __glXFreeContext(__GLXcontext 
      * __glXDispatch() or as a callback from the resource manager.  In
      * the latter case we need to lift the DRI lock manually. */
 
-    if (glxBlockClients) {
+    if (!glxBlockClients) {
 	__glXleaveServer();
 	cx->destroy(cx);
 	__glXenterServer();
diff-tree ae3c9ad4abe66784d7ee474455003d2745699286 (from 2eab230d9bd3f73ffe1b5a42111f89e85904ee11)
Author: Bjorn Helgaas <bjorn.helgaas at hp.com>
Date:   Thu Nov 16 17:29:06 2006 +0100

    Bug 9041: Check the return code in xf86MapDomainMemory().

diff --git a/hw/xfree86/os-support/bus/linuxPci.c b/hw/xfree86/os-support/bus/linuxPci.c
index 15fc2b8..03388f1 100644
--- a/hw/xfree86/os-support/bus/linuxPci.c
+++ b/hw/xfree86/os-support/bus/linuxPci.c
@@ -683,28 +683,28 @@ xf86MapDomainMemory(int ScreenNum, int F
 		    ADDRESS Base, unsigned long Size)
 {
     int domain = xf86GetPciDomain(Tag);
-    int fd;
+    int fd = -1;
     pointer addr;
 
     /*
      * We use /proc/bus/pci on non-legacy addresses or if the Linux sysfs
      * legacy_mem interface is unavailable.
      */
-    if (Base > 1024*1024)
-	return linuxMapPci(ScreenNum, Flags, Tag, Base, Size,
+    if (Base >= 1024*1024)
+	addr = linuxMapPci(ScreenNum, Flags, Tag, Base, Size,
 			   PCIIOC_MMAP_IS_MEM);
-
-    if ((fd = linuxOpenLegacy(Tag, "legacy_mem")) < 0)
-	return linuxMapPci(ScreenNum, Flags, Tag, Base, Size,
+    else if ((fd = linuxOpenLegacy(Tag, "legacy_mem")) < 0)
+	addr = linuxMapPci(ScreenNum, Flags, Tag, Base, Size,
 			   PCIIOC_MMAP_IS_MEM);
+    else
+	addr = mmap(NULL, Size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, Base);
 
-    addr = mmap(NULL, Size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, Base);
-    if (addr == MAP_FAILED) {
-	close (fd);
+    if (fd >= 0)
+	close(fd);
+    if (addr == NULL || addr == MAP_FAILED) {
 	perror("mmap failure");
 	FatalError("xf86MapDomainMem():  mmap() failure\n");
     }
-    close(fd);
     return addr;
 }
 
diff-tree 6ff7f2ad6a5e2e769244590578e6809974b5235d (from 0dee48b8af3e054228aef0d15c1cb1c9e23790cc)
Author: Eric Anholt <eric at anholt.net>
Date:   Tue Nov 7 13:13:53 2006 -0800

    Fix build on FreeBSD after input-hotplug.
    (cherry picked from commit 4e6e4baead6c565363abbcd9e06cc685be121596)

diff --git a/hw/xfree86/os-support/bsd/bsd_bell.c b/hw/xfree86/os-support/bsd/bsd_bell.c
index 60c2ffc..b7a0c48 100644
--- a/hw/xfree86/os-support/bsd/bsd_bell.c
+++ b/hw/xfree86/os-support/bsd/bsd_bell.c
@@ -27,10 +27,15 @@
 #include <xorg-config.h>
 #endif
 
+#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
+#include <sys/kbio.h>
+#endif
+
 #include <termios.h>
 
 #include "xf86.h"
 #include "xf86Priv.h"
+#include "xf86_OSlib.h"
 
 #ifdef WSCONS_SUPPORT
 #define KBD_FD(i) ((i).kbdFd != -1 ? (i).kbdFd : (i).consoleFd)
diff-tree 2eab230d9bd3f73ffe1b5a42111f89e85904ee11 (from 26d2e45bdb0cf4d18ba7b0365425da49d60b3d5c)
Author: Jeremy C. Reed <reed at glacier.reedmedia.net>
Date:   Tue Nov 14 16:37:18 2006 -0600

    For NetBSD, define PCVT_SUPPORT (System has PCVT console).
    
    Noticed by Joerg Sonnenberger.  This fixes problem with console
    switching.
    
    This was in original imake NetBSD.cf.

diff --git a/configure.ac b/configure.ac
index 048712e..2108db4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -282,6 +282,7 @@ case $host_os in
   *netbsd*)
 	AC_DEFINE(CSRG_BASED, 1, [System is BSD-like])
 	AC_DEFINE(PCCONS_SUPPORT, 1, [System has PC console])
+	AC_DEFINE(PCVT_SUPPORT, 1, [System has PCVT console])
 	AC_DEFINE(WSCONS_SUPPORT, 1, [System has wscons console])
 	DRI=yes
 	;;
diff-tree 26d2e45bdb0cf4d18ba7b0365425da49d60b3d5c (from a724b7f1302ba7a59f140b521f13d2ddf0fcf9bf)
Author: Matthias Hopf <mhopf at suse.de>
Date:   Tue Nov 14 15:33:07 2006 +0100

    Bug #9023: Only check mice for "mouse" or "void" if identifier is != NULL.

diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c
index ffdca12..c0e21dd 100644
--- a/hw/xfree86/common/xf86Config.c
+++ b/hw/xfree86/common/xf86Config.c
@@ -1307,7 +1307,7 @@ checkCoreInputDevices(serverLayoutPtr se
      * events, unless a 'void' section is found, in which case the user
      * probably wants to run footless.
      */
-    for (i = servlayoutp->inputs; i->driver; i++) {
+    for (i = servlayoutp->inputs; i->identifier && i->driver; i++) {
 	if (!strcmp(i->driver, "void") || !strcmp(i->driver, "mouse")) {
 	    found = 1; break;
 	}
diff-tree a724b7f1302ba7a59f140b521f13d2ddf0fcf9bf (from parents)
Merge: 6facd958c2e7098cb68eac2810a88b8cd40f19c0 f80a8ae6e6820378ea70ac0849cee8bf3055e0e8
Author: Jeremy C. Reed <reed at glacier.reedmedia.net>
Date:   Mon Nov 13 20:32:26 2006 -0600

    Merge branch 'master' of git+ssh://git.freedesktop.org/git/xorg/xserver

diff-tree 6facd958c2e7098cb68eac2810a88b8cd40f19c0 (from 8382234a7f318057de66490299d63807cefb5201)
Author: Jeremy C. Reed <reed at glacier.reedmedia.net>
Date:   Mon Nov 13 20:23:06 2006 -0600

    On DragonFLy, default to /dev/sysmouse (just like on FreeBSD).
    
    TODO: use autoconf to handle this so the code is not platform
    based but feature based.

diff --git a/hw/xfree86/utils/xorgcfg/text-mode.c b/hw/xfree86/utils/xorgcfg/text-mode.c
index 10f4b69..0430a54 100644
--- a/hw/xfree86/utils/xorgcfg/text-mode.c
+++ b/hw/xfree86/utils/xorgcfg/text-mode.c
@@ -551,7 +551,7 @@ MouseConfig(void)
     if (str == NULL)
 #ifdef WSCONS_SUPPORT
 	str = "/dev/wsmouse";
-#elif defined(__FreeBSD__)
+#elif defined(__FreeBSD__) || defined(__DragonFly__)
 	str = "/dev/sysmouse";
 #elif defined(__UNIXOS2__)
 	str = "mouse$";
diff --git a/hw/xfree86/utils/xorgconfig/xorgconfig.c b/hw/xfree86/utils/xorgconfig/xorgconfig.c
index f00eea0..091b2db 100644
--- a/hw/xfree86/utils/xorgconfig/xorgconfig.c
+++ b/hw/xfree86/utils/xorgconfig/xorgconfig.c
@@ -490,7 +490,7 @@ struct {
 
 #ifdef WSCONS_SUPPORT
 # define DEF_MOUSEDEV "/dev/wsmouse";
-#elif defined(__FreeBSD__)
+#elif defined(__FreeBSD__) || defined(__DragonFly__)
 # define DEF_MOUSEDEV "/dev/sysmouse";
 #elif defined(__linux__)
 # define DEF_MOUSEDEV "/dev/input/mice";
diff-tree f80a8ae6e6820378ea70ac0849cee8bf3055e0e8 (from 5bfe7f4dfc6ab51b6790d74faf11574385234423)
Author: Adam Jackson <ajax at benzedrine.nwnk.net>
Date:   Mon Nov 13 18:26:05 2006 -0500

    Disable Xprt server build by default.

diff --git a/configure.ac b/configure.ac
index 103b087..048712e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -462,7 +462,7 @@ AC_ARG_ENABLE(dmx,    	      AS_HELP_STR
 AC_ARG_ENABLE(xvfb,    	      AS_HELP_STRING([--enable-xvfb], [Build Xvfb server (default: yes)]), [XVFB=$enableval], [XVFB=yes])
 AC_ARG_ENABLE(xnest,   	      AS_HELP_STRING([--enable-xnest], [Build Xnest server (default: auto)]), [XNEST=$enableval], [XNEST=auto])
 AC_ARG_ENABLE(xwin,    	      AS_HELP_STRING([--enable-xwin], [Build XWin server (default: auto)]), [XWIN=$enableval], [XWIN=auto])
-AC_ARG_ENABLE(xprint,         AS_HELP_STRING([--enable-xprint], [Build Xprint extension and server (default: auto)]), [XPRINT=$enableval], [XPRINT=auto])
+AC_ARG_ENABLE(xprint,         AS_HELP_STRING([--enable-xprint], [Build Xprint extension and server (default: no)]), [XPRINT=$enableval], [XPRINT=no])
 AC_ARG_ENABLE(xgl,            AS_HELP_STRING([--enable-xgl], [Build Xgl server (default: no)]), [XGL=$enableval], [XGL=no])
 AC_ARG_ENABLE(xglx,           AS_HELP_STRING([--enable-xglx], [Build Xglx xgl module (default: no)]), [XGLX=$enableval], [XGLX=no])
 AC_ARG_ENABLE(xegl,           AS_HELP_STRING([--enable-xegl], [Build Xegl xgl module (default: no)]), [XEGL=$enableval], [XEGL=no])
diff-tree 5bfe7f4dfc6ab51b6790d74faf11574385234423 (from acb5ff4c73ac4d52201d7c421f488e2ead5c8b9c)
Author: George Sapountzis <gsap7 at yahoo.gr>
Date:   Mon Nov 13 01:54:32 2006 +0200

    DRI: call drmSetServerInfo() before drmOpen().
    
    Also, remove some libdrm remnants.

diff --git a/configure.ac b/configure.ac
index 0977ee3..103b087 100644
--- a/configure.ac
+++ b/configure.ac
@@ -49,8 +49,6 @@ dnl xwin-config.h covers the XWin DDX.
 AC_CONFIG_HEADERS(include/xwin-config.h)
 dnl kdrive-config.h covers the kdrive DDX
 AC_CONFIG_HEADERS(include/kdrive-config.h)
-dnl libdrm now needs 64-bit file offsets
-AC_CONFIG_HEADERS(include/libdrm-config.h)
 
 AC_PROG_CC
 AM_PROG_AS
diff --git a/hw/xfree86/dri/dri.c b/hw/xfree86/dri/dri.c
index fbb24e4..a49c632 100644
--- a/hw/xfree86/dri/dri.c
+++ b/hw/xfree86/dri/dri.c
@@ -84,6 +84,8 @@ static RESTYPE DRIDrawablePrivResType;
 static RESTYPE DRIContextPrivResType;
 static void    DRIDestroyDummyContext(ScreenPtr pScreen, Bool hasCtxPriv);
 
+static drmServerInfo DRIDRMServerInfo;
+
 				/* Wrapper just like xf86DrvMsg, but
 				   without the verbosity level checking.
 				   This will make it easy to turn off some
@@ -174,6 +176,8 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfo
     else
 	openbusid = NULL;
 
+    drmSetServerInfo(&DRIDRMServerInfo);
+
     /* Note that drmOpen will try to load the kernel module, if needed. */
     fd = drmOpen(pDRIInfo->drmDriverName, openbusid);
     if (fd < 0) {
@@ -622,8 +626,6 @@ DRIExtensionInit(void)
 	    return FALSE;
     }
 
-    drmSetServerInfo(&DRIDRMServerInfo);
-
     RegisterBlockAndWakeupHandlers(DRIBlockHandler, DRIWakeupHandler, NULL);
 
     return TRUE;
diff --git a/hw/xfree86/os-support/xf86drmCompat.h b/hw/xfree86/os-support/xf86drmCompat.h
deleted file mode 100644
index 8ac6ee4..0000000
--- a/hw/xfree86/os-support/xf86drmCompat.h
+++ /dev/null
@@ -1,258 +0,0 @@
-/* xf86drmCompat.h -- OS-independent header for old device specific DRM user-level
- *                    library interface
- *
- * Copyright 2000 VA Linux Systems, Inc., Fremont, California.
- * Copyright 2002 Tungsten Graphics, Inc., Cedar Park, Texas.
- * 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
- * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- *   Gareth Hughes <gareth at valinux.com>
- *   Kevin E. Martin <martin at valinux.com>
- *   Keith Whitwell <keith at tungstengraphics.com>
- *
- * Backwards compatability modules broken out by:
- *   Jens Owen <jens at tungstengraphics.com>
- *
- *
- */
-
-#ifndef _XF86DRI_COMPAT_H_
-#define _XF86DRI_COMPAT_H_
-
-/* WARNING: Do not change, or add, anything to this file.  It is only provided
- * for binary backwards compatability with the old driver specific DRM 
- * extensions used before XFree86 4.3.
- */
-
-#ifndef __user
-#define __user
-#endif
-
-/* I810 */
-
-typedef struct {
-   unsigned int start; 
-   unsigned int end; 
-   unsigned int size;
-   unsigned int mmio_offset;
-   unsigned int buffers_offset;
-   int sarea_off;
-
-   unsigned int front_offset;
-   unsigned int back_offset;
-   unsigned int depth_offset;
-   unsigned int overlay_offset;
-   unsigned int overlay_physical;
-   unsigned int w;
-   unsigned int h;
-   unsigned int pitch;
-   unsigned int pitch_bits;
-} drmCompatI810Init;
-
-extern Bool drmI810CleanupDma(int driSubFD);
-extern Bool drmI810InitDma(int driSubFD, drmCompatI810Init *info );
-
-/* Mga */
-
-typedef struct {
-   unsigned long sarea_priv_offset;
-   int chipset;
-   int sgram;
-   unsigned int maccess;
-   unsigned int fb_cpp;
-   unsigned int front_offset, front_pitch;
-   unsigned int back_offset, back_pitch;
-   unsigned int depth_cpp;
-   unsigned int depth_offset, depth_pitch;
-   unsigned int texture_offset[2];
-   unsigned int texture_size[2];
-   unsigned long fb_offset;
-   unsigned long mmio_offset;
-   unsigned long status_offset;
-   unsigned long warp_offset;
-   unsigned long primary_offset;
-   unsigned long buffers_offset;
-} drmCompatMGAInit;
-
-extern int drmMGAInitDMA( int fd, drmCompatMGAInit *info );
-extern int drmMGACleanupDMA( int fd );
-extern int drmMGAFlushDMA( int fd, drmLockFlags flags );
-extern int drmMGAEngineReset( int fd );
-extern int drmMGAFullScreen( int fd, int enable );
-extern int drmMGASwapBuffers( int fd );
-extern int drmMGAClear( int fd, unsigned int flags,
-			unsigned int clear_color, unsigned int clear_depth,
-			unsigned int color_mask, unsigned int depth_mask );
-extern int drmMGAFlushVertexBuffer( int fd, int indx, int used, int discard );
-extern int drmMGAFlushIndices( int fd, int indx,
-			       int start, int end, int discard );
-extern int drmMGATextureLoad( int fd, int indx,
-			      unsigned int dstorg, unsigned int length );
-extern int drmMGAAgpBlit( int fd, unsigned int planemask,
-			  unsigned int src, int src_pitch,
-			  unsigned int dst, int dst_pitch,
-			  int delta_sx, int delta_sy,
-			  int delta_dx, int delta_dy,
-			  int height, int ydir );
-
-/* R128 */
-
-typedef struct {
-   unsigned long sarea_priv_offset;
-   int is_pci;
-   int cce_mode;
-   int cce_secure;
-   int ring_size;
-   int usec_timeout;
-   unsigned int fb_bpp;
-   unsigned int front_offset, front_pitch;
-   unsigned int back_offset, back_pitch;
-   unsigned int depth_bpp;
-   unsigned int depth_offset, depth_pitch;
-   unsigned int span_offset;
-   unsigned long fb_offset;
-   unsigned long mmio_offset;
-   unsigned long ring_offset;
-   unsigned long ring_rptr_offset;
-   unsigned long buffers_offset;
-   unsigned long agp_textures_offset;
-} drmCompatR128Init;
-
-extern int drmR128InitCCE( int fd, drmCompatR128Init *info );
-extern int drmR128CleanupCCE( int fd );
-extern int drmR128StartCCE( int fd );
-extern int drmR128StopCCE( int fd );
-extern int drmR128ResetCCE( int fd );
-extern int drmR128WaitForIdleCCE( int fd );
-extern int drmR128EngineReset( int fd );
-extern int drmR128FullScreen( int fd, int enable );
-extern int drmR128SwapBuffers( int fd );
-extern int drmR128Clear( int fd, unsigned int flags,
-			 unsigned int clear_color, unsigned int clear_depth,
-			 unsigned int color_mask, unsigned int depth_mask );
-extern int drmR128FlushVertexBuffer( int fd, int prim, int indx,
-				     int count, int discard );
-extern int drmR128FlushIndices( int fd, int prim, int indx,
-				int start, int end, int discard );
-extern int drmR128TextureBlit( int fd, int indx,
-			       int offset, int pitch, int format,
-			       int x, int y, int width, int height );
-extern int drmR128WriteDepthSpan( int fd, int n, int x, int y,
-				  const unsigned int depth[],
-				  const unsigned char mask[] );
-extern int drmR128WriteDepthPixels( int fd, int n,
-				    const int x[], const int y[],
-				    const unsigned int depth[],
-				    const unsigned char mask[] );
-extern int drmR128ReadDepthSpan( int fd, int n, int x, int y );
-extern int drmR128ReadDepthPixels( int fd, int n,
-				   const int x[], const int y[] );
-extern int drmR128PolygonStipple( int fd, unsigned int *mask );
-extern int drmR128FlushIndirectBuffer( int fd, int indx,
-				       int start, int end, int discard );
-
-/* Radeon */
-
-typedef struct {
-   unsigned long sarea_priv_offset;
-   int is_pci;
-   int cp_mode;
-   int agp_size;
-   int ring_size;
-   int usec_timeout;
-
-   unsigned int fb_bpp;
-   unsigned int front_offset, front_pitch;
-   unsigned int back_offset, back_pitch;
-   unsigned int depth_bpp;
-   unsigned int depth_offset, depth_pitch;
-
-   unsigned long fb_offset;
-   unsigned long mmio_offset;
-   unsigned long ring_offset;
-   unsigned long ring_rptr_offset;
-   unsigned long buffers_offset;
-   unsigned long agp_textures_offset;
-} drmCompatRadeonInit;
-
-typedef struct {
-   unsigned int x;
-   unsigned int y;
-   unsigned int width;
-   unsigned int height;
-   void *data;
-} drmCompatRadeonTexImage;
-
-extern int drmRadeonInitCP( int fd, drmCompatRadeonInit *info );
-extern int drmRadeonCleanupCP( int fd );
-extern int drmRadeonStartCP( int fd );
-extern int drmRadeonStopCP( int fd );
-extern int drmRadeonResetCP( int fd );
-extern int drmRadeonWaitForIdleCP( int fd );
-extern int drmRadeonEngineReset( int fd );
-extern int drmRadeonFullScreen( int fd, int enable );
-extern int drmRadeonSwapBuffers( int fd );
-extern int drmRadeonClear( int fd, unsigned int flags,
-			   unsigned int clear_color, unsigned int clear_depth,
-			   unsigned int color_mask, unsigned int stencil,
-			   void *boxes, int nbox );
-extern int drmRadeonFlushVertexBuffer( int fd, int prim, int indx,
-				       int count, int discard );
-extern int drmRadeonFlushIndices( int fd, int prim, int indx,
-				  int start, int end, int discard );
-extern int drmRadeonLoadTexture( int fd, int offset, int pitch, int format,
-				 int width, int height,
-				 drmCompatRadeonTexImage *image );
-extern int drmRadeonPolygonStipple( int fd, unsigned int *mask );
-extern int drmRadeonFlushIndirectBuffer( int fd, int indx,
-					 int start, int end, int discard );
-
-/* SiS */
-extern Bool drmSiSAgpInit(int driSubFD, int offset, int size);
-
-/* I830 */
-typedef struct {
-   unsigned int start;
-   unsigned int end;
-   unsigned int size;
-   unsigned int mmio_offset;
-   unsigned int buffers_offset;
-   int sarea_off;
-   unsigned int front_offset;
-   unsigned int back_offset;
-   unsigned int depth_offset;
-   unsigned int w;
-   unsigned int h;
-   unsigned int pitch;
-   unsigned int pitch_bits;
-   unsigned int cpp;
-} drmCompatI830Init;
-
-extern Bool drmI830CleanupDma(int driSubFD);
-extern Bool drmI830InitDma(int driSubFD, drmCompatI830Init *info );
-
-#endif
-
-/* WARNING: Do not change, or add, anything to this file.  It is only provided
- * for binary backwards compatability with the old driver specific DRM 
- * extensions used before XFree86 4.3.
- */
diff --git a/hw/xfree86/os-support/xf86mm.h b/hw/xfree86/os-support/xf86mm.h
deleted file mode 100644
index e1a4e3e..0000000
--- a/hw/xfree86/os-support/xf86mm.h
+++ /dev/null
@@ -1,210 +0,0 @@
-/**************************************************************************
- * 
- * Copyright 2006 Tungsten Graphics, Inc., Bismarck, ND. USA.
- * 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, sub license, 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 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 NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS 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.
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- * 
- * 
- **************************************************************************/
-
-#ifndef _XF86MM_H_
-#define _XF86MM_H_
-#include <stddef.h>
-#include "drm.h"
-
-/*
- * Note on multithreaded applications using this interface.
- * Libdrm is not threadsafe, so common buffer, TTM, and fence objects need to
- * be protected using an external mutex.
- *
- * Note: Don't protect the following functions, as it may lead to deadlocks:
- * drmBOUnmap(), drmFenceBuffers().
- * The kernel is synchronizing and refcounting buffer maps. 
- * User space only needs to refcount object usage within the same application.
- */
-
-
-/*
- * List macros heavily inspired by the Linux kernel
- * list handling. No list looping yet.
- */
-
-typedef struct _drmMMListHead
-{
-    struct _drmMMListHead *prev;
-    struct _drmMMListHead *next;
-} drmMMListHead;
-
-#define DRMINITLISTHEAD(__item)		       \
-  do{					       \
-    (__item)->prev = (__item);		       \
-    (__item)->next = (__item);		       \
-  } while (0)
-
-#define DRMLISTADD(__item, __list)			\
-  do {						\
-    (__item)->prev = (__list);			\
-    (__item)->next = (__list)->next;		\
-    (__list)->next->prev = (__item);		\
-    (__list)->next = (__item);			\
-  } while (0)
-
-#define DRMLISTADDTAIL(__item, __list)		\
-  do {						\
-    (__item)->next = (__list);			\
-    (__item)->prev = (__list)->prev;		\
-    (__list)->prev->next = (__item);		\
-    (__list)->prev = (__item);			\
-  } while(0)
-
-#define DRMLISTDEL(__item)			\
-  do {						\
-    (__item)->prev->next = (__item)->next;	\
-    (__item)->next->prev = (__item)->prev;	\
-  } while(0)
-
-#define DRMLISTDELINIT(__item)			\
-  do {						\
-    (__item)->prev->next = (__item)->next;	\
-    (__item)->next->prev = (__item)->prev;	\
-    (__item)->next = (__item);			\
-    (__item)->prev = (__item);			\
-  } while(0)
-
-#define DRMLISTENTRY(__type, __item, __field)   \
-    ((__type *)(((char *) (__item)) - offsetof(__type, __field)))
-
-typedef struct _drmFence{
-        unsigned handle;
-        int class;
-        unsigned type; 
-        unsigned flags;
-        unsigned signaled;
-        unsigned pad[4]; /* for future expansion */
-} drmFence;
-
-typedef struct _drmBO{
-    drm_bo_type_t type;
-    unsigned handle;
-    drm_u64_t mapHandle;
-    unsigned flags;
-    unsigned mask;
-    unsigned mapFlags;
-    unsigned long size;
-    unsigned long offset;
-    unsigned long start;
-    unsigned replyFlags;
-    unsigned fenceFlags;
-    unsigned pageAlignment;
-    void *virtual;
-    void *mapVirtual;
-    int mapCount;
-    unsigned pad[8];     /* for future expansion */
-} drmBO;
-
-
-typedef struct _drmBONode {
-    drmMMListHead head;
-    drmBO *buf;
-    drm_bo_arg_t bo_arg;
-    unsigned long arg0;
-    unsigned long arg1;
-} drmBONode;
-
-typedef struct _drmBOList {
-    unsigned numTarget;
-    unsigned numCurrent;
-    unsigned numOnList;
-    drmMMListHead list;
-    drmMMListHead free;
-} drmBOList;
-
-/* Fencing */
-
-extern int drmFenceCreate(int fd, unsigned flags, int class,
-			  unsigned type, 
-			  drmFence *fence);
-extern int drmFenceDestroy(int fd, const drmFence *fence);
-extern int drmFenceReference(int fd, unsigned handle, drmFence *fence);
-extern int drmFenceUnreference(int fd, const drmFence *fence);
-extern int drmFenceFlush(int fd, drmFence *fence, unsigned flush_type);
-extern int drmFenceSignaled(int fd, drmFence *fence, 
-			    unsigned fenceType, int *signaled);
-extern int drmFenceWait(int fd, unsigned flags, drmFence *fence, 
-			unsigned flush_type);
-extern int drmFenceEmit(int fd, unsigned flags, drmFence *fence, 
-			unsigned emit_type);
-extern int drmFenceBuffers(int fd, unsigned flags, drmFence *fence);
-extern int drmFenceUpdate(int fd, drmFence *fence);
-
-
-/*
- * Buffer object list functions.
- */
-
-extern void drmBOFreeList(drmBOList *list);
-extern int drmBOResetList(drmBOList *list);
-extern void *drmBOListIterator(drmBOList *list);
-extern void *drmBOListNext(drmBOList *list, void *iterator);
-extern drmBO *drmBOListBuf(void *iterator);
-extern int drmBOCreateList(int numTarget, drmBOList *list);
-
-/*
- * Buffer object functions.
- */
-
-extern int drmBOCreate(int fd, unsigned long start, unsigned long size,
-		       unsigned pageAlignment,void *user_buffer, 
-		       drm_bo_type_t type, unsigned mask,
-		       unsigned hint, drmBO *buf);
-extern int drmBODestroy(int fd, drmBO *buf);
-extern int drmBOReference(int fd, unsigned handle, drmBO *buf);
-extern int drmBOUnReference(int fd, drmBO *buf);
-extern int drmBOMap(int fd, drmBO *buf, unsigned mapFlags, unsigned mapHint,
-		    void **address);
-extern int drmBOUnmap(int fd, drmBO *buf);
-extern int drmBOValidate(int fd, drmBO *buf, unsigned flags, unsigned mask, 
-			 unsigned hint);
-extern int drmBOFence(int fd, drmBO *buf, unsigned flags, unsigned fenceHandle);
-extern int drmBOInfo(int fd, drmBO *buf);
-extern int drmBOBusy(int fd, drmBO *buf, int *busy);
-
-
-extern int drmAddValidateItem(drmBOList *list, drmBO *buf, unsigned flags, 
-		       unsigned mask,
-		       int *newItem);
-extern int drmBOValidateList(int fd, drmBOList *list);
-extern int drmBOFenceList(int fd, drmBOList *list, unsigned fenceHandle);
-extern int drmBOWaitIdle(int fd, drmBO *buf, unsigned hint);
-
-/*
- * Initialization functions.
- */
-
-extern int drmMMInit(int fd, unsigned long pOffset, unsigned long pSize,
-		     unsigned memType);
-extern int drmMMTakedown(int fd, unsigned memType);
-extern int drmMMLock(int fd, unsigned memType);
-extern int drmMMUnlock(int fd, unsigned memType);
-
-
-#endif
diff --git a/include/libdrm-config.h.in b/include/libdrm-config.h.in
deleted file mode 100644
index 286004b..0000000
--- a/include/libdrm-config.h.in
+++ /dev/null
@@ -1,10 +0,0 @@
-/* 
- * libdrm-config.h.in: not at all generated.
- */
-
-/* Number of bits in a file offset, on hosts where this is settable. */
-#undef _FILE_OFFSET_BITS
-
-/* Define for large files, on AIX-style hosts. */
-#undef _LARGE_FILES
-
diff-tree acb5ff4c73ac4d52201d7c421f488e2ead5c8b9c (from ca094684196886a4a1c10273049fae0705a3edc2)
Author: Jurij Smakov <jurij at wooyd.org>
Date:   Sat Nov 11 14:09:15 2006 +0200

    ffs: handle 0 argument (bug #8968)
    
    Handle an argument of 0 in ffs(), instead of looping indefinitely.
    Add an ffs prototype to dix.h, and add includes to ffs.c.
    (cherry picked from 34164e551e4c3909322d50b09835ca4ac1d49d68 commit)

diff --git a/dix/ffs.c b/dix/ffs.c
index f84f7b4..b75657d 100644
--- a/dix/ffs.c
+++ b/dix/ffs.c
@@ -36,6 +36,8 @@ int
 ffs(int i)
 {
     int j;
+    if (i == 0)
+        return 0;
     for (j = 1; (i & 1) == 0; j++)
 	i >>= 1;
     return j;
diff --git a/include/dix.h b/include/dix.h
index 983a84f..a5a570a 100644
--- a/include/dix.h
+++ b/include/dix.h
@@ -817,4 +817,7 @@ typedef struct {
 extern int xstrcasecmp(char *s1, char *s2);
 #endif
 
+/* ffs.c */
+extern int ffs(int i);
+
 #endif /* DIX_H */
diff-tree ca094684196886a4a1c10273049fae0705a3edc2 (from 28337cc1060bc08adef81c304dd9ed02d0a0e37b)
Author: Alan Coopersmith <alan.coopersmith at sun.com>
Date:   Fri Nov 10 18:02:05 2006 -0800

    Correct symlink-mesa.sh usage message

diff --git a/GL/symlink-mesa.sh b/GL/symlink-mesa.sh
index c14c683..9687ce8 100755
--- a/GL/symlink-mesa.sh
+++ b/GL/symlink-mesa.sh
@@ -289,9 +289,9 @@ action() {
 }
 
 usage() {
-    echo symlink.sh src-dir dst-dir
-    echo src-dir: the xc directory of the monolithic source tree
-    echo dst-dir: the modular source tree containing proto, app, lib, ...
+    echo symlink-mesa.sh src-dir dst-dir
+    echo src-dir: the Mesa source directory
+    echo dst-dir: the GL subdirectory of the Xserver modular tree
 }
 
 # Check commandline args
diff-tree 28337cc1060bc08adef81c304dd9ed02d0a0e37b (from e1720b1089328af80ca0cb85e5289ced05263f95)
Author: Eric Anholt <eric at anholt.net>
Date:   Thu Nov 9 19:51:17 2006 -0800

    Fix typo before the last commit.

diff --git a/hw/xfree86/os-support/Makefile.am b/hw/xfree86/os-support/Makefile.am
index 5ade7e8..6346d1c 100644
--- a/hw/xfree86/os-support/Makefile.am
+++ b/hw/xfree86/os-support/Makefile.am
@@ -1,4 +1,4 @@
-t -SUBDIRS = bus @XORG_OS_SUBDIR@ misc $(DRI_SUBDIRS)
+SUBDIRS = bus @XORG_OS_SUBDIR@ misc $(DRI_SUBDIRS)
 DIST_SUBDIRS = bsd bus misc linux lynxos solaris sysv sco usl hurd
 
 sdk_HEADERS = xf86_OSproc.h xf86_OSlib.h xf86_ansic.h xf86_libc.h \
diff-tree e1720b1089328af80ca0cb85e5289ced05263f95 (from fd91630b73100e9d77ccb492c52807448bc772a5)
Author: Eric Anholt <eric at anholt.net>
Date:   Thu Nov 9 18:53:37 2006 -0800

    Bug #8868: Remove drm from SUBDIRS now that the directory is gone.

diff --git a/hw/xfree86/os-support/Makefile.am b/hw/xfree86/os-support/Makefile.am
index f9a888e..5ade7e8 100644
--- a/hw/xfree86/os-support/Makefile.am
+++ b/hw/xfree86/os-support/Makefile.am
@@ -1,5 +1,5 @@
-SUBDIRS = bus @XORG_OS_SUBDIR@ misc $(DRI_SUBDIRS)
-DIST_SUBDIRS = bsd bus drm misc linux lynxos solaris sysv sco usl hurd
+t -SUBDIRS = bus @XORG_OS_SUBDIR@ misc $(DRI_SUBDIRS)
+DIST_SUBDIRS = bsd bus misc linux lynxos solaris sysv sco usl hurd
 
 sdk_HEADERS = xf86_OSproc.h xf86_OSlib.h xf86_ansic.h xf86_libc.h \
               assyntax.h xf86OSmouse.h
diff-tree 0dee48b8af3e054228aef0d15c1cb1c9e23790cc (from ec77a95a02329a2ee3a94d7de9d2a234aecb9ca0)
Author: Keith Packard <keithp at mandolin.keithp.com>
Date:   Wed Nov 8 23:17:55 2006 -0800

    Add RRInit function to create resource types for RR objects.
    
    To allow RandR objects to be created before the screen object exists,
    the resource types must be registered with the resource database.
    A driver wishing to create RandR objects must call RRInit before doing so.
    
    Also, fix a segfault when setting Output data before it is associated with a
    screen.

diff --git a/randr/randr.c b/randr/randr.c
index 4426c47..147df8c 100644
--- a/randr/randr.c
+++ b/randr/randr.c
@@ -39,8 +39,7 @@
 #endif
 
 #define RR_VALIDATE
-int	RRGeneration;
-int	RRNScreens;
+static int	RRNScreens;
 
 #define wrap(priv,real,mem,func) {\
     priv->mem = real->mem; \
@@ -198,10 +197,10 @@ SRRNotifyEvent (xEvent *from,
     }
 }
 
-Bool RRScreenInit(ScreenPtr pScreen)
-{
-    rrScrPrivPtr   pScrPriv;
+static int RRGeneration;
 
+Bool RRInit (void)
+{
     if (RRGeneration != serverGeneration)
     {
 	if (!RRModeInit ())
@@ -210,9 +209,25 @@ Bool RRScreenInit(ScreenPtr pScreen)
 	    return FALSE;
 	if (!RROutputInit ())
 	    return FALSE;
+	RRGeneration = serverGeneration;
+    }
+    return TRUE;
+}
+
+static int RRScreenGeneration;
+
+Bool RRScreenInit(ScreenPtr pScreen)
+{
+    rrScrPrivPtr   pScrPriv;
+
+    if (!RRInit ())
+	return FALSE;
+
+    if (RRScreenGeneration != serverGeneration)
+    {
 	if ((rrPrivIndex = AllocateScreenPrivateIndex()) < 0)
 	    return FALSE;
-	RRGeneration = serverGeneration;
+	RRScreenGeneration = serverGeneration;
     }
 
     pScrPriv = (rrScrPrivPtr) xalloc (sizeof (rrScrPrivRec));
diff --git a/randr/randrstr.h b/randr/randrstr.h
index 345418b..2c3e0e7 100644
--- a/randr/randrstr.h
+++ b/randr/randrstr.h
@@ -384,6 +384,8 @@ RRTellChanged (ScreenPtr pScreen);
 Bool
 RRGetInfo (ScreenPtr pScreen);
 
+Bool RRInit (void);
+
 Bool RRScreenInit(ScreenPtr pScreen);
 
 RROutputPtr
diff --git a/randr/rroutput.c b/randr/rroutput.c
index 1b0ecab..102587b 100644
--- a/randr/rroutput.c
+++ b/randr/rroutput.c
@@ -31,10 +31,13 @@ void
 RROutputChanged (RROutputPtr output)
 {
     ScreenPtr	pScreen = output->pScreen;
-    rrScrPriv (pScreen);
-
+    
     output->changed = TRUE;
-    pScrPriv->changed = TRUE;
+    if (pScreen)
+    {
+	rrScrPriv (pScreen);
+	pScrPriv->changed = TRUE;
+    }
 }
 
 /*
@@ -335,17 +338,21 @@ RROutputDestroyResource (pointer value, 
 {
     RROutputPtr	output = (RROutputPtr) value;
     ScreenPtr	pScreen = output->pScreen;
-    rrScrPriv(pScreen);
-    int		i;
 
-    for (i = 0; i < pScrPriv->numOutputs; i++)
+    if (pScreen)
     {
-	if (pScrPriv->outputs[i] == output)
+	rrScrPriv(pScreen);
+	int		i;
+    
+	for (i = 0; i < pScrPriv->numOutputs; i++)
 	{
-	    memmove (pScrPriv->outputs + i, pScrPriv->outputs + i + 1,
-		     (pScrPriv->numOutputs - (i - 1)) * sizeof (RROutputPtr));
-	    --pScrPriv->numOutputs;
-	    break;
+	    if (pScrPriv->outputs[i] == output)
+	    {
+		memmove (pScrPriv->outputs + i, pScrPriv->outputs + i + 1,
+			 (pScrPriv->numOutputs - (i - 1)) * sizeof (RROutputPtr));
+		--pScrPriv->numOutputs;
+		break;
+	    }
 	}
     }
     if (output->modes)
@@ -481,4 +488,3 @@ ProcRRGetOutputInfo (ClientPtr client)
     
     return client->noClientException;
 }
-
diff-tree ec77a95a02329a2ee3a94d7de9d2a234aecb9ca0 (from 20e9144c0746943624ff77a61791b8596f3f8458)
Author: Keith Packard <keithp at mandolin.keithp.com>
Date:   Wed Nov 8 21:36:35 2006 -0800

    Allow RandR objects to be created before the associated ScreenRec.
    
    xf86 drivers need to create RandR object in the PreInit stage,
    before the ScreenRec is allocated. Changing the RandR DIX code
    to permit this required the addition of functions that later associate the
    objects with the related screen.
    
    An additional change is that modes are now global, and no longer associated
    with a specific screen. This change actually makes mode management cleaner
    as there is no more per-screen list of modes to deal with.
    
    This changes the RandR 1.2 ABI/API for drivers.

diff --git a/hw/xfree86/common/Makefile.am b/hw/xfree86/common/Makefile.am
index 0e1582e..35b22f0 100644
--- a/hw/xfree86/common/Makefile.am
+++ b/hw/xfree86/common/Makefile.am
@@ -51,7 +51,7 @@ sdk_HEADERS = compiler.h fourcc.h xf86.h
               xf86PciInfo.h xf86Priv.h xf86Privstr.h xf86Resources.h \
               xf86cmap.h xf86fbman.h xf86str.h $(XISDKINCS) \
               $(XVSDKINCS) atKeynames.h xf86Version.h xorgVersion.h \
-              xf86sbusBus.h xf86xv.h xf86xvmc.h xf86xvpriv.h
+              xf86sbusBus.h xf86xv.h xf86xvmc.h xf86xvpriv.h xf86Keymap.h
 
 DISTCLEANFILES = xf86Build.h
 CLEANFILES = $(BUILT_SOURCES)
diff --git a/randr/mirandr.c b/randr/mirandr.c
index 11c2991..3f56fe4 100644
--- a/randr/mirandr.c
+++ b/randr/mirandr.c
@@ -113,17 +113,24 @@ miRandRInit (ScreenPtr pScreen)
     modeInfo.height = pScreen->height;
     modeInfo.nameLength = strlen (name);
     
-    mode = RRModeGet (pScreen, &modeInfo, name);
+    mode = RRModeGet (&modeInfo, name);
     if (!mode)
 	return FALSE;
     
-    crtc = RRCrtcCreate (pScreen, NULL);
+    crtc = RRCrtcCreate (NULL);
     if (!crtc)
 	return FALSE;
+    if (!RRCrtcAttachScreen (crtc, pScreen))
+    {
+	RRCrtcDestroy (crtc);
+	return FALSE;
+    }
     
-    output = RROutputCreate (pScreen, "screen", 6, NULL);
+    output = RROutputCreate ("screen", 6, NULL);
     if (!output)
 	return FALSE;
+    if (!RROutputAttachScreen (output, pScreen))
+	return FALSE;
     if (!RROutputSetClones (output, NULL, 0))
 	return FALSE;
     if (!RROutputSetModes (output, &mode, 1, 0))
diff --git a/randr/randr.c b/randr/randr.c
index 7b39e80..4426c47 100644
--- a/randr/randr.c
+++ b/randr/randr.c
@@ -103,8 +103,6 @@ RRCloseScreen (int i, ScreenPtr pScreen)
 	RRCrtcDestroy (pScrPriv->crtcs[j]);
     for (j = pScrPriv->numOutputs - 1; j >= 0; j--)
 	RROutputDestroy (pScrPriv->outputs[j]);
-    for (j = pScrPriv->numModes - 1; j >= 0; j--)
-	RRModeDestroy (pScrPriv->modes[j]);
     
     xfree (pScrPriv);
     RRNScreens -= 1;	/* ok, one fewer screen with RandR running */
@@ -257,8 +255,6 @@ Bool RRScreenInit(ScreenPtr pScreen)
     
     wrap (pScrPriv, pScreen, CloseScreen, RRCloseScreen);
 
-    pScrPriv->numModes = 0;
-    pScrPriv->modes = NULL;
     pScrPriv->numOutputs = 0;
     pScrPriv->outputs = NULL;
     pScrPriv->numCrtcs = 0;
diff --git a/randr/randrstr.h b/randr/randrstr.h
index 60877a3..345418b 100644
--- a/randr/randrstr.h
+++ b/randr/randrstr.h
@@ -79,7 +79,6 @@ struct _rrMode {
     xRRModeInfo	    mode;
     char	    *name;
     void	    *devPrivate;
-    ScreenPtr	    screen;
     Bool	    userDefined;
 };
 
@@ -210,10 +209,6 @@ typedef struct _rrScrPriv {
     CARD16		    width, height;	/* last known screen size */
     Bool		    layoutChanged;	/* screen layout changed */
 
-    /* modes, outputs and crtcs */
-    int			    numModes;
-    RRModePtr		    *modes;
-
     int			    numOutputs;
     RROutputPtr		    *outputs;
 
@@ -457,10 +452,17 @@ RRCrtcChanged (RRCrtcPtr crtc, Bool layo
  * Create a CRTC
  */
 RRCrtcPtr
-RRCrtcCreate (ScreenPtr	pScreen,
-	      void	*devPrivate);
+RRCrtcCreate (void	*devPrivate);
 
 /*
+ * Attach a CRTC to a screen. Once done, this cannot be
+ * undone without destroying the CRTC; it is separate from Create
+ * only to allow an xf86-based driver to create objects in preinit
+ */
+Bool
+RRCrtcAttachScreen (RRCrtcPtr crtc, ScreenPtr pScreen);
+    
+/*
  * Notify the extension that the Crtc has been reconfigured,
  * the driver calls this whenever it has updated the mode
  */
@@ -556,8 +558,7 @@ RRClientKnowsRates (ClientPtr	pClient);
  */
 
 RRModePtr
-RRModeGet (ScreenPtr	pScreen,
-	   xRRModeInfo	*modeInfo,
+RRModeGet (xRRModeInfo	*modeInfo,
 	   const char	*name);
 
 void
@@ -571,6 +572,12 @@ void
 RRModeDestroy (RRModePtr mode);
 
 /*
+ * Return a list of modes that are valid for some output in pScreen
+ */
+RRModePtr *
+RRModesForScreen (ScreenPtr pScreen, int *num_ret);
+    
+/*
  * Initialize mode type
  */
 Bool
@@ -601,12 +608,19 @@ RROutputChanged (RROutputPtr output);
  */
 
 RROutputPtr
-RROutputCreate (ScreenPtr   pScreen,
-		const char  *name,
+RROutputCreate (const char  *name,
 		int	    nameLength,
 		void	    *devPrivate);
 
 /*
+ * Attach an output to a screen, again split from creation so
+ * xf86 DDXen can create randr resources before the ScreenRec
+ * exists
+ */
+Bool
+RROutputAttachScreen (RROutputPtr output, ScreenPtr pScreen);
+
+/*
  * Notify extension that output parameters have been changed
  */
 Bool
diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c
index 76d0b6b..9f7177a 100644
--- a/randr/rrcrtc.c
+++ b/randr/rrcrtc.c
@@ -32,43 +32,34 @@ void
 RRCrtcChanged (RRCrtcPtr crtc, Bool layoutChanged)
 {
     ScreenPtr	pScreen = crtc->pScreen;
-    rrScrPriv(pScreen);
 
     crtc->changed = TRUE;
-    pScrPriv->changed = TRUE;
-    /*
-     * Send ConfigureNotify on any layout change
-     */
-    if (layoutChanged)
-	pScrPriv->layoutChanged = TRUE;
+    if (pScreen)
+    {
+	rrScrPriv(pScreen);
+    
+	pScrPriv->changed = TRUE;
+	/*
+	 * Send ConfigureNotify on any layout change
+	 */
+	if (layoutChanged)
+	    pScrPriv->layoutChanged = TRUE;
+    }
 }
 
 /*
  * Create a CRTC
  */
 RRCrtcPtr
-RRCrtcCreate (ScreenPtr	pScreen,
-	      void	*devPrivate)
+RRCrtcCreate (void	*devPrivate)
 {
-    rrScrPriv (pScreen);
     RRCrtcPtr	crtc;
-    RRCrtcPtr	*crtcs;
     
     crtc = xalloc (sizeof (RRCrtcRec));
     if (!crtc)
 	return NULL;
-    if (pScrPriv->numCrtcs)
-	crtcs = xrealloc (pScrPriv->crtcs, 
-			  (pScrPriv->numCrtcs + 1) * sizeof (RRCrtcPtr));
-    else
-	crtcs = xalloc (sizeof (RRCrtcPtr));
-    if (!crtcs)
-    {
-	xfree (crtc);
-	return NULL;
-    }
     crtc->id = FakeClientID (0);
-    crtc->pScreen = pScreen;
+    crtc->pScreen = NULL;
     crtc->mode = NULL;
     crtc->x = 0;
     crtc->y = 0;
@@ -84,11 +75,37 @@ RRCrtcCreate (ScreenPtr	pScreen,
     if (!AddResource (crtc->id, RRCrtcType, (pointer) crtc))
 	return NULL;
 
+    return crtc;
+}
+
+/*
+ * Attach a Crtc to a screen. This is done as a separate step
+ * so that an xf86-based driver can create CRTCs in PreInit
+ * before the Screen has been created
+ */
+
+Bool
+RRCrtcAttachScreen (RRCrtcPtr crtc, ScreenPtr pScreen)
+{
+    rrScrPriv (pScreen);
+    RRCrtcPtr	*crtcs;
+
+    /* make space for the crtc pointer */
+    if (pScrPriv->numCrtcs)
+	crtcs = xrealloc (pScrPriv->crtcs, 
+			  (pScrPriv->numCrtcs + 1) * sizeof (RRCrtcPtr));
+    else
+	crtcs = xalloc (sizeof (RRCrtcPtr));
+    if (!crtcs)
+	return FALSE;
+    
+    /* attach the screen and crtc together */
+    crtc->pScreen = pScreen;
     pScrPriv->crtcs = crtcs;
     pScrPriv->crtcs[pScrPriv->numCrtcs++] = crtc;
 
     RRCrtcChanged (crtc, TRUE);
-    return crtc;
+    return TRUE;
 }
 
 /*
@@ -243,7 +260,6 @@ RRCrtcSet (RRCrtcPtr    crtc,
 	   RROutputConfigPtr  outputs)
 {
     ScreenPtr	pScreen = crtc->pScreen;
-    rrScrPriv(pScreen);
 
     /* See if nothing changed */
     if (crtc->mode == mode &&
@@ -255,45 +271,49 @@ RRCrtcSet (RRCrtcPtr    crtc,
     {
 	return TRUE;
     }
-#if RANDR_12_INTERFACE
-    if (pScrPriv->rrCrtcSet)
+    if (pScreen)
     {
-	return (*pScrPriv->rrCrtcSet) (pScreen, crtc, mode, x, y, 
-				       rotation, numOutputs, outputs);
-    }
-#endif
-#if RANDR_10_INTERFACE
-    if (pScrPriv->rrSetConfig)
-    {
-	RRScreenSize	    size;
-	RRScreenRate	    rate;
-	Bool		    ret;
-
-	size.width = mode->mode.width;
-	size.height = mode->mode.height;
-	if (outputs[0].output->mmWidth && outputs[0].output->mmHeight)
+#if RANDR_12_INTERFACE
+	rrScrPriv(pScreen);
+	if (pScrPriv->rrCrtcSet)
 	{
-	    size.mmWidth = outputs[0].output->mmWidth;
-	    size.mmHeight = outputs[0].output->mmHeight;
+	    return (*pScrPriv->rrCrtcSet) (pScreen, crtc, mode, x, y, 
+					   rotation, numOutputs, outputs);
 	}
-	else
+#endif
+#if RANDR_10_INTERFACE
+	if (pScrPriv->rrSetConfig)
 	{
-	    size.mmWidth = pScreen->mmWidth;
-	    size.mmHeight = pScreen->mmHeight;
+	    RRScreenSize	    size;
+	    RRScreenRate	    rate;
+	    Bool		    ret;
+
+	    size.width = mode->mode.width;
+	    size.height = mode->mode.height;
+	    if (outputs[0].output->mmWidth && outputs[0].output->mmHeight)
+	    {
+		size.mmWidth = outputs[0].output->mmWidth;
+		size.mmHeight = outputs[0].output->mmHeight;
+	    }
+	    else
+	    {
+		size.mmWidth = pScreen->mmWidth;
+		size.mmHeight = pScreen->mmHeight;
+	    }
+	    size.nRates = 1;
+	    rate.rate = RRVerticalRefresh (&mode->mode);
+	    size.pRates = &rate;
+	    ret = (*pScrPriv->rrSetConfig) (pScreen, rotation, rate.rate, &size);
+	    /*
+	     * Old 1.0 interface tied screen size to mode size
+	     */
+	    if (ret)
+		RRCrtcNotify (crtc, mode, x, y, rotation, 1, &outputs[0].output);
+	    return ret;
 	}
-	size.nRates = 1;
-	rate.rate = RRVerticalRefresh (&mode->mode);
-	size.pRates = &rate;
-	ret = (*pScrPriv->rrSetConfig) (pScreen, rotation, rate.rate, &size);
-	/*
-	 * Old 1.0 interface tied screen size to mode size
-	 */
-	if (ret)
-	    RRCrtcNotify (crtc, mode, x, y, rotation, 1, &outputs[0].output);
-	return ret;
-    }
 #endif
-    RRTellChanged (pScreen);
+	RRTellChanged (pScreen);
+    }
     return FALSE;
 }
 
@@ -311,22 +331,26 @@ RRCrtcDestroyResource (pointer value, XI
 {
     RRCrtcPtr	crtc = (RRCrtcPtr) value;
     ScreenPtr	pScreen = crtc->pScreen;
-    rrScrPriv(pScreen);
-    int		i;
 
-    for (i = 0; i < pScrPriv->numCrtcs; i++)
+    if (pScreen)
     {
-	if (pScrPriv->crtcs[i] == crtc)
+	rrScrPriv(pScreen);
+	int		i;
+    
+	for (i = 0; i < pScrPriv->numCrtcs; i++)
 	{
-	    memmove (pScrPriv->crtcs + i, pScrPriv->crtcs + i + 1,
-		     (pScrPriv->numCrtcs - (i - 1)) * sizeof (RRCrtcPtr));
-	    --pScrPriv->numCrtcs;
-	    break;
+	    if (pScrPriv->crtcs[i] == crtc)
+	    {
+		memmove (pScrPriv->crtcs + i, pScrPriv->crtcs + i + 1,
+			 (pScrPriv->numCrtcs - (i - 1)) * sizeof (RRCrtcPtr));
+		--pScrPriv->numCrtcs;
+		break;
+	    }
 	}
     }
     if (crtc->gammaRed)
 	xfree (crtc->gammaRed);
-    xfree (value);
+    xfree (crtc);
     return 1;
 }
 
@@ -343,15 +367,18 @@ RRCrtcGammaSet (RRCrtcPtr   crtc,
     Bool	ret = TRUE;
 #if RANDR_12_INTERFACE
     ScreenPtr	pScreen = crtc->pScreen;
-    rrScrPriv(pScreen);
 #endif
     
     memcpy (crtc->gammaRed, red, crtc->gammaSize * sizeof (CARD16));
     memcpy (crtc->gammaGreen, green, crtc->gammaSize * sizeof (CARD16));
     memcpy (crtc->gammaBlue, blue, crtc->gammaSize * sizeof (CARD16));
 #if RANDR_12_INTERFACE
-    if (pScrPriv->rrCrtcSetGamma)
-	ret = (*pScrPriv->rrCrtcSetGamma) (pScreen, crtc);
+    if (pScreen)
+    {
+	rrScrPriv(pScreen);
+	if (pScrPriv->rrCrtcSetGamma)
+	    ret = (*pScrPriv->rrCrtcSetGamma) (pScreen, crtc);
+    }
 #endif
     return ret;
 }
@@ -433,6 +460,9 @@ ProcRRGetCrtcInfo (ClientPtr client)
     if (!crtc)
 	return RRErrorBase + BadRRCrtc;
 
+    /* All crtcs must be associated with screens before client
+     * requests are processed
+     */
     pScreen = crtc->pScreen;
     pScrPriv = rrGetScrPriv(pScreen);
 
@@ -589,7 +619,7 @@ ProcRRSetCrtcConfig (ClientPtr client)
 	for (j = 0; j < outputs[i].output->numCrtcs; j++)
 	    if (outputs[i].output->crtcs[j] == crtc)
 		break;
-	if (j == outputs[j].output->numCrtcs)
+	if (j == outputs[i].output->numCrtcs)
 	{
 	    if (outputs)
 		xfree (outputs);
diff --git a/randr/rrinfo.c b/randr/rrinfo.c
index e92caad..244b089 100644
--- a/randr/rrinfo.c
+++ b/randr/rrinfo.c
@@ -44,7 +44,7 @@ RROldModeAdd (RROutputPtr output, RRScre
     modeInfo.dotClock = ((CARD32) size->width * (CARD32) size->height *
 			 (CARD32) refresh);
     modeInfo.nameLength = strlen (name);
-    mode = RRModeGet (pScreen, &modeInfo, name);
+    mode = RRModeGet (&modeInfo, name);
     if (!mode)
 	return NULL;
     for (i = 0; i < output->numModes; i++)
@@ -90,12 +90,19 @@ RRScanOldConfig (ScreenPtr pScreen, Rota
     if (pScrPriv->numOutputs == 0 &&
 	pScrPriv->numCrtcs == 0)
     {
-	crtc = RRCrtcCreate (pScreen, NULL);
+	crtc = RRCrtcCreate (NULL);
 	if (!crtc)
 	    return;
-	output = RROutputCreate (pScreen, "default", 7, NULL);
+	if (!RRCrtcAttachScreen (crtc, pScreen))
+	{
+	    RRCrtcDestroy (crtc);
+	    return;
+	}
+	output = RROutputCreate ("default", 7, NULL);
 	if (!output)
 	    return;
+	if (!RROutputAttachScreen (output, pScreen))
+	    return;
 	RROutputSetCrtcs (output, &crtc, 1);
 	RROutputSetCrtc (output, crtc);
 	RROutputSetConnection (output, RR_Connected);
@@ -206,7 +213,6 @@ RRGetInfo (ScreenPtr pScreen)
     if (pScrPriv->nSizes)
 	RRScanOldConfig (pScreen, rotations);
 #endif
-    RRModePruneUnused (pScreen);
     RRTellChanged (pScreen);
     return TRUE;
 }
diff --git a/randr/rrmode.c b/randr/rrmode.c
index fb4b5eb..3cd9ef2 100644
--- a/randr/rrmode.c
+++ b/randr/rrmode.c
@@ -42,19 +42,23 @@ RRModeEqual (xRRModeInfo *a, xRRModeInfo
     return TRUE;
 }
 
+/*
+ * Keep a list so it's easy to find modes in the resource database.
+ */
+static int	    num_modes;
+static RRModePtr    *modes;
+
 RRModePtr
-RRModeGet (ScreenPtr	pScreen,
-	   xRRModeInfo	*modeInfo,
+RRModeGet (xRRModeInfo	*modeInfo,
 	   const char	*name)
 {
-    rrScrPriv (pScreen);
     int	i;
     RRModePtr	mode;
-    RRModePtr	*modes;
+    RRModePtr	*newModes;
 
-    for (i = 0; i < pScrPriv->numModes; i++)
+    for (i = 0; i < num_modes; i++)
     {
-	mode = pScrPriv->modes[i];
+	mode = modes[i];
 	if (RRModeEqual (&mode->mode, modeInfo) &&
 	    !memcmp (name, mode->name, modeInfo->nameLength))
 	{
@@ -71,16 +75,14 @@ RRModeGet (ScreenPtr	pScreen,
     mode->name = (char *) (mode + 1);
     memcpy (mode->name, name, modeInfo->nameLength);
     mode->name[modeInfo->nameLength] = '\0';
-    mode->screen = pScreen;
     mode->userDefined = FALSE;
 
-    if (pScrPriv->numModes)
-	modes = xrealloc (pScrPriv->modes,
-			  (pScrPriv->numModes + 1) * sizeof (RRModePtr));
+    if (num_modes)
+	newModes = xrealloc (modes, (num_modes + 1) * sizeof (RRModePtr));
     else
-	modes = xalloc (sizeof (RRModePtr));
+	newModes = xalloc (sizeof (RRModePtr));
 
-    if (!modes)
+    if (!newModes)
     {
 	xfree (mode);
 	return NULL;
@@ -89,37 +91,64 @@ RRModeGet (ScreenPtr	pScreen,
     mode->mode.id = FakeClientID(0);
     if (!AddResource (mode->mode.id, RRModeType, (pointer) mode))
 	return NULL;
+    modes = newModes;
+    modes[num_modes++] = mode;
+    
+    /*
+     * give the caller a reference to this mode
+     */
     ++mode->refcnt;
-    pScrPriv->modes = modes;
-    pScrPriv->modes[pScrPriv->numModes++] = mode;
-    pScrPriv->changed = TRUE;
     return mode;
 }
 
+RRModePtr *
+RRModesForScreen (ScreenPtr pScreen, int *num_ret)
+{
+    rrScrPriv(pScreen);
+    int	o;
+    RRModePtr	*screen_modes;
+    int		num_screen_modes = 0;
+
+    screen_modes = xalloc ((num_modes ? num_modes : 1) * sizeof (RRModePtr));
+    
+    for (o = 0; o < pScrPriv->numOutputs; o++)
+    {
+	RROutputPtr	output = pScrPriv->outputs[o];
+	int		m, n;
+
+	for (m = 0; m < output->numModes; m++)
+	{
+	    RRModePtr	mode = output->modes[m];
+	    for (n = 0; n < num_screen_modes; n++)
+		if (screen_modes[n] == mode)
+		    break;
+	    if (n == num_screen_modes)
+		screen_modes[num_screen_modes++] = mode;
+	}
+    }
+    *num_ret = num_screen_modes;
+    return screen_modes;
+}
+
 void
 RRModeDestroy (RRModePtr mode)
 {
-    ScreenPtr	    pScreen;
-    rrScrPrivPtr    pScrPriv;
     int	m;
     
     if (--mode->refcnt > 0)
 	return;
-    pScreen = mode->screen;
-    pScrPriv = rrGetScrPriv (pScreen);
-    for (m = 0; m < pScrPriv->numModes; m++)
+    for (m = 0; m < num_modes; m++)
     {
-	if (pScrPriv->modes[m] == mode)
+	if (modes[m] == mode)
 	{
-	    memmove (pScrPriv->modes + m, pScrPriv->modes + m + 1,
-		     (pScrPriv->numModes - m - 1) * sizeof (RRModePtr));
-	    pScrPriv->numModes--;
-	    if (!pScrPriv->numModes)
+	    memmove (modes + m, modes + m + 1,
+		     (num_modes - m - 1) * sizeof (RRModePtr));
+	    num_modes--;
+	    if (!num_modes)
 	    {
-		xfree (pScrPriv->modes);
-		pScrPriv->modes = NULL;
+		xfree (modes);
+		modes = NULL;
 	    }
-	    pScrPriv->changed = TRUE;
 	    break;
 	}
     }
@@ -137,6 +166,8 @@ RRModeDestroyResource (pointer value, XI
 Bool
 RRModeInit (void)
 {
+    assert (num_modes == 0);
+    assert (modes == NULL);
     RRModeType = CreateNewResourceType (RRModeDestroyResource);
     if (!RRModeType)
 	return FALSE;
@@ -146,26 +177,6 @@ RRModeInit (void)
     return TRUE;
 }
 
-void
-RRModePruneUnused (ScreenPtr pScreen)
-{
-    rrScrPriv (pScreen);
-    RRModePtr	*unused, mode;
-    int		m;
-    int		num = pScrPriv->numModes;
-
-    unused = xalloc (num * sizeof (RRModePtr));
-    if (!unused)
-	return;
-    memcpy (unused, pScrPriv->modes, num * sizeof (RRModePtr));
-    for (m = 0; m < num; m++) {
-	mode = unused[m];
-	if (mode->refcnt == 1 && !mode->userDefined)
-	    FreeResource (mode->mode.id, 0);
-    }
-    xfree (unused);
-}
-
 int
 ProcRRCreateMode (ClientPtr client)
 {
@@ -205,4 +216,3 @@ ProcRRDeleteOutputMode (ClientPtr client
     (void) stuff;
     return BadImplementation; 
 }
-
diff --git a/randr/rroutput.c b/randr/rroutput.c
index 1f6f330..1b0ecab 100644
--- a/randr/rroutput.c
+++ b/randr/rroutput.c
@@ -42,30 +42,17 @@ RROutputChanged (RROutputPtr output)
  */
 
 RROutputPtr
-RROutputCreate (ScreenPtr   pScreen,
-		const char  *name,
+RROutputCreate (const char  *name,
 		int	    nameLength,
 		void	    *devPrivate)
 {
-    rrScrPriv (pScreen);
     RROutputPtr	output;
-    RROutputPtr	*outputs;
 
     output = xalloc (sizeof (RROutputRec) + nameLength + 1);
     if (!output)
 	return NULL;
-    if (pScrPriv->numOutputs)
-	outputs = xrealloc (pScrPriv->outputs, 
-			    (pScrPriv->numOutputs + 1) * sizeof (RROutputPtr));
-    else
-	outputs = xalloc (sizeof (RROutputPtr));
-    if (!outputs)
-    {
-	xfree (output);
-	return NULL;
-    }
     output->id = FakeClientID (0);
-    output->pScreen = pScreen;
+    output->pScreen = NULL;
     output->name = (char *) (output + 1);
     output->nameLength = nameLength;
     memcpy (output->name, name, nameLength);
@@ -91,12 +78,35 @@ RROutputCreate (ScreenPtr   pScreen,
     if (!AddResource (output->id, RROutputType, (pointer) output))
 	return NULL;
 
+    return output;
+}
+
+/*
+ * Attach an Output to a screen. This is done as a separate step
+ * so that an xf86-based driver can create Outputs in PreInit
+ * before the Screen has been created
+ */
+
+Bool
+RROutputAttachScreen (RROutputPtr output, ScreenPtr pScreen)
+{
+    rrScrPriv (pScreen);
+    RROutputPtr	*outputs;
+    
+    if (pScrPriv->numOutputs)
+	outputs = xrealloc (pScrPriv->outputs, 
+			    (pScrPriv->numOutputs + 1) * sizeof (RROutputPtr));
+    else
+	outputs = xalloc (sizeof (RROutputPtr));
+    if (!outputs)
+	return FALSE;
+    output->pScreen = pScreen;
     pScrPriv->outputs = outputs;
     pScrPriv->outputs[pScrPriv->numOutputs++] = output;
     RROutputChanged (output);
-    return output;
+    return TRUE;
 }
-
+		      
 /*
  * Notify extension that output parameters have been changed
  */
diff --git a/randr/rrscreen.c b/randr/rrscreen.c
index 705e7d7..d47e9d6 100644
--- a/randr/rrscreen.c
+++ b/randr/rrscreen.c
@@ -360,6 +360,13 @@ ProcRRGetScreenResources (ClientPtr clie
     }
     else
     {
+	RRModePtr   *modes;
+	int	    num_modes;
+
+	modes = RRModesForScreen (pScreen, &num_modes);
+	if (!modes)
+	    return BadAlloc;
+	
 	rep.type = X_Reply;
 	rep.sequenceNumber = client->sequence;
 	rep.length = 0;
@@ -367,15 +374,15 @@ ProcRRGetScreenResources (ClientPtr clie
 	rep.configTimestamp = pScrPriv->lastConfigTime.milliseconds;
 	rep.nCrtcs = pScrPriv->numCrtcs;
 	rep.nOutputs = pScrPriv->numOutputs;
-	rep.nModes = pScrPriv->numModes;;
+	rep.nModes = num_modes;
 	rep.nbytesNames = 0;
 
-	for (i = 0; i < pScrPriv->numModes; i++)
-	    rep.nbytesNames += pScrPriv->modes[i]->mode.nameLength;
+	for (i = 0; i < num_modes; i++)
+	    rep.nbytesNames += modes[i]->mode.nameLength;
 
 	rep.length = (pScrPriv->numCrtcs + 
 		      pScrPriv->numOutputs + 
-		      pScrPriv->numModes * (SIZEOF(xRRModeInfo) >> 2) +
+		      num_modes * (SIZEOF(xRRModeInfo) >> 2) +
 		      ((rep.nbytesNames + 3) >> 2));
 	
 	extraLen = rep.length << 2;
@@ -383,7 +390,10 @@ ProcRRGetScreenResources (ClientPtr clie
 	{
 	    extra = xalloc (extraLen);
 	    if (!extra)
+	    {
+		xfree (modes);
 		return BadAlloc;
+	    }
 	}
 	else
 	    extra = NULL;
@@ -391,7 +401,7 @@ ProcRRGetScreenResources (ClientPtr clie
 	crtcs = (RRCrtc *) extra;
 	outputs = (RROutput *) (crtcs + pScrPriv->numCrtcs);
 	modeinfos = (xRRModeInfo *) (outputs + pScrPriv->numOutputs);
-	names = (CARD8 *) (modeinfos + pScrPriv->numModes);
+	names = (CARD8 *) (modeinfos + num_modes);
 	
 	for (i = 0; i < pScrPriv->numCrtcs; i++)
 	{
@@ -407,9 +417,10 @@ ProcRRGetScreenResources (ClientPtr clie
 		swapl (&outputs[i], n);
 	}
 	
-	for (i = 0; i < pScrPriv->numModes; i++)
+	for (i = 0; i < num_modes; i++)
 	{
-	    modeinfos[i] = pScrPriv->modes[i]->mode;
+	    RRModePtr	mode = modes[i];
+	    modeinfos[i] = mode->mode;
 	    if (client->swapped)
 	    {
 		swapl (&modeinfos[i].id, n);
@@ -426,10 +437,11 @@ ProcRRGetScreenResources (ClientPtr clie
 		swaps (&modeinfos[i].nameLength, n);
 		swapl (&modeinfos[i].modeFlags, n);
 	    }
-	    memcpy (names, pScrPriv->modes[i]->name, 
-		    pScrPriv->modes[i]->mode.nameLength);
-	    names += pScrPriv->modes[i]->mode.nameLength;
+	    memcpy (names, mode->name, 
+		    mode->mode.nameLength);
+	    names += mode->mode.nameLength;
 	}
+    	xfree (modes);
 	assert (((((char *) names - (char *) extra) + 3) >> 2) == rep.length);
     }
     
diff-tree fd91630b73100e9d77ccb492c52807448bc772a5 (from 0409e1627a167db2efc1355f292d3c02a6989ffc)
Author: Dave Airlie <airlied at linux.ie>
Date:   Thu Nov 9 09:30:33 2006 +1100

    make X server use system libdrm - this requires libdrm >= 2.3.0
    
    This patch blacklists the load "drm" line, moves some functions in dri module
    links dri module against libdrm, and removes the X copy of libdrm

diff --git a/configure.ac b/configure.ac
index 3148403..0977ee3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -654,10 +654,11 @@ AM_CONDITIONAL(DRI, test "x$DRI" = xyes)
 if test "x$DRI" = xyes; then
 	AC_DEFINE(XF86DRI, 1, [Build DRI extension])
 	PKG_CHECK_MODULES([DRIPROTO], [xf86driproto])
-	PKG_CHECK_MODULES([LIBDRM], [libdrm])
+	PKG_CHECK_MODULES([LIBDRM], [libdrm >= 2.3.0])
 	PKG_CHECK_MODULES([GL], [glproto >= 1.4.1])
 	AC_SUBST(DRIPROTO_CFLAGS)
 	AC_SUBST(LIBDRM_CFLAGS)
+	AC_SUBST(LIBDRM_LIBS)
 	AC_SUBST(GL_CFLAGS)
 fi
 
@@ -1840,7 +1841,6 @@ hw/xfree86/loader/Makefile
 hw/xfree86/os-support/Makefile
 hw/xfree86/os-support/bsd/Makefile
 hw/xfree86/os-support/bus/Makefile
-hw/xfree86/os-support/drm/Makefile
 hw/xfree86/os-support/hurd/Makefile
 hw/xfree86/os-support/misc/Makefile
 hw/xfree86/os-support/linux/Makefile
diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c
index 57f929b..ffdca12 100644
--- a/hw/xfree86/common/xf86Config.c
+++ b/hw/xfree86/common/xf86Config.c
@@ -251,7 +251,7 @@ xf86ModulelistFromConfig(pointer **optli
 {
     int count = 0, i = 0;
     char **modulearray;
-    char *ignore[] = { "GLcore", "speedo", "bitmap", NULL };
+    char *ignore[] = { "GLcore", "speedo", "bitmap", "drm", NULL };
     pointer *optarray;
     XF86LoadPtr modp;
     
diff --git a/hw/xfree86/dri/Makefile.am b/hw/xfree86/dri/Makefile.am
index e711846..4def387 100644
--- a/hw/xfree86/dri/Makefile.am
+++ b/hw/xfree86/dri/Makefile.am
@@ -7,13 +7,10 @@ libdri_la_CFLAGS = -I$(top_srcdir)/hw/xf
                    -I$(top_builddir)/GL/include \
 		   -I at MESA_SOURCE@/include \
                    -DHAVE_XORG_CONFIG_H \
-		 \
-		 \
- \
                    @DRIPROTO_CFLAGS@ \
                    @LIBDRM_CFLAGS@ \
                    @GL_CFLAGS@
-libdri_la_LDFLAGS = -module -avoid-version
+libdri_la_LDFLAGS = -module -avoid-version @LIBDRM_LIBS@
 libdri_ladir = $(moduledir)/extensions
 libdri_la_SOURCES = \
 	dri.c \
diff --git a/hw/xfree86/dri/dri.c b/hw/xfree86/dri/dri.c
index 9e52e61..fbb24e4 100644
--- a/hw/xfree86/dri/dri.c
+++ b/hw/xfree86/dri/dri.c
@@ -42,11 +42,13 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN
 #include <unistd.h>
 #include <string.h>
 #include <stdio.h>
+#include <sys/ioctl.h>
 
 #define NEED_REPLIES
 #define NEED_EVENTS
 #include <X11/X.h>
 #include <X11/Xproto.h>
+#include "xf86drm.h"
 #include "misc.h"
 #include "dixstruct.h"
 #include "extnsionst.h"
@@ -67,6 +69,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN
 #include "glxserver.h"
 #include "mi.h"
 #include "mipointer.h"
+#include "xf86_OSproc.h"
 
 #if !defined(PANORAMIX)
 extern Bool noPanoramiXExtension;
@@ -104,6 +107,7 @@ DRIDrvMsg(int scrnIndex, MessageType typ
     va_end(ap);
 }
 
+
 Bool
 DRIScreenInit(ScreenPtr pScreen, DRIInfoPtr pDRIInfo, int *pDRMFD)
 {
@@ -571,6 +575,26 @@ DRICloseScreen(ScreenPtr pScreen)
     }
 }
 
+#define DRM_MSG_VERBOSITY 3
+
+static int dri_drm_debug_print(const char *format, va_list ap)
+{
+  xf86VDrvMsgVerb(-1, X_NONE, DRM_MSG_VERBOSITY, format, ap);
+  return 0;
+}
+
+static void dri_drm_get_perms(gid_t *group, mode_t *mode)
+{
+  *group = xf86ConfigDRI.group;
+  *mode = xf86ConfigDRI.mode;
+}
+
+static drmServerInfo DRIDRMServerInfo =  {
+  dri_drm_debug_print,
+  xf86LoadKernelModule,
+  dri_drm_get_perms,
+};
+
 Bool
 DRIExtensionInit(void)
 {
@@ -598,6 +622,8 @@ DRIExtensionInit(void)
 	    return FALSE;
     }
 
+    drmSetServerInfo(&DRIDRMServerInfo);
+
     RegisterBlockAndWakeupHandlers(DRIBlockHandler, DRIWakeupHandler, NULL);
 
     return TRUE;
@@ -2093,3 +2119,71 @@ DRICreatePCIBusID(pciVideoPtr PciInfo)
 	PciInfo->device, PciInfo->func);
     return busID;
 }
+
+static void drmSIGIOHandler(int interrupt, void *closure)
+{
+    unsigned long key;
+    void          *value;
+    ssize_t       count;
+    drm_ctx_t     ctx;
+    typedef void  (*_drmCallback)(int, void *, void *);
+    char          buf[256];
+    drm_context_t    old;
+    drm_context_t    new;
+    void          *oldctx;
+    void          *newctx;
+    char          *pt;
+    drmHashEntry  *entry;
+    void *hash_table;
+
+    hash_table = drmGetHashTable();
+
+    if (!hash_table) return;
+    if (drmHashFirst(hash_table, &key, &value)) {
+	entry = value;
+	do {
+#if 0
+	    fprintf(stderr, "Trying %d\n", entry->fd);
+#endif
+	    if ((count = read(entry->fd, buf, sizeof(buf))) > 0) {
+		buf[count] = '\0';
+#if 0
+		fprintf(stderr, "Got %s\n", buf);
+#endif
+
+		for (pt = buf; *pt != ' '; ++pt); /* Find first space */
+		++pt;
+		old    = strtol(pt, &pt, 0);
+		new    = strtol(pt, NULL, 0);
+		oldctx = drmGetContextTag(entry->fd, old);
+		newctx = drmGetContextTag(entry->fd, new);
+#if 0
+		fprintf(stderr, "%d %d %p %p\n", old, new, oldctx, newctx);
+#endif
+		((_drmCallback)entry->f)(entry->fd, oldctx, newctx);
+		ctx.handle = new;
+		ioctl(entry->fd, DRM_IOCTL_NEW_CTX, &ctx);
+	    }
+	} while (drmHashNext(hash_table, &key, &value));
+    }
+}
+
+
+int drmInstallSIGIOHandler(int fd, void (*f)(int, void *, void *))
+{
+    drmHashEntry     *entry;
+
+    entry     = drmGetEntry(fd);
+    entry->f  = f;
+
+    return xf86InstallSIGIOHandler(fd, drmSIGIOHandler, 0);
+}
+
+int drmRemoveSIGIOHandler(int fd)
+{
+    drmHashEntry     *entry = drmGetEntry(fd);
+
+    entry->f = NULL;
+
+    return xf86RemoveSIGIOHandler(fd);
+}
diff --git a/hw/xfree86/dri/dri.h b/hw/xfree86/dri/dri.h
index b49c426..dca0edd 100644
--- a/hw/xfree86/dri/dri.h
+++ b/hw/xfree86/dri/dri.h
@@ -339,6 +339,8 @@ extern void DRIMoveBuffersHelper(ScreenP
 
 extern char *DRICreatePCIBusID(pciVideoPtr PciInfo);
 
+extern int drmInstallSIGIOHandler(int fd, void (*f)(int, void *, void *));
+extern int drmRemoveSIGIOHandler(int fd);
 #define _DRI_H_
 
 #endif
diff --git a/hw/xfree86/dri/drimodule.c b/hw/xfree86/dri/drimodule.c
index 331de82..b39c22e 100644
--- a/hw/xfree86/dri/drimodule.c
+++ b/hw/xfree86/dri/drimodule.c
@@ -74,23 +74,14 @@ static pointer
 driSetup(pointer module, pointer opts, int *errmaj, int *errmin)
 {
     static Bool setupDone = FALSE;
-    pointer drm = NULL;
 
     if (!setupDone) {
 	setupDone = TRUE;
-    
-    	drm = 
-	   LoadSubModule(module, "drm", NULL, NULL, NULL, NULL, errmaj, errmin);
-    
-	if (!drm) {
-	    if (errmaj) *errmaj = LDR_NOSUBENT;
-	} else {
-	    LoadExtension(&XF86DRIExt, FALSE);
-	}
+	LoadExtension(&XF86DRIExt, FALSE);
     } else {
 	if (errmaj) *errmaj = LDR_ONCEONLY;
     }
     /* Need a non-NULL return value to indicate success */
-    return drm;
+    return 1;
 }
 
diff --git a/hw/xfree86/os-support/Makefile.am b/hw/xfree86/os-support/Makefile.am
index b07e3c9..f9a888e 100644
--- a/hw/xfree86/os-support/Makefile.am
+++ b/hw/xfree86/os-support/Makefile.am
@@ -1,14 +1,10 @@
-if DRI
-DRI_SUBDIRS=drm
-endif
-
 SUBDIRS = bus @XORG_OS_SUBDIR@ misc $(DRI_SUBDIRS)
 DIST_SUBDIRS = bsd bus drm misc linux lynxos solaris sysv sco usl hurd
 
 sdk_HEADERS = xf86_OSproc.h xf86_OSlib.h xf86_ansic.h xf86_libc.h \
               assyntax.h xf86OSmouse.h
 
-EXTRA_DIST = int10Defines.h xf86OSpriv.h README.OS-lib xf86drm.h
+EXTRA_DIST = int10Defines.h xf86OSpriv.h README.OS-lib
 
 # to get the grouping semantics right, you have to glom these three together
 # as one library, otherwise libtool will actively defeat your attempts to
diff --git a/hw/xfree86/os-support/drm/Makefile.am b/hw/xfree86/os-support/drm/Makefile.am
deleted file mode 100644
index 5389325..0000000
--- a/hw/xfree86/os-support/drm/Makefile.am
+++ /dev/null
@@ -1,19 +0,0 @@
-libdrm_la_LTLIBRARIES = libdrm.la
-libdrm_la_CFLAGS = -I$(top_srcdir)/hw/xfree86/common \
-                   -I$(top_srcdir)/hw/xfree86/dri \
-                   -I$(top_srcdir)/hw/xfree86/os-support \
-                   -I$(top_srcdir)/hw/xfree86/os-support/bus \
-                   -I$(top_srcdir)/hw/xfree86/os-suport/shared/drm/kernel \
-                   -I$(top_srcdir)/GL/glx \
-                   -I$(top_srcdir)/GL/include \
-                   -DHAVE_XORG_CONFIG_H \
-                   @LIBDRM_CFLAGS@
-
-libdrm_la_LDFLAGS = -module -avoid-version
-libdrm_ladir = $(moduledir)/@XORG_OS@
-libdrm_la_SOURCES = \
-	xf86drm.c \
-	xf86drmHash.c \
-	xf86drmRandom.c \
-	xf86drmSL.c \
-	drmmodule.c
diff --git a/hw/xfree86/os-support/drm/drmmodule.c b/hw/xfree86/os-support/drm/drmmodule.c
deleted file mode 100644
index 8d2b4bc..0000000
--- a/hw/xfree86/os-support/drm/drmmodule.c
+++ /dev/null
@@ -1,57 +0,0 @@
-/* drmmodule.c -- Module initialization
- * Created: Fri Jun  4 09:05:48 1999 by faith at precisioninsight.com
- *
- * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
- * 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
- * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- * 
- * Authors: Rickard E. (Rik) Faith <faith at valinux.com>
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "xf86Module.h"
-
-static MODULESETUPPROTO(drmSetup);
-
-static XF86ModuleVersionInfo VersRec =
-{
-        "drm",
-        MODULEVENDORSTRING,
-        MODINFOSTRING1,
-        MODINFOSTRING2,
-        XORG_VERSION_CURRENT,
-        1, 0, 0,
-        ABI_CLASS_EXTENSION,
-        ABI_EXTENSION_VERSION,
-        MOD_CLASS_NONE,
-        {0,0,0,0}
-};
-
-_X_EXPORT XF86ModuleData drmModuleData = { &VersRec, drmSetup, NULL };
-
-static pointer
-drmSetup(pointer module, pointer opts, int *errmaj, int *errmin)
-{
-    return (void *)1;
-}
diff --git a/hw/xfree86/os-support/drm/xf86drm.c b/hw/xfree86/os-support/drm/xf86drm.c
deleted file mode 100644
index e990e28..0000000
--- a/hw/xfree86/os-support/drm/xf86drm.c
+++ /dev/null
@@ -1,3262 +0,0 @@
-/**
- * \file xf86drm.c 
- * User-level interface to DRM device
- *
- * \author Rickard E. (Rik) Faith <faith at valinux.com>
- * \author Kevin E. Martin <martin at valinux.com>
- */
-
-/*
- * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
- * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
- * 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
- * PRECISION INSIGHT AND/OR ITS SUPPLIERS 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_XORG_CONFIG_H
-#include <libdrm-config.h>
-#include <xorg-config.h>
-#endif
-
-#include "xf86.h"
-#include "xf86_OSproc.h"
-#define _DRM_MALLOC xalloc
-#define _DRM_FREE   xfree
-
-#include "drm.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <ctype.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <signal.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#define stat_t struct stat
-#include <sys/ioctl.h>
-#include <sys/mman.h>
-#include <sys/time.h>
-#include <stdarg.h>
-
-/* No longer needed with CVS kernel modules on alpha 
-#if defined(__alpha__) && defined(__linux__)
-extern unsigned long _bus_base(void);
-#define BUS_BASE _bus_base()
-#endif
-*/
-
-/* Not all systems have MAP_FAILED defined */
-#ifndef MAP_FAILED
-#define MAP_FAILED ((void *)-1)
-#endif
-
-#include "xf86drm.h"
-
-#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
-#define DRM_MAJOR 145
-#endif
-
-#ifdef __NetBSD__
-#define DRM_MAJOR 34
-#endif
-
-# ifdef __OpenBSD__
-#  define DRM_MAJOR 81
-# endif
-
-#ifndef DRM_MAJOR
-#define DRM_MAJOR 226		/* Linux */
-#endif
-
-#ifndef DRM_MAX_MINOR
-#define DRM_MAX_MINOR 16
-#endif
-
-#ifndef makedev
-				/* This definition needs to be changed on
-                                   some systems if dev_t is a structure.
-                                   If there is a header file we can get it
-                                   from, there would be best. */
-#define makedev(x,y)    ((dev_t)(((x) << 8) | (y)))
-#endif
-
-#define DRM_MSG_VERBOSITY 3
-
-/**
- * Output a message to stderr.
- *
- * \param format printf() like format string.
- *
- * \internal
- * This function is a wrapper around vfprintf().
- */
-static void
-drmMsg(const char *format, ...)
-{
-    va_list	ap;
-
-    va_start(ap, format);
-    xf86VDrvMsgVerb(-1, X_NONE, DRM_MSG_VERBOSITY, format, ap);
-    va_end(ap);
-}
-
-static void *drmHashTable = NULL; /* Context switch callbacks */
-
-typedef struct drmHashEntry {
-    int      fd;
-    void     (*f)(int, void *, void *);
-    void     *tagTable;
-} drmHashEntry;
-
-void *drmMalloc(int size)
-{
-    void *pt;
-    if ((pt = _DRM_MALLOC(size))) memset(pt, 0, size);
-    return pt;
-}
-
-void drmFree(void *pt)
-{
-    if (pt) _DRM_FREE(pt);
-}
-
-/* drmStrdup can't use strdup(3), since it doesn't call _DRM_MALLOC... */
-static char *drmStrdup(const char *s)
-{
-    char *retval = NULL;
-
-    if (s) {
-	retval = _DRM_MALLOC(strlen(s)+1);
-	strcpy(retval, s);
-    }
-    return retval;
-}
-
-
-static unsigned long drmGetKeyFromFd(int fd)
-{
-    stat_t     st;
-
-    st.st_rdev = 0;
-    fstat(fd, &st);
-    return st.st_rdev;
-}
-
-static drmHashEntry *drmGetEntry(int fd)
-{
-    unsigned long key = drmGetKeyFromFd(fd);
-    void          *value;
-    drmHashEntry  *entry;
-
-    if (!drmHashTable) drmHashTable = drmHashCreate();
-
-    if (drmHashLookup(drmHashTable, key, &value)) {
-	entry           = drmMalloc(sizeof(*entry));
-	entry->fd       = fd;
-	entry->f        = NULL;
-	entry->tagTable = drmHashCreate();
-	drmHashInsert(drmHashTable, key, entry);
-    } else {
-	entry = value;
-    }
-    return entry;
-}
-
-/**
- * Compare two busid strings
- *
- * \param first
- * \param second
- *
- * \return 1 if matched.
- *
- * \internal
- * This function compares two bus ID strings.  It understands the older
- * PCI:b:d:f format and the newer pci:oooo:bb:dd.f format.  In the format, o is
- * domain, b is bus, d is device, f is function.
- */
-static int drmMatchBusID(const char *id1, const char *id2)
-{
-    /* First, check if the IDs are exactly the same */
-    if (strcasecmp(id1, id2) == 0)
-	return 1;
-
-    /* Try to match old/new-style PCI bus IDs. */
-    if (strncasecmp(id1, "pci", 3) == 0) {
-	int o1, b1, d1, f1;
-	int o2, b2, d2, f2;
-	int ret;
-
-	ret = sscanf(id1, "pci:%04x:%02x:%02x.%d", &o1, &b1, &d1, &f1);
-	if (ret != 4) {
-	    o1 = 0;
-	    ret = sscanf(id1, "PCI:%d:%d:%d", &b1, &d1, &f1);
-	    if (ret != 3)
-		return 0;
-	}
-
-	ret = sscanf(id2, "pci:%04x:%02x:%02x.%d", &o2, &b2, &d2, &f2);
-	if (ret != 4) {
-	    o2 = 0;
-	    ret = sscanf(id2, "PCI:%d:%d:%d", &b2, &d2, &f2);
-	    if (ret != 3)
-		return 0;
-	}
-
-	if ((o1 != o2) || (b1 != b2) || (d1 != d2) || (f1 != f2))
-	    return 0;
-	else
-	    return 1;
-    }
-    return 0;
-}
-
-/**
- * Open the DRM device, creating it if necessary.
- *
- * \param dev major and minor numbers of the device.
- * \param minor minor number of the device.
- * 
- * \return a file descriptor on success, or a negative value on error.
- *
- * \internal
- * Assembles the device name from \p minor and opens it, creating the device
- * special file node with the major and minor numbers specified by \p dev and
- * parent directory if necessary and was called by root.
- */
-static int drmOpenDevice(long dev, int minor)
-{
-    stat_t          st;
-    char            buf[64];
-    int             fd;
-    mode_t          devmode = DRM_DEV_MODE;
-    int             isroot  = !geteuid();
-    uid_t           user    = DRM_DEV_UID;
-    gid_t           group   = DRM_DEV_GID;
-
-    sprintf(buf, DRM_DEV_NAME, DRM_DIR_NAME, minor);
-    drmMsg("drmOpenDevice: node name is %s\n", buf);
-
-    devmode  = xf86ConfigDRI.mode ? xf86ConfigDRI.mode : DRM_DEV_MODE;
-    devmode &= ~(S_IXUSR|S_IXGRP|S_IXOTH);
-    group = (xf86ConfigDRI.group >= 0) ? xf86ConfigDRI.group : DRM_DEV_GID;
-
-    if (stat(DRM_DIR_NAME, &st)) {
-	if (!isroot) return DRM_ERR_NOT_ROOT;
-	mkdir(DRM_DIR_NAME, DRM_DEV_DIRMODE);
-	chown(DRM_DIR_NAME, 0, 0); /* root:root */
-	chmod(DRM_DIR_NAME, DRM_DEV_DIRMODE);
-    }
-
-    /* Check if the device node exists and create it if necessary. */
-    if (stat(buf, &st)) {
-	if (!isroot) return DRM_ERR_NOT_ROOT;
-	remove(buf);
-	mknod(buf, S_IFCHR | devmode, dev);
-    }
-    chown(buf, user, group);
-    chmod(buf, devmode);
-
-    fd = open(buf, O_RDWR, 0);
-    drmMsg("drmOpenDevice: open result is %d, (%s)\n",
-		fd, fd < 0 ? strerror(errno) : "OK");
-    if (fd >= 0) return fd;
-
-    /* Check if the device node is not what we expect it to be, and recreate it
-     * and try again if so.
-     */
-    if (st.st_rdev != dev) {
-	if (!isroot) return DRM_ERR_NOT_ROOT;
-	remove(buf);
-	mknod(buf, S_IFCHR | devmode, dev);
-	chown(buf, user, group);
-	chmod(buf, devmode);
-    }
-    fd = open(buf, O_RDWR, 0);
-    drmMsg("drmOpenDevice: open result is %d, (%s)\n",
-		fd, fd < 0 ? strerror(errno) : "OK");
-    if (fd >= 0) return fd;
-
-    drmMsg("drmOpenDevice: Open failed\n");
-    remove(buf);
-    return -errno;
-}
-
-
-/**
- * Open the DRM device
- *
- * \param minor device minor number.
- * \param create allow to create the device if set.
- *
- * \return a file descriptor on success, or a negative value on error.
- * 
- * \internal
- * Calls drmOpenDevice() if \p create is set, otherwise assembles the device
- * name from \p minor and opens it.
- */
-static int drmOpenMinor(int minor, int create)
-{
-    int  fd;
-    char buf[64];
-    
-    if (create) return drmOpenDevice(makedev(DRM_MAJOR, minor), minor);
-    
-    sprintf(buf, DRM_DEV_NAME, DRM_DIR_NAME, minor);
-    if ((fd = open(buf, O_RDWR, 0)) >= 0) return fd;
-    return -errno;
-}
-
-
-/**
- * Determine whether the DRM kernel driver has been loaded.
- * 
- * \return 1 if the DRM driver is loaded, 0 otherwise.
- *
- * \internal 
- * Determine the presence of the kernel driver by attempting to open the 0
- * minor and get version information.  For backward compatibility with older
- * Linux implementations, /proc/dri is also checked.
- */
-int drmAvailable(void)
-{
-    drmVersionPtr version;
-    int           retval = 0;
-    int           fd;
-
-    if ((fd = drmOpenMinor(0, 1)) < 0) {
-#ifdef __linux__
-				/* Try proc for backward Linux compatibility */
-	if (!access("/proc/dri/0", R_OK)) return 1;
-#endif
-	return 0;
-    }
-    
-    if ((version = drmGetVersion(fd))) {
-	retval = 1;
-	drmFreeVersion(version);
-    }
-    close(fd);
-
-    return retval;
-}
-
-
-/**
- * Open the device by bus ID.
- *
- * \param busid bus ID.
- *
- * \return a file descriptor on success, or a negative value on error.
- *
- * \internal
- * This function attempts to open every possible minor (up to DRM_MAX_MINOR),
- * comparing the device bus ID with the one supplied.
- *
- * \sa drmOpenMinor() and drmGetBusid().
- */
-static int drmOpenByBusid(const char *busid)
-{
-    int        i;
-    int        fd;
-    const char *buf;
-    drmSetVersion sv;
-
-    drmMsg("drmOpenByBusid: Searching for BusID %s\n", busid);
-    for (i = 0; i < DRM_MAX_MINOR; i++) {
-	fd = drmOpenMinor(i, 1);
-	drmMsg("drmOpenByBusid: drmOpenMinor returns %d\n", fd);
-	if (fd >= 0) {
-	    sv.drm_di_major = 1;
-	    sv.drm_di_minor = 1;
-	    sv.drm_dd_major = -1;	/* Don't care */
-	    drmSetInterfaceVersion(fd, &sv);
-	    buf = drmGetBusid(fd);
-	    drmMsg("drmOpenByBusid: drmGetBusid reports %s\n", buf);
-	    if (buf && drmMatchBusID(buf, busid)) {
-		drmFreeBusid(buf);
-		return fd;
-	    }
-	    if (buf) drmFreeBusid(buf);
-	    close(fd);
-	}
-    }
-    return -1;
-}
-
-
-/**
- * Open the device by name.
- *
- * \param name driver name.
- * 
- * \return a file descriptor on success, or a negative value on error.
- * 
- * \internal
- * This function opens the first minor number that matches the driver name and
- * isn't already in use.  If it's in use it then it will already have a bus ID
- * assigned.
- * 
- * \sa drmOpenMinor(), drmGetVersion() and drmGetBusid().
- */
-static int drmOpenByName(const char *name)
-{
-    int           i;
-    int           fd;
-    drmVersionPtr version;
-    char *        id;
-    
-    if (!drmAvailable()) {
-        /* try to load the kernel module now */
-        if (!xf86LoadKernelModule(name)) {
-            ErrorF("[drm] failed to load kernel module \"%s\"\n",
-		   name);
-            return -1;
-        }
-    }
-
-    /*
-     * Open the first minor number that matches the driver name and isn't
-     * already in use.  If it's in use it will have a busid assigned already.
-     */
-    for (i = 0; i < DRM_MAX_MINOR; i++) {
-	if ((fd = drmOpenMinor(i, 1)) >= 0) {
-	    if ((version = drmGetVersion(fd))) {
-		if (!strcmp(version->name, name)) {
-		    drmFreeVersion(version);
-		    id = drmGetBusid(fd);
-		    drmMsg("drmGetBusid returned '%s'\n", id ? id : "NULL");
-		    if (!id || !*id) {
-			if (id) {
-			    drmFreeBusid(id);
-			}
-			return fd;
-		    } else {
-			drmFreeBusid(id);
-		    }
-		} else {
-		    drmFreeVersion(version);
-		}
-	    }
-	    close(fd);
-	}
-    }
-
-#ifdef __linux__
-				/* Backward-compatibility /proc support */
-    for (i = 0; i < 8; i++) {
-	char proc_name[64], buf[512];
-	char *driver, *pt, *devstring;
-	int  retcode;
-	
-	sprintf(proc_name, "/proc/dri/%d/name", i);
-	if ((fd = open(proc_name, 0, 0)) >= 0) {
-	    retcode = read(fd, buf, sizeof(buf)-1);
-	    close(fd);
-	    if (retcode) {
-		buf[retcode-1] = '\0';
-		for (driver = pt = buf; *pt && *pt != ' '; ++pt)
-		    ;
-		if (*pt) {	/* Device is next */
-		    *pt = '\0';
-		    if (!strcmp(driver, name)) { /* Match */
-			for (devstring = ++pt; *pt && *pt != ' '; ++pt)
-			    ;
-			if (*pt) { /* Found busid */
-			    return drmOpenByBusid(++pt);
-			} else {	/* No busid */
-			    return drmOpenDevice(strtol(devstring, NULL, 0),i);
-			}
-		    }
-		}
-	    }
-	}
-    }
-#endif
-
-    return -1;
-}
-
-
-/**
- * Open the DRM device.
- *
- * Looks up the specified name and bus ID, and opens the device found.  The
- * entry in /dev/dri is created if necessary and if called by root.
- *
- * \param name driver name. Not referenced if bus ID is supplied.
- * \param busid bus ID. Zero if not known.
- * 
- * \return a file descriptor on success, or a negative value on error.
- * 
- * \internal
- * It calls drmOpenByBusid() if \p busid is specified or drmOpenByName()
- * otherwise.
- */
-int drmOpen(const char *name, const char *busid)
-{
-    if (!drmAvailable() && name != NULL) {
-	/* try to load the kernel */
-	if (!xf86LoadKernelModule(name)) {
-	    ErrorF("[drm] failed to load kernel module \"%s\"\n",
-	           name);
-	    return -1;
-	}
-    }
-
-    if (busid) {
-	int fd;
-
-	fd = drmOpenByBusid(busid);
-	if (fd >= 0)
-	    return fd;
-    }
-    if (name)
-	return drmOpenByName(name);
-    return -1;
-}
-
-
-/**
- * Free the version information returned by drmGetVersion().
- *
- * \param v pointer to the version information.
- *
- * \internal
- * It frees the memory pointed by \p %v as well as all the non-null strings
- * pointers in it.
- */
-void drmFreeVersion(drmVersionPtr v)
-{
-    if (!v) return;
-    if (v->name) drmFree(v->name);
-    if (v->date) drmFree(v->date);
-    if (v->desc) drmFree(v->desc);
-    drmFree(v);
-}
-
-
-/**
- * Free the non-public version information returned by the kernel.
- *
- * \param v pointer to the version information.
- *
- * \internal
- * Used by drmGetVersion() to free the memory pointed by \p %v as well as all
- * the non-null strings pointers in it.
- */
-static void drmFreeKernelVersion(drm_version_t *v)
-{
-    if (!v) return;
-    if (v->name) drmFree(v->name);
-    if (v->date) drmFree(v->date);
-    if (v->desc) drmFree(v->desc);
-    drmFree(v);
-}
-
-
-/**
- * Copy version information.
- * 
- * \param d destination pointer.
- * \param s source pointer.
- * 
- * \internal
- * Used by drmGetVersion() to translate the information returned by the ioctl
- * interface in a private structure into the public structure counterpart.
- */
-static void drmCopyVersion(drmVersionPtr d, const drm_version_t *s)
-{
-    d->version_major      = s->version_major;
-    d->version_minor      = s->version_minor;
-    d->version_patchlevel = s->version_patchlevel;
-    d->name_len           = s->name_len;
-    d->name               = drmStrdup(s->name);
-    d->date_len           = s->date_len;
-    d->date               = drmStrdup(s->date);
-    d->desc_len           = s->desc_len;
-    d->desc               = drmStrdup(s->desc);
-}
-
-
-/**
- * Query the driver version information.
- *
- * \param fd file descriptor.
- * 
- * \return pointer to a drmVersion structure which should be freed with
- * drmFreeVersion().
- * 
- * \note Similar information is available via /proc/dri.
- * 
- * \internal
- * It gets the version information via successive DRM_IOCTL_VERSION ioctls,
- * first with zeros to get the string lengths, and then the actually strings.
- * It also null-terminates them since they might not be already.
- */
-drmVersionPtr drmGetVersion(int fd)
-{
-    drmVersionPtr retval;
-    drm_version_t *version = drmMalloc(sizeof(*version));
-
-				/* First, get the lengths */
-    version->name_len    = 0;
-    version->name        = NULL;
-    version->date_len    = 0;
-    version->date        = NULL;
-    version->desc_len    = 0;
-    version->desc        = NULL;
-
-    if (ioctl(fd, DRM_IOCTL_VERSION, version)) {
-	drmFreeKernelVersion(version);
-	return NULL;
-    }
-
-				/* Now, allocate space and get the data */
-    if (version->name_len)
-	version->name    = drmMalloc(version->name_len + 1);
-    if (version->date_len)
-	version->date    = drmMalloc(version->date_len + 1);
-    if (version->desc_len)
-	version->desc    = drmMalloc(version->desc_len + 1);
-
-    if (ioctl(fd, DRM_IOCTL_VERSION, version)) {
-	drmMsg("DRM_IOCTL_VERSION: %s\n", strerror(errno));
-	drmFreeKernelVersion(version);
-	return NULL;
-    }
-
-				/* The results might not be null-terminated
-                                   strings, so terminate them. */
-
-    if (version->name_len) version->name[version->name_len] = '\0';
-    if (version->date_len) version->date[version->date_len] = '\0';
-    if (version->desc_len) version->desc[version->desc_len] = '\0';
-
-				/* Now, copy it all back into the
-                                   client-visible data structure... */
-    retval = drmMalloc(sizeof(*retval));
-    drmCopyVersion(retval, version);
-    drmFreeKernelVersion(version);
-    return retval;
-}
-
-
-/**
- * Get version information for the DRM user space library.
- * 
- * This version number is driver independent.
- * 
- * \param fd file descriptor.
- *
- * \return version information.
- * 
- * \internal
- * This function allocates and fills a drm_version structure with a hard coded
- * version number.
- */
-drmVersionPtr drmGetLibVersion(int fd)
-{
-    drm_version_t *version = drmMalloc(sizeof(*version));
-
-    /* Version history:
-     *   revision 1.0.x = original DRM interface with no drmGetLibVersion
-     *                    entry point and many drm<Device> extensions
-     *   revision 1.1.x = added drmCommand entry points for device extensions
-     *                    added drmGetLibVersion to identify libdrm.a version
-     *   revision 1.2.x = added drmSetInterfaceVersion
-     *                    modified drmOpen to handle both busid and name
-     */
-    version->version_major      = 1;
-    version->version_minor      = 2;
-    version->version_patchlevel = 0;
-
-    return (drmVersionPtr)version;
-}
-
-
-/**
- * Free the bus ID information.
- *
- * \param busid bus ID information string as given by drmGetBusid().
- *
- * \internal
- * This function is just frees the memory pointed by \p busid.
- */
-void drmFreeBusid(const char *busid)
-{
-    drmFree((void *)busid);
-}
-
-
-/**
- * Get the bus ID of the device.
- *
- * \param fd file descriptor.
- *
- * \return bus ID string.
- *
- * \internal
- * This function gets the bus ID via successive DRM_IOCTL_GET_UNIQUE ioctls to
- * get the string length and data, passing the arguments in a drm_unique
- * structure.
- */
-char *drmGetBusid(int fd)
-{
-    drm_unique_t u;
-
-    u.unique_len = 0;
-    u.unique     = NULL;
-
-    if (ioctl(fd, DRM_IOCTL_GET_UNIQUE, &u)) return NULL;
-    u.unique = drmMalloc(u.unique_len + 1);
-    if (ioctl(fd, DRM_IOCTL_GET_UNIQUE, &u)) return NULL;
-    u.unique[u.unique_len] = '\0';
-
-    return u.unique;
-}
-
-
-/**
- * Set the bus ID of the device.
- *
- * \param fd file descriptor.
- * \param busid bus ID string.
- *
- * \return zero on success, negative on failure.
- *
- * \internal
- * This function is a wrapper around the DRM_IOCTL_SET_UNIQUE ioctl, passing
- * the arguments in a drm_unique structure.
- */
-int drmSetBusid(int fd, const char *busid)
-{
-    drm_unique_t u;
-
-    u.unique     = (char *)busid;
-    u.unique_len = strlen(busid);
-
-    if (ioctl(fd, DRM_IOCTL_SET_UNIQUE, &u)) {
-	return -errno;
-    }
-    return 0;
-}
-
-int drmGetMagic(int fd, drm_magic_t * magic)
-{
-    drm_auth_t auth;
-
-    *magic = 0;
-    if (ioctl(fd, DRM_IOCTL_GET_MAGIC, &auth)) return -errno;
-    *magic = auth.magic;
-    return 0;
-}
-
-int drmAuthMagic(int fd, drm_magic_t magic)
-{
-    drm_auth_t auth;
-
-    auth.magic = magic;
-    if (ioctl(fd, DRM_IOCTL_AUTH_MAGIC, &auth)) return -errno;
-    return 0;
-}
-
-/**
- * Specifies a range of memory that is available for mapping by a
- * non-root process.
- *
- * \param fd file descriptor.
- * \param offset usually the physical address. The actual meaning depends of
- * the \p type parameter. See below.
- * \param size of the memory in bytes.
- * \param type type of the memory to be mapped.
- * \param flags combination of several flags to modify the function actions.
- * \param handle will be set to a value that may be used as the offset
- * parameter for mmap().
- * 
- * \return zero on success or a negative value on error.
- *
- * \par Mapping the frame buffer
- * For the frame buffer
- * - \p offset will be the physical address of the start of the frame buffer,
- * - \p size will be the size of the frame buffer in bytes, and
- * - \p type will be DRM_FRAME_BUFFER.
- *
- * \par
- * The area mapped will be uncached. If MTRR support is available in the
- * kernel, the frame buffer area will be set to write combining. 
- *
- * \par Mapping the MMIO register area
- * For the MMIO register area,
- * - \p offset will be the physical address of the start of the register area,
- * - \p size will be the size of the register area bytes, and
- * - \p type will be DRM_REGISTERS.
- * \par
- * The area mapped will be uncached. 
- * 
- * \par Mapping the SAREA
- * For the SAREA,
- * - \p offset will be ignored and should be set to zero,
- * - \p size will be the desired size of the SAREA in bytes,
- * - \p type will be DRM_SHM.
- * 
- * \par
- * A shared memory area of the requested size will be created and locked in
- * kernel memory. This area may be mapped into client-space by using the handle
- * returned. 
- * 
- * \note May only be called by root.
- *
- * \internal
- * This function is a wrapper around the DRM_IOCTL_ADD_MAP ioctl, passing
- * the arguments in a drm_map structure.
- */
-int drmAddMap(int fd,
-	      drm_handle_t offset,
-	      drmSize size,
-	      drmMapType type,
-	      drmMapFlags flags,
-	      drm_handle_t * handle)
-{
-    drm_map_t map;
-
-    map.offset  = offset;
-/* No longer needed with CVS kernel modules on alpha
-#ifdef __alpha__
-    if (type != DRM_SHM)
-	map.offset += BUS_BASE;
-#endif
-*/
-    map.size    = size;
-    map.handle  = 0;
-    map.type    = type;
-    map.flags   = flags;
-    if (ioctl(fd, DRM_IOCTL_ADD_MAP, &map)) return -errno;
-    if (handle) *handle = (drm_handle_t)(unsigned long)map.handle;
-    return 0;
-}
-
-int drmRmMap(int fd, drm_handle_t handle)
-{
-    drm_map_t map;
-
-    map.handle = (void *)(unsigned long)handle;
-
-    if(ioctl(fd, DRM_IOCTL_RM_MAP, &map)) return -errno;
-    return 0;
-}
-
-/**
- * Make buffers available for DMA transfers.
- * 
- * \param fd file descriptor.
- * \param count number of buffers.
- * \param size size of each buffer.
- * \param flags buffer allocation flags.
- * \param agp_offset offset in the AGP aperture 
- *
- * \return number of buffers allocated, negative on error.
- *
- * \internal
- * This function is a wrapper around DRM_IOCTL_ADD_BUFS ioctl.
- *
- * \sa drm_buf_desc.
- */
-int drmAddBufs(int fd, int count, int size, drmBufDescFlags flags,
-	       int agp_offset)
-{
-    drm_buf_desc_t request;
-
-    request.count     = count;
-    request.size      = size;
-    request.low_mark  = 0;
-    request.high_mark = 0;
-    request.flags     = flags;
-    request.agp_start = agp_offset;
-
-    if (ioctl(fd, DRM_IOCTL_ADD_BUFS, &request)) return -errno;
-    return request.count;
-}
-
-int drmMarkBufs(int fd, double low, double high)
-{
-    drm_buf_info_t info;
-    int            i;
-
-    info.count = 0;
-    info.list  = NULL;
-
-    if (ioctl(fd, DRM_IOCTL_INFO_BUFS, &info)) return -EINVAL;
-
-    if (!info.count) return -EINVAL;
-
-    if (!(info.list = drmMalloc(info.count * sizeof(*info.list))))
-	return -ENOMEM;
-
-    if (ioctl(fd, DRM_IOCTL_INFO_BUFS, &info)) {
-	int retval = -errno;
-	drmFree(info.list);
-	return retval;
-    }
-
-    for (i = 0; i < info.count; i++) {
-	info.list[i].low_mark  = low  * info.list[i].count;
-	info.list[i].high_mark = high * info.list[i].count;
-	if (ioctl(fd, DRM_IOCTL_MARK_BUFS, &info.list[i])) {
-	    int retval = -errno;
-	    drmFree(info.list);
-	    return retval;
-	}
-    }
-    drmFree(info.list);
-
-    return 0;
-}
-
-/**
- * Free buffers.
- *
- * \param fd file descriptor.
- * \param count number of buffers to free.
- * \param list list of buffers to be freed.
- *
- * \return zero on success, or a negative value on failure.
- * 
- * \note This function is primarily used for debugging.
- * 
- * \internal
- * This function is a wrapper around the DRM_IOCTL_FREE_BUFS ioctl, passing
- * the arguments in a drm_buf_free structure.
- */
-int drmFreeBufs(int fd, int count, int *list)
-{
-    drm_buf_free_t request;
-
-    request.count = count;
-    request.list  = list;
-    if (ioctl(fd, DRM_IOCTL_FREE_BUFS, &request)) return -errno;
-    return 0;
-}
-
-
-/**
- * Close the device.
- *
- * \param fd file descriptor.
- *
- * \internal
- * This function closes the file descriptor.
- */
-int drmClose(int fd)
-{
-    unsigned long key    = drmGetKeyFromFd(fd);
-    drmHashEntry  *entry = drmGetEntry(fd);
-
-    drmHashDestroy(entry->tagTable);
-    entry->fd       = 0;
-    entry->f        = NULL;
-    entry->tagTable = NULL;
-
-    drmHashDelete(drmHashTable, key);
-    drmFree(entry);
-
-    return close(fd);
-}
-
-
-/**
- * Map a region of memory.
- *
- * \param fd file descriptor.
- * \param handle handle returned by drmAddMap().
- * \param size size in bytes. Must match the size used by drmAddMap().
- * \param address will contain the user-space virtual address where the mapping
- * begins.
- *
- * \return zero on success, or a negative value on failure.
- * 
- * \internal
- * This function is a wrapper for mmap().
- */
-int drmMap(int fd,
-	   drm_handle_t handle,
-	   drmSize size,
-	   drmAddressPtr address)
-{
-    static unsigned long pagesize_mask = 0;
-
-    if (fd < 0) return -EINVAL;
-
-    if (!pagesize_mask)
-	pagesize_mask = getpagesize() - 1;
-
-    size = (size + pagesize_mask) & ~pagesize_mask;
-
-    *address = mmap(0, size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, handle);
-    if (*address == MAP_FAILED) return -errno;
-    return 0;
-}
-
-
-/**
- * Unmap mappings obtained with drmMap().
- *
- * \param address address as given by drmMap().
- * \param size size in bytes. Must match the size used by drmMap().
- * 
- * \return zero on success, or a negative value on failure.
- *
- * \internal
- * This function is a wrapper for unmap().
- */
-int drmUnmap(drmAddress address, drmSize size)
-{
-    return munmap(address, size);
-}
-
-drmBufInfoPtr drmGetBufInfo(int fd)
-{
-    drm_buf_info_t info;
-    drmBufInfoPtr  retval;
-    int            i;
-
-    info.count = 0;
-    info.list  = NULL;
-
-    if (ioctl(fd, DRM_IOCTL_INFO_BUFS, &info)) return NULL;
-
-    if (info.count) {
-	if (!(info.list = drmMalloc(info.count * sizeof(*info.list))))
-	    return NULL;
-
-	if (ioctl(fd, DRM_IOCTL_INFO_BUFS, &info)) {
-	    drmFree(info.list);
-	    return NULL;
-	}
-				/* Now, copy it all back into the
-                                   client-visible data structure... */
-	retval = drmMalloc(sizeof(*retval));
-	retval->count = info.count;
-	retval->list  = drmMalloc(info.count * sizeof(*retval->list));
-	for (i = 0; i < info.count; i++) {
-	    retval->list[i].count     = info.list[i].count;
-	    retval->list[i].size      = info.list[i].size;
-	    retval->list[i].low_mark  = info.list[i].low_mark;
-	    retval->list[i].high_mark = info.list[i].high_mark;
-	}
-	drmFree(info.list);
-	return retval;
-    }
-    return NULL;
-}
-
-/**
- * Map all DMA buffers into client-virtual space.
- *
- * \param fd file descriptor.
- *
- * \return a pointer to a ::drmBufMap structure.
- *
- * \note The client may not use these buffers until obtaining buffer indices
- * with drmDMA().
- * 
- * \internal
- * This function calls the DRM_IOCTL_MAP_BUFS ioctl and copies the returned
- * information about the buffers in a drm_buf_map structure into the
- * client-visible data structures.
- */ 
-drmBufMapPtr drmMapBufs(int fd)
-{
-    drm_buf_map_t bufs;
-    drmBufMapPtr  retval;
-    int           i;
-
-    bufs.count = 0;
-    bufs.list  = NULL;
-    bufs.virtual = NULL;
-    if (ioctl(fd, DRM_IOCTL_MAP_BUFS, &bufs)) return NULL;
-
-    if (!bufs.count) return NULL;
-
-	if (!(bufs.list = drmMalloc(bufs.count * sizeof(*bufs.list))))
-	    return NULL;
-
-	if (ioctl(fd, DRM_IOCTL_MAP_BUFS, &bufs)) {
-	    drmFree(bufs.list);
-	    return NULL;
-	}
-				/* Now, copy it all back into the
-                                   client-visible data structure... */
-	retval = drmMalloc(sizeof(*retval));
-	retval->count = bufs.count;
-	retval->list  = drmMalloc(bufs.count * sizeof(*retval->list));
-	for (i = 0; i < bufs.count; i++) {
-	    retval->list[i].idx     = bufs.list[i].idx;
-	    retval->list[i].total   = bufs.list[i].total;
-	    retval->list[i].used    = 0;
-	    retval->list[i].address = bufs.list[i].address;
-	}
-
-	drmFree(bufs.list);
-	
-	return retval;
-}
-
-
-/**
- * Unmap buffers allocated with drmMapBufs().
- *
- * \return zero on success, or negative value on failure.
- *
- * \internal
- * Calls munmap() for every buffer stored in \p bufs and frees the
- * memory allocated by drmMapBufs().
- */
-int drmUnmapBufs(drmBufMapPtr bufs)
-{
-    int i;
-
-    for (i = 0; i < bufs->count; i++) {
-	munmap(bufs->list[i].address, bufs->list[i].total);
-    }
-
-    drmFree(bufs->list);
-    drmFree(bufs);
-	
-    return 0;
-}
-
-
-#define DRM_DMA_RETRY		16
-
-/**
- * Reserve DMA buffers.
- *
- * \param fd file descriptor.
- * \param request 
- * 
- * \return zero on success, or a negative value on failure.
- *
- * \internal
- * Assemble the arguments into a drm_dma structure and keeps issuing the
- * DRM_IOCTL_DMA ioctl until success or until maximum number of retries.
- */
-int drmDMA(int fd, drmDMAReqPtr request)
-{
-    drm_dma_t dma;
-    int ret, i = 0;
-
-				/* Copy to hidden structure */
-    dma.context         = request->context;
-    dma.send_count      = request->send_count;
-    dma.send_indices    = request->send_list;
-    dma.send_sizes      = request->send_sizes;
-    dma.flags           = request->flags;
-    dma.request_count   = request->request_count;
-    dma.request_size    = request->request_size;
-    dma.request_indices = request->request_list;
-    dma.request_sizes   = request->request_sizes;
-    dma.granted_count   = 0;
-
-    do {
-	ret = ioctl( fd, DRM_IOCTL_DMA, &dma );
-    } while ( ret && errno == EAGAIN && i++ < DRM_DMA_RETRY );
-
-    if ( ret == 0 ) {
-	request->granted_count = dma.granted_count;
-	return 0;
-    } else {
-	return -errno;
-    }
-}
-
-
-/**
- * Obtain heavyweight hardware lock.
- *
- * \param fd file descriptor.
- * \param context context.
- * \param flags flags that determine the sate of the hardware when the function
- * returns.
- * 
- * \return always zero.
- * 
- * \internal
- * This function translates the arguments into a drm_lock structure and issue
- * the DRM_IOCTL_LOCK ioctl until the lock is successfully acquired.
- */
-int drmGetLock(int fd, drm_context_t context, drmLockFlags flags)
-{
-    drm_lock_t lock;
-
-    lock.context = context;
-    lock.flags   = 0;
-    if (flags & DRM_LOCK_READY)      lock.flags |= _DRM_LOCK_READY;
-    if (flags & DRM_LOCK_QUIESCENT)  lock.flags |= _DRM_LOCK_QUIESCENT;
-    if (flags & DRM_LOCK_FLUSH)      lock.flags |= _DRM_LOCK_FLUSH;
-    if (flags & DRM_LOCK_FLUSH_ALL)  lock.flags |= _DRM_LOCK_FLUSH_ALL;
-    if (flags & DRM_HALT_ALL_QUEUES) lock.flags |= _DRM_HALT_ALL_QUEUES;
-    if (flags & DRM_HALT_CUR_QUEUES) lock.flags |= _DRM_HALT_CUR_QUEUES;
-
-    while (ioctl(fd, DRM_IOCTL_LOCK, &lock))
-	;
-    return 0;
-}
-
-/**
- * Release the hardware lock.
- *
- * \param fd file descriptor.
- * \param context context.
- * 
- * \return zero on success, or a negative value on failure.
- * 
- * \internal
- * This function is a wrapper around the DRM_IOCTL_UNLOCK ioctl, passing the
- * argument in a drm_lock structure.
- */
-int drmUnlock(int fd, drm_context_t context)
-{
-    drm_lock_t lock;
-
-    lock.context = context;
-    lock.flags   = 0;
-    return ioctl(fd, DRM_IOCTL_UNLOCK, &lock);
-}
-
-drm_context_t * drmGetReservedContextList(int fd, int *count)
-{
-    drm_ctx_res_t res;
-    drm_ctx_t     *list;
-    drm_context_t * retval;
-    int           i;
-
-    res.count    = 0;
-    res.contexts = NULL;
-    if (ioctl(fd, DRM_IOCTL_RES_CTX, &res)) return NULL;
-
-    if (!res.count) return NULL;
-
-    if (!(list   = drmMalloc(res.count * sizeof(*list)))) return NULL;
-    if (!(retval = drmMalloc(res.count * sizeof(*retval)))) {
-	drmFree(list);
-	return NULL;
-    }
-
-    res.contexts = list;
-    if (ioctl(fd, DRM_IOCTL_RES_CTX, &res)) return NULL;
-
-    for (i = 0; i < res.count; i++) retval[i] = list[i].handle;
-    drmFree(list);
-
-    *count = res.count;
-    return retval;
-}
-
-void drmFreeReservedContextList(drm_context_t * pt)
-{
-    drmFree(pt);
-}
-
-/**
- * Create context.
- *
- * Used by the X server during GLXContext initialization. This causes
- * per-context kernel-level resources to be allocated.
- *
- * \param fd file descriptor.
- * \param handle is set on success. To be used by the client when requesting DMA
- * dispatch with drmDMA().
- * 
- * \return zero on success, or a negative value on failure.
- * 
- * \note May only be called by root.
- * 
- * \internal
- * This function is a wrapper around the DRM_IOCTL_ADD_CTX ioctl, passing the
- * argument in a drm_ctx structure.
- */
-int drmCreateContext(int fd, drm_context_t * handle)
-{
-    drm_ctx_t ctx;
-
-    ctx.flags = 0;	/* Modified with functions below */
-    if (ioctl(fd, DRM_IOCTL_ADD_CTX, &ctx)) return -errno;
-    *handle = ctx.handle;
-    return 0;
-}
-
-int drmSwitchToContext(int fd, drm_context_t context)
-{
-    drm_ctx_t ctx;
-
-    ctx.handle = context;
-    if (ioctl(fd, DRM_IOCTL_SWITCH_CTX, &ctx)) return -errno;
-    return 0;
-}
-
-int drmSetContextFlags(int fd, drm_context_t context, drm_context_tFlags flags)
-{
-    drm_ctx_t ctx;
-
-				/* Context preserving means that no context
-                                   switched are done between DMA buffers
-                                   from one context and the next.  This is
-                                   suitable for use in the X server (which
-                                   promises to maintain hardware context,
-                                   or in the client-side library when
-                                   buffers are swapped on behalf of two
-                                   threads. */
-    ctx.handle = context;
-    ctx.flags  = 0;
-    if (flags & DRM_CONTEXT_PRESERVED) ctx.flags |= _DRM_CONTEXT_PRESERVED;
-    if (flags & DRM_CONTEXT_2DONLY)    ctx.flags |= _DRM_CONTEXT_2DONLY;
-    if (ioctl(fd, DRM_IOCTL_MOD_CTX, &ctx)) return -errno;
-    return 0;
-}
-
-int drmGetContextFlags(int fd, drm_context_t context, drm_context_tFlagsPtr flags)
-{
-    drm_ctx_t ctx;
-
-    ctx.handle = context;
-    if (ioctl(fd, DRM_IOCTL_GET_CTX, &ctx)) return -errno;
-    *flags = 0;
-    if (ctx.flags & _DRM_CONTEXT_PRESERVED) *flags |= DRM_CONTEXT_PRESERVED;
-    if (ctx.flags & _DRM_CONTEXT_2DONLY)    *flags |= DRM_CONTEXT_2DONLY;
-    return 0;
-}
-
-/**
- * Destroy context.
- *
- * Free any kernel-level resources allocated with drmCreateContext() associated
- * with the context.
- * 
- * \param fd file descriptor.
- * \param handle handle given by drmCreateContext().
- * 
- * \return zero on success, or a negative value on failure.
- * 
- * \note May only be called by root.
- * 
- * \internal
- * This function is a wrapper around the DRM_IOCTL_RM_CTX ioctl, passing the
- * argument in a drm_ctx structure.
- */
-int drmDestroyContext(int fd, drm_context_t handle)
-{
-    drm_ctx_t ctx;
-    ctx.handle = handle;
-    if (ioctl(fd, DRM_IOCTL_RM_CTX, &ctx)) return -errno;
-    return 0;
-}
-
-int drmCreateDrawable(int fd, drm_drawable_t * handle)
-{
-    drm_draw_t draw;
-    if (ioctl(fd, DRM_IOCTL_ADD_DRAW, &draw)) return -errno;
-    *handle = draw.handle;
-    return 0;
-}
-
-int drmDestroyDrawable(int fd, drm_drawable_t handle)
-{
-    drm_draw_t draw;
-    draw.handle = handle;
-    if (ioctl(fd, DRM_IOCTL_RM_DRAW, &draw)) return -errno;
-    return 0;
-}
-
-int drmUpdateDrawableInfo(int fd, drm_drawable_t handle,
-			   drm_drawable_info_type_t type, unsigned int num,
-			   void *data)
-{
-    drm_update_draw_t update;
-
-    update.handle = handle;
-    update.type = type;
-    update.num = num;
-    update.data = (unsigned long long)(unsigned long)data;
-
-    if (ioctl(fd, DRM_IOCTL_UPDATE_DRAW, &update)) return -errno;
-
-    return 0;
-}
-
-/**
- * Acquire the AGP device.
- *
- * Must be called before any of the other AGP related calls.
- *
- * \param fd file descriptor.
- * 
- * \return zero on success, or a negative value on failure.
- * 
- * \internal
- * This function is a wrapper around the DRM_IOCTL_AGP_ACQUIRE ioctl.
- */
-int drmAgpAcquire(int fd)
-{
-    if (ioctl(fd, DRM_IOCTL_AGP_ACQUIRE, NULL)) return -errno;
-    return 0;
-}
-
-
-/**
- * Release the AGP device.
- *
- * \param fd file descriptor.
- * 
- * \return zero on success, or a negative value on failure.
- * 
- * \internal
- * This function is a wrapper around the DRM_IOCTL_AGP_RELEASE ioctl.
- */
-int drmAgpRelease(int fd)
-{
-    if (ioctl(fd, DRM_IOCTL_AGP_RELEASE, NULL)) return -errno;
-    return 0;
-}
-
-
-/**
- * Set the AGP mode.
- *
- * \param fd file descriptor.
- * \param mode AGP mode.
- * 
- * \return zero on success, or a negative value on failure.
- * 
- * \internal
- * This function is a wrapper around the DRM_IOCTL_AGP_ENABLE ioctl, passing the
- * argument in a drm_agp_mode structure.
- */
-int drmAgpEnable(int fd, unsigned long mode)
-{
-    drm_agp_mode_t m;
-
-    m.mode = mode;
-    if (ioctl(fd, DRM_IOCTL_AGP_ENABLE, &m)) return -errno;
-    return 0;
-}
-
-
-/**
- * Allocate a chunk of AGP memory.
- *
- * \param fd file descriptor.
- * \param size requested memory size in bytes. Will be rounded to page boundary.
- * \param type type of memory to allocate.
- * \param address if not zero, will be set to the physical address of the
- * allocated memory.
- * \param handle on success will be set to a handle of the allocated memory.
- * 
- * \return zero on success, or a negative value on failure.
- * 
- * \internal
- * This function is a wrapper around the DRM_IOCTL_AGP_ALLOC ioctl, passing the
- * arguments in a drm_agp_buffer structure.
- */
-int drmAgpAlloc(int fd, unsigned long size, unsigned long type,
-		unsigned long *address, drm_handle_t *handle)
-{
-    drm_agp_buffer_t b;
-
-    *handle = DRM_AGP_NO_HANDLE;
-    b.size   = size;
-    b.handle = 0;
-    b.type   = type;
-    if (ioctl(fd, DRM_IOCTL_AGP_ALLOC, &b)) return -errno;
-    if (address != 0UL) *address = b.physical;
-    *handle = b.handle;
-    return 0;
-}
-
-
-/**
- * Free a chunk of AGP memory.
- *
- * \param fd file descriptor.
- * \param handle handle to the allocated memory, as given by drmAgpAllocate().
- * 
- * \return zero on success, or a negative value on failure.
- * 
- * \internal
- * This function is a wrapper around the DRM_IOCTL_AGP_FREE ioctl, passing the
- * argument in a drm_agp_buffer structure.
- */
-int drmAgpFree(int fd, drm_handle_t handle)
-{
-    drm_agp_buffer_t b;
-
-    b.size   = 0;
-    b.handle = handle;
-    if (ioctl(fd, DRM_IOCTL_AGP_FREE, &b)) return -errno;
-    return 0;
-}
-
-
-/**
- * Bind a chunk of AGP memory.
- *
- * \param fd file descriptor.
- * \param handle handle to the allocated memory, as given by drmAgpAllocate().
- * \param offset offset in bytes. It will round to page boundary.
- * 
- * \return zero on success, or a negative value on failure.
- * 
- * \internal
- * This function is a wrapper around the DRM_IOCTL_AGP_BIND ioctl, passing the
- * argument in a drm_agp_binding structure.
- */
-int drmAgpBind(int fd, drm_handle_t handle, unsigned long offset)
-{
-    drm_agp_binding_t b;
-
-    b.handle = handle;
-    b.offset = offset;
-    if (ioctl(fd, DRM_IOCTL_AGP_BIND, &b)) return -errno;
-    return 0;
-}
-
-
-/**
- * Unbind a chunk of AGP memory.
- *
- * \param fd file descriptor.
- * \param handle handle to the allocated memory, as given by drmAgpAllocate().
- * 
- * \return zero on success, or a negative value on failure.
- * 
- * \internal
- * This function is a wrapper around the DRM_IOCTL_AGP_UNBIND ioctl, passing
- * the argument in a drm_agp_binding structure.
- */
-int drmAgpUnbind(int fd, drm_handle_t handle)
-{
-    drm_agp_binding_t b;
-
-    b.handle = handle;
-    b.offset = 0;
-    if (ioctl(fd, DRM_IOCTL_AGP_UNBIND, &b)) return -errno;
-    return 0;
-}
-
-
-/**
- * Get AGP driver major version number.
- *
- * \param fd file descriptor.
- * 
- * \return major version number on success, or a negative value on failure..
- * 
- * \internal
- * This function is a wrapper around the DRM_IOCTL_AGP_INFO ioctl, getting the
- * necessary information in a drm_agp_info structure.
- */
-int drmAgpVersionMajor(int fd)
-{
-    drm_agp_info_t i;
-
-    if (ioctl(fd, DRM_IOCTL_AGP_INFO, &i)) return -errno;
-    return i.agp_version_major;
-}
-
-
-/**
- * Get AGP driver minor version number.
- *
- * \param fd file descriptor.
- * 
- * \return minor version number on success, or a negative value on failure.
- * 
- * \internal
- * This function is a wrapper around the DRM_IOCTL_AGP_INFO ioctl, getting the
- * necessary information in a drm_agp_info structure.
- */
-int drmAgpVersionMinor(int fd)
-{
-    drm_agp_info_t i;
-
-    if (ioctl(fd, DRM_IOCTL_AGP_INFO, &i)) return -errno;
-    return i.agp_version_minor;
-}
-
-
-/**
- * Get AGP mode.
- *
- * \param fd file descriptor.
- * 
- * \return mode on success, or zero on failure.
- * 
- * \internal
- * This function is a wrapper around the DRM_IOCTL_AGP_INFO ioctl, getting the
- * necessary information in a drm_agp_info structure.
- */
-unsigned long drmAgpGetMode(int fd)
-{
-    drm_agp_info_t i;
-
-    if (ioctl(fd, DRM_IOCTL_AGP_INFO, &i)) return 0;
-    return i.mode;
-}
-
-
-/**
- * Get AGP aperture base.
- *
- * \param fd file descriptor.
- * 
- * \return aperture base on success, zero on failure.
- * 
- * \internal
- * This function is a wrapper around the DRM_IOCTL_AGP_INFO ioctl, getting the
- * necessary information in a drm_agp_info structure.
- */
-unsigned long drmAgpBase(int fd)
-{
-    drm_agp_info_t i;
-
-    if (ioctl(fd, DRM_IOCTL_AGP_INFO, &i)) return 0;
-    return i.aperture_base;
-}
-
-
-/**
- * Get AGP aperture size.
- *
- * \param fd file descriptor.
- * 
- * \return aperture size on success, zero on failure.
- * 
- * \internal
- * This function is a wrapper around the DRM_IOCTL_AGP_INFO ioctl, getting the
- * necessary information in a drm_agp_info structure.
- */
-unsigned long drmAgpSize(int fd)
-{
-    drm_agp_info_t i;
-
-    if (ioctl(fd, DRM_IOCTL_AGP_INFO, &i)) return 0;
-    return i.aperture_size;
-}
-
-
-/**
- * Get used AGP memory.
- *
- * \param fd file descriptor.
- * 
- * \return memory used on success, or zero on failure.
- * 
- * \internal
- * This function is a wrapper around the DRM_IOCTL_AGP_INFO ioctl, getting the
- * necessary information in a drm_agp_info structure.
- */
-unsigned long drmAgpMemoryUsed(int fd)
-{
-    drm_agp_info_t i;
-
-    if (ioctl(fd, DRM_IOCTL_AGP_INFO, &i)) return 0;
-    return i.memory_used;
-}
-
-
-/**
- * Get available AGP memory.
- *
- * \param fd file descriptor.
- * 
- * \return memory available on success, or zero on failure.
- * 
- * \internal
- * This function is a wrapper around the DRM_IOCTL_AGP_INFO ioctl, getting the
- * necessary information in a drm_agp_info structure.
- */
-unsigned long drmAgpMemoryAvail(int fd)
-{
-    drm_agp_info_t i;
-
-    if (ioctl(fd, DRM_IOCTL_AGP_INFO, &i)) return 0;
-    return i.memory_allowed;
-}
-
-
-/**
- * Get hardware vendor ID.
- *
- * \param fd file descriptor.
- * 
- * \return vendor ID on success, or zero on failure.
- * 
- * \internal
- * This function is a wrapper around the DRM_IOCTL_AGP_INFO ioctl, getting the
- * necessary information in a drm_agp_info structure.
- */
-unsigned int drmAgpVendorId(int fd)
-{
-    drm_agp_info_t i;
-
-    if (ioctl(fd, DRM_IOCTL_AGP_INFO, &i)) return 0;
-    return i.id_vendor;
-}
-
-
-/**
- * Get hardware device ID.
- *
- * \param fd file descriptor.
- * 
- * \return zero on success, or zero on failure.
- * 
- * \internal
- * This function is a wrapper around the DRM_IOCTL_AGP_INFO ioctl, getting the
- * necessary information in a drm_agp_info structure.
- */
-unsigned int drmAgpDeviceId(int fd)
-{
-    drm_agp_info_t i;
-
-    if (ioctl(fd, DRM_IOCTL_AGP_INFO, &i)) return 0;
-    return i.id_device;
-}
-
-int drmScatterGatherAlloc(int fd, unsigned long size, drm_handle_t *handle)
-{
-    drm_scatter_gather_t sg;
-
-    *handle = 0;
-    sg.size   = size;
-    sg.handle = 0;
-    if (ioctl(fd, DRM_IOCTL_SG_ALLOC, &sg)) return -errno;
-    *handle = sg.handle;
-    return 0;
-}
-
-int drmScatterGatherFree(int fd, drm_handle_t handle)
-{
-    drm_scatter_gather_t sg;
-
-    sg.size   = 0;
-    sg.handle = handle;
-    if (ioctl(fd, DRM_IOCTL_SG_FREE, &sg)) return -errno;
-    return 0;
-}
-
-/**
- * Wait for VBLANK.
- *
- * \param fd file descriptor.
- * \param vbl pointer to a drmVBlank structure.
- * 
- * \return zero on success, or a negative value on failure.
- * 
- * \internal
- * This function is a wrapper around the DRM_IOCTL_WAIT_VBLANK ioctl.
- */
-int drmWaitVBlank(int fd, drmVBlankPtr vbl)
-{
-    int ret;
-
-    do {
-       ret = ioctl(fd, DRM_IOCTL_WAIT_VBLANK, vbl);
-       vbl->request.type &= ~DRM_VBLANK_RELATIVE;
-    } while (ret && errno == EINTR);
-
-    return ret;
-}
-
-int drmError(int err, const char *label)
-{
-    switch (err) {
-    case DRM_ERR_NO_DEVICE: fprintf(stderr, "%s: no device\n", label);   break;
-    case DRM_ERR_NO_ACCESS: fprintf(stderr, "%s: no access\n", label);   break;
-    case DRM_ERR_NOT_ROOT:  fprintf(stderr, "%s: not root\n", label);    break;
-    case DRM_ERR_INVALID:   fprintf(stderr, "%s: invalid args\n", label);break;
-    default:
-	if (err < 0) err = -err;
-	fprintf( stderr, "%s: error %d (%s)\n", label, err, strerror(err) );
-	break;
-    }
-
-    return 1;
-}
-
-/**
- * Install IRQ handler.
- *
- * \param fd file descriptor.
- * \param irq IRQ number.
- * 
- * \return zero on success, or a negative value on failure.
- * 
- * \internal
- * This function is a wrapper around the DRM_IOCTL_CONTROL ioctl, passing the
- * argument in a drm_control structure.
- */
-int drmCtlInstHandler(int fd, int irq)
-{
-    drm_control_t ctl;
-
-    ctl.func  = DRM_INST_HANDLER;
-    ctl.irq   = irq;
-    if (ioctl(fd, DRM_IOCTL_CONTROL, &ctl)) return -errno;
-    return 0;
-}
-
-
-/**
- * Uninstall IRQ handler.
- *
- * \param fd file descriptor.
- * 
- * \return zero on success, or a negative value on failure.
- * 
- * \internal
- * This function is a wrapper around the DRM_IOCTL_CONTROL ioctl, passing the
- * argument in a drm_control structure.
- */
-int drmCtlUninstHandler(int fd)
-{
-    drm_control_t ctl;
-
-    ctl.func  = DRM_UNINST_HANDLER;
-    ctl.irq   = 0;
-    if (ioctl(fd, DRM_IOCTL_CONTROL, &ctl)) return -errno;
-    return 0;
-}
-
-int drmFinish(int fd, int context, drmLockFlags flags)
-{
-    drm_lock_t lock;
-
-    lock.context = context;
-    lock.flags   = 0;
-    if (flags & DRM_LOCK_READY)      lock.flags |= _DRM_LOCK_READY;
-    if (flags & DRM_LOCK_QUIESCENT)  lock.flags |= _DRM_LOCK_QUIESCENT;
-    if (flags & DRM_LOCK_FLUSH)      lock.flags |= _DRM_LOCK_FLUSH;
-    if (flags & DRM_LOCK_FLUSH_ALL)  lock.flags |= _DRM_LOCK_FLUSH_ALL;
-    if (flags & DRM_HALT_ALL_QUEUES) lock.flags |= _DRM_HALT_ALL_QUEUES;
-    if (flags & DRM_HALT_CUR_QUEUES) lock.flags |= _DRM_HALT_CUR_QUEUES;
-    if (ioctl(fd, DRM_IOCTL_FINISH, &lock)) return -errno;
-    return 0;
-}
-
-/**
- * Get IRQ from bus ID.
- *
- * \param fd file descriptor.
- * \param busnum bus number.
- * \param devnum device number.
- * \param funcnum function number.
- * 
- * \return IRQ number on success, or a negative value on failure.
- * 
- * \internal
- * This function is a wrapper around the DRM_IOCTL_IRQ_BUSID ioctl, passing the
- * arguments in a drm_irq_busid structure.
- */
-int drmGetInterruptFromBusID(int fd, int busnum, int devnum, int funcnum)
-{
-    drm_irq_busid_t p;
-
-    p.busnum  = busnum;
-    p.devnum  = devnum;
-    p.funcnum = funcnum;
-    if (ioctl(fd, DRM_IOCTL_IRQ_BUSID, &p)) return -errno;
-    return p.irq;
-}
-
-int drmAddContextTag(int fd, drm_context_t context, void *tag)
-{
-    drmHashEntry  *entry = drmGetEntry(fd);
-
-    if (drmHashInsert(entry->tagTable, context, tag)) {
-	drmHashDelete(entry->tagTable, context);
-	drmHashInsert(entry->tagTable, context, tag);
-    }
-    return 0;
-}
-
-int drmDelContextTag(int fd, drm_context_t context)
-{
-    drmHashEntry  *entry = drmGetEntry(fd);
-
-    return drmHashDelete(entry->tagTable, context);
-}
-
-void *drmGetContextTag(int fd, drm_context_t context)
-{
-    drmHashEntry  *entry = drmGetEntry(fd);
-    void          *value;
-
-    if (drmHashLookup(entry->tagTable, context, &value)) return NULL;
-
-    return value;
-}
-
-int drmAddContextPrivateMapping(int fd, drm_context_t ctx_id, drm_handle_t handle)
-{
-    drm_ctx_priv_map_t map;
-
-    map.ctx_id = ctx_id;
-    map.handle = (void *)(unsigned long)handle;
-
-    if (ioctl(fd, DRM_IOCTL_SET_SAREA_CTX, &map)) return -errno;
-    return 0;
-}
-
-int drmGetContextPrivateMapping(int fd, drm_context_t ctx_id, drm_handle_t * handle)
-{
-    drm_ctx_priv_map_t map;
-
-    map.ctx_id = ctx_id;
-
-    if (ioctl(fd, DRM_IOCTL_GET_SAREA_CTX, &map)) return -errno;
-    if (handle) *handle = (drm_handle_t)(unsigned long)map.handle;
-
-    return 0;
-}
-
-int drmGetMap(int fd, int idx, drm_handle_t *offset, drmSize *size,
-	      drmMapType *type, drmMapFlags *flags, drm_handle_t *handle,
-	      int *mtrr)
-{
-    drm_map_t map;
-
-    map.offset = idx;
-    if (ioctl(fd, DRM_IOCTL_GET_MAP, &map)) return -errno;
-    *offset = map.offset;
-    *size   = map.size;
-    *type   = map.type;
-    *flags  = map.flags;
-    *handle = (drm_handle_t)(unsigned long)map.handle;
-    *mtrr   = map.mtrr;
-    return 0;
-}
-
-int drmGetClient(int fd, int idx, int *auth, int *pid, int *uid,
-		 unsigned long *magic, unsigned long *iocs)
-{
-    drm_client_t client;
-
-    client.idx = idx;
-    if (ioctl(fd, DRM_IOCTL_GET_CLIENT, &client)) return -errno;
-    *auth      = client.auth;
-    *pid       = client.pid;
-    *uid       = client.uid;
-    *magic     = client.magic;
-    *iocs      = client.iocs;
-    return 0;
-}
-
-int drmGetStats(int fd, drmStatsT *stats)
-{
-    drm_stats_t s;
-    unsigned int i;
-
-    if (ioctl(fd, DRM_IOCTL_GET_STATS, &s)) return -errno;
-
-    stats->count = 0;
-    memset(stats, 0, sizeof(*stats));
-    if (s.count > sizeof(stats->data)/sizeof(stats->data[0]))
-	return -1;
-
-#define SET_VALUE                              \
-    stats->data[i].long_format = "%-20.20s";   \
-    stats->data[i].rate_format = "%8.8s";      \
-    stats->data[i].isvalue     = 1;            \
-    stats->data[i].verbose     = 0
-
-#define SET_COUNT                              \
-    stats->data[i].long_format = "%-20.20s";   \
-    stats->data[i].rate_format = "%5.5s";      \
-    stats->data[i].isvalue     = 0;            \
-    stats->data[i].mult_names  = "kgm";        \
-    stats->data[i].mult        = 1000;         \
-    stats->data[i].verbose     = 0
-
-#define SET_BYTE                               \
-    stats->data[i].long_format = "%-20.20s";   \
-    stats->data[i].rate_format = "%5.5s";      \
-    stats->data[i].isvalue     = 0;            \
-    stats->data[i].mult_names  = "KGM";        \
-    stats->data[i].mult        = 1024;         \
-    stats->data[i].verbose     = 0
-
-
-    stats->count = s.count;
-    for (i = 0; i < s.count; i++) {
-	stats->data[i].value = s.data[i].value;
-	switch (s.data[i].type) {
-	case _DRM_STAT_LOCK:
-	    stats->data[i].long_name = "Lock";
-	    stats->data[i].rate_name = "Lock";
-	    SET_VALUE;
-	    break;
-	case _DRM_STAT_OPENS:
-	    stats->data[i].long_name = "Opens";
-	    stats->data[i].rate_name = "O";
-	    SET_COUNT;
-	    stats->data[i].verbose   = 1;
-	    break;
-	case _DRM_STAT_CLOSES:
-	    stats->data[i].long_name = "Closes";
-	    stats->data[i].rate_name = "Lock";
-	    SET_COUNT;
-	    stats->data[i].verbose   = 1;
-	    break;
-	case _DRM_STAT_IOCTLS:
-	    stats->data[i].long_name = "Ioctls";
-	    stats->data[i].rate_name = "Ioc/s";
-	    SET_COUNT;
-	    break;
-	case _DRM_STAT_LOCKS:
-	    stats->data[i].long_name = "Locks";
-	    stats->data[i].rate_name = "Lck/s";
-	    SET_COUNT;
-	    break;
-	case _DRM_STAT_UNLOCKS:
-	    stats->data[i].long_name = "Unlocks";
-	    stats->data[i].rate_name = "Unl/s";
-	    SET_COUNT;
-	    break;
-	case _DRM_STAT_IRQ:
-	    stats->data[i].long_name = "IRQs";
-	    stats->data[i].rate_name = "IRQ/s";
-	    SET_COUNT;
-	    break;
-	case _DRM_STAT_PRIMARY:
-	    stats->data[i].long_name = "Primary Bytes";
-	    stats->data[i].rate_name = "PB/s";
-	    SET_BYTE;
-	    break;
-	case _DRM_STAT_SECONDARY:
-	    stats->data[i].long_name = "Secondary Bytes";
-	    stats->data[i].rate_name = "SB/s";
-	    SET_BYTE;
-	    break;
-	case _DRM_STAT_DMA:
-	    stats->data[i].long_name = "DMA";
-	    stats->data[i].rate_name = "DMA/s";
-	    SET_COUNT;
-	    break;
-	case _DRM_STAT_SPECIAL:
-	    stats->data[i].long_name = "Special DMA";
-	    stats->data[i].rate_name = "dma/s";
-	    SET_COUNT;
-	    break;
-	case _DRM_STAT_MISSED:
-	    stats->data[i].long_name = "Miss";
-	    stats->data[i].rate_name = "Ms/s";
-	    SET_COUNT;
-	    break;
-	case _DRM_STAT_VALUE:
-	    stats->data[i].long_name = "Value";
-	    stats->data[i].rate_name = "Value";
-	    SET_VALUE;
-	    break;
-	case _DRM_STAT_BYTE:
-	    stats->data[i].long_name = "Bytes";
-	    stats->data[i].rate_name = "B/s";
-	    SET_BYTE;
-	    break;
-	case _DRM_STAT_COUNT:
-	default:
-	    stats->data[i].long_name = "Count";
-	    stats->data[i].rate_name = "Cnt/s";
-	    SET_COUNT;
-	    break;
-	}
-    }
-    return 0;
-}
-
-/**
- * Issue a set-version ioctl.
- *
- * \param fd file descriptor.
- * \param drmCommandIndex command index 
- * \param data source pointer of the data to be read and written.
- * \param size size of the data to be read and written.
- * 
- * \return zero on success, or a negative value on failure.
- * 
- * \internal
- * It issues a read-write ioctl given by 
- * \code DRM_COMMAND_BASE + drmCommandIndex \endcode.
- */
-int drmSetInterfaceVersion(int fd, drmSetVersion *version )
-{
-    int retcode = 0;
-    drm_set_version_t sv;
-
-    sv.drm_di_major = version->drm_di_major;
-    sv.drm_di_minor = version->drm_di_minor;
-    sv.drm_dd_major = version->drm_dd_major;
-    sv.drm_dd_minor = version->drm_dd_minor;
-
-    if (ioctl(fd, DRM_IOCTL_SET_VERSION, &sv)) {
-	retcode = -errno;
-    }
-
-    version->drm_di_major = sv.drm_di_major;
-    version->drm_di_minor = sv.drm_di_minor;
-    version->drm_dd_major = sv.drm_dd_major;
-    version->drm_dd_minor = sv.drm_dd_minor;
-
-    return retcode;
-}
-
-/**
- * Send a device-specific command.
- *
- * \param fd file descriptor.
- * \param drmCommandIndex command index 
- * 
- * \return zero on success, or a negative value on failure.
- * 
- * \internal
- * It issues a ioctl given by 
- * \code DRM_COMMAND_BASE + drmCommandIndex \endcode.
- */
-int drmCommandNone(int fd, unsigned long drmCommandIndex)
-{
-    void *data = NULL; /* dummy */
-    unsigned long request;
-
-    request = DRM_IO( DRM_COMMAND_BASE + drmCommandIndex);
-
-    if (ioctl(fd, request, data)) {
-	return -errno;
-    }
-    return 0;
-}
-
-
-/**
- * Send a device-specific read command.
- *
- * \param fd file descriptor.
- * \param drmCommandIndex command index 
- * \param data destination pointer of the data to be read.
- * \param size size of the data to be read.
- * 
- * \return zero on success, or a negative value on failure.
- *
- * \internal
- * It issues a read ioctl given by 
- * \code DRM_COMMAND_BASE + drmCommandIndex \endcode.
- */
-int drmCommandRead(int fd, unsigned long drmCommandIndex,
-                   void *data, unsigned long size )
-{
-    unsigned long request;
-
-    request = DRM_IOC( DRM_IOC_READ, DRM_IOCTL_BASE, 
-	DRM_COMMAND_BASE + drmCommandIndex, size);
-
-    if (ioctl(fd, request, data)) {
-	return -errno;
-    }
-    return 0;
-}
-
-
-/**
- * Send a device-specific write command.
- *
- * \param fd file descriptor.
- * \param drmCommandIndex command index 
- * \param data source pointer of the data to be written.
- * \param size size of the data to be written.
- * 
- * \return zero on success, or a negative value on failure.
- * 
- * \internal
- * It issues a write ioctl given by 
- * \code DRM_COMMAND_BASE + drmCommandIndex \endcode.
- */
-int drmCommandWrite(int fd, unsigned long drmCommandIndex,
-                   void *data, unsigned long size )
-{
-    unsigned long request;
-
-    request = DRM_IOC( DRM_IOC_WRITE, DRM_IOCTL_BASE, 
-	DRM_COMMAND_BASE + drmCommandIndex, size);
-
-    if (ioctl(fd, request, data)) {
-	return -errno;
-    }
-    return 0;
-}
-
-
-/**
- * Send a device-specific read-write command.
- *
- * \param fd file descriptor.
- * \param drmCommandIndex command index 
- * \param data source pointer of the data to be read and written.
- * \param size size of the data to be read and written.
- * 
- * \return zero on success, or a negative value on failure.
- * 
- * \internal
- * It issues a read-write ioctl given by 
- * \code DRM_COMMAND_BASE + drmCommandIndex \endcode.
- */
-int drmCommandWriteRead(int fd, unsigned long drmCommandIndex,
-                   void *data, unsigned long size )
-{
-    unsigned long request;
-
-    request = DRM_IOC( DRM_IOC_READ|DRM_IOC_WRITE, DRM_IOCTL_BASE, 
-	DRM_COMMAND_BASE + drmCommandIndex, size);
-
-    if (ioctl(fd, request, data)) {
-	return -errno;
-    }
-    return 0;
-}
-
-static void drmSIGIOHandler(int interrupt, void *closure)
-{
-    unsigned long key;
-    void          *value;
-    ssize_t       count;
-    drm_ctx_t     ctx;
-    typedef void  (*_drmCallback)(int, void *, void *);
-    char          buf[256];
-    drm_context_t    old;
-    drm_context_t    new;
-    void          *oldctx;
-    void          *newctx;
-    char          *pt;
-    drmHashEntry  *entry;
-
-    if (!drmHashTable) return;
-    if (drmHashFirst(drmHashTable, &key, &value)) {
-	entry = value;
-	do {
-#if 0
-	    fprintf(stderr, "Trying %d\n", entry->fd);
-#endif
-	    if ((count = read(entry->fd, buf, sizeof(buf))) > 0) {
-		buf[count] = '\0';
-#if 0
-		fprintf(stderr, "Got %s\n", buf);
-#endif
-
-		for (pt = buf; *pt != ' '; ++pt); /* Find first space */
-		++pt;
-		old    = strtol(pt, &pt, 0);
-		new    = strtol(pt, NULL, 0);
-		oldctx = drmGetContextTag(entry->fd, old);
-		newctx = drmGetContextTag(entry->fd, new);
-#if 0
-		fprintf(stderr, "%d %d %p %p\n", old, new, oldctx, newctx);
-#endif
-		((_drmCallback)entry->f)(entry->fd, oldctx, newctx);
-		ctx.handle = new;
-		ioctl(entry->fd, DRM_IOCTL_NEW_CTX, &ctx);
-	    }
-	} while (drmHashNext(drmHashTable, &key, &value));
-    }
-}
-
-int drmInstallSIGIOHandler(int fd, void (*f)(int, void *, void *))
-{
-    drmHashEntry     *entry;
-
-    entry     = drmGetEntry(fd);
-    entry->f  = f;
-
-    return xf86InstallSIGIOHandler(fd, drmSIGIOHandler, 0);
-}
-
-int drmRemoveSIGIOHandler(int fd)
-{
-    drmHashEntry     *entry = drmGetEntry(fd);
-
-    entry->f = NULL;
-
-    return xf86RemoveSIGIOHandler(fd);
-}
-
-/*
- * Valid flags are 
- * DRM_FENCE_FLAG_EMIT
- * DRM_FENCE_FLAG_SHAREABLE
- * DRM_FENCE_MASK_DRIVER
- */
-
-int drmFenceCreate(int fd, unsigned flags, int class,unsigned type, 
-		   drmFence *fence)
-{
-    drm_fence_arg_t arg;
-    
-    memset(&arg, 0, sizeof(arg));
-    arg.type = type;
-    arg.class = class;
-    arg.op = drm_fence_create;
-    if (ioctl(fd, DRM_IOCTL_FENCE, &arg))
-	return -errno;
-    fence->handle = arg.handle;
-    fence->class = arg.class;
-    fence->type = arg.type;
-    fence->flags = arg.flags;
-    fence->signaled = 0;
-    return 0;
-}
-
-/*
- * Valid flags are 
- * DRM_FENCE_FLAG_SHAREABLE
- * DRM_FENCE_MASK_DRIVER
- */
-
-int drmFenceBuffers(int fd, unsigned flags, drmFence *fence)
-{
-    drm_fence_arg_t arg;
-    
-    memset(&arg, 0, sizeof(arg));
-    arg.flags = flags;
-    arg.op = drm_fence_buffers;
-    if (ioctl(fd, DRM_IOCTL_FENCE, &arg))
-	return -errno;
-    fence->handle = arg.handle;
-    fence->class = arg.class;
-    fence->type = arg.type;
-    fence->flags = arg.flags;
-    fence->signaled = 0;
-    return 0;
-}
-    
-int drmFenceDestroy(int fd, const drmFence *fence)
-{
-    drm_fence_arg_t arg;
-   
-    memset(&arg, 0, sizeof(arg));
-    arg.handle = fence->handle;
-    arg.op = drm_fence_destroy;
-    if (ioctl(fd, DRM_IOCTL_FENCE, &arg))
-	return -errno;
-    return 0;
-}
-
-int drmFenceReference(int fd, unsigned handle, drmFence *fence)
-{
-    drm_fence_arg_t arg;
-   
-    memset(&arg, 0, sizeof(arg));
-    arg.handle = handle;
-    arg.op = drm_fence_reference;
-    if (ioctl(fd, DRM_IOCTL_FENCE, &arg))
-	return -errno;
-    fence->handle = arg.handle;
-    fence->class = arg.class;
-    fence->type = arg.type;
-    fence->flags = arg.flags;
-    fence->signaled = arg.signaled;
-    return 0;
-}
-
-int drmFenceUnreference(int fd, const drmFence *fence)
-{
-    drm_fence_arg_t arg;
-   
-    memset(&arg, 0, sizeof(arg));
-    arg.handle = fence->handle;
-    arg.op = drm_fence_unreference;
-    if (ioctl(fd, DRM_IOCTL_FENCE, &arg))
-	return -errno;
-    return 0;
-}
-
-int drmFenceFlush(int fd, drmFence *fence, unsigned flush_type)
-{
-    drm_fence_arg_t arg;
-   
-    memset(&arg, 0, sizeof(arg));
-    arg.handle = fence->handle;
-    arg.type = flush_type;
-    arg.op = drm_fence_flush;
-    if (ioctl(fd, DRM_IOCTL_FENCE, &arg))
-	return -errno;
-    fence->class = arg.class;
-    fence->type = arg.type;
-    fence->signaled = arg.signaled;
-    return 0;
-}
-
-int drmFenceUpdate(int fd, drmFence *fence)
-{
-    drm_fence_arg_t arg;
-	
-    memset(&arg, 0, sizeof(arg));
-    arg.handle = fence->handle;
-    arg.op = drm_fence_signaled;
-    if (ioctl(fd, DRM_IOCTL_FENCE, &arg))
-	return -errno;
-    fence->class = arg.class;
-    fence->type = arg.type;
-    fence->signaled = arg.signaled;
-    return 0;
-}
-
-int drmFenceSignaled(int fd, drmFence *fence, unsigned fenceType, 
-		     int *signaled)
-{
-    int 
-	ret;
-
-    if ((fence->flags & DRM_FENCE_FLAG_SHAREABLE) ||
-	((fenceType & fence->signaled) != fenceType)) {
-
-	ret = drmFenceFlush(fd, fence, fenceType);
-	if (ret)
-	    return ret;
-    }
-
-    *signaled = ((fenceType & fence->signaled) == fenceType);
-
-    return 0;
-}
-
-/*
- * Valid flags are 
- * DRM_FENCE_FLAG_SHAREABLE
- * DRM_FENCE_MASK_DRIVER
- */
-
-
-int drmFenceEmit(int fd, unsigned flags, drmFence *fence, unsigned emit_type)
-{
-    drm_fence_arg_t arg;
-   
-    memset(&arg, 0, sizeof(arg));
-    arg.flags = flags;
-    arg.handle = fence->handle;
-    arg.type = emit_type;
-    arg.op = drm_fence_emit;
-    if (ioctl(fd, DRM_IOCTL_FENCE, &arg))
-	return -errno;
-    fence->class = arg.class;
-    fence->type = arg.type;
-    fence->signaled = arg.signaled;
-    return 0;
-}
-
-/*
- * Valid flags are 
- * DRM_FENCE_FLAG_WAIT_LAZY
- * DRM_FENCE_FLAG_WAIT_IGNORE_SIGNALS
- */
-    
-int drmFenceWait(int fd, unsigned flags, drmFence *fence, unsigned flush_type)
-{
-    drm_fence_arg_t arg;
-    int ret;
-
-    if (flush_type == 0) {
-	flush_type = fence->type;
-    }
-
-    if (!(fence->flags & DRM_FENCE_FLAG_SHAREABLE)) {
-	if ((flush_type & fence->signaled) == flush_type) {
-	    return 0;
-	}
-    }
-
-    memset(&arg, 0, sizeof(arg));
-    arg.handle = fence->handle;
-    arg.type = flush_type;
-    arg.flags = flags;
-    arg.op = drm_fence_wait;
-    do {
-	ret = ioctl(fd, DRM_IOCTL_FENCE, &arg);
-    } while (ret != 0 && errno == EAGAIN);
-
-    if (ret)
-	return -errno;
-
-    fence->class = arg.class;
-    fence->type = arg.type;
-    fence->signaled = arg.signaled;
-    return 0;
-}    
-
-static int drmAdjustListNodes(drmBOList *list)
-{
-    drmBONode *node;
-    drmMMListHead *l;
-    int ret = 0;
-
-    while(list->numCurrent < list->numTarget) {
-	node = (drmBONode *) malloc(sizeof(*node));
-	if (!node) {
-	    ret = -ENOMEM;
-	    break;
-	}
-	list->numCurrent++;
-	DRMLISTADD(&node->head, &list->free);
-    }
-
-    while(list->numCurrent > list->numTarget) {
-	l = list->free.next;
-	if (l == &list->free)
-	    break;
-	DRMLISTDEL(l);
-	node = DRMLISTENTRY(drmBONode, l, head);
-	free(node);
-	list->numCurrent--;
-    }
-    return ret;
-}
-
-void drmBOFreeList(drmBOList *list)
-{
-    drmBONode *node;
-    drmMMListHead *l;
-
-    l = list->list.next;
-    while(l != &list->list) {
-	DRMLISTDEL(l);
-	node = DRMLISTENTRY(drmBONode, l, head);
-	free(node);
-	l = list->free.next;
-	list->numCurrent--;
-	list->numOnList--;
-    }
-
-    l = list->free.next;
-    while(l != &list->free) {
-	DRMLISTDEL(l);
-	node = DRMLISTENTRY(drmBONode, l, head);
-	free(node);
-	l = list->free.next;
-	list->numCurrent--;
-    }
-}
-	
-int drmBOResetList(drmBOList *list) {
-
-    drmMMListHead *l;
-    int ret;
-
-    ret = drmAdjustListNodes(list);
-    if (ret)
-	return ret;
-
-    l = list->list.next;
-    while(l != &list->list) {
-	DRMLISTDEL(l);
-	DRMLISTADD(l, &list->free);
-	list->numOnList--;
-	l = list->list.next;
-    }
-    return drmAdjustListNodes(list);
-}
-	
-static drmBONode *drmAddListItem(drmBOList *list, drmBO *item, 
-				 unsigned long arg0,
-				 unsigned long arg1)
-{
-    drmBONode *node;
-    drmMMListHead *l;
-
-    l = list->free.next;
-    if (l == &list->free) {
-	node = (drmBONode *) malloc(sizeof(*node));
-	if (!node) {
-	    return NULL;
-	}
-	list->numCurrent++;
-    } else {
-	DRMLISTDEL(l);
-	node = DRMLISTENTRY(drmBONode, l, head);
-    }
-    node->buf = item;
-    node->arg0 = arg0;
-    node->arg1 = arg1;
-    DRMLISTADD(&node->head, &list->list);
-    list->numOnList++;
-    return node;
-}
-     	
-void *drmBOListIterator(drmBOList *list)
-{
-    void *ret = list->list.next;
-
-    if (ret == &list->list)
-	return NULL;
-    return ret;
-}
-
-void *drmBOListNext(drmBOList *list, void *iterator)
-{
-    void *ret;
-
-    drmMMListHead *l = (drmMMListHead *) iterator;
-    ret = l->next;
-    if (ret == &list->list)
-	return NULL;
-    return ret;
-}
-
-drmBO *drmBOListBuf(void *iterator)
-{
-    drmBONode *node;
-    drmMMListHead *l = (drmMMListHead *) iterator;
-    node = DRMLISTENTRY(drmBONode, l, head);
-    
-    return node->buf;
-}
-
-
-int drmBOCreateList(int numTarget, drmBOList *list)
-{
-    DRMINITLISTHEAD(&list->list);
-    DRMINITLISTHEAD(&list->free);
-    list->numTarget = numTarget;
-    list->numCurrent = 0;
-    list->numOnList = 0;
-    return drmAdjustListNodes(list);
-}
-
-static void drmBOCopyReply(const drm_bo_arg_reply_t *rep, 
-			   drmBO *buf)
-{
-    buf->handle = rep->handle;
-    buf->flags = rep->flags;
-    buf->size = rep->size;
-    buf->offset = rep->offset;
-    buf->mapHandle = rep->arg_handle;
-    buf->mask = rep->mask;
-    buf->start = rep->buffer_start;
-    buf->fenceFlags = rep->fence_flags;
-    buf->replyFlags = rep->rep_flags;
-    buf->pageAlignment = rep->page_alignment;
-}
-    
-    
-
-int drmBOCreate(int fd, unsigned long start, unsigned long size, 
-		unsigned pageAlignment, void *user_buffer, drm_bo_type_t type, 
-		unsigned mask,
-		unsigned hint, drmBO *buf)
-{
-    drm_bo_arg_t arg;
-    drm_bo_arg_request_t *req = &arg.d.req;
-    drm_bo_arg_reply_t *rep = &arg.d.rep;
-    int ret;
-
-    memset(buf, 0, sizeof(*buf));
-    memset(&arg, 0, sizeof(arg));
-    req->mask = mask;
-    req->hint = hint;
-    req->size = size;
-    req->type = type;
-    req->page_alignment = pageAlignment;
-
-    buf->virtual = NULL;
-
-    switch(type) {
-    case drm_bo_type_dc:
-        req->buffer_start = start;
-	break;
-    case drm_bo_type_user:
-	req->buffer_start = (unsigned long) user_buffer;
-	buf->virtual = user_buffer;
-	break;
-    case drm_bo_type_fake:
-        req->buffer_start = start;
-	break;
-    default:
-	return -EINVAL;
-    }
-    req->op = drm_bo_create;
-
-    do {
-	ret = ioctl(fd, DRM_IOCTL_BUFOBJ, &arg);
-    } while (ret != 0 && errno == EAGAIN);
-
-    if (ret)
-	return -errno;
-    if (!arg.handled) {
-	return -EFAULT;
-    }
-    if (rep->ret) {
-        fprintf(stderr, "Error %d\n", rep->ret);
-	return rep->ret;
-    }
-    
-    drmBOCopyReply(rep, buf);
-    buf->mapVirtual = NULL;
-    buf->mapCount = 0;
-
-    return 0;
-}
-
-int drmBODestroy(int fd, drmBO *buf)
-{
-    drm_bo_arg_t arg;
-    drm_bo_arg_request_t *req = &arg.d.req;
-    drm_bo_arg_reply_t *rep = &arg.d.rep;
-    
-    if (buf->mapVirtual && (buf->type != drm_bo_type_fake)) {
-	(void) drmUnmap(buf->mapVirtual, buf->start + buf->size);
-	buf->mapVirtual = NULL;
-	buf->virtual = NULL;
-    }
-
-    memset(&arg, 0, sizeof(arg));
-    req->handle = buf->handle;
-    req->op = drm_bo_destroy;
-
-    if (ioctl(fd, DRM_IOCTL_BUFOBJ, &arg))
-	return -errno;
-    if (!arg.handled) {
-	return -EFAULT;
-    }
-    if (rep->ret) {
-	return rep->ret;
-    }
-
-    buf->handle = 0;
-    return 0;
-}
- 
-int drmBOReference(int fd, unsigned handle, drmBO *buf)
-{
-
-    drm_bo_arg_t arg;
-    drm_bo_arg_request_t *req = &arg.d.req;
-    drm_bo_arg_reply_t *rep = &arg.d.rep;
-    
-    memset(&arg, 0, sizeof(arg));
-    req->handle = handle;
-    req->op = drm_bo_reference;
-    
-    if (ioctl(fd, DRM_IOCTL_BUFOBJ, &arg))
-	return -errno;
-    if (!arg.handled) {
-	return -EFAULT;
-    }
-    if (rep->ret) {
-	return rep->ret;
-    }
-
-    drmBOCopyReply(rep, buf);
-    buf->type = drm_bo_type_dc;
-    buf->mapVirtual = NULL;
-    buf->mapCount = 0;
-    buf->virtual = NULL;
-
-    return 0;
-}
-
-int drmBOUnReference(int fd, drmBO *buf)
-{
-    drm_bo_arg_t arg;
-    drm_bo_arg_request_t *req = &arg.d.req;
-    drm_bo_arg_reply_t *rep = &arg.d.rep;
-    
-
-    if (buf->mapVirtual && (buf->type != drm_bo_type_fake)) {
-	(void) munmap(buf->mapVirtual, buf->start + buf->size);
-	buf->mapVirtual = NULL;
-	buf->virtual = NULL;
-    }
-
-    memset(&arg, 0, sizeof(arg));
-    req->handle = buf->handle;
-    req->op = drm_bo_unreference;
-
-    if (ioctl(fd, DRM_IOCTL_BUFOBJ, &arg))
-	return -errno;
-    if (!arg.handled) {
-	return -EFAULT;
-    }
-    if (rep->ret) {
-	return rep->ret;
-    }
-
-    buf->handle = 0;
-    return 0;
-}   
-
-/*
- * Flags can be  DRM_BO_FLAG_READ, DRM_BO_FLAG_WRITE or'ed together
- * Hint currently be DRM_BO_HINT_DONT_BLOCK, which makes the
- * call return an -EBUSY if it can' immediately honor the mapping request.
- */
-
-int drmBOMap(int fd, drmBO *buf, unsigned mapFlags, unsigned mapHint,
-	     void **address)
-{
-
-    drm_bo_arg_t arg;
-    drm_bo_arg_request_t *req = &arg.d.req;
-    drm_bo_arg_reply_t *rep = &arg.d.rep;
-    int ret = 0;
-
-    /*
-     * Make sure we have a virtual address of the buffer.
-     */
-
-    if (!buf->virtual && buf->type != drm_bo_type_fake) {
-	drmAddress virtual;
-	virtual = mmap(0, buf->size + buf->start, 
-		       PROT_READ | PROT_WRITE, MAP_SHARED,
-		       fd, buf->mapHandle);
-	if (virtual == MAP_FAILED) {
-	    ret = -errno;
-	}
-	if (ret) 
-	    return ret;
-	buf->mapVirtual = virtual;
-	buf->virtual = ((char *) virtual) + buf->start;
-    }
-
-    memset(&arg, 0, sizeof(arg));
-    req->handle = buf->handle;
-    req->mask = mapFlags;
-    req->hint = mapHint;
-    req->op = drm_bo_map;
-
-    /*
-     * May hang if the buffer object is busy.
-     * This IOCTL synchronizes the buffer.
-     */
-    
-    do {
-	ret = ioctl(fd, DRM_IOCTL_BUFOBJ, &arg);
-    } while (ret != 0 && errno == EAGAIN);
-
-    if (ret) 
-	return ret;
-    if (!arg.handled) 
-	return -EFAULT;
-    if (rep->ret)
-	return rep->ret;
-
-    drmBOCopyReply(rep, buf);	
-    buf->mapFlags = mapFlags;
-    ++buf->mapCount;
-    *address = buf->virtual;
-
-    return 0;
-}
-
-int drmBOUnmap(int fd, drmBO *buf)
-{
-    drm_bo_arg_t arg;
-    drm_bo_arg_request_t *req = &arg.d.req;
-    drm_bo_arg_reply_t *rep = &arg.d.rep;
-
-	
-    memset(&arg, 0, sizeof(arg));
-    req->handle = buf->handle;
-    req->op = drm_bo_unmap;
-
-    if (ioctl(fd, DRM_IOCTL_BUFOBJ, &arg)) {
-	return -errno;
-    }
-    if (!arg.handled) 
-        return -EFAULT;
-    if (rep->ret)
-	return rep->ret;
-
-    return 0;
-}
-    
-int drmBOValidate(int fd, drmBO *buf, unsigned flags, unsigned mask, 
-		  unsigned hint)
-{
-    drm_bo_arg_t arg;
-    drm_bo_arg_request_t *req = &arg.d.req;
-    drm_bo_arg_reply_t *rep = &arg.d.rep;
-    int ret = 0;
-
-    memset(&arg, 0, sizeof(arg));
-    req->handle = buf->handle;
-    req->mask = flags;
-    req->hint = hint;
-    req->arg_handle = mask; /* Encode mask in the arg_handle field :/ */
-    req->op = drm_bo_validate;
-
-    do{
-	ret = ioctl(fd, DRM_IOCTL_BUFOBJ, &arg);
-    } while (ret && errno == EAGAIN);
-    
-    if (ret) 
-	return ret;
-    if (!arg.handled)
-	return -EFAULT;
-    if (rep->ret)
-	return rep->ret;
-
-    drmBOCopyReply(rep, buf);
-    return 0;
-}
-	    
-
-int drmBOFence(int fd, drmBO *buf, unsigned flags, unsigned fenceHandle)
-{
-    drm_bo_arg_t arg;
-    drm_bo_arg_request_t *req = &arg.d.req;
-    drm_bo_arg_reply_t *rep = &arg.d.rep;
-    int ret = 0;
-
-    memset(&arg, 0, sizeof(arg));
-    req->handle = buf->handle;
-    req->mask = flags;
-    req->arg_handle = fenceHandle;
-    req->op = drm_bo_validate;
-
-    ret = ioctl(fd, DRM_IOCTL_BUFOBJ, &arg);
-    
-    if (ret) 
-	return ret;
-    if (!arg.handled)
-	return -EFAULT;
-    if (rep->ret)
-	return rep->ret;
-    return 0;
-}
-
-int drmBOInfo(int fd, drmBO *buf)
-{
-    drm_bo_arg_t arg;
-    drm_bo_arg_request_t *req = &arg.d.req;
-    drm_bo_arg_reply_t *rep = &arg.d.rep;
-    int ret = 0;
-
-    memset(&arg, 0, sizeof(arg));
-    req->handle = buf->handle;
-    req->op = drm_bo_info;
-
-    ret = ioctl(fd, DRM_IOCTL_BUFOBJ, &arg);
-    
-    if (ret) 
-	return ret;
-    if (!arg.handled)
-	return -EFAULT;
-    if (rep->ret)
-	return rep->ret;
-    drmBOCopyReply(rep, buf);
-    return 0;
-}
-
-int drmBOWaitIdle(int fd, drmBO *buf, unsigned hint)
-{
-    drm_bo_arg_t arg;
-    drm_bo_arg_request_t *req = &arg.d.req;
-    drm_bo_arg_reply_t *rep = &arg.d.rep;
-    int ret = 0;
-
-    if ((buf->flags & DRM_BO_FLAG_SHAREABLE) ||
-	(buf->replyFlags & DRM_BO_REP_BUSY)) {
-        memset(&arg, 0, sizeof(arg));
-	req->handle = buf->handle;
-	req->op = drm_bo_wait_idle;
-	req->hint = hint;
-
-	do {
-	    ret = ioctl(fd, DRM_IOCTL_BUFOBJ, &arg);
-	} while (ret && errno == EAGAIN);
-
-	if (ret) 
-	    return ret;
-	if (!arg.handled)
-	    return -EFAULT;
-	if (rep->ret)
-	    return rep->ret;
-	drmBOCopyReply(rep, buf);
-    }
-    return 0;
-}
-	
-int drmBOBusy(int fd, drmBO *buf, int *busy)
-{
-    if (!(buf->flags & DRM_BO_FLAG_SHAREABLE) &&
-	!(buf->replyFlags & DRM_BO_REP_BUSY)) {
-	*busy = 0;
-	return 0;
-    } else {
-	int ret = drmBOInfo(fd, buf);
-	if (ret)
-	    return ret;
-	*busy = (buf->replyFlags & DRM_BO_REP_BUSY);
-	return 0;
-    }
-}
-    
-    
-int drmAddValidateItem(drmBOList *list, drmBO *buf, unsigned flags, 
-		       unsigned mask,
-		       int *newItem)
-{
-    drmBONode *node, *cur;
-    drmMMListHead *l;
-
-    *newItem = 0;
-    cur = NULL;
-
-    for (l = list->list.next; l != &list->list; l = l->next) {
-	node = DRMLISTENTRY(drmBONode, l, head);
-	if (node->buf == buf) {
-	    cur = node;
-	    break;
-	}
-    }
-    if (!cur) {
-	cur = drmAddListItem(list, buf, flags, mask);
-	if (!cur) {
-	    drmMsg("Out of memory creating validate list node.\n");
-	    return -ENOMEM;
-	}
-	*newItem = 1;
-	cur->arg0 = flags;
-	cur->arg1 = mask;
-    } else {
-	unsigned memMask = (cur->arg1 | mask) & DRM_BO_MASK_MEM;
-	unsigned memFlags = cur->arg0 & flags & memMask;
-	
-	if (!memFlags) {
-	    drmMsg("Incompatible memory location requests "
-		   "on validate list.\n");
-	    drmMsg("Previous flag: 0x%08lx, mask: 0x%08lx\n",
-		   cur->arg0, cur->arg1);
-	    drmMsg("Current flag: 0x%08lx, mask: 0x%08lx\n",
-		   flags, mask);
-	    return -EINVAL;
-	}
-	if (mask & cur->arg1 & ~DRM_BO_MASK_MEM  & (cur->arg0 ^ flags)) {
-	    drmMsg("Incompatible buffer flag requests "
-		   "on validate list.\n");
-	    drmMsg("Previous flag: 0x%08lx, mask: 0x%08lx\n",
-		   cur->arg0, cur->arg1);
-	    drmMsg("Current flag: 0x%08lx, mask: 0x%08lx\n",
-		   flags, mask);
-	    return -EINVAL;
-	}
-	cur->arg1 |= mask;
-	cur->arg0 = memFlags | ((cur->arg0 | flags) & 
-				cur->arg1 & ~DRM_BO_MASK_MEM);	
-    }
-    return 0;
-}
-
-
-int drmBOValidateList(int fd, drmBOList *list)
-{
-   
-  drmBONode *node;
-  drmMMListHead *l;
-  drm_bo_arg_t *arg, *first;
-  drm_bo_arg_request_t *req;
-  drm_bo_arg_reply_t *rep;
-  drm_u64_t *prevNext = NULL;
-  drmBO *buf;
-  int ret;
-
-  first = NULL;
-
-  for (l = list->list.next; l != &list->list; l = l->next) {
-      node = DRMLISTENTRY(drmBONode, l, head);
-
-      arg = &node->bo_arg;
-      req = &arg->d.req;
-
-      if (!first)
-	  first = arg;
-
-      if (prevNext)
-	  *prevNext = (unsigned long) arg;
-
-      memset(arg, 0, sizeof(*arg));
-      prevNext = &arg->next;
-      req->handle = node->buf->handle;
-      req->op = drm_bo_validate;
-      req->mask = node->arg0;
-      req->hint = 0;
-      req->arg_handle = node->arg1;
-  }
-  
-  if (!first) 
-      return 0;
-
-  do{
-      ret = ioctl(fd, DRM_IOCTL_BUFOBJ, first);
-  } while (ret && errno == EAGAIN);
-
-
-  if (ret)
-      return -errno;
-  
-  for (l = list->list.next; l != &list->list; l = l->next) {
-      node = DRMLISTENTRY(drmBONode, l, head);
-      arg = &node->bo_arg;
-      rep = &arg->d.rep;
-      
-      if (!arg->handled) {
-	  drmMsg("Unhandled request\n");
-	  return -EFAULT;
-      }
-      if (rep->ret)
-	  return rep->ret;
-
-      buf = node->buf;
-      drmBOCopyReply(rep, buf);
-  }
-
-  return 0;
-}
-	  
-
-int drmBOFenceList(int fd, drmBOList *list, unsigned fenceHandle)
-{
-   
-  drmBONode *node;
-  drmMMListHead *l;
-  drm_bo_arg_t *arg, *first;
-  drm_bo_arg_request_t *req;
-  drm_bo_arg_reply_t *rep;
-  drm_u64_t *prevNext = NULL;
-  int ret;
-
-  first = NULL;
-
-  for (l = list->list.next; l != &list->list; l = l->next) {
-      node = DRMLISTENTRY(drmBONode, l, head);
-
-      arg = &node->bo_arg;
-      req = &arg->d.req;
-
-      if (!first)
-	  first = arg;
-
-      if (prevNext)
-	  *prevNext = (unsigned long) arg;
-
-      memset(arg, 0, sizeof(*arg));
-      prevNext = &arg->next;
-      req->handle = node->buf->handle;
-      req->op = drm_bo_fence;
-      req->mask = node->arg0;
-      req->arg_handle = fenceHandle;
-  }
-  
-  if (!first) 
-      return 0;
-
-  ret = ioctl(fd, DRM_IOCTL_BUFOBJ, first);
-
-  if (ret)
-      return -errno;
-  
-  for (l = list->list.next; l != &list->list; l = l->next) {
-      node = DRMLISTENTRY(drmBONode, l, head);
-
-      arg = &node->bo_arg;
-      rep = &arg->d.rep;
-      
-      if (!arg->handled)
-	  return -EFAULT;
-      if (rep->ret)
-	  return rep->ret;
-      drmBOCopyReply(rep, node->buf);
-  }
-
-  return 0;
-}
-
-int drmMMInit(int fd, unsigned long pOffset, unsigned long pSize,
-	      unsigned memType)
-{
-    drm_mm_init_arg_t arg;
-    
-    memset(&arg, 0, sizeof(arg));
-    arg.req.op = mm_init;
-    arg.req.p_offset = pOffset;
-    arg.req.p_size = pSize;
-    arg.req.mem_type = memType;
-
-    if (ioctl(fd, DRM_IOCTL_MM_INIT, &arg))
-	return -errno;
-    
-    return 0;	
-}
-
-int drmMMTakedown(int fd, unsigned memType)
-{
-    drm_mm_init_arg_t arg;
-
-
-    memset(&arg, 0, sizeof(arg));
-    arg.req.op = mm_takedown;
-    arg.req.mem_type = memType;
-
-    if (ioctl(fd, DRM_IOCTL_MM_INIT, &arg))
-	return -errno;
-    
-    return 0;	
-}
-
-int drmMMLock(int fd, unsigned memType)
-{
-    drm_mm_init_arg_t arg;
-    int ret;
-
-    memset(&arg, 0, sizeof(arg));
-    arg.req.op = mm_lock;
-    arg.req.mem_type = memType;
-
-    do{
-	ret = ioctl(fd, DRM_IOCTL_MM_INIT, &arg);
-    } while (ret && errno == EAGAIN);
-    
-    return ret;	
-}
-
-int drmMMUnlock(int fd, unsigned memType)
-{
-    drm_mm_init_arg_t arg;
-    int ret;
-
-    memset(&arg, 0, sizeof(arg));
-    arg.req.op = mm_unlock;
-    arg.req.mem_type = memType;
-
-    do{
-	ret = ioctl(fd, DRM_IOCTL_MM_INIT, &arg);
-    } while (ret && errno == EAGAIN);
-    
-    return ret;	
-}
diff --git a/hw/xfree86/os-support/drm/xf86drmHash.c b/hw/xfree86/os-support/drm/xf86drmHash.c
deleted file mode 100644
index ba81a6e..0000000
--- a/hw/xfree86/os-support/drm/xf86drmHash.c
+++ /dev/null
@@ -1,432 +0,0 @@
-/* xf86drmHash.c -- Small hash table support for integer -> integer mapping
- * Created: Sun Apr 18 09:35:45 1999 by faith at precisioninsight.com
- *
- * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
- * 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
- * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * Authors: Rickard E. (Rik) Faith <faith at valinux.com>
- *
- *
- * DESCRIPTION
- *
- * This file contains a straightforward implementation of a fixed-sized
- * hash table using self-organizing linked lists [Knuth73, pp. 398-399] for
- * collision resolution.  There are two potentially interesting things
- * about this implementation:
- *
- * 1) The table is power-of-two sized.  Prime sized tables are more
- * traditional, but do not have a significant advantage over power-of-two
- * sized table, especially when double hashing is not used for collision
- * resolution.
- *
- * 2) The hash computation uses a table of random integers [Hanson97,
- * pp. 39-41].
- *
- * FUTURE ENHANCEMENTS
- *
- * With a table size of 512, the current implementation is sufficient for a
- * few hundred keys.  Since this is well above the expected size of the
- * tables for which this implementation was designed, the implementation of
- * dynamic hash tables was postponed until the need arises.  A common (and
- * naive) approach to dynamic hash table implementation simply creates a
- * new hash table when necessary, rehashes all the data into the new table,
- * and destroys the old table.  The approach in [Larson88] is superior in
- * two ways: 1) only a portion of the table is expanded when needed,
- * distributing the expansion cost over several insertions, and 2) portions
- * of the table can be locked, enabling a scalable thread-safe
- * implementation.
- *
- * REFERENCES
- *
- * [Hanson97] David R. Hanson.  C Interfaces and Implementations:
- * Techniques for Creating Reusable Software.  Reading, Massachusetts:
- * Addison-Wesley, 1997.
- *
- * [Knuth73] Donald E. Knuth. The Art of Computer Programming.  Volume 3:
- * Sorting and Searching.  Reading, Massachusetts: Addison-Wesley, 1973.
- *
- * [Larson88] Per-Ake Larson. "Dynamic Hash Tables".  CACM 31(4), April
- * 1988, pp. 446-457.
- *
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#define HASH_MAIN 0
-
-#include <stdio.h>
-#include <stdlib.h>
-#if !HASH_MAIN
-# include "drm.h"
-# include "xf86drm.h"
-# include "xf86.h"
-#endif
-
-#define N(x)  drm##x
-
-#define HASH_MAGIC 0xdeadbeef
-#define HASH_DEBUG 0
-#define HASH_SIZE  512		/* Good for about 100 entries */
-				/* If you change this value, you probably
-                                   have to change the HashHash hashing
-                                   function! */
-
-#if HASH_MAIN
-#define HASH_ALLOC malloc
-#define HASH_FREE  free
-#define HASH_RANDOM_DECL
-#define HASH_RANDOM_INIT(seed)  srandom(seed)
-#define HASH_RANDOM             random()
-#else
-#define HASH_ALLOC drmMalloc
-#define HASH_FREE  drmFree
-#define HASH_RANDOM_DECL        void *state
-#define HASH_RANDOM_INIT(seed)  state = drmRandomCreate(seed)
-#define HASH_RANDOM             drmRandom(state)
-
-#endif
-
-typedef struct HashBucket {
-    unsigned long     key;
-    void              *value;
-    struct HashBucket *next;
-} HashBucket, *HashBucketPtr;
-
-typedef struct HashTable {
-    unsigned long    magic;
-    unsigned long    entries;
-    unsigned long    hits;	/* At top of linked list */
-    unsigned long    partials;	/* Not at top of linked list */
-    unsigned long    misses;	/* Not in table */
-    HashBucketPtr    buckets[HASH_SIZE];
-    int              p0;
-    HashBucketPtr    p1;
-} HashTable, *HashTablePtr;
-
-#if HASH_MAIN
-extern void *N(HashCreate)(void);
-extern int  N(HashDestroy)(void *t);
-extern int  N(HashLookup)(void *t, unsigned long key, unsigned long *value);
-extern int  N(HashInsert)(void *t, unsigned long key, unsigned long value);
-extern int  N(HashDelete)(void *t, unsigned long key);
-#endif
-
-static unsigned long HashHash(unsigned long key)
-{
-    unsigned long        hash = 0;
-    unsigned long        tmp  = key;
-    static int           init = 0;
-    static unsigned long scatter[256];
-    int                  i;
-
-    if (!init) {
-	HASH_RANDOM_DECL;
-	HASH_RANDOM_INIT(37);
-	for (i = 0; i < 256; i++) scatter[i] = HASH_RANDOM;
-	++init;
-    }
-
-    while (tmp) {
-	hash = (hash << 1) + scatter[tmp & 0xff];
-	tmp >>= 8;
-    }
-
-    hash %= HASH_SIZE;
-#if HASH_DEBUG
-    printf( "Hash(%d) = %d\n", key, hash);
-#endif
-    return hash;
-}
-
-void *N(HashCreate)(void)
-{
-    HashTablePtr table;
-    int          i;
-
-    table           = HASH_ALLOC(sizeof(*table));
-    if (!table) return NULL;
-    table->magic    = HASH_MAGIC;
-    table->entries  = 0;
-    table->hits     = 0;
-    table->partials = 0;
-    table->misses   = 0;
-
-    for (i = 0; i < HASH_SIZE; i++) table->buckets[i] = NULL;
-    return table;
-}
-
-int N(HashDestroy)(void *t)
-{
-    HashTablePtr  table = (HashTablePtr)t;
-    HashBucketPtr bucket;
-    HashBucketPtr next;
-    int           i;
-
-    if (table->magic != HASH_MAGIC) return -1; /* Bad magic */
-
-    for (i = 0; i < HASH_SIZE; i++) {
-	for (bucket = table->buckets[i]; bucket;) {
-	    next = bucket->next;
-	    HASH_FREE(bucket);
-	    bucket = next;
-	}
-    }
-    HASH_FREE(table);
-    return 0;
-}
-
-/* Find the bucket and organize the list so that this bucket is at the
-   top. */
-
-static HashBucketPtr HashFind(HashTablePtr table,
-			      unsigned long key, unsigned long *h)
-{
-    unsigned long hash = HashHash(key);
-    HashBucketPtr prev = NULL;
-    HashBucketPtr bucket;
-
-    if (h) *h = hash;
-
-    for (bucket = table->buckets[hash]; bucket; bucket = bucket->next) {
-	if (bucket->key == key) {
-	    if (prev) {
-				/* Organize */
-		prev->next           = bucket->next;
-		bucket->next         = table->buckets[hash];
-		table->buckets[hash] = bucket;
-		++table->partials;
-	    } else {
-		++table->hits;
-	    }
-	    return bucket;
-	}
-	prev = bucket;
-    }
-    ++table->misses;
-    return NULL;
-}
-
-int N(HashLookup)(void *t, unsigned long key, void **value)
-{
-    HashTablePtr  table = (HashTablePtr)t;
-    HashBucketPtr bucket;
-
-    if (!table || table->magic != HASH_MAGIC) return -1; /* Bad magic */
-
-    bucket = HashFind(table, key, NULL);
-    if (!bucket) return 1;	/* Not found */
-    *value = bucket->value;
-    return 0;			/* Found */
-}
-
-int N(HashInsert)(void *t, unsigned long key, void *value)
-{
-    HashTablePtr  table = (HashTablePtr)t;
-    HashBucketPtr bucket;
-    unsigned long hash;
-
-    if (table->magic != HASH_MAGIC) return -1; /* Bad magic */
-
-    if (HashFind(table, key, &hash)) return 1; /* Already in table */
-
-    bucket               = HASH_ALLOC(sizeof(*bucket));
-    if (!bucket) return -1;	/* Error */
-    bucket->key          = key;
-    bucket->value        = value;
-    bucket->next         = table->buckets[hash];
-    table->buckets[hash] = bucket;
-#if HASH_DEBUG
-    printf("Inserted %d at %d/%p\n", key, hash, bucket);
-#endif
-    return 0;			/* Added to table */
-}
-
-int N(HashDelete)(void *t, unsigned long key)
-{
-    HashTablePtr  table = (HashTablePtr)t;
-    unsigned long hash;
-    HashBucketPtr bucket;
-
-    if (table->magic != HASH_MAGIC) return -1; /* Bad magic */
-
-    bucket = HashFind(table, key, &hash);
-
-    if (!bucket) return 1;	/* Not found */
-
-    table->buckets[hash] = bucket->next;
-    HASH_FREE(bucket);
-    return 0;
-}
-
-int N(HashNext)(void *t, unsigned long *key, void **value)
-{
-    HashTablePtr  table = (HashTablePtr)t;
-
-    for (; table->p0 < HASH_SIZE;
-	 ++table->p0, table->p1 = table->buckets[table->p0]) {
-	if (table->p1) {
-	    *key       = table->p1->key;
-	    *value     = table->p1->value;
-	    table->p1  = table->p1->next;
-	    return 1;
-	}
-    }
-    return 0;
-}
-
-int N(HashFirst)(void *t, unsigned long *key, void **value)
-{
-    HashTablePtr  table = (HashTablePtr)t;
-
-    if (table->magic != HASH_MAGIC) return -1; /* Bad magic */
-
-    table->p0 = 0;
-    table->p1 = table->buckets[0];
-    return N(HashNext)(table, key, value);
-}
-
-#if HASH_MAIN
-#define DIST_LIMIT 10
-static int dist[DIST_LIMIT];
-
-static void clear_dist(void) {
-    int i;
-
-    for (i = 0; i < DIST_LIMIT; i++) dist[i] = 0;
-}
-
-static int count_entries(HashBucketPtr bucket)
-{
-    int count = 0;
-
-    for (; bucket; bucket = bucket->next) ++count;
-    return count;
-}
-
-static void update_dist(int count)
-{
-    if (count >= DIST_LIMIT) ++dist[DIST_LIMIT-1];
-    else                     ++dist[count];
-}
-
-static void compute_dist(HashTablePtr table)
-{
-    int           i;
-    HashBucketPtr bucket;
-
-    printf("Entries = %ld, hits = %ld, partials = %ld, misses = %ld\n",
-	   table->entries, table->hits, table->partials, table->misses);
-    clear_dist();
-    for (i = 0; i < HASH_SIZE; i++) {
-	bucket = table->buckets[i];
-	update_dist(count_entries(bucket));
-    }
-    for (i = 0; i < DIST_LIMIT; i++) {
-	if (i != DIST_LIMIT-1) printf("%5d %10d\n", i, dist[i]);
-	else                   printf("other %10d\n", dist[i]);
-    }
-}
-
-static void check_table(HashTablePtr table,
-			unsigned long key, unsigned long value)
-{
-    unsigned long retval  = 0;
-    int           retcode = N(HashLookup)(table, key, &retval);
-
-    switch (retcode) {
-    case -1:
-	printf("Bad magic = 0x%08lx:"
-	       " key = %lu, expected = %lu, returned = %lu\n",
-	       table->magic, key, value, retval);
-	break;
-    case 1:
-	printf("Not found: key = %lu, expected = %lu returned = %lu\n",
-	       key, value, retval);
-	break;
-    case 0:
-	if (value != retval)
-	    printf("Bad value: key = %lu, expected = %lu, returned = %lu\n",
-		   key, value, retval);
-	break;
-    default:
-	printf("Bad retcode = %d: key = %lu, expected = %lu, returned = %lu\n",
-	       retcode, key, value, retval);
-	break;
-    }
-}
-
-int main(void)
-{
-    HashTablePtr table;
-    int          i;
-
-    printf("\n***** 256 consecutive integers ****\n");
-    table = N(HashCreate)();
-    for (i = 0; i < 256; i++) N(HashInsert)(table, i, i);
-    for (i = 0; i < 256; i++) check_table(table, i, i);
-    for (i = 256; i >= 0; i--) check_table(table, i, i);
-    compute_dist(table);
-    N(HashDestroy)(table);
-
-    printf("\n***** 1024 consecutive integers ****\n");
-    table = N(HashCreate)();
-    for (i = 0; i < 1024; i++) N(HashInsert)(table, i, i);
-    for (i = 0; i < 1024; i++) check_table(table, i, i);
-    for (i = 1024; i >= 0; i--) check_table(table, i, i);
-    compute_dist(table);
-    N(HashDestroy)(table);
-
-    printf("\n***** 1024 consecutive page addresses (4k pages) ****\n");
-    table = N(HashCreate)();
-    for (i = 0; i < 1024; i++) N(HashInsert)(table, i*4096, i);
-    for (i = 0; i < 1024; i++) check_table(table, i*4096, i);
-    for (i = 1024; i >= 0; i--) check_table(table, i*4096, i);
-    compute_dist(table);
-    N(HashDestroy)(table);
-
-    printf("\n***** 1024 random integers ****\n");
-    table = N(HashCreate)();
-    srandom(0xbeefbeef);
-    for (i = 0; i < 1024; i++) N(HashInsert)(table, random(), i);
-    srandom(0xbeefbeef);
-    for (i = 0; i < 1024; i++) check_table(table, random(), i);
-    srandom(0xbeefbeef);
-    for (i = 0; i < 1024; i++) check_table(table, random(), i);
-    compute_dist(table);
-    N(HashDestroy)(table);
-
-    printf("\n***** 5000 random integers ****\n");
-    table = N(HashCreate)();
-    srandom(0xbeefbeef);
-    for (i = 0; i < 5000; i++) N(HashInsert)(table, random(), i);
-    srandom(0xbeefbeef);
-    for (i = 0; i < 5000; i++) check_table(table, random(), i);
-    srandom(0xbeefbeef);
-    for (i = 0; i < 5000; i++) check_table(table, random(), i);
-    compute_dist(table);
-    N(HashDestroy)(table);
-
-    return 0;
-}
-#endif
diff --git a/hw/xfree86/os-support/drm/xf86drmRandom.c b/hw/xfree86/os-support/drm/xf86drmRandom.c
deleted file mode 100644
index cd63aea..0000000
--- a/hw/xfree86/os-support/drm/xf86drmRandom.c
+++ /dev/null
@@ -1,216 +0,0 @@
-/* xf86drmRandom.c -- "Minimal Standard" PRNG Implementation
- * Created: Mon Apr 19 08:28:13 1999 by faith at precisioninsight.com
- *
- * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
- * 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
- * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- * 
- * Authors: Rickard E. (Rik) Faith <faith at valinux.com>
- *
- *
- * DESCRIPTION
- *
- * This file contains a simple, straightforward implementation of the Park
- * & Miller "Minimal Standard" PRNG [PM88, PMS93], which is a Lehmer
- * multiplicative linear congruential generator (MLCG) with a period of
- * 2^31-1.
- *
- * This implementation is intended to provide a reliable, portable PRNG
- * that is suitable for testing a hash table implementation and for
- * implementing skip lists.
- *
- * FUTURE ENHANCEMENTS
- *
- * If initial seeds are not selected randomly, two instances of the PRNG
- * can be correlated.  [Knuth81, pp. 32-33] describes a shuffling technique
- * that can eliminate this problem.
- *
- * If PRNGs are used for simulation, the period of the current
- * implementation may be too short.  [LE88] discusses methods of combining
- * MLCGs to produce much longer periods, and suggests some alternative
- * values for A and M.  [LE90 and Sch92] also provide information on
- * long-period PRNGs.
- *
- * REFERENCES
- *
- * [Knuth81] Donald E. Knuth. The Art of Computer Programming.  Volume 2:
- * Seminumerical Algorithms.  Reading, Massachusetts: Addison-Wesley, 1981.
- *
- * [LE88] Pierre L'Ecuyer. "Efficient and Portable Combined Random Number
- * Generators".  CACM 31(6), June 1988, pp. 742-774.
- *
- * [LE90] Pierre L'Ecuyer. "Random Numbers for Simulation". CACM 33(10,
- * October 1990, pp. 85-97.
- *
- * [PM88] Stephen K. Park and Keith W. Miller. "Random Number Generators:
- * Good Ones are Hard to Find". CACM 31(10), October 1988, pp. 1192-1201.
- *
- * [Sch92] Bruce Schneier. "Pseudo-Ransom Sequence Generator for 32-Bit
- * CPUs".  Dr. Dobb's Journal 17(2), February 1992, pp. 34, 37-38, 40.
- *
- * [PMS93] Stephen K. Park, Keith W. Miller, and Paul K. Stockmeyer.  In
- * "Technical Correspondence: Remarks on Choosing and Implementing Random
- * Number Generators". CACM 36(7), July 1993, pp. 105-110.
- *
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#define RANDOM_MAIN 0
-
-#include <stdio.h>
-#include <stdlib.h>
-#if !RANDOM_MAIN
-# include "drm.h"
-# include "xf86drm.h"
-# include "xf86.h"
-#endif
-
-#define N(x)  drm##x
-
-#define RANDOM_MAGIC 0xfeedbeef
-#define RANDOM_DEBUG 0
-
-#if RANDOM_MAIN
-#define RANDOM_ALLOC malloc
-#define RANDOM_FREE  free
-#else
-#define RANDOM_ALLOC drmMalloc
-#define RANDOM_FREE  drmFree
-#endif
-
-typedef struct RandomState {
-    unsigned long magic;
-    unsigned long a;
-    unsigned long m;
-    unsigned long q;		/* m div a */
-    unsigned long r;		/* m mod a */
-    unsigned long check;
-    long          seed;
-} RandomState;
-
-#if RANDOM_MAIN
-extern void          *N(RandomCreate)(unsigned long seed);
-extern int           N(RandomDestroy)(void *state);
-extern unsigned long N(Random)(void *state);
-extern double        N(RandomDouble)(void *state);
-#endif
-
-void *N(RandomCreate)(unsigned long seed)
-{
-    RandomState  *state;
-
-    state           = RANDOM_ALLOC(sizeof(*state));
-    if (!state) return NULL;
-    state->magic    = RANDOM_MAGIC;
-#if 0
-				/* Park & Miller, October 1988 */
-    state->a        = 16807;
-    state->m        = 2147483647;
-    state->check    = 1043618065; /* After 10000 iterations */
-#else
-				/* Park, Miller, and Stockmeyer, July 1993 */
-    state->a        = 48271;
-    state->m        = 2147483647;
-    state->check    = 399268537; /* After 10000 iterations */
-#endif
-    state->q        = state->m / state->a;
-    state->r        = state->m % state->a;
-
-    state->seed     = seed;
-				/* Check for illegal boundary conditions,
-                                   and choose closest legal value. */
-    if (state->seed <= 0)        state->seed = 1;
-    if (state->seed >= state->m) state->seed = state->m - 1;
-
-    return state;
-}
-
-int N(RandomDestroy)(void *state)
-{
-    RANDOM_FREE(state);
-    return 0;
-}
-
-unsigned long N(Random)(void *state)
-{
-    RandomState   *s = (RandomState *)state;
-    long          hi;
-    long          lo;
-
-    hi      = s->seed / s->q;
-    lo      = s->seed % s->q;
-    s->seed = s->a * lo - s->r * hi;
-    if (s->seed <= 0) s->seed += s->m;
-
-    return s->seed;
-}
-
-double N(RandomDouble)(void *state)
-{
-    RandomState *s = (RandomState *)state;
-    
-    return (double)N(Random)(state)/(double)s->m;
-}
-
-#if RANDOM_MAIN
-static void check_period(long seed)
-{
-    unsigned long count = 0;
-    unsigned long initial;
-    void          *state;
-    
-    state = N(RandomCreate)(seed);
-    initial = N(Random)(state);
-    ++count;
-    while (initial != N(Random)(state)) {
-	if (!++count) break;
-    }
-    printf("With seed of %10ld, period = %10lu (0x%08lx)\n",
-	   seed, count, count);
-    N(RandomDestroy)(state);
-}
-
-int main(void)
-{
-    RandomState   *state;
-    int           i;
-    unsigned long rand;
-
-    state = N(RandomCreate)(1);
-    for (i = 0; i < 10000; i++) {
-	rand = N(Random)(state);
-    }
-    printf("After 10000 iterations: %lu (%lu expected): %s\n",
-	   rand, state->check,
-	   rand - state->check ? "*INCORRECT*" : "CORRECT");
-    N(RandomDestroy)(state);
-
-    printf("Checking periods...\n");
-    check_period(1);
-    check_period(2);
-    check_period(31415926);
-    
-    return 0;
-}
-#endif
diff --git a/hw/xfree86/os-support/drm/xf86drmSL.c b/hw/xfree86/os-support/drm/xf86drmSL.c
deleted file mode 100644
index 36d8fd5..0000000
--- a/hw/xfree86/os-support/drm/xf86drmSL.c
+++ /dev/null
@@ -1,488 +0,0 @@
-/* xf86drmSL.c -- Skip list support
- * Created: Mon May 10 09:28:13 1999 by faith at precisioninsight.com
- *
- * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
- * 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
- * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- * 
- * Authors: Rickard E. (Rik) Faith <faith at valinux.com>
- *
- *
- * DESCRIPTION
- *
- * This file contains a straightforward skip list implementation.n
- *
- * FUTURE ENHANCEMENTS
- *
- * REFERENCES
- *
- * [Pugh90] William Pugh.  Skip Lists: A Probabilistic Alternative to
- * Balanced Trees. CACM 33(6), June 1990, pp. 668-676.
- *
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#define SL_MAIN 0
-
-#if SL_MAIN
-# include <stdio.h>
-# include <stdlib.h>
-#  include <sys/time.h>
-#else
-# include "drm.h"
-# include "xf86drm.h"
-# include "xf86.h"
-#endif
-
-#define N(x)  drm##x
-
-#define SL_LIST_MAGIC  0xfacade00LU
-#define SL_ENTRY_MAGIC 0x00fab1edLU
-#define SL_FREED_MAGIC 0xdecea5edLU
-#define SL_MAX_LEVEL   16
-#define SL_DEBUG       0
-#define SL_RANDOM_SEED 0xc01055a1LU
-
-#if SL_MAIN
-#define SL_ALLOC malloc
-#define SL_FREE  free
-#define SL_RANDOM_DECL        static int state = 0;
-#define SL_RANDOM_INIT(seed)  if (!state) { srandom(seed); ++state; }
-#define SL_RANDOM             random()
-#else
-#define SL_ALLOC drmMalloc
-#define SL_FREE  drmFree
-#define SL_RANDOM_DECL        static void *state = NULL
-#define SL_RANDOM_INIT(seed)  if (!state) state = drmRandomCreate(seed)
-#define SL_RANDOM             drmRandom(state)
-
-#endif
-
-typedef struct SLEntry {
-    unsigned long     magic;	   /* SL_ENTRY_MAGIC */
-    unsigned long     key;
-    void              *value;
-    int               levels;
-    struct SLEntry    *forward[1]; /* variable sized array */
-} SLEntry, *SLEntryPtr;
-
-typedef struct SkipList {
-    unsigned long    magic;	/* SL_LIST_MAGIC */
-    int              level;
-    int              count;
-    SLEntryPtr       head;
-    SLEntryPtr       p0;	/* Position for iteration */
-} SkipList, *SkipListPtr;
-
-#if SL_MAIN
-extern void *N(SLCreate)(void);
-extern int  N(SLDestroy)(void *l);
-extern int  N(SLLookup)(void *l, unsigned long key, void **value);
-extern int  N(SLInsert)(void *l, unsigned long key, void *value);
-extern int  N(SLDelete)(void *l, unsigned long key);
-extern int  N(SLNext)(void *l, unsigned long *key, void **value);
-extern int  N(SLFirst)(void *l, unsigned long *key, void **value);
-extern void N(SLDump)(void *l);
-extern int  N(SLLookupNeighbors)(void *l, unsigned long key,
-				 unsigned long *prev_key, void **prev_value,
-				 unsigned long *next_key, void **next_value);
-#endif
-
-static SLEntryPtr SLCreateEntry(int max_level, unsigned long key, void *value)
-{
-    SLEntryPtr entry;
-    
-    if (max_level < 0 || max_level > SL_MAX_LEVEL) max_level = SL_MAX_LEVEL;
-
-    entry         = SL_ALLOC(sizeof(*entry)
-			     + (max_level + 1) * sizeof(entry->forward[0]));
-    if (!entry) return NULL;
-    entry->magic  = SL_ENTRY_MAGIC;
-    entry->key    = key;
-    entry->value  = value;
-    entry->levels = max_level + 1;
-
-    return entry;
-}
-
-static int SLRandomLevel(void)
-{
-    int level = 1;
-    SL_RANDOM_DECL;
-
-    SL_RANDOM_INIT(SL_RANDOM_SEED);
-    
-    while ((SL_RANDOM & 0x01) && level < SL_MAX_LEVEL) ++level;
-    return level;
-}
-
-void *N(SLCreate)(void)
-{
-    SkipListPtr  list;
-    int          i;
-
-    list           = SL_ALLOC(sizeof(*list));
-    if (!list) return NULL;
-    list->magic    = SL_LIST_MAGIC;
-    list->level    = 0;
-    list->head     = SLCreateEntry(SL_MAX_LEVEL, 0, NULL);
-    list->count    = 0;
-
-    for (i = 0; i <= SL_MAX_LEVEL; i++) list->head->forward[i] = NULL;
-    
-    return list;
-}
-
-int N(SLDestroy)(void *l)
-{
-    SkipListPtr   list  = (SkipListPtr)l;
-    SLEntryPtr    entry;
-    SLEntryPtr    next;
-
-    if (list->magic != SL_LIST_MAGIC) return -1; /* Bad magic */
-
-    for (entry = list->head; entry; entry = next) {
-	if (entry->magic != SL_ENTRY_MAGIC) return -1; /* Bad magic */
-	next         = entry->forward[0];
-	entry->magic = SL_FREED_MAGIC;
-	SL_FREE(entry);
-    }
-
-    list->magic = SL_FREED_MAGIC;
-    SL_FREE(list);
-    return 0;
-}
-
-static SLEntryPtr SLLocate(void *l, unsigned long key, SLEntryPtr *update)
-{
-    SkipListPtr   list  = (SkipListPtr)l;
-    SLEntryPtr    entry;
-    int           i;
-
-    if (list->magic != SL_LIST_MAGIC) return NULL;
-
-    for (i = list->level, entry = list->head; i >= 0; i--) {
-	while (entry->forward[i] && entry->forward[i]->key < key)
-	    entry = entry->forward[i];
-	update[i] = entry;
-    }
-
-    return entry->forward[0];
-}
-
-int N(SLInsert)(void *l, unsigned long key, void *value)
-{
-    SkipListPtr   list  = (SkipListPtr)l;
-    SLEntryPtr    entry;
-    SLEntryPtr    update[SL_MAX_LEVEL + 1];
-    int           level;
-    int           i;
-
-    if (list->magic != SL_LIST_MAGIC) return -1; /* Bad magic */
-
-    entry = SLLocate(list, key, update);
-
-    if (entry && entry->key == key) return 1; /* Already in list */
-
-
-    level = SLRandomLevel();
-    if (level > list->level) {
-	level = ++list->level;
-	update[level] = list->head;
-    }
-
-    entry = SLCreateEntry(level, key, value);
-
-				/* Fix up forward pointers */
-    for (i = 0; i <= level; i++) {
-	entry->forward[i]     = update[i]->forward[i];
-	update[i]->forward[i] = entry;
-    }
-
-    ++list->count;
-    return 0;			/* Added to table */
-}
-
-int N(SLDelete)(void *l, unsigned long key)
-{
-    SkipListPtr   list = (SkipListPtr)l;
-    SLEntryPtr    update[SL_MAX_LEVEL + 1];
-    SLEntryPtr    entry;
-    int           i;
-
-    if (list->magic != SL_LIST_MAGIC) return -1; /* Bad magic */
-
-    entry = SLLocate(list, key, update);
-
-    if (!entry || entry->key != key) return 1; /* Not found */
-
-				/* Fix up forward pointers */
-    for (i = 0; i <= list->level; i++) {
-	if (update[i]->forward[i] == entry)
-	    update[i]->forward[i] = entry->forward[i];
-    }
-
-    entry->magic = SL_FREED_MAGIC;
-    SL_FREE(entry);
-
-    while (list->level && !list->head->forward[list->level]) --list->level;
-    --list->count;
-    return 0;
-}
-
-int N(SLLookup)(void *l, unsigned long key, void **value)
-{
-    SkipListPtr   list = (SkipListPtr)l;
-    SLEntryPtr    update[SL_MAX_LEVEL + 1];
-    SLEntryPtr    entry;
-
-    entry = SLLocate(list, key, update);
-
-    if (entry && entry->key == key) {
-	*value = entry;
-	return 0;
-    }
-    *value = NULL;
-    return -1;
-}
-
-int N(SLLookupNeighbors)(void *l, unsigned long key,
-			 unsigned long *prev_key, void **prev_value,
-			 unsigned long *next_key, void **next_value)
-{
-    SkipListPtr   list = (SkipListPtr)l;
-    SLEntryPtr    update[SL_MAX_LEVEL + 1];
-    SLEntryPtr    entry;
-    int           retcode = 0;
-
-    entry = SLLocate(list, key, update);
-
-    *prev_key   = *next_key   = key;
-    *prev_value = *next_value = NULL;
-	
-    if (update[0]) {
-	*prev_key   = update[0]->key;
-	*prev_value = update[0]->value;
-	++retcode;
-	if (update[0]->forward[0]) {
-	    *next_key   = update[0]->forward[0]->key;
-	    *next_value = update[0]->forward[0]->value;
-	    ++retcode;
-	}
-    }
-    return retcode;
-}
-
-int N(SLNext)(void *l, unsigned long *key, void **value)
-{
-    SkipListPtr   list = (SkipListPtr)l;
-    SLEntryPtr    entry;
-    
-    if (list->magic != SL_LIST_MAGIC) return -1; /* Bad magic */
-
-    entry    = list->p0;
-
-    if (entry) {
-	list->p0 = entry->forward[0];
-	*key     = entry->key;
-	*value   = entry->value;
-	return 1;
-    }
-    list->p0 = NULL;
-    return 0;
-}
-
-int N(SLFirst)(void *l, unsigned long *key, void **value)
-{
-    SkipListPtr   list = (SkipListPtr)l;
-    
-    if (list->magic != SL_LIST_MAGIC) return -1; /* Bad magic */
-    
-    list->p0 = list->head->forward[0];
-    return N(SLNext)(list, key, value);
-}
-
-/* Dump internal data structures for debugging. */
-void N(SLDump)(void *l)
-{
-    SkipListPtr   list = (SkipListPtr)l;
-    SLEntryPtr    entry;
-    int           i;
-    
-    if (list->magic != SL_LIST_MAGIC) {
-	printf("Bad magic: 0x%08lx (expected 0x%08lx)\n",
-	       list->magic, SL_LIST_MAGIC);
-	return;
-    }
-
-    printf("Level = %d, count = %d\n", list->level, list->count);
-    for (entry = list->head; entry; entry = entry->forward[0]) {
-	if (entry->magic != SL_ENTRY_MAGIC) {
-	    printf("Bad magic: 0x%08lx (expected 0x%08lx)\n",
-		   list->magic, SL_ENTRY_MAGIC);
-	}
-	printf("\nEntry %p <0x%08lx, %p> has %2d levels\n",
-	       entry, entry->key, entry->value, entry->levels);
-	for (i = 0; i < entry->levels; i++) {
-	    if (entry->forward[i]) {
-		printf("   %2d: %p <0x%08lx, %p>\n",
-		       i,
-		       entry->forward[i],
-		       entry->forward[i]->key,
-		       entry->forward[i]->value);
-	    } else {
-		printf("   %2d: %p\n", i, entry->forward[i]);
-	    }
-	}
-    }
-}
-
-#if SL_MAIN
-static void print(SkipListPtr list)
-{
-    unsigned long key;
-    void          *value;
-    
-    if (N(SLFirst)(list, &key, &value)) {
-	do {
-	    printf("key = %5lu, value = %p\n", key, value);
-	} while (N(SLNext)(list, &key, &value));
-    }
-}
-
-static double do_time(int size, int iter)
-{
-    SkipListPtr    list;
-    int            i, j;
-    unsigned long  keys[1000000];
-    unsigned long  previous;
-    unsigned long  key;
-    void           *value;
-    struct timeval start, stop;
-    double         usec;
-    SL_RANDOM_DECL;
-
-    SL_RANDOM_INIT(12345);
-    
-    list = N(SLCreate)();
-
-    for (i = 0; i < size; i++) {
-	keys[i] = SL_RANDOM;
-	N(SLInsert)(list, keys[i], NULL);
-    }
-
-    previous = 0;
-    if (N(SLFirst)(list, &key, &value)) {
-	do {
-	    if (key <= previous) {
-		printf( "%lu !< %lu\n", previous, key);
-	    }
-	    previous = key;
-	} while (N(SLNext)(list, &key, &value));
-    }
-    
-    gettimeofday(&start, NULL);
-    for (j = 0; j < iter; j++) {
-	for (i = 0; i < size; i++) {
-	    if (N(SLLookup)(list, keys[i], &value))
-		printf("Error %lu %d\n", keys[i], i);
-	}
-    }
-    gettimeofday(&stop, NULL);
-    
-    usec = (double)(stop.tv_sec * 1000000 + stop.tv_usec
-		    - start.tv_sec * 1000000 - start.tv_usec) / (size * iter);
-    
-    printf("%0.2f microseconds for list length %d\n", usec, size);
-
-    N(SLDestroy)(list);
-    
-    return usec;
-}
-
-static void print_neighbors(void *list, unsigned long key)
-{
-    unsigned long prev_key = 0;
-    unsigned long next_key = 0;
-    void          *prev_value;
-    void          *next_value;
-    int           retval;
-
-    retval = drmSLLookupNeighbors(list, key,
-				  &prev_key, &prev_value,
-				  &next_key, &next_value);
-    printf("Neighbors of %5lu: %d %5lu %5lu\n",
-	   key, retval, prev_key, next_key);
-}
-
-int main(void)
-{
-    SkipListPtr    list;
-    double         usec, usec2, usec3, usec4;
-
-    list = N(SLCreate)();
-    printf( "list at %p\n", list);
-
-    print(list);
-    printf("\n==============================\n\n");
-
-    N(SLInsert)(list, 123, NULL);
-    N(SLInsert)(list, 213, NULL);
-    N(SLInsert)(list, 50, NULL);
-    print(list);
-    printf("\n==============================\n\n");
-    
-    print_neighbors(list, 0);
-    print_neighbors(list, 50);
-    print_neighbors(list, 51);
-    print_neighbors(list, 123);
-    print_neighbors(list, 200);
-    print_neighbors(list, 213);
-    print_neighbors(list, 256);
-    printf("\n==============================\n\n");    
-    
-    N(SLDelete)(list, 50);
-    print(list);
-    printf("\n==============================\n\n");
-
-    N(SLDump)(list);
-    N(SLDestroy)(list);
-    printf("\n==============================\n\n");
-
-    usec  = do_time(100, 10000);
-    usec2 = do_time(1000, 500);
-    printf("Table size increased by %0.2f, search time increased by %0.2f\n",
-	   1000.0/100.0, usec2 / usec);
-    
-    usec3 = do_time(10000, 50);
-    printf("Table size increased by %0.2f, search time increased by %0.2f\n",
-	   10000.0/100.0, usec3 / usec);
-    
-    usec4 = do_time(100000, 4);
-    printf("Table size increased by %0.2f, search time increased by %0.2f\n",
-	   100000.0/100.0, usec4 / usec);
-
-    return 0;
-}
-#endif
diff --git a/hw/xfree86/os-support/xf86drm.h b/hw/xfree86/os-support/xf86drm.h
deleted file mode 100644
index 18e4564..0000000
--- a/hw/xfree86/os-support/xf86drm.h
+++ /dev/null
@@ -1,641 +0,0 @@
-/**
- * \file xf86drm.h 
- * OS-independent header for DRM user-level library interface.
- *
- * \author Rickard E. (Rik) Faith <faith at valinux.com>
- */
- 
-/*
- * Copyright 1999, 2000 Precision Insight, Inc., Cedar Park, Texas.
- * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
- * 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
- * PRECISION INSIGHT AND/OR ITS SUPPLIERS 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.
- *
- */
-
-
-#ifndef _XF86DRM_H_
-#define _XF86DRM_H_
-
-#include <drm.h>
-#include <xf86mm.h>
-
-				/* Defaults, if nothing set in xf86config */
-#define DRM_DEV_UID	 0
-#define DRM_DEV_GID	 0
-/* Default /dev/dri directory permissions 0755 */
-#define DRM_DEV_DIRMODE	 	\
-	(S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH)
-#define DRM_DEV_MODE	 (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP)
-
-#define DRM_DIR_NAME  "/dev/dri"
-#define DRM_DEV_NAME  "%s/card%d"
-#define DRM_PROC_NAME "/proc/dri/" /* For backward Linux compatibility */
-
-#define DRM_ERR_NO_DEVICE  (-1001)
-#define DRM_ERR_NO_ACCESS  (-1002)
-#define DRM_ERR_NOT_ROOT   (-1003)
-#define DRM_ERR_INVALID    (-1004)
-#define DRM_ERR_NO_FD      (-1005)
-
-#define DRM_AGP_NO_HANDLE 0
-
-typedef unsigned int  drmSize,     *drmSizePtr;	    /**< For mapped regions */
-typedef void          *drmAddress, **drmAddressPtr; /**< For mapped regions */
-
-/**
- * Driver version information.
- *
- * \sa drmGetVersion() and drmSetVersion().
- */
-typedef struct _drmVersion {
-    int     version_major;        /**< Major version */
-    int     version_minor;        /**< Minor version */
-    int     version_patchlevel;   /**< Patch level */
-    int     name_len; 	          /**< Length of name buffer */
-    char    *name;	          /**< Name of driver */
-    int     date_len;             /**< Length of date buffer */
-    char    *date;                /**< User-space buffer to hold date */
-    int     desc_len;	          /**< Length of desc buffer */
-    char    *desc;                /**< User-space buffer to hold desc */
-} drmVersion, *drmVersionPtr;
-
-typedef struct _drmStats {
-    unsigned long count;	     /**< Number of data */
-    struct {
-	unsigned long value;	     /**< Value from kernel */
-	const char    *long_format;  /**< Suggested format for long_name */
-	const char    *long_name;    /**< Long name for value */
-	const char    *rate_format;  /**< Suggested format for rate_name */
-	const char    *rate_name;    /**< Short name for value per second */
-	int           isvalue;       /**< True if value (vs. counter) */
-	const char    *mult_names;   /**< Multiplier names (e.g., "KGM") */
-	int           mult;          /**< Multiplier value (e.g., 1024) */
-	int           verbose;       /**< Suggest only in verbose output */
-    } data[15];
-} drmStatsT;
-
-
-				/* All of these enums *MUST* match with the
-                                   kernel implementation -- so do *NOT*
-                                   change them!  (The drmlib implementation
-                                   will just copy the flags instead of
-                                   translating them.) */
-typedef enum {
-    DRM_FRAME_BUFFER    = 0,      /**< WC, no caching, no core dump */
-    DRM_REGISTERS       = 1,      /**< no caching, no core dump */
-    DRM_SHM             = 2,      /**< shared, cached */
-    DRM_AGP             = 3,	  /**< AGP/GART */
-    DRM_SCATTER_GATHER  = 4,	  /**< PCI scatter/gather */
-    DRM_CONSISTENT      = 5	  /**< PCI consistent */
-} drmMapType;
-
-typedef enum {
-    DRM_RESTRICTED      = 0x0001, /**< Cannot be mapped to client-virtual */
-    DRM_READ_ONLY       = 0x0002, /**< Read-only in client-virtual */
-    DRM_LOCKED          = 0x0004, /**< Physical pages locked */
-    DRM_KERNEL          = 0x0008, /**< Kernel requires access */
-    DRM_WRITE_COMBINING = 0x0010, /**< Use write-combining, if available */
-    DRM_CONTAINS_LOCK   = 0x0020, /**< SHM page that contains lock */
-    DRM_REMOVABLE	= 0x0040  /**< Removable mapping */
-} drmMapFlags;
-
-/**
- * \warning These values *MUST* match drm.h
- */
-typedef enum {
-    /** \name Flags for DMA buffer dispatch */
-    /*@{*/
-    DRM_DMA_BLOCK        = 0x01, /**< 
-				  * Block until buffer dispatched.
-				  * 
-				  * \note the buffer may not yet have been
-				  * processed by the hardware -- getting a
-				  * hardware lock with the hardware quiescent
-				  * will ensure that the buffer has been
-				  * processed.
-				  */
-    DRM_DMA_WHILE_LOCKED = 0x02, /**< Dispatch while lock held */
-    DRM_DMA_PRIORITY     = 0x04, /**< High priority dispatch */
-    /*@}*/
-
-    /** \name Flags for DMA buffer request */
-    /*@{*/
-    DRM_DMA_WAIT         = 0x10, /**< Wait for free buffers */
-    DRM_DMA_SMALLER_OK   = 0x20, /**< Smaller-than-requested buffers OK */
-    DRM_DMA_LARGER_OK    = 0x40  /**< Larger-than-requested buffers OK */
-    /*@}*/
-} drmDMAFlags;
-
-typedef enum {
-    DRM_PAGE_ALIGN       = 0x01,
-    DRM_AGP_BUFFER       = 0x02,
-    DRM_SG_BUFFER        = 0x04,
-    DRM_FB_BUFFER        = 0x08
-} drmBufDescFlags;
-
-typedef enum {
-    DRM_LOCK_READY      = 0x01, /**< Wait until hardware is ready for DMA */
-    DRM_LOCK_QUIESCENT  = 0x02, /**< Wait until hardware quiescent */
-    DRM_LOCK_FLUSH      = 0x04, /**< Flush this context's DMA queue first */
-    DRM_LOCK_FLUSH_ALL  = 0x08, /**< Flush all DMA queues first */
-				/* These *HALT* flags aren't supported yet
-                                   -- they will be used to support the
-                                   full-screen DGA-like mode. */
-    DRM_HALT_ALL_QUEUES = 0x10, /**< Halt all current and future queues */
-    DRM_HALT_CUR_QUEUES = 0x20  /**< Halt all current queues */
-} drmLockFlags;
-
-typedef enum {
-    DRM_CONTEXT_PRESERVED = 0x01, /**< This context is preserved and
-				     never swapped. */
-    DRM_CONTEXT_2DONLY    = 0x02  /**< This context is for 2D rendering only. */
-} drm_context_tFlags, *drm_context_tFlagsPtr;
-
-typedef struct _drmBufDesc {
-    int              count;	  /**< Number of buffers of this size */
-    int              size;	  /**< Size in bytes */
-    int              low_mark;	  /**< Low water mark */
-    int              high_mark;	  /**< High water mark */
-} drmBufDesc, *drmBufDescPtr;
-
-typedef struct _drmBufInfo {
-    int              count;	  /**< Number of buffers described in list */
-    drmBufDescPtr    list;	  /**< List of buffer descriptions */
-} drmBufInfo, *drmBufInfoPtr;
-
-typedef struct _drmBuf {
-    int              idx;	  /**< Index into the master buffer list */
-    int              total;	  /**< Buffer size */
-    int              used;	  /**< Amount of buffer in use (for DMA) */
-    drmAddress       address;	  /**< Address */
-} drmBuf, *drmBufPtr;
-
-/**
- * Buffer mapping information.
- *
- * Used by drmMapBufs() and drmUnmapBufs() to store information about the
- * mapped buffers.
- */
-typedef struct _drmBufMap {
-    int              count;	  /**< Number of buffers mapped */
-    drmBufPtr        list;	  /**< Buffers */
-} drmBufMap, *drmBufMapPtr;
-
-typedef struct _drmLock {
-    volatile unsigned int lock;
-    char                      padding[60];
-    /* This is big enough for most current (and future?) architectures:
-       DEC Alpha:              32 bytes
-       Intel Merced:           ?
-       Intel P5/PPro/PII/PIII: 32 bytes
-       Intel StrongARM:        32 bytes
-       Intel i386/i486:        16 bytes
-       MIPS:                   32 bytes (?)
-       Motorola 68k:           16 bytes
-       Motorola PowerPC:       32 bytes
-       Sun SPARC:              32 bytes
-    */
-} drmLock, *drmLockPtr;
-
-/**
- * Indices here refer to the offset into
- * list in drmBufInfo
- */
-typedef struct _drmDMAReq {
-    drm_context_t    context;  	  /**< Context handle */
-    int           send_count;     /**< Number of buffers to send */
-    int           *send_list;     /**< List of handles to buffers */
-    int           *send_sizes;    /**< Lengths of data to send, in bytes */
-    drmDMAFlags   flags;          /**< Flags */
-    int           request_count;  /**< Number of buffers requested */
-    int           request_size;	  /**< Desired size of buffers requested */
-    int           *request_list;  /**< Buffer information */
-    int           *request_sizes; /**< Minimum acceptable sizes */
-    int           granted_count;  /**< Number of buffers granted at this size */
-} drmDMAReq, *drmDMAReqPtr;
-
-typedef struct _drmRegion {
-    drm_handle_t     handle;
-    unsigned int  offset;
-    drmSize       size;
-    drmAddress    map;
-} drmRegion, *drmRegionPtr;
-
-typedef struct _drmTextureRegion {
-    unsigned char next;
-    unsigned char prev;
-    unsigned char in_use;
-    unsigned char padding;	/**< Explicitly pad this out */
-    unsigned int  age;
-} drmTextureRegion, *drmTextureRegionPtr;
-
-
-typedef enum {
-    DRM_VBLANK_ABSOLUTE = 0x0,	/**< Wait for specific vblank sequence number */
-    DRM_VBLANK_RELATIVE = 0x1,	/**< Wait for given number of vblanks */
-    DRM_VBLANK_SIGNAL   = 0x40000000	/* Send signal instead of blocking */
-} drmVBlankSeqType;
-
-typedef struct _drmVBlankReq {
-	drmVBlankSeqType type;
-	unsigned int sequence;
-	unsigned long signal;
-} drmVBlankReq, *drmVBlankReqPtr;
-
-typedef struct _drmVBlankReply {
-	drmVBlankSeqType type;
-	unsigned int sequence;
-	long tval_sec;
-	long tval_usec;
-} drmVBlankReply, *drmVBlankReplyPtr;
-
-typedef union _drmVBlank {
-	drmVBlankReq request;
-	drmVBlankReply reply;
-} drmVBlank, *drmVBlankPtr;
-
-typedef struct _drmSetVersion {
-	int drm_di_major;
-	int drm_di_minor;
-	int drm_dd_major;
-	int drm_dd_minor;
-} drmSetVersion, *drmSetVersionPtr;
-
-
-#define __drm_dummy_lock(lock) (*(__volatile__ unsigned int *)lock)
-
-#define DRM_LOCK_HELD  0x80000000U /**< Hardware lock is held */
-#define DRM_LOCK_CONT  0x40000000U /**< Hardware lock is contended */
-
-#if defined(__GNUC__) && (__GNUC__ >= 2)
-# if defined(__i386) || defined(__AMD64__) || defined(__x86_64__) || defined(__amd64__)
-				/* Reflect changes here to drmP.h */
-#define DRM_CAS(lock,old,new,__ret)                                    \
-	do {                                                           \
-                int __dummy;	/* Can't mark eax as clobbered */      \
-		__asm__ __volatile__(                                  \
-			"lock ; cmpxchg %4,%1\n\t"                     \
-                        "setnz %0"                                     \
-			: "=d" (__ret),                                \
-   			  "=m" (__drm_dummy_lock(lock)),               \
-                          "=a" (__dummy)                               \
-			: "2" (old),                                   \
-			  "r" (new));                                  \
-	} while (0)
-
-#elif defined(__alpha__)
-
-#define	DRM_CAS(lock, old, new, ret) 		\
- 	do {					\
- 		int old32;                      \
- 		int cur32;			\
- 		__asm__ __volatile__(		\
- 		"       mb\n"			\
- 		"       zap   %4, 0xF0, %0\n"   \
- 		"       ldl_l %1, %2\n"		\
- 		"       zap   %1, 0xF0, %1\n"   \
-                "       cmpeq %0, %1, %1\n"	\
-                "       beq   %1, 1f\n"		\
- 		"       bis   %5, %5, %1\n"	\
-                "       stl_c %1, %2\n"		\
-                "1:     xor   %1, 1, %1\n"	\
-                "       stl   %1, %3"		\
-                : "=r" (old32),                 \
-		  "=&r" (cur32),		\
-                   "=m" (__drm_dummy_lock(lock)),\
-                   "=m" (ret)			\
- 		: "r" (old),			\
- 		  "r" (new));			\
- 	} while(0)
-
-#elif defined(__sparc__)
-
-#define DRM_CAS(lock,old,new,__ret)				\
-do {	register unsigned int __old __asm("o0");		\
-	register unsigned int __new __asm("o1");		\
-	register volatile unsigned int *__lock __asm("o2");	\
-	__old = old;						\
-	__new = new;						\
-	__lock = (volatile unsigned int *)lock;			\
-	__asm__ __volatile__(					\
-		/*"cas [%2], %3, %0"*/				\
-		".word 0xd3e29008\n\t"				\
-		/*"membar #StoreStore | #StoreLoad"*/		\
-		".word 0x8143e00a"				\
-		: "=&r" (__new)					\
-		: "0" (__new),					\
-		  "r" (__lock),					\
-		  "r" (__old)					\
-		: "memory");					\
-	__ret = (__new != __old);				\
-} while(0)
-
-#elif defined(__ia64__)
-
-#ifdef __INTEL_COMPILER
-/* this currently generates bad code (missing stop bits)... */
-#include <ia64intrin.h>
-
-#define DRM_CAS(lock,old,new,__ret)					      \
-	do {								      \
-		unsigned long __result, __old = (old) & 0xffffffff;		\
-		__mf();							      	\
-		__result = _InterlockedCompareExchange_acq(&__drm_dummy_lock(lock), (new), __old);\
-		__ret = (__result) != (__old);					\
-/*		__ret = (__sync_val_compare_and_swap(&__drm_dummy_lock(lock), \
-						     (old), (new))	      \
-			 != (old));					      */\
-	} while (0)
-
-#else
-#define DRM_CAS(lock,old,new,__ret)					  \
-	do {								  \
-		unsigned int __result, __old = (old);			  \
-		__asm__ __volatile__(					  \
-			"mf\n"						  \
-			"mov ar.ccv=%2\n"				  \
-			";;\n"						  \
-			"cmpxchg4.acq %0=%1,%3,ar.ccv"			  \
-			: "=r" (__result), "=m" (__drm_dummy_lock(lock))  \
-			: "r" ((unsigned long)__old), "r" (new)			  \
-			: "memory");					  \
-		__ret = (__result) != (__old);				  \
-	} while (0)
-
-#endif
-
-#elif defined(__powerpc__)
-
-#define DRM_CAS(lock,old,new,__ret)			\
-	do {						\
-		__asm__ __volatile__(			\
-			"sync;"				\
-			"0:    lwarx %0,0,%1;"		\
-			"      xor. %0,%3,%0;"		\
-			"      bne 1f;"			\
-			"      stwcx. %2,0,%1;"		\
-			"      bne- 0b;"		\
-			"1:    "			\
-			"sync;"				\
-		: "=&r"(__ret)				\
-		: "r"(lock), "r"(new), "r"(old)		\
-		: "cr0", "memory");			\
-	} while (0)
-
-#endif /* architecture */
-#endif /* __GNUC__ >= 2 */
-
-#ifndef DRM_CAS
-#define DRM_CAS(lock,old,new,ret) do { ret=1; } while (0) /* FAST LOCK FAILS */
-#endif
-
-#if defined(__alpha__) || defined(__powerpc__)
-#define DRM_CAS_RESULT(_result)		int _result
-#else
-#define DRM_CAS_RESULT(_result)		char _result
-#endif
-
-#define DRM_LIGHT_LOCK(fd,lock,context)                                \
-	do {                                                           \
-                DRM_CAS_RESULT(__ret);                                 \
-		DRM_CAS(lock,context,DRM_LOCK_HELD|context,__ret);     \
-                if (__ret) drmGetLock(fd,context,0);                   \
-        } while(0)
-
-				/* This one counts fast locks -- for
-                                   benchmarking only. */
-#define DRM_LIGHT_LOCK_COUNT(fd,lock,context,count)                    \
-	do {                                                           \
-                DRM_CAS_RESULT(__ret);                                 \
-		DRM_CAS(lock,context,DRM_LOCK_HELD|context,__ret);     \
-                if (__ret) drmGetLock(fd,context,0);                   \
-                else       ++count;                                    \
-        } while(0)
-
-#define DRM_LOCK(fd,lock,context,flags)                                \
-	do {                                                           \
-		if (flags) drmGetLock(fd,context,flags);               \
-		else       DRM_LIGHT_LOCK(fd,lock,context);            \
-	} while(0)
-
-#define DRM_UNLOCK(fd,lock,context)                                    \
-	do {                                                           \
-                DRM_CAS_RESULT(__ret);                                 \
-		DRM_CAS(lock,DRM_LOCK_HELD|context,context,__ret);     \
-                if (__ret) drmUnlock(fd,context);                      \
-        } while(0)
-
-				/* Simple spin locks */
-#define DRM_SPINLOCK(spin,val)                                         \
-	do {                                                           \
-            DRM_CAS_RESULT(__ret);                                     \
-	    do {                                                       \
-		DRM_CAS(spin,0,val,__ret);                             \
-		if (__ret) while ((spin)->lock);                       \
-	    } while (__ret);                                           \
-	} while(0)
-
-#define DRM_SPINLOCK_TAKE(spin,val)                                    \
-	do {                                                           \
-            DRM_CAS_RESULT(__ret);                                     \
-            int  cur;                                                  \
-	    do {                                                       \
-                cur = (*spin).lock;                                    \
-		DRM_CAS(spin,cur,val,__ret);                           \
-	    } while (__ret);                                           \
-	} while(0)
-
-#define DRM_SPINLOCK_COUNT(spin,val,count,__ret)                       \
-	do {                                                           \
-            int  __i;                                                  \
-            __ret = 1;                                                 \
-            for (__i = 0; __ret && __i < count; __i++) {               \
-		DRM_CAS(spin,0,val,__ret);                             \
-		if (__ret) for (;__i < count && (spin)->lock; __i++);  \
-	    }                                                          \
-	} while(0)
-
-#define DRM_SPINUNLOCK(spin,val)                                       \
-	do {                                                           \
-            DRM_CAS_RESULT(__ret);                                     \
-            if ((*spin).lock == val) { /* else server stole lock */    \
-	        do {                                                   \
-		    DRM_CAS(spin,val,0,__ret);                         \
-	        } while (__ret);                                       \
-            }                                                          \
-	} while(0)
-
-/* General user-level programmer's API: unprivileged */
-extern int           drmAvailable(void);
-extern int           drmOpen(const char *name, const char *busid);
-extern int           drmClose(int fd);
-extern drmVersionPtr drmGetVersion(int fd);
-extern drmVersionPtr drmGetLibVersion(int fd);
-extern void          drmFreeVersion(drmVersionPtr);
-extern int           drmGetMagic(int fd, drm_magic_t * magic);
-extern char          *drmGetBusid(int fd);
-extern int           drmGetInterruptFromBusID(int fd, int busnum, int devnum,
-					      int funcnum);
-extern int           drmGetMap(int fd, int idx, drm_handle_t *offset,
-			       drmSize *size, drmMapType *type,
-			       drmMapFlags *flags, drm_handle_t *handle,
-			       int *mtrr);
-extern int           drmGetClient(int fd, int idx, int *auth, int *pid,
-				  int *uid, unsigned long *magic,
-				  unsigned long *iocs);
-extern int           drmGetStats(int fd, drmStatsT *stats);
-extern int           drmSetInterfaceVersion(int fd, drmSetVersion *version);
-extern int           drmCommandNone(int fd, unsigned long drmCommandIndex);
-extern int           drmCommandRead(int fd, unsigned long drmCommandIndex,
-                                    void *data, unsigned long size);
-extern int           drmCommandWrite(int fd, unsigned long drmCommandIndex,
-                                     void *data, unsigned long size);
-extern int           drmCommandWriteRead(int fd, unsigned long drmCommandIndex,
-                                         void *data, unsigned long size);
-
-/* General user-level programmer's API: X server (root) only  */
-extern void          drmFreeBusid(const char *busid);
-extern int           drmSetBusid(int fd, const char *busid);
-extern int           drmAuthMagic(int fd, drm_magic_t magic);
-extern int           drmAddMap(int fd,
-			       drm_handle_t offset,
-			       drmSize size,
-			       drmMapType type,
-			       drmMapFlags flags,
-			       drm_handle_t * handle);
-extern int	     drmRmMap(int fd, drm_handle_t handle);
-extern int	     drmAddContextPrivateMapping(int fd, drm_context_t ctx_id,
-						 drm_handle_t handle);
-
-extern int           drmAddBufs(int fd, int count, int size,
-				drmBufDescFlags flags,
-				int agp_offset);
-extern int           drmMarkBufs(int fd, double low, double high);
-extern int           drmCreateContext(int fd, drm_context_t * handle);
-extern int           drmSetContextFlags(int fd, drm_context_t context,
-					drm_context_tFlags flags);
-extern int           drmGetContextFlags(int fd, drm_context_t context,
-					drm_context_tFlagsPtr flags);
-extern int           drmAddContextTag(int fd, drm_context_t context, void *tag);
-extern int           drmDelContextTag(int fd, drm_context_t context);
-extern void          *drmGetContextTag(int fd, drm_context_t context);
-extern drm_context_t * drmGetReservedContextList(int fd, int *count);
-extern void          drmFreeReservedContextList(drm_context_t *);
-extern int           drmSwitchToContext(int fd, drm_context_t context);
-extern int           drmDestroyContext(int fd, drm_context_t handle);
-extern int           drmCreateDrawable(int fd, drm_drawable_t * handle);
-extern int           drmDestroyDrawable(int fd, drm_drawable_t handle);
-extern int           drmUpdateDrawableInfo(int fd, drm_drawable_t handle,
-					   drm_drawable_info_type_t type,
-					   unsigned int num, void *data);
-extern int           drmCtlInstHandler(int fd, int irq);
-extern int           drmCtlUninstHandler(int fd);
-extern int           drmInstallSIGIOHandler(int fd,
-					    void (*f)(int fd,
-						      void *oldctx,
-						      void *newctx));
-extern int           drmRemoveSIGIOHandler(int fd);
-
-/* General user-level programmer's API: authenticated client and/or X */
-extern int           drmMap(int fd,
-			    drm_handle_t handle,
-			    drmSize size,
-			    drmAddressPtr address);
-extern int           drmUnmap(drmAddress address, drmSize size);
-extern drmBufInfoPtr drmGetBufInfo(int fd);
-extern drmBufMapPtr  drmMapBufs(int fd);
-extern int           drmUnmapBufs(drmBufMapPtr bufs);
-extern int           drmDMA(int fd, drmDMAReqPtr request);
-extern int           drmFreeBufs(int fd, int count, int *list);
-extern int           drmGetLock(int fd,
-			        drm_context_t context,
-			        drmLockFlags flags);
-extern int           drmUnlock(int fd, drm_context_t context);
-extern int           drmFinish(int fd, int context, drmLockFlags flags);
-extern int	     drmGetContextPrivateMapping(int fd, drm_context_t ctx_id, 
-						 drm_handle_t * handle);
-
-/* AGP/GART support: X server (root) only */
-extern int           drmAgpAcquire(int fd);
-extern int           drmAgpRelease(int fd);
-extern int           drmAgpEnable(int fd, unsigned long mode);
-extern int           drmAgpAlloc(int fd, unsigned long size,
-				 unsigned long type, unsigned long *address,
-				 drm_handle_t *handle);
-extern int           drmAgpFree(int fd, drm_handle_t handle);
-extern int 	     drmAgpBind(int fd, drm_handle_t handle,
-				unsigned long offset);
-extern int           drmAgpUnbind(int fd, drm_handle_t handle);
-
-/* AGP/GART info: authenticated client and/or X */
-extern int           drmAgpVersionMajor(int fd);
-extern int           drmAgpVersionMinor(int fd);
-extern unsigned long drmAgpGetMode(int fd);
-extern unsigned long drmAgpBase(int fd); /* Physical location */
-extern unsigned long drmAgpSize(int fd); /* Bytes */
-extern unsigned long drmAgpMemoryUsed(int fd);
-extern unsigned long drmAgpMemoryAvail(int fd);
-extern unsigned int  drmAgpVendorId(int fd);
-extern unsigned int  drmAgpDeviceId(int fd);
-
-/* PCI scatter/gather support: X server (root) only */
-extern int           drmScatterGatherAlloc(int fd, unsigned long size,
-					   drm_handle_t *handle);
-extern int           drmScatterGatherFree(int fd, drm_handle_t handle);
-
-extern int           drmWaitVBlank(int fd, drmVBlankPtr vbl);
-
-/* Support routines */
-extern int           drmError(int err, const char *label);
-extern void          *drmMalloc(int size);
-extern void          drmFree(void *pt);
-
-/* Hash table routines */
-extern void *drmHashCreate(void);
-extern int  drmHashDestroy(void *t);
-extern int  drmHashLookup(void *t, unsigned long key, void **value);
-extern int  drmHashInsert(void *t, unsigned long key, void *value);
-extern int  drmHashDelete(void *t, unsigned long key);
-extern int  drmHashFirst(void *t, unsigned long *key, void **value);
-extern int  drmHashNext(void *t, unsigned long *key, void **value);
-
-/* PRNG routines */
-extern void          *drmRandomCreate(unsigned long seed);
-extern int           drmRandomDestroy(void *state);
-extern unsigned long drmRandom(void *state);
-extern double        drmRandomDouble(void *state);
-
-/* Skip list routines */
-
-extern void *drmSLCreate(void);
-extern int  drmSLDestroy(void *l);
-extern int  drmSLLookup(void *l, unsigned long key, void **value);
-extern int  drmSLInsert(void *l, unsigned long key, void *value);
-extern int  drmSLDelete(void *l, unsigned long key);
-extern int  drmSLNext(void *l, unsigned long *key, void **value);
-extern int  drmSLFirst(void *l, unsigned long *key, void **value);
-extern void drmSLDump(void *l);
-extern int  drmSLLookupNeighbors(void *l, unsigned long key,
-				 unsigned long *prev_key, void **prev_value,
-				 unsigned long *next_key, void **next_value);
-
-#endif
diff-tree 0409e1627a167db2efc1355f292d3c02a6989ffc (from 7e0aeebb8f8a5dff3cb4d88756e535dd70edeec4)
Author: Adam Jackson <ajax at benzedrine.nwnk.net>
Date:   Wed Nov 8 16:17:20 2006 -0500

    'make dist' fixes.

diff --git a/GL/glx/Makefile.am b/GL/glx/Makefile.am
index 44d9cf9..8184f60 100644
--- a/GL/glx/Makefile.am
+++ b/GL/glx/Makefile.am
@@ -28,7 +28,11 @@ INCLUDES = \
 	-I$(top_srcdir)/mi
 
 
-nodist_libglx_la_SOURCES = indirect_size.h
+nodist_libglx_la_SOURCES = indirect_size.h \
+			   glapi.c \
+			   glcontextmodes.c \
+			   glcontextmode.h \
+			   glthread.c
 
 libglxdri_la_SOURCES = \
         glxdri.c \
@@ -37,10 +41,6 @@ libglxdri_la_SOURCES = \
 
 libglx_la_SOURCES = \
         g_disptab.h \
-        glapi.c \
-        glcontextmodes.c \
-        glcontextmodes.h \
-        glthread.c \
         glxcmds.c \
         glxcmdsswap.c \
         glxcontext.h \
diff --git a/hw/xfree86/doc/Makefile.am b/hw/xfree86/doc/Makefile.am
index 55e69b0..6d8f4d2 100644
--- a/hw/xfree86/doc/Makefile.am
+++ b/hw/xfree86/doc/Makefile.am
@@ -5,9 +5,6 @@ SUBDIRS = man
 endif
 
 EXTRA_DIST = \
-	changelogs/CHANGELOG \
-	changelogs/CHANGELOG.ND \
-	changelogs/CHANGELOG.R5 \
 	README.DRI \
 	README.fonts \
 	README.rapidaccess
diff-tree 7e0aeebb8f8a5dff3cb4d88756e535dd70edeec4 (from b5d09d4adb8088719ff494a4281a793717046576)
Author: Adam Jackson <ajax at benzedrine.nwnk.net>
Date:   Wed Nov 8 12:03:37 2006 -0500

    Bug #6786: Use separate defines for server's Fixes support level.

diff --git a/xfixes/xfixes.c b/xfixes/xfixes.c
index a0e656d..cee9e09 100755
--- a/xfixes/xfixes.c
+++ b/xfixes/xfixes.c
@@ -48,6 +48,13 @@
 
 #include "xfixesint.h"
 
+/*
+ * Must use these instead of the constants from xfixeswire.h.  They advertise
+ * what we implement, not what the protocol headers define.
+ */
+#define SERVER_XFIXES_MAJOR 4
+#define SERVER_XFIXES_MINOR 0
+
 unsigned char	XFixesReqCode;
 int		XFixesEventBase;
 int		XFixesErrorBase;
@@ -65,16 +72,16 @@ ProcXFixesQueryVersion(ClientPtr client)
     rep.type = X_Reply;
     rep.length = 0;
     rep.sequenceNumber = client->sequence;
-    if (stuff->majorVersion < XFIXES_MAJOR) {
+    if (stuff->majorVersion < SERVER_XFIXES_MAJOR) {
 	rep.majorVersion = stuff->majorVersion;
 	rep.minorVersion = stuff->minorVersion;
     } else {
-	rep.majorVersion = XFIXES_MAJOR;
-	if (stuff->majorVersion == XFIXES_MAJOR && 
-	    stuff->minorVersion < XFIXES_MINOR)
+	rep.majorVersion = SERVER_XFIXES_MAJOR;
+	if (stuff->majorVersion == SERVER_XFIXES_MAJOR && 
+	    stuff->minorVersion < SERVER_XFIXES_MINOR)
 	    rep.minorVersion = stuff->minorVersion;
 	else
-	    rep.minorVersion = XFIXES_MINOR;
+	    rep.minorVersion = SERVER_XFIXES_MINOR;
     }
     pXFixesClient->major_version = rep.majorVersion;
     pXFixesClient->minor_version = rep.minorVersion;
diff-tree b5d09d4adb8088719ff494a4281a793717046576 (from 0567a6337b84fa045b5732e98203f488274aa2a2)
Author: Rich Coe <Richard.Coe at med.ge.com>
Date:   Wed Nov 8 18:10:14 2006 +0200

    CheckConnections: don't close down the server client (bug #7876)
    When an appgroup is shutting down, the list of clients can change, so make
    sure we're not trying to shut the server down.

diff --git a/os/connection.c b/os/connection.c
index 95c5500..100f1e5 100644
--- a/os/connection.c
+++ b/os/connection.c
@@ -1045,7 +1045,7 @@ CheckConnections(void)
 	FD_ZERO(&tmask);
 	FD_SET(curclient, &tmask);
 	r = Select (curclient + 1, &tmask, NULL, NULL, &notime);
-	if (r < 0)
+	if (r < 0 && GetConnectionTranslation(curclient) > 0)
 	    CloseDownClient(clients[GetConnectionTranslation(curclient)]);
     }	
 #endif
diff-tree 0567a6337b84fa045b5732e98203f488274aa2a2 (from e7900d68c3ee657158813f0650886d680c0a9a3c)
Author: Bram Verweij <amverweij at gmail.com>
Date:   Wed Nov 8 18:00:52 2006 +0200

    xfree86/linux acpi: fix tokenising
    Split on a space, rather on the 'video' string, as strtok takes a char,
    not a string.

diff --git a/hw/xfree86/os-support/linux/lnx_acpi.c b/hw/xfree86/os-support/linux/lnx_acpi.c
index aa30e72..024e6ef 100644
--- a/hw/xfree86/os-support/linux/lnx_acpi.c
+++ b/hw/xfree86/os-support/linux/lnx_acpi.c
@@ -78,7 +78,7 @@ lnxACPIGetEventFromOs(int fd, pmEvent *e
 	char *data = NULL; /* doesn't appear to be used in the kernel */
 	unsigned long int notify_l, data_l;
 
-	video = strtok(ev, "video");
+	video = strtok(ev, " ");
 
 	GFX = strtok(NULL, " ");
 #if 0
diff-tree e7900d68c3ee657158813f0650886d680c0a9a3c (from 2035f115b7db3c4b7deabeab0d814b3107d6ef30)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Wed Nov 8 15:36:47 2006 +0200

    remove trailing whitespace
    Whitespace police in full effect.

diff --git a/dix/getevents.c b/dix/getevents.c
index 4a3ee8e..c1b8840 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -168,7 +168,7 @@ updateMotionHistory(DeviceIntPtr pDev, C
 
     pDev->valuator->last_motion = (pDev->valuator->last_motion + 1) %
                                   pDev->valuator->numMotionEvents;
-    
+
     /* If we're wrapping around, just keep the circular buffer going. */
     if (pDev->valuator->first_motion == pDev->valuator->last_motion)
         pDev->valuator->first_motion = (pDev->valuator->first_motion + 1) %
@@ -745,7 +745,7 @@ SwitchCoreKeyboard(DeviceIntPtr pDev)
  * Currently a no-op.
  *
  * Call this just before processInputProc.
- */ 
+ */
 _X_EXPORT void
 SwitchCorePointer(DeviceIntPtr pDev)
 {
diff --git a/hw/xfree86/common/xf86Events.c b/hw/xfree86/common/xf86Events.c
index 905c56a..5469426 100644
--- a/hw/xfree86/common/xf86Events.c
+++ b/hw/xfree86/common/xf86Events.c
@@ -372,7 +372,7 @@ xf86ProcessActionEvent(ActionEvent actio
 #endif
 	    /* Okay the message made it to the ddx.  The common layer */
 	    /* can check for relevant messages here and react to any  */
-	    /* that have a global effect.  For example:               */ 
+	    /* that have a global effect.  For example:               */
 	    /*                                                        */
 	    /* if (!strcmp(message, "foo") {                          */
 	    /*      do_foo(); break                                   */
@@ -457,9 +457,9 @@ xf86Wakeup(pointer blockData, int err, p
 		if (pInfo->read_input && pInfo->fd >= 0 &&
 		    (FD_ISSET(pInfo->fd, &devicesWithInput) != 0)) {
 		    int sigstate = xf86BlockSIGIO();
-		    
+
 		    pInfo->read_input(pInfo);
-		    xf86UnblockSIGIO(sigstate);		    
+		    xf86UnblockSIGIO(sigstate);
 		    /*
 		     * Remove the descriptior from the set because more than one
 		     * device may share the same file descriptor.
@@ -478,9 +478,9 @@ xf86Wakeup(pointer blockData, int err, p
     while (pInfo) {
 		if (pInfo->read_input && pInfo->fd >= 0) {
 		    int sigstate = xf86BlockSIGIO();
-		    
+
 		    pInfo->read_input(pInfo);
-		    xf86UnblockSIGIO(sigstate);		    
+		    xf86UnblockSIGIO(sigstate);
 		    /*
 		     * Must break here because more than one device may share
 		     * the same file descriptor.
@@ -502,7 +502,7 @@ xf86Wakeup(pointer blockData, int err, p
 	    }
 	}
     }
-    
+
     if (xf86VTSwitchPending()) xf86VTSwitch();
 
     if (xf86Info.inputPending) ProcessInputEvents();
@@ -527,7 +527,7 @@ xf86SigioReadInput(int fd,
 
 /*
  * xf86AddEnabledDevice --
- *    
+ *
  */
 _X_EXPORT void
 xf86AddEnabledDevice(InputInfoPtr pInfo)
@@ -539,7 +539,7 @@ xf86AddEnabledDevice(InputInfoPtr pInfo)
 
 /*
  * xf86RemoveEnabledDevice --
- *    
+ *
  */
 _X_EXPORT void
 xf86RemoveEnabledDevice(InputInfoPtr pInfo)
@@ -560,7 +560,7 @@ xf86InterceptSignals(int *signo)
 
 static void (*xf86SigIllHandler)(void) = NULL;
 
-_X_EXPORT void 
+_X_EXPORT void
 xf86InterceptSigIll(void (*sigillhandler)(void))
 {
     xf86SigIllHandler = sigillhandler;
@@ -608,7 +608,7 @@ static int xorg_backtrace_frame(uintptr_
     ElfSym *dlsym;
     char header[32];
     int depth = *((int *) arg);
-    
+
     if (signo) {
 	char signame[SIG2STR_MAX];
 
@@ -621,7 +621,7 @@ static int xorg_backtrace_frame(uintptr_
 
     snprintf(header, sizeof(header), "%d: 0x%lx", depth, pc);
     *((int *) arg) = depth + 1;
-    
+
     /* Ask system dynamic loader for info on the address */
     if (dladdr1((void *) pc, &dlinfo, (void **) &dlsym, RTLD_DL_SYMENT)) {
 	unsigned long offset = pc - (uintptr_t) dlinfo.dli_saddr;
@@ -643,7 +643,7 @@ static int xorg_backtrace_frame(uintptr_
 	 */
 	ErrorF("%s\n", header);
     }
-    
+
     return 0;
 }
 # endif /* HAVE_WALKCONTEXT */
@@ -686,7 +686,7 @@ static int xorg_backtrace_pstack(void) {
 
 	while (!done) {
 	    bytesread = read(pipefd[0], btline, sizeof(btline) - 1);
-	    
+
 	    if (bytesread > 0) {
 		btline[bytesread] = 0;
 		ErrorF("%s", btline);
@@ -710,11 +710,11 @@ static int xorg_backtrace_pstack(void) {
 static __inline__ void xorg_backtrace(void) {
 
     ErrorF("\nBacktrace:\n");
-    
-#  ifdef HAVE_PSTACK    
+
+#  ifdef HAVE_PSTACK
 /* First try fork/exec of pstack - otherwise fall back to walkcontext
    pstack is preferred since it can print names of non-exported functions */
-    
+
     if (xorg_backtrace_pstack() < 0)
 #  endif	
     {
@@ -752,7 +752,7 @@ xf86SigHandler(int signo)
     (void) signal(signo, xf86SigHandler);
     return;
   }
-  
+
   if (xf86SignalIntercept && (*xf86SignalIntercept < 0)) {
     *xf86SignalIntercept = signo;
     /* Re-arm handler just in case */
@@ -767,7 +767,7 @@ xf86SigHandler(int signo)
 #endif
 
   xorg_backtrace();
-    
+
   FatalError("Caught signal %d.  Server aborting\n", signo);
 }
 
@@ -854,7 +854,7 @@ xf86VTSwitch()
 #ifdef DEBUG
   ErrorF("xf86VTSwitch()\n");
 #endif
-  
+
 #ifdef XFreeXDGA
   if(!DGAVTSwitch())
 	return;
@@ -881,9 +881,9 @@ xf86VTSwitch()
     }
 #if !defined(__UNIXOS2__)
 
-    /* 
+    /*
      * Keep the order: Disable Device > LeaveVT
-     *                        EnterVT > EnableDevice 
+     *                        EnterVT > EnableDevice
      */
     pInfo = xf86InputDevs;
     while (pInfo) {
@@ -903,7 +903,7 @@ xf86VTSwitch()
 
     if (!xf86VTSwitchAway()) {
       /*
-       * switch failed 
+       * switch failed
        */
 
 #ifdef DEBUG
@@ -1003,7 +1003,7 @@ xf86VTSwitch()
     /* XXX HACK */
     xf86ReleaseKeys(inputInfo.keyboard);
 #endif /* !__UNIXOS2__ */
-    
+
     for (ih = InputHandlers; ih; ih = ih->next)
       xf86EnableInputHandler(ih);
 
@@ -1039,7 +1039,7 @@ addInputHandler(int fd, InputHandlerProc
 
 _X_EXPORT pointer
 xf86AddInputHandler(int fd, InputHandlerProc proc, pointer data)
-{   
+{
     IHPtr ih = addInputHandler(fd, proc, data);
 
     if (ih)
@@ -1049,7 +1049,7 @@ xf86AddInputHandler(int fd, InputHandler
 
 _X_EXPORT pointer
 xf86AddGeneralHandler(int fd, InputHandlerProc proc, pointer data)
-{   
+{
     IHPtr ih = addInputHandler(fd, proc, data);
 
     if (ih)
@@ -1079,13 +1079,13 @@ xf86RemoveInputHandler(pointer handler)
 {
     IHPtr ih;
     int fd;
-    
+
     if (!handler)
 	return -1;
 
     ih = handler;
     fd = ih->fd;
-    
+
     if (ih->fd >= 0)
 	RemoveEnabledDevice(ih->fd);
     removeInputHandler(ih);
@@ -1098,13 +1098,13 @@ xf86RemoveGeneralHandler(pointer handler
 {
     IHPtr ih;
     int fd;
-    
+
     if (!handler)
 	return -1;
 
     ih = handler;
     fd = ih->fd;
-    
+
     if (ih->fd >= 0)
 	RemoveGeneralSocket(ih->fd);
     removeInputHandler(ih);
@@ -1193,7 +1193,7 @@ void
 xf86ReloadInputDevs(int sig)
 {
   InputInfoPtr pInfo;
-  
+
   signal(sig, (void(*)(int))xf86ReloadInputDevs);
 
   pInfo = xf86InputDevs;
@@ -1202,7 +1202,7 @@ xf86ReloadInputDevs(int sig)
     EnableDevice(pInfo->dev);
     pInfo = pInfo->next;
   }
-  
+
   return;
 }
 
@@ -1224,7 +1224,7 @@ xf86PostWSKbdEvent(struct wscons_event *
   int value = event->value;
   unsigned int keycode;
   int blocked;
-  
+
   if (type == WSCONS_EVENT_KEY_UP || type == WSCONS_EVENT_KEY_DOWN) {
     Bool down = (type == WSCONS_EVENT_KEY_DOWN ? TRUE : FALSE);
 
diff --git a/hw/xfree86/common/xf86Helper.c b/hw/xfree86/common/xf86Helper.c
index 09c08d2..93c89fd 100644
--- a/hw/xfree86/common/xf86Helper.c
+++ b/hw/xfree86/common/xf86Helper.c
@@ -90,7 +90,7 @@ xf86AddDriver(DriverPtr driver, pointer 
     else {
 	(void) memset( xf86DriverList[xf86NumDrivers - 1], 0,
 		       sizeof( DriverRec ) );
-	(void) memcpy( xf86DriverList[xf86NumDrivers - 1], driver, 
+	(void) memcpy( xf86DriverList[xf86NumDrivers - 1], driver,
 		       sizeof(DriverRec1));
 
     }
@@ -241,7 +241,7 @@ xf86AllocateScreen(DriverPtr drv, int fl
 #endif
 
     xf86Screens[i]->DriverFunc = drv->driverFunc;
-    
+
     return xf86Screens[i];
 }
 
@@ -293,7 +293,7 @@ xf86DeleteScreen(int scrnIndex, int flag
     xfree(pScrn);
 
     /* Move the other entries down, updating their scrnIndex fields */
-    
+
     xf86NumScreens--;
 
     for (i = scrnIndex; i < xf86NumScreens; i++) {
@@ -487,7 +487,7 @@ xf86SetDepthBpp(ScrnInfoPtr scrp, int de
     depth24flags &= ~(SupportConvert32to24 | SupportConvert32to24 |
 		      PreferConvert24to32 | PreferConvert32to24);
 #endif
-     
+
     if (xf86FbBpp > 0) {
 	scrp->bitsPerPixel = xf86FbBpp;
 	scrp->bitsPerPixelFrom = X_CMDLINE;
@@ -946,7 +946,7 @@ xf86SetGamma(ScrnInfoPtr scrp, Gamma gam
 {
     MessageType from = X_DEFAULT;
 #if 0
-    xf86MonPtr DDC = (xf86MonPtr)(scrp->monitor->DDC); 
+    xf86MonPtr DDC = (xf86MonPtr)(scrp->monitor->DDC);
 #endif
     if (TEST_GAMMA(xf86Gamma)) {
 	from = X_CMDLINE;
@@ -999,7 +999,7 @@ _X_EXPORT void
 xf86SetDpi(ScrnInfoPtr pScrn, int x, int y)
 {
     MessageType from = X_DEFAULT;
-    xf86MonPtr DDC = (xf86MonPtr)(pScrn->monitor->DDC); 
+    xf86MonPtr DDC = (xf86MonPtr)(pScrn->monitor->DDC);
     int ddcWidthmm, ddcHeightmm;
     int widthErr, heightErr;
 
@@ -1009,7 +1009,7 @@ xf86SetDpi(ScrnInfoPtr pScrn, int x, int
 
     if (DDC && (DDC->features.hsize > 0 && DDC->features.vsize > 0) ) {
       /* DDC gives display size in mm for individual modes,
-       * but cm for monitor 
+       * but cm for monitor
        */
       ddcWidthmm = DDC->features.hsize * 10; /* 10mm in 1cm */
       ddcHeightmm = DDC->features.vsize * 10; /* 10mm in 1cm */
@@ -1053,7 +1053,7 @@ xf86SetDpi(ScrnInfoPtr pScrn, int x, int
 	  if (widthErr>10 || heightErr>10) {
 	    /* Should include config file name for monitor here */
 	    xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
-		       "Probed monitor is %dx%d mm, using Displaysize %dx%d mm\n", 
+		       "Probed monitor is %dx%d mm, using Displaysize %dx%d mm\n",
 		       ddcWidthmm,ddcHeightmm, pScrn->widthmm,pScrn->heightmm);
 	  }
 	}
@@ -1149,7 +1149,7 @@ xf86SetRootClip (ScreenPtr pScreen, Bool
 	    pWin->valdata->before.resized = TRUE;
 	}
     }
-    
+
     /*
      * Use REGION_BREAK to avoid optimizations in ValidateTree
      * that assume the root borderClip can't change well, normally
@@ -1174,9 +1174,9 @@ xf86SetRootClip (ScreenPtr pScreen, Bool
 	REGION_EMPTY(pScreen, &pWin->borderClip);
 	REGION_BREAK (pWin->drawable.pScreen, &pWin->clipList);
     }
-    
+
     ResizeChildrenWinSize (pWin, 0, 0, 0, 0);
-    
+
     if (WasViewable)
     {
 	if (pWin->backStorage)
@@ -1221,7 +1221,7 @@ xf86SetRootClip (ScreenPtr pScreen, Bool
 	if (bsExposed)
 	{
 	    RegionPtr	valExposed = NullRegion;
-    
+
 	    if (pWin->valdata)
 		valExposed = &pWin->valdata->after.exposed;
 	    (*pScreen->WindowExposures) (pWin, valExposed, bsExposed);
@@ -1280,7 +1280,7 @@ xf86EnableDisableFBAccess(int scrnIndex,
 	 */
 	pspix->devPrivate = pScrnInfo->pixmapPrivate;
 	/*
-	 * Restore all of the clip lists on the screen 
+	 * Restore all of the clip lists on the screen
 	 */
 	if (!xf86Resetting)
 	    xf86SetRootClip (pScreen, TRUE);
@@ -1289,7 +1289,7 @@ xf86EnableDisableFBAccess(int scrnIndex,
     else
     {
 	/*
-	 * Empty all of the clip lists on the screen 
+	 * Empty all of the clip lists on the screen
 	 */
 	xf86SetRootClip (pScreen, FALSE);
 	/*
@@ -1410,7 +1410,7 @@ xf86LogInit()
 
 #define LOGSUFFIX ".log"
 #define LOGOLDSUFFIX ".old"
-    
+
     /* Get the log file name */
     if (xf86LogFileFrom == X_DEFAULT) {
 	/* Append the display number and ".log" */
@@ -1538,7 +1538,7 @@ xf86MatchDevice(const char *drivername, 
 	*sectlist = NULL;
 
     if (xf86DoProbe) return 1;
-  
+
     if (xf86DoConfigure && xf86DoConfigurePass1) return 1;
 
     /*
@@ -1546,18 +1546,18 @@ xf86MatchDevice(const char *drivername, 
      * as they show up in the config file with the drivers that the server
      * loads at run time.
      *
-     * ChipProbe can call 
-     * int xf86MatchDevice(char * drivername, GDevPtr ** sectlist) 
+     * ChipProbe can call
+     * int xf86MatchDevice(char * drivername, GDevPtr ** sectlist)
      * with its driver name. The function allocates an array of GDevPtr and
      * returns this via sectlist and returns the number of elements in
      * this list as return value. 0 means none found, -1 means fatal error.
-     * 
+     *
      * It can figure out which of the Device sections to use for which card
      * (using things like the Card statement, etc). For single headed servers
      * there will of course be just one such Device section.
      */
     i = 0;
-    
+
     /*
      * first we need to loop over all the Screens sections to get to all
      * 'active' device sections
@@ -1587,7 +1587,7 @@ xf86MatchDevice(const char *drivername, 
 	}
 	j++;
     }
-    
+
     /*
      * make the array NULL terminated and return its address
      */
@@ -1613,7 +1613,7 @@ struct Inst {
 
 /**
  * Find set of unclaimed devices matching a given vendor ID.
- * 
+ *
  * Used by drivers to find as yet unclaimed devices matching the specified
  * vendor ID.
  *
@@ -1629,7 +1629,7 @@ struct Inst {
  * \param drvp           Pointer the driver's control structure.
  * \param foundEntities  Returned list of entity indicies associated with the
  *                       driver.
- * 
+ *
  * \returns
  * The number of elements in returned in \c foundEntities on success or zero
  * on failure.
@@ -1644,7 +1644,7 @@ struct Inst {
  * that parameter.
  */
 _X_EXPORT int
-xf86MatchPciInstances(const char *driverName, int vendorID, 
+xf86MatchPciInstances(const char *driverName, int vendorID,
 		      SymTabPtr chipsets, PciChipsets *PCIchipsets,
 		      GDevPtr *devList, int numDevs, DriverPtr drvp,
 		      int **foundEntities)
@@ -1723,7 +1723,7 @@ xf86MatchPciInstances(const char *driver
 		    foundVendor = TRUE;
 		}
 		if ( (device_id == pPci->chipType)
-		     || ((vendorID == PCI_VENDOR_GENERIC) 
+		     || ((vendorID == PCI_VENDOR_GENERIC)
 			 && (match_class == device_class)) ) {
 		    if ( instances != NULL ) {
 			instances[allocatedInstances - 1].foundHW = TRUE;
@@ -1734,7 +1734,7 @@ xf86MatchPciInstances(const char *driver
 		    if ( xf86DoConfigure && xf86DoConfigurePass1 ) {
 			if ( xf86CheckPciSlot(pPci->bus, pPci->device,
 					      pPci->func) ) {
-			    GDevPtr pGDev = 
+			    GDevPtr pGDev =
 			      xf86AddDeviceToConfigure( drvp->driverName,
 							pPci, -1 );
 			    if (pGDev) {
@@ -1792,7 +1792,7 @@ xf86MatchPciInstances(const char *driver
     */
 
     for (j = 0; j < numDevs; j++) {
-        if (devList[j]->screen > 0 && devList[j]->busID 
+        if (devList[j]->screen > 0 && devList[j]->busID
 	    && *devList[j]->busID) {
 	    for (i = 0; i < allocatedInstances; i++) {
 	        pPci = instances[i].pci;
@@ -1821,7 +1821,7 @@ xf86MatchPciInstances(const char *driver
 					   pPci->device,
 					   pPci->func) &&
 		    devList[j]->screen == instances[i].screen) {
-		   
+
 		    if (devBus)
                         xf86MsgVerb(X_WARNING,0,
 			    "%s: More than one matching Device section for "
@@ -1830,10 +1830,10 @@ xf86MatchPciInstances(const char *driver
 			    devList[j]->identifier);
 		    else
 			devBus = devList[j];
-		} 
+		}
 	    } else {
-		/* 
-		 * if device section without BusID is found 
+		/*
+		 * if device section without BusID is found
 		 * only assign to it to the primary device.
 		 */
 		if (xf86IsPrimaryPci(pPci)) {
@@ -1848,7 +1848,7 @@ xf86MatchPciInstances(const char *driver
 		}
 	    }
 	}
-	if (devBus) dev = devBus;  /* busID preferred */ 
+	if (devBus) dev = devBus;  /* busID preferred */
 	if (!dev) {
 	    if (xf86CheckPciSlot(pPci->bus, pPci->device, pPci->func)) {
 		xf86MsgVerb(X_WARNING, 0, "%s: No matching Device section "
@@ -2068,7 +2068,7 @@ xf86MatchIsaInstances(const char *driver
 				dev->identifier);
 		} else
 		    foundChip = c->token;
-	    } else { 
+	    } else {
 		if (FindIsaDevice) foundChip = (*FindIsaDevice)(dev);
                                                         /* Probe it */
 		from = X_PROBED;
@@ -2079,7 +2079,7 @@ xf86MatchIsaInstances(const char *driver
 
 	if (foundChip >= 0){
 	    for (Chips = ISAchipsets; Chips->numChipset >= 0; Chips++) {
-		if (Chips->numChipset == foundChip) 
+		if (Chips->numChipset == foundChip)
 		    break;
 	    }
 	    if (Chips->numChipset == -1){
@@ -2102,7 +2102,7 @@ xf86MatchIsaInstances(const char *driver
 	}
     }
     *foundEntities = retEntities;
-    
+
     return numFound;
 }
 
@@ -2126,7 +2126,7 @@ xf86GetClocks(ScrnInfoPtr pScrn, int num
     if (num > MAXCLOCKS)
 	num = MAXCLOCKS;
 
-    for (i = 0; i < num; i++) 
+    for (i = 0; i < num; i++)
     {
 	if (ProtectRegs)
 	    (*ProtectRegs)(pScrn, TRUE);
@@ -2139,7 +2139,7 @@ xf86GetClocks(ScrnInfoPtr pScrn, int num
 	    (*ProtectRegs)(pScrn, FALSE);
 	if (BlankScreen)
 	    (*BlankScreen)(pScrn, FALSE);
-	    
+
     	usleep(50000);     /* let VCO stabilise */
 
     	cnt  = 0;
@@ -2153,25 +2153,25 @@ xf86GetClocks(ScrnInfoPtr pScrn, int num
 	    ErrorF("your OS does not support disabling interrupts, then you\n");
 	    FatalError("must specify a Clocks line in the XF86Config file.\n");
 	}
-	while ((inb(status) & maskval) == 0x00) 
+	while ((inb(status) & maskval) == 0x00)
 	    if (sync-- == 0) goto finish;
 	/* Something appears to be happening, so reset sync count */
 	sync = 200000;
-	while ((inb(status) & maskval) == maskval) 
+	while ((inb(status) & maskval) == maskval)
 	    if (sync-- == 0) goto finish;
 	/* Something appears to be happening, so reset sync count */
 	sync = 200000;
-	while ((inb(status) & maskval) == 0x00) 
+	while ((inb(status) & maskval) == 0x00)
 	    if (sync-- == 0) goto finish;
-    
-	for (rcnt = 0; rcnt < 5; rcnt++) 
+
+	for (rcnt = 0; rcnt < 5; rcnt++)
 	{
-	    while (!(inb(status) & maskval)) 
+	    while (!(inb(status) & maskval))
 		cnt++;
-	    while ((inb(status) & maskval)) 
+	    while ((inb(status) & maskval))
 		cnt++;
 	}
-    
+
 finish:
 	xf86EnableInterrupts();
 
@@ -2182,7 +2182,7 @@ finish:
 
     xf86SetPriority(FALSE);
 
-    for (i = 0; i < num; i++) 
+    for (i = 0; i < num; i++)
     {
 	if (i != knownclkindex)
 	{
@@ -2190,10 +2190,10 @@ finish:
 	    {
 		pScrn->clock[i] = 0;
 	    }
-	    else 
+	    else
 	    {
 		pScrn->clock[i] = (int)(0.5 +
-                    (((float)knownclkvalue) * pScrn->clock[knownclkindex]) / 
+                    (((float)knownclkvalue) * pScrn->clock[knownclkindex]) /
 	            (pScrn->clock[i]));
 		/* Round to nearest 10KHz */
 		pScrn->clock[i] += 5;
@@ -2204,7 +2204,7 @@ finish:
     }
 
     pScrn->clock[knownclkindex] = knownclkvalue;
-    pScrn->numClocks = num; 
+    pScrn->numClocks = num;
 
     /* Restore registers that were written on */
     (*ClockFunc)(pScrn, CLK_REG_RESTORE);
@@ -2425,17 +2425,17 @@ xf86LoadSubModule(ScrnInfoPtr pScrn, con
 
 /*
  * xf86LoadOneModule loads a single module.
- */             
+ */
 _X_EXPORT pointer
 xf86LoadOneModule(char *name, pointer opt)
 {
     int errmaj, errmin;
     char *Name;
     pointer mod;
-    
+
     if (!name)
 	return NULL;
-    
+
 #ifndef NORMALISE_MODULE_NAME
     Name = xstrdup(name);
 #else
@@ -2507,7 +2507,7 @@ static const OptionInfoRec BSOptions[] =
    { -1,                   NULL,           OPTV_NONE,    {0}, FALSE }
 };
 
-_X_EXPORT void 
+_X_EXPORT void
 xf86SetBackingStore(ScreenPtr pScreen)
 {
     Bool useBS = FALSE;
@@ -2547,7 +2547,7 @@ static const OptionInfoRec SMOptions[] =
    { -1,                   NULL,           OPTV_NONE,    {0}, FALSE }
 };
 
-_X_EXPORT void 
+_X_EXPORT void
 xf86SetSilkenMouse (ScreenPtr pScreen)
 {
     Bool useSM = TRUE;
@@ -2558,12 +2558,12 @@ xf86SetSilkenMouse (ScreenPtr pScreen)
     options = xnfalloc(sizeof(SMOptions));
     (void)memcpy(options, SMOptions, sizeof(SMOptions));
     xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, options);
-    
+
     /* check for commandline option here */
     /* disable if screen shares resources */
-    if (((pScrn->racMemFlags & RAC_CURSOR) && 
+    if (((pScrn->racMemFlags & RAC_CURSOR) &&
 	 !xf86NoSharedResources(pScrn->scrnIndex,MEM)) ||
-	((pScrn->racIoFlags & RAC_CURSOR) && 
+	((pScrn->racIoFlags & RAC_CURSOR) &&
 	 !xf86NoSharedResources(pScrn->scrnIndex,IO))) {
 	useSM = FALSE;
 	from = X_PROBED;
@@ -2632,7 +2632,7 @@ xf86ConfigIsaEntity(ScrnInfoPtr pScrn, i
     IsaChipsets *i_id;
     EntityInfoPtr pEnt = xf86GetEntityInfo(entityIndex);
     if (!pEnt) return pScrn;
-    
+
     if (!(pEnt->location.type == BUS_ISA)) {
 	xfree(pEnt);
 	return pScrn;
@@ -2646,7 +2646,7 @@ xf86ConfigIsaEntity(ScrnInfoPtr pScrn, i
     }
 
     if (!pScrn)
-	pScrn = xf86AllocateScreen(pEnt->driver,scrnFlag); 
+	pScrn = xf86AllocateScreen(pEnt->driver,scrnFlag);
     xf86AddEntityToScreen(pScrn,entityIndex);
 
     if (i_chip) {
@@ -2671,7 +2671,7 @@ xf86ConfigPciEntity(ScrnInfoPtr pScrn, i
     EntityInfoPtr pEnt = xf86GetEntityInfo(entityIndex);
     if (!pEnt) return pScrn;
 
-    if (!(pEnt->location.type == BUS_PCI) 
+    if (!(pEnt->location.type == BUS_PCI)
 	|| !xf86GetPciInfoForEntity(entityIndex)) {
 	xfree(pEnt);
 	return pScrn;
@@ -2708,12 +2708,12 @@ xf86ConfigPciEntity(ScrnInfoPtr pScrn, i
 
 _X_EXPORT ScrnInfoPtr
 xf86ConfigFbEntity(ScrnInfoPtr pScrn, int scrnFlag, int entityIndex,
-		   EntityProc init, EntityProc enter, EntityProc leave, 
+		   EntityProc init, EntityProc enter, EntityProc leave,
 		   pointer private)
 {
     EntityInfoPtr pEnt = xf86GetEntityInfo(entityIndex);
     if (!pEnt) return pScrn;
-    
+
     if (!(pEnt->location.type == BUS_NONE)) {
 	xfree(pEnt);
 	return pScrn;
@@ -2726,7 +2726,7 @@ xf86ConfigFbEntity(ScrnInfoPtr pScrn, in
     }
 
     if (!pScrn)
-	pScrn = xf86AllocateScreen(pEnt->driver,scrnFlag); 
+	pScrn = xf86AllocateScreen(pEnt->driver,scrnFlag);
     xf86AddEntityToScreen(pScrn,entityIndex);
 
     xf86SetEntityFuncs(entityIndex,init,enter,leave,private);
@@ -2748,14 +2748,14 @@ xf86ConfigActiveIsaEntity(ScrnInfoPtr pS
     IsaChipsets *i_id;
     EntityInfoPtr pEnt = xf86GetEntityInfo(entityIndex);
     if (!pEnt) return FALSE;
- 
+
     if (!pEnt->active || !(pEnt->location.type == BUS_ISA)) {
         xfree(pEnt);
         return FALSE;
     }
- 
+
     xf86AddEntityToScreen(pScrn,entityIndex);
- 
+
     if (i_chip) {
         for (i_id = i_chip; i_id->numChipset != -1; i_id++) {
             if (pEnt->chipset == i_id->numChipset) break;
@@ -2766,10 +2766,10 @@ xf86ConfigActiveIsaEntity(ScrnInfoPtr pS
     xf86ClaimFixedResources(res,entityIndex);
     if (!xf86SetEntityFuncs(entityIndex,init,enter,leave,private))
         return FALSE;
- 
+
     return TRUE;
 }
- 
+
 _X_EXPORT Bool
 xf86ConfigActivePciEntity(ScrnInfoPtr pScrn, int entityIndex,
                           PciChipsets *p_chip, resList res, EntityProc init,
@@ -2778,13 +2778,13 @@ xf86ConfigActivePciEntity(ScrnInfoPtr pS
     PciChipsets *p_id;
     EntityInfoPtr pEnt = xf86GetEntityInfo(entityIndex);
     if (!pEnt) return FALSE;
- 
+
     if (!pEnt->active || !(pEnt->location.type == BUS_PCI)) {
         xfree(pEnt);
         return FALSE;
     }
     xf86AddEntityToScreen(pScrn,entityIndex);
- 
+
     if (p_chip) {
         for (p_id = p_chip; p_id->numChipset != -1; p_id++) {
             if (pEnt->chipset == p_id->numChipset) break;
@@ -2792,11 +2792,11 @@ xf86ConfigActivePciEntity(ScrnInfoPtr pS
         xf86ClaimFixedResources(p_id->resList,entityIndex);
     }
     xfree(pEnt);
- 
+
     xf86ClaimFixedResources(res,entityIndex);
     if (!xf86SetEntityFuncs(entityIndex,init,enter,leave,private))
         return FALSE;
- 
+
     return TRUE;
 }
 
@@ -2852,7 +2852,7 @@ xf86ConfigIsaEntityInactive(EntityInfoPt
 }
 
 void
-xf86ConfigFbEntityInactive(EntityInfoPtr pEnt, EntityProc init, 
+xf86ConfigFbEntityInactive(EntityInfoPtr pEnt, EntityProc init,
 			   EntityProc enter, EntityProc leave, pointer private)
 {
     ScrnInfoPtr pScrn;
@@ -2921,7 +2921,7 @@ xf86RegisterRootWindowProperty(int ScrnI
     pNewProp->format = format;
     pNewProp->size = len;
     pNewProp->data = value;
- 
+
 #ifdef DEBUG
     ErrorF("new property filled\n");
 #endif
@@ -2963,7 +2963,7 @@ xf86RegisterRootWindowProperty(int ScrnI
 #ifdef DEBUG
     ErrorF("xf86RegisterRootWindowProperty succeeded\n");
 #endif
-    return(Success);    
+    return(Success);
 }
 
 _X_EXPORT Bool
diff-tree 2035f115b7db3c4b7deabeab0d814b3107d6ef30 (from 809e2841aaa54662a42498aacec558bc813bba1c)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Wed Nov 8 15:28:10 2006 +0200

    xfree86: remove xf86Keymap.h

diff --git a/hw/xfree86/common/Makefile.am b/hw/xfree86/common/Makefile.am
index 57493f3..6ad8566 100644
--- a/hw/xfree86/common/Makefile.am
+++ b/hw/xfree86/common/Makefile.am
@@ -66,7 +66,6 @@ EXTRA_DIST = \
 	xf86Bus.h \
 	xf86Config.h \
 	xf86InPriv.h \
-	xf86Keymap.h \
 	xf86Module.h \
 	xf86Opt.h \
 	xf86PciInfo.h \
diff --git a/hw/xfree86/common/xf86Keymap.h b/hw/xfree86/common/xf86Keymap.h
deleted file mode 100644
index 5299bad..0000000
--- a/hw/xfree86/common/xf86Keymap.h
+++ /dev/null
@@ -1,454 +0,0 @@
-
-/*
- * Copyright (c) 1994-2002 by The XFree86 Project, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name of the copyright holder(s)
- * and author(s) shall not be used in advertising or otherwise to promote
- * the sale, use or other dealings in this Software without prior written
- * authorization from the copyright holder(s) and author(s).
- */
-
-/*
- *
- * For Scancodes see notes in atKeynames.h  !!!!
- *
- */
-/* $XConsortium: xf86Keymap.h /main/14 1996/02/21 17:38:47 kaleb $ */
-
-static KeySym map[NUM_KEYCODES * GLYPHS_PER_KEY] = {
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#if !defined(__SOL8__) && (!defined(sun) || defined(i386))
-
-    /* 0x00 */  NoSymbol,       NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x01 */  XK_Escape,      NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x02 */  XK_1,           XK_exclam,	NoSymbol,	NoSymbol,
-    /* 0x03 */  XK_2,           XK_at,		NoSymbol,	NoSymbol,
-    /* 0x04 */  XK_3,           XK_numbersign,	NoSymbol,	NoSymbol,
-    /* 0x05 */  XK_4,           XK_dollar,	NoSymbol,	NoSymbol,
-    /* 0x06 */  XK_5,           XK_percent,	NoSymbol,	NoSymbol,
-    /* 0x07 */  XK_6,           XK_asciicircum,	NoSymbol,	NoSymbol,
-    /* 0x08 */  XK_7,           XK_ampersand,	NoSymbol,	NoSymbol,
-    /* 0x09 */  XK_8,           XK_asterisk,	NoSymbol,	NoSymbol,
-    /* 0x0a */  XK_9,           XK_parenleft,	NoSymbol,	NoSymbol,
-    /* 0x0b */  XK_0,           XK_parenright,	NoSymbol,	NoSymbol,
-    /* 0x0c */  XK_minus,       XK_underscore,	NoSymbol,	NoSymbol,
-    /* 0x0d */  XK_equal,       XK_plus,	NoSymbol,	NoSymbol,
-    /* 0x0e */  XK_BackSpace,   NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x0f */  XK_Tab,         XK_ISO_Left_Tab,NoSymbol,	NoSymbol,
-    /* 0x10 */  XK_Q,           NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x11 */  XK_W,           NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x12 */  XK_E,           NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x13 */  XK_R,           NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x14 */  XK_T,           NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x15 */  XK_Y,           NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x16 */  XK_U,           NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x17 */  XK_I,           NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x18 */  XK_O,           NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x19 */  XK_P,           NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x1a */  XK_bracketleft, XK_braceleft,	NoSymbol,	NoSymbol,
-    /* 0x1b */  XK_bracketright,XK_braceright,	NoSymbol,	NoSymbol,
-    /* 0x1c */  XK_Return,      NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x1d */  XK_Control_L,   NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x1e */  XK_A,           NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x1f */  XK_S,           NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x20 */  XK_D,           NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x21 */  XK_F,           NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x22 */  XK_G,           NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x23 */  XK_H,           NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x24 */  XK_J,           NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x25 */  XK_K,           NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x26 */  XK_L,           NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x27 */  XK_semicolon,   XK_colon,	NoSymbol,	NoSymbol,
-    /* 0x28 */  XK_quoteright,  XK_quotedbl,	NoSymbol,	NoSymbol,
-    /* 0x29 */  XK_quoteleft,	XK_asciitilde,	NoSymbol,	NoSymbol,
-    /* 0x2a */  XK_Shift_L,     NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x2b */  XK_backslash,   XK_bar,		NoSymbol,	NoSymbol,
-    /* 0x2c */  XK_Z,           NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x2d */  XK_X,           NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x2e */  XK_C,           NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x2f */  XK_V,           NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x30 */  XK_B,           NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x31 */  XK_N,           NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x32 */  XK_M,           NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x33 */  XK_comma,       XK_less,	NoSymbol,	NoSymbol,
-    /* 0x34 */  XK_period,      XK_greater,	NoSymbol,	NoSymbol,
-    /* 0x35 */  XK_slash,       XK_question,	NoSymbol,	NoSymbol,
-    /* 0x36 */  XK_Shift_R,     NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x37 */  XK_KP_Multiply, NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x38 */  XK_Alt_L,	XK_Meta_L,	NoSymbol,	NoSymbol,
-    /* 0x39 */  XK_space,       NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x3a */  XK_Caps_Lock,   NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x3b */  XK_F1,          NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x3c */  XK_F2,          NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x3d */  XK_F3,          NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x3e */  XK_F4,          NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x3f */  XK_F5,          NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x40 */  XK_F6,          NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x41 */  XK_F7,          NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x42 */  XK_F8,          NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x43 */  XK_F9,          NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x44 */  XK_F10,         NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x45 */  XK_Num_Lock,    NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x46 */  XK_Scroll_Lock,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x47 */  XK_KP_Home,	XK_KP_7,	NoSymbol,	NoSymbol,
-    /* 0x48 */  XK_KP_Up,	XK_KP_8,	NoSymbol,	NoSymbol,
-    /* 0x49 */  XK_KP_Prior,	XK_KP_9,	NoSymbol,	NoSymbol,
-    /* 0x4a */  XK_KP_Subtract, NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x4b */  XK_KP_Left,	XK_KP_4,	NoSymbol,	NoSymbol,
-    /* 0x4c */  XK_KP_Begin,	XK_KP_5,	NoSymbol,	NoSymbol,
-    /* 0x4d */  XK_KP_Right,	XK_KP_6,	NoSymbol,	NoSymbol,
-    /* 0x4e */  XK_KP_Add,      NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x4f */  XK_KP_End,	XK_KP_1,	NoSymbol,	NoSymbol,
-    /* 0x50 */  XK_KP_Down,	XK_KP_2,	NoSymbol,	NoSymbol,
-    /* 0x51 */  XK_KP_Next,	XK_KP_3,	NoSymbol,	NoSymbol,
-    /* 0x52 */  XK_KP_Insert,	XK_KP_0,	NoSymbol,	NoSymbol,
-    /* 0x53 */  XK_KP_Delete,	XK_KP_Decimal,	NoSymbol,	NoSymbol,
-    /* 0x54 */  XK_Sys_Req,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x55 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x56 */  XK_less,	XK_greater,	NoSymbol,	NoSymbol,
-    /* 0x57 */  XK_F11,		NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x58 */  XK_F12,		NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x59 */  XK_Home,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x5a */  XK_Up,		NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x5b */  XK_Prior,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x5c */  XK_Left,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x5d */  XK_Begin,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x5e */  XK_Right,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x5f */  XK_End,		NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x60 */  XK_Down,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x61 */  XK_Next,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x62 */  XK_Insert,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x63 */  XK_Delete,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x64 */  XK_KP_Enter,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x65 */  XK_Control_R,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x66 */  XK_Pause,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x67 */  XK_Print,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x68 */  XK_KP_Divide,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x69 */  XK_Alt_R,	XK_Meta_R,	NoSymbol,	NoSymbol,
-    /* 0x6a */  XK_Break,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x6b */  XK_Meta_L,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x6c */  XK_Meta_R,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x6d */  XK_Menu,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x6e */  XK_F13,		NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x6f */  XK_F14,		NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x70 */  XK_F15,		NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x71 */  XK_F16,		NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x72 */  XK_F17,		NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x73 */  XK_backslash,	XK_underscore,	NoSymbol,	NoSymbol,
-    /* 0x74 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x75 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x76 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x77 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x78 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x79 */  XK_Henkan,	XK_Mode_switch,	NoSymbol,	NoSymbol,
-    /* 0x7a */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x7b */  XK_Muhenkan,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x7c */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x7d */  XK_backslash,	XK_bar,		NoSymbol,	NoSymbol,
-    /* 0x7e */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x7f */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-
-#else /* SunOS */
-
-/* Assumes a US English keyboard as default - sorry 'bout that
- *
- * Hopefully it'll be enough someone can have a sorta working
- * keyboard, if they're not using XKB
- *
- * DWH 9/12/99
- */
-
-    /* 0x00 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x01 */  XK_quoteleft,	XK_asciitilde,	NoSymbol,	NoSymbol,
-    /* 0x02 */  XK_1,		XK_exclam,	NoSymbol,	NoSymbol,
-    /* 0x03 */  XK_2,		XK_at,		NoSymbol,	NoSymbol,
-    /* 0x04 */  XK_3,		XK_numbersign,	NoSymbol,	NoSymbol,
-    /* 0x05 */  XK_4,		XK_dollar,	NoSymbol,	NoSymbol,
-    /* 0x06 */  XK_5,		XK_percent,	NoSymbol,	NoSymbol,
-    /* 0x07 */  XK_6,		XK_asciicircum,	NoSymbol,	NoSymbol,
-    /* 0x08 */  XK_7,		XK_ampersand,	NoSymbol,	NoSymbol,
-    /* 0x09 */  XK_8,		XK_asterisk,	NoSymbol,	NoSymbol,
-    /* 0x0a */  XK_9,		XK_parenleft,	NoSymbol,	NoSymbol,
-    /* 0x0b */  XK_0,		XK_parenright,	NoSymbol,	NoSymbol,
-    /* 0x0c */  XK_minus,	XK_underscore,	NoSymbol,	NoSymbol,
-    /* 0x0d */  XK_equal,	XK_plus,	NoSymbol,	NoSymbol,
-    /* 0x0e */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x0f */  XK_BackSpace,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x10 */  XK_Tab,		NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x11 */  XK_Q,		NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x12 */  XK_W,		NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x13 */  XK_E,		NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x14 */  XK_R,		NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x15 */  XK_T,		NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x16 */  XK_Y,		NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x17 */  XK_U,		NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x18 */  XK_I,		NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x19 */  XK_O,		NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x1a */  XK_P,		NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x1b */  XK_bracketleft,	XK_braceleft,	NoSymbol,	NoSymbol,
-    /* 0x1c */  XK_bracketright,XK_braceright,	NoSymbol,	NoSymbol,
-    /* 0x1d */  XK_backslash,	XK_bar,		NoSymbol,	NoSymbol,
-    /* 0x1e */  XK_Caps_Lock,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x1f */  XK_A,		NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x20 */  XK_S,		NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x21 */  XK_D,		NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x22 */  XK_F,		NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x23 */  XK_G,		NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x24 */  XK_H,		NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x25 */  XK_J,		NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x26 */  XK_K,		NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x27 */  XK_L,		NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x28 */  XK_semicolon,	XK_colon,	NoSymbol,	NoSymbol,
-    /* 0x29 */  XK_quoteright,	XK_quotedbl,	NoSymbol,	NoSymbol,
-    /* 0x2a */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x2b */  XK_Return,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x2c */  XK_Shift_L,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x2d */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x2e */  XK_Z,		NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x2f */  XK_X,		NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x30 */  XK_C,		NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x31 */  XK_V,		NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x32 */  XK_B,		NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x33 */  XK_N,		NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x34 */  XK_M,		NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x35 */  XK_comma,	XK_less,	NoSymbol,	NoSymbol,
-    /* 0x36 */  XK_period,	XK_greater,	NoSymbol,	NoSymbol,
-    /* 0x37 */  XK_slash,	XK_question,	NoSymbol,	NoSymbol,
-    /* 0x38 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x39 */  XK_Shift_R,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x3a */  XK_Control_L,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x3b */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x3c */  XK_Alt_L,	XK_Meta_L,	NoSymbol,	NoSymbol,
-    /* 0x3d */  XK_space,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x3e */  XK_Alt_R,	XK_Meta_R,	NoSymbol,	NoSymbol,
-    /* 0x3f */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x40 */  XK_Control_R,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x41 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x42 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x43 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x44 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x45 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x46 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x47 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x48 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x49 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x4a */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x4b */  XK_Insert,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x4c */  XK_Delete,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x4d */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x4e */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x4f */  XK_Left,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x50 */  XK_Home,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x51 */  XK_End,		NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x52 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x53 */  XK_Up,		NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x54 */  XK_Down,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x55 */  XK_Prior,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x56 */  XK_Next,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x57 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x58 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x59 */  XK_Right,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x5a */  XK_Num_Lock,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x5b */  XK_KP_Home,	XK_KP_7,	NoSymbol,	NoSymbol,
-    /* 0x5c */  XK_KP_Left,	XK_KP_4,	NoSymbol,	NoSymbol,
-    /* 0x5d */  XK_KP_End,	XK_KP_1,	NoSymbol,	NoSymbol,
-    /* 0x5e */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x5f */  XK_KP_Divide,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x60 */  XK_KP_Up,	XK_KP_8,	NoSymbol,	NoSymbol,
-    /* 0x61 */  NoSymbol,	XK_KP_5,	NoSymbol,	NoSymbol,
-    /* 0x62 */  XK_KP_Down,	XK_KP_2,	NoSymbol,	NoSymbol,
-    /* 0x63 */  XK_KP_Insert,	XK_KP_0,	NoSymbol,	NoSymbol,
-    /* 0x64 */  XK_KP_Multiply,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x65 */  XK_KP_Prior,	XK_KP_9,	NoSymbol,	NoSymbol,
-    /* 0x66 */  XK_KP_Right,	XK_KP_6,	NoSymbol,	NoSymbol,
-    /* 0x67 */  XK_KP_Next,	XK_KP_3,	NoSymbol,	NoSymbol,
-    /* 0x68 */  XK_KP_Delete,	XK_KP_Decimal,	NoSymbol,	NoSymbol,
-    /* 0x69 */  XK_KP_Subtract,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x6a */  XK_KP_Add,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x6b */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x6c */  XK_KP_Enter,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x6d */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x6e */  XK_Escape,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x6f */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x70 */  XK_F1,		NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x71 */  XK_F2,		NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x72 */  XK_F3,		NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x73 */  XK_F4,		NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x74 */  XK_F5,		NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x75 */  XK_F6,		NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x76 */  XK_F7,		NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x77 */  XK_F8,		NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x78 */  XK_F9,		NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x79 */  XK_F10,		NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x7a */  XK_F11,		NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x7b */  XK_F12,		NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x7c */  XK_Print,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x7d */  XK_Scroll_Lock,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x7e */  XK_Pause,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x7f */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-
-#endif /* SunOS */
-
-};
-
-#if !defined(Lynx) && \
-    !defined(__UNIXOS2__) && \
-    !defined(__mips__) && \
-    !defined(linux) && \
-    !defined(CSRG_BASED) && \
-    !defined(__CYGWIN__) && \
-    !defined(__SOL8__) && \
-    (!defined(sun) || defined(i386))
-
-static KeySym map84[NUM_KEYCODES * GLYPHS_PER_KEY] = {
-    /* 0x00 */  NoSymbol,       NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x01 */  XK_Escape,      NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x02 */  XK_1,           XK_exclam,	NoSymbol,	NoSymbol,
-    /* 0x03 */  XK_2,           XK_at,		NoSymbol,	NoSymbol,
-    /* 0x04 */  XK_3,           XK_numbersign,	NoSymbol,	NoSymbol,
-    /* 0x05 */  XK_4,           XK_dollar,	NoSymbol,	NoSymbol,
-    /* 0x06 */  XK_5,           XK_percent,	NoSymbol,	NoSymbol,
-    /* 0x07 */  XK_6,           XK_asciicircum,	NoSymbol,	NoSymbol,
-    /* 0x08 */  XK_7,           XK_ampersand,	NoSymbol,	NoSymbol,
-    /* 0x09 */  XK_8,           XK_asterisk,	NoSymbol,	NoSymbol,
-    /* 0x0a */  XK_9,           XK_parenleft,	NoSymbol,	NoSymbol,
-    /* 0x0b */  XK_0,           XK_parenright,	NoSymbol,	NoSymbol,
-    /* 0x0c */  XK_minus,       XK_underscore,	NoSymbol,	NoSymbol,
-    /* 0x0d */  XK_equal,       XK_plus,	NoSymbol,	NoSymbol,
-    /* 0x0e */  XK_BackSpace,   NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x0f */  XK_Tab,         NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x10 */  XK_Q,           NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x11 */  XK_W,           NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x12 */  XK_E,           NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x13 */  XK_R,           NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x14 */  XK_T,           NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x15 */  XK_Y,           NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x16 */  XK_U,           NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x17 */  XK_I,           NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x18 */  XK_O,           NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x19 */  XK_P,           NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x1a */  XK_bracketleft, XK_braceleft,	NoSymbol,	NoSymbol,
-    /* 0x1b */  XK_bracketright,XK_braceright,	NoSymbol,	NoSymbol,
-    /* 0x1c */  XK_Return,      NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x1d */  XK_Control_L,   NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x1e */  XK_A,           NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x1f */  XK_S,           NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x20 */  XK_D,           NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x21 */  XK_F,           NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x22 */  XK_G,           NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x23 */  XK_H,           NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x24 */  XK_J,           NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x25 */  XK_K,           NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x26 */  XK_L,           NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x27 */  XK_semicolon,   XK_colon,	NoSymbol,	NoSymbol,
-    /* 0x28 */  XK_quoteright,  XK_quotedbl,	NoSymbol,	NoSymbol,
-    /* 0x29 */  XK_quoteleft,	XK_asciitilde,	NoSymbol,	NoSymbol,
-    /* 0x2a */  XK_Shift_L,     NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x2b */  XK_backslash,   XK_bar,		NoSymbol,	NoSymbol,
-    /* 0x2c */  XK_Z,           NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x2d */  XK_X,           NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x2e */  XK_C,           NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x2f */  XK_V,           NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x30 */  XK_B,           NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x31 */  XK_N,           NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x32 */  XK_M,           NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x33 */  XK_comma,       XK_less,	NoSymbol,	NoSymbol,
-    /* 0x34 */  XK_period,      XK_greater,	NoSymbol,	NoSymbol,
-    /* 0x35 */  XK_slash,       XK_question,	NoSymbol,	NoSymbol,
-    /* 0x36 */  XK_Shift_R,     NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x37 */  XK_KP_Multiply, NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x38 */  XK_Alt_L,	XK_Meta_L,	NoSymbol,	NoSymbol,
-    /* 0x39 */  XK_space,       NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x3a */  XK_Caps_Lock,   NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x3b */  XK_F1,          NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x3c */  XK_F2,          NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x3d */  XK_F3,          NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x3e */  XK_F4,          NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x3f */  XK_F5,          NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x40 */  XK_F6,          NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x41 */  XK_F7,          NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x42 */  XK_F8,          NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x43 */  XK_F9,          NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x44 */  XK_F10,         NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x45 */  XK_Num_Lock,    NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x46 */  XK_Scroll_Lock,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x47 */  XK_KP_Home,	XK_KP_7,	NoSymbol,	NoSymbol,
-    /* 0x48 */  XK_KP_Up,	XK_KP_8,	NoSymbol,	NoSymbol,
-    /* 0x49 */  XK_KP_Prior,	XK_KP_9,	NoSymbol,	NoSymbol,
-    /* 0x4a */  XK_KP_Subtract, NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x4b */  XK_KP_Left,	XK_KP_4,	NoSymbol,	NoSymbol,
-    /* 0x4c */  NoSymbol,	XK_KP_5,	NoSymbol,	NoSymbol,
-    /* 0x4d */  XK_KP_Right,	XK_KP_6,	NoSymbol,	NoSymbol,
-    /* 0x4e */  XK_KP_Add,      NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x4f */  XK_KP_End,	XK_KP_1,	NoSymbol,	NoSymbol,
-    /* 0x50 */  XK_KP_Down,	XK_KP_2,	NoSymbol,	NoSymbol,
-    /* 0x51 */  XK_KP_Next,	XK_KP_3,	NoSymbol,	NoSymbol,
-    /* 0x52 */  XK_KP_Insert,	XK_KP_0,	NoSymbol,	NoSymbol,
-    /* 0x53 */  XK_KP_Delete,	XK_KP_Decimal,	NoSymbol,	NoSymbol,
-    /* 0x54 */  XK_Sys_Req,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x55 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x56 */  XK_less,	XK_greater,	NoSymbol,	NoSymbol,
-    /* 0x57 */  XK_F11,		NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x58 */  XK_F12,		NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x59 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x5a */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x5b */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x5c */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x5d */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x5e */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x5f */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x60 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x61 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x62 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x63 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x64 */  XK_KP_Enter,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x65 */  XK_Control_R,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x66 */  XK_Pause,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x67 */  XK_Print,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x68 */  XK_KP_Divide,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x69 */  XK_Alt_R,	XK_Meta_R,	NoSymbol,	NoSymbol,
-    /* 0x6a */  XK_Break,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x6b */  XK_Meta_L,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x6c */  XK_Meta_R,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x6d */  XK_Menu,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x6e */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x6f */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x70 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x71 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x72 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x73 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x74 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x75 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x76 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x77 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x78 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x79 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x7a */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x7b */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x7c */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x7d */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-    /* 0x7e */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-};
-#endif
diff-tree 809e2841aaa54662a42498aacec558bc813bba1c (from b5438f7fb2879e0226b578f60b22a490e73c3a83)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Wed Nov 8 15:27:58 2006 +0200

    xfree86: add general handler, port ACPI to it (bug #5665)
    
    Add 'general' handler registration, which will not trigger DPMS when an
    event comes in.
    Make ACPI use this.

diff --git a/hw/xfree86/common/xf86.h b/hw/xfree86/common/xf86.h
index 4587500..5112530 100644
--- a/hw/xfree86/common/xf86.h
+++ b/hw/xfree86/common/xf86.h
@@ -222,6 +222,10 @@ pointer xf86AddInputHandler(int fd, Inpu
 int xf86RemoveInputHandler(pointer handler);
 void xf86DisableInputHandler(pointer handler);
 void xf86EnableInputHandler(pointer handler);
+pointer xf86AddGeneralHandler(int fd, InputHandlerProc proc, pointer data);
+int xf86RemoveGeneralHandler(pointer handler);
+void xf86DisableGeneralHandler(pointer handler);
+void xf86EnableGeneralHandler(pointer handler);
 void xf86InterceptSignals(int *signo);
 void xf86InterceptSigIll(void (*sigillhandler)(void));
 Bool xf86EnableVTSwitch(Bool new);
diff --git a/hw/xfree86/common/xf86Events.c b/hw/xfree86/common/xf86Events.c
index 6ce9319..905c56a 100644
--- a/hw/xfree86/common/xf86Events.c
+++ b/hw/xfree86/common/xf86Events.c
@@ -1014,8 +1014,8 @@ xf86VTSwitch()
 
 /* Input handler registration */
 
-_X_EXPORT pointer
-xf86AddInputHandler(int fd, InputHandlerProc proc, pointer data)
+static pointer
+addInputHandler(int fd, InputHandlerProc proc, pointer data)
 {
     IHPtr ih;
 
@@ -1034,15 +1034,50 @@ xf86AddInputHandler(int fd, InputHandler
     ih->next = InputHandlers;
     InputHandlers = ih;
 
-    AddEnabledDevice(fd);
+    return ih;
+}
+
+_X_EXPORT pointer
+xf86AddInputHandler(int fd, InputHandlerProc proc, pointer data)
+{   
+    IHPtr ih = addInputHandler(fd, proc, data);
+
+    if (ih)
+        AddEnabledDevice(fd);
+    return ih;
+}
+
+_X_EXPORT pointer
+xf86AddGeneralHandler(int fd, InputHandlerProc proc, pointer data)
+{   
+    IHPtr ih = addInputHandler(fd, proc, data);
 
+    if (ih)
+        AddGeneralSocket(fd);
     return ih;
 }
 
+static void
+removeInputHandler(IHPtr ih)
+{
+    IHPtr p;
+
+    if (ih == InputHandlers)
+	InputHandlers = ih->next;
+    else {
+	p = InputHandlers;
+	while (p && p->next != ih)
+	    p = p->next;
+	if (ih)
+	    p->next = ih->next;
+    }
+    xfree(ih);
+}
+
 _X_EXPORT int
 xf86RemoveInputHandler(pointer handler)
 {
-    IHPtr ih, p;
+    IHPtr ih;
     int fd;
     
     if (!handler)
@@ -1053,17 +1088,27 @@ xf86RemoveInputHandler(pointer handler)
     
     if (ih->fd >= 0)
 	RemoveEnabledDevice(ih->fd);
+    removeInputHandler(ih);
+
+    return fd;
+}
+
+_X_EXPORT int
+xf86RemoveGeneralHandler(pointer handler)
+{
+    IHPtr ih;
+    int fd;
+    
+    if (!handler)
+	return -1;
+
+    ih = handler;
+    fd = ih->fd;
+    
+    if (ih->fd >= 0)
+	RemoveGeneralSocket(ih->fd);
+    removeInputHandler(ih);
 
-    if (ih == InputHandlers)
-	InputHandlers = ih->next;
-    else {
-	p = InputHandlers;
-	while (p && p->next != ih)
-	    p = p->next;
-	if (ih)
-	    p->next = ih->next;
-    }
-    xfree(ih);
     return fd;
 }
 
@@ -1082,6 +1127,20 @@ xf86DisableInputHandler(pointer handler)
 }
 
 _X_EXPORT void
+xf86DisableGeneralHandler(pointer handler)
+{
+    IHPtr ih;
+
+    if (!handler)
+	return;
+
+    ih = handler;
+    ih->enabled = FALSE;
+    if (ih->fd >= 0)
+	RemoveGeneralSocket(ih->fd);
+}
+
+_X_EXPORT void
 xf86EnableInputHandler(pointer handler)
 {
     IHPtr ih;
@@ -1095,6 +1154,20 @@ xf86EnableInputHandler(pointer handler)
 	AddEnabledDevice(ih->fd);
 }
 
+_X_EXPORT void
+xf86EnableGeneralHandler(pointer handler)
+{
+    IHPtr ih;
+
+    if (!handler)
+	return;
+
+    ih = handler;
+    ih->enabled = TRUE;
+    if (ih->fd >= 0)
+	AddGeneralSocket(ih->fd);
+}
+
 /*
  * As used currently by the DRI, the return value is ignored.
  */
diff --git a/hw/xfree86/os-support/linux/lnx_acpi.c b/hw/xfree86/os-support/linux/lnx_acpi.c
index eca76db..aa30e72 100644
--- a/hw/xfree86/os-support/linux/lnx_acpi.c
+++ b/hw/xfree86/os-support/linux/lnx_acpi.c
@@ -163,7 +163,7 @@ lnxACPIOpen(void)
 
     xf86PMGetEventFromOs = lnxACPIGetEventFromOs;
     xf86PMConfirmEventToOs = lnxACPIConfirmEventToOs;
-    ACPIihPtr = xf86AddInputHandler(fd,xf86HandlePMEvents,NULL);
+    ACPIihPtr = xf86AddGeneralHandler(fd,xf86HandlePMEvents,NULL);
     xf86MsgVerb(X_INFO,3,"Open ACPI successful (%s)\n", ACPI_SOCKET);
 
     return lnxCloseACPI;
@@ -178,7 +178,7 @@ lnxCloseACPI(void)
    ErrorF("ACPI: Closing device\n");
 #endif
     if (ACPIihPtr) {
-	fd = xf86RemoveInputHandler(ACPIihPtr);
+	fd = xf86RemoveGeneralHandler(ACPIihPtr);
 	shutdown(fd, 2);
 	close(fd);
 	ACPIihPtr = NULL;
diff-tree b5438f7fb2879e0226b578f60b22a490e73c3a83 (from b0a7443ca8bd224994f98c1c1e25de88f2573224)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Wed Nov 8 15:24:58 2006 +0200

    Get*Events: massive reorganisation
    
    Reorganise the code logically, and put more comments in.
    Clip valuators in proximity calls.

diff --git a/dix/getevents.c b/dix/getevents.c
index b19a73f..4a3ee8e 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -1,5 +1,6 @@
 /*
  * Copyright © 2006 Nokia Corporation
+ * Copyright © 2006 Daniel Stone
  *
  * Permission to use, copy, modify, distribute, and sell this software and
  * its documentation for any purpose is hereby granted without fee,
@@ -27,18 +28,17 @@
 
 #include <X11/X.h>
 #include <X11/keysym.h>
-#include "misc.h"
-#include "resource.h"
 #define NEED_EVENTS
 #define NEED_REPLIES
 #include <X11/Xproto.h>
+
+#include "misc.h"
+#include "resource.h"
 #include "inputstr.h"
 #include "scrnintstr.h"
 #include "cursorstr.h"
-
 #include "dixstruct.h"
 #include "globals.h"
-
 #include "mipointer.h"
 
 #ifdef XKB
@@ -63,177 +63,143 @@ extern Bool XkbCopyKeymap(XkbDescPtr src
 #include "exglobals.h"
 #include "extnsionst.h"
 
-/* Maximum number of valuators, divided by six, rounded up. */
+
+/* Maximum number of valuators, divided by six, rounded up, to get number
+ * of events. */
 #define MAX_VALUATOR_EVENTS 6
 
 /* Number of motion history events to store. */
 #define MOTION_HISTORY_SIZE 256
 
+
 /**
- * Returns the maximum number of events GetKeyboardEvents,
- * GetKeyboardValuatorEvents, and GetPointerEvents will ever return.
- *
- * Should be used in DIX as:
- * xEvent *events = xcalloc(sizeof(xEvent), GetMaximumEventsNum());
+ * Pick some arbitrary size for Xi motion history.
  */
 _X_EXPORT int
-GetMaximumEventsNum() {
-    /* Two base events -- core and device, plus valuator events.  Multiply
-     * by two if we're doing key repeats. */
-    int ret = 2 + MAX_VALUATOR_EVENTS;
-
-#ifdef XKB
-    if (noXkbExtension)
-#endif
-        ret *= 2;
-
-    return ret;
+GetMotionHistorySize()
+{
+    return MOTION_HISTORY_SIZE;
 }
 
+
 /**
- * Convenience wrapper around GetKeyboardValuatorEvents, that takes no
- * valuators.
+ * Allocate the motion history buffer.
  */
-_X_EXPORT int
-GetKeyboardEvents(xEvent *events, DeviceIntPtr pDev, int type, int key_code) {
-    return GetKeyboardValuatorEvents(events, pDev, type, key_code, 0, 0, NULL);
+_X_EXPORT void
+AllocateMotionHistory(DeviceIntPtr pDev)
+{
+    if (pDev->valuator->motion)
+        xfree(pDev->valuator->motion);
+
+    if (pDev->valuator->numMotionEvents < 1)
+        return;
+
+    pDev->valuator->motion = xalloc(((sizeof(INT32) * pDev->valuator->numAxes) +
+                                     sizeof(Time)) *
+                                    pDev->valuator->numMotionEvents);
+    pDev->valuator->first_motion = 0;
+    pDev->valuator->last_motion = 0;
 }
 
+
 /**
- * Returns a set of keyboard events for KeyPress/KeyRelease, optionally
- * also with valuator events.  Handles Xi and XKB.
- *
- * 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.
- *
- * This function does not change the core keymap to that of the device;
- * that is done by SwitchCoreKeyboard, which is called from
- * mieqProcessInputEvents.  If replacing function, take care to call
- * SetCoreKeyboard before processInputProc, so keymaps are altered to suit.
- *
- * Note that this function recurses!  If called for non-XKB, a repeating
- * key press will trigger a matching KeyRelease, as well as the
- * KeyPresses.
+ * Dump the motion history between start and stop into the supplied buffer.
+ * Only records the event for a given screen in theory, but in practice, we
+ * sort of ignore this.
  */
 _X_EXPORT int
-GetKeyboardValuatorEvents(xEvent *events, DeviceIntPtr pDev, int type,
-                          int key_code, int first_valuator,
-                          int num_valuators, int *valuators) {
-    int numEvents = 0, i = 0;
-    CARD32 ms = 0;
-    int final_valuator = first_valuator + num_valuators;
-    KeySym sym = pDev->key->curKeySyms.map[key_code *
-                                           pDev->key->curKeySyms.mapWidth];
-    deviceKeyButtonPointer *kbp = NULL;
-    deviceValuator *xv = NULL;
+GetMotionHistory(DeviceIntPtr pDev, xTimecoord *buff, unsigned long start,
+                 unsigned long stop, ScreenPtr pScreen)
+{
+    char *ibuff = NULL, *obuff = (char *) buff;
+    int i = 0, ret = 0;
+    Time current;
+    /* The size of a single motion event. */
+    int size = (sizeof(INT32) * pDev->valuator->numAxes) + sizeof(Time);
 
-    if (!events)
+    if (!pDev->valuator || !pDev->valuator->numMotionEvents)
         return 0;
 
-    if (type != KeyPress && type != KeyRelease)
-        return 0;
+    for (i = pDev->valuator->first_motion;
+         i != pDev->valuator->last_motion;
+         i = (i + 1) % pDev->valuator->numMotionEvents) {
+        /* We index the input buffer by which element we're accessing, which
+         * is not monotonic, and the output buffer by how many events we've
+         * written so far. */
+        ibuff = (char *) pDev->valuator->motion + (i * size);
+        memcpy(&current, ibuff, sizeof(Time));
 
-    if (!pDev->key || !pDev->focus || !pDev->kbdfeed ||
-        (pDev->coreEvents && !inputInfo.keyboard->key))
-        return 0;
+        if (current > stop) {
+            return ret;
+        }
+        else if (current >= start) {
+            memcpy(obuff, ibuff, size);
+            obuff += size;
+            ret++;
+        }
+    }
 
-    if (pDev->coreEvents)
-        numEvents = 2;
-    else
-        numEvents = 1;
+    return ret;
+}
 
-    if (num_valuators) {
-        if ((num_valuators / 6) + 1 > MAX_VALUATOR_EVENTS)
-            num_valuators = MAX_VALUATOR_EVENTS;
-        numEvents += (num_valuators / 6) + 1;
-    }
 
-#ifdef XKB
-    if (noXkbExtension)
-#endif
-    {
-        switch (sym) {
-            case XK_Num_Lock:
-            case XK_Caps_Lock:
-            case XK_Scroll_Lock:
-            case XK_Shift_Lock:
-                if (type == KeyRelease)
-                    return 0;
-                else if (type == KeyPress &&
-                         (pDev->key->down[key_code >> 3] & (key_code & 7)) & 1)
-                        type = KeyRelease;
-        }
-    }
+/**
+ * Update the motion history for a specific device, with the list of
+ * valuators.
+ */
+static void
+updateMotionHistory(DeviceIntPtr pDev, CARD32 ms, int first_valuator,
+                    int num_valuators, int *valuators)
+{
+    char *buff = (char *) pDev->valuator->motion;
 
-    /* Handle core repeating, via press/release/press/release.
-     * FIXME: In theory, if you're repeating with two keyboards,
-     *        you could get unbalanced events here. */
-    if (type == KeyPress &&
-        (((pDev->key->down[key_code >> 3] & (key_code & 7))) & 1)) {
-        if (!pDev->kbdfeed->ctrl.autoRepeat ||
-            pDev->key->modifierMap[key_code] ||
-            !(pDev->kbdfeed->ctrl.autoRepeats[key_code >> 3]
-                & (1 << (key_code & 7))))
-            return 0;
+    if (!pDev->valuator->numMotionEvents)
+        return;
 
-#ifdef XKB
-        if (noXkbExtension)
-#endif
-        {
-            numEvents += GetKeyboardValuatorEvents(events, pDev,
-                                                   KeyRelease, key_code,
-                                                   first_valuator, num_valuators,
-                                                   valuators);
-            events += numEvents;
-        }
-    }
+    buff += ((sizeof(INT32) * pDev->valuator->numAxes) + sizeof(CARD32)) *
+            pDev->valuator->last_motion;
+    memcpy(buff, &ms, sizeof(Time));
 
-    ms = GetTimeInMillis();
+    buff += sizeof(Time);
+    bzero(buff, sizeof(INT32) * pDev->valuator->numAxes);
 
-    kbp = (deviceKeyButtonPointer *) events;
-    kbp->time = ms;
-    kbp->deviceid = pDev->id;
-    if (type == KeyPress)
-        kbp->type = DeviceKeyPress;
-    else if (type == KeyRelease)
-        kbp->type = DeviceKeyRelease;
+    buff += sizeof(INT32) * first_valuator;
+    memcpy(buff, valuators, sizeof(INT32) * num_valuators);
 
-    if (num_valuators) {
-        kbp->deviceid |= MORE_EVENTS;
-        for (i = first_valuator; i < final_valuator; i += 6) {
-            xv = (deviceValuator *) ++events;
-            xv->type = DeviceValuator;
-            xv->first_valuator = i;
-            xv->num_valuators = num_valuators;
-            xv->deviceid = kbp->deviceid;
-            switch (num_valuators - first_valuator) {
-            case 6:
-                xv->valuator5 = valuators[i+5];
-            case 5:
-                xv->valuator4 = valuators[i+4];
-            case 4:
-                xv->valuator3 = valuators[i+3];
-            case 3:
-                xv->valuator2 = valuators[i+2];
-            case 2:
-                xv->valuator1 = valuators[i+1];
-            case 1:
-                xv->valuator0 = valuators[i];
-            }
-        }
-    }
+    pDev->valuator->last_motion = (pDev->valuator->last_motion + 1) %
+                                  pDev->valuator->numMotionEvents;
+    
+    /* If we're wrapping around, just keep the circular buffer going. */
+    if (pDev->valuator->first_motion == pDev->valuator->last_motion)
+        pDev->valuator->first_motion = (pDev->valuator->first_motion + 1) %
+                                       pDev->valuator->numMotionEvents;
 
-    if (pDev->coreEvents) {
-        events++;
-        events->u.keyButtonPointer.time = ms;
-        events->u.u.type = type;
-        events->u.u.detail = key_code;
-    }
+    return;
+}
 
-    return numEvents;
+
+/**
+ * Returns the maximum number of events GetKeyboardEvents,
+ * GetKeyboardValuatorEvents, and GetPointerEvents will ever return.
+ *
+ * Should be used in DIX as:
+ * xEvent *events = xcalloc(sizeof(xEvent), GetMaximumEventsNum());
+ */
+_X_EXPORT int
+GetMaximumEventsNum() {
+    /* Two base events -- core and device, plus valuator events.  Multiply
+     * by two if we're doing key repeats. */
+    int ret = 2 + MAX_VALUATOR_EVENTS;
+
+#ifdef XKB
+    if (noXkbExtension)
+#endif
+        ret *= 2;
+
+    return ret;
 }
 
+
 /* Originally a part of xf86PostMotionEvent; modifies valuators
  * in-place. */
 static void
@@ -307,8 +273,10 @@ acceleratePointer(DeviceIntPtr pDev, int
     }
 }
 
+
 /**
- * Clip an axis to its bounds.
+ * Clip an axis to its bounds, which are declared in the call to
+ * InitValuatorAxisClassStruct.
  */
 static void
 clipAxis(DeviceIntPtr pDev, int axisNum, int *val)
@@ -322,8 +290,7 @@ clipAxis(DeviceIntPtr pDev, int axisNum,
 }
 
 /**
- * Compare the list of valuators against the limits for each axis, and clip
- * them to those bounds.
+ * Clip every axis in the list of valuators to its bounds.
  */
 static void
 clipValuators(DeviceIntPtr pDev, int first_valuator, int num_valuators,
@@ -336,9 +303,14 @@ clipValuators(DeviceIntPtr pDev, int fir
         clipAxis(pDev, i + first_valuator, &(valuators[i]));
 }
 
+
 /**
  * Fills events with valuator events for pDev, as given by the other
  * parameters.
+ *
+ * FIXME: Need to fix ValuatorClassRec to store all the valuators as
+ *        last posted, not just x and y; otherwise relative non-x/y
+ *        valuators, though a very narrow use case, will be broken.
  */
 static xEvent *
 getValuatorEvents(xEvent *events, DeviceIntPtr pDev, int first_valuator,
@@ -373,108 +345,133 @@ getValuatorEvents(xEvent *events, Device
     return events;
 }
 
+
 /**
- * Pick some arbitrary size for Xi motion history.
+ * Convenience wrapper around GetKeyboardValuatorEvents, that takes no
+ * valuators.
  */
 _X_EXPORT int
-GetMotionHistorySize()
-{
-    return MOTION_HISTORY_SIZE;
+GetKeyboardEvents(xEvent *events, DeviceIntPtr pDev, int type, int key_code) {
+    return GetKeyboardValuatorEvents(events, pDev, type, key_code, 0, 0, NULL);
 }
 
-/**
- * Allocate the motion history buffer.
- */
-_X_EXPORT void
-AllocateMotionHistory(DeviceIntPtr pDev)
-{
-    if (pDev->valuator->motion)
-        xfree(pDev->valuator->motion);
-
-    if (pDev->valuator->numMotionEvents < 1)
-        return;
-
-    pDev->valuator->motion = xalloc(((sizeof(INT32) * pDev->valuator->numAxes) +
-                                     sizeof(Time)) *
-                                    pDev->valuator->numMotionEvents);
-    pDev->valuator->first_motion = 0;
-    pDev->valuator->last_motion = 0;
-}
 
 /**
- * Dump the motion history between start and stop into the supplied buffer.
- * Only records the event for a given screen in theory, but in practice, we
- * sort of ignore this.
+ * Returns a set of keyboard events for KeyPress/KeyRelease, optionally
+ * also with valuator events.  Handles Xi and XKB.
+ *
+ * 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.
+ *
+ * This function does not change the core keymap to that of the device;
+ * that is done by SwitchCoreKeyboard, which is called from
+ * mieqProcessInputEvents.  If replacing that function, take care to call
+ * SetCoreKeyboard before processInputProc, so keymaps are altered to suit.
+ *
+ * Note that this function recurses!  If called for non-XKB, a repeating
+ * key press will trigger a matching KeyRelease, as well as the
+ * KeyPresses.
  */
 _X_EXPORT int
-GetMotionHistory(DeviceIntPtr pDev, xTimecoord *buff, unsigned long start,
-                 unsigned long stop, ScreenPtr pScreen)
-{
-    int i = 0, ret = 0;
-    /* The size of a single motion event. */
-    int size = (sizeof(INT32) * pDev->valuator->numAxes) + sizeof(Time);
-    Time current;
-    char *ibuff = NULL, *obuff = (char *) buff;
+GetKeyboardValuatorEvents(xEvent *events, DeviceIntPtr pDev, int type,
+                          int key_code, int first_valuator,
+                          int num_valuators, int *valuators) {
+    int numEvents = 0;
+    CARD32 ms = 0;
+    KeySym *map = pDev->key->curKeySyms.map;
+    KeySym sym = map[key_code * pDev->key->curKeySyms.mapWidth];
+    deviceKeyButtonPointer *kbp = NULL;
 
-    if (!pDev->valuator || !pDev->valuator->numMotionEvents)
+    if (!events)
         return 0;
 
-    for (i = pDev->valuator->first_motion;
-         i != pDev->valuator->last_motion;
-         i = (i + 1) % pDev->valuator->numMotionEvents) {
-        /* We index the input buffer by which element we're accessing, which
-         * is not monotonic, and the output buffer by how many events we've
-         * written so far. */
-        ibuff = (char *) pDev->valuator->motion + (i * size);
-        memcpy(&current, ibuff, sizeof(Time));
+    if (type != KeyPress && type != KeyRelease)
+        return 0;
 
-        if (current > stop) {
-            return ret;
-        }
-        else if (current >= start) {
-            memcpy(obuff, ibuff, size);
-            obuff += size;
-            ret++;
-        }
+    if (!pDev->key || !pDev->focus || !pDev->kbdfeed ||
+        (pDev->coreEvents && !inputInfo.keyboard->key))
+        return 0;
+
+    if (pDev->coreEvents)
+        numEvents = 2;
+    else
+        numEvents = 1;
+
+    if (num_valuators) {
+        if ((num_valuators / 6) + 1 > MAX_VALUATOR_EVENTS)
+            num_valuators = MAX_VALUATOR_EVENTS;
+        numEvents += (num_valuators / 6) + 1;
     }
 
-    return ret;
-}
+#ifdef XKB
+    if (noXkbExtension)
+#endif
+    {
+        switch (sym) {
+            case XK_Num_Lock:
+            case XK_Caps_Lock:
+            case XK_Scroll_Lock:
+            case XK_Shift_Lock:
+                if (type == KeyRelease)
+                    return 0;
+                else if (type == KeyPress &&
+                         (pDev->key->down[key_code >> 3] & (key_code & 7)) & 1)
+                        type = KeyRelease;
+        }
+    }
 
-/**
- * Update the motion history for a specific device, with the list of
- * valuators.
- */
-static void
-updateMotionHistory(DeviceIntPtr pDev, CARD32 ms, int first_valuator,
-                    int num_valuators, int *valuators)
-{
-    char *buff = (char *) pDev->valuator->motion;
+    /* Handle core repeating, via press/release/press/release.
+     * FIXME: In theory, if you're repeating with two keyboards in non-XKB,
+     *        you could get unbalanced events here. */
+    if (type == KeyPress &&
+        (((pDev->key->down[key_code >> 3] & (key_code & 7))) & 1)) {
+        if (!pDev->kbdfeed->ctrl.autoRepeat ||
+            pDev->key->modifierMap[key_code] ||
+            !(pDev->kbdfeed->ctrl.autoRepeats[key_code >> 3]
+                & (1 << (key_code & 7))))
+            return 0;
 
-    if (!pDev->valuator->numMotionEvents)
-        return;
+#ifdef XKB
+        if (noXkbExtension)
+#endif
+        {
+            numEvents += GetKeyboardValuatorEvents(events, pDev,
+                                                   KeyRelease, key_code,
+                                                   first_valuator, num_valuators,
+                                                   valuators);
+            events += numEvents;
+        }
+    }
 
-    buff += ((sizeof(INT32) * pDev->valuator->numAxes) + sizeof(CARD32)) *
-            pDev->valuator->last_motion;
-    memcpy(buff, &ms, sizeof(Time));
+    ms = GetTimeInMillis();
 
-    buff += sizeof(Time);
-    bzero(buff, sizeof(INT32) * pDev->valuator->numAxes);
+    kbp = (deviceKeyButtonPointer *) events;
+    kbp->time = ms;
+    kbp->deviceid = pDev->id;
+    if (type == KeyPress)
+        kbp->type = DeviceKeyPress;
+    else if (type == KeyRelease)
+        kbp->type = DeviceKeyRelease;
 
-    buff += sizeof(INT32) * first_valuator;
-    memcpy(buff, valuators, sizeof(INT32) * num_valuators);
+    events++;
+    if (num_valuators) {
+        kbp->deviceid |= MORE_EVENTS;
+        clipValuators(pDev, first_valuator, num_valuators, valuators);
+        events = getValuatorEvents(events, pDev, first_valuator,
+                                   num_valuators, valuators);
+    }
 
-    pDev->valuator->last_motion = (pDev->valuator->last_motion + 1) %
-                                  pDev->valuator->numMotionEvents;
-    
-    /* If we're wrapping around, just keep the circular buffer going. */
-    if (pDev->valuator->first_motion == pDev->valuator->last_motion)
-        pDev->valuator->first_motion = (pDev->valuator->first_motion + 1) %
-                                       pDev->valuator->numMotionEvents;
+    if (pDev->coreEvents) {
+        events->u.keyButtonPointer.time = ms;
+        events->u.u.type = type;
+        events->u.u.detail = key_code;
+    }
 
-    return;
+    return numEvents;
 }
 
+
 /**
  * Generate a series of xEvents (returned in xE) representing pointer
  * motion, or button presses.  Xi and XKB-aware.
@@ -528,6 +525,8 @@ GetPointerEvents(xEvent *events, DeviceI
     kbp->time = ms;
     kbp->deviceid = pDev->id;
 
+    /* Set x and y based on whether this is absolute or relative, and
+     * accelerate if we need to. */
     if (flags & POINTER_ABSOLUTE) {
         if (num_valuators >= 1 && first_valuator == 0) {
             x = valuators[0];
@@ -645,6 +644,7 @@ GetPointerEvents(xEvent *events, DeviceI
     return num_events;
 }
 
+
 /**
  * Post ProximityIn/ProximityOut events, accompanied by valuators.
  *
@@ -689,6 +689,7 @@ GetProximityEvents(xEvent *events, Devic
     if (num_valuators) {
         kbp->deviceid |= MORE_EVENTS;
         events++;
+        clipValuators(pDev, first_valuator, num_valuators, valuators);
         events = getValuatorEvents(events, pDev, first_valuator,
                                    num_valuators, valuators);
     }
@@ -696,6 +697,7 @@ GetProximityEvents(xEvent *events, Devic
     return num_events;
 }
 
+
 /**
  * Note that pDev was the last device to send a core event.  This function
  * copies the complete keymap from the originating device to the core
@@ -737,6 +739,7 @@ SwitchCoreKeyboard(DeviceIntPtr pDev)
     }
 }
 
+
 /**
  * Note that pDev was the last function to send a core pointer event.
  * Currently a no-op.
diff-tree b0a7443ca8bd224994f98c1c1e25de88f2573224 (from 332f179db7c38310db1f752d45f51b6d8301fd30)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Wed Nov 8 15:23:52 2006 +0200

    configure.ac: axe redundant SDL test

diff --git a/configure.ac b/configure.ac
index 6bfa74c..3148403 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1584,6 +1584,7 @@ if test "$KDRIVE" = yes; then
         AC_DEFINE(TSLIB, 1, [Have tslib support])
     fi
 
+    AC_CHECK_HEADERS([SDL/SDL.h])
     if test x"$ac_cv_header_SDL_SDL_h" = xyes && test "x$XSDL" = xauto; then
        XSDL=yes
     fi
@@ -1642,12 +1643,6 @@ if test "$KDRIVE" = yes; then
     AC_CHECK_FUNC([nanosleep], [],
         AC_CHECK_LIB([rt], [nanosleep], XEPHYR_LIBS="$XEPHYR_LIBS -lrt"))
 
-    # check for SDL SDK
-    AC_CHECK_HEADERS([SDL/SDL.h])
-    if test "x$XSDL" = xauto; then
-        XSDL="$ac_cv_header_SDL_SDL_h"
-    fi
-
     AC_SUBST([XEPHYR_LIBS])
     AC_SUBST([XEPHYR_INCS])
     AC_SUBST([XSDL_LIBS])
diff-tree 332f179db7c38310db1f752d45f51b6d8301fd30 (from 988757a44197c91027109076e2e33ff6510ed71d)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Wed Nov 8 15:23:35 2006 +0200

    kdrive/sdl: fix compilation

diff --git a/hw/kdrive/sdl/sdl.c b/hw/kdrive/sdl/sdl.c
index d354f6f..d7448ff 100644
--- a/hw/kdrive/sdl/sdl.c
+++ b/hw/kdrive/sdl/sdl.c
@@ -30,7 +30,6 @@
 #include "kdrive-config.h"
 #endif
 #include "kdrive.h"
-#include "kkeymap.h"
 #include <SDL/SDL.h>
 #include <X11/keysym.h>
 
@@ -39,20 +38,20 @@ static Bool sdlScreenInit(KdScreenInfo *
 static Bool sdlFinishInitScreen(ScreenPtr pScreen);
 static Bool sdlCreateRes(ScreenPtr pScreen);
 
-static void sdlKeyboardBell (int volume, int pitch, int duration);
-static void sdlKeyboardLeds (int leds);
-static void sdlKeyboardFini(void);
-static void sdlKeyboardLoad (void);
-static Bool sdlKeyboardInit(void);
+static void sdlKeyboardFini(KdKeyboardInfo *ki);
+static Bool sdlKeyboardInit(KdKeyboardInfo *ki);
 
-static Bool sdlMouseInit(void);
-static void sdlMouseFini(void);
+static Bool sdlMouseInit(KdPointerInfo *pi);
+static void sdlMouseFini(KdPointerInfo *pi);
 
 void *sdlShadowWindow (ScreenPtr pScreen, CARD32 row, CARD32 offset, int mode, CARD32 *size, void *closure);
 void sdlShadowUpdate (ScreenPtr pScreen, shadowBufPtr pBuf);
 
 void sdlTimer(void);
 
+KdKeyboardInfo *sdlKeyboard = NULL;
+KdPointerInfo *sdlPointer = NULL;
+
 KeySym sdlKeymap[]={
 	0, 			/* 8 */
 	0, 
@@ -168,51 +167,23 @@ KeySym sdlKeymap[]={
 	NoSymbol, NoSymbol		/* 118 */
 };
 
-//KdMouseInfo *kdMouseInfo;
-
-KdKeyboardFuncs sdlKeyboardFuncs = {
-    sdlKeyboardLoad,
-    sdlKeyboardInit,
-    sdlKeyboardLeds,
-    sdlKeyboardBell,
-    sdlKeyboardFini,
-    3,
+KdKeyboardDriver sdlKeyboardDriver = {
+    .name = "keyboard",
+    .Init = sdlKeyboardInit,
+    .Fini = sdlKeyboardFini,
 };
 
-KdMouseFuncs sdlMouseFuncs = {
-    sdlMouseInit,
-    sdlMouseFini,
+KdPointerDriver sdlMouseDriver = {
+    .name = "mouse",
+    .Init = sdlMouseInit,
+    .Fini = sdlMouseFini,
 };
 
 
 KdCardFuncs sdlFuncs = {
-    0,	/* cardinit */
-    sdlScreenInit,	/* scrinit */
-    0,	/* initScreen */
-    sdlFinishInitScreen, /* finishInitScreen */
-    sdlCreateRes,	/* createRes */
-    0,	/* preserve */
-    0,		/* enable */
-    0,		/* dpms */
-    0,		/* disable */
-    0,		/* restore */
-    0,	/* scrfini */
-    0,	/* cardfini */
-    
-    0,			/* initCursor */
-    0,			/* enableCursor */
-    0,			/* disableCursor */
-    0,			/* finiCursor */
-    0,			/* recolorCursor */
-    
-    0,	/* initAccel */
-    0,	/* enableAccel */
-    0,	/* syncAccel */
-    0,	/* disableAccel */
-    0,	/* finiAccel */
-    
-    0,    	 /* getColors */
-    0	 /* putColors */
+    .scrinit = sdlScreenInit,	/* scrinit */
+    .finishInitScreen = sdlFinishInitScreen, /* finishInitScreen */
+    .createRes = sdlCreateRes,	/* createRes */
 };
 
 int mouseState=0;
@@ -327,52 +298,34 @@ static Bool sdlFinishInitScreen(ScreenPt
 	return TRUE;
 }
 
-static void sdlKeyboardBell (int volume, int pitch, int duration)
-{
-#ifdef DEBUG
-	printf("a bell would go here\n");
-#endif
-}
-
-static void sdlKeyboardLeds (int leds)
-{
-#ifdef DEBUG
-	printf("Leds: %d\n", leds);
-#endif
-}
-
-static void sdlKeyboardLoad(void)
+static void sdlKeyboardFini(KdKeyboardInfo *ki)
 {
-	int x;
-	kdMinScanCode = 8;
-	kdMaxScanCode = 255;
-	kdMinKeyCode = 8;
-	kdMaxKeyCode = 255;
-	kdKeymapWidth = 2;
-
-	memcpy(kdKeymap, sdlKeymap, sizeof(sdlKeymap));
+        sdlKeyboard = NULL;
 }
 
-static void sdlKeyboardFini(void)
+static Bool sdlKeyboardInit(KdKeyboardInfo *ki)
 {
+        ki->minScanCode = 8;
+        ki->maxScanCode = 255;
+        ki->keySyms.minKeyCode = 8;
+        ki->keySyms.maxKeyCode = 255;
+        ki->keySyms.mapWidth = 2;
+        memcpy(ki->keySyms.map, sdlKeymap, sizeof(sdlKeymap));
 
-}
+	sdlKeyboard = ki;
 
-static Bool sdlKeyboardInit(void)
-{
-	return TRUE;
+        return TRUE;
 }
 
-static Bool sdlMouseInit (void)
+static Bool sdlMouseInit (KdPointerInfo *pi)
 {
-#ifdef DEBUG
-	printf("kdMouseInfo: 0x%x\n", kdMouseInfo);
-#endif
+        sdlPointer = pi;
 	return TRUE;
 }
 
-static void sdlMouseFini(void)
+static void sdlMouseFini(KdPointerInfo *pi)
 {
+        sdlPointer = NULL;
 }
 
 
@@ -395,8 +348,18 @@ void InitOutput(ScreenInfo *pScreenInfo,
 
 void InitInput(int argc, char **argv)
 {
-	/* FIXME: change this to use SDL key/mouse funcs */
-	KdInitInput(&sdlMouseFuncs, &sdlKeyboardFuncs);
+        KdPointerInfo *pi;
+        KdKeyboardInfo *ki;
+
+        KdAddKeyboardDriver(&sdlKeyboardDriver);
+        KdAddPointerDriver(&sdlMouseDriver);
+        
+        ki = KdParseKeyboard("keyboard");
+        KdAddKeyboard(ki);
+        pi = KdParsePointer("mouse");
+        KdAddPointer(pi);
+
+        KdInitInput();
 }
 
 void ddxUseMsg(void)
@@ -418,7 +381,7 @@ void sdlTimer(void)
 	while ( SDL_PollEvent(&event) ) {
 		switch (event.type) {
 			case SDL_MOUSEMOTION:
-				KdEnqueueMouseEvent(kdMouseInfo, mouseState,  event.motion.x, event.motion.y);
+				KdEnqueuePointerEvent(sdlPointer, mouseState, event.motion.x, event.motion.y, 0);
 				break;
 			case SDL_MOUSEBUTTONDOWN:
 				switch(event.button.button)
@@ -434,7 +397,7 @@ void sdlTimer(void)
 						break;
 				}
 				mouseState|=buttonState;
-				KdEnqueueMouseEvent(kdMouseInfo, mouseState|KD_MOUSE_DELTA, 0, 0);
+				KdEnqueuePointerEvent(sdlPointer, mouseState|KD_MOUSE_DELTA, 0, 0, 0);
 				break;
 			case SDL_MOUSEBUTTONUP:
 				switch(event.button.button)
@@ -450,14 +413,14 @@ void sdlTimer(void)
 						break;
 				}
 				mouseState &= ~buttonState;
-				KdEnqueueMouseEvent(kdMouseInfo, mouseState|KD_MOUSE_DELTA, 0, 0);
+				KdEnqueuePointerEvent(sdlPointer, mouseState|KD_MOUSE_DELTA, 0, 0, 0);
 				break;
 			case SDL_KEYDOWN:
 			case SDL_KEYUP:
 #ifdef DEBUG
 				printf("Keycode: %d\n", event.key.keysym.scancode);
 #endif
-			        KdEnqueueKeyboardEvent (event.key.keysym.scancode, event.type==SDL_KEYUP);
+			        KdEnqueueKeyboardEvent (sdlKeyboard, event.key.keysym.scancode, event.type==SDL_KEYUP);
 				break;
 
 			case SDL_QUIT:
@@ -482,12 +445,9 @@ static void xsdlFini(void)
 }
 
 KdOsFuncs sdlOsFuncs={
-	xsdlInit,
-	0,
-	0,
-	0,
-	xsdlFini,
-	sdlTimer
+	.Init = xsdlInit,
+	.Fini = xsdlFini,
+	.pollEvents = sdlTimer,
 };
 
 void OsVendorInit (void)
diff-tree 988757a44197c91027109076e2e33ff6510ed71d (from e2b78df5800fb4e3f0ed01b38a1974ba3577949c)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Wed Nov 8 14:06:51 2006 +0200

    config: error messages non-fatal, and before we free them
    
    Move error messages before we free the error structure, and make them all
    non-fatal.

diff --git a/config/config.c b/config/config.c
index b95128d..05757e2 100644
--- a/config/config.c
+++ b/config/config.c
@@ -258,49 +258,51 @@ configInitialise()
     dbus_error_init(&error);
     bus = dbus_bus_get(DBUS_BUS_SYSTEM, &error);
     if (!bus || dbus_error_is_set(&error)) {
-        FatalError("[dbus] some kind of error occurred: %s (%s)\n", error.name,
-                   error.message);
+        ErrorF("[dbus] some kind of error occurred: %s (%s)\n", error.name,
+                error.message);
         dbus_error_free(&error);
         return;
     }
 
     if (!dbus_connection_get_unix_fd(bus, &configfd)) {
         dbus_connection_unref(bus);
+        ErrorF("[dbus] couldn't get fd for bus\n");
+        dbus_error_free(&error);
         configfd = -1;
-        FatalError("[dbus] couldn't get fd for bus\n");
         return;
     }
 
     snprintf(busname, sizeof(busname), "org.x.config.display%d", atoi(display));
     if (!dbus_bus_request_name(bus, busname, 0, &error) ||
         dbus_error_is_set(&error)) {
+        ErrorF("[dbus] couldn't take over org.x.config: %s (%s)\n",
+               error.name, error.message);
+        dbus_error_free(&error);
         dbus_connection_unref(bus);
         configfd = -1;
-        FatalError("[dbus] couldn't take over org.x.config: %s (%s)\n",
-                   error.name, error.message);
-        dbus_error_free(&error);
         return;
     }
 
     /* blocks until we get a reply. */
     dbus_bus_add_match(bus, MATCH_RULE, &error);
     if (dbus_error_is_set(&error)) {
+        ErrorF("[dbus] couldn't match X.Org rule: %s (%s)\n", error.name,
+               error.message);
+        dbus_error_free(&error);
         dbus_bus_release_name(bus, busname, &error);
         dbus_connection_unref(bus);
         configfd = -1;
-        FatalError("[dbus] couldn't match X.Org rule: %s (%s)\n", error.name,
-                   error.message);
-        dbus_error_free(&error);
         return;
     }
 
     snprintf(busobject, sizeof(busobject), "/org/x/config/%d", atoi(display));
     if (!dbus_connection_register_object_path(bus, busobject, &vtable, bus)) {
+        ErrorF("[dbus] couldn't register object path\n");
         configfd = -1;
         dbus_bus_release_name(bus, busname, &error);
         dbus_bus_remove_match(bus, MATCH_RULE, &error);
         dbus_connection_unref(bus);
-        FatalError("[dbus] couldn't register object path\n");
+        dbus_error_free(&error);
         return;
     }
 
diff-tree e2b78df5800fb4e3f0ed01b38a1974ba3577949c (from b55007d8cc9d20baa23d5de67683e414c827d3e5)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Tue Nov 7 11:13:56 2006 +0200

    xkb: warning fix

diff --git a/xkb/xkbEvents.c b/xkb/xkbEvents.c
index 86a40e0..139221f 100644
--- a/xkb/xkbEvents.c
+++ b/xkb/xkbEvents.c
@@ -816,7 +816,7 @@ XkbSrvInfoPtr	xkbi;
 		((xE[0].u.u.type==KeyPress)||(xE[0].u.u.type==KeyRelease))) {
 	    ErrorF("XKbFilterWriteEvents:\n");
 	    ErrorF("   Event state= 0x%04x\n",xE[0].u.keyButtonPointer.state);
-	    ErrorF("   XkbLastRepeatEvent!=xE (0x%x!=0x%x) %s\n",
+	    ErrorF("   XkbLastRepeatEvent!=xE (0x%p!=0x%p) %s\n",
 			XkbLastRepeatEvent,xE,
 			((XkbLastRepeatEvent!=(pointer)xE)?"True":"False"));
 	    ErrorF("   (xkbClientEventsFlags&XWDA)==0 (0x%x) %s\n",
diff-tree b55007d8cc9d20baa23d5de67683e414c827d3e5 (from f93d10ce9bb4a6de83b561f44fb7b046def16234)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Tue Nov 7 11:13:32 2006 +0200

    SyntheticMotion: don't dereference sprite.screen when not using Xinerama

diff --git a/dix/events.c b/dix/events.c
index 68a2d38..e5701ee 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -330,7 +330,8 @@ static void ConfineToShape(RegionPtr sha
 static void PostNewCursor(void);
 
 #define SyntheticMotion(x, y) \
-    PostSyntheticMotion(x, y, sprite.screen->myNum, \
+    PostSyntheticMotion(x, y, noPanoramiXExtension ? 0 : \
+                              sprite.screen->myNum, \
                         syncEvents.playingEvents ? \
                           syncEvents.time.milliseconds : \
                           currentTime.milliseconds);
diff-tree f93d10ce9bb4a6de83b561f44fb7b046def16234 (from 389275d240e4ba19d62fda0f138a45c7ecb245ff)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Mon Nov 6 18:33:45 2006 +0200

    dix: remove staggeringly broken vendor workarounds
    
    Dear SGI,
    No.
    
    Scant regards,
    Daniel

diff --git a/dix/events.c b/dix/events.c
index b5937e7..68a2d38 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -3079,12 +3079,7 @@ EventSelectForWindow(register WindowPtr 
     if (wClient (pWin) == client)
     {
 	check = pWin->eventMask;
-#ifdef SGIMISC
-	pWin->eventMask =
-	    (mask & ~SGIMiscSpecialDestroyMask) | (pWin->eventMask & SGIMiscSpecialDestroyMask);
-#else
 	pWin->eventMask = mask;
-#endif
     }
     else
     {
@@ -3093,9 +3088,6 @@ EventSelectForWindow(register WindowPtr 
 	    if (SameClient(others, client))
 	    {
 		check = others->mask;
-#ifdef SGIMISC
-		mask = (mask & ~SGIMiscSpecialDestroyMask) | (others->mask & SGIMiscSpecialDestroyMask);
-#endif
 		if (mask == 0)
 		{
 		    FreeResource(others->resource, RT_NONE);
diff-tree 389275d240e4ba19d62fda0f138a45c7ecb245ff (from d585b4189aff8d7952847f75b19b4f092ab3b88b)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sun Nov 5 02:47:59 2006 +0200

    XkbCopyKeymap: don't iterate broken types, or dereference null pointers
    
    Don't iterate invalid destination types (>= num_types) when coping key
    types.
    Don't free key_aliases if it's NULL (theoretical, but sure).
    Make sure dst's label_font gets allocated if it's NULL.
    (Thanks, Chris Lee.)

diff --git a/xkb/xkbUtils.c b/xkb/xkbUtils.c
index 627ab20..321bf2e 100644
--- a/xkb/xkbUtils.c
+++ b/xkb/xkbUtils.c
@@ -1047,34 +1047,40 @@ XkbCopyKeymap(XkbDescPtr src, XkbDescPtr
             }
         }
 
-        if (src->map->types) {
-            if (src->map->size_types > dst->map->size_types) {
-                if (dst->map->types) {
+        if (src->map->types && src->map->num_types) {
+            if (src->map->num_types > dst->map->size_types ||
+                !dst->map->types || !dst->map->size_types) {
+                if (dst->map->types && dst->map->size_types) {
                     tmp = xrealloc(dst->map->types,
-                                   src->map->size_types * sizeof(XkbKeyTypeRec));
+                                   src->map->num_types * sizeof(XkbKeyTypeRec));
                     if (!tmp)
                         return FALSE;
                     dst->map->types = tmp;
                     bzero(dst->map->types +
-                            (dst->map->size_types * sizeof(XkbKeyTypeRec)),
-                          (src->map->size_types - dst->map->size_types) *
+                            (dst->map->num_types * sizeof(XkbKeyTypeRec)),
+                          (src->map->num_types - dst->map->size_types) *
                             sizeof(XkbKeyTypeRec));
                 }
                 else {
-                    tmp = xcalloc(src->map->size_types, sizeof(XkbKeyTypeRec));
+                    tmp = xcalloc(src->map->num_types, sizeof(XkbKeyTypeRec));
                     if (!tmp)
                         return FALSE;
                     dst->map->types = tmp;
                 }
             }
-            else if (src->map->size_types < dst->map->size_types) {
-                if (dst->map->types) {
-                    for (i = src->map->num_types, dtype = (dst->map->types + i);
-                         i < dst->map->size_types; i++, dtype++) {
-                        if (dtype->level_names)
-                            xfree(dtype->level_names);
-                        dtype->level_names = NULL;
-                        dtype->num_levels = 0;
+            else if (src->map->num_types < dst->map->num_types &&
+                     dst->map->types) {
+                for (i = src->map->num_types, dtype = (dst->map->types + i);
+                     i < dst->map->num_types; i++, dtype++) {
+                    if (dtype->level_names)
+                        xfree(dtype->level_names);
+                    dtype->level_names = NULL;
+                    dtype->num_levels = 0;
+                    if (dtype->map_count) {
+                        if (dtype->map)
+                            xfree(dtype->map);
+                        if (dtype->preserve)
+                            xfree(dtype->preserve);
                     }
                 }
             }
@@ -1082,16 +1088,18 @@ XkbCopyKeymap(XkbDescPtr src, XkbDescPtr
             stype = src->map->types;
             dtype = dst->map->types;
             for (i = 0; i < src->map->num_types; i++, dtype++, stype++) {
-                if (stype->num_levels) {
+                if (stype->num_levels && stype->level_names) {
                     if (stype->num_levels != dtype->num_levels &&
-                        dtype->num_levels && dtype->level_names) {
+                        dtype->num_levels && dtype->level_names &&
+                        i < dst->map->num_types) {
                         tmp = xrealloc(dtype->level_names,
                                        stype->num_levels * sizeof(Atom));
                         if (!tmp)
                             continue;
                         dtype->level_names = tmp;
                     }
-                    else if (!dtype->num_levels || !dtype->level_names) {
+                    else if (!dtype->num_levels || !dtype->level_names ||
+                             i >= dst->map->num_types) {
                         tmp = xalloc(stype->num_levels * sizeof(Atom));
                         if (!tmp)
                             continue;
@@ -1102,7 +1110,8 @@ XkbCopyKeymap(XkbDescPtr src, XkbDescPtr
                            stype->num_levels * sizeof(Atom));
                 }
                 else {
-                    if (dtype->num_levels && dtype->level_names)
+                    if (dtype->num_levels && dtype->level_names &&
+                        i < dst->map->num_types)
                         xfree(dtype->level_names);
                     dtype->num_levels = 0;
                     dtype->level_names = NULL;
@@ -1114,15 +1123,17 @@ XkbCopyKeymap(XkbDescPtr src, XkbDescPtr
                 if (stype->map_count) {
                     if (stype->map) {
                         if (stype->map_count != dtype->map_count &&
-                            dtype->map_count && dtype->map) {
+                            dtype->map_count && dtype->map &&
+                            i < dst->map->num_types) {
                             tmp = xrealloc(dtype->map,
                                            stype->map_count *
                                              sizeof(XkbKTMapEntryRec));
                             if (!tmp)
                                 return FALSE;
                             dtype->map = tmp;
-                       }
-                        else if (!dtype->map_count || !dtype->map) {
+                        }
+                        else if (!dtype->map_count || !dtype->map ||
+                                 i >= dst->map->num_types) {
                             tmp = xalloc(stype->map_count *
                                            sizeof(XkbKTMapEntryRec));
                             if (!tmp)
@@ -1136,7 +1147,8 @@ XkbCopyKeymap(XkbDescPtr src, XkbDescPtr
 
                     if (stype->preserve) {
                         if (stype->map_count != dtype->map_count &&
-                            dtype->map_count && dtype->preserve) {
+                            dtype->map_count && dtype->preserve &&
+                            i < dst->map->num_types) {
                             tmp = xrealloc(dtype->preserve,
                                            stype->map_count *
                                              sizeof(XkbModsRec));
@@ -1144,7 +1156,8 @@ XkbCopyKeymap(XkbDescPtr src, XkbDescPtr
                                 return FALSE;
                             dtype->preserve = tmp;
                         }
-                        else if (!dtype->preserve || !dtype->map_count) {
+                        else if (!dtype->preserve || !dtype->map_count ||
+                                 i >= dst->map->num_types) {
                             tmp = xalloc(stype->map_count *
                                          sizeof(XkbModsRec));
                             if (!tmp)
@@ -1179,14 +1192,14 @@ XkbCopyKeymap(XkbDescPtr src, XkbDescPtr
                         xfree(dtype->level_names);
                     if (dtype->map && dtype->map_count)
                         xfree(dtype->map);
-                    if (dtype->preserve && dtype->preserve)
+                    if (dtype->preserve && dtype->map_count)
                         xfree(dtype->preserve);
                 }
                 xfree(dst->map->types);
                 dst->map->types = NULL;
             }
         }
-        dst->map->size_types = src->map->size_types;
+        dst->map->size_types = src->map->num_types;
         dst->map->num_types = src->map->num_types;
 
         if (src->map->modmap) {
@@ -1957,7 +1970,7 @@ XkbCopyKeymap(XkbDescPtr src, XkbDescPtr
             dst->geom->num_key_aliases = dst->geom->sz_key_aliases;
         }
         else {
-            if (dst->geom->sz_key_aliases) {
+            if (dst->geom->sz_key_aliases && dst->geom->key_aliases) {
                 xfree(dst->geom->key_aliases);
                 dst->geom->key_aliases = NULL;
             }
@@ -1967,13 +1980,16 @@ XkbCopyKeymap(XkbDescPtr src, XkbDescPtr
         
         /* font */
         if (src->geom->label_font) {
-            if (strlen(src->geom->label_font) !=
+            if (!dst->geom->label_font) {
+                tmp = xalloc(strlen(src->geom->label_font));
+                if (!tmp)
+                    return FALSE;
+                dst->geom->label_font = tmp;
+            }
+            else if (strlen(src->geom->label_font) !=
                 strlen(dst->geom->label_font)) {
-                if (dst->geom->label_font)
-                    tmp = xrealloc(dst->geom->label_font,
-                                   strlen(src->geom->label_font));
-                else
-                    tmp = xalloc(strlen(src->geom->label_font));
+                tmp = xrealloc(dst->geom->label_font,
+                               strlen(src->geom->label_font));
                 if (!tmp)
                     return FALSE;
                 dst->geom->label_font = tmp;
diff-tree d585b4189aff8d7952847f75b19b4f092ab3b88b (from b6d7b537ed8975363ad0f7c4180a62822358e418)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sat Nov 4 21:47:55 2006 +0200

    xkb: fix uninitialised warning
    
    Fix uninitialised warning with memset(); we never actually use it
    uninitialised, but gcc doesn't know that.

diff --git a/xkb/xkbActions.c b/xkb/xkbActions.c
index 0cbf8d0..e0bf89c 100644
--- a/xkb/xkbActions.c
+++ b/xkb/xkbActions.c
@@ -868,6 +868,10 @@ XkbStateRec	old;
 unsigned	mods,mask,oldCoreState = 0,oldCorePrevState = 0;
 xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(xkbi->device);
 
+    /* never actually used uninitialised, but gcc isn't smart enough
+     * to work that out. */
+    memset(&old, 0, sizeof(old));
+
     if ((filter->keycode!=0)&&(filter->keycode!=keycode))
 	return 1;
 
diff-tree b6d7b537ed8975363ad0f7c4180a62822358e418 (from 8ba0c7b62c78dead722b0c8aa414f37bac4414b7)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sat Nov 4 21:43:22 2006 +0200

    os: fix sun extensions test
    
    'else if' is not very valid, plus the logic is kind of broken, so just
    move it outside the ifdef in the first place.

diff --git a/os/utils.c b/os/utils.c
index 65e1311..9824501 100644
--- a/os/utils.c
+++ b/os/utils.c
@@ -55,11 +55,13 @@ OR PERFORMANCE OF THIS SOFTWARE.
 
 /* The world's most shocking hack, to ensure we get clock_gettime() and
  * CLOCK_MONOTONIC. */
+#ifdef sun              /* Needed to tell Solaris headers not to restrict to */
+#define __EXTENSIONS__  /* only the functions defined in POSIX 199309.       */
+#endif
+
 #ifdef _POSIX_C_SOURCE
 #define _SAVED_POSIX_C_SOURCE _POSIX_C_SOURCE
 #undef _POSIX_C_SOURCE
-#else if defined(sun)	/* Needed to tell Solaris headers not to restrict to */
-#define __EXTENSIONS__	/* only the functions defined in POSIX 199309.       */
 #endif
 #define _POSIX_C_SOURCE 199309L
 #include <time.h>
diff-tree 8ba0c7b62c78dead722b0c8aa414f37bac4414b7 (from c3ea1f7db494365032526dc06a7283384bd0ecd1)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sat Nov 4 21:41:03 2006 +0200

    xace: avoid 'unused variable pScreen'
    
    Initialise pScreen explicitly, as REGION_* macros ignore pScreen.

diff --git a/Xext/xace.c b/Xext/xace.c
index 14a5e79..7f7944a 100644
--- a/Xext/xace.c
+++ b/Xext/xace.c
@@ -406,12 +406,14 @@ XaceCensorImage(client, pVisibleRegion, 
     unsigned int format;
     char * pBuf;
 {
-    ScreenPtr pScreen = pDraw->pScreen;
+    ScreenPtr pScreen;
     RegionRec imageRegion;  /* region representing x,y,w,h */
     RegionRec censorRegion; /* region to obliterate */
     BoxRec imageBox;
     int nRects;
 
+    pScreen = pDraw->pScreen;
+
     imageBox.x1 = x;
     imageBox.y1 = y;
     imageBox.x2 = x + w;
diff-tree c3ea1f7db494365032526dc06a7283384bd0ecd1 (from 3a9b96425851b495503bd2eb0fd0d01c08f6a097)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sat Nov 4 21:38:31 2006 +0200

    dix/mi: still more warning fixes
    
    Fix up prototypes for PrintChildren and PrintWindowTree in the dix.
    Make miPrintRegion be unconditionally defined, and move the prototype into
    regionstr.h.
    Change a bunch of ScreenPtr pScreen = foo; to
    ScreenPtr pScreen; pScreen = foo; in window.c, so we avoid unused variable
    references (as inline REGION_* doesn't reference pScreen).

diff --git a/dix/window.c b/dix/window.c
index 3dfeda3..f0079e0 100644
--- a/dix/window.c
+++ b/dix/window.c
@@ -187,7 +187,7 @@ _X_EXPORT int deltaSaveUndersViewable = 
  *    For debugging only
  ******/
 
-int
+static void
 PrintChildren(WindowPtr p1, int indent)
 {
     WindowPtr p2;
@@ -197,14 +197,15 @@ PrintChildren(WindowPtr p1, int indent)
     {
 	p2 = p1->firstChild;
 	for (i=0; i<indent; i++) ErrorF( " ");
-	ErrorF( "%x\n", p1->drawable.id);
+	ErrorF( "%lx\n", p1->drawable.id);
 	miPrintRegion(&p1->clipList);
 	PrintChildren(p2, indent+4);
 	p1 = p1->nextSib;
     }
 }
 
-PrintWindowTree()
+static void
+PrintWindowTree(void)
 {
     int i;
     WindowPtr pWin, p1;
@@ -547,9 +548,11 @@ ClippedRegionFromBox(register WindowPtr 
                      register int x, register int y,
                      register int w, register int h)
 {
-    ScreenPtr pScreen = pWin->drawable.pScreen;
+    ScreenPtr pScreen;
     BoxRec box;
 
+    pScreen = pWin->drawable.pScreen;
+
     box = *(REGION_EXTENTS(pScreen, &pWin->winSize));
     /* we do these calculations to avoid overflows */
     if (x > box.x1)
@@ -1663,7 +1666,8 @@ CreateUnclippedWinSize (register WindowP
     pRgn = REGION_CREATE(pWin->drawable.pScreen, &box, 1);
 #ifdef SHAPE
     if (wBoundingShape (pWin) || wClipShape (pWin)) {
-	ScreenPtr pScreen = pWin->drawable.pScreen;
+	ScreenPtr pScreen;
+        pScreen = pWin->drawable.pScreen;
 
 	REGION_TRANSLATE(pScreen, pRgn, - pWin->drawable.x,
 			 - pWin->drawable.y);
@@ -1699,7 +1703,8 @@ SetWinSize (register WindowPtr pWin)
 			 (int)pWin->drawable.height);
 #ifdef SHAPE
     if (wBoundingShape (pWin) || wClipShape (pWin)) {
-	ScreenPtr pScreen = pWin->drawable.pScreen;
+	ScreenPtr pScreen;
+        pScreen = pWin->drawable.pScreen;
 
 	REGION_TRANSLATE(pScreen, &pWin->winSize, - pWin->drawable.x,
 			 - pWin->drawable.y);
@@ -1741,7 +1746,8 @@ SetBorderSize (register WindowPtr pWin)
 		(int)(pWin->drawable.height + (bw<<1)));
 #ifdef SHAPE
 	if (wBoundingShape (pWin)) {
-	    ScreenPtr pScreen = pWin->drawable.pScreen;
+	    ScreenPtr pScreen;
+            pScreen = pWin->drawable.pScreen;
 
 	    REGION_TRANSLATE(pScreen, &pWin->borderSize, - pWin->drawable.x,
 			     - pWin->drawable.y);
@@ -1952,7 +1958,8 @@ MakeBoundingRegion (
     BoxPtr	pBox)
 {
     RegionPtr	pRgn;
-    ScreenPtr   pScreen = pWin->drawable.pScreen;
+    ScreenPtr   pScreen;
+    pScreen = pWin->drawable.pScreen;
 
     pRgn = REGION_CREATE(pScreen, pBox, 1);
     if (wBoundingShape (pWin)) {
diff --git a/include/regionstr.h b/include/regionstr.h
index 6c39324..e6882e7 100644
--- a/include/regionstr.h
+++ b/include/regionstr.h
@@ -321,4 +321,7 @@ extern void miRegionEmpty(
 extern BoxPtr miRegionExtents(
     RegionPtr /*pReg*/);
 
+extern void miPrintRegion(
+    RegionPtr /*pReg*/);
+
 #endif /* REGIONSTRUCT_H */
diff --git a/mi/miregion.c b/mi/miregion.c
index fdb538c..0db46dc 100644
--- a/mi/miregion.c
+++ b/mi/miregion.c
@@ -223,8 +223,7 @@ _X_EXPORT RegDataRec miEmptyData = {0, 0
 RegDataRec  miBrokenData = {0, 0};
 RegionRec   miBrokenRegion = { { 0, 0, 0, 0 }, &miBrokenData };
 
-#ifdef DEBUG
-int
+_X_EXPORT void
 miPrintRegion(rgn)
     RegionPtr rgn;
 {
@@ -242,9 +241,7 @@ miPrintRegion(rgn)
       ErrorF("%d %d %d %d \n",
 	     rects[i].x1, rects[i].y1, rects[i].x2, rects[i].y2);
     ErrorF("\n");
-    return(num);
 }
-#endif /* DEBUG */
 
 _X_EXPORT Bool
 miRegionEqual(reg1, reg2)
diff-tree 3a9b96425851b495503bd2eb0fd0d01c08f6a097 (from 6716488fa256798070017232405b107d5c985479)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sat Nov 4 21:33:09 2006 +0200

    dix: add missing prototypes
    
    Add missing prototype for ffs, and include headers from ffs.c.
    Move PostSyntheticMotion prototype to input.h.

diff --git a/dix/events.c b/dix/events.c
index 3b1a0aa..b5937e7 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -327,7 +327,6 @@ static CARD8 criticalEvents[32] =
 
 #ifdef PANORAMIX
 static void ConfineToShape(RegionPtr shape, int *px, int *py);
-extern void PostSyntheticMotion(int x, int y, int screenNum, int time);
 static void PostNewCursor(void);
 
 #define SyntheticMotion(x, y) \
diff --git a/dix/ffs.c b/dix/ffs.c
index e25d715..f84f7b4 100644
--- a/dix/ffs.c
+++ b/dix/ffs.c
@@ -26,6 +26,12 @@ The Open Group.
 
 */
 
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "dix.h"
+
 int
 ffs(int i)
 {
diff --git a/include/dix.h b/include/dix.h
index f346b43..983a84f 100644
--- a/include/dix.h
+++ b/include/dix.h
@@ -701,6 +701,8 @@ extern Bool AllocateClientPrivate(
     int /*index*/,
     unsigned /*amount*/);
 
+extern int ffs(int i);
+
 /*
  *  callback manager stuff
  */
diff --git a/include/input.h b/include/input.h
index f2fe6d1..e7017cb 100644
--- a/include/input.h
+++ b/include/input.h
@@ -418,6 +418,12 @@ extern int GetProximityEvents(
     int num_valuators,
     int *valuators);
 
+extern void PostSyntheticMotion(
+    int x,
+    int y,
+    int screenNum,
+    unsigned long time);
+
 extern int GetMotionHistorySize(
     void);
 
diff-tree 6716488fa256798070017232405b107d5c985479 (from 51813d77bfb84609a58a98e678efe9b6c0bf5503)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sat Nov 4 21:30:23 2006 +0200

    dix: remove unused debug code

diff --git a/dix/main.c b/dix/main.c
index 203773a..88d7755 100644
--- a/dix/main.c
+++ b/dix/main.c
@@ -701,9 +701,6 @@ AddScreen(
     int i;
     int scanlinepad, format, depth, bitsPerPixel, j, k;
     ScreenPtr pScreen;
-#ifdef DEBUG
-    void	(**jNI) ();
-#endif /* DEBUG */
 
     i = screenInfo.numScreens;
     if (i == MAXSCREENS)
@@ -737,13 +734,6 @@ AddScreen(
     pScreen->ClipNotify = 0;	/* for R4 ddx compatibility */
     pScreen->CreateScreenResources = 0;
     
-#ifdef DEBUG
-    for (jNI = &pScreen->QueryBestSize; 
-	 jNI < (void (**) ()) &pScreen->SendGraphicsExpose;
-	 jNI++)
-	*jNI = NotImplemented;
-#endif /* DEBUG */
-
     /*
      * This loop gets run once for every Screen that gets added,
      * but thats ok.  If the ddx layer initializes the formats
diff-tree 51813d77bfb84609a58a98e678efe9b6c0bf5503 (from 844090a5b557705dd0adce2b7ed98813b5104d85)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sat Nov 4 21:29:05 2006 +0200

    dix: remove unused variable

diff --git a/dix/main.c b/dix/main.c
index 81350cc..203773a 100644
--- a/dix/main.c
+++ b/dix/main.c
@@ -249,7 +249,6 @@ main(int argc, char *argv[], char *envp[
     int		i, j, k, error;
     char	*xauthfile;
     HWEventQueueType	alwaysCheckForInput[2];
-    CursorMetricRec cm;
 
     display = "0";
 
diff-tree 844090a5b557705dd0adce2b7ed98813b5104d85 (from 61b570d0c1eb448f0aa08b4598118f0d43bc7345)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sat Nov 4 21:21:29 2006 +0200

    xfree86/xf86misc: warning fixes

diff --git a/hw/xfree86/common/xf86MiscExt.c b/hw/xfree86/common/xf86MiscExt.c
index 375226a..6524284 100644
--- a/hw/xfree86/common/xf86MiscExt.c
+++ b/hw/xfree86/common/xf86MiscExt.c
@@ -247,7 +247,6 @@ _X_EXPORT Bool
 MiscExtSetMouseDevice(pointer mouse, char* device)
 {
     mseParamsPtr mse = mouse;
-
     mse->device = device;
     
     return TRUE;
@@ -256,9 +255,6 @@ MiscExtSetMouseDevice(pointer mouse, cha
 _X_EXPORT Bool
 MiscExtGetKbdSettings(pointer *kbd)
 {
-    kbdParamsPtr kbdptr;
-    InputInfoPtr pInfo;
-
     DEBUG_P("MiscExtGetKbdSettings");
 
     return FALSE;
diff-tree 61b570d0c1eb448f0aa08b4598118f0d43bc7345 (from c51fadc07d938f6a3edfd5620170fcb7d6486a11)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sat Nov 4 21:21:09 2006 +0200

    xfree86/os-support: update prototype for OSRingBell

diff --git a/hw/xfree86/os-support/xf86_OSproc.h b/hw/xfree86/os-support/xf86_OSproc.h
index 0311b81..1bbbf56 100644
--- a/hw/xfree86/os-support/xf86_OSproc.h
+++ b/hw/xfree86/os-support/xf86_OSproc.h
@@ -150,7 +150,7 @@ extern Bool xf86DisableInterrupts(void);
 extern void xf86EnableInterrupts(void);
 extern void xf86SetTVOut(int);
 extern void xf86SetRGBOut(void);
-extern void xf86SoundKbdBell(int, int, int);
+extern void xf86OSRingBell(int, int, int);
 #if defined(QNX4)
 #pragma aux xf86BusToMem modify [eax ebx ecx edx esi edi];
 #pragma aux xf86MemToBus modify [eax ebx ecx edx esi edi];
diff-tree c51fadc07d938f6a3edfd5620170fcb7d6486a11 (from 578899139f133746634a7bf8845e25362b5dfca2)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sat Nov 4 21:20:45 2006 +0200

    mieq: annotate with some more comments

diff --git a/mi/mieq.c b/mi/mieq.c
index be76580..80915fd 100644
--- a/mi/mieq.c
+++ b/mi/mieq.c
@@ -58,7 +58,7 @@ typedef struct _Event {
     xEvent          event[7];
     int             nevents;
     ScreenPtr	    pScreen;
-    DeviceIntPtr    pDev;
+    DeviceIntPtr    pDev; /* device this event _originated_ from */
 } EventRec, *EventPtr;
 
 typedef struct _EventQueue {
@@ -136,7 +136,9 @@ mieqEnqueue(DeviceIntPtr pDev, xEvent *e
     	newtail = oldtail + 1;
     	if (newtail == QUEUE_SIZE)
 	    newtail = 0;
-    	/* Toss events which come in late */
+    	/* Toss events which come in late.  Usually this means your server's
+         * stuck in an infinite loop somewhere, but SIGIO is still getting
+         * handled. */
     	if (newtail == miEventQueue.head) {
             ErrorF("tossed event which came in late\n");
 	    return;
@@ -200,6 +202,8 @@ mieqProcessInputEvents()
             else
                 ++miEventQueue.head;
 
+            /* If this is a core event, make sure our keymap, et al, is
+             * changed to suit. */
             if (e->event[0].u.u.type == KeyPress ||
                 e->event[0].u.u.type == KeyRelease) {
                 SwitchCoreKeyboard(e->pDev);
diff-tree 578899139f133746634a7bf8845e25362b5dfca2 (from ae58d349c1cf5d63ad3616c485baa858350978d5)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sat Nov 4 20:35:55 2006 +0200

    RemoveGeneralSocket: don't touch EnabledDevices
    
    RemoveGeneralSocket.  Harmless, but.

diff --git a/os/connection.c b/os/connection.c
index cdd1d18..95c5500 100644
--- a/os/connection.c
+++ b/os/connection.c
@@ -1091,7 +1091,6 @@ AddEnabledDevice(int fd)
 _X_EXPORT void
 RemoveGeneralSocket(int fd)
 {
-    FD_CLR(fd, &EnabledDevices);
     FD_CLR(fd, &AllSockets);
     if (GrabInProgress)
 	FD_CLR(fd, &SavedAllSockets);
diff-tree ae58d349c1cf5d63ad3616c485baa858350978d5 (from 96f78e3886791b723ccd9ba40bea701603537b0c)
Author: Laurence Withers <l at lwithers.me.uk>
Date:   Sat Nov 4 19:34:37 2006 +0200

    CreateColormap: fix return value (bug #7083)
    
    Return BadMatch when an unsupported visual type is given, not BadValue --
    this is correct according to the spec.

diff --git a/dix/dispatch.c b/dix/dispatch.c
index d8e3ae7..26cb544 100644
--- a/dix/dispatch.c
+++ b/dix/dispatch.c
@@ -2520,7 +2520,7 @@ ProcCreateColormap(register ClientPtr cl
 	    return(result);
     }
     client->errorValue = stuff->visual;
-    return(BadValue);
+    return(BadMatch);
 }
 
 int
diff-tree 96f78e3886791b723ccd9ba40bea701603537b0c (from 5a40448f2d0ac2c86c617bebe3fb649174bf0d7f)
Author: Erik Andren <erik.andren at gmail.com>
Date:   Sat Nov 4 19:29:49 2006 +0200

    remove XFree86 changelogs (bug #7262)
    
    Without being able to tie these to specific commits, the text changelog is
    useless, as well as being huge.

diff --git a/hw/xfree86/doc/changelogs/CHANGELOG b/hw/xfree86/doc/changelogs/CHANGELOG
deleted file mode 100644
index a8d6dff..0000000
--- a/hw/xfree86/doc/changelogs/CHANGELOG
+++ /dev/null
@@ -1,18691 +0,0 @@
-XFree86 4.4.0 (29 February 2004)
- 821. Fix Radeon secondary head register initialization (Hui Yu at ATI,
-      Benjamin Herrenschmidt).
- 820. ati & atimisc module changes (Marc La France)
-      - Allow builds with ATIAvoidNonPCI && !ATIAvoidCPIO;
-      - Make handling of unknown Radeon's saner;
-      - Add private option to re-enable BIOS display switches;
-      - Deal with ati & atimisc module version skews;
-      - Fix private option handling;
- 819. Fix rendition driver system lockup on changes to text mode
-      (Bugzilla #1204, Eric Wittry).
- 818. Make the "fp=n" TTCap option behave the same with the FreeType backend
-      as with the X-TT backend (Bugzilla #1163, Chisato Yamauchi).
- 817. Fix the disappearance of the RAW_ASCENT, RAW_DESCENT, RAW_PIXEL_SIZE,
-      and RAW_POINT_SIZE properties for the FreeType backend (Bugzilla #1163,
-      Chisato Yamauchi).
- 816. Fix a FreeType backend problem with the font ascent/descent being
-      incorrect with some fonts (Bugzilla #1163, Chisato Yamauchi, reported by
-      Michael Lampe).
- 815. Fix for detection of hardwired panel for the via driver (Bugzilla #813,
-      Luc Verhaegen, reported by Johannes Specht).
- 814. Fix missing ';' in via_driver.c hidden by an empty macro (Bugzilla #813,
-      Luc Verhaegen).
- 813. Add FT_Get_Postscript_Name() to the freetype2 export list for OS/2.
-      This is needed for the recent PostScript fontname property fix
-      (Bugzilla #1189, Frank Giessler).
- 812. Fix MGA driver for big endian and EXTRADEBUG compilation (derived from
-      #6132, Rene Rebe).
- 811. Turn off the GetDisplayInfo BIOS call by default and add an option 
-      to turn it back on in the i810 driver. This fixes some lockup
-      problems found with some Dell BIOS' (Alan Hourihane, Alain Poirier).
- 810. Fix compile issue in imstt driver (#6140, Rene Rebe)
- 809. Only reset primary head of a Radeon (#6133, Rene Rebe).
- 808. Fix big-endian typo in xf86CopyYUV12ToPacked (#6131, Rene Rebe).
- 807. Fix neomagic white screen/lockup bug introduced in 4.3.99.15 (Bugzilla
-      #1179, #1157, David Dawes).
- 806. Fixing DPMS: let modification of DPMS timeout take effect immeditately,
-      don't activate DPMS when disabled (Egbert Eich).
-
-XFree86 4.3.99.903 (15 February 2004)
- 805. Resync the pci.ids data with pciids.sf.net (2004-02-15 snapshot).
- 804. Improve X server performance on OS/2 when using TCP transport:
-       - Let the server set TCP_NODELAY, et al.
-       - Change the behavior of os2PseudoSelect() on sockets.
-      (Bugzilla #1175, Frank Giessler).
- 803. X server on OS/2 doesn't respect AutoRepeat on/off unless XKB is disabled
-      (Bugzilla #1174, Frank Giessler).
- 802. Licence update.
- 801. Optimise SlowBcopy() for ia64 architecture (Marc La France).
- 800. Simplify vgaHWSaveFonts() and vgaHWRestoreFonts() to fix hangs seen with
-      certain nVidia boards on ZX1-based systems (Marc La France).
- 799. Some more font path checks.
- 798. Don't define X_LOCALE on Panther (Etsushi Kato and Toshimitsu Tanaka).
- 797. Fix GL_VERSION string for indirect rendering (Bugzilla #1147, DRI Project)
- 796. Fix the 1024x576 modes in the via driver (Bugzilla #812, Luc Verhaegen,
-      reported by Julian Cable).
- 795. Add uz_UZ locale (Bugzilla #1151, Mashrab Kuvatov).
- 794. Fix font alias overrun.
- 793. Fix for the way the FreeType backend sets the
-      _ADOBE_POSTSCRIPT_FONTNAME property for Type1 fonts (Bugzilla #1123,
-      David Dawes, based on Roland Mainz, reported by David Capshaw).
- 792. Fix formatting of the XLookupString bytes that xev prints out (Bugzilla
-      #1153, Noah Levitt).
- 791. Likely fix for FreeBSD 5.2 libGL build problem (David Dawes, reported by
-      Terry R. Friedrichsen).
- 790. Fix typo in bsd_mouse.c (Tyler Retzlaff).
- 789. Fix off-by-one errors in the emulation of an ix86's BT, BTS, BTR and BTC
-      instructions (Marc La France).
- 788. Fixing segfaults that may happen in some corner cases on VT switch
-      and int10 initialization (Egbert Eich).
- 787. Increase PCI I/O space size on Linux/PowerPC (Bugzilla #1143,
-      Paul Mackerras).
- 786. Fix DRI cleanup at exit and re-enabling on reset for the via driver
-      (Bugzilla #998, Thomas Hellström).
- 785. Fix Xv error propagation to the client for the via driver (Bugzilla #998,
-      Thomas Hellström).
- 784. Fix a problem when utilizing DrawArrays when indirect rendering
-      (Bugzilla #1142, DRI Project).
- 783. Xterm followup fix for Bugzilla #981 (Thomas Dickey).
- 782. Fix EXT version of vertex arrays (DRI Project).
- 781. Fix long-standing off-by-one bug in calculating dimensions of single
-      (private) back cliprect when the window is partially offscreen in
-      libdri.a (Keith Whitwell)
- 780. Don't do the MGAISBUSY() loop in MGAStormSync() for Mystique cards
-      because this reportedly results in an infinite loop (Bugzila #85,
-      David Dawes, reported by Phil ??? and Stéphane VOLTZ).
- 779. Make sure the r128 driver enables the hsync and vsync signals after
-      programming a video mode (Bugzilla #935, Kevin Martin).
- 778. Fix Multitexture problems with vertex arrays and indirect rendering
-      (Bugzilla #1092, DRI Project).
- 777. Fix SecondaryColor & FogColor when indirect rendering (Bugzilla #1091, 
-      DRI Project).
- 776. Fix build failures on Mac OS X 10.1.x (Torrey T. Lyons).
- 775. Fix a timing problem in the nsc driver that prevents the display from
-      working in some cases (Bugzilla #840, Hansruedi Glauser, Alan Hourihane).
- 774. Via driver workaround to handle setting WC for the video memory when
-      initially only part of it has WC set (Bugzilla #1010 Thomas Hellström).
- 773. Fix the XAA clipping flags for the via driver, which fixes a line
-      drawing problem seen with OpenOffice Calc (Bugzilla #1026,
-      Thomas Hellström).
- 772. HKSCS and GB18030 support for luit (Bugzilla #1048, Zarick Lau).
- 771. Fix some remaining memory allocation related problems with the via
-      driver (Bugzilla #998, Thomas Hellström).
- 770. Add a UseRpath build switch to allow the use of -rpath to be enabled
-      or disabled from the host.def file.  Implemented for *BSD, Hurd, Linux.
-      The default settings remains as before (David Dawes).
- 769. Add a root window property called XFree86_VT that holds the VT number
-      that the XFree86 server is running on (Andrew Aitcheson, suggested by
-      Samuel Thibault).
- 768. Fix a problem where root window properties registered with
-      xf86RegisterRootWindowProperty() are not re-registered after server
-      regeneration (David Dawes, reported by Samuel Thibault).
- 767. Fix xtest failures for the savage driver's zero width lines by
-      removing the TwoPointLine and using only the Bresenham version
-      (reported by Nicolas Joly).
- 766. Fix refresh rate setting for 845G/856G systems that don't support the
-      Intel-specific refresh rate BIOS calls (Bugzilla #1106, David Dawes,
-      reported by Lucian Precup).
- 765. Fixes/build updates for BSD/OS 5.1 and 4.3.1 (Bugzilla #1111, Kurt Lidl).
- 764. Fix a problem in libXmu's FindChildren() that can cause a crash by
-      copying memory from outside the bounds of an array (Bugzilla #1109,
-      John Tillman).
- 763. Add missing TimerCallback in trident_video.c to shutdown the video.
-      This could account for many peoples lockups with video on Trident chips.
-      Also, add a Wait for vsync when programming video modes to avoid lockups.
-      (Yukun Chen, Alan Hourihane).
- 762. Fix a lockup problem on Trident Blade3D engines by permanently turning
-      on PCI Retry. Also sync the engine on CloseScreen and LeaveVT.
-      (Yukun Chen, Alan Hourihane).
- 761. Fix getaddrinfo() return value check in SmsGenerateClientID() that was
-      causing a crash when the current hostname is unresolved, and returning
-      a NULL id otherwise (Bugzilla #1096, David Dawes).
- 760. Support automatic configuration of the X server on OpenBSD with 
-      wsmouse-supported mices. (Matthieu Herrb).
- 759. Updates for XKB keyboard maps:
-      - Add Tibetan/Dzongkha keyboard layout (Bugzilla #1082, Gregory Mokhin).
-      - Add three new Internet/multimedia keyboard descriptions
-        (Bugzilla #1088, Radics Laszlo).
- 758. Add overlooked SecondaryColor entries to AppleDRI indirect dispatch
-      table (Torrey T. Lyons).
- 757. Allocate pBIOSInfo->UserSetting in the via driver, which fixes a crash
-      (James Harris).
- 756. Fix Linux drm kernel modules to handle the nopage() prototype change in
-      Linux 2.6.1 (Michel Dänzer, from DRI CVS).
- 755. Fix use of dynamic xcursors on OS/2 (Bugzilla #1087, Frank Giessler).
- 754. Fix the fbdev driver so that it allows 24-bit pixel size, and disable
-      the RandR extension when rotation is enabled (Jonathan Thambidurai).
- 753. Rendition driver fixes:
-       - Fix the mode size limits so that the set of modes that the driver
-         accepts isn't unnecessarily restricted.
-       - Fix color palette refreshing after VT switching.
-       - Fix a core dump at server exit with the hardware cursor was enabled.
-       - Add checking for supported depths.  Without this the server could
-         crash if an unsupported depth was specified.
-      (Eric Wittry)
- 752. Update XKB registry file rules/xfree86.xml (Sergey Oudaltsov).
- 751. Fix some rules in en_US.UTF-8 Compose file (Bugzilla #1071,
-      Matthew Fischer).
- 750. Add some content (supported hardware and driver options) to the tdfx(4)
-      man page (Bugzilla #1068, Nicolas Joly).
- 749. Make '-pn' (partial network) the default for all X servers, and document
-      the '-nopn' option (David Dawes).
- 748. Allow rstartd.real to be installed into a location other than LIBDIR
-      (#6034, Luke Mewburn).
- 747. Allow xdm's chooser to be installed into a directory other than LIBDIR
-      (#6033, Luke Mewburn).
- 746. Add XKB description for the Logitech Access keyboard (#6026,
-      Michael Geddes).
- 745. Fix typo in computing xterm's relative font size (Jess Thrysoee).
- 744. Fix typo in savage man page (Bugzilla #1065, Nicolas Joly).
- 743. Fix for xf86Msg() call with swapped arguments (Bugzilla #1064,
-      Nicolas Joly).
- 742. Set the dependencies correctly for SCO shared libraries, and use gcc
-      for linking instead of ld (Bugzilla #1045, Kean Johnston).
- 741. Some cleanups for the SCO support, and a few changes required for
-      compilation on UnixWare (Bugzilla #1045, Kean Johnston).
- 740. Make the X server lock file code treat the display string in the same
-      way as the local listener code (i.e., convert it to an integer then back
-      to a string).  This fixes a problem where an non-numeric display
-      argument could cause a second server to be started on display :0,
-      replacing the local listener nodes for the original server.
-      (Bugzilla #1056, David Dawes, reported by Robin Schoonover).
- 739. Fix xfs and xdm core dumps in BecomeOrphan(), and rework/simplify
-      the BecomeDaemon() code (Bugzilla #1060, #1074, David Dawes, 
-      reported by Martin Birgmeier).
- 738. Add a "VBERestore" option for the i830 part of the i810 driver, to
-      allow the VBE restore bug workaround to be disabled.  This is needed
-      for correct text mode restoration on some 830M-based machines
-      (David Dawes, reported by Martin van Es).
- 737. Fix memory leak when list of registered renderers are cleared at the
-      start of each new server generation (Kevin Martin and Rik Faith).
- 736. Fix memory double freeing at XIM destroying in imLcIm.c (Ivan Pascal,
-      reported: Bugzilla #1015).
- 735. Add xkb keymap for Microsoft Mutimedia Keyboard keys (Bugzilla #1052,
-      Jacques Legare).
- 734. Update Compose file for en_US.UTF-8 locale (Bugzilla #1053,
-      Matthew Fischer) and fix wrong comment signs there (Ivan Pascal).
- 733. VIA driver fixes:
-       - Restructure the via driver's cache allocation to work with both
-	 the VIA and new open DRI module, and remove the now unneeded
-	 version check (Thomas Hellström, Alan Cox, bugzilla #998).
-       - Remove special case lindvd hack (Alan Cox)
-       - Add support for Xv when unaccelerated (Thomas Hellström)
-      (Bugzilla #998, #1020, #1021).
- 732. Check for a NULL argument in XSetICFocus() before dereferencing it.
-      This fixes crashes with some XIM software (see
-      http://bugzilla.mozilla.gr.jp/show_bug.cgi?id=2961#c19).
- 731. Improve the i810 bitblt bug workaround, and re-enable the pixmap cache
-      at depth 24 (David Dawes).
- 730. Workaround for lockup at mode switch with an i810 (David Dawes).
- 729. Fix transparent mono 8x8 pattern fills for the i810 (David Dawes).
- 728. Disable XKB by default in XDarwin (Torrey T. Lyons).
- 727. Fix manpage build warnings on Panther (Matthieu Herrb).
- 726. Make sure that the ring buffer is flushed in I810CloseScreen().  This
-      fixes unpredictable behaviour that sometimes shows up after server
-      exit/restart or server reset, including memory corruption, spontaneous
-      reboots, etc, and some odd xtest behaviour (David Dawes).
- 725. Xdmcp fixes for IPv6 and mixed IPv6/IPv4 operation. (Mario Klebsch, 
-      Matthieu Herrb).
- 724. Update rman by merging XFree86 changes to rman 3.2 (Thomas Dickey).
- 723. Create fonts.scale and fonts.dir files in the target directories at
-      'make install' time.  This fixes several problems where some font
-      entries get left out (David Dawes).
- 722. Add the Bitstream Vera fonts (Bitstream, Inc and The Gnome Project).
- 721. Xterm patches #183, #184 (Thomas Dickey).
- 720. Build fix for the Chips driver on Linux/arm (#6011, Michel Dänzer and
-      Othmar Pasteka).
- 719. Change v4l "norm" names to the bttv versions (#5993,
-      Marco Antonio Alvarez).
- 718. Fix for symbols/hr map (#5991, Vlatko Kosturjak).
- 717. The current VIA DRI driver isn't remotely compatible with the current
-      code, so make sure it isn't loaded by requiring version 2.0.0 or later
-      (Alan Cox).
- 716. Fix VIA KM400 memory detection (Luc Verhaegen, Bugzilla #813).
- 715. Fix a long standing VIA Xv problem with totem/xine and YUV surface
-      types (Uberto Barbini).
- 714. VIA driver updates/fixes:
-       - Remove HARDWARE_NEEDS_PROGRAMMED_ORIGIN (Bugzilla #1011).
-       - Allocate the UserSetting structure and use it. Changed the names so
-         its uses can be tracked through the tree (Bugzilla #1006, #1014).
-       - Remove dead FIFO handling code.
-       - Clean up formatting in via_bios.h, via_driver.h.
-       - via_tuner module (1/2 of Bugzilla #1012, #1013):
-         + Add via_tuner structures and methods.
-         + Handle the back end work for boards with Philips SAA71xx
-           devices on the I2C bus providing one or two TV overlays.
-         + Handle CXA2104S audio decoder if present.
-         + Handle FI1236 TV tuners if present.
-       - Remove bogus DriverVersion, DriverName stuff.
-       - Xv updates (Bugzilla #1013):
-         + Remove DDR mode tables and compute supported overlay modes properly.
-         + Remove various bits of dead code.
-         + Probe for Tuners in the Xv setup.
-	 + Don't advertise XvImageMask on the tuner overlays - they can't do it.
-         + Clean up tuner channel computation.
-         + Make the property setting code use the via_tuner backend.
-         + Fix formatting of the various YUV copying loops.
-      (Alan Cox).
- 713. Add a missing code for jisx0208.1990-0.enc (Chisato Yamauchi).
- 712. Xtt2 update: Restore the behaviour of "bw" TTCap option for Netscape 4.x.
-      (Chisato Yamauchi).
- 711. Fix neomagic driver default mode selection to match the detected
-      panel size.  This allows it to work correctly with automatic
-      configuration (David Dawes).
- 710. Fixes and updates for XKB keyboard maps:
-      - Fix Armenian phonetic keymap (Bugzilla #1016, Ani).
-      - Fix rules for Brasilian ABNT2 keyboard (Ricardo Y. Igarashi).
-      - Add Shift+CapsLock group switcher (Ivan Pascal, see Bugzilla #1025).
-      - Update rules/xfree86.lst with missing descriptions (Ivan Pascal).
- 709. Build fix for Solaris Express (Bugzilla #1032, Alan Coopersmith).
- 708. Fix warning in lib/Xt/Alloc.c (Bugzilla #1035, Nicolas Joly).
- 707. Fix short overflow problem with box clipping in fb/fbcopy.c
-      (Bugzilla #978, Stephen McCamant).
- 706. Fix logic in xterm's get_pty() for platforms where old-style pty's are
-      preferred to /dev/ptmx (Bugzilla #997, Kean Johnston, Thomas Dickey).
- 705. Fix handling of eightBitInput for UTF-8 locales in xterm (Thomas Dickey).
- 704. Merge recent cygwin-related changes from freedesktop.org's config/cf
-      (Thomas Dickey).
- 703. Disable Xv in the via driver when acceleration is disabled (Alan Cox).
- 702. Fix bugs caused by empty PCI buses on ZX1-based systems (Marc La France).
- 701. Fix optional save/restore of BIOS area data in int10 module
-      (Marc La France).
- 700. Update Swedish localization of XDarwin GUI (Patrik Montgomery).
- 699. Fixes to build/run on cygwin (Thomas Dickey).  This includes a workaround
-      for _XtInherit by Ralf Habacker, needed to run applications such as xman.
- 698. Warning fixes for gcc 3.3.2 (Marc La France).
- 697. Fix file descriptor leaks in xdm (Marc La France).
- 696. Fix memory leaks in libFS (Marc La France).
- 695. Security fix:  change xdm to use mkstemp(), where available, instead of
-      mktemp() (Marc La France).
- 694. Update XKB registry file rules/xfree86.xml (Sergey Oudaltsov).
- 693. Fix for FreeType-related crash when attempting to draw a missing glyph
-      with constant-width fonts (Chisato Yamauchi).
-
-XFree86 4.3.99.902 (18 December 2003)
- 672. Fixes for xterm (Thomas Dickey):
-      - Add a limit-check in selection to fix a bug in triple-clicking
-        (Bugzilla #981)
-      - add -v/-version/-h/-help options to uxterm (Debian #223926)
- 671. Updates for SCO support (Bugzilla #994, Kean Johnston).
- 670. Don't build the Aiptek driver unless HasLinuxInput is set
-      (Bugzilla #972, Andrew Aitchison).
- 669. A new fixed version of the zh_CN.UTF-8 locale file (Bugzilla #991,
-      James Su).
- 668. Fix locale.dir/locale.alias bugs that break the zh_CN.GB2312 locale
-      (Bugzilla #990, James Su).
- 667. Fixes and updates for XKB keyboard maps:
-      - Add to 'us' keymap backslash key that can be rewritten in other layouts
-        (Bugzilla #976, Børre Gaup).
-      - Fix some keys in Georgian latin keymap (Bugzilla #985, Vano Beridze).
-      - Add Korean keymap (Jungshik Shin).
-      - Add French variant of 'dvorak' keymap (Josselin Mouette).
-      - Fix wrong key type in the 'keymap without special keys' (Ivan Pascal).
- 666. Via driver updates:
-       - Fix pixmap caches and Xv. The blitter has a 2048 pixel limit so we
-         must constrain the pixmap cache.
-       - Rip out all the memory allocator garbage and put it in one place.
-       - Allow optional use of AlanH's new linear allocator (not yet heavily
-         tested).
-       - Fix allocation bugs that this clean up made visible.
-       - Add missing I2C symbols.
-       - Some small formatting/other cleanups.
-      (Alan Cox).
- 665. Fix a problem with distinguishing unassigned characters in the FreeType
-      backend (Bugzilla #975, Roland Mainz, Chisato Yamauchi).
- 664. Update Japanese localization of XDarwin GUI (Toshimitsu Tanaka).
- 663. Fix setjmp-related build issues on Solaris 2.5.1/x86 (Lindsay Haigh).
- 662. Xdm, xf86cfg, mkfontscale and fonttosfnt fixes for platforms without
-      snprintf() (Lindsay Haigh).
- 661. Update Brazilian keyboard map (Ricardo Y. Igarashi).
- 660. Fix a bug in the fbgc.c code that caused the even stipple code path to
-      be used instead of the odd stipple path. Basically causing glitches in
-      rendering or no rendering at all. (Alan Hourihane).
- 659. Fix XDarwin crash in IOKit mode for certain screen resolutions
-      (Torrey T. Lyons).
- 658. DRI update - update the SiS DRI driver from DRI trunk (Eric Anholt).
- 657. Fix mouse wheel code again for PowerPC (#5990, Rene Rebe).
- 656. Fix sparc asm glapi initialisation in libGL when using indirect rendering
-      (GLX) (Bugzilla #923, Ferris McCormick).
- 655. Disable the OPTGX1SubsequentHorVertLine() function in the NSC Geode
-      GX1 driver to due problems falling back to the FillRectSolid function.
-      (Alan Hourihane, See Bugzilla #841 for reasons).
- 654. Add sun.unicode.india-0.enc (Bugzilla #939, JungShik Shin, Roland Mainz).
- 653. Fix an x86emu crash for a BIOS that references the FS (or GS) register
-      (Sergey Babkin).
- 652. Install the DRM kernel module source under ProjectRoot/src (David Dawes).
- 651. Update XKB registry file rules/xfree86.xml (Sergey Oudaltsov).
- 650. Fix '-nolisten tcp' when building with IPv6 disabled (Bugzilla #651,
-      Andrew Bevitt).
- 649. Add some missing dead-key compose sequences for Vietnamese (#5981,
-      Le Hong Boi).
- 648. Fix a problem with the v4l driver not seeing all the tv-norms
-      available under the bttv driver with the Linux 2.6.0-test11 kernel
-      (#5976, Marco Antonio Alvarez).
- 647. Build fix after recent REGION_* changes (Part of #5983, Oswald
-      Buddenhagen, and #5984, Alexander Stohr).
- 646. Fix for XKB map 'altwin' to avoid one keysym to more than one modifier
-      mapping (Ivan Pascal).
- 
-XFree86 4.3.99.901 ( 2 December 2003)
- 645. Update xterm's checking of modifiers to match change 635, and handle
-      the case of keys like Meta_L being in more than one modifier.  This
-      addresses an issue arising from Bugzilla #924 (David Dawes).
- 644. When XDM-AUTHORIZATION-1 is used with IPv6 IPv4-mapped addresses,
-      (which should not happen with change 643, but can be done with other 
-      xdm implementations) send the IPv4 address in the auth data; otherwise
-      send fake data for alignement purposes. (Matthieu Herrb).
- 643. Don't generate XDM-AUTHORIZATION-1 authentification data for 
-      IPv6 connections (Matthieu Herrb).
- 642. Fix fontconfig timestamp checking problem that shows up on JFS
-      (Bugzilla #932, Frank Giessler).
- 641. Restore VT ownership at XFree86 server exit on Linux.  Should do the
-      same for other platforms that change change VT ownership at startup
-      (Bugzilla #927, Andrew Bevitt).
- 640. Fix Mesa/GL problem on Linux with -mcpu=ultrasparc (reported by
-      Ferris McCormick).
- 639. Fix a problem connecting to an IPv4-only X server running on a
-      machine which happens to have an AAAA DNS record from a NetBSD or
-      OpenBSD host with IPv6 configured (Matthieu Herrb).
- 638. Don't use IPv6 sockets with IPv4-mapped addresses (::FFFF:w.x.y.z)
-      when making IPv4 connections with the "tcp" transport type.  This
-      fixes problems on platforms (such as FreeBSD 5.1) which disable
-      IPv4-mapped addresses by default.  It also fixes a problem with
-      XDM-AUTHORIZATION-1 for IPv4 connections with the default "tcp"
-      transport as reported in Bugzilla #903 (David Dawes).
- 637. Fix backward compatibility of Xlib+IPv6 for apps linked against a libc
-      without IPv6 support (David Dawes).
- 636. Restore the behaviour of scalable fonts.dir entries in directories with
-      the ":unscaled" attribute (Chisato Yamauchi, David Dawes, reported by
-      Mike Fabian).
- 635. Fix xmodmap's output of the modifiers map when the first column keysym
-      is empty (Ivan Pascal).
- 634. Fixes for XKB keyboard maps:
-      - fix Meta, Super, Hyper keysyms interpretation
-      - fix typo in rules/xfree86.xml (Ivan Pascal).
- 633. DRI updates.
-      - Latest kernel drivers from the DRI trunk.
-      - Fix FB_LOCATION in radeon driver (Michel Daenzer).
-      - Texture managment code consolidation (Ian Romanick)
-      - i830 stencil fix (Keith Whitwell)
-      - mga blend fixes (Ville Syrjala)
- 632. Fix a problem that prevented the i810 driver from using dot clocks less
-      than 12MHz (which appear to work) (Bugzilla #925, Richard Dengler).
- 631. Fix a server crash that can happen when loading some CID fonts
-      (Bugzilla #906, David Dawes).
- 630. Restructured version of the wacom driver, with support for TwinView,
-      fixed bugs and added filters (Bugzilla #537, Ping Cheng).
- 629. Fix libfontenc link failure on OS/2 (Bugzilla #921, Frank Giessler).
- 628. OS/2 fixes:
-       - Unable to connect to a font server.
-       - SIGFPE in GLX.
-      (Bugzila #920, Frank Giessler).
- 627. Add a missing entry to big5hkscs-0.enc (Bugzilla #917, Jungshik Shin).
- 626. Update libfreetype-xtt2 to version 1.1a:
-       - Fixed erroneous method of making up italic bitmap.
-      (Chisato Yamauchi, After X-TT Project).
- 625. OS/2 build fixes:
-       - Cleanup of bootstrap leftovers in xc/config/imake.
-       - Explicitly define int32_t and int64_t in Mesa.
-       - Missing Xft/Imakefile patch.
-      (Bugzilla #915, Frank Giessler).
- 624. Fix hide/unhide of XDarwin application with xpr when an AppleWM-aware
-      window manager is not present (Torrey T. Lyons).
- 623. Fix generic rootless code bug which caused the wrong region to be
-      damaged on window resize (Torrey T. Lyons).
- 622. Fix server crash when doing 'listwithinfo' of an outline font in
-      a directory marked ":unscaled" (Bugzilla #911, David Dawes).
- 621. Fix a key truncation problem with 'xauth add' (Bugzilla #903,
-      David Dawes).
- 620. With AppleDRI, don't use APPLE_fence as a replacement for NV_fence
-      calls (John Harper).
- 619. Fix intermittent XDarwin crash when quitting (Torrey T. Lyons).
- 618. Build fixes and updates for GNU/Hurd and GNU/K*BSD systems (Bugzilla
-      #907, #908, Robert Millan).
- 617. Xterm fixes (Bugzilla #893, #905, Thomas Dickey).
- 616. XDarwin fixes:
-       - Fix intermittent crash on XDarwin startup.
-       - Fix failure to redraw after resizing with cr implementation.
-       - Fix install failure when DESTDIR is specified (Reported by
-         Benjamin Reed).
-      (Torrey T. Lyons).
- 615. Add command line options to mkfontscale to enable/disable generation
-      of iso10646-1 lines (Bugzilla #885, Roland Mainz).
- 614. Add a more complete set of the encodings we support to mkfontscale
-      (Bugzilla #884, Roland Mainz).
- 613. Add ansi-1251 encoding file (Bugzilla #884, Roland Mainz).
- 612. Update XDMCP to use the IPv6 multicast address that has been assigned
-      by IANA.  Draft XDMCP 1.1 specs updated accordingly (Bugzilla #895,
-      Alan Coopersmith).
- 611. Add 'defined(VT_ACTIVATE)' to the test for platforms that support VT
-      switching (based on Bugzilla #894, Robert Millan).
- 610. Make several tests for glibc features glibc-specific rather than
-      specific to the underlying OS (Bugzila #890, 891, Robert Millan).
-
-XFree86 4.3.99.16 (20 November 2003)
- 609. Fix 'constype' for modern framebuffers on Solaris (Bugzilla #890,
-      Alan Coopersmith).
- 608. Fix a thread deadlock problem in libXp (Bugzilla #887, Roland Mainz).
- 607. Fix event buffer overrun in the wacom driver (Bugzilla #882, David Dawes,
-      reported by Jonathan Hough).
- 606. Add unmapping code to DGAUnmapPhysical() for most systems that use
-      mmap().  Without this lots of map/unmap calls would result in running
-      out of address space and/or file handles (Bugzilla #880, David Dawes,
-      reported by Eckhard Neber).
- 605. Restore the Windows keycodes in the 'xfree86' XKB keycodes map,
-      and add the Solaris-compatible tokens as aliases (reported by
-      Panagiotis Papadakos).
- 604. Fix some problems building against external installations of
-      freetype2 (David Dawes).
- 603. Add font bounds checking to the X server side of the font server
-      interface (Chisato Yamauchi, David Dawes).
- 602. Fix ForcePCIMode option to work as advertised in Radeon driver
-      (Bugzilla #850, Kevin Martin).
- 601. Update the fonts document for the FreeType backend changes
-      (Chisato Yamauchi, Reiko Nakajima, After X-TT Project).
- 600. Don't allow the lack of "SUPERSCRIPT TWO" to prevent Adobe Standard
-      Cyrillic encoded fonts from being accepted as "koi8" capable
-      (Michail Vidiassov).
- 599. Xvfb didn't have enough pixmap formats for Render (David Da