xserver: Branch 'mpx' - 77 commits

Peter Hutterer whot at kemper.freedesktop.org
Mon May 19 17:55:19 PDT 2008


 .gitignore                                                                                                       |    9 
 Xext/Makefile.am                                                                                                 |    7 
 Xext/panoramiX.c                                                                                                 |   33 
 Xext/panoramiXsrv.h                                                                                              |   10 
 Xext/xprint.c                                                                                                    | 2617 ------
 composite/Makefile.am                                                                                            |    1 
 composite/compext.c                                                                                              |  193 
 composite/compinit.c                                                                                             |   13 
 composite/compint.h                                                                                              |   24 
 composite/compoverlay.c                                                                                          |  159 
 composite/compwindow.c                                                                                           |   72 
 config/hal.c                                                                                                     |   21 
 configure.ac                                                                                                     |  160 
 dev/null                                                                                                         |binary
 dix/Makefile.am                                                                                                  |   10 
 dix/dispatch.c                                                                                                   |    6 
 dix/dixfonts.c                                                                                                   |   58 
 dix/globals.c                                                                                                    |    7 
 dix/main.c                                                                                                       |   23 
 dix/xpstubs.c                                                                                                    |   28 
 hw/Makefile.am                                                                                                   |    9 
 hw/kdrive/Makefile.am                                                                                            |    8 
 hw/kdrive/Xkdrive.man                                                                                            |   20 
 hw/kdrive/ati/Makefile.am                                                                                        |   74 
 hw/kdrive/ati/ati.c                                                                                              |  761 --
 hw/kdrive/ati/ati.h                                                                                              |  409 -
 hw/kdrive/ati/ati_cursor.c                                                                                       |  561 -
 hw/kdrive/ati/ati_dma.c                                                                                          | 1037 --
 hw/kdrive/ati/ati_dma.h                                                                                          |  141 
 hw/kdrive/ati/ati_draw.c                                                                                         |  918 --
 hw/kdrive/ati/ati_draw.h                                                                                         |   93 
 hw/kdrive/ati/ati_drawtmp.h                                                                                      |  237 
 hw/kdrive/ati/ati_dri.c                                                                                          | 1138 ---
 hw/kdrive/ati/ati_dri.h                                                                                          |   97 
 hw/kdrive/ati/ati_dripriv.h                                                                                      |   57 
 hw/kdrive/ati/ati_microcode.c                                                                                    |  857 --
 hw/kdrive/ati/ati_reg.h                                                                                          | 1927 -----
 hw/kdrive/ati/ati_sarea.h                                                                                        |   38 
 hw/kdrive/ati/ati_stub.c                                                                                         |   77 
 hw/kdrive/ati/ati_video.c                                                                                        |  988 --
 hw/kdrive/ati/r128_blendtmp.h                                                                                    |  134 
 hw/kdrive/ati/r128_common.h                                                                                      |  170 
 hw/kdrive/ati/r128_composite.c                                                                                   |  564 -
 hw/kdrive/ati/r128_sarea.h                                                                                       |  185 
 hw/kdrive/ati/radeon_common.h                                                                                    |  460 -
 hw/kdrive/ati/radeon_composite.c                                                                                 |  875 --
 hw/kdrive/ati/radeon_sarea.h                                                                                     |  221 
 hw/kdrive/chips/Makefile.am                                                                                      |   36 
 hw/kdrive/chips/chips.c                                                                                          |  334 
 hw/kdrive/chips/chips.h                                                                                          |  117 
 hw/kdrive/chips/chipsdraw.c                                                                                      |  491 -
 hw/kdrive/chips/chipsstub.c                                                                                      |   67 
 hw/kdrive/ephyr/ephyr.c                                                                                          |   13 
 hw/kdrive/epson/Makefile.am                                                                                      |   36 
 hw/kdrive/epson/Xepson.man                                                                                       |   26 
 hw/kdrive/epson/epson13806.c                                                                                     |  604 -
 hw/kdrive/epson/epson13806.h                                                                                     |  132 
 hw/kdrive/epson/epson13806draw.c                                                                                 |  649 -
 hw/kdrive/epson/epson13806draw.h                                                                                 |  119 
 hw/kdrive/epson/epson13806reg.h                                                                                  |  183 
 hw/kdrive/epson/epson13806stub.c                                                                                 |   69 
 hw/kdrive/i810/Makefile.am                                                                                       |   39 
 hw/kdrive/i810/i810.c                                                                                            | 2112 -----
 hw/kdrive/i810/i810.h                                                                                            |  511 -
 hw/kdrive/i810/i810_cursor.c                                                                                     |  436 -
 hw/kdrive/i810/i810_reg.h                                                                                        |  695 -
 hw/kdrive/i810/i810_video.c                                                                                      | 1136 ---
 hw/kdrive/i810/i810draw.c                                                                                        |  352 
 hw/kdrive/i810/i810draw.h                                                                                        |   46 
 hw/kdrive/i810/i810stub.c                                                                                        |   92 
 hw/kdrive/igs/igs.c                                                                                              |  667 -
 hw/kdrive/igs/igs.h                                                                                              |  327 
 hw/kdrive/igs/igscmap.c                                                                                          |   62 
 hw/kdrive/igs/igscurs.c                                                                                          |  345 
 hw/kdrive/igs/igsdraw.c                                                                                          | 1463 ---
 hw/kdrive/igs/igsdraw.h                                                                                          |  258 
 hw/kdrive/igs/igsreg.c                                                                                           |  969 --
 hw/kdrive/igs/igsreg.h                                                                                           |  155 
 hw/kdrive/igs/igsstub.c                                                                                          |   71 
 hw/kdrive/ipaq/ipaq.c                                                                                            |   70 
 hw/kdrive/itsy/itsy.c                                                                                            |  325 
 hw/kdrive/itsy/itsy.h                                                                                            |   39 
 hw/kdrive/itsy/kbd.c                                                                                             |  251 
 hw/kdrive/itsy/ts.c                                                                                              |  210 
 hw/kdrive/mach64/Makefile.am                                                                                     |   43 
 hw/kdrive/mach64/mach64.c                                                                                        |  433 -
 hw/kdrive/mach64/mach64.h                                                                                        |  653 -
 hw/kdrive/mach64/mach64curs.c                                                                                    |  389 -
 hw/kdrive/mach64/mach64draw.c                                                                                    |  590 -
 hw/kdrive/mach64/mach64draw.h                                                                                    |   69 
 hw/kdrive/mach64/mach64stub.c                                                                                    |   75 
 hw/kdrive/mach64/mach64video.c                                                                                   |  994 --
 hw/kdrive/mga/Makefile.am                                                                                        |   38 
 hw/kdrive/mga/g400_common.h                                                                                      |  185 
 hw/kdrive/mga/g400_composite.c                                                                                   |  510 -
 hw/kdrive/mga/mga.c                                                                                              |  240 
 hw/kdrive/mga/mga.h                                                                                              |  164 
 hw/kdrive/mga/mgadraw.c                                                                                          |  324 
 hw/kdrive/mga/mgastub.c                                                                                          |   64 
 hw/kdrive/neomagic/Makefile.am                                                                                   |   49 
 hw/kdrive/neomagic/README                                                                                        |   15 
 hw/kdrive/neomagic/neo_draw.c                                                                                    |  210 
 hw/kdrive/neomagic/neomagic.c                                                                                    |  335 
 hw/kdrive/neomagic/neomagic.h                                                                                    |  210 
 hw/kdrive/neomagic/neomagicstub.c                                                                                |   73 
 hw/kdrive/nvidia/Makefile.am                                                                                     |   39 
 hw/kdrive/nvidia/nvidia.c                                                                                        |  361 
 hw/kdrive/nvidia/nvidia.h                                                                                        |  247 
 hw/kdrive/nvidia/nvidiacurs.c                                                                                    |  389 -
 hw/kdrive/nvidia/nvidiadraw.c                                                                                    |  238 
 hw/kdrive/nvidia/nvidiadraw.h                                                                                    |   69 
 hw/kdrive/nvidia/nvidiastub.c                                                                                    |   65 
 hw/kdrive/nvidia/nvidiavideo.c                                                                                   | 1016 --
 hw/kdrive/pcmcia/modes.h                                                                                         |   65 
 hw/kdrive/pcmcia/pcmcia.c                                                                                        | 1199 ---
 hw/kdrive/pcmcia/pcmcia.h                                                                                        |  267 
 hw/kdrive/pcmcia/pcmciacurs.c                                                                                    |  451 -
 hw/kdrive/pcmcia/pcmciarotate.c                                                                                  |  333 
 hw/kdrive/pcmcia/pcmciashadow.c                                                                                  |  199 
 hw/kdrive/pcmcia/pcmciastub.c                                                                                    |   63 
 hw/kdrive/pm2/Makefile.am                                                                                        |   37 
 hw/kdrive/pm2/glint_regs.h                                                                                       | 1370 ---
 hw/kdrive/pm2/pm2.c                                                                                              |  295 
 hw/kdrive/pm2/pm2.h                                                                                              |  162 
 hw/kdrive/pm2/pm2_draw.c                                                                                         |  318 
 hw/kdrive/pm2/pm2stub.c                                                                                          |   54 
 hw/kdrive/r128/Makefile.am                                                                                       |   36 
 hw/kdrive/r128/r128.c                                                                                            |  250 
 hw/kdrive/r128/r128.h                                                                                            |  123 
 hw/kdrive/r128/r128draw.c                                                                                        |  296 
 hw/kdrive/r128/r128stub.c                                                                                        |   67 
 hw/kdrive/savage/s3.c                                                                                            | 1835 ----
 hw/kdrive/savage/s3.h                                                                                            |  533 -
 hw/kdrive/savage/s3.nick                                                                                         |   41 
 hw/kdrive/savage/s3clock.c                                                                                       |   84 
 hw/kdrive/savage/s3cmap.c                                                                                        |  122 
 hw/kdrive/savage/s3curs.c                                                                                        |  422 -
 hw/kdrive/savage/s3draw.c                                                                                        | 3114 --------
 hw/kdrive/savage/s3draw.h                                                                                        |  468 -
 hw/kdrive/savage/s3gc.c                                                                                          |  299 
 hw/kdrive/savage/s3reg.c                                                                                         | 1301 ---
 hw/kdrive/savage/s3reg.h                                                                                         |  227 
 hw/kdrive/savage/s3rtst.c                                                                                        |  141 
 hw/kdrive/savage/s3stub.c                                                                                        |   93 
 hw/kdrive/sis300/Makefile.am                                                                                     |   51 
 hw/kdrive/sis300/sis.c                                                                                           |  311 
 hw/kdrive/sis300/sis.h                                                                                           |  160 
 hw/kdrive/sis300/sis_draw.c                                                                                      |  320 
 hw/kdrive/sis300/sis_reg.h                                                                                       |  902 --
 hw/kdrive/sis300/sis_stub.c                                                                                      |   77 
 hw/kdrive/sis530/sis.c                                                                                           |  921 --
 hw/kdrive/sis530/sis.h                                                                                           | 1215 ---
 hw/kdrive/sis530/sisclock.c                                                                                      |  232 
 hw/kdrive/sis530/siscmap.c                                                                                       |   64 
 hw/kdrive/sis530/siscurs.c                                                                                       |  364 
 hw/kdrive/sis530/sisdraw.c                                                                                       | 1649 ----
 hw/kdrive/sis530/sisdraw.h                                                                                       |  180 
 hw/kdrive/sis530/sisio.c                                                                                         |   30 
 hw/kdrive/sis530/sisstub.c                                                                                       |   67 
 hw/kdrive/smi/Makefile.am                                                                                        |   41 
 hw/kdrive/smi/smi.c                                                                                              |  343 
 hw/kdrive/smi/smi.h                                                                                              |  257 
 hw/kdrive/smi/smidraw.c                                                                                          |  340 
 hw/kdrive/smi/smidraw.h                                                                                          |   69 
 hw/kdrive/smi/smistub.c                                                                                          |   67 
 hw/kdrive/smi/smivideo.c                                                                                         | 1015 --
 hw/kdrive/src/kdrive.c                                                                                           |    6 
 hw/kdrive/trident/trident.c                                                                                      |  612 -
 hw/kdrive/trident/trident.h                                                                                      |  269 
 hw/kdrive/trident/tridentcurs.c                                                                                  |  389 -
 hw/kdrive/trident/tridentdraw.c                                                                                  |  496 -
 hw/kdrive/trident/tridentdraw.h                                                                                  |   69 
 hw/kdrive/trident/tridentstub.c                                                                                  |   94 
 hw/kdrive/trio/s3.c                                                                                              | 1013 --
 hw/kdrive/trio/s3.h                                                                                              | 1200 ---
 hw/kdrive/trio/s3clock.c                                                                                         |   85 
 hw/kdrive/trio/s3cmap.c                                                                                          |   70 
 hw/kdrive/trio/s3curs.c                                                                                          |  408 -
 hw/kdrive/trio/s3stub.c                                                                                          |   66 
 hw/kdrive/ts300/ts300.c                                                                                          |  136 
 hw/kdrive/via/Makefile.am                                                                                        |   37 
 hw/kdrive/via/via.c                                                                                              |  435 -
 hw/kdrive/via/via.h                                                                                              |  129 
 hw/kdrive/via/via_regs.h                                                                                         |  154 
 hw/kdrive/via/viadraw.c                                                                                          |  499 -
 hw/kdrive/via/viadraw.h                                                                                          |   45 
 hw/kdrive/via/viastub.c                                                                                          |  135 
 hw/kdrive/vxworks/vxkbd.c                                                                                        |  263 
 hw/kdrive/vxworks/vxmouse.c                                                                                      |  122 
 hw/kdrive/vxworks/vxworks.c                                                                                      |   42 
 hw/xfree86/common/Makefile.am                                                                                    |    1 
 hw/xfree86/common/xf86Init.c                                                                                     |   11 
 hw/xfree86/fbdevhw/fbdevhw.c                                                                                     |    4 
 hw/xfree86/modes/xf86Crtc.c                                                                                      |  280 
 hw/xfree86/modes/xf86Cursors.c                                                                                   |   15 
 hw/xfree86/modes/xf86EdidModes.c                                                                                 |    2 
 hw/xfree86/modes/xf86Modes.c                                                                                     |   22 
 hw/xfree86/modes/xf86Modes.h                                                                                     |    3 
 hw/xfree86/modes/xf86RandR12.c                                                                                   |    4 
 hw/xfree86/os-support/bsd/i386_video.c                                                                           |    8 
 hw/xfree86/xaa/xaaInit.c                                                                                         |    4 
 hw/xfree86/xaa/xaaPict.c                                                                                         |  144 
 hw/xnest/Font.c                                                                                                  |    5 
 hw/xprint/AttrValid.c                                                                                            |  701 -
 hw/xprint/AttrValid.h                                                                                            |  219 
 hw/xprint/DiPrint.h                                                                                              |   85 
 hw/xprint/Init.c                                                                                                 | 1920 -----
 hw/xprint/Makefile.am                                                                                            |   58 
 hw/xprint/Oid.c                                                                                                  | 3181 --------
 hw/xprint/Oid.h                                                                                                  |  293 
 hw/xprint/OidDefs.h                                                                                              |  170 
 hw/xprint/OidStrs.h                                                                                              |  172 
 hw/xprint/Util.c                                                                                                 |  370 
 hw/xprint/ValTree.c                                                                                              |  191 
 hw/xprint/attributes.c                                                                                           | 1740 ----
 hw/xprint/attributes.h                                                                                           |  130 
 hw/xprint/config/C/Makefile.am                                                                                   |    1 
 hw/xprint/config/C/print/Makefile.am                                                                             |   14 
 hw/xprint/config/C/print/Xprinters                                                                               |   49 
 hw/xprint/config/C/print/attributes/Makefile.am                                                                  |    3 
 hw/xprint/config/C/print/attributes/document                                                                     |   49 
 hw/xprint/config/C/print/attributes/job                                                                          |   25 
 hw/xprint/config/C/print/attributes/printer                                                                      |   96 
 hw/xprint/config/C/print/ddx-config/Makefile.am                                                                  |    1 
 hw/xprint/config/C/print/ddx-config/raster/Makefile.am                                                           |    3 
 hw/xprint/config/C/print/ddx-config/raster/pcl                                                                   |   39 
 hw/xprint/config/C/print/models/CANONBJ10E-GS/Makefile.am                                                        |    3 
 hw/xprint/config/C/print/models/CANONBJ10E-GS/model-config                                                       |   23 
 hw/xprint/config/C/print/models/CANONC3200-PS/Makefile.am                                                        |    5 
 hw/xprint/config/C/print/models/CANONC3200-PS/fonts/Makefile.am                                                  |   54 
 hw/xprint/config/C/print/models/CANONC3200-PS/model-config                                                       |   40 
 hw/xprint/config/C/print/models/GSdefault/Makefile.am                                                            |    3 
 hw/xprint/config/C/print/models/GSdefault/model-config                                                           |  137 
 hw/xprint/config/C/print/models/HPDJ1600C/Makefile.am                                                            |    5 
 hw/xprint/config/C/print/models/HPDJ1600C/fonts/Makefile.am                                                      |   50 
 hw/xprint/config/C/print/models/HPDJ1600C/fonts/README                                                           |  197 
 hw/xprint/config/C/print/models/HPDJ1600C/fonts/fonts.dir                                                        |   45 
 hw/xprint/config/C/print/models/HPDJ1600C/model-config                                                           |   40 
 hw/xprint/config/C/print/models/HPLJ4050-PS/Makefile.am                                                          |    5 
 hw/xprint/config/C/print/models/HPLJ4050-PS/fonts/Makefile.am                                                    |   54 
 hw/xprint/config/C/print/models/HPLJ4050-PS/model-config                                                         |   36 
 hw/xprint/config/C/print/models/HPLJ4family/Makefile.am                                                          |    5 
 hw/xprint/config/C/print/models/HPLJ4family/fonts/Makefile.am                                                    |   50 
 hw/xprint/config/C/print/models/HPLJ4family/fonts/README                                                         |  203 
 hw/xprint/config/C/print/models/HPLJ4family/fonts/fonts.dir                                                      |   45 
 hw/xprint/config/C/print/models/HPLJ4family/model-config                                                         |   39 
 hw/xprint/config/C/print/models/Makefile.am                                                                      |   11 
 hw/xprint/config/C/print/models/PS2PDFspooldir-GS/Makefile.am                                                    |    4 
 hw/xprint/config/C/print/models/PS2PDFspooldir-GS/model-config                                                   |   72 
 hw/xprint/config/C/print/models/PS2PDFspooldir-GS/ps2pdf_spooltodir.sh                                           |  130 
 hw/xprint/config/C/print/models/PSdefault/Makefile.am                                                            |    5 
 hw/xprint/config/C/print/models/PSdefault/fonts/Makefile.am                                                      |   44 
 hw/xprint/config/C/print/models/PSdefault/model-config                                                           |  136 
 hw/xprint/config/C/print/models/PSspooldir/Makefile.am                                                           |    4 
 hw/xprint/config/C/print/models/PSspooldir/model-config                                                          |   71 
 hw/xprint/config/C/print/models/PSspooldir/spooltodir.sh                                                         |  127 
 hw/xprint/config/C/print/models/SPSPARC2/Makefile.am                                                             |    5 
 hw/xprint/config/C/print/models/SPSPARC2/fonts/Makefile.am                                                       |   37 
 hw/xprint/config/C/print/models/SPSPARC2/model-config                                                            |   18 
 hw/xprint/config/Makefile.am                                                                                     |  712 -
 hw/xprint/config/README                                                                                          |  318 
 hw/xprint/config/en_US/Makefile.am                                                                               |    1 
 hw/xprint/config/en_US/print/Makefile.am                                                                         |    1 
 hw/xprint/config/en_US/print/attributes/Makefile.am                                                              |    3 
 hw/xprint/config/en_US/print/attributes/document                                                                 |   13 
 hw/xprint/ddxInit.c                                                                                              |  380 -
 hw/xprint/doc/Makefile.am                                                                                        |   19 
 hw/xprint/doc/Xprt.html                                                                                          |  115 
 hw/xprint/doc/Xprt.man.pre                                                                                       |  196 
 hw/xprint/doc/Xprt.sgml                                                                                          |  371 
 hw/xprint/etc/Makefile.am                                                                                        |    1 
 hw/xprint/etc/Xsession.d/92xprint-xpserverlist                                                                   |   30 
 hw/xprint/etc/Xsession.d/Makefile.am                                                                             |    2 
 hw/xprint/etc/init.d/Makefile.am                                                                                 |   12 
 hw/xprint/etc/init.d/xprint.cpp                                                                                  | 1277 ---
 hw/xprint/etc/profile.d/Makefile.am                                                                              |    1 
 hw/xprint/etc/profile.d/xprint.csh                                                                               |   16 
 hw/xprint/etc/profile.d/xprint.sh                                                                                |   16 
 hw/xprint/mediaSizes.c                                                                                           |  782 --
 hw/xprint/pcl-mono/Makefile.am                                                                                   |    5 
 hw/xprint/pcl/Makefile.am                                                                                        |    6 
 hw/xprint/pcl/Makefile.am.inc                                                                                    |   27 
 hw/xprint/pcl/Pcl.h                                                                                              |  619 -
 hw/xprint/pcl/PclArc.c                                                                                           |  268 
 hw/xprint/pcl/PclArea.c                                                                                          |  436 -
 hw/xprint/pcl/PclAttVal.c                                                                                        |  206 
 hw/xprint/pcl/PclAttr.c                                                                                          |   86 
 hw/xprint/pcl/PclColor.c                                                                                         |  851 --
 hw/xprint/pcl/PclCursor.c                                                                                        |  113 
 hw/xprint/pcl/PclDef.h                                                                                           |   67 
 hw/xprint/pcl/PclFonts.c                                                                                         |   72 
 hw/xprint/pcl/PclGC.c                                                                                            |  971 --
 hw/xprint/pcl/PclInit.c                                                                                          |  575 -
 hw/xprint/pcl/PclLine.c                                                                                          |  314 
 hw/xprint/pcl/PclMisc.c                                                                                          |  301 
 hw/xprint/pcl/PclPixel.c                                                                                         |  159 
 hw/xprint/pcl/PclPolygon.c                                                                                       |  351 
 hw/xprint/pcl/PclPrint.c                                                                                         |  709 -
 hw/xprint/pcl/PclSFonts.c                                                                                        |  427 -
 hw/xprint/pcl/PclSFonts.h                                                                                        |  115 
 hw/xprint/pcl/PclSpans.c                                                                                         |  137 
 hw/xprint/pcl/PclText.c                                                                                          |  934 --
 hw/xprint/pcl/PclWindow.c                                                                                        |  209 
 hw/xprint/pcl/Pclmap.h                                                                                           |  210 
 hw/xprint/ps/Makefile.am                                                                                         |   42 
 hw/xprint/ps/Ps.h                                                                                                |  600 -
 hw/xprint/ps/PsArc.c                                                                                             |  181 
 hw/xprint/ps/PsArea.c                                                                                            |  390 -
 hw/xprint/ps/PsAttVal.c                                                                                          |  289 
 hw/xprint/ps/PsAttr.c                                                                                            |  116 
 hw/xprint/ps/PsCache.c                                                                                           |  328 
 hw/xprint/ps/PsColor.c                                                                                           |  257 
 hw/xprint/ps/PsDef.h                                                                                             |   96 
 hw/xprint/ps/PsFTFonts.c                                                                                         |   85 
 hw/xprint/ps/PsFonts.c                                                                                           |  873 --
 hw/xprint/ps/PsGC.c                                                                                              |  418 -
 hw/xprint/ps/PsImageUtil.c                                                                                       |  329 
 hw/xprint/ps/PsInit.c                                                                                            |  648 -
 hw/xprint/ps/PsLine.c                                                                                            |  191 
 hw/xprint/ps/PsMisc.c                                                                                            |  320 
 hw/xprint/ps/PsPixel.c                                                                                           |  156 
 hw/xprint/ps/PsPixmap.c                                                                                          |  623 -
 hw/xprint/ps/PsPolygon.c                                                                                         |  259 
 hw/xprint/ps/PsPrint.c                                                                                           |  459 -
 hw/xprint/ps/PsSpans.c                                                                                           |  164 
 hw/xprint/ps/PsText.c                                                                                            |  581 -
 hw/xprint/ps/PsWindow.c                                                                                          |  222 
 hw/xprint/ps/psout.c                                                                                             | 1789 ----
 hw/xprint/ps/psout.h                                                                                             |  335 
 hw/xprint/ps/psout_ft.c                                                                                          |  337 
 hw/xprint/ps/psout_ftpstype1.c                                                                                   |  185 
 hw/xprint/ps/psout_ftpstype3.c                                                                                   |  439 -
 hw/xprint/ps/ttf2pt1wrap.c                                                                                       |   14 
 hw/xprint/raster/Makefile.am                                                                                     |   10 
 hw/xprint/raster/Raster.c                                                                                        | 1563 ----
 hw/xprint/raster/Raster.h                                                                                        |  117 
 hw/xprint/raster/RasterAttVal.c                                                                                  |  267 
 hw/xprint/spooler.c                                                                                              |  202 
 hw/xprint/spooler.h                                                                                              |   75 
 hw/xquartz/Makefile.am                                                                                           |    8 
 hw/xquartz/X11Application.m                                                                                      |   51 
 hw/xquartz/X11Controller.m                                                                                       |    1 
 hw/xquartz/bundle/English.lproj/main.nib/designable.nib                                                          | 3734 ---------
 hw/xquartz/bundle/Info.plist                                                                                     |    6 
 hw/xquartz/bundle/Makefile.am                                                                                    |  334 
 hw/xquartz/bundle/PkgInfo                                                                                        |    1 
 hw/xquartz/bundle/Resources/Dutch.lproj/InfoPlist.strings                                                        |binary
 hw/xquartz/bundle/Resources/Dutch.lproj/Localizable.strings                                                      |binary
 hw/xquartz/bundle/Resources/Dutch.lproj/main.nib/keyedobjects.nib                                                |binary
 hw/xquartz/bundle/Resources/English.lproj/InfoPlist.strings                                                      |binary
 hw/xquartz/bundle/Resources/English.lproj/Localizable.strings                                                    |binary
 hw/xquartz/bundle/Resources/English.lproj/main.nib/designable.nib                                                | 3753 ++++++++++
 hw/xquartz/bundle/Resources/English.lproj/main.nib/keyedobjects.nib                                              |binary
 hw/xquartz/bundle/Resources/French.lproj/InfoPlist.strings                                                       |binary
 hw/xquartz/bundle/Resources/French.lproj/Localizable.strings                                                     |binary
 hw/xquartz/bundle/Resources/French.lproj/main.nib/keyedobjects.nib                                               |binary
 hw/xquartz/bundle/Resources/German.lproj/InfoPlist.strings                                                       |binary
 hw/xquartz/bundle/Resources/German.lproj/Localizable.strings                                                     |binary
 hw/xquartz/bundle/Resources/German.lproj/main.nib/keyedobjects.nib                                               |binary
 hw/xquartz/bundle/Resources/Italian.lproj/InfoPlist.strings                                                      |binary
 hw/xquartz/bundle/Resources/Italian.lproj/Localizable.strings                                                    |binary
 hw/xquartz/bundle/Resources/Italian.lproj/main.nib/keyedobjects.nib                                              |binary
 hw/xquartz/bundle/Resources/Japanese.lproj/InfoPlist.strings                                                     |binary
 hw/xquartz/bundle/Resources/Japanese.lproj/Localizable.strings                                                   |binary
 hw/xquartz/bundle/Resources/Japanese.lproj/main.nib/keyedobjects.nib                                             |binary
 hw/xquartz/bundle/Resources/Spanish.lproj/InfoPlist.strings                                                      |binary
 hw/xquartz/bundle/Resources/Spanish.lproj/Localizable.strings                                                    |binary
 hw/xquartz/bundle/Resources/Spanish.lproj/main.nib/keyedobjects.nib                                              |binary
 hw/xquartz/bundle/Resources/X11.icns                                                                             |binary
 hw/xquartz/bundle/Resources/da.lproj/InfoPlist.strings                                                           |binary
 hw/xquartz/bundle/Resources/da.lproj/Localizable.strings                                                         |binary
 hw/xquartz/bundle/Resources/da.lproj/main.nib/keyedobjects.nib                                                   |binary
 hw/xquartz/bundle/Resources/fi.lproj/InfoPlist.strings                                                           |binary
 hw/xquartz/bundle/Resources/fi.lproj/Localizable.strings                                                         |binary
 hw/xquartz/bundle/Resources/fi.lproj/main.nib/keyedobjects.nib                                                   |binary
 hw/xquartz/bundle/Resources/ko.lproj/InfoPlist.strings                                                           |binary
 hw/xquartz/bundle/Resources/ko.lproj/Localizable.strings                                                         |binary
 hw/xquartz/bundle/Resources/ko.lproj/main.nib/keyedobjects.nib                                                   |binary
 hw/xquartz/bundle/Resources/no.lproj/InfoPlist.strings                                                           |binary
 hw/xquartz/bundle/Resources/no.lproj/Localizable.strings                                                         |binary
 hw/xquartz/bundle/Resources/no.lproj/main.nib/keyedobjects.nib                                                   |binary
 hw/xquartz/bundle/Resources/pl.lproj/InfoPlist.strings                                                           |binary
 hw/xquartz/bundle/Resources/pl.lproj/Localizable.strings                                                         |binary
 hw/xquartz/bundle/Resources/pl.lproj/main.nib/keyedobjects.nib                                                   |binary
 hw/xquartz/bundle/Resources/pt.lproj/InfoPlist.strings                                                           |binary
 hw/xquartz/bundle/Resources/pt.lproj/Localizable.strings                                                         |binary
 hw/xquartz/bundle/Resources/pt.lproj/main.nib/keyedobjects.nib                                                   |binary
 hw/xquartz/bundle/Resources/pt_PT.lproj/InfoPlist.strings                                                        |binary
 hw/xquartz/bundle/Resources/pt_PT.lproj/Localizable.strings                                                      |binary
 hw/xquartz/bundle/Resources/pt_PT.lproj/main.nib/keyedobjects.nib                                                |binary
 hw/xquartz/bundle/Resources/ru.lproj/InfoPlist.strings                                                           |binary
 hw/xquartz/bundle/Resources/ru.lproj/Localizable.strings                                                         |binary
 hw/xquartz/bundle/Resources/ru.lproj/main.nib/keyedobjects.nib                                                   |binary
 hw/xquartz/bundle/Resources/sv.lproj/InfoPlist.strings                                                           |binary
 hw/xquartz/bundle/Resources/sv.lproj/Localizable.strings                                                         |binary
 hw/xquartz/bundle/Resources/sv.lproj/main.nib/keyedobjects.nib                                                   |binary
 hw/xquartz/bundle/Resources/zh_CN.lproj/InfoPlist.strings                                                        |binary
 hw/xquartz/bundle/Resources/zh_CN.lproj/Localizable.strings                                                      |binary
 hw/xquartz/bundle/Resources/zh_CN.lproj/main.nib/keyedobjects.nib                                                |binary
 hw/xquartz/bundle/Resources/zh_TW.lproj/InfoPlist.strings                                                        |binary
 hw/xquartz/bundle/Resources/zh_TW.lproj/Localizable.strings                                                      |binary
 hw/xquartz/bundle/Resources/zh_TW.lproj/main.nib/keyedobjects.nib                                                |binary
 hw/xquartz/bundle/Sparkle.framework/Headers                                                                      |    1 
 hw/xquartz/bundle/Sparkle.framework/Resources                                                                    |    1 
 hw/xquartz/bundle/Sparkle.framework/Sparkle                                                                      |    1 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Headers/NSApplication+AppCopies.h                                 |   13 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Headers/NSFileManager+Authentication.h                            |   11 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Headers/NSFileManager+Verification.h                              |   15 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Headers/NSString+extras.h                                         |   61 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Headers/RSS.h                                                     |   98 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Headers/SUAppcast.h                                               |   27 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Headers/SUAppcastItem.h                                           |   57 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Headers/SUAutomaticUpdateAlert.h                                  |   21 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Headers/SUConstants.h                                             |   20 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Headers/SUStatusChecker.h                                         |   26 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Headers/SUStatusController.h                                      |   33 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Headers/SUUnarchiver.h                                            |   25 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Headers/SUUpdateAlert.h                                           |   40 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Headers/SUUpdater.h                                               |   55 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Headers/SUUtilities.h                                             |   20 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Headers/Sparkle.h                                                 |   22 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/Info.plist                                              |   22 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/SUStatus.nib/classes.nib                                |   12 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/SUStatus.nib/info.nib                                   |   16 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/SUStatus.nib/keyedobjects.nib                           |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/ca.lproj/SUAutomaticUpdateAlert.nib/classes.nib         |   12 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/ca.lproj/SUAutomaticUpdateAlert.nib/info.nib            |   12 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/ca.lproj/SUAutomaticUpdateAlert.nib/keyedobjects.nib    |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/ca.lproj/SUUpdateAlert.nib/classes.nib                  |   21 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/ca.lproj/SUUpdateAlert.nib/info.nib                     |   16 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/ca.lproj/SUUpdateAlert.nib/keyedobjects.nib             |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/ca.lproj/Sparkle.strings                                |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/cs.lproj/SUAutomaticUpdateAlert.nib/classes.nib         |   12 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/cs.lproj/SUAutomaticUpdateAlert.nib/info.nib            |   12 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/cs.lproj/SUAutomaticUpdateAlert.nib/keyedobjects.nib    |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/cs.lproj/SUUpdateAlert.nib/classes.nib                  |   21 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/cs.lproj/SUUpdateAlert.nib/info.nib                     |   16 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/cs.lproj/SUUpdateAlert.nib/keyedobjects.nib             |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/cs.lproj/Sparkle.strings                                |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/cy.lproj/SUAutomaticUpdateAlert.nib/classes.nib         |   12 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/cy.lproj/SUAutomaticUpdateAlert.nib/info.nib            |   12 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/cy.lproj/SUAutomaticUpdateAlert.nib/keyedobjects.nib    |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/cy.lproj/SUUpdateAlert.nib/classes.nib                  |   21 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/cy.lproj/SUUpdateAlert.nib/info.nib                     |   16 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/cy.lproj/SUUpdateAlert.nib/keyedobjects.nib             |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/cy.lproj/Sparkle.strings                                |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/da.lproj/SUAutomaticUpdateAlert.nib/classes.nib         |   12 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/da.lproj/SUAutomaticUpdateAlert.nib/info.nib            |   12 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/da.lproj/SUAutomaticUpdateAlert.nib/keyedobjects.nib    |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/da.lproj/SUUpdateAlert.nib/classes.nib                  |   21 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/da.lproj/SUUpdateAlert.nib/info.nib                     |   16 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/da.lproj/SUUpdateAlert.nib/keyedobjects.nib             |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/da.lproj/Sparkle.strings                                |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/de.lproj/SUAutomaticUpdateAlert.nib/classes.nib         |   12 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/de.lproj/SUAutomaticUpdateAlert.nib/info.nib            |   12 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/de.lproj/SUAutomaticUpdateAlert.nib/keyedobjects.nib    |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/de.lproj/SUUpdateAlert.nib/classes.nib                  |   21 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/de.lproj/SUUpdateAlert.nib/info.nib                     |   16 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/de.lproj/SUUpdateAlert.nib/keyedobjects.nib             |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/de.lproj/Sparkle.strings                                |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/en.lproj/SUAutomaticUpdateAlert.nib/classes.nib         |   12 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/en.lproj/SUAutomaticUpdateAlert.nib/info.nib            |   16 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/en.lproj/SUAutomaticUpdateAlert.nib/keyedobjects.nib    |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/en.lproj/SUUpdateAlert.nib/classes.nib                  |   21 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/en.lproj/SUUpdateAlert.nib/info.nib                     |   16 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/en.lproj/SUUpdateAlert.nib/keyedobjects.nib             |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/en.lproj/Sparkle.strings                                |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/es.lproj/SUAutomaticUpdateAlert.nib/classes.nib         |   12 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/es.lproj/SUAutomaticUpdateAlert.nib/info.nib            |   12 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/es.lproj/SUAutomaticUpdateAlert.nib/keyedobjects.nib    |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/es.lproj/SUUpdateAlert.nib/classes.nib                  |   21 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/es.lproj/SUUpdateAlert.nib/info.nib                     |   16 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/es.lproj/SUUpdateAlert.nib/keyedobjects.nib             |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/es.lproj/Sparkle.strings                                |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/fi.lproj/SUAutomaticUpdateAlert.nib/classes.nib         |   12 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/fi.lproj/SUAutomaticUpdateAlert.nib/info.nib            |   12 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/fi.lproj/SUAutomaticUpdateAlert.nib/keyedobjects.nib    |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/fi.lproj/SUUpdateAlert.nib/classes.nib                  |   21 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/fi.lproj/SUUpdateAlert.nib/info.nib                     |   16 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/fi.lproj/SUUpdateAlert.nib/keyedobjects.nib             |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/fi.lproj/Sparkle.strings                                |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/fr.lproj/SUAutomaticUpdateAlert.nib/classes.nib         |   12 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/fr.lproj/SUAutomaticUpdateAlert.nib/info.nib            |   12 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/fr.lproj/SUAutomaticUpdateAlert.nib/keyedobjects.nib    |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/fr.lproj/SUUpdateAlert.nib/classes.nib                  |   21 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/fr.lproj/SUUpdateAlert.nib/info.nib                     |   16 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/fr.lproj/SUUpdateAlert.nib/keyedobjects.nib             |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/fr.lproj/Sparkle.strings                                |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/he.lproj/SUAutomaticUpdateAlert.nib/classes.nib         |   12 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/he.lproj/SUAutomaticUpdateAlert.nib/info.nib            |   12 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/he.lproj/SUAutomaticUpdateAlert.nib/keyedobjects.nib    |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/he.lproj/SUUpdateAlert.nib/classes.nib                  |   21 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/he.lproj/SUUpdateAlert.nib/info.nib                     |   16 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/he.lproj/SUUpdateAlert.nib/keyedobjects.nib             |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/he.lproj/Sparkle.strings                                |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/hu.lproj/SUAutomaticUpdateAlert.nib/classes.nib         |   12 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/hu.lproj/SUAutomaticUpdateAlert.nib/info.nib            |   12 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/hu.lproj/SUAutomaticUpdateAlert.nib/keyedobjects.nib    |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/hu.lproj/SUUpdateAlert.nib/classes.nib                  |   21 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/hu.lproj/SUUpdateAlert.nib/info.nib                     |   16 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/hu.lproj/SUUpdateAlert.nib/keyedobjects.nib             |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/hu.lproj/Sparkle.strings                                |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/id.lproj/SUAutomaticUpdateAlert.nib/classes.nib         |   12 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/id.lproj/SUAutomaticUpdateAlert.nib/info.nib            |   12 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/id.lproj/SUAutomaticUpdateAlert.nib/keyedobjects.nib    |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/id.lproj/SUUpdateAlert.nib/classes.nib                  |   21 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/id.lproj/SUUpdateAlert.nib/info.nib                     |   16 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/id.lproj/SUUpdateAlert.nib/keyedobjects.nib             |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/id.lproj/Sparkle.strings                                |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/is.lproj/SUAutomaticUpdateAlert.nib/classes.nib         |   12 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/is.lproj/SUAutomaticUpdateAlert.nib/info.nib            |   12 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/is.lproj/SUAutomaticUpdateAlert.nib/keyedobjects.nib    |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/is.lproj/SUUpdateAlert.nib/classes.nib                  |   21 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/is.lproj/SUUpdateAlert.nib/info.nib                     |   16 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/is.lproj/SUUpdateAlert.nib/keyedobjects.nib             |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/is.lproj/Sparkle.strings                                |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/it.lproj/SUAutomaticUpdateAlert.nib/classes.nib         |   12 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/it.lproj/SUAutomaticUpdateAlert.nib/info.nib            |   12 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/it.lproj/SUAutomaticUpdateAlert.nib/keyedobjects.nib    |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/it.lproj/SUUpdateAlert.nib/classes.nib                  |   21 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/it.lproj/SUUpdateAlert.nib/info.nib                     |   16 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/it.lproj/SUUpdateAlert.nib/keyedobjects.nib             |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/it.lproj/Sparkle.strings                                |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/ja.lproj/SUAutomaticUpdateAlert.nib/classes.nib         |   12 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/ja.lproj/SUAutomaticUpdateAlert.nib/info.nib            |   12 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/ja.lproj/SUAutomaticUpdateAlert.nib/keyedobjects.nib    |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/ja.lproj/SUUpdateAlert.nib/classes.nib                  |   21 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/ja.lproj/SUUpdateAlert.nib/info.nib                     |   16 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/ja.lproj/SUUpdateAlert.nib/keyedobjects.nib             |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/ja.lproj/Sparkle.strings                                |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/ko.lproj/SUAutomaticUpdateAlert.nib/classes.nib         |   12 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/ko.lproj/SUAutomaticUpdateAlert.nib/info.nib            |   12 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/ko.lproj/SUAutomaticUpdateAlert.nib/keyedobjects.nib    |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/ko.lproj/SUUpdateAlert.nib/classes.nib                  |   21 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/ko.lproj/SUUpdateAlert.nib/info.nib                     |   16 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/ko.lproj/SUUpdateAlert.nib/keyedobjects.nib             |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/ko.lproj/Sparkle.strings                                |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/nl.lproj/SUAutomaticUpdateAlert.nib/classes.nib         |   12 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/nl.lproj/SUAutomaticUpdateAlert.nib/info.nib            |   12 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/nl.lproj/SUAutomaticUpdateAlert.nib/keyedobjects.nib    |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/nl.lproj/SUUpdateAlert.nib/classes.nib                  |   21 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/nl.lproj/SUUpdateAlert.nib/info.nib                     |   16 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/nl.lproj/SUUpdateAlert.nib/keyedobjects.nib             |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/nl.lproj/Sparkle.strings                                |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/no.lproj/SUAutomaticUpdateAlert.nib/classes.nib         |   12 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/no.lproj/SUAutomaticUpdateAlert.nib/info.nib            |   12 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/no.lproj/SUAutomaticUpdateAlert.nib/keyedobjects.nib    |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/no.lproj/SUUpdateAlert.nib/classes.nib                  |   21 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/no.lproj/SUUpdateAlert.nib/info.nib                     |   16 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/no.lproj/SUUpdateAlert.nib/keyedobjects.nib             |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/no.lproj/Sparkle.strings                                |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/pl.lproj/SUAutomaticUpdateAlert.nib/classes.nib         |   12 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/pl.lproj/SUAutomaticUpdateAlert.nib/info.nib            |   12 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/pl.lproj/SUAutomaticUpdateAlert.nib/keyedobjects.nib    |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/pl.lproj/SUUpdateAlert.nib/classes.nib                  |   21 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/pl.lproj/SUUpdateAlert.nib/info.nib                     |   16 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/pl.lproj/SUUpdateAlert.nib/keyedobjects.nib             |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/pl.lproj/Sparkle.strings                                |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/ru.lproj/SUAutomaticUpdateAlert.nib/classes.nib         |   12 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/ru.lproj/SUAutomaticUpdateAlert.nib/info.nib            |   12 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/ru.lproj/SUAutomaticUpdateAlert.nib/keyedobjects.nib    |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/ru.lproj/SUUpdateAlert.nib/classes.nib                  |   21 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/ru.lproj/SUUpdateAlert.nib/info.nib                     |   16 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/ru.lproj/SUUpdateAlert.nib/keyedobjects.nib             |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/ru.lproj/Sparkle.strings                                |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/sk.lproj/SUAutomaticUpdateAlert.nib/classes.nib         |   12 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/sk.lproj/SUAutomaticUpdateAlert.nib/info.nib            |   12 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/sk.lproj/SUAutomaticUpdateAlert.nib/keyedobjects.nib    |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/sk.lproj/SUUpdateAlert.nib/classes.nib                  |   21 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/sk.lproj/SUUpdateAlert.nib/info.nib                     |   16 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/sk.lproj/SUUpdateAlert.nib/keyedobjects.nib             |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/sk.lproj/Sparkle.strings                                |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/sv.lproj/SUAutomaticUpdateAlert.nib/classes.nib         |   12 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/sv.lproj/SUAutomaticUpdateAlert.nib/info.nib            |   12 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/sv.lproj/SUAutomaticUpdateAlert.nib/keyedobjects.nib    |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/sv.lproj/SUUpdateAlert.nib/classes.nib                  |   21 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/sv.lproj/SUUpdateAlert.nib/info.nib                     |   16 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/sv.lproj/SUUpdateAlert.nib/keyedobjects.nib             |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/sv.lproj/Sparkle.strings                                |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/th.lproj/SUAutomaticUpdateAlert.nib/classes.nib         |   12 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/th.lproj/SUAutomaticUpdateAlert.nib/info.nib            |   12 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/th.lproj/SUAutomaticUpdateAlert.nib/keyedobjects.nib    |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/th.lproj/SUUpdateAlert.nib/classes.nib                  |   21 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/th.lproj/SUUpdateAlert.nib/info.nib                     |   16 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/th.lproj/SUUpdateAlert.nib/keyedobjects.nib             |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/th.lproj/Sparkle.strings                                |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/tr.lproj/SUAutomaticUpdateAlert.nib/classes.nib         |   12 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/tr.lproj/SUAutomaticUpdateAlert.nib/info.nib            |   12 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/tr.lproj/SUAutomaticUpdateAlert.nib/keyedobjects.nib    |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/tr.lproj/SUUpdateAlert.nib/classes.nib                  |   21 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/tr.lproj/SUUpdateAlert.nib/info.nib                     |   16 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/tr.lproj/SUUpdateAlert.nib/keyedobjects.nib             |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/tr.lproj/Sparkle.strings                                |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/zh_CN.lproj/SUAutomaticUpdateAlert.nib/classes.nib      |   12 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/zh_CN.lproj/SUAutomaticUpdateAlert.nib/info.nib         |   12 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/zh_CN.lproj/SUAutomaticUpdateAlert.nib/keyedobjects.nib |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/zh_CN.lproj/SUUpdateAlert.nib/classes.nib               |   21 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/zh_CN.lproj/SUUpdateAlert.nib/info.nib                  |   16 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/zh_CN.lproj/SUUpdateAlert.nib/keyedobjects.nib          |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/zh_CN.lproj/Sparkle.strings                             |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/zh_TW.lproj/SUAutomaticUpdateAlert.nib/classes.nib      |   12 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/zh_TW.lproj/SUAutomaticUpdateAlert.nib/info.nib         |   12 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/zh_TW.lproj/SUAutomaticUpdateAlert.nib/keyedobjects.nib |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/zh_TW.lproj/SUUpdateAlert.nib/classes.nib               |   21 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/zh_TW.lproj/SUUpdateAlert.nib/info.nib                  |   16 
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/zh_TW.lproj/SUUpdateAlert.nib/keyedobjects.nib          |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Resources/zh_TW.lproj/Sparkle.strings                             |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/A/Sparkle                                                           |binary
 hw/xquartz/bundle/Sparkle.framework/Versions/Current                                                             |    1 
 hw/xquartz/bundle/X11.xcodeproj/project.pbxproj                                                                  |  458 -
 hw/xquartz/bundle/bundle-main.c                                                                                  |  136 
 hw/xquartz/bundle/mk_bundke.sh                                                                                   |   25 
 hw/xquartz/darwin.c                                                                                              |    1 
 hw/xquartz/darwinEvents.c                                                                                        |  144 
 hw/xquartz/darwinEvents.h                                                                                        |    2 
 hw/xquartz/doc/Makefile.am                                                                                       |   14 
 hw/xquartz/doc/Xquartz.man.pre                                                                                   |  156 
 hw/xquartz/mach-startup/Makefile.am                                                                              |   62 
 hw/xquartz/mach-startup/bundle-main.c                                                                            |  490 +
 hw/xquartz/mach-startup/launchd_fd.c                                                                             |   82 
 hw/xquartz/mach-startup/launchd_fd.h                                                                             |   36 
 hw/xquartz/mach-startup/mach_startup.defs                                                                        |   46 
 hw/xquartz/mach-startup/mach_startup_types.h                                                                     |   10 
 hw/xquartz/mach-startup/stub.c                                                                                   |  286 
 hw/xquartz/quartzKeyboard.c                                                                                      |   34 
 hw/xquartz/quartzStartup.c                                                                                       |    2 
 hw/xquartz/xpr/Makefile.am                                                                                       |   33 
 hw/xquartz/xpr/Xquartz.man.pre                                                                                   |  156 
 hw/xquartz/xpr/xprScreen.c                                                                                       |    1 
 include/dix-config.h.in                                                                                          |    6 
 include/dix.h                                                                                                    |    3 
 include/globals.h                                                                                                |    1 
 include/opaque.h                                                                                                 |    2 
 include/os.h                                                                                                     |    4 
 mi/miinitext.c                                                                                                   |   48 
 mi/mivaltree.c                                                                                                   |    4 
 miext/rootless/rootlessWindow.c                                                                                  |   71 
 os/connection.c                                                                                                  |   39 
 os/log.c                                                                                                         |   22 
 os/utils.c                                                                                                       |   13 
 os/xdmcp.c                                                                                                       |    3 
 render/glyph.c                                                                                                   |   17 
 xkb/ddxLoad.c                                                                                                    |   56 
 643 files changed, 8354 insertions(+), 108110 deletions(-)

New commits:
commit 99d28c3ef37aeffe7d8ec41e45a650ba248c6958
Merge: fc7e256... 0178b6a...
Author: Peter Hutterer <peter at cs.unisa.edu.au>
Date:   Tue May 20 10:20:14 2008 +0930

    Merge branch 'master' into mpx
    
    Conflicts:
    
    	Xext/xprint.c (removed in master)
    	config/hal.c
    	dix/main.c
    	hw/kdrive/ati/ati_cursor.c (removed in master)
    	hw/kdrive/i810/i810_cursor.c (removed in master)
    	hw/xprint/ddxInit.c (removed in master)
    	xkb/ddxLoad.c

diff --cc dix/main.c
index 42d3309,2e12b70..11ea29b
--- a/dix/main.c
+++ b/dix/main.c
@@@ -372,15 -358,14 +358,10 @@@ int main(int argc, char *argv[], char *
  	    if (!CreateRootWindow(pScreen))
  		FatalError("failed to create root window");
  	}
 -        InitCoreDevices();
 -	InitInput(argc, argv);
 -	if (InitAndStartDevices() != Success)
 -	    FatalError("failed to initialize core devices");
  
  	InitFonts();
- 	if (loadableFonts)
- 	    SetFontPath(serverClient, 0, (unsigned char *)defaultFontPath,
- 			&error);
-         else {
- 	    if (SetDefaultFontPath(defaultFontPath) != Success)
- 		ErrorF("[dix] failed to set default font path '%s'",
- 			defaultFontPath);
+ 	if (SetDefaultFontPath(defaultFontPath) != Success) {
 -	    ErrorF("failed to set default font path '%s'", defaultFontPath);
++	    ErrorF("[dix] failed to set default font path '%s'", defaultFontPath);
  	}
  	if (!SetDefaultFont(defaultTextFont)) {
  	    FatalError("could not open default font '%s'", defaultTextFont);
diff --cc mi/miinitext.c
index 00f0d27,9a87360..a4374d5
--- a/mi/miinitext.c
+++ b/mi/miinitext.c
@@@ -491,10 -460,8 +457,10 @@@ InitExtensions(argc, argv
      int		argc;
      char	*argv[];
  {
 +    if (!noGEExtension) GEExtensionInit();
 +
  #ifdef PANORAMIX
- # if !defined(PRINT_ONLY_SERVER) && !defined(NO_PANORAMIX)
+ # if !defined(NO_PANORAMIX)
    if (!noPanoramiXExtension) PanoramiXExtensionInit();
  # endif
  #endif
commit 0178b6a4abed0df3e90ba393709ed566105e7c2c
Author: Adam Jackson <ajax at redhat.com>
Date:   Mon May 19 11:22:19 2008 -0400

    Fix reduced-blanking mode filtering in RANDR 1.2.
    
    If the monitor isn't reduced-blanking (either through EDID logic, or
    config file setting), then remove RB modes from the default pool.  Any
    RB modes from the driver and config file pools will stick around though;
    you asked for them, you got them.

diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
index 9512805..41ac2f6 100644
--- a/hw/xfree86/modes/xf86Crtc.c
+++ b/hw/xfree86/modes/xf86Crtc.c
@@ -1484,7 +1484,14 @@ xf86ProbeOutputModes (ScrnInfoPtr scrn, int maxX, int maxY)
 	}
 	default_modes = xf86GetDefaultModes (output->interlaceAllowed,
 					     output->doubleScanAllowed);
-	
+
+	/*
+	 * If this is not an RB monitor, remove RB modes from the default
+	 * pool.  RB modes from the config or the monitor itself are fine.
+	 */
+	if (!mon_rec.reducedblanking)
+	    xf86ValidateModesReducedBlanking (scrn, default_modes);
+
 	if (sync_source == sync_config)
 	{
 	    /* 
diff --git a/hw/xfree86/modes/xf86Modes.c b/hw/xfree86/modes/xf86Modes.c
index 2dff31b..3a9f3ff 100644
--- a/hw/xfree86/modes/xf86Modes.c
+++ b/hw/xfree86/modes/xf86Modes.c
@@ -519,6 +519,28 @@ xf86ValidateModesBandwidth(ScrnInfoPtr pScrn, DisplayModePtr modeList,
 }
 
 /**
+ * Marks as bad any reduced-blanking modes.
+ *
+ * \param modeList doubly-linked list of modes.
+ */
+_X_EXPORT void
+xf86ValidateModesReducedBlanking(ScrnInfoPtr pScrn, DisplayModePtr modeList)
+{
+    Bool mode_is_reduced = FALSE;
+    DisplayModePtr mode;
+
+    for (mode = modeList; mode != NULL; mode = mode->next) {
+	/* gratuitous duplication from pre-randr validation code */
+	if ((((mode->HDisplay * 5 / 4) & ~0x07) > mode->HTotal) &&
+	    ((mode->HTotal - mode->HDisplay) == 160) &&
+	    ((mode->HSyncEnd - mode->HDisplay) == 80) &&
+	    ((mode->HSyncEnd - mode->HSyncStart) == 32) &&
+	    ((mode->VSyncStart - mode->VDisplay) == 3))
+	    mode->status = MODE_NO_REDUCED;
+    }
+}
+
+/**
  * Frees any modes from the list with a status other than MODE_OK.
  *
  * \param modeList pointer to a doubly-linked or circular list of modes.
diff --git a/hw/xfree86/modes/xf86Modes.h b/hw/xfree86/modes/xf86Modes.h
index 5d49c93..acdea65 100644
--- a/hw/xfree86/modes/xf86Modes.h
+++ b/hw/xfree86/modes/xf86Modes.h
@@ -85,6 +85,9 @@ xf86ValidateModesBandwidth(ScrnInfoPtr pScrn, DisplayModePtr modeList,
 			   unsigned int bandwidth, int depth);
 
 void
+xf86ValidateModesReducedBlanking(ScrnInfoPtr pScrn, DisplayModePtr modeList);
+
+void
 xf86PruneInvalidModes(ScrnInfoPtr pScrn, DisplayModePtr *modeList,
 		      Bool verbose);
 
commit bb687465d0c5aef3cc1c865e6ea67c01a8b417fb
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Mon May 19 02:45:47 2008 -0700

    XQuartz: First stab at SCM_RIGHTS passing the $DISPLAY launchd fd from the stub to server
    (cherry picked from commit cccee9cfc29f85cca635df3b8dd54199b45c4df8)

diff --git a/hw/xquartz/mach-startup/bundle-main.c b/hw/xquartz/mach-startup/bundle-main.c
index 4ddd82f..c975123 100644
--- a/hw/xquartz/mach-startup/bundle-main.c
+++ b/hw/xquartz/mach-startup/bundle-main.c
@@ -37,6 +37,7 @@
 #include <stdlib.h>
 #include <pthread.h>
 #include <stdbool.h>
+
 #include <sys/socket.h>
 #include <sys/un.h>
 
@@ -120,68 +121,140 @@ static pthread_t create_thread(void *func, void *arg) {
 }
 
 /*** $DISPLAY handoff ***/
-static char display_handoff_socket[PATH_MAX + 1];
-
-kern_return_t do_get_display_handoff_socket(mach_port_t port, string_t filename) {
-    strlcpy(filename, display_handoff_socket, STRING_T_SIZE);
-    fprintf(stderr, "Telling him the filename is %s = %s\n", filename, display_handoff_socket);
-    return KERN_SUCCESS;
-}
-
 /* From darwinEvents.c ... but don't want to pull in all the server cruft */
 void DarwinListenOnOpenFD(int fd);
 
-static void accept_fd_handoff(int connectedSocket) {
-    int fd;
-    return;
-    DarwinListenOnOpenFD(fd);
+static void accept_fd_handoff(int connected_fd) {
+    int launchd_fd;
+    
+    char databuf[] = "display";
+    struct iovec iov[1];
+    
+    iov[0].iov_base = databuf;
+    iov[0].iov_len  = sizeof(databuf);
+    
+    union {
+        struct cmsghdr hdr;
+        char bytes[CMSG_SPACE(sizeof(int))];
+    } buf;
+    
+    struct msghdr msg;
+    msg.msg_iov = iov;
+    msg.msg_iovlen = 1;
+    msg.msg_control = buf.bytes;
+    msg.msg_controllen = sizeof(buf);
+    msg.msg_name = 0;
+    msg.msg_namelen = 0;
+    msg.msg_flags = 0;
+    
+    struct cmsghdr *cmsg = CMSG_FIRSTHDR (&msg);
+    cmsg->cmsg_level = SOL_SOCKET;
+    cmsg->cmsg_type = SCM_RIGHTS;
+    cmsg->cmsg_len = CMSG_LEN(sizeof(int));
+    
+    msg.msg_controllen = cmsg->cmsg_len;
+    
+    *((int*)CMSG_DATA(cmsg)) = -1;
+    
+    if(recvmsg(connected_fd, &msg, 0) < 0) {
+        fprintf(stderr, "Error receiving $DISPLAY file descriptor: %s\n", strerror(errno));
+        return;
+    }
+    
+    launchd_fd = *((int*)CMSG_DATA(cmsg));
+    
+    if(launchd_fd > 0)
+        DarwinListenOnOpenFD(launchd_fd);
+    else
+        fprintf(stderr, "Error receiving $DISPLAY file descriptor, no descriptor received? %d\n", launchd_fd);
 }
 
+typedef struct {
+    string_t socket_filename;
+    pthread_mutex_t lock;
+    pthread_cond_t cond;
+    kern_return_t retval;
+} handoff_data_t;
+
 /* This thread loops accepting incoming connections and handing off the file
  * descriptor for the new connection to accept_fd_handoff()
  */
 static void socket_handoff_thread(void *arg) {
+    handoff_data_t *data = (handoff_data_t *)arg;
+    string_t filename;
     struct sockaddr_un servaddr_un;
     struct sockaddr *servaddr;
-    int handoff_fd;
-    int servaddr_len;
+    socklen_t servaddr_len;
+    int handoff_fd, connected_fd;
+
+    /* We need to save it since data dies after we pthread_cond_broadcast */
+    strlcpy(filename, data->socket_filename, STRING_T_SIZE); 
     
-    /* Wipe ourselves clean */
-    memset (&servaddr_un, 0, sizeof (struct sockaddr_un));
+    /* Make sure we only run once the dispatch thread is waiting for us */
+    pthread_mutex_lock(&data->lock);
     
+    /* Setup servaddr_un */
+    memset (&servaddr_un, 0, sizeof (struct sockaddr_un));
     servaddr_un.sun_family  = AF_UNIX;
-    strcpy(servaddr_un.sun_path, display_handoff_socket);
+    strlcpy(servaddr_un.sun_path, filename, sizeof(servaddr_un.sun_path));
+
     servaddr = (struct sockaddr *) &servaddr_un;
-    servaddr_len = sizeof(struct sockaddr_un) - sizeof(servaddr_un.sun_path) + strlen(display_handoff_socket);
+    servaddr_len = sizeof(struct sockaddr_un) - sizeof(servaddr_un.sun_path) + strlen(filename);
     
     handoff_fd = socket(AF_UNIX, SOCK_STREAM, 0);
     if(handoff_fd == 0) {
-        fprintf(stderr, "Failed to create socket: %s - %s\n", display_handoff_socket, strerror(errno));
+        fprintf(stderr, "Failed to create socket: %s - %s\n", filename, strerror(errno));
+        data->retval = EXIT_FAILURE;
         return;
-        exit(EXIT_FAILURE);
     }
     
     if(bind(handoff_fd, servaddr, servaddr_len) != 0) {
-        fprintf(stderr, "Failed to bind socket: %s - %s\n", display_handoff_socket, strerror(errno));
+        fprintf(stderr, "Failed to bind socket: %s - %s\n", filename, strerror(errno));
+        data->retval = EXIT_FAILURE;
         return;
-        exit(EXIT_FAILURE);
     }
     
     if(listen(handoff_fd, 10) != 0) {
-        fprintf(stderr, "Failed to listen to socket: %s - %s\n", display_handoff_socket, strerror(errno));
+        fprintf(stderr, "Failed to listen to socket: %s - %s\n", filename, strerror(errno));
+        data->retval = EXIT_FAILURE;
         return;
-        exit(EXIT_FAILURE);
     }
+
+    /* Let the dispatch thread now tell the caller that we're listening */
+    data->retval = EXIT_SUCCESS;
+    pthread_mutex_unlock(&data->lock);
+    pthread_cond_broadcast(&data->cond);
     
-    while(true) {
-        int connectedSocket = accept(handoff_fd, NULL, NULL);
-        
-        if(connectedSocket == -1) {
-            fprintf(stderr, "Failed to accept incoming connection on socket: %s - %s\n", display_handoff_socket, strerror(errno));
-            continue;
-        }
-        accept_fd_handoff(connectedSocket);    
+    connected_fd = accept(handoff_fd, NULL, NULL);
+    
+    /* We delete this temporary socket after we get the connection */
+    unlink(filename);
+
+    if(connected_fd == -1) {
+        fprintf(stderr, "Failed to accept incoming connection on socket: %s - %s\n", filename, strerror(errno));
+        return;
     }
+
+    /* Now actually get the passed file descriptor from this connection */
+    accept_fd_handoff(connected_fd);
+    
+    close(handoff_fd);
+}
+
+kern_return_t do_prep_fd_handoff(mach_port_t port, string_t socket_filename) {
+    handoff_data_t handoff_data;
+
+    pthread_mutex_init(&handoff_data.lock, NULL);
+    pthread_cond_init(&handoff_data.cond, NULL);
+    strlcpy(handoff_data.socket_filename, socket_filename, STRING_T_SIZE); 
+
+    pthread_mutex_lock(&handoff_data.lock);
+    
+    create_thread(socket_handoff_thread, &handoff_data);
+    
+    pthread_cond_wait(&handoff_data.cond, &handoff_data.lock);
+
+    return handoff_data.retval;
 }
 
 /*** Server Startup ***/
@@ -334,14 +407,6 @@ int main(int argc, char **argv, char **envp) {
         return EXIT_FAILURE;
     }
     
-    /* Figure out what our handoff socket will be
-     * TODO: cleanup on exit.
-     */
-    tmpnam(display_handoff_socket);
-    create_thread(socket_handoff_thread, NULL);
-    
-    fprintf(stderr, "Hi\n");
-    
     /* Check if we need to do something other than listen, and make another
      * thread handle it.
      */
diff --git a/hw/xquartz/mach-startup/mach_startup.defs b/hw/xquartz/mach-startup/mach_startup.defs
index 05bdf56..19c105c 100644
--- a/hw/xquartz/mach-startup/mach_startup.defs
+++ b/hw/xquartz/mach-startup/mach_startup.defs
@@ -41,6 +41,6 @@ routine start_x11_server(
     argv  : string_array_t;
     envp  : string_array_t);
 
-routine get_display_handoff_socket(
+routine prep_fd_handoff(
 	port  : mach_port_t;
-    filename  : string_t);
+    socket_filename  : string_t);
diff --git a/hw/xquartz/mach-startup/stub.c b/hw/xquartz/mach-startup/stub.c
index 5fdbad8..0a9ab66 100644
--- a/hw/xquartz/mach-startup/stub.c
+++ b/hw/xquartz/mach-startup/stub.c
@@ -37,6 +37,9 @@
 #include <unistd.h>
 #include <errno.h>
 
+#include <sys/socket.h>
+#include <sys/un.h>
+
 #define kX11AppBundleId "org.x.X11"
 #define kX11AppBundlePath "/Contents/MacOS/X11"
 
@@ -47,6 +50,13 @@
 
 #include "launchd_fd.h"
 
+#ifndef BUILD_DATE
+#define BUILD_DATE "?"
+#endif
+#ifndef XSERVER_VERSION
+#define XSERVER_VERSION "?"
+#endif
+
 static char x11_path[PATH_MAX + 1];
 
 static void set_x11_path() {
@@ -103,12 +113,75 @@ static void set_x11_path() {
     }
 }
 
-#ifndef BUILD_DATE
-#define BUILD_DATE "?"
-#endif
-#ifndef XSERVER_VERSION
-#define XSERVER_VERSION "?"
-#endif
+static void send_fd_handoff(int connected_fd, int launchd_fd) {
+    char databuf[] = "display";
+    struct iovec iov[1];
+    
+    iov[0].iov_base = databuf;
+    iov[0].iov_len  = sizeof(databuf);
+
+    union {
+        struct cmsghdr hdr;
+        char bytes[CMSG_SPACE(sizeof(int))];
+    } buf;
+    
+    struct msghdr msg;
+    msg.msg_iov = iov;
+    msg.msg_iovlen = 1;
+    msg.msg_control = buf.bytes;
+    msg.msg_controllen = sizeof(buf);
+    msg.msg_name = 0;
+    msg.msg_namelen = 0;
+    msg.msg_flags = 0;
+
+    struct cmsghdr *cmsg = CMSG_FIRSTHDR (&msg);
+    cmsg->cmsg_level = SOL_SOCKET;
+    cmsg->cmsg_type = SCM_RIGHTS;
+    cmsg->cmsg_len = CMSG_LEN(sizeof(int));
+
+    msg.msg_controllen = cmsg->cmsg_len;
+    
+    *((int*)CMSG_DATA(cmsg)) = launchd_fd;
+    
+    if (sendmsg(connected_fd, &msg, 0) < 0) {
+        fprintf(stderr, "Error sending $DISPLAY file descriptor: %s\n", strerror(errno));
+        return;
+    }
+
+    fprintf(stderr, "send %d %d %d %s\n", connected_fd, launchd_fd, errno, strerror(errno));
+}
+
+static void handoff_fd(const char *filename, int launchd_fd) {
+    struct sockaddr_un servaddr_un;
+    struct sockaddr *servaddr;
+    socklen_t servaddr_len;
+    int handoff_fd, connected_fd;
+
+    /* Setup servaddr_un */
+    memset (&servaddr_un, 0, sizeof (struct sockaddr_un));
+    servaddr_un.sun_family = AF_UNIX;
+    strlcpy(servaddr_un.sun_path, filename, sizeof(servaddr_un.sun_path));
+
+    servaddr = (struct sockaddr *) &servaddr_un;
+    servaddr_len = sizeof(struct sockaddr_un) - sizeof(servaddr_un.sun_path) + strlen(filename);
+
+    handoff_fd = socket(PF_UNIX, SOCK_STREAM, 0);
+    if(handoff_fd == 0) {
+        fprintf(stderr, "Failed to create socket: %s - %s\n", filename, strerror(errno));
+        return;
+    }
+
+    connected_fd = connect(handoff_fd, servaddr, servaddr_len);
+
+    if(connected_fd == -1) {
+        fprintf(stderr, "Failed to establish connection on socket: %s - %s\n", filename, strerror(errno));
+        return;
+    }
+
+    send_fd_handoff(connected_fd, launchd_fd);
+
+    close(handoff_fd);
+}
 
 int main(int argc, char **argv, char **envp) {
 #ifdef NEW_LAUNCH_METHOD
@@ -169,8 +242,12 @@ int main(int argc, char **argv, char **envp) {
     
     /* Handoff the $DISPLAY FD */
     if(launchd_fd != -1) {
-        get_display_handoff_socket(mp, handoff_socket);
-        fprintf(stderr, "Handoff socket: %s %d\n", handoff_socket, launchd_fd);
+        tmpnam(handoff_socket);
+        if(prep_fd_handoff(mp, handoff_socket) == KERN_SUCCESS) {
+            handoff_fd(handoff_socket, launchd_fd);
+        } else {
+            fprintf(stderr, "Unable to hand of $DISPLAY file descriptor\n");
+        }
     }
 
     /* Count envp */
commit 4b69d22bcb79210225379da2cefb0cd8d5ffa10e
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Sun May 18 23:51:06 2008 -0700

    XQuartz: Fixed dropped code in the !XKB blocks, disable XKB support until we figure out a solution for xkeyboard-config
    (cherry picked from commit 2a72309c061f7060480d150791019ce232481462)

diff --git a/hw/xquartz/quartzKeyboard.c b/hw/xquartz/quartzKeyboard.c
index c75cd1d..5b8d32d 100644
--- a/hw/xquartz/quartzKeyboard.c
+++ b/hw/xquartz/quartzKeyboard.c
@@ -43,7 +43,7 @@
 // Define this to get a diagnostic output to stderr which is helpful
 // in determining how the X server is interpreting the Darwin keymap.
 #define DUMP_DARWIN_KEYMAP
-#define XQUARTZ_USE_XKB 
+//#define XQUARTZ_USE_XKB 
 #define HACK_MISSING 1
 #define HACK_KEYPAD 1
 
@@ -910,24 +910,26 @@ void DarwinKeyboardInit(DeviceIntPtr pDev) {
 
 
 void DarwinKeyboardReloadHandler(int screenNum, xEventPtr xe, DeviceIntPtr pDev, int nevents) {
-	if (pDev == NULL) pDev = darwinKeyboard;
-	
-	DEBUG_LOG("DarwinKeyboardReloadHandler(%p)\n", pDev);
+    if (pDev == NULL) pDev = darwinKeyboard;
+    
+    DEBUG_LOG("DarwinKeyboardReloadHandler(%p)\n", pDev);
 
 #ifdef XQUARTZ_USE_XKB
-	QuartzXkbUpdate(pDev);
+    QuartzXkbUpdate(pDev);
 #else
-	if (pDev->key) {
-		if (pDev->key->curKeySyms.map) xfree(pDev->key->curKeySyms.map);
-		if (pDev->key->modifierKeyMap) xfree(pDev->key->modifierKeyMap);
-		xfree(pDev->key);
-	}
-	
     KeySymsRec keySyms;
-	if (!InitKeyClassDeviceStruct(pDev, &keySyms, keyInfo.modMap)) {
-		DEBUG_LOG("InitKeyClassDeviceStruct failed\n");
-		return;
-	}
+    DarwinLoadKeyboardMapping(&keySyms);
+
+    if (pDev->key) {
+        if (pDev->key->curKeySyms.map) xfree(pDev->key->curKeySyms.map);
+        if (pDev->key->modifierKeyMap) xfree(pDev->key->modifierKeyMap);
+        xfree(pDev->key);
+    }
+    
+    if (!InitKeyClassDeviceStruct(pDev, &keySyms, keyInfo.modMap)) {
+        DEBUG_LOG("InitKeyClassDeviceStruct failed\n");
+        return;
+    }
 
     SendMappingNotify(MappingKeyboard, MIN_KEYCODE, NUM_KEYCODES, 0);
     SendMappingNotify(MappingModifier, 0, 0, 0);
commit e997df8cd3c4222ea9fc3f0ebda728c4d1f15df5
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Sun May 18 23:31:41 2008 -0700

    XQuartz: Cleaned up ListenOnOpenFD...
    (cherry picked from commit 6fb587d3d5fbbaee9e46cdce24d03e5d1c66d58a)

diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c
index 9ecebe4..0ecb064 100644
--- a/hw/xquartz/darwinEvents.c
+++ b/hw/xquartz/darwinEvents.c
@@ -220,7 +220,6 @@ static void kXquartzListenOnOpenFDHandler(int screenNum, xEventPtr xe, DeviceInt
     TA_SERVER();
 
     for (i=0; i<nevents; i++) {
-        //sleep(20);
         ListenOnOpenFD(xe[i].u.clientMessage.u.l.longs0);
     }
 }
diff --git a/os/connection.c b/os/connection.c
index a877257..316e347 100644
--- a/os/connection.c
+++ b/os/connection.c
@@ -1301,8 +1301,7 @@ MakeClientGrabPervious(ClientPtr client)
 /* Add a fd (from launchd) to our listeners */
 _X_EXPORT void ListenOnOpenFD(int fd) {
     char port[20];
-    XtransConnInfo ciptr, *ciptr2, *ciptr3;
-    int *iptr, *iptr2;
+    XtransConnInfo ciptr;
     
     /* Sigh for inconsistencies. */  
     sprintf (port, ":%d", atoi(display));
@@ -1312,37 +1311,13 @@ _X_EXPORT void ListenOnOpenFD(int fd) {
      */
     ciptr = _XSERVTransReopenCOTSServer(5, fd, port);
     if(ciptr == NULL) {
-        fprintf(stderr, "Got NULL while trying to Reopen launchd port.\n");
+        ErrorF("Got NULL while trying to Reopen launchd port.\n");
         return;
     }
     
     /* Allocate space to store it */
-    iptr = (int *) realloc(ListenTransFds, (ListenTransCount + 1) * sizeof (int));
-    
-    if(!iptr) {
-        fprintf(stderr, "Memory allocation error");
-        return;
-    }
-    
-    ciptr2 = (XtransConnInfo *) realloc(ListenTransConns, (ListenTransCount + 1) * sizeof (XtransConnInfo));
-    if(!ciptr2) {
-        fprintf(stderr, "Memory allocation error");
-        if(iptr != ListenTransFds)
-            free(ListenTransFds);
-        return;
-    }
-
-    if(iptr != ListenTransFds) {
-        iptr2 = ListenTransFds;
-        ListenTransFds = iptr;
-        free(iptr2);
-    }
-    
-    if(ciptr2 != ListenTransConns) {
-        ciptr3 = ListenTransConns;
-        ListenTransConns = ciptr2;
-        free(ciptr3);
-    }
+    ListenTransFds = (int *) xrealloc(ListenTransFds, (ListenTransCount + 1) * sizeof (int));
+    ListenTransConns = (XtransConnInfo *) xrealloc(ListenTransConns, (ListenTransCount + 1) * sizeof (XtransConnInfo));
     
     /* Store it */
     ListenTransConns[ListenTransCount] = ciptr;
@@ -1355,7 +1330,7 @@ _X_EXPORT void ListenOnOpenFD(int fd) {
     //    DefineSelf (fd);
     }
     */
-    
+
     /* Increment the count */
     ListenTransCount++;
 }
commit 738672858d9399ecbc170500c15f90bf657502d2
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Sun May 18 23:02:12 2008 -0700

    New XQuartz icon thanks to Simone Karin Lehmann
    (cherry picked from commit c27e0c8f3c5108192362735db8a80bf3a9a1cc3a)

diff --git a/hw/xquartz/bundle/Resources/X11.icns b/hw/xquartz/bundle/Resources/X11.icns
index d770e61..d19cc63 100644
Binary files a/hw/xquartz/bundle/Resources/X11.icns and b/hw/xquartz/bundle/Resources/X11.icns differ
commit 4be2104c801340075e030d06d24ceb4d8a6d6549
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Thu May 15 12:26:32 2008 -0700

    XQuartz: More work towards Mach-IPC startup... started working on FD passing
    (cherry picked from commit 27fbfeacfa16d620801ac3492b25c1e50aec8588)

diff --git a/hw/xquartz/Makefile.am b/hw/xquartz/Makefile.am
index 77d662f..cc39c9d 100644
--- a/hw/xquartz/Makefile.am
+++ b/hw/xquartz/Makefile.am
@@ -8,6 +8,7 @@ AM_CPPFLAGS = \
 	-DUSE_NEW_CLUT \
 	-DXFree86Server \
 	-I$(top_srcdir)/miext/rootless
+#	-DNEW_LAUNCH_METHOD
 
 SUBDIRS = bundle . GL xpr mach-startup doc
 
diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index 1a7d55a..d687c1f 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -787,7 +787,6 @@ environment?", @"Startup xinitrc dialog");
 
 void X11ApplicationMain (int argc, char **argv, char **envp) {
     NSAutoreleasePool *pool;
-    int launchd_fd;
 
 #ifdef DEBUG
     while (access ("/tmp/x11-block", F_OK) == 0) sleep (1);
@@ -818,9 +817,9 @@ void X11ApplicationMain (int argc, char **argv, char **envp) {
     
 #ifndef NEW_LAUNCH_METHOD
     /* Start listening on the launchd fd */
-    launchd_fd = launchd_display_fd();
+    int launchd_fd = launchd_display_fd();
     if(launchd_fd != -1) {
-        DarwinSendDDXEvent(kXquartzListenOnOpenFD, 1, launchd_fd);
+        DarwinListenOnOpenFD(launchd_fd);
     }
 #endif
 
diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c
index 06c5df0..9ecebe4 100644
--- a/hw/xquartz/darwinEvents.c
+++ b/hw/xquartz/darwinEvents.c
@@ -551,6 +551,9 @@ void DarwinUpdateModKeys(int flags) {
 	old_flags = flags;
 }
 
+void DarwinListenOnOpenFD(int fd) {
+    DarwinSendDDXEvent(kXquartzListenOnOpenFD, 1, fd);
+}
 
 /*
  * DarwinSendDDXEvent
diff --git a/hw/xquartz/darwinEvents.h b/hw/xquartz/darwinEvents.h
index 58817fb..7a1e8ca 100644
--- a/hw/xquartz/darwinEvents.h
+++ b/hw/xquartz/darwinEvents.h
@@ -39,6 +39,7 @@ void DarwinSendKeyboardEvents(int ev_type, int keycode);
 void DarwinSendScrollEvents(float count_x, float count_y, int pointer_x, int pointer_y,
 			    float pressure, float tilt_x, float tilt_y);
 void DarwinUpdateModKeys(int flags);
+void DarwinListenOnOpenFD(int fd);
 
 /*
  * Special ddx events understood by the X server
diff --git a/hw/xquartz/mach-startup/Makefile.am b/hw/xquartz/mach-startup/Makefile.am
index 3ed1c1a..11f6ba6 100644
--- a/hw/xquartz/mach-startup/Makefile.am
+++ b/hw/xquartz/mach-startup/Makefile.am
@@ -10,9 +10,9 @@ dist_X11_SOURCES = \
 	bundle-main.c \
 	launchd_fd.c
 
-nodist_X11_SOURCES = \
-	mach_startupServer.c \
-	mach_startupUser.c
+#nodist_X11_SOURCES = \
+#	mach_startupServer.c \
+#	mach_startupUser.c
 
 X11_LDADD = \
 	$(top_builddir)/hw/xquartz/libXquartz.la \
@@ -34,11 +34,11 @@ X11_LDFLAGS =  \
 bin_PROGRAMS = Xquartz
 
 dist_Xquartz_SOURCES = \
-	stub.c \
-	launchd_fd.c
+	stub.c
+#	launchd_fd.c
 
-nodist_Xquartz_SOURCES = \
-	mach_startupUser.c
+#nodist_Xquartz_SOURCES = \
+#	mach_startupUser.c
 
 Xquartz_LDFLAGS =  \
 	-Wl,-framework,CoreServices
diff --git a/hw/xquartz/mach-startup/bundle-main.c b/hw/xquartz/mach-startup/bundle-main.c
index dd75f02..4ddd82f 100644
--- a/hw/xquartz/mach-startup/bundle-main.c
+++ b/hw/xquartz/mach-startup/bundle-main.c
@@ -28,6 +28,8 @@
  promote the sale, use or other dealings in this Software without
  prior written authorization. */
 
+#include <CoreFoundation/CoreFoundation.h>
+
 #include <X11/Xlib.h>
 #include <unistd.h>
 #include <stdio.h>
@@ -35,10 +37,8 @@
 #include <stdlib.h>
 #include <pthread.h>
 #include <stdbool.h>
-
-#include <CoreFoundation/CoreFoundation.h>
-
-#include <asl.h>
+#include <sys/socket.h>
+#include <sys/un.h>
 
 #include <mach/mach.h>
 #include <mach/mach_error.h>
@@ -56,6 +56,11 @@ static char *command_from_prefs(const char *key, const char *default_value);
 /* This is in quartzStartup.c */
 int server_main(int argc, char **argv, char **envp);
 
+static int execute(const char *command);
+static char *command_from_prefs(const char *key, const char *default_value);
+
+#ifdef NEW_LAUNCH_METHOD
+
 struct arg {
     int argc;
     char **argv;
@@ -69,39 +74,6 @@ union MaxMsgSize {
 	union __ReplyUnion__mach_startup_subsystem rep; 
 };
 
-kern_return_t do_start_x11_server(mach_port_t port, string_array_t argv,
-                                  mach_msg_type_number_t argvCnt,
-                                  string_array_t envp,
-                                  mach_msg_type_number_t envpCnt) {
-    /* And now back to char ** */
-    char **_argv = alloca((argvCnt + 1) * sizeof(char *));
-    char **_envp = alloca((envpCnt + 1) * sizeof(char *));
-    size_t i;
-
-    if(!_argv || !_envp) {
-        return KERN_FAILURE;
-    }
-
-    for(i=0; i < argvCnt; i++) {
-        _argv[i] = argv[i];
-    }
-    _argv[argvCnt] = NULL;
-
-    for(i=0; i < envpCnt; i++) {
-        _envp[i] = envp[i];
-    }
-    _envp[envpCnt] = NULL;
-    
-    if(server_main(argvCnt, _argv, _envp) == 0)
-        return KERN_SUCCESS;
-    else
-        return KERN_FAILURE;
-}
-
-kern_return_t do_exit(mach_port_t port, int value) {
-    exit(value);
-}
-
 static mach_port_t checkin_or_register(char *bname) {
     kern_return_t kr;
     mach_port_t mp;
@@ -147,71 +119,99 @@ static pthread_t create_thread(void *func, void *arg) {
     return tid;
 }
 
-/*** Main ***/
-static int execute(const char *command);
-static char *command_from_prefs(const char *key, const char *default_value);
+/*** $DISPLAY handoff ***/
+static char display_handoff_socket[PATH_MAX + 1];
 
-#ifdef NEW_LAUNCH_METHOD
-static void startup_trigger_thread(void *arg) {
-    struct arg args = *((struct arg *)arg);
-    free(arg);
-    startup_trigger(args.argc, args.argv, args.envp);
+kern_return_t do_get_display_handoff_socket(mach_port_t port, string_t filename) {
+    strlcpy(filename, display_handoff_socket, STRING_T_SIZE);
+    fprintf(stderr, "Telling him the filename is %s = %s\n", filename, display_handoff_socket);
+    return KERN_SUCCESS;
 }
 
-int main(int argc, char **argv, char **envp) {
-    Bool listen, listenOnly = FALSE;
-    int i;
-    mach_msg_size_t mxmsgsz = sizeof(union MaxMsgSize) + MAX_TRAILER_SIZE;
-    mach_port_t mp;
-    kern_return_t kr;
+/* From darwinEvents.c ... but don't want to pull in all the server cruft */
+void DarwinListenOnOpenFD(int fd);
 
-    fprintf(stderr, "X11.app: main(): argc=%d\n", argc);
-    for(i=1; i < argc; i++) {
-        fprintf(stderr, "\targv[%u] = %s\n", (unsigned)i, argv[i]);
-        if(!strcmp(argv[i], "--listenonly")) {
-            listenOnly = TRUE;
-        }
-    }
+static void accept_fd_handoff(int connectedSocket) {
+    int fd;
+    return;
+    DarwinListenOnOpenFD(fd);
+}
 
-    /* TODO: This should be unconditional once we figure out fd passing */
-    listen = (argc > 1 && argv[1][0] == ':') || listenOnly;
-    if(listen) {
-        mp = checkin_or_register(SERVER_BOOTSTRAP_NAME);
+/* This thread loops accepting incoming connections and handing off the file
+ * descriptor for the new connection to accept_fd_handoff()
+ */
+static void socket_handoff_thread(void *arg) {
+    struct sockaddr_un servaddr_un;
+    struct sockaddr *servaddr;
+    int handoff_fd;
+    int servaddr_len;
+    
+    /* Wipe ourselves clean */
+    memset (&servaddr_un, 0, sizeof (struct sockaddr_un));
+    
+    servaddr_un.sun_family  = AF_UNIX;
+    strcpy(servaddr_un.sun_path, display_handoff_socket);
+    servaddr = (struct sockaddr *) &servaddr_un;
+    servaddr_len = sizeof(struct sockaddr_un) - sizeof(servaddr_un.sun_path) + strlen(display_handoff_socket);
+    
+    handoff_fd = socket(AF_UNIX, SOCK_STREAM, 0);
+    if(handoff_fd == 0) {
+        fprintf(stderr, "Failed to create socket: %s - %s\n", display_handoff_socket, strerror(errno));
+        return;
+        exit(EXIT_FAILURE);
     }
-
-    /* Check if we need to do something other than listen, and make another
-     * thread handle it.
-     */
-    if(!listenOnly) {
-        struct arg *args = (struct arg*)malloc(sizeof(struct arg));
-        if(!args) {
-            fprintf(stderr, "Memory allocation error.\n");
-            return EXIT_FAILURE;
-        }
-
-        args->argc = argc;
-        args->argv = argv;
-        args->envp = envp;
-
-        create_thread(startup_trigger_thread, args);
+    
+    if(bind(handoff_fd, servaddr, servaddr_len) != 0) {
+        fprintf(stderr, "Failed to bind socket: %s - %s\n", display_handoff_socket, strerror(errno));
+        return;
+        exit(EXIT_FAILURE);
     }
-
-    /* TODO: This should actually fall through rather than be the else
-     *       case once we figure out how to get the stub to pass the
-     *       file descriptor.  For now, we only listen if we are explicitly
-     *       told to.
-     */
-    if(listen) {
-        /* Main event loop */
-        kr = mach_msg_server(mach_startup_server, mxmsgsz, mp, 0);
-        if (kr != KERN_SUCCESS) {
-            asl_log(NULL, NULL, ASL_LEVEL_ERR,
-                    "org.x.X11(mp): %s\n", mach_error_string(kr));
-            return EXIT_FAILURE;
+    
+    if(listen(handoff_fd, 10) != 0) {
+        fprintf(stderr, "Failed to listen to socket: %s - %s\n", display_handoff_socket, strerror(errno));
+        return;
+        exit(EXIT_FAILURE);
+    }
+    
+    while(true) {
+        int connectedSocket = accept(handoff_fd, NULL, NULL);
+        
+        if(connectedSocket == -1) {
+            fprintf(stderr, "Failed to accept incoming connection on socket: %s - %s\n", display_handoff_socket, strerror(errno));
+            continue;
         }
+        accept_fd_handoff(connectedSocket);    
     }
+}
 
-    return EXIT_SUCCESS;
+/*** Server Startup ***/
+kern_return_t do_start_x11_server(mach_port_t port, string_array_t argv,
+                                  mach_msg_type_number_t argvCnt,
+                                  string_array_t envp,
+                                  mach_msg_type_number_t envpCnt) {
+    /* And now back to char ** */
+    char **_argv = alloca((argvCnt + 1) * sizeof(char *));
+    char **_envp = alloca((envpCnt + 1) * sizeof(char *));
+    size_t i;
+    
+    if(!_argv || !_envp) {
+        return KERN_FAILURE;
+    }
+    
+    for(i=0; i < argvCnt; i++) {
+        _argv[i] = argv[i];
+    }
+    _argv[argvCnt] = NULL;
+    
+    for(i=0; i < envpCnt; i++) {
+        _envp[i] = envp[i];
+    }
+    _envp[envpCnt] = NULL;
+    
+    if(server_main(argvCnt, _argv, _envp) == 0)
+        return KERN_SUCCESS;
+    else
+        return KERN_FAILURE;
 }
 
 int startup_trigger(int argc, char **argv, char **envp) {
@@ -305,6 +305,72 @@ int main(int argc, char **argv, char **envp) {
     return execute(command_from_prefs("startx_script", DEFAULT_STARTX));
 }
 
+#ifdef NEW_LAUNCH_METHOD
+static void startup_trigger_thread(void *arg) {
+    struct arg args = *((struct arg *)arg);
+    free(arg);
+    startup_trigger(args.argc, args.argv, args.envp);
+}
+
+/*** Main ***/
+int main(int argc, char **argv, char **envp) {
+    Bool listenOnly = FALSE;
+    int i;
+    mach_msg_size_t mxmsgsz = sizeof(union MaxMsgSize) + MAX_TRAILER_SIZE;
+    mach_port_t mp;
+    kern_return_t kr;
+    
+    fprintf(stderr, "X11.app: main(): argc=%d\n", argc);
+    for(i=1; i < argc; i++) {
+        fprintf(stderr, "\targv[%u] = %s\n", (unsigned)i, argv[i]);
+        if(!strcmp(argv[i], "--listenonly")) {
+            listenOnly = TRUE;
+        }
+    }
+    
+    mp = checkin_or_register(SERVER_BOOTSTRAP_NAME);
+    if(mp == MACH_PORT_NULL) {
+        fprintf(stderr, "NULL mach service: %s", SERVER_BOOTSTRAP_NAME);
+        return EXIT_FAILURE;
+    }
+    
+    /* Figure out what our handoff socket will be
+     * TODO: cleanup on exit.
+     */
+    tmpnam(display_handoff_socket);
+    create_thread(socket_handoff_thread, NULL);
+    
+    fprintf(stderr, "Hi\n");
+    
+    /* Check if we need to do something other than listen, and make another
+     * thread handle it.
+     */
+    if(!listenOnly) {
+        struct arg *args = (struct arg*)malloc(sizeof(struct arg));
+        if(!args) {
+            fprintf(stderr, "Memory allocation error.\n");
+            return EXIT_FAILURE;
+        }
+        
+        args->argc = argc;
+        args->argv = argv;
+        args->envp = envp;
+        
+        create_thread(startup_trigger_thread, args);
+    }
+    
+    /* Main event loop */
+    fprintf(stderr, "Statrup coming...\n");
+    kr = mach_msg_server(mach_startup_server, mxmsgsz, mp, 0);
+    if (kr != KERN_SUCCESS) {
+        fprintf(stderr, "org.x.X11(mp): %s\n", mach_error_string(kr));
+        return EXIT_FAILURE;
+    }
+    
+    return EXIT_SUCCESS;
+}
+#endif
+    
 static int execute(const char *command) {
     const char *newargv[7];
     const char **s;
diff --git a/hw/xquartz/mach-startup/mach_startup.defs b/hw/xquartz/mach-startup/mach_startup.defs
index 83b31b7..05bdf56 100644
--- a/hw/xquartz/mach-startup/mach_startup.defs
+++ b/hw/xquartz/mach-startup/mach_startup.defs
@@ -33,9 +33,14 @@ import "mach_startup_types.h";
 subsystem mach_startup 1000;
 serverprefix do_;
 
-type string_array_t = array[] of c_string[1024];
+type string_t = c_string[1024];
+type string_array_t = array[] of string_t;
 
 routine start_x11_server(
 	port  : mach_port_t;
     argv  : string_array_t;
     envp  : string_array_t);
+
+routine get_display_handoff_socket(
+	port  : mach_port_t;
+    filename  : string_t);
diff --git a/hw/xquartz/mach-startup/stub.c b/hw/xquartz/mach-startup/stub.c
index c53ed53..5fdbad8 100644
--- a/hw/xquartz/mach-startup/stub.c
+++ b/hw/xquartz/mach-startup/stub.c
@@ -45,6 +45,8 @@
 #include <servers/bootstrap.h>
 #include "mach_startup.h"
 
+#include "launchd_fd.h"
+
 static char x11_path[PATH_MAX + 1];
 
 static void set_x11_path() {
@@ -109,13 +111,15 @@ static void set_x11_path() {
 #endif
 
 int main(int argc, char **argv, char **envp) {
-#ifdef NEW_LAUNCH_METHOD_2
+#ifdef NEW_LAUNCH_METHOD
     int envpc;
     kern_return_t kr;
     mach_port_t mp;
     string_array_t newenvp;
     string_array_t newargv;
     size_t i;
+    int launchd_fd;
+    string_t handoff_socket;
 #endif
 
     if(argc == 2 && !strcmp(argv[1], "-version")) {
@@ -125,7 +129,10 @@ int main(int argc, char **argv, char **envp) {
         return EXIT_SUCCESS;
     }
 
-#ifdef NEW_LAUNCH_METHOD_2
+#ifdef NEW_LAUNCH_METHOD
+    /* Get the $DISPLAY FD */
+    launchd_fd = launchd_display_fd();
+
     kr = bootstrap_look_up(bootstrap_port, SERVER_BOOTSTRAP_NAME, &mp);
     if(kr != KERN_SUCCESS) {
         set_x11_path();
@@ -147,7 +154,7 @@ int main(int argc, char **argv, char **envp) {
         }
 
         /* Try connecting for 10 seconds */
-        for(i=0; i < 40; i++) {
+        for(i=0; i < 80; i++) {
             usleep(250000);
             kr = bootstrap_look_up(bootstrap_port, SERVER_BOOTSTRAP_NAME, &mp);
             if(kr == KERN_SUCCESS)
@@ -159,6 +166,12 @@ int main(int argc, char **argv, char **envp) {
             return EXIT_FAILURE;
         }
     }
+    
+    /* Handoff the $DISPLAY FD */
+    if(launchd_fd != -1) {
+        get_display_handoff_socket(mp, handoff_socket);
+        fprintf(stderr, "Handoff socket: %s %d\n", handoff_socket, launchd_fd);
+    }
 
     /* Count envp */
     for(envpc=0; envp[envpc]; envpc++);
commit 82c4075d4ba3bea03341c80b754b0f9d2f62a826
Author: Julien Cristau <jcristau at debian.org>
Date:   Mon May 19 03:15:11 2008 +0200

    xfree86: fix initial output positions with Above or LeftOf and rotation
    
    The fix in fa19e84714aa84a2f2e817e363d6440349d0b619 was incomplete,
    as it was still using the wrong output's initial rotation to compute
    the position.

diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
index 58c3512..9512805 100644
--- a/hw/xfree86/modes/xf86Crtc.c
+++ b/hw/xfree86/modes/xf86Crtc.c
@@ -1137,10 +1137,10 @@ xf86InitialOutputPositions (ScrnInfoPtr scrn, DisplayModePtr *modes)
 		    output->initial_x += xf86ModeWidth (modes[or], relative->initial_rotation);
 		    break;
 		case OPTION_ABOVE:
-		    output->initial_y -= xf86ModeHeight (modes[o], relative->initial_rotation);
+		    output->initial_y -= xf86ModeHeight (modes[o], output->initial_rotation);
 		    break;
 		case OPTION_LEFT_OF:
-		    output->initial_x -= xf86ModeWidth (modes[o], relative->initial_rotation);
+		    output->initial_x -= xf86ModeWidth (modes[o], output->initial_rotation);
 		    break;
 		default:
 		    break;
commit 7dca84f3ee7265119fb81d598d7d2f7363e25f1f
Author: Dave Airlie <airlied at redhat.com>
Date:   Mon May 19 11:16:08 2008 +1000

    cursor: don't dereference NULL pointer is devPrivates not yet set.
    
    This fixes a bug on server recycle with ati zaphod.

diff --git a/hw/xfree86/modes/xf86Cursors.c b/hw/xfree86/modes/xf86Cursors.c
index 57cfcb6..19fe9f5 100644
--- a/hw/xfree86/modes/xf86Cursors.c
+++ b/hw/xfree86/modes/xf86Cursors.c
@@ -613,18 +613,17 @@ xf86_reload_cursors (ScreenPtr screen)
 
     if (cursor)
     {
+#if XORG_VERSION_CURRENT < XORG_VERSION_NUMERIC(7,0,0,0,0)
+	void *src = dixLookupPrivate(&cursor->devPrivates, screen);
+#else
+	void *src = cursor->devPriv[screen->myNum];
+#endif
 #ifdef ARGB_CURSOR
 	if (cursor->bits->argb && cursor_info->LoadCursorARGB)
 	    (*cursor_info->LoadCursorARGB) (scrn, cursor);
-	else
-#endif
-	    (*cursor_info->LoadCursorImage)(cursor_info->pScrn,
-#if XORG_VERSION_CURRENT < XORG_VERSION_NUMERIC(7,0,0,0,0)
-			dixLookupPrivate(&cursor->devPrivates, screen)
-#else
-			cursor->devPriv[screen->myNum]
+	else if (src)
 #endif
-	    );
+	    (*cursor_info->LoadCursorImage)(cursor_info->pScrn, src);
 
 	(*cursor_info->SetCursorPosition)(cursor_info->pScrn, x, y);
 	(*cursor_info->ShowCursor)(cursor_info->pScrn);
commit 5af5db5033582a84b616d5c50f4288adb0210459
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Sat May 17 14:51:09 2008 -0700

    XQuartz: Ok, pass XQUARTZ_USE_XKB since it breaks worse without it... but we have issues when we have the keyboard configs installed... need to figure out what to do there...
    (cherry picked from commit 301262b07024ad960f22d99a1267fe137f5c3fce)

diff --git a/hw/xquartz/quartzKeyboard.c b/hw/xquartz/quartzKeyboard.c
index b9d45cb..c75cd1d 100644
--- a/hw/xquartz/quartzKeyboard.c
+++ b/hw/xquartz/quartzKeyboard.c
@@ -43,10 +43,7 @@
 // Define this to get a diagnostic output to stderr which is helpful
 // in determining how the X server is interpreting the Darwin keymap.
 #define DUMP_DARWIN_KEYMAP
-
-// This breaks when we actually install xkeyboard-config files to start using it
-// We need to serup keymaps in the configs or something...
-// #define XQUARTZ_USE_XKB 
+#define XQUARTZ_USE_XKB 
 #define HACK_MISSING 1
 #define HACK_KEYPAD 1
 
commit 2408303d79297385063cae557195bd5fd3698478
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Sat May 17 14:56:53 2008 -0700

    XQuartz: Added functionality to add a file descriptor to the connection list after the server is already running.
    (cherry picked from commit 543c2cd68d1ffef65d4644b860faad7191c6b9da)

diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index 50a30fb..1a7d55a 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -38,12 +38,16 @@
 
 #import "X11Application.h"
 
-# include "darwin.h"
-# include "darwinEvents.h"
-# include "quartz.h"
-# define _APPLEWM_SERVER_
-# include "X11/extensions/applewm.h"
-# include "micmap.h"
+#include "darwin.h"
+#include "darwinEvents.h"
+#include "quartz.h"
+#define _APPLEWM_SERVER_
+#include "X11/extensions/applewm.h"
+#include "micmap.h"
+
+#include "os.h"
+#include "mach-startup/launchd_fd.h"
+
 #include <mach/mach.h>
 #include <unistd.h>
 
@@ -783,6 +787,7 @@ environment?", @"Startup xinitrc dialog");
 
 void X11ApplicationMain (int argc, char **argv, char **envp) {
     NSAutoreleasePool *pool;
+    int launchd_fd;
 
 #ifdef DEBUG
     while (access ("/tmp/x11-block", F_OK) == 0) sleep (1);
@@ -810,6 +815,14 @@ void X11ApplicationMain (int argc, char **argv, char **envp) {
 
     /* Tell the server thread that it can proceed */
     QuartzInitServer(argc, argv, envp);
+    
+#ifndef NEW_LAUNCH_METHOD
+    /* Start listening on the launchd fd */
+    launchd_fd = launchd_display_fd();
+    if(launchd_fd != -1) {
+        DarwinSendDDXEvent(kXquartzListenOnOpenFD, 1, launchd_fd);
+    }
+#endif
 
     [NSApp run];
     /* not reached */
diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c
index 7376c57..06c5df0 100644
--- a/hw/xquartz/darwinEvents.c
+++ b/hw/xquartz/darwinEvents.c
@@ -45,6 +45,7 @@ in this Software without prior written authorization from The Open Group.
 #include   "mi.h"
 #include   "scrnintstr.h"
 #include   "mipointer.h"
+#include   "os.h"
 
 #include "darwin.h"
 #include "quartz.h"
@@ -214,6 +215,16 @@ static void DarwinSimulateMouseClick(
     DarwinUpdateModifiers(KeyPress, modifierMask);
 }
 
+static void kXquartzListenOnOpenFDHandler(int screenNum, xEventPtr xe, DeviceIntPtr dev, int nevents) {
+    size_t i;
+    TA_SERVER();
+
+    for (i=0; i<nevents; i++) {
+        //sleep(20);
+        ListenOnOpenFD(xe[i].u.clientMessage.u.l.longs0);
+    }
+}
+
 /* Generic handler for Xquartz-specifc events.  When possible, these should
    be moved into their own individual functions and set as handlers using
    mieqSetHandler. */
@@ -319,7 +330,8 @@ Bool DarwinEQInit(void) {
     mieqSetHandler(kXquartzControllerNotify, DarwinEventHandler);
     mieqSetHandler(kXquartzPasteboardNotify, DarwinEventHandler);
     mieqSetHandler(kXquartzDisplayChanged, QuartzDisplayChangedHandler);
-
+    mieqSetHandler(kXquartzListenOnOpenFD, kXquartzListenOnOpenFDHandler);
+    
     QuartzModeEQInit();
 
     if (!darwinEvents)
diff --git a/hw/xquartz/darwinEvents.h b/hw/xquartz/darwinEvents.h
index a676aeb..58817fb 100644
--- a/hw/xquartz/darwinEvents.h
+++ b/hw/xquartz/darwinEvents.h
@@ -56,6 +56,7 @@ enum {
     kXquartzToggleFullscreen, // Enable/Disable fullscreen mode
     kXquartzSetRootless,      // Set rootless mode
     kXquartzSpaceChanged,     // Spaces changed
+    kXquartzListenOnOpenFD,   // Listen to the launchd fd (passed as arg)
     /*
      * AppleWM events
      */
diff --git a/hw/xquartz/mach-startup/Makefile.am b/hw/xquartz/mach-startup/Makefile.am
index d81caa9..3ed1c1a 100644
--- a/hw/xquartz/mach-startup/Makefile.am
+++ b/hw/xquartz/mach-startup/Makefile.am
@@ -7,7 +7,8 @@ x11appdir = $(APPLE_APPLICATIONS_DIR)/X11.app/Contents/MacOS
 x11app_PROGRAMS = X11
 
 dist_X11_SOURCES = \
-	bundle-main.c
+	bundle-main.c \
+	launchd_fd.c
 
 nodist_X11_SOURCES = \
 	mach_startupServer.c \
@@ -33,7 +34,8 @@ X11_LDFLAGS =  \
 bin_PROGRAMS = Xquartz
 
 dist_Xquartz_SOURCES = \
-	stub.c
+	stub.c \
+	launchd_fd.c
 
 nodist_Xquartz_SOURCES = \
 	mach_startupUser.c
@@ -54,6 +56,7 @@ $(BUILT_SOURCES): mach_startup.defs
 	mig -sheader mach_startupServer.h mach_startup.defs
 
 EXTRA_DIST = \
+	launchd_fd.h \
 	mach_startup.defs \
 	mach_startup_types.h
 
diff --git a/hw/xquartz/mach-startup/launchd_fd.c b/hw/xquartz/mach-startup/launchd_fd.c
new file mode 100644
index 0000000..44a243a
--- /dev/null
+++ b/hw/xquartz/mach-startup/launchd_fd.c
@@ -0,0 +1,82 @@
+/* Copyright (c) 2008 Apple 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 ABOVE LISTED COPYRIGHT
+ * HOLDER(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(s) of the above
+ * copyright holders shall not be used in advertising or otherwise to
+ * promote the sale, use or other dealings in this Software without
+ * prior written authorization.
+ */
+
+#include <launch.h>
+#include <stdio.h>
+#include <errno.h>
+
+#include "launchd_fd.h"
+
+int launchd_display_fd() {
+    launch_data_t sockets_dict, checkin_request, checkin_response;
+    launch_data_t listening_fd_array, listening_fd;
+
+    /* Get launchd fd */
+    if ((checkin_request = launch_data_new_string(LAUNCH_KEY_CHECKIN)) == NULL) {
+        fprintf(stderr,"launch_data_new_string(\"" LAUNCH_KEY_CHECKIN "\") Unable to create string.\n");
+        return ERROR_FD;
+    }
+    
+    if ((checkin_response = launch_msg(checkin_request)) == NULL) {
+        fprintf(stderr,"launch_msg(\"" LAUNCH_KEY_CHECKIN "\") IPC failure: %s\n",strerror(errno));
+        return ERROR_FD;
+    }
+    
+    if (LAUNCH_DATA_ERRNO == launch_data_get_type(checkin_response)) {
+        // ignore EACCES, which is common if we weren't started by launchd
+        if (launch_data_get_errno(checkin_response) != EACCES)
+            fprintf(stderr,"launchd check-in failed: %s\n", strerror(launch_data_get_errno(checkin_response)));
+        return ERROR_FD;
+    } 
+    
+    sockets_dict = launch_data_dict_lookup(checkin_response, LAUNCH_JOBKEY_SOCKETS);
+    if (NULL == sockets_dict) {
+        fprintf(stderr,"launchd check-in: no sockets found to answer requests on!\n");
+        return ERROR_FD;
+    }
+    
+    if (launch_data_dict_get_count(sockets_dict) > 1) {
+        fprintf(stderr,"launchd check-in: some sockets will be ignored!\n");
+        return ERROR_FD;
+    }
+    
+    listening_fd_array = launch_data_dict_lookup(sockets_dict, ":0");
+    if (NULL == listening_fd_array) {
+        fprintf(stderr,"launchd check-in: No known sockets found to answer requests on!\n");
+        return ERROR_FD;
+    }
+    
+    if (launch_data_array_get_count(listening_fd_array)!=1) {
+        fprintf(stderr,"launchd check-in: Expected 1 socket from launchd, got %u)\n",
+                (unsigned)launch_data_array_get_count(listening_fd_array));
+        return ERROR_FD;
+    }
+    
+    listening_fd=launch_data_array_get_index(listening_fd_array, 0);
+    return launch_data_get_fd(listening_fd);
+}
diff --git a/hw/xquartz/mach-startup/launchd_fd.h b/hw/xquartz/mach-startup/launchd_fd.h
new file mode 100644
index 0000000..5083fae
--- /dev/null
+++ b/hw/xquartz/mach-startup/launchd_fd.h
@@ -0,0 +1,36 @@
+/* Copyright (c) 2008 Apple 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 ABOVE LISTED COPYRIGHT
+ * HOLDER(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(s) of the above
+ * copyright holders shall not be used in advertising or otherwise to
+ * promote the sale, use or other dealings in this Software without
+ * prior written authorization.
+ */
+
+#ifndef _XQUARTZ_LAUNCHD_FD_H_
+#define _XQUARTZ_LAUNCHD_FD_H_
+
+#define ERROR_FD -1
+
+int launchd_display_fd(void);
+
+#endif /* _XQUARTZ_LAUNCHD_FD_H_ */
\ No newline at end of file
diff --git a/hw/xquartz/quartzKeyboard.c b/hw/xquartz/quartzKeyboard.c
index cc0c889..b9d45cb 100644
--- a/hw/xquartz/quartzKeyboard.c
+++ b/hw/xquartz/quartzKeyboard.c
@@ -904,7 +904,6 @@ void DarwinKeyboardInit(DeviceIntPtr pDev) {
 	
 	QuartzXkbUpdate(pDev);
 #else
-#error FAIL
     assert( InitKeyboardDeviceStruct( (DevicePtr)pDev, &keySyms,
                                       keyInfo.modMap, QuartzBell,
                                       DarwinChangeKeyboardControl ));
@@ -921,7 +920,6 @@ void DarwinKeyboardReloadHandler(int screenNum, xEventPtr xe, DeviceIntPtr pDev,
 #ifdef XQUARTZ_USE_XKB
 	QuartzXkbUpdate(pDev);
 #else
-#error FAIL
 	if (pDev->key) {
 		if (pDev->key->curKeySyms.map) xfree(pDev->key->curKeySyms.map);
 		if (pDev->key->modifierKeyMap) xfree(pDev->key->modifierKeyMap);
diff --git a/include/os.h b/include/os.h
index c0f04c6..fd34077 100644
--- a/include/os.h
+++ b/include/os.h
@@ -166,6 +166,10 @@ extern void MakeClientGrabImpervious(ClientPtr /*client*/);
 
 extern void MakeClientGrabPervious(ClientPtr /*client*/);
 
+#ifdef XQUARTZ
+extern void ListenOnOpenFD(int /* fd */);
+#endif
+
 extern void AvailableClientInput(ClientPtr /* client */);
 
 extern CARD32 GetTimeInMillis(void);
diff --git a/os/connection.c b/os/connection.c
index 3965936..a877257 100644
--- a/os/connection.c
+++ b/os/connection.c
@@ -1297,3 +1297,67 @@ MakeClientGrabPervious(ClientPtr client)
     }
 }
 
+#ifdef XQUARTZ
+/* Add a fd (from launchd) to our listeners */
+_X_EXPORT void ListenOnOpenFD(int fd) {
+    char port[20];
+    XtransConnInfo ciptr, *ciptr2, *ciptr3;
+    int *iptr, *iptr2;
+    
+    /* Sigh for inconsistencies. */  
+    sprintf (port, ":%d", atoi(display));
+
+    /* Make our XtransConnInfo
+     * TRANS_SOCKET_LOCAL_INDEX = 5 from Xtrans.c
+     */
+    ciptr = _XSERVTransReopenCOTSServer(5, fd, port);
+    if(ciptr == NULL) {
+        fprintf(stderr, "Got NULL while trying to Reopen launchd port.\n");
+        return;
+    }
+    
+    /* Allocate space to store it */
+    iptr = (int *) realloc(ListenTransFds, (ListenTransCount + 1) * sizeof (int));
+    
+    if(!iptr) {
+        fprintf(stderr, "Memory allocation error");
+        return;
+    }
+    
+    ciptr2 = (XtransConnInfo *) realloc(ListenTransConns, (ListenTransCount + 1) * sizeof (XtransConnInfo));
+    if(!ciptr2) {
+        fprintf(stderr, "Memory allocation error");
+        if(iptr != ListenTransFds)
+            free(ListenTransFds);
+        return;
+    }
+
+    if(iptr != ListenTransFds) {
+        iptr2 = ListenTransFds;
+        ListenTransFds = iptr;
+        free(iptr2);
+    }
+    
+    if(ciptr2 != ListenTransConns) {
+        ciptr3 = ListenTransConns;
+        ListenTransConns = ciptr2;
+        free(ciptr3);
+    }
+    
+    /* Store it */
+    ListenTransConns[ListenTransCount] = ciptr;
+    ListenTransFds[ListenTransCount] = fd;
+
+    FD_SET(fd, &WellKnownConnections);
+    
+    /* It is always local
+    if (!_XSERVTransIsLocal(ciptr)) {
+    //    DefineSelf (fd);
+    }
+    */
+    
+    /* Increment the count */
+    ListenTransCount++;
+}
+
+#endif
commit 01612fe612aa27262fc3c8167f52e0376941f1ef
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Thu May 15 07:08:21 2008 -0700

    XQuartz: Disable xkb since it doesn't work after getting xkeyboard-config installed
    
    Need to setup configs for the quartz keyboard
    (cherry picked from commit c28fecc621b1803a4d4536afbc724d141de9e6ee)

diff --git a/hw/xquartz/quartzKeyboard.c b/hw/xquartz/quartzKeyboard.c
index 698f39a..cc0c889 100644
--- a/hw/xquartz/quartzKeyboard.c
+++ b/hw/xquartz/quartzKeyboard.c
@@ -43,7 +43,10 @@
 // Define this to get a diagnostic output to stderr which is helpful
 // in determining how the X server is interpreting the Darwin keymap.
 #define DUMP_DARWIN_KEYMAP
-#define XQUARTZ_USE_XKB
+
+// This breaks when we actually install xkeyboard-config files to start using it
+// We need to serup keymaps in the configs or something...
+// #define XQUARTZ_USE_XKB 
 #define HACK_MISSING 1
 #define HACK_KEYPAD 1
 
commit 1d09deaa6e5a75420ea4f24f6b5533f0ebc3ba28
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Thu May 15 05:49:43 2008 -0700

    XQuartz: Made DarwinSendDDXEvent a little more robust to context switching diring server init.
    (cherry picked from commit 5626b0949b1a6bdd2fa3ec2ef53a688084349b87)

diff --git a/hw/xquartz/X11Application.m b/hw/xquartz/X11Application.m
index 9367c9f..50a30fb 100644
--- a/hw/xquartz/X11Application.m
+++ b/hw/xquartz/X11Application.m
@@ -59,11 +59,9 @@
 int X11EnableKeyEquivalents = TRUE;
 int quartzHasRoot = FALSE, quartzEnableRootless = TRUE;
 
-extern int darwinFakeButtons, input_check_flag;
+extern int darwinFakeButtons;
 extern Bool enable_stereo;
 
-extern xEvent *darwinEvents;
-
 X11Application *X11App;
 
 #define ALL_KEY_MASKS (NSShiftKeyMask | NSControlKeyMask | NSAlternateKeyMask | NSCommandKeyMask)
diff --git a/hw/xquartz/darwinEvents.c b/hw/xquartz/darwinEvents.c
index 1547094..7376c57 100644
--- a/hw/xquartz/darwinEvents.c
+++ b/hw/xquartz/darwinEvents.c
@@ -76,12 +76,10 @@ in this Software without prior written authorization from The Open Group.
 /* FIXME: Abstract this better */
 void QuartzModeEQInit(void);
 
-int input_check_zero, input_check_flag;
-
 static int old_flags = 0;  // last known modifier state
 
-xEvent *darwinEvents = NULL;
-pthread_mutex_t darwinEvents_mutex = PTHREAD_MUTEX_INITIALIZER;
+static xEvent *darwinEvents = NULL;
+static pthread_mutex_t darwinEvents_mutex = PTHREAD_MUTEX_INITIALIZER;
 
 static inline void darwinEvents_lock(void) {
     int err;
@@ -307,11 +305,6 @@ static void DarwinEventHandler(int screenNum, xEventPtr xe, DeviceIntPtr dev, in
 }
 
 Bool DarwinEQInit(void) { 
-    if (!darwinEvents)
-        darwinEvents = (xEvent *)xcalloc(sizeof(xEvent), GetMaximumEventsNum());
-    if (!darwinEvents)
-        FatalError("Couldn't allocate event buffer\n");
-
     mieqInit();
     mieqSetHandler(kXquartzReloadKeymap, DarwinKeyboardReloadHandler);
     mieqSetHandler(kXquartzActivate, DarwinEventHandler);
@@ -328,6 +321,11 @@ Bool DarwinEQInit(void) {
     mieqSetHandler(kXquartzDisplayChanged, QuartzDisplayChangedHandler);
 
     QuartzModeEQInit();
+
+    if (!darwinEvents)
+        darwinEvents = (xEvent *)xcalloc(sizeof(xEvent), GetMaximumEventsNum());
+    if (!darwinEvents)
+        FatalError("Couldn't allocate event buffer\n");
     
     return TRUE;
 }
@@ -354,7 +352,6 @@ void ProcessInputEvents(void) {
    Dispatch() event loop to check out event queue */
 static void DarwinPokeEQ(void) {
 	char nullbyte=0;
-	input_check_flag++;
 	//  <daniels> oh, i ... er ... christ.
 	write(darwinEventWriteFD, &nullbyte, 1);
 }
@@ -567,8 +564,13 @@ void DarwinSendDDXEvent(int type, int argc, ...) {
         va_end (args);
     }
 
-    darwinEvents_lock();
+    /* If we're called from something other than the X server thread, we need
+     * to wait for the X server to setup darwinEvents.
+     */
+    while(darwinEvents == NULL) {
+        usleep(250000);
+    }
+
     mieqEnqueue(darwinPointer, &xe);
     DarwinPokeEQ();
-    darwinEvents_unlock();
 }
commit adc62f62b9f08aa6633718989ab61b61e3c1e8e2
Author: Jeremy Huddleston <jeremyhu at freedesktop.org>
Date:   Wed May 14 01:33:43 2008 -0700

    Xquartz: Xquartz stub now can send Mach IPC to start the server.
    (cherry picked from commit 55a3bca8ea42f8677897f94bf0a429bdc08c6696)

diff --git a/hw/xquartz/mach-startup/Makefile.am b/hw/xquartz/mach-startup/Makefile.am
index ee2cbfe..d81caa9 100644
--- a/hw/xquartz/mach-startup/Makefile.am
+++ b/hw/xquartz/mach-startup/Makefile.am
@@ -1,6 +1,7 @@
 AM_CPPFLAGS = \
 	-DBUILD_DATE=\"$(BUILD_DATE)\" \
 	-DXSERVER_VERSION=\"$(VERSION)\"
+#	-DNEW_LAUNCH_METHOD -DNEW_LAUNCH_METHOD_2
 
 x11appdir = $(APPLE_APPLICATIONS_DIR)/X11.app/Contents/MacOS
 x11app_PROGRAMS = X11
diff --git a/hw/xquartz/mach-startup/bundle-main.c b/hw/xquartz/mach-startup/bundle-main.c
index cd64e42..dd75f02 100644
--- a/hw/xquartz/mach-startup/bundle-main.c
+++ b/hw/xquartz/mach-startup/bundle-main.c
@@ -165,10 +165,11 @@ int main(int argc, char **argv, char **envp) {
     mach_port_t mp;
     kern_return_t kr;
 
+    fprintf(stderr, "X11.app: main(): argc=%d\n", argc);
     for(i=1; i < argc; i++) {
+        fprintf(stderr, "\targv[%u] = %s\n", (unsigned)i, argv[i]);
         if(!strcmp(argv[i], "--listenonly")) {
             listenOnly = TRUE;
-            break;
         }
     }
 
@@ -221,10 +222,12 @@ int main(int argc, char **argv, char **envp) {
     const char *s;
     
     size_t i;
+#ifndef NEW_LAUNCH_METHOD
     fprintf(stderr, "X11.app: main(): argc=%d\n", argc);
     for(i=0; i < argc; i++) {
         fprintf(stderr, "\targv[%u] = %s\n", (unsigned)i, argv[i]);
     }
+#endif
     
     /* Take care of the case where we're called like a normal DDX */
     if(argc > 1 && argv[1][0] == ':') {
diff --git a/hw/xquartz/mach-startup/stub.c b/hw/xquartz/mach-startup/stub.c
index fae9720..c53ed53 100644
--- a/hw/xquartz/mach-startup/stub.c
+++ b/hw/xquartz/mach-startup/stub.c
@@ -115,6 +115,7 @@ int main(int argc, char **argv, char **envp) {
     mach_port_t mp;
     string_array_t newenvp;
     string_array_t newargv;
+    size_t i;
 #endif
 
     if(argc == 2 && !strcmp(argv[1], "-version")) {
@@ -127,7 +128,6 @@ int main(int argc, char **argv, char **envp) {
 #ifdef NEW_LAUNCH_METHOD_2
     kr = bootstrap_look_up(bootstrap_port, SERVER_BOOTSTRAP_NAME, &mp);
     if(kr != KERN_SUCCESS) {
-        int i;
         set_x11_path();
 
         /* This forking is ugly and will be cleaned up later */
@@ -142,19 +142,20 @@ int main(int argc, char **argv, char **envp) {
             _argv[0] = x11_path;
             _argv[1] = "--listenonly";
             _argv[2] = NULL;
+            fprintf(stderr, "Starting X server: %s --listenonly\n", x11_path);
             return execvp(x11_path, _argv);
         }
 
         /* Try connecting for 10 seconds */
-        for(i=0; i < 20; i++) {
-            usleep(500);
+        for(i=0; i < 40; i++) {
+            usleep(250000);
             kr = bootstrap_look_up(bootstrap_port, SERVER_BOOTSTRAP_NAME, &mp);
             if(kr == KERN_SUCCESS)
                 break;
         }
 
         if(kr != KERN_SUCCESS) {
-            fprintf(stderr, "bootstrap_look_up(): %s\n", bootstrap_strerror(kr));
+            fprintf(stderr, "bootstrap_look_up(): Timed out: %s\n", bootstrap_strerror(kr));
             return EXIT_FAILURE;
         }
     }
commit 93c082a060bfa8d2a204c0c57ec3507a8edea087
Author: Brad Smith <brad at comstyle.com>
Date:   Sat May 17 13:14:31 2008 +0200

    OpenBSD doesn't define __x86_64__, simplify tests.
    
    Seeing as this code seems to be specific to OpenBSD I don't think
    __x86_64__ should have been added there at all. It appears to have
    been added wherever __amd64__ existed before which is wrong. I
    think that part of the commit should be reverted but also all four of
    the checks should be __OpenBSD__ && __amd64__ instead of two one
    direction and two flipped.

diff --git a/hw/xfree86/os-support/bsd/i386_video.c b/hw/xfree86/os-support/bsd/i386_video.c
index e2f6420..505659e 100644
--- a/hw/xfree86/os-support/bsd/i386_video.c
+++ b/hw/xfree86/os-support/bsd/i386_video.c
@@ -55,7 +55,7 @@
 #endif
 #endif
 
-#if defined(__OpenBSD__) && (defined(__amd64__) || defined(__x86_64__))
+#if defined(__OpenBSD__) && defined(__amd64__)
 #include <machine/mtrr.h>
 #include <machine/sysarch.h>
 #endif
@@ -108,7 +108,7 @@ static pointer NetBSDsetWC(int, unsigned long, unsigned long, Bool,
 			   MessageType);
 static void NetBSDundoWC(int, pointer);
 #endif
-#if (defined(__amd64__) || defined(__x86_64__)) && defined(__OpenBSD__)
+#if defined(__OpenBSD__) && defined(__amd64__)
 static pointer amd64setWC(int, unsigned long, unsigned long, Bool, 
     MessageType);
 static void amd64undoWC(int, pointer);
@@ -229,7 +229,7 @@ xf86OSInitVidMem(VidMemInfoPtr pVidMem)
 	pVidMem->setWC = NetBSDsetWC;
 	pVidMem->undoWC = NetBSDundoWC;
 #endif
-#if (defined(__amd64__) || defined(__x86_64__))  && defined(__OpenBSD__)
+#if defined(__OpenBSD__) && defined(__amd64__)
 	pVidMem->setWC = amd64setWC;
 	pVidMem->undoWC = amd64undoWC;
 #endif
@@ -953,7 +953,7 @@ NetBSDundoWC(int screenNum, pointer list)
 }
 #endif
 
-#if defined(__OpenBSD__) && (defined(__amd64__) || defined(__x86_64__))
+#if defined(__OpenBSD__) && defined(__amd64__)
 static pointer
 amd64setWC(int screenNum, unsigned long base, unsigned long size, Bool enable,
 	    MessageType from)
commit 895d4e274d2b4638f0e6838dfee0e543311dba34
Author: Brad Smith <brad at comstyle.com>
Date:   Sat May 17 13:05:58 2008 +0200

    BSD's also have /dev/urandom.

diff --git a/configure.ac b/configure.ac
index 403ce8c..311f5c5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -179,6 +179,8 @@ AC_CHECK_FUNC([dlopen], [],
 case $host_os in
     linux*|darwin*)
 	AC_DEFINE(HAVE_URANDOM, 1, [Has /dev/urandom]) ;;
+    freebsd*|netbsd*|openbsd*|dragonfly*)
+	AC_DEFINE(HAVE_URANDOM, 1, [Has /dev/urandom]) ;;
     solaris*)
 	# Solaris 8 with patches, or Solaris 9 or later have /dev/urandom
 	if test -r /dev/urandom ; then
commit aad1c37b0951eae216ac323c5d8bfc6fbcf096bd
Author: Adam Jackson <ajax at redhat.com>
Date:   Fri May 16 10:52:41 2008 -0400

    RANDR 1.1 compat: remove senseless comparison against the virtual size.

diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c
index 4767f26..6c4ab43 100644
--- a/hw/xfree86/modes/xf86RandR12.c
+++ b/hw/xfree86/modes/xf86RandR12.c
@@ -129,9 +129,7 @@ xf86RandR12GetInfo (ScreenPtr pScreen, Rotation *rotations)
 	    return FALSE;
 	RRRegisterRate (pScreen, pSize, refresh);
 
-	if (xf86ModesEqual(mode, scrp->currentMode) &&
-	    mode->HDisplay == scrp->virtualX &&
-	    mode->VDisplay == scrp->virtualY)
+	if (xf86ModesEqual(mode, scrp->currentMode))
 	{
 	    RRSetCurrentConfig (pScreen, randrp->rotation, refresh, pSize);
 	}
commit 14726b776d6cebb7d864b6ffa7554e1ce5637d5c
Author: Adam Jackson <ajax at redhat.com>
Date:   Fri May 16 10:51:32 2008 -0400

    xf86SetDesiredModes(): Skip disabled CRTCs first thing.

diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
index 1a49cb5..58c3512 100644
--- a/hw/xfree86/modes/xf86Crtc.c
+++ b/hw/xfree86/modes/xf86Crtc.c
@@ -2244,6 +2244,10 @@ xf86SetDesiredModes (ScrnInfoPtr scrn)
 	xf86OutputPtr	output = NULL;
 	int		o;
 
+	/* Skip disabled CRTCs */
+	if (!crtc->enabled)
+	    continue;
+
 	if (config->output[config->compat_output]->crtc == crtc)
 	    output = config->output[config->compat_output];
 	else
@@ -2255,9 +2259,7 @@ xf86SetDesiredModes (ScrnInfoPtr scrn)
 		    break;
 		}
 	}
-	/*
-	 * Skip disabled crtcs
-	 */
+	/* paranoia */
 	if (!output)
 	    continue;
 
commit 459f34b089aca4f4eee9752600c3a9e4f4e343ab
Author: Adam Jackson <ajax at redhat.com>
Date:   Fri May 16 10:48:00 2008 -0400

    Fix initial mode selection even harder.
    
    The first guess used to be "is the preferred mode for one output the
    preferred mode on all outputs".  Instead, do "find the largest mode that's
    preferred for at least one output and available on all outputs".

diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
index 1b6bb9f..1a49cb5 100644
--- a/hw/xfree86/modes/xf86Crtc.c
+++ b/hw/xfree86/modes/xf86Crtc.c
@@ -1760,46 +1760,65 @@ nextEnabledOutput(xf86CrtcConfigPtr config, Bool *enabled, int *index)
 }
 
 static Bool
-xf86TargetExact(ScrnInfoPtr scrn, xf86CrtcConfigPtr config,
-		DisplayModePtr *modes, Bool *enabled,
-		int width, int height)
+xf86TargetPreferred(ScrnInfoPtr scrn, xf86CrtcConfigPtr config,
+		    DisplayModePtr *modes, Bool *enabled,
+		    int width, int height)
 {
-    int o;
-    int pref_width = 0, pref_height = 0;
-    DisplayModePtr *preferred;
+    int o, p;
+    int max_pref_width = 0, max_pref_height = 0;
+    DisplayModePtr *preferred, *preferred_match;
     Bool ret = FALSE;
 
     preferred = xnfcalloc(config->num_output, sizeof(DisplayModePtr));
+    preferred_match = xnfcalloc(config->num_output, sizeof(DisplayModePtr));
+
+    /* Check if the preferred mode is available on all outputs */
+    for (p = -1; nextEnabledOutput(config, enabled, &p); ) {
+	Rotation r = config->output[p]->initial_rotation;
+	DisplayModePtr mode;
+	if ((preferred[p] = xf86OutputHasPreferredMode(config->output[p],
+			width, height))) {
+	    int pref_width = xf86ModeWidth(preferred[p], r);
+	    int pref_height = xf86ModeHeight(preferred[p], r);
+	    Bool all_match = TRUE;
+
+	    for (o = -1; nextEnabledOutput(config, enabled, &o); ) {
+		Bool match = FALSE;
+		xf86OutputPtr output = config->output[o];
+		if (o == p)
+		    continue;
 
-    /* Find all the preferred modes; fail if any outputs lack them */
-    for (o = -1; nextEnabledOutput(config, enabled, &o); ) {
-	preferred[o] =
-	    xf86OutputHasPreferredMode(config->output[o], width, height);
+		for (mode = output->probed_modes; mode; mode = mode->next) {
+		    Rotation r = output->initial_rotation;
+		    if (xf86ModeWidth(mode, r) == pref_width &&
+			    xf86ModeHeight(mode, r) == pref_height) {
+			preferred[o] = mode;
+			match = TRUE;
+		    }
+		}
 
-	if (!preferred[o])
-	    goto out;
-    }
+		all_match &= match;
+	    }
 
-    /* check that they're all the same size */
-    for (o = -1; nextEnabledOutput(config, enabled, &o); ) {
-	Rotation r = config->output[o]->initial_rotation;
-	if (!pref_width) {
-	    pref_width = xf86ModeWidth(preferred[o], r);
-	    pref_height = xf86ModeHeight(preferred[o], r);
-	} else {
-	    if (pref_width != xf86ModeWidth(preferred[o], r))
-		goto out;
-	    if (pref_height != xf86ModeHeight(preferred[o], r))
-		goto out;
+	    if (all_match &&
+		    (pref_width*pref_height > max_pref_width*max_pref_height)) {
+		for (o = -1; nextEnabledOutput(config, enabled, &o); )
+		    preferred_match[o] = preferred[o];
+		max_pref_width = pref_width;
+		max_pref_height = pref_height;
+		ret = TRUE;
+	    }
 	}
     }
 
-    /* oh good, they match.  stash the selected modes and return. */
-    memcpy(modes, preferred, config->num_output * sizeof(DisplayModePtr));
-    ret = TRUE;
+    if (ret) {
+	/* oh good, there is a match.  stash the selected modes and return. */
+	memcpy(modes, preferred_match,
+		config->num_output * sizeof(DisplayModePtr));
+    }
 
-out:
     xfree(preferred);
+    xfree(preferred_match);
     return ret;
 }
 
@@ -2025,7 +2044,7 @@ xf86InitialConfiguration (ScrnInfoPtr scrn, Bool canGrow)
 
     if (xf86TargetUserpref(scrn, config, modes, enabled, width, height))
 	xf86DrvMsg(i, X_INFO, "Using user preference for initial modes\n");
-    else if (xf86TargetExact(scrn, config, modes, enabled, width, height))
+    else if (xf86TargetPreferred(scrn, config, modes, enabled, width, height))
 	xf86DrvMsg(i, X_INFO, "Using exact sizes for initial modes\n");
     else if (xf86TargetAspect(scrn, config, modes, enabled, width, height))
 	xf86DrvMsg(i, X_INFO, "Using fuzzy aspect match for initial modes\n");
@@ -2097,6 +2116,8 @@ xf86InitialConfiguration (ScrnInfoPtr scrn, Bool canGrow)
 	    crtc->x = output->initial_x;
 	    crtc->y = output->initial_y;
 	    output->crtc = crtc;
+	} else {
+	    output->crtc = NULL;
 	}
     }
     
commit 96111c154713600dd534dd82104ac18b91466202
Author: Adam Jackson <ajax at redhat.com>
Date:   Fri May 16 10:31:58 2008 -0400

    Redo RANDR compatibility output selection.
    
    Old logic was just the first one that happened to have an associated
    CRTC.  The new logic tries to find one that's definitely connected, has
    probed modes, and has the largest candidate mode.

diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
index 402336f..1b6bb9f 100644
--- a/hw/xfree86/modes/xf86Crtc.c
+++ b/hw/xfree86/modes/xf86Crtc.c
@@ -1593,7 +1593,98 @@ xf86ProbeOutputModes (ScrnInfoPtr scrn, int maxX, int maxY)
 _X_EXPORT void
 xf86RandR12GetOriginalVirtualSize(ScrnInfoPtr scrn, int *x, int *y);
 
-_X_EXPORT void
+static DisplayModePtr
+biggestMode(DisplayModePtr a, DisplayModePtr b)
+{
+    int A, B;
+
+    if (!a)
+	return b;
+    if (!b)
+	return a;
+
+    A = a->HDisplay * a->VDisplay;
+    B = b->HDisplay * b->VDisplay;
+
+    if (A > B)
+	return a;
+
+    return b;
+}
+
+static xf86OutputPtr
+SetCompatOutput(xf86CrtcConfigPtr config)
+{
+    xf86OutputPtr output = NULL, test = NULL;
+    DisplayModePtr maxmode = NULL, testmode, mode;
+    int o, compat = -1, count, mincount = 0;
+
+    /* Look for one that's definitely connected */
+    for (o = 0; o < config->num_output; o++)
+    {
+	test = config->output[o];
+	if (!test->crtc)
+	    continue;
+	if (test->status != XF86OutputStatusConnected)
+	    continue;
+	if (!test->probed_modes)
+	    continue;
+
+	testmode = mode = test->probed_modes;
+	for (count = 0; mode; mode = mode->next, count++)
+	    testmode = biggestMode(testmode, mode);
+
+	if (!output) {
+	    output = test;
+	    compat = o;
+	    maxmode = testmode;
+	    mincount = count;
+	} else if (maxmode == biggestMode(maxmode, testmode)) {
+	    output = test;
+	    compat = o;
+	    maxmode = testmode;
+	    mincount = count;
+	} else if ((maxmode->HDisplay == testmode->HDisplay) && 
+		(maxmode->VDisplay == testmode->VDisplay) &&
+		count <= mincount) {
+	    output = test;
+	    compat = o;
+	    maxmode = testmode;
+	    mincount = count;
+	}
+    }
+
+    /* If we didn't find one, take anything we can get */
+    if (!output)
+    {
+	for (o = 0; o < config->num_output; o++)
+	{
+	    test = config->output[o];
+	    if (!test->crtc)
+		continue;
+	    if (!test->probed_modes)
+		continue;
+
+	    if (!output) {
+		output = test;
+		compat = o;
+	    } else if (test->probed_modes->HDisplay < output->probed_modes->HDisplay) {
+		output = test;
+		compat = o;
+	    }
+	}
+    }
+
+    if (compat >= 0) {
+	config->compat_output = compat;
+    } else {
+	/* Don't change the compat output when no valid outputs found */
+	output = config->output[config->compat_output];
+    }
+
+    return output;
+}
+
 xf86SetScrnInfoModes (ScrnInfoPtr scrn)
 {
     xf86CrtcConfigPtr	config = XF86_CRTC_CONFIG_PTR(scrn);
@@ -1601,23 +1692,11 @@ xf86SetScrnInfoModes (ScrnInfoPtr scrn)
     xf86CrtcPtr		crtc;
     DisplayModePtr	last, mode;
 
-    output = config->output[config->compat_output];
-    if (!output->crtc)
-    {
-	int o;
+    output = SetCompatOutput(config);
+
+    if (!output)
+	return; /* punt */
 
-	output = NULL;
-	for (o = 0; o < config->num_output; o++)
-	    if (config->output[o]->crtc)
-	    {
-		config->compat_output = o;
-		output = config->output[o];
-		break;
-	    }
-	/* no outputs are active, punt and leave things as they are */
-	if (!output)
-	    return;
-    }
     crtc = output->crtc;
 
     /* Clear any existing modes from scrn->modes */
@@ -1782,25 +1861,6 @@ bestModeForAspect(xf86CrtcConfigPtr config, Bool *enabled, float aspect)
     return match;
 }
 
-static DisplayModePtr
-biggestMode(DisplayModePtr a, DisplayModePtr b)
-{
-    int A, B;
-
-    if (!a)
-	return b;
-    if (!b)
-	return a;
-
-    A = a->HDisplay * a->VDisplay;
-    B = b->HDisplay * b->VDisplay;
-
-    if (A > B)
-	return a;
-
-    return b;
-}
-
 static Bool
 xf86TargetAspect(ScrnInfoPtr scrn, xf86CrtcConfigPtr config,
 		 DisplayModePtr *modes, Bool *enabled,
commit a4bbe1c8bca08f3df5ff7e50444af6aef7ec8b25
Author: Adam Jackson <ajax at redhat.com>
Date:   Fri May 16 10:25:12 2008 -0400

    Re-add sync range inference from legacy setup to RANDR 1.2.

diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
index 8c2b247..402336f 100644
--- a/hw/xfree86/modes/xf86Crtc.c
+++ b/hw/xfree86/modes/xf86Crtc.c
@@ -1300,6 +1300,50 @@ preferredMode(ScrnInfoPtr pScrn, xf86OutputPtr output)
     return preferred_mode;
 }
 
+static void
+GuessRangeFromModes(MonPtr mon, DisplayModePtr mode)
+{
+    if (!mon || !mode)
+       return;
+
+    mon->nHsync = 1;
+    mon->hsync[0].lo = 1024.0;
+    mon->hsync[0].hi = 0.0;
+
+    mon->nVrefresh = 1;
+    mon->vrefresh[0].lo = 1024.0;
+    mon->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 < mon->hsync[0].lo)
+	    mon->hsync[0].lo = mode->HSync;
+
+	if (mode->HSync > mon->hsync[0].hi)
+	    mon->hsync[0].hi = mode->HSync;
+
+	if (mode->VRefresh < mon->vrefresh[0].lo)
+	    mon->vrefresh[0].lo = mode->VRefresh;
+
+	if (mode->VRefresh > mon->vrefresh[0].hi)
+	    mon->vrefresh[0].hi = mode->VRefresh;
+
+	mode = mode->next;
+    }
+
+    /* stretch out the bottom to fit 640x480 at 60 */
+    if (mon->hsync[0].lo > 31.0)
+       mon->hsync[0].lo = 31.0;
+    if (mon->vrefresh[0].lo > 58.0)
+       mon->vrefresh[0].lo = 58.0;
+}
+
 _X_EXPORT void
 xf86ProbeOutputModes (ScrnInfoPtr scrn, int maxX, int maxY)
 {
@@ -1417,6 +1461,10 @@ xf86ProbeOutputModes (ScrnInfoPtr scrn, int maxX, int maxY)
 			       OPTUNITS_KHZ, &clock))
 	    max_clock = (int) clock;
 
+	/* If we still don't have a sync range, guess wildly */
+	if (!mon_rec.nHsync || !mon_rec.nVrefresh)
+	    GuessRangeFromModes(&mon_rec, output_modes);
+
 	/*
 	 * These limits will end up setting a 1024x768 at 60Hz mode by default,
 	 * which seems like a fairly good mode to use when nothing else is
commit f52f6c5c7efc281f9ac204fbaa4f71383df7463d
Author: Adam Jackson <ajax at redhat.com>
Date:   Mon May 5 14:37:07 2008 -0400

    Fix hal shutdown crash.
    
    Removing the device invalidates its ->next pointer.  Copy it aside before
    destroying the device.

diff --git a/config/hal.c b/config/hal.c
index e197cb1..1d62a1d 100644
--- a/config/hal.c
+++ b/config/hal.c
@@ -74,7 +74,7 @@ remove_device(DeviceIntPtr dev)
 static void
 device_removed(LibHalContext *ctx, const char *udi)
 {
-    DeviceIntPtr dev;
+    DeviceIntPtr dev, next;
     char *value;
 
     value = xalloc(strlen(udi) + 5); /* "hal:" + NULL */
@@ -82,11 +82,13 @@ device_removed(LibHalContext *ctx, const char *udi)
         return;
     sprintf(value, "hal:%s", udi);
 
-    for (dev = inputInfo.devices; dev; dev = dev->next) {
+    for (dev = inputInfo.devices; dev; dev = next) {
+	next = dev->next;
         if (dev->config_info && strcmp(dev->config_info, value) == 0)
             remove_device(dev);
     }
-    for (dev = inputInfo.off_devices; dev; dev = dev->next) {
+    for (dev = inputInfo.off_devices; dev; dev = next) {
+	next = dev->next;
         if (dev->config_info && strcmp(dev->config_info, value) == 0)
             remove_device(dev);
     }
commit 99e4531f7c3fafce065dfd21f65bad1cf190c3f1
Author: Adam Jackson <ajax at redhat.com>
Date:   Fri May 16 08:16:01 2008 -0400

    The great kdrive purge.
    
    Most of these drivers didn't work.  ati was the only one that even came
    close.  The igs, ipaq, itsy, pcmcia, savage, sis530, trident, trio, ts300,
    and vxworks directories have never built since modularisation, so clearly
    no one can miss them.

diff --git a/configure.ac b/configure.ac
index 8716ba5..403ce8c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2102,25 +2102,12 @@ hw/xquartz/doc/Makefile
 hw/xquartz/mach-startup/Makefile
 hw/xquartz/xpr/Makefile
 hw/kdrive/Makefile
-hw/kdrive/ati/Makefile
-hw/kdrive/chips/Makefile
 hw/kdrive/ephyr/Makefile
-hw/kdrive/epson/Makefile
 hw/kdrive/fake/Makefile
 hw/kdrive/fbdev/Makefile
-hw/kdrive/i810/Makefile
 hw/kdrive/linux/Makefile
-hw/kdrive/mach64/Makefile
-hw/kdrive/mga/Makefile
-hw/kdrive/neomagic/Makefile
-hw/kdrive/nvidia/Makefile
-hw/kdrive/pm2/Makefile
-hw/kdrive/r128/Makefile
 hw/kdrive/sdl/Makefile
-hw/kdrive/sis300/Makefile
-hw/kdrive/smi/Makefile
 hw/kdrive/src/Makefile
 hw/kdrive/vesa/Makefile
-hw/kdrive/via/Makefile
 xorg-server.pc
 ])
diff --git a/hw/kdrive/Makefile.am b/hw/kdrive/Makefile.am
index 767e1c4..c30a157 100644
--- a/hw/kdrive/Makefile.am
+++ b/hw/kdrive/Makefile.am
@@ -1,10 +1,9 @@
 if KDRIVEVESA
-VESA_SUBDIRS = vesa ati chips i810 mach64 mga nvidia pm2 r128 \
-               smi via
+VESA_SUBDIRS = vesa
 endif
 
 if BUILD_KDRIVEFBDEVLIB
-FBDEV_SUBDIRS = fbdev epson
+FBDEV_SUBDIRS = fbdev
 endif
 
 if XFAKESERVER
@@ -35,8 +34,7 @@ SUBDIRS =			\
 	$(LINUX_SUBDIRS)	\
 	$(SERVER_SUBDIRS)
 
-DIST_SUBDIRS = vesa ati chips epson i810 mach64 mga neomagic nvidia pm2 r128 \
-               smi via fbdev sdl ephyr src linux fake sis300
+DIST_SUBDIRS = vesa fbdev sdl ephyr src linux fake
 
 relink:
 	@for i in $(SERVER_SUBDIRS) ; do make -C $$i relink ; done
diff --git a/hw/kdrive/Xkdrive.man b/hw/kdrive/Xkdrive.man
index b4f1a97..b37f9f1 100644
--- a/hw/kdrive/Xkdrive.man
+++ b/hw/kdrive/Xkdrive.man
@@ -11,26 +11,6 @@ Xkdrive \- tiny X server
 .B Xfbdev
 .RI [ :display ]
 .RI [ option ...]
-
-.B Xigs
-.RI [ :display ]
-.RI [ option ...]
-
-.B Xtrident
-.RI [ :display ]
-.RI [ option ...]
-
-.B Xsis530
-.RI [ :display ]
-.RI [ option ...]
-
-.B Xtrio
-.RI [ :display ]
-.RI [ option ...]
-
-.B Xitsy
-.RI [ :display ]
-.RI [ option ...]
 .SH DESCRIPTION
 .B Xkdrive
 is a family of X servers designed to be particularly small.  This
diff --git a/hw/kdrive/ati/Makefile.am b/hw/kdrive/ati/Makefile.am
deleted file mode 100644
index 31462bb..0000000
--- a/hw/kdrive/ati/Makefile.am
+++ /dev/null
@@ -1,74 +0,0 @@
-#if DRI
-#DRI_INCLUDES = 	-I$(top_srcdir)/dri	\
-#		-I$(top_srcdir)/drm
-#DRI_LIBS = 	$(top_builddir)/dri/libdri.a	\
-#		$(top_builddir)/drm/libdrm.a
-#DRI_SOURCES =	ati_dri.c	\
-#		ati_dri.h	\
-#		ati_dripriv.h	\
-#		r128_common.h	\
-#		r128_sarea.h	\
-#		radeon_common.h	\
-#		radeon_sarea.h
-#endif
-
-if KDRIVEFBDEV
-FBDEV_INCLUDES =-I$(top_srcdir)/hw/kdrive/fbdev
-FBDEV_LIBS = $(top_builddir)/hw/kdrive/fbdev/libfbdev.a
-endif
-
-if KDRIVEVESA
-VESA_INCLUDES = -I$(top_srcdir)/hw/kdrive/vesa
-VESA_LIBS = $(top_builddir)/hw/kdrive/vesa/libvesa.a
-endif
-
-INCLUDES = 					\
-	@KDRIVE_INCS@				\
-	$(DRI_INCLUDES)				\
-	$(FBDEV_INCLUDES)			\
-	$(VESA_INCLUDES)			\
-	@KDRIVE_CFLAGS@
-
-bin_PROGRAMS = Xati
-
-noinst_LIBRARIES = libati.a
-
-libati_a_SOURCES = 	\
-	ati_cursor.c	\
-	ati_dma.c	\
-	ati_dma.h	\
-	ati_draw.c	\
-	ati_draw.h	\
-	ati_microcode.c	\
-	ati.c		\
-	ati.h		\
-	ati_reg.h	\
-	r128_composite.c \
-	ati_video.c	\
-	radeon_composite.c \
-	$(DRI_SOURCES)
-
-Xati_SOURCES = \
-	ati_stub.c
-
-ATI_LIBS =				\
-	libati.a 			\
-	$(FBDEV_LIBS)			\
-	$(VESA_LIBS)			\
-	$(DRI_LIBS)			\
-	@KDRIVE_LIBS@
-
-if GLX
-Xati_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
-endif
-
-Xati_LDADD = \
-	$(ATI_LIBS)			\
-	@KDRIVE_LIBS@
-
-Xati_DEPENDENCIES =	\
-	libati.a 			\
-	@KDRIVE_LOCAL_LIBS@
-
-relink:
-	rm -f $(bin_PROGRAMS) && make $(bin_PROGRAMS)
diff --git a/hw/kdrive/ati/ati.c b/hw/kdrive/ati/ati.c
deleted file mode 100644
index c4f67e1..0000000
--- a/hw/kdrive/ati/ati.c
+++ /dev/null
@@ -1,761 +0,0 @@
-/*
- * Copyright © 2003 Eric Anholt
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Eric Anholt not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  Eric Anholt makes no
- * representations about the suitability of this software for any purpose.  It
- * is provided "as is" without express or implied warranty.
- *
- * ERIC ANHOLT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL ERIC ANHOLT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <kdrive-config.h>
-#endif
-#include "ati.h"
-#include "ati_reg.h"
-#if defined(USE_DRI) && defined(GLXEXT)
-#include "ati_sarea.h"
-#endif
-
-static Bool ATIIsAGP(ATICardInfo *atic);
-
-#define CAP_SERIESMASK		0xf
-#define CAP_R128		0x1	/* If it's a Rage 128 */
-#define CAP_R100		0x2	/* If it's an r100 series radeon. */
-#define CAP_R200		0x3	/* If it's an r200 series radeon. */
-#define CAP_R300		0x4	/* If it's an r300 series radeon. */
-
-#define CAP_FEATURESMASK	0xf0
-#define CAP_NOAGP		0x10	/* If it's a PCI-only card. */
-
-struct pci_id_entry ati_pci_ids[] = {
-	{0x1002, 0x4136, 0x2, "ATI Radeon RS100"},
-	{0x1002, 0x4137, 0x2, "ATI Radeon RS200"},
-	{0x1002, 0x4237, 0x2, "ATI Radeon RS250"},
-	{0x1002, 0x4144, 0x4, "ATI Radeon R300 AD"},
-	{0x1002, 0x4145, 0x4, "ATI Radeon R300 AE"},
-	{0x1002, 0x4146, 0x4, "ATI Radeon R300 AF"},
-	{0x1002, 0x4147, 0x4, "ATI Radeon R300 AG"},
-	{0x1002, 0x4148, 0x4, "ATI Radeon R350 AH"},
-	{0x1002, 0x4149, 0x4, "ATI Radeon R350 AI"},
-	{0x1002, 0x414a, 0x4, "ATI Radeon R350 AJ"},
-	{0x1002, 0x414b, 0x4, "ATI Radeon R350 AK"},
-	{0x1002, 0x4150, 0x4, "ATI Radeon RV350 AP"},
-	{0x1002, 0x4151, 0x4, "ATI Radeon RV350 AQ"},
-	{0x1002, 0x4152, 0x4, "ATI Radeon RV350 AR"},
-	{0x1002, 0x4153, 0x4, "ATI Radeon RV350 AS"},
-	{0x1002, 0x4154, 0x4, "ATI Radeon RV350 AT"},
-	{0x1002, 0x4156, 0x4, "ATI Radeon RV350 AV"},
-	{0x1002, 0x4242, 0x3, "ATI Radeon R200 BB"},
-	{0x1002, 0x4243, 0x3, "ATI Radeon R200 BC"},
-	{0x1002, 0x4336, 0x2, "ATI Radeon RS100"},
-	{0x1002, 0x4337, 0x2, "ATI Radeon RS200"},
-	{0x1002, 0x4437, 0x2, "ATI Radeon RS250"},
-	{0x1002, 0x4964, 0x2, "ATI Radeon RV250 Id"},
-	{0x1002, 0x4965, 0x2, "ATI Radeon RV250 Ie"},
-	{0x1002, 0x4966, 0x2, "ATI Radeon RV250 If"},
-	{0x1002, 0x4967, 0x2, "ATI Radeon R250 Ig"},
-	{0x1002, 0x4c45, 0x11, "ATI Rage 128 LE"},
-	{0x1002, 0x4c46, 0x1, "ATI Rage 128 LF"},
-	{0x1002, 0x4c57, 0x2, "ATI Radeon Mobiliy M7 RV200 LW (7500)"},
-	{0x1002, 0x4c58, 0x2, "ATI Radeon Mobiliy M7 RV200 LX (7500)"},
-	{0x1002, 0x4c59, 0x2, "ATI Radeon Mobility M6 LY"},
-	{0x1002, 0x4c5a, 0x2, "ATI Radeon Mobility M6 LZ"},
-	{0x1002, 0x4c64, 0x3, "ATI Radeon RV250 Ld"},
-	{0x1002, 0x4c65, 0x3, "ATI Radeon RV250 Le"},
-	{0x1002, 0x4c66, 0x3, "ATI Radeon Mobility M9 RV250 Lf"},
-	{0x1002, 0x4c67, 0x3, "ATI Radeon RV250 Lg"},
-	{0x1002, 0x4d46, 0x1, "ATI Rage 128 MF"},
-	{0x1002, 0x4d46, 0x1, "ATI Rage 128 ML"},
-	{0x1002, 0x4e44, 0x4, "ATI Radeon R300 ND"},
-	{0x1002, 0x4e45, 0x4, "ATI Radeon R300 NE"},
-	{0x1002, 0x4e46, 0x4, "ATI Radeon R300 NF"},
-	{0x1002, 0x4e47, 0x4, "ATI Radeon R300 NG"},
-	{0x1002, 0x4e48, 0x4, "ATI Radeon R350 NH"},
-	{0x1002, 0x4e49, 0x4, "ATI Radeon R350 NI"},
-	{0x1002, 0x4e4a, 0x4, "ATI Radeon R350 NJ"},
-	{0x1002, 0x4e4b, 0x4, "ATI Radeon R350 NK"},
-	{0x1002, 0x4e50, 0x4, "ATI Radeon Mobility RV350 NP"},
-	{0x1002, 0x4e51, 0x4, "ATI Radeon Mobility RV350 NQ"},
-	{0x1002, 0x4e52, 0x4, "ATI Radeon Mobility RV350 NR"},
-	{0x1002, 0x4e53, 0x4, "ATI Radeon Mobility RV350 NS"},
-	{0x1002, 0x4e54, 0x4, "ATI Radeon Mobility RV350 NT"},
-	{0x1002, 0x4e56, 0x4, "ATI Radeon Mobility RV350 NV"},
-	{0x1002, 0x5041, 0x1, "ATI Rage 128 PA"},
-	{0x1002, 0x5042, 0x1, "ATI Rage 128 PB"},
-	{0x1002, 0x5043, 0x1, "ATI Rage 128 PC"},
-	{0x1002, 0x5044, 0x11, "ATI Rage 128 PD"},
-	{0x1002, 0x5045, 0x1, "ATI Rage 128 PE"},
-	{0x1002, 0x5046, 0x1, "ATI Rage 128 PF"},
-	{0x1002, 0x5047, 0x1, "ATI Rage 128 PG"},
-	{0x1002, 0x5048, 0x1, "ATI Rage 128 PH"},
-	{0x1002, 0x5049, 0x1, "ATI Rage 128 PI"},
-	{0x1002, 0x504a, 0x1, "ATI Rage 128 PJ"},
-	{0x1002, 0x504b, 0x1, "ATI Rage 128 PK"},
-	{0x1002, 0x504c, 0x1, "ATI Rage 128 PL"},
-	{0x1002, 0x504d, 0x1, "ATI Rage 128 PM"},
-	{0x1002, 0x504e, 0x1, "ATI Rage 128 PN"},
-	{0x1002, 0x504f, 0x1, "ATI Rage 128 PO"},
-	{0x1002, 0x5050, 0x11, "ATI Rage 128 PP"},
-	{0x1002, 0x5051, 0x1, "ATI Rage 128 PQ"},
-	{0x1002, 0x5052, 0x11, "ATI Rage 128 PR"},
-	{0x1002, 0x5053, 0x1, "ATI Rage 128 PS"},
-	{0x1002, 0x5054, 0x1, "ATI Rage 128 PT"},
-	{0x1002, 0x5055, 0x1, "ATI Rage 128 PU"},
-	{0x1002, 0x5056, 0x1, "ATI Rage 128 PV"},
-	{0x1002, 0x5057, 0x1, "ATI Rage 128 PW"},
-	{0x1002, 0x5058, 0x1, "ATI Rage 128 PX"},
-	{0x1002, 0x5144, 0x2, "ATI Radeon R100 QD"},
-	{0x1002, 0x5145, 0x2, "ATI Radeon R100 QE"},
-	{0x1002, 0x5146, 0x2, "ATI Radeon R100 QF"},
-	{0x1002, 0x5147, 0x2, "ATI Radeon R100 QG"},
-	{0x1002, 0x5148, 0x3, "ATI Radeon R200 QH"},
-	{0x1002, 0x514c, 0x3, "ATI Radeon R200 QL"},
-	{0x1002, 0x514d, 0x3, "ATI Radeon R200 QM"},
-	{0x1002, 0x5157, 0x2, "ATI Radeon RV200 QW (7500)"},
-	{0x1002, 0x5158, 0x2, "ATI Radeon RV200 QX (7500)"},
-	{0x1002, 0x5159, 0x2, "ATI Radeon RV100 QY"},
-	{0x1002, 0x515a, 0x2, "ATI Radeon RV100 QZ"},
-	{0x1002, 0x5245, 0x11, "ATI Rage 128 RE"},
-	{0x1002, 0x5246, 0x1, "ATI Rage 128 RF"},
-	{0x1002, 0x5247, 0x1, "ATI Rage 128 RG"},
-	{0x1002, 0x524b, 0x11, "ATI Rage 128 RK"},
-	{0x1002, 0x524c, 0x1, "ATI Rage 128 RL"},
-	{0x1002, 0x5345, 0x1, "ATI Rage 128 SE"},
-	{0x1002, 0x5346, 0x1, "ATI Rage 128 SF"},
-	{0x1002, 0x5347, 0x1, "ATI Rage 128 SG"},
-	{0x1002, 0x5348, 0x1, "ATI Rage 128 SH"},
-	{0x1002, 0x534b, 0x1, "ATI Rage 128 SK"},
-	{0x1002, 0x534c, 0x1, "ATI Rage 128 SL"},
-	{0x1002, 0x534d, 0x1, "ATI Rage 128 SM"},
-	{0x1002, 0x534e, 0x1, "ATI Rage 128 SN"},
-	{0x1002, 0x5446, 0x1, "ATI Rage 128 TF"},
-	{0x1002, 0x544c, 0x1, "ATI Rage 128 TL"},
-	{0x1002, 0x5452, 0x1, "ATI Rage 128 TR"},
-	{0x1002, 0x5453, 0x1, "ATI Rage 128 TS"},
-	{0x1002, 0x5454, 0x1, "ATI Rage 128 TT"},
-	{0x1002, 0x5455, 0x1, "ATI Rage 128 TU"},
-	{0x1002, 0x5834, 0x3, "ATI Radeon RS300"},
-	{0x1002, 0x5835, 0x3, "ATI Radeon RS300 Mobility"},
-	{0x1002, 0x5941, 0x3, "ATI Radeon RV280 (9200)"},
-	{0x1002, 0x5961, 0x3, "ATI Radeon RV280 (9200 SE)"},
-	{0x1002, 0x5964, 0x3, "ATI Radeon RV280 (9200 SE)"},
-	{0x1002, 0x5c60, 0x3, "ATI Radeon RV280"},
-	{0x1002, 0x5c61, 0x3, "ATI Radeon RV280 Mobility"},
-	{0x1002, 0x5c62, 0x3, "ATI Radeon RV280"},
-	{0x1002, 0x5c63, 0x3, "ATI Radeon RV280 Mobility"},
-	{0x1002, 0x5c64, 0x3, "ATI Radeon RV280"},
-	{0, 0, 0, NULL}
-};
-
-static char *
-make_busid(KdCardAttr *attr)
-{
-	char *busid;
-	
-	busid = xalloc(20);
-	if (busid == NULL)
-		return NULL;
-	snprintf(busid, 20, "pci:%04x:%02x:%02x.%d", attr->domain, attr->bus, 
-	    attr->slot, attr->func);
-	return busid;
-}
-
-static Bool
-ATICardInit(KdCardInfo *card)
-{
-	ATICardInfo *atic;
-	int i;
-	Bool initialized = FALSE;
-
-	atic = xcalloc(sizeof(ATICardInfo), 1);
-	if (atic == NULL)
-		return FALSE;
-
-#ifdef KDRIVEFBDEV
-	if (!initialized && fbdevInitialize(card, &atic->backend_priv.fbdev)) {
-		atic->use_fbdev = TRUE;
-		initialized = TRUE;
-		atic->backend_funcs.cardfini = fbdevCardFini;
-		atic->backend_funcs.scrfini = fbdevScreenFini;
-		atic->backend_funcs.initScreen = fbdevInitScreen;
-		atic->backend_funcs.finishInitScreen = fbdevFinishInitScreen;
-		atic->backend_funcs.createRes = fbdevCreateResources;
-		atic->backend_funcs.preserve = fbdevPreserve;
-		atic->backend_funcs.restore = fbdevRestore;
-		atic->backend_funcs.dpms = fbdevDPMS;
-		atic->backend_funcs.enable = fbdevEnable;
-		atic->backend_funcs.disable = fbdevDisable;
-		atic->backend_funcs.getColors = fbdevGetColors;
-		atic->backend_funcs.putColors = fbdevPutColors;
-#ifdef RANDR
-		atic->backend_funcs.randrSetConfig = fbdevRandRSetConfig;
-#endif
-	}
-#endif
-#ifdef KDRIVEVESA
-	if (!initialized && vesaInitialize(card, &atic->backend_priv.vesa)) {
-		atic->use_vesa = TRUE;
-		initialized = TRUE;
-		atic->backend_funcs.cardfini = vesaCardFini;
-		atic->backend_funcs.scrfini = vesaScreenFini;
-		atic->backend_funcs.initScreen = vesaInitScreen;
-		atic->backend_funcs.finishInitScreen = vesaFinishInitScreen;
-		atic->backend_funcs.createRes = vesaCreateResources;
-		atic->backend_funcs.preserve = vesaPreserve;
-		atic->backend_funcs.restore = vesaRestore;
-		atic->backend_funcs.dpms = vesaDPMS;
-		atic->backend_funcs.enable = vesaEnable;
-		atic->backend_funcs.disable = vesaDisable;
-		atic->backend_funcs.getColors = vesaGetColors;
-		atic->backend_funcs.putColors = vesaPutColors;
-#ifdef RANDR
-		atic->backend_funcs.randrSetConfig = vesaRandRSetConfig;
-#endif
-	}
-#endif
-
-	if (!initialized || !ATIMapReg(card, atic)) {
-		xfree(atic);
-		return FALSE;
-	}
-
-	atic->busid = make_busid(&card->attr);
-	if (atic->busid == NULL) {
-		xfree(atic);
-		return FALSE;
-	}
-
-#ifdef USE_DRI
-	/* We demand identification by busid, not driver name */
-	atic->drmFd = drmOpen(NULL, atic->busid);
-	if (atic->drmFd < 0)
-		ErrorF("Failed to open DRM, DRI disabled.\n");
-#endif /* USE_DRI */
-
-	card->driver = atic;
-
-	for (i = 0; ati_pci_ids[i].name != NULL; i++) {
-		if (ati_pci_ids[i].device == card->attr.deviceID) {
-			atic->pci_id = &ati_pci_ids[i];
-			break;
-		}
-	}
-
-	if ((atic->pci_id->caps & CAP_SERIESMASK) != CAP_R128)
-		atic->is_radeon = TRUE;
-	if ((atic->pci_id->caps & CAP_SERIESMASK) == CAP_R100)
-		atic->is_r100 = TRUE;
-	if ((atic->pci_id->caps & CAP_SERIESMASK) == CAP_R200)
-		atic->is_r200 = TRUE;
-	if ((atic->pci_id->caps & CAP_SERIESMASK) == CAP_R300)
-		atic->is_r300 = TRUE;
-
-	atic->is_agp = ATIIsAGP(atic);
-
-	ErrorF("Using ATI card: %s (%s) at %s\n", atic->pci_id->name,
-	    atic->is_agp ? "AGP" : "PCI", atic->busid);
-
-	return TRUE;
-}
-
-static void
-ATICardFini(KdCardInfo *card)
-{
-	ATICardInfo *atic = (ATICardInfo *)card->driver;
-
-	ATIUnmapReg(card, atic);
-	atic->backend_funcs.cardfini(card);
-}
-
-/*
- * Once screen->off_screen_base is set, this function
- * allocates the remaining memory appropriately
- */
-
-static void
-ATISetOffscreen (KdScreenInfo *screen)
-{
-	ATICardInfo(screen);
-#if defined(USE_DRI) && defined(GLXEXT)
-	ATIScreenInfo *atis = (ATIScreenInfo *)screen->driver;
-	int l;
-#endif
-	int screen_size;
-	char *mmio = atic->reg_base;
-    
-	/* check (and adjust) pitch */
-	if (mmio)
-	{
-		int	byteStride = screen->fb[0].byteStride;
-		int	bitStride;
-		int	pixelStride;
-		int	bpp = screen->fb[0].bitsPerPixel;
-		
-		/*
-		 * Ensure frame buffer is correctly aligned
-		 */
-		if (byteStride & 0x3f)
-		{
-			byteStride = (byteStride + 0x3f) & ~0x3f;
-			bitStride = byteStride * 8;
-			pixelStride = bitStride / bpp;
-
-			screen->fb[0].byteStride = byteStride;
-			screen->fb[0].pixelStride = pixelStride;
-		}
-	}
-
-	screen_size = screen->fb[0].byteStride * screen->height;
-
-	screen->off_screen_base = screen_size;
-
-#if defined(USE_DRI) && defined(GLXEXT)
-	/* Reserve a static area for the back buffer the same size as the
-	 * visible screen.  XXX: This would be better initialized in ati_dri.c
-	 * when GLX is set up, but the offscreen memory manager's allocations
-	 * don't last through VT switches, while the kernel's understanding of
-	 * offscreen locations does.
-	 */
-	atis->frontOffset = 0;
-	atis->frontPitch = screen->fb[0].byteStride;
-
-	if (screen->off_screen_base + screen_size <= screen->memory_size) {
-		atis->backOffset = screen->off_screen_base;
-		atis->backPitch = screen->fb[0].byteStride;
-		screen->off_screen_base += screen_size;
-	}
-
-	/* Reserve the depth span for Rage 128 */
-	if (!atic->is_radeon && screen->off_screen_base +
-	    screen->fb[0].byteStride <= screen->memory_size) {
-		atis->spanOffset = screen->off_screen_base;
-		screen->off_screen_base += screen->fb[0].byteStride;
-	}
-
-	/* Reserve the static depth buffer, which happens to be the same
-	 * bitsPerPixel as the screen.
-	 */
-	if (screen->off_screen_base + screen_size <= screen->memory_size) {
-		atis->depthOffset = screen->off_screen_base;
-		atis->depthPitch = screen->fb[0].byteStride;
-		screen->off_screen_base += screen_size;
-	}
-
-	/* Reserve approx. half of remaining offscreen memory for local
-	 * textures.  Round down to a whole number of texture regions.
-	 */
-	atis->textureSize = (screen->memory_size - screen->off_screen_base) / 2;
-	l = ATILog2(atis->textureSize / ATI_NR_TEX_REGIONS);
-	if (l < ATI_LOG_TEX_GRANULARITY)
-		l = ATI_LOG_TEX_GRANULARITY;
-	atis->textureSize = (atis->textureSize >> l) << l;
-	if (atis->textureSize >= 512 * 1024) {
-		atis->textureOffset = screen->off_screen_base;
-		screen->off_screen_base += atis->textureSize;
-	} else {
-		/* Minimum texture size is for 2 256x256x32bpp textures */
-		atis->textureSize = 0;
-	}
-#endif /* USE_DRI && GLXEXT */
-}
-
-static void
-ATISetPitch (KdScreenInfo *screen)
-{
-	ATICardInfo(screen);
-#if defined(USE_DRI) && defined(GLXEXT)
-	ATIScreenInfo *atis = (ATIScreenInfo *)screen->driver;
-	int l;
-#endif
-	char *mmio = atic->reg_base;
-    
-	/* check (and adjust) pitch for radeon */
-	if (mmio)
-	{
-		int	byteStride = screen->fb[0].byteStride;
-		int	bitStride;
-		int	pixelStride;
-		int	bpp = screen->fb[0].bitsPerPixel;
-		CARD32	crtc_pitch;
-		CARD32	crtc2_pitch;
-#if 0
-		CARD32	crtc_ext_cntl;
-		CARD32	dac_cntl;
-#endif
-		bitStride = byteStride * 8;
-		pixelStride = bitStride / bpp;
-
-		crtc_pitch = (pixelStride >> 3);
-		crtc_pitch |= crtc_pitch << 16;
-		crtc2_pitch = (pixelStride >> 3);
-		crtc2_pitch |= crtc2_pitch << 16;
-#if 0
-		crtc_ext_cntl = MMIO_IN32 (mmio, ATI_REG_CRTC_EXT_CNTL);
-		dac_cntl = MMIO_IN32 (mmio, ATI_REG_DAC_CNTL);
-		/* Turn off the screen */
-		MMIO_OUT32 (mmio, ATI_REG_CRTC_EXT_CNTL,
-			    crtc_ext_cntl |
-			    ATI_CRTC_VSYNC_DIS |
-			    ATI_CRTC_HSYNC_DIS |
-			    ATI_CRTC_DISPLAY_DIS);
-		MMIO_OUT32 (mmio, ATI_REG_DAC_CNTL,
-			    dac_cntl |
-			    ATI_DAC_RANGE_CNTL |
-			    ATI_DAC_BLANKING);
-#endif
-		MMIO_OUT32 (mmio, ATI_REG_CRTC_PITCH, crtc_pitch);
-		MMIO_OUT32 (mmio, ATI_REG_CRTC2_PITCH, crtc2_pitch);
-#if 0
-		/* Turn the screen back on */
-		MMIO_OUT32 (mmio, ATI_REG_CRTC_EXT_CNTL,
-			    crtc_ext_cntl);
-		MMIO_OUT32 (mmio, ATI_REG_DAC_CNTL,
-			    dac_cntl);
-#endif
-	}
-}
-
-static Bool
-ATIScreenInit(KdScreenInfo *screen)
-{
-	ATIScreenInfo *atis;
-	ATICardInfo(screen);
-	Bool success = FALSE;
-
-	atis = xcalloc(sizeof(ATIScreenInfo), 1);
-	if (atis == NULL)
-		return FALSE;
-
-	atis->atic = atic;
-	atis->screen = screen;
-	screen->driver = atis;
-
-	if (screen->fb[0].depth == 0)
-		screen->fb[0].depth = 16;
-#ifdef KDRIVEFBDEV
-	if (atic->use_fbdev) {
-		success = fbdevScreenInitialize(screen,
-						&atis->backend_priv.fbdev);
-	}
-#endif
-#ifdef KDRIVEVESA
-	if (atic->use_vesa) {
-		success = vesaScreenInitialize(screen,
-					       &atis->backend_priv.vesa);
-	}
-#endif
-
-	if (!success) {
-		screen->driver = NULL;
-		xfree(atis);
-		return FALSE;
-	}
-
-	ATISetOffscreen (screen);
-
-	return TRUE;
-}
-
-#ifdef RANDR
-static Bool
-ATIRandRSetConfig (ScreenPtr		pScreen,
-		   Rotation		randr,
-		   int			rate,
-		   RRScreenSizePtr	pSize)
-{
-	KdScreenPriv(pScreen);
-	KdScreenInfo *screen = pScreenPriv->screen;
-	ATICardInfo *atic = screen->card->driver;
-	Bool ret;
-
-	ATIDrawDisable (pScreen);
-	ret = atic->backend_funcs.randrSetConfig(pScreen, randr, rate, pSize);
-	ATISetOffscreen (screen);
-	ATISetPitch (screen);
-	/*
-	 * Set frame buffer mapping
-	 */
-	(*pScreen->ModifyPixmapHeader) (fbGetScreenPixmap (pScreen),
-					pScreen->width,
-					pScreen->height,
-					screen->fb[0].depth,
-					screen->fb[0].bitsPerPixel,
-					screen->fb[0].byteStride,
-					screen->fb[0].frameBuffer);
-
-	ATIDrawEnable (pScreen);
-	return ret;
-}
-
-static Bool
-ATIRandRInit (ScreenPtr pScreen)
-{
-    rrScrPrivPtr    pScrPriv;
-    
-    pScrPriv = rrGetScrPriv(pScreen);
-    pScrPriv->rrSetConfig = ATIRandRSetConfig;
-    return TRUE;
-}
-#endif
-
-static void
-ATIScreenFini(KdScreenInfo *screen)
-{
-	ATIScreenInfo *atis = (ATIScreenInfo *)screen->driver;
-	ATICardInfo *atic = screen->card->driver;
-
-#ifdef XV
-	ATIFiniVideo(screen->pScreen);
-#endif
-
-	atic->backend_funcs.scrfini(screen);
-	xfree(atis);
-	screen->driver = 0;
-}
-
-Bool
-ATIMapReg(KdCardInfo *card, ATICardInfo *atic)
-{
-	atic->reg_base = (char *)KdMapDevice(ATI_REG_BASE(card),
-	    ATI_REG_SIZE(card));
-
-	if (atic->reg_base == NULL)
-		return FALSE;
-
-	KdSetMappedMode(ATI_REG_BASE(card), ATI_REG_SIZE(card),
-	    KD_MAPPED_MODE_REGISTERS);
-
-	return TRUE;
-}
-
-void
-ATIUnmapReg(KdCardInfo *card, ATICardInfo *atic)
-{
-	if (atic->reg_base) {
-		KdResetMappedMode(ATI_REG_BASE(card), ATI_REG_SIZE(card),
-		    KD_MAPPED_MODE_REGISTERS);
-		KdUnmapDevice((void *)atic->reg_base, ATI_REG_SIZE(card));
-		atic->reg_base = 0;
-	}
-}
-
-static Bool
-ATIInitScreen(ScreenPtr pScreen)
-{
-	KdScreenPriv(pScreen);
-	ATICardInfo(pScreenPriv);
-
-#ifdef XV
-	ATIInitVideo(pScreen);
-#endif
-	return atic->backend_funcs.initScreen(pScreen);
-}
-
-static Bool
-ATIFinishInitScreen(ScreenPtr pScreen)
-{
-	KdScreenPriv(pScreen);
-	ATICardInfo(pScreenPriv);
-
-	if (!atic->backend_funcs.finishInitScreen(pScreen))
-		return FALSE;
-#ifdef RANDR
-	if (!ATIRandRInit (pScreen))
-		return FALSE;
-#endif
-	return TRUE;
-}
-
-static Bool
-ATICreateResources(ScreenPtr pScreen)
-{
-	KdScreenPriv(pScreen);
-	ATICardInfo(pScreenPriv);
-
-	return atic->backend_funcs.createRes(pScreen);
-}
-
-static void
-ATIPreserve(KdCardInfo *card)
-{
-	ATICardInfo *atic = card->driver;
-	char *mmio = atic->reg_base;
-
-	atic->backend_funcs.preserve(card);
-	if (atic->is_radeon && mmio)
-	{
-		atic->crtc_pitch = MMIO_IN32(mmio, ATI_REG_CRTC_PITCH);
-		atic->crtc2_pitch = MMIO_IN32(mmio, ATI_REG_CRTC2_PITCH);
-		
-	}
-}
-
-static void
-ATIRestore(KdCardInfo *card)
-{
-	ATICardInfo *atic = card->driver;
-	char *mmio = atic->reg_base;
-
-	if (mmio)
-	{
-		MMIO_OUT32(mmio, ATI_REG_CRTC_PITCH, atic->crtc_pitch);
-		MMIO_OUT32(mmio, ATI_REG_CRTC2_PITCH, atic->crtc2_pitch);
-	}
-	ATIUnmapReg(card, atic);
-
-	atic->backend_funcs.restore(card);
-}
-
-static Bool
-ATIDPMS(ScreenPtr pScreen, int mode)
-{
-	KdScreenPriv(pScreen);
-	ATICardInfo(pScreenPriv);
-
-	return atic->backend_funcs.dpms(pScreen, mode);
-}
-
-static Bool
-ATIEnable(ScreenPtr pScreen)
-{
-	KdScreenPriv(pScreen);
-	ATICardInfo(pScreenPriv);
-
-	if (!atic->backend_funcs.enable(pScreen))
-		return FALSE;
-
-	if ((atic->reg_base == NULL) && !ATIMapReg(pScreenPriv->screen->card,
-	    atic))
-		return FALSE;
-
-	ATISetOffscreen (pScreenPriv->screen);
-
-	ATISetPitch (pScreenPriv->screen);
-
-	return TRUE;
-}
-
-static void
-ATIDisable(ScreenPtr pScreen)
-{
-	KdScreenPriv(pScreen);
-#if defined(USE_DRI) && defined(GLXEXT)
-	ATIScreenInfo(pScreenPriv);
-#endif /* USE_DRI && GLXEXT */
-	ATICardInfo(pScreenPriv);
-
-	ATIUnmapReg(pScreenPriv->card, atic);
-
-	atic->backend_funcs.disable(pScreen);
-}
-
-static void
-ATIGetColors(ScreenPtr pScreen, int fb, int n, xColorItem *pdefs)
-{
-	KdScreenPriv(pScreen);
-	ATICardInfo(pScreenPriv);
-
-	atic->backend_funcs.getColors(pScreen, fb, n, pdefs);
-}
-
-static void
-ATIPutColors(ScreenPtr pScreen, int fb, int n, xColorItem *pdefs)
-{
-	KdScreenPriv(pScreen);
-	ATICardInfo(pScreenPriv);
-
-	atic->backend_funcs.putColors(pScreen, fb, n, pdefs);
-}
-
-/* Compute log base 2 of val. */
-int
-ATILog2(int val)
-{
-	int bits;
-
-	for (bits = 0; val != 0; val >>= 1, ++bits)
-		;
-	return bits - 1;
-}
-
-static Bool
-ATIIsAGP(ATICardInfo *atic)
-{
-	char *mmio = atic->reg_base;
-	CARD32 cap_ptr, cap_id;
-
-	if (mmio == NULL)
-		return FALSE;
-
-	if (MMIO_IN32(mmio, ATI_REG_PCI_CFG_STATUS) & ATI_CAP_LIST) {
-		cap_ptr = MMIO_IN32(mmio, ATI_REG_PCI_CFG_CAPABILITIES_PTR) &
-		    ATI_CAP_PTR_MASK;
-		while (cap_ptr != ATI_CAP_ID_NULL) {
-			cap_id = MMIO_IN32(mmio, ATI_PCI_CFG_OFFSET + cap_ptr);
-			if ((cap_id & 0xff) == ATI_CAP_ID_AGP)
-				return TRUE;
-			cap_ptr = (cap_id >> 8) & ATI_CAP_PTR_MASK;
-		}
-	}
-
-	return FALSE;
-}
-
-/* This function is required to work around a hardware bug in some (all?)
- * revisions of the R300.  This workaround should be called after every
- * CLOCK_CNTL_INDEX register access.  If not, register reads afterward
- * may not be correct.
- */
-void R300CGWorkaround(ATIScreenInfo *atis) {
-	ATICardInfo *atic = atis->atic;
-	char *mmio = atic->reg_base;
-	CARD32 save;
-
-	save = MMIO_IN32(mmio, ATI_REG_CLOCK_CNTL_INDEX);
-	MMIO_OUT32(mmio, ATI_REG_CLOCK_CNTL_INDEX, save & ~(0x3f |
-	    ATI_PLL_WR_EN));
-	MMIO_IN32(mmio, ATI_REG_CLOCK_CNTL_INDEX);
-	MMIO_OUT32(mmio, ATI_REG_CLOCK_CNTL_INDEX, save);
-}
-
-KdCardFuncs ATIFuncs = {
-	ATICardInit,		/* cardinit */
-	ATIScreenInit,		/* scrinit */
-	ATIInitScreen,		/* initScreen */
-	ATIFinishInitScreen,	/* finishInitScreen */
-	ATICreateResources,	/* createRes */
-	ATIPreserve,		/* preserve */
-	ATIEnable,		/* enable */
-	ATIDPMS,		/* dpms */
-	ATIDisable,		/* disable */
-	ATIRestore,		/* restore */
-	ATIScreenFini,		/* scrfini */
-	ATICardFini,		/* cardfini */
-
-	ATICursorInit,		/* initCursor */
-	ATICursorEnable,	/* enableCursor */
-	ATICursorDisable,	/* disableCursor */
-	ATICursorFini,		/* finiCursor */
-	ATIRecolorCursor,	/* recolorCursor */
-
-	ATIDrawInit,		/* initAccel */
-	ATIDrawEnable,		/* enableAccel */
-	ATIDrawDisable,		/* disableAccel */
-	ATIDrawFini,		/* finiAccel */
-
-	ATIGetColors,		/* getColors */
-	ATIPutColors,		/* putColors */
-};
diff --git a/hw/kdrive/ati/ati.h b/hw/kdrive/ati/ati.h
deleted file mode 100644
index 3ff3e3f..0000000
--- a/hw/kdrive/ati/ati.h
+++ /dev/null
@@ -1,409 +0,0 @@
-/*
- * Copyright © 2003 Eric Anholt
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Eric Anholt not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  Eric Anholt makes no
- * representations about the suitability of this software for any purpose.  It
- * is provided "as is" without express or implied warranty.
- *
- * ERIC ANHOLT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL ERIC ANHOLT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifndef _ATI_H_
-#define _ATI_H_
-
-#ifdef HAVE_CONFIG_H
-#include <kdrive-config.h>
-#endif
-
-#ifdef KDRIVEFBDEV
-#include <fbdev.h>
-#endif
-#ifdef KDRIVEVESA
-#include <vesa.h>
-#endif
-
-#include "kxv.h"
-
-#undef XF86DRI
-#ifdef XF86DRI
-#define USE_DRI
-#include "xf86drm.h"
-#include "dri.h"
-#ifdef GLXEXT
-#include "GL/glxint.h"
-#include "GL/glxtokens.h"
-#include "ati_dripriv.h"
-#endif
-#endif
-
-#define ATI_REG_BASE(c)		((c)->attr.address[1])
-#define ATI_REG_SIZE(c)		(0x4000)
-
-#ifdef __powerpc__
-
-static __inline__ void
-MMIO_OUT32(__volatile__ void *base, const unsigned long offset,
-	   const unsigned int val)
-{
-	__asm__ __volatile__(
-			"stwbrx %1,%2,%3\n\t"
-			"eieio"
-			: "=m" (*((volatile unsigned char *)base+offset))
-			: "r" (val), "b" (base), "r" (offset));
-}
-
-static __inline__ CARD32
-MMIO_IN32(__volatile__ void *base, const unsigned long offset)
-{
-	register unsigned int val;
-	__asm__ __volatile__(
-			"lwbrx %0,%1,%2\n\t"
-			"eieio"
-			: "=r" (val)
-			: "b" (base), "r" (offset),
-			"m" (*((volatile unsigned char *)base+offset)));
-	return val;
-}
-
-#else
-
-#define MMIO_OUT32(mmio, a, v)		(*(VOL32 *)((mmio) + (a)) = (v))
-#define MMIO_IN32(mmio, a)		(*(VOL32 *)((mmio) + (a)))
-
-#endif
-
-#define MMIO_OUT8(mmio, a, v)		(*(VOL8 *)((mmio) + (a)) = (v))
-#define MMIO_IN8(mmio, a, v)		(*(VOL8 *)((mmio) + (a)))
-
-#define INPLL(mmio, addr) \
-	(MMIO_OUT8(mmio, ATI_REG_CLOCK_CNTL_INDEX, addr),		\
-	 MMIO_IN32(mmio, ATI_REG_CLOCK_CNTL_DATA))
-
-#define OUTPLL(mmio, addr, val) do {					\
-	MMIO_OUT8(mmio, ATI_REG_CLOCK_CNTL_INDEX, (addr) | ATI_PLL_WR_EN); \
-	MMIO_OUT32(mmio, ATI_REG_CLOCK_CNTL_DATA, val);			\
-} while (0)
-
-typedef volatile CARD8	VOL8;
-typedef volatile CARD16	VOL16;
-typedef volatile CARD32	VOL32;
-
-struct pci_id_entry {
-	CARD16 vendor;
-	CARD16 device;
-	CARD8 caps;
-	char *name;
-};
-
-struct backend_funcs {
-	void    (*cardfini)(KdCardInfo *);
-	void    (*scrfini)(KdScreenInfo *);
-	Bool    (*initScreen)(ScreenPtr);
-	Bool    (*finishInitScreen)(ScreenPtr pScreen);
-	Bool	(*createRes)(ScreenPtr);
-	void    (*preserve)(KdCardInfo *);
-	void    (*restore)(KdCardInfo *);
-	Bool    (*dpms)(ScreenPtr, int);
-	Bool    (*enable)(ScreenPtr);
-	void    (*disable)(ScreenPtr);
-	void    (*getColors)(ScreenPtr, int, int, xColorItem *);
-	void    (*putColors)(ScreenPtr, int, int, xColorItem *);
-#ifdef RANDR
-	Bool	(*randrSetConfig) (ScreenPtr, Rotation, int, RRScreenSizePtr);
-#endif
-};
-
-typedef struct _ATICardInfo {
-	union {
-#ifdef KDRIVEFBDEV
-		FbdevPriv fbdev;
-#endif
-#ifdef KDRIVEVESA
-		VesaCardPrivRec vesa;
-#endif
-	} backend_priv;
-	struct backend_funcs backend_funcs;
-
-	struct pci_id_entry *pci_id;
-	char *reg_base;
-	Bool is_radeon;
-	Bool is_r100;
-	Bool is_r200;
-	Bool is_r300;
-	Bool is_agp;
-	char *busid;
-	CARD32 crtc_pitch;
-	CARD32 crtc2_pitch;
-#ifdef USE_DRI
-	int drmFd;
-#endif /* USE_DRI */
-	Bool use_fbdev, use_vesa;
-} ATICardInfo;
-
-#define getATICardInfo(kd)	((ATICardInfo *) ((kd)->card->driver))
-#define ATICardInfo(kd)		ATICardInfo *atic = getATICardInfo(kd)
-
-typedef struct _ATICursor {
-	int		width, height;
-	int		xhot, yhot;
-	
-	Bool		has_cursor;
-	CursorPtr	pCursor;
-	Pixel		source, mask;
-	KdOffscreenArea *area;
-} ATICursor;
-
-typedef struct _ATIPortPriv {
-	int brightness;
-	int saturation;
-	RegionRec clip;
-	CARD32 size;
-	KdOffscreenArea *off_screen;
-	DrawablePtr pDraw;
-	PixmapPtr pPixmap;
-
-	CARD32 src_offset;
-	CARD32 src_pitch;
-	CARD8 *src_addr;
-
-	int id;
-	int src_x1, src_y1, src_x2, src_y2;
-	int dst_x1, dst_y1, dst_x2, dst_y2;
-	int src_w, src_h, dst_w, dst_h;
-} ATIPortPrivRec, *ATIPortPrivPtr;
-
-typedef struct _dmaBuf {
-	int size;
-	int used;
-	void *address;
-#ifdef USE_DRI
-	drmBufPtr drmBuf;
-#endif
-} dmaBuf;
-
-typedef struct _ATIScreenInfo {
-	union {
-#ifdef KDRIVEFBDEV
-		FbdevScrPriv fbdev;
-#endif
-#ifdef KDRIVEVESA
-		VesaScreenPrivRec vesa;
-#endif
-	} backend_priv;
-	KaaScreenInfoRec kaa;
-
-	ATICardInfo *atic;
-	KdScreenInfo *screen;
-
-	int		scratch_offset;
-	int		scratch_next;
-	KdOffscreenArea *scratch_area;
-
-	ATICursor	cursor;
-
-	KdVideoAdaptorPtr pAdaptor;
-	int		num_texture_ports;
-
-	Bool		using_pio;	/* If we use decode DMA packets to MMIO. */
-	Bool		using_pseudo;	/* If we use MMIO to submit DMA packets. */
-	Bool		using_dma;	/* If we use non-DRI DMA to submit packets. */
-	Bool		using_dri;	/* If we use the DRM for DMA. */
-	Bool		using_agp;	/* If we are using AGP or not for DMA. */
-
-	KdOffscreenArea *dma_space;	/* For "DMA" from framebuffer. */
-	void		*agp_addr;	/* Mapped AGP aperture */
-	int		agp_size;
-	int		agp_key;	/* Key of AGP memory for DMA */
-	CARD32		*ring_addr;	/* Beginning of ring buffer. */
-	int		ring_write;	/* Index of write ptr in ring. */
-	int		ring_read;	/* Index of read ptr in ring. */
-	int		ring_len;
-
-
-	dmaBuf		*indirectBuffer;
-	int		indirectStart;
-
-	int		mmio_avail;
-	int		cce_pri_size;
-	int		cce_pri_avail;
-
-#ifdef USE_DRI
-	Bool		dma_started;
-
-	drmSize         registerSize;
-	drmHandle       registerHandle;
-	drmHandle       fbHandle;
-
-	drmSize		gartSize;
-	drmHandle	agpMemHandle;		/* Handle from drmAgpAlloc */
-	unsigned long	gartOffset;
-	unsigned char	*AGP;			/* Map */
-	int		agpMode;
-	drmSize         pciSize;
-	drmHandle       pciMemHandle;
-
-	/* ring buffer data */
-	unsigned long	ringStart;		/* Offset into AGP space */
-	drmHandle	ringHandle;		/* Handle from drmAddMap */
-	drmSize		ringMapSize;		/* Size of map */
-	int		ringSize;		/* Size of ring (MB) */
-	unsigned char	*ring;			/* Map */
-
-	unsigned long	ringReadOffset;		/* Offset into AGP space */
-	drmHandle	ringReadPtrHandle;	/* Handle from drmAddMap */
-	drmSize		ringReadMapSize;	/* Size of map */
-	unsigned char	*ringReadPtr;		/* Map */
-
-	/* vertex/indirect buffer data */
-	unsigned long	bufStart;		/* Offset into AGP space */
-	drmHandle	bufHandle;		/* Handle from drmAddMap */
-	drmSize		bufMapSize;		/* Size of map */
-	int		bufSize;		/* Size of buffers (MB) */
-	unsigned char	*buf;			/* Map */
-	int		bufNumBufs;		/* Number of buffers */
-	drmBufMapPtr	buffers;		/* Buffer map */
-	
-	/* AGP Texture data */
-	unsigned long	gartTexStart;		/* Offset into AGP space */
-	drmHandle	gartTexHandle;		/* Handle from drmAddMap */
-	drmSize		gartTexMapSize;		/* Size of map */
-	int		gartTexSize;		/* Size of AGP tex space (MB) */
-	unsigned char	*gartTex;		/* Map */
-	int		log2GARTTexGran;
-
-	int		DMAusecTimeout;   /* CCE timeout in usecs */
-
-	/* DRI screen private data */	
-	int		frontOffset;
-	int		frontPitch;
-	int		backOffset;
-	int		backPitch;
-	int		depthOffset;
-	int		depthPitch;
-	int		spanOffset;
-	int		textureOffset;
-	int		textureSize;
-	int		log2TexGran;
-
-	int		irqEnabled;
-
-	int		serverContext;
-
-	DRIInfoPtr	pDRIInfo;
-#ifdef GLXEXT
-	int		numVisualConfigs;
-	__GLXvisualConfig *pVisualConfigs;
-	ATIConfigPrivPtr pVisualConfigsPriv;
-#endif /* GLXEXT */
-#endif /* USE_DRI */
-} ATIScreenInfo;
-
-#define getATIScreenInfo(kd)	((ATIScreenInfo *) ((kd)->screen->driver))
-#define ATIScreenInfo(kd)	ATIScreenInfo *atis = getATIScreenInfo(kd)
-
-typedef union { float f; CARD32 i; } fi_type;
-
-/* Surely there's a better way to go about this */
-static inline CARD32
-ATIFloatAsInt(float val)
-{
-	fi_type fi;
-
-	fi.f = val;
-	return fi.i;
-}
-
-#define GET_FLOAT_BITS(x) ATIFloatAsInt(x)
-
-/* ati.c */
-Bool
-ATIMapReg(KdCardInfo *card, ATICardInfo *atic);
-
-void
-ATIUnmapReg(KdCardInfo *card, ATICardInfo *atic);
-
-void
-R300CGWorkaround(ATIScreenInfo *atis);
-
-/* ati_draw.c */
-void
-ATIDrawSetup(ScreenPtr pScreen);
-
-Bool
-ATIDrawInit(ScreenPtr pScreen);
-
-void
-ATIDrawEnable(ScreenPtr pScreen);
-
-void
-ATIDrawDisable(ScreenPtr pScreen);
-
-void
-ATIDrawFini(ScreenPtr pScreen);
-
-/* ati_dri.c */
-#ifdef USE_DRI
-Bool
-ATIDRIScreenInit(ScreenPtr pScreen);
-
-void
-ATIDRICloseScreen(ScreenPtr pScreen);
-
-void
-ATIDRIDMAStart(ATIScreenInfo *atis);
-
-void
-ATIDRIDMAStop(ATIScreenInfo *atis);
-
-void
-ATIDRIDMAReset(ATIScreenInfo *atis);
-
-void
-ATIDRIDispatchIndirect(ATIScreenInfo *atis, Bool discard);
-
-drmBufPtr
-ATIDRIGetBuffer(ATIScreenInfo *atis);
-
-#endif /* USE_DRI */
-
-/* ati_cursor.c */
-Bool
-ATICursorInit(ScreenPtr pScreen);
-
-void
-ATICursorEnable(ScreenPtr pScreen);
-
-void
-ATICursorDisable(ScreenPtr pScreen);
-
-void
-ATICursorFini(ScreenPtr pScreen);
-
-void
-ATIRecolorCursor(ScreenPtr pScreen, int ndef, xColorItem *pdef);
-
-int
-ATILog2(int val);
-
-/* ati_video.c */
-Bool
-ATIInitVideo(ScreenPtr pScreen);
-
-void
-ATIFiniVideo(ScreenPtr pScreen);
-
-extern KdCardFuncs ATIFuncs;
-
-#endif /* _ATI_H_ */
diff --git a/hw/kdrive/ati/ati_cursor.c b/hw/kdrive/ati/ati_cursor.c
deleted file mode 100644
index d2ce686..0000000
--- a/hw/kdrive/ati/ati_cursor.c
+++ /dev/null
@@ -1,559 +0,0 @@
-/*
- * Copyright © 2004 Eric Anholt
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Eric Anholt not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  Eric Anholt makes no
- * representations about the suitability of this software for any purpose.  It
- * is provided "as is" without express or implied warranty.
- *
- * ERIC ANHOLT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL ERIC ANHOLT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <kdrive-config.h>
-#endif
-#include "ati.h"
-#include "ati_reg.h"
-#include "cursorstr.h"
-#include "ati_draw.h"
-
-static void
-ATIMoveCursor(ScreenPtr pScreen, int x, int y)
-{
-	KdScreenPriv(pScreen);
-	ATICardInfo(pScreenPriv);
-	ATIScreenInfo(pScreenPriv);
-	ATICursor *pCurPriv = &atis->cursor;
-	CARD16 xoff, yoff;
-	char *mmio = atic->reg_base;
-	int stride = atic->is_radeon ? 256 : 16;
-
-	if (!pCurPriv->has_cursor)
-		return;
-
-	if (!pScreenPriv->enabled)
-		return;
-
-	x -= pCurPriv->xhot;
-	xoff = 0;
-	if (x < 0) {
-		xoff = -x;
-		x = 0;
-	}
-	y -= pCurPriv->yhot;
-	yoff = 0;
-	if (y < 0) {
-		yoff = -y;
-		y = 0;
-	}
-
-	MMIO_OUT32(mmio, ATI_REG_CUR_HORZ_VERT_OFF, ATI_CUR_LOCK |
-	    (xoff << 16) | yoff);
-	MMIO_OUT32(mmio, ATI_REG_CUR_HORZ_VERT_POSN, ATI_CUR_LOCK |
-	    (x << 16) | y);
-	MMIO_OUT32(mmio, ATI_REG_CUR_OFFSET, (pCurPriv->area->offset + yoff *
-	    stride));
-}
-
-static void
-ClassicAllocCursorColors(ScreenPtr pScreen)
-{
-	KdScreenPriv(pScreen);
-	ATIScreenInfo(pScreenPriv);
-	ATICursor *pCurPriv = &atis->cursor;
-	CursorPtr pCursor = pCurPriv->pCursor;
-
-	KdAllocateCursorPixels(pScreen, 0, pCursor, &pCurPriv->source,
-	    &pCurPriv->mask);
-	switch (pScreenPriv->screen->fb[0].bitsPerPixel) {
-	case 4:
-		pCurPriv->source |= pCurPriv->source << 4;
-		pCurPriv->mask |= pCurPriv->mask << 4;
-		/* FALLTHROUGH */
-	case 8:
-		pCurPriv->source |= pCurPriv->source << 8;
-		pCurPriv->mask |= pCurPriv->mask << 8;
-		/* FALLTHROUGH */
-	case 16:
-		pCurPriv->source |= pCurPriv->source << 16;
-		pCurPriv->mask |= pCurPriv->mask << 16;
-	}
-}
-
-static void
-ClassicSetCursorColors(ScreenPtr pScreen)
-{
-	KdScreenPriv(pScreen);
-	ATICardInfo(pScreenPriv);
-	ATIScreenInfo(pScreenPriv);
-	ATICursor *pCurPriv = &atis->cursor;
-	char *mmio = atic->reg_base;
-
-	MMIO_OUT32(mmio, ATI_REG_CUR_CLR0, pCurPriv->mask);
-	MMIO_OUT32(mmio, ATI_REG_CUR_CLR1, pCurPriv->source);
-}
-
-static void
-ClassicRecolorCursor(ScreenPtr pScreen, int ndef, xColorItem *pdef)
-{
-	KdScreenPriv(pScreen);
-	ATIScreenInfo(pScreenPriv);
-	ATICursor *pCurPriv = &atis->cursor;
-	CursorPtr pCursor = pCurPriv->pCursor;
-
-	if (!pCurPriv->has_cursor || !pCursor)
-		return;
-
-	if (!pScreenPriv->enabled)
-		return;
-
-	if (pdef) { 
-		while (ndef != 0) {
-			if (pdef->pixel == pCurPriv->source || 
-			    pdef->pixel == pCurPriv->mask)
-				break;
-			ndef--;
-		}
-
-		if (ndef == 0)
-			return;
-	}
-	ClassicAllocCursorColors(pScreen);
-	ClassicSetCursorColors(pScreen);
-}
-
-#define InvertBits32(v) do { \
-	v = ((v & 0x55555555) << 1) | ((v >> 1) & 0x55555555); \
-	v = ((v & 0x33333333) << 2) | ((v >> 2) & 0x33333333); \
-	v = ((v & 0x0f0f0f0f) << 4) | ((v >> 4) & 0x0f0f0f0f); \
-} while (0)
-
-static void
-ClassicLoadCursor(ScreenPtr pScreen)
-{
-	KdScreenPriv(pScreen);
-	ATICardInfo(pScreenPriv);
-	ATIScreenInfo(pScreenPriv);
-	ATICursor *pCurPriv = &atis->cursor;
-	CursorPtr pCursor = pCurPriv->pCursor;
-	CursorBitsPtr bits = pCursor->bits;
-	int h;
-	CARD32 *ram, *msk, *mskLine, *src, *srcLine;
-	int i;
-	int lwsrc;
-	CARD32 tmp;
-	char *mmio = atic->reg_base;
-
-	ClassicAllocCursorColors(pScreen);
-
-	pCurPriv->pCursor = pCursor;
-	pCurPriv->xhot = pCursor->bits->xhot;
-	pCurPriv->yhot = pCursor->bits->yhot;
-
-	/* Stick new image into cursor memory */
-	ram = (CARD32 *)(pScreenPriv->screen->memory_base +
-	    pCurPriv->area->offset);
-	mskLine = (CARD32 *)bits->mask;
-	srcLine = (CARD32 *)bits->source;
-
-	h = bits->height;
-	if (h > ATI_CURSOR_HEIGHT)
-		h = ATI_CURSOR_HEIGHT;
-
-	lwsrc = BitmapBytePad(bits->width) / 4;		/* words per line */
-
-	tmp = MMIO_IN32(mmio, ATI_REG_GEN_CNTL);
-	MMIO_OUT32(mmio, ATI_REG_GEN_CNTL, tmp & ~ATI_CRTC_CUR_EN);
-
-	for (i = 0; i < ATI_CURSOR_HEIGHT; i++) {
-		CARD32 m1, m2, s1, s2;
-
-		msk = mskLine;
-		src = srcLine;
-		mskLine += lwsrc;
-		srcLine += lwsrc;
-
-		if (i < h && 0 < lwsrc) {
-			m1 = ~*msk++;
-			s1 = *src++;
-			InvertBits32(m1);
-			InvertBits32(s1);
-		} else {
-			m1 = 0xffffffff;
-			s1 = 0x0;
-		}
-		if (i < h && 1 < lwsrc) {
-			m2 = ~*msk++;
-			s2 = *src++;
-			InvertBits32(m2);
-			InvertBits32(s2);
-		} else {
-			m2 = 0xffffffff;
-			s2 = 0x0;
-		}
-
-		*ram++ = m1;
-		*ram++ = m2;
-		*ram++ = s1;
-		*ram++ = s2;
-	}
-
-	/* Not sure why this is necessary, but it prevents some cursor
-	 * corruption.  Not even all of it.
-	 */
-	for (i = 0; i < ATI_CURSOR_HEIGHT; i++) {
-		*ram++ = 0xffffffff;
-		*ram++ = 0xffffffff;
-		*ram++ = 0x0;
-		*ram++ = 0x0;
-	}
-
-	/* Enable the cursor */
-	tmp = MMIO_IN32(mmio, ATI_REG_GEN_CNTL);
-	MMIO_OUT32(mmio, ATI_REG_GEN_CNTL, tmp | ATI_CRTC_CUR_EN);
-
-	/* Set new color */
-	ClassicSetCursorColors(pScreen);
-
-}
-
-static void
-RadeonLoadCursor(ScreenPtr pScreen)
-{
-	KdScreenPriv(pScreen);
-	ATICardInfo(pScreenPriv);
-	ATIScreenInfo(pScreenPriv);
-	ATICursor *pCurPriv = &atis->cursor;
-	CursorPtr pCursor = pCurPriv->pCursor;
-	CursorBitsPtr bits = pCursor->bits;
-	int h, w;
-	int x, y;
-	CARD32 *ram, *msk, *mskLine, *src, *srcLine;
-	int lwsrc;
-	CARD32 tmp;
-	char *mmio = atic->reg_base;
-
-	pCurPriv->pCursor = pCursor;
-	pCurPriv->xhot = pCursor->bits->xhot;
-	pCurPriv->yhot = pCursor->bits->yhot;
-
-	w = bits->width;
-	if (w > ATI_CURSOR_WIDTH)
-		w = ATI_CURSOR_WIDTH;
-
-	h = bits->height;
-	if (h > ATI_CURSOR_HEIGHT)
-		h = ATI_CURSOR_HEIGHT;
-    
-	tmp = MMIO_IN32(mmio, 0x7c);
-	tmp = 0x00010f80;
-	MMIO_OUT32 (mmio, 0x7c, tmp);
-
-	tmp = MMIO_IN32(mmio, ATI_REG_GEN_CNTL);
-	tmp &= ~(ATI_CRTC_CUR_EN | ATI_CRTC_ICON_EN | ATI_CRTC_ARGB_EN);
-	MMIO_OUT32(mmio, ATI_REG_GEN_CNTL, tmp);
-
-	/* Stick new image into cursor memory */
-	ram = (CARD32 *)(pScreenPriv->screen->memory_base +
-	    pCurPriv->area->offset);
-	if (pCursor->bits->argb)
-	{
-		srcLine = pCursor->bits->argb;
-		for (y = 0; y < h; y++)
-		{
-			src = srcLine;
-			srcLine += pCursor->bits->width;
-			for (x = 0; x < w; x++)
-				*ram++ = *src++;
-			for (; x < ATI_CURSOR_WIDTH; x++)
-				*ram++ = 0;
-		}
-		for (; y < ATI_CURSOR_HEIGHT; y++)
-			for (x = 0; x < ATI_CURSOR_WIDTH; x++)
-				*ram++ = 0;
-	}
-	else
-	{
-		CARD32	colors[4];
-		
-		colors[0] = 0;
-		colors[1] = 0;
-		colors[2] = (((pCursor->backRed   >> 8) << 16) |
-			     ((pCursor->backGreen >> 8) <<  8) |
-			     ((pCursor->backBlue  >> 8) <<  0) |
-			     0xff000000);
-		colors[3] = (((pCursor->foreRed   >> 8) << 16) |
-			     ((pCursor->foreGreen >> 8) <<  8) |
-			     ((pCursor->foreBlue  >> 8) <<  0) |
-			     0xff000000);
-		
-		mskLine = (CARD32 *)bits->mask;
-		srcLine = (CARD32 *)bits->source;
-
-		/* words per line */
-		lwsrc = BitmapBytePad(bits->width) / 4;
-
-		for (y = 0; y < ATI_CURSOR_HEIGHT; y++) 
-		{
-			CARD32 m, s;
-
-			msk = mskLine;
-			src = srcLine;
-			mskLine += lwsrc;
-			srcLine += lwsrc;
-
-			for (x = 0; x < ATI_CURSOR_WIDTH / 32; x++)
-			{
-				int k;
-				if (y < h && x < lwsrc) 
-				{
-					m = *msk++;
-					s = *src++;
-				}
-				else 
-				{
-					m = 0x0;
-					s = 0x0;
-				}
-
-				for (k = 0; k < 32; k++)
-				{
-					CARD32 bits = (s & 1) | ((m & 1) << 1);
-					*ram++ = colors[bits];
-					s >>= 1;
-					m >>= 1;
-				}
-			}
-		}
-	}
-
-	/* Enable the cursor */
-	tmp &= ~(ATI_CRTC_ICON_EN);
-	tmp |= ATI_CRTC_ARGB_EN;
-	tmp |= ATI_CRTC_CUR_EN;
-	MMIO_OUT32(mmio, ATI_REG_GEN_CNTL, tmp);
-}
-
-static void
-ATIUnloadCursor(ScreenPtr pScreen)
-{
-	KdScreenPriv(pScreen);
-	ATICardInfo(pScreenPriv);
-	char *mmio = atic->reg_base;
-	CARD32 tmp;
-
-	tmp = MMIO_IN32(mmio, ATI_REG_GEN_CNTL);
-	tmp &= ~(ATI_CRTC_CUR_EN | ATI_CRTC_ICON_EN | ATI_CRTC_ARGB_EN);
-	MMIO_OUT32(mmio, ATI_REG_GEN_CNTL, tmp);
-}
-
-static Bool
-ATIRealizeCursor(ScreenPtr pScreen, CursorPtr pCursor)
-{
-	KdScreenPriv(pScreen);
-	ATICardInfo(pScreenPriv);
-	ATIScreenInfo(pScreenPriv);
-	ATICursor *pCurPriv = &atis->cursor;
-
-	if (!pScreenPriv->enabled)
-		return TRUE;
-
-	/* miRecolorCursor does this */
-	if (pCursor && pCurPriv->pCursor == pCursor)
-	{
-		int x, y;
-
-		miPointerPosition(&x, &y);
-		if (atic->is_radeon)
-			RadeonLoadCursor (pScreen);
-		else
-			ClassicLoadCursor(pScreen);
-		/* Move to new position */
-		ATIMoveCursor(pScreen, x, y);
-	}
-
-	return TRUE;
-}
-
-static Bool
-ATIUnrealizeCursor(ScreenPtr pScreen, CursorPtr pCursor)
-{
-	return TRUE;
-}
-
-static void
-ATISetCursor(ScreenPtr pScreen, CursorPtr pCursor, int x, int y)
-{
-	KdScreenPriv(pScreen);
-	ATICardInfo(pScreenPriv);
-	ATIScreenInfo(pScreenPriv);
-	ATICursor *pCurPriv = &atis->cursor;
-
-	pCurPriv->pCursor = pCursor;
-
-	if (!pScreenPriv->enabled)
-		return;
-
-	if (pCursor)
-	{
-		if (atic->is_radeon)
-			RadeonLoadCursor (pScreen);
-		else
-			ClassicLoadCursor(pScreen);
-		/* Move to new position */
-		ATIMoveCursor(pScreen, x, y);
-	}
-	else
-		ATIUnloadCursor(pScreen);
-}
-
-miPointerSpriteFuncRec ATIPointerSpriteFuncs = {
-	ATIRealizeCursor,
-	ATIUnrealizeCursor,
-	ATISetCursor,
-	ATIMoveCursor,
-};
-
-static void
-ATIQueryBestSize(int class, unsigned short *pwidth, unsigned short *pheight, 
-    ScreenPtr pScreen)
-{
-	KdScreenPriv(pScreen);
-	ATIScreenInfo(pScreenPriv);
-	ATICursor *pCurPriv = &atis->cursor;
-
-	switch (class)
-	{
-	case CursorShape:
-		if (*pwidth > pCurPriv->width)
-			*pwidth = pCurPriv->width;
-		if (*pheight > pCurPriv->height)
-			*pheight = pCurPriv->height;
-		if (*pwidth > pScreen->width)
-			*pwidth = pScreen->width;
-		if (*pheight > pScreen->height)
-			*pheight = pScreen->height;
-		break;
-	default:
-		fbQueryBestSize(class, pwidth, pheight, pScreen);
-		break;
-	}
-}
-
-static void
-ATICursorSave(ScreenPtr pScreen, KdOffscreenArea *area)
-{
-	KdScreenPriv(pScreen);
-	ATIScreenInfo(pScreenPriv);
-	ATICursor *pCurPriv = &atis->cursor;
-
-	pCurPriv->area = NULL;
-}
-
-void
-ATICursorEnable(ScreenPtr pScreen)
-{
-	KdScreenPriv(pScreen);
-	ATICardInfo(pScreenPriv);
-	ATIScreenInfo(pScreenPriv);
-	ATICursor *pCurPriv = &atis->cursor;
-
-	if (!pCurPriv->has_cursor)
-		return;
-
-	if (pCurPriv->area == NULL) {
-		if (atic->is_radeon)
-			pCurPriv->area = KdOffscreenAlloc(pScreen,
-			    ATI_CURSOR_HEIGHT * ATI_CURSOR_WIDTH * 4,
-			    128, TRUE, ATICursorSave, atis);
-		else
-			pCurPriv->area = KdOffscreenAlloc(pScreen,
-			    ATI_CURSOR_HEIGHT * ATI_CURSOR_PITCH * 2,
-			    32, TRUE, ATICursorSave, atis);
-	}
-	if (pCurPriv->area == NULL)
-		FatalError("Couldn't allocate offscreen memory for cursor.\n");
-
-	if (pCurPriv->pCursor) {
-		int x, y;
-
-		miPointerPosition(&x, &y);
-		if (atic->is_radeon)
-			RadeonLoadCursor(pScreen);
-		else
-			ClassicLoadCursor(pScreen);
-		/* Move to new position */
-		ATIMoveCursor(pScreen, x, y);
-	}
-	else
-		ATIUnloadCursor(pScreen);
-}
-
-void
-ATICursorDisable(ScreenPtr pScreen)
-{
-	KdScreenPriv(pScreen);
-	ATIScreenInfo(pScreenPriv);
-	ATICursor *pCurPriv = &atis->cursor;
-
-	if (!pScreenPriv->enabled || !pCurPriv->has_cursor)
-		return;
-
-	if (pCurPriv->pCursor)
-		ATIUnloadCursor(pScreen);
-}
-
-Bool
-ATICursorInit(ScreenPtr pScreen)
-{
-	KdScreenPriv(pScreen);
-	ATICardInfo(pScreenPriv);
-	ATIScreenInfo(pScreenPriv);
-	ATICursor *pCurPriv = &atis->cursor;
-
-	pCurPriv->has_cursor = FALSE;
-
-	if (atic->reg_base == NULL)
-		return FALSE;
-
-	pCurPriv->width = ATI_CURSOR_WIDTH;
-	pCurPriv->height= ATI_CURSOR_HEIGHT;
-	pScreen->QueryBestSize = ATIQueryBestSize;
-	miPointerInitialize(pScreen, &ATIPointerSpriteFuncs,
-	    &kdPointerScreenFuncs, FALSE);
-	pCurPriv->has_cursor = TRUE;
-	pCurPriv->pCursor = NULL;
-	return TRUE;
-}
-
-void
-ATIRecolorCursor (ScreenPtr pScreen, int ndef, xColorItem *pdef)
-{
-	KdScreenPriv(pScreen);
-	ATICardInfo(pScreenPriv);
-
-	if (!atic->is_radeon)
-		ClassicRecolorCursor (pScreen, ndef, pdef);
-}
-
-void  
-ATICursorFini(ScreenPtr pScreen)
-{
-	KdScreenPriv(pScreen);
-	ATIScreenInfo(pScreenPriv);
-	ATICursor *pCurPriv = &atis->cursor;
-
-	pCurPriv->has_cursor = FALSE;
-	pCurPriv->pCursor = NULL;
-}
diff --git a/hw/kdrive/ati/ati_dma.c b/hw/kdrive/ati/ati_dma.c
deleted file mode 100644
index b97d79b..0000000
--- a/hw/kdrive/ati/ati_dma.c
+++ /dev/null
@@ -1,1037 +0,0 @@
-/*
- * Copyright © 2004 Eric Anholt
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Eric Anholt not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  Eric Anholt makes no
- * representations about the suitability of this software for any purpose.  It
- * is provided "as is" without express or implied warranty.
- *
- * ERIC ANHOLT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL ERIC ANHOLT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <sys/time.h>
-
-#include "ati.h"
-#include "ati_reg.h"
-#include "ati_dma.h"
-#include "ati_draw.h"
-
-#ifdef USE_DRI
-#include "radeon_common.h"
-#include "r128_common.h"
-#include "ati_sarea.h"
-#endif /* USE_DRI */
-
-#include "agp.h"
-
-#define DEBUG_FIFO 0
-
-extern CARD32 r128_cce_microcode[];
-extern CARD32 radeon_cp_microcode[][2];
-extern CARD32 r200_cp_microcode[][2];
-extern CARD32 r300_cp_microcode[][2];
-
-#if DEBUG_FIFO
-static void
-ATIDebugFifo(ATIScreenInfo *atis)
-{
-	ATICardInfo *atic = atis->atic;
-	char *mmio = atic->reg_base;
-
-	if (atic->is_radeon) {
-		ErrorF("RADEON_REG_CP_CSQ_CNTL: 0x%08x\n",
-		    MMIO_IN32(mmio, RADEON_REG_CP_CSQ_CNTL));
-		ErrorF("RADEON_REG_CP_CSQ_STAT: 0x%08x\n",
-		    MMIO_IN32(mmio, RADEON_REG_CP_CSQ_STAT));
-		ErrorF("RADEON_REG_RBBM_STATUS: 0x%08x\n",
-		    MMIO_IN32(mmio, RADEON_REG_RBBM_STATUS));
-		ErrorF("RADEON_REG_RB3D_DSTCACHE_CTLSTAT: 0x%08x\n",
-		    MMIO_IN32(mmio, RADEON_REG_RB3D_DSTCACHE_CTLSTAT));
-	} else {
-		ErrorF("R128_REG_PM4_BUFFER_CNTL: 0x%08x\n",
-		    MMIO_IN32(mmio, R128_REG_PM4_BUFFER_CNTL));
-		ErrorF("R128_REG_PM4_STAT: 0x%08x\n",
-		    MMIO_IN32(mmio, R128_REG_PM4_STAT));
-		ErrorF("R128_REG_GUI_STAT: 0x%08x\n",
-		    MMIO_IN32(mmio, R128_REG_GUI_STAT));
-		ErrorF("R128_REG_PC_NGUI_CTLSTAT: 0x%08x\n",
-		    MMIO_IN32(mmio, R128_REG_PC_NGUI_CTLSTAT));
-	}
-}
-#endif
-
-static void
-ATIUploadMicrocode(ATIScreenInfo *atis)
-{
-	ATICardInfo *atic = atis->atic;
-	char *mmio = atic->reg_base;
-	int i;
-
-	MMIO_OUT32(mmio, ATI_REG_MICROCODE_RAM_ADDR, 0);
-	if (atic->is_radeon && atic->is_r300) {
-		for (i = 0; i < 256; i++) {
-			MMIO_OUT32(mmio, ATI_REG_MICROCODE_RAM_DATAH,
-			    r300_cp_microcode[i][1]);
-			MMIO_OUT32(mmio, ATI_REG_MICROCODE_RAM_DATAL,
-			    r300_cp_microcode[i][0]);
-		}
-	} else if (atic->is_radeon && atic->is_r200) {
-		for (i = 0; i < 256; i++) {
-			MMIO_OUT32(mmio, ATI_REG_MICROCODE_RAM_DATAH,
-			    r200_cp_microcode[i][1]);
-			MMIO_OUT32(mmio, ATI_REG_MICROCODE_RAM_DATAL,
-			    r200_cp_microcode[i][0]);
-		}
-	} else if (atic->is_radeon && atic->is_r100) {
-		for (i = 0; i < 256; i++) {
-			MMIO_OUT32(mmio, ATI_REG_MICROCODE_RAM_DATAH,
-			    radeon_cp_microcode[i][1]);
-			MMIO_OUT32(mmio, ATI_REG_MICROCODE_RAM_DATAL,
-			    radeon_cp_microcode[i][0]);
-		}
-	} else {
-		for (i = 0; i < 256; i++) {
-			MMIO_OUT32(mmio, ATI_REG_MICROCODE_RAM_DATAH,
-			    r128_cce_microcode[i * 2]);
-			MMIO_OUT32(mmio, ATI_REG_MICROCODE_RAM_DATAL,
-			    r128_cce_microcode[i * 2 + 1]);
-		}
-	}
-}
-
-/* Required when reading from video memory after acceleration to make sure all
- * data has been flushed to video memory from the pixel cache.
- */
-static void
-ATIFlushPixelCache(ATIScreenInfo *atis)
-{
-	ATICardInfo *atic = atis->atic;
-	char *mmio = atic->reg_base;
-	CARD32 temp;
-	TIMEOUT_LOCALS;
-
-	if (atic->is_radeon) {
-		temp = MMIO_IN32(mmio, RADEON_REG_RB3D_DSTCACHE_CTLSTAT);
-		temp |= RADEON_RB3D_DC_FLUSH_ALL;
-		MMIO_OUT32(mmio, RADEON_REG_RB3D_DSTCACHE_CTLSTAT, temp);
-
-		WHILE_NOT_TIMEOUT(.2) {
-			if ((MMIO_IN32(mmio, RADEON_REG_RB3D_DSTCACHE_CTLSTAT) &
-			    RADEON_RB3D_DC_BUSY) == 0)
-				break;
-		}
-	} else {
-		temp = MMIO_IN32(mmio, R128_REG_PC_NGUI_CTLSTAT);
-		temp |= R128_PC_FLUSH_ALL;
-		MMIO_OUT32(mmio, R128_REG_PC_NGUI_CTLSTAT, temp);
-
-		WHILE_NOT_TIMEOUT(.2) {
-			if ((MMIO_IN32(mmio, R128_REG_PC_NGUI_CTLSTAT) &
-			    R128_PC_BUSY) != R128_PC_BUSY)
-				break;
-		}
-	}
-	if (TIMEDOUT())
-		ErrorF("Timeout flushing pixel cache.\n");
-}
-
-static void
-ATIEngineReset(ATIScreenInfo *atis)
-{
-	ATICardInfo *atic = atis->atic;
-	char *mmio = atic->reg_base;
-	CARD32 clockcntlindex, mclkcntl;
-
-#if DEBUG_FIFO
-	ErrorF("Engine Reset!\n");
-	ATIDebugFifo(atis);
-#endif
-
-	ATIFlushPixelCache(atis);
-
-	clockcntlindex = MMIO_IN32(mmio, ATI_REG_CLOCK_CNTL_INDEX);
-	if (atic->is_r300)
-		R300CGWorkaround(atis);
-
-	if (atic->is_radeon) {
-		CARD32 host_path_cntl;
-
-		mclkcntl = INPLL(mmio, RADEON_REG_MCLK_CNTL);
-
-		OUTPLL(mmio, RADEON_REG_MCLK_CNTL, mclkcntl |
-		    RADEON_FORCEON_MCLKA |
-		    RADEON_FORCEON_MCLKB |
-		    RADEON_FORCEON_YCLKA |
-		    RADEON_FORCEON_YCLKB |
-		    RADEON_FORCEON_MC |
-		    RADEON_FORCEON_AIC);
-
-		host_path_cntl = MMIO_IN32(mmio, RADEON_REG_HOST_PATH_CNTL);
-
-		if (atic->is_r300) {
-			MMIO_OUT32(mmio, RADEON_REG_RBBM_SOFT_RESET,
-			    RADEON_SOFT_RESET_CP |
-			    RADEON_SOFT_RESET_HI |
-			    RADEON_SOFT_RESET_E2);
-		} else {
-			MMIO_OUT32(mmio, RADEON_REG_RBBM_SOFT_RESET,
-			    RADEON_SOFT_RESET_CP |
-			    RADEON_SOFT_RESET_SE |
-			    RADEON_SOFT_RESET_RE |
-			    RADEON_SOFT_RESET_PP |
-			    RADEON_SOFT_RESET_E2 |
-			    RADEON_SOFT_RESET_RB);
-		}
-		MMIO_IN32(mmio, RADEON_REG_RBBM_SOFT_RESET);
-		MMIO_OUT32(mmio, RADEON_REG_RBBM_SOFT_RESET, 0);
-
-		MMIO_OUT32(mmio, RADEON_REG_HOST_PATH_CNTL, host_path_cntl |
-		    RADEON_HDP_SOFT_RESET);
-		MMIO_IN32(mmio, RADEON_REG_HOST_PATH_CNTL);
-		MMIO_OUT32(mmio, RADEON_REG_HOST_PATH_CNTL, host_path_cntl);
-
-		MMIO_OUT32(mmio, ATI_REG_CLOCK_CNTL_INDEX, clockcntlindex);
-		OUTPLL(mmio, RADEON_REG_MCLK_CNTL, mclkcntl);
-		if (atic->is_r300)
-			R300CGWorkaround(atis);
-	} else {
-		CARD32 temp;
-
-		mclkcntl = INPLL(mmio, R128_REG_MCLK_CNTL);
-
-		OUTPLL(mmio, R128_REG_MCLK_CNTL,
-		    mclkcntl | R128_FORCE_GCP | R128_FORCE_PIPE3D_CP);
-
-		temp = MMIO_IN32(mmio, R128_REG_GEN_RESET_CNTL);
-		MMIO_OUT32(mmio, R128_REG_GEN_RESET_CNTL,
-		    temp | R128_SOFT_RESET_GUI);
-		temp = MMIO_IN32(mmio, R128_REG_GEN_RESET_CNTL);
-		MMIO_OUT32(mmio, R128_REG_GEN_RESET_CNTL,
-		    temp & ~R128_SOFT_RESET_GUI);
-		temp = MMIO_IN32(mmio, R128_REG_GEN_RESET_CNTL);
-
-		OUTPLL(mmio, R128_REG_MCLK_CNTL, mclkcntl);
-		MMIO_OUT32(mmio, ATI_REG_CLOCK_CNTL_INDEX, clockcntlindex);
-	}
-#ifdef USE_DRI
-	if (atis->using_dri) {
-		ATIDRIDMAReset(atis);
-		ATIDRIDMAStart(atis);
-	}
-#endif
-}
-
-static void
-ATIWaitAvailMMIO(ATIScreenInfo *atis, int n)
-{
-	ATICardInfo *atic = atis->atic;
-	char *mmio = atic->reg_base;
-	TIMEOUT_LOCALS;
-
-	if (atis->mmio_avail >= n) {
-		atis->mmio_avail -= n;
-		return;
-	}
-	if (atic->is_radeon) {
-		WHILE_NOT_TIMEOUT(.2) {
-			atis->mmio_avail = MMIO_IN32(mmio,
-			    RADEON_REG_RBBM_STATUS) & RADEON_RBBM_FIFOCNT_MASK;
-			if (atis->mmio_avail >= n)
-				break;
-		}
-	} else {
-		WHILE_NOT_TIMEOUT(.2) {
-			atis->mmio_avail = MMIO_IN32(mmio, R128_REG_GUI_STAT) &
-			    0xfff;
-			if (atis->mmio_avail >= n)
-				break;
-		}
-	}
-	if (TIMEDOUT()) {
-		ErrorF("Timeout waiting for %d MMIO slots.\n", n);
-		ATIEngineReset(atis);
-		ATIDrawSetup(atis->screen->pScreen);
-	}
-	atis->mmio_avail -= n;
-}
-
-static int
-ATIGetAvailPrimary(ATIScreenInfo *atis)
-{
-	ATICardInfo *atic = atis->atic;
-	char *mmio = atic->reg_base;
-
-	if (atic->is_radeon) {
-		int csq_stat, diff;
-	
-		csq_stat = MMIO_IN32(mmio, RADEON_REG_CP_CSQ_STAT);
-		if (atic->is_r200)
-			diff = ((csq_stat & R200_CSQ_WPTR_PRIMARY_MASK) >> 9) - 
-			    (csq_stat & R200_CSQ_RPTR_PRIMARY_MASK);
-		else
-			diff = ((csq_stat & RADEON_CSQ_WPTR_PRIMARY_MASK) >> 8) - 
-			    (csq_stat & RADEON_CSQ_RPTR_PRIMARY_MASK);
-	
-		if (diff < 0)
-			return -diff;
-		else
-			return atis->cce_pri_size - diff;
-	} else {
-		return MMIO_IN32(mmio, R128_REG_PM4_STAT) &
-		    R128_PM4_FIFOCNT_MASK;
-	}
-}
-
-static void
-ATIWaitAvailPrimary(ATIScreenInfo *atis, int n)
-{
-	TIMEOUT_LOCALS;
-
-	if (atis->cce_pri_avail >= n) {
-		atis->cce_pri_avail -= n;
-		return;
-	}
-
-	WHILE_NOT_TIMEOUT(.2) {
-		if (atis->cce_pri_avail >= n)
-			break;
-		atis->cce_pri_avail = ATIGetAvailPrimary(atis);
-		if (atis->cce_pri_avail >= n)
-			break;
-	}
-	if (TIMEDOUT()) {
-		ErrorF("Timeout waiting for %d CCE slots (%d avail).\n", n,
-		    atis->cce_pri_avail);
-		ATIEngineReset(atis);
-		ATIDrawSetup(atis->screen->pScreen);
-	}
-	atis->cce_pri_avail -= n;
-}
-
-void
-ATIWaitIdle(ATIScreenInfo *atis)
-{
-	ATICardInfo *atic = atis->atic;
-	char *mmio = atic->reg_base;
-	TIMEOUT_LOCALS;
-
-	if (atis->indirectBuffer != NULL)
-		ATIFlushIndirect(atis, 0);
-
-#ifdef USE_DRI
-	if (atis->using_dri) {
-		int ret = 0;
-		int cmd = (atic->is_radeon ? DRM_RADEON_CP_IDLE :
-		    DRM_R128_CCE_IDLE);
-		WHILE_NOT_TIMEOUT(2) {
-			ret = drmCommandNone(atic->drmFd, cmd);
-			if (ret != -EBUSY)
-				break;
-		}
-		if (TIMEDOUT()) {
-			ATIDebugFifo(atis);
-			FatalError("Timed out idling CCE (card hung)\n");
-		}
-		if (ret != 0)
-			ErrorF("Failed to idle DMA, returned %d\n", ret);
-		return;
-	}
-#endif
-
-	if (!atic->is_radeon && (atis->using_pseudo || atis->using_dma)) {
-		ATIWaitAvailPrimary(atis, atis->cce_pri_size);
-
-		WHILE_NOT_TIMEOUT(.2) {
-			if ((MMIO_IN32(mmio, R128_REG_PM4_STAT) &
-			    (R128_PM4_BUSY | R128_PM4_GUI_ACTIVE)) == 0)
-				break;
-		}
-		if (TIMEDOUT()) {
-			ErrorF("Timeout idling CCE, resetting...\n");
-			ATIEngineReset(atis);
-			ATIDrawSetup(atis->screen->pScreen);
-		}
-	}
-
-	/* Radeon CP idle is the same as MMIO idle. */
-	if (atis->using_pio || atic->is_radeon) {
-		/* Empty the fifo */
-		ATIWaitAvailMMIO(atis, 64);
-
-		if (atic->is_radeon) {
-			WHILE_NOT_TIMEOUT(.2) {
-				if ((MMIO_IN32(mmio, RADEON_REG_RBBM_STATUS) &
-				    RADEON_RBBM_ACTIVE) == 0)
-					break;
-			}
-		} else {
-			WHILE_NOT_TIMEOUT(.2) {
-				if ((MMIO_IN32(mmio, R128_REG_GUI_STAT) &
-				    R128_GUI_ACTIVE) == 0)
-					break;
-			}
-		}
-		if (TIMEDOUT()) {
-			ErrorF("Timeout idling accelerator, resetting...\n");
-			ATIEngineReset(atis);
-			ATIDrawSetup(atis->screen->pScreen);
-		}
-	}
-
-	ATIFlushPixelCache(atis);
-
-#if DEBUG_FIFO
-	ErrorF("Idle?\n");
-	ATIDebugFifo(atis);
-#endif
-}
-
-dmaBuf *
-ATIGetDMABuffer(ATIScreenInfo *atis)
-{
-	dmaBuf *buf;
-
-	buf = (dmaBuf *)xalloc(sizeof(dmaBuf));
-	if (buf == NULL)
-		return NULL;
-
-#ifdef USE_DRI
-	if (atis->using_dri) {
-		buf->drmBuf = ATIDRIGetBuffer(atis);
-		if (buf->drmBuf == NULL) {
-			xfree(buf);
-			return NULL;
-		}
-		buf->size = buf->drmBuf->total;
-		buf->used = buf->drmBuf->used;
-		buf->address = buf->drmBuf->address;
-		return buf;
-	}
-#endif /* USE_DRI */
-
-	if (atis->using_dma)
-		buf->size = atis->ring_len / 2;
-	else
-		buf->size = 512 * 1024;
-	buf->address = xalloc(buf->size);
-	if (buf->address == NULL) {
-		xfree(buf);
-		return NULL;
-	}
-	buf->used = 0;
-
-	return buf;
-}
-
-/* Decode a type-3 packet into MMIO register writes. Only some type-3 packets
- * supported, and only partially.
- */
-static void
-ATIDispatchPacket3MMIO(ATIScreenInfo *atis, CARD32 header, CARD32 *addr,
-    int count)
-{
-	ATICardInfo *atic = atis->atic;
-	char *mmio = atic->reg_base;
-	CARD32 settings;
-	int i = 0;
-
-	settings = addr[i++];
-
-	if ((settings & ATI_GMC_SRC_PITCH_OFFSET_CNTL) != 0)
-		MMIO_OUT32(mmio, ATI_REG_SRC_PITCH_OFFSET, addr[i++]);
-	if ((settings & ATI_GMC_DST_PITCH_OFFSET_CNTL) != 0)
-		MMIO_OUT32(mmio, ATI_REG_DST_PITCH_OFFSET, addr[i++]);
-	if ((settings & ATI_GMC_BRUSH_MASK) == ATI_GMC_BRUSH_SOLID_COLOR)
-		MMIO_OUT32(mmio, ATI_REG_DP_BRUSH_FRGD_CLR, addr[i++]);
-
-	switch (header & (ATI_CCE_PACKETTYPE_MASK |
-	    ATI_CCE_PACKET3_IT_OPCODE_MASK))
-	{
-	case ATI_CCE_PACKET3_PAINT_MULTI:
-		while (i < count) {
-			MMIO_OUT32(mmio, ATI_REG_DST_Y_X,
-			    (addr[i] >> 16) | (addr[i] << 16));
-			i++;
-			MMIO_OUT32(mmio, ATI_REG_DST_HEIGHT_WIDTH,
-			    (addr[i] >> 16) | (addr[i] << 16));
-			i++;
-		}
-		break;
-	case ATI_CCE_PACKET3_BITBLT_MULTI:
-		while (i < count) {
-			MMIO_OUT32(mmio, ATI_REG_SRC_Y_X,
-			    (addr[i] >> 16) | (addr[i] << 16));
-			i++;
-			MMIO_OUT32(mmio, ATI_REG_DST_Y_X,
-			    (addr[i] >> 16) | (addr[i] << 16));
-			i++;
-			MMIO_OUT32(mmio, ATI_REG_DST_HEIGHT_WIDTH,
-			    (addr[i] >> 16) | (addr[i] << 16));
-			i++;
-		}
-		break;
-	default:
-		ErrorF("Unsupported packet: 0x%x\n", header);
-	}
-}
-
-/* Dispatch packets by decoding them and writing to registers.  Doesn't support
- * the type 3 packets.
- */
-static void
-ATIDispatchIndirectMMIO(ATIScreenInfo *atis)
-{
-	ATICardInfo *atic = atis->atic;
-	dmaBuf *buf = atis->indirectBuffer;
-	char *mmio = atic->reg_base;
-	CARD32 *addr;
-	CARD32 reg;
-	int i, n, count;
-
-	addr = (CARD32 *)((char *)buf->address + atis->indirectStart);
-	count = (buf->used - atis->indirectStart) / 4;
-
-	for (i = 0; i < count; i++) {
-		CARD32 header = addr[i];
-
-		switch (header & ATI_CCE_PACKETTYPE_MASK)
-		{
-		case ATI_CCE_PACKET0:
-			n = ((header & ATI_CCE_PACKET0_COUNT_MASK) >> 16) + 1;
-			reg = (header & ATI_CCE_PACKET0_REG_MASK) << 2;
-			ATIWaitAvailMMIO(atis, n);
-			while (n > 0) {
-				i++;
-				MMIO_OUT32(mmio, reg, addr[i]);
-				if ((header & ATI_CCE_PACKET0_ONE_REG_WR) == 0)
-					reg += 4;
-				n--;
-			}
-			break;
-		case ATI_CCE_PACKET1:
-			reg = (header & ATI_CCE_PACKET1_REG_1) << 2;
-			MMIO_OUT32(mmio, reg, addr[++i]);
-			reg = ((header & ATI_CCE_PACKET1_REG_2) >>
-			    ATI_CCE_PACKET1_REG_2_SHIFT) << 2;
-			MMIO_OUT32(mmio, reg, addr[++i]);
-			break;
-		case ATI_CCE_PACKET2:
-			/* PACKET2 is a no-op packet. */
-			break;
-		case ATI_CCE_PACKET3:
-			n = ((header & ATI_CCE_PACKET3_COUNT_MASK) >> 16) + 1;
-			ATIDispatchPacket3MMIO(atis, header, &addr[i], n);
-			i += n;
-			break;
-		default:
-			ErrorF("Unsupported packet: 0x%x\n", addr[i]);
-		}
-	}
-}
-
-/* Dispatch packets by sending them through the MMIO aperture. */
-static void
-R128DispatchIndirectPDMA(ATIScreenInfo *atis)
-{
-	ATICardInfo *atic = atis->atic;
-	dmaBuf *buf = atis->indirectBuffer;
-	char *mmio = atic->reg_base;
-	CARD32 *addr;
-	int count;
-
-	addr = (CARD32 *)((char *)buf->address + atis->indirectStart);
-	count = (buf->used - atis->indirectStart) / 4;
-
-	while (count > 1) {
-		ATIWaitAvailPrimary(atis, 2);
-		MMIO_OUT32(mmio, R128_REG_PM4_FIFO_DATA_EVEN, *addr++);
-		MMIO_OUT32(mmio, R128_REG_PM4_FIFO_DATA_ODD, *addr++);
-		count -= 2;
-	}
-
-	/* Submit last DWORD if necessary. */
-	if (count != 0) {
-		ATIWaitAvailPrimary(atis, 2);
-		MMIO_OUT32(mmio, R128_REG_PM4_FIFO_DATA_EVEN, *addr++);
-		MMIO_OUT32(mmio, R128_REG_PM4_FIFO_DATA_ODD, ATI_CCE_PACKET2);
-	}
-}
-
-/* Dispatch packets by sending them through the MMIO aperture, using the
- * primary CCE ring. */
-static void
-RadeonDispatchIndirectPDMA(ATIScreenInfo *atis)
-{
-	ATICardInfo *atic = atis->atic;
-	dmaBuf *buf = atis->indirectBuffer;
-	char *mmio = atic->reg_base;
-	CARD32 *addr;
-	int count, avail, reg, i;
-	TIMEOUT_LOCALS;
-
-	addr = (CARD32 *)((char *)buf->address + atis->indirectStart);
-	count = (buf->used - atis->indirectStart) / 4;
-
-	reg = RADEON_REG_CSQ_APER_PRIMARY;
-	WHILE_NOT_TIMEOUT(3) {
-		/* 3 seconds is empirical, using render_bench on an r100. */
-		if (count <= 0)
-			break;
-		avail = ATIGetAvailPrimary(atis);
-		for (i = 0; i < min(count, avail); i++) {
-			MMIO_OUT32(mmio, reg, *addr++);
-			if (reg == RADEON_REG_CSQ_APER_PRIMARY_END)
-				reg = RADEON_REG_CSQ_APER_PRIMARY;
-			else
-				reg += 4;
-		}
-		count -= i;
-	}
-	if (TIMEDOUT()) {
-		ErrorF("Timeout submitting packets, resetting...\n");
-		ATIEngineReset(atis);
-		ATIDrawSetup(atis->screen->pScreen);
-	}
-}
-
-
-/* Dispatch packets by writing them to the (primary) ring buffer, which happens
- * to be in framebuffer memory.
- */
-static void
-R128DispatchIndirectDMA(ATIScreenInfo *atis)
-{
-	ATICardInfo *atic = atis->atic;
-	dmaBuf *buf = atis->indirectBuffer;
-	char *mmio = atic->reg_base;
-	CARD32 *addr;
-	int count, ring_count;
-	TIMEOUT_LOCALS;
-
-	addr = (CARD32 *)((char *)buf->address + atis->indirectStart);
-	count = (buf->used - atis->indirectStart) / 4;
-	ring_count = atis->ring_len / 4;
-
-	WHILE_NOT_TIMEOUT(.2) {
-		if (count <= 0)
-			break;
-
-		atis->ring_addr[atis->ring_write++] = *addr++;
-		if (atis->ring_write >= ring_count)
-			atis->ring_write = 0;
-		while (atis->ring_write == atis->ring_read) {
-			atis->ring_read = MMIO_IN32(mmio, ATI_REG_CCE_RPTR);
-		}
-		count--;
-	}
-	if (TIMEDOUT()) {
-		ErrorF("Timeout submitting packets, resetting...\n");
-		ATIEngineReset(atis);
-		ATIDrawSetup(atis->screen->pScreen);
-	}
-		
-	/* Workaround for some early Rage 128 ASIC spins where the CCE parser
-	 * may read up to 32 DWORDS beyond the end of the ring buffer memory
-	 * before wrapping around, if the ring buffer was empty and a <32 DWORD
-	 * packet that wraps around the end of the ring buffer is submitted.
-	 * To work around that, copy the beginning of the ring buffer past the
-	 * end if that may happen.
-	 */
-	if (atis->ring_write < 32)
-		memcpy(atis->ring_addr + ring_count, atis->ring_addr, 32 * 4);
-
-	/* Update write pointer */
-	MMIO_OUT32(mmio, ATI_REG_CCE_WPTR, atis->ring_write);
-}
-
-void
-ATIFlushIndirect(ATIScreenInfo *atis, Bool discard)
-{
-	ATICardInfo *atic = atis->atic;
-	dmaBuf *buf = atis->indirectBuffer;
-
-	if ((atis->indirectStart == buf->used) && !discard)
-		return;
-
-#if DEBUG_FIFO
-	ErrorF("Dispatching %d DWORDS\n", (buf->used - atis->indirectStart) /
-	    4);
-#endif
-
-#ifdef USE_DRI
-	if (atis->using_dri) {
-		buf->drmBuf->used = buf->used;
-		ATIDRIDispatchIndirect(atis, discard);
-		if (discard) {
-			buf->drmBuf = ATIDRIGetBuffer(atis);
-			buf->size = buf->drmBuf->total;
-			buf->used = buf->drmBuf->used;
-			buf->address = buf->drmBuf->address;
-			atis->indirectStart = 0;
-		} else {
-			/* Start on a double word boundary */
-			atis->indirectStart = buf->used = (buf->used + 7) & ~7;
-		}
-		return;
-	}
-#endif /* USE_DRI */
-
-	if (atis->using_dma && !atic->is_radeon)
-		R128DispatchIndirectDMA(atis);
-	else if (atis->using_pseudo) {
-		if (atic->is_radeon)
-			RadeonDispatchIndirectPDMA(atis);
-		else
-			R128DispatchIndirectPDMA(atis);
-	} else
-		ATIDispatchIndirectMMIO(atis);
-
-	buf->used = 0;
-	atis->indirectStart = 0;
-}
-
-static Bool
-ATIInitAGP(ScreenPtr pScreen, int size)
-{
-	KdScreenPriv(pScreen);
-	ATIScreenInfo(pScreenPriv);
-	ATICardInfo(pScreenPriv);
-	AgpInfoPtr agp_info;
-	int screennum = atis->screen->mynum;
-
-	if (atic->is_radeon)
-		return FALSE;
-
-	if (!KdAgpGARTSupported()) 
-		return FALSE; 
-
-	if (!KdAcquireGART(screennum))
-		return FALSE;
-
-	atis->agp_key = KdAllocateGARTMemory(screennum, size, 0, NULL);
-	if (atis->agp_key == -1) {
-		ErrorF("Failed to allocate %dKB GART memory\n", size/1024);
-		KdReleaseGART(screennum);
-		return FALSE;
-	}
-
-	if (!KdBindGARTMemory(screennum, atis->agp_key, 0)) {
-		ErrorF("Failed to bind GART memory\n");
-		KdReleaseGART(screennum);
-		return FALSE;
-	}
-
-	agp_info = KdGetAGPInfo(screennum);
-	if (agp_info == NULL) {
-		KdUnbindGARTMemory(screennum, atis->agp_key);
-		KdReleaseGART(screennum);
-		return FALSE;
-	}
-
-	atis->agp_addr = KdMapDevice(agp_info->base, agp_info->size);
-	if (atis->agp_addr == NULL) {
-		ErrorF("Failed to map GART memory\n");
-		KdUnbindGARTMemory(screennum, atis->agp_key);
-		KdReleaseGART(screennum);
-		free(agp_info);
-		return FALSE;
-	}
-	KdSetMappedMode(agp_info->base, agp_info->size,
-	    KD_MAPPED_MODE_FRAMEBUFFER);
-
-	atis->agp_size = size;
-	free(agp_info);
-
-	return TRUE;
-}
-
-static void
-ATIFiniAGP(ScreenPtr pScreen)
-{
-	KdScreenPriv(pScreen);
-	ATIScreenInfo(pScreenPriv);
-	int screennum = atis->screen->mynum;
-
-	KdUnbindGARTMemory(screennum, atis->agp_key);
-	KdReleaseGART(screennum);
-	atis->agp_addr = NULL;
-	atis->agp_size = 0;
-}
-
-static Bool
-ATIPseudoDMAInit(ScreenPtr pScreen)
-{
-	KdScreenPriv(pScreen);
-	ATIScreenInfo(pScreenPriv);
-	ATICardInfo(pScreenPriv);
-	char *mmio = atic->reg_base;
-
-	if (atic->is_r300)
-		return FALSE;
-
-	ATIUploadMicrocode(atis);
-	ATIEngineReset(atis);
-
-	if (atic->is_r200) {
-		MMIO_OUT32(mmio, RADEON_REG_CP_CSQ_CNTL,
-		    RADEON_CSQ_PRIPIO_INDDIS);
-		atis->cce_pri_size = MMIO_IN32(mmio, RADEON_REG_CP_CSQ_CNTL) &
-		    R200_CSQ_CNT_PRIMARY_MASK;
-		MMIO_OUT32(mmio, RADEON_REG_ME_CNTL, RADEON_ME_MODE_FREE_RUN);
-	} else if (atic->is_radeon) {
-		MMIO_OUT32(mmio, RADEON_REG_CP_CSQ_CNTL,
-		    RADEON_CSQ_PRIPIO_INDDIS);
-		atis->cce_pri_size = MMIO_IN32(mmio, RADEON_REG_CP_CSQ_CNTL) &
-		    RADEON_CSQ_CNT_PRIMARY_MASK;
-		MMIO_OUT32(mmio, RADEON_REG_ME_CNTL, RADEON_ME_MODE_FREE_RUN);
-	} else {
-		MMIO_OUT32(mmio, R128_REG_PM4_BUFFER_CNTL, R128_PM4_192PIO |
-		    R128_PM4_BUFFER_CNTL_NOUPDATE);
-		atis->cce_pri_size = 192;
-		MMIO_OUT32(mmio, R128_REG_PM4_MICRO_CNTL,
-		    R128_PM4_MICRO_FREERUN);
-	}
-
-	return TRUE;
-}
-
-static Bool
-ATIPseudoDMAFini(ScreenPtr pScreen)
-{	KdScreenPriv(pScreen);
-	ATIScreenInfo(pScreenPriv);
-	ATICardInfo(pScreenPriv);
-	char *mmio = atic->reg_base;
-
-	if (atic->is_radeon) {
-		MMIO_OUT32(mmio, RADEON_REG_ME_CNTL, 0);
-		MMIO_OUT32(mmio, RADEON_REG_CP_CSQ_CNTL,
-		    RADEON_CSQ_PRIDIS_INDDIS);
-	} else {
-		MMIO_OUT32(mmio, R128_REG_PM4_MICRO_CNTL, 0);
-		MMIO_OUT32(mmio, R128_REG_PM4_BUFFER_CNTL,
-		    R128_PM4_NONPM4 | R128_PM4_BUFFER_CNTL_NOUPDATE);
-	}
-	atis->cce_pri_size = 0;
-
-	ATIEngineReset(atis);
-
-	return TRUE;
-}
-
-static Bool
-ATIDMAInit(ScreenPtr pScreen, Bool use_agp)
-{
-	KdScreenPriv(pScreen);
-	ATIScreenInfo(pScreenPriv);
-	ATICardInfo(pScreenPriv);
-	char *mmio = atic->reg_base;
-	int dma_offset;
-	CARD32 tmp;
-
-	/* XXX: Not for radeons.  Yet? */
-	if (atic->is_radeon)
-		return FALSE;
-
-	if (use_agp) {
-		if (1)
-			return FALSE; /* XXX */
-		/* Allocate a 1MB AGP space, but only use 128k + 128 for DMA.
-		 * XXX: Should use the rest for things like scratch space.
-		 */
-		if (!ATIInitAGP(pScreen, 1024 * 1024))
-			return FALSE;
-		atis->ring_addr = atis->agp_addr;
-		atis->ring_len = 128 * 1024;
-		dma_offset = R128_AGP_OFFSET;
-	} else {
-		if (1)
-			return FALSE; /* XXX */
-		/* Allocate a 128K buffer, plus 32 DWORDS to give space for the
-		 * R128 ASIC bug workaround.
-		 */
-		atis->dma_space = KdOffscreenAlloc(pScreen, 128 * 1024 + 128,
-		    128, TRUE, NULL, NULL);
-		if (atis->dma_space == NULL)
-			return FALSE;
-		atis->ring_addr = (CARD32 *)(atis->dma_space->offset +
-		    pScreenPriv->screen->memory_base);
-		atis->ring_len = 128 * 1024;
-		dma_offset = atis->dma_space->offset;
-	}
-
-	ATIUploadMicrocode(atis);
-	ATIEngineReset(atis);
-
-	atis->ring_read = 0;
-	atis->ring_write = 0;
-
-	tmp = MMIO_IN32(mmio, ATI_REG_BUS_CNTL);
-	MMIO_OUT32(mmio, ATI_REG_BUS_CNTL, tmp & ~ATI_BUS_MASTER_DIS);
-
-	MMIO_OUT32(mmio, ATI_REG_CCE_RB_BASE, dma_offset);
-	MMIO_OUT32(mmio, ATI_REG_CCE_WPTR, atis->ring_write);
-	MMIO_OUT32(mmio, ATI_REG_CCE_RPTR, atis->ring_read);
-	MMIO_OUT32(mmio, ATI_REG_CCE_RPTR_ADDR, 0 /* XXX? */);
-
-	if (atic->is_r200) {
-		MMIO_OUT32(mmio, RADEON_REG_CP_CSQ_CNTL,
-		    RADEON_CSQ_PRIBM_INDBM);
-		atis->cce_pri_size = MMIO_IN32(mmio, RADEON_REG_CP_CSQ_CNTL) &
-		    R200_CSQ_CNT_PRIMARY_MASK;
-		MMIO_OUT32(mmio, RADEON_REG_ME_CNTL, RADEON_ME_MODE_FREE_RUN);
-	} else if (atic->is_radeon) {
-		MMIO_OUT32(mmio, RADEON_REG_CP_CSQ_CNTL,
-		    RADEON_CSQ_PRIBM_INDBM);
-		atis->cce_pri_size = MMIO_IN32(mmio, RADEON_REG_CP_CSQ_CNTL) &
-		    RADEON_CSQ_CNT_PRIMARY_MASK;
-		MMIO_OUT32(mmio, RADEON_REG_ME_CNTL, RADEON_ME_MODE_FREE_RUN);
-	} else {
-		MMIO_OUT32(mmio, R128_REG_PM4_BUFFER_WM_CNTL,
-		    ((R128_WATERMARK_L/4) << R128_WMA_SHIFT) |
-		    ((R128_WATERMARK_M/4) << R128_WMB_SHIFT) |
-		    ((R128_WATERMARK_N/4) << R128_WMC_SHIFT) |
-		    ((R128_WATERMARK_K/64) << R128_WB_WM_SHIFT));
-		/* The sample code reads from an undocumneted register
-		 * (PM4_BUFFER_ADDR).  Perhaps it's a write posting thing?  Do
-		 * a read in case that's it.
-		 */
-		MMIO_IN32(mmio, R128_REG_PM4_BUFFER_CNTL);
-		if (use_agp) {
-			/* XXX Magic num */
-			MMIO_OUT32(mmio, R128_REG_PCI_GART_PAGE, 1);
-			MMIO_OUT32(mmio, R128_REG_PM4_BUFFER_CNTL,
-			    ATILog2(atis->ring_len) |
-			    R128_PM4_192BM |
-			    R128_PM4_BUFFER_CNTL_NOUPDATE);
-		} else {
-			MMIO_OUT32(mmio, R128_REG_PM4_BUFFER_CNTL,
-			    ATILog2(atis->ring_len) |
-			    R128_PM4_192BM |
-			    R128_PM4_BUFFER_CNTL_NOUPDATE |
-			    R128_PM4_IN_FRAME_BUFFER);
-		}
-		atis->cce_pri_size = 192;
-		MMIO_IN32(mmio, R128_REG_PM4_BUFFER_CNTL);
-		MMIO_OUT32(mmio, R128_REG_PM4_MICRO_CNTL,
-		    R128_PM4_MICRO_FREERUN);
-	}
-
-	return TRUE;
-}
-
-static Bool
-ATIDMAFini(ScreenPtr pScreen)
-{
-	KdScreenPriv(pScreen);
-	ATIScreenInfo(pScreenPriv);
-	ATICardInfo(pScreenPriv);
-	char *mmio = atic->reg_base;
-
-	if (atic->is_radeon) {
-		MMIO_OUT32(mmio, RADEON_REG_ME_CNTL, 0);
-		MMIO_OUT32(mmio, RADEON_REG_CP_CSQ_CNTL,
-		    RADEON_CSQ_PRIDIS_INDDIS);
-	} else {
-		MMIO_OUT32(mmio, ATI_REG_CCE_WPTR,
-		    atis->ring_write | R128_PM4_BUFFER_DL_DONE);
-		MMIO_OUT32(mmio, R128_REG_PM4_MICRO_CNTL, 0);
-		MMIO_OUT32(mmio, R128_REG_PM4_BUFFER_CNTL,
-		    R128_PM4_NONPM4 | R128_PM4_BUFFER_CNTL_NOUPDATE);
-	}
-	atis->cce_pri_size = 0;
-
-	ATIEngineReset(atis);
-
-	if (atis->using_agp)
-		ATIFiniAGP(pScreen);
-	else
-		KdOffscreenFree(pScreen, atis->dma_space);
-
-	return TRUE;
-}
-
-void
-ATIDMASetup(ScreenPtr pScreen)
-{
-	KdScreenPriv(pScreen);
-	ATICardInfo(pScreenPriv);
-	ATIScreenInfo(pScreenPriv);
-
-#ifdef USE_DRI
-	if (atis->using_dri)
-		ATIDRIDMAStart(atis);
-#endif /* USE_DRI */
-
-	if (!atis->using_dri) {
-		atis->using_agp = FALSE;
-		if (atic->is_agp && ATIDMAInit(pScreen, TRUE)) {
-			atis->using_agp = TRUE;
-			atis->using_dma = TRUE;
-		} else if (ATIDMAInit(pScreen, FALSE)) {
-			atis->using_agp = FALSE;
-			atis->using_dma = TRUE;
-		} else if (ATIPseudoDMAInit(pScreen))
-			atis->using_pseudo = TRUE;
-		else
-			atis->using_pio = TRUE;
-	}
-
-	atis->indirectBuffer = ATIGetDMABuffer(atis);
-	if (atis->indirectBuffer == FALSE)
-		FatalError("Failed to allocate DMA buffer.\n");
-
-	if (atis->using_dri)
-		ErrorF("Initialized %s DRI DMA\n",
-		    atis->using_agp ? "AGP" : "PCI");
-	else if (atis->using_dma && atis->using_agp)
-		ErrorF("Initialized AGP DMA\n");
-	else if (atis->using_dma)
-		ErrorF("Initialized framebuffer pseudo-DMA\n");
-	else if (atis->using_pseudo)
-		ErrorF("Initialized pseudo-DMA\n");
-	else if (atis->using_pio)
-		ErrorF("Initialized PIO\n");
-}
-
-void
-ATIDMATeardown(ScreenPtr pScreen)
-{
-	KdScreenPriv(pScreen);
-	ATIScreenInfo(pScreenPriv);
-
-	ATIWaitIdle(atis);
-
-#ifdef USE_DRI
-	if (atis->using_dri)
-		ATIDRIDMAStop(atis);
-#endif /* USE_DRI */
-
-	if (atis->using_dma)
-		ATIDMAFini(pScreen);
-
-	if (atis->using_pseudo)
-		ATIPseudoDMAFini(pScreen);
-
-	if (atis->using_pio || atis->using_pseudo || atis->using_dma) {
-		xfree(atis->indirectBuffer->address);
-		xfree(atis->indirectBuffer);
-	}
-	atis->indirectBuffer = NULL;
-
-	atis->using_pio = FALSE;
-	atis->using_pseudo = FALSE;
-	atis->using_dma = FALSE;
-	atis->using_agp = FALSE;
-}
-
diff --git a/hw/kdrive/ati/ati_dma.h b/hw/kdrive/ati/ati_dma.h
deleted file mode 100644
index 4c2092b..0000000
--- a/hw/kdrive/ati/ati_dma.h
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * Copyright © 2004 Eric Anholt
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Eric Anholt not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  Eric Anholt makes no
- * representations about the suitability of this software for any purpose.  It
- * is provided "as is" without express or implied warranty.
- *
- * ERIC ANHOLT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL ERIC ANHOLT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifndef _ATI_DMA_H_
-#define _ATI_DMA_H_
-
-#define CCE_DEBUG 1
-
-#if !CCE_DEBUG
-#define DMA_PACKET0(reg, count)						\
-	(ATI_CCE_PACKET0 | (((count) - 1) << 16) | ((reg) >> 2))
-#else
-#define DMA_PACKET0(reg, count)						\
-	(__packet0count = (count), __reg = (reg),			\
-	ATI_CCE_PACKET0 | (((count) - 1) << 16) | ((reg) >> 2))
-#endif
-#define DMA_PACKET1(reg1, reg2)						\
-	(ATI_CCE_PACKET1 |						\
-	(((reg2) >> 2) << ATI_CCE_PACKET1_REG_2_SHIFT) |  ((reg1) >> 2))
-#define DMA_PACKET3(type, count)					\
-	((type) | (((count) - 1) << 16))
-
-#if !CCE_DEBUG
-
-#define RING_LOCALS	CARD32 *__head; int __count
-#define BEGIN_DMA(n)							\
-do {									\
-	if ((atis->indirectBuffer->used + 4*(n)) >			\
-	    atis->indirectBuffer->size) {				\
-		ATIFlushIndirect(atis, 1);				\
-	}								\
-	__head = (CARD32 *)((char *)atis->indirectBuffer->address +	\
-	    atis->indirectBuffer->used);				\
-	__count = 0;							\
-} while (0)
-#define END_DMA() do {							\
-	atis->indirectBuffer->used += __count * 4;			\
-} while (0)
-
-#else
-
-#define RING_LOCALS	\
-	CARD32 *__head; int __count, __total, __reg, __packet0count
-#define BEGIN_DMA(n)							\
-do {									\
-	if ((atis->indirectBuffer->used + 4*(n)) >			\
-	    atis->indirectBuffer->size) {				\
-		ATIFlushIndirect(atis, 1);				\
-	}								\
-	__head = (CARD32 *)((char *)atis->indirectBuffer->address +	\
-	    atis->indirectBuffer->used);				\
-	__count = 0;							\
-	__total = n;							\
-	__reg = 0;								\
-	__packet0count = 0;								\
-} while (0)
-#define END_DMA() do {							\
-	if (__count != __total)						\
-		FatalError("count != total (%d vs %d) at %s:%d\n",	 \
-		     __count, __total, __FILE__, __LINE__);		\
-	atis->indirectBuffer->used += __count * 4;			\
-} while (0)
-
-#endif
-
-#define OUT_RING(val) do {						\
-	__head[__count++] = (val);					\
-} while (0)
-
-#define OUT_RING_REG(reg, val) do {					\
-	if (__reg != reg)						\
-		FatalError("unexpected reg (0x%x vs 0x%x) at %s:%d\n",	\
-		    reg, __reg, __FILE__, __LINE__);			\
-	if (__packet0count-- <= 0)					\
-		FatalError("overrun of packet0 at %s:%d\n",		\
-		    __FILE__, __LINE__);				\
-	__head[__count++] = (val);					\
-	__reg += 4;							\
-} while (0)
-
-#define OUT_RING_F(x) OUT_RING(GET_FLOAT_BITS(x))
-
-#define OUT_REG(reg, val)						\
-do {									\
-	OUT_RING(DMA_PACKET0(reg, 1));					\
-	OUT_RING(val);							\
-} while (0)
-
-#define TIMEOUT_LOCALS struct timeval _target, _curtime
-
-static inline Bool
-tv_le(struct timeval *tv1, struct timeval *tv2)
-{
-	if (tv1->tv_sec < tv2->tv_sec ||
-	    (tv1->tv_sec == tv2->tv_sec && tv1->tv_usec < tv2->tv_usec))
-		return TRUE;
-	else
-		return FALSE;
-}
-
-#define WHILE_NOT_TIMEOUT(_timeout)					\
-	gettimeofday(&_target, NULL);					\
-	_target.tv_usec += ((_timeout) * 1000000);			\
-	_target.tv_sec += _target.tv_usec / 1000000;			\
-	_target.tv_usec = _target.tv_usec % 1000000;			\
-	while (gettimeofday(&_curtime, NULL), tv_le(&_curtime, &_target))
-
-#define TIMEDOUT()	(!tv_le(&_curtime, &_target))
-
-dmaBuf *
-ATIGetDMABuffer(ATIScreenInfo *atis);
-
-void
-ATIFlushIndirect(ATIScreenInfo *atis, Bool discard);
-
-void
-ATIDMASetup(ScreenPtr pScreen);
-
-void
-ATIDMATeardown(ScreenPtr pScreen);
-
-#endif /* _ATI_DMA_H_ */
diff --git a/hw/kdrive/ati/ati_draw.c b/hw/kdrive/ati/ati_draw.c
deleted file mode 100644
index c10fea4..0000000
--- a/hw/kdrive/ati/ati_draw.c
+++ /dev/null
@@ -1,918 +0,0 @@
-/*
- * Copyright © 2003 Eric Anholt
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Eric Anholt not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  Eric Anholt makes no
- * representations about the suitability of this software for any purpose.  It
- * is provided "as is" without express or implied warranty.
- *
- * ERIC ANHOLT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL ERIC ANHOLT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <kdrive-config.h>
-#endif
-#include "ati.h"
-#include "ati_reg.h"
-#include "ati_dma.h"
-#include "ati_draw.h"
-#include "kaa.h"
-
-CARD8 ATISolidRop[16] = {
-    /* GXclear      */      0x00,         /* 0 */
-    /* GXand        */      0xa0,         /* src AND dst */
-    /* GXandReverse */      0x50,         /* src AND NOT dst */
-    /* GXcopy       */      0xf0,         /* src */
-    /* GXandInverted*/      0x0a,         /* NOT src AND dst */
-    /* GXnoop       */      0xaa,         /* dst */
-    /* GXxor        */      0x5a,         /* src XOR dst */
-    /* GXor         */      0xfa,         /* src OR dst */
-    /* GXnor        */      0x05,         /* NOT src AND NOT dst */
-    /* GXequiv      */      0xa5,         /* NOT src XOR dst */
-    /* GXinvert     */      0x55,         /* NOT dst */
-    /* GXorReverse  */      0xf5,         /* src OR NOT dst */
-    /* GXcopyInverted*/     0x0f,         /* NOT src */
-    /* GXorInverted */      0xaf,         /* NOT src OR dst */
-    /* GXnand       */      0x5f,         /* NOT src OR NOT dst */
-    /* GXset        */      0xff,         /* 1 */
-};
-
-CARD8 ATIBltRop[16] = {
-    /* GXclear      */      0x00,         /* 0 */
-    /* GXand        */      0x88,         /* src AND dst */
-    /* GXandReverse */      0x44,         /* src AND NOT dst */
-    /* GXcopy       */      0xcc,         /* src */
-    /* GXandInverted*/      0x22,         /* NOT src AND dst */
-    /* GXnoop       */      0xaa,         /* dst */
-    /* GXxor        */      0x66,         /* src XOR dst */
-    /* GXor         */      0xee,         /* src OR dst */
-    /* GXnor        */      0x11,         /* NOT src AND NOT dst */
-    /* GXequiv      */      0x99,         /* NOT src XOR dst */
-    /* GXinvert     */      0x55,         /* NOT dst */
-    /* GXorReverse  */      0xdd,         /* src OR NOT dst */
-    /* GXcopyInverted*/     0x33,         /* NOT src */
-    /* GXorInverted */      0xbb,         /* NOT src OR dst */
-    /* GXnand       */      0x77,         /* NOT src OR NOT dst */
-    /* GXset        */      0xff,         /* 1 */
-};
-
-int copydx, copydy;
-ATIScreenInfo *accel_atis;
-/* If is_24bpp is set, then we are using the accelerator in 8-bit mode due
- * to it being broken for 24bpp, so coordinates have to be multiplied by 3.
- */
-Bool is_24bpp;
-CARD32 settings, color, src_pitch_offset, dst_pitch_offset;
-
-int sample_count;
-float sample_offsets_x[255];
-float sample_offsets_y[255];
-
-#define DRAW_USING_PACKET3 0
-
-void
-ATIDrawSetup(ScreenPtr pScreen)
-{
-	KdScreenPriv(pScreen);
-	ATIScreenInfo(pScreenPriv);
-	ATICardInfo(pScreenPriv);
-	RING_LOCALS;
-
-	/* XXX: this shouldn't be necessary, but fixes some R128 composite
-	 * issues.
-	 */
-	/*if (!atic->is_radeon) {
-		char *mmio = atic->reg_base;
-		ATIWaitIdle(atis);
-		MMIO_OUT32(mmio, R128_REG_PC_GUI_MODE,
-		    R128_PC_BYPASS_EN);
-	}*/
-
-	BEGIN_DMA(2);
-	OUT_REG(ATI_REG_DEFAULT_SC_BOTTOM_RIGHT,
-	    ATI_DEFAULT_SC_RIGHT_MAX | ATI_DEFAULT_SC_BOTTOM_MAX);
-	END_DMA();
-
-	if (!atic->is_radeon) {
-		/* Setup for R128 Composite */
-		BEGIN_DMA(12);
-		OUT_REG(R128_REG_SCALE_3D_CNTL,
-		    R128_SCALE_3D_TEXMAP_SHADE |
-		    R128_SCALE_PIX_REPLICATE |
-		    R128_TEX_CACHE_SPLIT |
-		    R128_TEX_MAP_ALPHA_IN_TEXTURE |
-		    R128_TEX_CACHE_LINE_SIZE_4QW);
-		OUT_REG(R128_REG_SETUP_CNTL,
-		    R128_COLOR_SOLID_COLOR |
-		    R128_PRIM_TYPE_TRI |
-		    R128_TEXTURE_ST_MULT_W |
-		    R128_STARTING_VERTEX_1 |
-		    R128_ENDING_VERTEX_3 |
-		    R128_SUB_PIX_4BITS);
-		OUT_REG(R128_REG_PM4_VC_FPU_SETUP,
-		    R128_FRONT_DIR_CCW |
-		    R128_BACKFACE_CULL |
-		    R128_FRONTFACE_SOLID |
-		    R128_FPU_COLOR_SOLID |
-		    R128_FPU_SUB_PIX_4BITS |
-		    R128_FPU_MODE_3D |
-		    R128_TRAP_BITS_DISABLE |
-		    R128_XFACTOR_2 |
-		    R128_YFACTOR_2 |
-		    R128_FLAT_SHADE_VERTEX_OGL |
-		    R128_FPU_ROUND_TRUNCATE |
-		    R128_WM_SEL_8DW);
-		OUT_REG(R128_REG_PLANE_3D_MASK_C, 0xffffffff);
-		OUT_REG(R128_REG_CONSTANT_COLOR_C, 0xff000000);
-		OUT_REG(R128_REG_WINDOW_XY_OFFSET, 0x00000000);
-		END_DMA();
-	} else if (!atic->is_r300) {
-		/* Setup for R100/R200 Composite */
-		BEGIN_DMA(8);
-		OUT_REG(RADEON_REG_RE_TOP_LEFT, 0);
-		OUT_REG(RADEON_REG_RE_WIDTH_HEIGHT, 0xffffffff);
-		OUT_REG(RADEON_REG_RB3D_PLANEMASK, 0xffffffff);
-		OUT_REG(RADEON_REG_SE_CNTL,
-		    RADEON_FFACE_CULL_CCW |
-		    RADEON_FFACE_SOLID |
-		    RADEON_VTX_PIX_CENTER_OGL);
-		END_DMA();
-
-		if (atic->is_r100) {
-			BEGIN_DMA(6);
-			OUT_REG(RADEON_REG_SE_CNTL_STATUS, RADEON_TCL_BYPASS);
-			OUT_REG(RADEON_REG_SE_COORD_FMT,
-			    RADEON_VTX_XY_PRE_MULT_1_OVER_W0 |
-			    RADEON_VTX_ST0_NONPARAMETRIC |
-			    RADEON_VTX_ST1_NONPARAMETRIC |
-			    RADEON_TEX1_W_ROUTING_USE_W0);
-			OUT_REG(RADEON_REG_RB3D_DSTCACHE_MODE, 
-				RADEON_RB3D_DC_2D_CACHE_AUTOFLUSH |
-				RADEON_RB3D_DC_3D_CACHE_AUTOFLUSH);
-			END_DMA();
-		} else {
-			BEGIN_DMA(18);
-			/* XXX: The 0 below should be RADEON_TCL_BYPASS on
-			 * RS300s.
-			 */
-			OUT_REG(R200_REG_SE_VAP_CNTL_STATUS, 0);
-			OUT_REG(R200_REG_PP_CNTL_X, 0);
-			OUT_REG(R200_REG_PP_TXMULTI_CTL_0, 0);
-			OUT_REG(R200_REG_SE_VTX_STATE_CNTL, 0);
-			OUT_REG(R200_REG_RE_CNTL, 0);
-			/* XXX: VTX_ST_DENORMALIZED is illegal for the case of
-			 * repeating textures.
-			 */
-			OUT_REG(R200_REG_SE_VTE_CNTL, R200_VTX_ST_DENORMALIZED);
-			OUT_REG(R200_REG_SE_VAP_CNTL,
-			    R200_VAP_FORCE_W_TO_ONE |
-			    R200_VAP_VF_MAX_VTX_NUM);
-			OUT_REG(R200_REG_RE_AUX_SCISSOR_CNTL, 0);
-			OUT_REG(RADEON_REG_RB3D_DSTCACHE_MODE, 
-				RADEON_RB3D_DC_2D_CACHE_AUTOFLUSH |
-				RADEON_RB3D_DC_3D_CACHE_AUTOFLUSH |
-				R200_RB3D_DC_2D_CACHE_AUTOFREE |
-				R200_RB3D_DC_3D_CACHE_AUTOFREE);
-			END_DMA();
-		}
-	}
-}
-
-static void
-ATIWaitMarker(ScreenPtr pScreen, int marker)
-{
-	KdScreenPriv(pScreen);
-	ATIScreenInfo(pScreenPriv);
-
-	ENTER_DRAW(0);
-	ATIWaitIdle(atis);
-	LEAVE_DRAW(0);
-}
-
-void
-RadeonSwitchTo2D(ATIScreenInfo *atis)
-{
-	RING_LOCALS;
-
-	ENTER_DRAW(0);
-	BEGIN_DMA(4);
-	OUT_REG(RADEON_REG_RB3D_DSTCACHE_CTLSTAT, RADEON_RB3D_DC_FLUSH);
-	OUT_REG(ATI_REG_WAIT_UNTIL,
-	    RADEON_WAIT_HOST_IDLECLEAN | RADEON_WAIT_3D_IDLECLEAN);
-	END_DMA();
-	LEAVE_DRAW(0);
-}
-
-void
-RadeonSwitchTo3D(ATIScreenInfo *atis)
-{
-	RING_LOCALS;
-
-	ENTER_DRAW(0);
-	BEGIN_DMA(4);
-	OUT_REG(RADEON_REG_RB3D_DSTCACHE_CTLSTAT, RADEON_RB3D_DC_FLUSH);
-	/* We must wait for 3d to idle, in case source was just written as a dest. */
-	OUT_REG(ATI_REG_WAIT_UNTIL,
-	    RADEON_WAIT_HOST_IDLECLEAN | RADEON_WAIT_2D_IDLECLEAN | RADEON_WAIT_3D_IDLECLEAN);
-	END_DMA();
-	LEAVE_DRAW(0);
-}
-
-#if ATI_TRACE_DRAW
-void
-ATIEnterDraw (PixmapPtr pPix, char *function)
-{
-    if (pPix != NULL) {
-	KdScreenPriv(pPix->drawable.pScreen);
-	CARD32 offset;
-    
-	offset = ((CARD8 *)pPix->devPrivate.ptr -
-		  pScreenPriv->screen->memory_base);
-    
-	ErrorF ("Enter %s 0x%x (%dx%dx%d/%d)\n", function, offset,
-	    pPix->drawable.width, pPix->drawable.height, pPix->drawable.depth,
-	    pPix->drawable.bitsPerPixel);
-    } else
-	ErrorF ("Enter %s\n", function);
-}
-
-void
-ATILeaveDraw (PixmapPtr pPix, char *function)
-{
-    if (pPix != NULL) {
-	KdScreenPriv(pPix->drawable.pScreen);
-	CARD32 offset;
-    
-	offset = ((CARD8 *)pPix->devPrivate.ptr -
-		  pScreenPriv->screen->memory_base);
-    
-	ErrorF ("Leave %s 0x%x\n", function, offset);
-    } else
-	ErrorF ("Leave %s\n", function);
-}
-#endif
-
-/* Assumes that depth 15 and 16 can be used as depth 16, which is okay since we
- * require src and dest datatypes to be equal.
- */
-static Bool
-ATIGetDatatypeBpp(int bpp, CARD32 *type)
-{
-	switch (bpp) {
-	case 8:
-		*type = R128_DATATYPE_CI8;
-		return TRUE;
-	case 16:
-		*type = R128_DATATYPE_RGB565;
-		return TRUE;
-	case 24:
-		*type = R128_DATATYPE_CI8;
-		return TRUE;
-	case 32:
-		*type = R128_DATATYPE_ARGB8888;
-		return TRUE;
-	default:
-		ATI_FALLBACK(("Unsupported bpp: %d\n", bpp));
-		return FALSE;
-	}
-}
-
-Bool
-ATIGetOffsetPitch(ATIScreenInfo *atis, int bpp, CARD32 *pitch_offset,
-    int offset, int pitch)
-{
-	ATICardInfo *atic = atis->atic;
-
-	/* On the R128, depending on the bpp the screen can be set up so that it
-	 * doesn't meet the pitchAlign requirement but can still be
-	 * accelerated, so we check the specific pitch requirement of alignment
-	 * to 8 pixels.
-	 */
-	if (atic->is_radeon) {
-		if (pitch % atis->kaa.pitchAlign != 0)
-			ATI_FALLBACK(("Bad pitch 0x%08x\n", pitch));
-		*pitch_offset = ((pitch >> 6) << 22) | (offset >> 10);
-
-	} else {
-		if (pitch % bpp != 0)
-			ATI_FALLBACK(("Bad pitch 0x%08x\n", pitch));
-		*pitch_offset = ((pitch / bpp) << 21) | (offset >> 5);
-	}
-
-	if (offset % atis->kaa.offsetAlign != 0)
-		ATI_FALLBACK(("Bad offset 0x%08x\n", offset));
-
-	return TRUE;
-}
-
-Bool
-ATIGetPixmapOffsetPitch(PixmapPtr pPix, CARD32 *pitch_offset)
-{
-	KdScreenPriv(pPix->drawable.pScreen);
-	ATIScreenInfo(pScreenPriv);
-	CARD32 pitch, offset;
-	int bpp;
-
-	bpp = pPix->drawable.bitsPerPixel;
-	if (bpp == 24)
-		bpp = 8;
-
-	offset = ((CARD8 *)pPix->devPrivate.ptr -
-	    pScreenPriv->screen->memory_base);
-	pitch = pPix->devKind;
-
-	return ATIGetOffsetPitch(atis, bpp, pitch_offset, offset, pitch);
-}
-
-static Bool
-ATIPrepareSolid(PixmapPtr pPix, int alu, Pixel pm, Pixel fg)
-{
-	KdScreenPriv(pPix->drawable.pScreen);
-	ATIScreenInfo(pScreenPriv);
-	ATICardInfo(pScreenPriv);
-	CARD32 datatype;
-	RING_LOCALS;
-
-	is_24bpp = (pPix->drawable.bitsPerPixel == 24);
-	accel_atis = atis;
-
-	if (is_24bpp) {
-		/* Solid fills in fake-24bpp mode only work if the pixel color
-		 * and planemask are all the same byte.
-		 */
-		if ((fg & 0xffffff) != (((fg & 0xff) << 16) | ((fg >> 8) &
-		    0xffff)))
-			ATI_FALLBACK(("Can't do solid color 0x%08x in 24bpp\n",
-			    fg));
-		if ((pm & 0xffffff) != (((pm & 0xff) << 16) | ((pm >> 8) &
-		    0xffff)))
-			ATI_FALLBACK(("Can't do planemask 0x%08x in 24bpp\n",
-			    pm));
-	}
-
-	if (!ATIGetDatatypeBpp(pPix->drawable.bitsPerPixel, &datatype))
-		return FALSE;
-	if (!ATIGetPixmapOffsetPitch(pPix, &dst_pitch_offset))
-		return FALSE;
-
-	ENTER_DRAW(pPix);
-
-	if (atic->is_radeon)
-		RadeonSwitchTo2D(atis);
-
-	settings =
-	    ATI_GMC_DST_PITCH_OFFSET_CNTL |
-	    ATI_GMC_BRUSH_SOLID_COLOR |
-	    (datatype << 8) |
-	    ATI_GMC_SRC_DATATYPE_COLOR |
-	    (ATISolidRop[alu] << 16) |
-	    ATI_GMC_CLR_CMP_CNTL_DIS |
-	    R128_GMC_AUX_CLIP_DIS;
-	color = fg;
-
-#if DRAW_USING_PACKET3
-	BEGIN_DMA(6);
-	OUT_REG(ATI_REG_DEFAULT_SC_BOTTOM_RIGHT,
-	    ATI_DEFAULT_SC_RIGHT_MAX | ATI_DEFAULT_SC_BOTTOM_MAX);
-	OUT_REG(ATI_REG_DP_WRITE_MASK, pm);
-	OUT_REG(ATI_REG_DP_CNTL, ATI_DST_X_LEFT_TO_RIGHT |
-	    ATI_DST_Y_TOP_TO_BOTTOM);
-	END_DMA();
-#else
-	BEGIN_DMA(12);
-	OUT_REG(ATI_REG_DEFAULT_SC_BOTTOM_RIGHT,
-	    ATI_DEFAULT_SC_RIGHT_MAX | ATI_DEFAULT_SC_BOTTOM_MAX);
-	OUT_REG(ATI_REG_DST_PITCH_OFFSET, dst_pitch_offset);
-	OUT_REG(ATI_REG_DP_GUI_MASTER_CNTL, settings);
-	OUT_REG(ATI_REG_DP_BRUSH_FRGD_CLR, fg);
-	OUT_REG(ATI_REG_DP_WRITE_MASK, pm);
-	OUT_REG(ATI_REG_DP_CNTL, ATI_DST_X_LEFT_TO_RIGHT |
-	    ATI_DST_Y_TOP_TO_BOTTOM);
-	END_DMA();
-#endif
-
-	LEAVE_DRAW(pPix);
-	return TRUE;
-}
-
-static void
-ATISolid(int x1, int y1, int x2, int y2)
-{
-	ENTER_DRAW(0);
-	ATIScreenInfo *atis = accel_atis;
-	RING_LOCALS;
-	
-	if (is_24bpp) {
-		x1 *= 3;
-		x2 *= 3;
-	}
-#if DRAW_USING_PACKET3
-	BEGIN_DMA(6);
-	OUT_RING(DMA_PACKET3(ATI_CCE_PACKET3_PAINT_MULTI, 5));
-	OUT_RING(settings);
-	OUT_RING(dst_pitch_offset);
-	OUT_RING(color);
-	OUT_RING((x1 << 16) | y1);
-	OUT_RING(((x2 - x1) << 16) | (y2 - y1));
-	END_DMA();
-#else
-	BEGIN_DMA(3);
-	OUT_RING(DMA_PACKET0(ATI_REG_DST_Y_X, 2));
-	OUT_RING_REG(ATI_REG_DST_Y_X, (y1 << 16) | x1);
-	OUT_RING_REG(ATI_REG_DST_HEIGHT_WIDTH, ((y2 - y1) << 16) | (x2 - x1));
-	END_DMA();
-#endif
-	LEAVE_DRAW(0);
-}
-
-static void
-ATIDoneSolid(void)
-{
-	ENTER_DRAW(0);
-	LEAVE_DRAW(0);
-}
-
-static Bool
-ATIPrepareCopy(PixmapPtr pSrc, PixmapPtr pDst, int dx, int dy, int alu, Pixel pm)
-{
-	KdScreenPriv(pDst->drawable.pScreen);
-	ATIScreenInfo(pScreenPriv);
-	ATICardInfo(pScreenPriv);
-	CARD32 datatype;
-	RING_LOCALS;
-
-	copydx = dx;
-	copydy = dy;
-	is_24bpp = pDst->drawable.bitsPerPixel == 24;
-	accel_atis = atis;
-
-	if (is_24bpp && ((pm & 0xffffff) != (((pm & 0xff) << 16) | ((pm >> 8) &
-	    0xffff))))
-		ATI_FALLBACK(("Can't do planemask 0x%08x in 24bpp\n", pm));
-
-	if (!ATIGetDatatypeBpp(pDst->drawable.bitsPerPixel, &datatype))
-		return FALSE;
-	if (!ATIGetPixmapOffsetPitch(pSrc, &src_pitch_offset))
-		return FALSE;
-	if (!ATIGetPixmapOffsetPitch(pDst, &dst_pitch_offset))
-		return FALSE;
-
-	ENTER_DRAW (pDst);
-	if (atic->is_radeon)
-		RadeonSwitchTo2D(atis);
-
-	settings =
-	    ATI_GMC_SRC_PITCH_OFFSET_CNTL |
-	    ATI_GMC_DST_PITCH_OFFSET_CNTL |
-	    ATI_GMC_BRUSH_NONE |
-	    (datatype << 8) |
-	    ATI_GMC_SRC_DATATYPE_COLOR |
-	    (ATIBltRop[alu] << 16) |
-	    ATI_DP_SRC_SOURCE_MEMORY |
-	    ATI_GMC_CLR_CMP_CNTL_DIS |
-	    R128_GMC_AUX_CLIP_DIS;
-
-#if DRAW_USING_PACKET3
-	BEGIN_DMA(6);
-	OUT_REG(ATI_REG_DEFAULT_SC_BOTTOM_RIGHT,
-	    ATI_DEFAULT_SC_RIGHT_MAX | ATI_DEFAULT_SC_BOTTOM_MAX);
-	OUT_REG(ATI_REG_DP_WRITE_MASK, pm);
-	OUT_REG(ATI_REG_DP_CNTL,
-	    (dx >= 0 ? ATI_DST_X_LEFT_TO_RIGHT : 0) |
-	    (dy >= 0 ? ATI_DST_Y_TOP_TO_BOTTOM : 0));
-	END_DMA();
-
-#else
-	BEGIN_DMA(12);
-	OUT_REG(ATI_REG_DEFAULT_SC_BOTTOM_RIGHT,
-	    ATI_DEFAULT_SC_RIGHT_MAX | ATI_DEFAULT_SC_BOTTOM_MAX);
-	OUT_REG(ATI_REG_SRC_PITCH_OFFSET, src_pitch_offset);
-	OUT_REG(ATI_REG_DST_PITCH_OFFSET, dst_pitch_offset);
-	OUT_REG(ATI_REG_DP_GUI_MASTER_CNTL, settings);
-	OUT_REG(ATI_REG_DP_WRITE_MASK, pm);
-	OUT_REG(ATI_REG_DP_CNTL,
-	    (dx >= 0 ? ATI_DST_X_LEFT_TO_RIGHT : 0) |
-	    (dy >= 0 ? ATI_DST_Y_TOP_TO_BOTTOM : 0));
-	END_DMA();
-#endif
-	LEAVE_DRAW(pDst);
-
-	return TRUE;
-}
-
-static void
-ATICopy(int srcX, int srcY, int dstX, int dstY, int w, int h)
-{
-	ATIScreenInfo *atis = accel_atis;
-	RING_LOCALS;
-
-	if (is_24bpp) {
-		srcX *= 3;
-		dstX *= 3;
-		w *= 3;
-	}
-
-#if !DRAW_USING_PACKET3
-	if (copydx < 0) {
-		srcX += w - 1;
-		dstX += w - 1;
-	}
-
-	if (copydy < 0)  {
-		srcY += h - 1;
-		dstY += h - 1;
-	}
-#endif
-
-#if DRAW_USING_PACKET3
-	BEGIN_DMA(7);
-	OUT_RING(DMA_PACKET3(ATI_CCE_PACKET3_BITBLT_MULTI, 6));
-	OUT_RING(settings);
-	OUT_RING(src_pitch_offset);
-	OUT_RING(dst_pitch_offset);
-	OUT_RING((srcX << 16) | srcY);
-	OUT_RING((dstX << 16) | dstY);
-	OUT_RING((w << 16) | h);
-	END_DMA();
-#else
-	BEGIN_DMA(4);
-	OUT_RING(DMA_PACKET0(ATI_REG_SRC_Y_X, 3));
-	OUT_RING_REG(ATI_REG_SRC_Y_X, (srcY << 16) | srcX);
-	OUT_RING_REG(ATI_REG_DST_Y_X, (dstY << 16) | dstX);
-	OUT_RING_REG(ATI_REG_DST_HEIGHT_WIDTH, (h << 16) | w);
-	END_DMA();
-#endif
-}
-
-static void
-ATIDoneCopy(void)
-{
-}
-
-static Bool
-ATIUploadToScreen(PixmapPtr pDst, char *src, int src_pitch)
-{
-	ScreenPtr pScreen = pDst->drawable.pScreen;
-	KdScreenPriv(pScreen);
-	ATIScreenInfo(pScreenPriv);
-	ATICardInfo(pScreenPriv);
-	int width, height, bpp, i, dwords;
-	int dst_pitch, dst_offset;
-	CARD32 dst_pitch_offset, datatype;
-	Bool success;
-	RING_LOCALS;
-
-	ENTER_DRAW (pDst);
-
-	LEAVE_DRAW (pDst);
-	/* XXX: Hostdata uploads aren't working yet. */
-	return FALSE;
-	
-	dst_offset = ((CARD8 *)pDst->devPrivate.ptr -
-	    pScreenPriv->screen->memory_base);
-	dst_pitch = pDst->devKind;
-	width = pDst->drawable.width;
-	height = pDst->drawable.height;
-	bpp =  pDst->drawable.bitsPerPixel;
-
-	success = ATIGetDatatypeBpp(bpp, &datatype);
-
-	if (bpp == 24) {
-		is_24bpp = TRUE;
-		bpp = 8;
-	} else
-		is_24bpp = FALSE;
-
-	if (!ATIGetOffsetPitch(atis, bpp, &dst_pitch_offset, dst_offset,
-	    dst_pitch))
-		return FALSE;
-
-	if (src_pitch != (width * bpp / 8))
-		return FALSE;
-
-	/* No PACKET3 packets when in PIO mode. */
-	if (atis->using_pio)
-		return FALSE;
-
-	dwords = (width * height * (bpp / 8) + 3) / 4;
-
-	/* Flush pixel cache so nothing being written to the destination
-	 * previously gets mixed up with the hostdata blit.
-	 */
-	if (atic->is_radeon) {
-		BEGIN_DMA(4);
-		OUT_REG(RADEON_REG_RB3D_DSTCACHE_CTLSTAT, RADEON_RB3D_DC_FLUSH);
-		OUT_REG(ATI_REG_WAIT_UNTIL,
-		    RADEON_WAIT_2D_IDLECLEAN |
-		    RADEON_WAIT_3D_IDLECLEAN |
-		    RADEON_WAIT_HOST_IDLECLEAN);
-		END_DMA();
-	} else {
-		BEGIN_DMA(2);
-		OUT_REG(R128_REG_PC_GUI_CTLSTAT,
-		    R128_PC_FLUSH_GUI | R128_PC_RI_GUI);
-		END_DMA();
-	}
-
-	BEGIN_DMA(8);
-	OUT_RING(DMA_PACKET3(ATI_CCE_PACKET3_HOSTDATA_BLT, 7 + dwords));
-	OUT_RING(ATI_GMC_DST_PITCH_OFFSET_CNTL |
-	    ATI_GMC_BRUSH_NONE |
-	    (datatype << 8) |
-	    ATI_GMC_SRC_DATATYPE_COLOR |
-	    (ATISolidRop[GXcopy] << 16) |
-	    ATI_DP_SRC_SOURCE_HOST_DATA |
-	    ATI_GMC_CLR_CMP_CNTL_DIS |
-	    R128_GMC_AUX_CLIP_DIS |
-	    ATI_GMC_WR_MSK_DIS);
-	OUT_RING(dst_pitch_offset);
-	OUT_RING(0xffffffff);
-	OUT_RING(0xffffffff);
-	OUT_RING((0 << 16) | 0);
-	OUT_RING((height << 16) | width);
-	OUT_RING(dwords);
-	END_DMA();
-
-	for (i = 0; i < dwords; i++) {
-		BEGIN_DMA(1);
-		OUT_RING(((CARD32 *)src)[i]);
-		END_DMA();
-	}
-
-	if (atic->is_radeon) {
-		BEGIN_DMA(4);
-		OUT_REG(RADEON_REG_RB3D_DSTCACHE_CTLSTAT,
-		    RADEON_RB3D_DC_FLUSH_ALL);
-		OUT_REG(ATI_REG_WAIT_UNTIL,
-		    RADEON_WAIT_2D_IDLECLEAN |
-		    RADEON_WAIT_HOST_IDLECLEAN);
-		END_DMA();
-	} else {
-		BEGIN_DMA(2);
-		OUT_REG(R128_REG_PC_GUI_CTLSTAT, R128_PC_FLUSH_GUI);
-		END_DMA();
-	}
-
-	kaaMarkSync(pScreen);
-
-	ErrorF("hostdata upload %d,%d %dbpp\n", width, height, bpp);
-
-	return TRUE;
-}
-
-
-static Bool
-ATIUploadToScratch(PixmapPtr pSrc, PixmapPtr pDst)
-{
-	KdScreenPriv(pSrc->drawable.pScreen);
-	ATICardInfo(pScreenPriv);
-	ATIScreenInfo(pScreenPriv);
-	int dst_pitch, src_pitch, w, i, size, bytes;
-	unsigned char *dst, *src;
-	RING_LOCALS;
-
-	ENTER_DRAW(pSrc);
-	/* Align width to log 2, useful for R128 composite.  This should be a
-	 * KAA flag we check for (and supported in kaa.c in general) since many
-	 * older bits of hardware are going to want POT pitches.
-	 */
-	w = pSrc->drawable.width;
-	if (atis->kaa.flags & KAA_OFFSCREEN_ALIGN_POT)
-		w = 1 << (ATILog2(w - 1) + 1);
-	dst_pitch = (w * pSrc->drawable.bitsPerPixel / 8 +
-	    atis->kaa.pitchAlign - 1) & ~(atis->kaa.pitchAlign - 1);
-
-	size = dst_pitch * pSrc->drawable.height;
-	if (size > atis->scratch_area->size)
-		ATI_FALLBACK(("Pixmap too large for scratch (%d,%d)\n",
-		    pSrc->drawable.width, pSrc->drawable.height));
-
-	atis->scratch_next = (atis->scratch_next + atis->kaa.offsetAlign - 1) &
-	    ~(atis->kaa.offsetAlign - 1);
-	if (atis->scratch_next + size > atis->scratch_area->offset +
-	    atis->scratch_area->size) {
-		/* Only sync when we've used all of the scratch area. */
-		kaaWaitSync(pSrc->drawable.pScreen);
-		atis->scratch_next = atis->scratch_area->offset;
-	}
-	memcpy(pDst, pSrc, sizeof(*pDst));
-	pDst->devKind = dst_pitch;
-	pDst->devPrivate.ptr = pScreenPriv->screen->memory_base +
-	    atis->scratch_next;
-	atis->scratch_next += size;
-
-	src = pSrc->devPrivate.ptr;
-	src_pitch = pSrc->devKind;
-	dst = pDst->devPrivate.ptr;
-	bytes = src_pitch < dst_pitch ? src_pitch : dst_pitch;
-
-	i = pSrc->drawable.height;
-	while (i--) {
-		memcpy(dst, src, bytes);
-		dst += dst_pitch;
-		src += src_pitch;
-	}
-
-	/* Flush the pixel cache */
-	if (atic->is_radeon) {
-		BEGIN_DMA(4);
-		OUT_REG(RADEON_REG_RB3D_DSTCACHE_CTLSTAT,
-		    RADEON_RB3D_DC_FLUSH_ALL);
-		OUT_REG(ATI_REG_WAIT_UNTIL, RADEON_WAIT_HOST_IDLECLEAN);
-		END_DMA();
-	} else {
-		BEGIN_DMA(2);
-		OUT_REG(R128_REG_PC_GUI_CTLSTAT, R128_PC_FLUSH_ALL);
-		END_DMA();
-	}
-
-	LEAVE_DRAW(pSrc);
-	return TRUE;
-}
-
-static void
-ATIBlockHandler(pointer blockData, OSTimePtr timeout, pointer readmask)
-{
-	ScreenPtr pScreen = (ScreenPtr) blockData;
-	KdScreenPriv(pScreen);
-	ATIScreenInfo(pScreenPriv);
-
-	/* When the server is going to sleep, make sure that all DMA data has
-	 * been flushed.
-	 */
-	if (atis->indirectBuffer)
-		ATIFlushIndirect(atis, 1);
-}
-
-static void
-ATIWakeupHandler(pointer blockData, int result, pointer readmask)
-{
-}
-
-Bool
-ATIDrawInit(ScreenPtr pScreen)
-{
-	KdScreenPriv(pScreen);
-	ATIScreenInfo(pScreenPriv);
-	ATICardInfo(pScreenPriv);
-
-	ErrorF("Screen: %d/%d depth/bpp\n", pScreenPriv->screen->fb[0].depth,
-	    pScreenPriv->screen->fb[0].bitsPerPixel);
-
-	RegisterBlockAndWakeupHandlers(ATIBlockHandler, ATIWakeupHandler,
-	    pScreen);
-
-#ifdef USE_DRI
-	atis->using_dri = ATIDRIScreenInit(pScreen);
-#endif /* USE_DRI */
-
-	memset(&atis->kaa, 0, sizeof(KaaScreenInfoRec));
-	atis->kaa.waitMarker = ATIWaitMarker;
-	atis->kaa.PrepareSolid = ATIPrepareSolid;
-	atis->kaa.Solid = ATISolid;
-	atis->kaa.DoneSolid = ATIDoneSolid;
-	atis->kaa.PrepareCopy = ATIPrepareCopy;
-	atis->kaa.Copy = ATICopy;
-	atis->kaa.DoneCopy = ATIDoneCopy;
-	/* Other acceleration will be hooked in in DrawEnable depending on
-	 * what type of DMA gets initialized.
-	 */
-
-	atis->kaa.flags = KAA_OFFSCREEN_PIXMAPS;
-	if (atic->is_radeon) {
-		atis->kaa.offsetAlign = 1024;
-		atis->kaa.pitchAlign = 64;
-	} else {
-		/* Rage 128 compositing wants power-of-two pitches. */
-		atis->kaa.flags |= KAA_OFFSCREEN_ALIGN_POT;
-		atis->kaa.offsetAlign = 32;
-		/* Pitch alignment is in sets of 8 pixels, and we need to cover
-		 * 32bpp, so 32 bytes.
-		 */
-		atis->kaa.pitchAlign = 32;
-	}
-
-	kaaInitTrapOffsets(8, sample_offsets_x, sample_offsets_y, 0.0, 0.0);
-	sample_count = (1 << 8) - 1;
-
-	if (!kaaDrawInit(pScreen, &atis->kaa))
-		return FALSE;
-
-	return TRUE;
-}
-
-static void
-ATIScratchSave(ScreenPtr pScreen, KdOffscreenArea *area)
-{
-	KdScreenPriv(pScreen);
-	ATIScreenInfo(pScreenPriv);
-
-	atis->scratch_area = NULL;
-}
-
-void
-ATIDrawEnable(ScreenPtr pScreen)
-{
-	KdScreenPriv(pScreen);
-	ATIScreenInfo(pScreenPriv);
-	ATICardInfo(pScreenPriv);
-
-	ATIDMASetup(pScreen);
-	ATIDrawSetup(pScreen);
-
-	atis->scratch_area = NULL;
-	atis->kaa.PrepareBlend = NULL;
-	atis->kaa.Blend = NULL;
-	atis->kaa.DoneBlend = NULL;
-	atis->kaa.CheckComposite = NULL;
-	atis->kaa.PrepareComposite = NULL;
-	atis->kaa.Composite = NULL;
-	atis->kaa.DoneComposite = NULL;
-	atis->kaa.UploadToScreen = NULL;
-    	atis->kaa.UploadToScratch = NULL;
-
-	/* We can't dispatch 3d commands in PIO mode. */
-	if (!atis->using_pio) {
-		if (!atic->is_radeon) {
-			atis->kaa.CheckComposite = R128CheckComposite;
-			atis->kaa.PrepareComposite = R128PrepareComposite;
-			atis->kaa.Composite = R128Composite;
-			atis->kaa.DoneComposite = R128DoneComposite;
-		} else if (atic->is_r100) {
-			atis->kaa.CheckComposite = R100CheckComposite;
-			atis->kaa.PrepareComposite = R100PrepareComposite;
-			atis->kaa.Composite = RadeonComposite;
-			atis->kaa.DoneComposite = RadeonDoneComposite;
-		} else if (atic->is_r200) {
-			atis->kaa.CheckComposite = R200CheckComposite;
-			atis->kaa.PrepareComposite = R200PrepareComposite;
-			atis->kaa.Composite = RadeonComposite;
-			atis->kaa.DoneComposite = RadeonDoneComposite;
-		}
-	}
-#ifdef USE_DRI
-	if (atis->using_dri) {
-		if (!atic->is_radeon) {
-			/*atis->kaa.PrepareTrapezoids = R128PrepareTrapezoids;
-			atis->kaa.Trapezoids = R128Trapezoids;
-			atis->kaa.DoneTrapezoids = R128DoneTrapezoids;*/
-		} else if (atic->is_r100 || atic->is_r200) {
-			atis->kaa.PrepareTrapezoids = RadeonPrepareTrapezoids;
-			atis->kaa.Trapezoids = RadeonTrapezoids;
-			atis->kaa.DoneTrapezoids = RadeonDoneTrapezoids;
-		}
-	}
-#endif /* USE_DRI */
-
-	atis->kaa.UploadToScreen = ATIUploadToScreen;
-
-	/* Reserve a scratch area.  It'll be used for storing glyph data during
-	 * Composite operations, because glyphs aren't in real pixmaps and thus
-	 * can't be migrated.
-	 */
-	atis->scratch_area = KdOffscreenAlloc(pScreen, 131072,
-	    atis->kaa.offsetAlign, TRUE, ATIScratchSave, atis);
-	if (atis->scratch_area != NULL) {
-		atis->scratch_next = atis->scratch_area->offset;
-		atis->kaa.UploadToScratch = ATIUploadToScratch;
-	}
-
-	kaaMarkSync(pScreen);
-}
-
-void
-ATIDrawDisable(ScreenPtr pScreen)
-{
-	kaaWaitSync(pScreen);
-	ATIDMATeardown(pScreen);
-}
-
-void
-ATIDrawFini(ScreenPtr pScreen)
-{
-#ifdef USE_DRI
-	KdScreenPriv(pScreen);
-	ATIScreenInfo(pScreenPriv);
-	if (atis->using_dri) {
-		ATIDRICloseScreen(pScreen);
-		atis->using_dri = FALSE;
-	}
-#endif /* USE_DRI */
-
-	RemoveBlockAndWakeupHandlers(ATIBlockHandler, ATIWakeupHandler,
-	    pScreen);
-
-	kaaDrawFini(pScreen);
-}
-
diff --git a/hw/kdrive/ati/ati_draw.h b/hw/kdrive/ati/ati_draw.h
deleted file mode 100644
index 98a130a..0000000
--- a/hw/kdrive/ati/ati_draw.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright © 2004 Eric Anholt
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Eric Anholt not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  Eric Anholt makes no
- * representations about the suitability of this software for any purpose.  It
- * is provided "as is" without express or implied warranty.
- *
- * ERIC ANHOLT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL ERIC ANHOLT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifndef _ATI_DRAW_H_
-#define _ATI_DRAW_H_
-
-Bool ATIGetOffsetPitch(ATIScreenInfo *atis, int bpp, CARD32 *pitch_offset,
-    int offset, int pitch);
-Bool ATIGetPixmapOffsetPitch(PixmapPtr pPix, CARD32 *pitch_offset);
-
-Bool R128CheckComposite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture,
-    PicturePtr pDstPicture);
-Bool R128PrepareComposite(int op, PicturePtr pSrcPicture,
-    PicturePtr pMaskPicture, PicturePtr pDstPicture, PixmapPtr pSrc,
-    PixmapPtr pMask, PixmapPtr pDst);
-void R128Composite(int srcX, int srcY, int maskX, int maskY, int dstX, int dstY,
-    int w, int h);
-void R128DoneComposite(void);
-
-Bool R128PrepareTrapezoids(PicturePtr pDstPicture, PixmapPtr pDst);
-void R128Trapezoids(KaaTrapezoid *traps, int ntraps);
-void R128DoneTrapezoids(void);
-
-Bool R100CheckComposite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture,
-    PicturePtr pDstPicture);
-Bool R100PrepareComposite(int op, PicturePtr pSrcPicture,
-    PicturePtr pMaskPicture, PicturePtr pDstPicture, PixmapPtr pSrc,
-    PixmapPtr pMask, PixmapPtr pDst);
-Bool R200CheckComposite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture,
-    PicturePtr pDstPicture);
-Bool R200PrepareComposite(int op, PicturePtr pSrcPicture,
-    PicturePtr pMaskPicture, PicturePtr pDstPicture, PixmapPtr pSrc,
-    PixmapPtr pMask, PixmapPtr pDst);
-void RadeonComposite(int srcX, int srcY, int maskX, int maskY, int dstX,
-    int dstY, int w, int h);
-void RadeonDoneComposite(void);
-
-Bool RadeonPrepareTrapezoids(PicturePtr pDstPicture, PixmapPtr pDst);
-void RadeonTrapezoids(KaaTrapezoid *traps, int ntraps);
-void RadeonDoneTrapezoids(void);
-
-void RadeonSwitchTo2D(ATIScreenInfo *atis);
-void RadeonSwitchTo3D(ATIScreenInfo *atis);
-void ATIWaitIdle(ATIScreenInfo *atis);
-
-#define ATI_TRACE_FALL 0
-#define ATI_TRACE_DRAW 0
-
-#if ATI_TRACE_FALL
-#define ATI_FALLBACK(x)			\
-do {					\
-	ErrorF("%s: ", __FUNCTION__);	\
-	ErrorF x;			\
-	return FALSE;			\
-} while (0)
-#else
-#define ATI_FALLBACK(x) return FALSE
-#endif
-
-#if ATI_TRACE_DRAW
-#define ENTER_DRAW(pix) ATIEnterDraw(pix, __FUNCTION__)
-#define LEAVE_DRAW(pix) ATILeaveDraw(pix, __FUNCTION__)
-
-void
-ATIEnterDraw (PixmapPtr pPixmap, char *function);
-
-void
-ATILeaveDraw (PixmapPtr pPixmap, char *function);
-#else /* ATI_TRACE */
-#define ENTER_DRAW(pix)
-#define LEAVE_DRAW(pix)
-#endif /* !ATI_TRACE */
-
-#endif /* _ATI_DRAW_H_ */
diff --git a/hw/kdrive/ati/ati_drawtmp.h b/hw/kdrive/ati/ati_drawtmp.h
deleted file mode 100644
index 82c99ac..0000000
--- a/hw/kdrive/ati/ati_drawtmp.h
+++ /dev/null
@@ -1,237 +0,0 @@
-/*
- * Copyright © 2003 Eric Anholt
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Eric Anholt not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  Eric Anholt makes no
- * representations about the suitability of this software for any purpose.  It
- * is provided "as is" without express or implied warranty.
- *
- * ERIC ANHOLT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL ERIC ANHOLT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifdef USE_DMA
-#define TAG(x)		x##DMA
-#define LOCALS		RING_LOCALS; \
-			(void)atic
-#define BEGIN(x)	BEGIN_RING(x * 2)
-#define OUT_REG(reg, val) OUT_RING_REG(reg, val)
-#define END()		ADVANCE_RING()
-#else
-#define TAG(x)		x##MMIO
-#define LOCALS		char *mmio = atic->reg_base; \
-			(void)atis
-#define BEGIN(x)	ATIWaitAvailMMIO(x)
-#define OUT_REG(reg, val) MMIO_OUT32((mmio), (reg), (val))
-#define END()
-#endif
-
-static Bool
-TAG(ATISetup)(PixmapPtr pDst, PixmapPtr pSrc)
-{
-	KdScreenPriv(pDst->drawable.pScreen);
-	ATIScreenInfo(pScreenPriv);
-	ATICardInfo(pScreenPriv);
-	int dst_offset, dst_pitch;
-	int bpp = pDst->drawable.bitsPerPixel;
-	LOCALS;
-
-	accel_atis = atis;
-
-	dst_pitch = pDst->devKind;
-	dst_offset = ((CARD8 *)pDst->devPrivate.ptr -
-	    pScreenPriv->screen->memory_base);
-	if ((dst_pitch & (atis->kaa.offscreenPitch - 1)) != 0)
-		ATI_FALLBACK(("Bad dst pitch 0x%x\n", dst_pitch));
-	if ((dst_offset & (atis->kaa.offscreenByteAlign - 1)) != 0)
-		ATI_FALLBACK(("Bad dst offset 0x%x\n", dst_offset));
-
-	if (pSrc != NULL) {
-		src_pitch = pSrc->devKind;
-		src_offset = ((CARD8 *)pSrc->devPrivate.ptr -
-		    pScreenPriv->screen->memory_base);
-		if ((src_pitch & (atis->kaa.offscreenPitch - 1)) != 0)
-			ATI_FALLBACK(("Bad src pitch 0x%x\n", src_pitch));
-		if ((src_offset & (atis->kaa.offscreenByteAlign - 1)) != 0)
-			ATI_FALLBACK(("Bad src offset 0x%x\n", src_offset));
-	}
-
-#ifdef USE_DMA
-	if (atic->is_radeon && !atic->is_r200)
-		RadeonSwitchTo2D();
-#endif
-	BEGIN((pSrc != NULL) ? 3 : 2);
-	if (atic->is_radeon) {
-		OUT_REG(RADEON_REG_DST_PITCH_OFFSET,
-		    ((dst_pitch >> 6) << 22) | (dst_offset >> 10));
-		if (pSrc != NULL) {
-			OUT_REG(RADEON_REG_SRC_PITCH_OFFSET,
-			    ((src_pitch >> 6) << 22) | (src_offset >> 10));
-		}
-	} else {
-		if (is_24bpp) {
-			dst_pitch *= 3;
-			src_pitch *= 3;
-		}
-		/* R128 pitch is in units of 8 pixels, offset in 32 bytes */
-		OUT_REG(RADEON_REG_DST_PITCH_OFFSET,
-		    ((dst_pitch/bpp) << 21) | (dst_offset >> 5));
-		if (pSrc != NULL) {
-			OUT_REG(RADEON_REG_SRC_PITCH_OFFSET,
-			    ((src_pitch/bpp) << 21) | (src_offset >> 5));
-		}
-	}
-	OUT_REG(RADEON_REG_DEFAULT_SC_BOTTOM_RIGHT,
-	    (RADEON_DEFAULT_SC_RIGHT_MAX | RADEON_DEFAULT_SC_BOTTOM_MAX));
-	END();
-
-	return TRUE;
-}
-
-static Bool
-TAG(ATIPrepareSolid)(PixmapPtr pPixmap, int alu, Pixel pm, Pixel fg)
-{
-	KdScreenPriv(pPixmap->drawable.pScreen);
-	ATIScreenInfo(pScreenPriv);
-	ATICardInfo(pScreenPriv);
-	CARD32 datatype;
-	LOCALS;
-
-	if (is_24bpp) {
-		/* Solid fills in fake-24bpp mode only work if the pixel color
-		 * and planemask are all the same byte.
-		 */
-		if ((fg & 0xffffff) != (((fg & 0xff) << 16) | ((fg >> 8) &
-		    0xffff)))
-			ATI_FALLBACK(("Can't do solid color %d in 24bpp\n"));
-		if ((pm & 0xffffff) != (((pm & 0xff) << 16) | ((pm >> 8) &
-		    0xffff)))
-			ATI_FALLBACK(("Can't do planemask %d in 24bpp\n"));
-	}
-
-	if (!ATIGetDatatypeBpp(pPixmap->drawable.bitsPerPixel, &datatype))
-		return FALSE;
-	if (!TAG(ATISetup)(pPixmap, NULL))
-		return FALSE;
-
-	BEGIN(4);
-	OUT_REG(RADEON_REG_DP_GUI_MASTER_CNTL,
-	    (datatype << 8) |
-	    RADEON_GMC_CLR_CMP_CNTL_DIS |
-	    RADEON_GMC_AUX_CLIP_DIS |
-	    RADEON_GMC_BRUSH_SOLID_COLOR |
-	    RADEON_GMC_DST_PITCH_OFFSET_CNTL |
-	    RADEON_GMC_SRC_DATATYPE_COLOR |
-	    (ATISolidRop[alu] << 16));
-	OUT_REG(RADEON_REG_DP_BRUSH_FRGD_CLR, fg);
-	OUT_REG(RADEON_REG_DP_WRITE_MASK, pm);
-	OUT_REG(RADEON_REG_DP_CNTL, RADEON_DST_X_LEFT_TO_RIGHT |
-	    RADEON_DST_Y_TOP_TO_BOTTOM);
-	END();
-
-	return TRUE;
-}
-
-static void
-TAG(ATISolid)(int x1, int y1, int x2, int y2)
-{
-	ATIScreenInfo *atis = accel_atis;
-	ATICardInfo *atic = atis->atic;
-	LOCALS;
-	
-	if (is_24bpp) {
-		x1 *= 3;
-		x2 *= 3;
-	}
-	BEGIN(2);
-	OUT_REG(RADEON_REG_DST_Y_X, (y1 << 16) | x1);
-	OUT_REG(RADEON_REG_DST_WIDTH_HEIGHT, ((x2 - x1) << 16) | (y2 - y1));
-	END();
-}
-
-static Bool
-TAG(ATIPrepareCopy)(PixmapPtr pSrc, PixmapPtr pDst, int dx, int dy, int alu, Pixel pm)
-{
-	KdScreenPriv(pDst->drawable.pScreen);
-	ATIScreenInfo(pScreenPriv);
-	ATICardInfo(pScreenPriv);
-	CARD32 datatype;
-	LOCALS;
-
-	copydx = dx;
-	copydy = dy;
-
-	if (is_24bpp && ((pm & 0xffffff) != (((pm & 0xff) << 16) | ((pm >> 8) &
-	    0xffff))))
-		ATI_FALLBACK(("Can't do planemask %d in 24bpp\n"));
-
-	if (!ATIGetDatatypeBpp(pDst->drawable.bitsPerPixel, &datatype))
-		return FALSE;
-	if (!TAG(ATISetup)(pDst, pSrc))
-		return FALSE;
-
-	BEGIN(3);
-	OUT_REG(RADEON_REG_DP_GUI_MASTER_CNTL,
-	    (datatype << 8) |
-	    RADEON_GMC_CLR_CMP_CNTL_DIS |
-	    RADEON_GMC_AUX_CLIP_DIS |
-	    RADEON_GMC_BRUSH_SOLID_COLOR |
-	    RADEON_GMC_SRC_DATATYPE_COLOR |
-	    (ATIBltRop[alu] << 16) |
-	    RADEON_GMC_SRC_PITCH_OFFSET_CNTL |
-	    RADEON_GMC_DST_PITCH_OFFSET_CNTL |
-	    RADEON_DP_SRC_SOURCE_MEMORY);
-	OUT_REG(RADEON_REG_DP_WRITE_MASK, pm);
-	OUT_REG(RADEON_REG_DP_CNTL, 
-	    (dx >= 0 ? RADEON_DST_X_LEFT_TO_RIGHT : 0) |
-	    (dy >= 0 ? RADEON_DST_Y_TOP_TO_BOTTOM : 0));
-	END();
-
-	return TRUE;
-}
-
-static void
-TAG(ATICopy)(int srcX, int srcY, int dstX, int dstY, int w, int h)
-{
-	ATIScreenInfo *atis = accel_atis;
-	ATICardInfo *atic = atis->atic;
-	LOCALS;
-
-	if (is_24bpp) {
-		srcX *= 3;
-		dstX *= 3;
-		w *= 3;
-	}
-
-	if (copydx < 0) {
-		srcX += w - 1;
-		dstX += w - 1;
-	}
-
-	if (copydy < 0)  {
-		srcY += h - 1;
-		dstY += h - 1;
-	}
-
-	BEGIN(3);
-	OUT_REG(RADEON_REG_SRC_Y_X, (srcY << 16) | srcX);
-	OUT_REG(RADEON_REG_DST_Y_X, (dstY << 16) | dstX);
-	OUT_REG(RADEON_REG_DST_HEIGHT_WIDTH, (h << 16) | w);
-	END();
-}
-
-#undef TAG
-#undef LOCALS
-#undef BEGIN
-#undef OUT_REG
-#undef END
diff --git a/hw/kdrive/ati/ati_dri.c b/hw/kdrive/ati/ati_dri.c
deleted file mode 100644
index edef720..0000000
--- a/hw/kdrive/ati/ati_dri.c
+++ /dev/null
@@ -1,1138 +0,0 @@
-/*
- * Copyright © 2003 Eric Anholt
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Eric Anholt not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  Eric Anholt makes no
- * representations about the suitability of this software for any purpose.  It
- * is provided "as is" without express or implied warranty.
- *
- * ERIC ANHOLT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL ERIC ANHOLT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <sys/time.h>
-
-#ifdef HAVE_CONFIG_H
-#include <kdrive-config.h>
-#endif
-
-#include "ati.h"
-#include "ati_reg.h"
-#include "ati_dma.h"
-#include "ati_dri.h"
-#include "ati_dripriv.h"
-#include "sarea.h"
-#include "ati_sarea.h"
-#include "ati_draw.h"
-#include "r128_common.h"
-#include "radeon_common.h"
-#include "kaa.h"
-
-/* ?? HACK - for now, put this here... */
-/* ?? Alpha - this may need to be a variable to handle UP1x00 vs TITAN */
-#if defined(__alpha__)
-# define DRM_PAGE_SIZE 8192
-#elif defined(__ia64__)
-# define DRM_PAGE_SIZE getpagesize()
-#else
-# define DRM_PAGE_SIZE 4096
-#endif
-
-#ifdef GLXEXT
-/* Initialize the visual configs that are supported by the hardware.
- * These are combined with the visual configs that the indirect
- * rendering core supports, and the intersection is exported to the
- * client.
- */
-static Bool ATIInitVisualConfigs(ScreenPtr pScreen)
-{
-	KdScreenPriv(pScreen);
-	ATIScreenInfo(pScreenPriv);
-	int numConfigs = 0;
-	__GLXvisualConfig *pConfigs = NULL;
-	ATIConfigPrivPtr pATIConfigs = NULL;
-	ATIConfigPrivPtr *pATIConfigPtrs = NULL;
-	int i, accum, stencil, db, use_db;
-	int depth = pScreenPriv->screen->fb[0].depth;
-	int bpp = pScreenPriv->screen->fb[0].bitsPerPixel;
-
-	if (depth != 16 && (depth != 24 || bpp != 32))
-		ErrorF("DRI GLX unsupported at %d/%d depth/bpp\n", depth, bpp);
-
-	if (atis->depthOffset != 0)
-		use_db = 1;
-	else
-		use_db = 0;
-
-	numConfigs = 4;
-	if (use_db)
-		numConfigs *= 2;
-
-	pConfigs = xcalloc(sizeof(__GLXvisualConfig), numConfigs);
-	pATIConfigs = xcalloc(sizeof(ATIConfigPrivRec), numConfigs);
-	pATIConfigPtrs = xcalloc(sizeof(ATIConfigPrivPtr), numConfigs);
-	if (pConfigs == NULL || pATIConfigs == NULL || pATIConfigPtrs == NULL) {
-		xfree(pConfigs);
-		xfree(pATIConfigs);
-		xfree(pATIConfigPtrs);
-		return FALSE;
-	}
-
-	i = 0;
-	for (db = 0; db <= use_db; db++) {
-	  for (accum = 0; accum <= 1; accum++) {
-	    for (stencil = 0; stencil <= 1; stencil++) {
-		pATIConfigPtrs[i] = &pATIConfigs[i];
-
-		pConfigs[i].vid                = (VisualID)(-1);
-		pConfigs[i].class              = -1;
-		pConfigs[i].rgba               = TRUE;
-		if (depth == 16) {
-			pConfigs[i].redSize            = 5;
-			pConfigs[i].greenSize          = 6;
-			pConfigs[i].blueSize           = 5;
-			pConfigs[i].alphaSize          = 0;
-			pConfigs[i].redMask            = 0x0000F800;
-			pConfigs[i].greenMask          = 0x000007E0;
-			pConfigs[i].blueMask           = 0x0000001F;
-			pConfigs[i].alphaMask          = 0x00000000;
-		} else {
-			pConfigs[i].redSize            = 8;
-			pConfigs[i].greenSize          = 8;
-			pConfigs[i].blueSize           = 8;
-			pConfigs[i].alphaSize          = 8;
-			pConfigs[i].redMask            = 0x00FF0000;
-			pConfigs[i].greenMask          = 0x0000FF00;
-			pConfigs[i].blueMask           = 0x000000FF;
-			pConfigs[i].alphaMask          = 0xFF000000;
-		}
-		if (accum) { /* Simulated in software */
-			pConfigs[i].accumRedSize   = 16;
-			pConfigs[i].accumGreenSize = 16;
-			pConfigs[i].accumBlueSize  = 16;
-			if (depth == 16)
-				pConfigs[i].accumAlphaSize = 0;
-			else
-				pConfigs[i].accumAlphaSize = 16;
-		} else {
-		    pConfigs[i].accumRedSize   = 0;
-		    pConfigs[i].accumGreenSize = 0;
-		    pConfigs[i].accumBlueSize  = 0;
-		    pConfigs[i].accumAlphaSize = 0;
-		}
-		if (db)
-		    pConfigs[i].doubleBuffer   = TRUE;
-		else
-		    pConfigs[i].doubleBuffer   = FALSE;
-		pConfigs[i].stereo             = FALSE;
-		if (depth == 16) {
-			pConfigs[i].bufferSize         = 16;
-			pConfigs[i].depthSize          = 16;
-			if (stencil)
-			    pConfigs[i].stencilSize    = 8;
-			else
-			    pConfigs[i].stencilSize    = 0;
-		} else {
-			pConfigs[i].bufferSize         = 32;
-			if (stencil) {
-			    pConfigs[i].depthSize      = 24;
-			    pConfigs[i].stencilSize    = 8;
-			} else {
-			    pConfigs[i].depthSize      = 24;
-			    pConfigs[i].stencilSize    = 0;
-			}
-		}
-		pConfigs[i].auxBuffers         = 0;
-		pConfigs[i].level              = 0;
-		if (accum) {
-		   pConfigs[i].visualRating    = GLX_SLOW_CONFIG;
-		} else {
-		   pConfigs[i].visualRating    = GLX_NONE;
-		}
-		pConfigs[i].transparentPixel   = GLX_NONE;
-		pConfigs[i].transparentRed     = 0;
-		pConfigs[i].transparentGreen   = 0;
-		pConfigs[i].transparentBlue    = 0;
-		pConfigs[i].transparentAlpha   = 0;
-		pConfigs[i].transparentIndex   = 0;
-		i++;
-	    }
-	  }
-	}
-
-	atis->numVisualConfigs = numConfigs;
-	atis->pVisualConfigs = pConfigs;
-	atis->pVisualConfigsPriv = pATIConfigs;
-	GlxSetVisualConfigs(numConfigs, pConfigs, (void**)pATIConfigPtrs);
-	return TRUE;
-}
-#endif /* GLXEXT */
-
-static void
-ATIDRIInitGARTValues(ScreenPtr pScreen)
-{
-	KdScreenPriv(pScreen);
-	ATIScreenInfo(pScreenPriv);
-	int s, l;
-
-	atis->gartOffset = 0;
-
-	/* Initialize the ring buffer data */
-	atis->ringStart       = atis->gartOffset;
-	atis->ringMapSize     = atis->ringSize * 1024 * 1024 + DRM_PAGE_SIZE;
-
-	atis->ringReadOffset  = atis->ringStart + atis->ringMapSize;
-	atis->ringReadMapSize = DRM_PAGE_SIZE;
-
-	/* Reserve space for vertex/indirect buffers */
-	atis->bufStart        = atis->ringReadOffset + atis->ringReadMapSize;
-	atis->bufMapSize      = atis->bufSize * 1024 * 1024;
-
-	/* Reserve the rest for GART textures */
-	atis->gartTexStart     = atis->bufStart + atis->bufMapSize;
-	s = (atis->gartSize * 1024 * 1024 - atis->gartTexStart);
-	l = ATILog2((s-1) / ATI_NR_TEX_REGIONS);
-	if (l < ATI_LOG_TEX_GRANULARITY) l = ATI_LOG_TEX_GRANULARITY;
-	atis->gartTexMapSize   = (s >> l) << l;
-	atis->log2GARTTexGran  = l;
-}
-
-static int
-ATIDRIAddAndMap(int fd, drmHandle offset, drmSize size,
-    drmMapType type, drmMapFlags flags, drmHandlePtr handle,
-    drmAddressPtr address, char *desc)
-{
-	char *name;
-
-	name = (type == DRM_AGP) ? "agp" : "pci";
-
-	if (drmAddMap(fd, offset, size, type, flags, handle) < 0) {
-		ErrorF("[%s] Could not add %s mapping\n", name, desc);
-		return FALSE;
-	}
-	ErrorF("[%s] %s handle = 0x%08lx\n", name, desc, *handle);
-
-	if (drmMap(fd, *handle, size, address) < 0) {
-		ErrorF("[%s] Could not map %s\n", name, desc);
-		return FALSE;
-	}
-	ErrorF("[%s] %s mapped at 0x%08lx\n", name, desc, *address);
-
-	return TRUE;
-}
-
-/* Initialize the AGP state.  Request memory for use in AGP space, and
-   initialize the Rage 128 registers to point to that memory. */
-static Bool
-ATIDRIAgpInit(ScreenPtr pScreen)
-{
-	KdScreenPriv(pScreen);
-	ATIScreenInfo(pScreenPriv);
-	ATICardInfo(pScreenPriv);
-	unsigned char *mmio = atic->reg_base;
-	unsigned long mode;
-	int           ret;
-	CARD32        cntl, chunk;
-
-	if (drmAgpAcquire(atic->drmFd) < 0) {
-		ErrorF("[agp] AGP not available\n");
-		return FALSE;
-	}
-
-	ATIDRIInitGARTValues(pScreen);
-
-	mode = drmAgpGetMode(atic->drmFd);
-	if (atic->is_radeon) {
-		mode &= ~RADEON_AGP_MODE_MASK;
-		mode |= RADEON_AGP_1X_MODE;
-	} else {
-		mode &= ~R128_AGP_MODE_MASK;
-		mode |= R128_AGP_1X_MODE;
-	}
-
-	if (drmAgpEnable(atic->drmFd, mode) < 0) {
-		ErrorF("[agp] AGP not enabled\n");
-		drmAgpRelease(atic->drmFd);
-		return FALSE;
-	}
-	ErrorF("[agp] Mode 0x%08x selected\n", drmAgpGetMode(atic->drmFd));
-
-	if ((ret = drmAgpAlloc(atic->drmFd, atis->gartSize * 1024 * 1024, 0,
-	    NULL, &atis->agpMemHandle)) < 0) {
-		ErrorF("[agp] Out of memory (%d)\n", ret);
-		drmAgpRelease(atic->drmFd);
-		return FALSE;
-	}
-	ErrorF("[agp] %d kB allocated with handle 0x%08lx\n",
-	    atis->gartSize * 1024, (long)atis->agpMemHandle);
-
-	if (drmAgpBind(atic->drmFd, atis->agpMemHandle, atis->gartOffset) < 0) {
-		ErrorF("[agp] Could not bind\n");
-		drmAgpFree(atic->drmFd, atis->agpMemHandle);
-		drmAgpRelease(atic->drmFd);
-		return FALSE;
-	}
-
-	if (!ATIDRIAddAndMap(atic->drmFd, atis->ringStart, atis->ringMapSize,
-	    DRM_AGP, DRM_READ_ONLY, &atis->ringHandle,
-	    (drmAddressPtr)&atis->ring, "ring"))
-		return FALSE;
-
-	if (!ATIDRIAddAndMap(atic->drmFd, atis->ringReadOffset,
-	    atis->ringReadMapSize, DRM_AGP, DRM_READ_ONLY,
-	    &atis->ringReadPtrHandle, (drmAddressPtr)&atis->ringReadPtr,
-	    "ring read ptr"))
-		return FALSE;
-
-	if (!ATIDRIAddAndMap(atic->drmFd, atis->bufStart, atis->bufMapSize,
-	    DRM_AGP, 0, &atis->bufHandle, (drmAddressPtr)&atis->buf,
-	    "vertex/indirect buffers"))
-		return FALSE;
-
-	if (!ATIDRIAddAndMap(atic->drmFd, atis->gartTexStart,
-	    atis->gartTexMapSize, DRM_AGP, 0, &atis->gartTexHandle,
-	    (drmAddressPtr)&atis->gartTex, "AGP texture map"))
-		return FALSE;
-
-	if (atic->is_r100) {
-		/* Workaround for some hardware bugs */
-		cntl = MMIO_IN32(mmio, ATI_REG_AGP_CNTL);
-		MMIO_OUT32(mmio, ATI_REG_AGP_CNTL, cntl |
-		    RADEON_PENDING_SLOTS_VAL | RADEON_PENDING_SLOTS_SEL);
-	} else if (!atic->is_radeon) {
-		cntl = MMIO_IN32(mmio, ATI_REG_AGP_CNTL);
-		cntl &= ~R128_AGP_APER_SIZE_MASK;
-		switch (atis->gartSize) {
-		case 256: cntl |= R128_AGP_APER_SIZE_256MB; break;
-		case 128: cntl |= R128_AGP_APER_SIZE_128MB; break;
-		case  64: cntl |= R128_AGP_APER_SIZE_64MB;  break;
-		case  32: cntl |= R128_AGP_APER_SIZE_32MB;  break;
-		case  16: cntl |= R128_AGP_APER_SIZE_16MB;  break;
-		case   8: cntl |= R128_AGP_APER_SIZE_8MB;   break;
-		case   4: cntl |= R128_AGP_APER_SIZE_4MB;   break;
-		default:
-			ErrorF("[agp] Illegal aperture size %d kB\n", atis->gartSize *
-			    1024);
-			return FALSE;
-		}
-		MMIO_OUT32(mmio, ATI_REG_AGP_CNTL, cntl);
-
-		/* Disable Rage 128 PCIGART registers */
-		chunk = MMIO_IN32(mmio, R128_REG_BM_CHUNK_0_VAL);
-		chunk &= ~(R128_BM_PTR_FORCE_TO_PCI |
-		    R128_BM_PM4_RD_FORCE_TO_PCI |
-		    R128_BM_GLOBAL_FORCE_TO_PCI);
-		MMIO_OUT32(mmio, R128_REG_BM_CHUNK_0_VAL, chunk);
-
-		/* Ensure AGP GART is used (for now) */
-		MMIO_OUT32(mmio, R128_REG_PCI_GART_PAGE, 1);
-	}
-
-	MMIO_OUT32(mmio, ATI_REG_AGP_BASE, drmAgpBase(atic->drmFd)); 
-
-	return TRUE;
-}
-
-static Bool
-ATIDRIPciInit(ScreenPtr pScreen)
-{
-	KdScreenPriv(pScreen);
-	ATIScreenInfo(pScreenPriv);
-	ATICardInfo(pScreenPriv);
-	unsigned char *mmio = atic->reg_base;
-	CARD32 chunk;
-	int ret;
-
-	ATIDRIInitGARTValues(pScreen);
-
-	ret = drmScatterGatherAlloc(atic->drmFd, atis->gartSize * 1024 * 1024,
-	    &atis->pciMemHandle);
-	if (ret < 0) {
-		ErrorF("[pci] Out of memory (%d)\n", ret);
-		return FALSE;
-	}
-	ErrorF("[pci] %d kB allocated with handle 0x%08lx\n",
-	    atis->gartSize * 1024, (long)atis->pciMemHandle);
-
-	if (!ATIDRIAddAndMap(atic->drmFd, atis->ringStart, atis->ringMapSize,
-	    DRM_SCATTER_GATHER, DRM_READ_ONLY | DRM_LOCKED | DRM_KERNEL,
-	    &atis->ringHandle, (drmAddressPtr)&atis->ring, "ring"))
-		return FALSE;
-
-	if (!ATIDRIAddAndMap(atic->drmFd, atis->ringReadOffset,
-	    atis->ringReadMapSize, DRM_SCATTER_GATHER,
-	    DRM_READ_ONLY | DRM_LOCKED | DRM_KERNEL,
-	    &atis->ringReadPtrHandle, (drmAddressPtr)&atis->ringReadPtr,
-	    "ring read ptr"))
-		return FALSE;
-
-	if (!ATIDRIAddAndMap(atic->drmFd, atis->bufStart, atis->bufMapSize,
-	    DRM_SCATTER_GATHER, 0, &atis->bufHandle, (drmAddressPtr)&atis->buf,
-	    "vertex/indirect buffers"))
-		return FALSE;
-
-	if (!ATIDRIAddAndMap(atic->drmFd, atis->gartTexStart,
-	    atis->gartTexMapSize, DRM_SCATTER_GATHER, 0, &atis->gartTexHandle,
-	    (drmAddressPtr)&atis->gartTex, "PCI texture map"))
-		return FALSE;
-
-	if (!atic->is_radeon) {
-		/* Force PCI GART mode */
-		chunk = MMIO_IN32(mmio, R128_REG_BM_CHUNK_0_VAL);
-		chunk |= (R128_BM_PTR_FORCE_TO_PCI |
-		    R128_BM_PM4_RD_FORCE_TO_PCI | R128_BM_GLOBAL_FORCE_TO_PCI);
-		MMIO_OUT32(mmio, R128_REG_BM_CHUNK_0_VAL, chunk);
-		/* Ensure PCI GART is used */
-		MMIO_OUT32(mmio, R128_REG_PCI_GART_PAGE, 0);
-	}
-	return TRUE;
-}
-
-
-/* Initialize the kernel data structures. */
-static int
-R128DRIKernelInit(ScreenPtr pScreen)
-{
-	KdScreenPriv(pScreen);
-	ATIScreenInfo(pScreenPriv);
-	ATICardInfo(pScreenPriv);
-	drmR128Init drmInfo;
-	int bpp = pScreenPriv->screen->fb[0].bitsPerPixel;
-
-	memset(&drmInfo, 0, sizeof(drmR128Init) );
-
-	drmInfo.func                = DRM_R128_INIT_CCE;
-	drmInfo.sarea_priv_offset   = sizeof(XF86DRISAREARec);
-	drmInfo.is_pci              = !atis->using_agp;
-	drmInfo.cce_mode            = R128_PM4_64BM_64VCBM_64INDBM;
-	drmInfo.cce_secure          = TRUE;
-	drmInfo.ring_size           = atis->ringSize * 1024 * 1024;
-	drmInfo.usec_timeout        = atis->DMAusecTimeout;
-
-	drmInfo.front_offset        = atis->frontOffset;
-	drmInfo.front_pitch         = atis->frontPitch / (bpp / 8);
-	drmInfo.back_offset         = atis->backOffset;
-	drmInfo.back_pitch          = atis->backPitch / (bpp / 8);
-	drmInfo.fb_bpp              = bpp;
-
-	drmInfo.depth_offset        = atis->depthOffset;
-	drmInfo.depth_pitch         = atis->depthPitch / (bpp / 8);
-	drmInfo.depth_bpp           = bpp;
-
-	drmInfo.span_offset         = atis->spanOffset;
-
-	drmInfo.fb_offset           = atis->fbHandle;
-	drmInfo.mmio_offset         = atis->registerHandle;
-	drmInfo.ring_offset         = atis->ringHandle;
-	drmInfo.ring_rptr_offset    = atis->ringReadPtrHandle;
-	drmInfo.buffers_offset      = atis->bufHandle;
-	drmInfo.agp_textures_offset = atis->gartTexHandle;
-
-	if (drmCommandWrite(atic->drmFd, DRM_R128_INIT, &drmInfo,
-	    sizeof(drmR128Init)) < 0)
-		return FALSE;
-
-	return TRUE;
-}
-
-/* Initialize the kernel data structures */
-static int
-RadeonDRIKernelInit(ScreenPtr pScreen)
-{
-	KdScreenPriv(pScreen);
-	ATIScreenInfo(pScreenPriv);
-	ATICardInfo(pScreenPriv);
-	drmRadeonInit drmInfo;
-
-	memset(&drmInfo, 0, sizeof(drmRadeonInit));
-
-	if (atic->is_r200)
-	    drmInfo.func             = DRM_RADEON_INIT_R200_CP;
-	else
-	    drmInfo.func             = DRM_RADEON_INIT_CP;
-
-	drmInfo.sarea_priv_offset   = sizeof(XF86DRISAREARec);
-	drmInfo.is_pci              = !atis->using_agp;
-	drmInfo.cp_mode             = RADEON_CSQ_PRIBM_INDBM;
-	drmInfo.gart_size           = atis->gartSize * 1024 * 1024;
-	drmInfo.ring_size           = atis->ringSize * 1024 * 1024;
-	drmInfo.usec_timeout        = atis->DMAusecTimeout;
-
-	drmInfo.front_offset        = atis->frontOffset;
-	drmInfo.front_pitch         = atis->frontPitch;
-	drmInfo.back_offset         = atis->backOffset;
-	drmInfo.back_pitch          = atis->backPitch;
-	drmInfo.fb_bpp              = pScreenPriv->screen->fb[0].bitsPerPixel;
-	drmInfo.depth_offset        = atis->depthOffset;
-	drmInfo.depth_pitch         = atis->depthPitch;
-	drmInfo.depth_bpp           = pScreenPriv->screen->fb[0].bitsPerPixel;
-
-	drmInfo.fb_offset           = atis->fbHandle;
-	drmInfo.mmio_offset         = atis->registerHandle;
-	drmInfo.ring_offset         = atis->ringHandle;
-	drmInfo.ring_rptr_offset    = atis->ringReadPtrHandle;
-	drmInfo.buffers_offset      = atis->bufHandle;
-	drmInfo.gart_textures_offset = atis->gartTexHandle;
-
-	if (drmCommandWrite(atic->drmFd, DRM_RADEON_CP_INIT,
-	    &drmInfo, sizeof(drmRadeonInit)) < 0)
-		return FALSE;
-
-	return TRUE;
-}
-
-/* Add a map for the vertex buffers that will be accessed by any
-   DRI-based clients. */
-static Bool
-ATIDRIBufInit(ScreenPtr pScreen)
-{
-	KdScreenPriv(pScreen);
-	ATIScreenInfo(pScreenPriv);
-	ATICardInfo(pScreenPriv);
-	int type, size;
-
-	if (atic->is_radeon)
-		size = RADEON_BUFFER_SIZE;
-	else
-		size = R128_BUFFER_SIZE;
-
-	if (atis->using_agp)
-		type = DRM_AGP_BUFFER;
-	else
-		type = DRM_SG_BUFFER;
-
-	/* Initialize vertex buffers */
-	atis->bufNumBufs = drmAddBufs(atic->drmFd, atis->bufMapSize / size,
-	    size, type, atis->bufStart);
-
-	if (atis->bufNumBufs <= 0) {
-		ErrorF("[drm] Could not create vertex/indirect buffers list\n");
-		return FALSE;
-	}
-	ErrorF("[drm] Added %d %d byte vertex/indirect buffers\n",
-	    atis->bufNumBufs, size);
-
-	atis->buffers = drmMapBufs(atic->drmFd);
-	if (atis->buffers == NULL) {
-		ErrorF("[drm] Failed to map vertex/indirect buffers list\n");
-		return FALSE;
-	}
-	ErrorF("[drm] Mapped %d vertex/indirect buffers\n",
-	    atis->buffers->count);
-
-	return TRUE;
-}
-
-static int 
-ATIDRIIrqInit(ScreenPtr pScreen)
-{
-	KdScreenPriv(pScreen);
-	ATIScreenInfo(pScreenPriv);
-	ATICardInfo(pScreenPriv);
-
-	if (atis->irqEnabled)
-		return FALSE;
-
-	atis->irqEnabled = drmCtlInstHandler(atic->drmFd, 0);
-
-	if (!atis->irqEnabled)
-		return FALSE;
-
-	return TRUE;
-}
-
-static void ATIDRISwapContext(ScreenPtr pScreen, DRISyncType syncType,
-    DRIContextType oldContextType, void *oldContext,
-    DRIContextType newContextType, void *newContext)
-{
-	KdScreenPriv(pScreen);
-	ATIScreenInfo(pScreenPriv);
-
-	if ((syncType==DRI_3D_SYNC) && (oldContextType==DRI_2D_CONTEXT) &&
-	    (newContextType==DRI_2D_CONTEXT)) {
-		/* Entering from Wakeup */
-		kaaMarkSync(pScreen);
-	}
-	if ((syncType==DRI_2D_SYNC) && (oldContextType==DRI_NO_CONTEXT) &&
-	    (newContextType==DRI_2D_CONTEXT)) {
-		/* Exiting from Block Handler */
-		if (atis->dma_started)
-			ATIFlushIndirect(atis, 1);
-	}
-}
-
-static Bool ATIDRIFinishScreenInit(ScreenPtr pScreen);
-
-/* Initialize the screen-specific data structures for the Radeon or
-   Rage 128.  This is the main entry point to the device-specific
-   initialization code.  It calls device-independent DRI functions to
-   create the DRI data structures and initialize the DRI state. */
-Bool
-ATIDRIScreenInit(ScreenPtr pScreen)
-{
-	KdScreenPriv(pScreen);
-	ATIScreenInfo(pScreenPriv);
-	ATICardInfo(pScreenPriv);
-	void *scratch_ptr;
-	int scratch_int;
-	DRIInfoPtr pDRIInfo;
-	int devSareaSize;
-	drmSetVersion sv;
-
-	if (pScreenPriv->screen->fb[0].depth < 16 ||
-	    pScreenPriv->screen->fb[0].bitsPerPixel == 24) {
-		ErrorF("DRI unsupported at this depth/bpp, disabling.\n");
-		return FALSE;
-	}
-
-	atis->agpMode = 1;
-	atis->gartSize = 8;
-	atis->ringSize = 1;
-	atis->bufSize = 2;
-	atis->gartTexSize = 1;
-	atis->DMAusecTimeout = 10000;
-
-	if (atic->drmFd < 0)
-		return FALSE;
-
-	sv.drm_di_major = -1;
-	sv.drm_dd_major = -1;
-	drmSetInterfaceVersion(atic->drmFd, &sv);
-	if (atic->is_radeon) {
-		if (sv.drm_dd_major != 1 || sv.drm_dd_minor < 6) {
-			ErrorF("[dri] radeon kernel module version is %d.%d "
-			    "but version 1.6 or greater is needed.\n",
-			    sv.drm_dd_major, sv.drm_dd_minor);
-			return FALSE;
-		}
-	} else {
-		if (sv.drm_dd_major != 2 || sv.drm_dd_minor < 2) {
-			ErrorF("[dri] r128 kernel module version is %d.%d "
-			    "but version 2.2 or greater is needed.\n",
-			    sv.drm_dd_major, sv.drm_dd_minor);
-			return FALSE;
-		}
-	}
-
-	/* Create the DRI data structure, and fill it in before calling the
-	 * DRIScreenInit().
-	 */
-	pDRIInfo = DRICreateInfoRec();
-	if (pDRIInfo == NULL)
-		return FALSE;
-
-	atis->pDRIInfo = pDRIInfo;
-	pDRIInfo->busIdString = atic->busid;
-	if (atic->is_radeon) {
-		pDRIInfo->drmDriverName = "radeon";
-		if (atic->is_r100)
-			pDRIInfo->clientDriverName = "radeon";
-		else
-			pDRIInfo->clientDriverName = "r200";
-	} else {
-		pDRIInfo->drmDriverName = "r128";
-		pDRIInfo->clientDriverName = "r128";
-	}
-	pDRIInfo->ddxDriverMajorVersion = 4;
-	pDRIInfo->ddxDriverMinorVersion = 0;
-	pDRIInfo->ddxDriverPatchVersion = 0;
-	pDRIInfo->frameBufferPhysicalAddress =
-	    pScreenPriv->card->attr.address[0] & 0xfc000000;
-	pDRIInfo->frameBufferSize = pScreenPriv->screen->memory_size;
-	pDRIInfo->frameBufferStride = pScreenPriv->screen->fb[0].byteStride;
-	pDRIInfo->ddxDrawableTableEntry = SAREA_MAX_DRAWABLES;
-	pDRIInfo->maxDrawableTableEntry = SAREA_MAX_DRAWABLES;
-
-	/* For now the mapping works by using a fixed size defined
-	 * in the SAREA header
-	 */
-	pDRIInfo->SAREASize = SAREA_MAX;
-
-	if (atic->is_radeon) {
-		pDRIInfo->devPrivateSize = sizeof(RADEONDRIRec);
-		devSareaSize = sizeof(RADEONSAREAPriv);
-	} else {
-		pDRIInfo->devPrivateSize = sizeof(R128DRIRec);
-		devSareaSize = sizeof(R128SAREAPriv);
-	}
-
-	if (sizeof(XF86DRISAREARec) + devSareaSize > SAREA_MAX) {
-		ErrorF("[dri] Data does not fit in SAREA.  Disabling DRI.\n");
-		return FALSE;
-	}
-
-	pDRIInfo->devPrivate = xcalloc(pDRIInfo->devPrivateSize, 1);
-	if (pDRIInfo->devPrivate == NULL) {
-		DRIDestroyInfoRec(atis->pDRIInfo);
-		atis->pDRIInfo = NULL;
-		return FALSE;
-	}
-
-	pDRIInfo->contextSize    = sizeof(ATIDRIContextRec);
-
-	pDRIInfo->SwapContext    = ATIDRISwapContext;
-	/*pDRIInfo->InitBuffers    = R128DRIInitBuffers;*/ /* XXX Appears unnecessary */
-	/*pDRIInfo->MoveBuffers    = R128DRIMoveBuffers;*/ /* XXX Badness */
-	pDRIInfo->bufferRequests = DRI_ALL_WINDOWS;
-	/*pDRIInfo->TransitionTo2d = R128DRITransitionTo2d;
-	pDRIInfo->TransitionTo3d = R128DRITransitionTo3d;
-	pDRIInfo->TransitionSingleToMulti3D = R128DRITransitionSingleToMulti3d;
-	pDRIInfo->TransitionMultiToSingle3D = R128DRITransitionMultiToSingle3d;*/
-
-	pDRIInfo->createDummyCtx     = TRUE;
-	pDRIInfo->createDummyCtxPriv = FALSE;
-
-	if (!DRIScreenInit(pScreen, pDRIInfo, &atic->drmFd)) {
-		ErrorF("[dri] DRIScreenInit failed.  Disabling DRI.\n");
-		xfree(pDRIInfo->devPrivate);
-		pDRIInfo->devPrivate = NULL;
-		DRIDestroyInfoRec(pDRIInfo);
-		pDRIInfo = NULL;
-		return FALSE;
-	}
-
-	/* Add a map for the MMIO registers that will be accessed by any
-	 * DRI-based clients.
-	 */
-	atis->registerSize = ATI_REG_SIZE(pScreenPriv->screen->card);
-	if (drmAddMap(atic->drmFd, ATI_REG_BASE(pScreenPriv->screen->card),
-	    atis->registerSize, DRM_REGISTERS, DRM_READ_ONLY,
-	    &atis->registerHandle) < 0) {
-		ATIDRICloseScreen(pScreen);
-		return FALSE;
-	}
-	ErrorF("[drm] register handle = 0x%08lx\n", atis->registerHandle);
-
-	/* DRIScreenInit adds the frame buffer map, but we need it as well */
-	DRIGetDeviceInfo(pScreen, &atis->fbHandle, &scratch_int, &scratch_int,
-	    &scratch_int, &scratch_int, &scratch_ptr);
-
-	/* Initialize AGP */
-	atis->using_agp = atic->is_agp;
-	if (atic->is_agp && !ATIDRIAgpInit(pScreen)) {
-		atis->using_agp = FALSE;
-		ErrorF("[agp] AGP failed to initialize; falling back to PCI mode.\n");
-		ErrorF("[agp] Make sure your kernel's AGP support is loaded and functioning.\n");
-	}
-
-	/* Initialize PCIGART */
-	if (!atis->using_agp && !ATIDRIPciInit(pScreen)) {
-		ATIDRICloseScreen(pScreen);
-		return FALSE;
-	}
-
-#ifdef GLXEXT
-	if (!ATIInitVisualConfigs(pScreen)) {
-		ATIDRICloseScreen(pScreen);
-		return FALSE;
-	}
-	ErrorF("[dri] Visual configs initialized\n");
-#endif
-
-	atis->serverContext = DRIGetContext(pScreen);
-
-	return ATIDRIFinishScreenInit(pScreen);
-}
-
-/* Finish initializing the device-dependent DRI state, and call
-   DRIFinishScreenInit() to complete the device-independent DRI
-   initialization. */
-static Bool
-R128DRIFinishScreenInit(ScreenPtr pScreen)
-{
-	KdScreenPriv(pScreen);
-	ATIScreenInfo(pScreenPriv);
-	R128SAREAPrivPtr pSAREAPriv;
-	R128DRIPtr       pR128DRI;
-	int bpp = pScreenPriv->screen->fb[0].bitsPerPixel;
-
-	/* Initialize the kernel data structures */
-	if (!R128DRIKernelInit(pScreen)) {
-		ATIDRICloseScreen(pScreen);
-		return FALSE;
-	}
-
-	/* Initialize the vertex buffers list */
-	if (!ATIDRIBufInit(pScreen)) {
-		ATIDRICloseScreen(pScreen);
-		return FALSE;
-	}
-
-	/* Initialize IRQ */
-	ATIDRIIrqInit(pScreen);
-
-	pSAREAPriv = (R128SAREAPrivPtr)DRIGetSAREAPrivate(pScreen);
-	memset(pSAREAPriv, 0, sizeof(*pSAREAPriv));
-
-	pR128DRI                    = (R128DRIPtr)atis->pDRIInfo->devPrivate;
-
-	pR128DRI->deviceID          = pScreenPriv->screen->card->attr.deviceID;
-	pR128DRI->width             = pScreenPriv->screen->width;
-	pR128DRI->height            = pScreenPriv->screen->height;
-	pR128DRI->depth             = pScreenPriv->screen->fb[0].depth;
-	pR128DRI->bpp               = pScreenPriv->screen->fb[0].bitsPerPixel;
-
-	pR128DRI->IsPCI             = !atis->using_agp;
-	pR128DRI->AGPMode           = atis->agpMode;
-
-	pR128DRI->frontOffset       = atis->frontOffset;
-	pR128DRI->frontPitch        = atis->frontPitch / (bpp / 8);
-	pR128DRI->backOffset        = atis->backOffset;
-	pR128DRI->backPitch         = atis->backPitch / (bpp / 8);
-	pR128DRI->depthOffset       = atis->depthOffset;
-	pR128DRI->depthPitch        = atis->depthPitch / (bpp / 8);
-	pR128DRI->spanOffset        = atis->spanOffset;
-	pR128DRI->textureOffset     = atis->textureOffset;
-	pR128DRI->textureSize       = atis->textureSize;
-	pR128DRI->log2TexGran       = atis->log2TexGran;
-
-	pR128DRI->registerHandle    = atis->registerHandle;
-	pR128DRI->registerSize      = atis->registerSize;
-
-	pR128DRI->gartTexHandle     = atis->gartTexHandle;
-	pR128DRI->gartTexMapSize    = atis->gartTexMapSize;
-	pR128DRI->log2AGPTexGran    = atis->log2GARTTexGran;
-	pR128DRI->gartTexOffset     = atis->gartTexStart;
-	pR128DRI->sarea_priv_offset = sizeof(XF86DRISAREARec);
-
-	return TRUE;
-}
-
-/* Finish initializing the device-dependent DRI state, and call
- * DRIFinishScreenInit() to complete the device-independent DRI
- * initialization.
- */
-static Bool
-RadeonDRIFinishScreenInit(ScreenPtr pScreen)
-{
-	KdScreenPriv(pScreen);
-	ATIScreenInfo(pScreenPriv);
-	ATICardInfo(pScreenPriv);
-	RADEONSAREAPrivPtr  pSAREAPriv;
-	RADEONDRIPtr        pRADEONDRI;
-	drmRadeonMemInitHeap drmHeap;
-
-	/* Initialize the kernel data structures */
-	if (!RadeonDRIKernelInit(pScreen)) {
-		ATIDRICloseScreen(pScreen);
-		return FALSE;
-	}
-
-	/* Initialize the vertex buffers list */
-	if (!ATIDRIBufInit(pScreen)) {
-		ATIDRICloseScreen(pScreen);
-		return FALSE;
-	}
-
-	/* Initialize IRQ */
-	ATIDRIIrqInit(pScreen);
-
-	drmHeap.region = RADEON_MEM_REGION_GART;
-	drmHeap.start  = 0;
-	drmHeap.size   = atis->gartTexMapSize;
-
-	if (drmCommandWrite(atic->drmFd, DRM_RADEON_INIT_HEAP, &drmHeap,
-	    sizeof(drmHeap))) {
-		ErrorF("[drm] Failed to initialize GART heap manager\n");
-	}
-
-	/* Initialize the SAREA private data structure */
-	pSAREAPriv = (RADEONSAREAPrivPtr)DRIGetSAREAPrivate(pScreen);
-	memset(pSAREAPriv, 0, sizeof(*pSAREAPriv));
-
-	pRADEONDRI = (RADEONDRIPtr)atis->pDRIInfo->devPrivate;
-
-	pRADEONDRI->deviceID          = pScreenPriv->screen->card->attr.deviceID;
-	pRADEONDRI->width             = pScreenPriv->screen->width;
-	pRADEONDRI->height            = pScreenPriv->screen->height;
-	pRADEONDRI->depth             = pScreenPriv->screen->fb[0].depth;
-	pRADEONDRI->bpp               = pScreenPriv->screen->fb[0].bitsPerPixel;
-
-	pRADEONDRI->IsPCI             = !atis->using_agp;
-	pRADEONDRI->AGPMode           = atis->agpMode;
-
-	pRADEONDRI->frontOffset       = atis->frontOffset;
-	pRADEONDRI->frontPitch        = atis->frontPitch;
-	pRADEONDRI->backOffset        = atis->backOffset;
-	pRADEONDRI->backPitch         = atis->backPitch;
-	pRADEONDRI->depthOffset       = atis->depthOffset;
-	pRADEONDRI->depthPitch        = atis->depthPitch;
-	pRADEONDRI->textureOffset     = atis->textureOffset;
-	pRADEONDRI->textureSize       = atis->textureSize;
-	pRADEONDRI->log2TexGran       = atis->log2TexGran;
-
-	pRADEONDRI->registerHandle    = atis->registerHandle;
-	pRADEONDRI->registerSize      = atis->registerSize;
-
-	pRADEONDRI->statusHandle      = atis->ringReadPtrHandle;
-	pRADEONDRI->statusSize        = atis->ringReadMapSize;
-
-	pRADEONDRI->gartTexHandle     = atis->gartTexHandle;
-	pRADEONDRI->gartTexMapSize    = atis->gartTexMapSize;
-	pRADEONDRI->log2GARTTexGran   = atis->log2GARTTexGran;
-	pRADEONDRI->gartTexOffset     = atis->gartTexStart;
-
-	pRADEONDRI->sarea_priv_offset = sizeof(XF86DRISAREARec);
-
-	return TRUE;
-}
-
-static Bool
-ATIDRIFinishScreenInit(ScreenPtr pScreen)
-{
-	KdScreenPriv(pScreen);
-	ATIScreenInfo(pScreenPriv);
-	ATICardInfo (pScreenPriv);
-
-	atis->pDRIInfo->driverSwapMethod = DRI_HIDE_X_CONTEXT;
-
-	/* NOTE: DRIFinishScreenInit must be called before *DRIKernelInit
-	 * because *DRIKernelInit requires that the hardware lock is held by
-	 * the X server, and the first time the hardware lock is grabbed is
-	 * in DRIFinishScreenInit.
-	 */
-	if (!DRIFinishScreenInit(pScreen)) {
-		ATIDRICloseScreen(pScreen);
-		return FALSE;
-	}
-
-	if (atic->is_radeon) {
-		if (!RadeonDRIFinishScreenInit(pScreen)) {
-			ATIDRICloseScreen(pScreen);
-			return FALSE;
-		}
-	} else {
-		if (!R128DRIFinishScreenInit(pScreen)) {
-			ATIDRICloseScreen(pScreen);
-			return FALSE;
-		}
-	}
-
-	return TRUE;
-}
-
-/* The screen is being closed, so clean up any state and free any
-   resources used by the DRI. */
-void
-ATIDRICloseScreen(ScreenPtr pScreen)
-{
-	KdScreenPriv (pScreen);
-	ATIScreenInfo (pScreenPriv);
-	ATICardInfo (pScreenPriv);
-	drmR128Init drmR128Info;
-	drmRadeonInit drmRadeonInfo;
-
-	if (atis->indirectBuffer != NULL) {
-		/* Flush any remaining commands and free indirect buffers.
-		 * Two steps are used because ATIFlushIndirect gets a
-		 * new buffer after discarding.
-		 */
-		ATIFlushIndirect(atis, 1);
-		ATIDRIDispatchIndirect(atis, 1);
-		xfree(atis->indirectBuffer);
-		atis->indirectBuffer = NULL;
-		atis->indirectStart = 0;
-	}
-	ATIDRIDMAStop(atis);
-
-	if (atis->irqEnabled) {
-		drmCtlUninstHandler(atic->drmFd);
-		atis->irqEnabled = FALSE;
-	}
-
-	/* De-allocate vertex buffers */
-	if (atis->buffers) {
-		drmUnmapBufs(atis->buffers);
-		atis->buffers = NULL;
-	}
-
-	/* De-allocate all kernel resources */
-	if (!atic->is_radeon) {
-		memset(&drmR128Info, 0, sizeof(drmR128Init));
-		drmR128Info.func = DRM_R128_CLEANUP_CCE;
-		drmCommandWrite(atic->drmFd, DRM_R128_INIT, &drmR128Info,
-		    sizeof(drmR128Init));
-	} else {
-		memset(&drmRadeonInfo, 0, sizeof(drmRadeonInfo));
-		drmRadeonInfo.func = DRM_RADEON_CLEANUP_CP;
-		drmCommandWrite(atic->drmFd, DRM_RADEON_CP_INIT, &drmRadeonInfo,
-		    sizeof(drmR128Init));
-	}
-
-	/* De-allocate all AGP resources */
-	if (atis->gartTex) {
-		drmUnmap(atis->gartTex, atis->gartTexMapSize);
-		atis->gartTex = NULL;
-	}
-	if (atis->buf) {
-		drmUnmap(atis->buf, atis->bufMapSize);
-		atis->buf = NULL;
-	}
-	if (atis->ringReadPtr) {
-		drmUnmap(atis->ringReadPtr, atis->ringReadMapSize);
-		atis->ringReadPtr = NULL;
-	}
-	if (atis->ring) {
-		drmUnmap(atis->ring, atis->ringMapSize);
-		atis->ring = NULL;
-	}
-	if (atis->agpMemHandle != DRM_AGP_NO_HANDLE) {
-		drmAgpUnbind(atic->drmFd, atis->agpMemHandle);
-		drmAgpFree(atic->drmFd, atis->agpMemHandle);
-		atis->agpMemHandle = DRM_AGP_NO_HANDLE;
-		drmAgpRelease(atic->drmFd);
-	}
-	if (atis->pciMemHandle) {
-		drmScatterGatherFree(atic->drmFd, atis->pciMemHandle);
-		atis->pciMemHandle = 0;
-	}
-
-	/* De-allocate all DRI resources */
-	DRICloseScreen(pScreen);
-
-	/* De-allocate all DRI data structures */
-	if (atis->pDRIInfo) {
-		if (atis->pDRIInfo->devPrivate) {
-			xfree(atis->pDRIInfo->devPrivate);
-			atis->pDRIInfo->devPrivate = NULL;
-		}
-		DRIDestroyInfoRec(atis->pDRIInfo);
-		atis->pDRIInfo = NULL;
-	}
-
-#ifdef GLXEXT
-	if (atis->pVisualConfigs) {
-		xfree(atis->pVisualConfigs);
-		atis->pVisualConfigs = NULL;
-	}
-	if (atis->pVisualConfigsPriv) {
-		xfree(atis->pVisualConfigsPriv);
-		atis->pVisualConfigsPriv = NULL;
-	}
-#endif /* GLXEXT */
-	atic->drmFd = -1;
-}
-
-void
-ATIDRIDMAStart(ATIScreenInfo *atis)
-{
-	ATICardInfo *atic = atis->atic;
-	int ret;
-
-	if (atic->is_radeon)
-		ret = drmCommandNone(atic->drmFd, DRM_RADEON_CP_START);
-	else
-		ret = drmCommandNone(atic->drmFd, DRM_R128_CCE_START);
-
-	if (ret == 0)
-		atis->dma_started = TRUE;
-	else
-		FatalError("%s: DMA start returned %d\n", __FUNCTION__, ret);
-}
-
-/* Attempts to idle the DMA engine and stops it.  Note that the ioctl is the
- * same for both R128 and Radeon, so we can just use the name of one of them.
- */
-void
-ATIDRIDMAStop(ATIScreenInfo *atis)
-{
-	ATICardInfo *atic = atis->atic;
-	drmRadeonCPStop stop;
-	int ret;
-
-	stop.flush = 1;
-	stop.idle  = 1;
-	ret = drmCommandWrite(atic->drmFd, DRM_RADEON_CP_STOP, &stop, 
-	    sizeof(drmRadeonCPStop));
-
-	if (ret != 0 && errno == EBUSY) {
-		ErrorF("Failed to idle the DMA engine\n");
-
-		stop.idle = 0;
-		ret = drmCommandWrite(atic->drmFd, DRM_RADEON_CP_STOP, &stop,
-		    sizeof(drmRadeonCPStop));
-	}
-	atis->dma_started = FALSE;
-}
-
-void
-ATIDRIDMAReset(ATIScreenInfo *atis)
-{
-	ATICardInfo *atic = atis->atic;
-	int ret;
-
-	ret = drmCommandNone(atic->drmFd, atic->is_radeon ?
-	    DRM_RADEON_CP_RESET : DRM_R128_CCE_RESET);
-
-	if (ret != 0)
-		FatalError("Failed to reset CCE/CP\n");
-
-	atis->dma_started = FALSE;
-}
-
-/* The R128 and Radeon Indirect ioctls differ only in the ioctl number */
-void
-ATIDRIDispatchIndirect(ATIScreenInfo *atis, Bool discard)
-{
-	ATICardInfo *atic = atis->atic;
-	drmBufPtr buffer = atis->indirectBuffer->drmBuf;
-	drmR128Indirect indirect;
-	int cmd;
-
-	indirect.idx = buffer->idx;
-	indirect.start = atis->indirectStart;
-	indirect.end = buffer->used;
-	indirect.discard = discard;
-	cmd = atic->is_radeon ? DRM_RADEON_INDIRECT : DRM_R128_INDIRECT;
-	drmCommandWriteRead(atic->drmFd, cmd, &indirect,
-	    sizeof(drmR128Indirect));
-}
-
-/* Get an indirect buffer for the DMA 2D acceleration commands  */
-drmBufPtr
-ATIDRIGetBuffer(ATIScreenInfo *atis)
-{
-	ATICardInfo *atic = atis->atic;
-	drmDMAReq dma;
-	drmBufPtr buf = NULL;
-	int indx = 0, size = 0, ret = 0;
-	TIMEOUT_LOCALS;
-
-	dma.context = atis->serverContext;
-	dma.send_count = 0;
-	dma.send_list = NULL;
-	dma.send_sizes = NULL;
-	dma.flags = 0;
-	dma.request_count = 1;
-	if (atic->is_radeon)
-		dma.request_size = RADEON_BUFFER_SIZE;
-	else
-		dma.request_size = R128_BUFFER_SIZE;
-	dma.request_list = &indx;
-	dma.request_sizes = &size;
-	dma.granted_count = 0;
-
-	WHILE_NOT_TIMEOUT(.2) {
-		ret = drmDMA(atic->drmFd, &dma);
-		if (ret != -EBUSY)
-			break;
-	}
-	if (TIMEDOUT())
-		FatalError("Timeout fetching DMA buffer (card hung)\n");
-	if (ret != 0)
-		FatalError("Error fetching DMA buffer: %d\n", ret);
-
-	buf = &atis->buffers->list[indx];
-	buf->used = 0;
-	return buf;
-}
diff --git a/hw/kdrive/ati/ati_dri.h b/hw/kdrive/ati/ati_dri.h
deleted file mode 100644
index 985f7eb..0000000
--- a/hw/kdrive/ati/ati_dri.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright © 2003 Eric Anholt
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Eric Anholt not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  Eric Anholt makes no
- * representations about the suitability of this software for any purpose.  It
- * is provided "as is" without express or implied warranty.
- *
- * ERIC ANHOLT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL ERIC ANHOLT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifndef _ATI_DRI_H_
-#define _ATI_DRI_H_
-
-typedef struct {
-	/* DRI screen private data */
-	int		deviceID;	/* PCI device ID */
-	int		width;		/* Width in pixels of display */
-	int		height;		/* Height in scanlines of display */
-	int		depth;		/* Depth of display (8, 15, 16, 24) */
-	int		bpp;		/* Bit depth of display (8, 16, 24, 32) */
-
-	int		IsPCI;		/* Current card is a PCI card */
-	int		AGPMode;
-
-	int		frontOffset;	/* Start of front buffer */
-	int		frontPitch;
-	int		backOffset;	/* Start of shared back buffer */
-	int		backPitch;
-	int		depthOffset;	/* Start of shared depth buffer */
-	int		depthPitch;
-	int		spanOffset;	/* Start of scratch spanline */
-	int		textureOffset;	/* Start of texture data in frame buffer */
-	int		textureSize;
-	int		log2TexGran;
-
-	/* MMIO register data */
-	drmHandle	registerHandle;
-	drmSize		registerSize;
-
-	/* CCE AGP Texture data */
-	drmHandle	gartTexHandle;
-	drmSize		gartTexMapSize;
-	int		log2AGPTexGran;
-	int		gartTexOffset;
-	unsigned int sarea_priv_offset;
-} R128DRIRec, *R128DRIPtr;
-
-typedef struct {
-	/* DRI screen private data */
-	int		deviceID;	/* PCI device ID */
-	int		width;		/* Width in pixels of display */
-	int		height;		/* Height in scanlines of display */
-	int		depth;		/* Depth of display (8, 15, 16, 24) */
-	int		bpp;		/* Bit depth of display (8, 16, 24, 32) */
-
-	int		IsPCI;		/* Current card is a PCI card */
-	int		AGPMode;
-
-	int		frontOffset;	/* Start of front buffer */
-	int		frontPitch;
-	int		backOffset;	/* Start of shared back buffer */
-	int		backPitch;
-	int		depthOffset;	/* Start of shared depth buffer */
-	int		depthPitch;
-	int		textureOffset;	/* Start of texture data in frame buffer */
-	int		textureSize;
-	int		log2TexGran;
-
-	/* MMIO register data */
-	drmHandle	registerHandle;
-	drmSize		registerSize;
-
-	/* CP in-memory status information */
-	drmHandle	statusHandle;
-	drmSize		statusSize;
-
-	/* CP GART Texture data */
-	drmHandle	gartTexHandle;
-	drmSize		gartTexMapSize;
-	int		log2GARTTexGran;
-	int		gartTexOffset;
-	unsigned int	sarea_priv_offset;
-} RADEONDRIRec, *RADEONDRIPtr;
-
-#endif /* _ATI_DRI_H_ */
diff --git a/hw/kdrive/ati/ati_dripriv.h b/hw/kdrive/ati/ati_dripriv.h
deleted file mode 100644
index f0e1393..0000000
--- a/hw/kdrive/ati/ati_dripriv.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright 1999, 2000 ATI Technologies Inc., Markham, Ontario,
- *                      Precision Insight, Inc., Cedar Park, Texas, and
- *                      VA Linux Systems Inc., Fremont, 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 on 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
- * NON-INFRINGEMENT.  IN NO EVENT SHALL ATI, PRECISION INSIGHT, VA LINUX
- * SYSTEMS AND/OR THEIR 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. Faith <faith at valinux.com>
- *   Kevin E. Martin <martin at valinux.com>
- *
- */
-
-#ifndef _ATI_DRIPRIV_H_
-#define _ATI_DRIPRIV_H_
-
-#ifdef GLXEXT
-#include "GL/glxint.h"
-
-extern void GlxSetVisualConfigs(int nconfigs, __GLXvisualConfig *configs,
-				void **configprivs);
-#endif
-
-typedef struct {
-    /* Nothing here yet */
-    int dummy;
-} ATIConfigPrivRec, *ATIConfigPrivPtr;
-
-typedef struct {
-    /* Nothing here yet */
-    int dummy;
-} ATIDRIContextRec, *ATIDRIContextPtr;
-
-#endif
diff --git a/hw/kdrive/ati/ati_microcode.c b/hw/kdrive/ati/ati_microcode.c
deleted file mode 100644
index f8829e8..0000000
--- a/hw/kdrive/ati/ati_microcode.c
+++ /dev/null
@@ -1,857 +0,0 @@
-/* r128_cce.c -- ATI Rage 128 driver -*- linux-c -*-
- * radeon_cp.c -- CP support for Radeon -*- linux-c -*-
- *
- * Copyright 2000 Precision Insight, Inc., Cedar Park, Texas.
- * Copyright 2000 VA Linux Systems, Inc., Fremont, 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.
- *
- * Authors:
- *    Kevin E. Martin <martin at valinux.com>
- *    Gareth Hughes <gareth at valinux.com>
- */
-
-/* CCE microcode (from ATI) */
-
-#include "ati.h"
-
-CARD32 r128_cce_microcode[] = {
-	0, 276838400, 0, 268449792, 2, 142, 2, 145, 0, 1076765731, 0,
-	1617039951, 0, 774592877, 0, 1987540286, 0, 2307490946U, 0,
-	599558925, 0, 589505315, 0, 596487092, 0, 589505315, 1,
-	11544576, 1, 206848, 1, 311296, 1, 198656, 2, 912273422, 11,
-	262144, 0, 0, 1, 33559837, 1, 7438, 1, 14809, 1, 6615, 12, 28,
-	1, 6614, 12, 28, 2, 23, 11, 18874368, 0, 16790922, 1, 409600, 9,
-	30, 1, 147854772, 16, 420483072, 3, 8192, 0, 10240, 1, 198656,
-	1, 15630, 1, 51200, 10, 34858, 9, 42, 1, 33559823, 2, 10276, 1,
-	15717, 1, 15718, 2, 43, 1, 15936948, 1, 570480831, 1, 14715071,
-	12, 322123831, 1, 33953125, 12, 55, 1, 33559908, 1, 15718, 2,
-	46, 4, 2099258, 1, 526336, 1, 442623, 4, 4194365, 1, 509952, 1,
-	459007, 3, 0, 12, 92, 2, 46, 12, 176, 1, 15734, 1, 206848, 1,
-	18432, 1, 133120, 1, 100670734, 1, 149504, 1, 165888, 1,
-	15975928, 1, 1048576, 6, 3145806, 1, 15715, 16, 2150645232U, 2,
-	268449859, 2, 10307, 12, 176, 1, 15734, 1, 15735, 1, 15630, 1,
-	15631, 1, 5253120, 6, 3145810, 16, 2150645232U, 1, 15864, 2, 82,
-	1, 343310, 1, 1064207, 2, 3145813, 1, 15728, 1, 7817, 1, 15729,
-	3, 15730, 12, 92, 2, 98, 1, 16168, 1, 16167, 1, 16002, 1, 16008,
-	1, 15974, 1, 15975, 1, 15990, 1, 15976, 1, 15977, 1, 15980, 0,
-	15981, 1, 10240, 1, 5253120, 1, 15720, 1, 198656, 6, 110, 1,
-	180224, 1, 103824738, 2, 112, 2, 3145839, 0, 536885440, 1,
-	114880, 14, 125, 12, 206975, 1, 33559995, 12, 198784, 0,
-	33570236, 1, 15803, 0, 15804, 3, 294912, 1, 294912, 3, 442370,
-	1, 11544576, 0, 811612160, 1, 12593152, 1, 11536384, 1,
-	14024704, 7, 310382726, 0, 10240, 1, 14796, 1, 14797, 1, 14793,
-	1, 14794, 0, 14795, 1, 268679168, 1, 9437184, 1, 268449792, 1,
-	198656, 1, 9452827, 1, 1075854602, 1, 1075854603, 1, 557056, 1,
-	114880, 14, 159, 12, 198784, 1, 1109409213, 12, 198783, 1,
-	1107312059, 12, 198784, 1, 1109409212, 2, 162, 1, 1075854781, 1,
-	1073757627, 1, 1075854780, 1, 540672, 1, 10485760, 6, 3145894,
-	16, 274741248, 9, 168, 3, 4194304, 3, 4209949, 0, 0, 0, 256, 14,
-	174, 1, 114857, 1, 33560007, 12, 176, 0, 10240, 1, 114858, 1,
-	33560018, 1, 114857, 3, 33560007, 1, 16008, 1, 114874, 1,
-	33560360, 1, 114875, 1, 33560154, 0, 15963, 0, 256, 0, 4096, 1,
-	409611, 9, 188, 0, 10240, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
-};
-
-CARD32 radeon_cp_microcode[][2] = {
-	{ 0x21007000, 0000000000 },
-	{ 0x20007000, 0000000000 },
-	{ 0x000000b4, 0x00000004 },
-	{ 0x000000b8, 0x00000004 },
-	{ 0x6f5b4d4c, 0000000000 },
-	{ 0x4c4c427f, 0000000000 },
-	{ 0x5b568a92, 0000000000 },
-	{ 0x4ca09c6d, 0000000000 },
-	{ 0xad4c4c4c, 0000000000 },
-	{ 0x4ce1af3d, 0000000000 },
-	{ 0xd8afafaf, 0000000000 },
-	{ 0xd64c4cdc, 0000000000 },
-	{ 0x4cd10d10, 0000000000 },
-	{ 0x000f0000, 0x00000016 },
-	{ 0x362f242d, 0000000000 },
-	{ 0x00000012, 0x00000004 },
-	{ 0x000f0000, 0x00000016 },
-	{ 0x362f282d, 0000000000 },
-	{ 0x000380e7, 0x00000002 },
-	{ 0x04002c97, 0x00000002 },
-	{ 0x000f0001, 0x00000016 },
-	{ 0x333a3730, 0000000000 },
-	{ 0x000077ef, 0x00000002 },
-	{ 0x00061000, 0x00000002 },
-	{ 0x00000021, 0x0000001a },
-	{ 0x00004000, 0x0000001e },
-	{ 0x00061000, 0x00000002 },
-	{ 0x00000021, 0x0000001a },
-	{ 0x00004000, 0x0000001e },
-	{ 0x00061000, 0x00000002 },
-	{ 0x00000021, 0x0000001a },
-	{ 0x00004000, 0x0000001e },
-	{ 0x00000017, 0x00000004 },
-	{ 0x0003802b, 0x00000002 },
-	{ 0x040067e0, 0x00000002 },
-	{ 0x00000017, 0x00000004 },
-	{ 0x000077e0, 0x00000002 },
-	{ 0x00065000, 0x00000002 },
-	{ 0x000037e1, 0x00000002 },
-	{ 0x040067e1, 0x00000006 },
-	{ 0x000077e0, 0x00000002 },
-	{ 0x000077e1, 0x00000002 },
-	{ 0x000077e1, 0x00000006 },
-	{ 0xffffffff, 0000000000 },
-	{ 0x10000000, 0000000000 },
-	{ 0x0003802b, 0x00000002 },
-	{ 0x040067e0, 0x00000006 },
-	{ 0x00007675, 0x00000002 },
-	{ 0x00007676, 0x00000002 },
-	{ 0x00007677, 0x00000002 },
-	{ 0x00007678, 0x00000006 },
-	{ 0x0003802c, 0x00000002 },
-	{ 0x04002676, 0x00000002 },
-	{ 0x00007677, 0x00000002 },
-	{ 0x00007678, 0x00000006 },
-	{ 0x0000002f, 0x00000018 },
-	{ 0x0000002f, 0x00000018 },
-	{ 0000000000, 0x00000006 },
-	{ 0x00000030, 0x00000018 },
-	{ 0x00000030, 0x00000018 },
-	{ 0000000000, 0x00000006 },
-	{ 0x01605000, 0x00000002 },
-	{ 0x00065000, 0x00000002 },
-	{ 0x00098000, 0x00000002 },
-	{ 0x00061000, 0x00000002 },
-	{ 0x64c0603e, 0x00000004 },
-	{ 0x000380e6, 0x00000002 },
-	{ 0x040025c5, 0x00000002 },
-	{ 0x00080000, 0x00000016 },
-	{ 0000000000, 0000000000 },
-	{ 0x0400251d, 0x00000002 },
-	{ 0x00007580, 0x00000002 },
-	{ 0x00067581, 0x00000002 },
-	{ 0x04002580, 0x00000002 },
-	{ 0x00067581, 0x00000002 },
-	{ 0x00000049, 0x00000004 },
-	{ 0x00005000, 0000000000 },
-	{ 0x000380e6, 0x00000002 },
-	{ 0x040025c5, 0x00000002 },
-	{ 0x00061000, 0x00000002 },
-	{ 0x0000750e, 0x00000002 },
-	{ 0x00019000, 0x00000002 },
-	{ 0x00011055, 0x00000014 },
-	{ 0x00000055, 0x00000012 },
-	{ 0x0400250f, 0x00000002 },
-	{ 0x0000504f, 0x00000004 },
-	{ 0x000380e6, 0x00000002 },
-	{ 0x040025c5, 0x00000002 },
-	{ 0x00007565, 0x00000002 },
-	{ 0x00007566, 0x00000002 },
-	{ 0x00000058, 0x00000004 },
-	{ 0x000380e6, 0x00000002 },
-	{ 0x040025c5, 0x00000002 },
-	{ 0x01e655b4, 0x00000002 },
-	{ 0x4401b0e4, 0x00000002 },
-	{ 0x01c110e4, 0x00000002 },
-	{ 0x26667066, 0x00000018 },
-	{ 0x040c2565, 0x00000002 },
-	{ 0x00000066, 0x00000018 },
-	{ 0x04002564, 0x00000002 },
-	{ 0x00007566, 0x00000002 },
-	{ 0x0000005d, 0x00000004 },
-	{ 0x00401069, 0x00000008 },
-	{ 0x00101000, 0x00000002 },
-	{ 0x000d80ff, 0x00000002 },
-	{ 0x0080006c, 0x00000008 },
-	{ 0x000f9000, 0x00000002 },
-	{ 0x000e00ff, 0x00000002 },
-	{ 0000000000, 0x00000006 },
-	{ 0x0000008f, 0x00000018 },
-	{ 0x0000005b, 0x00000004 },
-	{ 0x000380e6, 0x00000002 },
-	{ 0x040025c5, 0x00000002 },
-	{ 0x00007576, 0x00000002 },
-	{ 0x00065000, 0x00000002 },
-	{ 0x00009000, 0x00000002 },
-	{ 0x00041000, 0x00000002 },
-	{ 0x0c00350e, 0x00000002 },
-	{ 0x00049000, 0x00000002 },
-	{ 0x00051000, 0x00000002 },
-	{ 0x01e785f8, 0x00000002 },
-	{ 0x00200000, 0x00000002 },
-	{ 0x0060007e, 0x0000000c },
-	{ 0x00007563, 0x00000002 },
-	{ 0x006075f0, 0x00000021 },
-	{ 0x20007073, 0x00000004 },
-	{ 0x00005073, 0x00000004 },
-	{ 0x000380e6, 0x00000002 },
-	{ 0x040025c5, 0x00000002 },
-	{ 0x00007576, 0x00000002 },
-	{ 0x00007577, 0x00000002 },
-	{ 0x0000750e, 0x00000002 },
-	{ 0x0000750f, 0x00000002 },
-	{ 0x00a05000, 0x00000002 },
-	{ 0x00600083, 0x0000000c },
-	{ 0x006075f0, 0x00000021 },
-	{ 0x000075f8, 0x00000002 },
-	{ 0x00000083, 0x00000004 },
-	{ 0x000a750e, 0x00000002 },
-	{ 0x000380e6, 0x00000002 },
-	{ 0x040025c5, 0x00000002 },
-	{ 0x0020750f, 0x00000002 },
-	{ 0x00600086, 0x00000004 },
-	{ 0x00007570, 0x00000002 },
-	{ 0x00007571, 0x00000002 },
-	{ 0x00007572, 0x00000006 },
-	{ 0x000380e6, 0x00000002 },
-	{ 0x040025c5, 0x00000002 },
-	{ 0x00005000, 0x00000002 },
-	{ 0x00a05000, 0x00000002 },
-	{ 0x00007568, 0x00000002 },
-	{ 0x00061000, 0x00000002 },
-	{ 0x00000095, 0x0000000c },
-	{ 0x00058000, 0x00000002 },
-	{ 0x0c607562, 0x00000002 },
-	{ 0x00000097, 0x00000004 },
-	{ 0x000380e6, 0x00000002 },
-	{ 0x040025c5, 0x00000002 },
-	{ 0x00600096, 0x00000004 },
-	{ 0x400070e5, 0000000000 },
-	{ 0x000380e6, 0x00000002 },
-	{ 0x040025c5, 0x00000002 },
-	{ 0x000380e5, 0x00000002 },
-	{ 0x000000a8, 0x0000001c },
-	{ 0x000650aa, 0x00000018 },
-	{ 0x040025bb, 0x00000002 },
-	{ 0x000610ab, 0x00000018 },
-	{ 0x040075bc, 0000000000 },
-	{ 0x000075bb, 0x00000002 },
-	{ 0x000075bc, 0000000000 },
-	{ 0x00090000, 0x00000006 },
-	{ 0x00090000, 0x00000002 },
-	{ 0x000d8002, 0x00000006 },
-	{ 0x00007832, 0x00000002 },
-	{ 0x00005000, 0x00000002 },
-	{ 0x000380e7, 0x00000002 },
-	{ 0x04002c97, 0x00000002 },
-	{ 0x00007820, 0x00000002 },
-	{ 0x00007821, 0x00000002 },
-	{ 0x00007800, 0000000000 },
-	{ 0x01200000, 0x00000002 },
-	{ 0x20077000, 0x00000002 },
-	{ 0x01200000, 0x00000002 },
-	{ 0x20007000, 0x00000002 },
-	{ 0x00061000, 0x00000002 },
-	{ 0x0120751b, 0x00000002 },
-	{ 0x8040750a, 0x00000002 },
-	{ 0x8040750b, 0x00000002 },
-	{ 0x00110000, 0x00000002 },
-	{ 0x000380e5, 0x00000002 },
-	{ 0x000000c6, 0x0000001c },
-	{ 0x000610ab, 0x00000018 },
-	{ 0x844075bd, 0x00000002 },
-	{ 0x000610aa, 0x00000018 },
-	{ 0x840075bb, 0x00000002 },
-	{ 0x000610ab, 0x00000018 },
-	{ 0x844075bc, 0x00000002 },
-	{ 0x000000c9, 0x00000004 },
-	{ 0x804075bd, 0x00000002 },
-	{ 0x800075bb, 0x00000002 },
-	{ 0x804075bc, 0x00000002 },
-	{ 0x00108000, 0x00000002 },
-	{ 0x01400000, 0x00000002 },
-	{ 0x006000cd, 0x0000000c },
-	{ 0x20c07000, 0x00000020 },
-	{ 0x000000cf, 0x00000012 },
-	{ 0x00800000, 0x00000006 },
-	{ 0x0080751d, 0x00000006 },
-	{ 0000000000, 0000000000 },
-	{ 0x0000775c, 0x00000002 },
-	{ 0x00a05000, 0x00000002 },
-	{ 0x00661000, 0x00000002 },
-	{ 0x0460275d, 0x00000020 },
-	{ 0x00004000, 0000000000 },
-	{ 0x01e00830, 0x00000002 },
-	{ 0x21007000, 0000000000 },
-	{ 0x6464614d, 0000000000 },
-	{ 0x69687420, 0000000000 },
-	{ 0x00000073, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0x00005000, 0x00000002 },
-	{ 0x000380d0, 0x00000002 },
-	{ 0x040025e0, 0x00000002 },
-	{ 0x000075e1, 0000000000 },
-	{ 0x00000001, 0000000000 },
-	{ 0x000380e0, 0x00000002 },
-	{ 0x04002394, 0x00000002 },
-	{ 0x00005000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0x00000008, 0000000000 },
-	{ 0x00000004, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-};
-
-CARD32 r200_cp_microcode[][2] = {
-	{ 0x21007000, 0000000000 },        
-	{ 0x20007000, 0000000000 }, 
-	{ 0x000000ab, 0x00000004 },
-	{ 0x000000af, 0x00000004 },
-	{ 0x66544a49, 0000000000 },
-	{ 0x49494174, 0000000000 },
-	{ 0x54517d83, 0000000000 },
-	{ 0x498d8b64, 0000000000 },
-	{ 0x49494949, 0000000000 },
-	{ 0x49da493c, 0000000000 },
-	{ 0x49989898, 0000000000 },
-	{ 0xd34949d5, 0000000000 },
-	{ 0x9dc90e11, 0000000000 },
-	{ 0xce9b9b9b, 0000000000 },
-	{ 0x000f0000, 0x00000016 },
-	{ 0x352e232c, 0000000000 },
-	{ 0x00000013, 0x00000004 },
-	{ 0x000f0000, 0x00000016 },
-	{ 0x352e272c, 0000000000 },
-	{ 0x000f0001, 0x00000016 },
-	{ 0x3239362f, 0000000000 },
-	{ 0x000077ef, 0x00000002 },
-	{ 0x00061000, 0x00000002 },
-	{ 0x00000020, 0x0000001a },
-	{ 0x00004000, 0x0000001e },
-	{ 0x00061000, 0x00000002 },
-	{ 0x00000020, 0x0000001a },
-	{ 0x00004000, 0x0000001e },
-	{ 0x00061000, 0x00000002 },
-	{ 0x00000020, 0x0000001a },
-	{ 0x00004000, 0x0000001e },
-	{ 0x00000016, 0x00000004 },
-	{ 0x0003802a, 0x00000002 },
-	{ 0x040067e0, 0x00000002 },
-	{ 0x00000016, 0x00000004 },
-	{ 0x000077e0, 0x00000002 },
-	{ 0x00065000, 0x00000002 },
-	{ 0x000037e1, 0x00000002 },
-	{ 0x040067e1, 0x00000006 },
-	{ 0x000077e0, 0x00000002 },
-	{ 0x000077e1, 0x00000002 },
-	{ 0x000077e1, 0x00000006 },
-	{ 0xffffffff, 0000000000 },
-	{ 0x10000000, 0000000000 },
-	{ 0x0003802a, 0x00000002 },
-	{ 0x040067e0, 0x00000006 },
-	{ 0x00007675, 0x00000002 },
-	{ 0x00007676, 0x00000002 },
-	{ 0x00007677, 0x00000002 },
-	{ 0x00007678, 0x00000006 },
-	{ 0x0003802b, 0x00000002 },
-	{ 0x04002676, 0x00000002 },
-	{ 0x00007677, 0x00000002 },
-	{ 0x00007678, 0x00000006 },
-	{ 0x0000002e, 0x00000018 },
-	{ 0x0000002e, 0x00000018 },
-	{ 0000000000, 0x00000006 },
-	{ 0x0000002f, 0x00000018 },
-	{ 0x0000002f, 0x00000018 },
-	{ 0000000000, 0x00000006 },
-	{ 0x01605000, 0x00000002 },
-	{ 0x00065000, 0x00000002 },
-	{ 0x00098000, 0x00000002 },
-	{ 0x00061000, 0x00000002 },
-	{ 0x64c0603d, 0x00000004 },
-	{ 0x00080000, 0x00000016 },
-	{ 0000000000, 0000000000 },
-	{ 0x0400251d, 0x00000002 },
-	{ 0x00007580, 0x00000002 },
-	{ 0x00067581, 0x00000002 },
-	{ 0x04002580, 0x00000002 },
-	{ 0x00067581, 0x00000002 },
-	{ 0x00000046, 0x00000004 },
-	{ 0x00005000, 0000000000 },
-	{ 0x00061000, 0x00000002 },
-	{ 0x0000750e, 0x00000002 },
-	{ 0x00019000, 0x00000002 },
-	{ 0x00011055, 0x00000014 },
-	{ 0x00000055, 0x00000012 },
-	{ 0x0400250f, 0x00000002 },
-	{ 0x0000504a, 0x00000004 },
-	{ 0x00007565, 0x00000002 },
-	{ 0x00007566, 0x00000002 },
-	{ 0x00000051, 0x00000004 },
-	{ 0x01e655b4, 0x00000002 },
-	{ 0x4401b0dc, 0x00000002 },
-	{ 0x01c110dc, 0x00000002 },
-	{ 0x2666705d, 0x00000018 },
-	{ 0x040c2565, 0x00000002 },
-	{ 0x0000005d, 0x00000018 },
-	{ 0x04002564, 0x00000002 },
-	{ 0x00007566, 0x00000002 },
-	{ 0x00000054, 0x00000004 },
-	{ 0x00401060, 0x00000008 },
-	{ 0x00101000, 0x00000002 },
-	{ 0x000d80ff, 0x00000002 },
-	{ 0x00800063, 0x00000008 },
-	{ 0x000f9000, 0x00000002 },
-	{ 0x000e00ff, 0x00000002 },
-	{ 0000000000, 0x00000006 },
-	{ 0x00000080, 0x00000018 },
-	{ 0x00000054, 0x00000004 },
-	{ 0x00007576, 0x00000002 },
-	{ 0x00065000, 0x00000002 },
-	{ 0x00009000, 0x00000002 },
-	{ 0x00041000, 0x00000002 },
-	{ 0x0c00350e, 0x00000002 },
-	{ 0x00049000, 0x00000002 },
-	{ 0x00051000, 0x00000002 },
-	{ 0x01e785f8, 0x00000002 },
-	{ 0x00200000, 0x00000002 },
-	{ 0x00600073, 0x0000000c },
-	{ 0x00007563, 0x00000002 },
-	{ 0x006075f0, 0x00000021 },
-	{ 0x20007068, 0x00000004 },
-	{ 0x00005068, 0x00000004 },
-	{ 0x00007576, 0x00000002 },
-	{ 0x00007577, 0x00000002 },
-	{ 0x0000750e, 0x00000002 },
-	{ 0x0000750f, 0x00000002 },
-	{ 0x00a05000, 0x00000002 },
-	{ 0x00600076, 0x0000000c },
-	{ 0x006075f0, 0x00000021 },
-	{ 0x000075f8, 0x00000002 },
-	{ 0x00000076, 0x00000004 },
-	{ 0x000a750e, 0x00000002 },
-	{ 0x0020750f, 0x00000002 },
-	{ 0x00600079, 0x00000004 },
-	{ 0x00007570, 0x00000002 },
-	{ 0x00007571, 0x00000002 },
-	{ 0x00007572, 0x00000006 },
-	{ 0x00005000, 0x00000002 },
-	{ 0x00a05000, 0x00000002 },
-	{ 0x00007568, 0x00000002 },
-	{ 0x00061000, 0x00000002 },
-	{ 0x00000084, 0x0000000c },
-	{ 0x00058000, 0x00000002 },
-	{ 0x0c607562, 0x00000002 },
-	{ 0x00000086, 0x00000004 },
-	{ 0x00600085, 0x00000004 },
-	{ 0x400070dd, 0000000000 },
-	{ 0x000380dd, 0x00000002 },
-	{ 0x00000093, 0x0000001c },
-	{ 0x00065095, 0x00000018 },
-	{ 0x040025bb, 0x00000002 },
-	{ 0x00061096, 0x00000018 },
-	{ 0x040075bc, 0000000000 },
-	{ 0x000075bb, 0x00000002 },
-	{ 0x000075bc, 0000000000 },
-	{ 0x00090000, 0x00000006 },
-	{ 0x00090000, 0x00000002 },
-	{ 0x000d8002, 0x00000006 },
-	{ 0x00005000, 0x00000002 },
-	{ 0x00007821, 0x00000002 },
-	{ 0x00007800, 0000000000 },
-	{ 0x00007821, 0x00000002 },
-	{ 0x00007800, 0000000000 },
-	{ 0x01665000, 0x00000002 },
-	{ 0x000a0000, 0x00000002 },
-	{ 0x000671cc, 0x00000002 },
-	{ 0x0286f1cd, 0x00000002 },
-	{ 0x000000a3, 0x00000010 },
-	{ 0x21007000, 0000000000 },
-	{ 0x000000aa, 0x0000001c },
-	{ 0x00065000, 0x00000002 },
-	{ 0x000a0000, 0x00000002 },
-	{ 0x00061000, 0x00000002 },
-	{ 0x000b0000, 0x00000002 },
-	{ 0x38067000, 0x00000002 },
-	{ 0x000a00a6, 0x00000004 },
-	{ 0x20007000, 0000000000 },
-	{ 0x01200000, 0x00000002 },
-	{ 0x20077000, 0x00000002 },
-	{ 0x01200000, 0x00000002 },
-	{ 0x20007000, 0000000000 },
-	{ 0x00061000, 0x00000002 },
-	{ 0x0120751b, 0x00000002 },
-	{ 0x8040750a, 0x00000002 },
-	{ 0x8040750b, 0x00000002 },
-	{ 0x00110000, 0x00000002 },
-	{ 0x000380dd, 0x00000002 },
-	{ 0x000000bd, 0x0000001c },
-	{ 0x00061096, 0x00000018 },
-	{ 0x844075bd, 0x00000002 },
-	{ 0x00061095, 0x00000018 },
-	{ 0x840075bb, 0x00000002 },
-	{ 0x00061096, 0x00000018 },
-	{ 0x844075bc, 0x00000002 },
-	{ 0x000000c0, 0x00000004 },
-	{ 0x804075bd, 0x00000002 },
-	{ 0x800075bb, 0x00000002 },
-	{ 0x804075bc, 0x00000002 },
-	{ 0x00108000, 0x00000002 },
-	{ 0x01400000, 0x00000002 },
-	{ 0x006000c4, 0x0000000c },
-	{ 0x20c07000, 0x00000020 },
-	{ 0x000000c6, 0x00000012 },
-	{ 0x00800000, 0x00000006 },
-	{ 0x0080751d, 0x00000006 },
-	{ 0x000025bb, 0x00000002 },
-	{ 0x000040c0, 0x00000004 },
-	{ 0x0000775c, 0x00000002 },
-	{ 0x00a05000, 0x00000002 },
-	{ 0x00661000, 0x00000002 },
-	{ 0x0460275d, 0x00000020 },
-	{ 0x00004000, 0000000000 },
-	{ 0x00007999, 0x00000002 },
-	{ 0x00a05000, 0x00000002 },
-	{ 0x00661000, 0x00000002 },
-	{ 0x0460299b, 0x00000020 },
-	{ 0x00004000, 0000000000 },
-	{ 0x01e00830, 0x00000002 },
-	{ 0x21007000, 0000000000 },
-	{ 0x00005000, 0x00000002 },
-	{ 0x00038042, 0x00000002 },
-	{ 0x040025e0, 0x00000002 },
-	{ 0x000075e1, 0000000000 },
-	{ 0x00000001, 0000000000 },
-	{ 0x000380d9, 0x00000002 },
-	{ 0x04007394, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-};
-
-/* Microcode from http://volodya-project.sourceforge.net/ */
-
-CARD32 r300_cp_microcode[][2] = {
-	{ 0x4200e000, 0000000000 },
-	{ 0x4000e000, 0000000000 },
-	{ 0x000000af, 0x00000008 },
-	{ 0x000000b3, 0x00000008 },
-	{ 0x6c5a504f, 0000000000 },
-	{ 0x4f4f497a, 0000000000 },
-	{ 0x5a578288, 0000000000 },
-	{ 0x4f91906a, 0000000000 },
-	{ 0x4f4f4f4f, 0000000000 },
-	{ 0x4fe24f44, 0000000000 },
-	{ 0x4f9c9c9c, 0000000000 },
-	{ 0xdc4f4fde, 0000000000 },
-	{ 0xa1cd4f4f, 0000000000 },
-	{ 0xd29d9d9d, 0000000000 },
-	{ 0x4f0f9fd7, 0000000000 },
-	{ 0x000ca000, 0x00000004 },
-	{ 0x000d0012, 0x00000038 },
-	{ 0x0000e8b4, 0x00000004 },
-	{ 0x000d0014, 0x00000038 },
-	{ 0x0000e8b6, 0x00000004 },
-	{ 0x000d0016, 0x00000038 },
-	{ 0x0000e854, 0x00000004 },
-	{ 0x000d0018, 0x00000038 },
-	{ 0x0000e855, 0x00000004 },
-	{ 0x000d001a, 0x00000038 },
-	{ 0x0000e856, 0x00000004 },
-	{ 0x000d001c, 0x00000038 },
-	{ 0x0000e857, 0x00000004 },
-	{ 0x000d001e, 0x00000038 },
-	{ 0x0000e824, 0x00000004 },
-	{ 0x000d0020, 0x00000038 },
-	{ 0x0000e825, 0x00000004 },
-	{ 0x000d0022, 0x00000038 },
-	{ 0x0000e830, 0x00000004 },
-	{ 0x000d0024, 0x00000038 },
-	{ 0x0000f0c0, 0x00000004 },
-	{ 0x000d0026, 0x00000038 },
-	{ 0x0000f0c1, 0x00000004 },
-	{ 0x000d0028, 0x00000038 },
-	{ 0x0000f041, 0x00000004 },
-	{ 0x000d002a, 0x00000038 },
-	{ 0x0000f184, 0x00000004 },
-	{ 0x000d002c, 0x00000038 },
-	{ 0x0000f185, 0x00000004 },
-	{ 0x000d002e, 0x00000038 },
-	{ 0x0000f186, 0x00000004 },
-	{ 0x000d0030, 0x00000038 },
-	{ 0x0000f187, 0x00000004 },
-	{ 0x000d0032, 0x00000038 },
-	{ 0x0000f180, 0x00000004 },
-	{ 0x000d0034, 0x00000038 },
-	{ 0x0000f393, 0x00000004 },
-	{ 0x000d0036, 0x00000038 },
-	{ 0x0000f38a, 0x00000004 },
-	{ 0x000d0038, 0x00000038 },
-	{ 0x0000f38e, 0x00000004 },
-	{ 0x0000e821, 0x00000004 },
-	{ 0x0140a000, 0x00000004 },
-	{ 0x00000043, 0x00000018 },
-	{ 0x00cce800, 0x00000004 },
-	{ 0x001b0001, 0x00000004 },
-	{ 0x08004800, 0x00000004 },
-	{ 0x001b0001, 0x00000004 },
-	{ 0x08004800, 0x00000004 },
-	{ 0x001b0001, 0x00000004 },
-	{ 0x08004800, 0x00000004 },
-	{ 0x0000003a, 0x00000008 },
-	{ 0x0000a000, 0000000000 },
-	{ 0x02c0a000, 0x00000004 },
-	{ 0x000ca000, 0x00000004 },
-	{ 0x00130000, 0x00000004 },
-	{ 0x000c2000, 0x00000004 },
-	{ 0xc980c045, 0x00000008 },
-	{ 0x2000451d, 0x00000004 },
-	{ 0x0000e580, 0x00000004 },
-	{ 0x000ce581, 0x00000004 },
-	{ 0x08004580, 0x00000004 },
-	{ 0x000ce581, 0x00000004 },
-	{ 0x0000004c, 0x00000008 },
-	{ 0x0000a000, 0000000000 },
-	{ 0x000c2000, 0x00000004 },
-	{ 0x0000e50e, 0x00000004 },
-	{ 0x00032000, 0x00000004 },
-	{ 0x00022056, 0x00000028 },
-	{ 0x00000056, 0x00000024 },
-	{ 0x0800450f, 0x00000004 },
-	{ 0x0000a050, 0x00000008 },
-	{ 0x0000e565, 0x00000004 },
-	{ 0x0000e566, 0x00000004 },
-	{ 0x00000057, 0x00000008 },
-	{ 0x03cca5b4, 0x00000004 },
-	{ 0x05432000, 0x00000004 },
-	{ 0x00022000, 0x00000004 },
-	{ 0x4ccce063, 0x00000030 },
-	{ 0x08274565, 0x00000004 },
-	{ 0x00000063, 0x00000030 },
-	{ 0x08004564, 0x00000004 },
-	{ 0x0000e566, 0x00000004 },
-	{ 0x0000005a, 0x00000008 },
-	{ 0x00802066, 0x00000010 },
-	{ 0x00202000, 0x00000004 },
-	{ 0x001b00ff, 0x00000004 },
-	{ 0x01000069, 0x00000010 },
-	{ 0x001f2000, 0x00000004 },
-	{ 0x001c00ff, 0x00000004 },
-	{ 0000000000, 0x0000000c },
-	{ 0x00000085, 0x00000030 },
-	{ 0x0000005a, 0x00000008 },
-	{ 0x0000e576, 0x00000004 },
-	{ 0x000ca000, 0x00000004 },
-	{ 0x00012000, 0x00000004 },
-	{ 0x00082000, 0x00000004 },
-	{ 0x1800650e, 0x00000004 },
-	{ 0x00092000, 0x00000004 },
-	{ 0x000a2000, 0x00000004 },
-	{ 0x000f0000, 0x00000004 },
-	{ 0x00400000, 0x00000004 },
-	{ 0x00000079, 0x00000018 },
-	{ 0x0000e563, 0x00000004 },
-	{ 0x00c0e5f9, 0x000000c2 },
-	{ 0x0000006e, 0x00000008 },
-	{ 0x0000a06e, 0x00000008 },
-	{ 0x0000e576, 0x00000004 },
-	{ 0x0000e577, 0x00000004 },
-	{ 0x0000e50e, 0x00000004 },
-	{ 0x0000e50f, 0x00000004 },
-	{ 0x0140a000, 0x00000004 },
-	{ 0x0000007c, 0x00000018 },
-	{ 0x00c0e5f9, 0x000000c2 },
-	{ 0x0000007c, 0x00000008 },
-	{ 0x0014e50e, 0x00000004 },
-	{ 0x0040e50f, 0x00000004 },
-	{ 0x00c0007f, 0x00000008 },
-	{ 0x0000e570, 0x00000004 },
-	{ 0x0000e571, 0x00000004 },
-	{ 0x0000e572, 0x0000000c },
-	{ 0x0000a000, 0x00000004 },
-	{ 0x0140a000, 0x00000004 }, 
-	{ 0x0000e568, 0x00000004 },
-	{ 0x000c2000, 0x00000004 },
-	{ 0x00000089, 0x00000018 },
-	{ 0x000b0000, 0x00000004 },
-	{ 0x18c0e562, 0x00000004 },
-	{ 0x0000008b, 0x00000008 },
-	{ 0x00c0008a, 0x00000008 },
-	{ 0x000700e4, 0x00000004 },
-	{ 0x00000097, 0x00000038 },
-	{ 0x000ca099, 0x00000030 },
-	{ 0x080045bb, 0x00000004 },
-	{ 0x000c209a, 0x00000030 },
-	{ 0x0800e5bc, 0000000000 },
-	{ 0x0000e5bb, 0x00000004 },
-	{ 0x0000e5bc, 0000000000 },
-	{ 0x00120000, 0x0000000c },
-	{ 0x00120000, 0x00000004 },
-	{ 0x001b0002, 0x0000000c },
-	{ 0x0000a000, 0x00000004 },
-	{ 0x0000e821, 0x00000004 },
-	{ 0x0000e800, 0000000000 },
-	{ 0x0000e821, 0x00000004 },
-	{ 0x0000e82e, 0000000000 },
-	{ 0x02cca000, 0x00000004 },
-	{ 0x00140000, 0x00000004 },
-	{ 0x000ce1cc, 0x00000004 },
-	{ 0x050de1cd, 0x00000004 },
-	{ 0x000000a7, 0x00000020 },
-	{ 0x4200e000, 0000000000 },
-	{ 0x000000ae, 0x00000038 },
-	{ 0x000ca000, 0x00000004 },
-	{ 0x00140000, 0x00000004 },
-	{ 0x000c2000, 0x00000004 },
-	{ 0x00160000, 0x00000004 },
-	{ 0x700ce000, 0x00000004 },
-	{ 0x001400aa, 0x00000008 },
-	{ 0x4000e000, 0000000000 },
-	{ 0x02400000, 0x00000004 },
-	{ 0x400ee000, 0x00000004 },
-	{ 0x02400000, 0x00000004 },
-	{ 0x4000e000, 0000000000 },
-	{ 0x000c2000, 0x00000004 },
-	{ 0x0240e51b, 0x00000004 },
-	{ 0x0080e50a, 0x00000005 },
-	{ 0x0080e50b, 0x00000005 },
-	{ 0x00220000, 0x00000004 },
-	{ 0x000700e4, 0x00000004 },
-	{ 0x000000c1, 0x00000038 },
-	{ 0x000c209a, 0x00000030 },
-	{ 0x0880e5bd, 0x00000005 },
-	{ 0x000c2099, 0x00000030 },
-	{ 0x0800e5bb, 0x00000005 },
-	{ 0x000c209a, 0x00000030 },
-	{ 0x0880e5bc, 0x00000005 },
-	{ 0x000000c4, 0x00000008 },
-	{ 0x0080e5bd, 0x00000005 },
-	{ 0x0000e5bb, 0x00000005 },
-	{ 0x0080e5bc, 0x00000005 },
-	{ 0x00210000, 0x00000004 },
-	{ 0x02800000, 0x00000004 },
-	{ 0x00c000c8, 0x00000018 },
-	{ 0x4180e000, 0x00000040 },
-	{ 0x000000ca, 0x00000024 },
-	{ 0x01000000, 0x0000000c },
-	{ 0x0100e51d, 0x0000000c },
-	{ 0x000045bb, 0x00000004 },
-	{ 0x000080c4, 0x00000008 },
-	{ 0x0000f3ce, 0x00000004 },
-	{ 0x0140a000, 0x00000004 },
-	{ 0x00cc2000, 0x00000004 },
-	{ 0x08c053cf, 0x00000040 },
-	{ 0x00008000, 0000000000 },
-	{ 0x0000f3d2, 0x00000004 },
-	{ 0x0140a000, 0x00000004 },
-	{ 0x00cc2000, 0x00000004 },
-	{ 0x08c053d3, 0x00000040 },
-	{ 0x00008000, 0000000000 },
-	{ 0x0000f39d, 0x00000004 },
-	{ 0x0140a000, 0x00000004 },
-	{ 0x00cc2000, 0x00000004 },
-	{ 0x08c0539e, 0x00000040 },
-	{ 0x00008000, 0000000000 },
-	{ 0x03c00830, 0x00000004 },
-	{ 0x4200e000, 0000000000 },
-	{ 0x0000a000, 0x00000004 },
-	{ 0x200045e0, 0x00000004 },
-	{ 0x0000e5e1, 0000000000 },
-	{ 0x00000001, 0000000000 },
-	{ 0x000700e1, 0x00000004 },
-	{ 0x0800e394, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-	{ 0000000000, 0000000000 },
-};
diff --git a/hw/kdrive/ati/ati_reg.h b/hw/kdrive/ati/ati_reg.h
deleted file mode 100644
index 3089cba..0000000
--- a/hw/kdrive/ati/ati_reg.h
+++ /dev/null
@@ -1,1927 +0,0 @@
-/*
- * Copyright © 2003 Eric Anholt
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Eric Anholt not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  Eric Anholt makes no
- * representations about the suitability of this software for any purpose.  It
- * is provided "as is" without express or implied warranty.
- *
- * ERIC ANHOLT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL ERIC ANHOLT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-/* Many of the Radeon and Rage 128 registers are the same.
- * ATI_ should denote registers and values that are common for R128 and Radeon.
- *
- * The information in this file comes from many sources, including the Rage 128
- * DDK, Rage 128 register reference, the XFree86 and kernel Rage 128 and Radeon
- * register definition headers, and bits from the Radeon DDK and RV200 register
- * specs supplied by others.
- */
-
-#define ATI_REG_CLOCK_CNTL_INDEX		0x0008
-# define ATI_PLL_WR_EN				(1 << 7)
-# define ATI_PLL_DIV_SEL			(3 << 8)
-
-#define ATI_REG_CLOCK_CNTL_DATA			0x000c
-
-#define ATI_REG_BUS_CNTL			0x0030
-# define ATI_BUS_MASTER_DIS			(1 << 6)
-
-#define ATI_REG_GEN_INT_CNTL			0x0040
-
-#define ATI_REG_GEN_CNTL			0x0050
-# define ATI_CRTC_DBL_SCAN_EN			(1 <<  0)   /* 0x00000001 */
-# define ATI_CRTC_INTERLACE_EN			(1 <<  1)   /* 0x00000002 */
-# define ATI_CRTC_CSYNC_EN			(1 <<  4)   /* 0x00000010 */
-# define ATI_CRTC_PIX_WIDTH_MASK		(7 << 8)    /* 0x00000700 */
-# define ATI_CRTC_CUR_EN			(1 << 16)   /* 0x00010000 */
-# define ATI_CRTC_CUR_MODE_MASK			(7 << 17)   /* 0x000e0000 */
-# define ATI_CRTC_ICON_EN			(1 << 20)   /* 0x00100000 */
-# define ATI_CRTC_ARGB_EN			(2 << 20)   /* 0x00200000 */
-# define ATI_CRTC_EXT_DISP_EN			(1 << 24)   /* 0x01000000 */
-# define ATI_CRTC_EN				(1 << 25)   /* 0x02000000 */
-# define ATI_CRTC_DISP_REQ_EN_B			(1 << 26)   /* 0x04000000 */
-
-#define ATI_REG_CRTC_EXT_CNTL			0x0054
-# define ATI_CRTC_EN				(1 << 25)
-# define ATI_CRTC_VGA_XOVERSCAN			(1 <<  0)
-# define ATI_VGA_ATI_LINEAR			(1 <<  3)
-# define ATI_XCRT_CNT_EN			(1 <<  6)
-# define ATI_CRTC_HSYNC_DIS			(1 <<  8)
-# define ATI_CRTC_VSYNC_DIS			(1 <<  9)
-# define ATI_CRTC_DISPLAY_DIS			(1 << 10)
-# define RADEON_CRTC_SYNC_TRISTAT		(1 << 11)
-# define ATI_CRTC_CRT_ON			(1 << 15)
-# define R128_FP_OUT_EN				(1 << 22)
-# define R128_FP_ACTIVE				(1 << 23)
-
-#define ATI_REG_DAC_CNTL			0x0058
-# define ATI_DAC_RANGE_CNTL			(3 <<  0)
-# define ATI_DAC_BLANKING			(1 <<  2)
-# define R128_DAC_CRT_SEL_CRTC2			(1 <<  4)
-# define ATI_DAC_CMP_EN				(1 <<  3)
-# define R128_DAC_PALETTE_ACC_CTL		(1 <<  5)
-# define ATI_DAC_CMP_OUTPUT			(1 <<  7)
-# define ATI_DAC_8BIT_EN			(1 <<  8)
-# define ATI_DAC_VGA_ADR_EN			(1 << 13)
-# define ATI_DAC_PDWN				(1 << 15)
-# define ATI_DAC_MASK_ALL			(0xff << 24)
-
-#define ATI_REG_I2C_CNTL_1			0x0094
-
-#define R128_REG_GEN_RESET_CNTL			0x00f0
-# define R128_SOFT_RESET_GUI			(1 <<  0)
-# define R128_SOFT_RESET_VCLK			(1 <<  8)
-# define R128_SOFT_RESET_PCLK			(1 <<  9)
-# define R128_SOFT_RESET_DISPENG_XCLK		(1 << 11)
-# define R128_SOFT_RESET_MEMCTLR_XCLK		(1 << 12)
-
-#define RADEON_REG_RBBM_SOFT_RESET		0x00f0
-# define RADEON_SOFT_RESET_CP			(1 <<  0)
-# define RADEON_SOFT_RESET_HI			(1 <<  1)
-# define RADEON_SOFT_RESET_SE			(1 <<  2)
-# define RADEON_SOFT_RESET_RE			(1 <<  3)
-# define RADEON_SOFT_RESET_PP			(1 <<  4)
-# define RADEON_SOFT_RESET_E2			(1 <<  5)
-# define RADEON_SOFT_RESET_RB			(1 <<  6)
-# define RADEON_SOFT_RESET_HDP			(1 <<  7)
-
-#define RADEON_REG_HOST_PATH_CNTL		0x0130
-# define RADEON_HDP_SOFT_RESET			(1 << 26)
-
-#define ATI_REG_AGP_BASE			0x0170
-
-#define ATI_REG_AGP_CNTL			0x0174
-# define R128_AGP_APER_SIZE_256MB		(0x00 << 0)
-# define R128_AGP_APER_SIZE_128MB		(0x20 << 0)
-# define R128_AGP_APER_SIZE_64MB		(0x30 << 0)
-# define R128_AGP_APER_SIZE_32MB		(0x38 << 0)
-# define R128_AGP_APER_SIZE_16MB		(0x3c << 0)
-# define R128_AGP_APER_SIZE_8MB			(0x3e << 0)
-# define R128_AGP_APER_SIZE_4MB			(0x3f << 0)
-# define R128_AGP_APER_SIZE_MASK		(0x3f << 0)
-# define RADEON_PENDING_SLOTS_VAL		0x00060000
-# define RADEON_PENDING_SLOTS_SEL		0x00080000
-
-#define R128_REG_PCI_GART_PAGE			0x017c
-
-#define R128_REG_PC_NGUI_CTLSTAT		0x0184
-# define R128_PC_FLUSH_GUI			(3 << 0)
-# define R128_PC_RI_GUI				(1 << 2)
-# define R128_PC_FLUSH_ALL			0x00ff
-# define R128_PC_BUSY				(1 << 31)
-
-#define R128_REG_VIPH_CONTROL			0x01d0
-
-#define ATI_REG_CRTC_H_TOTAL_DISP		0x0200
-#define ATI_REG_CRTC2_H_TOTAL_DISP		0x0300
-# define ATI_CRTC_H_TOTAL			(0x01ff << 0)
-# define ATI_CRTC_H_TOTAL_SHIFT			0
-# define ATI_CRTC_H_DISP			(0x00ff << 16)
-# define ATI_CRTC_H_DISP_SHIFT			16
-
-#define ATI_REG_CRTC_H_SYNC_STRT_WID		0x0204
-#define ATI_REG_CRTC2_H_SYNC_STRT_WID		0x0304
-# define RADEON_CRTC_H_SYNC_STRT_PIX		(0x07  <<  0)
-# define RADEON_CRTC_H_SYNC_STRT_CHAR		(0x3ff <<  3)
-# define RADEON_CRTC_H_SYNC_STRT_CHAR_SHIFT	3
-# define RADEON_CRTC_H_SYNC_WID			(0x3f  << 16)
-# define RADEON_CRTC_H_SYNC_WID_SHIFT		16
-# define RADEON_CRTC_H_SYNC_POL			(1     << 23)
-
-#define ATI_REG_CRTC_OFFSET			0x0224
-#define ATI_REG_CRTC2_OFFSET			0x0324
-#define ATI_REG_CRTC_OFFSET_CNTL		0x0228
-#define ATI_REG_CRTC2_OFFSET_CNTL		0x0328
-#define ATI_REG_CRTC_PITCH			0x022c
-#define ATI_REG_CRTC2_PITCH			0x032c
-
-#define ATI_REG_OVR_CLR				0x0230
-#define ATI_REG_OVR_WID_LEFT_RIGHT		0x0234
-#define ATI_REG_OVR_WID_TOP_BOTTOM		0x0238
-
-#define ATI_REG_CUR_OFFSET			0x0260
-#define ATI_REG_CUR_HORZ_VERT_POSN		0x0264
-#define ATI_REG_CUR_HORZ_VERT_OFF		0x0268
-# define ATI_CUR_LOCK				(1 << 31)
-# define ATI_CURSOR_WIDTH			64
-# define ATI_CURSOR_HEIGHT			64
-# define ATI_CURSOR_PITCH			16
-
-#define ATI_REG_CUR_CLR0			0x026c
-#define ATI_REG_CUR_CLR1			0x0270
-#define ATI_REG_OV0_SCALE_CNTL			0x0420
-#define ATI_REG_SUBPIC_CNTL			0x0540
-#define ATI_REG_CAP0_TRIG_CNTL			0x0950
-#define RADEON_REG_VIPH_CONTROL			0x0c50
-
-#define RADEON_REG_RBBM_STATUS			0x0e40
-# define RADEON_RBBM_FIFOCNT_MASK		0x007f
-# define RADEON_RBBM_ACTIVE			(1 << 31)
-
-#define ATI_REG_CCE_RB_BASE			0x0700
-
-#define R128_REG_PM4_BUFFER_CNTL		0x0704
-# define R128_PM4_IN_FRAME_BUFFER		(1  << 26)
-# define R128_PM4_BUFFER_CNTL_NOUPDATE		(1  << 27)
-# define R128_PM4_NONPM4			(0  << 28)
-# define R128_PM4_192PIO			(1  << 28)
-# define R128_PM4_192BM				(2  << 28)
-# define R128_PM4_128PIO_64INDBM		(3  << 28)
-# define R128_PM4_128BM_64INDBM			(4  << 28)
-# define R128_PM4_64PIO_128INDBM		(5  << 28)
-# define R128_PM4_64BM_128INDBM			(6  << 28)
-# define R128_PM4_64PIO_64VCBM_64INDBM		(7  << 28)
-# define R128_PM4_64BM_64VCBM_64INDBM		(8  << 28)
-# define R128_PM4_64PIO_64VCPIO_64INDPIO	(15 << 28)
-
-#define RADEON_REG_CP_RB_CNTL			0x0704
-
-#define R128_REG_PM4_BUFFER_WM_CNTL		0x0708
-# define R128_WMA_SHIFT				0
-# define R128_WMB_SHIFT				8
-# define R128_WMC_SHIFT				16
-# define R128_WB_WM_SHIFT			24
-
-#define ATI_REG_CCE_RPTR_ADDR			0x070c
-#define ATI_REG_CCE_RPTR			0x0710
-#define ATI_REG_CCE_WPTR			0x0714
-# define R128_PM4_BUFFER_DL_DONE		(1 << 31)
-
-#define R128_REG_PM4_VC_FPU_SETUP		0x071c
-# define R128_FRONT_DIR_CW			(0 <<  0)
-# define R128_FRONT_DIR_CCW			(1 <<  0)
-# define R128_FRONT_DIR_MASK			(1 <<  0)
-# define R128_BACKFACE_CULL			(0 <<  1)
-# define R128_BACKFACE_POINTS			(1 <<  1)
-# define R128_BACKFACE_LINES			(2 <<  1)
-# define R128_BACKFACE_SOLID			(3 <<  1)
-# define R128_BACKFACE_MASK			(3 <<  1)
-# define R128_FRONTFACE_CULL			(0 <<  3)
-# define R128_FRONTFACE_POINTS			(1 <<  3)
-# define R128_FRONTFACE_LINES			(2 <<  3)
-# define R128_FRONTFACE_SOLID			(3 <<  3)
-# define R128_FRONTFACE_MASK			(3 <<  3)
-# define R128_FPU_COLOR_SOLID			(0 <<  5)
-# define R128_FPU_COLOR_FLAT			(1 <<  5)
-# define R128_FPU_COLOR_GOURAUD			(2 <<  5)
-# define R128_FPU_COLOR_GOURAUD2		(3 <<  5)
-# define R128_FPU_COLOR_MASK			(3 <<  5)
-# define R128_FPU_SUB_PIX_2BITS			(0 <<  7)
-# define R128_FPU_SUB_PIX_4BITS			(1 <<  7)
-# define R128_FPU_MODE_2D			(0 <<  8)
-# define R128_FPU_MODE_3D			(1 <<  8)
-# define R128_TRAP_BITS_DISABLE			(1 <<  9)
-# define R128_EDGE_ANTIALIAS			(1 << 10)
-# define R128_SUPERSAMPLE			(1 << 11)
-# define R128_XFACTOR_2				(0 << 12)
-# define R128_XFACTOR_4				(1 << 12)
-# define R128_YFACTOR_2				(0 << 13)
-# define R128_YFACTOR_4				(1 << 13)
-# define R128_FLAT_SHADE_VERTEX_D3D		(0 << 14)
-# define R128_FLAT_SHADE_VERTEX_OGL		(1 << 14)
-# define R128_FPU_ROUND_TRUNCATE		(0 << 15)
-# define R128_FPU_ROUND_NEAREST			(1 << 15)
-# define R128_WM_SEL_8DW			(0 << 16)
-# define R128_WM_SEL_16DW			(1 << 16)
-# define R128_WM_SEL_32DW			(2 << 16)
-
-#define R128_REG_PM4_IW_INDOFF			0x0738
-#define R128_REG_PM4_IW_INDSIZE			0x073c
-
-#define RADEON_REG_CP_CSQ_CNTL			0x0740
-# define RADEON_CSQ_CNT_PRIMARY_MASK		0x000000ff
-# define RADEON_CSQ_CNT_INDIRECT_MASK		0x0000ff00
-# define R200_CSQ_CNT_PRIMARY_MASK		0x000001ff
-# define R200_CSQ_CNT_INDIRECT_MASK		0x0003fe00
-# define RADEON_CSQ_PRIDIS_INDDIS		(0 << 28)
-# define RADEON_CSQ_PRIPIO_INDDIS		(1 << 28)
-# define RADEON_CSQ_PRIBM_INDDIS		(2 << 28)
-# define RADEON_CSQ_PRIPIO_INDBM		(3 << 28)
-# define RADEON_CSQ_PRIBM_INDBM			(4 << 28)
-# define RADEON_CSQ_PRIPIO_INDPIO		(15 << 28)
-
-#define R128_REG_PM4_STAT			0x07b8
-# define R128_PM4_FIFOCNT_MASK			0x00000fff
-# define R128_PM4_BUSY				(1 << 16)
-# define R128_PM4_GUI_ACTIVE			(1 << 31)
-
-#define RADEON_REG_CP_STAT			0x07c0
-# define RADEON_CSQ_PRIMARY_BUSY		(1 << 10)
-# define RADEON_CSQ_INDIRECT_BUSY		(1 << 11)
-
-#define RADEON_REG_ME_CNTL			0x07d0
-# define RADEON_ME_MODE_FREE_RUN		(1 << 30)
-
-#define ATI_REG_MICROCODE_RAM_ADDR		0x07d4
-#define ATI_REG_MICROCODE_RAM_RADDR		0x07d8
-#define ATI_REG_MICROCODE_RAM_DATAH		0x07dc
-#define ATI_REG_MICROCODE_RAM_DATAL		0x07e0
-#define R128_REG_PM4_BUFFER_ADDR		0x07f0
-
-#define RADEON_REG_CP_CSQ_STAT			0x07f8
-# define RADEON_CSQ_RPTR_PRIMARY_MASK		(0xff <<  0)
-# define RADEON_CSQ_WPTR_PRIMARY_MASK		(0xff <<  8)
-# define RADEON_CSQ_RPTR_INDIRECT_MASK		(0xff << 16)
-# define RADEON_CSQ_WPTR_INDIRECT_MASK		(0xff << 24)
-# define R200_CSQ_RPTR_PRIMARY_MASK		(0x1ff <<  0)
-# define R200_CSQ_WPTR_PRIMARY_MASK		(0x1ff <<  9)
-
-#define R128_REG_PM4_MICRO_CNTL			0x07fc
-# define R128_PM4_MICRO_FREERUN			(1 << 30)
-
-#define RADEON_TV_MASTER_CNTL                    0x0800
-# define RADEON_TV_MACROVISION			(1 << 5)
-# define RADEON_TVCLK_ALWAYS_ON           	(1 << 30)
-
-#define R128_REG_BM_CHUNK_0_VAL			0x0a18
-# define R128_BM_PTR_FORCE_TO_PCI		(1 << 21)
-# define R128_BM_PM4_RD_FORCE_TO_PCI		(1 << 22)
-# define R128_BM_GLOBAL_FORCE_TO_PCI		(1 << 23)
-
-/* Offset of the PCI config space mirror */
-#define ATI_PCI_CFG_OFFSET			0x0f00
-
-#define ATI_REG_PCI_CFG_STATUS			0x0f06
-# define ATI_CAP_LIST				0x0010
-
-#define ATI_REG_PCI_CFG_CAPABILITIES_PTR	0x0f34
-# define ATI_CAP_PTR_MASK			0x00fc
-# define ATI_CAP_ID_NULL			0x0000 /* End of capability list */
-# define ATI_CAP_ID_AGP				0x0002 /* AGP capability ID */
-
-#define R128_REG_AGP_STATUS			0x0f54 /* PCI */
-# define R128_AGP_1X_MODE			0x01
-# define R128_AGP_2X_MODE			0x02
-# define R128_AGP_4X_MODE			0x04
-# define R128_AGP_MODE_MASK			0x07
-
-#define R128_REG_AGP_COMMAND			0x0f58
-# define R128_AGP_ENABLE			(1 << 8)
-
-#define RADEON_REG_AGP_STATUS			0x0f5c /* PCI */
-# define RADEON_AGP_1X_MODE			0x01
-# define RADEON_AGP_2X_MODE			0x02
-# define RADEON_AGP_4X_MODE			0x04
-# define RADEON_AGP_FW_MODE			0x10
-# define RADEON_AGP_MODE_MASK			0x17
-
-#define RADEON_REG_AGP_COMMAND			0x0f60
-# define RADEON_AGP_ENABLE			(1 << 8)
-
-#define R128_REG_PM4_FIFO_DATA_EVEN		0x1000
-#define R128_REG_PM4_FIFO_DATA_ODD		0x1004
-
-#define RADEON_REG_CSQ_APER_PRIMARY		0x1000
-#define RADEON_REG_CSQ_APER_PRIMARY_END		0x11fc
-#define RADEON_REG_CSQ_APER_INDIRECT		0x1300
-#define RADEON_REG_CSQ_APER_INDIRECT_END	0x13fc
-#define ATI_REG_SRC_PITCH_OFFSET		0x1428
-#define ATI_REG_DST_PITCH_OFFSET		0x142c
-#define ATI_REG_SRC_Y_X				0x1434
-#define ATI_REG_DST_Y_X				0x1438
-#define ATI_REG_DST_HEIGHT_WIDTH		0x143c
-
-#define ATI_REG_DP_GUI_MASTER_CNTL		0x146c
-# define ATI_GMC_SRC_PITCH_OFFSET_CNTL		(1  <<  0)
-# define ATI_GMC_DST_PITCH_OFFSET_CNTL		(1  <<  1)
-# define ATI_GMC_SRC_CLIPPING			(1  <<  2)
-# define ATI_GMC_DST_CLIPPING			(1  <<  3)
-# define ATI_GMC_BRUSH_SOLID_COLOR		(13 <<  4)
-# define ATI_GMC_BRUSH_NONE			(15 <<  4)
-# define ATI_GMC_BRUSH_MASK			(15 <<  4)
-# define ATI_GMC_DST_DATATYPE_MASK		(0xf <<  8)
-# define ATI_GMC_SRC_DATATYPE_COLOR		(3  << 12)
-# define R128_GMC_CONVERSION_TEMP		(1  << 15)
-# define R128_GMC_CONVERSION_TEMP_6500		(0  << 15)
-# define R128_GMC_CONVERSION_TEMP_9300		(1  << 15)
-# define ATI_GMC_ROP3_MASK			(0xff << 16)
-# define ATI_DP_SRC_SOURCE_MEMORY		(2  << 24)
-# define ATI_DP_SRC_SOURCE_HOST_DATA		(3  << 24)
-# define R128_GMC_3D_FCN_EN			(1  << 27)
-# define ATI_GMC_CLR_CMP_CNTL_DIS		(1  << 28)
-# define R128_GMC_AUX_CLIP_DIS			(1  << 29)
-# define ATI_GMC_WR_MSK_DIS			(1  << 30)
-# define R128_GMC_LD_BRUSH_Y_X			(1  << 31)
-
-#define ATI_REG_DP_BRUSH_FRGD_CLR		0x147c
-#define ATI_REG_DST_WIDTH_HEIGHT		0x1598
-#define ATI_REG_CLR_CMP_CNTL			0x15c0
-
-#define R128_REG_AUX_SC_CNTL			0x1660
-# define R128_AUX1_SC_ENB			(1 << 0)
-# define R128_AUX1_SC_MODE_SUB			(1 << 1)
-# define R128_AUX2_SC_ENB			(1 << 0)
-# define R128_AUX2_SC_MODE_SUB			(1 << 1)
-# define R128_AUX3_SC_ENB			(1 << 0)
-# define R128_AUX3_SC_MODE_SUB			(1 << 1)
-
-#define R128_REG_AUX1_SC_LEFT			0x1664
-#define R128_REG_AUX1_SC_RIGHT			0x1668
-#define R128_REG_AUX1_SC_TOP			0x166c
-#define R128_REG_AUX1_SC_BOTTOM			0x1670
-#define R128_REG_AUX2_SC_LEFT			0x1674
-#define R128_REG_AUX2_SC_RIGHT			0x1678
-#define R128_REG_AUX2_SC_TOP			0x167c
-#define R128_REG_AUX2_SC_BOTTOM			0x1680
-#define R128_REG_AUX3_SC_LEFT			0x1684
-#define R128_REG_AUX3_SC_RIGHT			0x1688
-#define R128_REG_AUX3_SC_TOP			0x168c
-#define R128_REG_AUX3_SC_BOTTOM			0x1690
-
-#define ATI_REG_DP_CNTL				0x16c0
-# define ATI_DST_X_LEFT_TO_RIGHT		(1 <<  0)
-# define ATI_DST_Y_TOP_TO_BOTTOM		(1 <<  1)
-
-#define ATI_REG_DP_MIX				0x16c8
-#define ATI_REG_DP_WRITE_MASK			0x16cc
-#define ATI_REG_DEFAULT_OFFSET			0x16e0
-#define ATI_REG_DEFAULT_PITCH			0x16e4
-
-#define ATI_REG_DEFAULT_SC_BOTTOM_RIGHT		0x16e8
-# define ATI_DEFAULT_SC_RIGHT_MAX		0x00001fff
-# define ATI_DEFAULT_SC_BOTTOM_MAX		0x1fff0000
-
-#define ATI_REG_SC_TOP_LEFT			0x16ec
-#define ATI_REG_SC_BOTTOM_RIGHT			0x16f0
-
-#define ATI_REG_WAIT_UNTIL			0x1720
-# define ATI_WAIT_CRTC_PFLIP			(1 << 0)
-# define ATI_WAIT_RE_CRTC_VLINE			(1 << 1)
-# define ATI_WAIT_FE_CRTC_VLINE			(1 << 2)
-# define ATI_WAIT_CRTC_VLINE			(1 << 3)
-# define ATI_WAIT_DMA_VIPH0_IDLE		(1 << 4)
-# define ATI_WAIT_DMA_VIPH1_IDLE		(1 << 5)
-# define ATI_WAIT_DMA_VIPH2_IDLE		(1 << 6)
-# define ATI_WAIT_DMA_VIPH3_IDLE		(1 << 7)
-# define ATI_WAIT_DMA_VID_IDLE			(1 << 8)
-# define ATI_WAIT_DMA_GUI_IDLE			(1 << 9)
-# define ATI_WAIT_CMDFIFO			(1 << 10)
-# define ATI_WAIT_OV0_FLIP			(1 << 11)
-# define RADEON_WAIT_OV0_SLICEDONE		(1 << 12)
-# define RADEON_WAIT_2D_IDLE			(1 << 14)
-# define RADEON_WAIT_3D_IDLE			(1 << 15)
-# define RADEON_WAIT_2D_IDLECLEAN		(1 << 16)
-# define RADEON_WAIT_3D_IDLECLEAN		(1 << 17)
-# define RADEON_WAIT_HOST_IDLECLEAN		(1 << 18)
-# define ATI_WAIT_CMDFIFO_ENTRIES		(0x07f00000)
-# define RADEON_WAIT_BOTH_CRTC_PFLIP		(1 << 30)
-# define RADEON_ENG_DISPLAY_SELECT		(1 << 31)
-
-#define RADEON_REG_ISYNC_CNTL			0x1724
-#define ISYNC_ANY2D_IDLE3D			0x1
-#define ISYNC_ANY3D_IDLE2D			0x2
-
-#define R128_REG_GUI_STAT			0x1740
-# define R128_GUI_ACTIVE			(1 << 31)
-
-#define R128_REG_PC_GUI_MODE			0x1744
-#define R128_PC_GUI_PRIORITY			(1 << 0)
-#define R128_PC_RISE_DF_EN			(1 << 1)
-#define R128_PC_FALL_DF_EN			(1 << 2)
-#define R128_PC_BYPASS_EN			(1 << 3)
-#define R128_PC_CACHE_SIZE			(1 << 4)
-#define R128_PC_IGNORE_UNIFY			(1 << 5)
-#define R128_PC_IGNORE_WRHINT			(1 << 6)
-#define R128_PC_IGNORE_RDHINT			(1 << 7)
-#define R128_PC_RISE_DP_EN			(1 << 8)
-
-#define R128_REG_PC_GUI_CTLSTAT			0x1748
-/* bits match R128_REG_PC_NGUI_CTLSTAT */
-
-#define R128_REG_TEX_CNTL			0x1800
-#define R128_REG_SECONDARY_SCALE_OFFSET		0x1980
-#define R128_REG_SECONDARY_SCALE_PITCH		0x1980
-#define R128_REG_SECONDARY_SCALE_X_INC		0x1984
-#define R128_REG_SECONDARY_SCALE_Y_INC		0x1988
-#define R128_REG_SECONDARY_SCALE_HACC		0x198c
-#define R128_REG_SECONDARY_SCALE_VACC		0x1990
-#define R128_REG_SCALE_SRC_HEIGHT_WIDTH		0x1994
-#define R128_REG_SCALE_OFFSET_0			0x1998
-#define R128_REG_SCALE_PITCH			0x199c
-#define R128_REG_SCALE_X_INC			0x19a0
-#define R128_REG_SCALE_Y_INC			0x19a4
-#define R128_REG_SCALE_HACC			0x19a8
-#define R128_REG_SCALE_VACC			0x19ac
-#define R128_REG_SCALE_DST_X_Y			0x19b0
-#define R128_REG_SCALE_DST_HEIGHT_WIDTH		0x19b4
-
-#define R128_REG_SCALE_3D_CNTL			0x1a00
-# define R128_SCALE_DITHER_ERR_DIFF		(0  <<  1)
-# define R128_SCALE_DITHER_TABLE		(1  <<  1)
-# define R128_TEX_CACHE_SIZE_FULL		(0  <<  2)
-# define R128_TEX_CACHE_SIZE_HALF		(1  <<  2)
-# define R128_DITHER_INIT_CURR			(0  <<  3)
-# define R128_DITHER_INIT_RESET			(1  <<  3)
-# define R128_ROUND_24BIT			(1  <<  4)
-# define R128_TEX_CACHE_DISABLE			(1  <<  5)
-# define R128_SCALE_3D_NOOP			(0  <<  6)
-# define R128_SCALE_3D_SCALE			(1  <<  6)
-# define R128_SCALE_3D_TEXMAP_SHADE		(2  <<  6)
-# define R128_SCALE_PIX_BLEND			(0  <<  8)
-# define R128_SCALE_PIX_REPLICATE		(1  <<  8)
-# define R128_TEX_CACHE_SPLIT			(1  <<  9)
-# define R128_APPLE_YUV_MODE			(1  << 10)
-# define R128_TEX_CACHE_PALLETE_MODE		(1  << 11)
-# define R128_ALPHA_COMB_ADD_CLAMP		(0  << 12)
-# define R128_ALPHA_COMB_ADD_NCLAMP		(1  << 12)
-# define R128_ALPHA_COMB_SUB_DST_SRC_CLAMP	(2  << 12)
-# define R128_ALPHA_COMB_SUB_DST_SRC_NCLAMP	(3  << 12)
-# define R128_FOG_TABLE				(1  << 14)
-# define R128_SIGNED_DST_CLAMP			(1  << 15)
-/* Alpha bits from R128_REG_MISC_3D_CNTL */
-# define R128_COMPOSITE_SHADOW_CMP_EQUAL	(0  << 28)
-# define R128_COMPOSITE_SHADOW_CMP_NEQUAL	(1  << 28)
-# define R128_COMPOSITE_SHADOW			(1  << 29)
-# define R128_TEX_MAP_ALPHA_IN_TEXTURE		(1  << 30)
-# define R128_TEX_CACHE_LINE_SIZE_8QW		(0  << 31)
-# define R128_TEX_CACHE_LINE_SIZE_4QW		(1  << 31)
-
-#define R128_REG_SCALE_3D_DATATYPE		0x1a20
-
-#define R128_REG_SETUP_CNTL			0x1bc4
-# define R128_DONT_START_TRIANGLE		(1 <<  0)
-# define R128_Z_BIAS				(0 <<  1)
-# define R128_DONT_START_ANY_ON			(1 <<  2)
-# define R128_COLOR_SOLID_COLOR			(0 <<  3)
-# define R128_COLOR_FLAT_VERT_1			(1 <<  3)
-# define R128_COLOR_FLAT_VERT_2			(2 <<  3)
-# define R128_COLOR_FLAT_VERT_3			(3 <<  3)
-# define R128_COLOR_GOURAUD			(4 <<  3)
-# define R128_PRIM_TYPE_TRI			(0 <<  7)
-# define R128_PRIM_TYPE_LINE			(1 <<  7)
-# define R128_PRIM_TYPE_POINT			(2 <<  7)
-# define R128_PRIM_TYPE_POLY_EDGE		(3 <<  7)
-# define R128_TEXTURE_ST_MULT_W			(0 <<  9)
-# define R128_TEXTURE_ST_DIRECT			(1 <<  9)
-# define R128_STARTING_VERTEX_1			(1 << 14)
-# define R128_STARTING_VERTEX_2			(2 << 14)
-# define R128_STARTING_VERTEX_3			(3 << 14)
-# define R128_ENDING_VERTEX_1			(1 << 16)
-# define R128_ENDING_VERTEX_2			(2 << 16)
-# define R128_ENDING_VERTEX_3			(3 << 16)
-# define R128_SU_POLY_LINE_LAST			(0 << 18)
-# define R128_SU_POLY_LINE_NOT_LAST		(1 << 18)
-# define R128_SUB_PIX_2BITS			(0 << 19)
-# define R128_SUB_PIX_4BITS			(1 << 19)
-# define R128_SET_UP_CONTINUE			(1 << 31)
-
-#define R128_REG_WINDOW_XY_OFFSET		0x1bcc
-
-#define RADEON_REG_RB3D_BLENDCNTL		0x1c20
-# define RADEON_COMB_FCN_MASK			(3  << 12)
-# define RADEON_COMB_FCN_ADD_CLAMP		(0  << 12)
-# define RADEON_COMB_FCN_ADD_NOCLAMP		(1  << 12)
-# define RADEON_COMB_FCN_SUB_CLAMP		(2  << 12)
-# define RADEON_COMB_FCN_SUB_NOCLAMP		(3  << 12)
-# define R200_COMB_FCN_MIN			(4  << 12)
-# define R200_COMB_FCN_MAX			(5  << 12)
-# define R200_COMB_FCN_RSUB_CLAMP		(6  << 12)
-# define R200_COMB_FCN_RSUB_NOCLAMP		(7  << 12)
-# define RADEON_SBLEND_GL_ZERO			(32 << 16)
-# define RADEON_SBLEND_GL_ONE			(33 << 16)
-# define RADEON_SBLEND_GL_SRC_COLOR		(34 << 16)
-# define RADEON_SBLEND_GL_INV_SRC_COLOR		(35 << 16)
-# define RADEON_SBLEND_GL_DST_COLOR		(36 << 16)
-# define RADEON_SBLEND_GL_INV_DST_COLOR		(37 << 16)
-# define RADEON_SBLEND_GL_SRC_ALPHA		(38 << 16)
-# define RADEON_SBLEND_GL_INV_SRC_ALPHA		(39 << 16)
-# define RADEON_SBLEND_GL_DST_ALPHA		(40 << 16)
-# define RADEON_SBLEND_GL_INV_DST_ALPHA		(41 << 16)
-# define RADEON_SBLEND_GL_SRC_ALPHA_SATURATE	(42 << 16)
-# define R200_SBLEND_GL_CONST_COLOR		(43 << 16)
-# define R200_SBLEND_GL_ONE_MINUS_CONST_COLOR	(44 << 16)
-# define R200_SBLEND_GL_CONST_ALPHA		(45 << 16)
-# define R200_SBLEND_GL_ONE_MINUS_CONST_ALPHA	(46 << 16)
-# define RADEON_SBLEND_MASK			(63 << 16)
-# define RADEON_DBLEND_GL_ZERO			(32 << 24)
-# define RADEON_DBLEND_GL_ONE			(33 << 24)
-# define RADEON_DBLEND_GL_SRC_COLOR		(34 << 24)
-# define RADEON_DBLEND_GL_INV_SRC_COLOR		(35 << 24)
-# define RADEON_DBLEND_GL_DST_COLOR		(36 << 24)
-# define RADEON_DBLEND_GL_INV_DST_COLOR		(37 << 24)
-# define RADEON_DBLEND_GL_SRC_ALPHA		(38 << 24)
-# define RADEON_DBLEND_GL_INV_SRC_ALPHA		(39 << 24)
-# define RADEON_DBLEND_GL_DST_ALPHA		(40 << 24)
-# define RADEON_DBLEND_GL_INV_DST_ALPHA		(41 << 24)
-# define R200_DBLEND_GL_CONST_COLOR		(43 << 24)
-# define R200_DBLEND_GL_ONE_MINUS_CONST_COLOR	(44 << 24)
-# define R200_DBLEND_GL_CONST_ALPHA		(45 << 24)
-# define R200_DBLEND_GL_ONE_MINUS_CONST_ALPHA	(46 << 24)
-# define RADEON_DBLEND_MASK			(63 << 24)
-
-#define RADEON_REG_PP_CNTL			0x1c38
-# define RADEON_STIPPLE_ENABLE			(1 <<  0)
-# define RADEON_SCISSOR_ENABLE			(1 <<  1)
-# define RADEON_PATTERN_ENABLE			(1 <<  2)
-# define RADEON_SHADOW_ENABLE			(1 <<  3)
-# define RADEON_TEX_ENABLE_MASK			(0xf << 4)
-# define RADEON_TEX_0_ENABLE			(1 <<  4)
-# define RADEON_TEX_1_ENABLE			(1 <<  5)
-# define RADEON_TEX_2_ENABLE			(1 <<  6)
-# define RADEON_TEX_3_ENABLE			(1 <<  7)
-# define R200_TEX_4_ENABLE			(1 <<  8)
-# define R200_TEX_5_ENABLE			(1 <<  9)
-# define RADEON_TEX_BLEND_ENABLE_MASK		(0xf << 12)
-# define RADEON_TEX_BLEND_0_ENABLE		(1 << 12)
-# define RADEON_TEX_BLEND_1_ENABLE		(1 << 13)
-# define RADEON_TEX_BLEND_2_ENABLE		(1 << 14)
-# define RADEON_TEX_BLEND_3_ENABLE		(1 << 15)
-# define R200_TEX_BLEND_4_ENABLE		(1 << 16)
-# define R200_TEX_BLEND_5_ENABLE		(1 << 17)
-# define R200_TEX_BLEND_6_ENABLE		(1 << 18)
-# define RADEON_PLANAR_YUV_ENABLE		(1 << 20)
-# define RADEON_SPECULAR_ENABLE			(1 << 21)
-# define RADEON_FOG_ENABLE			(1 << 22)
-# define RADEON_ALPHA_TEST_ENABLE		(1 << 23)
-# define RADEON_ANTI_ALIAS_NONE			(0 << 24)
-# define RADEON_ANTI_ALIAS_LINE			(1 << 24)
-# define RADEON_ANTI_ALIAS_POLY			(2 << 24)
-# define RADEON_ANTI_ALIAS_LINE_POLY		(3 << 24)
-# define RADEON_BUMP_MAP_ENABLE			(1 << 26)
-# define RADEON_BUMPED_MAP_T0			(0 << 27)
-# define RADEON_BUMPED_MAP_T1			(1 << 27)
-# define RADEON_BUMPED_MAP_T2			(2 << 27)
-# define RADEON_TEX_3D_ENABLE_0			(1 << 29)
-# define RADEON_TEX_3D_ENABLE_1			(1 << 30)
-# define RADEON_MC_ENABLE			(1 << 31)
-
-#define RADEON_REG_RB3D_CNTL			0x1c3c
-# define RADEON_ALPHA_BLEND_ENABLE		(1  <<  0)
-# define RADEON_PLANE_MASK_ENABLE		(1  <<  1)
-# define RADEON_DITHER_ENABLE			(1  <<  2)
-# define RADEON_ROUND_ENABLE			(1  <<  3)
-# define RADEON_SCALE_DITHER_ENABLE		(1  <<  4)
-# define RADEON_DITHER_INIT			(1  <<  5)
-# define RADEON_ROP_ENABLE			(1  <<  6)
-# define RADEON_STENCIL_ENABLE			(1  <<  7)
-# define RADEON_Z_ENABLE			(1  <<  8)
-# define RADEON_DEPTH_XZ_OFFEST_ENABLE		(1  <<  9)
-# define RADEON_COLOR_FORMAT_ARGB1555		(3  << 10)
-# define RADEON_COLOR_FORMAT_RGB565		(4  << 10)
-# define RADEON_COLOR_FORMAT_ARGB8888		(6  << 10)
-# define RADEON_COLOR_FORMAT_RGB332		(7  << 10)
-# define RADEON_COLOR_FORMAT_Y8			(8  << 10)
-# define RADEON_COLOR_FORMAT_RGB8		(9  << 10)
-# define RADEON_COLOR_FORMAT_YUV422_VYUY	(11 << 10)
-# define RADEON_COLOR_FORMAT_YUV422_YVYU	(12 << 10)
-# define RADEON_COLOR_FORMAT_aYUV444		(14 << 10)
-# define RADEON_COLOR_FORMAT_ARGB4444		(15 << 10)
-# define RADEON_CLRCMP_FLIP_ENABLE		(1  << 14)
-
-#define RADEON_REG_RB3D_COLOROFFSET		0x1c40
-# define RADEON_COLOROFFSET_MASK		0xfffffff0
-
-#define RADEON_REG_RE_WIDTH_HEIGHT		0x1c44
-
-#define RADEON_REG_RB3D_COLORPITCH		0x1c48
-# define RADEON_COLORPITCH_MASK			0x000001ff8
-# define RADEON_COLOR_TILE_ENABLE		(1 << 16)
-# define RADEON_COLOR_MICROTILE_ENABLE		(1 << 17)
-# define RADEON_COLOR_ENDIAN_NO_SWAP		(0 << 18)
-# define RADEON_COLOR_ENDIAN_WORD_SWAP		(1 << 18)
-# define RADEON_COLOR_ENDIAN_DWORD_SWAP		(2 << 18)
-
-#define RADEON_REG_SE_CNTL			0x1c4c
-# define RADEON_FFACE_CULL_CW			(0 <<  0)
-# define RADEON_FFACE_CULL_CCW			(1 <<  0)
-# define RADEON_FFACE_CULL_DIR_MASK		(1 <<  0)
-# define RADEON_BFACE_CULL			(0 <<  1)
-# define RADEON_BFACE_SOLID			(3 <<  1)
-# define RADEON_FFACE_CULL			(0 <<  3)
-# define RADEON_FFACE_SOLID			(3 <<  3)
-# define RADEON_FFACE_CULL_MASK			(3 <<  3)
-# define RADEON_BADVTX_CULL_DISABLE		(1 <<  5)
-# define RADEON_FLAT_SHADE_VTX_0		(0 <<  6)
-# define RADEON_FLAT_SHADE_VTX_1		(1 <<  6)
-# define RADEON_FLAT_SHADE_VTX_2		(2 <<  6)
-# define RADEON_FLAT_SHADE_VTX_LAST		(3 <<  6)
-# define RADEON_DIFFUSE_SHADE_SOLID		(0 <<  8)
-# define RADEON_DIFFUSE_SHADE_FLAT		(1 <<  8)
-# define RADEON_DIFFUSE_SHADE_GOURAUD		(2 <<  8)
-# define RADEON_DIFFUSE_SHADE_MASK		(3 <<  8)
-# define RADEON_ALPHA_SHADE_SOLID		(0 << 10)
-# define RADEON_ALPHA_SHADE_FLAT		(1 << 10)
-# define RADEON_ALPHA_SHADE_GOURAUD		(2 << 10)
-# define RADEON_ALPHA_SHADE_MASK		(3 << 10)
-# define RADEON_SPECULAR_SHADE_SOLID		(0 << 12)
-# define RADEON_SPECULAR_SHADE_FLAT		(1 << 12)
-# define RADEON_SPECULAR_SHADE_GOURAUD		(2 << 12)
-# define RADEON_SPECULAR_SHADE_MASK		(3 << 12)
-# define RADEON_FOG_SHADE_SOLID			(0 << 14)
-# define RADEON_FOG_SHADE_FLAT			(1 << 14)
-# define RADEON_FOG_SHADE_GOURAUD		(2 << 14)
-# define RADEON_FOG_SHADE_MASK			(3 << 14)
-# define RADEON_ZBIAS_ENABLE_POINT		(1 << 16)
-# define RADEON_ZBIAS_ENABLE_LINE		(1 << 17)
-# define RADEON_ZBIAS_ENABLE_TRI		(1 << 18)
-# define RADEON_WIDELINE_ENABLE			(1 << 20)
-# define RADEON_VPORT_XY_XFORM_ENABLE		(1 << 24)
-# define RADEON_VPORT_Z_XFORM_ENABLE		(1 << 25)
-# define RADEON_VTX_PIX_CENTER_D3D		(0 << 27)
-# define RADEON_VTX_PIX_CENTER_OGL		(1 << 27)
-# define RADEON_ROUND_MODE_TRUNC		(0 << 28)
-# define RADEON_ROUND_MODE_ROUND		(1 << 28)
-# define RADEON_ROUND_MODE_ROUND_EVEN		(2 << 28)
-# define RADEON_ROUND_MODE_ROUND_ODD		(3 << 28)
-# define RADEON_ROUND_PREC_16TH_PIX		(0 << 30)
-# define RADEON_ROUND_PREC_8TH_PIX		(1 << 30)
-# define RADEON_ROUND_PREC_4TH_PIX		(2 << 30)
-# define RADEON_ROUND_PREC_HALF_PIX		(3 << 30)
-
-#define R200_REG_RE_CNTL			0x1c50 
-
-#define RADEON_REG_SE_COORD_FMT			0x1c50
-# define RADEON_VTX_XY_PRE_MULT_1_OVER_W0	(1 <<  0)
-# define RADEON_VTX_Z_PRE_MULT_1_OVER_W0	(1 <<  1)
-# define RADEON_VTX_ST0_NONPARAMETRIC		(1 <<  8)
-# define RADEON_VTX_ST1_NONPARAMETRIC		(1 <<  9)
-# define RADEON_VTX_ST2_NONPARAMETRIC		(1 << 10)
-# define RADEON_VTX_ST3_NONPARAMETRIC		(1 << 11)
-# define RADEON_VTX_W0_NORMALIZE		(1 << 12)
-# define RADEON_VTX_W0_IS_NOT_1_OVER_W0		(1 << 16)
-# define RADEON_VTX_ST0_PRE_MULT_1_OVER_W0	(1 << 17)
-# define RADEON_VTX_ST1_PRE_MULT_1_OVER_W0	(1 << 19)
-# define RADEON_VTX_ST2_PRE_MULT_1_OVER_W0	(1 << 21)
-# define RADEON_VTX_ST3_PRE_MULT_1_OVER_W0	(1 << 23)
-# define RADEON_TEX1_W_ROUTING_USE_W0		(0 << 26)
-# define RADEON_TEX1_W_ROUTING_USE_Q1		(1 << 26)
-
-#define RADEON_REG_PP_TXFILTER_0		0x1c54
-#define RADEON_REG_PP_TXFILTER_1		0x1c6c
-#define RADEON_REG_PP_TXFILTER_2		0x1c84
-# define RADEON_MAG_FILTER_NEAREST		(0  <<  0)
-# define RADEON_MAG_FILTER_LINEAR		(1  <<  0)
-# define RADEON_MAG_FILTER_MASK			(1  <<  0)
-# define RADEON_MIN_FILTER_NEAREST		(0  <<  1)
-# define RADEON_MIN_FILTER_LINEAR		(1  <<  1)
-# define RADEON_MIN_FILTER_NEAREST_MIP_NEAREST	(2  <<  1)
-# define RADEON_MIN_FILTER_NEAREST_MIP_LINEAR	(3  <<  1)
-# define RADEON_MIN_FILTER_LINEAR_MIP_NEAREST	(6  <<  1)
-# define RADEON_MIN_FILTER_LINEAR_MIP_LINEAR	(7  <<  1)
-# define RADEON_MIN_FILTER_ANISO_NEAREST	(8  <<  1)
-# define RADEON_MIN_FILTER_ANISO_LINEAR		(9  <<  1)
-# define RADEON_MIN_FILTER_ANISO_NEAREST_MIP_NEAREST	(10 <<  1)
-# define RADEON_MIN_FILTER_ANISO_NEAREST_MIP_LINEAR	(11 <<  1)
-# define RADEON_MIN_FILTER_MASK			(15 <<  1)
-# define RADEON_MAX_ANISO_1_TO_1		(0  <<  5)
-# define RADEON_MAX_ANISO_2_TO_1		(1  <<  5)
-# define RADEON_MAX_ANISO_4_TO_1		(2  <<  5)
-# define RADEON_MAX_ANISO_8_TO_1		(3  <<  5)
-# define RADEON_MAX_ANISO_16_TO_1		(4  <<  5)
-# define RADEON_MAX_ANISO_MASK			(7  <<  5)
-# define RADEON_LOD_BIAS_MASK			(0xff <<  8)
-# define RADEON_LOD_BIAS_SHIFT			8
-# define RADEON_MAX_MIP_LEVEL_MASK		(0x0f << 16)
-# define RADEON_MAX_MIP_LEVEL_SHIFT		16
-# define RADEON_YUV_TO_RGB			(1  << 20)
-# define RADEON_YUV_TEMPERATURE_COOL		(0  << 21)
-# define RADEON_YUV_TEMPERATURE_HOT		(1  << 21)
-# define RADEON_YUV_TEMPERATURE_MASK		(1  << 21)
-# define RADEON_WRAPEN_S			(1  << 22)
-# define RADEON_CLAMP_S_WRAP			(0  << 23)
-# define RADEON_CLAMP_S_MIRROR			(1  << 23)
-# define RADEON_CLAMP_S_CLAMP_LAST		(2  << 23)
-# define RADEON_CLAMP_S_MIRROR_CLAMP_LAST	(3  << 23)
-# define RADEON_CLAMP_S_CLAMP_BORDER		(4  << 23)
-# define RADEON_CLAMP_S_MIRROR_CLAMP_BORDER	(5  << 23)
-# define RADEON_CLAMP_S_CLAMP_GL		(6  << 23)
-# define RADEON_CLAMP_S_MIRROR_CLAMP_GL		(7  << 23)
-# define RADEON_CLAMP_S_MASK			(7  << 23)
-# define RADEON_WRAPEN_T			(1  << 26)
-# define RADEON_CLAMP_T_WRAP			(0  << 27)
-# define RADEON_CLAMP_T_MIRROR			(1  << 27)
-# define RADEON_CLAMP_T_CLAMP_LAST		(2  << 27)
-# define RADEON_CLAMP_T_MIRROR_CLAMP_LAST	(3  << 27)
-# define RADEON_CLAMP_T_CLAMP_BORDER		(4  << 27)
-# define RADEON_CLAMP_T_MIRROR_CLAMP_BORDER	(5  << 27)
-# define RADEON_CLAMP_T_CLAMP_GL		(6  << 27)
-# define RADEON_CLAMP_T_MIRROR_CLAMP_GL		(7  << 27)
-# define RADEON_CLAMP_T_MASK			(7  << 27)
-# define RADEON_BORDER_MODE_OGL			(0  << 31)
-# define RADEON_BORDER_MODE_D3D			(1  << 31)
-
-#define RADEON_REG_PP_TXFORMAT_0		0x1c58
-#define RADEON_REG_PP_TXFORMAT_1		0x1c70
-#define RADEON_REG_PP_TXFORMAT_2		0x1c88
-# define RADEON_TXFORMAT_I8			(0  <<  0)
-# define RADEON_TXFORMAT_AI88			(1  <<  0)
-# define RADEON_TXFORMAT_RGB332			(2  <<  0)
-# define RADEON_TXFORMAT_ARGB1555		(3  <<  0)
-# define RADEON_TXFORMAT_RGB565			(4  <<  0)
-# define RADEON_TXFORMAT_ARGB4444		(5  <<  0)
-# define RADEON_TXFORMAT_ARGB8888		(6  <<  0)
-# define RADEON_TXFORMAT_RGBA8888		(7  <<  0)
-# define RADEON_TXFORMAT_Y8			(8  <<  0)
-# define RADEON_TXFORMAT_AYUV444		(9  <<  0)
-# define RADEON_TXFORMAT_VYUY422		(10 <<  0)
-# define RADEON_TXFORMAT_YVYU422		(11 <<  0)
-# define RADEON_TXFORMAT_DXT1			(12 <<  0)
-# define RADEON_TXFORMAT_DXT23			(14 <<  0)
-# define RADEON_TXFORMAT_DXT45			(15 <<  0)
-# define RADEON_TXFORMAT_FORMAT_MASK		(31 <<  0)
-# define RADEON_TXFORMAT_FORMAT_SHIFT		0
-# define RADEON_TXFORMAT_APPLE_YUV_MODE		(1  <<  5)
-# define RADEON_TXFORMAT_ALPHA_IN_MAP		(1  <<  6)
-# define RADEON_TXFORMAT_NON_POWER2		(1  <<  7)
-# define RADEON_TXFORMAT_WIDTH_MASK		(15 <<  8)
-# define RADEON_TXFORMAT_WIDTH_SHIFT		8
-# define RADEON_TXFORMAT_HEIGHT_MASK		(15 << 12)
-# define RADEON_TXFORMAT_HEIGHT_SHIFT		12
-# define RADEON_TXFORMAT_F5_WIDTH_MASK		(15 << 16)
-# define RADEON_TXFORMAT_F5_WIDTH_SHIFT		16
-# define RADEON_TXFORMAT_F5_HEIGHT_MASK		(15 << 20)
-# define RADEON_TXFORMAT_F5_HEIGHT_SHIFT	20
-# define RADEON_TXFORMAT_ST_ROUTE_STQ0		(0  << 24)
-# define RADEON_TXFORMAT_ST_ROUTE_STQ1		(1  << 24)
-# define RADEON_TXFORMAT_ST_ROUTE_STQ2		(2  << 24)
-# define RADEON_TXFORMAT_ST_ROUTE_MASK		(3  << 24)
-# define RADEON_TXFORMAT_ENDIAN_NO_SWAP		(0  << 26)
-# define RADEON_TXFORMAT_ENDIAN_16BPP_SWAP	(1  << 26)
-# define RADEON_TXFORMAT_ENDIAN_32BPP_SWAP	(2  << 26)
-# define RADEON_TXFORMAT_ENDIAN_HALFDW_SWAP	(3  << 26)
-# define RADEON_TXFORMAT_ALPHA_MASK_ENABLE	(1  << 28)
-# define RADEON_TXFORMAT_CHROMA_KEY_ENABLE	(1  << 29)
-# define RADEON_TXFORMAT_CUBIC_MAP_ENABLE	(1  << 30)
-# define RADEON_TXFORMAT_PERSPECTIVE_ENABLE	(1  << 31)
-
-#define RADEON_REG_PP_TXOFFSET_0		0x1c5c
-#define RADEON_REG_PP_TXOFFSET_1		0x1c74
-#define RADEON_REG_PP_TXOFFSET_2		0x1c8c
-# define RADEON_TXO_ENDIAN_NO_SWAP		(0 << 0)
-# define RADEON_TXO_ENDIAN_BYTE_SWAP		(1 << 0)
-# define RADEON_TXO_ENDIAN_WORD_SWAP		(2 << 0)
-# define RADEON_TXO_ENDIAN_HALFDW_SWAP		(3 << 0)
-# define RADEON_TXO_MACRO_LINEAR		(0 << 2)
-# define RADEON_TXO_MACRO_TILE			(1 << 2)
-# define RADEON_TXO_MICRO_LINEAR		(0 << 3)
-# define RADEON_TXO_MICRO_TILE_X2		(1 << 3)
-# define RADEON_TXO_MICRO_TILE_OPT		(2 << 3)
-# define RADEON_TXO_OFFSET_MASK			0xffffffe0
-# define RADEON_TXO_OFFSET_SHIFT		5
-
-#define RADEON_REG_PP_TXCBLEND_0		0x1c60
-#define RADEON_REG_PP_TXCBLEND_1		0x1c78
-#define RADEON_REG_PP_TXCBLEND_2		0x1c90
-# define RADEON_COLOR_ARG_A_SHIFT		0
-# define RADEON_COLOR_ARG_A_MASK		(0x1f << 0)
-# define RADEON_COLOR_ARG_A_ZERO		(0    << 0)
-# define RADEON_COLOR_ARG_A_CURRENT_COLOR	(2    << 0)
-# define RADEON_COLOR_ARG_A_CURRENT_ALPHA	(3    << 0)
-# define RADEON_COLOR_ARG_A_DIFFUSE_COLOR	(4    << 0)
-# define RADEON_COLOR_ARG_A_DIFFUSE_ALPHA	(5    << 0)
-# define RADEON_COLOR_ARG_A_SPECULAR_COLOR	(6    << 0)
-# define RADEON_COLOR_ARG_A_SPECULAR_ALPHA	(7    << 0)
-# define RADEON_COLOR_ARG_A_TFACTOR_COLOR	(8    << 0)
-# define RADEON_COLOR_ARG_A_TFACTOR_ALPHA	(9    << 0)
-# define RADEON_COLOR_ARG_A_T0_COLOR		(10   << 0)
-# define RADEON_COLOR_ARG_A_T0_ALPHA		(11   << 0)
-# define RADEON_COLOR_ARG_A_T1_COLOR		(12   << 0)
-# define RADEON_COLOR_ARG_A_T1_ALPHA		(13   << 0)
-# define RADEON_COLOR_ARG_A_T2_COLOR		(14   << 0)
-# define RADEON_COLOR_ARG_A_T2_ALPHA		(15   << 0)
-# define RADEON_COLOR_ARG_A_T3_COLOR		(16   << 0)
-# define RADEON_COLOR_ARG_A_T3_ALPHA		(17   << 0)
-# define RADEON_COLOR_ARG_B_SHIFT		5
-# define RADEON_COLOR_ARG_B_MASK		(0x1f << 5)
-# define RADEON_COLOR_ARG_B_ZERO		(0    << 5)
-# define RADEON_COLOR_ARG_B_CURRENT_COLOR	(2    << 5)
-# define RADEON_COLOR_ARG_B_CURRENT_ALPHA	(3    << 5)
-# define RADEON_COLOR_ARG_B_DIFFUSE_COLOR	(4    << 5)
-# define RADEON_COLOR_ARG_B_DIFFUSE_ALPHA	(5    << 5)
-# define RADEON_COLOR_ARG_B_SPECULAR_COLOR	(6    << 5)
-# define RADEON_COLOR_ARG_B_SPECULAR_ALPHA	(7    << 5)
-# define RADEON_COLOR_ARG_B_TFACTOR_COLOR	(8    << 5)
-# define RADEON_COLOR_ARG_B_TFACTOR_ALPHA	(9    << 5)
-# define RADEON_COLOR_ARG_B_T0_COLOR		(10   << 5)
-# define RADEON_COLOR_ARG_B_T0_ALPHA		(11   << 5)
-# define RADEON_COLOR_ARG_B_T1_COLOR		(12   << 5)
-# define RADEON_COLOR_ARG_B_T1_ALPHA		(13   << 5)
-# define RADEON_COLOR_ARG_B_T2_COLOR		(14   << 5)
-# define RADEON_COLOR_ARG_B_T2_ALPHA		(15   << 5)
-# define RADEON_COLOR_ARG_B_T3_COLOR		(16   << 5)
-# define RADEON_COLOR_ARG_B_T3_ALPHA		(17   << 5)
-# define RADEON_COLOR_ARG_C_SHIFT		10
-# define RADEON_COLOR_ARG_C_MASK		(0x1f << 10)
-# define RADEON_COLOR_ARG_C_ZERO		(0    << 10)
-# define RADEON_COLOR_ARG_C_CURRENT_COLOR	(2    << 10)
-# define RADEON_COLOR_ARG_C_CURRENT_ALPHA	(3    << 10)
-# define RADEON_COLOR_ARG_C_DIFFUSE_COLOR	(4    << 10)
-# define RADEON_COLOR_ARG_C_DIFFUSE_ALPHA	(5    << 10)
-# define RADEON_COLOR_ARG_C_SPECULAR_COLOR	(6    << 10)
-# define RADEON_COLOR_ARG_C_SPECULAR_ALPHA	(7    << 10)
-# define RADEON_COLOR_ARG_C_TFACTOR_COLOR	(8    << 10)
-# define RADEON_COLOR_ARG_C_TFACTOR_ALPHA	(9    << 10)
-# define RADEON_COLOR_ARG_C_T0_COLOR		(10   << 10)
-# define RADEON_COLOR_ARG_C_T0_ALPHA		(11   << 10)
-# define RADEON_COLOR_ARG_C_T1_COLOR		(12   << 10)
-# define RADEON_COLOR_ARG_C_T1_ALPHA		(13   << 10)
-# define RADEON_COLOR_ARG_C_T2_COLOR		(14   << 10)
-# define RADEON_COLOR_ARG_C_T2_ALPHA		(15   << 10)
-# define RADEON_COLOR_ARG_C_T3_COLOR		(16   << 10)
-# define RADEON_COLOR_ARG_C_T3_ALPHA		(17   << 10)
-# define RADEON_COMP_ARG_A			(1 << 15)
-# define RADEON_COMP_ARG_A_SHIFT		15
-# define RADEON_COMP_ARG_B			(1 << 16)
-# define RADEON_COMP_ARG_B_SHIFT		16
-# define RADEON_COMP_ARG_C			(1 << 17)
-# define RADEON_COMP_ARG_C_SHIFT		17
-# define RADEON_BLEND_CTL_MASK			(7 << 18)
-# define RADEON_BLEND_CTL_ADD			(0 << 18)
-# define RADEON_BLEND_CTL_SUBTRACT		(1 << 18)
-# define RADEON_BLEND_CTL_ADDSIGNED		(2 << 18)
-# define RADEON_BLEND_CTL_BLEND			(3 << 18)
-# define RADEON_BLEND_CTL_DOT3			(4 << 18)
-# define RADEON_SCALE_SHIFT			21
-# define RADEON_SCALE_MASK			(3 << 21)
-# define RADEON_SCALE_1X			(0 << 21)
-# define RADEON_SCALE_2X			(1 << 21)
-# define RADEON_SCALE_4X			(2 << 21)
-# define RADEON_CLAMP_TX			(1 << 23)
-# define RADEON_T0_EQ_TCUR			(1 << 24)
-# define RADEON_T1_EQ_TCUR			(1 << 25)
-# define RADEON_T2_EQ_TCUR			(1 << 26)
-# define RADEON_T3_EQ_TCUR			(1 << 27)
-# define RADEON_COLOR_ARG_MASK			0x1f
-# define RADEON_COMP_ARG_SHIFT			15
-
-#define RADEON_REG_PP_TXABLEND_0		0x1c64
-#define RADEON_REG_PP_TXABLEND_1		0x1c7c
-#define RADEON_REG_PP_TXABLEND_2		0x1c94
-# define RADEON_ALPHA_ARG_A_SHIFT		0
-# define RADEON_ALPHA_ARG_A_MASK		(0xf << 0)
-# define RADEON_ALPHA_ARG_A_ZERO		(0   << 0)
-# define RADEON_ALPHA_ARG_A_CURRENT_ALPHA	(1   << 0)
-# define RADEON_ALPHA_ARG_A_DIFFUSE_ALPHA	(2   << 0)
-# define RADEON_ALPHA_ARG_A_SPECULAR_ALPHA	(3   << 0)
-# define RADEON_ALPHA_ARG_A_TFACTOR_ALPHA	(4   << 0)
-# define RADEON_ALPHA_ARG_A_T0_ALPHA		(5   << 0)
-# define RADEON_ALPHA_ARG_A_T1_ALPHA		(6   << 0)
-# define RADEON_ALPHA_ARG_A_T2_ALPHA		(7   << 0)
-# define RADEON_ALPHA_ARG_A_T3_ALPHA		(8   << 0)
-# define RADEON_ALPHA_ARG_B_SHIFT		4
-# define RADEON_ALPHA_ARG_B_MASK		(0xf << 4)
-# define RADEON_ALPHA_ARG_B_ZERO		(0   << 4)
-# define RADEON_ALPHA_ARG_B_CURRENT_ALPHA	(1   << 4)
-# define RADEON_ALPHA_ARG_B_DIFFUSE_ALPHA	(2   << 4)
-# define RADEON_ALPHA_ARG_B_SPECULAR_ALPHA	(3   << 4)
-# define RADEON_ALPHA_ARG_B_TFACTOR_ALPHA	(4   << 4)
-# define RADEON_ALPHA_ARG_B_T0_ALPHA		(5   << 4)
-# define RADEON_ALPHA_ARG_B_T1_ALPHA		(6   << 4)
-# define RADEON_ALPHA_ARG_B_T2_ALPHA		(7   << 4)
-# define RADEON_ALPHA_ARG_B_T3_ALPHA		(8   << 4)
-# define RADEON_ALPHA_ARG_C_SHIFT		8
-# define RADEON_ALPHA_ARG_C_MASK		(0xf << 8)
-# define RADEON_ALPHA_ARG_C_ZERO		(0   << 8)
-# define RADEON_ALPHA_ARG_C_CURRENT_ALPHA	(1   << 8)
-# define RADEON_ALPHA_ARG_C_DIFFUSE_ALPHA	(2   << 8)
-# define RADEON_ALPHA_ARG_C_SPECULAR_ALPHA	(3   << 8)
-# define RADEON_ALPHA_ARG_C_TFACTOR_ALPHA	(4   << 8)
-# define RADEON_ALPHA_ARG_C_T0_ALPHA		(5   << 8)
-# define RADEON_ALPHA_ARG_C_T1_ALPHA		(6   << 8)
-# define RADEON_ALPHA_ARG_C_T2_ALPHA		(7   << 8)
-# define RADEON_ALPHA_ARG_C_T3_ALPHA		(8   << 8)
-# define RADEON_DOT_ALPHA_DONT_REPLICATE	(1   << 9)
-/* COMP_ARG, BLEND_CNTL, CLAMP_TX same as for CBLEND, T*_EQ_TCUR */
-# define RADEON_ALPHA_ARG_MASK			0xf
-
-#define RADEON_REG_PP_TFACTOR_0			0x1c68
-#define RADEON_REG_PP_TFACTOR_1			0x1c80
-#define RADEON_REG_PP_TFACTOR_2			0x1c98
-
-#define R128_REG_TEX_CNTL_C			0x1c9c
-# define R128_Z_ENABLE				(1 <<  0)
-# define R128_Z_WRITE_ENABLE			(1 <<  1)
-# define R128_STENCIL_ENABLE			(1 <<  3)
-# define R128_SHADE_ENABLE			(0 <<  4)
-# define R128_TEXMAP_ENABLE			(1 <<  4)
-# define R128_SEC_TEXMAP_ENABLE			(1 <<  5)
-# define R128_FOG_ENABLE			(1 <<  7)
-# define R128_DITHER_ENABLE			(1 <<  8)
-# define R128_ALPHA_ENABLE			(1 <<  9)
-# define R128_ALPHA_TEST_ENABLE			(1 << 10)
-# define R128_SPEC_LIGHT_ENABLE			(1 << 11)
-# define R128_TEX_CHROMA_KEY_ENABLE		(1 << 12)
-# define R128_ALPHA_IN_TEX_COMPLETE_A		(0 << 13)
-# define R128_ALPHA_IN_TEX_LSB_A		(1 << 13)
-# define R128_LIGHT_DIS				(0 << 14)
-# define R128_LIGHT_COPY			(1 << 14)
-# define R128_LIGHT_MODULATE			(2 << 14)
-# define R128_LIGHT_ADD				(3 << 14)
-# define R128_LIGHT_BLEND_CONSTANT		(4 << 14)
-# define R128_LIGHT_BLEND_TEXTURE		(5 << 14)
-# define R128_LIGHT_BLEND_VERTEX		(6 << 14)
-# define R128_LIGHT_BLEND_CONST_COLOR		(7 << 14)
-# define R128_ALPHA_LIGHT_DIS			(0 << 18)
-# define R128_ALPHA_LIGHT_COPY			(1 << 18)
-# define R128_ALPHA_LIGHT_MODULATE		(2 << 18)
-# define R128_ALPHA_LIGHT_ADD			(3 << 18)
-# define R128_ANTI_ALIAS			(1 << 21)
-# define R128_TEX_CACHE_FLUSH			(1 << 23)
-# define R128_LOD_BIAS_SHIFT			24
-# define R128_LOD_BIAS_MASK			(0xff << 24)
-
-#define R128_REG_MISC_3D_STATE_CNTL		0x1ca0
-# define R128_REF_ALPHA_MASK			0xff
-# define R128_MISC_SCALE_3D_NOOP		(0  <<  8)
-# define R128_MISC_SCALE_3D_SCALE		(1  <<  8)
-# define R128_MISC_SCALE_3D_TEXMAP_SHADE	(2  <<  8)
-# define R128_MISC_SCALE_PIX_BLEND		(0  << 10)
-# define R128_MISC_SCALE_PIX_REPLICATE		(1  << 10)
-# define R128_ALPHA_COMB_ADD_CLAMP		(0  << 12)
-# define R128_ALPHA_COMB_ADD_NO_CLAMP		(1  << 12)
-# define R128_ALPHA_COMB_SUB_SRC_DST_CLAMP	(2  << 12)
-# define R128_ALPHA_COMB_SUB_SRC_DST_NO_CLAMP	(3  << 12)
-# define R128_FOG_VERTEX			(0  << 14)
-# define R128_FOG_TABLE				(1  << 14)
-# define R128_SBLEND_ZERO			(0  << 16)
-# define R128_SBLEND_ONE			(1  << 16)
-# define R128_SBLEND_SRCCOLOR			(2  << 16)
-# define R128_SBLEND_INVSRCCOLOR		(3  << 16)
-# define R128_SBLEND_SRC_ALPHA			(4  << 16)
-# define R128_SBLEND_INV_SRC_ALPHA		(5  << 16)
-# define R128_SBLEND_DST_ALPHA			(6  << 16)
-# define R128_SBLEND_INV_DST_ALPHA		(7  << 16)
-# define R128_SBLEND_DSTCOLOR			(8  << 16)
-# define R128_SBLEND_INVDSTCOLOR		(9  << 16)
-# define R128_SBLEND_SRC_ALPHASAT		(10 << 16)
-# define R128_SBLEND_BOTHSRC_ALPHA		(11 << 16)
-# define R128_SBLEND_BOTHINV_SRC_ALPHA		(12 << 16)
-# define R128_SBLEND_MASK			(15 << 16)
-# define R128_DBLEND_ZERO			(0  << 20)
-# define R128_DBLEND_ONE			(1  << 20)
-# define R128_DBLEND_SRCCOLOR			(2  << 20)
-# define R128_DBLEND_INVSRCCOLOR		(3  << 20)
-# define R128_DBLEND_SRC_ALPHA			(4  << 20)
-# define R128_DBLEND_INV_SRC_ALPHA		(5  << 20)
-# define R128_DBLEND_DST_ALPHA			(6  << 20)
-# define R128_DBLEND_INV_DST_ALPHA		(7  << 20)
-# define R128_DBLEND_DSTCOLOR			(8  << 20)
-# define R128_DBLEND_INVDSTCOLOR		(9  << 20)
-# define R128_DBLEND_SRC_ALPHASAT		(10 << 20)
-# define R128_DBLEND_MASK			(15 << 20)
-# define R128_ALPHA_TEST_NEVER			(0  << 24)
-# define R128_ALPHA_TEST_LESS			(1  << 24)
-# define R128_ALPHA_TEST_LESSEQUAL		(2  << 24)
-# define R128_ALPHA_TEST_EQUAL			(3  << 24)
-# define R128_ALPHA_TEST_GREATEREQUAL		(4  << 24)
-# define R128_ALPHA_TEST_GREATER		(5  << 24)
-# define R128_ALPHA_TEST_NEQUAL			(6  << 24)
-# define R128_ALPHA_TEST_ALWAYS			(7  << 24)
-# define R128_ALPHA_TEST_MASK			(7  << 24)
-
-#define R128_REG_PRIM_TEX_CNTL_C		0x1cb0
-#define R128_REG_SEC_TEX_CNTL_C			0x1d00
-# define R128_SEC_SELECT_PRIM_ST		(0  <<  0)
-# define R128_SEC_SELECT_SEC_ST			(1  <<  0)
-# define R128_MIN_BLEND_NEAREST			(0  <<  1)
-# define R128_MIN_BLEND_LINEAR			(1  <<  1)
-# define R128_MIN_BLEND_MIPNEAREST		(2  <<  1)
-# define R128_MIN_BLEND_MIPLINEAR		(3  <<  1)
-# define R128_MIN_BLEND_LINEARMIPNEAREST	(4  <<  1)
-# define R128_MIN_BLEND_LINEARMIPLINEAR		(5  <<  1)
-# define R128_MIN_BLEND_MASK			(7  <<  1)
-# define R128_MAG_BLEND_NEAREST			(0  <<  4)
-# define R128_MAG_BLEND_LINEAR			(1  <<  4)
-# define R128_MAG_BLEND_MASK			(7  <<  4)
-# define R128_MIP_MAP_DISABLE			(1  <<  7)
-# define R128_TEX_CLAMP_S_WRAP			(0  <<  8)
-# define R128_TEX_CLAMP_S_MIRROR		(1  <<  8)
-# define R128_TEX_CLAMP_S_CLAMP			(2  <<  8)
-# define R128_TEX_CLAMP_S_BORDER_COLOR		(3  <<  8)
-# define R128_TEX_CLAMP_S_MASK			(3  <<  8)
-# define R128_TEX_WRAP_S			(1  << 10)
-# define R128_TEX_CLAMP_T_WRAP			(0  << 11)
-# define R128_TEX_CLAMP_T_MIRROR		(1  << 11)
-# define R128_TEX_CLAMP_T_CLAMP			(2  << 11)
-# define R128_TEX_CLAMP_T_BORDER_COLOR		(3  << 11)
-# define R128_TEX_CLAMP_T_MASK			(3  << 11)
-# define R128_TEX_WRAP_T			(1  << 13)
-# define R128_TEX_PERSPECTIVE_DISABLE		(1  << 14)
-# define R128_TEX_DATATYPE_SHIFT		16
-# define R128_PALLETE_EITHER			(0  << 20)
-# define R128_PALLETE_1				(1  << 20)
-# define R128_PALLETE_2				(2  << 20)
-# define R128_PSEUDOCOLOR_DT_RGB565		(0  << 24)
-# define R128_PSEUDOCOLOR_DT_ARGB1555		(1  << 24)
-# define R128_PSEUDOCOLOR_DT_ARGB4444		(2  << 24)
-
-#define R128_REG_PRIM_TEXTURE_COMBINE_CNTL_C	0x1cb4
-#define R128_REG_SEC_TEXTURE_COMBINE_CNTL_C	0x1d04
-# define R128_COMB_DIS				(0  <<  0)
-# define R128_COMB_COPY				(1  <<  0)
-# define R128_COMB_COPY_INP			(2  <<  0)
-# define R128_COMB_MODULATE			(3  <<  0)
-# define R128_COMB_MODULATE2X			(4  <<  0)
-# define R128_COMB_MODULATE4X			(5  <<  0)
-# define R128_COMB_ADD				(6  <<  0)
-# define R128_COMB_ADD_SIGNED			(7  <<  0)
-# define R128_COMB_BLEND_VERTEX			(8  <<  0)
-# define R128_COMB_BLEND_TEXTURE		(9  <<  0)
-# define R128_COMB_BLEND_CONST			(10 <<  0)
-# define R128_COMB_BLEND_PREMULT		(11 <<  0)
-# define R128_COMB_BLEND_PREV			(12 <<  0)
-# define R128_COMB_BLEND_PREMULT_INV		(13 <<  0)
-# define R128_COMB_ADD_SIGNED2X			(14 <<  0)
-# define R128_COMB_BLEND_CONST_COLOR		(15 <<  0)
-# define R128_COMB_MASK				(15 <<  0)
-# define R128_COLOR_FACTOR_CONST_COLOR		(0  <<  4)
-# define R128_COLOR_FACTOR_NCONST_COLOR		(1  <<  4)
-# define R128_COLOR_FACTOR_TEX			(4  <<  4)
-# define R128_COLOR_FACTOR_NTEX			(5  <<  4)
-# define R128_COLOR_FACTOR_ALPHA		(6  <<  4)
-# define R128_COLOR_FACTOR_NALPHA		(7  <<  4)
-# define R128_COLOR_FACTOR_PREV_COLOR		(8  <<  4)
-# define R128_COLOR_FACTOR_MASK			(15 <<  4)
-# define R128_COMB_FCN_MSB			(1  <<  8)
-# define R128_INPUT_FACTOR_CONST_COLOR		(2  << 10)
-# define R128_INPUT_FACTOR_CONST_ALPHA		(3  << 10)
-# define R128_INPUT_FACTOR_INT_COLOR		(4  << 10)
-# define R128_INPUT_FACTOR_INT_ALPHA		(5  << 10)
-# define R128_INPUT_FACTOR_PREV_COLOR		(8  << 10)	/* SEC only */
-# define R128_INPUT_FACTOR_PREV_ALPHA		(9  << 10)	/* SEC only */
-# define R128_INPUT_FACTOR_MASK			(15 << 10)
-# define R128_COMB_ALPHA_DIS			(0  << 14)
-# define R128_COMB_ALPHA_COPY			(1  << 14)
-# define R128_COMB_ALPHA_COPY_INP		(2  << 14)
-# define R128_COMB_ALPHA_MODULATE		(3  << 14)
-# define R128_COMB_ALPHA_MODULATE2X		(4  << 14)
-# define R128_COMB_ALPHA_MODULATE4X		(5  << 14)
-# define R128_COMB_ALPHA_ADD			(6  << 14)
-# define R128_COMB_ALPHA_ADD_SIGNED		(7  << 14)
-# define R128_COMB_ALPHA_ADD_SIGNED2X		(14 << 14)
-# define R128_COMB_ALPHA_MASK			(15 << 14)
-# define R128_ALPHA_FACTOR_TEX_ALPHA		(6  << 18)
-# define R128_ALPHA_FACTOR_NTEX_ALPHA		(7  << 18)
-# define R128_ALPHA_FACTOR_MASK			(15 << 18)
-# define R128_INP_FACTOR_A_CONST_ALPHA		(1  << 25)
-# define R128_INP_FACTOR_A_INT_ALPHA		(2  << 25)
-# define R128_INP_FACTOR_A_PREV_ALPHA		(4  << 25)	/* SEC only */
-# define R128_INP_FACTOR_A_MASK			(7  << 25)
-
-#define R128_REG_TEX_SIZE_PITCH_C		0x1cb8
-# define R128_TEX_PITCH_SHIFT			0
-# define R128_TEX_SIZE_SHIFT			4
-# define R128_TEX_HEIGHT_SHIFT			8
-# define R128_TEX_MIN_SIZE_SHIFT		12
-# define R128_SEC_TEX_PITCH_SHIFT		16
-# define R128_SEC_TEX_SIZE_SHIFT		20
-# define R128_SEC_TEX_HEIGHT_SHIFT		24
-# define R128_SEC_TEX_MIN_SIZE_SHIFT		28
-# define R128_TEX_PITCH_MASK			(0x0f <<  0)
-# define R128_TEX_SIZE_MASK			(0x0f <<  4)
-# define R128_TEX_HEIGHT_MASK			(0x0f <<  8)
-# define R128_TEX_MIN_SIZE_MASK			(0x0f << 12)
-# define R128_SEC_TEX_PITCH_MASK		(0x0f << 16)
-# define R128_SEC_TEX_SIZE_MASK			(0x0f << 20)
-# define R128_SEC_TEX_HEIGHT_MASK		(0x0f << 24)
-# define R128_SEC_TEX_MIN_SIZE_MASK		(0x0f << 28)
-# define R128_TEX_SIZE_PITCH_SHIFT		0
-# define R128_SEC_TEX_SIZE_PITCH_SHIFT		16
-# define R128_TEX_SIZE_PITCH_MASK		(0xffff <<  0)
-# define R128_SEC_TEX_SIZE_PITCH_MASK		(0xffff << 16)
-
-#define R128_REG_PRIM_TEX_0_OFFSET_C		0x1cbc
-#define R128_REG_PRIM_TEX_1_OFFSET_C		0x1cc0
-#define R128_REG_PRIM_TEX_2_OFFSET_C		0x1cc4
-#define R128_REG_PRIM_TEX_3_OFFSET_C		0x1cc8
-#define R128_REG_PRIM_TEX_4_OFFSET_C		0x1ccc
-#define R128_REG_PRIM_TEX_5_OFFSET_C		0x1cd0
-#define R128_REG_PRIM_TEX_6_OFFSET_C		0x1cd4
-#define R128_REG_PRIM_TEX_7_OFFSET_C		0x1cd8
-#define R128_REG_PRIM_TEX_8_OFFSET_C		0x1cdc
-#define R128_REG_PRIM_TEX_9_OFFSET_C		0x1ce0
-#define R128_REG_PRIM_TEX_10_OFFSET_C		0x1ce4
-#define R128_REG_SEC_TEX_0_OFFSET_C		0x1d08
-#define R128_REG_SEC_TEX_1_OFFSET_C		0x1d0c
-#define R128_REG_SEC_TEX_2_OFFSET_C		0x1d10
-#define R128_REG_SEC_TEX_3_OFFSET_C		0x1d14
-#define R128_REG_SEC_TEX_4_OFFSET_C		0x1d18
-#define R128_REG_SEC_TEX_5_OFFSET_C		0x1d1c
-#define R128_REG_SEC_TEX_6_OFFSET_C		0x1d20
-#define R128_REG_SEC_TEX_7_OFFSET_C		0x1d24
-#define R128_REG_SEC_TEX_8_OFFSET_C		0x1d28
-#define R128_REG_SEC_TEX_9_OFFSET_C		0x1d2c
-#define R128_REG_SEC_TEX_10_OFFSET_C		0x1d30
-# define R128_TEX_NO_TILE			(0 << 30)
-# define R128_TEX_TILED_BY_HOST			(1 << 30)
-# define R128_TEX_TILED_BY_STORAGE		(2 << 30)
-# define R128_TEX_TILED_BY_STORAGE2		(3 << 30)
-#define R128_REG_CONSTANT_COLOR_C		0x1d34
-# define R128_CONSTANT_BLUE_SHIFT		0
-# define R128_CONSTANT_GREEN_SHIFT		8
-# define R128_CONSTANT_RED_SHIFT		16
-# define R128_CONSTANT_ALPHA_SHIFT		24
-
-#define RADEON_REG_PP_TEX_SIZE_0		0x1d04  /* NPOT */
-#define RADEON_REG_PP_TEX_SIZE_1		0x1d0c  /* NPOT */
-#define RADEON_REG_PP_TEX_SIZE_2		0x1d14  /* NPOT */
-# define RADEON_TEX_USIZE_MASK			(0x7ff << 0)
-# define RADEON_TEX_USIZE_SHIFT			0
-# define RADEON_TEX_VSIZE_MASK			(0x7ff << 16)
-# define RADEON_TEX_VSIZE_SHIFT			16
-# define RADEON_SIGNED_RGB_MASK			(1 << 30)
-# define RADEON_SIGNED_RGB_SHIFT		30
-# define RADEON_SIGNED_ALPHA_MASK		(1 << 31)
-# define RADEON_SIGNED_ALPHA_SHIFT		31
-
-#define RADEON_REG_PP_TEX_PITCH_0		0x1d08  /* NPOT */
-#define RADEON_REG_PP_TEX_PITCH_1		0x1d10  /* NPOT */
-#define RADEON_REG_PP_TEX_PITCH_2		0x1d18  /* NPOT */
-/* note: bits 13-5: 32 byte aligned stride of texture map */
-
-#define R128_REG_PLANE_3D_MASK_C			0x1d44
-
-#define RADEON_REG_RB3D_PLANEMASK		0x1d84
-
-#define R200_REG_SE_VAP_CNTL			0x2080
-# define R200_VAP_TCL_ENABLE			0x00000001
-# define R200_VAP_SINGLE_BUF_STATE_ENABLE	0x00000010
-# define R200_VAP_FORCE_W_TO_ONE		0x00010000
-# define R200_VAP_D3D_TEX_DEFAULT		0x00020000
-# define R200_VAP_VF_MAX_VTX_NUM__SHIFT		18
-# define R200_VAP_VF_MAX_VTX_NUM		(9 << 18)
-# define R200_VAP_DX_CLIP_SPACE_DEF		0x00400000
-
-#define R200_REG_SE_VTX_FMT_0			0x2088
-# define R200_VTX_XY				0 /* always have xy */
-# define R200_VTX_Z0				(1 <<  0)
-# define R200_VTX_W0				(1 <<  1)
-# define R200_VTX_WEIGHT_COUNT_SHIFT		(2)
-# define R200_VTX_PV_MATRIX_SEL			(1 <<  5)
-# define R200_VTX_N0				(1 <<  6)
-# define R200_VTX_POINT_SIZE			(1 <<  7)
-# define R200_VTX_DISCRETE_FOG			(1 <<  8)
-# define R200_VTX_SHININESS_0			(1 <<  9)
-# define R200_VTX_SHININESS_1			(1 << 10)
-# define   R200_VTX_COLOR_NOT_PRESENT		0
-# define   R200_VTX_PK_RGBA			1
-# define   R200_VTX_FP_RGB			2
-# define   R200_VTX_FP_RGBA			3
-# define   R200_VTX_COLOR_MASK			3
-# define R200_VTX_COLOR_0_SHIFT			11
-# define R200_VTX_COLOR_1_SHIFT			13
-# define R200_VTX_COLOR_2_SHIFT			15
-# define R200_VTX_COLOR_3_SHIFT			17
-# define R200_VTX_COLOR_4_SHIFT			19
-# define R200_VTX_COLOR_5_SHIFT			21
-# define R200_VTX_COLOR_6_SHIFT			23
-# define R200_VTX_COLOR_7_SHIFT			25
-# define R200_VTX_XY1				(1 << 28)
-# define R200_VTX_Z1				(1 << 29)
-# define R200_VTX_W1				(1 << 30)
-# define R200_VTX_N1				(1 << 31)
-
-#define R200_REG_SE_VTX_FMT_1			0x208c
-# define R200_VTX_TEX0_COMP_CNT_SHIFT		0
-# define R200_VTX_TEX1_COMP_CNT_SHIFT		3
-# define R200_VTX_TEX2_COMP_CNT_SHIFT		6
-# define R200_VTX_TEX3_COMP_CNT_SHIFT		9
-# define R200_VTX_TEX4_COMP_CNT_SHIFT		12
-# define R200_VTX_TEX5_COMP_CNT_SHIFT		15
-
-#define R200_REG_SE_VTE_CNTL			0x20b0
-# define R200_VPORT_X_SCALE_ENA			0x00000001
-# define R200_VPORT_X_OFFSET_ENA		0x00000002
-# define R200_VPORT_Y_SCALE_ENA			0x00000004
-# define R200_VPORT_Y_OFFSET_ENA		0x00000008
-# define R200_VPORT_Z_SCALE_ENA			0x00000010
-# define R200_VPORT_Z_OFFSET_ENA		0x00000020
-# define R200_VTX_XY_FMT			0x00000100
-# define R200_VTX_Z_FMT				0x00000200
-# define R200_VTX_W0_FMT			0x00000400
-# define R200_VTX_W0_NORMALIZE			0x00000800
-# define R200_VTX_ST_DENORMALIZED		0x00001000
-
-#define R200_REG_SE_VAP_CNTL_STATUS		0x2140
-#define RADEON_REG_SE_CNTL_STATUS		0x2140
-# define RADEON_VC_NO_SWAP			(0 << 0)
-# define RADEON_VC_16BIT_SWAP			(1 << 0)
-# define RADEON_VC_32BIT_SWAP			(2 << 0)
-# define RADEON_VC_HALF_DWORD_SWAP		(3 << 0)
-# define RADEON_TCL_BYPASS			(1 << 8)
-
-#define R200_REG_SE_VTX_STATE_CNTL		0x2180
-
-#define RADEON_REG_RE_TOP_LEFT			0x26c0
-
-#define R200_REG_RE_AUX_SCISSOR_CNTL		0x26f0
-
-#define R200_REG_PP_TXFILTER_0			0x2c00
-#define R200_REG_PP_TXFILTER_1			0x2c20 
-#define R200_REG_PP_TXFILTER_2			0x2c40 
-#define R200_REG_PP_TXFILTER_3			0x2c60 
-#define R200_REG_PP_TXFILTER_4			0x2c80 
-#define R200_REG_PP_TXFILTER_5			0x2ca0 
-# define R200_MAG_FILTER_NEAREST		(0  <<  0)
-# define R200_MAG_FILTER_LINEAR			(1  <<  0)
-# define R200_MAG_FILTER_MASK			(1  <<  0)
-# define R200_MIN_FILTER_NEAREST		(0  <<  1)
-# define R200_MIN_FILTER_LINEAR			(1  <<  1)
-# define R200_MIN_FILTER_NEAREST_MIP_NEAREST	(2  <<  1)
-# define R200_MIN_FILTER_NEAREST_MIP_LINEAR	(3  <<  1)
-# define R200_MIN_FILTER_LINEAR_MIP_NEAREST	(6  <<  1)
-# define R200_MIN_FILTER_LINEAR_MIP_LINEAR	(7  <<  1)
-# define R200_MIN_FILTER_ANISO_NEAREST		(8  <<  1)
-# define R200_MIN_FILTER_ANISO_LINEAR		(9  <<  1)
-# define R200_MIN_FILTER_ANISO_NEAREST_MIP_NEAREST (10 <<  1)
-# define R200_MIN_FILTER_ANISO_NEAREST_MIP_LINEAR (11 <<  1)
-# define R200_MIN_FILTER_MASK			(15 <<  1)
-# define R200_MAX_ANISO_1_TO_1			(0  <<  5)
-# define R200_MAX_ANISO_2_TO_1			(1  <<  5)
-# define R200_MAX_ANISO_4_TO_1			(2  <<  5)
-# define R200_MAX_ANISO_8_TO_1			(3  <<  5)
-# define R200_MAX_ANISO_16_TO_1			(4  <<  5)
-# define R200_MAX_ANISO_MASK			(7  <<  5)
-# define R200_MAX_MIP_LEVEL_MASK		(0x0f << 16)
-# define R200_MAX_MIP_LEVEL_SHIFT		16
-# define R200_YUV_TO_RGB			(1  << 20)
-# define R200_YUV_TEMPERATURE_COOL		(0  << 21)
-# define R200_YUV_TEMPERATURE_HOT		(1  << 21)
-# define R200_YUV_TEMPERATURE_MASK		(1  << 21)
-# define R200_WRAPEN_S				(1  << 22)
-# define R200_CLAMP_S_WRAP			(0  << 23)
-# define R200_CLAMP_S_MIRROR			(1  << 23)
-# define R200_CLAMP_S_CLAMP_LAST		(2  << 23)
-# define R200_CLAMP_S_MIRROR_CLAMP_LAST		(3  << 23)
-# define R200_CLAMP_S_CLAMP_BORDER		(4  << 23)
-# define R200_CLAMP_S_MIRROR_CLAMP_BORDER	(5  << 23)
-# define R200_CLAMP_S_CLAMP_GL			(6  << 23)
-# define R200_CLAMP_S_MIRROR_CLAMP_GL		(7  << 23)
-# define R200_CLAMP_S_MASK			(7  << 23)
-# define R200_WRAPEN_T				(1  << 26)
-# define R200_CLAMP_T_WRAP			(0  << 27)
-# define R200_CLAMP_T_MIRROR			(1  << 27)
-# define R200_CLAMP_T_CLAMP_LAST		(2  << 27)
-# define R200_CLAMP_T_MIRROR_CLAMP_LAST		(3  << 27)
-# define R200_CLAMP_T_CLAMP_BORDER		(4  << 27)
-# define R200_CLAMP_T_MIRROR_CLAMP_BORDER	(5  << 27)
-# define R200_CLAMP_T_CLAMP_GL			(6  << 27)
-# define R200_CLAMP_T_MIRROR_CLAMP_GL		(7  << 27)
-# define R200_CLAMP_T_MASK			(7  << 27)
-# define R200_KILL_LT_ZERO			(1  << 30)
-# define R200_BORDER_MODE_OGL			(0  << 31)
-# define R200_BORDER_MODE_D3D			(1  << 31)
-
-#define R200_REG_PP_TXFORMAT_0			0x2c04
-#define R200_REG_PP_TXFORMAT_1			0x2c24
-#define R200_REG_PP_TXFORMAT_2			0x2c44
-#define R200_REG_PP_TXFORMAT_3			0x2c64
-#define R200_REG_PP_TXFORMAT_4			0x2c84
-#define R200_REG_PP_TXFORMAT_5			0x2ca4
-# define R200_TXFORMAT_I8			(0 << 0)
-# define R200_TXFORMAT_AI88			(1 << 0)
-# define R200_TXFORMAT_RGB332			(2 << 0)
-# define R200_TXFORMAT_ARGB1555			(3 << 0)
-# define R200_TXFORMAT_RGB565			(4 << 0)
-# define R200_TXFORMAT_ARGB4444			(5 << 0)
-# define R200_TXFORMAT_ARGB8888			(6 << 0)
-# define R200_TXFORMAT_RGBA8888			(7 << 0)
-# define R200_TXFORMAT_Y8			(8 << 0)
-# define R200_TXFORMAT_AVYU4444			(9 << 0)
-# define R200_TXFORMAT_VYUY422			(10 << 0)
-# define R200_TXFORMAT_YVYU422			(11 << 0)
-# define R200_TXFORMAT_DXT1			(12 << 0)
-# define R200_TXFORMAT_DXT23			(14 << 0)
-# define R200_TXFORMAT_DXT45			(15 << 0)
-# define R200_TXFORMAT_FORMAT_MASK		(31 <<	0)
-# define R200_TXFORMAT_FORMAT_SHIFT		0
-# define R200_TXFORMAT_ALPHA_IN_MAP		(1 << 6)
-# define R200_TXFORMAT_NON_POWER2		(1 << 7)
-# define R200_TXFORMAT_WIDTH_MASK		(15 <<	8)
-# define R200_TXFORMAT_WIDTH_SHIFT		8
-# define R200_TXFORMAT_HEIGHT_MASK		(15 << 12)
-# define R200_TXFORMAT_HEIGHT_SHIFT		12
-# define R200_TXFORMAT_F5_WIDTH_MASK		(15 << 16)	/* cube face 5 */
-# define R200_TXFORMAT_F5_WIDTH_SHIFT		16
-# define R200_TXFORMAT_F5_HEIGHT_MASK		(15 << 20)
-# define R200_TXFORMAT_F5_HEIGHT_SHIFT		20
-# define R200_TXFORMAT_ST_ROUTE_STQ0		(0 << 24)
-# define R200_TXFORMAT_ST_ROUTE_STQ1		(1 << 24)
-# define R200_TXFORMAT_ST_ROUTE_STQ2		(2 << 24)
-# define R200_TXFORMAT_ST_ROUTE_STQ3		(3 << 24)
-# define R200_TXFORMAT_ST_ROUTE_STQ4		(4 << 24)
-# define R200_TXFORMAT_ST_ROUTE_STQ5		(5 << 24)
-# define R200_TXFORMAT_ST_ROUTE_MASK		(7 << 24)
-# define R200_TXFORMAT_ST_ROUTE_SHIFT		24
-# define R200_TXFORMAT_ALPHA_MASK_ENABLE	(1 << 28)
-# define R200_TXFORMAT_CHROMA_KEY_ENABLE	(1 << 29)
-# define R200_TXFORMAT_CUBIC_MAP_ENABLE		(1 << 30)
-
-#define R200_REG_PP_TXFORMAT_X_0		0x2c08
-#define R200_REG_PP_TXFORMAT_X_1		0x2c28
-#define R200_REG_PP_TXFORMAT_X_2		0x2c48
-#define R200_REG_PP_TXFORMAT_X_3		0x2c68
-#define R200_REG_PP_TXFORMAT_X_4		0x2c88
-#define R200_REG_PP_TXFORMAT_X_5		0x2ca8
-# define R200_DEPTH_LOG2_MASK			(0xf << 0)
-# define R200_DEPTH_LOG2_SHIFT			0
-# define R200_VOLUME_FILTER_SHIFT		4
-# define R200_VOLUME_FILTER_MASK		(1 << 4)
-# define R200_VOLUME_FILTER_NEAREST		(0 << 4)
-# define R200_VOLUME_FILTER_LINEAR		(1 << 4)
-# define R200_WRAPEN_Q				(1 << 8)
-# define R200_CLAMP_Q_WRAP			(0 << 9)
-# define R200_CLAMP_Q_MIRROR			(1 << 9)
-# define R200_CLAMP_Q_CLAMP_LAST		(2 << 9)
-# define R200_CLAMP_Q_MIRROR_CLAMP_LAST		(3 << 9)
-# define R200_CLAMP_Q_CLAMP_BORDER		(4 << 9)
-# define R200_CLAMP_Q_MIRROR_CLAMP_BORDER	(5 << 9)
-# define R200_CLAMP_Q_CLAMP_GL			(6 << 9)
-# define R200_CLAMP_Q_MIRROR_CLAMP_GL		(7 << 9)
-# define R200_CLAMP_Q_MASK			(7 << 9)
-# define R200_MIN_MIP_LEVEL_MASK		(0xff << 12)
-# define R200_MIN_MIP_LEVEL_SHIFT		12
-# define R200_TEXCOORD_NONPROJ			(0 << 16)
-# define R200_TEXCOORD_CUBIC_ENV		(1 << 16)
-# define R200_TEXCOORD_VOLUME			(2 << 16)
-# define R200_TEXCOORD_PROJ			(3 << 16)
-# define R200_TEXCOORD_DEPTH			(4 << 16)
-# define R200_TEXCOORD_1D_PROJ			(5 << 16)
-# define R200_TEXCOORD_1D			(6 << 16)
-# define R200_TEXCOORD_ZERO			(7 << 16)
-# define R200_TEXCOORD_MASK			(7 << 16)
-# define R200_LOD_BIAS_MASK			(0xfff80000)
-# define R200_LOD_BIAS_SHIFT			19
-
-#define R200_REG_PP_TXSIZE_0			0x2c0c /* NPOT only */
-#define R200_REG_PP_TXSIZE_1			0x2c2c /* NPOT only */
-#define R200_REG_PP_TXSIZE_2			0x2c4c /* NPOT only */
-#define R200_REG_PP_TXSIZE_3			0x2c6c /* NPOT only */
-#define R200_REG_PP_TXSIZE_4			0x2c8c /* NPOT only */
-#define R200_REG_PP_TXSIZE_5			0x2cac /* NPOT only */
-
-#define R200_REG_PP_TXPITCH_0			0x2c10 /* NPOT only */
-#define R200_REG_PP_TXPITCH_1			0x2c30 /* NPOT only */
-#define R200_REG_PP_TXPITCH_2			0x2c50 /* NPOT only */
-#define R200_REG_PP_TXPITCH_3			0x2c70 /* NPOT only */
-#define R200_REG_PP_TXPITCH_4			0x2c90 /* NPOT only */
-#define R200_REG_PP_TXPITCH_5			0x2cb0 /* NPOT only */
-
-#define R200_REG_PP_BORDER_COLOR_0		0x2c14
-#define R200_REG_PP_TXMULTI_CTL_0		0x2c1c
-
-#define R200_REG_PP_CNTL_X			0x2cc4
-
-#define R200_PP_TXOFFSET_0			0x2d00
-#define R200_PP_TXOFFSET_1			0x2d18
-#define R200_PP_TXOFFSET_2			0x2d30
-#define R200_PP_TXOFFSET_3			0x2d48
-#define R200_PP_TXOFFSET_4			0x2d60
-#define R200_PP_TXOFFSET_5			0x2d78
-# define R200_TXO_ENDIAN_NO_SWAP		(0 << 0)
-# define R200_TXO_ENDIAN_BYTE_SWAP		(1 << 0)
-# define R200_TXO_ENDIAN_WORD_SWAP		(2 << 0)
-# define R200_TXO_ENDIAN_HALFDW_SWAP		(3 << 0)
-# define R200_TXO_OFFSET_MASK			0xffffffe0
-# define R200_TXO_OFFSET_SHIFT			5
-
-#define R200_PP_CUBIC_OFFSET_F1_0		0x2d04
-#define R200_PP_CUBIC_OFFSET_F2_0		0x2d08
-#define R200_PP_CUBIC_OFFSET_F3_0		0x2d0c
-#define R200_PP_CUBIC_OFFSET_F4_0		0x2d10
-#define R200_PP_CUBIC_OFFSET_F5_0		0x2d14
-#define R200_PP_CUBIC_OFFSET_F1_1		0x2d1c
-#define R200_PP_CUBIC_OFFSET_F2_1		0x2d20
-#define R200_PP_CUBIC_OFFSET_F3_1		0x2d24
-#define R200_PP_CUBIC_OFFSET_F4_1		0x2d28
-#define R200_PP_CUBIC_OFFSET_F5_1		0x2d2c
-#define R200_PP_CUBIC_OFFSET_F1_2		0x2d34
-#define R200_PP_CUBIC_OFFSET_F2_2		0x2d38
-#define R200_PP_CUBIC_OFFSET_F3_2		0x2d3c
-#define R200_PP_CUBIC_OFFSET_F4_2		0x2d40
-#define R200_PP_CUBIC_OFFSET_F5_2		0x2d44
-#define R200_PP_CUBIC_OFFSET_F1_3		0x2d4c
-#define R200_PP_CUBIC_OFFSET_F2_3		0x2d50
-#define R200_PP_CUBIC_OFFSET_F3_3		0x2d54
-#define R200_PP_CUBIC_OFFSET_F4_3		0x2d58
-#define R200_PP_CUBIC_OFFSET_F5_3		0x2d5c
-#define R200_PP_CUBIC_OFFSET_F1_4		0x2d64
-#define R200_PP_CUBIC_OFFSET_F2_4		0x2d68
-#define R200_PP_CUBIC_OFFSET_F3_4		0x2d6c
-#define R200_PP_CUBIC_OFFSET_F4_4		0x2d70
-#define R200_PP_CUBIC_OFFSET_F5_4		0x2d74
-#define R200_PP_CUBIC_OFFSET_F1_5		0x2d7c
-#define R200_PP_CUBIC_OFFSET_F2_5		0x2d80
-#define R200_PP_CUBIC_OFFSET_F3_5		0x2d84
-#define R200_PP_CUBIC_OFFSET_F4_5		0x2d88
-#define R200_PP_CUBIC_OFFSET_F5_5		0x2d8c
-
-/* AKA PIXSHADER_I0_C0 */
-#define R200_REG_PP_TXCBLEND_0			0x2f00
-# define R200_TXC_ARG_A_ZERO			(0)
-# define R200_TXC_ARG_A_CURRENT_COLOR		(2)
-# define R200_TXC_ARG_A_CURRENT_ALPHA		(3)
-# define R200_TXC_ARG_A_DIFFUSE_COLOR		(4)
-# define R200_TXC_ARG_A_DIFFUSE_ALPHA		(5)
-# define R200_TXC_ARG_A_SPECULAR_COLOR		(6)
-# define R200_TXC_ARG_A_SPECULAR_ALPHA		(7)
-# define R200_TXC_ARG_A_TFACTOR_COLOR		(8)
-# define R200_TXC_ARG_A_TFACTOR_ALPHA		(9)
-# define R200_TXC_ARG_A_R0_COLOR		(10)
-# define R200_TXC_ARG_A_R0_ALPHA		(11)
-# define R200_TXC_ARG_A_R1_COLOR		(12)
-# define R200_TXC_ARG_A_R1_ALPHA		(13)
-# define R200_TXC_ARG_A_R2_COLOR		(14)
-# define R200_TXC_ARG_A_R2_ALPHA		(15)
-# define R200_TXC_ARG_A_R3_COLOR		(16)
-# define R200_TXC_ARG_A_R3_ALPHA		(17)
-# define R200_TXC_ARG_A_R4_COLOR		(18)
-# define R200_TXC_ARG_A_R4_ALPHA		(19)
-# define R200_TXC_ARG_A_R5_COLOR		(20)
-# define R200_TXC_ARG_A_R5_ALPHA		(21)
-# define R200_TXC_ARG_A_TFACTOR1_COLOR		(26)
-# define R200_TXC_ARG_A_TFACTOR1_ALPHA		(27)
-# define R200_TXC_ARG_A_MASK			(31 << 0)
-# define R200_TXC_ARG_A_SHIFT			0
-# define R200_TXC_ARG_B_ZERO			(0 << 5)
-# define R200_TXC_ARG_B_CURRENT_COLOR		(2 << 5)
-# define R200_TXC_ARG_B_CURRENT_ALPHA		(3 << 5)
-# define R200_TXC_ARG_B_DIFFUSE_COLOR		(4 << 5)
-# define R200_TXC_ARG_B_DIFFUSE_ALPHA		(5 << 5)
-# define R200_TXC_ARG_B_SPECULAR_COLOR		(6 << 5)
-# define R200_TXC_ARG_B_SPECULAR_ALPHA		(7 << 5)
-# define R200_TXC_ARG_B_TFACTOR_COLOR		(8 << 5)
-# define R200_TXC_ARG_B_TFACTOR_ALPHA		(9 << 5)
-# define R200_TXC_ARG_B_R0_COLOR		(10 << 5)
-# define R200_TXC_ARG_B_R0_ALPHA		(11 << 5)
-# define R200_TXC_ARG_B_R1_COLOR		(12 << 5)
-# define R200_TXC_ARG_B_R1_ALPHA		(13 << 5)
-# define R200_TXC_ARG_B_R2_COLOR		(14 << 5)
-# define R200_TXC_ARG_B_R2_ALPHA		(15 << 5)
-# define R200_TXC_ARG_B_R3_COLOR		(16 << 5)
-# define R200_TXC_ARG_B_R3_ALPHA		(17 << 5)
-# define R200_TXC_ARG_B_R4_COLOR		(18 << 5)
-# define R200_TXC_ARG_B_R4_ALPHA		(19 << 5)
-# define R200_TXC_ARG_B_R5_COLOR		(20 << 5)
-# define R200_TXC_ARG_B_R5_ALPHA		(21 << 5)
-# define R200_TXC_ARG_B_TFACTOR1_COLOR		(26 << 5)
-# define R200_TXC_ARG_B_TFACTOR1_ALPHA		(27 << 5)
-# define R200_TXC_ARG_B_MASK			(31 << 5)
-# define R200_TXC_ARG_B_SHIFT			5
-# define R200_TXC_ARG_C_ZERO			(0 << 10)
-# define R200_TXC_ARG_C_CURRENT_COLOR		(2 << 10)
-# define R200_TXC_ARG_C_CURRENT_ALPHA		(3 << 10)
-# define R200_TXC_ARG_C_DIFFUSE_COLOR		(4 << 10)
-# define R200_TXC_ARG_C_DIFFUSE_ALPHA		(5 << 10)
-# define R200_TXC_ARG_C_SPECULAR_COLOR		(6 << 10)
-# define R200_TXC_ARG_C_SPECULAR_ALPHA		(7 << 10)
-# define R200_TXC_ARG_C_TFACTOR_COLOR		(8 << 10)
-# define R200_TXC_ARG_C_TFACTOR_ALPHA		(9 << 10)
-# define R200_TXC_ARG_C_R0_COLOR		(10 << 10)
-# define R200_TXC_ARG_C_R0_ALPHA		(11 << 10)
-# define R200_TXC_ARG_C_R1_COLOR		(12 << 10)
-# define R200_TXC_ARG_C_R1_ALPHA		(13 << 10)
-# define R200_TXC_ARG_C_R2_COLOR		(14 << 10)
-# define R200_TXC_ARG_C_R2_ALPHA		(15 << 10)
-# define R200_TXC_ARG_C_R3_COLOR		(16 << 10)
-# define R200_TXC_ARG_C_R3_ALPHA		(17 << 10)
-# define R200_TXC_ARG_C_R4_COLOR		(18 << 10)
-# define R200_TXC_ARG_C_R4_ALPHA		(19 << 10)
-# define R200_TXC_ARG_C_R5_COLOR		(20 << 10)
-# define R200_TXC_ARG_C_R5_ALPHA		(21 << 10)
-# define R200_TXC_ARG_C_TFACTOR1_COLOR		(26 << 10)
-# define R200_TXC_ARG_C_TFACTOR1_ALPHA		(27 << 10)
-# define R200_TXC_ARG_C_MASK			(31 << 10)
-# define R200_TXC_ARG_C_SHIFT			10
-# define R200_TXC_COMP_ARG_A			(1 << 16)
-# define R200_TXC_COMP_ARG_A_SHIFT		(16)
-# define R200_TXC_BIAS_ARG_A			(1 << 17)
-# define R200_TXC_SCALE_ARG_A			(1 << 18)
-# define R200_TXC_NEG_ARG_A			(1 << 19)
-# define R200_TXC_COMP_ARG_B			(1 << 20)
-# define R200_TXC_COMP_ARG_B_SHIFT		(20)
-# define R200_TXC_BIAS_ARG_B			(1 << 21)
-# define R200_TXC_SCALE_ARG_B			(1 << 22)
-# define R200_TXC_NEG_ARG_B			(1 << 23)
-# define R200_TXC_COMP_ARG_C			(1 << 24)
-# define R200_TXC_COMP_ARG_C_SHIFT		(24)
-# define R200_TXC_BIAS_ARG_C			(1 << 25)
-# define R200_TXC_SCALE_ARG_C			(1 << 26)
-# define R200_TXC_NEG_ARG_C			(1 << 27)
-# define R200_TXC_OP_MADD			(0 << 28)
-# define R200_TXC_OP_CND0			(2 << 28)
-# define R200_TXC_OP_LERP			(3 << 28)
-# define R200_TXC_OP_DOT3			(4 << 28)
-# define R200_TXC_OP_DOT4			(5 << 28)
-# define R200_TXC_OP_CONDITIONAL		(6 << 28)
-# define R200_TXC_OP_DOT2_ADD			(7 << 28)
-# define R200_TXC_OP_MASK			(7 << 28)
-
-/* AKA PIXSHADER_I0_C1 */
-#define R200_REG_PP_TXCBLEND2_0			0x2f04
-# define R200_TXC_TFACTOR_SEL_SHIFT		0
-# define R200_TXC_TFACTOR_SEL_MASK		0x7
-# define R200_TXC_TFACTOR1_SEL_SHIFT		4
-# define R200_TXC_TFACTOR1_SEL_MASK		(0x7 << 4)
-# define R200_TXC_SCALE_SHIFT			8
-# define R200_TXC_SCALE_MASK			(7 << 8)
-# define R200_TXC_SCALE_1X			(0 << 8)
-# define R200_TXC_SCALE_2X			(1 << 8)
-# define R200_TXC_SCALE_4X			(2 << 8)
-# define R200_TXC_SCALE_8X			(3 << 8)
-# define R200_TXC_SCALE_INV2			(5 << 8)
-# define R200_TXC_SCALE_INV4			(6 << 8)
-# define R200_TXC_SCALE_INV8			(7 << 8)
-# define R200_TXC_CLAMP_SHIFT			12
-# define R200_TXC_CLAMP_MASK			(3 << 12)
-# define R200_TXC_CLAMP_WRAP			(0 << 12)
-# define R200_TXC_CLAMP_0_1			(1 << 12)
-# define R200_TXC_CLAMP_8_8			(2 << 12)
-# define R200_TXC_OUTPUT_REG_MASK		(7 << 16)
-# define R200_TXC_OUTPUT_REG_NONE		(0 << 16)
-# define R200_TXC_OUTPUT_REG_R0			(1 << 16)
-# define R200_TXC_OUTPUT_REG_R1			(2 << 16)
-# define R200_TXC_OUTPUT_REG_R2			(3 << 16)
-# define R200_TXC_OUTPUT_REG_R3			(4 << 16)
-# define R200_TXC_OUTPUT_REG_R4			(5 << 16)
-# define R200_TXC_OUTPUT_REG_R5			(6 << 16)
-# define R200_TXC_OUTPUT_MASK_MASK		(7 << 20)
-# define R200_TXC_OUTPUT_MASK_RGB		(0 << 20)
-# define R200_TXC_OUTPUT_MASK_RG		(1 << 20)
-# define R200_TXC_OUTPUT_MASK_RB		(2 << 20)
-# define R200_TXC_OUTPUT_MASK_R			(3 << 20)
-# define R200_TXC_OUTPUT_MASK_GB		(4 << 20)
-# define R200_TXC_OUTPUT_MASK_G			(5 << 20)
-# define R200_TXC_OUTPUT_MASK_B			(6 << 20)
-# define R200_TXC_OUTPUT_MASK_NONE		(7 << 20)
-# define R200_TXC_REPL_NORMAL			0
-# define R200_TXC_REPL_RED			1
-# define R200_TXC_REPL_GREEN			2
-# define R200_TXC_REPL_BLUE			3
-# define R200_TXC_REPL_ARG_A_SHIFT		26
-# define R200_TXC_REPL_ARG_A_MASK		(3 << 26)
-# define R200_TXC_REPL_ARG_B_SHIFT		28
-# define R200_TXC_REPL_ARG_B_MASK		(3 << 28)
-# define R200_TXC_REPL_ARG_C_SHIFT		30
-# define R200_TXC_REPL_ARG_C_MASK		(3 << 30)
-
-/* AKA PIXSHADER_I0_A0 */
-#define R200_REG_PP_TXABLEND_0			0x2f08
-# define R200_TXA_ARG_A_ZERO			(0)
-# define R200_TXA_ARG_A_CURRENT_ALPHA		(2) /* guess */
-# define R200_TXA_ARG_A_CURRENT_BLUE		(3) /* guess */
-# define R200_TXA_ARG_A_DIFFUSE_ALPHA		(4)
-# define R200_TXA_ARG_A_DIFFUSE_BLUE		(5)
-# define R200_TXA_ARG_A_SPECULAR_ALPHA		(6)
-# define R200_TXA_ARG_A_SPECULAR_BLUE		(7)
-# define R200_TXA_ARG_A_TFACTOR_ALPHA		(8)
-# define R200_TXA_ARG_A_TFACTOR_BLUE		(9)
-# define R200_TXA_ARG_A_R0_ALPHA		(10)
-# define R200_TXA_ARG_A_R0_BLUE			(11)
-# define R200_TXA_ARG_A_R1_ALPHA		(12)
-# define R200_TXA_ARG_A_R1_BLUE			(13)
-# define R200_TXA_ARG_A_R2_ALPHA		(14)
-# define R200_TXA_ARG_A_R2_BLUE			(15)
-# define R200_TXA_ARG_A_R3_ALPHA		(16)
-# define R200_TXA_ARG_A_R3_BLUE			(17)
-# define R200_TXA_ARG_A_R4_ALPHA		(18)
-# define R200_TXA_ARG_A_R4_BLUE			(19)
-# define R200_TXA_ARG_A_R5_ALPHA		(20)
-# define R200_TXA_ARG_A_R5_BLUE			(21)
-# define R200_TXA_ARG_A_TFACTOR1_ALPHA		(26)
-# define R200_TXA_ARG_A_TFACTOR1_BLUE		(27)
-# define R200_TXA_ARG_A_MASK			(31 << 0)
-# define R200_TXA_ARG_A_SHIFT			0
-# define R200_TXA_ARG_B_ZERO			(0 << 5)
-# define R200_TXA_ARG_B_CURRENT_ALPHA		(2 << 5) /* guess */
-# define R200_TXA_ARG_B_CURRENT_BLUE		(3 << 5) /* guess */
-# define R200_TXA_ARG_B_DIFFUSE_ALPHA		(4 << 5)
-# define R200_TXA_ARG_B_DIFFUSE_BLUE		(5 << 5)
-# define R200_TXA_ARG_B_SPECULAR_ALPHA		(6 << 5)
-# define R200_TXA_ARG_B_SPECULAR_BLUE		(7 << 5)
-# define R200_TXA_ARG_B_TFACTOR_ALPHA		(8 << 5)
-# define R200_TXA_ARG_B_TFACTOR_BLUE		(9 << 5)
-# define R200_TXA_ARG_B_R0_ALPHA		(10 << 5)
-# define R200_TXA_ARG_B_R0_BLUE			(11 << 5)
-# define R200_TXA_ARG_B_R1_ALPHA		(12 << 5)
-# define R200_TXA_ARG_B_R1_BLUE			(13 << 5)
-# define R200_TXA_ARG_B_R2_ALPHA		(14 << 5)
-# define R200_TXA_ARG_B_R2_BLUE			(15 << 5)
-# define R200_TXA_ARG_B_R3_ALPHA		(16 << 5)
-# define R200_TXA_ARG_B_R3_BLUE			(17 << 5)
-# define R200_TXA_ARG_B_R4_ALPHA		(18 << 5)
-# define R200_TXA_ARG_B_R4_BLUE			(19 << 5)
-# define R200_TXA_ARG_B_R5_ALPHA		(20 << 5)
-# define R200_TXA_ARG_B_R5_BLUE			(21 << 5)
-# define R200_TXA_ARG_B_TFACTOR1_ALPHA		(26 << 5)
-# define R200_TXA_ARG_B_TFACTOR1_BLUE		(27 << 5)
-# define R200_TXA_ARG_B_MASK			(31 << 5)
-# define R200_TXA_ARG_B_SHIFT			5
-# define R200_TXA_ARG_C_ZERO			(0 << 10)
-# define R200_TXA_ARG_C_CURRENT_ALPHA		(2 << 10) /* guess */
-# define R200_TXA_ARG_C_CURRENT_BLUE		(3 << 10) /* guess */
-# define R200_TXA_ARG_C_DIFFUSE_ALPHA		(4 << 10)
-# define R200_TXA_ARG_C_DIFFUSE_BLUE		(5 << 10)
-# define R200_TXA_ARG_C_SPECULAR_ALPHA		(6 << 10)
-# define R200_TXA_ARG_C_SPECULAR_BLUE		(7 << 10)
-# define R200_TXA_ARG_C_TFACTOR_ALPHA		(8 << 10)
-# define R200_TXA_ARG_C_TFACTOR_BLUE		(9 << 10)
-# define R200_TXA_ARG_C_R0_ALPHA		(10 << 10)
-# define R200_TXA_ARG_C_R0_BLUE			(11 << 10)
-# define R200_TXA_ARG_C_R1_ALPHA		(12 << 10)
-# define R200_TXA_ARG_C_R1_BLUE			(13 << 10)
-# define R200_TXA_ARG_C_R2_ALPHA		(14 << 10)
-# define R200_TXA_ARG_C_R2_BLUE			(15 << 10)
-# define R200_TXA_ARG_C_R3_ALPHA		(16 << 10)
-# define R200_TXA_ARG_C_R3_BLUE			(17 << 10)
-# define R200_TXA_ARG_C_R4_ALPHA		(18 << 10)
-# define R200_TXA_ARG_C_R4_BLUE			(19 << 10)
-# define R200_TXA_ARG_C_R5_ALPHA		(20 << 10)
-# define R200_TXA_ARG_C_R5_BLUE			(21 << 10)
-# define R200_TXA_ARG_C_TFACTOR1_ALPHA		(26 << 10)
-# define R200_TXA_ARG_C_TFACTOR1_BLUE		(27 << 10)
-# define R200_TXA_ARG_C_MASK			(31 << 10)
-# define R200_TXA_ARG_C_SHIFT			10
-# define R200_TXA_COMP_ARG_A			(1 << 16)
-# define R200_TXA_COMP_ARG_A_SHIFT		(16)
-# define R200_TXA_BIAS_ARG_A			(1 << 17)
-# define R200_TXA_SCALE_ARG_A			(1 << 18)
-# define R200_TXA_NEG_ARG_A			(1 << 19)
-# define R200_TXA_COMP_ARG_B			(1 << 20)
-# define R200_TXA_COMP_ARG_B_SHIFT		(20)
-# define R200_TXA_BIAS_ARG_B			(1 << 21)
-# define R200_TXA_SCALE_ARG_B			(1 << 22)
-# define R200_TXA_NEG_ARG_B			(1 << 23)
-# define R200_TXA_COMP_ARG_C			(1 << 24)
-# define R200_TXA_COMP_ARG_C_SHIFT		(24)
-# define R200_TXA_BIAS_ARG_C			(1 << 25)
-# define R200_TXA_SCALE_ARG_C			(1 << 26)
-# define R200_TXA_NEG_ARG_C			(1 << 27)
-# define R200_TXA_OP_MADD			(0 << 28)
-# define R200_TXA_OP_CND0			(2 << 28)
-# define R200_TXA_OP_LERP			(3 << 28)
-# define R200_TXA_OP_CONDITIONAL		(6 << 28)
-# define R200_TXA_OP_MASK			(7 << 28)
-
-/* AKA PIXSHADER_I0_A1 */
-#define R200_REG_PP_TXABLEND2_0			0x2f0c
-# define R200_TXA_TFACTOR_SEL_SHIFT		0
-# define R200_TXA_TFACTOR_SEL_MASK		0x7
-# define R200_TXA_TFACTOR1_SEL_SHIFT		4
-# define R200_TXA_TFACTOR1_SEL_MASK		(0x7 << 4)
-# define R200_TXA_SCALE_SHIFT			8
-# define R200_TXA_SCALE_MASK			(7 << 8)
-# define R200_TXA_SCALE_1X			(0 << 8)
-# define R200_TXA_SCALE_2X			(1 << 8)
-# define R200_TXA_SCALE_4X			(2 << 8)
-# define R200_TXA_SCALE_8X			(3 << 8)
-# define R200_TXA_SCALE_INV2			(5 << 8)
-# define R200_TXA_SCALE_INV4			(6 << 8)
-# define R200_TXA_SCALE_INV8			(7 << 8)
-# define R200_TXA_CLAMP_SHIFT			12
-# define R200_TXA_CLAMP_MASK			(3 << 12)
-# define R200_TXA_CLAMP_WRAP			(0 << 12)
-# define R200_TXA_CLAMP_0_1			(1 << 12)
-# define R200_TXA_CLAMP_8_8			(2 << 12)
-# define R200_TXA_OUTPUT_REG_MASK		(7 << 16)
-# define R200_TXA_OUTPUT_REG_NONE		(0 << 16)
-# define R200_TXA_OUTPUT_REG_R0			(1 << 16)
-# define R200_TXA_OUTPUT_REG_R1			(2 << 16)
-# define R200_TXA_OUTPUT_REG_R2			(3 << 16)
-# define R200_TXA_OUTPUT_REG_R3			(4 << 16)
-# define R200_TXA_OUTPUT_REG_R4			(5 << 16)
-# define R200_TXA_OUTPUT_REG_R5			(6 << 16)
-# define R200_TXA_DOT_ALPHA			(1 << 20)
-# define R200_TXA_REPL_NORMAL			0
-# define R200_TXA_REPL_RED			1
-# define R200_TXA_REPL_GREEN			2
-# define R200_TXA_REPL_ARG_A_SHIFT		26
-# define R200_TXA_REPL_ARG_A_MASK		(3 << 26)
-# define R200_TXA_REPL_ARG_B_SHIFT		28
-# define R200_TXA_REPL_ARG_B_MASK		(3 << 28)
-# define R200_TXA_REPL_ARG_C_SHIFT		30
-# define R200_TXA_REPL_ARG_C_MASK		(3 << 30)
-
-#define RADEON_REG_RB2D_DSTCACHE_MODE		0x3428
-/* This is a read-only mirror of RADEON_REG_RB3D_DSTCACHE_MODE */
-
-#define RADEON_REG_RB2D_DSTCACHE_CTLSTAT	0x342C
-/* This is a read-only mirror of RADEON_REG_RB3D_DSTCACHE_CTLSTAT */
-
-#define RADEON_REG_RB3D_DSTCACHE_MODE		0x3258
-# define RADEON_RB3D_DC_CACHE_ENABLE		(0)
-# define RADEON_RB3D_DC_2D_CACHE_DISABLE	(1)
-# define RADEON_RB3D_DC_3D_CACHE_DISABLE	(2)
-# define RADEON_RB3D_DC_CACHE_DISABLE		(3)
-# define RADEON_RB3D_DC_2D_CACHE_LINESIZE_128	(1 << 2)
-# define RADEON_RB3D_DC_3D_CACHE_LINESIZE_128	(2 << 2)
-# define RADEON_RB3D_DC_2D_CACHE_AUTOFLUSH	(1 << 8)
-# define RADEON_RB3D_DC_3D_CACHE_AUTOFLUSH	(2 << 8)
-# define R200_RB3D_DC_2D_CACHE_AUTOFREE		(1 << 10)
-# define R200_RB3D_DC_3D_CACHE_AUTOFREE		(2 << 10)
-# define RADEON_RB3D_DC_FORCE_RMW		(1 << 16)
-# define RADEON_RB3D_DC_DISABLE_RI_FILL		(1 << 24)
-# define RADEON_RB3D_DC_DISABLE_RI_READ		(1 << 25)
-# define RADEON_RB3D_DC_DISABLE_MASK_CHK	(1 << 26)
-
-#define RADEON_REG_RB3D_DSTCACHE_CTLSTAT	0x325C
-# define RADEON_RB3D_DC_FLUSH			(3 << 0)
-# define RADEON_RB3D_DC_FREE			(3 << 2)
-# define RADEON_RB3D_DC_FLUSH_ALL		0xf
-# define RADEON_RB3D_DC_BUSY			(1 << 31)
-
-/* PLL register defines */
-#define R128_REG_MCLK_CNTL			0x000f
-# define R128_FORCE_GCP				(1 << 16)
-# define R128_FORCE_PIPE3D_CP			(1 << 17)
-# define R128_FORCE_RCP				(1 << 18)
-#define RADEON_REG_MCLK_CNTL			0x0012
-# define RADEON_FORCEON_MCLKA			(1 << 16)
-# define RADEON_FORCEON_MCLKB			(1 << 17)
-# define RADEON_FORCEON_YCLKA			(1 << 18)
-# define RADEON_FORCEON_YCLKB			(1 << 19)
-# define RADEON_FORCEON_MC			(1 << 20)
-# define RADEON_FORCEON_AIC			(1 << 21)
-
-/* CCE packet defines */
-
-#define ATI_CCE_PACKETTYPE_MASK			0xc0000000
-#define ATI_CCE_PACKET0				0x00000000
-#define ATI_CCE_PACKET0_COUNT_MASK		0x3fff0000
-#define ATI_CCE_PACKET0_ONE_REG_WR		0x00008000
-#define ATI_CCE_PACKET0_REG_MASK		0x000007ff
-#define ATI_CCE_PACKET1				0x40000000
-#define ATI_CCE_PACKET1_REG_1			0x000007ff
-#define ATI_CCE_PACKET1_REG_2			0x003ff800
-#define ATI_CCE_PACKET1_REG_2_SHIFT		10
-#define ATI_CCE_PACKET2				0x80000000
-#define ATI_CCE_PACKET3				0xc0000000
-#define ATI_CCE_PACKET3_COUNT_MASK		0x3fff0000
-#define ATI_CCE_PACKET3_IT_OPCODE_MASK		0x0000ff00
-#define ATI_CCE_PACKET3_NOP			0xc0001000
-#define ATI_CCE_PACKET3_NEXT_CHAR		0xc0001900
-#define ATI_CCE_PACKET3_PLY_NEXTSCAN		0xc0001d00
-#define ATI_CCE_PACKET3_SET_SCISSORS		0xc0001e00
-#define R128_CCE_PACKET3_SET_MODE_24BPP		0xc0001f00
-#define R128_CCE_PACKET3_3D_SAVE_CONTEXT	0xc0002000
-#define R128_CCE_PACKET3_3D_PLAY_CONTEXT	0xc0002100
-#define ATI_CCE_PACKET3_3D_RNDR_GEN_INDX_PRIM	0xc0002300
-#define RADEON_CP_PACKET3_LOAD_MICROCODE	0xc0002400
-#define ATI_CCE_PACKET3_3D_RNDR_GEN_PRIM	0xc0002500
-#define RADEON_CP_PACKET3_WAIT_FOR_IDLE		0xc0002600
-#define RADEON_CP_PACKET3_3D_DRAW_VBUF		0xc0002800
-#define RADEON_CP_PACKET3_3D_DRAW_IMMD		0xc0002900
-#define RADEON_CP_PACKET3_3D_DRAW_INDX		0xc0002a00
-#define ATI_CCE_PACKET3_LOAD_PALETTE		0xc0002c00
-#define R128_CCE_PACKET3_PURGE			0xc0002d00
-#define R128_CCE_PACKET3_NEXT_VERTEX_BUNDLE	0xc0002e00
-#define RADEON_CP_PACKET3_3D_LOAD_VBPNTR	0xc0002f00
-#define RADEON_CP_PACKET3_3D_CLEAR_ZMASK	0xc0003200
-#define R200_CP_PACKET3_3D_DRAW_IMMD_2		0xc0003500
-#define ATI_CCE_PACKET3_CNTL_PAINT		0xc0009100
-#define ATI_CCE_PACKET3_CNTL_BITBLT		0xc0009200
-#define ATI_CCE_PACKET3_CNTL_SMALLTEXT		0xc0009300
-#define ATI_CCE_PACKET3_HOSTDATA_BLT		0xc0009400
-#define ATI_CCE_PACKET3_CNTL_POLYLINE		0xc0009500
-#define R128_CCE_PACKET3_SCALE			0xc0009600
-#define R128_CCE_PACKET3_TRANS_SCALE		0xc0009700
-#define ATI_CCE_PACKET3_CNTL_POLYSCANLINES	0xc0009800
-#define ATI_CCE_PACKET3_PAINT_MULTI		0xc0009a00
-#define ATI_CCE_PACKET3_BITBLT_MULTI		0xc0009b00
-#define ATI_CCE_PACKET3_CNTL_TRANS_BITBLT	0xc0009c00
-
-#define RADEON_CP_VC_FRMT_XY			0x00000000
-#define RADEON_CP_VC_FRMT_W0			0x00000001
-#define RADEON_CP_VC_FRMT_FPCOLOR		0x00000002
-#define RADEON_CP_VC_FRMT_FPALPHA		0x00000004
-#define RADEON_CP_VC_FRMT_PKCOLOR		0x00000008
-#define RADEON_CP_VC_FRMT_FPSPEC		0x00000010
-#define RADEON_CP_VC_FRMT_FPFOG			0x00000020
-#define RADEON_CP_VC_FRMT_PKSPEC		0x00000040
-#define RADEON_CP_VC_FRMT_ST0			0x00000080
-#define RADEON_CP_VC_FRMT_ST1			0x00000100
-#define RADEON_CP_VC_FRMT_Q1			0x00000200
-#define RADEON_CP_VC_FRMT_ST2			0x00000400
-#define RADEON_CP_VC_FRMT_Q2			0x00000800
-#define RADEON_CP_VC_FRMT_ST3			0x00001000
-#define RADEON_CP_VC_FRMT_Q3			0x00002000
-#define RADEON_CP_VC_FRMT_Q0			0x00004000
-#define RADEON_CP_VC_FRMT_BLND_WEIGHT_CNT_MASK	0x00038000
-#define RADEON_CP_VC_FRMT_N0			0x00040000
-#define RADEON_CP_VC_FRMT_XY1			0x08000000
-#define RADEON_CP_VC_FRMT_Z1			0x10000000
-#define RADEON_CP_VC_FRMT_W1			0x20000000
-#define RADEON_CP_VC_FRMT_N1			0x40000000
-#define RADEON_CP_VC_FRMT_Z			0x80000000
-
-#define RADEON_CP_VC_CNTL_PRIM_TYPE_NONE	0x00000000
-#define RADEON_CP_VC_CNTL_PRIM_TYPE_POINT	0x00000001
-#define RADEON_CP_VC_CNTL_PRIM_TYPE_LINE	0x00000002
-#define RADEON_CP_VC_CNTL_PRIM_TYPE_LINE_STRIP	0x00000003
-#define RADEON_CP_VC_CNTL_PRIM_TYPE_TRI_LIST	0x00000004
-#define RADEON_CP_VC_CNTL_PRIM_TYPE_TRI_FAN	0x00000005
-#define RADEON_CP_VC_CNTL_PRIM_TYPE_TRI_STRIP	0x00000006
-#define RADEON_CP_VC_CNTL_PRIM_TYPE_TRI_TYPE_2	0x00000007
-#define RADEON_CP_VC_CNTL_PRIM_TYPE_RECT_LIST	0x00000008
-#define RADEON_CP_VC_CNTL_PRIM_TYPE_3VRT_POINT_LIST 0x00000009
-#define RADEON_CP_VC_CNTL_PRIM_TYPE_3VRT_LINE_LIST 0x0000000a
-#define RADEON_CP_VC_CNTL_PRIM_WALK_IND		0x00000010
-#define RADEON_CP_VC_CNTL_PRIM_WALK_LIST	0x00000020
-#define RADEON_CP_VC_CNTL_PRIM_WALK_RING	0x00000030
-#define RADEON_CP_VC_CNTL_COLOR_ORDER_BGRA	0x00000000
-#define RADEON_CP_VC_CNTL_COLOR_ORDER_RGBA	0x00000040
-#define RADEON_CP_VC_CNTL_MAOS_ENABLE		0x00000080
-#define RADEON_CP_VC_CNTL_VTX_FMT_NON_RADEON_MODE 0x00000000
-#define RADEON_CP_VC_CNTL_VTX_FMT_RADEON_MODE	0x00000100
-#define RADEON_CP_VC_CNTL_TCL_DISABLE		0x00000000
-#define RADEON_CP_VC_CNTL_TCL_ENABLE		0x00000200
-#define RADEON_CP_VC_CNTL_NUM_SHIFT		16
-
-#define R128_CCE_VC_FRMT_RHW			0x00000001
-#define R128_CCE_VC_FRMT_DIFFUSE_BGR		0x00000002
-#define R128_CCE_VC_FRMT_DIFFUSE_A		0x00000004
-#define R128_CCE_VC_FRMT_DIFFUSE_ARGB		0x00000008
-#define R128_CCE_VC_FRMT_SPEC_BGR		0x00000010
-#define R128_CCE_VC_FRMT_SPEC_F			0x00000020
-#define R128_CCE_VC_FRMT_SPEC_FRGB		0x00000040
-#define R128_CCE_VC_FRMT_S_T			0x00000080
-#define R128_CCE_VC_FRMT_S2_T2			0x00000100
-#define R128_CCE_VC_FRMT_RHW2			0x00000200
-
-#define R128_CCE_VC_CNTL_PRIM_TYPE_NONE		0x00000000
-#define R128_CCE_VC_CNTL_PRIM_TYPE_POINT	0x00000001
-#define R128_CCE_VC_CNTL_PRIM_TYPE_LINE		0x00000002
-#define R128_CCE_VC_CNTL_PRIM_TYPE_POLY_LINE	0x00000003
-#define R128_CCE_VC_CNTL_PRIM_TYPE_TRI_LIST	0x00000004
-#define R128_CCE_VC_CNTL_PRIM_TYPE_TRI_FAN	0x00000005
-#define R128_CCE_VC_CNTL_PRIM_TYPE_TRI_STRIP	0x00000006
-#define R128_CCE_VC_CNTL_PRIM_TYPE_TRI_TYPE2	0x00000007
-#define R128_CCE_VC_CNTL_PRIM_WALK_IND		0x00000010
-#define R128_CCE_VC_CNTL_PRIM_WALK_LIST		0x00000020
-#define R128_CCE_VC_CNTL_PRIM_WALK_RING		0x00000030
-#define R128_CCE_VC_CNTL_NUM_SHIFT		16
-
-#define R128_DATATYPE_VQ			0
-#define R128_DATATYPE_CI4			1
-#define R128_DATATYPE_CI8			2
-#define R128_DATATYPE_ARGB1555			3
-#define R128_DATATYPE_RGB565			4
-#define R128_DATATYPE_RGB888			5
-#define R128_DATATYPE_ARGB8888			6
-#define R128_DATATYPE_RGB332			7
-#define R128_DATATYPE_Y8			8
-#define R128_DATATYPE_RGB8			9
-#define R128_DATATYPE_CI16			10
-#define R128_DATATYPE_VYUY_422			11
-#define R128_DATATYPE_YVYU_422			12
-#define R128_DATATYPE_AYUV_444			14
-#define R128_DATATYPE_ARGB4444			15
-
-#define R128_AGP_OFFSET				0x02000000
-
-#define R128_WATERMARK_L			16
-#define R128_WATERMARK_M			8
-#define R128_WATERMARK_N			8
-#define R128_WATERMARK_K			128
diff --git a/hw/kdrive/ati/ati_sarea.h b/hw/kdrive/ati/ati_sarea.h
deleted file mode 100644
index 2f04c7b..0000000
--- a/hw/kdrive/ati/ati_sarea.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright © 2003 Eric Anholt
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Eric Anholt not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  Eric Anholt makes no
- * representations about the suitability of this software for any purpose.  It
- * is provided "as is" without express or implied warranty.
- *
- * ERIC ANHOLT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL ERIC ANHOLT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifndef _ATI_SAREA_H_
-#define _ATI_SAREA_H_
-
-/* There are 2 heaps (local/AGP).  Each region within a heap is a
- * minimum of 64k, and there are at most 64 of them per heap.
- */
-#define ATI_CARD_HEAP			0
-#define ATI_GART_HEAP			1
-#define ATI_NR_TEX_HEAPS		2
-#define ATI_NR_TEX_REGIONS		64
-#define ATI_LOG_TEX_GRANULARITY		16
-
-#include "r128_sarea.h"
-#include "radeon_sarea.h"
-
-#endif /* _ATI_SAREA_H_ */
diff --git a/hw/kdrive/ati/ati_stub.c b/hw/kdrive/ati/ati_stub.c
deleted file mode 100644
index f881b7f..0000000
--- a/hw/kdrive/ati/ati_stub.c
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright © 2003 Eric Anholt
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Eric Anholt not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  Eric Anholt makes no
- * representations about the suitability of this software for any purpose.  It
- * is provided "as is" without express or implied warranty.
- *
- * ERIC ANHOLT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL ERIC ANHOLT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <kdrive-config.h>
-#endif
-#include "ati.h"
-#include "klinux.h"
-
-extern struct pci_id_entry ati_pci_ids[];
-
-void
-InitCard(char *name)
-{
-	struct pci_id_entry *id;
-	KdCardAttr attr;
-
-	for (id = ati_pci_ids; id->name != NULL; id++) {
-		int j = 0;
-		while (LinuxFindPci(id->vendor, id->device, j++, &attr))
-			KdCardInfoAdd(&ATIFuncs, &attr, 0);
-	}
-}
-
-void
-InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
-{
-	KdInitOutput(pScreenInfo, argc, argv);
-}
-
-void
-InitInput(int argc, char **argv)
-{
-	KdOsAddInputDrivers();
-	KdInitInput();
-}
-
-void
-ddxUseMsg (void)
-{
-	KdUseMsg();
-#ifdef KDRIVEVESA
-	vesaUseMsg();
-#endif
-}
-
-int
-ddxProcessArgument(int argc, char **argv, int i)
-{
-	int	ret;
-    
-#ifdef KDRIVEVESA
-	if (!(ret = vesaProcessArgument (argc, argv, i)))
-#endif
-		ret = KdProcessArgument(argc, argv, i);
-
-	return ret;
-}
diff --git a/hw/kdrive/ati/ati_video.c b/hw/kdrive/ati/ati_video.c
deleted file mode 100644
index ca0ab46..0000000
--- a/hw/kdrive/ati/ati_video.c
+++ /dev/null
@@ -1,988 +0,0 @@
-/*
- * Copyright © 2004 Keith Packard
- * Copyright © 2005 Eric Anholt
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Eric Anholt not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  Eric Anholt makes no
- * representations about the suitability of this software for any purpose.  It
- * is provided "as is" without express or implied warranty.
- *
- * ERIC ANHOLT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL ERIC ANHOLT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- *
- * Based on mach64video.c by Keith Packard.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <kdrive-config.h>
-#endif
-#include "ati.h"
-#include "ati_dma.h"
-#include "ati_draw.h"
-#include "ati_reg.h"
-#include "kaa.h"
-
-#include <X11/extensions/Xv.h>
-#include "fourcc.h"
-
-#define MAKE_ATOM(a) MakeAtom(a, sizeof(a) - 1, TRUE)
-
-static Atom xvBrightness, xvSaturation;
-
-extern CARD8 ATIBltRop[16];
-
-#define IMAGE_MAX_WIDTH		2048
-#define IMAGE_MAX_HEIGHT	2048
-
-static void
-ATIStopVideo(KdScreenInfo *screen, pointer data, Bool exit)
-{
-	ScreenPtr pScreen = screen->pScreen;
-	ATIPortPrivPtr pPortPriv = (ATIPortPrivPtr)data;
-
-	REGION_EMPTY(screen->pScreen, &pPortPriv->clip);   
-
-	if (pPortPriv->off_screen) {
-		KdOffscreenFree (pScreen, pPortPriv->off_screen);
-		pPortPriv->off_screen = 0;
-	}
-}
-
-static int
-ATISetPortAttribute(KdScreenInfo *screen, Atom attribute, int value,
-    pointer data)
-{
-	return BadMatch;
-}
-
-static int
-ATIGetPortAttribute(KdScreenInfo *screen, Atom attribute, int *value,
-    pointer data)
-{
-	return BadMatch;
-}
-
-static void
-ATIQueryBestSize(KdScreenInfo *screen, Bool motion, short vid_w, short vid_h,
-    short drw_w, short drw_h, unsigned int *p_w, unsigned int *p_h,
-    pointer data)
-{
-	*p_w = drw_w;
-	*p_h = drw_h;
-}
-
-/* ATIClipVideo -  
-
-   Takes the dst box in standard X BoxRec form (top and left
-   edges inclusive, bottom and right exclusive).  The new dst
-   box is returned.  The source boundaries are given (x1, y1 
-   inclusive, x2, y2 exclusive) and returned are the new source 
-   boundaries in 16.16 fixed point. 
-*/
-
-static void
-ATIClipVideo(BoxPtr dst, INT32 *x1, INT32 *x2, INT32 *y1, INT32 *y2,
-    BoxPtr extents, INT32 width, INT32 height)
-{
-	INT32 vscale, hscale, delta;
-	int diff;
-
-	hscale = ((*x2 - *x1) << 16) / (dst->x2 - dst->x1);
-	vscale = ((*y2 - *y1) << 16) / (dst->y2 - dst->y1);
-
-	*x1 <<= 16; *x2 <<= 16;
-	*y1 <<= 16; *y2 <<= 16;
-
-	diff = extents->x1 - dst->x1;
-	if (diff > 0) {
-		dst->x1 = extents->x1;
-		*x1 += diff * hscale;
-	}
-	diff = dst->x2 - extents->x2;
-	if (diff > 0) {
-		dst->x2 = extents->x2;
-		*x2 -= diff * hscale;
-	}
-	diff = extents->y1 - dst->y1;
-	if (diff > 0) {
-		dst->y1 = extents->y1;
-		*y1 += diff * vscale;
-	}
-	diff = dst->y2 - extents->y2;
-	if (diff > 0) {
-		dst->y2 = extents->y2;
-		*y2 -= diff * vscale;
-	}
-
-	if (*x1 < 0) {
-		diff =  (- *x1 + hscale - 1)/ hscale;
-		dst->x1 += diff;
-		*x1 += diff * hscale;
-	}
-	delta = *x2 - (width << 16);
-	if (delta > 0) {
-		diff = (delta + hscale - 1)/ hscale;
-		dst->x2 -= diff;
-		*x2 -= diff * hscale;
-	}
-	if (*y1 < 0) {
-		diff =  (- *y1 + vscale - 1)/ vscale;
-		dst->y1 += diff;
-		*y1 += diff * vscale;
-	}
-	delta = *y2 - (height << 16);
-	if (delta > 0) {
-		diff = (delta + vscale - 1)/ vscale;
-		dst->y2 -= diff;
-		*y2 -= diff * vscale;
-	}
-}
-
-static void
-R128DisplayVideo(KdScreenInfo *screen, ATIPortPrivPtr pPortPriv)
-{
-	ScreenPtr pScreen = screen->pScreen;
-	KdScreenPriv(pScreen);
-	ATIScreenInfo(pScreenPriv);
-	CARD32 dstDatatype, srcDatatype;
-	CARD32 dst_offset, dst_pitch;
-	int dstxoff, dstyoff;
-	PixmapPtr pPixmap = pPortPriv->pPixmap;
-	int bpp = pPixmap->drawable.bitsPerPixel;
-	RING_LOCALS;
-
-	BoxPtr pBox = REGION_RECTS(&pPortPriv->clip);
-	int nBox = REGION_NUM_RECTS(&pPortPriv->clip);
-
-	if (pPortPriv->id == FOURCC_UYVY)
-		srcDatatype = R128_DATATYPE_YVYU_422;
-	else
-		srcDatatype = R128_DATATYPE_VYUY_422;
-
-	switch (bpp)
-	{
-	case 16:
-		if (pPixmap->drawable.depth == 15)
-			dstDatatype = R128_DATATYPE_ARGB1555;
-		else
-			dstDatatype = R128_DATATYPE_RGB565;
-		break;
-	case 32:
-		dstDatatype = R128_DATATYPE_ARGB8888;
-		break;
-	default:
-		return;
-	}
-
-	dst_offset = ((CARD8 *)pPixmap->devPrivate.ptr -
-	    pScreenPriv->screen->memory_base);
-	dst_pitch = pPixmap->devKind;
-#ifdef COMPOSITE
-	dstxoff = -pPixmap->screen_x + pPixmap->drawable.x;
-	dstyoff = -pPixmap->screen_y + pPixmap->drawable.y;
-#else
-	dstxoff = 0;
-	dstyoff = 0;
-#endif
-
-	BEGIN_DMA(18);
-	OUT_REG(ATI_REG_DST_PITCH_OFFSET,
-	    ((dst_pitch / bpp) << 21) | (dst_offset >> 5));
-	OUT_REG(ATI_REG_DP_GUI_MASTER_CNTL,
-	    ATI_GMC_DST_PITCH_OFFSET_CNTL |
-	    ATI_GMC_BRUSH_NONE |
-	    (dstDatatype << 8) |
-	    ATI_GMC_SRC_DATATYPE_COLOR |
-	    (ATIBltRop[GXcopy] << 16) |
-	    R128_GMC_3D_FCN_EN |
-	    ATI_GMC_CLR_CMP_CNTL_DIS |
-	    R128_GMC_AUX_CLIP_DIS);
-	OUT_REG(ATI_REG_DP_CNTL, 
-	    ATI_DST_X_LEFT_TO_RIGHT | ATI_DST_Y_TOP_TO_BOTTOM );
-	OUT_REG(R128_REG_SCALE_3D_CNTL,
-	    R128_SCALE_3D_SCALE |
-	    R128_SBLEND_ONE |
-	    R128_DBLEND_ZERO);
-	OUT_REG(R128_REG_TEX_CNTL_C, R128_TEX_CACHE_FLUSH);
-	OUT_REG(R128_REG_SCALE_3D_DATATYPE, srcDatatype);
-
-	OUT_RING(DMA_PACKET0(R128_REG_SCALE_PITCH, 5));
-	OUT_RING_REG(R128_REG_SCALE_PITCH, pPortPriv->src_pitch / 16);
-	OUT_RING_REG(R128_REG_SCALE_X_INC,
-	    (pPortPriv->src_w << 16) / pPortPriv->dst_w);
-	OUT_RING_REG(R128_REG_SCALE_Y_INC,
-	    (pPortPriv->src_h << 16) / pPortPriv->dst_h);
-	OUT_RING_REG(R128_REG_SCALE_HACC, 0x0);
-	OUT_RING_REG(R128_REG_SCALE_VACC, 0x0);
-
-	END_DMA();
-
-	while (nBox--) {
-		int srcX, srcY, dstX, dstY, srcw, srch, dstw, dsth;
-
-		dstX = pBox->x1 + dstxoff;
-		dstY = pBox->y1 + dstyoff;
-		dstw = pBox->x2 - pBox->x1;
-		dsth = pBox->y2 - pBox->y1;
-		srcX = (pBox->x1 - pPortPriv->dst_x1) *
-		    pPortPriv->src_w / pPortPriv->dst_w;
-		srcY = (pBox->y1 - pPortPriv->dst_y1) *
-		    pPortPriv->src_h / pPortPriv->dst_h;
-		srcw = pPortPriv->src_w - srcX;
-		srch = pPortPriv->src_h - srcY;
-
-		BEGIN_DMA(6);
-		OUT_RING(DMA_PACKET0(R128_REG_SCALE_SRC_HEIGHT_WIDTH, 2));
-		OUT_RING_REG(R128_REG_SCALE_SRC_HEIGHT_WIDTH,
-		    (srch << 16) | srcw);
-		OUT_RING_REG(R128_REG_SCALE_OFFSET_0, pPortPriv->src_offset +
-		    srcY * pPortPriv->src_pitch + srcX * 2);
-
-		OUT_RING(DMA_PACKET0(R128_REG_SCALE_DST_X_Y, 2));
-		OUT_RING_REG(R128_REG_SCALE_DST_X_Y, (dstX << 16) | dstY);
-		OUT_RING_REG(R128_REG_SCALE_DST_HEIGHT_WIDTH,
-		    (dsth << 16) | dstw);
-		END_DMA();
-		pBox++;
-	}
-#ifdef DAMAGEEXT
-	/* XXX: Shouldn't this be in kxv.c instead? */
-	DamageDamageRegion(pPortPriv->pDraw, &pPortPriv->clip);
-#endif
-	kaaMarkSync(pScreen);
-}
-
-union intfloat {
-	float f;
-	CARD32 i;
-};
-
-struct blend_vertex {
-	union intfloat x, y;
-	union intfloat s0, t0;
-};
-
-#define VTX_DWORD_COUNT 4
-
-#define VTX_OUT(vtx)		\
-do {				\
-	OUT_RING(vtx.x.i);	\
-	OUT_RING(vtx.y.i);	\
-	OUT_RING(vtx.s0.i);	\
-	OUT_RING(vtx.t0.i);	\
-} while (0)
-
-static void
-RadeonDisplayVideo(KdScreenInfo *screen, ATIPortPrivPtr pPortPriv)
-{
-	ScreenPtr pScreen = screen->pScreen;
-	KdScreenPriv(pScreen);
-	ATICardInfo(pScreenPriv);
-	ATIScreenInfo(pScreenPriv);
-	struct blend_vertex vtx[4];
-	PixmapPtr pPixmap = pPortPriv->pPixmap;
-	CARD32 txformat;
-	CARD32 dst_offset, dst_pitch, dst_format;
-	int dstxoff, dstyoff, pixel_shift;
-	RING_LOCALS;
-
-	BoxPtr pBox = REGION_RECTS(&pPortPriv->clip);
-	int nBox = REGION_NUM_RECTS(&pPortPriv->clip);
-
-	switch (pPixmap->drawable.bitsPerPixel) {
-	case 16:
-		if (pPixmap->drawable.depth == 15)
-			dst_format = RADEON_COLOR_FORMAT_ARGB1555;
-		else
-			dst_format = RADEON_COLOR_FORMAT_RGB565;
-		pixel_shift = 1;
-		break;
-	case 32:
-		dst_format = RADEON_COLOR_FORMAT_ARGB8888;
-		pixel_shift = 2;
-		break;
-	default:
-		return;
-	}
-
-	dst_offset = ((CARD8 *)pPixmap->devPrivate.ptr -
-	    pScreenPriv->screen->memory_base);
-	dst_pitch = pPixmap->devKind;
-
-#ifdef COMPOSITE
-	dstxoff = -pPixmap->screen_x + pPixmap->drawable.x;
-	dstyoff = -pPixmap->screen_y + pPixmap->drawable.y;
-#else
-	dstxoff = 0;
-	dstyoff = 0;
-#endif
-
-	/* Same for R100/R200 */
-	if (pPortPriv->id == FOURCC_UYVY)
-		txformat = RADEON_TXFORMAT_YVYU422;
-	else
-		txformat = RADEON_TXFORMAT_VYUY422;
-
-	txformat |= RADEON_TXFORMAT_NON_POWER2;
-
-	RadeonSwitchTo3D(atis);
-
-	BEGIN_DMA(8);
-
-	OUT_RING(DMA_PACKET0(RADEON_REG_PP_CNTL, 3));
-	OUT_RING_REG(RADEON_REG_PP_CNTL,
-	    RADEON_TEX_0_ENABLE | RADEON_TEX_BLEND_0_ENABLE);
-	OUT_RING_REG(RADEON_REG_RB3D_CNTL,
-	    dst_format | RADEON_ALPHA_BLEND_ENABLE);
-	OUT_RING_REG(RADEON_REG_RB3D_COLOROFFSET, dst_offset);
-
-	OUT_REG(RADEON_REG_RB3D_COLORPITCH, dst_pitch >> pixel_shift);
-
-	OUT_REG(RADEON_REG_RB3D_BLENDCNTL,
-	    RADEON_SBLEND_GL_ONE | RADEON_DBLEND_GL_ZERO);
-
-	END_DMA();
-
-	if (atic->is_r200) {
-		BEGIN_DMA(17);
-
-		OUT_REG(R200_REG_SE_VTX_FMT_0, R200_VTX_XY);
-		OUT_REG(R200_REG_SE_VTX_FMT_1,
-		    (2 << R200_VTX_TEX0_COMP_CNT_SHIFT));
-
-		OUT_RING(DMA_PACKET0(R200_REG_PP_TXFILTER_0, 5));
-		OUT_RING_REG(R200_REG_PP_TXFILTER_0,
-		    R200_MAG_FILTER_LINEAR |
-		    R200_MIN_FILTER_LINEAR |
-		    R200_YUV_TO_RGB);
-		OUT_RING_REG(R200_REG_PP_TXFORMAT_0, txformat);
-		OUT_RING_REG(R200_REG_PP_TXFORMAT_X_0, 0);
-		OUT_RING_REG(R200_REG_PP_TXSIZE_0,
-		    (pPixmap->drawable.width - 1) |
-		    ((pPixmap->drawable.height - 1) << RADEON_TEX_VSIZE_SHIFT));
-		OUT_RING_REG(R200_REG_PP_TXPITCH_0, pPortPriv->src_pitch - 32);
-
-		OUT_REG(R200_PP_TXOFFSET_0, pPortPriv->src_offset);
-
-		OUT_RING(DMA_PACKET0(R200_REG_PP_TXCBLEND_0, 4));
-		OUT_RING_REG(R200_REG_PP_TXCBLEND_0,
-		    R200_TXC_ARG_A_ZERO |
-		    R200_TXC_ARG_B_ZERO |
-		    R200_TXC_ARG_C_R0_COLOR |
-		    R200_TXC_OP_MADD);
-		OUT_RING_REG(R200_REG_PP_TXCBLEND2_0,
-		    R200_TXC_CLAMP_0_1 | R200_TXC_OUTPUT_REG_R0);
-		OUT_RING_REG(R200_REG_PP_TXABLEND_0,
-		    R200_TXA_ARG_A_ZERO |
-		    R200_TXA_ARG_B_ZERO |
-		    R200_TXA_ARG_C_R0_ALPHA |
-		    R200_TXA_OP_MADD);
-		OUT_RING_REG(R200_REG_PP_TXABLEND2_0,
-		    R200_TXA_CLAMP_0_1 | R200_TXA_OUTPUT_REG_R0);
-
-		END_DMA();
-	} else {
-//		BEGIN_DMA(11);
-		BEGIN_DMA(9);
-
-		OUT_RING(DMA_PACKET0(RADEON_REG_PP_TXFILTER_0, 5));
-		OUT_RING_REG(RADEON_REG_PP_TXFILTER_0, RADEON_MAG_FILTER_LINEAR |
-		    RADEON_MIN_FILTER_LINEAR |
-		    RADEON_YUV_TO_RGB);
-		OUT_RING_REG(RADEON_REG_PP_TXFORMAT_0, txformat);
-		OUT_RING_REG(RADEON_REG_PP_TXOFFSET_0, pPortPriv->src_offset);
-		OUT_RING_REG(RADEON_REG_PP_TXCBLEND_0,
-		    RADEON_COLOR_ARG_A_ZERO |
-		    RADEON_COLOR_ARG_B_ZERO |
-		    RADEON_COLOR_ARG_C_T0_COLOR |
-		    RADEON_BLEND_CTL_ADD |
-		    RADEON_CLAMP_TX);
-		OUT_RING_REG(RADEON_REG_PP_TXABLEND_0,
-		    RADEON_ALPHA_ARG_A_ZERO |
-		    RADEON_ALPHA_ARG_B_ZERO |
-		    RADEON_ALPHA_ARG_C_T0_ALPHA |
-		    RADEON_BLEND_CTL_ADD |
-		    RADEON_CLAMP_TX);
-
-		OUT_RING(DMA_PACKET0(RADEON_REG_PP_TEX_SIZE_0, 2));
-		OUT_RING_REG(RADEON_REG_PP_TEX_SIZE_0,
-		    (pPixmap->drawable.width - 1) |
-		    ((pPixmap->drawable.height - 1) << RADEON_TEX_VSIZE_SHIFT));
-		OUT_RING_REG(RADEON_REG_PP_TEX_PITCH_0,
-		    pPortPriv->src_pitch - 32);
-
-//	        OUT_RING_REG(ATI_REG_WAIT_UNTIL, ATI_WAIT_CRTC_VLINE);
-
-		END_DMA();
-	}
-
-	while (nBox--) {
-		float srcX, srcY, dstX, dstY, srcw, srch, dstw, dsth;
-
-		dstX = pBox->x1 + dstxoff;
-		dstY = pBox->y1 + dstyoff;
-		dstw = pBox->x2 - pBox->x1;
-		dsth = pBox->y2 - pBox->y1;
-		srcX = (pBox->x1 - pPortPriv->dst_x1) *
-		    pPortPriv->src_w / pPortPriv->dst_w;
-		srcY = (pBox->y1 - pPortPriv->dst_y1) *
-		    pPortPriv->src_h / pPortPriv->dst_h;
-		srcw = pPortPriv->src_w * (dstw / pPortPriv->dst_w);
-		srch = pPortPriv->src_h * (dsth / pPortPriv->dst_h);
-
-		/*
-		 * rectangle:
-		 *
-		 *  +---------2
-		 *  |         |
-		 *  |         |
-		 *  0---------1
-		 */
-		
-		vtx[0].x.f = dstX;
-		vtx[0].y.f = dstY + dsth;
-		vtx[0].s0.f = srcX;
-		vtx[0].t0.f = srcY + srch;
-
-		vtx[1].x.f = dstX + dstw;
-		vtx[1].y.f = dstY + dsth;
-		vtx[1].s0.f = srcX + srcw;
-		vtx[1].t0.f = srcY + srch;
-
-		vtx[2].x.f = dstX + dstw;
-		vtx[2].y.f = dstY;
-		vtx[2].s0.f = srcX + srcw;
-		vtx[2].t0.f = srcY;
-
-		if (atic->is_r100) {
-			BEGIN_DMA(3 * VTX_DWORD_COUNT + 3);
-			OUT_RING(DMA_PACKET3(RADEON_CP_PACKET3_3D_DRAW_IMMD,
-			    3 * VTX_DWORD_COUNT + 2));
-			OUT_RING(RADEON_CP_VC_FRMT_XY |
-			    RADEON_CP_VC_FRMT_ST0);
-			OUT_RING(RADEON_CP_VC_CNTL_PRIM_TYPE_RECT_LIST |
-			    RADEON_CP_VC_CNTL_PRIM_WALK_RING |
-			    RADEON_CP_VC_CNTL_MAOS_ENABLE |
-			    RADEON_CP_VC_CNTL_VTX_FMT_RADEON_MODE |
-			    (3 << RADEON_CP_VC_CNTL_NUM_SHIFT));
-		} else {
-			BEGIN_DMA(3 * VTX_DWORD_COUNT + 2);
-			OUT_RING(DMA_PACKET3(R200_CP_PACKET3_3D_DRAW_IMMD_2,
-			    3 * VTX_DWORD_COUNT + 1));
-			OUT_RING(RADEON_CP_VC_CNTL_PRIM_TYPE_RECT_LIST |
-			    RADEON_CP_VC_CNTL_PRIM_WALK_RING |
-			    (3 << RADEON_CP_VC_CNTL_NUM_SHIFT));
-		}
-
-		VTX_OUT(vtx[0]);
-		VTX_OUT(vtx[1]);
-		VTX_OUT(vtx[2]);
-		END_DMA();
-
-		pBox++;
-	}
-#ifdef DAMAGEEXT
-	/* XXX: Shouldn't this be in kxv.c instead? */
-	DamageDamageRegion(pPortPriv->pDraw, &pPortPriv->clip);
-#endif
-	kaaMarkSync(pScreen);
-}
-
-static void
-ATIVideoSave(ScreenPtr pScreen, KdOffscreenArea *area)
-{
-	KdScreenPriv(pScreen);
-	ATIScreenInfo(pScreenPriv);
-	ATIPortPrivPtr pPortPriv = atis->pAdaptor->pPortPrivates[0].ptr;
-
-	if (pPortPriv->off_screen == area)
-		pPortPriv->off_screen = 0;
-}
-
-static int
-ATIPutImage(KdScreenInfo *screen, DrawablePtr pDraw,
-	       short src_x, short src_y,
-	       short drw_x, short drw_y,
-	       short src_w, short src_h,
-	       short drw_w, short drw_h,
-	       int id,
-	       unsigned char *buf,
-	       short width,
-	       short height,
-	       Bool sync,
-	       RegionPtr clipBoxes,
-	       pointer data)
-{
-	ScreenPtr pScreen = screen->pScreen;
-	KdScreenPriv(pScreen);
-	ATICardInfo(pScreenPriv);
-	ATIScreenInfo(pScreenPriv);
-	ATIPortPrivPtr pPortPriv = (ATIPortPrivPtr)data;
-	char *mmio = atic->reg_base;
-	INT32 x1, x2, y1, y2;
-	int randr = RR_Rotate_0 /* XXX */;
-	int srcPitch, srcPitch2, dstPitch;
-	int top, left, npixels, nlines, size;
-	BoxRec dstBox;
-	int dst_width = width, dst_height = height;
-	int rot_x1, rot_y1, rot_x2, rot_y2;
-	int dst_x1, dst_y1, dst_x2, dst_y2;
-	int rot_src_w, rot_src_h, rot_drw_w, rot_drw_h;
-
-	/* Clip */
-	x1 = src_x;
-	x2 = src_x + src_w;
-	y1 = src_y;
-	y2 = src_y + src_h;
-
-	dstBox.x1 = drw_x;
-	dstBox.x2 = drw_x + drw_w;
-	dstBox.y1 = drw_y;
-	dstBox.y2 = drw_y + drw_h;
-
-	ATIClipVideo(&dstBox, &x1, &x2, &y1, &y2,
-	    REGION_EXTENTS(pScreen, clipBoxes), width, height);
-
-	src_w = (x2 - x1) >> 16;
-	src_h = (y2 - y1) >> 16;
-	drw_w = dstBox.x2 - dstBox.x1;
-	drw_h = dstBox.y2 - dstBox.y1;
-
-	if ((x1 >= x2) || (y1 >= y2))
-		return Success;
-
-	if (mmio == NULL)
-		return BadAlloc;
-
-	if (randr & (RR_Rotate_0|RR_Rotate_180)) {
-		dst_width = width;
-		dst_height = height;
-		rot_src_w = src_w;
-		rot_src_h = src_h;
-		rot_drw_w = drw_w;
-		rot_drw_h = drw_h;
-	} else {
-		dst_width = height;
-		dst_height = width;
-		rot_src_w = src_h;
-		rot_src_h = src_w;
-		rot_drw_w = drw_h;
-		rot_drw_h = drw_w;
-	}
-
-	switch (randr & RR_Rotate_All) {
-	case RR_Rotate_0:
-	default:
-		dst_x1 = dstBox.x1;
-		dst_y1 = dstBox.y1;
-		dst_x2 = dstBox.x2;
-		dst_y2 = dstBox.y2;
-		rot_x1 = x1;
-		rot_y1 = y1;
-		rot_x2 = x2;
-		rot_y2 = y2;
-		break;
-	case RR_Rotate_90:
-		dst_x1 = dstBox.y1;
-		dst_y1 = screen->height - dstBox.x2;
-		dst_x2 = dstBox.y2;
-		dst_y2 = screen->height - dstBox.x1;
-		rot_x1 = y1;
-		rot_y1 = (src_w << 16) - x2;
-		rot_x2 = y2;
-		rot_y2 = (src_w << 16) - x1;
-		break;
-	case RR_Rotate_180:
-		dst_x1 = screen->width - dstBox.x2;
-		dst_y1 = screen->height - dstBox.y2;
-		dst_x2 = screen->width - dstBox.x1;
-		dst_y2 = screen->height - dstBox.y1;
-		rot_x1 = (src_w << 16) - x2;
-		rot_y1 = (src_h << 16) - y2;
-		rot_x2 = (src_w << 16) - x1;
-		rot_y2 = (src_h << 16) - y1;
-		break;
-	case RR_Rotate_270:
-		dst_x1 = screen->width - dstBox.y2;
-		dst_y1 = dstBox.x1;
-		dst_x2 = screen->width - dstBox.y1;
-		dst_y2 = dstBox.x2;
-		rot_x1 = (src_h << 16) - y2;
-		rot_y1 = x1;
-		rot_x2 = (src_h << 16) - y1;
-		rot_y2 = x2;
-		break;
-	}
-
-	switch(id) {
-	case FOURCC_YV12:
-	case FOURCC_I420:
-		dstPitch = ((dst_width << 1) + 15) & ~15;
-		srcPitch = (width + 3) & ~3;
-		srcPitch2 = ((width >> 1) + 3) & ~3;
-		size = dstPitch * dst_height;
-		break;
-	case FOURCC_UYVY:
-	case FOURCC_YUY2:
-	default:
-		dstPitch = ((dst_width << 1) + 15) & ~15;
-		srcPitch = (width << 1);
-		srcPitch2 = 0;
-		size = dstPitch * dst_height;
-		break;
-	}
-
-	if (pPortPriv->off_screen != NULL && size != pPortPriv->size) {
-		KdOffscreenFree(screen->pScreen, pPortPriv->off_screen);
-		pPortPriv->off_screen = 0;
-	}
-
-	if (pPortPriv->off_screen == NULL) {
-		pPortPriv->off_screen = KdOffscreenAlloc(screen->pScreen,
-		    size * 2, 64, TRUE, ATIVideoSave, pPortPriv);
-		if (pPortPriv->off_screen == NULL)
-			return BadAlloc;
-	}
-
-
-	if (pDraw->type == DRAWABLE_WINDOW)
-		pPortPriv->pPixmap =
-		    (*pScreen->GetWindowPixmap)((WindowPtr)pDraw);
-	else
-		pPortPriv->pPixmap = (PixmapPtr)pDraw;
-
-	/* Migrate the pixmap to offscreen if necessary. */
-	if (!kaaPixmapIsOffscreen(pPortPriv->pPixmap))
-		kaaMoveInPixmap(pPortPriv->pPixmap);
-
-	if (!kaaPixmapIsOffscreen(pPortPriv->pPixmap)) {
-		return BadAlloc;
-	}
-
-	pPortPriv->src_offset = pPortPriv->off_screen->offset;
-	pPortPriv->src_addr = (CARD8 *)(pScreenPriv->screen->memory_base +
-	    pPortPriv->src_offset);
-	pPortPriv->src_pitch = dstPitch;
-	pPortPriv->size = size;
-	pPortPriv->pDraw = pDraw;
-
-	/* copy data */
-	top = rot_y1 >> 16;
-	left = (rot_x1 >> 16) & ~1;
-	npixels = ((((rot_x2 + 0xffff) >> 16) + 1) & ~1) - left;
-
-	/* Since we're probably overwriting the area that might still be used
-	 * for the last PutImage request, wait for idle.
-	 */
-	ATIWaitIdle(atis);
-
-	switch(id) {
-	case FOURCC_YV12:
-	case FOURCC_I420:
-		top &= ~1;
-		nlines = ((((rot_y2 + 0xffff) >> 16) + 1) & ~1) - top;
-		KdXVCopyPlanarData(screen, buf, pPortPriv->src_addr, randr,
-		    srcPitch, srcPitch2, dstPitch, rot_src_w, rot_src_h,
-		    height, top, left, nlines, npixels, id);
-		break;
-	case FOURCC_UYVY:
-	case FOURCC_YUY2:
-	default:
-		nlines = ((rot_y2 + 0xffff) >> 16) - top;
-		KdXVCopyPackedData(screen, buf, pPortPriv->src_addr, randr,
-		    srcPitch, dstPitch, rot_src_w, rot_src_h, top, left,
-		    nlines, npixels);
-		break;
-	}
-
-	/* update cliplist */
-	if (!REGION_EQUAL(screen->pScreen, &pPortPriv->clip, clipBoxes)) {
-		REGION_COPY(screen->pScreen, &pPortPriv->clip, clipBoxes);
-	}
-
-	pPortPriv->id = id;
-	pPortPriv->src_x1 = rot_x1;
-	pPortPriv->src_y1 = rot_y1;
-	pPortPriv->src_x2 = rot_x2;
-	pPortPriv->src_y2 = rot_y2;
-	pPortPriv->src_w = rot_src_w;
-	pPortPriv->src_h = rot_src_h;
-	pPortPriv->dst_x1 = dst_x1;
-	pPortPriv->dst_y1 = dst_y1;
-	pPortPriv->dst_x2 = dst_x2;
-	pPortPriv->dst_y2 = dst_y2;
-	pPortPriv->dst_w = rot_drw_w;
-	pPortPriv->dst_h = rot_drw_h;
-
-	if (atic->is_radeon)
-		RadeonDisplayVideo(screen, pPortPriv);
-	else
-		R128DisplayVideo(screen, pPortPriv);
-
-	return Success;
-}
-
-static int
-ATIReputImage(KdScreenInfo *screen, DrawablePtr pDraw, short drw_x, short drw_y,
-    RegionPtr clipBoxes, pointer data)
-{
-	ScreenPtr pScreen = screen->pScreen;
-	KdScreenPriv(pScreen);
-	ATICardInfo(pScreenPriv);
-	ATIPortPrivPtr	pPortPriv = (ATIPortPrivPtr)data;
-	BoxPtr pOldExtents = REGION_EXTENTS(screen->pScreen, &pPortPriv->clip);
-	BoxPtr pNewExtents = REGION_EXTENTS(screen->pScreen, clipBoxes);
-
-	if (pOldExtents->x1 != pNewExtents->x1 ||
-	    pOldExtents->x2 != pNewExtents->x2 ||
-	    pOldExtents->y1 != pNewExtents->y1 ||
-	    pOldExtents->y2 != pNewExtents->y2)
-		return BadMatch;
-
-	if (pDraw->type == DRAWABLE_WINDOW)
-		pPortPriv->pPixmap =
-		    (*pScreen->GetWindowPixmap)((WindowPtr)pDraw);
-	else
-		pPortPriv->pPixmap = (PixmapPtr)pDraw;
-
-	if (!kaaPixmapIsOffscreen(pPortPriv->pPixmap))
-		kaaMoveInPixmap(pPortPriv->pPixmap);
-
-	if (!kaaPixmapIsOffscreen(pPortPriv->pPixmap)) {
-		ErrorF("err\n");
-		return BadAlloc;
-	}
-
-
-	/* update cliplist */
-	if (!REGION_EQUAL(screen->pScreen, &pPortPriv->clip, clipBoxes))
-		REGION_COPY(screen->pScreen, &pPortPriv->clip, clipBoxes);
-
-	/* XXX: What do the drw_x and drw_y here mean for us? */
-
-	if (atic->is_radeon)
-		RadeonDisplayVideo(screen, pPortPriv);
-	else
-		R128DisplayVideo(screen, pPortPriv);
-
-	return Success;
-}
-
-static int
-ATIQueryImageAttributes(KdScreenInfo *screen, int id, unsigned short *w,
-    unsigned short *h, int *pitches, int *offsets)
-{
-	int size, tmp;
-
-	if (*w > IMAGE_MAX_WIDTH) 
-		*w = IMAGE_MAX_WIDTH;
-	if (*h > IMAGE_MAX_HEIGHT) 
-		*h = IMAGE_MAX_HEIGHT;
-
-	*w = (*w + 1) & ~1;
-	if (offsets)
-		offsets[0] = 0;
-
-	switch (id)
-	{
-	case FOURCC_YV12:
-	case FOURCC_I420:
-		*h = (*h + 1) & ~1;
-		size = (*w + 3) & ~3;
-		if (pitches) 
-			pitches[0] = size;
-		size *= *h;
-		if (offsets) 
-			offsets[1] = size;
-		tmp = ((*w >> 1) + 3) & ~3;
-		if (pitches) 
-			pitches[1] = pitches[2] = tmp;
-		tmp *= (*h >> 1);
-		size += tmp;
-		if (offsets) 
-			offsets[2] = size;
-		size += tmp;
-		break;
-	case FOURCC_UYVY:
-	case FOURCC_YUY2:
-	default:
-		size = *w << 1;
-		if (pitches) 
-			pitches[0] = size;
-		size *= *h;
-		break;
-	}
-
-	return size;
-}
-
-
-/* client libraries expect an encoding */
-static KdVideoEncodingRec DummyEncoding[1] =
-{
-	{
-		0,
-		"XV_IMAGE",
-		IMAGE_MAX_WIDTH, IMAGE_MAX_HEIGHT,
-		{1, 1}
-	}
-};
-
-#define NUM_FORMATS 3
-
-static KdVideoFormatRec Formats[NUM_FORMATS] = 
-{
-	{15, TrueColor}, {16, TrueColor}, {24, TrueColor}
-};
-
-#define NUM_ATTRIBUTES 0
-
-static KdAttributeRec Attributes[NUM_ATTRIBUTES] =
-{
-};
-
-#define NUM_IMAGES 4
-
-static KdImageRec Images[NUM_IMAGES] =
-{
-	XVIMAGE_YUY2,
-	XVIMAGE_YV12,
-	XVIMAGE_I420,
-	XVIMAGE_UYVY
-};
-
-static KdVideoAdaptorPtr 
-ATISetupImageVideo(ScreenPtr pScreen)
-{
-	KdScreenPriv(pScreen);
-	ATIScreenInfo(pScreenPriv);
-	KdVideoAdaptorPtr adapt;
-	ATIPortPrivPtr pPortPriv;
-	int i;
-
-	atis->num_texture_ports = 16;
-
-	adapt = xcalloc(1, sizeof(KdVideoAdaptorRec) + atis->num_texture_ports *
-	    (sizeof(ATIPortPrivRec) + sizeof(DevUnion)));
-	if (adapt == NULL)
-		return NULL;
-
-	adapt->type = XvWindowMask | XvInputMask | XvImageMask;
-	adapt->flags = VIDEO_CLIP_TO_VIEWPORT;
-	adapt->name = "ATI Texture Video";
-	adapt->nEncodings = 1;
-	adapt->pEncodings = DummyEncoding;
-	adapt->nFormats = NUM_FORMATS;
-	adapt->pFormats = Formats;
-	adapt->nPorts = atis->num_texture_ports;
-	adapt->pPortPrivates = (DevUnion*)(&adapt[1]);
-
-	pPortPriv =
-	    (ATIPortPrivPtr)(&adapt->pPortPrivates[atis->num_texture_ports]);
-
-	for (i = 0; i < atis->num_texture_ports; i++)
-		adapt->pPortPrivates[i].ptr = &pPortPriv[i];
-
-	adapt->nAttributes = NUM_ATTRIBUTES;
-	adapt->pAttributes = Attributes;
-	adapt->pImages = Images;
-	adapt->nImages = NUM_IMAGES;
-	adapt->PutVideo = NULL;
-	adapt->PutStill = NULL;
-	adapt->GetVideo = NULL;
-	adapt->GetStill = NULL;
-	adapt->StopVideo = ATIStopVideo;
-	adapt->SetPortAttribute = ATISetPortAttribute;
-	adapt->GetPortAttribute = ATIGetPortAttribute;
-	adapt->QueryBestSize = ATIQueryBestSize;
-	adapt->PutImage = ATIPutImage;
-	adapt->ReputImage = ATIReputImage;
-	adapt->QueryImageAttributes = ATIQueryImageAttributes;
-
-	/* gotta uninit this someplace */
-	REGION_INIT(pScreen, &pPortPriv->clip, NullBox, 0); 
-
-	atis->pAdaptor = adapt;
-
-	xvBrightness = MAKE_ATOM("XV_BRIGHTNESS");
-	xvSaturation = MAKE_ATOM("XV_SATURATION");
-
-	return adapt;
-}
-
-Bool ATIInitVideo(ScreenPtr pScreen)
-{
-	KdScreenPriv(pScreen);
-	ATIScreenInfo(pScreenPriv);
-	ATICardInfo(pScreenPriv);
-	KdScreenInfo *screen = pScreenPriv->screen;
-	KdVideoAdaptorPtr *adaptors, *newAdaptors = NULL;
-	KdVideoAdaptorPtr newAdaptor = NULL;
-	int num_adaptors;
-    
-	atis->pAdaptor = NULL;
-
-	if (atic->reg_base == NULL)
-		return FALSE;
-	if (atic->is_r300)
-		return FALSE;
-
-	num_adaptors = KdXVListGenericAdaptors(screen, &adaptors);
-
-	newAdaptor = ATISetupImageVideo(pScreen);
-
-	if (newAdaptor)  {
-		if (!num_adaptors) {
-			num_adaptors = 1;
-			adaptors = &newAdaptor;
-		} else {
-			newAdaptors = xalloc((num_adaptors + 1) * 
-			    sizeof(KdVideoAdaptorPtr *));
-			if (newAdaptors) {
-				memcpy(newAdaptors, adaptors, num_adaptors *
-				    sizeof(KdVideoAdaptorPtr));
-				newAdaptors[num_adaptors] = newAdaptor;
-				adaptors = newAdaptors;
-				num_adaptors++;
-			}
-		}
-	}
-
-	if (num_adaptors)
-		KdXVScreenInit(pScreen, adaptors, num_adaptors);
-
-	if (newAdaptors)
-		xfree(newAdaptors);
-
-	return TRUE;
-}
-
-void
-ATIFiniVideo(ScreenPtr pScreen)
-{
-	KdScreenPriv(pScreen);
-	ATIScreenInfo(pScreenPriv);
-	KdVideoAdaptorPtr adapt = atis->pAdaptor;
-	ATIPortPrivPtr pPortPriv;
-	int i;
-
-	if (!adapt)
-		return;
-
-	for (i = 0; i < atis->num_texture_ports; i++) {
-		pPortPriv = (ATIPortPrivPtr)(&adapt->pPortPrivates[i].ptr);
-		REGION_UNINIT(pScreen, &pPortPriv->clip);
-	}
-	xfree(adapt);
-	atis->pAdaptor = NULL;
-}
diff --git a/hw/kdrive/ati/r128_blendtmp.h b/hw/kdrive/ati/r128_blendtmp.h
deleted file mode 100644
index b663eac..0000000
--- a/hw/kdrive/ati/r128_blendtmp.h
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Copyright © 2003 Eric Anholt, Anders Carlsson
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Eric Anholt not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  Eric Anholt makes no
- * representations about the suitability of this software for any purpose.  It
- * is provided "as is" without express or implied warranty.
- *
- * ERIC ANHOLT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL ERIC ANHOLT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifdef USE_DMA
-#define TAG(x)		x##DMA
-#define LOCALS		RING_LOCALS; \
-			(void)atic
-#define BEGIN(x)	BEGIN_RING(x * 2)
-#define OUT_REG(reg, val) OUT_RING_REG(reg, val)
-#define END()		ADVANCE_RING()
-#else
-#define TAG(x)		x##MMIO
-#define LOCALS		char *mmio = atic->reg_base
-#define BEGIN(x)	ATIWaitAvailMMIO(x)
-#define OUT_REG(reg, val) MMIO_OUT32(mmio, (reg), (val))
-#define END()
-#endif
-
-static Bool
-TAG(R128PrepareBlend)(int op, PicturePtr pSrcPicture, PicturePtr pDstPicture,
-    PixmapPtr pSrc, PixmapPtr pDst)
-{
-	KdScreenPriv(pDst->drawable.pScreen);
-	ATIScreenInfo(pScreenPriv);
-	ATICardInfo(pScreenPriv);
-	CARD32 dstDatatype, srcDatatype;
-	LOCALS;
-
-	accel_atis = atis;
-
-	if (!TAG(ATISetup)(pDst, pSrc))
-		return FALSE;
-
-	src_bpp = pSrc->drawable.bitsPerPixel;
-	is_repeat = pSrcPicture->repeat;
-
-	if (op >= sizeof(R128BlendOp)/sizeof(R128BlendOp[0]))
-		ATI_FALLBACK(("Unsupported op 0x%x\n", op));
-	if (pSrcPicture->repeat && (pSrc->drawable.width != 1 ||
-	    pSrc->drawable.height != 1))
-		ATI_FALLBACK(("repeat unsupported\n"));
-	if (pSrcPicture->transform != NULL)
-		ATI_FALLBACK(("transform unsupported\n"));
-	if (!R128GetDatatypePict(pDstPicture->format, &dstDatatype))
-		ATI_FALLBACK(("Unsupported dest format 0x%x\n",
-		    pDstPicture->format));
-	if (!R128GetDatatypePict(pSrcPicture->format, &srcDatatype))
-		ATI_FALLBACK(("Unsupported src format 0x%x\n",
-		    pSrcPicture->format));
-
-	BEGIN(11);
-	OUT_REG(RADEON_REG_DP_GUI_MASTER_CNTL,
-	    (dstDatatype << 8) |
-	    RADEON_GMC_SRC_DATATYPE_COLOR |
-	    RADEON_GMC_DST_PITCH_OFFSET_CNTL |
-	    RADEON_GMC_CLR_CMP_CNTL_DIS |
-	    RADEON_GMC_AUX_CLIP_DIS |
-	    (ATIBltRop[3] << 16) |
-	    RADEON_GMC_3D_FCN_EN);
-	OUT_REG(R128_REG_TEX_CNTL_C, R128_TEX_ALPHA_EN | R128_TEX_CACHE_FLUSH);
-	OUT_REG(R128_REG_PRIM_TEXTURE_COMBINE_CNTL_C, 0);
-	OUT_REG(R128_REG_SCALE_3D_CNTL,
-	    R128_SCALE_3D_SCALE |
-	    R128BlendOp[op] |
-	    R128_TEX_MAP_ALPHA_IN_TEXTURE);
-	OUT_REG(R128_REG_SCALE_3D_DATATYPE, srcDatatype);
-	OUT_REG(R128_REG_SCALE_PITCH, src_pitch / src_bpp);
-	/* 4.16 fixed point scaling factor? */
-	if (is_repeat) {
-		OUT_REG(R128_REG_SCALE_X_INC, 0);
-		OUT_REG(R128_REG_SCALE_Y_INC, 0);
-	} else {
-		OUT_REG(R128_REG_SCALE_X_INC, 65536);
-		OUT_REG(R128_REG_SCALE_Y_INC, 65536);
-	}
-	OUT_REG(R128_REG_SCALE_HACC, 0x00000000);
-	OUT_REG(R128_REG_SCALE_VACC, 0x00000000);
-	OUT_REG(RADEON_REG_DP_CNTL, 
-	    RADEON_DST_X_LEFT_TO_RIGHT | RADEON_DST_Y_TOP_TO_BOTTOM );
-	END();
-
-	return TRUE;
-}
-
-static void
-TAG(R128Blend)(int srcX, int srcY, int dstX, int dstY, int width, int height)
-{
-	ATIScreenInfo *atis = accel_atis;
-	ATICardInfo *atic = atis->atic;
-	LOCALS;
-
-	if (is_repeat) {
-		srcX = 0;
-		srcY = 0;
-	}
-
-	BEGIN(4);
-	OUT_REG(R128_REG_SCALE_OFFSET_0, src_offset + srcY * src_pitch + srcX *
-	    (src_bpp >> 3));
-	OUT_REG(R128_REG_SCALE_SRC_HEIGHT_WIDTH, (height << 16) | width);
-	OUT_REG(R128_REG_SCALE_DST_X_Y, (dstX << 16) | dstY);
-	OUT_REG(R128_REG_SCALE_DST_HEIGHT_WIDTH, (height << 16) | width);
-	END();
-}
-
-static void
-TAG(R128DoneBlend)(void)
-{
-}
-
-#undef TAG
-#undef LOCALS
-#undef BEGIN
-#undef OUT_REG
-#undef END
diff --git a/hw/kdrive/ati/r128_common.h b/hw/kdrive/ati/r128_common.h
deleted file mode 100644
index 862fea5..0000000
--- a/hw/kdrive/ati/r128_common.h
+++ /dev/null
@@ -1,170 +0,0 @@
-/* r128_common.h -- common header definitions for R128 2D/3D/DRM suite
- * Created: Sun Apr  9 18:16:28 2000 by kevin at precisioninsight.com
- *
- * Copyright 1999, 2000 Precision Insight, Inc., Cedar Park, Texas.
- * 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.
- *
- * Author:
- *   Gareth Hughes <gareth at valinux.com>
- *   Kevin E. Martin <martin at valinux.com>
- *
- * Converted to common header format:
- *   Jens Owen <jens at tungstengraphics.com>
- *
- *
- */
-
-#ifndef _R128_COMMON_H_
-#define _R128_COMMON_H_
-
-#include "X11/Xmd.h"
-
-/*
- * WARNING: If you change any of these defines, make sure to change
- * the kernel include file as well (r128_drm.h)
- */
-
-/* Driver specific DRM command indices
- * NOTE: these are not OS specific, but they are driver specific
- */
-#define DRM_R128_INIT           0x00
-#define DRM_R128_CCE_START      0x01
-#define DRM_R128_CCE_STOP       0x02
-#define DRM_R128_CCE_RESET      0x03
-#define DRM_R128_CCE_IDLE       0x04
-#define DRM_R128_UNDEFINED1     0x05
-#define DRM_R128_RESET          0x06
-#define DRM_R128_SWAP           0x07
-#define DRM_R128_CLEAR          0x08
-#define DRM_R128_VERTEX         0x09
-#define DRM_R128_INDICES        0x0a
-#define DRM_R128_BLIT           0x0b
-#define DRM_R128_DEPTH          0x0c
-#define DRM_R128_STIPPLE        0x0d
-#define DRM_R128_UNDEFINED2     0x0e
-#define DRM_R128_INDIRECT       0x0f
-#define DRM_R128_FULLSCREEN     0x10
-#define DRM_R128_CLEAR2         0x11
-#define DRM_R128_GETPARAM       0x12
-#define DRM_R128_FLIP           0x13
-
-#define DRM_R128_FRONT_BUFFER	0x1
-#define DRM_R128_BACK_BUFFER	0x2
-#define DRM_R128_DEPTH_BUFFER	0x4
-
-typedef struct {
-   enum {
-      DRM_R128_INIT_CCE    = 0x01,
-      DRM_R128_CLEANUP_CCE = 0x02
-   } func;
-   unsigned long sarea_priv_offset;
-   int is_pci;
-   int cce_mode;
-   int cce_secure;		/* FIXME: Deprecated, we should remove this */
-   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;
-} drmR128Init;
-
-typedef struct {
-   int flush;
-   int idle;
-} drmR128CCEStop;
-
-typedef struct {
-   int idx;
-   int start;
-   int end;
-   int discard;
-} drmR128Indirect;
-
-typedef struct {
-   int idx;
-   int pitch;
-   int offset;
-   int format;
-   unsigned short x, y;
-   unsigned short width, height;
-} drmR128Blit;
-
-typedef struct {
-   enum {
-      DRM_R128_WRITE_SPAN         = 0x01,
-      DRM_R128_WRITE_PIXELS       = 0x02,
-      DRM_R128_READ_SPAN          = 0x03,
-      DRM_R128_READ_PIXELS        = 0x04
-   } func;
-   int n;
-   int *x;
-   int *y;
-   unsigned int *buffer;
-   unsigned char *mask;
-} drmR128Depth;
-
-typedef struct {
-   int prim;
-   int idx;                        /* Index of vertex buffer */
-   int count;                      /* Number of vertices in buffer */
-   int discard;                    /* Client finished with buffer? */
-} drmR128Vertex;
-
-typedef struct {
-   unsigned int *mask;
-} drmR128Stipple;
-
-typedef struct {
-   unsigned int flags;
-   unsigned int clear_color;
-   unsigned int clear_depth;
-   unsigned int color_mask;
-   unsigned int depth_mask;
-} drmR128Clear;
-
-typedef struct {
-   enum {
-      DRM_R128_INIT_FULLSCREEN    = 0x01,
-      DRM_R128_CLEANUP_FULLSCREEN = 0x02
-   } func;
-} drmR128Fullscreen;
-
-typedef struct drm_r128_getparam {
-	int param;
-	int *value;
-} drmR128GetParam;
-
-#define R128_PARAM_IRQ_NR            1
-
-#endif
diff --git a/hw/kdrive/ati/r128_composite.c b/hw/kdrive/ati/r128_composite.c
deleted file mode 100644
index 0d18ebf..0000000
--- a/hw/kdrive/ati/r128_composite.c
+++ /dev/null
@@ -1,564 +0,0 @@
-/*
- * Copyright © 2003 Eric Anholt, Anders Carlsson
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Eric Anholt not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  Eric Anholt makes no
- * representations about the suitability of this software for any purpose.  It
- * is provided "as is" without express or implied warranty.
- *
- * ERIC ANHOLT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL ERIC ANHOLT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include "ati.h"
-#include "ati_reg.h"
-#include "ati_dma.h"
-#include "ati_draw.h"
-
-extern ATIScreenInfo *accel_atis;
-extern int sample_count;
-extern float sample_offsets_x[255];
-extern float sample_offsets_y[255];
-extern CARD8 ATIBltRop[16];
-
-static int widths[2] = {1,1};
-static int heights[2] = {1,1};
-static Bool is_transform[2];
-static PictTransform *transform[2];
-
-struct blendinfo {
-	Bool dst_alpha;
-	Bool src_alpha;
-	CARD32 blendctl;
-};
-
-static struct blendinfo R128BlendOp[] = {
-	/* Clear */
-	{0, 0, R128_SBLEND_ZERO		 | R128_DBLEND_ZERO},
-	/* Src */
-	{0, 0, R128_SBLEND_ONE		 | R128_DBLEND_ZERO},
-	/* Dst */
-	{0, 0, R128_SBLEND_ZERO		 | R128_DBLEND_ONE},
-	/* Over */
-	{0, 1, R128_SBLEND_ONE		 | R128_DBLEND_INV_SRC_ALPHA},
-	/* OverReverse */
-	{1, 0, R128_SBLEND_INV_DST_ALPHA | R128_DBLEND_ONE},
-	/* In */
-	{1, 0, R128_SBLEND_DST_ALPHA	 | R128_DBLEND_ZERO},
-	/* InReverse */
-	{0, 1, R128_SBLEND_ZERO		 | R128_DBLEND_SRC_ALPHA},
-	/* Out */
-	{1, 0, R128_SBLEND_INV_DST_ALPHA | R128_DBLEND_ZERO},
-	/* OutReverse */
-	{0, 1, R128_SBLEND_ZERO		 | R128_DBLEND_INV_SRC_ALPHA},
-	/* Atop */
-	{1, 1, R128_SBLEND_DST_ALPHA	 | R128_DBLEND_INV_SRC_ALPHA},
-	/* AtopReverse */
-	{1, 1, R128_SBLEND_INV_DST_ALPHA | R128_DBLEND_SRC_ALPHA},
-	/* Xor */
-	{1, 1, R128_SBLEND_INV_DST_ALPHA | R128_DBLEND_INV_SRC_ALPHA},
-	/* Add */
-	{0, 0, R128_SBLEND_ONE		 | R128_DBLEND_ONE},
-};
-
-static Bool
-R128GetDatatypePict(CARD32 format, CARD32 *type)
-{
-	switch (format) {
-	case PICT_a1r5g5b5:
-	case PICT_x1r5g5b5:
-		*type = R128_DATATYPE_ARGB1555;
-		return TRUE;
-	case PICT_r5g6b5:
-		*type = R128_DATATYPE_RGB565;
-		return TRUE;
-	case PICT_a8r8g8b8:
-	case PICT_x8r8g8b8:
-		*type = R128_DATATYPE_ARGB8888;
-		return TRUE;
-	default:
-		return FALSE;
-	}
-
-}
-
-static Bool
-R128CheckCompositeTexture(PicturePtr pPict)
-{
-	int w = pPict->pDrawable->width;
-	int h = pPict->pDrawable->height;
-
-	if (w > (1 << 10) || h > (1 << 10))
-		ATI_FALLBACK(("Picture w/h too large (%dx%d)\n", w, h));
-	if (pPict->repeat && ((w & (w - 1)) != 0 || (h & (h - 1)) != 0))
-		ATI_FALLBACK(("NPOT repeat unsupported (%dx%d)\n", w, h));
-
-	switch (pPict->format) {
-	case PICT_a8:
-	case PICT_a1r5g5b5:
-	case PICT_a4r4g4b4:
-	case PICT_r5g6b5:
-	case PICT_a8r8g8b8:
-		break;
-	default:
-		ATI_FALLBACK(("Unsupported picture format 0x%x\n",
-		    pPict->format));
-	}
-
-	return TRUE;
-}
-
-Bool
-R128CheckComposite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture,
-    PicturePtr pDstPicture)
-{
-	CARD32 dstDatatype;
-
-	if (op >= sizeof(R128BlendOp)/sizeof(R128BlendOp[0]))
-		ATI_FALLBACK(("Unsupported op 0x%x\n", op));
-	if (pDstPicture->format == PICT_a8) {
-		if (R128BlendOp[op].src_alpha || R128BlendOp[op].dst_alpha ||
-		    pMaskPicture != NULL)
-			ATI_FALLBACK(("alpha blending unsupported with "
-			    "A8 dst?\n"));
-	} else if (!R128GetDatatypePict(pDstPicture->format, &dstDatatype)) {
-		ATI_FALLBACK(("Unsupported dest format 0x%x\n",
-		    pDstPicture->format));
-	}
-	if (pMaskPicture != NULL && pMaskPicture->componentAlpha &&
-	    R128BlendOp[op].src_alpha)
-		ATI_FALLBACK(("Component alpha not supported with source alpha "
-		    "blending.\n"));
-
-	if (!R128CheckCompositeTexture(pSrcPicture))
-		return FALSE;
-	if (pMaskPicture != NULL && !R128CheckCompositeTexture(pMaskPicture))
-		return FALSE;
-
-	return TRUE;
-}
-
-static Bool
-R128TextureSetup(PicturePtr pPict, PixmapPtr pPix, int unit, CARD32 *txsize,
-    CARD32 *tex_cntl_c)
-{
-	int w = pPict->pDrawable->width;
-	int h = pPict->pDrawable->height;
-	int bytepp, shift, l2w, l2h, l2p;
-	int pitch;
-
-	pitch = pPix->devKind;
-	if ((pitch & (pitch - 1)) != 0)
-		ATI_FALLBACK(("NPOT pitch 0x%x unsupported\n", pitch));
-
-	switch (pPict->format) {
-	case PICT_a8:
-		/* DATATYPE_RGB8 appears to expand the value into the alpha
-		 * channel like we want.  We then blank out the R,G,B channels
-		 * as necessary using the combiners.
-		 */
-		*tex_cntl_c = R128_DATATYPE_RGB8 << R128_TEX_DATATYPE_SHIFT;
-		break;
-	case PICT_a1r5g5b5:
-		*tex_cntl_c = R128_DATATYPE_ARGB1555 << R128_TEX_DATATYPE_SHIFT;
-		break;
-	case PICT_a4r4g4b4:
-		*tex_cntl_c = R128_DATATYPE_ARGB4444 << R128_TEX_DATATYPE_SHIFT;
-		break;
-	case PICT_r5g6b5:
-		*tex_cntl_c = R128_DATATYPE_RGB565 << R128_TEX_DATATYPE_SHIFT;
-		break;
-	case PICT_a8r8g8b8:
-		*tex_cntl_c = R128_DATATYPE_ARGB8888 << R128_TEX_DATATYPE_SHIFT;
-		break;
-	default:
-		return FALSE;
-	}
-	bytepp = PICT_FORMAT_BPP(pPict->format) / 8;
-
-	*tex_cntl_c |= R128_MIP_MAP_DISABLE;
-
-	if (pPict->filter == PictFilterBilinear)
-		*tex_cntl_c |= R128_MIN_BLEND_LINEAR | R128_MAG_BLEND_LINEAR;
-
-	if (unit == 0)
-		shift = 0;
-	else {
-		shift = 16;
-		*tex_cntl_c |= R128_SEC_SELECT_SEC_ST;
-	}
-
-	/* ATILog2 returns -1 for value of 0 */
-	l2w = ATILog2(w - 1) + 1;
-	l2h = ATILog2(h - 1) + 1;
-	l2p = ATILog2(pPix->devKind / bytepp);
-
-	if (pPict->repeat && w == 1 && h == 1)
-		l2p = 0;
-	else if (pPict->repeat && l2p != l2w)
-		ATI_FALLBACK(("Repeat not supported for pitch != width\n"));
-	l2w = l2p;
-
-	widths[unit] = 1 << l2w;
-	heights[unit] = 1 << l2h;
-	*txsize |= l2p << (R128_TEX_PITCH_SHIFT + shift);
-	*txsize |= ((l2w > l2h) ? l2w : l2h) << (R128_TEX_SIZE_SHIFT + shift);
-	*txsize |= l2h << (R128_TEX_HEIGHT_SHIFT + shift);
-
-	if (pPict->transform != 0) {
-		is_transform[unit] = TRUE;
-		transform[unit] = pPict->transform;
-	} else {
-		is_transform[unit] = FALSE;
-	}
-
-	return TRUE;
-}
-
-Bool
-R128PrepareComposite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture,
-    PicturePtr pDstPicture, PixmapPtr pSrc, PixmapPtr pMask, PixmapPtr pDst)
-{
-	KdScreenPriv(pDst->drawable.pScreen);
-	ATIScreenInfo(pScreenPriv);
-	CARD32 txsize = 0, prim_tex_cntl_c, sec_tex_cntl_c = 0, dstDatatype;
-	CARD32 dst_pitch_offset, color_factor, in_color_factor, alpha_comb;
-	CARD32 blend_cntl;
-	int i;
-	RING_LOCALS;
-
-	accel_atis = atis;
-
-	if (pDstPicture->format == PICT_a8)
-		dstDatatype = R128_DATATYPE_Y8;
-	else
-		R128GetDatatypePict(pDstPicture->format, &dstDatatype);
-
-	if (!R128TextureSetup(pSrcPicture, pSrc, 0, &txsize, &prim_tex_cntl_c))
-		return FALSE;
-	if (pMask != NULL && !R128TextureSetup(pMaskPicture, pMask, 1, &txsize,
-	    &sec_tex_cntl_c))
-		return FALSE;
-	else if (pMask == NULL)
-		is_transform[1] = FALSE;
-
-	if (!ATIGetPixmapOffsetPitch(pDst, &dst_pitch_offset))
-		return FALSE;
-
-	blend_cntl = R128BlendOp[op].blendctl;
-	if (PICT_FORMAT_A(pDstPicture->format) == 0 &&
-	    R128BlendOp[op].dst_alpha) {
-		if ((blend_cntl & R128_SBLEND_MASK) ==
-		    R128_SBLEND_DST_ALPHA)
-			blend_cntl = (blend_cntl & ~R128_SBLEND_MASK) |
-			    R128_SBLEND_ONE;
-		else if ((blend_cntl & R128_SBLEND_MASK) ==
-		    R128_SBLEND_INV_DST_ALPHA)
-			blend_cntl = (blend_cntl & ~R128_SBLEND_MASK) |
-			    R128_SBLEND_ZERO;
-	}
-
-	BEGIN_DMA(12);
-	OUT_REG(R128_REG_SCALE_3D_CNTL,
-	    R128_SCALE_3D_TEXMAP_SHADE |
-	    R128_SCALE_PIX_REPLICATE |
-	    R128_TEX_CACHE_SPLIT |
-	    R128_TEX_MAP_ALPHA_IN_TEXTURE |
-	    R128_TEX_CACHE_LINE_SIZE_4QW);
-	OUT_REG(ATI_REG_DST_PITCH_OFFSET, dst_pitch_offset);
-	OUT_REG(ATI_REG_DP_GUI_MASTER_CNTL,
-	    ATI_GMC_DST_PITCH_OFFSET_CNTL |
-	    ATI_GMC_BRUSH_SOLID_COLOR |
-	    (dstDatatype << 8) |
-	    ATI_GMC_SRC_DATATYPE_COLOR |
-	    (ATIBltRop[GXcopy] << 16) |
-	    ATI_DP_SRC_SOURCE_MEMORY |
-	    R128_GMC_3D_FCN_EN |
-	    ATI_GMC_CLR_CMP_CNTL_DIS |
-	    R128_GMC_AUX_CLIP_DIS |
-	    ATI_GMC_WR_MSK_DIS);
-	OUT_REG(R128_REG_MISC_3D_STATE_CNTL,
-	    R128_MISC_SCALE_3D_TEXMAP_SHADE |
-	    R128_MISC_SCALE_PIX_REPLICATE |
-	    R128_ALPHA_COMB_ADD_CLAMP |
-	    blend_cntl);
-	OUT_REG(R128_REG_TEX_CNTL_C,
-	    R128_TEXMAP_ENABLE |
-	    ((pMask != NULL) ? R128_SEC_TEXMAP_ENABLE : 0) |
-	    R128_ALPHA_ENABLE |
-	    R128_TEX_CACHE_FLUSH);
-	OUT_REG(R128_REG_PC_GUI_CTLSTAT, R128_PC_FLUSH_GUI);
-	END_DMA();
-
-	/* IN operator: Without a mask, only the first texture unit is enabled.
-	 * With a mask, we put the source in the first unit and have it pass
-	 * through as input to the 2nd.  The 2nd unit takes the incoming source
-	 * pixel and modulates it with either the alpha or each of the channels
-	 * in the mask, depending on componentAlpha.
-	 */
-	BEGIN_DMA(15);
-	OUT_RING(DMA_PACKET0(R128_REG_PRIM_TEX_CNTL_C, 14));
-	OUT_RING_REG(R128_REG_PRIM_TEX_CNTL_C, prim_tex_cntl_c);
-
-	/* If this is the only stage and the dest is a8, route the alpha result 
-	 * to the color (red channel, in particular), too.  Otherwise, be sure
-	 * to zero out color channels of an a8 source.
-	 */
-	if (pMaskPicture == NULL && pDstPicture->format == PICT_a8)
-		color_factor = R128_COLOR_FACTOR_ALPHA;
-	else if (pSrcPicture->format == PICT_a8)
-		color_factor = R128_COLOR_FACTOR_CONST_COLOR;
-	else
-		color_factor = R128_COLOR_FACTOR_TEX;
-
-	if (PICT_FORMAT_A(pSrcPicture->format) == 0)
-		alpha_comb = R128_COMB_ALPHA_COPY_INP;
-	else
-		alpha_comb = R128_COMB_ALPHA_DIS;
-
-	OUT_RING_REG(R128_REG_PRIM_TEXTURE_COMBINE_CNTL_C,
-	    R128_COMB_COPY |
-	    color_factor |
-	    R128_INPUT_FACTOR_INT_COLOR |
-	    alpha_comb |
-	    R128_ALPHA_FACTOR_TEX_ALPHA |
-	    R128_INP_FACTOR_A_CONST_ALPHA);
-	OUT_RING_REG(R128_REG_TEX_SIZE_PITCH_C, txsize);
-	/* We could save some output by only writing the offset register that
-	 * will actually be used.  On the other hand, this is easy.
-	 */
-	for (i = 0; i <= 10; i++) {
-		OUT_RING_REG(R128_REG_PRIM_TEX_0_OFFSET_C + 4 * i,
-		    ((CARD8 *)pSrc->devPrivate.ptr -
-		    pScreenPriv->screen->memory_base));
-	}
-	END_DMA();
-
-	if (pMask != NULL) {
-		BEGIN_DMA(14);
-		OUT_RING(DMA_PACKET0(R128_REG_SEC_TEX_CNTL_C, 13));
-		OUT_RING_REG(R128_REG_SEC_TEX_CNTL_C, sec_tex_cntl_c);
-
-		if (pDstPicture->format == PICT_a8) {
-			color_factor = R128_COLOR_FACTOR_ALPHA;
-			in_color_factor = R128_INPUT_FACTOR_PREV_ALPHA;
-		} else if (pMaskPicture->componentAlpha) {
-			color_factor = R128_COLOR_FACTOR_TEX;
-			in_color_factor = R128_INPUT_FACTOR_PREV_COLOR;
-		} else {
-			color_factor = R128_COLOR_FACTOR_ALPHA;
-			in_color_factor = R128_INPUT_FACTOR_PREV_COLOR;
-		}
-
-		OUT_RING_REG(R128_REG_SEC_TEXTURE_COMBINE_CNTL_C,
-		    R128_COMB_MODULATE |
-		    color_factor |
-		    in_color_factor |
-		    R128_COMB_ALPHA_MODULATE |
-		    R128_ALPHA_FACTOR_TEX_ALPHA |
-		    R128_INP_FACTOR_A_PREV_ALPHA);
-		for (i = 0; i <= 10; i++) {
-			OUT_RING_REG(R128_REG_SEC_TEX_0_OFFSET_C + 4 * i,
-			    ((CARD8 *)pMask->devPrivate.ptr -
-			    pScreenPriv->screen->memory_base));
-		}
-		END_DMA();
-	}
-
-	return TRUE;
-}
-#define VTX_RING_COUNT 8
-
-#define VTX_OUT(_dstX, _dstY, _srcX, _srcY, _maskX, _maskY)		\
-do {									\
-	OUT_RING_F((_dstX));						\
-	OUT_RING_F(((float)(_dstY)) + .125);				\
-	OUT_RING_F(0.0);						\
-	OUT_RING_F(1.0);						\
-	OUT_RING_F((((float)(_srcX)) + 0.5) / (widths[0]));		\
-	OUT_RING_F((((float)(_srcY)) + 0.5) / (heights[0]));		\
-	OUT_RING_F((((float)(_maskX)) + 0.5) / (widths[1]));		\
-	OUT_RING_F((((float)(_maskY)) + 0.5) / (heights[1]));		\
-} while (0)
-
-void
-R128Composite(int srcX, int srcY, int maskX, int maskY, int dstX, int dstY,
-    int w, int h)
-{
-	ATIScreenInfo *atis = accel_atis;
-	int srcXend, srcYend, maskXend, maskYend;
-	PictVector v;
-	RING_LOCALS;
-
-	/*ErrorF("R128Composite (%d,%d) (%d,%d) (%d,%d) (%d,%d)\n",
-	    srcX, srcY, maskX, maskY,dstX, dstY, w, h);*/
-
-	srcXend = srcX + w;
-	srcYend = srcY + h;
-	maskXend = maskX + w;
-	maskYend = maskY + h;
-	if (is_transform[0]) {
-		v.vector[0] = IntToxFixed(srcX);
-		v.vector[1] = IntToxFixed(srcY);
-		v.vector[2] = xFixed1;
-		PictureTransformPoint(transform[0], &v);
-		srcX = xFixedToInt(v.vector[0]);
-		srcY = xFixedToInt(v.vector[1]);
-		v.vector[0] = IntToxFixed(srcXend);
-		v.vector[1] = IntToxFixed(srcYend);
-		v.vector[2] = xFixed1;
-		PictureTransformPoint(transform[0], &v);
-		srcXend = xFixedToInt(v.vector[0]);
-		srcYend = xFixedToInt(v.vector[1]);
-	}
-	if (is_transform[1]) {
-		v.vector[0] = IntToxFixed(maskX);
-		v.vector[1] = IntToxFixed(maskY);
-		v.vector[2] = xFixed1;
-		PictureTransformPoint(transform[1], &v);
-		maskX = xFixedToInt(v.vector[0]);
-		maskY = xFixedToInt(v.vector[1]);
-		v.vector[0] = IntToxFixed(maskXend);
-		v.vector[1] = IntToxFixed(maskYend);
-		v.vector[2] = xFixed1;
-		PictureTransformPoint(transform[1], &v);
-		maskXend = xFixedToInt(v.vector[0]);
-		maskYend = xFixedToInt(v.vector[1]);
-	}
-
-	BEGIN_DMA(3 + 4 * VTX_RING_COUNT);
-	OUT_RING(DMA_PACKET3(ATI_CCE_PACKET3_3D_RNDR_GEN_PRIM,
-	    2 + 4 * VTX_RING_COUNT));
-	OUT_RING(R128_CCE_VC_FRMT_RHW |
-	    R128_CCE_VC_FRMT_S_T |
-	    R128_CCE_VC_FRMT_S2_T2);
-	OUT_RING(R128_CCE_VC_CNTL_PRIM_TYPE_TRI_FAN |
-	    R128_CCE_VC_CNTL_PRIM_WALK_RING |
-	    (4 << R128_CCE_VC_CNTL_NUM_SHIFT));
-
-	VTX_OUT(dstX,     dstY,     srcX,    srcY,    maskX,    maskY);
-	VTX_OUT(dstX,     dstY + h, srcX,    srcYend, maskX,    maskYend);
-	VTX_OUT(dstX + w, dstY + h, srcXend, srcYend, maskXend, maskYend);
-	VTX_OUT(dstX + w, dstY,     srcXend, srcY,    maskXend, maskY);
-
-	END_DMA();
-}
-
-void
-R128DoneComposite(void)
-{
-}
-
-Bool
-R128PrepareTrapezoids(PicturePtr pDstPicture, PixmapPtr pDst)
-{
-	KdScreenPriv(pDst->drawable.pScreen);
-	ATIScreenInfo(pScreenPriv);
-	CARD32 dst_pitch_offset;
-	RING_LOCALS;
-
-	accel_atis = atis;
-
-	if (!ATIGetPixmapOffsetPitch(pDst, &dst_pitch_offset))
-		return FALSE;
-
-	BEGIN_DMA(18);
-	OUT_REG(R128_REG_SCALE_3D_CNTL,
-	    R128_SCALE_3D_TEXMAP_SHADE |
-	    R128_SCALE_PIX_REPLICATE |
-	    R128_TEX_CACHE_SPLIT |
-	    R128_TEX_CACHE_LINE_SIZE_4QW);
-	OUT_REG(ATI_REG_DST_PITCH_OFFSET, dst_pitch_offset);
-	OUT_REG(ATI_REG_DP_GUI_MASTER_CNTL,
-	    ATI_GMC_DST_PITCH_OFFSET_CNTL |
-	    ATI_GMC_BRUSH_SOLID_COLOR |
-	    (R128_DATATYPE_RGB8 << 8) |
-	    ATI_GMC_SRC_DATATYPE_COLOR |
-	    (ATIBltRop[GXcopy] << 16) |
-	    ATI_DP_SRC_SOURCE_MEMORY |
-	    R128_GMC_3D_FCN_EN |
-	    ATI_GMC_CLR_CMP_CNTL_DIS |
-	    ATI_GMC_WR_MSK_DIS);
-	OUT_REG(R128_REG_MISC_3D_STATE_CNTL,
-	    R128_MISC_SCALE_3D_TEXMAP_SHADE |
-	    R128_MISC_SCALE_PIX_REPLICATE |
-	    R128_ALPHA_COMB_ADD_CLAMP | 
-	    R128BlendOp[PictOpAdd].blendctl);
-	OUT_REG(R128_REG_TEX_CNTL_C,
-	    R128_ALPHA_ENABLE);
-	OUT_REG(R128_REG_PC_GUI_CTLSTAT, R128_PC_FLUSH_GUI);
-
-	OUT_RING(DMA_PACKET0(R128_REG_AUX_SC_CNTL, 5));
-	OUT_RING_REG(R128_REG_AUX_SC_CNTL, R128_AUX1_SC_ENB);
-	OUT_RING_REG(R128_REG_AUX1_SC_LEFT, 0);
-	OUT_RING_REG(R128_REG_AUX1_SC_RIGHT, pDst->drawable.width);
-	OUT_RING_REG(R128_REG_AUX1_SC_TOP, 0);
-	OUT_RING_REG(R128_REG_AUX1_SC_BOTTOM, pDst->drawable.height);
-	END_DMA();
-
-	return TRUE;
-}
-
-#define TRAP_VERT_RING_COUNT 4
-
-#define TRAP_VERT(_x, _y)						\
-do {									\
-	OUT_RING_F((_x) + sample_x);					\
-	OUT_RING_F((_y) + 0.125 + sample_y);				\
-	OUT_RING_F(0.0);						\
-	OUT_RING(0x01010101);						\
-} while (0)
-
-void
-R128Trapezoids(KaaTrapezoid *traps, int ntraps)
-{
-	ATIScreenInfo *atis = accel_atis;
-	RING_LOCALS;
-
-	while (ntraps > 0) {
-		int i, sample, count, vertcount;
-
-		count = 0xffff / 4 / sample_count;
-		if (count > ntraps)
-			count = ntraps;
-		vertcount = count * sample_count * 4;
-
-		BEGIN_DMA(3 + vertcount * TRAP_VERT_RING_COUNT);
-		OUT_RING(DMA_PACKET3(ATI_CCE_PACKET3_3D_RNDR_GEN_PRIM,
-		    2 + vertcount * TRAP_VERT_RING_COUNT));
-		OUT_RING(R128_CCE_VC_FRMT_DIFFUSE_ARGB);
-		OUT_RING(R128_CCE_VC_CNTL_PRIM_TYPE_TRI_FAN |
-		    R128_CCE_VC_CNTL_PRIM_WALK_RING |
-		    (vertcount << R128_CCE_VC_CNTL_NUM_SHIFT));
-
-		for (i = 0; i < count; i++) {
-		    for (sample = 0; sample < sample_count; sample++) {
-			float sample_x = sample_offsets_x[sample];
-			float sample_y = sample_offsets_y[sample];
-			TRAP_VERT(traps[i].tl, traps[i].ty);
-			TRAP_VERT(traps[i].bl, traps[i].by);
-			TRAP_VERT(traps[i].br, traps[i].by);
-			TRAP_VERT(traps[i].tr, traps[i].ty);
-		    }
-		}
-		END_DMA();
-
-		ntraps -= count;
-		traps += count;
-	}
-}
-
-void
-R128DoneTrapezoids(void)
-{
-}
diff --git a/hw/kdrive/ati/r128_sarea.h b/hw/kdrive/ati/r128_sarea.h
deleted file mode 100644
index 6fbd05e..0000000
--- a/hw/kdrive/ati/r128_sarea.h
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- * Copyright 1999, 2000 ATI Technologies Inc., Markham, Ontario,
- *                      Precision Insight, Inc., Cedar Park, Texas, and
- *                      VA Linux Systems Inc., Fremont, 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 on 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
- * NON-INFRINGEMENT.  IN NO EVENT SHALL ATI, PRECISION INSIGHT, VA LINUX
- * SYSTEMS AND/OR THEIR 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:
- *   Kevin E. Martin <martin at valinux.com>
- *   Gareth Hughes <gareth at valinux.com>
- *
- */
-
-#ifndef _R128_SAREA_H_
-#define _R128_SAREA_H_
-
-/* WARNING: If you change any of these defines, make sure to change the
- * defines in the kernel file (r128_drm.h)
- */
-#ifndef __R128_SAREA_DEFINES__
-#define __R128_SAREA_DEFINES__
-
-/* What needs to be changed for the current vertex buffer?
- */
-#define R128_UPLOAD_CONTEXT		0x001
-#define R128_UPLOAD_SETUP		0x002
-#define R128_UPLOAD_TEX0		0x004
-#define R128_UPLOAD_TEX1		0x008
-#define R128_UPLOAD_TEX0IMAGES		0x010
-#define R128_UPLOAD_TEX1IMAGES		0x020
-#define R128_UPLOAD_CORE		0x040
-#define R128_UPLOAD_MASKS		0x080
-#define R128_UPLOAD_WINDOW		0x100
-#define R128_UPLOAD_CLIPRECTS		0x200	/* handled client-side */
-#define R128_REQUIRE_QUIESCENCE		0x400
-#define R128_UPLOAD_ALL			0x7ff
-
-#define R128_FRONT			0x1
-#define R128_BACK			0x2
-#define R128_DEPTH			0x4
-
-/* Primitive types
- */
-#define R128_POINTS			0x1
-#define R128_LINES			0x2
-#define R128_LINE_STRIP			0x3
-#define R128_TRIANGLES			0x4
-#define R128_TRIANGLE_FAN		0x5
-#define R128_TRIANGLE_STRIP		0x6
-
-/* Vertex/indirect buffer size
- */
-#define R128_BUFFER_SIZE		16384
-
-/* Byte offsets for indirect buffer data
- */
-#define R128_INDEX_PRIM_OFFSET		20
-#define R128_HOSTDATA_BLIT_OFFSET	32
-
-/* Keep these small for testing
- */
-#define R128_NR_SAREA_CLIPRECTS		12
-
-#define R128_NR_CONTEXT_REGS		12
-
-#define R128_MAX_TEXTURE_LEVELS		11
-#define R128_MAX_TEXTURE_UNITS		2
-
-#endif /* __R128_SAREA_DEFINES__ */
-
-typedef struct {
-    /* Context state - can be written in one large chunk */
-    unsigned int dst_pitch_offset_c;
-    unsigned int dp_gui_master_cntl_c;
-    unsigned int sc_top_left_c;
-    unsigned int sc_bottom_right_c;
-    unsigned int z_offset_c;
-    unsigned int z_pitch_c;
-    unsigned int z_sten_cntl_c;
-    unsigned int tex_cntl_c;
-    unsigned int misc_3d_state_cntl_reg;
-    unsigned int texture_clr_cmp_clr_c;
-    unsigned int texture_clr_cmp_msk_c;
-    unsigned int fog_color_c;
-
-    /* Texture state */
-    unsigned int tex_size_pitch_c;
-    unsigned int constant_color_c;
-
-    /* Setup state */
-    unsigned int pm4_vc_fpu_setup;
-    unsigned int setup_cntl;
-
-    /* Mask state */
-    unsigned int dp_write_mask;
-    unsigned int sten_ref_mask_c;
-    unsigned int plane_3d_mask_c;
-
-    /* Window state */
-    unsigned int window_xy_offset;
-
-    /* Core state */
-    unsigned int scale_3d_cntl;
-} r128_context_regs_t;
-
-/* Setup registers for each texture unit
- */
-typedef struct {
-    unsigned int tex_cntl;
-    unsigned int tex_combine_cntl;
-    unsigned int tex_size_pitch;
-    unsigned int tex_offset[R128_MAX_TEXTURE_LEVELS];
-    unsigned int tex_border_color;
-} r128_texture_regs_t;
-
-typedef struct {
-    /* The channel for communication of state information to the kernel
-     * on firing a vertex buffer.
-     */
-    r128_context_regs_t	ContextState;
-    r128_texture_regs_t	TexState[R128_MAX_TEXTURE_UNITS];
-    unsigned int dirty;
-    unsigned int vertsize;
-    unsigned int vc_format;
-
-#ifdef XF86DRI
-    /* The current cliprects, or a subset thereof.
-     */
-    XF86DRIClipRectRec boxes[R128_NR_SAREA_CLIPRECTS];
-    unsigned int nbox;
-#endif
-
-    /* Counters for throttling of rendering clients.
-     */
-    unsigned int last_frame;
-    unsigned int last_dispatch;
-
-    /* Maintain an LRU of contiguous regions of texture space.  If you
-     * think you own a region of texture memory, and it has an age
-     * different to the one you set, then you are mistaken and it has
-     * been stolen by another client.  If global texAge hasn't changed,
-     * there is no need to walk the list.
-     *
-     * These regions can be used as a proxy for the fine-grained texture
-     * information of other clients - by maintaining them in the same
-     * lru which is used to age their own textures, clients have an
-     * approximate lru for the whole of global texture space, and can
-     * make informed decisions as to which areas to kick out.  There is
-     * no need to choose whether to kick out your own texture or someone
-     * else's - simply eject them all in LRU order.
-     */
-				/* Last elt is sentinal */
-    drmTextureRegion texList[ATI_NR_TEX_HEAPS][ATI_NR_TEX_REGIONS+1];
-				/* last time texture was uploaded */
-    unsigned int texAge[ATI_NR_TEX_HEAPS];
-
-    int ctxOwner;		/* last context to upload state */
-    int pfAllowPageFlip;	/* set by the 2d driver, read by the client */
-    int pfCurrentPage;		/* set by kernel, read by others */
-} R128SAREAPriv, *R128SAREAPrivPtr;
-
-#endif
diff --git a/hw/kdrive/ati/radeon_common.h b/hw/kdrive/ati/radeon_common.h
deleted file mode 100644
index 6c416c6..0000000
--- a/hw/kdrive/ati/radeon_common.h
+++ /dev/null
@@ -1,460 +0,0 @@
-/* radeon_common.h -- common header definitions for Radeon 2D/3D/DRM suite
- *
- * 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.
- *
- * Author:
- *   Gareth Hughes <gareth at valinux.com>
- *   Kevin E. Martin <martin at valinux.com>
- *   Keith Whitwell <keith at tungstengraphics.com>
- *
- * Converted to common header format:
- *   Jens Owen <jens at tungstengraphics.com>
- *
- *
- */
-
-#ifndef _RADEON_COMMON_H_
-#define _RADEON_COMMON_H_
-
-#include <inttypes.h>
-
-/* WARNING: If you change any of these defines, make sure to change
- * the kernel include file as well (radeon_drm.h)
- */
-
-/* Driver specific DRM command indices
- * NOTE: these are not OS specific, but they are driver specific
- */
-#define DRM_RADEON_CP_INIT                0x00
-#define DRM_RADEON_CP_START               0x01
-#define DRM_RADEON_CP_STOP                0x02
-#define DRM_RADEON_CP_RESET               0x03
-#define DRM_RADEON_CP_IDLE                0x04
-#define DRM_RADEON_RESET                  0x05
-#define DRM_RADEON_FULLSCREEN             0x06
-#define DRM_RADEON_SWAP                   0x07
-#define DRM_RADEON_CLEAR                  0x08
-#define DRM_RADEON_VERTEX                 0x09
-#define DRM_RADEON_INDICES                0x0a
-#define DRM_RADEON_STIPPLE                0x0c
-#define DRM_RADEON_INDIRECT               0x0d
-#define DRM_RADEON_TEXTURE                0x0e
-#define DRM_RADEON_VERTEX2                0x0f
-#define DRM_RADEON_CMDBUF                 0x10
-#define DRM_RADEON_GETPARAM               0x11
-#define DRM_RADEON_FLIP                   0x12
-#define DRM_RADEON_ALLOC                  0x13
-#define DRM_RADEON_FREE                   0x14
-#define DRM_RADEON_INIT_HEAP              0x15
-#define DRM_RADEON_IRQ_EMIT               0x16
-#define DRM_RADEON_IRQ_WAIT               0x17
-#define DRM_RADEON_CP_RESUME              0x18
-#define DRM_RADEON_SETPARAM               0x19
-#define DRM_RADEON_MAX_DRM_COMMAND_INDEX  0x39
-
-
-#define RADEON_FRONT	0x1
-#define RADEON_BACK	0x2
-#define RADEON_DEPTH	0x4
-#define RADEON_STENCIL	0x8
-
-#define RADEON_CLEAR_X1        0
-#define RADEON_CLEAR_Y1        1
-#define RADEON_CLEAR_X2        2
-#define RADEON_CLEAR_Y2        3
-#define RADEON_CLEAR_DEPTH     4
-
-
-typedef struct {
-   enum {
-      DRM_RADEON_INIT_CP    = 0x01,
-      DRM_RADEON_CLEANUP_CP = 0x02,
-      DRM_RADEON_INIT_R200_CP = 0x03
-   } func;
-   unsigned long sarea_priv_offset;
-   int is_pci;
-   int cp_mode;
-   int gart_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 gart_textures_offset;
-} drmRadeonInit;
-
-typedef struct {
-   int flush;
-   int idle;
-} drmRadeonCPStop;
-
-typedef struct {
-   int idx;
-   int start;
-   int end;
-   int discard;
-} drmRadeonIndirect;
-
-typedef union drmRadeonClearR {
-        float f[5];
-        unsigned int ui[5];
-} drmRadeonClearRect;
-
-typedef struct drmRadeonClearT {
-        unsigned int flags;
-        unsigned int clear_color;
-        unsigned int clear_depth;
-        unsigned int color_mask;
-        unsigned int depth_mask;   /* misnamed field:  should be stencil */
-        drmRadeonClearRect *depth_boxes;
-} drmRadeonClearType;
-
-typedef struct drmRadeonFullscreenT {
-        enum {
-                RADEON_INIT_FULLSCREEN    = 0x01,
-                RADEON_CLEANUP_FULLSCREEN = 0x02
-        } func;
-} drmRadeonFullscreenType;
-
-typedef struct {
-        unsigned int *mask;
-} drmRadeonStipple;
-
-typedef struct {
-        unsigned int x;
-        unsigned int y;
-        unsigned int width;
-        unsigned int height;
-        const void *data;
-} drmRadeonTexImage;
-
-typedef struct {
-        unsigned int offset;
-        int pitch;
-        int format;
-        int width;                      /* Texture image coordinates */
-        int height;
-        drmRadeonTexImage *image;
-} drmRadeonTexture;
-
-
-#define RADEON_MAX_TEXTURE_UNITS 3
-
-/* Layout matches drm_radeon_state_t in linux drm_radeon.h.  
- */
-typedef struct {
-	struct {
-		unsigned int pp_misc;				/* 0x1c14 */
-		unsigned int pp_fog_color;
-		unsigned int re_solid_color;
-		unsigned int rb3d_blendcntl;
-		unsigned int rb3d_depthoffset;
-		unsigned int rb3d_depthpitch;
-		unsigned int rb3d_zstencilcntl;
-		unsigned int pp_cntl;				/* 0x1c38 */
-		unsigned int rb3d_cntl;
-		unsigned int rb3d_coloroffset;
-		unsigned int re_width_height;
-		unsigned int rb3d_colorpitch;
-	} context;
-	struct {
-		unsigned int se_cntl;
-	} setup1;
-	struct {
-		unsigned int se_coord_fmt;			/* 0x1c50 */
-	} vertex;
-	struct {
-		unsigned int re_line_pattern;			/* 0x1cd0 */
-		unsigned int re_line_state;
-		unsigned int se_line_width;			/* 0x1db8 */
-	} line;
-	struct {
-		unsigned int pp_lum_matrix;			/* 0x1d00 */
-		unsigned int pp_rot_matrix_0;			/* 0x1d58 */
-		unsigned int pp_rot_matrix_1;
-	} bumpmap;
-	struct {
-		unsigned int rb3d_stencilrefmask;		/* 0x1d7c */
-		unsigned int rb3d_ropcntl;
-		unsigned int rb3d_planemask;
-	} mask;
-	struct {
-		unsigned int se_vport_xscale;			/* 0x1d98 */
-		unsigned int se_vport_xoffset;
-		unsigned int se_vport_yscale;
-		unsigned int se_vport_yoffset;
-		unsigned int se_vport_zscale;
-		unsigned int se_vport_zoffset;
-	} viewport;
-	struct {
-		unsigned int se_cntl_status;			/* 0x2140 */
-	} setup2;
-	struct {
-		unsigned int re_top_left;	/*ignored*/	/* 0x26c0 */
-		unsigned int re_misc;
-	} misc;
-	struct {
-		unsigned int pp_txfilter;
-		unsigned int pp_txformat;
-		unsigned int pp_txoffset;
-		unsigned int pp_txcblend;
-		unsigned int pp_txablend;
-		unsigned int pp_tfactor;
-		unsigned int pp_border_color;
-	} texture[RADEON_MAX_TEXTURE_UNITS];
-	struct {
-		unsigned int se_zbias_factor; 
-		unsigned int se_zbias_constant;
-	} zbias;
-	unsigned int dirty;
-} drmRadeonState;
-
-/* 1.1 vertex ioctl.  Used in compatibility modes.
- */
-typedef struct {
-	int prim;
-	int idx;			/* Index of vertex buffer */
-	int count;			/* Number of vertices in buffer */
-	int discard;			/* Client finished with buffer? */
-} drmRadeonVertex;
-
-typedef struct {
-	unsigned int start;
-	unsigned int finish;
-	unsigned int prim:8;
-	unsigned int stateidx:8;
-	unsigned int numverts:16; /* overloaded as offset/64 for elt prims */
-        unsigned int vc_format;
-} drmRadeonPrim;
-
-typedef struct {
-        int idx;                        /* Index of vertex buffer */
-        int discard;                    /* Client finished with buffer? */
-        int nr_states;
-        drmRadeonState *state;
-        int nr_prims;
-        drmRadeonPrim *prim;
-} drmRadeonVertex2;
-
-#define RADEON_MAX_STATES 16
-#define RADEON_MAX_PRIMS  64
-
-/* Command buffer.  Replace with true dma stream?
- */
-typedef struct {
-	int bufsz;
-	char *buf;
-	int nbox;
-        drmClipRect *boxes;
-} drmRadeonCmdBuffer;
-
-/* New style per-packet identifiers for use in cmd_buffer ioctl with
- * the RADEON_EMIT_PACKET command.  Comments relate new packets to old
- * state bits and the packet size:
- */
-#define RADEON_EMIT_PP_MISC                         0 /* context/7 */
-#define RADEON_EMIT_PP_CNTL                         1 /* context/3 */
-#define RADEON_EMIT_RB3D_COLORPITCH                 2 /* context/1 */
-#define RADEON_EMIT_RE_LINE_PATTERN                 3 /* line/2 */
-#define RADEON_EMIT_SE_LINE_WIDTH                   4 /* line/1 */
-#define RADEON_EMIT_PP_LUM_MATRIX                   5 /* bumpmap/1 */
-#define RADEON_EMIT_PP_ROT_MATRIX_0                 6 /* bumpmap/2 */
-#define RADEON_EMIT_RB3D_STENCILREFMASK             7 /* masks/3 */
-#define RADEON_EMIT_SE_VPORT_XSCALE                 8 /* viewport/6 */
-#define RADEON_EMIT_SE_CNTL                         9 /* setup/2 */
-#define RADEON_EMIT_SE_CNTL_STATUS                  10 /* setup/1 */
-#define RADEON_EMIT_RE_MISC                         11 /* misc/1 */
-#define RADEON_EMIT_PP_TXFILTER_0                   12 /* tex0/6 */
-#define RADEON_EMIT_PP_BORDER_COLOR_0               13 /* tex0/1 */
-#define RADEON_EMIT_PP_TXFILTER_1                   14 /* tex1/6 */
-#define RADEON_EMIT_PP_BORDER_COLOR_1               15 /* tex1/1 */
-#define RADEON_EMIT_PP_TXFILTER_2                   16 /* tex2/6 */
-#define RADEON_EMIT_PP_BORDER_COLOR_2               17 /* tex2/1 */
-#define RADEON_EMIT_SE_ZBIAS_FACTOR                 18 /* zbias/2 */
-#define RADEON_EMIT_SE_TCL_OUTPUT_VTX_FMT           19 /* tcl/11 */
-#define RADEON_EMIT_SE_TCL_MATERIAL_EMMISSIVE_RED   20 /* material/17 */
-#define R200_EMIT_PP_TXCBLEND_0                     21 /* tex0/4 */
-#define R200_EMIT_PP_TXCBLEND_1                     22 /* tex1/4 */
-#define R200_EMIT_PP_TXCBLEND_2                     23 /* tex2/4 */
-#define R200_EMIT_PP_TXCBLEND_3                     24 /* tex3/4 */
-#define R200_EMIT_PP_TXCBLEND_4                     25 /* tex4/4 */
-#define R200_EMIT_PP_TXCBLEND_5                     26 /* tex5/4 */
-#define R200_EMIT_PP_TXCBLEND_6                     27 /* /4 */
-#define R200_EMIT_PP_TXCBLEND_7                     28 /* /4 */
-#define R200_EMIT_TCL_LIGHT_MODEL_CTL_0             29 /* tcl/6 */
-#define R200_EMIT_TFACTOR_0                         30 /* tf/6 */
-#define R200_EMIT_VTX_FMT_0                         31 /* vtx/4 */
-#define R200_EMIT_VAP_CTL                           32 /* vap/1 */
-#define R200_EMIT_MATRIX_SELECT_0                   33 /* msl/5 */
-#define R200_EMIT_TEX_PROC_CTL_2                    34 /* tcg/5 */
-#define R200_EMIT_TCL_UCP_VERT_BLEND_CTL            35 /* tcl/1 */
-#define R200_EMIT_PP_TXFILTER_0                     36 /* tex0/6 */
-#define R200_EMIT_PP_TXFILTER_1                     37 /* tex1/6 */
-#define R200_EMIT_PP_TXFILTER_2                     38 /* tex2/6 */
-#define R200_EMIT_PP_TXFILTER_3                     39 /* tex3/6 */
-#define R200_EMIT_PP_TXFILTER_4                     40 /* tex4/6 */
-#define R200_EMIT_PP_TXFILTER_5                     41 /* tex5/6 */
-#define R200_EMIT_PP_TXOFFSET_0                     42 /* tex0/1 */
-#define R200_EMIT_PP_TXOFFSET_1                     43 /* tex1/1 */
-#define R200_EMIT_PP_TXOFFSET_2                     44 /* tex2/1 */
-#define R200_EMIT_PP_TXOFFSET_3                     45 /* tex3/1 */
-#define R200_EMIT_PP_TXOFFSET_4                     46 /* tex4/1 */
-#define R200_EMIT_PP_TXOFFSET_5                     47 /* tex5/1 */
-#define R200_EMIT_VTE_CNTL                          48 /* vte/1 */
-#define R200_EMIT_OUTPUT_VTX_COMP_SEL               49 /* vtx/1 */
-#define R200_EMIT_PP_TAM_DEBUG3                     50 /* tam/1 */
-#define R200_EMIT_PP_CNTL_X                         51 /* cst/1 */
-#define R200_EMIT_RB3D_DEPTHXY_OFFSET               52 /* cst/1 */
-#define R200_EMIT_RE_AUX_SCISSOR_CNTL               53 /* cst/1 */
-#define R200_EMIT_RE_SCISSOR_TL_0                   54 /* cst/2 */
-#define R200_EMIT_RE_SCISSOR_TL_1                   55 /* cst/2 */
-#define R200_EMIT_RE_SCISSOR_TL_2                   56 /* cst/2 */
-#define R200_EMIT_SE_VAP_CNTL_STATUS                57 /* cst/1 */
-#define R200_EMIT_SE_VTX_STATE_CNTL                 58 /* cst/1 */
-#define R200_EMIT_RE_POINTSIZE                      59 /* cst/1 */
-#define R200_EMIT_TCL_INPUT_VTX_VECTOR_ADDR_0       60 /* cst/4 */
-#define R200_EMIT_PP_CUBIC_FACES_0                  61
-#define R200_EMIT_PP_CUBIC_OFFSETS_0                62
-#define R200_EMIT_PP_CUBIC_FACES_1                  63
-#define R200_EMIT_PP_CUBIC_OFFSETS_1                64
-#define R200_EMIT_PP_CUBIC_FACES_2                  65
-#define R200_EMIT_PP_CUBIC_OFFSETS_2                66
-#define R200_EMIT_PP_CUBIC_FACES_3                  67
-#define R200_EMIT_PP_CUBIC_OFFSETS_3                68
-#define R200_EMIT_PP_CUBIC_FACES_4                  69
-#define R200_EMIT_PP_CUBIC_OFFSETS_4                70
-#define R200_EMIT_PP_CUBIC_FACES_5                  71
-#define R200_EMIT_PP_CUBIC_OFFSETS_5                72
-#define RADEON_EMIT_PP_TEX_SIZE_0                   73
-#define RADEON_EMIT_PP_TEX_SIZE_1                   74
-#define RADEON_EMIT_PP_TEX_SIZE_2                   75
-#define RADEON_MAX_STATE_PACKETS                    76
-
-
-/* Commands understood by cmd_buffer ioctl.  More can be added but
- * obviously these can't be removed or changed:
- */
-#define RADEON_CMD_PACKET      1 /* emit one of the register packets above */
-#define RADEON_CMD_SCALARS     2 /* emit scalar data */
-#define RADEON_CMD_VECTORS     3 /* emit vector data */
-#define RADEON_CMD_DMA_DISCARD 4 /* discard current dma buf */
-#define RADEON_CMD_PACKET3     5 /* emit hw packet */
-#define RADEON_CMD_PACKET3_CLIP 6 /* emit hw packet wrapped in cliprects */
-#define RADEON_CMD_SCALARS2     7 /* R200 stopgap */
-#define RADEON_CMD_WAIT         8 /* synchronization */
-
-typedef union {
-	int i;
-	struct { 
-	   unsigned char cmd_type, pad0, pad1, pad2;
-	} header;
-	struct { 
-	   unsigned char cmd_type, packet_id, pad0, pad1;
-	} packet;
-	struct { 
-	   unsigned char cmd_type, offset, stride, count; 
-	} scalars;
-	struct { 
-	   unsigned char cmd_type, offset, stride, count; 
-	} vectors;
-	struct { 
-	   unsigned char cmd_type, buf_idx, pad0, pad1; 
-	} dma;
-	struct { 
-	   unsigned char cmd_type, flags, pad0, pad1; 
-	} wait;
-} drmRadeonCmdHeader;
-
-
-#define RADEON_WAIT_2D  0x1
-#define RADEON_WAIT_3D  0x2
-
-
-typedef struct drm_radeon_getparam {
-	int param;
-	int *value;
-} drmRadeonGetParam;
-
-#define RADEON_PARAM_GART_BUFFER_OFFSET 1
-#define RADEON_PARAM_LAST_FRAME         2
-#define RADEON_PARAM_LAST_DISPATCH      3
-#define RADEON_PARAM_LAST_CLEAR         4
-#define RADEON_PARAM_IRQ_NR             5
-#define RADEON_PARAM_GART_BASE          6
-
-
-#define RADEON_MEM_REGION_GART 1
-#define RADEON_MEM_REGION_FB   2
-
-typedef struct drm_radeon_mem_alloc {
-	int region;
-	int alignment;
-	int size;
-	int *region_offset;	/* offset from start of fb or GART */
-} drmRadeonMemAlloc;
-
-typedef struct drm_radeon_mem_free {
-	int region;
-	int region_offset;
-} drmRadeonMemFree;
-
-typedef struct drm_radeon_mem_init_heap {
-	int region;
-	int size;
-	int start;	
-} drmRadeonMemInitHeap;
-
-/* 1.6: Userspace can request & wait on irq's:
- */
-typedef struct drm_radeon_irq_emit {
-	int *irq_seq;
-} drmRadeonIrqEmit;
-
-typedef struct drm_radeon_irq_wait {
-	int irq_seq;
-} drmRadeonIrqWait;
-
-
-/* 1.10: Clients tell the DRM where they think the framebuffer is located in
- * the card's address space, via a new generic ioctl to set parameters
- */
-
-typedef struct drm_radeon_set_param {
-	unsigned int param;
-	int64_t      value;
-} drmRadeonSetParam;
-
-#define RADEON_SETPARAM_FB_LOCATION     1
-
-
-#endif
diff --git a/hw/kdrive/ati/radeon_composite.c b/hw/kdrive/ati/radeon_composite.c
deleted file mode 100644
index ddad343..0000000
--- a/hw/kdrive/ati/radeon_composite.c
+++ /dev/null
@@ -1,875 +0,0 @@
-/*
- * Copyright © 2003 Eric Anholt
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Eric Anholt not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  Eric Anholt makes no
- * representations about the suitability of this software for any purpose.  It
- * is provided "as is" without express or implied warranty.
- *
- * ERIC ANHOLT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL ERIC ANHOLT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <kdrive-config.h>
-#endif
-#include "ati.h"
-#include "ati_reg.h"
-#include "ati_dma.h"
-#include "ati_draw.h"
-
-extern ATIScreenInfo *accel_atis;
-extern int sample_count;
-extern float sample_offsets_x[255];
-extern float sample_offsets_y[255];
-static Bool is_transform[2];
-static PictTransform *transform[2];
-
-struct blendinfo {
-	Bool dst_alpha;
-	Bool src_alpha;
-	CARD32 blend_cntl;
-};
-
-static struct blendinfo RadeonBlendOp[] = {
-	/* Clear */
-	{0, 0, RADEON_SBLEND_GL_ZERO	      | RADEON_DBLEND_GL_ZERO},
-	/* Src */
-	{0, 0, RADEON_SBLEND_GL_ONE	      | RADEON_DBLEND_GL_ZERO},
-	/* Dst */
-	{0, 0, RADEON_SBLEND_GL_ZERO	      | RADEON_DBLEND_GL_ONE},
-	/* Over */
-	{0, 1, RADEON_SBLEND_GL_ONE	      | RADEON_DBLEND_GL_INV_SRC_ALPHA},
-	/* OverReverse */
-	{1, 0, RADEON_SBLEND_GL_INV_DST_ALPHA | RADEON_DBLEND_GL_ONE},
-	/* In */
-	{1, 0, RADEON_SBLEND_GL_DST_ALPHA     | RADEON_DBLEND_GL_ZERO},
-	/* InReverse */
-	{0, 1, RADEON_SBLEND_GL_ZERO	      | RADEON_DBLEND_GL_SRC_ALPHA},
-	/* Out */
-	{1, 0, RADEON_SBLEND_GL_INV_DST_ALPHA | RADEON_DBLEND_GL_ZERO},
-	/* OutReverse */
-	{0, 1, RADEON_SBLEND_GL_ZERO	      | RADEON_DBLEND_GL_INV_SRC_ALPHA},
-	/* Atop */
-	{1, 1, RADEON_SBLEND_GL_DST_ALPHA     | RADEON_DBLEND_GL_INV_SRC_ALPHA},
-	/* AtopReverse */
-	{1, 1, RADEON_SBLEND_GL_INV_DST_ALPHA | RADEON_DBLEND_GL_SRC_ALPHA},
-	/* Xor */
-	{1, 1, RADEON_SBLEND_GL_INV_DST_ALPHA | RADEON_DBLEND_GL_INV_SRC_ALPHA},
-	/* Add */
-	{0, 0, RADEON_SBLEND_GL_ONE	      | RADEON_DBLEND_GL_ONE},
-};
-
-struct formatinfo {
-	int fmt;
-	Bool byte_swap;
-	CARD32 card_fmt;
-};
-
-/* Note on texture formats:
- * TXFORMAT_Y8 expands to (Y,Y,Y,1).  TXFORMAT_I8 expands to (I,I,I,I)
- */
-static struct formatinfo R100TexFormats[] = {
-	{PICT_a8r8g8b8,	0, RADEON_TXFORMAT_ARGB8888 | RADEON_TXFORMAT_ALPHA_IN_MAP},
-	{PICT_x8r8g8b8,	0, RADEON_TXFORMAT_ARGB8888},
-	{PICT_a8b8g8r8,	1, RADEON_TXFORMAT_RGBA8888 | RADEON_TXFORMAT_ALPHA_IN_MAP},
-	{PICT_x8b8g8r8,	1, RADEON_TXFORMAT_RGBA8888},
-	{PICT_r5g6b5,	0, RADEON_TXFORMAT_RGB565},
-	{PICT_a1r5g5b5,	0, RADEON_TXFORMAT_ARGB1555 | RADEON_TXFORMAT_ALPHA_IN_MAP},
-	{PICT_x1r5g5b5,	0, RADEON_TXFORMAT_ARGB1555},
-	{PICT_a8,	0, RADEON_TXFORMAT_I8 | RADEON_TXFORMAT_ALPHA_IN_MAP},
-};
-
-static struct formatinfo R200TexFormats[] = {
-	{PICT_a8r8g8b8,	0, R200_TXFORMAT_ARGB8888 | R200_TXFORMAT_ALPHA_IN_MAP},
-	{PICT_x8r8g8b8,	0, R200_TXFORMAT_ARGB8888},
-	{PICT_a8r8g8b8,	1, R200_TXFORMAT_RGBA8888 | R200_TXFORMAT_ALPHA_IN_MAP},
-	{PICT_x8r8g8b8,	1, R200_TXFORMAT_RGBA8888},
-	{PICT_r5g6b5,	0, R200_TXFORMAT_RGB565},
-	{PICT_a1r5g5b5,	0, R200_TXFORMAT_ARGB1555 | R200_TXFORMAT_ALPHA_IN_MAP},
-	{PICT_x1r5g5b5,	0, R200_TXFORMAT_ARGB1555},
-	{PICT_a8,	0, R200_TXFORMAT_I8 | R200_TXFORMAT_ALPHA_IN_MAP},
-};
-
-/* Common Radeon setup code */
-
-static Bool
-RadeonGetDestFormat(PicturePtr pDstPicture, CARD32 *dst_format)
-{
-	switch (pDstPicture->format) {
-	case PICT_a8r8g8b8:
-	case PICT_x8r8g8b8:
-		*dst_format = RADEON_COLOR_FORMAT_ARGB8888;
-		break;
-	case PICT_r5g6b5:
-		*dst_format = RADEON_COLOR_FORMAT_RGB565;
-		break;
-	case PICT_a1r5g5b5:
-	case PICT_x1r5g5b5:
-		*dst_format = RADEON_COLOR_FORMAT_ARGB1555;
-		break;
-	case PICT_a8:
-		*dst_format = RADEON_COLOR_FORMAT_RGB8;
-		break;
-	default:
-		ATI_FALLBACK(("Unsupported dest format 0x%x\n",
-		    pDstPicture->format));
-	}
-
-	return TRUE;
-}
-
-/* R100-specific code */
-
-static Bool
-R100CheckCompositeTexture(PicturePtr pPict, int unit)
-{
-	int w = pPict->pDrawable->width;
-	int h = pPict->pDrawable->height;
-	int i;
-
-	if ((w > 0x7ff) || (h > 0x7ff))
-		ATI_FALLBACK(("Picture w/h too large (%dx%d)\n", w, h));
-
-	for (i = 0; i < sizeof(R100TexFormats) / sizeof(R100TexFormats[0]); i++)
-	{
-		if (R100TexFormats[i].fmt == pPict->format)
-			break;
-	}
-	if (i == sizeof(R100TexFormats) / sizeof(R100TexFormats[0]))
-		ATI_FALLBACK(("Unsupported picture format 0x%x\n",
-		    pPict->format));
-
-	if (pPict->repeat && ((w & (w - 1)) != 0 || (h & (h - 1)) != 0))
-		ATI_FALLBACK(("NPOT repeat unsupported (%dx%d)\n", w, h));
-
-	if (pPict->filter != PictFilterNearest &&
-	    pPict->filter != PictFilterBilinear)
-		ATI_FALLBACK(("Unsupported filter 0x%x\n", pPict->filter));
-
-	return TRUE;
-}
-
-static Bool
-R100TextureSetup(PicturePtr pPict, PixmapPtr pPix, int unit)
-{
-	ATIScreenInfo *atis = accel_atis;
-	KdScreenPriv(pPix->drawable.pScreen);
-	CARD32 txfilter, txformat, txoffset, txpitch;
-	int w = pPict->pDrawable->width;
-	int h = pPict->pDrawable->height;
-	int i;
-	RING_LOCALS;
-
-	txpitch = pPix->devKind;
-	txoffset = ((CARD8 *)pPix->devPrivate.ptr -
-	    pScreenPriv->screen->memory_base);
-
-	for (i = 0; i < sizeof(R100TexFormats) / sizeof(R100TexFormats[0]); i++)
-	{
-		if (R100TexFormats[i].fmt == pPict->format)
-			break;
-	}
-	txformat = R100TexFormats[i].card_fmt;
-	if (R100TexFormats[i].byte_swap)
-		txoffset |= RADEON_TXO_ENDIAN_BYTE_SWAP;
-
-	if (pPict->repeat) {
-		txformat |= ATILog2(w) << RADEON_TXFORMAT_WIDTH_SHIFT;
-		txformat |= ATILog2(h) << RADEON_TXFORMAT_HEIGHT_SHIFT;
-	} else 
-		txformat |= RADEON_TXFORMAT_NON_POWER2;
-	txformat |= unit << 24; /* RADEON_TXFORMAT_ST_ROUTE_STQX */
-
- 
-	if ((txoffset & 0x1f) != 0)
-		ATI_FALLBACK(("Bad texture offset 0x%x\n", txoffset));
-	if ((txpitch & 0x1f) != 0)
-		ATI_FALLBACK(("Bad texture pitch 0x%x\n", txpitch));
-
-	switch (pPict->filter) {
-	case PictFilterNearest:
-		txfilter = (RADEON_MAG_FILTER_NEAREST |
-			    RADEON_MIN_FILTER_NEAREST);
-		break;
-	case PictFilterBilinear:
-		txfilter = (RADEON_MAG_FILTER_LINEAR |
-			    RADEON_MIN_FILTER_LINEAR);
-		break;
-	default:
-		ATI_FALLBACK(("Bad filter 0x%x\n", pPict->filter));
-	}
-
-	BEGIN_DMA(7);
-	if (unit == 0) {
-		OUT_RING(DMA_PACKET0(RADEON_REG_PP_TXFILTER_0, 3));
-		OUT_RING_REG(RADEON_REG_PP_TXFILTER_0, txfilter);
-		OUT_RING_REG(RADEON_REG_PP_TXFORMAT_0, txformat);
-		OUT_RING_REG(RADEON_REG_PP_TXOFFSET_0, txoffset);
-		OUT_RING(DMA_PACKET0(RADEON_REG_PP_TEX_SIZE_0, 2));
-		OUT_RING_REG(RADEON_REG_PP_TEX_SIZE_0,
-		    (pPix->drawable.width - 1) |
-		    ((pPix->drawable.height - 1) << RADEON_TEX_VSIZE_SHIFT));
-		OUT_RING_REG(RADEON_REG_PP_TEX_PITCH_0, txpitch - 32);
-	} else {
-		OUT_RING(DMA_PACKET0(RADEON_REG_PP_TXFILTER_1, 3));
-		OUT_RING_REG(RADEON_REG_PP_TXFILTER_1, txfilter);
-		OUT_RING_REG(RADEON_REG_PP_TXFORMAT_1, txformat);
-		OUT_RING_REG(RADEON_REG_PP_TXOFFSET_1, txoffset);
-		OUT_RING(DMA_PACKET0(RADEON_REG_PP_TEX_SIZE_1, 2));
-		OUT_RING_REG(RADEON_REG_PP_TEX_SIZE_1,
-		    (pPix->drawable.width - 1) |
-		    ((pPix->drawable.height - 1) << RADEON_TEX_VSIZE_SHIFT));
-		OUT_RING_REG(RADEON_REG_PP_TEX_PITCH_1, txpitch - 32);
-	}
-	END_DMA();
-
-	if (pPict->transform != 0) {
-		is_transform[unit] = TRUE;
-		transform[unit] = pPict->transform;
-	} else {
-		is_transform[unit] = FALSE;
-	}
-
-	return TRUE;
-}
-
-Bool
-R100CheckComposite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture,
-    PicturePtr pDstPicture)
-{
-	CARD32 tmp1;
-
-	/* Check for unsupported compositing operations. */
-	if (op >= sizeof(RadeonBlendOp) / sizeof(RadeonBlendOp[0]))
-		ATI_FALLBACK(("Unsupported Composite op 0x%x\n", op));
-	if (pMaskPicture != NULL && pMaskPicture->componentAlpha &&
-	    RadeonBlendOp[op].src_alpha)
-		ATI_FALLBACK(("Component alpha not supported with source "
-		    "alpha blending.\n"));
-	if (pDstPicture->pDrawable->width >= (1 << 11) ||
-	    pDstPicture->pDrawable->height >= (1 << 11))
-		ATI_FALLBACK(("Dest w/h too large (%d,%d).\n",
-		    pDstPicture->pDrawable->width,
-		    pDstPicture->pDrawable->height));
-
-	if (!R100CheckCompositeTexture(pSrcPicture, 0))
-		return FALSE;
-	if (pMaskPicture != NULL && !R100CheckCompositeTexture(pMaskPicture, 1))
-		return FALSE;
-
-	if (pDstPicture->componentAlpha)
-		return FALSE;
-
-	if (!RadeonGetDestFormat(pDstPicture, &tmp1))
-		return FALSE;
-
-	return TRUE;
-}
-
-Bool
-R100PrepareComposite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture,
-    PicturePtr pDstPicture, PixmapPtr pSrc, PixmapPtr pMask, PixmapPtr pDst)
-{
-	KdScreenPriv(pDst->drawable.pScreen);
-	ATIScreenInfo(pScreenPriv);
-	CARD32 dst_format, dst_offset, dst_pitch;
-	CARD32 pp_cntl, blendcntl, cblend, ablend;
-	int pixel_shift;
-	RING_LOCALS;
-
-	accel_atis = atis;
-
-	RadeonGetDestFormat(pDstPicture, &dst_format);
-	pixel_shift = pDst->drawable.bitsPerPixel >> 4;
-
-	dst_offset = ((CARD8 *)pDst->devPrivate.ptr -
-	    pScreenPriv->screen->memory_base);
-	dst_pitch = pDst->devKind;
-	if ((dst_offset & 0x0f) != 0)
-		ATI_FALLBACK(("Bad destination offset 0x%x\n", dst_offset));
-	if (((dst_pitch >> pixel_shift) & 0x7) != 0)
-		ATI_FALLBACK(("Bad destination pitch 0x%x\n", dst_pitch));
-
-	if (!R100TextureSetup(pSrcPicture, pSrc, 0))
-		return FALSE;
-	pp_cntl = RADEON_TEX_0_ENABLE | RADEON_TEX_BLEND_0_ENABLE;
-
-	if (pMask != NULL) {
-		if (!R100TextureSetup(pMaskPicture, pMask, 1))
-			return FALSE;
-		pp_cntl |= RADEON_TEX_1_ENABLE;
-	} else {
-		is_transform[1] = FALSE;
-	}
-
-	ENTER_DRAW(pDst);
-	
-	RadeonSwitchTo3D(atis);
-
-	BEGIN_DMA(12);
-
-	OUT_RING(DMA_PACKET0(RADEON_REG_PP_CNTL, 3));
-	OUT_RING_REG(RADEON_REG_PP_CNTL, pp_cntl);
-	OUT_RING_REG(RADEON_REG_RB3D_CNTL,
-	    dst_format | RADEON_ALPHA_BLEND_ENABLE);
-	OUT_RING_REG(RADEON_REG_RB3D_COLOROFFSET, dst_offset);
-
-	OUT_REG(RADEON_REG_RB3D_COLORPITCH, dst_pitch >> pixel_shift);
-
-	/* IN operator: Multiply src by mask components or mask alpha.
-	 * BLEND_CTL_ADD is A * B + C.
-	 * If a picture is a8, we have to explicitly zero its color values.
-	 * If the destination is a8, we have to route the alpha to red, I think.
-	 */
-	cblend = RADEON_BLEND_CTL_ADD | RADEON_CLAMP_TX |
-	    RADEON_COLOR_ARG_C_ZERO;
-	ablend = RADEON_BLEND_CTL_ADD | RADEON_CLAMP_TX |
-	    RADEON_ALPHA_ARG_C_ZERO;
-
-	if (pDstPicture->format == PICT_a8)
-		cblend |= RADEON_COLOR_ARG_A_T0_ALPHA;
-	else if (pSrcPicture->format == PICT_a8)
-		cblend |= RADEON_COLOR_ARG_A_ZERO;
-	else
-		cblend |= RADEON_COLOR_ARG_A_T0_COLOR;
-	ablend |= RADEON_ALPHA_ARG_A_T0_ALPHA;
-
-	if (pMask) {
-		if (pMaskPicture->componentAlpha &&
-		    pDstPicture->format != PICT_a8)
-			cblend |= RADEON_COLOR_ARG_B_T1_COLOR;
-		else
-			cblend |= RADEON_COLOR_ARG_B_T1_ALPHA;
-		ablend |= RADEON_ALPHA_ARG_B_T1_ALPHA;
-	} else {
-		cblend |= RADEON_COLOR_ARG_B_ZERO | RADEON_COMP_ARG_B;
-		ablend |= RADEON_ALPHA_ARG_B_ZERO | RADEON_COMP_ARG_B;
-	}
-
-	OUT_REG(RADEON_REG_PP_TXCBLEND_0, cblend);
-	OUT_REG(RADEON_REG_PP_TXABLEND_0, ablend);
-
-	/* Op operator. */
-	blendcntl = RadeonBlendOp[op].blend_cntl;
-	if (PICT_FORMAT_A(pDstPicture->format) == 0 &&
-	    RadeonBlendOp[op].dst_alpha) {
-		if ((blendcntl & RADEON_SBLEND_MASK) ==
-		    RADEON_SBLEND_GL_DST_ALPHA)
-			blendcntl = (blendcntl & ~RADEON_SBLEND_MASK) |
-			    RADEON_SBLEND_GL_ONE;
-		else if ((blendcntl & RADEON_SBLEND_MASK) ==
-		    RADEON_SBLEND_GL_INV_DST_ALPHA)
-			blendcntl = (blendcntl & ~RADEON_SBLEND_MASK) |
-			    RADEON_SBLEND_GL_ZERO;
-	}
-	OUT_REG(RADEON_REG_RB3D_BLENDCNTL, blendcntl);
-	END_DMA();
-
-	LEAVE_DRAW(pDst);
-
-	return TRUE;
-}
-
-static Bool
-R200CheckCompositeTexture(PicturePtr pPict, int unit)
-{
-	int w = pPict->pDrawable->width;
-	int h = pPict->pDrawable->height;
-	int i;
-
-	if ((w > 0x7ff) || (h > 0x7ff))
-		ATI_FALLBACK(("Picture w/h too large (%dx%d)\n", w, h));
-
-	for (i = 0; i < sizeof(R200TexFormats) / sizeof(R200TexFormats[0]); i++)
-	{
-		if (R200TexFormats[i].fmt == pPict->format)
-			break;
-	}
-	if (i == sizeof(R200TexFormats) / sizeof(R200TexFormats[0]))
-		ATI_FALLBACK(("Unsupported picture format 0x%x\n",
-		    pPict->format));
-
-	if (pPict->repeat && ((w & (w - 1)) != 0 || (h & (h - 1)) != 0))
-		ATI_FALLBACK(("NPOT repeat unsupported (%dx%d)\n", w, h));
-
-	if (pPict->filter != PictFilterNearest &&
-	    pPict->filter != PictFilterBilinear)
-		ATI_FALLBACK(("Unsupported filter 0x%x\n", pPict->filter));
-
-	return TRUE;
-}
-
-static Bool
-R200TextureSetup(PicturePtr pPict, PixmapPtr pPix, int unit)
-{
-	ATIScreenInfo *atis = accel_atis;
-	KdScreenPriv(pPix->drawable.pScreen);
-	CARD32 txfilter, txformat, txoffset, txpitch;
-	int w = pPict->pDrawable->width;
-	int h = pPict->pDrawable->height;
-	int i;
-	RING_LOCALS;
-
-	txpitch = pPix->devKind;
-	txoffset = ((CARD8 *)pPix->devPrivate.ptr -
-	    pScreenPriv->screen->memory_base);
-
-	for (i = 0; i < sizeof(R200TexFormats) / sizeof(R200TexFormats[0]); i++)
-	{
-		if (R200TexFormats[i].fmt == pPict->format)
-			break;
-	}
-	txformat = R200TexFormats[i].card_fmt;
-	if (R200TexFormats[i].byte_swap)
-		txoffset |= R200_TXO_ENDIAN_BYTE_SWAP;
-
-	if (pPict->repeat) {
-		txformat |= ATILog2(w) << R200_TXFORMAT_WIDTH_SHIFT;
-		txformat |= ATILog2(h) << R200_TXFORMAT_HEIGHT_SHIFT;
-	} else 
-		txformat |= R200_TXFORMAT_NON_POWER2;
-	txformat |= unit << R200_TXFORMAT_ST_ROUTE_SHIFT;
-
-	if ((txoffset & 0x1f) != 0)
-		ATI_FALLBACK(("Bad texture offset 0x%x\n", txoffset));
-	if ((txpitch & 0x1f) != 0)
-		ATI_FALLBACK(("Bad texture pitch 0x%x\n", txpitch));
-
-	switch (pPict->filter) {
-	case PictFilterNearest:
-		txfilter = (R200_MAG_FILTER_NEAREST |
-			    R200_MIN_FILTER_NEAREST);
-		break;
-	case PictFilterBilinear:
-		txfilter = (R200_MAG_FILTER_LINEAR |
-			    R200_MIN_FILTER_LINEAR);
-		break;
-	default:
-		ATI_FALLBACK(("Bad filter 0x%x\n", pPict->filter));
-	}
-
-	if (unit == 0) {
-		BEGIN_DMA(6);
-		OUT_RING(DMA_PACKET0(R200_REG_PP_TXFILTER_0 + 0x20 * unit, 5));
-		OUT_RING_REG(R200_REG_PP_TXFILTER_0, txfilter);
-		OUT_RING_REG(R200_REG_PP_TXFORMAT_0, txformat);
-		OUT_RING_REG(R200_REG_PP_TXFORMAT_X_0, 0);
-		OUT_RING_REG(R200_REG_PP_TXSIZE_0,
-		    (pPix->drawable.width - 1) |
-		    ((pPix->drawable.height - 1) << RADEON_TEX_VSIZE_SHIFT));
-		OUT_RING_REG(R200_REG_PP_TXPITCH_0, txpitch - 32);
-		END_DMA();
-	} else {
-		BEGIN_DMA(6);
-		OUT_RING(DMA_PACKET0(R200_REG_PP_TXFILTER_1, 5));
-		OUT_RING_REG(R200_REG_PP_TXFILTER_1, txfilter);
-		OUT_RING_REG(R200_REG_PP_TXFORMAT_1, txformat);
-		OUT_RING_REG(R200_REG_PP_TXFORMAT_X_1, 0);
-		OUT_RING_REG(R200_REG_PP_TXSIZE_1,
-		    (pPix->drawable.width - 1) |
-		    ((pPix->drawable.height - 1) << RADEON_TEX_VSIZE_SHIFT));
-		OUT_RING_REG(R200_REG_PP_TXPITCH_1, txpitch - 32);
-		END_DMA();
-	}
-
-	BEGIN_DMA(2);
-	OUT_REG(R200_PP_TXOFFSET_0 + 0x18 * unit, txoffset);
-	END_DMA();
-
-	if (pPict->transform != 0) {
-		is_transform[unit] = TRUE;
-		transform[unit] = pPict->transform;
-	} else {
-		is_transform[unit] = FALSE;
-	}
-
-	return TRUE;
-}
-
-Bool
-R200CheckComposite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture,
-    PicturePtr pDstPicture)
-{
-	CARD32 tmp1;
-
-	/* Check for unsupported compositing operations. */
-	if (op >= sizeof(RadeonBlendOp) / sizeof(RadeonBlendOp[0]))
-		ATI_FALLBACK(("Unsupported Composite op 0x%x\n", op));
-	if (pMaskPicture != NULL && pMaskPicture->componentAlpha &&
-	    RadeonBlendOp[op].src_alpha)
-		ATI_FALLBACK(("Component alpha not supported with source "
-		    "alpha blending.\n"));
-
-	if (!R200CheckCompositeTexture(pSrcPicture, 0))
-		return FALSE;
-	if (pMaskPicture != NULL && !R200CheckCompositeTexture(pMaskPicture, 1))
-		return FALSE;
-
-	if (!RadeonGetDestFormat(pDstPicture, &tmp1))
-		return FALSE;
-
-	return TRUE;
-}
-
-Bool
-R200PrepareComposite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture,
-    PicturePtr pDstPicture, PixmapPtr pSrc, PixmapPtr pMask, PixmapPtr pDst)
-{
-	KdScreenPriv(pDst->drawable.pScreen);
-	ATIScreenInfo(pScreenPriv);
-	CARD32 dst_format, dst_offset, dst_pitch;
-	CARD32 pp_cntl, blendcntl, cblend, ablend;
-	int pixel_shift;
-	RING_LOCALS;
-
-	RadeonGetDestFormat(pDstPicture, &dst_format);
-	pixel_shift = pDst->drawable.bitsPerPixel >> 4;
-
-	accel_atis = atis;
-
-	dst_offset = ((CARD8 *)pDst->devPrivate.ptr -
-	    pScreenPriv->screen->memory_base);
-	dst_pitch = pDst->devKind;
-	if ((dst_offset & 0x0f) != 0)
-		ATI_FALLBACK(("Bad destination offset 0x%x\n", dst_offset));
-	if (((dst_pitch >> pixel_shift) & 0x7) != 0)
-		ATI_FALLBACK(("Bad destination pitch 0x%x\n", dst_pitch));
-
-	if (!R200TextureSetup(pSrcPicture, pSrc, 0))
-		return FALSE;
-	pp_cntl = RADEON_TEX_0_ENABLE | RADEON_TEX_BLEND_0_ENABLE;
-
-	if (pMask != NULL) {
-		if (!R200TextureSetup(pMaskPicture, pMask, 1))
-			return FALSE;
-		pp_cntl |= RADEON_TEX_1_ENABLE;
-	} else {
-		is_transform[1] = FALSE;
-	}
-
-	RadeonSwitchTo3D(atis);
-
-	BEGIN_DMA(17);
-
-	OUT_RING(DMA_PACKET0(RADEON_REG_PP_CNTL, 3));
-	OUT_RING_REG(RADEON_REG_PP_CNTL, pp_cntl);
-	OUT_RING_REG(RADEON_REG_RB3D_CNTL, dst_format | RADEON_ALPHA_BLEND_ENABLE);
-	OUT_RING_REG(RADEON_REG_RB3D_COLOROFFSET, dst_offset);
-
-	OUT_REG(R200_REG_SE_VTX_FMT_0, R200_VTX_XY);
-	OUT_REG(R200_REG_SE_VTX_FMT_1,
-	    (2 << R200_VTX_TEX0_COMP_CNT_SHIFT) |
-	    (2 << R200_VTX_TEX1_COMP_CNT_SHIFT));
-
-	OUT_REG(RADEON_REG_RB3D_COLORPITCH, dst_pitch >> pixel_shift);
-
-	/* IN operator: Multiply src by mask components or mask alpha.
-	 * BLEND_CTL_ADD is A * B + C.
-	 * If a picture is a8, we have to explicitly zero its color values.
-	 * If the destination is a8, we have to route the alpha to red, I think.
-	 */
-	cblend = R200_TXC_OP_MADD | R200_TXC_ARG_C_ZERO;
-	ablend = R200_TXA_OP_MADD | R200_TXA_ARG_C_ZERO;
-
-	if (pDstPicture->format == PICT_a8)
-		cblend |= R200_TXC_ARG_A_R0_ALPHA;
-	else if (pSrcPicture->format == PICT_a8)
-		cblend |= R200_TXC_ARG_A_ZERO;
-	else
-		cblend |= R200_TXC_ARG_A_R0_COLOR;
-	ablend |= R200_TXA_ARG_A_R0_ALPHA;
-
-	if (pMask) {
-		if (pMaskPicture->componentAlpha &&
-		    pDstPicture->format != PICT_a8)
-			cblend |= R200_TXC_ARG_B_R1_COLOR;
-		else
-			cblend |= R200_TXC_ARG_B_R1_ALPHA;
-		ablend |= R200_TXA_ARG_B_R1_ALPHA;
-	} else {
-		cblend |= R200_TXC_ARG_B_ZERO | R200_TXC_COMP_ARG_B;
-		ablend |= R200_TXA_ARG_B_ZERO | R200_TXA_COMP_ARG_B;
-	}
-
-	OUT_RING(DMA_PACKET0(R200_REG_PP_TXCBLEND_0, 4));
-	OUT_RING_REG(R200_REG_PP_TXCBLEND_0, cblend);
-	OUT_RING_REG(R200_REG_PP_TXCBLEND2_0,
-	    R200_TXC_CLAMP_0_1 | R200_TXC_OUTPUT_REG_R0);
-	OUT_RING_REG(R200_REG_PP_TXABLEND_0, ablend);
-	OUT_RING_REG(R200_REG_PP_TXABLEND2_0,
-	    R200_TXA_CLAMP_0_1 | R200_TXA_OUTPUT_REG_R0);
-
-	/* Op operator. */
-	blendcntl = RadeonBlendOp[op].blend_cntl;
-	if (PICT_FORMAT_A(pDstPicture->format) == 0 &&
-	    RadeonBlendOp[op].dst_alpha) {
-		if ((blendcntl & RADEON_SBLEND_MASK) ==
-		    RADEON_SBLEND_GL_DST_ALPHA)
-			blendcntl = (blendcntl & ~RADEON_SBLEND_MASK) |
-			    RADEON_SBLEND_GL_ONE;
-		else if ((blendcntl & RADEON_SBLEND_MASK) ==
-		    RADEON_SBLEND_GL_INV_DST_ALPHA)
-			blendcntl = (blendcntl & ~RADEON_SBLEND_MASK) |
-			    RADEON_SBLEND_GL_ZERO;
-	}
-	OUT_REG(RADEON_REG_RB3D_BLENDCNTL, blendcntl);
-	END_DMA();
-
-	return TRUE;
-}
-
-union intfloat {
-	float f;
-	CARD32 i;
-};
-
-struct blend_vertex {
-	union intfloat x, y;
-	union intfloat s0, t0;
-	union intfloat s1, t1;
-};
-
-#define VTX_DWORD_COUNT 6
-
-#define VTX_OUT(_dstX, _dstY, _srcX, _srcY, _maskX, _maskY)		\
-do {									\
-	OUT_RING_F(_dstX);						\
-	OUT_RING_F(_dstY);						\
-	OUT_RING_F(_srcX);						\
-	OUT_RING_F(_srcY);						\
-	OUT_RING_F(_maskX);						\
-	OUT_RING_F(_maskY);						\
-} while (0)
-
-void
-RadeonComposite(int srcX, int srcY, int maskX, int maskY, int dstX, int dstY,
-    int w, int h)
-{
-	ATIScreenInfo *atis = accel_atis;
-	ATICardInfo *atic = atis->atic;
-	int srcXend, srcYend, maskXend, maskYend;
-	RING_LOCALS;
-	PictVector v;
-
-	ENTER_DRAW(0);
-	
-	/*ErrorF("RadeonComposite (%d,%d) (%d,%d) (%d,%d) (%d,%d)\n",
-	    srcX, srcY, maskX, maskY,dstX, dstY, w, h);*/
-
-	srcXend = srcX + w;
-	srcYend = srcY + h;
-	maskXend = maskX + w;
-	maskYend = maskY + h;
-	if (is_transform[0]) {
-		v.vector[0] = IntToxFixed(srcX);
-		v.vector[1] = IntToxFixed(srcY);
-		v.vector[2] = xFixed1;
-		PictureTransformPoint(transform[0], &v);
-		srcX = xFixedToInt(v.vector[0]);
-		srcY = xFixedToInt(v.vector[1]);
-		v.vector[0] = IntToxFixed(srcXend);
-		v.vector[1] = IntToxFixed(srcYend);
-		v.vector[2] = xFixed1;
-		PictureTransformPoint(transform[0], &v);
-		srcXend = xFixedToInt(v.vector[0]);
-		srcYend = xFixedToInt(v.vector[1]);
-	}
-	if (is_transform[1]) {
-		v.vector[0] = IntToxFixed(maskX);
-		v.vector[1] = IntToxFixed(maskY);
-		v.vector[2] = xFixed1;
-		PictureTransformPoint(transform[1], &v);
-		maskX = xFixedToInt(v.vector[0]);
-		maskY = xFixedToInt(v.vector[1]);
-		v.vector[0] = IntToxFixed(maskXend);
-		v.vector[1] = IntToxFixed(maskYend);
-		v.vector[2] = xFixed1;
-		PictureTransformPoint(transform[1], &v);
-		maskXend = xFixedToInt(v.vector[0]);
-		maskYend = xFixedToInt(v.vector[1]);
-	}
-
-	if (atic->is_r100) {
-		BEGIN_DMA(4 * VTX_DWORD_COUNT + 3);
-		OUT_RING(DMA_PACKET3(RADEON_CP_PACKET3_3D_DRAW_IMMD,
-		    4 * VTX_DWORD_COUNT + 2));
-		OUT_RING(RADEON_CP_VC_FRMT_XY |
-		    RADEON_CP_VC_FRMT_ST0 |
-		    RADEON_CP_VC_FRMT_ST1);
-		OUT_RING(RADEON_CP_VC_CNTL_PRIM_TYPE_TRI_FAN |
-		    RADEON_CP_VC_CNTL_PRIM_WALK_RING |
-		    RADEON_CP_VC_CNTL_MAOS_ENABLE |
-		    RADEON_CP_VC_CNTL_VTX_FMT_RADEON_MODE |
-		    (4 << RADEON_CP_VC_CNTL_NUM_SHIFT));
-	} else {
-		BEGIN_DMA(4 * VTX_DWORD_COUNT + 2);
-		OUT_RING(DMA_PACKET3(R200_CP_PACKET3_3D_DRAW_IMMD_2,
-		    4 * VTX_DWORD_COUNT + 1));
-		OUT_RING(RADEON_CP_VC_CNTL_PRIM_TYPE_TRI_FAN |
-		    RADEON_CP_VC_CNTL_PRIM_WALK_RING |
-		    (4 << RADEON_CP_VC_CNTL_NUM_SHIFT));
-	}
-
-	VTX_OUT(dstX,     dstY,     srcX,    srcY,    maskX,    maskY);
-	VTX_OUT(dstX,     dstY + h, srcX,    srcYend, maskX,    maskYend);
-	VTX_OUT(dstX + w, dstY + h, srcXend, srcYend, maskXend, maskYend);
-	VTX_OUT(dstX + w, dstY,     srcXend, srcY,    maskXend, maskY);
-
-	LEAVE_DRAW(0);
-
-	END_DMA();
-}
-
-void
-RadeonDoneComposite(void)
-{
-	ENTER_DRAW(0);
-	LEAVE_DRAW(0);
-}
-
-Bool
-RadeonPrepareTrapezoids(PicturePtr pDstPicture, PixmapPtr pDst)
-{
-	KdScreenPriv(pDst->drawable.pScreen);
-	ATIScreenInfo(pScreenPriv);
-	ATICardInfo(pScreenPriv);
-	CARD32 dst_offset, dst_pitch;
-	int pixel_shift;
-	RING_LOCALS;
-
-	pixel_shift = pDst->drawable.bitsPerPixel >> 4;
-
-	accel_atis = atis;
-
-	dst_offset = ((CARD8 *)pDst->devPrivate.ptr -
-	    pScreenPriv->screen->memory_base);
-	dst_pitch = pDst->devKind;
-	if ((dst_offset & 0x0f) != 0)
-		ATI_FALLBACK(("Bad destination offset 0x%x\n", dst_offset));
-	if (((dst_pitch >> pixel_shift) & 0x7) != 0)
-		ATI_FALLBACK(("Bad destination pitch 0x%x\n", dst_pitch));
-
-	RadeonSwitchTo3D(atis);
-
-	BEGIN_DMA(8);
-
-	OUT_RING(DMA_PACKET0(RADEON_REG_PP_CNTL, 5));
-	OUT_RING_REG(RADEON_REG_PP_CNTL, RADEON_TEX_BLEND_0_ENABLE);
-	OUT_RING_REG(RADEON_REG_RB3D_CNTL,
-	    RADEON_COLOR_FORMAT_RGB8 | RADEON_ALPHA_BLEND_ENABLE);
-	OUT_RING_REG(RADEON_REG_RB3D_COLOROFFSET, dst_offset);
-	OUT_RING_REG(RADEON_REG_RE_WIDTH_HEIGHT,
-	    ((pDst->drawable.height - 1) << 16) |
-	    (pDst->drawable.width - 1));
-	OUT_RING_REG(RADEON_REG_RB3D_COLORPITCH, dst_pitch >> pixel_shift);
-	OUT_REG(RADEON_REG_RB3D_BLENDCNTL, RadeonBlendOp[PictOpAdd].blend_cntl);
-	END_DMA();
-
-	if (atic->is_r100) {
-		BEGIN_DMA(4);
-		OUT_RING(DMA_PACKET0(RADEON_REG_PP_TXCBLEND_0, 3));
-		OUT_RING_REG(RADEON_REG_PP_TXCBLEND_0,
-		    RADEON_BLEND_CTL_ADD | RADEON_CLAMP_TX |
-		    RADEON_COLOR_ARG_C_TFACTOR_ALPHA);
-		OUT_RING_REG(RADEON_REG_PP_TXABLEND_0,
-		    RADEON_BLEND_CTL_ADD | RADEON_CLAMP_TX |
-		    RADEON_ALPHA_ARG_C_TFACTOR_ALPHA);
-		OUT_RING_REG(RADEON_REG_PP_TFACTOR_0, 0x01000000);
-		END_DMA();
-	} else if (atic->is_r200) {
-		BEGIN_DMA(14);
-		OUT_REG(R200_REG_SE_VTX_FMT_0, R200_VTX_XY);
-		OUT_REG(R200_REG_SE_VTX_FMT_1, 0);
-		OUT_REG(R200_REG_PP_TXCBLEND_0,
-		    R200_TXC_ARG_C_TFACTOR_COLOR);
-		OUT_REG(R200_REG_PP_TXABLEND_0,
-		    R200_TXA_ARG_C_TFACTOR_ALPHA);
-		OUT_REG(R200_REG_PP_TXCBLEND2_0, R200_TXC_OUTPUT_REG_R0);
-		OUT_REG(R200_REG_PP_TXABLEND2_0, R200_TXA_OUTPUT_REG_R0);
-		OUT_REG(RADEON_REG_PP_TFACTOR_0, 0x01000000);
-		END_DMA();
-	}
-
-	return TRUE;
-}
-
-#define TRAP_VERT_RING_COUNT 2
-
-#define TRAP_VERT(_x, _y)						\
-do {									\
-	OUT_RING_F((_x) + sample_x);					\
-	OUT_RING_F((_y) + sample_y);					\
-} while (0)
-
-void
-RadeonTrapezoids(KaaTrapezoid *traps, int ntraps)
-{
-	ATIScreenInfo *atis = accel_atis;
-	ATICardInfo *atic = atis->atic;
-	RING_LOCALS;
-
-	while (ntraps > 0) {
-		int i, sample, count, vertcount;
-
-		count = 0xffff / 4 / sample_count;
-		if (count > ntraps)
-			count = ntraps;
-		vertcount = count * sample_count * 4;
-
-		if (atic->is_r100) {
-			BEGIN_DMA(3 + vertcount * TRAP_VERT_RING_COUNT);
-			OUT_RING(DMA_PACKET3(RADEON_CP_PACKET3_3D_DRAW_IMMD,
-			    2 + vertcount * TRAP_VERT_RING_COUNT));
-			OUT_RING(RADEON_CP_VC_FRMT_XY);
-			OUT_RING(RADEON_CP_VC_CNTL_PRIM_TYPE_TRI_FAN |
-			    RADEON_CP_VC_CNTL_PRIM_WALK_RING |
-			    RADEON_CP_VC_CNTL_MAOS_ENABLE |
-			    RADEON_CP_VC_CNTL_VTX_FMT_RADEON_MODE |
-			    (vertcount << RADEON_CP_VC_CNTL_NUM_SHIFT));
-		} else {
-			BEGIN_DMA(2 + vertcount * TRAP_VERT_RING_COUNT);
-			OUT_RING(DMA_PACKET3(R200_CP_PACKET3_3D_DRAW_IMMD_2,
-			    1 + vertcount * TRAP_VERT_RING_COUNT));
-			OUT_RING(RADEON_CP_VC_CNTL_PRIM_TYPE_TRI_FAN |
-			    RADEON_CP_VC_CNTL_PRIM_WALK_RING |
-			    (vertcount << RADEON_CP_VC_CNTL_NUM_SHIFT));
-		}
-
-		for (i = 0; i < count; i++) {
-		    for (sample = 0; sample < sample_count; sample++) {
-			float sample_x = sample_offsets_x[sample];
-			float sample_y = sample_offsets_y[sample];
-			TRAP_VERT(traps[i].tl, traps[i].ty);
-			TRAP_VERT(traps[i].bl, traps[i].by);
-			TRAP_VERT(traps[i].br, traps[i].by);
-			TRAP_VERT(traps[i].tr, traps[i].ty);
-		    }
-		}
-		END_DMA();
-
-		ntraps -= count;
-		traps += count;
-	}
-}
-
-void
-RadeonDoneTrapezoids(void)
-{
-	ATIScreenInfo *atis = accel_atis;
-	RING_LOCALS;
-
-	BEGIN_DMA(2);
-	OUT_REG(RADEON_REG_RE_WIDTH_HEIGHT, 0xffffffff);
-	END_DMA();
-}
diff --git a/hw/kdrive/ati/radeon_sarea.h b/hw/kdrive/ati/radeon_sarea.h
deleted file mode 100644
index 1d39bca..0000000
--- a/hw/kdrive/ati/radeon_sarea.h
+++ /dev/null
@@ -1,221 +0,0 @@
-/*
- * Copyright 2000 ATI Technologies Inc., Markham, Ontario,
- *                VA Linux Systems Inc., Fremont, 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 on 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
- * NON-INFRINGEMENT.  IN NO EVENT SHALL ATI, VA LINUX SYSTEMS AND/OR
- * THEIR 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:
- *   Kevin E. Martin <martin at xfree86.org>
- *   Gareth Hughes <gareth at valinux.com>
- *
- */
-
-#ifndef _RADEON_SAREA_H_
-#define _RADEON_SAREA_H_
-
-/* WARNING: If you change any of these defines, make sure to change the
- * defines in the kernel file (radeon_drm.h)
- */
-#ifndef __RADEON_SAREA_DEFINES__
-#define __RADEON_SAREA_DEFINES__
-
-/* What needs to be changed for the current vertex buffer? */
-#define RADEON_UPLOAD_CONTEXT		0x00000001
-#define RADEON_UPLOAD_VERTFMT		0x00000002
-#define RADEON_UPLOAD_LINE		0x00000004
-#define RADEON_UPLOAD_BUMPMAP		0x00000008
-#define RADEON_UPLOAD_MASKS		0x00000010
-#define RADEON_UPLOAD_VIEWPORT		0x00000020
-#define RADEON_UPLOAD_SETUP		0x00000040
-#define RADEON_UPLOAD_TCL		0x00000080
-#define RADEON_UPLOAD_MISC		0x00000100
-#define RADEON_UPLOAD_TEX0		0x00000200
-#define RADEON_UPLOAD_TEX1		0x00000400
-#define RADEON_UPLOAD_TEX2		0x00000800
-#define RADEON_UPLOAD_TEX0IMAGES	0x00001000
-#define RADEON_UPLOAD_TEX1IMAGES	0x00002000
-#define RADEON_UPLOAD_TEX2IMAGES	0x00004000
-#define RADEON_UPLOAD_CLIPRECTS		0x00008000 /* handled client-side */
-#define RADEON_REQUIRE_QUIESCENCE	0x00010000
-#define RADEON_UPLOAD_ZBIAS		0x00020000
-#define RADEON_UPLOAD_ALL		0x0002ffff
-#define RADEON_UPLOAD_CONTEXT_ALL       0x000201ff
-
-#define RADEON_FRONT			0x1
-#define RADEON_BACK			0x2
-#define RADEON_DEPTH			0x4
-#define RADEON_STENCIL                  0x8
-
-/* Primitive types */
-#define RADEON_POINTS			0x1
-#define RADEON_LINES			0x2
-#define RADEON_LINE_STRIP		0x3
-#define RADEON_TRIANGLES		0x4
-#define RADEON_TRIANGLE_FAN		0x5
-#define RADEON_TRIANGLE_STRIP		0x6
-#define RADEON_3VTX_POINTS		0x9
-#define RADEON_3VTX_LINES		0xa
-
-/* Vertex/indirect buffer size */
-#define RADEON_BUFFER_SIZE		65536
-
-/* Byte offsets for indirect buffer data */
-#define RADEON_INDEX_PRIM_OFFSET	20
-#define RADEON_HOSTDATA_BLIT_OFFSET	32
-
-#define RADEON_SCRATCH_REG_OFFSET	32
-
-/* Keep these small for testing */
-#define RADEON_NR_SAREA_CLIPRECTS	12
-
-#define RADEON_MAX_TEXTURE_LEVELS	12
-#define RADEON_MAX_TEXTURE_UNITS	3
-
-/* Blits have strict offset rules.  All blit offset must be aligned on
- * a 1K-byte boundary.
- */
-#define RADEON_OFFSET_SHIFT		10
-#define RADEON_OFFSET_ALIGN		(1 << RADEON_OFFSET_SHIFT)
-#define RADEON_OFFSET_MASK		(RADEON_OFFSET_ALIGN - 1)
-
-#endif /* __RADEON_SAREA_DEFINES__ */
-
-typedef struct {
-    unsigned int red;
-    unsigned int green;
-    unsigned int blue;
-    unsigned int alpha;
-} radeon_color_regs_t;
-
-typedef struct {
-    /* Context state */
-    unsigned int pp_misc;
-    unsigned int pp_fog_color;
-    unsigned int re_solid_color;
-    unsigned int rb3d_blendcntl;
-    unsigned int rb3d_depthoffset;
-    unsigned int rb3d_depthpitch;
-    unsigned int rb3d_zstencilcntl;
-
-    unsigned int pp_cntl;
-    unsigned int rb3d_cntl;
-    unsigned int rb3d_coloroffset;
-    unsigned int re_width_height;
-    unsigned int rb3d_colorpitch;
-    unsigned int se_cntl;
-
-    /* Vertex format state */
-    unsigned int se_coord_fmt;
-
-    /* Line state */
-    unsigned int re_line_pattern;
-    unsigned int re_line_state;
-
-    unsigned int se_line_width;
-
-    /* Bumpmap state */
-    unsigned int pp_lum_matrix;
-
-    unsigned int pp_rot_matrix_0;
-    unsigned int pp_rot_matrix_1;
-
-    /* Mask state */
-    unsigned int rb3d_stencilrefmask;
-    unsigned int rb3d_ropcntl;
-    unsigned int rb3d_planemask;
-
-    /* Viewport state */
-    unsigned int se_vport_xscale;
-    unsigned int se_vport_xoffset;
-    unsigned int se_vport_yscale;
-    unsigned int se_vport_yoffset;
-    unsigned int se_vport_zscale;
-    unsigned int se_vport_zoffset;
-
-    /* Setup state */
-    unsigned int se_cntl_status;
-
-    /* Misc state */
-    unsigned int re_top_left;
-    unsigned int re_misc;
-} radeon_context_regs_t;
-
-/* Setup registers for each texture unit */
-typedef struct {
-    unsigned int pp_txfilter;
-    unsigned int pp_txformat;
-    unsigned int pp_txoffset;
-    unsigned int pp_txcblend;
-    unsigned int pp_txablend;
-    unsigned int pp_tfactor;
-    unsigned int pp_border_color;
-} radeon_texture_regs_t;
-
-typedef struct {
-    /* The channel for communication of state information to the kernel
-     * on firing a vertex buffer.
-     */
-    radeon_context_regs_t ContextState;
-    radeon_texture_regs_t TexState[RADEON_MAX_TEXTURE_UNITS];
-    unsigned int dirty;
-    unsigned int vertsize;
-    unsigned int vc_format;
-
-    /* The current cliprects, or a subset thereof */
-    XF86DRIClipRectRec boxes[RADEON_NR_SAREA_CLIPRECTS];
-    unsigned int nbox;
-
-    /* Counters for throttling of rendering clients */
-    unsigned int last_frame;
-    unsigned int last_dispatch;
-    unsigned int last_clear;
-
-    /* Maintain an LRU of contiguous regions of texture space.  If you
-     * think you own a region of texture memory, and it has an age
-     * different to the one you set, then you are mistaken and it has
-     * been stolen by another client.  If global texAge hasn't changed,
-     * there is no need to walk the list.
-     *
-     * These regions can be used as a proxy for the fine-grained texture
-     * information of other clients - by maintaining them in the same
-     * lru which is used to age their own textures, clients have an
-     * approximate lru for the whole of global texture space, and can
-     * make informed decisions as to which areas to kick out.  There is
-     * no need to choose whether to kick out your own texture or someone
-     * else's - simply eject them all in LRU order.
-     */
-				/* Last elt is sentinal */
-    drmTextureRegion texList[ATI_NR_TEX_HEAPS][ATI_NR_TEX_REGIONS+1];
-				/* last time texture was uploaded */
-    unsigned int texAge[ATI_NR_TEX_HEAPS];
-
-    int ctxOwner;		/* last context to upload state */
-    int pfAllowPageFlip;	/* set by the 2d driver, read by the client */
-    int pfCurrentPage;		/* set by kernel, read by others */
-    int crtc2_base;		/* for pageflipping with CloneMode */
-} RADEONSAREAPriv, *RADEONSAREAPrivPtr;
-
-#endif
diff --git a/hw/kdrive/chips/Makefile.am b/hw/kdrive/chips/Makefile.am
deleted file mode 100644
index 46e1760..0000000
--- a/hw/kdrive/chips/Makefile.am
+++ /dev/null
@@ -1,36 +0,0 @@
-INCLUDES = 					\
-	@KDRIVE_INCS@				\
-	-I$(top_srcdir)/hw/kdrive/vesa		\
-	@KDRIVE_CFLAGS@
-
-bin_PROGRAMS = Xchips
-
-noinst_LIBRARIES = libchips.a
-
-libchips_a_SOURCES = 	\
-	chipsdraw.c	\
-	chips.c		\
-	chips.h	
-
-Xchips_SOURCES = \
-	chipsstub.c
-
-CHIPS_LIBS =					 \
-	libchips.a 				 \
-	$(top_builddir)/hw/kdrive/vesa/libvesa.a \
-	@KDRIVE_LIBS@
-
-if GLX
-Xchips_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
-endif
-
-Xchips_LDADD = \
-	$(CHIPS_LIBS)				\
-	@KDRIVE_LIBS@
-
-Xchips_DEPENDENCIES = 	\
-	libchips.a 				 \
-	@KDRIVE_LOCAL_LIBS@
-
-relink:
-	rm -f $(bin_PROGRAMS) && make $(bin_PROGRAMS)
diff --git a/hw/kdrive/chips/chips.c b/hw/kdrive/chips/chips.c
deleted file mode 100644
index b419863..0000000
--- a/hw/kdrive/chips/chips.c
+++ /dev/null
@@ -1,334 +0,0 @@
-/*
- * Copyright © 2001 Keith Packard
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Keith Packard not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  Keith Packard makes no
- * representations about the suitability of this software for any purpose.  It
- * is provided "as is" without express or implied warranty.
- *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <kdrive-config.h>
-#endif
-#include "chips.h"
-#include "kaa.h"
-#include <sys/io.h>
-
-#undef CHIPS_DEBUG
-
-static Bool
-chipsCardInit (KdCardInfo *card)
-{
-    ChipsCardInfo	*chipsc;
-
-    chipsc = (ChipsCardInfo *) xalloc (sizeof (ChipsCardInfo));
-    if (!chipsc)
-	return FALSE;
-    
-    iopl (3);
-    
-    if (!vesaInitialize (card, &chipsc->vesa))
-    {
-	xfree (chipsc);
-	return FALSE;
-    }
-    
-#ifdef USE_PCI
-    chipsc->window = (CARD32 *) (chipsc->cop_base + 0x10000);
-#else
-    chipsc->window = 0;
-#endif
-    card->driver = chipsc;
-    
-    return TRUE;
-}
-
-static Bool
-chipsScreenInit (KdScreenInfo *screen)
-{
-    ChipsScreenInfo	*chipss;
-    int			screen_size, memory;
-
-    chipss = (ChipsScreenInfo *) xalloc (sizeof (ChipsScreenInfo));
-    if (!chipss)
-	return FALSE;
-    memset (chipss, '\0', sizeof (ChipsScreenInfo));
-    if (!vesaScreenInitialize (screen, &chipss->vesa))
-    {
-	xfree (chipss);
-	return FALSE;
-    }
-
-    if (chipss->vesa.mapping != VESA_LINEAR)
-	screen->dumb = TRUE;
-    if (!screen->dumb)
-    {
-	chipss->mmio_base = (CARD8 *) KdMapDevice (CHIPS_MMIO_BASE(chipss),
-						   CHIPS_MMIO_SIZE(chipss));
-	
-	if (chipss->mmio_base)
-	{
-	    KdSetMappedMode (CHIPS_MMIO_BASE(chipss),
-			     CHIPS_MMIO_SIZE(chipss),
-			     KD_MAPPED_MODE_REGISTERS);
-	}
-	else
-	    screen->dumb = TRUE;
-    }
-    else
-	chipss->mmio_base = 0;
-
-    chipss->screen = chipss->vesa.fb;
-    memory = chipss->vesa.fb_size;
-    
-    screen_size = screen->fb[0].byteStride * screen->height;
-    
-    if (chipss->screen && memory >= screen_size + 2048)
-    {
-	memory -= 2048;
-	chipss->cursor_base = chipss->screen + memory - 2048;
-    }
-    else
-	chipss->cursor_base = 0;
-    memory -= screen_size;
-    if (memory > screen->fb[0].byteStride)
-    {
-	chipss->off_screen = chipss->screen + screen_size;
-	chipss->off_screen_size = memory;
-    }
-    else
-    {
-	chipss->off_screen = 0;
-	chipss->off_screen_size = 0;
-    }
-    screen->driver = chipss;
-    return TRUE;
-}
-
-static Bool
-chipsInitScreen (ScreenPtr pScreen)
-{
-    return vesaInitScreen (pScreen);
-}
-
-#ifdef RANDR
-static Bool
-chipsRandRSetConfig (ScreenPtr		pScreen,
-		      Rotation		rotation,
-		      int		rate,
-		      RRScreenSizePtr	pSize)
-{
-    kaaWaitSync (pScreen);
-
-    if (!vesaRandRSetConfig (pScreen, rotation, rate, pSize))
-	return FALSE;
-    
-    return TRUE;
-}
-
-static void
-chipsRandRInit (ScreenPtr pScreen)
-{
-    rrScrPriv(pScreen);
-
-    pScrPriv->rrSetConfig = chipsRandRSetConfig;
-}
-#endif
-
-static Bool
-chipsFinishInitScreen (ScreenPtr pScreen)
-{
-    Bool    ret;
-    ret = vesaFinishInitScreen (pScreen);
-#ifdef RANDR
-    chipsRandRInit (pScreen);
-#endif
-    return ret;
-}
-
-static Bool
-chipsCreateResources (ScreenPtr pScreen)
-{
-    return vesaCreateResources (pScreen);
-}
-
-CARD8
-chipsReadXR (ChipsScreenInfo *chipss, CARD8 index)
-{
-    CARD8 value;
-    outb (index, 0x3d6);
-    value = inb (0x3d7);
-    return value;
-}
-
-void
-chipsWriteXR (ChipsScreenInfo *chipss, CARD8 index, CARD8 value)
-{
-    outb (index, 0x3d6);
-    outb (value, 0x3d7);
-}
-
-#if 0
-static CARD8
-chipsReadFR (ChipsScreenInfo *chipss, CARD8 index)
-{
-    CARD8 value;
-    outb (index, 0x3d0);
-    value = inb (0x3d1);
-    return value;
-}
-
-static void
-chipsWriteFR (ChipsScreenInfo *chipss, CARD8 index, CARD8 value)
-{
-    outb (index, 0x3d0);
-    outb (value, 0x3d1);
-}
-
-static CARD8
-chipsReadSeq (ChipsScreenInfo *chipss, CARD8 index)
-{
-    CARD8   value;
-    outb (index, 0x3c4);
-    value = inb (0x3c5);
-    return value;
-}
-
-static void
-chipsWriteSeq (ChipsScreenInfo *chipss, CARD8 index, CARD8 value)
-{
-    outb (index, 0x3c4);
-    outb (value, 0x3c5);
-}
-#endif
-
-static void
-chipsPreserve (KdCardInfo *card)
-{
-    vesaPreserve(card);
-}
-
-static void
-chipsSetMMIO (ChipsCardInfo *chipsc)
-{
-}
-
-static void
-chipsResetMMIO (ChipsCardInfo *chipsc)
-{
-}
-
-static Bool
-chipsEnable (ScreenPtr pScreen)
-{
-    KdScreenPriv(pScreen);
-    ChipsCardInfo	*chipsc = pScreenPriv->card->driver;
-
-    if (!vesaEnable (pScreen))
-	return FALSE;
-    chipsSetMMIO (chipsc);
-    return TRUE;
-}
-
-#if 0
-static Bool
-chipsDPMS (ScreenPtr pScreen, int mode)
-{
-    KdScreenPriv(pScreen);
-    chipsScreenInfo(pScreenPriv);
-    
-    ErrorF ("seqreg 0x01 0x%x\n", chipsReadSeq (chipss, 0x1));
-    ErrorF ("dpmsreg XR61 0x%x\n", chipsReadXR (chipss, 0x61));
-    ErrorF ("dpmsreg XR73 0x%x\n", chipsReadXR (chipss, 0x73));
-    
-    ErrorF ("flat panel FR05 0x%x\n", chipsReadFR (chipss, 0x5));
-    ErrorF ("flat panel XR52 0x%x\n", chipsReadXR (chipss, 0x52));
-    return TRUE;
-}
-#endif
-
-static void
-chipsDisable (ScreenPtr pScreen)
-{
-    vesaDisable (pScreen);
-}
-
-static void
-chipsRestore (KdCardInfo *card)
-{
-    ChipsCardInfo	*chipsc = card->driver;
-
-    chipsResetMMIO (chipsc);
-    vesaRestore (card);
-}
-
-static void
-chipsScreenFini (KdScreenInfo *screen)
-{
-    ChipsScreenInfo	*chipss = (ChipsScreenInfo *) screen->driver;
-
-    if (chipss->mmio_base)
-    {
-	KdUnmapDevice ((void *) chipss->mmio_base, CHIPS_MMIO_SIZE(chipss));
-	KdResetMappedMode (CHIPS_MMIO_BASE(chipss),
-			   CHIPS_MMIO_SIZE(chipss),
-			   KD_MAPPED_MODE_REGISTERS);
-    }
-    vesaScreenFini (screen);
-    xfree (chipss);
-    screen->driver = 0;
-}
-
-static void
-chipsCardFini (KdCardInfo *card)
-{
-    vesaCardFini (card);
-}
-
-#define chipsCursorInit	(void *) 0
-#define chipsCursorEnable	(void *) 0
-#define chipsCursorDisable	(void *) 0
-#define chipsCursorFini	(void *) 0
-#define chipsRecolorCursor	(void *) 0
-
-KdCardFuncs	chipsFuncs = {
-    chipsCardInit,	    /* cardinit */
-    chipsScreenInit,	    /* scrinit */
-    chipsInitScreen,	    /* initScreen */
-    chipsFinishInitScreen,  /* finishInitScreen */
-    chipsCreateResources,   /* createRes */
-    chipsPreserve,	    /* preserve */
-    chipsEnable,	    /* enable */
-    vesaDPMS,		    /* dpms */
-    chipsDisable,	    /* disable */
-    chipsRestore,	    /* restore */
-    chipsScreenFini,	    /* scrfini */
-    chipsCardFini,	    /* cardfini */
-    
-    chipsCursorInit,	    /* initCursor */
-    chipsCursorEnable,    /* enableCursor */
-    chipsCursorDisable,   /* disableCursor */
-    chipsCursorFini,	    /* finiCursor */
-    chipsRecolorCursor,   /* recolorCursor */
-    
-    chipsDrawInit,        /* initAccel */
-    chipsDrawEnable,      /* enableAccel */
-    chipsDrawDisable,     /* disableAccel */
-    chipsDrawFini,        /* finiAccel */
-    
-    vesaGetColors,    	    /* getColors */
-    vesaPutColors,	    /* putColors */
-};
diff --git a/hw/kdrive/chips/chips.h b/hw/kdrive/chips/chips.h
deleted file mode 100644
index 6ad17fe..0000000
--- a/hw/kdrive/chips/chips.h
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Copyright © 1999 Keith Packard
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Keith Packard not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  Keith Packard makes no
- * representations about the suitability of this software for any purpose.  It
- * is provided "as is" without express or implied warranty.
- *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifndef _CHIPS_H_
-#define _CHIPS_H_
-#include <vesa.h>
-
-/*
- * offset from ioport beginning 
- */
-
-#define HIQV
-#ifdef HIQV
-#define CHIPS_MMIO_BASE(c)	((c)->vesa.fb_phys + 0x400000)
-#else
-#define CHIPS_MMIO_BASE(c)	((c)->vesa.fb_phys + 0x200000)
-#endif
-#define CHIPS_MMIO_SIZE(c)	(0x20000)
-
-typedef volatile CARD8	VOL8;
-typedef volatile CARD16	VOL16;
-typedef volatile CARD32	VOL32;
-
-typedef struct _chipsSave {
-    int	    dummy;
-} ChipsSave;
-
-typedef struct _chipsCardInfo {
-    VesaCardPrivRec	vesa;
-    CARD32		*window;
-    Bool		mmio;
-    ChipsSave		save;
-} ChipsCardInfo;
-    
-#define getChipsCardInfo(kd)  ((ChipsCardInfo *) ((kd)->card->driver))
-#define chipsCardInfo(kd)	    ChipsCardInfo	*chipsc = getChipsCardInfo(kd)
-
-typedef struct _chipsCursor {
-    int		width, height;
-    int		xhot, yhot;
-    Bool	has_cursor;
-    CursorPtr	pCursor;
-    Pixel	source, mask;
-} ChipsCursor;
-
-#define CHIPS_CURSOR_WIDTH	64
-#define CHIPS_CURSOR_HEIGHT	64
-
-typedef struct _chipsScreenInfo {
-    VesaScreenPrivRec	vesa;
-    CARD8	    *mmio_base;
-    CARD8	    *cursor_base;
-    CARD8	    *screen;
-    CARD8	    *off_screen;
-    int		    off_screen_size;
-    ChipsCursor   cursor;
-    KaaScreenInfoRec kaa;
-} ChipsScreenInfo;
-
-#define getChipsScreenInfo(kd) ((ChipsScreenInfo *) ((kd)->screen->driver))
-#define chipsScreenInfo(kd)    ChipsScreenInfo *chipss = getChipsScreenInfo(kd)
-
-Bool
-chipsDrawInit (ScreenPtr pScreen);
-
-void
-chipsDrawEnable (ScreenPtr pScreen);
-
-void
-chipsDrawDisable (ScreenPtr pScreen);
-
-void
-chipsDrawFini (ScreenPtr pScreen);
-
-CARD8
-chipsReadXR (ChipsScreenInfo *chipsc, CARD8 index);
-
-void
-chipsWriteXR (ChipsScreenInfo *chipsc, CARD8 index, CARD8 value);
-
-Bool
-chipsCursorInit (ScreenPtr pScreen);
-
-void
-chipsCursorEnable (ScreenPtr pScreen);
-
-void
-chipsCursorDisable (ScreenPtr pScreen);
-
-void
-chipsCursorFini (ScreenPtr pScreen);
-
-void
-chipsRecolorCursor (ScreenPtr pScreen, int ndef, xColorItem *pdef);
-
-extern KdCardFuncs  chipsFuncs;
-
-#endif /* _CHIPS_H_ */
diff --git a/hw/kdrive/chips/chipsdraw.c b/hw/kdrive/chips/chipsdraw.c
deleted file mode 100644
index b1c35f9..0000000
--- a/hw/kdrive/chips/chipsdraw.c
+++ /dev/null
@@ -1,491 +0,0 @@
-/*
- * Copyright © 1999 Keith Packard
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Keith Packard not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  Keith Packard makes no
- * representations about the suitability of this software for any purpose.  It
- * is provided "as is" without express or implied warranty.
- *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <kdrive-config.h>
-#endif
-#include "chips.h"
-
-#include	<X11/Xmd.h>
-#include	"gcstruct.h"
-#include	"scrnintstr.h"
-#include	"pixmapstr.h"
-#include	"regionstr.h"
-#include	"mistruct.h"
-#include	"dixfontstr.h"
-#include	"fb.h"
-#include	"migc.h"
-#include	"miline.h"
-#include	"kaa.h"
-
-CARD8 chipsBltRop[16] = {
-    /* GXclear      */      0x00,         /* 0 */
-    /* GXand        */      0x88,         /* src AND dst */
-    /* GXandReverse */      0x44,         /* src AND NOT dst */
-    /* GXcopy       */      0xcc,         /* src */
-    /* GXandInverted*/      0x22,         /* NOT src AND dst */
-    /* GXnoop       */      0xaa,         /* dst */
-    /* GXxor        */      0x66,         /* src XOR dst */
-    /* GXor         */      0xee,         /* src OR dst */
-    /* GXnor        */      0x11,         /* NOT src AND NOT dst */
-    /* GXequiv      */      0x99,         /* NOT src XOR dst */
-    /* GXinvert     */      0x55,         /* NOT dst */
-    /* GXorReverse  */      0xdd,         /* src OR NOT dst */
-    /* GXcopyInverted*/     0x33,         /* NOT src */
-    /* GXorInverted */      0xbb,         /* NOT src OR dst */
-    /* GXnand       */      0x77,         /* NOT src OR NOT dst */
-    /* GXset        */      0xff,         /* 1 */
-};
-
-CARD8 chipsSolidRop[16] = {
-    /* GXclear      */      0x00,         /* 0 */
-    /* GXand        */      0xa0,         /* src AND dst */
-    /* GXandReverse */      0x50,         /* src AND NOT dst */
-    /* GXcopy       */      0xf0,         /* src */
-    /* GXandInverted*/      0x0a,         /* NOT src AND dst */
-    /* GXnoop       */      0xaa,         /* dst */
-    /* GXxor        */      0x5a,         /* src XOR dst */
-    /* GXor         */      0xfa,         /* src OR dst */
-    /* GXnor        */      0x05,         /* NOT src AND NOT dst */
-    /* GXequiv      */      0xa5,         /* NOT src XOR dst */
-    /* GXinvert     */      0x55,         /* NOT dst */
-    /* GXorReverse  */      0xf5,         /* src OR NOT dst */
-    /* GXcopyInverted*/     0x0f,         /* NOT src */
-    /* GXorInverted */      0xaf,         /* NOT src OR dst */
-    /* GXnand       */      0x5f,         /* NOT src OR NOT dst */
-    /* GXset        */      0xff,         /* 1 */
-};
-
-/* Definitions for the Chips and Technology BitBLT engine communication. */
-/* These are done using Memory Mapped IO, of the registers */
-/* BitBLT modes for register 93D0. */
-
-#ifdef HIQV
-#define ctPATCOPY               0xF0
-#define ctLEFT2RIGHT            0x000
-#define ctRIGHT2LEFT            0x100
-#define ctTOP2BOTTOM            0x000
-#define ctBOTTOM2TOP            0x200
-#define ctSRCSYSTEM             0x400
-#define ctDSTSYSTEM             0x800
-#define ctSRCMONO               0x1000
-#define ctBGTRANSPARENT         0x22000
-#define ctCOLORTRANSENABLE      0x4000
-#define ctCOLORTRANSDISABLE     0x0
-#define ctCOLORTRANSDST         0x8000
-#define ctCOLORTRANSROP         0x0
-#define ctCOLORTRANSEQUAL       0x10000L
-#define ctCOLORTRANSNEQUAL      0x0
-#define ctPATMONO               0x40000L
-#define ctPATSOLID              0x80000L
-#define ctPATSTART0             0x000000L
-#define ctPATSTART1             0x100000L
-#define ctPATSTART2             0x200000L
-#define ctPATSTART3             0x300000L
-#define ctPATSTART4             0x400000L
-#define ctPATSTART5             0x500000L
-#define ctPATSTART6             0x600000L
-#define ctPATSTART7             0x700000L
-#define ctSRCFG                 0x000000L	/* Where is this for the 65550?? */
-#else
-#define ctPATCOPY               0xF0
-#define ctTOP2BOTTOM            0x100
-#define ctBOTTOM2TOP            0x000
-#define ctLEFT2RIGHT            0x200
-#define ctRIGHT2LEFT            0x000
-#define ctSRCFG                 0x400
-#define ctSRCMONO               0x800
-#define ctPATMONO               0x1000
-#define ctBGTRANSPARENT         0x2000
-#define ctSRCSYSTEM             0x4000
-#define ctPATSOLID              0x80000L
-#define ctPATSTART0             0x00000L
-#define ctPATSTART1             0x10000L
-#define ctPATSTART2             0x20000L
-#define ctPATSTART3             0x30000L
-#define ctPATSTART4             0x40000L
-#define ctPATSTART5             0x50000L
-#define ctPATSTART6             0x60000L
-#define ctPATSTART7             0x70000L
-#endif
-
-#define chipsFillPix(bpp,pixel) {\
-    if (bpp == 8) \
-    { \
-	pixel = pixel & 0xff; \
-    } \
-    else if (bpp == 16) \
-    { \
-	pixel = pixel & 0xffff; \
-    } \
-}
-
-static VOL8	*mmio;
-static CARD32	byteStride;
-static CARD32	bytesPerPixel;
-static CARD32	pixelStride;
-
-static void
-chipsSet (ScreenPtr pScreen)
-{
-    KdScreenPriv(pScreen);
-    chipsScreenInfo(pScreenPriv);
-    
-    mmio = chipss->mmio_base;
-    byteStride = pScreenPriv->screen->fb[0].byteStride;
-    bytesPerPixel = pScreenPriv->screen->fb[0].bitsPerPixel >> 3;
-    pixelStride = pScreenPriv->screen->fb[0].pixelStride;
-}
-
-#ifdef HIQV
-#define CHIPS_BR0	0x00	/* offset */
-#define CHIPS_BR1    	0x04	/* bg */
-#define CHIPS_BR2    	0x08	/* fg */
-#define CHIPS_BR3    	0x0c	/* monochrome */
-#define CHIPS_BR4	0x10	/* bitblt */
-#define CHIPS_BR5	0x14	/* pattern addr */
-#define CHIPS_BR6	0x18	/* source addr */
-#define CHIPS_BR7	0x1c	/* dst addr */
-#define CHIPS_BR8	0x20	/* dst w/h */
-#else
-#define CHIPS_DR0	0x83d0
-#define CHIPS_DR1    	0x87d0
-#define CHIPS_DR2    	0x8bd0
-#define CHIPS_DR3    	0x8fd0
-#define CHIPS_DR4	0x93d0
-#define CHIPS_DR5	0x97d0
-#define CHIPS_DR6	0x9bd0
-#define CHIPS_DR7	0x9fd0
-#endif
-
-#define DBG(x)
-
-static void
-chipsPitch (int src, int dst)
-{
-    CARD32  p;
-
-    p = ((dst & 0xffff) << 16) | (src & 0xffff);
-    DBG(ErrorF ("\tpitch 0x%x\n", p));
-#ifdef HIQV
-    *(VOL32 *) (mmio + CHIPS_BR0) = p;
-#else
-    *(VOL32 *) (mmio + CHIPS_DR0) = p;
-#endif
-}
-
-static void
-chipsBg (Pixel   bg)
-{
-    DBG(ErrorF ("\tbg 0x%x\n", bg));
-#ifdef HIQV
-    *(VOL32 *) (mmio + CHIPS_BR1) = bg & 0xffff;
-#else
-    *(VOL32 *) (mmio + CHIPS_DR2) = bg;
-#endif
-}
-
-static void
-chipsFg (Pixel   fg)
-{
-    DBG(ErrorF ("\tfg 0x%x\n", fg));
-#ifdef HIQV
-    *(VOL32 *) (mmio + CHIPS_BR2) = fg;
-#else
-    *(VOL32 *) (mmio + CHIPS_DR3) = fg;
-#endif
-}
-
-static void
-chipsOp (CARD32 op)
-{
-    DBG(ErrorF ("\top 0x%x\n", op));
-#ifdef HIQV
-    *(VOL32 *) (mmio + CHIPS_BR4) = op;
-#else
-    *(VOL32 *) (mmio + CHIPS_DR4) = op;
-#endif
-}
-    
-static void
-chipsRopSolid (int rop)
-{
-    CARD32  op;
-    
-    op = chipsSolidRop[rop] | ctTOP2BOTTOM | ctLEFT2RIGHT | ctPATSOLID | ctPATMONO;
-    chipsOp (op);
-}
-
-static void
-chipsSrc (int addr)
-{
-    DBG(ErrorF ("\tsrc 0x%x\n", addr));
-#ifdef HIQV
-    *(VOL32 *) (mmio + CHIPS_BR6) = addr;
-#else
-    *(VOL32 *) (mmio + CHIPS_DR5) = addr;
-#endif
-}
-
-static void
-chipsDst (int addr)
-{
-    DBG(ErrorF ("\tdst 0x%x\n", addr));
-#ifdef HIQV
-    *(VOL32 *) (mmio + CHIPS_BR7) = addr;
-#else
-    *(VOL32 *) (mmio + CHIPS_DR6) = addr;
-#endif
-}
-
-static void
-chipsWidthHeightGo (int w, int h)
-{
-    DBG(ErrorF ("\twidth height %d/%d\n", w, h));
-#ifdef HIQV
-    *(VOL32 *) (mmio + CHIPS_BR8) = ((h & 0xffff) << 16) | (w & 0xffff);
-#else
-    *(VOL32 *) (mmio + CHIPS_DR7) = ((h & 0xffff) << 16) | (w & 0xffff);
-#endif
-}
-
-static void
-chipsWaitIdle (void)
-{
-#ifdef HIQV
-    int	timeout = 0;
-    CARD8   tmp;
-    VOL32   *br4 = (VOL32 *) (mmio + CHIPS_BR4);
-    
-    DBG(ErrorF ("\tBR4 0x%x 0x%x\n", mmio + CHIPS_BR4, *br4));
-    DBG(ErrorF ("\tXR20 0x%x\n", chipsReadXR (0, 0x20)));
-    for (;;)
-    {
-	if ((*br4 & 0x80000000) == 0)
-	    break;
-	tmp = chipsReadXR (0, 0x20);
-	if ((tmp & 1) == 0)
-	    break;
-	if (++timeout > 1000000)
-	{
-	    ErrorF ("timeout\n");
-	    tmp = chipsReadXR (0, 0x20);
-	    chipsWriteXR (0, 0x20, tmp | 2);
-	    sleep (1);
-	    chipsWriteXR (0, 0x20, tmp);
-	    sleep (1);
-	}
-    }
-#else
-    while (*(VOL32 *) (mmio + CHIPS_DR4) & 0x00100000)
-	;
-#endif
-}
-
-static void
-chipsWaitMarker (ScreenPtr pScreen, int marker)
-{
-    chipsSet (pScreen);
-    chipsWaitIdle ();
-}
-
-static Bool
-chipsPrepareSolid (PixmapPtr	pPixmap,
-		   int		alu,
-		   Pixel	pm,
-		   Pixel	fg)
-{
-    FbBits  depthMask;
-    
-    DBG(ErrorF ("PrepareSolid %d 0x%x\n", alu, fg));
-    depthMask = FbFullMask(pPixmap->drawable.depth);
-    if ((pm & depthMask) != depthMask)
-	return FALSE;
-    else
-    {
-	chipsSet (pPixmap->drawable.pScreen);
-	chipsWaitIdle ();
-	chipsFillPix(pPixmap->drawable.bitsPerPixel,fg);
-	chipsFg (fg);
-	chipsBg (fg);
-	chipsRopSolid (alu);
-	chipsPitch (byteStride, byteStride);
-	return TRUE;
-    }
-}
-
-static void
-chipsSolid (int x1, int y1, int x2, int y2)
-{
-    CARD32  dst;
-    int	    w, h;
-
-    DBG(ErrorF ("    Solid %dx%d %dx%d\n", x1, y1, x2, y2));
-    dst = y1 * byteStride + x1 * bytesPerPixel;
-    w = (x2 - x1) * bytesPerPixel;
-    h = (y2 - y1);
-    chipsWaitIdle ();
-    chipsDst (dst);
-    chipsWidthHeightGo (w, h);
-}
-
-static void
-chipsDoneSolid (void)
-{
-}
-
-static CARD32	copyOp;
-
-static Bool
-chipsPrepareCopy (PixmapPtr	pSrcPixmap,
-		  PixmapPtr	pDstPixmap,
-		  int		dx,
-		  int		dy,
-		  int		alu,
-		  Pixel		pm)
-{
-    FbBits  depthMask;
-    
-    DBG(ErrorF ("PrepareSolid %d 0x%x\n", alu, fg));
-    depthMask = FbFullMask(pDstPixmap->drawable.depth);
-    if ((pm & depthMask) != depthMask)
-	return FALSE;
-    else
-    {
-	copyOp = chipsBltRop[alu];
-	if (dy >= 0)
-	    copyOp |= ctTOP2BOTTOM;
-	else
-	    copyOp |= ctBOTTOM2TOP;
-	if (dx >= 0)
-	    copyOp |= ctLEFT2RIGHT;
-	else
-	    copyOp |= ctRIGHT2LEFT;
-	chipsSet (pDstPixmap->drawable.pScreen);
-	chipsWaitIdle ();
-	chipsOp (copyOp);
-	chipsPitch (byteStride, byteStride);
-	return TRUE;
-    }
-}
-
-static void
-chipsCopy (int srcX,
-	   int srcY,
-	   int dstX,
-	   int dstY,
-	   int w,
-	   int h)
-{
-    int	src, dst;
-    if ((copyOp & (ctTOP2BOTTOM|ctBOTTOM2TOP)) == ctBOTTOM2TOP)
-    {
-	src = (srcY + h - 1) * byteStride;
-	dst = (dstY + h - 1) * byteStride;
-    }
-    else
-    {
-	src = srcY * byteStride;
-	dst = dstY * byteStride;
-    }
-    if ((copyOp & (ctLEFT2RIGHT|ctRIGHT2LEFT)) == ctRIGHT2LEFT)
-    {
-	src = src + (srcX + w) * bytesPerPixel - 1;
-	dst = dst + (dstX + w) * bytesPerPixel - 1;
-    }
-    else
-    {
-	src = src + srcX * bytesPerPixel;
-	dst = dst + dstX * bytesPerPixel;
-    }
-    chipsWaitIdle ();
-    chipsSrc (src);
-    chipsDst (dst);
-    chipsWidthHeightGo (w * bytesPerPixel, h);
-}
-
-static void
-chipsDoneCopy (void)
-{
-}
-
-Bool
-chipsDrawInit (ScreenPtr pScreen)
-{
-    KdScreenPriv(pScreen);
-    chipsScreenInfo(pScreenPriv);
-
-    switch (pScreenPriv->screen->fb[0].bitsPerPixel) {
-    case 8:
-    case 16:
-	break;
-    default:
-	return FALSE;
-    }
-	
-    memset(&chipss->kaa, 0, sizeof(KaaScreenInfoRec));
-    chipss->kaa.waitMarker	= chipsWaitMarker;
-    chipss->kaa.PrepareSolid	= chipsPrepareSolid;
-    chipss->kaa.Solid		= chipsSolid;
-    chipss->kaa.DoneSolid	= chipsDoneSolid;
-    chipss->kaa.PrepareCopy	= chipsPrepareCopy;
-    chipss->kaa.Copy		= chipsCopy;
-    chipss->kaa.DoneCopy	= chipsDoneCopy;
-
-    if (!kaaDrawInit (pScreen, &chipss->kaa))
-	return FALSE;
-    
-    return TRUE;
-}
-
-void
-chipsDrawEnable (ScreenPtr pScreen)
-{
-    KdScreenPriv(pScreen);
-    chipsScreenInfo(pScreenPriv);
-    CARD8 mode = 0x00;
-    
-    switch (pScreenPriv->screen->fb[0].bitsPerPixel) {
-    case 8:
-	mode = 0x00;
-	break;
-    case 16:
-	mode = 0x10;
-	break;
-    }
-    chipsSet (pScreen);
-    chipsWaitIdle ();
-    chipsWriteXR (chipss, 0x20, mode);
-    
-    kaaMarkSync (pScreen);
-}
-
-void
-chipsDrawDisable (ScreenPtr pScreen)
-{
-}
-
-void
-chipsDrawFini (ScreenPtr pScreen)
-{
-}
-
diff --git a/hw/kdrive/chips/chipsstub.c b/hw/kdrive/chips/chipsstub.c
deleted file mode 100644
index 9024a7d..0000000
--- a/hw/kdrive/chips/chipsstub.c
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright 1999 SuSE, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of SuSE not be used in advertising or
- * publicity pertaining to distribution of the software without specific,
- * written prior permission.  SuSE makes no representations about the
- * suitability of this software for any purpose.  It is provided "as is"
- * without express or implied warranty.
- *
- * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
- * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
- * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
- * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * Author:  Keith Packard, SuSE, Inc.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <kdrive-config.h>
-#endif
-#include "chips.h"
-
-extern int  chips_clk, chips_mclk;
-
-void
-InitCard (char *name)
-{
-    KdCardAttr	attr;
-
-    KdCardInfoAdd (&chipsFuncs, &attr, 0);
-}
-
-void
-InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv)
-{
-    KdInitOutput (pScreenInfo, argc, argv);
-}
-
-void
-InitInput (int argc, char **argv)
-{
-    KdOsAddInputDrivers ();
-    KdInitInput ();
-}
-
-void
-ddxUseMsg (void)
-{
-    KdUseMsg();
-    vesaUseMsg();
-}
-
-int
-ddxProcessArgument (int argc, char **argv, int i)
-{
-    int	ret;
-    
-    if (!(ret = vesaProcessArgument (argc, argv, i)))
-	ret = KdProcessArgument(argc, argv, i);
-    return ret;
-}
diff --git a/hw/kdrive/epson/Makefile.am b/hw/kdrive/epson/Makefile.am
deleted file mode 100644
index 14bb049..0000000
--- a/hw/kdrive/epson/Makefile.am
+++ /dev/null
@@ -1,36 +0,0 @@
-INCLUDES = 					\
-	@KDRIVE_INCS@				\
-	@KDRIVE_CFLAGS@
-
-bin_PROGRAMS = Xepson
-
-noinst_LIBRARIES = libepson.a
-
-libepson_a_SOURCES = 	\
-	epson13806.c	\
-	epson13806.h	\
-	epson13806draw.c\
-	epson13806draw.h\
-	epson13806reg.h
-
-Xepson_SOURCES = \
-	epson13806stub.c
-
-EPSON_LIBS =					\
-	libepson.a 				\
-	@KDRIVE_LIBS@
-
-if GLX
-Xepson_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
-endif
-
-Xepson_LDADD = \
-	$(EPSON_LIBS)			       \
-	@KDRIVE_LIBS@
-
-Xepson_DEPENDENCIES =	\
-	libepson.a 				\
-	@KDRIVE_LOCAL_LIBS@
-
-relink:
-	rm -f $(bin_PROGRAMS) && make $(bin_PROGRAMS)
diff --git a/hw/kdrive/epson/Xepson.man b/hw/kdrive/epson/Xepson.man
deleted file mode 100644
index 96aab81..0000000
--- a/hw/kdrive/epson/Xepson.man
+++ /dev/null
@@ -1,26 +0,0 @@
-.\" $XFree86: xc/programs/Xserver/hw/kdrive/epson/Xepson.man,v 1.5 2001/02/13 21:15:15 dawes Exp $
-.\"
-.TH Xepson 1 __vendorversion__
-.SH NAME
-Xepson \- Epson 13806 accelerated framebuffer device tiny X server
-.SH SYNOPSIS
-.B Xepson
-.RI [ :display ]
-.RI [ option ...]
-.SH DESCRIPTION
-.B Xepson
-is a driver for the Epson LCD 13806 framebuffer.
-.B Xepson
-is heavily based upon the Kdrive Xfbdev driver, and behaves very similarly, except for accelerated operations targetted at the Epson chip.
-.SH OPTIONS
-.B Xepson
-accepts the common options of the Xkdrive family of servers.  Please
-see Xkdrive(1).
-.SH KEYBOARD
-To be written.
-.SH SEE ALSO
-X(__miscmansuffix__), Xserver(1), Xkdrive(1), xdm(1), xinit(1).
-.SH AUTHORS
-The
-.B Xepson
-server was written by Costas Stylianou based on the Xfbdev sources with some contributions from Phil Blundell & Peter Naulls.
diff --git a/hw/kdrive/epson/epson13806.c b/hw/kdrive/epson/epson13806.c
deleted file mode 100644
index 6cf8c9a..0000000
--- a/hw/kdrive/epson/epson13806.c
+++ /dev/null
@@ -1,604 +0,0 @@
-/*
- * Copyright 2004 by Costas Stylianou <costas.stylianou at psion.com> +44(0)7850 394095
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Costas Sylianou not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. Costas Stylianou makes no representations
- * about the suitability of this software for any purpose.  It is provided
- * "as is" without express or implied warranty.
- *
- * COSTAS STYLIANOU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL COSTAS STYLIANOU BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-/*
- * epson13806.c - Implementation of hardware accelerated functions for
- *                Epson S1D13806 graphics controller.
- *
- * History:
- * 28-Jan-04  C.Stylianou                     PRJ NBL: Created from fbdev.c.
- * 30-Mar-04  Phil Blundell/Peter Naulls      Integration with XFree 4.3
- *  
- */
-
-#ifdef HAVE_CONFIG_H
-#include <kdrive-config.h>
-#endif
-
-#include <sys/ioctl.h>
-
-#include "epson13806.h"
-#include "epson13806reg.h"
-
-extern int KdTsPhyScreen;
-
-Bool
-epsonInitialize (KdCardInfo *card, EpsonPriv *priv)
-{
-    int k;
-    unsigned long off;
-    if ((priv->fd = open("/dev/fb0", O_RDWR)) < 0) {
-        perror("Error opening /dev/fb0\n");
-        return FALSE;
-        }
-
-    if ((k=ioctl(priv->fd, FBIOGET_FSCREENINFO, &priv->fix)) < 0) {
-        perror("Error with /dev/fb ioctl FIOGET_FSCREENINFO");
-        close (priv->fd);
-        return FALSE;
-        }
-
-    if ((k=ioctl(priv->fd, FBIOGET_VSCREENINFO, &priv->var)) < 0) {
-        perror("Error with /dev/fb ioctl FIOGET_VSCREENINFO");
-        close (priv->fd);
-        return FALSE;
-        }
-    
-    priv->fb_base = KdMapDevice (EPSON13806_PHYSICAL_VMEM_ADDR, EPSON13806_VMEM_SIZE);
-        
-        
-    if (priv->fb_base == (char *)-1) {
-        perror("ERROR: mmap framebuffer fails!");
-        close (priv->fd);
-        return FALSE;
-        }
-
-    off = (unsigned long) priv->fix.smem_start % (unsigned long) getpagesize();
-    priv->fb = priv->fb_base + off;
-    return TRUE;
-}
-
-Bool
-epsonCardInit (KdCardInfo *card)
-{
-    EpsonPriv    *priv;
-
-    priv = (EpsonPriv *) xalloc (sizeof (EpsonPriv));
-    if (!priv)
-    return FALSE;
-    
-    if (!epsonInitialize (card, priv))
-    {
-    	xfree (priv);
-    	return FALSE;
-    }
-    card->driver = priv;
-    
-    // Call InitEpson to map onto Epson registers
-    initEpson13806();
-    
-    return TRUE;
-}
-
-#define FBDEV_KLUDGE_FORMAT
-#ifdef FBDEV_KLUDGE_FORMAT
-static Pixel
-epsonMakeContig (Pixel orig, Pixel others)
-{
-    Pixel   low;
-
-    low = lowbit (orig) >> 1;
-    while (low && (others & low) == 0)
-    {
-    	orig |= low;
-    	low >>= 1;
-    }
-    return orig;
-}
-#endif
-
-Bool
-epsonScreenInitialize (KdScreenInfo *screen, EpsonScrPriv *scrpriv)
-{
-    EpsonPriv    *priv = screen->card->driver;
-    Pixel    allbits;
-    int        depth;
-    Bool    gray;
-    depth = priv->var.bits_per_pixel;
-    gray = priv->var.grayscale;
-    
-    
-    screen->fb[0].visuals = (1 << TrueColor);
-#define Mask(o,l)   (((1 << l) - 1) << o)
-    screen->fb[0].redMask = Mask (priv->var.red.offset, priv->var.red.length);
-    screen->fb[0].greenMask = Mask (priv->var.green.offset, priv->var.green.length);
-    screen->fb[0].blueMask = Mask (priv->var.blue.offset, priv->var.blue.length);
-#ifdef FBDEV_KLUDGE_FORMAT
-    /*
-     * This is a kludge so that Render will work -- fill in the gaps
-     * in the pixel
-     */
-    screen->fb[0].redMask = epsonMakeContig (screen->fb[0].redMask,
-                         screen->fb[0].greenMask|
-                         screen->fb[0].blueMask);
-
-    screen->fb[0].greenMask = epsonMakeContig (screen->fb[0].greenMask,
-                           screen->fb[0].redMask|
-                           screen->fb[0].blueMask);
-
-    screen->fb[0].blueMask = epsonMakeContig (screen->fb[0].blueMask,
-                          screen->fb[0].redMask|
-                          screen->fb[0].greenMask);
-
-#endif
-    allbits = screen->fb[0].redMask | screen->fb[0].greenMask | screen->fb[0].blueMask;
-    depth = 32;
-    while (depth && !(allbits & (1 << (depth - 1))))
-        depth--;
-    
-    screen->rate = 60;
-    scrpriv->randr = screen->randr;
-    
-    {
-        screen->fb[0].depth = depth;
-        screen->fb[0].bitsPerPixel = priv->var.bits_per_pixel;
-        screen->width = priv->var.xres;
-        screen->height = priv->var.yres;
-        screen->fb[0].byteStride = priv->fix.line_length;
-        screen->fb[0].pixelStride = (priv->fix.line_length * 8 / 
-                     priv->var.bits_per_pixel);
-        screen->fb[0].frameBuffer = (CARD8 *) (priv->fb);
-        screen->off_screen_base = screen->fb[0].byteStride * screen->height;
-        screen->memory_base = priv->fb;
-        screen->memory_size = EPSON13806_VMEM_SIZE;
-    }
-    return TRUE;
-}
-
-Bool
-epsonScreenInit (KdScreenInfo *screen)
-{
-    EpsonScrPriv *scrpriv;
-
-    scrpriv = xalloc (sizeof (EpsonScrPriv));
-    if (!scrpriv)
-        return FALSE;
-    memset (scrpriv, '\0', sizeof (EpsonScrPriv));
-    screen->driver = scrpriv;
-    if (!epsonScreenInitialize (screen, scrpriv)) {
-        screen->driver = 0;
-    xfree (scrpriv);
-    return FALSE;
-    }
-    return TRUE;
-}
-    
-static void *
-epsonWindowLinear (ScreenPtr    pScreen,
-           CARD32    row,
-           CARD32    offset,
-           int        mode,
-           CARD32    *size,
-           void        *closure)
-{
-    KdScreenPriv(pScreen);
-    EpsonPriv        *priv = pScreenPriv->card->driver;
-
-    if (!pScreenPriv->enabled)
-        return 0;
-    *size = priv->fix.line_length;
-    return (CARD8 *) priv->fb + row * priv->fix.line_length + offset;
-}
-
-
-#ifdef RANDR
-static Bool
-epsonRandRGetInfo (ScreenPtr pScreen, Rotation *rotations)
-{
-    KdScreenPriv(pScreen);
-    KdScreenInfo        *screen = pScreenPriv->screen;
-    EpsonScrPriv        *scrpriv = screen->driver;
-#if 0
-    RRVisualGroupPtr        pVisualGroup;
-    RRGroupOfVisualGroupPtr pGroupOfVisualGroup;
-#endif
-    RRScreenSizePtr        pSize;
-    Rotation            randr;
-    int                n;
-    
-    *rotations = RR_Rotate_0|RR_Rotate_90|RR_Rotate_180|RR_Rotate_270;
-    
-    for (n = 0; n < pScreen->numDepths; n++)
-        if (pScreen->allowedDepths[n].numVids)
-            break;
-    if (n == pScreen->numDepths)
-        return FALSE;
-
-#if 0    
-    pVisualGroup = RRCreateVisualGroup (pScreen);
-    if (!pVisualGroup)
-        return FALSE;
-    
-    if (!RRAddDepthToVisualGroup (pScreen, pVisualGroup, &pScreen->allowedDepths[n])) {
-        RRDestroyVisualGroup (pScreen, pVisualGroup);
-        return FALSE;
-        }
-
-    pVisualGroup = RRRegisterVisualGroup (pScreen, pVisualGroup);
-    if (!pVisualGroup)
-        return FALSE;
-    
-    pGroupOfVisualGroup = RRCreateGroupOfVisualGroup (pScreen);
-
-    if (!RRAddVisualGroupToGroupOfVisualGroup (pScreen,
-                     pGroupOfVisualGroup,
-                     pVisualGroup))
-    {
-    RRDestroyGroupOfVisualGroup (pScreen, pGroupOfVisualGroup);
-    /* pVisualGroup left until screen closed */
-    return FALSE;
-    }
-
-    pGroupOfVisualGroup = RRRegisterGroupOfVisualGroup (pScreen, pGroupOfVisualGroup);
-    if (!pGroupOfVisualGroup)
-    return FALSE;
-#endif
-
-    pSize = RRRegisterSize (pScreen,
-                screen->width,
-                screen->height,
-                screen->width_mm,
-                screen->height_mm);
-    
-    randr = KdSubRotation (scrpriv->randr, screen->randr);
-    
-    RRSetCurrentConfig (pScreen, randr, RR_Rotate_0, pSize);
-    
-    return TRUE;
-}
-
-static Bool
-epsonRandRSetConfig (ScreenPtr        pScreen,
-             Rotation        randr,
-             int        rate,
-             RRScreenSizePtr    pSize)
-{
-    KdScreenPriv(pScreen);
-    KdScreenInfo    *screen = pScreenPriv->screen;
-    EpsonScrPriv    *scrpriv = screen->driver;
-    Bool        wasEnabled = pScreenPriv->enabled;
-
-    randr = KdAddRotation (randr, screen->randr);
-
-    if (scrpriv->randr != randr)
-    {
-        if (wasEnabled)
-            KdDisableScreen (pScreen);
-    
-        scrpriv->randr = randr;
-
-        if (wasEnabled)
-            KdEnableScreen (pScreen);
-    }
-    return TRUE;
-}
-
-static Bool
-epsonRandRInit (ScreenPtr pScreen)
-{
-    rrScrPrivPtr    pScrPriv;
-    
-    if (!RRScreenInit (pScreen))
-    return FALSE;
-
-    pScrPriv = rrGetScrPriv(pScreen);
-    pScrPriv->rrGetInfo = epsonRandRGetInfo;
-    pScrPriv->rrSetConfig = epsonRandRSetConfig;
-    return TRUE;
-}
-#endif
-
-static Bool
-epsonCreateColormap (ColormapPtr pmap)
-{
-    ScreenPtr        pScreen = pmap->pScreen;
-    KdScreenPriv(pScreen);
-    EpsonPriv        *priv = pScreenPriv->card->driver;
-    VisualPtr        pVisual;
-    int            i;
-    int            nent;
-    xColorItem        *pdefs;
-    
-    switch (priv->fix.visual) {
-        case FB_VISUAL_STATIC_PSEUDOCOLOR:
-            pVisual = pmap->pVisual;
-            nent = pVisual->ColormapEntries;
-            pdefs = xalloc (nent * sizeof (xColorItem));
-            if (!pdefs)
-                return FALSE;
-            for (i = 0; i < nent; i++)
-                pdefs[i].pixel = i;
-            epsonGetColors (pScreen, 0, nent, pdefs);
-            for (i = 0; i < nent; i++)
-            {
-                pmap->red[i].co.local.red = pdefs[i].red;
-                pmap->red[i].co.local.green = pdefs[i].green;
-                pmap->red[i].co.local.blue = pdefs[i].blue;
-            }
-            xfree (pdefs);
-            return TRUE;
-
-        default:
-            return fbInitializeColormap (pmap);
-    }
-}
-
-Bool
-epsonInitScreen (ScreenPtr pScreen)
-{
-#ifdef TOUCHSCREEN
-    KdTsPhyScreen = pScreen->myNum;
-#endif
-
-    pScreen->CreateColormap = epsonCreateColormap;
-
-    return TRUE;
-}
-
-static Bool
-epsonFinishInitScreen (ScreenPtr pScreen)
-{
-    if (!shadowSetup (pScreen))
-    return FALSE;
-
-#ifdef RANDR
-    if (!epsonRandRInit (pScreen))
-    return FALSE;
-#endif
-
-    return TRUE;
-}
-
-static Bool
-epsonSetShadow (ScreenPtr pScreen)
-{
-    KdScreenPriv(pScreen);
-    KdScreenInfo    *screen = pScreenPriv->screen;
-    EpsonScrPriv    *scrpriv = screen->driver;
-    ShadowUpdateProc    update;
-    ShadowWindowProc    window;
-
-    window = epsonWindowLinear;
-    update = shadowUpdatePacked;
-
-    return KdShadowSet (pScreen, scrpriv->randr, update, window);
-}
-
-static Bool
-epsonCreateResources (ScreenPtr pScreen)
-{
-    return epsonSetShadow (pScreen);
-}
-
-void
-epsonPreserve (KdCardInfo *card)
-{
-}
-
-Bool
-epsonEnable (ScreenPtr pScreen)
-{
-    KdScreenPriv(pScreen);
-    EpsonPriv        *priv = pScreenPriv->card->driver;
-    int            k;
-
-    priv->var.activate = FB_ACTIVATE_NOW|FB_CHANGE_CMAP_VBL;
-    
-    /* display it on the LCD */
-    k = ioctl (priv->fd, FBIOPUT_VSCREENINFO, &priv->var);
-    if (k < 0) {
-        perror ("FBIOPUT_VSCREENINFO");
-        return FALSE;
-        }
-
-    k = ioctl (priv->fd, FBIOGET_FSCREENINFO, &priv->fix);
-    if (k < 0) {
-        perror ("FBIOGET_FSCREENINFO");
-        return FALSE;
-    }
-
-    if (priv->fix.visual == FB_VISUAL_DIRECTCOLOR) {
-        struct fb_cmap    cmap;
-        int        i;
-
-        for (i = 0; 
-             i < (1 << priv->var.red.length) ||
-             i < (1 << priv->var.green.length) ||
-             i < (1 << priv->var.blue.length); i++) {
-            priv->red[i] = i * 65535 / ((1 << priv->var.red.length) - 1);
-            priv->green[i] = i * 65535 / ((1 << priv->var.green.length) - 1);
-            priv->blue[i] = i * 65535 / ((1 << priv->var.blue.length) - 1);
-        }
-        cmap.start = 0;
-        cmap.len = i;
-        cmap.red = &priv->red[0];
-        cmap.green = &priv->green[0];
-        cmap.blue = &priv->blue[0];
-        cmap.transp = 0;
-        ioctl (priv->fd, FBIOPUTCMAP, &cmap);
-        }
-    return TRUE;
-}
-
-Bool
-epsonDPMS (ScreenPtr pScreen, int mode)
-{
-    KdScreenPriv(pScreen);
-    EpsonPriv    *priv = pScreenPriv->card->driver;
-    static int oldmode = -1;
-
-    if (mode == oldmode)
-        return TRUE;
-#ifdef FBIOPUT_POWERMODE
-    if (ioctl (priv->fd, FBIOPUT_POWERMODE, &mode) >= 0) {
-        oldmode = mode;
-        return TRUE;
-        }
-#endif
-#ifdef FBIOBLANK
-    if (ioctl (priv->fd, FBIOBLANK, mode ? mode + 1 : 0) >= 0) {
-        oldmode = mode;
-        return TRUE;
-        }
-#endif
-    return FALSE;
-}
-
-void
-epsonDisable (ScreenPtr pScreen)
-{
-}
-
-void
-epsonRestore (KdCardInfo *card)
-{
-}
-
-void
-epsonScreenFini (KdScreenInfo *screen)
-{
-}
-
-void
-epsonCardFini (KdCardInfo *card)
-{
-    EpsonPriv    *priv = card->driver;
-    
-    munmap (priv->fb_base, priv->fix.smem_len);
-    close (priv->fd);
-    xfree (priv);
-}
-
-void
-epsonGetColors (ScreenPtr pScreen, int fb, int n, xColorItem *pdefs)
-{
-    KdScreenPriv(pScreen);
-    EpsonPriv        *priv = pScreenPriv->card->driver;
-    struct fb_cmap  cmap;
-    int            p;
-    int            k;
-    int            min, max;
-
-    min = 256;
-    max = 0;
-    for (k = 0; k < n; k++) {
-        if (pdefs[k].pixel < min)
-            min = pdefs[k].pixel;
-        if (pdefs[k].pixel > max)
-            max = pdefs[k].pixel;
-        }
-    cmap.start = min;
-    cmap.len = max - min + 1;
-    cmap.red = &priv->red[min];
-    cmap.green = &priv->green[min];;
-    cmap.blue = &priv->blue[min];
-    cmap.transp = 0;
-    k = ioctl (priv->fd, FBIOGETCMAP, &cmap);
-    if (k < 0) {
-        perror ("can't get colormap");
-        return;
-        }
-    while (n--) {
-    p = pdefs->pixel;
-    pdefs->red = priv->red[p];
-    pdefs->green = priv->green[p];
-    pdefs->blue = priv->blue[p];
-    pdefs++;
-    }
-}
-
-void
-epsonPutColors (ScreenPtr pScreen, int fb, int n, xColorItem *pdefs)
-{
-    KdScreenPriv(pScreen);
-    EpsonPriv    *priv = pScreenPriv->card->driver;
-    struct fb_cmap  cmap;
-    int            p;
-    int            min, max;
-
-    min = 256;
-    max = 0;
-    while (n--) {
-        p = pdefs->pixel;
-        priv->red[p] = pdefs->red;
-        priv->green[p] = pdefs->green;
-        priv->blue[p] = pdefs->blue;
-        if (p < min)
-            min = p;
-        if (p > max)
-            max = p;
-        pdefs++;
-        }
-    cmap.start = min;
-    cmap.len = max - min + 1;
-    cmap.red = &priv->red[min];
-    cmap.green = &priv->green[min];
-    cmap.blue = &priv->blue[min];
-    cmap.transp = 0;
-    ioctl (priv->fd, FBIOPUTCMAP, &cmap);
-}
-
-
-
-KdCardFuncs epsonFuncs = {
-    epsonCardInit,          /* cardinit */
-    epsonScreenInit,        /* scrinit */
-    epsonInitScreen,        /* initScreen */
-    epsonFinishInitScreen,
-    epsonCreateResources,
-    epsonPreserve,          /* preserve */
-    epsonEnable,            /* enable */
-    epsonDPMS,              /* dpms */
-    epsonDisable,           /* disable */
-    epsonRestore,           /* restore */
-    epsonScreenFini,        /* scrfini */
-    epsonCardFini,          /* cardfini */
-    
-    0,                      /* initCursor */
-    0,                      /* enableCursor */
-    0,                      /* disableCursor */
-    0,                      /* finiCursor */
-    0,                      /* recolorCursor */
-    
-    /* 
-     * History:
-     * 28-Jan-04  C.Stylianou       NBL: Added the following for h/w accel.
-     *
-     */
-
-    epsonDrawInit,          /* initAccel */
-    epsonDrawEnable,        /* enableAccel */
-    epsonDrawDisable,       /* disableAccel */
-    epsonDrawFini,          /* finiAccel */
-    
-    epsonGetColors,         /* getColors */
-    epsonPutColors,         /* putColors */
-};
diff --git a/hw/kdrive/epson/epson13806.h b/hw/kdrive/epson/epson13806.h
deleted file mode 100644
index b28d7c0..0000000
--- a/hw/kdrive/epson/epson13806.h
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Copyright 2004 by Costas Stylianou <costas.stylianou at psion.com> +44(0)7850 394095
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Costas Sylianou not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. Costas Stylianou makes no representations
- * about the suitability of this software for any purpose.  It is provided
- * "as is" without express or implied warranty.
- *
- * COSTAS STYLIANOU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL COSTAS STYLIANOU BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-/* 
- * epson13806draw.h - Implementation of hard ware accelerated functions for epson S1D13806
- *               Graphic controller.
- *
- * History:
- * 28-Jan-04  C.Stylianou       PRJ NBL: Created from fbdev.h
- *
- */
-
-#ifndef _EPSON13806_H_
-#define _EPSON13806_H_
-
-#include <stdio.h>
-#include <linux/fb.h>
-#include <unistd.h>
-#include <sys/mman.h>
-
-#include "kdrive.h"
-
-#ifdef RANDR
-#include "randrstr.h"
-#endif
-
-typedef struct _epsonPriv {
-    struct fb_var_screeninfo	var;
-    struct fb_fix_screeninfo	fix;
-    __u16			red[256];
-    __u16			green[256];
-    __u16			blue[256];
-    int				fd;
-    char			*fb;
-    char			*fb_base;
-} EpsonPriv;
-    
-typedef struct _epsonScrPriv {
-    Rotation		randr;
-    Bool			shadow;
-    KaaScreenInfoRec	kaa;
-} EpsonScrPriv;
-
-extern KdCardFuncs  epsonFuncs;
-
-Bool
-epsonInitialize (KdCardInfo *card, EpsonPriv *priv);
-
-Bool
-epsonCardInit (KdCardInfo *card);
-
-Bool
-epsonScreenInit (KdScreenInfo *screen);
-
-Bool
-epsonScreenInitialize (KdScreenInfo *screen, EpsonScrPriv *scrpriv);
-    
-Bool
-epsonInitScreen (ScreenPtr pScreen);
-
-void
-epsonPreserve (KdCardInfo *card);
-
-Bool
-epsonEnable (ScreenPtr pScreen);
-
-Bool
-epsonDPMS (ScreenPtr pScreen, int mode);
-
-void
-epsonDisable (ScreenPtr pScreen);
-
-void
-epsonRestore (KdCardInfo *card);
-
-void
-epsonScreenFini (KdScreenInfo *screen);
-
-void
-epsonCardFini (KdCardInfo *card);
-
-void
-epsonGetColors (ScreenPtr pScreen, int fb, int n, xColorItem *pdefs);
-
-void
-epsonPutColors (ScreenPtr pScreen, int fb, int n, xColorItem *pdefs);
-
-/* 
- * History:
- * 28-Jan-04  C.Stylianou       NBL: Added the following prototypes for h/w accel.
- *
- */
-Bool
-epsonDrawInit (ScreenPtr pScreen);
-
-void
-epsonDrawEnable (ScreenPtr pScreen);
-
-void
-epsonDrawDisable (ScreenPtr pScreen);
-
-void
-epsonDrawFini (ScreenPtr pScreen);
-
-/* 
- * History:
- * 28-Jan-04  C.Stylianou       NBL: Maps to Epson registers
- *
- */
-void
-initEpson13806(void);
-
-
-#endif /* __EPSON13806_H_ */
diff --git a/hw/kdrive/epson/epson13806draw.c b/hw/kdrive/epson/epson13806draw.c
deleted file mode 100644
index 3222353..0000000
--- a/hw/kdrive/epson/epson13806draw.c
+++ /dev/null
@@ -1,649 +0,0 @@
-/*
- * Copyright 2004 by Costas Stylianou <costas.stylianou at psion.com> +44(0)7850 394095
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Costas Sylianou not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. Costas Stylianou makes no representations
- * about the suitability of this software for any purpose.  It is provided
- * "as is" without express or implied warranty.
- *
- * COSTAS STYLIANOU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL COSTAS STYLIANOU BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-/* 
- * epson13806draw.c - Implementation of hardware accelerated functions for epson S1D13806
- *               Graphic controller.
- *
- * History:
- * 28-Jan-04  C.Stylianou       PRJ NBL: Created from chipsdraw.c
- *
- */
-
-#include    "epson13806.h"
-#include    "epson13806draw.h"
-#include    "epson13806reg.h"
-
-#include    "kaa.h"
-
-#include    "gcstruct.h"
-#include    "scrnintstr.h"
-#include    "pixmapstr.h"
-#include    "regionstr.h"
-#include    "mistruct.h"
-#include    "dixfontstr.h"
-#include    "fb.h"
-#include    "migc.h"
-#include    "miline.h"
-
-
-// Functionality of BitBLT ROP register for Epson S1D13806 Graphics controller
-CARD8 epson13806Rop[16] = {
-    /* GXclear      */      0x00,         /* 0 */
-    /* GXand        */      0x08,         /* src AND dst */
-    /* GXandReverse */      0x04,         /* src AND NOT dst */
-    /* GXcopy       */      0x0C,         /* src */
-    /* GXandInverted*/      0x02,         /* NOT src AND dst */
-    /* GXnoop       */      0x0A,         /* dst */
-    /* GXxor        */      0x06,         /* src XOR dst */
-    /* GXor         */      0x0E,         /* src OR dst */
-    /* GXnor        */      0x01,         /* NOT src AND NOT dst */
-    /* GXequiv      */      0x09,         /* NOT src XOR dst */
-    /* GXinvert     */      0x05,         /* NOT dst */
-    /* GXorReverse  */      0x0D,         /* src OR NOT dst */
-    /* GXcopyInverted*/     0x03,         /* NOT src */
-    /* GXorInverted */      0x0B,         /* NOT src OR dst */
-    /* GXnand       */      0x07,         /* NOT src OR NOT dst */
-    /* GXset        */      0x0F,         /* 1 */
-};
-
-
-
-#undef __DEBUG_EPSON__
-#undef __DEBUG_EPSON_FBSET__
-#undef __DEBUG_EPSON_SOLID__
-#undef __DEBUG_EPSON_COPY__
-
-
-#ifdef __DEBUG_EPSON__
-    #define EPSON_DEBUG(a) a
-#else
-    #define EPSON_DEBUG(a)
-#endif
-   
-#ifdef __DEBUG_EPSON_FBSET__
-    #define EPSON_DEBUG_FBSET(a) a
-#else
-    #define EPSON_DEBUG_FBSET(a)
-#endif
-
-#ifdef __DEBUG_EPSON_SOLID__
-    #define EPSON_DEBUG_SOLID(a) a
-#else
-    #define EPSON_DEBUG_SOLID(a)
-#endif
-
-#ifdef __DEBUG_EPSON_COPY__
-    #define EPSON_DEBUG_COPY(a) a
-#else
-    #define EPSON_DEBUG_COPY(a)
-#endif
-
-
-static unsigned int    byteStride;     // Distance between lines in the frame buffer (in bytes)
-static unsigned int    bytesPerPixel;
-static unsigned int    pixelStride;
-
-static unsigned char *regbase;
-
-/*
- * epsonSet
- *
- * Description:    Sets Epson variables
- *
- * History:
- * 11-Feb-04  C.Stylianou       NBL: Created.
- *
- */
-
-static void
-epsonSet (ScreenPtr pScreen)
-{
-    EPSON_DEBUG_FBSET (fprintf(stderr,"+epsonSet\n"));
-
-    KdScreenPriv(pScreen);
-   
-    byteStride = pScreenPriv->screen->fb[0].byteStride;
-    bytesPerPixel = pScreenPriv->screen->fb[0].bitsPerPixel >> 3;
-    pixelStride = pScreenPriv->screen->fb[0].pixelStride;
-
-    EPSON_DEBUG_FBSET (fprintf(stderr,"byteStride:     [%x]\n", pScreenPriv->screen->fb[0].byteStride));
-    EPSON_DEBUG_FBSET (fprintf(stderr,"bytesPerPixel:  [%x]\n", pScreenPriv->screen->fb[0].bitsPerPixel >> 3));
-    EPSON_DEBUG_FBSET (fprintf(stderr,"pixelStride:    [%x]\n", pScreenPriv->screen->fb[0].pixelStride));
-
-    EPSON_DEBUG_FBSET (fprintf(stderr,"-epsonSet\n"));
-}
-
-
-/*
- * epsonBg
- *
- * Description:    Sets background colour
- *
- * History:
- * 11-Feb-04  C.Stylianou       NBL: Created.
- *
- */
-
-static void
-epsonBg (Pixel bg)
-{
-   EPSON13806_REG16(EPSON13806_BLTBGCOLOR) = bg;
-}
-
-
-/*
- * epsonFg
- *
- * Description:    Sets foreground colour
- *
- * History:
- * 11-Feb-04  C.Stylianou       NBL: Created.
- *
- */
-
-static void
-epsonFg (Pixel fg)
-{    
-    EPSON13806_REG16(EPSON13806_BLTFGCOLOR) = fg;
-}
-
-
-/*
- * epsonWaitForHwBltDone
- *
- * Description:    Wait for previous blt to be done before programming any blt registers
- *
- * History:
- * 11-Feb-04  C.Stylianou       NBL: Created.
- *
- */
-
-static void
-epsonWaitForHwBltDone (void)
-{
-    while (EPSON13806_REG (EPSON13806_BLTCTRL0) & EPSON13806_BLTCTRL0_ACTIVE) {}
-}
-
-
-/*
- * epsonDrawSync
- *
- * Description:    Sync hardware acceleration
- *
- * History:
- * 11-Feb-04  C.Stylianou       NBL: Created.
- *
- */
-
-static void
-epsonWaitMarker (ScreenPtr pScreen, int marker)
-{
-    EPSON_DEBUG (fprintf(stderr,"+epsonDrawSync\n"));
-
-    epsonWaitForHwBltDone ();
-
-    EPSON_DEBUG (fprintf(stderr,"-epsonDrawSync\n"));
-}
-
-
-/*
- * epsonPrepareSolid
- *
- * Description:    Prepare Solid Fill i.e, can it be accelerated
- *
- * History:
- * 11-Feb-04  C.Stylianou       NBL: Created.
- *
- */
-
-static Bool
-epsonPrepareSolid (PixmapPtr    pPixmap,
-           int        alu,
-           Pixel    pm,
-           Pixel    fg)
-{
-    EPSON_DEBUG_SOLID (fprintf(stderr,"+epsonPrepareSolid\n"));
-    
-    FbBits  depthMask;
-
-    depthMask = FbFullMask(pPixmap->drawable.depth);
-    if ((pm & depthMask) != depthMask)
-        return FALSE;
-	
-	epsonSet (pPixmap->drawable.pScreen);
-    fg &= 0xffff;
-    epsonFg (fg);
-    epsonBg (fg);
-	
-	epsonWaitForHwBltDone ();
-	
-	EPSON_DEBUG_SOLID (fprintf(stderr,"Solid.alu [0x%x], [%d]\n", alu ,epson13806Rop[alu]));
-	EPSON13806_REG(EPSON13806_BLTROP) = epson13806Rop[alu];
-	
-	if (epson13806Rop[alu] == GXnoop)
-	{
-		EPSON13806_REG(EPSON13806_BLTOPERATION) = EPSON13806_BLTOPERATION_PATFILLROP;
-	}
-	else
-	{
-		EPSON13806_REG(EPSON13806_BLTOPERATION) = EPSON13806_BLTOPERATION_SOLIDFILL;
-	}
-   
-   
-    EPSON_DEBUG_SOLID (fprintf(stderr,"-epsonPrepareSolid\n"));
-    return TRUE;
-    
-}
-
-
-/*
- * epsonSolid
- *
- * Description:    Executes Solid Fill
- *
- * History:
- * 11-Feb-04  C.Stylianou       NBL: Created.
- *
- */
-
-static void
-epsonSolid (int x1, int y1, int x2, int y2)
-{
-    
-    EPSON_DEBUG_SOLID (fprintf(stderr,"+epsonSolid\n"));
-    
-    CARD32  dst_addr;
-    int width, height;
-    
-    EPSON_DEBUG_SOLID (fprintf(stderr,"Solid X1 [%d] Y1 [%d] X2 [%d] Y2 [%d]\n", x1, y1, x2, y2));
-    
-    dst_addr = y1 * byteStride + x1 * bytesPerPixel;
-    width = ((x2 - x1)-1);
-    height = ((y2 - y1)-1);
-    
-    // program dst address
-    EPSON13806_REG16(EPSON13806_BLTDSTSTART01) = dst_addr;
-    EPSON13806_REG(EPSON13806_BLTDSTSTART2) = dst_addr >> 16;
-    
-    // program width and height of blit
-    EPSON13806_REG16(EPSON13806_BLTWIDTH) = width;
-    EPSON13806_REG16(EPSON13806_BLTHEIGHT) = height;
-    
-    EPSON13806_REG(EPSON13806_BLTCTRL0) = EPSON13806_BLTCTRL0_ACTIVE;
-
-    // Wait for operation to complete
-    while (EPSON13806_REG(EPSON13806_BLTCTRL0) & EPSON13806_BLTCTRL0_ACTIVE) {}
-        
-    EPSON_DEBUG_SOLID (fprintf(stderr,"-epsonSolid\n"));
-}
-
-
-/*
- * epsonDoneSolid
- *
- * Description:    Done Solid
- *
- * History:
- * 11-Feb-04  C.Stylianou       NBL: Created.
- *
- */
-
-static void
-epsonDoneSolid (void)
-{
-    EPSON_DEBUG_SOLID (fprintf(stderr,"+epsonDoneSolid\n"));
-    
-    // Read from BitBLT data offset 0 to shut it down
-    //(void)EPSON13806_REG(EPSON13806_BITBLTDATA);
-
-    EPSON_DEBUG_SOLID (fprintf(stderr,"-epsonDoneSolid\n"));
-    
-}
-
-
-/*
- * epsonPrepareCopy
- *
- * Description:    Prepares BitBLT, i.e, can it be accelerated
- *
- * History:
- * 11-Feb-04  C.Stylianou       NBL: Created.
- *
- */
-
-static Bool
-epsonPrepareCopy (PixmapPtr    pSrcPixmap,
-          PixmapPtr    pDstPixmap,
-          int        dx,
-          int        dy,
-          int        alu,
-          Pixel        pm)
-{
-    EPSON_DEBUG_COPY (fprintf(stderr,"+epsonPrepareCopy dx [0x%x] dy [0x%x]\n", dx, dy));
-    
-    FbBits  depthMask;
-
-    depthMask = FbFullMask(pDstPixmap->drawable.depth);
-    
-    if ((pm & depthMask) != depthMask)
-        return FALSE;
-    
-    epsonSet (pDstPixmap->drawable.pScreen);
-	epsonWaitForHwBltDone ();
-    EPSON13806_REG(EPSON13806_BLTROP) = epson13806Rop[alu];
-            
-    EPSON_DEBUG_COPY (fprintf(stderr,"-epsonPrepareCopy\n"));
-        
-    return TRUE;
-}
-
-
-/*
- * epsonCopy
- *
- * Description:    Executes BitBLT
- *
- * History:
- * 11-Feb-04  C.Stylianou       NBL: Created.
- *
- */
-
-static void
-epsonCopy (int srcX,
-       int srcY,
-       int dstX,
-       int dstY,
-       int width,
-       int height)
-{
-    EPSON_DEBUG_COPY (fprintf(stderr,"+epsonCopy\n"));
-    int    src_addr, dst_addr;
-    int neg_dir = FALSE;
-    
-    if (!width || !height)
-        return;
-    
-    src_addr = srcX * bytesPerPixel + srcY * byteStride;
-    dst_addr = dstX * bytesPerPixel + dstY * byteStride;
-    
-    /*
-     * See if regions overlap and dest region is beyond source region.
-     * If so, we need to do a move BLT in negative direction. Only applies
-     * if the BLT is not transparent.
-     */
-    
-    if ((srcX + width  > dstX) && (srcX < dstX + width) &&
-        (srcY + height > dstY) && (srcY < dstY + height) &&
-        (dst_addr > src_addr)) 
-    {
-        neg_dir = TRUE;
-            
-        // negative direction : get the coords of lower right corner
-        src_addr += byteStride * (height-1) + bytesPerPixel * (width-1);
-        dst_addr += byteStride * (height-1) + bytesPerPixel * (width-1);
-    }
-    
-    // program BLIT memory offset
-    EPSON13806_REG16(EPSON13806_BLTSTRIDE) = byteStride/2;
-
-    // program src and dst addresses
-    EPSON13806_REG16(EPSON13806_BLTSRCSTART01) = src_addr;
-    EPSON13806_REG(EPSON13806_BLTSRCSTART2) = src_addr >> 16;
-    EPSON13806_REG16(EPSON13806_BLTDSTSTART01) = dst_addr;
-    EPSON13806_REG(EPSON13806_BLTDSTSTART2) = dst_addr >> 16;
-
-    // program width and height of blit
-    EPSON13806_REG16(EPSON13806_BLTWIDTH) = width-1;
-    EPSON13806_REG16(EPSON13806_BLTHEIGHT) = height-1;
-    
-    // select pos/neg move BLIT
-    EPSON13806_REG(EPSON13806_BLTOPERATION) = neg_dir ? 
-                EPSON13806_BLTOPERATION_MOVENEGROP : EPSON13806_BLTOPERATION_MOVEPOSROP;
-    
-    EPSON13806_REG(EPSON13806_BLTCTRL0) = EPSON13806_BLTCTRL0_ACTIVE;
-
-    // Wait for operation to complete
-    while (EPSON13806_REG(EPSON13806_BLTCTRL0) & EPSON13806_BLTCTRL0_ACTIVE) {}
-
-    EPSON_DEBUG_COPY (fprintf(stderr,"-epsonCopy\n"));
-}
-
-
-/*
- * epsonDoneCopy
- *
- * Description:    Done Copy
- *
- * History:
- * 11-Feb-04  C.Stylianou       NBL: Created.
- *
- */
-
-static void
-epsonDoneCopy (void)
-{
-    EPSON_DEBUG_COPY (fprintf(stderr,"+epsonDoneCopy\n"));
-    
-    // Read from BitBLT data offset 0 to shut it down
-    //(void)EPSON13806_REG(EPSON13806_BITBLTDATA);
-
-    EPSON_DEBUG_COPY (fprintf(stderr,"-epsonDoneCopy\n"));
-}
-
-
-/*
- * epsonDrawInit
- *
- * Description:    Configure the Epson S1D13806 for a 800x600 TFT colour display
- *
- * History:
- * 11-Feb-04  C.Stylianou       NBL: Created.
- *
- */
-
-Bool
-epsonDrawInit (ScreenPtr pScreen)
-{
-    KdScreenPriv(pScreen);
-    KdScreenInfo *screen = pScreenPriv->screen;
-    EpsonScrPriv *epsons = screen->driver;
-
-   EPSON_DEBUG (fprintf(stderr,"+epsonDrawInit\n"));
-   
-   epsonSet(pScreen);
-
-#if 0
-    EPSON13806_REG(EPSON13806_MISC) = 0x00;
-    EPSON13806_REG(EPSON13806_DISPMODE) = 0x00;
-    EPSON13806_REG16(EPSON13806_GPIOCFG) = 0xffff;
-    EPSON13806_REG16(EPSON13806_GPIOCTRL) = 0x0001;
-    
-    EPSON13806_REG(EPSON13806_MEMCLKCFG) = 0x01;
-    EPSON13806_REG(EPSON13806_LCDPCLKCFG) = 0x00;
-    EPSON13806_REG(EPSON13806_CRTPCLKCFG) = 0x02;
-    EPSON13806_REG(EPSON13806_MPCLKCFG) = 0x02;
-    EPSON13806_REG(EPSON13806_CPUMEMWAITSEL) = 0x01;
-    EPSON13806_REG(EPSON13806_MEMCFG) = 0x80;
-    EPSON13806_REG(EPSON13806_DRAMREFRESH) = 0x03;
-    EPSON13806_REG16(EPSON13806_DRAMTIMINGCTRL) = 0x0100;
-    
-    // 5ms delay for internal LCD SDRAM to initialize
-     usleep(5000);
-    
-    EPSON13806_REG(EPSON13806_PANELTYPE) = 0x25;
-    EPSON13806_REG(EPSON13806_MODRATE) = 0x00;
-    EPSON13806_REG(EPSON13806_LCDHDP) = 0x63;
-    EPSON13806_REG(EPSON13806_LCDHNDP) = 0x1f;
-    EPSON13806_REG(EPSON13806_TFTFPLINESTART) = 0x01;
-    EPSON13806_REG(EPSON13806_TFTFPLINEPULSE) = 0x0b;
-    EPSON13806_REG16(EPSON13806_LCDVDP0) = 0x0257;
-    EPSON13806_REG(EPSON13806_LCDVNDP) = 0x1b;
-    EPSON13806_REG(EPSON13806_TFTFPFRAMESTART) = 0x0a;
-    EPSON13806_REG(EPSON13806_TFTFPFRAMEPULSE) = 0x01;
-    EPSON13806_REG(EPSON13806_LCDDISPMODE) = 0x85;
-    EPSON13806_REG(EPSON13806_LCDMISC) = 0x00;
-    EPSON13806_REG16(EPSON13806_LCDSTART01) = 0x0000;
-    EPSON13806_REG(EPSON13806_LCDSTART2) = 0x00;
-    EPSON13806_REG16(EPSON13806_LCDSTRIDE) = byteStride>>1;
-    EPSON13806_REG(EPSON13806_LCDPIXELPAN) = 0x00;
-    EPSON13806_REG(EPSON13806_LCDFIFOHIGH) = 0x00;
-    EPSON13806_REG(EPSON13806_LCDFIFOLOW) = 0x00;
-#endif
-
-
-    EPSON13806_REG(EPSON13806_BLTCTRL0) = 0x00;
-    EPSON13806_REG(EPSON13806_BLTCTRL1) = 0x01;     // We're using 16 bpp
-    EPSON13806_REG16(EPSON13806_BLTSTRIDE) = byteStride>>1; // program BLIT memory offset
-    
-#if 0
-    EPSON13806_REG(EPSON13806_LUTMODE) = 0x00;
-    EPSON13806_REG(EPSON13806_LUTADDR) = 0x00;
-    EPSON13806_REG(EPSON13806_PWRSAVECFG) = 0x10;
-    EPSON13806_REG(EPSON13806_PWRSAVESTATUS) = 0x00;
-    EPSON13806_REG(EPSON13806_CPUMEMWATCHDOG) = 0x00;
-    EPSON13806_REG(EPSON13806_DISPMODE) = 0x01;
-    
-    // Enable backlight voltage
-    EPSON13806_REG16(EPSON13806_GPIOCTRL) |= 1<<1;
-    // 10ms delay after turning on LCD.
-    usleep(10000);
-#endif
-
-    // Instruct the BitBLT unit to fill the screen with black, i.e clear fb.
-    static int addr = 0x00000000;
-    EPSON13806_REG16(EPSON13806_BLTDSTSTART01) = addr;
-    EPSON13806_REG(EPSON13806_BLTDSTSTART2) = addr >> 16;
-    EPSON13806_REG16(EPSON13806_BLTFGCOLOR) = 0x0000;
-    EPSON13806_REG(EPSON13806_BLTOPERATION) = EPSON13806_BLTOPERATION_SOLIDFILL; // solid fill blt
-    EPSON13806_REG16(EPSON13806_BLTWIDTH) = (0x0320-1);
-    EPSON13806_REG16(EPSON13806_BLTHEIGHT) = (0x0258-1);
-    EPSON13806_REG(EPSON13806_BLTCTRL0) = EPSON13806_BLTCTRL0_ACTIVE;
-
-#if 0
-    // Enable LCD data
-    EPSON13806_REG(EPSON13806_LCDDISPMODE) &= ~(1<<7);
-    
-    // Turn on backlight full
-    EPSON13806_REG16(EPSON13806_GPIOCTRL) |= 0x00fc;
-#endif
-    
-    memset(&epsons->kaa, 0, sizeof(KaaScreenInfoRec));
-    epsons->kaa.waitMarker	= epsonWaitMarker;
-    epsons->kaa.PrepareSolid	= epsonPrepareSolid;
-    epsons->kaa.Solid		= epsonSolid;
-    epsons->kaa.DoneSolid	= epsonDoneSolid;
-    epsons->kaa.PrepareCopy	= epsonPrepareCopy;
-    epsons->kaa.Copy		= epsonCopy;
-    epsons->kaa.DoneCopy	= epsonDoneCopy;
-    epsons->kaa.flags		= KAA_OFFSCREEN_PIXMAPS;
-
-    if (!kaaDrawInit (pScreen, &epsons->kaa))
-        return FALSE;
-    
-    EPSON_DEBUG (fprintf(stderr,"-epsonDrawInit\n"));
-    return TRUE;
-}
-
-
-/*
- * epsonDrawEnable
- *
- * Description:    Enables hardware acceleration
- *
- * History:
- * 11-Feb-04  C.Stylianou       NBL: Created.
- *
- */
-
-void
-epsonDrawEnable (ScreenPtr pScreen)
-{
-    EPSON_DEBUG (fprintf(stderr,"+epsonDrawEnable\n"));
-    epsonWaitForHwBltDone ();
-    kaaMarkSync (pScreen);
-    EPSON_DEBUG (fprintf(stderr,"-epsonDrawEnable\n"));
-}
-
-
-/*
- * epsonDrawDisable
- *
- * Description:    Disables hardware acceleration
- *
- * History:
- * 11-Feb-04  C.Stylianou       NBL: Created.
- *
- */
-
-void
-epsonDrawDisable (ScreenPtr pScreen)
-{
-    EPSON_DEBUG (fprintf(stderr,"+epsonDrawDisable\n"));
-}
-
-
-/*
- * epsonDrawFini
- *
- * Description:    Finish hardware acceleration
- *
- * History:
- * 11-Feb-04  C.Stylianou       NBL: Created.
- *
- */
-
-void
-epsonDrawFini (ScreenPtr pScreen)
-{
-    EPSON_DEBUG (fprintf(stderr,"+epsonDrawFini\n"));
-}
-
-
-/*
- * initEpson13806
- *
- * Description:    Maps Epson S1D13806 registers
- *
- * History:
- * 11-Feb-04  C.Stylianou       NBL: Created.
- *
- */
-
-void
-initEpson13806(void)
-{
-    EPSON_DEBUG (fprintf(stderr,"+initEpson\n"));
-    
-    // Map Epson S1D13806 registers
-    regbase = KdMapDevice (EPSON13806_PHYSICAL_REG_ADDR, EPSON13806_GPIO_REGSIZE);
-    if (!regbase)
-        perror("ERROR: regbase\n");   // Sets up register mappings in header files.
-
-#if 0
-    CARD8 rev_code;
-    rev_code = EPSON13806_REG (EPSON13806_REVCODE);
-    if ((rev_code >> 2) != 0x07) 
-        perror("ERROR: EPSON13806 Display Controller NOT FOUND!\n");
-#endif
-    
-    EPSON_DEBUG (fprintf(stderr,"-initEpson\n"));
-}
diff --git a/hw/kdrive/epson/epson13806draw.h b/hw/kdrive/epson/epson13806draw.h
deleted file mode 100644
index b5f1bf5..0000000
--- a/hw/kdrive/epson/epson13806draw.h
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Copyright 2004 by Costas Stylianou <costas.stylianou at psion.com> +44(0)7850 394095
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Costas Sylianou not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. Costas Stylianou makes no representations
- * about the suitability of this software for any purpose.  It is provided
- * "as is" without express or implied warranty.
- *
- * COSTAS STYLIANOU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL COSTAS STYLIANOU BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-/* 
- * epson13806draw.h - Implementation of hard ware accelerated functions for epson S1D13806
- *               Graphic controller.
- *
- * History:
- * 28-Jan-04  C.Stylianou       PRJ NBL: Created from chipsdraw.h
- *
- */
-
-#ifndef _EPSON13806DRAW_H_
-#define _EPSON13806DRAW_H_
-
-
-/*
- * offset from ioport beginning 
- */
-
-
-#define SetupEpson(s)  KdScreenPriv(s); \
-		    epsonCardInfo(pScreenPriv); \
-		    EpsonPtr epson = epsonc->epson
-
-
-typedef volatile CARD8	VOL8;
-typedef volatile CARD16	VOL16;
-typedef volatile CARD32	VOL32;
-
-typedef struct _epsonSave {
-    int	    dummy;
-} EpsonSave;
-
-typedef struct _epsonCardInfo {
-    EpsonPriv    epson;
-    CARD32		*window;
-    Bool		mmio;
-    EpsonSave		save;
-} epsonCardInfo;
-    
-#define getEpsonCardInfo(kd)  ((epsonCardInfo *) ((kd)->card->driver))
-#define epsonCardInfo(kd)	    epsonCardInfo	*epsonc = getEpsonCardInfo(kd)
-
-typedef struct _epsonCursor {
-    int		width, height;
-    int		xhot, yhot;
-    Bool	has_cursor;
-    CursorPtr	pCursor;
-    Pixel	source, mask;
-} EpsonCursor;
-
-#define epson_CURSOR_WIDTH	64
-#define epson_CURSOR_HEIGHT	64
-
-typedef struct _epsonScreenInfo {
-    EpsonScrPriv    epson;
-    CARD8	    *cursor_base;
-    CARD8	    *screen;
-    CARD8	    *off_screen;
-    int		    off_screen_size;
-    EpsonCursor   cursor;
-    void       *regbase_virt;
-} EpsonScreenInfo;
-
-#define getEpsonScreenInfo(kd) ((EpsonScreenInfo *) ((kd)->screen->driver))
-#define epsonScreenInfo(kd)    EpsonScreenInfo *epsons = getEpsonScreenInfo(kd)
-
-Bool
-epsonDrawInit (ScreenPtr pScreen);
-
-void
-epsonDrawEnable (ScreenPtr pScreen);
-
-void
-epsonDrawSync (ScreenPtr pScreen);
-
-void
-epsonDrawDisable (ScreenPtr pScreen);
-
-void
-epsonDrawFini (ScreenPtr pScreen);
-
-Bool
-epsonCursorInit (ScreenPtr pScreen);
-
-void
-epsonCursorEnable (ScreenPtr pScreen);
-
-void
-epsonCursorDisable (ScreenPtr pScreen);
-
-void
-epsonCursorFini (ScreenPtr pScreen);
-
-void
-epsonRecolorCursor (ScreenPtr pScreen, int ndef, xColorItem *pdef);
-
-extern KdCardFuncs  epsonFuncs;
-
-#endif
diff --git a/hw/kdrive/epson/epson13806reg.h b/hw/kdrive/epson/epson13806reg.h
deleted file mode 100644
index ee745a0..0000000
--- a/hw/kdrive/epson/epson13806reg.h
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- * Copyright 2004 by Costas Stylianou <costas.stylianou at psion.com> +44(0)7850 394095
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Costas Sylianou not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. Costas Stylianou makes no representations
- * about the suitability of this software for any purpose.  It is provided
- * "as is" without express or implied warranty.
- *
- * COSTAS STYLIANOU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL COSTAS STYLIANOU BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-/* 
- * epson13806reg.h         Epson S1D13806 LCD controller header file.
- *
- * History:
- * 15-Feb-04  C.Stylianou       PRJ NBL: Created.
- *
- */
- 
-
-#ifndef EPSON13806REG_H
-#define EPSON13806REG_H
-
-
-#define TT_UNUSED(x) ((void) (x))
-
-
-#define EPSON13806_PHYSICAL_REG_ADDR   0x14000000
-#define EPSON13806_GPIO_REGSIZE        0x001f0000
-
-#define EPSON13806_PHYSICAL_VMEM_ADDR  0x14200000
-#define EPSON13806_VMEM_SIZE           0x140000
-
-#define PLATFORM_EPSON13806_BASE    (regbase)
-#define EPSON13806_REG_BASE         (PLATFORM_EPSON13806_BASE + 0x000000)   // Register base address
-#define EPSON13806_SDRAM_BASE       (PLATFORM_EPSON13806_BASE + 0x200000)   // SDRAM base address
-
-//////////////////////////////////////////////////////////////////////////////////////////
-// Register Offsets
-//////////////////////////////////////////////////////////////////////////////////////////
-#define EPSON13806_REVCODE              (EPSON13806_REG_BASE + 0x0000)  // Revision Code Register
-#define EPSON13806_MISC                 (EPSON13806_REG_BASE + 0x0001)  // Miscellaneous Register
-#define EPSON13806_GPIOCFG              (EPSON13806_REG_BASE + 0x0004)  // General IO Pins Configuration Register (16 bits)
-#define EPSON13806_GPIOCFG0             (EPSON13806_REG_BASE + 0x0004)  // General IO Pins Configuration Register 0
-#define EPSON13806_GPIOCFG1             (EPSON13806_REG_BASE + 0x0005)  // General IO Pins Configuration Register 1
-#define EPSON13806_GPIOCTRL             (EPSON13806_REG_BASE + 0x0008)  // General IO Pins Control Register (16 bits)
-#define EPSON13806_GPIOCTRL0            (EPSON13806_REG_BASE + 0x0008)  // General IO Pins Control Register 0
-#define EPSON13806_GPIOCTRL1            (EPSON13806_REG_BASE + 0x0009)  // General IO Pins Control Register 1
-#define EPSON13806_MDCFGSTATUS          (EPSON13806_REG_BASE + 0x000C)  // Configuration Status Register
-#define EPSON13806_MEMCLKCFG            (EPSON13806_REG_BASE + 0x0010)  // Memory Clock Configuration Register
-#define EPSON13806_LCDPCLKCFG           (EPSON13806_REG_BASE + 0x0014)  // LCD Pixel Clock Configuration Register
-#define EPSON13806_CRTPCLKCFG           (EPSON13806_REG_BASE + 0x0018)  // CRT/TV Clock Configuration Register
-#define EPSON13806_MPCLKCFG             (EPSON13806_REG_BASE + 0x001C)  // MediaPlug Clock Configuration Register
-#define EPSON13806_CPUMEMWAITSEL        (EPSON13806_REG_BASE + 0x001E)  // CPU To Memory Wait State Select Register
-#define EPSON13806_MEMCFG               (EPSON13806_REG_BASE + 0x0020)  // Memory Configuration Register
-#define EPSON13806_DRAMREFRESH          (EPSON13806_REG_BASE + 0x0021)  // DRAM Refresh Rate Register
-#define EPSON13806_DRAMTIMINGCTRL       (EPSON13806_REG_BASE + 0x002A)  // DRAM Timings Control Register (16 bits)
-#define EPSON13806_DRAMTIMINGCTRL0      (EPSON13806_REG_BASE + 0x002A)  // DRAM Timings Control Register 0
-#define EPSON13806_DRAMTIMINGCTRL1      (EPSON13806_REG_BASE + 0x002B)  // DRAM Timings Control Register 1
-#define EPSON13806_PANELTYPE            (EPSON13806_REG_BASE + 0x0030)  // Panel Type Register
-#define EPSON13806_MODRATE              (EPSON13806_REG_BASE + 0x0031)  // MOD Rate Register
-#define EPSON13806_LCDHDP               (EPSON13806_REG_BASE + 0x0032)  // LCD Horizontal Display Width Register
-#define EPSON13806_LCDHNDP              (EPSON13806_REG_BASE + 0x0034)  // LCD Horizontal Non-Display Period Register
-#define EPSON13806_TFTFPLINESTART       (EPSON13806_REG_BASE + 0x0035)  // TFT FPLINE Start Position Register
-#define EPSON13806_TFTFPLINEPULSE       (EPSON13806_REG_BASE + 0x0036)  // TFT FPLINE Pulse Width Register
-#define EPSON13806_LCDVDP               (EPSON13806_REG_BASE + 0x0038)  // LCD Vertical Display Height Register (16 bits)
-#define EPSON13806_LCDVDP0              (EPSON13806_REG_BASE + 0x0038)  // LCD Vertical Display Height Register 0
-#define EPSON13806_LCDVDP1              (EPSON13806_REG_BASE + 0x0039)  // LCD Vertical Display Height Register 1
-#define EPSON13806_LCDVNDP              (EPSON13806_REG_BASE + 0x003A)  // LCD Vertical Non-Display Period Register
-#define EPSON13806_TFTFPFRAMESTART      (EPSON13806_REG_BASE + 0x003B)  // TFT FPFRAME Start Position Register
-#define EPSON13806_TFTFPFRAMEPULSE      (EPSON13806_REG_BASE + 0x003C)  // TFT FPFRAME Pulse Width Register
-#define EPSON13806_LCDLINECOUNT         (EPSON13806_REG_BASE + 0x003E)  // LCD Line Count Register (16 bits)
-#define EPSON13806_LCDLINECOUNT0        (EPSON13806_REG_BASE + 0x003E)  // LCD Line Count Register 0
-#define EPSON13806_LCDLINECOUNT1        (EPSON13806_REG_BASE + 0x003F)  // LCD Line Count Register 1
-#define EPSON13806_LCDDISPMODE          (EPSON13806_REG_BASE + 0x0040)  // LCD Display Mode Register
-#define EPSON13806_LCDMISC              (EPSON13806_REG_BASE + 0x0041)  // LCD Miscellaneous Register
-#define EPSON13806_LCDSTART01           (EPSON13806_REG_BASE + 0x0042)  // LCD Display Start Address Register 0 and 1 (16 bits)
-#define EPSON13806_LCDSTART0            (EPSON13806_REG_BASE + 0x0042)  // LCD Display Start Address Register 0
-#define EPSON13806_LCDSTART1            (EPSON13806_REG_BASE + 0x0043)  // LCD Display Start Address Register 1
-#define EPSON13806_LCDSTART2            (EPSON13806_REG_BASE + 0x0044)  // LCD Display Start Address Register 2
-#define EPSON13806_LCDSTRIDE            (EPSON13806_REG_BASE + 0x0046)  // LCD Memory Address Offset Register (16 bits)
-#define EPSON13806_LCDSTRIDE0           (EPSON13806_REG_BASE + 0x0046)  // LCD Memory Address Offset Register 0
-#define EPSON13806_LCDSTRIDE1           (EPSON13806_REG_BASE + 0x0047)  // LCD Memory Address Offset Register 1
-#define EPSON13806_LCDPIXELPAN          (EPSON13806_REG_BASE + 0x0048)  // LCD Pixel Panning Register
-#define EPSON13806_LCDFIFOHIGH          (EPSON13806_REG_BASE + 0x004A)  // LCD Display FIFO High Threshold Control Register
-#define EPSON13806_LCDFIFOLOW           (EPSON13806_REG_BASE + 0x004B)  // LCD Display FIFO Low Threshold Control Register
-
-#define EPSON13806_LCDINKCURSCTRL       (EPSON13806_REG_BASE + 0x0070)  // LCD INK/Cursor Control Register
-#define EPSON13806_LCDINKCURSSTART      (EPSON13806_REG_BASE + 0x0071)  // LCD INK/Cursor Start Address Register
-#define EPSON13806_LCDCURSORXPOS        (EPSON13806_REG_BASE + 0x0072)  // LCD Cursor X Position Register (16 bits)
-#define EPSON13806_LCDCURSORXPOS0       (EPSON13806_REG_BASE + 0x0072)  // LCD Cursor X Position Register 0
-#define EPSON13806_LCDCURSORXPOS1       (EPSON13806_REG_BASE + 0x0073)  // LCD Cursor X Position Register 1
-#define EPSON13806_LCDCURSORYPOS        (EPSON13806_REG_BASE + 0x0074)  // LCD Cursor Y Position Register (16 bits)
-#define EPSON13806_LCDCURSORYPOS0       (EPSON13806_REG_BASE + 0x0074)  // LCD Cursor Y Position Register 0
-#define EPSON13806_LCDCURSORYPOS1       (EPSON13806_REG_BASE + 0x0075)  // LCD Cursor Y Position Register 1
-#define EPSON13806_LCDINKCURSBLUE0      (EPSON13806_REG_BASE + 0x0076)  // LCD INK/Cursor Blue Color 0 Register
-#define EPSON13806_LCDINKCURSGREEN0     (EPSON13806_REG_BASE + 0x0077)  // LCD INK/Cursor Green Color 0 Register
-#define EPSON13806_LCDINKCURSRED0       (EPSON13806_REG_BASE + 0x0078)  // LCD INK/Cursor Red Color 0 Register
-#define EPSON13806_LCDINKCURSBLUE1      (EPSON13806_REG_BASE + 0x007A)  // LCD INK/Cursor Blue Color 1 Register
-#define EPSON13806_LCDINKCURSGREEN1     (EPSON13806_REG_BASE + 0x007B)  // LCD INK/Cursor Green Colour 1 Register
-#define EPSON13806_LCDINKCURSRED1       (EPSON13806_REG_BASE + 0x007C)  // LCD INK/Cursor Red Color 1 Register
-#define EPSON13806_LCDINKCURSFIFO       (EPSON13806_REG_BASE + 0x007E)  // LCD INK/Cursor FIFO Threshold Register
-
-#define EPSON13806_BLTCTRL0             (EPSON13806_REG_BASE + 0x0100)  // BitBlt Control Register 0
-#define EPSON13806_BLTCTRL1             (EPSON13806_REG_BASE + 0x0101)  // BitBlt Control Register 1
-#define EPSON13806_BLTROP               (EPSON13806_REG_BASE + 0x0102)  // BitBlt ROP Code/Color Expansion Register
-#define EPSON13806_BLTOPERATION         (EPSON13806_REG_BASE + 0x0103)  // BitBlt Operation Register
-#define EPSON13806_BLTSRCSTART01        (EPSON13806_REG_BASE + 0x0104)  // BitBlt Source Start Address Register 0 and 1 (16 bits)
-#define EPSON13806_BLTSRCSTART0         (EPSON13806_REG_BASE + 0x0104)  // BitBlt Source Start Address Register 0
-#define EPSON13806_BLTSRCSTART1         (EPSON13806_REG_BASE + 0x0105)  // BitBlt Source Start Address Register 1
-#define EPSON13806_BLTSRCSTART2         (EPSON13806_REG_BASE + 0x0106)  // BitBlt Source Start Address Register 2
-#define EPSON13806_BLTDSTSTART01        (EPSON13806_REG_BASE + 0x0108)  // BitBlt Destination Start Address Register 0 and 1 (16 bits)
-#define EPSON13806_BLTDSTSTART0         (EPSON13806_REG_BASE + 0x0108)  // BitBlt Destination Start Address Register 0
-#define EPSON13806_BLTDSTSTART1         (EPSON13806_REG_BASE + 0x0109)  // BitBlt Destination Start Address Register 1
-#define EPSON13806_BLTDSTSTART2         (EPSON13806_REG_BASE + 0x010A)  // BitBlt Destination Start Address Register 2
-#define EPSON13806_BLTSTRIDE            (EPSON13806_REG_BASE + 0x010C)  // BitBlt Memory Address Offset Register (16 bits)
-#define EPSON13806_BLTSTRIDE0           (EPSON13806_REG_BASE + 0x010C)  // BitBlt Memory Address Offset Register 0
-#define EPSON13806_BLTSTRIDE1           (EPSON13806_REG_BASE + 0x010D)  // BitBlt Memory Address Offset Register 1
-#define EPSON13806_BLTWIDTH             (EPSON13806_REG_BASE + 0x0110)  // BitBlt Width Register (16 bits)
-#define EPSON13806_BLTWIDTH0            (EPSON13806_REG_BASE + 0x0110)  // BitBlt Width Register 0
-#define EPSON13806_BLTWIDTH1            (EPSON13806_REG_BASE + 0x0111)  // BitBlt Width Register 1
-#define EPSON13806_BLTHEIGHT            (EPSON13806_REG_BASE + 0x0112)  // BitBlt Height Register (16 bits)
-#define EPSON13806_BLTHEIGHT0           (EPSON13806_REG_BASE + 0x0112)  // BitBlt Height Register 0
-#define EPSON13806_BLTHEIGHT1           (EPSON13806_REG_BASE + 0x0113)  // BitBlt Height Register 1
-#define EPSON13806_BLTBGCOLOR           (EPSON13806_REG_BASE + 0x0114)  // BitBlt Background Color Register (16 bits)
-#define EPSON13806_BLTBGCOLOR0          (EPSON13806_REG_BASE + 0x0114)  // BitBlt Background Color Register 0
-#define EPSON13806_BLTBGCOLOR1          (EPSON13806_REG_BASE + 0x0115)  // BitBlt Background Color Register 1
-#define EPSON13806_BLTFGCOLOR           (EPSON13806_REG_BASE + 0x0118)  // BitBlt Foreground Color Register (16 bits)
-#define EPSON13806_BLTFGCOLOR0          (EPSON13806_REG_BASE + 0x0118)  // BitBlt Foreground Color Register 0
-#define EPSON13806_BLTFGCOLOR1          (EPSON13806_REG_BASE + 0x0119)  // BitBlt Foreground Color Register 0
-
-#define EPSON13806_LUTMODE              (EPSON13806_REG_BASE + 0x01E0)  // Look-Up Table Mode Register
-#define EPSON13806_LUTADDR              (EPSON13806_REG_BASE + 0x01E2)  // Look-Up Table Address Register
-#define EPSON13806_LUTDATA              (EPSON13806_REG_BASE + 0x01E4)  // Look-Up Table Data Register
-#define EPSON13806_PWRSAVECFG           (EPSON13806_REG_BASE + 0x01F0)  // Power Save Configuration Register
-#define EPSON13806_PWRSAVESTATUS        (EPSON13806_REG_BASE + 0x01F1)  // Power Save Status Register
-#define EPSON13806_CPUMEMWATCHDOG       (EPSON13806_REG_BASE + 0x01F4)  // CPU-to-Memory Access Watchdog Timer Register
-#define EPSON13806_DISPMODE             (EPSON13806_REG_BASE + 0x01FC)  // Display Mode Register
-
-#define EPSON13806_MEDIALCMD            (EPSON13806_REG_BASE + 0x1000)  // MediaPlug LCMD Register
-#define EPSON13806_MEDIARESERVEDLCMD    (EPSON13806_REG_BASE + 0x1002)  // MediaPlug Reserved LCMD Register
-#define EPSON13806_MEDIACMD             (EPSON13806_REG_BASE + 0x1004)  // MediaPlug CMD Register
-#define EPSON13806_MEDIARESERVEDCMD     (EPSON13806_REG_BASE + 0x1006)  // MediaPlug Reserved CMD Register
-#define EPSON13806_MEDIADATA            (EPSON13806_REG_BASE + 0x1008)  // MediaPlug Data Registers (base)
-
-#define EPSON13806_BITBLTDATA           (EPSON13806_REG_BASE + 0x100000)    // BitBLT Data Registers (base)
-
-// BLTCTRL0 register defines
-#define EPSON13806_BLTCTRL0_ACTIVE      (1<<7)  // Read: 1=busy, 0=idle / Write: 1=start, 0=no change
-
-// BLTOPERATION register defines
-#define EPSON13806_BLTOPERATION_WRITEROP            (0x00)  // Write BitBLT with ROP
-#define EPSON13806_BLTOPERATION_READ                (0x01)  // Read BitBLT
-#define EPSON13806_BLTOPERATION_MOVEPOSROP          (0x02)  // Move BitBLT in positive direction with ROP
-#define EPSON13806_BLTOPERATION_MOVENEGROP          (0x03)  // Move BitBLT in negative direction with ROP
-#define EPSON13806_BLTOPERATION_TRANSWRITE          (0x04)  // Transparent Write BitBLT
-#define EPSON13806_BLTOPERATION_TRANSMOVEPOS        (0x05)  // Transparent Move BitBLT in positive direction
-#define EPSON13806_BLTOPERATION_PATFILLROP          (0x06)  // Pattern fill with ROP
-#define EPSON13806_BLTOPERATION_PATFILLTRANS        (0x07)  // Pattern fill with transparency
-#define EPSON13806_BLTOPERATION_COLOREXP            (0x08)  // Color expansion
-#define EPSON13806_BLTOPERATION_COLOREXPTRANS       (0x09)  // Color expansion with transparency
-#define EPSON13806_BLTOPERATION_MOVECOLOREXP        (0x0A)  // Move BitBLT with color expansion
-#define EPSON13806_BLTOPERATION_MOVECOLOREXPTRANS   (0x0B)  // Move BitBLT with color expansion and transparency
-#define EPSON13806_BLTOPERATION_SOLIDFILL           (0x0C)  // Solid fill
-
-//////////////////////////////////////////////////////////////////////////////////////////
-// Epson register access macros
-//////////////////////////////////////////////////////////////////////////////////////////
-#define EPSON13806_REG(address)   *(VOL8 *)(address)
-#define EPSON13806_REG16(address) *(VOL16 *)(address)
-
-
-#endif  // EPSON13806
diff --git a/hw/kdrive/epson/epson13806stub.c b/hw/kdrive/epson/epson13806stub.c
deleted file mode 100644
index 087a30f..0000000
--- a/hw/kdrive/epson/epson13806stub.c
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright 2004 by Costas Stylianou <costas.stylianou at psion.com> +44(0)7850 394095
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Costas Sylianou not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. Costas Stylianou makes no representations
- * about the suitability of this software for any purpose.  It is provided
- * "as is" without express or implied warranty.
- *
- * COSTAS STYLIANOU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL COSTAS STYLIANOU BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-/*
- * epson13806stub.c 
- *
- * History:
- * 28-Jan-04  C.Stylianou       PRJ NBL: Created from fbdevinit.c
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <kdrive-config.h>
-#endif
-
-#include <epson13806.h>
-
-void
-InitCard (char *name)
-{
-    KdCardAttr	attr;
-
-    fprintf(stderr, "Epson 13806 Tiny X Driver ver 1.01\n");
-
-    KdCardInfoAdd (&epsonFuncs, &attr, 0);
-}
-
-void
-InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv)
-{
-    KdInitOutput (pScreenInfo, argc, argv);
-}
-
-void
-InitInput (int argc, char **argv)
-{
-    KdOsAddInputDrivers ();
-    KdInitInput ();
-}
-
-int
-ddxProcessArgument (int argc, char **argv, int i)
-{
-    return KdProcessArgument (argc, argv, i);
-}
-
-void
-ddxUseMsg (void)
-{
-    KdUseMsg();
-}
diff --git a/hw/kdrive/i810/Makefile.am b/hw/kdrive/i810/Makefile.am
deleted file mode 100644
index 30919fa..0000000
--- a/hw/kdrive/i810/Makefile.am
+++ /dev/null
@@ -1,39 +0,0 @@
-INCLUDES = 					\
-	@KDRIVE_INCS@				\
-	@KDRIVE_CFLAGS@
-
-bin_PROGRAMS = Xi810
-
-noinst_LIBRARIES = libi810.a
-
-
-libi810_a_SOURCES = 		\
-	i810_cursor.c	\
-	i810_video.c	\
-	i810draw.c	\
-	i810draw.h	\
-	i810_reg.h	\
-	i810.c		\
-	i810.h
-
-Xi810_SOURCES = \
-	i810stub.c
-
-I810_LIBS =						\
-	libi810.a 					\
-	@KDRIVE_LIBS@
-
-if GLX
-Xi810_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
-endif
-
-Xi810_LDADD = \
-	$(I810_LIBS)					\
-	@KDRIVE_LIBS@
-
-Xi810_DEPENDENCIES =	\
-	libi810.a 					\
-	@KDRIVE_LOCAL_LIBS@
-
-relink:
-	rm -f $(bin_PROGRAMS) && make $(bin_PROGRAMS)
diff --git a/hw/kdrive/i810/i810.c b/hw/kdrive/i810/i810.c
deleted file mode 100644
index 49090f9..0000000
--- a/hw/kdrive/i810/i810.c
+++ /dev/null
@@ -1,2112 +0,0 @@
-/* COPYRIGHT AND PERMISSION NOTICE
-
-Copyright (c) 2000, 2001 Nokia Home Communications
-
-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, and/or sell copies of the Software, and to permit persons
-to whom the Software is furnished to do so, provided that the above
-copyright notice(s) and this permission notice appear in all copies of
-the Software and that both the above copyright notice(s) and this
-permission notice appear in supporting documentation.
-
-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
-OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
-HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
-SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
-RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
-CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
-CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
-Except as contained in this notice, the name of a copyright holder
-shall not be used in advertising or otherwise to promote the sale, use
-or other dealings in this Software without prior written authorization
-of the copyright holder.
-
-X Window System is a trademark of The Open Group */
-
-/*
- * i810.c - KDrive driver for the i810 chipset
- *
- * Authors:
- *   Pontus Lidman  <pontus.lidman at nokia.com>
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <kdrive-config.h>
-#endif
-#include "kdrive.h"
-#include "kxv.h"
-#include "klinux.h"
-
-#include "i810.h"
-#include "agp.h"
-
-#include "i810draw.h"
-
-#ifndef I810_DEBUG
-int I810_DEBUG = (0
-/*      		  | DEBUG_ALWAYS_SYNC   */
-/*     		  | DEBUG_VERBOSE_ACCEL   */
-/*   		  | DEBUG_VERBOSE_SYNC  */
-/*  		  | DEBUG_VERBOSE_VGA */
-/*   		  | DEBUG_VERBOSE_RING     */
-/*  		  | DEBUG_VERBOSE_OUTREG  */
-/*  		  | DEBUG_VERBOSE_MEMORY */
-/*  		  | DEBUG_VERBOSE_CURSOR  */
-   );
-#endif
-
-
-static Bool
-i810ModeInit(KdScreenInfo *screen, const KdMonitorTiming *t);
-
-static void 
-i810PrintMode( vgaRegPtr vgaReg, I810RegPtr mode );
-
-Bool
-i810CardInit (KdCardInfo *card)
-{
-    int i;
-
-    I810CardInfo	*i810c;
-
-/*     fprintf(stderr,"i810CardInit\n"); */
-
-    i810c = (I810CardInfo *) xalloc (sizeof (I810CardInfo));
-
-    if (!i810c)
-	return FALSE;
-
-    /* 2MB Video RAM */
-    i810c->videoRam=2048;
-
-    /* Find FB address */
-
-    if (card->attr.address[1] != 0) {
-        i810c->LinearAddr = card->attr.address[0] & 0xFF000000;
-
-        if (!i810c->LinearAddr) {
-            fprintf(stderr,"No valid FB address in PCI config space(1)\n");
-            xfree(i810c);
-            return FALSE;
-        } else {
-/*             fprintf(stderr,"Linear framebuffer at %lx\n",i810c->LinearAddr); */
-        }
-    } else {
-        fprintf(stderr,"No valid FB address in PCI config space(2)\n");
-        xfree(i810c);
-        return FALSE;
-    }
-
-    if (card->attr.address[1]) {
-
-        i810c->MMIOAddr = card->attr.address[1] & 0xFFF80000;
-
-        i810c->MMIOBase = 
-            KdMapDevice (i810c->MMIOAddr, I810_REG_SIZE);
-        if (!i810c->MMIOBase) {
-            fprintf(stderr,"No valid MMIO address in PCI config space(1)\n");
-            xfree(i810c);
-            return FALSE;
-        } else {
-            
-        }
-    } else {
-        fprintf(stderr,"No valid MMIO address in PCI config space(2)\n");
-        xfree(i810c);
-        return FALSE;
-    }
-
-/*     fprintf(stderr,"Mapped 0x%x bytes of MMIO regs at phys 0x%lx virt %p\n", */
-/*             I810_REG_SIZE,i810c->MMIOAddr,i810c->MMIOBase); */
-
-   /* Find out memory bus frequency.
-    */
-
-    {
-        unsigned long *p;
-
-        if (!(p= (unsigned long *) LinuxGetPciCfg(&card->attr)))
-            return FALSE;
-        
-/*         fprintf(stderr,"Frequency long %lx\n",p[WHTCFG_PAMR_DRP]); */
-
-        if ( (p[WHTCFG_PAMR_DRP] & LM_FREQ_MASK) == LM_FREQ_133 )
-            i810c->LmFreqSel = 133;
-        else
-            i810c->LmFreqSel = 100;
-
-        xfree(p);
-
-/*         fprintf(stderr,"Selected frequency %d\n",i810c->LmFreqSel); */
-    }
-
-/*     fprintf(stderr,"Will alloc AGP framebuffer: %d kByte\n",i810c->videoRam); */
-
-    /* Since we always want write combining on first 32 mb of framebuffer
-     * we pass a mapsize of 32 mb */
-    i810c->FbMapSize = 32*1024*1024;
-
-    for (i = 2 ; i < i810c->FbMapSize ; i <<= 1);
-    i810c->FbMapSize = i;
-
-    i810c->FbBase = 
-        KdMapDevice (i810c->LinearAddr, i810c->FbMapSize);
-    
-    if (!i810c->FbBase) return FALSE; 
-/*     fprintf(stderr,"Mapped 0x%lx bytes of framebuffer at %p\n", */
-/*             i810c->FbMapSize,i810c->FbBase); */
-    
-    card->driver=i810c;
-    
-    return TRUE;
-}
-
-static void
-i810ScreenFini (KdScreenInfo *screen)
-{
-    I810ScreenInfo    *i810s = (I810ScreenInfo *) screen->driver;
-    
-    xfree (i810s);
-    screen->driver = 0;    
-}
-
-static Bool
-i810InitScreen (ScreenPtr pScreen) {
-
-#ifdef XV
-    i810InitVideo(pScreen);
-#endif
-    return TRUE;
-}
-
-static Bool
-i810FinishInitScreen(ScreenPtr pScreen)
-{
-    /* XXX: RandR init */
-    return TRUE;
-}
-
-static void
-i810CardFini (KdCardInfo *card)
-{
-    I810CardInfo	*i810c = (I810CardInfo *) card->driver;
-    
-    KdUnmapDevice (i810c->FbBase, i810c->FbMapSize);
-    KdUnmapDevice (i810c->MMIOBase, I810_REG_SIZE);
-    xfree (i810c);
-    card->driver = 0;
-}
-
-struct wm_info {
-   double freq;
-   unsigned int wm;
-};
-
-struct wm_info i810_wm_8_100[] = {
-   { 0,    0x22003000 },
-   { 25.2, 0x22003000 },
-   { 28.0, 0x22003000 },
-   { 31.5, 0x22003000 },
-   { 36.0, 0x22007000 },
-   { 40.0, 0x22007000 },
-   { 45.0, 0x22007000 },
-   { 49.5, 0x22008000 },
-   { 50.0, 0x22008000 },
-   { 56.3, 0x22008000 },
-   { 65.0, 0x22008000 },
-   { 75.0, 0x22008000 },
-   { 78.8, 0x22008000 },
-   { 80.0, 0x22008000 },
-   { 94.0, 0x22008000 },
-   { 96.0, 0x22107000 },
-   { 99.0, 0x22107000 },
-   { 108.0, 0x22107000 },
-   { 121.0, 0x22107000 },
-   { 128.9, 0x22107000 },
-   { 132.0, 0x22109000 },
-   { 135.0, 0x22109000 },
-   { 157.5, 0x2210b000 },
-   { 162.0, 0x2210b000 },
-   { 175.5, 0x2210b000 },
-   { 189.0, 0x2220e000 },
-   { 202.5, 0x2220e000 }
-};
-
-struct wm_info i810_wm_16_100[] = {
-   { 0, 0x22004000 },
-   { 25.2, 0x22006000 },
-   { 28.0, 0x22006000 },
-   { 31.5, 0x22007000 },
-   { 36.0, 0x22007000 },
-   { 40.0, 0x22007000 },
-   { 45.0, 0x22007000 },
-   { 49.5, 0x22009000 },
-   { 50.0, 0x22009000 },
-   { 56.3, 0x22108000 },
-   { 65.0, 0x2210e000 },
-   { 75.0, 0x2210e000 },
-   { 78.8, 0x2210e000 },
-   { 80.0, 0x22210000 },
-   { 94.5, 0x22210000 },
-   { 96.0, 0x22210000 },
-   { 99.0, 0x22210000 },
-   { 108.0, 0x22210000 },
-   { 121.0, 0x22210000 },
-   { 128.9, 0x22210000 },
-   { 132.0, 0x22314000 },
-   { 135.0, 0x22314000 },
-   { 157.5, 0x22415000 },
-   { 162.0, 0x22416000 },
-   { 175.5, 0x22416000 },
-   { 189.0, 0x22416000 },
-   { 195.0, 0x22416000 },
-   { 202.5, 0x22416000 }
-};
-
-
-struct wm_info i810_wm_24_100[] = {
-   { 0,  0x22006000 },
-   { 25.2, 0x22009000 },
-   { 28.0, 0x22009000 },
-   { 31.5, 0x2200a000 },
-   { 36.0, 0x2210c000 },
-   { 40.0, 0x2210c000 },
-   { 45.0, 0x2210c000 },
-   { 49.5, 0x22111000 },
-   { 50.0, 0x22111000 },
-   { 56.3, 0x22111000 },
-   { 65.0, 0x22214000 },
-   { 75.0, 0x22214000 },
-   { 78.8, 0x22215000 },
-   { 80.0, 0x22216000 },
-   { 94.5, 0x22218000 },
-   { 96.0, 0x22418000 },
-   { 99.0, 0x22418000 },
-   { 108.0, 0x22418000 },
-   { 121.0, 0x22418000 },
-   { 128.9, 0x22419000 },
-   { 132.0, 0x22519000 },
-   { 135.0, 0x4441d000 },
-   { 157.5, 0x44419000 },
-   { 162.0, 0x44419000 },
-   { 175.5, 0x44419000 },
-   { 189.0, 0x44419000 },
-   { 195.0, 0x44419000 },
-   { 202.5, 0x44419000 }
-};
-
-struct wm_info i810_wm_32_100[] = {
-   { 0, 0x2210b000 },
-   { 60, 0x22415000 },		/* 0x314000 works too */
-   { 80, 0x22419000 }           /* 0x518000 works too */
-};
-
-
-struct wm_info i810_wm_8_133[] = {
-  { 0,    0x22003000 },
-   { 25.2, 0x22003000 },
-   { 28.0, 0x22003000 },
-   { 31.5, 0x22003000 },
-   { 36.0, 0x22007000 },
-   { 40.0, 0x22007000 },
-   { 45.0, 0x22007000 },
-   { 49.5, 0x22008000 },
-   { 50.0, 0x22008000 },
-   { 56.3, 0x22008000 },
-   { 65.0, 0x22008000 },
-   { 75.0, 0x22008000 },
-   { 78.8, 0x22008000 },
-   { 80.0, 0x22008000 },
-   { 94.0, 0x22008000 },
-   { 96.0, 0x22107000 },
-   { 99.0, 0x22107000 },
-   { 108.0, 0x22107000 },
-   { 121.0, 0x22107000 },
-   { 128.9, 0x22107000 },
-   { 132.0, 0x22109000 },
-   { 135.0, 0x22109000 },
-   { 157.5, 0x2210b000 },
-   { 162.0, 0x2210b000 },
-   { 175.5, 0x2210b000 },
-   { 189.0, 0x2220e000 },
-   { 202.5, 0x2220e000 }
-};
-
-
-struct wm_info i810_wm_16_133[] = {
-   { 0, 0x22004000 },
-   { 25.2, 0x22006000 },
-   { 28.0, 0x22006000 },
-   { 31.5, 0x22007000 },
-   { 36.0, 0x22007000 },
-   { 40.0, 0x22007000 },
-   { 45.0, 0x22007000 },
-   { 49.5, 0x22009000 },
-   { 50.0, 0x22009000 },
-   { 56.3, 0x22108000 },
-   { 65.0, 0x2210e000 },
-   { 75.0, 0x2210e000 },
-   { 78.8, 0x2210e000 },
-   { 80.0, 0x22210000 },
-   { 94.5, 0x22210000 },
-   { 96.0, 0x22210000 },
-   { 99.0, 0x22210000 },
-   { 108.0, 0x22210000 },
-   { 121.0, 0x22210000 },
-   { 128.9, 0x22210000 },
-   { 132.0, 0x22314000 },
-   { 135.0, 0x22314000 },
-   { 157.5, 0x22415000 },
-   { 162.0, 0x22416000 },
-   { 175.5, 0x22416000 },
-   { 189.0, 0x22416000 },
-   { 195.0, 0x22416000 },
-   { 202.5, 0x22416000 }
-};
-
-struct wm_info i810_wm_24_133[] = {
-  { 0,  0x22006000 },
-   { 25.2, 0x22009000 },
-   { 28.0, 0x22009000 },
-   { 31.5, 0x2200a000 },
-   { 36.0, 0x2210c000 },
-   { 40.0, 0x2210c000 },
-   { 45.0, 0x2210c000 },
-   { 49.5, 0x22111000 },
-   { 50.0, 0x22111000 },
-   { 56.3, 0x22111000 },
-   { 65.0, 0x22214000 },
-   { 75.0, 0x22214000 },
-   { 78.8, 0x22215000 },
-   { 80.0, 0x22216000 },
-   { 94.5, 0x22218000 },
-   { 96.0, 0x22418000 },
-   { 99.0, 0x22418000 },
-   { 108.0, 0x22418000 },
-   { 121.0, 0x22418000 },
-   { 128.9, 0x22419000 },
-   { 132.0, 0x22519000 },
-   { 135.0, 0x4441d000 },
-   { 157.5, 0x44419000 },
-   { 162.0, 0x44419000 },
-   { 175.5, 0x44419000 },
-   { 189.0, 0x44419000 },
-   { 195.0, 0x44419000 },
-   { 202.5, 0x44419000 }
-};
-
-static void
-i810WriteControlMMIO(I810CardInfo *i810c, int addr, CARD8 index, CARD8 val) {
-  moutb(addr, index);
-  moutb(addr+1, val);
-}
-
-static CARD8
-i810ReadControlMMIO(I810CardInfo *i810c, int addr, CARD8 index) {
-  moutb(addr, index);
-  return minb(addr+1);
-}
-
-static Bool
-i810ModeSupported (KdScreenInfo *screen, const KdMonitorTiming *t)
-{
-    /* This is just a guess. */
-    if (t->horizontal > 1600 || t->horizontal < 640) return FALSE;
-    if (t->vertical > 1200 || t->horizontal < 350) return FALSE;
-    return TRUE;
-}
-
-static Bool
-i810ModeUsable (KdScreenInfo *screen)
-{
-    KdCardInfo	    *card = screen->card;
-    I810CardInfo    *i810c = (I810CardInfo *) card->driver;
-    int		    byte_width, pixel_width, screen_size;
-
-/*     fprintf(stderr,"i810ModeUsable\n"); */
-    
-    if (screen->fb[0].depth >= 24)
-    {
-	screen->fb[0].depth = 24;
-	screen->fb[0].bitsPerPixel = 24;
-	screen->dumb = TRUE;
-    }
-    else if (screen->fb[0].depth >= 16)
-    {
-	screen->fb[0].depth = 16;
-	screen->fb[0].bitsPerPixel = 16;
-    }
-    else if (screen->fb[0].depth >= 15)
-    {
-	screen->fb[0].depth = 15;
-	screen->fb[0].bitsPerPixel = 16;
-    }
-    else
-    {
-	screen->fb[0].depth = 8;
-	screen->fb[0].bitsPerPixel = 8;
-    }
-    byte_width = screen->width * (screen->fb[0].bitsPerPixel >> 3);
-    pixel_width = screen->width;
-
-    screen->fb[0].pixelStride = pixel_width;
-    screen->fb[0].byteStride = byte_width;
-
-    screen_size = byte_width * screen->height;
-
-    return screen_size <= (i810c->videoRam * 1024);
-}
-
-static int i810AllocateGARTMemory( KdScreenInfo *screen ) 
-{
-   KdCardInfo	    *card = screen->card;
-   I810CardInfo    *i810c = (I810CardInfo *) card->driver;
-   unsigned long size = i810c->videoRam * 1024;
-
-   int key;
-   long tom = 0;
-   unsigned long physical;
-
-   if (!KdAgpGARTSupported()) 
-        return FALSE; 
-
-   if (!KdAcquireGART(screen->mynum))
-      return FALSE;
-
-   /* This allows the 2d only Xserver to regen */
-   i810c->agpAcquired2d = TRUE;
-   
-   /* Treat the gart like video memory - we assume we own all that is
-    * there, so ignore EBUSY errors.  Don't try to remove it on
-    * failure, either, as other X server may be using it.
-    */
-
-   if ((key = KdAllocateGARTMemory(screen->mynum, size, 0, NULL)) == -1)
-      return FALSE;
-
-   i810c->VramOffset = 0;
-   i810c->VramKey = key;
-
-   if (!KdBindGARTMemory(screen->mynum, key, 0))
-      return FALSE;
-
-
-   i810c->SysMem.Start = 0;
-   i810c->SysMem.Size = size;
-   i810c->SysMem.End = size;
-   i810c->SavedSysMem = i810c->SysMem;
-
-   tom = i810c->SysMem.End;
-
-   i810c->DcacheMem.Start = 0;
-   i810c->DcacheMem.End = 0;
-   i810c->DcacheMem.Size = 0;
-   i810c->CursorPhysical = 0;
-
-   /* Dcache - half the speed of normal ram, so not really useful for
-    * a 2d server.  Don't bother reporting its presence.  This is
-    * mapped in addition to the requested amount of system ram.
-    */
-   size = 1024 * 4096;
-
-   /* Keep it 512K aligned for the sake of tiled regions.
-    */
-   tom += 0x7ffff;
-   tom &= ~0x7ffff;
-
-   if ((key = KdAllocateGARTMemory(screen->mynum, size, AGP_DCACHE_MEMORY, NULL)) != -1) {
-      i810c->DcacheOffset= tom;
-      i810c->DcacheKey = key;
-      if (!KdBindGARTMemory(screen->mynum, key, tom)) {
-	 fprintf(stderr,"Allocation of %ld bytes for DCACHE failed\n", size);
-	 i810c->DcacheKey = -1;
-      }	else {
-	 i810c->DcacheMem.Start = tom;
-	 i810c->DcacheMem.Size = size;
-	 i810c->DcacheMem.End = i810c->DcacheMem.Start + i810c->DcacheMem.Size;
-	 tom = i810c->DcacheMem.End;
-      }
-   } else {
-      fprintf(stderr,
-		 "No physical memory available for %ld bytes of DCACHE\n",
-		 size);
-      i810c->DcacheKey = -1;
-   }
-   
-   /* Mouse cursor -- The i810 (crazy) needs a physical address in
-    * system memory from which to upload the cursor.  We get this from 
-    * the agpgart module using a special memory type.
-    */
-
-   /* 4k for the cursor is excessive, I'm going to steal 3k for
-    * overlay registers later
-    */
-
-   size = 4096;
-
-   if ((key = KdAllocateGARTMemory(screen->mynum, size, AGP_PHYS_MEMORY,
-				     &physical)) == -1) {
-      fprintf(stderr,
-		    "No physical memory available for HW cursor\n");
-      i810c->HwcursKey = -1;
-   } else {
-      i810c->HwcursOffset= tom;
-      i810c->HwcursKey = key;
-      if (!KdBindGARTMemory(screen->mynum, key, tom)) {
-	 fprintf(stderr,
-		    "Allocation of %ld bytes for HW cursor failed\n", 
-		    size);
-	 i810c->HwcursKey = -1;
-      }	else {
-	 i810c->CursorPhysical = physical;
-	 i810c->CursorStart = tom;
-	 tom += size;
-      }
-   }
-
-   /* Overlay register buffer -- Just like the cursor, the i810 needs a
-    * physical address in system memory from which to upload the overlay
-    * registers.
-    */
-   if (i810c->CursorStart != 0) {
-        i810c->OverlayPhysical = i810c->CursorPhysical + 1024;
-        i810c->OverlayStart = i810c->CursorStart + 1024;
-   }
-
-
-   i810c->GttBound = 1;
-
-   return TRUE;
-}
-
-/* Allocate from a memrange, returns success */
-
-static int i810AllocLow( I810MemRange *result, I810MemRange *pool, int size )
-{
-   if (size > pool->Size) return FALSE;
-
-   pool->Size -= size;
-   result->Size = size;
-   result->Start = pool->Start;
-   result->End = pool->Start += size;
-   return TRUE;
-}
-
-static int i810AllocHigh( I810MemRange *result, I810MemRange *pool, int size )
-{
-   if (size > pool->Size) return 0;
-
-   pool->Size -= size;
-   result->Size = size;
-   result->End = pool->End;
-   result->Start = pool->End -= size;
-   return 1;
-}
-
-static Bool
-i810AllocateFront(KdScreenInfo *screen) {
-
-    KdCardInfo	    *card = screen->card;
-    I810CardInfo    *i810c = (I810CardInfo *) card->driver;
-
-   int cache_lines = -1;
-
-   if(i810c->DoneFrontAlloc) 
-      return TRUE;
-      
-   memset(&(i810c->FbMemBox), 0, sizeof(BoxRec));
-   /* Alloc FrontBuffer/Ring/Accel memory */
-   i810c->FbMemBox.x1=0;
-   i810c->FbMemBox.x2=screen->width;
-   i810c->FbMemBox.y1=0;
-   i810c->FbMemBox.y2=screen->height;
-
-   /* This could be made a command line option */
-   cache_lines = 0;
-
-   if(cache_lines >= 0)	
-	i810c->FbMemBox.y2 += cache_lines;
-   else {
-       /* make sure there is enough for two DVD sized YUV buffers */
-	i810c->FbMemBox.y2 += (screen->fb[0].depth == 24) ? 256 : 384;
-	if (screen->width <= 1024)
-	    i810c->FbMemBox.y2 += (screen->fb[0].depth == 24) ? 256 : 384;
-	cache_lines = i810c->FbMemBox.y2 - screen->height;
-   }
-
-   if (I810_DEBUG)
-       ErrorF("Adding %i scanlines for pixmap caching\n", cache_lines);
-
-   /* Reserve room for the framebuffer and pixcache.  Put at the top
-    * of memory so we can have nice alignment for the tiled regions at
-    * the start of memory.
-    */
-   i810AllocLow( &(i810c->FrontBuffer), 
-		 &(i810c->SysMem), 
-		 ((i810c->FbMemBox.x2 * 
-		   i810c->FbMemBox.y2 * 
-		   i810c->cpp) + 4095) & ~4095);
-   
-   memset( &(i810c->LpRing), 0, sizeof( I810RingBuffer ) );
-   if(i810AllocLow( &(i810c->LpRing.mem), &(i810c->SysMem), 16*4096 )) {
-	 if (I810_DEBUG & DEBUG_VERBOSE_MEMORY)
-	    ErrorF( "ring buffer at local %lx\n", 
-		    i810c->LpRing.mem.Start);
-
-	 i810c->LpRing.tail_mask = i810c->LpRing.mem.Size - 1;
-	 i810c->LpRing.virtual_start = i810c->FbBase + i810c->LpRing.mem.Start;
-	 i810c->LpRing.head = 0;
-	 i810c->LpRing.tail = 0;      
-	 i810c->LpRing.space = 0;		 
-   }
-   
-   if ( i810AllocLow( &i810c->Scratch, &(i810c->SysMem), 64*1024 ) || 
-	i810AllocLow( &i810c->Scratch, &(i810c->SysMem), 16*1024 ) ) {       
-       if (I810_DEBUG & DEBUG_VERBOSE_MEMORY)
-           ErrorF("Allocated Scratch Memory\n");
-   }
-
-#ifdef XV
-   /* 720x720 is just how much memory the mpeg player needs for overlays */
-
-   if ( i810AllocHigh( &i810c->XvMem, &(i810c->SysMem), 720*720*2 )) {       
-       if (I810_DEBUG & DEBUG_VERBOSE_MEMORY)
-           ErrorF("Allocated overlay Memory\n");
-   }
-#endif
-   
-   i810c->DoneFrontAlloc = TRUE;
-   return TRUE;
-}
-
-static Bool
-i810MapMem(KdScreenInfo *screen)
-{
-
-    KdCardInfo	    *card = screen->card;
-    I810CardInfo    *i810c = (I810CardInfo *) card->driver;
-    
-    i810c->LpRing.virtual_start = i810c->FbBase + i810c->LpRing.mem.Start;
-    
-    return TRUE;
-}
-
-
-Bool
-i810ScreenInit (KdScreenInfo *screen)
-{
-    KdCardInfo	    *card = screen->card;
-    I810CardInfo    *i810c = (I810CardInfo *) card->driver;
-    I810ScreenInfo   *i810s;
-
-    int i;
-
-    const KdMonitorTiming *t;
-
-/*     fprintf(stderr,"i810ScreenInit\n"); */
-
-    i810s = (I810ScreenInfo *) xalloc (sizeof (I810ScreenInfo));
-    if (!i810s)
-	return FALSE;
-
-    memset (i810s, '\0', sizeof (I810ScreenInfo));
-
-    i810s->i810c = i810c;
-
-    /* Default dimensions */
-    if (!screen->width || !screen->height)
-    {
-        screen->width = 720;
-        screen->height = 576;
-        screen->rate = 52;
-#if 0
-        screen->width = 1024;
-        screen->height = 768;
-        screen->rate = 72;
-#endif
-    }
-
-    if (!screen->fb[0].depth)
-	screen->fb[0].depth = 16;
-    
-    t = KdFindMode (screen, i810ModeSupported);
-    
-    screen->rate = t->rate;
-    screen->width = t->horizontal;
-    screen->height = t->vertical;
-    
-    if (!KdTuneMode (screen, i810ModeUsable, i810ModeSupported))
-    {
-	xfree (i810c);
-	return FALSE;
-    }
-
-/*     fprintf(stderr,"Screen rate %d horiz %d vert %d\n",t->rate,t->horizontal,t->vertical); */
-
-    switch (screen->fb[0].depth) {
-    case 8:
-	screen->fb[0].visuals = ((1 << StaticGray) |
-			   (1 << GrayScale) |
-			   (1 << StaticColor) |
-			   (1 << PseudoColor) |
-			   (1 << TrueColor) |
-			   (1 << DirectColor));
-	screen->fb[0].blueMask  = 0x00;
-	screen->fb[0].greenMask = 0x00;
-	screen->fb[0].redMask   = 0x00;
-	break;
-    case 15:
-	screen->fb[0].visuals = (1 << TrueColor);
-	screen->fb[0].blueMask  = 0x001f;
-	screen->fb[0].greenMask = 0x03e0;
-	screen->fb[0].redMask   = 0x7c00;
-
-        i810c->colorKey = 0x043f;
-
-	break;
-    case 16:
-	screen->fb[0].visuals = (1 << TrueColor);
-	screen->fb[0].blueMask  = 0x001f;
-	screen->fb[0].greenMask = 0x07e0;
-	screen->fb[0].redMask   = 0xf800;
-
-        i810c->colorKey = 0x083f;
-
-	break;
-    case 24:
-	screen->fb[0].visuals = (1 << TrueColor);
-	screen->fb[0].blueMask  = 0x0000ff;
-	screen->fb[0].greenMask = 0x00ff00;
-	screen->fb[0].redMask   = 0xff0000;
-
-        i810c->colorKey = 0x0101ff;
-        
-	break;
-    default:
-        fprintf(stderr,"Unsupported depth %d\n",screen->fb[0].depth);
-        return FALSE;
-    }
-
-
-
-    /* Set all colours to black */
-    for (i=0; i<768; i++) i810c->vga.ModeReg.DAC[i] = 0x00;
-
-    /* ... and the overscan */
-    if (screen->fb[0].depth >= 4)
-        i810c->vga.ModeReg.Attribute[OVERSCAN] = 0xFF;
-
-    /* Could be made a command-line option */
-
-#ifdef I810CFG_SHOW_OVERSCAN
-	i810c->vga.ModeReg.DAC[765] = 0x3F; 
-	i810c->vga.ModeReg.DAC[766] = 0x00; 
-	i810c->vga.ModeReg.DAC[767] = 0x3F; 
-	i810c->vga.ModeReg.Attribute[OVERSCAN] = 0xFF;
-	i810c->vga.ShowOverscan = TRUE;
-#else
-	i810c->vga.ShowOverscan = FALSE;
-#endif
-
-    i810c->vga.paletteEnabled = FALSE;
-    i810c->vga.cmapSaved = FALSE;
-    i810c->vga.MMIOBase		= i810c->MMIOBase;
-
-    i810c->cpp = screen->fb[0].bitsPerPixel/8;
-
-    /* move to initscreen? */
-    
-    switch (screen->fb[0].bitsPerPixel) {
-    case 8:
-        i810c->MaxClock = 203000;
-        break;
-    case 16:
-        i810c->MaxClock = 163000;
-        break;
-    case 24:
-        i810c->MaxClock = 136000;
-        break;
-    case 32:  /* not supported */
-        i810c->MaxClock = 86000;
-    default:
-        fprintf(stderr,"Unsupported bpp %d\n",screen->fb[0].bitsPerPixel);
-        return FALSE;
-    }
-
-   if (!i810AllocateGARTMemory( screen )) {
-       return FALSE;
-   }
-
-   i810AllocateFront(screen);
-
-   /* Map LpRing memory */
-   if (!i810MapMem(screen)) return FALSE;
-
-   screen->fb[0].frameBuffer = i810c->FbBase;
-
-   screen->driver = i810s;
-   
-   return TRUE;
-}
-   
-/*
- * I810Save --
- *
- * This function saves the video state.  It reads all of the SVGA registers
- * into the vgaI810Rec data structure.  There is in general no need to
- * mask out bits here - just read the registers.
- */
-static void
-DoSave(KdCardInfo *card, vgaRegPtr vgaReg, I810RegPtr i810Reg, Bool saveFonts)
-{
-
-    I810CardInfo    *i810c = card->driver;
-    i810VGAPtr      vgap = &i810c->vga;
-
-    int i;
-
-    /* Save VGA registers */
-
-    vgaReg->MiscOutReg = mmioReadMiscOut(vgap);
-    if (vgaReg->MiscOutReg & 0x01)
-	vgap->IOBase = VGA_IOBASE_COLOR;
-    else
-	vgap->IOBase = VGA_IOBASE_MONO;
-
-    for (i = 0; i < VGA_NUM_CRTC; i++) {
-	vgaReg->CRTC[i] = mmioReadCrtc(vgap, i);
-    }
-
-    mmioEnablePalette(vgap);
-    for (i = 0; i < VGA_NUM_ATTR; i++) {
-	vgaReg->Attribute[i] = mmioReadAttr(vgap, i);
-    }
-    mmioDisablePalette(vgap);
-
-    for (i = 0; i < VGA_NUM_GFX; i++) {
-	vgaReg->Graphics[i] = mmioReadGr(vgap, i);
-    }
-
-    for (i = 1; i < VGA_NUM_SEQ; i++) {
-	vgaReg->Sequencer[i] = mmioReadSeq(vgap, i);
-    }
-
-    /*
-     * The port I/O code necessary to read in the extended registers 
-     * into the fields of the I810Rec structure goes here.
-     */
-    i810Reg->IOControl = mmioReadCrtc(vgap, IO_CTNL);
-    i810Reg->AddressMapping = i810ReadControlMMIO(i810c, GRX, ADDRESS_MAPPING);
-    i810Reg->BitBLTControl = INREG8(BITBLT_CNTL);
-    i810Reg->VideoClk2_M = INREG16(VCLK2_VCO_M);
-    i810Reg->VideoClk2_N = INREG16(VCLK2_VCO_N);
-    i810Reg->VideoClk2_DivisorSel = INREG8(VCLK2_VCO_DIV_SEL);
-
-    i810Reg->ExtVertTotal=mmioReadCrtc(vgap, EXT_VERT_TOTAL);
-    i810Reg->ExtVertDispEnd=mmioReadCrtc(vgap, EXT_VERT_DISPLAY);
-    i810Reg->ExtVertSyncStart=mmioReadCrtc(vgap, EXT_VERT_SYNC_START);
-    i810Reg->ExtVertBlankStart=mmioReadCrtc(vgap, EXT_VERT_BLANK_START);
-    i810Reg->ExtHorizTotal=mmioReadCrtc(vgap, EXT_HORIZ_TOTAL);
-    i810Reg->ExtHorizBlank=mmioReadCrtc(vgap, EXT_HORIZ_BLANK);
-    i810Reg->ExtOffset=mmioReadCrtc(vgap, EXT_OFFSET);
-    i810Reg->InterlaceControl=mmioReadCrtc(vgap, INTERLACE_CNTL);
-
-    i810Reg->PixelPipeCfg0 = INREG8(PIXPIPE_CONFIG_0);
-    i810Reg->PixelPipeCfg1 = INREG8(PIXPIPE_CONFIG_1);
-    i810Reg->PixelPipeCfg2 = INREG8(PIXPIPE_CONFIG_2);
-    i810Reg->DisplayControl = INREG8(DISPLAY_CNTL);  
-    i810Reg->LMI_FIFO_Watermark = INREG(FWATER_BLC);
-
-    for (i = 0 ; i < 8 ; i++)
-        i810Reg->Fence[i] = INREG(FENCE+i*4);
-
-    i810Reg->LprbTail = INREG(LP_RING + RING_TAIL);
-    i810Reg->LprbHead = INREG(LP_RING + RING_HEAD);
-    i810Reg->LprbStart = INREG(LP_RING + RING_START);
-    i810Reg->LprbLen = INREG(LP_RING + RING_LEN);
-
-    if ((i810Reg->LprbTail & TAIL_ADDR) != (i810Reg->LprbHead & HEAD_ADDR) &&
-        i810Reg->LprbLen & RING_VALID) {
-        i810PrintErrorState( i810c );
-        FatalError( "Active ring not flushed\n");
-    }
-
-    if (I810_DEBUG) {
-        fprintf(stderr,"Got mode in I810Save:\n");
-        i810PrintMode( vgaReg, i810Reg );
-    }       
-}
-
-static void
-i810Preserve(KdCardInfo *card)
-{
-    I810CardInfo    *i810c = card->driver;
-    i810VGAPtr      vgap = &i810c->vga;
-
-/*     fprintf(stderr,"i810Preserve\n"); */
-    DoSave(card, &vgap->SavedReg, &i810c->SavedReg, TRUE);
-}
-
-/* Famous last words
- */
-void 
-i810PrintErrorState(i810CardInfo *i810c)
-{
-    
-   fprintf(stderr, "pgetbl_ctl: 0x%lx pgetbl_err: 0x%lx\n", 
-	   INREG(PGETBL_CTL),
-	   INREG(PGE_ERR));
-
-   fprintf(stderr, "ipeir: %lx iphdr: %lx\n", 
-	   INREG(IPEIR),
-	   INREG(IPEHR));
-
-   fprintf(stderr, "LP ring tail: %lx head: %lx len: %lx start %lx\n",
-	   INREG(LP_RING + RING_TAIL),
-	   INREG(LP_RING + RING_HEAD) & HEAD_ADDR,
-	   INREG(LP_RING + RING_LEN),
-	   INREG(LP_RING + RING_START));
-
-   fprintf(stderr, "eir: %x esr: %x emr: %x\n",
-	   INREG16(EIR),
-	   INREG16(ESR),
-	   INREG16(EMR));
-
-   fprintf(stderr, "instdone: %x instpm: %x\n",
-	   INREG16(INST_DONE),
-	   INREG8(INST_PM));
-
-   fprintf(stderr, "memmode: %lx instps: %lx\n",
-	   INREG(MEMMODE),
-	   INREG(INST_PS));
-
-   fprintf(stderr, "hwstam: %x ier: %x imr: %x iir: %x\n",
-	   INREG16(HWSTAM),
-	   INREG16(IER),
-	   INREG16(IMR),
-	   INREG16(IIR));
-}
-
-static Bool
-i810BindGARTMemory( KdScreenInfo *screen ) 
-{
-    
-    KdCardInfo	    *card = screen->card;
-    I810CardInfo    *i810c = card->driver;
-    
-    if (!i810c->GttBound) {
-        if (!KdAcquireGART(screen->mynum))
-            return FALSE;
-        if (!KdBindGARTMemory(screen->mynum, i810c->VramKey,
-                              i810c->VramOffset))
-
-            return FALSE;
-        if (i810c->DcacheKey != -1) {
-            if (!KdBindGARTMemory(screen->mynum, i810c->DcacheKey,
-                                  i810c->DcacheOffset))
-                return FALSE;
-        }
-        if (i810c->HwcursKey != -1) {
-            if (!KdBindGARTMemory(screen->mynum, i810c->HwcursKey,
-                                  i810c->HwcursOffset))
-                return FALSE;
-        }
-        i810c->GttBound = 1;
-    }
-    return TRUE;
-}
-
-static Bool
-i810UnbindGARTMemory(KdScreenInfo  *screen) 
-{
-    KdCardInfo	    *card = screen->card;
-    I810CardInfo    *i810c = card->driver;
-
-
-    if (KdAgpGARTSupported() && i810c->GttBound) {
-        if (!KdUnbindGARTMemory(screen->mynum, i810c->VramKey))
-            return FALSE;
-        if (i810c->DcacheKey != -1) {
-            if (!KdUnbindGARTMemory(screen->mynum, i810c->DcacheKey))
-                return FALSE;
-        }
-        if (i810c->HwcursKey != -1) {
-            if (!KdUnbindGARTMemory(screen->mynum, i810c->HwcursKey))
-                return FALSE;
-        }
-        if (!KdReleaseGART(screen->mynum))
-            return FALSE;
-        i810c->GttBound = 0;
-    }
-    return TRUE;
-}
-
-/*
- * I810CalcVCLK --
- *
- * Determine the closest clock frequency to the one requested.
- */
-
-#define MAX_VCO_FREQ 600.0
-#define TARGET_MAX_N 30
-#define REF_FREQ 24.0
-
-#define CALC_VCLK(m,n,p) \
-    (double)m / ((double)n * (1 << p)) * 4 * REF_FREQ
-
-static void
-i810CalcVCLK( KdScreenInfo *screen, double freq )
-{
-
-    KdCardInfo	    *card = screen->card;
-    I810CardInfo    *i810c = card->driver;
-    I810RegPtr i810Reg = &i810c->ModeReg;
-
-   int m, n, p;
-   double f_out, f_best;
-   double f_err;
-   double f_vco;
-   int m_best = 0, n_best = 0, p_best = 0;
-   double f_target = freq;
-   double err_max = 0.005;
-   double err_target = 0.001;
-   double err_best = 999999.0;
-
-   p_best = p = log(MAX_VCO_FREQ/f_target)/log((double)2);
-   f_vco = f_target * (1 << p);
-
-   n = 2;
-   do {
-      n++;
-      m = f_vco / (REF_FREQ / (double)n) / (double)4.0 + 0.5;
-      if (m < 3) m = 3;
-      f_out = CALC_VCLK(m,n,p);
-      f_err = 1.0 - (f_target/f_out);
-      if (fabs(f_err) < err_max) {
-	 m_best = m;
-	 n_best = n;
-	 f_best = f_out;
-	 err_best = f_err;
-      }
-   } while ((fabs(f_err) >= err_target) &&
-	    ((n <= TARGET_MAX_N) || (fabs(err_best) > err_max)));
-
-   if (fabs(f_err) < err_target) {
-      m_best = m;
-      n_best = n;
-   }
-
-   i810Reg->VideoClk2_M          = (m_best-2) & 0x3FF;
-   i810Reg->VideoClk2_N          = (n_best-2) & 0x3FF;
-   i810Reg->VideoClk2_DivisorSel = (p_best << 4);
-
-/*    fprintf(stderr, "Setting dot clock to %.1f MHz " */
-/*            "[ 0x%x 0x%x 0x%x ] " */
-/*            "[ %d %d %d ]\n", */
-/*            CALC_VCLK(m_best,n_best,p_best), */
-/*            i810Reg->VideoClk2_M, */
-/*            i810Reg->VideoClk2_N, */
-/*            i810Reg->VideoClk2_DivisorSel, */
-/*            m_best, n_best, p_best); */
-}
-
-/*
- * I810CalcFIFO --
- *
- * Calculate burst length and FIFO watermark.
- */
-
-#define Elements(x) (sizeof(x)/sizeof(*x))
-
-static unsigned int 
-i810CalcWatermark( KdScreenInfo *screen, double freq, Bool dcache )
-{
-
-    KdCardInfo	    *card = screen->card;
-    I810CardInfo    *i810c = card->driver;
-    
-
-    struct wm_info *tab;
-    int nr;
-    int i;
-
-    if (i810c->LmFreqSel == 100) {
-        switch(screen->fb[0].bitsPerPixel) {
-        case 8:
-            tab = i810_wm_8_100;
-            nr = Elements(i810_wm_8_100);
-            break;
-        case 16:
-            tab = i810_wm_16_100;
-            nr = Elements(i810_wm_16_100);
-            break;
-        case 24:
-            tab = i810_wm_24_100;
-            nr = Elements(i810_wm_24_100);
-            break;
-        default: 
-            return 0;
-        }
-    } else {
-        switch(screen->fb[0].bitsPerPixel) {
-        case 8:
-            tab = i810_wm_8_133;
-            nr = Elements(i810_wm_8_133);
-            break;
-        case 16:
-            tab = i810_wm_16_133;
-            nr = Elements(i810_wm_16_133);
-            break;
-        case 24:
-            tab = i810_wm_24_133;
-            nr = Elements(i810_wm_24_133);
-            break;
-        default:
-            return 0;
-        }
-    }
-
-    for (i = 0 ; i < nr && tab[i].freq < freq ; i++);
-   
-    if (i == nr)
-        i--;
-
-/*     fprintf(stderr,"chose watermark 0x%x: (tab.freq %.1f)\n", */
-/*             tab[i].wm, tab[i].freq); */
-
-    /* None of these values (sourced from intel) have watermarks for
-     * the dcache memory.  Fake it for now by using the same watermark
-     * for both...  
-     *
-     * Update: this is probably because dcache isn't real useful as
-     * framebuffer memory, so intel's drivers don't need watermarks
-     * for that memory because they never use it to feed the ramdacs.
-     * We do use it in the fallback mode, so keep the watermarks for
-     * now.
-     */
-    if (dcache)
-        return (tab[i].wm & ~0xffffff) | ((tab[i].wm>>12) & 0xfff);
-    else
-        return tab[i].wm;
-}
-
-static void i810PrintMode( vgaRegPtr vgaReg, I810RegPtr mode )
-{
-   int i;
-
-   fprintf(stderr,"   MiscOut: %x\n", vgaReg->MiscOutReg);
-   
-
-   fprintf(stderr,"SEQ: ");   
-   for (i = 0 ; i < VGA_NUM_SEQ ; i++) {
-      if ((i&7)==0) fprintf(stderr,"\n");
-      fprintf(stderr,"   %d: %x", i, vgaReg->Sequencer[i]);
-   }
-   fprintf(stderr,"\n");
-
-   fprintf(stderr,"CRTC: ");   
-   for (i = 0 ; i < VGA_NUM_CRTC ; i++) {
-      if ((i&3)==0) fprintf(stderr,"\n");
-      fprintf(stderr,"   CR%02x: %2x", i, vgaReg->CRTC[i]);
-   }
-   fprintf(stderr,"\n");
-
-   fprintf(stderr,"GFX: ");   
-   for (i = 0 ; i < VGA_NUM_GFX ; i++) {
-      if ((i&3)==0) fprintf(stderr,"\n");
-      fprintf(stderr,"   GR%02x: %02x", i, vgaReg->Graphics[i]);
-   }
-   fprintf(stderr,"\n");
-
-   fprintf(stderr,"ATTR: ");   
-   for (i = 0 ; i < VGA_NUM_ATTR ; i++) {
-      if ((i&7)==0) fprintf(stderr,"\n");
-      fprintf(stderr,"   %d: %x", i, vgaReg->Attribute[i]);
-   }
-   fprintf(stderr,"\n");
-
-
-   fprintf(stderr,"   DisplayControl: %x\n", mode->DisplayControl);
-   fprintf(stderr,"   PixelPipeCfg0: %x\n", mode->PixelPipeCfg0);
-   fprintf(stderr,"   PixelPipeCfg1: %x\n", mode->PixelPipeCfg1);
-   fprintf(stderr,"   PixelPipeCfg2: %x\n", mode->PixelPipeCfg2);
-   fprintf(stderr,"   VideoClk2_M: %x\n", mode->VideoClk2_M);
-   fprintf(stderr,"   VideoClk2_N: %x\n", mode->VideoClk2_N);
-   fprintf(stderr,"   VideoClk2_DivisorSel: %x\n", mode->VideoClk2_DivisorSel);
-   fprintf(stderr,"   AddressMapping: %x\n", mode->AddressMapping);
-   fprintf(stderr,"   IOControl: %x\n", mode->IOControl);
-   fprintf(stderr,"   BitBLTControl: %x\n", mode->BitBLTControl);
-   fprintf(stderr,"   ExtVertTotal: %x\n", mode->ExtVertTotal);
-   fprintf(stderr,"   ExtVertDispEnd: %x\n", mode->ExtVertDispEnd);
-   fprintf(stderr,"   ExtVertSyncStart: %x\n", mode->ExtVertSyncStart);
-   fprintf(stderr,"   ExtVertBlankStart: %x\n", mode->ExtVertBlankStart);
-   fprintf(stderr,"   ExtHorizTotal: %x\n", mode->ExtHorizTotal);
-   fprintf(stderr,"   ExtHorizBlank: %x\n", mode->ExtHorizBlank);
-   fprintf(stderr,"   ExtOffset: %x\n", mode->ExtOffset);
-   fprintf(stderr,"   InterlaceControl: %x\n", mode->InterlaceControl);
-   fprintf(stderr,"   LMI_FIFO_Watermark: %x\n", mode->LMI_FIFO_Watermark);   
-   fprintf(stderr,"   LprbTail: %x\n", mode->LprbTail);
-   fprintf(stderr,"   LprbHead: %x\n", mode->LprbHead);
-   fprintf(stderr,"   LprbStart: %x\n", mode->LprbStart);
-   fprintf(stderr,"   LprbLen: %x\n", mode->LprbLen);
-   fprintf(stderr,"   OverlayActiveStart: %x\n", mode->OverlayActiveStart);
-   fprintf(stderr,"   OverlayActiveEnd: %x\n", mode->OverlayActiveEnd);
-}
-
-
-/*
- * i810VGASeqReset
- *      perform a sequencer reset.
- *
- * The i815 documentation states that these bits are not used by the
- * HW, but still warns about not programming them...
- */
-
-static void
-i810VGASeqReset(i810VGAPtr vgap, Bool start)
-{
-    if (start)
-    {
-        mmioWriteSeq(vgap, 0x00, 0x01); 	/* Synchronous Reset */
-    }	
-    else
-    {
-        mmioWriteSeq(vgap, 0x00, 0x03);		/* End Reset */
-    }
-}
-
-static void
-i810VGAProtect(KdCardInfo *card, Bool on)
-{
-
-    I810CardInfo    *i810c = card->driver;
-    i810VGAPtr      vgap = &i810c->vga;
-    
-    unsigned char tmp;
-  
-    if (on) {
-        /*
-         * Turn off screen and disable sequencer.
-         */
-        tmp = mmioReadSeq(vgap, 0x01);
-
-        i810VGASeqReset(vgap, TRUE); /* start synchronous reset */
-        mmioWriteSeq(vgap, 0x01, tmp | 0x20); /* disable the display */
-
-        mmioEnablePalette(vgap);
-    } else {
-        /*
-         * Reenable sequencer, then turn on screen.
-         */
-  
-        tmp = mmioReadSeq(vgap, 0x01);
-
-        mmioWriteSeq(vgap, 0x01, tmp & ~0x20);	/* reenable display */
-        i810VGASeqReset(vgap, FALSE);		/* clear synchronousreset */
-
-        mmioDisablePalette(vgap);
-    }
-}
-
-/*
- * i810VGABlankScreen -- blank the screen.
- */
-
-void
-i810VGABlankScreen(KdCardInfo *card, Bool on)
-{
-    I810CardInfo    *i810c = card->driver;
-    i810VGAPtr      vgap = &i810c->vga;
-
-    unsigned char scrn;
-
-    scrn = mmioReadSeq(vgap, 0x01);
-
-    if (on) {
-        scrn &= ~0x20;			/* enable screen */
-    } else {
-        scrn |= 0x20;			/* blank screen */
-    }
-    
-    mmioWriteSeq(vgap,0x00,0x01);
-    mmioWriteSeq(vgap, 0x01, scrn);	/* change mode */
-    mmioWriteSeq(vgap,0x00,0x03);
-}
-
-/* Restore hardware state */
-
-static void
-DoRestore(KdCardInfo *card, vgaRegPtr vgaReg, I810RegPtr i810Reg, 
-	  Bool restoreFonts) {
-
-    
-    I810CardInfo    *i810c = card->driver;
-
-    i810VGAPtr      vgap = &i810c->vga;
-
-    unsigned char temp;
-    unsigned int  itemp;
-    int i;
-
-    if (I810_DEBUG & DEBUG_VERBOSE_VGA) {
-        fprintf(stderr,"Setting mode in DoRestore:\n");
-        i810PrintMode( vgaReg, i810Reg );
-    }
-    
-    /* Blank screen (i810vgaprotect) */
-    i810VGAProtect(card, TRUE);
-    
-    /* Should wait for at least two hsync and no more than two vsync
-       before writing PIXCONF and turning the display on (?) */
-    usleep(50000);
-
-    /* Turn off DRAM Refresh */
-    temp = INREG8( DRAM_ROW_CNTL_HI );
-    temp &= ~DRAM_REFRESH_RATE;
-    temp |= DRAM_REFRESH_DISABLE;
-    OUTREG8( DRAM_ROW_CNTL_HI, temp );
-
-    usleep(1000); /* Wait 1 ms */
-
-    /* Write the M, N and P values */
-    OUTREG16( VCLK2_VCO_M, i810Reg->VideoClk2_M);
-    OUTREG16( VCLK2_VCO_N, i810Reg->VideoClk2_N);
-    OUTREG8( VCLK2_VCO_DIV_SEL, i810Reg->VideoClk2_DivisorSel);
-
-    /*
-     * Turn on 8 bit dac mode, if requested.  This is needed to make
-     * sure that vgaHWRestore writes the values into the DAC properly.
-     * The problem occurs if 8 bit dac mode is requested and the HW is
-     * in 6 bit dac mode.  If this happens, all the values are
-     * automatically shifted left twice by the HW and incorrect colors
-     * will be displayed on the screen.  The only time this can happen
-     * is at server startup time and when switching back from a VT.
-     */
-    temp = INREG8(PIXPIPE_CONFIG_0); 
-    temp &= 0x7F; /* Save all but the 8 bit dac mode bit */
-    temp |= (i810Reg->PixelPipeCfg0 & DAC_8_BIT);
-    OUTREG8( PIXPIPE_CONFIG_0, temp );
-
-    /*
-     * Code to restore any SVGA registers that have been saved/modified
-     * goes here.  Note that it is allowable, and often correct, to 
-     * only modify certain bits in a register by a read/modify/write cycle.
-     *
-     * A special case - when using an external clock-setting program,
-     * this function must not change bits associated with the clock
-     * selection.  This condition can be checked by the condition:
-     *
-     *	if (i810Reg->std.NoClock >= 0)
-     *		restore clock-select bits.
-     */
-
-    /* VGA restore */
-    if (vgaReg->MiscOutReg & 0x01)
-	vgap->IOBase = VGA_IOBASE_COLOR;
-    else
-	vgap->IOBase = VGA_IOBASE_MONO;
-
-    mmioWriteMiscOut(vgap, vgaReg->MiscOutReg);
-
-    for (i = 1; i < VGA_NUM_SEQ; i++)
-	mmioWriteSeq(vgap, i, vgaReg->Sequencer[i]);
-  
-    /* Ensure CRTC registers 0-7 are unlocked by clearing bit 7 or CRTC[17] */
-    /* = CR11 */
-    mmioWriteCrtc(vgap, 17, vgaReg->CRTC[17] & ~0x80);
-
-    for (i = 0; i < VGA_NUM_CRTC; i++) {
-	mmioWriteCrtc(vgap, i, vgaReg->CRTC[i]);
-    }
-
-    for (i = 0; i < VGA_NUM_GFX; i++)
-	mmioWriteGr(vgap, i, vgaReg->Graphics[i]);
-
-    mmioEnablePalette(vgap);
-    for (i = 0; i < VGA_NUM_ATTR; i++)
-	mmioWriteAttr(vgap, i, vgaReg->Attribute[i]);
-    mmioDisablePalette(vgap);
-
-
-    mmioWriteCrtc(vgap, EXT_VERT_TOTAL, i810Reg->ExtVertTotal);
-    mmioWriteCrtc(vgap, EXT_VERT_DISPLAY, i810Reg->ExtVertDispEnd);
-    mmioWriteCrtc(vgap, EXT_VERT_SYNC_START, i810Reg->ExtVertSyncStart);
-    mmioWriteCrtc(vgap, EXT_VERT_BLANK_START, i810Reg->ExtVertBlankStart);
-    mmioWriteCrtc(vgap, EXT_HORIZ_TOTAL, i810Reg->ExtHorizTotal);
-    mmioWriteCrtc(vgap, EXT_HORIZ_BLANK, i810Reg->ExtHorizBlank);
-
-    /* write CR40, CR42 first etc to get CR13 written as described in PRM */
-
-    mmioWriteCrtc(vgap, EXT_START_ADDR_HI, 0);
-    mmioWriteCrtc(vgap, EXT_START_ADDR, EXT_START_ADDR_ENABLE);
-
-    mmioWriteCrtc(vgap, EXT_OFFSET, i810Reg->ExtOffset);
-    mmioWriteCrtc(vgap, 0x13, vgaReg->CRTC[0x13]);
-
-    temp=mmioReadCrtc(vgap, INTERLACE_CNTL);
-    temp &= ~INTERLACE_ENABLE;
-    temp |= i810Reg->InterlaceControl;
-    mmioWriteCrtc(vgap, INTERLACE_CNTL, temp);
-
-    temp=i810ReadControlMMIO(i810c, GRX, ADDRESS_MAPPING);
-    temp &= 0xE0; /* Save reserved bits 7:5 */
-    temp |= i810Reg->AddressMapping;
-    i810WriteControlMMIO(i810c, GRX, ADDRESS_MAPPING, temp);
-
-    /* Setting the OVRACT Register for video overlay*/
-    OUTREG(0x6001C, (i810Reg->OverlayActiveEnd << 16) | i810Reg->OverlayActiveStart);
-
-    /* Turn on DRAM Refresh */
-    temp = INREG8( DRAM_ROW_CNTL_HI );
-    temp &= ~DRAM_REFRESH_RATE;
-    temp |= DRAM_REFRESH_60HZ;
-    OUTREG8( DRAM_ROW_CNTL_HI, temp );
-
-    temp = INREG8( BITBLT_CNTL );
-    temp &= ~COLEXP_MODE;
-    temp |= i810Reg->BitBLTControl;
-    OUTREG8( BITBLT_CNTL, temp );
-
-    temp = INREG8( DISPLAY_CNTL );
-    temp &= ~(VGA_WRAP_MODE | GUI_MODE);
-    temp |= i810Reg->DisplayControl;
-    OUTREG8( DISPLAY_CNTL, temp );
-   
-
-    temp = INREG8( PIXPIPE_CONFIG_0 );
-    temp &= 0x64; /* Save reserved bits 6:5,2 */
-    temp |= i810Reg->PixelPipeCfg0;
-    OUTREG8( PIXPIPE_CONFIG_0, temp );
-
-    temp = INREG8( PIXPIPE_CONFIG_2 );
-    temp &= 0xF3; /* Save reserved bits 7:4,1:0 */
-    temp |= i810Reg->PixelPipeCfg2;
-    OUTREG8( PIXPIPE_CONFIG_2, temp );
-
-    temp = INREG8( PIXPIPE_CONFIG_1 );
-    temp &= ~DISPLAY_COLOR_MODE;
-    temp &= 0xEF; /* Restore the CRT control bit */
-    temp |= i810Reg->PixelPipeCfg1;
-    OUTREG8( PIXPIPE_CONFIG_1, temp );
-   
-    OUTREG16(EIR, 0);
-
-    itemp = INREG(FWATER_BLC);
-    itemp &= ~(LM_BURST_LENGTH | LM_FIFO_WATERMARK | 
-               MM_BURST_LENGTH | MM_FIFO_WATERMARK );
-    itemp |= i810Reg->LMI_FIFO_Watermark;
-    OUTREG(FWATER_BLC, itemp);
-
-
-    for (i = 0 ; i < 8 ; i++) {
-        OUTREG( FENCE+i*4, i810Reg->Fence[i] );
-        if (I810_DEBUG & DEBUG_VERBOSE_VGA)
-            fprintf(stderr,"Fence Register : %x\n",  i810Reg->Fence[i]);
-    }
-   
-    /* First disable the ring buffer (Need to wait for empty first?, if so
-     * should probably do it before entering this section)
-     */
-    itemp = INREG(LP_RING + RING_LEN);
-    itemp &= ~RING_VALID_MASK;
-    OUTREG(LP_RING + RING_LEN, itemp );
-
-    /* Set up the low priority ring buffer.
-     */
-    OUTREG(LP_RING + RING_TAIL, 0 );
-    OUTREG(LP_RING + RING_HEAD, 0 );
-
-    i810c->LpRing.head = 0;
-    i810c->LpRing.tail = 0;
-
-    itemp = INREG(LP_RING + RING_START);
-    itemp &= ~(START_ADDR);
-    itemp |= i810Reg->LprbStart;
-    OUTREG(LP_RING + RING_START, itemp );
-
-    itemp = INREG(LP_RING + RING_LEN);
-    itemp &= ~(RING_NR_PAGES | RING_REPORT_MASK | RING_VALID_MASK);
-    itemp |= i810Reg->LprbLen;
-    OUTREG(LP_RING + RING_LEN, itemp );
-
-    i810VGAProtect(card, FALSE);
-
-    temp=mmioReadCrtc(vgap, IO_CTNL);
-    temp &= ~(EXTENDED_ATTR_CNTL | EXTENDED_CRTC_CNTL);
-    temp |= i810Reg->IOControl;
-    mmioWriteCrtc(vgap, IO_CTNL, temp);
-    /* Protect CRTC[0-7] */
-    mmioWriteCrtc(vgap, 0x11, mmioReadCrtc(vgap, 0x11) | 0x80);
-}
-
-
-static Bool
-i810SetMode(KdScreenInfo *screen, const KdMonitorTiming *t) 
-{
-
-    KdCardInfo	    *card = screen->card;
-    I810CardInfo    *i810c = card->driver;
-    i810VGAPtr      vgap = &i810c->vga;
-
-    I810RegPtr i810Reg = &i810c->ModeReg;
-    vgaRegPtr pVga = &vgap->ModeReg;
-
-    double dclk = t->clock/1000.0;
-
-    switch (screen->fb[0].bitsPerPixel) {
-    case 8:
-        pVga->CRTC[0x13]        = screen->width >> 3;
-        i810Reg->ExtOffset      = screen->width >> 11;
-        i810Reg->PixelPipeCfg1 = DISPLAY_8BPP_MODE;
-        i810Reg->BitBLTControl = COLEXP_8BPP;
-        break;
-    case 16:
-        i810Reg->PixelPipeCfg1 = DISPLAY_16BPP_MODE;
-        pVga->CRTC[0x13] = screen->width >> 2;
-        i810Reg->ExtOffset      = screen->width >> 10;
-        i810Reg->BitBLTControl = COLEXP_16BPP;
-        break;
-    case 24:
-        pVga->CRTC[0x13]       = (screen->width * 3) >> 3;
-        i810Reg->ExtOffset     = (screen->width * 3) >> 11;
-
-        i810Reg->PixelPipeCfg1 = DISPLAY_24BPP_MODE;
-        i810Reg->BitBLTControl = COLEXP_24BPP;
-        break;
-    default:
-        break;
-    }
-
-    i810Reg->PixelPipeCfg0 = DAC_8_BIT;
-
-    /* Do not delay CRT Blank: needed for video overlay */
-    i810Reg->PixelPipeCfg1 |= 0x10;
-
-    /* Turn on Extended VGA Interpretation */
-    i810Reg->IOControl = EXTENDED_CRTC_CNTL;
-
-    /* Turn on linear and page mapping */
-    i810Reg->AddressMapping = (LINEAR_MODE_ENABLE | 
-                               GTT_MEM_MAP_ENABLE);
-
-    /* Turn on GUI mode */
-    i810Reg->DisplayControl = HIRES_MODE;
-
-    i810Reg->OverlayActiveStart = t->horizontal + t->hblank - 32;
-    i810Reg->OverlayActiveEnd = t->horizontal  - 32;
-
-    /* Turn on interlaced mode if necessary (it's not) */
-    i810Reg->InterlaceControl = INTERLACE_DISABLE;
-
-    /*
-     * Set the overscan color to 0.
-     * NOTE: This only affects >8bpp mode.
-     */
-    pVga->Attribute[0x11] = 0;
-
-    /*
-     * Calculate the VCLK that most closely matches the requested dot
-     * clock.
-     */
-    i810CalcVCLK(screen, dclk);
-
-    /* Since we program the clocks ourselves, always use VCLK2. */
-    pVga->MiscOutReg |= 0x0C;
-
-    /* Calculate the FIFO Watermark and Burst Length. */
-    i810Reg->LMI_FIFO_Watermark = i810CalcWatermark(screen, dclk, FALSE);
-    
-    /* Setup the ring buffer */
-    i810Reg->LprbTail = 0;
-    i810Reg->LprbHead = 0;
-    i810Reg->LprbStart = i810c->LpRing.mem.Start;
-
-    if (i810Reg->LprbStart) 
-        i810Reg->LprbLen = ((i810c->LpRing.mem.Size-4096) |
-                            RING_NO_REPORT | RING_VALID);
-    else
-        i810Reg->LprbLen = RING_INVALID;
-
-    return TRUE;
-}
-
-static Bool
-i810ModeInit(KdScreenInfo *screen, const KdMonitorTiming *t)
-{
-
-    KdCardInfo	    *card = screen->card;
-    I810CardInfo    *i810c = card->driver;
-    i810VGAPtr      vgap = &i810c->vga;
-    vgaRegPtr pVga;
-
-/*     fprintf(stderr,"i810ModeInit\n"); */
-    
-    i810VGAUnlock(vgap);
-
-    if (!i810VGAInit(screen, t)) return FALSE;
-    pVga = &vgap->ModeReg;
-
-    if (!i810SetMode(screen, t)) return FALSE;
-
-    DoRestore(screen->card, &vgap->ModeReg, &i810c->ModeReg, FALSE);
-
-    return TRUE;
-}
-
-Bool
-i810VGAInit(KdScreenInfo *screen, const KdMonitorTiming *t)
-{
-    unsigned int       i;
-
-    int hactive, hblank, hbp, hfp;
-    int vactive, vblank, vbp, vfp;
-    int h_screen_off = 0, h_adjust = 0, h_total, h_display_end, h_blank_start;
-    int h_blank_end, h_sync_start, h_sync_end, v_total, v_retrace_start;
-    int v_retrace_end, v_display_end, v_blank_start, v_blank_end;
-
-    KdCardInfo	    *card = screen->card;
-    I810CardInfo    *i810c = card->driver;
-
-    i810VGAPtr      vgap = &i810c->vga;
-    I810RegPtr ireg = &i810c->ModeReg;
-    
-
-    vgaRegPtr regp;
-    int depth = screen->fb[0].depth;
-
-    regp = &vgap->ModeReg;
-    
-    /*
-     * compute correct Hsync & Vsync polarity 
-     */
-
-    regp->MiscOutReg = 0x23;
-    if (t->vpol == KdSyncNegative) regp->MiscOutReg |= 0x40;
-    if (t->hpol == KdSyncNegative) regp->MiscOutReg |= 0x80;
-
-    /*
-     * Time Sequencer
-     */
-    if (depth == 4)
-        regp->Sequencer[0] = 0x02;
-    else
-        regp->Sequencer[0] = 0x00;
-    /* No support for 320 or 360 x resolution */
-    regp->Sequencer[1] = 0x01;
-
-    if (depth == 1)
-        regp->Sequencer[2] = 1 << BIT_PLANE;
-    else
-        regp->Sequencer[2] = 0x0F;
-
-    regp->Sequencer[3] = 0x00;                             /* Font select */
-
-    if (depth < 8)
-        regp->Sequencer[4] = 0x06;                             /* Misc */
-    else
-        regp->Sequencer[4] = 0x0E;                             /* Misc */
-
-    hactive = t->horizontal;
-    hblank = t->hblank;
-    hbp = t->hbp;
-    hfp = t->hfp;
-    
-    vactive = t->vertical;
-    vblank = t->vblank;
-    vbp = t->vbp;
-    vfp = t->vfp;
-        
-    switch (screen->fb[0].bitsPerPixel) {
-    case 8:
-	hactive /= 8;
-	hblank /= 8;
-	hfp /= 8;
-	hbp /= 8;
-	h_screen_off = hactive;
-	h_adjust = 1;	
-	break;
-    case 16:
-	hactive /= 8;
-	hblank /= 8;
-	hfp /= 8;
-	hbp /= 8;
-
-	h_screen_off = hactive * 2;
-	h_adjust = 1;
-	break;
-    case 24:
-	hactive /= 8;
-	hblank /= 8;
-	hfp /= 8;
-	hbp /= 8;
-	
-	h_screen_off = hactive * 3;
-	h_adjust = 1;
-	break;
-    case 32:
-	hactive /= 8;
-	hblank /= 8;
-	hfp /= 8;
-	hbp /= 8;
-	
-	h_screen_off = hactive * 4;
-	h_adjust = 1;
-	break;
-    }
-	    
-    /*
-     * Compute horizontal register values from timings
-     */
-    h_total = hactive + hblank - 5;
-    h_display_end = hactive - 1;
-    h_blank_start = h_display_end;
-    h_blank_end = h_blank_start + hblank;
-    
-    h_sync_start = hactive + hfp + h_adjust;
-    h_sync_end = h_sync_start + hblank - hbp - hfp;
-
-    /* Set CRTC regs for horizontal timings */
-    regp->CRTC[0x0] = h_total;
-    ireg->ExtHorizTotal=(h_total & 0x100) >> 8;
-    
-    regp->CRTC[0x1] = h_display_end;
-    
-    regp->CRTC[0x2] = h_blank_start;
-
-    regp->CRTC[0x3] = 0x80 | (h_blank_end & 0x1f);
-    regp->CRTC[0x5] = (h_blank_end & 0x20) << 2;
-
-    regp->CRTC[0x4] = h_sync_start;
-
-    regp->CRTC[0x5] |= h_sync_end & 0x1f;
-    
-    regp->CRTC[0x13] = h_screen_off;
-    ireg->ExtOffset = h_screen_off >> 8;
-
-    /* Compute vertical timings */
-    v_total = vactive + vblank - 2;
-    v_retrace_start = vactive + vfp - 1;
-    v_retrace_end = v_retrace_start + vblank - vbp - vfp;
-    v_display_end = vactive - 1;
-    v_blank_start = vactive - 1;
-    v_blank_end = v_blank_start + vblank /* - 1 */;
-
-    regp->CRTC[0x6] = v_total;
-    ireg->ExtVertTotal = v_total >> 8;
-   
-    regp->CRTC[0x10] = v_retrace_start;
-    ireg->ExtVertSyncStart = v_retrace_start >> 8;
-
-    regp->CRTC[0x11] = v_retrace_end;
-
-    regp->CRTC[0x12] = v_display_end;
-    ireg->ExtVertDispEnd = v_display_end >> 8;
-
-    regp->CRTC[0x15] = v_blank_start;
-    ireg->ExtVertBlankStart = v_blank_start >> 8;
-
-    regp->CRTC[0x16] = v_blank_end;
-    
-    if (depth < 8)
-	regp->CRTC[23] = 0xE3;
-    else
-	regp->CRTC[23] = 0xC3;
-    regp->CRTC[24] = 0xFF;
-
-    /*
-     * Graphics Display Controller
-     */
-    regp->Graphics[0] = 0x00;
-    regp->Graphics[1] = 0x00;
-    regp->Graphics[2] = 0x00;
-    regp->Graphics[3] = 0x00;
-    if (depth == 1) {
-        regp->Graphics[4] = BIT_PLANE;
-        regp->Graphics[5] = 0x00;
-    } else {
-        regp->Graphics[4] = 0x00;
-        if (depth == 4)
-            regp->Graphics[5] = 0x02;
-        else
-            regp->Graphics[5] = 0x40;
-    }
-    regp->Graphics[6] = 0x05;
-    regp->Graphics[7] = 0x0F;
-    regp->Graphics[8] = 0xFF;
-  
-    if (depth == 1) {
-        /* Initialise the Mono map according to which bit-plane gets used */
-
-        Bool flipPixels = FALSE; /* maybe support this in the future? */
-
-        for (i=0; i<16; i++)
-            if (((i & (1 << BIT_PLANE)) != 0) != flipPixels)
-                regp->Attribute[i] = WHITE_VALUE;
-            else
-                regp->Attribute[i] = BLACK_VALUE;
-
-        regp->Attribute[16] = 0x01;  /* -VGA2- */
-	if (!vgap->ShowOverscan)
-            regp->Attribute[OVERSCAN] = OVERSCAN_VALUE;  /* -VGA2- */
-    } else {
-        regp->Attribute[0]  = 0x00; /* standard colormap translation */
-        regp->Attribute[1]  = 0x01;
-        regp->Attribute[2]  = 0x02;
-        regp->Attribute[3]  = 0x03;
-        regp->Attribute[4]  = 0x04;
-        regp->Attribute[5]  = 0x05;
-        regp->Attribute[6]  = 0x06;
-        regp->Attribute[7]  = 0x07;
-        regp->Attribute[8]  = 0x08;
-        regp->Attribute[9]  = 0x09;
-        regp->Attribute[10] = 0x0A;
-        regp->Attribute[11] = 0x0B;
-        regp->Attribute[12] = 0x0C;
-        regp->Attribute[13] = 0x0D;
-        regp->Attribute[14] = 0x0E;
-        regp->Attribute[15] = 0x0F;
-        if (depth == 4)
-            regp->Attribute[16] = 0x81;
-        else
-            regp->Attribute[16] = 0x41;
-        /* Attribute[17] (overscan) was initialised earlier */
-    }
-    regp->Attribute[18] = 0x0F;
-    regp->Attribute[19] = 0x00;
-    regp->Attribute[20] = 0x00;
-
-    return(TRUE);
-}
-
-void
-i810VGALock(i810VGAPtr vgap)
-{
-    /* Protect CRTC[0-7] */
-    mmioWriteCrtc(vgap, 0x11, mmioReadCrtc(vgap, 0x11) & ~0x80);
-}
-
-void
-i810VGAUnlock(i810VGAPtr vgap)
-{
-    /* Unprotect CRTC[0-7] */
-    mmioWriteCrtc(vgap, 0x11, mmioReadCrtc(vgap, 0x11) | 0x80);
-}
-
-static void
-i810Restore(KdCardInfo *card) {
-
-    I810CardInfo    *i810c = card->driver;
-
-    i810VGAPtr      vgap = &i810c->vga;
-
-    if (I810_DEBUG)
-        fprintf(stderr,"i810Restore\n");
-
-    DoRestore(card, &vgap->SavedReg, &i810c->SavedReg, TRUE);
-}
-
-static Bool
-i810Enable (ScreenPtr pScreen)
-{
-    KdScreenPriv(pScreen);
-    KdScreenInfo    *screen = pScreenPriv->screen;
-    KdCardInfo	    *card = pScreenPriv->card;
-    I810CardInfo    *i810c = card->driver;
-    i810VGAPtr vgap = &i810c->vga;
-    const KdMonitorTiming *t;
-
-    if (I810_DEBUG)
-        fprintf(stderr,"i810Enable\n");
-
-    vgap->IOBase = (mmioReadMiscOut(vgap) & 0x01) ?
-        VGA_IOBASE_COLOR : VGA_IOBASE_MONO;
-    
-    {
-        I810RegPtr i810Reg = &i810c->ModeReg;
-        int i;
-	
-        for (i = 0 ; i < 8 ; i++)
-            i810Reg->Fence[i] = 0;
-    }
-
-    t = KdFindMode (screen, i810ModeSupported);
-    
-    if (!i810BindGARTMemory(screen))
-        return FALSE;
-
-    if (!i810ModeInit(screen, t)) return FALSE;
-
-    {
-        /* DPMS power on state */
-
-        unsigned char SEQ01=0;
-        int DPMSSyncSelect=0;
-
-        SEQ01 = 0x00;
-        DPMSSyncSelect = HSYNC_ON | VSYNC_ON;
-
-        SEQ01 |= i810ReadControlMMIO(i810c, SRX, 0x01) & ~0x20;
-        i810WriteControlMMIO(i810c, SRX, 0x01, SEQ01);
-
-        /* Set the DPMS mode */
-        OUTREG8(DPMS_SYNC_SELECT, DPMSSyncSelect);
-    }
-#ifdef XV
-    KdXVEnable (pScreen);
-#endif
-    return TRUE;
-}
-
-
-static void
-i810Disable(ScreenPtr pScreen) {
-
-    KdScreenPriv(pScreen);
-    KdScreenInfo    *screen = pScreenPriv->screen;
-    KdCardInfo	    *card = pScreenPriv->card;
-    I810CardInfo    *i810c = card->driver;
-
-    i810VGAPtr      vgap = &i810c->vga;
-
-    if (I810_DEBUG)
-        fprintf(stderr,"i810Disable\n");
-
-#ifdef XV
-    KdXVDisable (pScreen);
-#endif
-    i810Restore(screen->card);
-
-    if (!i810UnbindGARTMemory(screen))
-        return;
-
-    i810VGALock(vgap);
-}
-
-
-static Bool
-i810DPMS(ScreenPtr pScreen, int mode) 
-{
-    KdScreenPriv(pScreen);
-    KdCardInfo	    *card = pScreenPriv->card;
-    I810CardInfo    *i810c = card->driver;
-
-   unsigned char SEQ01=0;
-   int DPMSSyncSelect=0;
-
-   if (I810_DEBUG)
-       fprintf(stderr,"i810DPMS: %d\n",mode);
-
-   switch (mode) {
-   case KD_DPMS_NORMAL:
-      /* Screen: On; HSync: On, VSync: On */
-      SEQ01 = 0x00;
-      DPMSSyncSelect = HSYNC_ON | VSYNC_ON;
-      break;
-   case KD_DPMS_STANDBY:
-      /* Screen: Off; HSync: Off, VSync: On */
-      SEQ01 = 0x20;
-      DPMSSyncSelect = HSYNC_OFF | VSYNC_ON;
-      break;
-   case KD_DPMS_SUSPEND:
-      /* Screen: Off; HSync: On, VSync: Off */
-      SEQ01 = 0x20;
-      DPMSSyncSelect = HSYNC_ON | VSYNC_OFF;
-      break;
-   case KD_DPMS_POWERDOWN:
-      /* Screen: Off; HSync: Off, VSync: Off */
-      SEQ01 = 0x20;
-      DPMSSyncSelect = HSYNC_OFF | VSYNC_OFF;
-      break;
-   }
-
-   /* Turn the screen on/off */
-   SEQ01 |= i810ReadControlMMIO(i810c, SRX, 0x01) & ~0x20;
-   i810WriteControlMMIO(i810c, SRX, 0x01, SEQ01);
-
-   /* Set the DPMS mode */
-   OUTREG8(DPMS_SYNC_SELECT, DPMSSyncSelect);
-   return TRUE;
-}
-
-
-static void
-i810GetColors (ScreenPtr pScreen, int fb, int ndefs, xColorItem *c)
-{
-
-    if (I810_DEBUG)
-        fprintf(stderr,"i810GetColors (NOT IMPLEMENTED)\n");
-}
-
-#define DACDelay(hw)							     \
-	do {								     \
-	    unsigned char temp = Vminb((hw)->IOBase + VGA_IN_STAT_1_OFFSET);   \
-	    temp = Vminb((hw)->IOBase + VGA_IN_STAT_1_OFFSET);		     \
-	} while (0)
-
-static void
-i810PutColors (ScreenPtr pScreen, int fb, int ndef, xColorItem *pdefs)
-{
-
-    KdScreenPriv(pScreen);
-    KdScreenInfo    *screen = pScreenPriv->screen;
-    KdCardInfo	    *card = screen->card;
-    I810CardInfo    *i810c = (I810CardInfo *) card->driver;
-
-    i810VGAPtr vgap = &i810c->vga;
-
-    if (I810_DEBUG)
-        fprintf(stderr,"i810PutColors\n");
-
-    while (ndef--)
-    {
-        mmioWriteDacWriteAddr(vgap, pdefs->pixel);
-	DACDelay(vgap);
-	mmioWriteDacData(vgap, pdefs->red);
-	DACDelay(vgap);
-	mmioWriteDacData(vgap, pdefs->green);
-	DACDelay(vgap);
-	mmioWriteDacData(vgap, pdefs->blue);
-	DACDelay(vgap);
-
-	pdefs++;
-    }
-}
-
-
-KdCardFuncs	i810Funcs = {
-    i810CardInit,               /* cardinit */
-    i810ScreenInit,             /* scrinit */
-    i810InitScreen,             /* initScreen */
-    i810FinishInitScreen,       /* finishInitScreen */
-    NULL,			/* createResources */
-    i810Preserve,               /* preserve */
-    i810Enable,                 /* enable */
-    i810DPMS,                   /* dpms */
-    i810Disable,                /* disable */
-    i810Restore,                /* restore */
-    i810ScreenFini,             /* scrfini */
-    i810CardFini,               /* cardfini */
-    
-    i810CursorInit,             /* initCursor */
-    i810CursorEnable,           /* enableCursor */
-    i810CursorDisable,          /* disableCursor */
-    i810CursorFini,             /* finiCursor */
-    NULL,                       /* recolorCursor */
-
-    i810InitAccel,              /* initAccel */
-    i810EnableAccel,            /* enableAccel */
-    i810DisableAccel,           /* disableAccel */
-    i810FiniAccel,              /* finiAccel */
-    
-    i810GetColors,    	    /* getColors */
-    i810PutColors,	    /* putColors */
-};
diff --git a/hw/kdrive/i810/i810.h b/hw/kdrive/i810/i810.h
deleted file mode 100644
index 8fc2d56..0000000
--- a/hw/kdrive/i810/i810.h
+++ /dev/null
@@ -1,511 +0,0 @@
-/* COPYRIGHT AND PERMISSION NOTICE
-
-Copyright (c) 2000, 2001 Nokia Home Communications
-
-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, and/or sell copies of the Software, and to permit persons
-to whom the Software is furnished to do so, provided that the above
-copyright notice(s) and this permission notice appear in all copies of
-the Software and that both the above copyright notice(s) and this
-permission notice appear in supporting documentation.
-
-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
-OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
-HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
-SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
-RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
-CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
-CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
-Except as contained in this notice, the name of a copyright holder
-shall not be used in advertising or otherwise to promote the sale, use
-or other dealings in this Software without prior written authorization
-of the copyright holder.
-
-X Window System is a trademark of The Open Group */
-
-/*
- * Author:
- *   Pontus Lidman <pontus.lidman at nokia.com>
- */
-
-#ifndef _I810_H_
-#define _I810_H_
-
-#include "i810_reg.h"
-
-/* Globals */
-
-typedef struct _I810Rec *I810Ptr;
-
-/* Linear region allocated in framebuffer.
- */
-typedef struct {
-   unsigned long Start;
-   unsigned long End;
-   unsigned long Size;
-} I810MemRange;
-
-typedef struct {
-   int tail_mask;
-   I810MemRange mem;
-   unsigned char *virtual_start;
-   int head;
-   int tail;
-   int space;
-} I810RingBuffer;
-
-typedef struct {
-   unsigned char DisplayControl;
-   unsigned char PixelPipeCfg0;
-   unsigned char PixelPipeCfg1;
-   unsigned char PixelPipeCfg2;
-   unsigned short VideoClk2_M;
-   unsigned short VideoClk2_N;
-   unsigned char VideoClk2_DivisorSel;
-   unsigned char AddressMapping;
-   unsigned char IOControl;
-   unsigned char BitBLTControl;
-   unsigned char ExtVertTotal;
-   unsigned char ExtVertDispEnd;
-   unsigned char ExtVertSyncStart;
-   unsigned char ExtVertBlankStart;
-   unsigned char ExtHorizTotal;
-   unsigned char ExtHorizBlank;
-   unsigned char ExtOffset;
-   unsigned char InterlaceControl;
-   unsigned int  LMI_FIFO_Watermark;
-
-   unsigned int  LprbTail;
-   unsigned int  LprbHead;
-   unsigned int  LprbStart;
-   unsigned int  LprbLen;
-
-   unsigned int Fence[8];
-
-   unsigned short OverlayActiveStart;
-   unsigned short OverlayActiveEnd;
-
-
-} I810RegRec, *I810RegPtr;
-
-#define minb(p) *(volatile CARD8 *)(i810c->MMIOBase + (p))
-#define moutb(p,v) *(volatile CARD8 *)(i810c->MMIOBase + (p)) = (v)
-
-#define OUT_RING(n) {					\
-   if (I810_DEBUG & DEBUG_VERBOSE_RING)			\
-      ErrorF( "OUT_RING %x: %x\n", outring, n);	\
-   *(volatile unsigned int *)(virt + outring) = n;	\
-   outring += 4;					\
-   outring &= ringmask;					\
-}
-
-#define ADVANCE_LP_RING() {					\
-    i810c->LpRing.tail = outring;					\
-    OUTREG(LP_RING + RING_TAIL, outring);	\
-}
-
-#ifdef __GNUC__
-#define LP_RING_MESSAGE(n) \
-   ErrorF("BEGIN_LP_RING %d in %s\n", n, __FUNCTION__)
-#else
-#define LP_RING_MESSAGE(n) \
-   ErrorF("BEGIN_LP_RING %d in %s:%d\n", n, __FILE__, __LINE__)
-#endif
-
-#define LP_RING_LOCALS \
-    unsigned int outring, ringmask;					\
-    volatile unsigned char *virt
-
-#define BEGIN_LP_RING(n)						\
-    if (n>2 && (I810_DEBUG&DEBUG_ALWAYS_SYNC))				\
-	i810Sync(i810s);	\
-    if (i810c->LpRing.space < n*4) i810WaitLpRing(i810s, n*4, 0);	\
-    i810c->LpRing.space -= n*4;						\
-    if (I810_DEBUG & DEBUG_VERBOSE_RING) 				\
-	LP_RING_MESSAGE(n);						\
-    outring = i810c->LpRing.tail;					\
-    ringmask = i810c->LpRing.tail_mask;					\
-    virt = i810c->LpRing.virtual_start;			
-
-/* Memory mapped register access macros */
-#define INREG8(addr)        *(volatile CARD8  *)(i810c->MMIOBase + (addr))
-#define INREG16(addr)       *(volatile CARD16 *)(i810c->MMIOBase + (addr))
-#define INREG(addr)         *(volatile CARD32 *)(i810c->MMIOBase + (addr))
-
-#define OUTREG8(addr, val) do {				\
-   *(volatile CARD8 *)(i810c->MMIOBase  + (addr)) = (val);	\
-   if (I810_DEBUG&DEBUG_VERBOSE_OUTREG)			\
-     ErrorF( "OUTREG8(%x, %x)\n", addr, val);	\
-} while (0)
-
-#define OUTREG16(addr, val) do {			\
-   *(volatile CARD16 *)(i810c->MMIOBase + (addr)) = (val);	\
-   if (I810_DEBUG&DEBUG_VERBOSE_OUTREG)			\
-     ErrorF( "OUTREG16(%x, %x)\n", addr, val);	\
-} while (0)
-
-#define OUTREG(addr, val) do {				\
-   *(volatile CARD32 *)(i810c->MMIOBase + (addr)) = (val);	\
-   if (I810_DEBUG&DEBUG_VERBOSE_OUTREG)			\
-     ErrorF( "OUTREG(%x, %x)\n", addr, val);	\
-} while (0)
-
-/* To remove all debugging, make sure I810_DEBUG is defined as a
- * preprocessor symbol, and equal to zero.  
- */
-
-#define I810_DEBUG 0
-
-#ifndef I810_DEBUG
-#warning "Debugging enabled - expect reduced performance"
-extern int I810_DEBUG;
-#endif
-
-#define DEBUG_VERBOSE_ACCEL  0x1
-#define DEBUG_VERBOSE_SYNC   0x2
-#define DEBUG_VERBOSE_VGA    0x4
-#define DEBUG_VERBOSE_RING   0x8
-#define DEBUG_VERBOSE_OUTREG 0x10
-#define DEBUG_VERBOSE_MEMORY 0x20
-#define DEBUG_VERBOSE_CURSOR 0x40
-#define DEBUG_ALWAYS_SYNC    0x80
-#define DEBUG_VERBOSE_DRI    0x100
-
-
-/* Size of the mmio region.
- */
-#define I810_REG_SIZE 0x80000
-
-/* PCI identifiers */
-#ifndef PCI_CHIP_I810
-#define PCI_CHIP_I810              0x7121
-#define PCI_CHIP_I810_DC100        0x7123
-#define PCI_CHIP_I810_E            0x7125 
-#define PCI_CHIP_I815              0x1132 
-#define PCI_CHIP_I810_BRIDGE       0x7120
-#define PCI_CHIP_I810_DC100_BRIDGE 0x7122
-#define PCI_CHIP_I810_E_BRIDGE     0x7124
-#define PCI_CHIP_I815_BRIDGE       0x1130
-#define PCI_CHIP_I845G             0x2562
-#endif
-
-
-#define IS_I810(i810c) (i810c->PciInfo->chipType == PCI_CHIP_I810 ||	\
-			i810c->PciInfo->chipType == PCI_CHIP_I810_DC100 || \
-			i810c->PciInfo->chipType == PCI_CHIP_I810_E)
-#define IS_I815(i810c) (i810c->PciInfo->chipType == PCI_CHIP_I815)
-
-
-/* default number of VGA registers stored internally */
-#define VGA_NUM_CRTC 25 /* 0x19 */
-#define VGA_NUM_SEQ 5
-#define VGA_NUM_GFX 9
-#define VGA_NUM_ATTR 21
-
-/*
- * Settings of standard VGA registers.
- */
-typedef struct {
-    unsigned char MiscOutReg;     /* */
-    unsigned char CRTC[VGA_NUM_CRTC];       /* Crtc Controller */
-    unsigned char Sequencer[VGA_NUM_SEQ];   /* Video Sequencer */
-    unsigned char Graphics[VGA_NUM_GFX];    /* Video Graphics */
-    unsigned char Attribute[VGA_NUM_ATTR];  /* Video Atribute */
-    unsigned char DAC[768];       /* Internal Colorlookuptable */
-} vgaRegRec, *vgaRegPtr;
-
-
-typedef struct _i810VGARec *i810VGAPtr;
-
-/* VGA registers */
-typedef struct _i810VGARec {
-    int				IOBase;		/* I/O Base address */
-    CARD8 * 			MMIOBase;	/* Pointer to MMIO start */
-    vgaRegRec			SavedReg;	/* saved registers */
-    vgaRegRec			ModeReg;	/* register settings for
-							current mode */
-    Bool			ShowOverscan;
-    Bool			paletteEnabled;
-    Bool			cmapSaved;
-} i810VGARec;
-
-typedef struct _i810CardInfo {
-    int videoRam;
-    int MaxClock;    
-    long FbMapSize;
-    int cpp;                    /* chars per pixel */
-
-    unsigned long LinearAddr;
-    unsigned long MMIOAddr;
-    
-    unsigned char *MMIOBase;
-    unsigned char *FbBase;
-
-    Bool GttBound;
-    Bool agpAcquired2d;
-    int VramKey;
-    unsigned long VramOffset;
-    int DcacheKey;
-    unsigned long DcacheOffset;
-    int HwcursKey; 
-    unsigned long HwcursOffset;
-
-    I810MemRange DcacheMem;
-    I810MemRange SysMem;
-
-    I810MemRange SavedDcacheMem;
-    I810MemRange SavedSysMem;
-
-    unsigned int bufferOffset;	/* for I810SelectBuffer */
-    Bool DoneFrontAlloc;
-    BoxRec FbMemBox;
-    I810MemRange FrontBuffer;
-    I810MemRange Scratch;
-    I810MemRange XvMem;
-
-    int  LmFreqSel;
-    
-    i810VGARec vga;
-
-    I810RegRec SavedReg;
-    I810RegRec ModeReg;
-    I810RingBuffer LpRing;
-
-    unsigned int BR[20]; 
-
-    int CursorOffset;
-    unsigned long CursorPhysical;
-    unsigned long CursorStart;
-    unsigned long OverlayPhysical;
-    unsigned long OverlayStart;
-    int colorKey;
-
-    int nextColorExpandBuf;
-
-    ScreenBlockHandlerProcPtr BlockHandler;
-
-#ifdef XV
-    KdVideoAdaptorPtr adaptor;
-#endif
-
-} i810CardInfo;
-
-typedef struct _i810CardInfo I810CardInfo;	/* compatibility */
-
-#define getI810CardInfo(kd)	((I810CardInfo *) ((kd)->card->driver))
-#define i810CardInfo(kd)	I810CardInfo *i810c = getI810CardInfo(kd)
-
-#define getI810ScreenInfo(kd)	((I810ScreenInfo *) ((kd)->screen->driver))
-#define i810ScreenInfo(kd)	I810ScreenInfo *i810s = getI810ScreenInfo(kd)
-
-typedef struct _i810Cursor {
-    int		width, height;
-    int		xhot, yhot;
-    Bool	has_cursor;
-    CursorPtr	pCursor;
-} i810Cursor, *i810CursorPtr;
-
-typedef struct _i810ScreenInfo {
-    i810CardInfo *i810c;
-    i810Cursor cursor;
-
-    int pitch;
-    KaaScreenInfoRec kaa;
-} i810ScreenInfo;
-
-typedef struct _i810ScreenInfo I810ScreenInfo;	/* compatibility */
-
-#define I810_CURSOR_HEIGHT 64
-#define I810_CURSOR_WIDTH 64
-
-/* init functions (i810.c) */
-
-Bool 
-i810CardInit (KdCardInfo *card);
-
-Bool 
-i810ScreenInit (KdScreenInfo *screen);
-
-/* The cursor functions (i810_cursor.c) */
-
-Bool
-i810CursorInit(ScreenPtr pScreen);
-
-void
-i810CursorEnable (ScreenPtr pScreen);
-
-void
-i810CursorDisable (ScreenPtr pScreen);
-
-void
-i810CursorFini (ScreenPtr pScreen);
-
-/* Accel functions (i810draw.c) */
-
-Bool        
-i810InitAccel(ScreenPtr);
-
-void        
-i810EnableAccel (ScreenPtr);
-
-void        
-i810DisableAccel (ScreenPtr);
-
-void        
-i810FiniAccel (ScreenPtr);
-
-void
-i810FillBoxSolid (KdScreenInfo *screen, int nBox, BoxPtr pBox, 
-                  unsigned long pixel, int alu, unsigned long planemask);
-
-
-extern KdCardFuncs  i810Funcs;
-
-/* Standard VGA registers */
-
-#define VGA_ATTR_INDEX		0x3C0
-#define VGA_ATTR_DATA_W		0x3C0
-#define VGA_ATTR_DATA_R		0x3C1
-#define VGA_IN_STAT_0		0x3C2		/* read */
-#define VGA_MISC_OUT_W		0x3C2		/* write */
-#define VGA_ENABLE		0x3C3
-#define VGA_SEQ_INDEX		0x3C4
-#define VGA_SEQ_DATA		0x3C5
-#define VGA_DAC_MASK		0x3C6
-#define VGA_DAC_READ_ADDR	0x3C7
-#define VGA_DAC_WRITE_ADDR	0x3C8
-#define VGA_DAC_DATA		0x3C9
-#define VGA_FEATURE_R		0x3CA		/* read */
-#define VGA_MISC_OUT_R		0x3CC		/* read */
-#define VGA_GRAPH_INDEX		0x3CE
-#define VGA_GRAPH_DATA		0x3CF
-
-#define VGA_IOBASE_MONO		0x3B0
-#define VGA_IOBASE_COLOR	0x3D0
-
-#define VGA_CRTC_INDEX_OFFSET	0x04
-#define VGA_CRTC_DATA_OFFSET	0x05
-#define VGA_IN_STAT_1_OFFSET	0x0A		/* read */
-#define VGA_FEATURE_W_OFFSET	0x0A		/* write */
-
-/* VGA stuff */
-#define BIT_PLANE 3		/* Which plane we write to in mono mode */
-
-/* DAC indices for white and black */
-#define WHITE_VALUE 0x3F
-#define BLACK_VALUE 0x00
-#define OVERSCAN_VALUE 0x01
-
-#define OVERSCAN 0x11		/* Index of OverScan register */
-
-void 
-i810VGAUnlock(i810VGAPtr vgap);
-
-void 
-i810VGALock(i810VGAPtr vgap);
-
-Bool 
-i810VGAInit(KdScreenInfo *scrninfp, const KdMonitorTiming *t);
-
-void
-i810VGABlankScreen(KdCardInfo *card, Bool on);
-
-void
-i810AdjustFrame(KdScreenInfo *screen, int x, int y, int flags);
-
-Bool
-i810VGAMapMem(KdCardInfo *card);
-
-void
-i810VGASave(KdCardInfo *card, vgaRegPtr save, int flags);
-
-void 
-i810PrintErrorState(i810CardInfo *i810c);
-
-void
-i810VGAGetIOBase(i810VGAPtr vgap);
-
-Bool
-i810InitVideo(ScreenPtr pScreen);
-
-/*
- * MMIO versions of the register access functions.  These require
- * hwp->MemBase to be set in such a way that when the standard VGA port
- * address is added the correct memory address results.
- */
-
-#define Vminb(p) ( *(volatile CARD8 *)(vgap->MMIOBase + (p)))
-#define Vmoutb(p,v) ( *(volatile CARD8 *)(vgap->MMIOBase + (p)) = (v))
-
-#define mmioWriteCrtc(vgap, index, value) { \
-    Vmoutb(vgap->IOBase + VGA_CRTC_INDEX_OFFSET, index); \
-    Vmoutb(vgap->IOBase + VGA_CRTC_DATA_OFFSET, value); \
-}
-
-#define mmioReadCrtc(vgap, index) ( \
-    Vmoutb(vgap->IOBase + VGA_CRTC_INDEX_OFFSET, index), \
-    Vminb(vgap->IOBase + VGA_CRTC_DATA_OFFSET) \
-)
-
-#define mmioWriteGr(vgap, index, value) { \
-    Vmoutb(VGA_GRAPH_INDEX, index); \
-    Vmoutb(VGA_GRAPH_DATA, value); \
-}
-
-#define mmioReadGr(vgap, index) ( \
-    Vmoutb(VGA_GRAPH_INDEX, index), \
-    Vminb(VGA_GRAPH_DATA) \
-)
-
-#define mmioWriteSeq(vgap, index, value) {\
-    Vmoutb(VGA_SEQ_INDEX, index); \
-    Vmoutb(VGA_SEQ_DATA, value); \
-}
-
-#define mmioReadSeq(vgap, index) ( \
-    Vmoutb(VGA_SEQ_INDEX, index), \
-    Vminb(VGA_SEQ_DATA) \
-)
-
-#define mmioWriteAttr(vgap, index, value) { \
-    (void) Vminb(vgap->IOBase + VGA_IN_STAT_1_OFFSET); \
-    Vmoutb(VGA_ATTR_INDEX, index); \
-    Vmoutb(VGA_ATTR_DATA_W, value); \
-}
-
-#define mmioReadAttr(vgap, index) ( \
-    (void) Vminb(vgap->IOBase + VGA_IN_STAT_1_OFFSET), \
-    Vmoutb(VGA_ATTR_INDEX, index), \
-    Vminb(VGA_ATTR_DATA_R) \
-)
-
-#define mmioWriteMiscOut(vgap, value) Vmoutb(VGA_MISC_OUT_W, value)
-
-
-#define mmioReadMiscOut(vgap) Vminb(VGA_MISC_OUT_R)
-
-#define mmioEnablePalette(vgap) { \
-    (void) Vminb(vgap->IOBase + VGA_IN_STAT_1_OFFSET); \
-    Vmoutb(VGA_ATTR_INDEX, 0x00); \
-    vgap->paletteEnabled = TRUE; \
-}
-
-#define mmioDisablePalette(vgap) { \
-    (void) Vminb(vgap->IOBase + VGA_IN_STAT_1_OFFSET); \
-    Vmoutb(VGA_ATTR_INDEX, 0x20); \
-    vgap->paletteEnabled = FALSE; \
-}
-
-#define mmioWriteDacWriteAddr(vgap, value) Vmoutb(VGA_DAC_WRITE_ADDR, value)
-
-#define mmioWriteDacData(vgap, value) Vmoutb(VGA_DAC_DATA, value)
-
-#endif /* _I810_H_ */
diff --git a/hw/kdrive/i810/i810_cursor.c b/hw/kdrive/i810/i810_cursor.c
deleted file mode 100644
index 434fc40..0000000
--- a/hw/kdrive/i810/i810_cursor.c
+++ /dev/null
@@ -1,435 +0,0 @@
-/* COPYRIGHT AND PERMISSION NOTICE
-
-Copyright (c) 2000, 2001 Nokia Home Communications
-
-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, and/or sell copies of the Software, and to permit persons
-to whom the Software is furnished to do so, provided that the above
-copyright notice(s) and this permission notice appear in all copies of
-the Software and that both the above copyright notice(s) and this
-permission notice appear in supporting documentation.
-
-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
-OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
-HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
-SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
-RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
-CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
-CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
-Except as contained in this notice, the name of a copyright holder
-shall not be used in advertising or otherwise to promote the sale, use
-or other dealings in this Software without prior written authorization
-of the copyright holder.
-
-X Window System is a trademark of The Open Group */
-
-/**************************************************************************
-
-Copyright 1998-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, 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 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.
-
-**************************************************************************/
-
-/* i810_cursor.c: KDrive hardware cursor routines for the i810 chipset */
-
-/*
- * Authors:
- *   Keith Whitwell <keith at tungstengraphics.com>
- *   Pontus Lidman <pontus.lidman at nokia.com>
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <kdrive-config.h>
-#endif
-#include "kdrive.h"
-#include "kxv.h"
-#include "i810.h"
-#include "cursorstr.h"
-
-#define SetupCursor(s)	    KdScreenPriv(pScreen); \
-			    i810CardInfo(pScreenPriv); \
-			    i810ScreenInfo(pScreenPriv); \
-			    i810Cursor *pCurPriv = &i810s->cursor
-
-
-static void
-writeStandardMMIO(I810CardInfo *i810c, int addr, CARD8 val)
-{
-  moutb(addr, val);
-}
-
-static void
-_i810MoveCursor(ScreenPtr pScreen, int x, int y)
-{
-    KdScreenPriv(pScreen);
-    i810CardInfo(pScreenPriv);
-    int flag;
-
-    if (I810_DEBUG & DEBUG_VERBOSE_CURSOR)
-      ErrorF( "I810SetCursorPosition %d %d\n", x, y);
-
-    x += i810c->CursorOffset;
-
-    if (x >= 0) flag = CURSOR_X_POS;
-    else {
-        flag = CURSOR_X_NEG;
-        x=-x;
-    }
-
-    OUTREG8( CURSOR_X_LO, x&0xFF);
-    OUTREG8( CURSOR_X_HI, (((x >> 8) & 0x07) | flag));
-    
-    if (y >= 0) flag = CURSOR_Y_POS;
-    else {
-        flag = CURSOR_Y_NEG;
-        y=-y;
-    }
-    OUTREG8( CURSOR_Y_LO, y&0xFF);
-    OUTREG8( CURSOR_Y_HI, (((y >> 8) & 0x07) | flag));
-
-    /* Enable cursor */
-    OUTREG( CURSOR_BASEADDR, i810c->CursorPhysical);
-    OUTREG8( CURSOR_CONTROL, CURSOR_ORIGIN_DISPLAY | CURSOR_MODE_64_3C);
-
-}
-
-static void i810LoadCursor(ScreenPtr pScreen, int x, int y);
-
-static void
-i810MoveCursor (ScreenPtr pScreen, int x, int y)
-{
-    KdScreenPriv(pScreen);
-    i810ScreenInfo(pScreenPriv);
-    i810Cursor *pCurPriv = &i810s->cursor;
-    
-    if (!pCurPriv->has_cursor)
-	return;
-    
-    if (!pScreenPriv->enabled)
-	return;
-    
-    _i810MoveCursor (pScreen, x, y);
-
-    i810LoadCursor(pScreen, x, y);
-}
-
-static void
-_i810SetCursorColors(ScreenPtr pScreen)
-{
-
-    KdScreenPriv(pScreen);
-    i810CardInfo(pScreenPriv);
-    int tmp;
-
-    int bg = 0xffffff;
-    int fg = 0x000000;
-
-    tmp=INREG8(PIXPIPE_CONFIG_0);
-    tmp |= EXTENDED_PALETTE;
-    OUTREG8( PIXPIPE_CONFIG_0, tmp);
-
-    writeStandardMMIO(i810c, DACMASK, 0xFF);
-    writeStandardMMIO(i810c, DACWX, 0x04);
-
-    writeStandardMMIO(i810c, DACDATA, (bg & 0x00FF0000) >> 16);
-    writeStandardMMIO(i810c, DACDATA, (bg & 0x0000FF00) >> 8);
-    writeStandardMMIO(i810c, DACDATA, (bg & 0x000000FF));
-
-    writeStandardMMIO(i810c, DACDATA, (fg & 0x00FF0000) >> 16);
-    writeStandardMMIO(i810c, DACDATA, (fg & 0x0000FF00) >> 8);
-    writeStandardMMIO(i810c, DACDATA, (fg & 0x000000FF));
-
-    tmp=INREG8( PIXPIPE_CONFIG_0 );
-    tmp &= ~EXTENDED_PALETTE;
-    OUTREG8( PIXPIPE_CONFIG_0, tmp );
-}
-
-#define InvertBits32(v) { \
-    v = ((v & 0x55555555) << 1) | ((v >> 1) & 0x55555555); \
-    v = ((v & 0x33333333) << 2) | ((v >> 2) & 0x33333333); \
-    v = ((v & 0x0f0f0f0f) << 4) | ((v >> 4) & 0x0f0f0f0f); \
-}
-
-static void i810LoadCursor(ScreenPtr pScreen, int x, int y)
-{
-    SetupCursor(pScreen);
-
-    int		    h;
-    unsigned int   *msk, *mskLine, *src, *srcLine;
-    
-    int		    i, j;
-    int		    src_stride, src_width;
-
-    CursorPtr	    pCursor = pCurPriv->pCursor;
-    CursorBitsPtr   bits = pCursor->bits;
-    CARD8 tmp;
-    unsigned int *ram, *ramLine;
-
-    pCurPriv->pCursor = pCursor;
-    pCurPriv->xhot = pCursor->bits->xhot;
-    pCurPriv->yhot = pCursor->bits->yhot;
-
-    ramLine = (unsigned int *) (i810c->FbBase + i810c->CursorStart);
-    mskLine = (unsigned int *) (bits->mask);
-    srcLine = (unsigned int *) (bits->source);
-
-    h = bits->height;
-    if (h > I810_CURSOR_HEIGHT)
-	h = I810_CURSOR_HEIGHT;
-
-    src_stride = BitmapBytePad(bits->width);		/* bytes per line */
-    src_stride = (src_stride +3) >> 2;
-    src_width = (bits->width + 31) >> 5;
-
-    for (i = 0; i < I810_CURSOR_HEIGHT; i++) {
-
-	msk = mskLine;
-	src = srcLine;
-        ram = ramLine;
-	mskLine += src_stride;
-	srcLine += src_stride;
-        ramLine += I810_CURSOR_WIDTH / 16;
-
-	for (j = 0; j < I810_CURSOR_WIDTH / 32; j++) {
-
-	    unsigned long  m, s;
-
-	    if (i < h && j < src_width) 
-	    {
-		m = *msk++;
-		s = *src++ & m;
-		m = ~m;
-		/* mask off right side */
-		if (j == src_width - 1 && (bits->width & 31))
-		{
-		    m |= 0xffffffff << (bits->width & 31);
-		}
-	    }
-	    else
-	    {
-		m = 0xffffffff;
-		s = 0x00000000;
-	    }
-
-            InvertBits32(s);
-            InvertBits32(m);
-
-            ram[2+j]=s;
-            ram[0+j]=m;
-	}
-    }
-    /* Set new color */
-    _i810SetCursorColors (pScreen);
-     
-    /* Move to new position */
-    _i810MoveCursor (pScreen, x, y);
-    
-    /* Enable cursor */
-    OUTREG( CURSOR_BASEADDR, i810c->CursorPhysical);
-    OUTREG8( CURSOR_CONTROL, CURSOR_ORIGIN_DISPLAY | CURSOR_MODE_64_3C);
-    
-    tmp = INREG8( PIXPIPE_CONFIG_0 );
-    tmp |= HW_CURSOR_ENABLE;
-    OUTREG8( PIXPIPE_CONFIG_0, tmp);
-}
-
-static void
-i810UnloadCursor(ScreenPtr pScreen)
-{
-    KdScreenPriv(pScreen);
-    i810CardInfo(pScreenPriv);
-
-    unsigned char tmp;
-    
-    tmp=INREG8( PIXPIPE_CONFIG_0 );
-    tmp &= ~HW_CURSOR_ENABLE;
-    OUTREG8( PIXPIPE_CONFIG_0, tmp);
-}
-
-
-static Bool
-i810RealizeCursor (ScreenPtr pScreen, CursorPtr pCursor)
-{
-    KdScreenPriv(pScreen);
-    i810ScreenInfo(pScreenPriv);
-    i810Cursor *pCurPriv = &i810s->cursor;
-
-    if (!pScreenPriv->enabled)
-	return TRUE;
-    
-    /* miRecolorCursor does this */
-    if (pCurPriv->pCursor == pCursor)
-    {
-	if (pCursor)
-	{
-	    int	    x, y;
-	    
-	    miPointerPosition (&x, &y);
-	    i810LoadCursor (pScreen, x, y);
-	}
-    }
-    return TRUE;
-}
-
-static Bool
-i810UnrealizeCursor (ScreenPtr pScreen, CursorPtr pCursor)
-{
-    return TRUE;
-}
-
-static void
-i810SetCursor (ScreenPtr pScreen, CursorPtr pCursor, int x, int y)
-{
-    KdScreenPriv(pScreen);
-    i810ScreenInfo(pScreenPriv);
-    i810Cursor *pCurPriv = &i810s->cursor;
-
-    pCurPriv->pCursor = pCursor;
-    
-    if (!pScreenPriv->enabled)
-	return;
-    
-    if (pCursor)
-	i810LoadCursor (pScreen, x, y);
-    else
-	i810UnloadCursor (pScreen);
-}
-
-miPointerSpriteFuncRec i810PointerSpriteFuncs = {
-    i810RealizeCursor,
-    i810UnrealizeCursor,
-    i810SetCursor,
-    i810MoveCursor,
-};
-
-static void
-i810QueryBestSize (int class, 
-                   unsigned short *pwidth, unsigned short *pheight, 
-                   ScreenPtr pScreen)
-{
-    KdScreenPriv(pScreen);
-    i810ScreenInfo(pScreenPriv);
-    i810Cursor *pCurPriv = &i810s->cursor;
-
-    switch (class)
-    {
-    case CursorShape:
-	if (*pwidth > pCurPriv->width)
-	    *pwidth = pCurPriv->width;
-	if (*pheight > pCurPriv->height)
-	    *pheight = pCurPriv->height;
-	if (*pwidth > pScreen->width)
-	    *pwidth = pScreen->width;
-	if (*pheight > pScreen->height)
-	    *pheight = pScreen->height;
-	break;
-    default:
-	fbQueryBestSize (class, pwidth, pheight, pScreen);
-	break;
-    }
-}
-
-Bool
-i810CursorInit(ScreenPtr pScreen)
-{
-    KdScreenPriv(pScreen);
-    i810ScreenInfo(pScreenPriv);
-    i810CardInfo(pScreenPriv);
-    i810Cursor *pCurPriv = &i810s->cursor;
-
-    if (!i810c->CursorStart) {
-	pCurPriv->has_cursor = FALSE;
-	return FALSE;
-    }
-
-    pCurPriv->width = I810_CURSOR_WIDTH;
-    pCurPriv->height= I810_CURSOR_HEIGHT;
-    pScreen->QueryBestSize = i810QueryBestSize;
-    miPointerInitialize (pScreen,
-			 &i810PointerSpriteFuncs,
-			 &kdPointerScreenFuncs,
-			 FALSE);
-    pCurPriv->has_cursor = TRUE;
-    pCurPriv->pCursor = NULL;
-    return TRUE;
-}
-
-void
-i810CursorEnable (ScreenPtr pScreen)
-{
-    KdScreenPriv(pScreen);
-    i810ScreenInfo(pScreenPriv);
-    i810Cursor *pCurPriv = &i810s->cursor;
-
-    if (pCurPriv->has_cursor)
-    {
-	if (pCurPriv->pCursor)
-	{
-	    int	    x, y;
-	    
-	    miPointerPosition (&x, &y);
-	    i810LoadCursor (pScreen, x, y);
-	}
-	else
-	    i810UnloadCursor (pScreen);
-    }
-}
-
-void
-i810CursorDisable (ScreenPtr pScreen)
-{
-    KdScreenPriv(pScreen);
-    i810ScreenInfo(pScreenPriv);
-    i810Cursor *pCurPriv = &i810s->cursor;
-
-    if (!pScreenPriv->enabled)
-	return;
-    
-    if (pCurPriv->has_cursor)
-    {
-	if (pCurPriv->pCursor)
-	{
-	    i810UnloadCursor (pScreen);
-	}
-    }
-}
-
-void
-i810CursorFini (ScreenPtr pScreen)
-{
-    KdScreenPriv(pScreen);
-    i810ScreenInfo(pScreenPriv);
-    i810Cursor *pCurPriv = &i810s->cursor;
-
-    pCurPriv->pCursor = NULL;
-}
-
diff --git a/hw/kdrive/i810/i810_reg.h b/hw/kdrive/i810/i810_reg.h
deleted file mode 100644
index d9f4c8f..0000000
--- a/hw/kdrive/i810/i810_reg.h
+++ /dev/null
@@ -1,695 +0,0 @@
-/* COPYRIGHT AND PERMISSION NOTICE
-
-Copyright (c) 2000, 2001 Nokia Home Communications
-
-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, and/or sell copies of the Software, and to permit persons
-to whom the Software is furnished to do so, provided that the above
-copyright notice(s) and this permission notice appear in all copies of
-the Software and that both the above copyright notice(s) and this
-permission notice appear in supporting documentation.
-
-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
-OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
-HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
-SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
-RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
-CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
-CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
-Except as contained in this notice, the name of a copyright holder
-shall not be used in advertising or otherwise to promote the sale, use
-or other dealings in this Software without prior written authorization
-of the copyright holder.
-
-X Window System is a trademark of The Open Group */
-
-/**************************************************************************
-
-Copyright 1998-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, 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 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:
- *   Keith Whitwell <keith at tungstengraphics.com>
- *   Pontus Lidman <pontus.lidman at nokia.com>
- *
- *   based on the i740 driver by
- *        Kevin E. Martin <kevin at precisioninsight.com> 
- *   
- *
- */
-
-/* I/O register offsets 
- */
-#define SRX 0x3C4		/* p208 */
-#define GRX 0x3CE		/* p213 */
-#define ARX 0x3C0		/* p224 */
-
-/* VGA Color Palette Registers */
-#define DACMASK  0x3C6		/* p232 */
-#define DACSTATE 0x3C7		/* p232 */
-#define DACRX    0x3C7		/* p233 */
-#define DACWX    0x3C8		/* p233 */
-#define DACDATA  0x3C9		/* p233 */
-
-/* CRT Controller Registers (CRX) */
-#define START_ADDR_HI        0x0C /* p246 */
-#define START_ADDR_LO        0x0D /* p247 */
-#define VERT_SYNC_END        0x11 /* p249 */
-#define EXT_VERT_TOTAL       0x30 /* p257 */
-#define EXT_VERT_DISPLAY     0x31 /* p258 */
-#define EXT_VERT_SYNC_START  0x32 /* p259 */
-#define EXT_VERT_BLANK_START 0x33 /* p260 */
-#define EXT_HORIZ_TOTAL      0x35 /* p261 */
-#define EXT_HORIZ_BLANK      0x39 /* p261 */
-#define EXT_START_ADDR       0x40 /* p262 */
-#define EXT_START_ADDR_ENABLE    0x80 
-#define EXT_OFFSET           0x41 /* p263 */
-#define EXT_START_ADDR_HI    0x42 /* p263 */
-#define INTERLACE_CNTL       0x70 /* p264 */
-#define INTERLACE_ENABLE         0x80 
-#define INTERLACE_DISABLE        0x00 
-
-/* Miscellaneous Output Register 
- */
-#define MSR_R          0x3CC	/* p207 */
-#define MSR_W          0x3C2	/* p207 */
-#define IO_ADDR_SELECT     0x01
-
-#define MDA_BASE       0x3B0	/* p207 */
-#define CGA_BASE       0x3D0	/* p207 */
-
-/* CR80 - IO Control, p264
- */
-#define IO_CTNL            0x80
-#define EXTENDED_ATTR_CNTL     0x02
-#define EXTENDED_CRTC_CNTL     0x01
-
-/* GR10 - Address mapping, p221
- */
-#define ADDRESS_MAPPING    0x10
-#define PAGE_TO_LOCAL_MEM_ENABLE 0x10
-#define GTT_MEM_MAP_ENABLE     0x08
-#define PACKED_MODE_ENABLE     0x04
-#define LINEAR_MODE_ENABLE     0x02
-#define PAGE_MAPPING_ENABLE    0x01
-
-/* Blitter control, p378
- */
-#define BITBLT_CNTL        0x7000c
-#define COLEXP_MODE            0x30
-#define COLEXP_8BPP            0x00
-#define COLEXP_16BPP           0x10
-#define COLEXP_24BPP           0x20
-#define COLEXP_RESERVED        0x30
-#define BITBLT_STATUS          0x01
-
-/* p375. 
- */
-#define DISPLAY_CNTL       0x70008
-#define VGA_WRAP_MODE          0x02
-#define VGA_WRAP_AT_256KB      0x00
-#define VGA_NO_WRAP            0x02
-#define GUI_MODE               0x01
-#define STANDARD_VGA_MODE      0x00
-#define HIRES_MODE             0x01
-
-/* p375
- */
-#define PIXPIPE_CONFIG_0   0x70009
-#define DAC_8_BIT              0x80
-#define DAC_6_BIT              0x00
-#define HW_CURSOR_ENABLE       0x10
-#define EXTENDED_PALETTE       0x01
-
-/* p375
- */
-#define PIXPIPE_CONFIG_1   0x7000a
-#define DISPLAY_COLOR_MODE     0x0F
-#define DISPLAY_VGA_MODE       0x00
-#define DISPLAY_8BPP_MODE      0x02
-#define DISPLAY_15BPP_MODE     0x04
-#define DISPLAY_16BPP_MODE     0x05
-#define DISPLAY_24BPP_MODE     0x06
-#define DISPLAY_32BPP_MODE     0x07
-
-/* p375
- */
-#define PIXPIPE_CONFIG_2   0x7000b
-#define DISPLAY_GAMMA_ENABLE   0x08
-#define DISPLAY_GAMMA_DISABLE  0x00
-#define OVERLAY_GAMMA_ENABLE   0x04
-#define OVERLAY_GAMMA_DISABLE  0x00
-
-
-/* p380
- */
-#define DISPLAY_BASE       0x70020
-#define DISPLAY_BASE_MASK  0x03fffffc
-
-
-/* Cursor control registers, pp383-384
- */
-#define CURSOR_CONTROL     0x70080
-#define CURSOR_ORIGIN_SCREEN   0x00
-#define CURSOR_ORIGIN_DISPLAY  0x10
-#define CURSOR_MODE            0x07
-#define CURSOR_MODE_DISABLE    0x00
-#define CURSOR_MODE_32_4C_AX   0x01
-#define CURSOR_MODE_64_3C      0x04
-#define CURSOR_MODE_64_4C_AX   0x05
-#define CURSOR_MODE_64_4C      0x06
-#define CURSOR_MODE_RESERVED   0x07
-#define CURSOR_BASEADDR    0x70084
-#define CURSOR_BASEADDR_MASK 0x1FFFFF00
-#define CURSOR_X_LO        0x70088
-#define CURSOR_X_HI        0x70089
-#define CURSOR_X_POS           0x00
-#define CURSOR_X_NEG           0x80
-#define CURSOR_Y_LO        0x7008A
-#define CURSOR_Y_HI        0x7008B
-#define CURSOR_Y_POS           0x00
-#define CURSOR_Y_NEG           0x80
-
-
-
-/* Similar registers exist in Device 0 on the i810 (pp55-65), but I'm
- * not sure they refer to local (graphics) memory.
- *
- * These details are for the local memory control registers,
- * (pp301-310).  The test machines are not equiped with local memory,
- * so nothing is tested.  Only a single row seems to be supported.
- */
-#define DRAM_ROW_TYPE      0x3000
-#define DRAM_ROW_0             0x01
-#define DRAM_ROW_0_SDRAM       0x01
-#define DRAM_ROW_0_EMPTY       0x00
-#define DRAM_ROW_CNTL_LO   0x3001
-#define DRAM_PAGE_MODE_CTRL    0x10
-#define DRAM_RAS_TO_CAS_OVRIDE 0x08
-#define DRAM_CAS_LATENCY       0x04
-#define DRAM_RAS_TIMING        0x02
-#define DRAM_RAS_PRECHARGE     0x01
-#define DRAM_ROW_CNTL_HI   0x3002
-#define DRAM_REFRESH_RATE      0x18
-#define DRAM_REFRESH_DISABLE   0x00
-#define DRAM_REFRESH_60HZ      0x08
-#define DRAM_REFRESH_FAST_TEST 0x10
-#define DRAM_REFRESH_RESERVED  0x18
-#define DRAM_SMS               0x07
-#define DRAM_SMS_NORMAL        0x00
-#define DRAM_SMS_NOP_ENABLE    0x01
-#define DRAM_SMS_ABPCE         0x02
-#define DRAM_SMS_MRCE          0x03
-#define DRAM_SMS_CBRCE         0x04
-
-/* p307
- */
-#define DPMS_SYNC_SELECT   0x5002
-#define VSYNC_CNTL             0x08
-#define VSYNC_ON               0x00
-#define VSYNC_OFF              0x08
-#define HSYNC_CNTL             0x02
-#define HSYNC_ON               0x00
-#define HSYNC_OFF              0x02
-
-
-
-/* p317, 319
- */
-#define VCLK2_VCO_M        0x6008 /* treat as 16 bit? (includes msbs) */
-#define VCLK2_VCO_N        0x600a
-#define VCLK2_VCO_DIV_SEL  0x6012
-#define POST_DIV_SELECT        0x70
-#define POST_DIV_1             0x00
-#define POST_DIV_2             0x10
-#define POST_DIV_4             0x20
-#define POST_DIV_8             0x30
-#define POST_DIV_16            0x40
-#define POST_DIV_32            0x50
-#define VCO_LOOP_DIV_BY_4M     0x00
-#define VCO_LOOP_DIV_BY_16M    0x04
-
-
-/* Instruction Parser Mode Register 
- *    - p281
- *    - 2 new bits.
- */
-#define INST_PM                  0x20c0	
-#define AGP_SYNC_PACKET_FLUSH_ENABLE 0x20 /* reserved */
-#define SYNC_PACKET_FLUSH_ENABLE     0x10
-#define TWO_D_INST_DISABLE           0x08
-#define THREE_D_INST_DISABLE         0x04
-#define STATE_VAR_UPDATE_DISABLE     0x02
-#define PAL_STIP_DISABLE             0x01
-
-#define INST_DONE                0x2090
-#define INST_PS                  0x20c4
-
-#define MEMMODE                  0x20dc
-
-
-/* Instruction parser error register.  p279
- */
-#define IPEIR                  0x2088
-#define IPEHR                  0x208C
-
-
-/* General error reporting regs, p296
- */
-#define EIR               0x20B0
-#define EMR               0x20B4
-#define ESR               0x20B8
-#define IP_ERR                    0x0001
-#define ERROR_RESERVED            0xffc6
-
-
-/* Interrupt Control Registers 
- *   - new bits for i810
- *   - new register hwstam (mask)
- */
-#define HWSTAM               0x2098 /* p290 */
-#define IER                  0x20a0 /* p291 */
-#define IIR                  0x20a4 /* p292 */
-#define IMR                  0x20a8 /* p293 */
-#define ISR                  0x20ac /* p294 */
-#define HW_ERROR                 0x8000
-#define SYNC_STATUS_TOGGLE       0x1000
-#define DPY_0_FLIP_PENDING       0x0800
-#define DPY_1_FLIP_PENDING       0x0400	/* not implemented on i810 */
-#define OVL_0_FLIP_PENDING       0x0200
-#define OVL_1_FLIP_PENDING       0x0100	/* not implemented on i810 */
-#define DPY_0_VBLANK             0x0080
-#define DPY_0_EVENT              0x0040
-#define DPY_1_VBLANK             0x0020	/* not implemented on i810 */
-#define DPY_1_EVENT              0x0010	/* not implemented on i810 */
-#define HOST_PORT_EVENT          0x0008	/*  */
-#define CAPTURE_EVENT            0x0004	/*  */
-#define USER_DEFINED             0x0002
-#define BREAKPOINT               0x0001
-
-
-#define INTR_RESERVED            (0x6000 | 		\
-				  DPY_1_FLIP_PENDING |	\
-				  OVL_1_FLIP_PENDING |	\
-				  DPY_1_VBLANK |	\
-				  DPY_1_EVENT |		\
-				  HOST_PORT_EVENT |	\
-				  CAPTURE_EVENT )
-
-/* FIFO Watermark and Burst Length Control Register 
- *
- * - different offset and contents on i810 (p299) (fewer bits per field)
- * - some overlay fields added
- * - what does it all mean?
- */
-#define FWATER_BLC       0x20d8
-#define MM_BURST_LENGTH     0x00700000
-#define MM_FIFO_WATERMARK   0x0001F000
-#define LM_BURST_LENGTH     0x00000700
-#define LM_FIFO_WATERMARK   0x0000001F
-
-
-/* Fence/Tiling ranges [0..7]
- */
-#define FENCE            0x2000
-#define FENCE_NR         8
-
-#define FENCE_START_MASK    0x03F80000
-#define FENCE_X_MAJOR       0x00000000
-#define FENCE_Y_MAJOR       0x00001000
-#define FENCE_SIZE_MASK     0x00000700
-#define FENCE_SIZE_512K     0x00000000
-#define FENCE_SIZE_1M       0x00000100
-#define FENCE_SIZE_2M       0x00000200
-#define FENCE_SIZE_4M       0x00000300
-#define FENCE_SIZE_8M       0x00000400
-#define FENCE_SIZE_16M      0x00000500
-#define FENCE_SIZE_32M      0x00000600
-#define FENCE_PITCH_MASK    0x00000070
-#define FENCE_PITCH_1       0x00000000
-#define FENCE_PITCH_2       0x00000010
-#define FENCE_PITCH_4       0x00000020
-#define FENCE_PITCH_8       0x00000030
-#define FENCE_PITCH_16      0x00000040
-#define FENCE_PITCH_32      0x00000050
-#define FENCE_VALID         0x00000001
-
-
-/* Registers to control page table, p274
- */
-#define PGETBL_CTL       0x2020
-#define PGETBL_ADDR_MASK    0xFFFFF000
-#define PGETBL_ENABLE_MASK  0x00000001
-#define PGETBL_ENABLED      0x00000001
-
-/* Register containing pge table error results, p276
- */
-#define PGE_ERR          0x2024
-#define PGE_ERR_ADDR_MASK   0xFFFFF000
-#define PGE_ERR_ID_MASK     0x00000038
-#define PGE_ERR_CAPTURE     0x00000000
-#define PGE_ERR_OVERLAY     0x00000008
-#define PGE_ERR_DISPLAY     0x00000010
-#define PGE_ERR_HOST        0x00000018
-#define PGE_ERR_RENDER      0x00000020
-#define PGE_ERR_BLITTER     0x00000028
-#define PGE_ERR_MAPPING     0x00000030
-#define PGE_ERR_CMD_PARSER  0x00000038
-#define PGE_ERR_TYPE_MASK   0x00000007
-#define PGE_ERR_INV_TABLE   0x00000000
-#define PGE_ERR_INV_PTE     0x00000001
-#define PGE_ERR_MIXED_TYPES 0x00000002
-#define PGE_ERR_PAGE_MISS   0x00000003
-#define PGE_ERR_ILLEGAL_TRX 0x00000004
-#define PGE_ERR_LOCAL_MEM   0x00000005
-#define PGE_ERR_TILED       0x00000006
-
-
-
-/* Page table entries loaded via mmio region, p323
- */
-#define PTE_BASE         0x10000
-#define PTE_ADDR_MASK       0x3FFFF000
-#define PTE_TYPE_MASK       0x00000006
-#define PTE_LOCAL           0x00000002
-#define PTE_MAIN_UNCACHED   0x00000000
-#define PTE_MAIN_CACHED     0x00000006
-#define PTE_VALID_MASK      0x00000001
-#define PTE_VALID           0x00000001
-
-
-/* Ring buffer registers, p277, overview p19
- */
-#define LP_RING     0x2030
-#define HP_RING     0x2040
-
-#define RING_TAIL      0x00
-#define TAIL_ADDR           0x000FFFF8
-
-#define RING_HEAD      0x04
-#define HEAD_WRAP_COUNT     0xFFE00000
-#define HEAD_WRAP_ONE       0x00200000
-#define HEAD_ADDR           0x001FFFFC
-
-#define RING_START     0x08
-#define START_ADDR          0x00FFFFF8
-
-#define RING_LEN       0x0C
-#define RING_NR_PAGES       0x000FF000 
-#define RING_REPORT_MASK    0x00000006
-#define RING_REPORT_64K     0x00000002
-#define RING_REPORT_128K    0x00000004
-#define RING_NO_REPORT      0x00000000
-#define RING_VALID_MASK     0x00000001
-#define RING_VALID          0x00000001
-#define RING_INVALID        0x00000000
-
-
-
-/* BitBlt Instructions
- *
- * There are many more masks & ranges yet to add.
- */
-#define BR00_BITBLT_CLIENT   0x40000000
-#define BR00_OP_COLOR_BLT    0x10000000
-#define BR00_OP_SRC_COPY_BLT 0x10C00000
-#define BR00_OP_FULL_BLT     0x11400000
-#define BR00_OP_MONO_SRC_BLT 0x11800000
-#define BR00_OP_MONO_SRC_COPY_BLT 0x11000000
-#define BR00_OP_MONO_PAT_BLT 0x11C00000
-#define BR00_OP_MONO_SRC_COPY_IMMEDIATE_BLT (0x61 << 22)
-#define BR00_OP_TEXT_IMMEDIATE_BLT 0xc000000
-
-
-#define BR00_TPCY_DISABLE    0x00000000
-#define BR00_TPCY_ENABLE     0x00000010
-
-#define BR00_TPCY_ROP        0x00000000
-#define BR00_TPCY_NO_ROP     0x00000020
-#define BR00_TPCY_EQ         0x00000000
-#define BR00_TPCY_NOT_EQ     0x00000040
-
-#define BR00_PAT_MSB_FIRST   0x00000000	/* ? */
-
-#define BR00_PAT_VERT_ALIGN  0x000000e0
-
-#define BR00_LENGTH          0x0000000F
-
-#define BR09_DEST_ADDR       0x03FFFFFF
-
-#define BR11_SOURCE_PITCH    0x00003FFF
-
-#define BR12_SOURCE_ADDR     0x03FFFFFF
-
-#define BR13_SOLID_PATTERN   0x80000000
-#define BR13_RIGHT_TO_LEFT   0x40000000
-#define BR13_LEFT_TO_RIGHT   0x00000000
-#define BR13_MONO_TRANSPCY   0x20000000
-#define BR13_USE_DYN_DEPTH   0x04000000
-#define BR13_DYN_8BPP        0x00000000
-#define BR13_DYN_16BPP       0x01000000
-#define BR13_DYN_24BPP       0x02000000
-#define BR13_ROP_MASK        0x00FF0000
-#define BR13_DEST_PITCH      0x0000FFFF
-#define BR13_PITCH_SIGN_BIT  0x00008000
-
-#define BR14_DEST_HEIGHT     0xFFFF0000
-#define BR14_DEST_WIDTH      0x0000FFFF
-
-#define BR15_PATTERN_ADDR    0x03FFFFFF
-
-#define BR16_SOLID_PAT_COLOR 0x00FFFFFF
-#define BR16_BACKGND_PAT_CLR 0x00FFFFFF
-
-#define BR17_FGND_PAT_CLR    0x00FFFFFF
-
-#define BR18_SRC_BGND_CLR    0x00FFFFFF
-#define BR19_SRC_FGND_CLR    0x00FFFFFF
-
-
-/* Instruction parser instructions
- */
-
-#define INST_PARSER_CLIENT   0x00000000
-#define INST_OP_FLUSH        0x02000000
-#define INST_FLUSH_MAP_CACHE 0x00000001
-
-#define INST_DEST_BUFFER_INFO 0x06800000
-
-#define INST_FRONT_BUFFER_INFO 0x06000000
-#define FRONT_INFO_ASYNC_FLIP 1<<6
-#define FRONT_INFO_PITCH_B    8
-
-#define GFX_OP_USER_INTERRUPT ((0<<29)|(2<<23))
-
-
-/* Registers in the i810 host-pci bridge pci config space which affect
- * the i810 graphics operations.  
- */
-#define SMRAM_MISCC         0x70
-#define GMS                    0x000000c0
-#define GMS_DISABLE            0x00000000
-#define GMS_ENABLE_BARE        0x00000040
-#define GMS_ENABLE_512K        0x00000080
-#define GMS_ENABLE_1M          0x000000c0
-#define USMM                   0x00000030 
-#define USMM_DISABLE           0x00000000
-#define USMM_TSEG_ZERO         0x00000010
-#define USMM_TSEG_512K         0x00000020
-#define USMM_TSEG_1M           0x00000030  
-#define GFX_MEM_WIN_SIZE       0x00010000
-#define GFX_MEM_WIN_32M        0x00010000
-#define GFX_MEM_WIN_64M        0x00000000
-
-/* Overkill?  I don't know.  Need to figure out top of mem to make the
- * SMRAM calculations come out.  Linux seems to have problems
- * detecting it all on its own, so this seems a reasonable double
- * check to any user supplied 'mem=...' boot param.
- *
- * ... unfortunately this reg doesn't work according to spec on the
- * test hardware.
- */
-#define WHTCFG_PAMR_DRP      0x50
-#define SYS_DRAM_ROW_0_SHIFT    16
-#define SYS_DRAM_ROW_1_SHIFT    20
-#define DRAM_MASK           0x0f
-#define DRAM_VALUE_0        0
-#define DRAM_VALUE_1        8
-/* No 2 value defined */
-#define DRAM_VALUE_3        16
-#define DRAM_VALUE_4        16
-#define DRAM_VALUE_5        24
-#define DRAM_VALUE_6        32
-#define DRAM_VALUE_7        32
-#define DRAM_VALUE_8        48
-#define DRAM_VALUE_9        64
-#define DRAM_VALUE_A        64
-#define DRAM_VALUE_B        96
-#define DRAM_VALUE_C        128
-#define DRAM_VALUE_D        128
-#define DRAM_VALUE_E        192
-#define DRAM_VALUE_F        256	/* nice one, geezer */
-#define LM_FREQ_MASK        0x10
-#define LM_FREQ_133         0x10
-#define LM_FREQ_100         0x00
-
-
-
-
-/* These are 3d state registers, but the state is invarient, so we let
- * the X server handle it:
- */
-
-
-
-/* GFXRENDERSTATE_COLOR_CHROMA_KEY, p135
- */
-#define GFX_OP_COLOR_CHROMA_KEY  ((0x3<<29)|(0x1d<<24)|(0x2<<16)|0x1)
-#define CC1_UPDATE_KILL_WRITE    (1<<28)
-#define CC1_ENABLE_KILL_WRITE    (1<<27)
-#define CC1_DISABLE_KILL_WRITE    0
-#define CC1_UPDATE_COLOR_IDX     (1<<26)
-#define CC1_UPDATE_CHROMA_LOW    (1<<25)
-#define CC1_UPDATE_CHROMA_HI     (1<<24)
-#define CC1_CHROMA_LOW_MASK      ((1<<24)-1)
-#define CC2_COLOR_IDX_SHIFT      24
-#define CC2_COLOR_IDX_MASK       (0xff<<24)
-#define CC2_CHROMA_HI_MASK       ((1<<24)-1)
-
-
-#define GFX_CMD_CONTEXT_SEL      ((0<<29)|(0x5<<23))
-#define CS_UPDATE_LOAD           (1<<17)
-#define CS_UPDATE_USE            (1<<16)
-#define CS_UPDATE_LOAD           (1<<17)
-#define CS_LOAD_CTX0             0
-#define CS_LOAD_CTX1             (1<<8)
-#define CS_USE_CTX0              0
-#define CS_USE_CTX1              (1<<0)
-
-/* 3D Rendering Engine */
-
-#define RENDER_CLIENT            0x60000000
-
-/* Primitive rendering instruction */
-
-#define GFX_PRIMITIVE            0x1f000000
-#define PRIMITIVE_TRIANGLE       0 << 18
-#define PRIMITIVE_TRI_STRIP      1 << 18
-#define PRIMITIVE_TRI_REV_STRIP  2 << 18
-#define PRIMITIVE_TRI_FAN        3 << 18
-#define PRIMITIVE_POLYGON        4 << 18
-#define PRIMITIVE_LINE           5 << 18
-#define PRIMITIVE_LINE_STRIP     6 << 18
-#define PRIMITIVE_RECTANGLE      7 << 18
-
-/* Vertex format instruction */
-#define GFX_VERTEX_FORMAT        0x05000000
-#define VERTEX_0_TEXCOORDS       0 << 8
-#define VERTEX_1_TEXCOORDS       1 << 8
-#define VERTEX_2_TEXCOORDS       2 << 8
-#define VERTEX_SPECULAR_FOG      1 << 7
-#define VERTEX_DIFFUSE_ALPHA     1 << 6
-#define VERTEX_Z_OFFSET          1 << 5
-#define VERTEX_POS_XYZ           1 << 1
-#define VERTEX_POS_XYZ_RHW       2 << 1
-#define VERTEX_POS_XY            3 << 1
-#define VERTEX_POS_XY_RHW        4 << 1
-
-/* Drawing Rectangle Info instruction */
-
-#define GFX_DRAWING_RECTANGLE_INFO 0x1d800003
-#define GFX_DRAWING_CLIP_DISABLE 1<<31
- 
-/* Boolean enable 1 */
-#define GFX_BOOLEAN_ENA_1        0x03000000
-#define BOOL1_ALPHA_SETUP_MASK   1<<17
-#define BOOL1_ALPHA_SETUP_BIT    1<<16
-#define BOOL1_FOG_ENABLE_MASK    1<<7
-#define BOOL1_FOG_ENABLE_BIT     1<<6
-#define BOOL1_ALPHA_TEST_MASK    1<<5
-#define BOOL1_ALPHA_TEST_BIT     1<<4
-#define BOOL1_BLEND_ENABLE_MASK  1<<3
-#define BOOL1_BLEND_ENABLE_BIT   1<<2
-#define BOOL1_Z_ENABLE_MASK      1<<1
-#define BOOL1_Z_ENABLE_BIT       1<<0
-
-/* Boolean enable 2 */
-#define GFX_BOOLEAN_ENA_2        0x04000000
-#define BOOL2_MAPPING_CACHE_MASK 1<<17
-#define BOOL2_MAPPING_CACHE_BIT  1<<16
-#define BOOL2_ALPHA_DITHER_MASK  1<<15
-#define BOOL2_ALPHA_DITHER_BIT   1<<14
-#define BOOL2_FOG_DITHER_MASK    1<<13
-#define BOOL2_FOG_DITHER_BIT     1<<12
-#define BOOL2_SPECULAR_DITHER_MASK 1<<11
-#define BOOL2_SPECULAR_DITHER_BIT  1<<10
-#define BOOL2_COLOR_DITHER_MASK  1<<9
-#define BOOL2_COLOR_DITHER_BIT   1<<8
-#define BOOL2_FB_WRITE_MASK      1<<3
-#define BOOL2_FB_WRITE_BIT       1<<2
-#define BOOL2_Z_WRITE_MASK       1<<1
-#define BOOL2_Z_WRITE_BIT        1<<0
-
-/* Dest buffer variables */
-
-#define GFX_DEST_BUFFER_VARIABLES 0x1d850000
-
-#define DEST_BUF_VAR_8BIT        0 << 8
-#define DEST_BUF_VAR_555         1 << 8
-#define DEST_BUF_VAR_565         2 << 8
-
-/* map color blend stages */
-
-#define GFX_MAP_COLOR_BLEND_STAGES 0
-
-#define MAP_BLEND_STAGE_B        20
-#define MAP_BLEND_ACC_SEL_MASK   1<<19
-#define MAP_BLEND_ACC_SEL_BIT    1<<18
-#define MAP_BLEND_ARG1_MASK      1<<17
-#define MAP_BLEND_ARG1_B         14
-#define MAP_BLEND_REPLICATE_ARG1 1<<13
-#define MAP_BLEND_INVERT_ARG1    1<<12
-
-#define MAP_BLEND_ARG2_MASK      1<<11
-#define MAP_BLEND_ARG2_B         8
-#define MAP_BLEND_REPLICATE_ARG2 1<<7
-#define MAP_BLEND_INVERT_ARG2    1<<6
-
-#define MAP_BLEND_COLOR_OP_MASK  1<<5
-#define MAP_BLEND_COLOR_OP_B     0
-
-#define GFX_SCISSOR_ENABLE       0x1c800000
-
-#define SCISSOR_ENABLE_MASK      1<<1
-#define SCISSOR_ENABLE_BIT       1<<0
diff --git a/hw/kdrive/i810/i810_video.c b/hw/kdrive/i810/i810_video.c
deleted file mode 100644
index ac881d5..0000000
--- a/hw/kdrive/i810/i810_video.c
+++ /dev/null
@@ -1,1136 +0,0 @@
-/* COPYRIGHT AND PERMISSION NOTICE
-
-Copyright (c) 2000, 2001 Nokia Home Communications
-
-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, and/or sell copies of the Software, and to permit persons
-to whom the Software is furnished to do so, provided that the above
-copyright notice(s) and this permission notice appear in all copies of
-the Software and that both the above copyright notice(s) and this
-permission notice appear in supporting documentation.
-
-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
-OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
-HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
-SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
-RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
-CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
-CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
-Except as contained in this notice, the name of a copyright holder
-shall not be used in advertising or otherwise to promote the sale, use
-or other dealings in this Software without prior written authorization
-of the copyright holder.
-
-X Window System is a trademark of The Open Group */
-
-/***************************************************************************
- 
-Copyright 2000 Intel Corporation.  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 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 INTEL, 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.
-
-**************************************************************************/
-
-
-/*
- * i810_video.c: i810 KDrive Xv driver. 
- *               Based on the XFree86 i810 Xv driver by Jonathan Bian.
- *
- * Authors: 
- * 	Jonathan Bian <jonathan.bian at intel.com>
- *      Pontus Lidman <pontus.lidman at nokia.com>
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <kdrive-config.h>
-#endif
-#include "kdrive.h"
-#include "kxv.h"
-#include "i810.h"
-
-#include <X11/extensions/Xv.h>
-
-#include "fourcc.h"
-
-typedef struct {
-    CARD32 size;
-    CARD32 offset;
-} FBLinearRec, *FBLinearPtr;
-
-#define OFF_DELAY 	250  /* milliseconds */
-#define FREE_DELAY 	15000
-
-#define OFF_TIMER 	0x01
-#define FREE_TIMER	0x02
-#define CLIENT_VIDEO_ON	0x04
-
-#define TIMER_MASK      (OFF_TIMER | FREE_TIMER)
-
-static KdVideoAdaptorPtr i810SetupImageVideo(ScreenPtr);
-static void i810StopVideo(KdScreenInfo *, pointer, Bool);
-static int i810SetPortAttribute(KdScreenInfo *, Atom, int, pointer);
-static int i810GetPortAttribute(KdScreenInfo *, Atom, int *, pointer);
-static void i810QueryBestSize(KdScreenInfo *, Bool,
-	short, short, short, short, unsigned int *, unsigned int *, pointer);
-static int i810PutImage( KdScreenInfo *, DrawablePtr, 
-	short, short, short, short, short, short, short, short,
-	int, unsigned char*, short, short, Bool, RegionPtr, pointer);
-static int i810QueryImageAttributes(KdScreenInfo *, 
-	int, unsigned short *, unsigned short *,  int *, int *);
-
-static void i810BlockHandler(int, pointer, pointer, pointer);
-
-#define MAKE_ATOM(a) MakeAtom(a, sizeof(a) - 1, TRUE)
-
-static Atom xvBrightness, xvContrast, xvColorKey;
-
-#define IMAGE_MAX_WIDTH		720
-#define IMAGE_MAX_HEIGHT	576
-#define Y_BUF_SIZE		(IMAGE_MAX_WIDTH * IMAGE_MAX_HEIGHT)
-
-#define OVERLAY_UPDATE(p)	OUTREG(0x30000, p | 0x80000000);
-
-/*
- * OV0CMD - Overlay Command Register
- */
-#define	VERTICAL_CHROMINANCE_FILTER 	0x70000000
-#define VC_SCALING_OFF		0x00000000
-#define VC_LINE_REPLICATION	0x10000000
-#define VC_UP_INTERPOLATION	0x20000000
-#define VC_PIXEL_DROPPING	0x50000000
-#define VC_DOWN_INTERPOLATION	0x60000000
-#define VERTICAL_LUMINANCE_FILTER	0x0E000000
-#define VL_SCALING_OFF		0x00000000
-#define VL_LINE_REPLICATION	0x02000000
-#define VL_UP_INTERPOLATION	0x04000000
-#define VL_PIXEL_DROPPING	0x0A000000
-#define VL_DOWN_INTERPOLATION	0x0C000000
-#define	HORIZONTAL_CHROMINANCE_FILTER 	0x01C00000
-#define HC_SCALING_OFF		0x00000000
-#define HC_LINE_REPLICATION	0x00400000
-#define HC_UP_INTERPOLATION	0x00800000
-#define HC_PIXEL_DROPPING	0x01400000
-#define HC_DOWN_INTERPOLATION	0x01800000
-#define HORIZONTAL_LUMINANCE_FILTER	0x00380000
-#define HL_SCALING_OFF		0x00000000
-#define HL_LINE_REPLICATION	0x00080000
-#define HL_UP_INTERPOLATION	0x00100000
-#define HL_PIXEL_DROPPING	0x00280000
-#define HL_DOWN_INTERPOLATION	0x00300000
-
-#define Y_ADJUST		0x00010000	
-#define OV_BYTE_ORDER		0x0000C000
-#define UV_SWAP			0x00004000
-#define Y_SWAP			0x00008000
-#define Y_AND_UV_SWAP		0x0000C000
-#define SOURCE_FORMAT		0x00003C00
-#define	RGB_555			0x00000800
-#define	RGB_565			0x00000C00
-#define	YUV_422			0x00002000
-#define	YUV_411			0x00002400
-#define	YUV_420			0x00003000
-#define	YUV_410			0x00003800
-#define BUFFER_AND_FIELD	0x00000006
-#define	BUFFER0_FIELD0		0x00000000
-#define	BUFFER1_FIELD0		0x00000004
-#define OVERLAY_ENABLE		0x00000001
-
-/*
- * DOV0STA - Display/Overlay 0 Status Register
- */
-#define	DOV0STA 	0x30008
-
-#define MINUV_SCALE	0x1
-
-#define RGB16ToColorKey(c) \
-	(((c & 0xF800) << 8) | ((c & 0x07E0) << 5) | ((c & 0x001F) << 3))
-
-#define RGB15ToColorKey(c) \
-        (((c & 0x7c00) << 9) | ((c & 0x03E0) << 6) | ((c & 0x001F) << 3))
-
-Bool i810InitVideo(ScreenPtr pScreen)
-{
-    KdScreenPriv(pScreen);
-    KdScreenInfo *screen = pScreenPriv->screen;
-    KdVideoAdaptorPtr *adaptors, *newAdaptors = NULL;
-    KdVideoAdaptorPtr newAdaptor = NULL;
-    int num_adaptors;
-
-/*     fprintf(stderr,"i810InitVideo\n"); */
-	
-    if (screen->fb[0].bitsPerPixel != 8) 
-    {
-	newAdaptor = i810SetupImageVideo(pScreen);
-    }
-
-    num_adaptors = KdXVListGenericAdaptors(screen, &adaptors);
-
-    if(newAdaptor) {
-	if(!num_adaptors) {
-	    num_adaptors = 1;
-	    adaptors = &newAdaptor;
-	} else {
-	    newAdaptors =  /* need to free this someplace */
-		xalloc((num_adaptors + 1) * sizeof(KdVideoAdaptorPtr*));
-	    if(newAdaptors) {
-		memcpy(newAdaptors, adaptors, num_adaptors * 
-					sizeof(KdVideoAdaptorPtr));
-		newAdaptors[num_adaptors] = newAdaptor;
-		adaptors = newAdaptors;
-		num_adaptors++;
-	    }
-	}
-    }
-
-    if(num_adaptors)
-        KdXVScreenInit(pScreen, adaptors, num_adaptors);
-
-    if(newAdaptors)
-        xfree(newAdaptors);
-    return TRUE;
-}
-
-/* client libraries expect an encoding */
-static KdVideoEncodingRec DummyEncoding[1] =
-{
- {
-   0,
-   "XV_IMAGE",
-   IMAGE_MAX_WIDTH, IMAGE_MAX_HEIGHT,
-   {1, 1}
- }
-};
-
-#define NUM_FORMATS 3
-
-static KdVideoFormatRec Formats[NUM_FORMATS] = 
-{
-  {15, TrueColor}, {16, TrueColor}, {24, TrueColor}
-};
-
-#define NUM_ATTRIBUTES 3
-
-static KdAttributeRec Attributes[NUM_ATTRIBUTES] =
-{
-   {XvSettable | XvGettable, 0, (1 << 24) - 1, "XV_COLORKEY"},
-   {XvSettable | XvGettable, -128, 127, "XV_BRIGHTNESS"},
-   {XvSettable | XvGettable, 0, 255, "XV_CONTRAST"}
-};
-
-#define NUM_IMAGES 4
-
-static KdImageRec Images[NUM_IMAGES] =
-{
-	XVIMAGE_YUY2,
-	XVIMAGE_YV12,
-	XVIMAGE_I420,
-	XVIMAGE_UYVY
-};
-
-typedef struct {
-    CARD32 OBUF_0Y;
-    CARD32 OBUF_1Y;
-    CARD32 OBUF_0U;
-    CARD32 OBUF_0V;
-    CARD32 OBUF_1U;
-    CARD32 OBUF_1V;
-    CARD32 OV0STRIDE;
-    CARD32 YRGB_VPH;
-    CARD32 UV_VPH;
-    CARD32 HORZ_PH;
-    CARD32 INIT_PH;
-    CARD32 DWINPOS;
-    CARD32 DWINSZ;
-    CARD32 SWID;
-    CARD32 SWIDQW;
-    CARD32 SHEIGHT;
-    CARD32 YRGBSCALE;
-    CARD32 UVSCALE;
-    CARD32 OV0CLRC0;
-    CARD32 OV0CLRC1;
-    CARD32 DCLRKV;
-    CARD32 DCLRKM;
-    CARD32 SCLRKVH;
-    CARD32 SCLRKVL;
-    CARD32 SCLRKM;
-    CARD32 OV0CONF;
-    CARD32 OV0CMD;
-} I810OverlayRegRec, *I810OverlayRegPtr;
-
-typedef struct {
-	CARD32       YBuf0offset;
-	CARD32       UBuf0offset;
-	CARD32       VBuf0offset;
-
-	CARD32       YBuf1offset;
-	CARD32       UBuf1offset;
-	CARD32       VBuf1offset;
-
-	unsigned char currentBuf;
-
-	unsigned char brightness;
-	unsigned char contrast;
-
-	RegionRec    clip;
-	CARD32       colorKey;
-
-	CARD32       videoStatus;
-	Time         offTime;
-	Time         freeTime;
-    FBLinearPtr  linear;
-} I810PortPrivRec, *I810PortPrivPtr;        
-
-#define GET_PORT_PRIVATE(screen) \
-   (I810PortPrivPtr)(((I810CardInfo *) (screen->card->driver))->adaptor->pPortPrivates[0].ptr)
-
-static void i810ResetVideo(KdScreenInfo *screen) 
-{
-    ScreenPtr pScreen = screen->pScreen;
-    KdScreenPriv(pScreen);
-    KdCardInfo *card = pScreenPriv->card;
-    I810CardInfo *i810c = (I810CardInfo *) card->driver;
-
-    I810PortPrivPtr pPriv = i810c->adaptor->pPortPrivates[0].ptr;
-    I810OverlayRegPtr overlay = (I810OverlayRegPtr) (i810c->FbBase + i810c->OverlayStart); 
-
-    /*
-     * Default to maximum image size in YV12
-     */
-
-    overlay->YRGB_VPH = 0;
-    overlay->UV_VPH = 0;
-    overlay->HORZ_PH = 0;
-    overlay->INIT_PH = 0;
-    overlay->DWINPOS = 0;
-    overlay->DWINSZ = (IMAGE_MAX_HEIGHT << 16) | IMAGE_MAX_WIDTH; 
-    overlay->SWID =  IMAGE_MAX_WIDTH | (IMAGE_MAX_WIDTH << 15);       
-    overlay->SWIDQW = (IMAGE_MAX_WIDTH >> 3) | (IMAGE_MAX_WIDTH << 12);
-    overlay->SHEIGHT = IMAGE_MAX_HEIGHT | (IMAGE_MAX_HEIGHT << 15);
-    overlay->YRGBSCALE = 0x80004000; /* scale factor 1 */
-    overlay->UVSCALE = 0x80004000; /* scale factor 1 */
-    overlay->OV0CLRC0 = 0x4000; /* brightness: 0 contrast: 1.0 */
-    overlay->OV0CLRC1 = 0x80; /* saturation: bypass */
-
-    /*
-     * Enable destination color keying
-     */
-    switch(screen->fb[0].depth) {
-    case 16: overlay->DCLRKV = RGB16ToColorKey(pPriv->colorKey);
-             overlay->DCLRKM = 0x80070307;
-             break;
-    case 15: overlay->DCLRKV = RGB15ToColorKey(pPriv->colorKey);
-             overlay->DCLRKM = 0x80070707;
-             break;
-    default: overlay->DCLRKV = pPriv->colorKey;
-             overlay->DCLRKM = 0x80000000;
-             break;
-    }
-
-    overlay->SCLRKVH = 0;
-    overlay->SCLRKVL = 0;
-    overlay->SCLRKM = 0; /* source color key disable */
-    overlay->OV0CONF = 0; /* two 720 pixel line buffers */ 
-
-    overlay->OV0CMD = VC_UP_INTERPOLATION | HC_UP_INTERPOLATION | Y_ADJUST |
-		      YUV_420;
-
-    OVERLAY_UPDATE(i810c->OverlayPhysical);
-}
-
-
-static KdVideoAdaptorPtr 
-i810SetupImageVideo(ScreenPtr pScreen)
-{
-    KdScreenPriv(pScreen);
-    KdScreenInfo *screen = pScreenPriv->screen;
-    KdCardInfo *card = pScreenPriv->card;
-    I810CardInfo  *i810c = (I810CardInfo *) card->driver;
-
-
-    KdVideoAdaptorPtr adapt;
-    I810PortPrivPtr pPriv;
-
-/*     fprintf(stderr,"i810SetupImageVideo\n"); */
-
-    if(!(adapt = xcalloc(1, sizeof(KdVideoAdaptorRec) +
-			    sizeof(I810PortPrivRec) +
-			    sizeof(DevUnion))))
-	return NULL;
-
-    adapt->type = XvWindowMask | XvInputMask | XvImageMask;
-    adapt->flags = VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT;
-    adapt->name = "I810 Video Overlay";
-    adapt->nEncodings = 1;
-    adapt->pEncodings = DummyEncoding;
-    adapt->nFormats = NUM_FORMATS;
-    adapt->pFormats = Formats;
-    adapt->nPorts = 1;
-    adapt->pPortPrivates = (DevUnion*)(&adapt[1]);
-
-    pPriv = (I810PortPrivPtr)(&adapt->pPortPrivates[1]);
-
-    adapt->pPortPrivates[0].ptr = (pointer)(pPriv);
-    adapt->pAttributes = Attributes;
-    adapt->nImages = NUM_IMAGES;
-    adapt->nAttributes = NUM_ATTRIBUTES;
-    adapt->pImages = Images;
-    adapt->PutVideo = NULL;
-    adapt->PutStill = NULL;
-    adapt->GetVideo = NULL;
-    adapt->GetStill = NULL;
-    adapt->StopVideo = i810StopVideo;
-    adapt->SetPortAttribute = i810SetPortAttribute;
-    adapt->GetPortAttribute = i810GetPortAttribute;
-    adapt->QueryBestSize = i810QueryBestSize;
-    adapt->PutImage = i810PutImage;
-    adapt->QueryImageAttributes = i810QueryImageAttributes;
-
-    pPriv->colorKey = i810c->colorKey & ((1 << screen->fb[0].depth) - 1);
-    pPriv->videoStatus = 0;
-    pPriv->brightness = 0;
-    pPriv->contrast = 128;
-    pPriv->linear = NULL;
-    pPriv->currentBuf = 0;
-
-    /* gotta uninit this someplace */
-    REGION_INIT(pScreen, &pPriv->clip, NullBox, 0); 
-
-    i810c->adaptor = adapt;
-
-    i810c->BlockHandler = pScreen->BlockHandler;
-    pScreen->BlockHandler = i810BlockHandler;
-
-    xvBrightness = MAKE_ATOM("XV_BRIGHTNESS");
-    xvContrast   = MAKE_ATOM("XV_CONTRAST");
-    xvColorKey   = MAKE_ATOM("XV_COLORKEY");
-
-    i810ResetVideo(screen);
-
-    return adapt;
-}
-
-
-/* I810ClipVideo -  
-
-   Takes the dst box in standard X BoxRec form (top and left
-   edges inclusive, bottom and right exclusive).  The new dst
-   box is returned.  The source boundaries are given (x1, y1 
-   inclusive, x2, y2 exclusive) and returned are the new source 
-   boundaries in 16.16 fixed point. 
-*/
-
-static void
-I810ClipVideo(
-  BoxPtr dst, 
-  INT32 *x1, 
-  INT32 *x2, 
-  INT32 *y1, 
-  INT32 *y2,
-  BoxPtr extents,            /* extents of the clip region */
-  INT32 width, 
-  INT32 height
-){
-    INT32 vscale, hscale, delta;
-    int diff;
-
-    hscale = ((*x2 - *x1) << 16) / (dst->x2 - dst->x1);
-    vscale = ((*y2 - *y1) << 16) / (dst->y2 - dst->y1);
-
-    *x1 <<= 16; *x2 <<= 16;
-    *y1 <<= 16; *y2 <<= 16;
-
-    diff = extents->x1 - dst->x1;
-    if(diff > 0) {
-	dst->x1 = extents->x1;
-	*x1 += diff * hscale;     
-    }
-    diff = dst->x2 - extents->x2;
-    if(diff > 0) {
-	dst->x2 = extents->x2;
-	*x2 -= diff * hscale;     
-    }
-    diff = extents->y1 - dst->y1;
-    if(diff > 0) {
-	dst->y1 = extents->y1;
-	*y1 += diff * vscale;     
-    }
-    diff = dst->y2 - extents->y2;
-    if(diff > 0) {
-	dst->y2 = extents->y2;
-	*y2 -= diff * vscale;     
-    }
-
-    if(*x1 < 0) {
-	diff =  (- *x1 + hscale - 1)/ hscale;
-	dst->x1 += diff;
-	*x1 += diff * hscale;
-    }
-    delta = *x2 - (width << 16);
-    if(delta > 0) {
-	diff = (delta + hscale - 1)/ hscale;
-	dst->x2 -= diff;
-	*x2 -= diff * hscale;
-    }
-    if(*y1 < 0) {
-	diff =  (- *y1 + vscale - 1)/ vscale;
-	dst->y1 += diff;
-	*y1 += diff * vscale;
-    }
-    delta = *y2 - (height << 16);
-    if(delta > 0) {
-	diff = (delta + vscale - 1)/ vscale;
-	dst->y2 -= diff;
-	*y2 -= diff * vscale;
-    }
-} 
-
-static void 
-i810StopVideo(KdScreenInfo *screen, pointer data, Bool exit)
-{
-  I810PortPrivPtr pPriv = (I810PortPrivPtr)data;
-  KdCardInfo *card = screen->card;
-  I810CardInfo	*i810c = (I810CardInfo *) card->driver;  
-
-  I810OverlayRegPtr overlay = (I810OverlayRegPtr) (i810c->FbBase + i810c->OverlayStart); 
-
-  REGION_EMPTY(screen->pScreen, &pPriv->clip);   
-
-  if(exit) {
-     if(pPriv->videoStatus & CLIENT_VIDEO_ON) {
-	overlay->OV0CMD &= 0xFFFFFFFE;
-	OVERLAY_UPDATE(i810c->OverlayPhysical);
-     }
-     if(pPriv->linear) {
-         xfree(pPriv->linear);
-         pPriv->linear = NULL;
-     }
-     pPriv->videoStatus = 0;
-  } else {
-     if(pPriv->videoStatus & CLIENT_VIDEO_ON) {
-	pPriv->videoStatus |= OFF_TIMER;
-	pPriv->offTime = currentTime.milliseconds + OFF_DELAY; 
-     }
-  }
-
-}
-
-static int 
-i810SetPortAttribute(
-  KdScreenInfo *screen, 
-  Atom attribute,
-  int value, 
-  pointer data
-){
-  I810PortPrivPtr pPriv = (I810PortPrivPtr)data;
-  KdCardInfo *card = screen->card;
-  I810CardInfo	*i810c = (I810CardInfo *) card->driver;
-
-  I810OverlayRegPtr overlay = (I810OverlayRegPtr) (i810c->FbBase + i810c->OverlayStart); 
-
-  if(attribute == xvBrightness) {
-	if((value < -128) || (value > 127))
-	   return BadValue;
-	pPriv->brightness = value;
-	overlay->OV0CLRC0 &= 0xFFFFFF00;
-	overlay->OV0CLRC0 |= value;
-	OVERLAY_UPDATE(i810c->OverlayPhysical);
-  } else
-  if(attribute == xvContrast) {
-	if((value < 0) || (value > 255))
-	   return BadValue;
-	pPriv->contrast = value;
-	overlay->OV0CLRC0 &= 0xFFFE00FF;
-	overlay->OV0CLRC0 |= value << 9;
-	OVERLAY_UPDATE(i810c->OverlayPhysical);
-  } else
-  if(attribute == xvColorKey) {
-	pPriv->colorKey = value;
-	switch(screen->fb[0].depth) {
-	case 16: overlay->DCLRKV = RGB16ToColorKey(pPriv->colorKey);
-	         break;
-	case 15: overlay->DCLRKV = RGB15ToColorKey(pPriv->colorKey);
-                 break;
-	default: overlay->DCLRKV = pPriv->colorKey;
-                 break;
-	}
-	OVERLAY_UPDATE(i810c->OverlayPhysical);
-	REGION_EMPTY(screen->pScreen, &pPriv->clip);   
-  } else return BadMatch;
-
-  return Success;
-}
-
-static int 
-i810GetPortAttribute(
-  KdScreenInfo *screen, 
-  Atom attribute,
-  int *value, 
-  pointer data
-){
-  I810PortPrivPtr pPriv = (I810PortPrivPtr)data;
-
-  if(attribute == xvBrightness) {
-	*value = pPriv->brightness;
-  } else
-  if(attribute == xvContrast) {
-	*value = pPriv->contrast;
-  } else
-  if(attribute == xvColorKey) {
-	*value = pPriv->colorKey;
-  } else return BadMatch;
-
-  return Success;
-}
-
-static void 
-i810QueryBestSize(
-  KdScreenInfo *screen, 
-  Bool motion,
-  short vid_w, short vid_h, 
-  short drw_w, short drw_h, 
-  unsigned int *p_w, unsigned int *p_h, 
-  pointer data
-){
-  *p_w = drw_w;
-  *p_h = drw_h; 
-}
-
-
-static void
-I810CopyPackedData(
-   KdScreenInfo *screen, 
-   unsigned char *buf,
-   int srcPitch,
-   int dstPitch,
-   int top,
-   int left,
-   int h,
-   int w
-   )
-{
-  KdCardInfo *card = screen->card;
-  I810CardInfo	*i810c = (I810CardInfo *) card->driver;
-    I810PortPrivPtr pPriv = i810c->adaptor->pPortPrivates[0].ptr;
-    unsigned char *src, *dst;
-    
-    src = buf + (top*srcPitch) + (left<<1);
-
-    if (pPriv->currentBuf == 0)
-	dst = i810c->FbBase + pPriv->YBuf0offset;
-    else
-	dst = i810c->FbBase + pPriv->YBuf1offset;
-
-    w <<= 1;
-    while(h--) {
-	memcpy(dst, src, w);
-	src += srcPitch;
-	dst += dstPitch;
-    }
-}
-
-static void
-i810CopyPlanarData(
-   KdScreenInfo *screen, 
-   unsigned char *buf,
-   int srcPitch,
-   int dstPitch,  /* of chroma */
-   int srcH,
-   int top,
-   int left,
-   int h,
-   int w,
-   int id
-   )
-{
-  KdCardInfo *card = screen->card;
-  I810CardInfo	*i810c = (I810CardInfo *) card->driver;
-    I810PortPrivPtr pPriv = i810c->adaptor->pPortPrivates[0].ptr;
-    int i;
-    unsigned char *src1, *src2, *src3, *dst1, *dst2, *dst3;
-
-    /* Copy Y data */
-    src1 = buf + (top*srcPitch) + left;
-    if (pPriv->currentBuf == 0)
-	dst1 = i810c->FbBase + pPriv->YBuf0offset;
-    else
-	dst1 = i810c->FbBase + pPriv->YBuf1offset;
-
-    for (i = 0; i < h; i++) {
-	memcpy(dst1, src1, w);
-	src1 += srcPitch;
-	dst1 += dstPitch << 1;
-    }
-
-    /* Copy V data for YV12, or U data for I420 */
-    src2 = buf + (srcH*srcPitch) + ((top*srcPitch)>>2) + (left>>1);
-    if (pPriv->currentBuf == 0) {
-	if (id == FOURCC_I420)
-	    dst2 = i810c->FbBase + pPriv->UBuf0offset;
-	else
-	    dst2 = i810c->FbBase + pPriv->VBuf0offset;
-    } else {
-	if (id == FOURCC_I420)
-	    dst2 = i810c->FbBase + pPriv->UBuf1offset;
-	else
-	    dst2 = i810c->FbBase + pPriv->VBuf1offset;
-    }
-
-    for (i = 0; i < h/2; i++) {
-	memcpy(dst2, src2, w/2);
-	src2 += srcPitch>>1;
-	dst2 += dstPitch;
-    }
-
-    /* Copy U data for YV12, or V data for I420 */
-    src3 = buf + (srcH*srcPitch) + ((srcH*srcPitch)>>2) + ((top*srcPitch)>>2) + (left>>1);
-    if (pPriv->currentBuf == 0) {
-	if (id == FOURCC_I420) 
-	    dst3 = i810c->FbBase + pPriv->VBuf0offset;
-	else
-	    dst3 = i810c->FbBase + pPriv->UBuf0offset;
-    } else {
-	if (id == FOURCC_I420) 
-	    dst3 = i810c->FbBase + pPriv->VBuf1offset;
-	else
-	    dst3 = i810c->FbBase + pPriv->UBuf1offset;
-    }
-    
-    for (i = 0; i < h/2; i++) {
-	memcpy(dst3, src3, w/2);
-	src3 += srcPitch>>1;
-	dst3 += dstPitch;
-    }
-}
-
-static void
-i810DisplayVideo(
-    KdScreenInfo *screen,
-    int id,
-    short width, short height,
-    int dstPitch,  /* of chroma for 4:2:0 */
-    int x1, int y1, int x2, int y2,
-    BoxPtr dstBox,
-    short src_w, short src_h,
-    short drw_w, short drw_h
-){
-  KdCardInfo *card = screen->card;
-  I810CardInfo	*i810c = (I810CardInfo *) card->driver;
-    I810PortPrivPtr pPriv = i810c->adaptor->pPortPrivates[0].ptr;
-    I810OverlayRegPtr overlay = (I810OverlayRegPtr) (i810c->FbBase + i810c->OverlayStart); 
-    int xscaleInt, xscaleFract, yscaleInt, yscaleFract;
-    int xscaleIntUV = 0, xscaleFractUV = 0, yscaleIntUV = 0, yscaleFractUV = 0;
-    unsigned int swidth;
-
-    switch(id) {
-    case FOURCC_YV12:
-    case FOURCC_I420:
-	swidth = (width + 7) & ~7;
-	overlay->SWID = (swidth << 15) | swidth;
-	overlay->SWIDQW = (swidth << 12) | (swidth >> 3);
-	break;
-    case FOURCC_UYVY:
-    case FOURCC_YUY2:
-    default:
-	swidth = ((width + 3) & ~3) << 1;
-	overlay->SWID = swidth;
-	overlay->SWIDQW = swidth >> 3;
-	break;
-    }
-
-    overlay->SHEIGHT = height | (height << 15);
-    overlay->DWINPOS = (dstBox->y1 << 16) | dstBox->x1;
-    overlay->DWINSZ = ((dstBox->y2 - dstBox->y1) << 16) | 
-	              (dstBox->x2 - dstBox->x1);
-
-    /* buffer locations */
-    overlay->OBUF_0Y = pPriv->YBuf0offset;
-    overlay->OBUF_1Y = pPriv->YBuf1offset;
-    overlay->OBUF_0U = pPriv->UBuf0offset; 
-    overlay->OBUF_0V = pPriv->VBuf0offset;
-    overlay->OBUF_1U = pPriv->UBuf1offset;
-    overlay->OBUF_1V = pPriv->VBuf1offset;
-
-    /* 
-     * Calculate horizontal and vertical scaling factors, default to 1:1
-     */
-    overlay->YRGBSCALE = 0x80004000;
-    overlay->UVSCALE = 0x80004000;
-
-    /* 
-     * Initially, YCbCr and Overlay Enable and
-     * vertical chrominance up interpolation and horozontal chrominance
-     * up interpolation
-     */
-    overlay->OV0CMD = VC_UP_INTERPOLATION | HC_UP_INTERPOLATION | Y_ADJUST | 
-	              OVERLAY_ENABLE; 
-
-    if ((drw_w != src_w) || (drw_h != src_h)) 
-    {
-	xscaleInt = (src_w / drw_w) & 0x3;
-	xscaleFract = (src_w << 12) / drw_w;
-	yscaleInt = (src_h / drw_h) & 0x3;
-	yscaleFract = (src_h << 12) / drw_h;
-
-	overlay->YRGBSCALE = (xscaleInt << 15) | 
-	                     ((xscaleFract & 0xFFF) << 3) |
-	                     (yscaleInt) |
-			     ((yscaleFract & 0xFFF) << 20);
-
-	if (drw_w > src_w) 
-	{
-	    /* horizontal up-scaling */
-	    overlay->OV0CMD &= ~HORIZONTAL_CHROMINANCE_FILTER;
-	    overlay->OV0CMD &= ~HORIZONTAL_LUMINANCE_FILTER;
-	    overlay->OV0CMD |= (HC_UP_INTERPOLATION | HL_UP_INTERPOLATION);
-	}
-
-	if (drw_h > src_h) 
-	{ 
-	    /* vertical up-scaling */
-	    overlay->OV0CMD &= ~VERTICAL_CHROMINANCE_FILTER;
-	    overlay->OV0CMD &= ~VERTICAL_LUMINANCE_FILTER;
-	    overlay->OV0CMD |= (VC_UP_INTERPOLATION | VL_UP_INTERPOLATION);
-	}
-
-	if (drw_w < src_w) 
-	{ 
-	    /* horizontal down-scaling */
-	    overlay->OV0CMD &= ~HORIZONTAL_CHROMINANCE_FILTER;
-	    overlay->OV0CMD &= ~HORIZONTAL_LUMINANCE_FILTER;
-	    overlay->OV0CMD |= (HC_DOWN_INTERPOLATION | HL_DOWN_INTERPOLATION);
-	}
-
-	if (drw_h < src_h) 
-	{ 
-	    /* vertical down-scaling */
-	    overlay->OV0CMD &= ~VERTICAL_CHROMINANCE_FILTER;
-	    overlay->OV0CMD &= ~VERTICAL_LUMINANCE_FILTER;
-	    overlay->OV0CMD |= (VC_DOWN_INTERPOLATION | VL_DOWN_INTERPOLATION);
-	}
-
-	/* now calculate the UV scaling factor */
-
-	if (xscaleFract)
-	{
-	    xscaleFractUV = xscaleFract >> MINUV_SCALE;
-	    overlay->OV0CMD &= ~HC_DOWN_INTERPOLATION;
-	    overlay->OV0CMD |= HC_UP_INTERPOLATION;
-	}
-
-	if (xscaleInt)
-	{
-	    xscaleIntUV = xscaleInt >> MINUV_SCALE;
-	    if (xscaleIntUV)
-	    {
-		overlay->OV0CMD &= ~HC_UP_INTERPOLATION;
-	    }
-	}
-
-	if (yscaleFract)
-	{
-	    yscaleFractUV = yscaleFract >> MINUV_SCALE;
-	    overlay->OV0CMD &= ~VC_DOWN_INTERPOLATION;
-	    overlay->OV0CMD |= VC_UP_INTERPOLATION;
-	}
-
-	if (yscaleInt)
-	{
-	    yscaleIntUV = yscaleInt >> MINUV_SCALE;
-	    if (yscaleIntUV)
-	    {
-		overlay->OV0CMD &= ~VC_UP_INTERPOLATION;
-		overlay->OV0CMD |= VC_DOWN_INTERPOLATION;
-	    }
-	}
-
-	overlay->UVSCALE = yscaleIntUV | ((xscaleFractUV & 0xFFF) << 3) |
-	                   ((yscaleFractUV & 0xFFF) << 20);
-    }
-
-    switch(id) {
-    case FOURCC_YV12:
-    case FOURCC_I420:
-	overlay->OV0STRIDE = (dstPitch << 1) | (dstPitch << 16);
-	overlay->OV0CMD &= ~SOURCE_FORMAT;
-	overlay->OV0CMD |= YUV_420;
-	break;
-    case FOURCC_UYVY:
-    case FOURCC_YUY2:
-    default:
-	overlay->OV0STRIDE = dstPitch;
-	overlay->OV0CMD &= ~SOURCE_FORMAT;
-	overlay->OV0CMD |= YUV_422;
-	overlay->OV0CMD &= ~OV_BYTE_ORDER;
-	if (id == FOURCC_UYVY)
-	    overlay->OV0CMD |= Y_SWAP;
-	break;
-    }
-
-    overlay->OV0CMD &= ~BUFFER_AND_FIELD;
-    if (pPriv->currentBuf == 0)
-	overlay->OV0CMD |= BUFFER0_FIELD0;
-    else
-	overlay->OV0CMD |= BUFFER1_FIELD0;
-
-    OVERLAY_UPDATE(i810c->OverlayPhysical);
-
-}
-
-static FBLinearPtr
-i810AllocateMemory(
-  KdScreenInfo *screen,
-  FBLinearPtr linear,
-  int size
-){
-    KdCardInfo *card=screen->card;
-    I810CardInfo *i810c = (I810CardInfo *) card->driver;
-    FBLinearPtr new_linear;
-  
-    if(linear) {
-	if(linear->size >= size)
-            return linear;
-        else
-            ErrorF("Ran out of memory for overlay buffer, requested size = %d\n",size);
-    }
-    
-   new_linear = xalloc(sizeof(FBLinearRec));
-   new_linear->size = i810c->XvMem.Size;
-   new_linear->offset = i810c->XvMem.Start;
-
-/*    fprintf(stderr,"Overlay mem offset %lx\n",new_linear->offset); */
-
-   return new_linear;
-}
-
-static int
-i810PutImage(KdScreenInfo	    *screen, 
-	       DrawablePtr	    pDraw,
-	       short		    src_x,
-	       short		    src_y,
-	       short		    drw_x,
-	       short		    drw_y,
-	       short		    src_w,
-	       short		    src_h,
-	       short		    drw_w,
-	       short		    drw_h,
-	       int		     id,
-	       unsigned char	    *buf,
-	       short		    width,
-	       short		    height,
-	       Bool		    sync,
-	       RegionPtr	    clipBoxes,
-	       pointer		    data)
-{
-    KdCardInfo *card = screen->card;
-    I810CardInfo *i810c = (I810CardInfo *) card->driver;
-    I810PortPrivPtr pPriv = (I810PortPrivPtr)data;
-    INT32 x1, x2, y1, y2;
-    int srcPitch, dstPitch;
-    int top, left, npixels, nlines, size;
-    BoxRec dstBox;
-
-    /* Clip */
-    x1 = src_x;
-    x2 = src_x + src_w;
-    y1 = src_y;
-    y2 = src_y + src_h;
-
-    dstBox.x1 = drw_x;
-    dstBox.x2 = drw_x + drw_w;
-    dstBox.y1 = drw_y;
-    dstBox.y2 = drw_y + drw_h;
-
-    I810ClipVideo(&dstBox, &x1, &x2, &y1, &y2, 
-		  REGION_EXTENTS(pScreen, clipBoxes), width, height);
-
-    if((x1 >= x2) || (y1 >= y2))
-       return Success;
-
-    switch(id) {
-    case FOURCC_YV12:
-    case FOURCC_I420:
-	 srcPitch = (width + 3) & ~3;
-	 dstPitch = ((width >> 1) + 7) & ~7;  /* of chroma */
-	 size =  dstPitch * height * 3;	
-	 break;
-    case FOURCC_UYVY:
-    case FOURCC_YUY2:
-    default:
-	 srcPitch = (width << 1);
-	 dstPitch = (srcPitch + 7) & ~7;
-	 size = dstPitch * height;
-	 break;
-    }  
-
-    if(!(pPriv->linear = i810AllocateMemory(screen, pPriv->linear, 
-		(screen->fb[0].bitsPerPixel == 16) ? size : (size >> 1))))
-	return BadAlloc;
-
-    /* fixup pointers */
-    pPriv->YBuf0offset = pPriv->linear->offset;
-    pPriv->UBuf0offset = pPriv->YBuf0offset + (dstPitch * 2 * height);
-    pPriv->VBuf0offset = pPriv->UBuf0offset + (dstPitch * height >> 1);
-    
-    pPriv->YBuf1offset = pPriv->linear->offset + size;
-    pPriv->UBuf1offset = pPriv->YBuf1offset + (dstPitch * 2 * height);
-    pPriv->VBuf1offset = pPriv->UBuf1offset + (dstPitch * height >> 1);
-
-    /* wait for the last rendered buffer to be flipped in */
-    while (((INREG(DOV0STA)&0x00100000)>>20) != pPriv->currentBuf);
-
-    /* buffer swap */
-    if (pPriv->currentBuf == 0)
-        pPriv->currentBuf = 1;
-    else
-        pPriv->currentBuf = 0;
-
-    /* copy data */
-    top = y1 >> 16;
-    left = (x1 >> 16) & ~1;
-    npixels = ((((x2 + 0xffff) >> 16) + 1) & ~1) - left;
-
-    switch(id) {
-    case FOURCC_YV12:
-    case FOURCC_I420:
-	top &= ~1;
-	nlines = ((((y2 + 0xffff) >> 16) + 1) & ~1) - top;
-	i810CopyPlanarData(screen, buf, srcPitch, dstPitch,  height, top, left, 
-                           nlines, npixels, id);
-	break;
-    case FOURCC_UYVY:
-    case FOURCC_YUY2:
-    default:
-	nlines = ((y2 + 0xffff) >> 16) - top;
-	I810CopyPackedData(screen, buf, srcPitch, dstPitch, top, left, nlines, 
-                                                              npixels);
-        break;
-    }
-
-    /* update cliplist */
-    if(!REGION_EQUAL(screen->pScreen, &pPriv->clip, clipBoxes)) {
-	REGION_COPY(screen->pScreen, &pPriv->clip, clipBoxes);
-	KXVPaintRegion (pDraw, &pPriv->clip, pPriv->colorKey);
-    }
-
-
-    i810DisplayVideo(screen, id, width, height, dstPitch, 
-	     x1, y1, x2, y2, &dstBox, src_w, src_h, drw_w, drw_h);
-
-    pPriv->videoStatus = CLIENT_VIDEO_ON;
-
-    return Success;
-}
-
-
-static int 
-i810QueryImageAttributes(
-  KdScreenInfo *screen, 
-  int id, 
-  unsigned short *w, unsigned short *h, 
-  int *pitches, int *offsets
-){
-    int size, tmp;
-
-    if(*w > 720) *w = 720;
-    if(*h > 576) *h = 576;
-
-    *w = (*w + 1) & ~1;
-    if(offsets) offsets[0] = 0;
-
-    switch(id) {
-    case FOURCC_YV12:
-    case FOURCC_I420:
-	*h = (*h + 1) & ~1;
-	size = (*w + 3) & ~3;
-	if(pitches) pitches[0] = size;
-	size *= *h;
-	if(offsets) offsets[1] = size;
-	tmp = ((*w >> 1) + 3) & ~3;
-	if(pitches) pitches[1] = pitches[2] = tmp;
-	tmp *= (*h >> 1);
-	size += tmp;
-	if(offsets) offsets[2] = size;
-	size += tmp;
-	break;
-    case FOURCC_UYVY:
-    case FOURCC_YUY2:
-    default:
-	size = *w << 1;
-	if(pitches) pitches[0] = size;
-	size *= *h;
-	break;
-    }
-
-    return size;
-}
-
-static void
-i810BlockHandler (
-    int i,
-    pointer     blockData,
-    pointer     pTimeout,
-    pointer     pReadmask
-){
-    ScreenPtr   pScreen = screenInfo.screens[i];
-    KdScreenPriv(pScreen);
-    KdScreenInfo *screen = pScreenPriv->screen;
-    KdCardInfo *card = screen->card;
-    I810CardInfo	*i810c = (I810CardInfo *) card->driver;
-    I810PortPrivPtr pPriv = GET_PORT_PRIVATE(screen);
-    I810OverlayRegPtr overlay = (I810OverlayRegPtr) (i810c->FbBase + i810c->OverlayStart); 
-
-    pScreen->BlockHandler = i810c->BlockHandler;
-    
-    (*pScreen->BlockHandler) (i, blockData, pTimeout, pReadmask);
-
-    pScreen->BlockHandler = i810BlockHandler;
-
-    if(pPriv->videoStatus & TIMER_MASK) {
-	UpdateCurrentTime();
-	if(pPriv->videoStatus & OFF_TIMER) {
-	    if(pPriv->offTime < currentTime.milliseconds) {
-		/* Turn off the overlay */
-		overlay->OV0CMD &= 0xFFFFFFFE;
-		OVERLAY_UPDATE(i810c->OverlayPhysical);
-
-		pPriv->videoStatus = FREE_TIMER;
-		pPriv->freeTime = currentTime.milliseconds + FREE_DELAY;
-	    }
-	} else {  /* FREE_TIMER */
-	    if(pPriv->freeTime < currentTime.milliseconds) {
-		if(pPriv->linear) {
-                    xfree(pPriv->linear);
-                    pPriv->linear = NULL;
-		}
-		pPriv->videoStatus = 0;
-	    }
-        }
-    }
-}
diff --git a/hw/kdrive/i810/i810draw.c b/hw/kdrive/i810/i810draw.c
deleted file mode 100644
index b571efb..0000000
--- a/hw/kdrive/i810/i810draw.c
+++ /dev/null
@@ -1,352 +0,0 @@
-/* COPYRIGHT AND PERMISSION NOTICE
-
-Copyright (c) 2000, 2001 Nokia Home Communications
-
-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, and/or sell copies of the Software, and to permit persons
-to whom the Software is furnished to do so, provided that the above
-copyright notice(s) and this permission notice appear in all copies of
-the Software and that both the above copyright notice(s) and this
-permission notice appear in supporting documentation.
-
-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
-OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
-HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
-SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
-RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
-CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
-CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
-Except as contained in this notice, the name of a copyright holder
-shall not be used in advertising or otherwise to promote the sale, use
-or other dealings in this Software without prior written authorization
-of the copyright holder.
-
-X Window System is a trademark of The Open Group */
-
-/* Hardware accelerated drawing for KDrive i810 driver.
-   Author: Pontus Lidman <pontus.lidman at nokia.com>
-*/
-
-#ifdef HAVE_CONFIG_H
-#include <kdrive-config.h>
-#endif
-#include "kdrive.h"
-#include "kaa.h"
-#ifdef XV
-#include "kxv.h"
-#endif
-#include "i810.h"
-#include "i810_reg.h"
-
-//#include	"Xmd.h"
-#include	"gcstruct.h"
-#include	"scrnintstr.h"
-#include	"pixmapstr.h"
-#include	"regionstr.h"
-#include	"mistruct.h"
-#include	"dixfontstr.h"
-#include	"fb.h"
-#include	"migc.h"
-#include	"miline.h"
-#include	"picturestr.h"
-
-#define NUM_STACK_RECTS	1024
-
-i810ScreenInfo    *accel_i810s;
-
-static int
-i810WaitLpRing(i810ScreenInfo *i810s, int n, int timeout_millis)
-{
-    i810CardInfo *i810c = i810s->i810c;
-    I810RingBuffer *ring = &(i810c->LpRing);
-    int iters = 0;
-    int start = 0;
-    int now = 0;
-    int last_head = 0;
-    int first = 0;
-    
-    /* If your system hasn't moved the head pointer in 2 seconds, I'm going to
-    * call it crashed.
-    */
-   if (timeout_millis == 0)
-      timeout_millis = 2000;
-
-   if (I810_DEBUG) {
-      fprintf(stderr, "i810WaitLpRing %d\n", n); 
-      first = GetTimeInMillis();
-   }
-
-   while (ring->space < n) 
-   {
-      int i;
-
-      ring->head = INREG(LP_RING + RING_HEAD) & HEAD_ADDR;
-      ring->space = ring->head - (ring->tail+8);
-
-      if (ring->space < 0) 
-	 ring->space += ring->mem.Size;
-      
-      iters++;
-      now = GetTimeInMillis();
-      if ( start == 0 || now < start || ring->head != last_head) {
-	 if (I810_DEBUG)
-	    if (now > start) 
-	       fprintf(stderr, "space: %d wanted %d\n", ring->space, n ); 
-	 start = now;
-	 last_head = ring->head;
-      } else if ( now - start > timeout_millis ) { 
-
-	 i810PrintErrorState(i810c); 
-	 fprintf(stderr, "space: %d wanted %d\n", ring->space, n );
-	 FatalError("lockup\n"); 
-      }
-
-      for (i = 0 ; i < 2000 ; i++)
-	 ;
-   }
-
-   if (I810_DEBUG)
-   {
-      now = GetTimeInMillis();
-      if (now - first) {
-	 fprintf(stderr,"Elapsed %d ms\n", now - first);
-	 fprintf(stderr, "space: %d wanted %d\n", ring->space, n );
-      }
-   }
-
-   return iters;
-}
-
-static void
-i810Sync(i810ScreenInfo *i810s) 
-{
-    i810CardInfo *i810c = i810s->i810c;
-    LP_RING_LOCALS;
-
-    if (I810_DEBUG)
-	fprintf(stderr, "i810Sync\n");
-   
-   /* Send a flush instruction and then wait till the ring is empty.
-    * This is stronger than waiting for the blitter to finish as it also
-    * flushes the internal graphics caches.
-    */
-    BEGIN_LP_RING(2);
-    OUT_RING( INST_PARSER_CLIENT | INST_OP_FLUSH | INST_FLUSH_MAP_CACHE );
-    OUT_RING( 0 );		/* pad to quadword */
-    ADVANCE_LP_RING();
-
-    i810WaitLpRing(i810s, i810c->LpRing.mem.Size - 8, 0);
-
-    i810c->LpRing.space = i810c->LpRing.mem.Size - 8;
-    i810c->nextColorExpandBuf = 0;
-}
-
-static void
-i810WaitMarker(ScreenPtr pScreen, int marker)
-{
-    KdScreenPriv(pScreen);
-    i810ScreenInfo(pScreenPriv);
-
-    i810Sync(i810s);
-}
-
-#if 0
-static void
-i810EmitInvarientState(ScreenPtr pScreen)
-{
-    KdScreenPriv(pScreen);
-    i810CardInfo(pScreenPriv);
-    i810ScreenInfo(pScreenPriv);
-    LP_RING_LOCALS;
-
-    BEGIN_LP_RING( 10 );
-
-    OUT_RING( INST_PARSER_CLIENT | INST_OP_FLUSH | INST_FLUSH_MAP_CACHE );
-    OUT_RING( GFX_CMD_CONTEXT_SEL | CS_UPDATE_USE | CS_USE_CTX0 );
-    OUT_RING( INST_PARSER_CLIENT | INST_OP_FLUSH | INST_FLUSH_MAP_CACHE);
-    OUT_RING( 0 );
-
-
-    OUT_RING( GFX_OP_COLOR_CHROMA_KEY );
-    OUT_RING( CC1_UPDATE_KILL_WRITE | 
-              CC1_DISABLE_KILL_WRITE | 
-              CC1_UPDATE_COLOR_IDX |
-              CC1_UPDATE_CHROMA_LOW |
-              CC1_UPDATE_CHROMA_HI |
-              0);
-    OUT_RING( 0 );
-    OUT_RING( 0 );
-
-    /* No depth buffer in KDrive yet */
-    /*     OUT_RING( CMD_OP_Z_BUFFER_INFO ); */
-    /*     OUT_RING( pI810->DepthBuffer.Start | pI810->auxPitchBits); */
-
-    ADVANCE_LP_RING();
-}
-#endif
-
-static unsigned int i810PatternRop[16] = {
-    0x00, /* GXclear      */
-    0xA0, /* GXand        */
-    0x50, /* GXandReverse */
-    0xF0, /* GXcopy       */
-    0x0A, /* GXandInvert  */
-    0xAA, /* GXnoop       */
-    0x5A, /* GXxor        */
-    0xFA, /* GXor         */
-    0x05, /* GXnor        */
-    0xA5, /* GXequiv      */
-    0x55, /* GXinvert     */
-    0xF5, /* GXorReverse  */
-    0x0F, /* GXcopyInvert */
-    0xAF, /* GXorInverted */
-    0x5F, /* GXnand       */
-    0xFF  /* GXset        */
-};
-
-static Bool
-i810PrepareSolid(PixmapPtr pPix, int alu, Pixel pm, Pixel fg)
-{
-    KdScreenPriv(pPix->drawable.pScreen);
-    i810ScreenInfo(pScreenPriv);
-    i810CardInfo(pScreenPriv);
-
-    if (I810_DEBUG & DEBUG_VERBOSE_ACCEL)
-      ErrorF( "i810PrepareSolid color: %x rop: %x mask: %x\n", 
-	      fg, alu, pm);
-
-    /* Color blit, p166 */
-    i810c->BR[13] = BR13_SOLID_PATTERN | 
-		    (i810PatternRop[alu] << 16) |
-		    (pPix->drawable.pScreen->width * i810c->cpp);
-    i810c->BR[16] = fg;
-
-    accel_i810s = i810s;
-
-    return TRUE;
-}
-
-static void
-i810Solid(int x1, int y1, int x2, int y2)
-{
-    I810ScreenInfo *i810s = accel_i810s;
-    I810CardInfo *i810c = i810s->i810c;
-    LP_RING_LOCALS;
-
-    if (I810_DEBUG & DEBUG_VERBOSE_ACCEL)
-	ErrorF( "i810SubsequentFillRectSolid %d,%d %d,%d\n", x1, y1, x2, y2);
-
-    BEGIN_LP_RING(6);
-
-    OUT_RING( BR00_BITBLT_CLIENT | BR00_OP_COLOR_BLT | 0x3 );
-    OUT_RING( i810c->BR[13] );
-    OUT_RING( ((y2 - y1) << 16) | ((x2 - x1) * i810c->cpp));
-    OUT_RING( i810c->bufferOffset + y1 * i810s->pitch + x1 * i810c->cpp );
-
-    OUT_RING( i810c->BR[16]);
-    OUT_RING( 0 );		/* pad to quadword */
-
-    ADVANCE_LP_RING();
-}
-
-static void
-i810DoneSolid(void)
-{
-}
-
-static Bool
-i810PrepareCopy(PixmapPtr pSrc, PixmapPtr pDst, int dx, int dy, int alu, Pixel pm)
-{
-	return FALSE;
-}
-
-static void 
-i810RefreshRing(i810CardInfo *i810c)
-{
-    i810c->LpRing.head = INREG(LP_RING + RING_HEAD) & HEAD_ADDR;
-    i810c->LpRing.tail = INREG(LP_RING + RING_TAIL);
-    i810c->LpRing.space = i810c->LpRing.head - (i810c->LpRing.tail+8);
-    if (i810c->LpRing.space < 0) 
-	i810c->LpRing.space += i810c->LpRing.mem.Size;
-}
-
-
-static void
-i810SetRingRegs(i810CardInfo *i810c)
-{
-   unsigned int itemp;
-
-   OUTREG(LP_RING + RING_TAIL, 0 );
-   OUTREG(LP_RING + RING_HEAD, 0 );
-
-   itemp = INREG(LP_RING + RING_START);
-   itemp &= ~(START_ADDR);
-   itemp |= i810c->LpRing.mem.Start;
-   OUTREG(LP_RING + RING_START, itemp );
-
-   itemp = INREG(LP_RING + RING_LEN);
-   itemp &= ~(RING_NR_PAGES | RING_REPORT_MASK | RING_VALID_MASK);
-   itemp |= ((i810c->LpRing.mem.Size-4096) | RING_NO_REPORT | RING_VALID);
-   OUTREG(LP_RING + RING_LEN, itemp );
-}
-
-Bool
-i810InitAccel(ScreenPtr pScreen)
-{
-    KdScreenPriv(pScreen);
-    i810ScreenInfo(pScreenPriv);
-    i810CardInfo(pScreenPriv);
-
-    memset(&i810s->kaa, 0, sizeof(KaaScreenInfoRec));
-    i810s->kaa.waitMarker	= i810WaitMarker;
-    i810s->kaa.PrepareSolid	= i810PrepareSolid;
-    i810s->kaa.Solid		= i810Solid;
-    i810s->kaa.DoneSolid	= i810DoneSolid;
-    i810s->kaa.PrepareCopy	= i810PrepareCopy;
-    i810s->kaa.Copy		= NULL;
-    i810s->kaa.DoneCopy		= NULL;
-
-    i810s->pitch = pScreen->width * i810c->cpp;
-
-    return FALSE;
-}
-
-void
-i810EnableAccel(ScreenPtr pScreen)
-{
-    KdScreenPriv(pScreen);
-    i810CardInfo(pScreenPriv);
-
-    if (i810c->LpRing.mem.Size == 0) {
-        ErrorF("No memory for LpRing!! Acceleration not functional!!\n");
-    }
-
-    i810SetRingRegs(i810c);
-
-    kaaMarkSync (pScreen);
-}
-
-
-void
-i810DisableAccel(ScreenPtr pScreen)
-{
-    KdScreenPriv(pScreen);
-    i810CardInfo(pScreenPriv);
-    i810ScreenInfo(pScreenPriv);
-    
-    i810RefreshRing(i810c);
-    i810Sync(i810s);
-}
-
-void
-i810FiniAccel(ScreenPtr pScreen)
-{
-}
diff --git a/hw/kdrive/i810/i810draw.h b/hw/kdrive/i810/i810draw.h
deleted file mode 100644
index 7c8c044..0000000
--- a/hw/kdrive/i810/i810draw.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/* COPYRIGHT AND PERMISSION NOTICE
-
-Copyright (c) 2000, 2001 Nokia Home Communications
-
-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, and/or sell copies of the Software, and to permit persons
-to whom the Software is furnished to do so, provided that the above
-copyright notice(s) and this permission notice appear in all copies of
-the Software and that both the above copyright notice(s) and this
-permission notice appear in supporting documentation.
-
-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
-OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
-HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
-SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
-RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
-CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
-CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
-Except as contained in this notice, the name of a copyright holder
-shall not be used in advertising or otherwise to promote the sale, use
-or other dealings in this Software without prior written authorization
-of the copyright holder.
-
-X Window System is a trademark of The Open Group */
-
-/* Hardware accelerated drawing for KDrive i810 driver, header file.
-   Author: Pontus Lidman <pontus.lidman at nokia.com>
-*/
-
-
-#ifndef _I810DRAW_H_
-#define _I810DRAW_H_
-
-void  i810RefreshRing(KdScreenInfo *screen);
-int i810WaitLpRing( KdScreenInfo *screen, int n, int timeout_millis );
-void i810Sync( KdScreenInfo *screen );
-
-#endif /* _I810DRAW_H_ */
diff --git a/hw/kdrive/i810/i810stub.c b/hw/kdrive/i810/i810stub.c
deleted file mode 100644
index 3109984..0000000
--- a/hw/kdrive/i810/i810stub.c
+++ /dev/null
@@ -1,92 +0,0 @@
-/* COPYRIGHT AND PERMISSION NOTICE
-
-Copyright (c) 2000, 2001 Nokia Home Communications
-
-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, and/or sell copies of the Software, and to permit persons
-to whom the Software is furnished to do so, provided that the above
-copyright notice(s) and this permission notice appear in all copies of
-the Software and that both the above copyright notice(s) and this
-permission notice appear in supporting documentation.
-
-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
-OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
-HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
-SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
-RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
-CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
-CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
-Except as contained in this notice, the name of a copyright holder
-shall not be used in advertising or otherwise to promote the sale, use
-or other dealings in this Software without prior written authorization
-of the copyright holder.
-
-X Window System is a trademark of The Open Group */
-
-/* Stub functions for the i810 KDrive driver
-   Author: Pontus Lidman <pontus.lidman at nokia.com>
-*/
-
-#ifdef HAVE_CONFIG_H
-#include <kdrive-config.h>
-#endif
-#include "kdrive.h"
-#include "kxv.h"
-#include "i810.h"
-#include "klinux.h"
-
-static const int i810Cards[]={
-    PCI_CHIP_I810,
-    PCI_CHIP_I810_DC100,
-    PCI_CHIP_I810_E
-};
-
-#define numI810Cards (sizeof(i810Cards) / sizeof(i810Cards[0]))
-
-void
-InitCard (char *name)
-{
-    KdCardAttr	attr;
-    int		i;
-
-    for (i = 0; i < numI810Cards; i++)
-	if (LinuxFindPci (0x8086, i810Cards[i], 0, &attr))
-	    KdCardInfoAdd (&i810Funcs, &attr, (void *) i810Cards[i]);
-}
-
-
-void
-InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv)
-{
-    KdInitOutput (pScreenInfo, argc, argv);
-}
-
-void
-InitInput (int argc, char **argv)
-{
-    KdOsAddInputDrivers ();
-    KdInitInput ();
-}
-
-void
-ddxUseMsg (void)
-{
-    KdUseMsg();
-}
-
-int
-ddxProcessArgument (int argc, char **argv, int i)
-{
-    int	ret;
-    
-    ret = KdProcessArgument(argc, argv, i);
-    return ret;
-}
diff --git a/hw/kdrive/igs/igs.c b/hw/kdrive/igs/igs.c
deleted file mode 100644
index 1c446f7..0000000
--- a/hw/kdrive/igs/igs.c
+++ /dev/null
@@ -1,667 +0,0 @@
-/*
- * Copyright © 1999 SuSE, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of SuSE not be used in advertising or
- * publicity pertaining to distribution of the software without specific,
- * written prior permission.  SuSE makes no representations about the
- * suitability of this software for any purpose.  It is provided "as is"
- * without express or implied warranty.
- *
- * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
- * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
- * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
- * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * Author:  Keith Packard, SuSE, Inc.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <kdrive-config.h>
-#endif
-#include "igs.h"
-
-Bool
-igsCardInit (KdCardInfo *card)
-{
-    int		k;
-    char	*pixels;
-    IgsCardInfo	*igsc;
-
-    igsc = (IgsCardInfo *) xalloc (sizeof (IgsCardInfo));
-    if (!igsc)
-	return FALSE;
-    
-    memset (igsc, '\0', sizeof (IgsCardInfo));
-
-    igsc->frameBuffer = (CARD8 *) KdMapDevice (card->attr.address[0] +
-					       IGS_FB,
-					       IGS_MEM);
-    
-    igsc->vga = (VOL8 *) KdMapDevice (card->attr.address[0] +
-				      IGS_VGA,
-				      64 * 1024);
-
-    igsc->cop = (Cop5xxx *) KdMapDevice (card->attr.address[0] + 
-					 IGS_COP_OFFSET,
-					 sizeof (Cop5xxx));
-    
-    igsc->copData = (VOL32 *) KdMapDevice (card->attr.address[0] +
-					   IGS_COP_DATA,
-					   IGS_COP_DATA_LEN);
-    
-    igsRegInit (&igsc->igsvga, igsc->vga);
-
-    card->driver = igsc;
-    
-    return TRUE;
-}
-
-Bool
-igsModeSupported (KdScreenInfo		*screen,
-		 const KdMonitorTiming	*t)
-{
-    /* make sure the clock isn't too fast */
-    if (t->clock > IGS_MAX_CLOCK)
-	return FALSE;
-    /* width must be a multiple of 16 */
-    if (t->horizontal & 0xf)
-	return FALSE;
-    return TRUE;
-}
-
-Bool
-igsModeUsable (KdScreenInfo	*screen)
-{
-    KdCardInfo	    *card = screen->card;
-    int		    screen_size;
-    int		    pixel_width;
-    int		    byte_width;
-    int		    fb = 0;
-    
-    screen_size = 0;
-    if (screen->fb[fb].depth >= 24)
-    {
-	screen->fb[fb].depth = 24;
-	if (screen->fb[fb].bitsPerPixel != 24)
-	    screen->fb[fb].bitsPerPixel = 32;
-    }
-    else if (screen->fb[fb].depth >= 16)
-    {
-	screen->fb[fb].depth = 16;
-	screen->fb[fb].bitsPerPixel = 16;
-    }
-    else if (screen->fb[fb].depth >= 15)
-    {
-	screen->fb[fb].depth = 15;
-	screen->fb[fb].bitsPerPixel = 16;
-    }
-    else if (screen->fb[fb].depth >= 12)
-    {
-	screen->fb[fb].depth = 12;
-	screen->fb[fb].bitsPerPixel = 16;
-    }
-    else
-    {
-	screen->fb[fb].depth = 8;
-	screen->fb[fb].bitsPerPixel = 8;
-    }
-
-    byte_width = screen->width * (screen->fb[fb].bitsPerPixel >> 3);
-    pixel_width = screen->width;
-    screen->fb[fb].pixelStride = pixel_width;
-    screen->fb[fb].byteStride = byte_width;
-    screen_size += byte_width * screen->height;
-
-    return TRUE;
-}
-
-Bool
-igsScreenInit (KdScreenInfo *screen)
-{
-    IgsCardInfo		*igsc = screen->card->driver;
-    int			fb = 0;
-    IgsScreenInfo	*igss;
-    int			screen_size, memory;
-    int			pattern_size;
-    int			tile_size;
-    int			stipple_size;
-    int			poffset, boffset;
-    const KdMonitorTiming *t;
-
-    if (!screen->width || !screen->height)
-    {
-	screen->width = 800;
-	screen->height = 600;
-	screen->rate = 72;
-    }
-    if (!screen->fb[0].depth)
-	screen->fb[0].depth = 8;
-    
-    t = KdFindMode (screen, igsModeSupported);
-
-    screen->rate = t->rate;
-    screen->width = t->horizontal;
-    screen->height = t->vertical;
-
-    if (!KdTuneMode (screen, igsModeUsable, igsModeSupported))
-    {
-	return FALSE;
-    }
-    
-    igss = (IgsScreenInfo *) xalloc (sizeof (IgsScreenInfo));
-    if (!igss)
-	return FALSE;
-
-    memset (igss, '\0', sizeof (IgsScreenInfo));
-
-    screen_size = screen->fb[fb].byteStride * screen->height;
-    memory = IGS_MEM;
-    memory -= screen_size;
-    if (memory >= 1024)
-    {
-	igss->cursor_offset = memory - 1024;
-#if BITMAP_BIT_ORDER == MSBFirst
-	igss->cursor_base = (CARD8 *) KdMapDevice (card->attr.address[0] +
-						   igss->cursor_offset,
-						   1024);
-#else
-	igss->cursor_base = igsc->frameBuffer + igss->cursor_offset;
-#endif
-	memory -= 1024;
-    }
-    else
-	igss->cursor_base = 0;
-
-    tile_size = IgsTileSize(screen->fb[fb].bitsPerPixel) * IGS_NUM_PATTERN;
-    stipple_size = IgsStippleSize(screen->fb[fb].bitsPerPixel) * IGS_NUM_PATTERN;
-    pattern_size = tile_size + stipple_size;
-    if (memory >= pattern_size)
-    {
-	boffset = screen_size;
-	poffset = boffset * 8 / screen->fb[fb].bitsPerPixel;
-	igss->tile.offset = poffset;
-	igss->tile.base = igsc->frameBuffer + boffset;
-	
-	boffset = screen_size + tile_size;
-	poffset = boffset * 8 / screen->fb[fb].bitsPerPixel;
-	igss->stipple.offset = poffset;
-	igss->stipple.base = igsc->frameBuffer + boffset;
-	
-	memory -= pattern_size;
-    }
-    else
-    {
-	igss->tile.base = 0;
-	igss->stipple.base = 0;
-    }
-    
-    switch (screen->fb[fb].depth) {
-    case 8:
-	screen->fb[fb].visuals = ((1 << StaticGray) |
-				  (1 << GrayScale) |
-				  (1 << StaticColor) |
-				  (1 << PseudoColor) |
-				  (1 << TrueColor) |
-				  (1 << DirectColor));
-	screen->fb[fb].blueMask  = 0x00;
-	screen->fb[fb].greenMask = 0x00;
-	screen->fb[fb].redMask   = 0x00;
-	break;
-    case 15:
-	screen->fb[fb].visuals = (1 << TrueColor);
-	screen->fb[fb].blueMask  = 0x001f;
-	screen->fb[fb].greenMask = 0x03e0;
-	screen->fb[fb].redMask   = 0x7c00;
-	break;
-    case 16:
-	screen->fb[fb].visuals = (1 << TrueColor);
-	screen->fb[fb].blueMask  = 0x001f;
-	screen->fb[fb].greenMask = 0x07e0;
-	screen->fb[fb].redMask   = 0xf800;
-	break;
-    case 24:
-	screen->fb[fb].visuals = (1 << TrueColor);
-	screen->fb[fb].blueMask  = 0x0000ff;
-	screen->fb[fb].greenMask = 0x00ff00;
-	screen->fb[fb].redMask   = 0xff0000;
-	break;
-    }
-
-    screen->fb[fb].pixelStride = screen->width;
-    screen->fb[fb].byteStride = screen->width * (screen->fb[fb].bitsPerPixel >> 3);
-    screen->fb[fb].frameBuffer = igsc->frameBuffer;
-    if (!igsc->cop)
-	screen->dumb = TRUE;
-    screen->driver = igss;
-    return TRUE;
-}
-
-Bool
-igsInitScreen(ScreenPtr pScreen)
-{
-    return TRUE;
-}
-    
-void
-igsPreserve (KdCardInfo *card)
-{
-    IgsCardInfo	*igsc = card->driver;
-    IgsVga	*igsvga = &igsc->igsvga;
-    
-    igsSave (igsvga);
-}
-
-void
-igsSetBlank (IgsVga    *igsvga, Bool blank)
-{
-    igsSetImm(igsvga, igs_screen_off, blank ? 1 : 0);
-}
-
-void
-igsSetSync (IgsCardInfo *igsc, int hsync, int vsync)
-{
-    IgsVga   *igsvga = &igsc->igsvga;
-    
-    igsSet (igsvga, igs_mexhsyn, hsync);
-    igsSet (igsvga, igs_mexvsyn, vsync);
-    VgaFlush (&igsvga->card);
-}
-
-
-/*
- * Clock synthesis:
- *
- *  scale = p ? (2 * p) : 1
- *  f_out = f_ref * ((M + 1) / ((N + 1) * scale))
- *
- *  Constraints:
- *
- *  1.	115MHz <= f_ref * ((M + 1) / (N + 1)) <= 260 MHz
- *  2.	N >= 1
- *
- *  Vertical refresh rate = clock / ((hsize + hblank) * (vsize + vblank))
- *  Horizontal refresh rate = clock / (hsize + hblank)
- */
- 
-/* all in kHz */
-
-void
-igsGetClock (int target, int *Mp, int *Np, int *Pp, int maxM, int maxN, int maxP, int minVco)
-{
-    int	    M, N, P, bestM, bestN;
-    int	    f_vco, f_out;
-    int	    err, abserr, besterr;
-
-    /*
-     * Compute correct P value to keep VCO in range
-     */
-    for (P = 0; P <= maxP; P++)
-    {
-	f_vco = target * IGS_SCALE(P);
-	if (f_vco >= minVco)
-	    break;
-    }
-
-    /* M = f_out / f_ref * ((N + 1) * IGS_SCALE(P)); */
-    besterr = target;
-    for (N = 1; N <= maxN; N++)
-    {
-	M = ((target * (N + 1) * IGS_SCALE(P) + (IGS_CLOCK_REF/2)) + IGS_CLOCK_REF/2) / IGS_CLOCK_REF - 1;
-	if (0 <= M && M <= maxM)
-	{
-	    f_out = IGS_CLOCK(M,N,P);
-	    err = target - f_out;
-	    if (err < 0)
-		err = -err;
-	    if (err < besterr)
-	    {
-		besterr = err;
-		bestM = M;
-		bestN = N;
-	    }
-	}
-    }
-    *Mp = bestM;
-    *Np = bestN;
-    *Pp = P;
-}
-
-Bool
-igsEnable (ScreenPtr pScreen)
-{
-    KdScreenPriv(pScreen);
-    KdCardInfo	    *card = pScreenPriv->card;
-    KdScreenInfo    *screen = pScreenPriv->screen;
-    IgsCardInfo	    *igsc = card->driver;
-    IgsVga	    *igsvga = &igsc->igsvga;
-    const KdMonitorTiming *t;
-    int	    hactive, hblank, hfp, hbp;
-    int	    vactive, vblank, vfp, vbp;
-    int	    hsize;
-    int	    fb = 0;
-    int	    m, n, r;
-    int	    h_total;
-    int	    h_display_end;
-    int	    h_blank_start;
-    int	    h_blank_end;
-    int	    h_sync_start;
-    int	    h_sync_end;
-    int	    h_screen_off;
-    int	    v_total;
-    int	    v_retrace_start;
-    int	    v_retrace_end;
-    int	    v_display_end;
-    int	    v_blank_start;
-    int	    v_blank_end;
-    int	    offset;
-    int	    num_fetch;
-    int	    m_m, m_n, m_r;
-    
-    
-    igsSetBlank (igsvga, TRUE);
-    
-    t = KdFindMode (screen, igsModeSupported);
-    
-    igsGetClock (t->clock, &m, &n, &r, 2047, 255, 7, IGS_MIN_VCO);
-
-    /*
-     * Set the chip so that 0x400000 is a big-endian frame buffer
-     * with the correct byte swapping enabled
-     */
-    igsSet (igsvga, igs_biga22force, 0);
-    igsSet (igsvga, igs_biga22en, 1);
-    igsSet (igsvga, igs_biga24en, 1);
-    /*
-     * Enable 8-bit DACs
-     */
-    igsSet (igsvga, igs_rampwdn, 0);
-    igsSet (igsvga, igs_dac6_8, 1);
-    igsSet (igsvga, igs_dacpwdn, 0);
-    /*
-     * Set overscan to black
-     */
-    igsSet (igsvga, igs_overscan_red, 0x00);
-    igsSet (igsvga, igs_overscan_green, 0x00);
-    igsSet (igsvga, igs_overscan_blue, 0x00);
-    /*
-     * Enable PCI retries
-     */
-    igsSet (igsvga, igs_iow_retry, 1);
-    igsSet (igsvga, igs_mw_retry, 1);
-    igsSet (igsvga, igs_mr_retry, 1);
-    igsSet (igsvga, igs_pci_burst_write, 1);
-    igsSet (igsvga, igs_pci_burst_read, 1);
-    /*
-     * Set FIFO
-     */
-    igsSet (igsvga, igs_memgopg, 1);
-    igsSet (igsvga, igs_memr2wpg, 0);
-    igsSet (igsvga, igs_crtff16, 0);
-    igsSet (igsvga, igs_fifomust, 0xff);
-    igsSet (igsvga, igs_fifogen, 0xff);
-    /*
-     * Enable CRT reg access
-     */
-    igsSetImm (igsvga, igs_ena_vr_access, 1);
-    igsSetImm (igsvga, igs_crt_protect, 0);
-
-    hfp = t->hfp;
-    hbp = t->hbp;
-    hblank = t->hblank;
-    hactive = t->horizontal;
-    offset = screen->fb[0].byteStride;
-    
-    vfp = t->vfp;
-    vbp = t->vbp;
-    vblank = t->vblank;
-    vactive = t->vertical;
-
-    /*
-     * Compute character lengths for horizontal timing values
-     */
-    hactive = screen->width / 8;
-    hblank /= 8;
-    hfp /= 8;
-    hbp /= 8;
-    offset /= 8;
-    
-    switch (screen->fb[fb].bitsPerPixel) {
-    case 8:
-	igsSet (igsvga, igs_overscan_red, pScreen->blackPixel);
-	igsSet (igsvga, igs_overscan_green, pScreen->blackPixel);
-	igsSet (igsvga, igs_overscan_blue, pScreen->blackPixel);
-	igsSet (igsvga, igs_bigswap, IGS_BIGSWAP_8);
-	igsSet (igsvga, igs_mode_sel, IGS_MODE_8);
-	igsSet (igsvga, igs_ramdacbypass, 0);
-	break;
-    case 16:
-	igsSet (igsvga, igs_bigswap, IGS_BIGSWAP_16);
-	igsSet (igsvga, igs_ramdacbypass, 1);
-	switch (screen->fb[fb].depth) {
-	case 12:
-	    igsSet (igsvga, igs_mode_sel, IGS_MODE_4444);
-	    break;
-	case 15:
-	    igsSet (igsvga, igs_mode_sel, IGS_MODE_5551);
-	    break;
-	case 16:
-	    igsSet (igsvga, igs_mode_sel, IGS_MODE_565);
-	    break;
-	}
-	break;
-    case 24:
-	igsSet (igsvga, igs_ramdacbypass, 1);
-	igsSet (igsvga, igs_bigswap, IGS_BIGSWAP_8);
-	igsSet (igsvga, igs_mode_sel, IGS_MODE_888);
-	break;
-    case 32:
-	igsSet (igsvga, igs_ramdacbypass, 1);
-	igsSet (igsvga, igs_bigswap, IGS_BIGSWAP_32);
-	igsSet (igsvga, igs_mode_sel, IGS_MODE_8888);
-	break;
-    }
-
-    /*
-     * Compute horizontal register values from timings
-     */
-    h_total = hactive + hblank - 5;
-    h_display_end = hactive - 1;
-   
-    h_sync_start = hactive + hfp;
-    h_sync_end = hactive + hblank - hbp;
-    /* 
-     * pad the blank values narrow a bit and use the border_select to
-     * eliminate the remaining border; don't know why, but it doesn't
-     * work in the documented fashion
-     */
-    h_blank_start = hactive - 1;
-    h_blank_end = hactive + hblank - 1 - 1;
-
-    num_fetch = (t->horizontal * screen->fb[fb].bitsPerPixel / 64) + 1;
-    
-    v_total = vactive + vblank - 2;
-    v_display_end = vactive - 1;
-    
-    v_blank_start = vactive - 1;
-    v_blank_end = v_blank_start + vblank - 1;
-    
-    v_retrace_start = vactive + vfp;
-    v_retrace_end = vactive + vblank - vbp;
-
-#if 0
-#define chk(a,b,c)  fprintf (stderr, "%20.20s: BIOS %6d X %6d\n", a, igsGet(igsvga, b), c);
-
-    chk("h_total", igs_h_total, h_total);
-    chk("h_display_end", igs_h_de_end, h_display_end);
-    chk("h_sync_start", igs_h_rstart, h_sync_start);
-    chk("h_sync_end", igs_h_rend, h_sync_end&0x1f);
-    chk("h_blank_start", igs_h_bstart, h_blank_start);
-    chk("h_blank_end", igs_h_bend, h_blank_end&0x3f);
-    chk("offset", igs_offset, offset);
-    chk("num_fetch", igs_num_fetch, num_fetch);
-    
-    chk("v_total", igs_v_total, v_total);
-    chk("v_display_end", igs_v_de_end, v_display_end);
-    chk("v_blank_start", igs_v_bstart, v_blank_start);
-    chk("v_blank_end", igs_v_bend, v_blank_end&0xf);
-    chk("v_retrace_start", igs_v_rstart, v_retrace_start);
-    chk("v_retrace_end", igs_v_rend, v_retrace_end&0xf);
-    chk("vclk_m", igs_vclk_m, m);
-    chk("vclk_n", igs_vclk_n, n);
-    chk("vclk_p", igs_vclk_p, r);
-
-    fprintf (stderr, "%20.20s: BIOS %6d X %6d\n", "vclk",
-	     IGS_CLOCK(igsGet(igsvga,igs_vclk_m),
-		       igsGet(igsvga,igs_vclk_n),
-		       igsGet(igsvga,igs_vclk_p)),
-	     IGS_CLOCK(m,n,r));
-#endif
-    igsSet (igsvga, igs_h_total, h_total);
-    igsSet (igsvga, igs_h_de_end, h_display_end);
-    igsSet (igsvga, igs_h_rstart, h_sync_start);
-    igsSet (igsvga, igs_h_rend, h_sync_end);
-    igsSet (igsvga, igs_h_bstart, h_blank_start);
-    igsSet (igsvga, igs_h_bend, h_blank_end);
-    igsSet (igsvga, igs_offset, offset);
-    igsSet (igsvga, igs_num_fetch, num_fetch);
-    
-    igsSet (igsvga, igs_v_total, v_total);
-    igsSet (igsvga, igs_v_de_end, v_display_end);
-    igsSet (igsvga, igs_v_bstart, v_blank_start);
-    igsSet (igsvga, igs_v_bend, v_blank_end&0xf);
-    igsSet (igsvga, igs_v_rstart, v_retrace_start);
-    igsSet (igsvga, igs_v_rend, v_retrace_end&0xf);
-
-    igsSet (igsvga, igs_vclk_m, m);
-    igsSet (igsvga, igs_vclk_n, n);
-    igsSet (igsvga, igs_vclk_p, r);
-    igsSet (igsvga, igs_vfsel, IGS_CLOCK(m, n, 0) >= 180000);
-    VgaFlush (&igsvga->card);
-
-    igsSetImm (igsvga, igs_frqlat, 0);
-    igsSetImm (igsvga, igs_frqlat, 1);
-    igsSetImm (igsvga, igs_frqlat, 0);
-    
-    igsSetBlank (igsvga, FALSE);
-#if 0
-#define dbg(a,b) fprintf(stderr, "%20.20s = 0x%x\n", a, igsGet(igsvga,b))
-    
-#include "reg.dbg"
-
-    {
-	VGA16	reg;
-	char	buf[128];
-
-	for (reg = 0; reg < IGS_NREG; reg++)
-	    fprintf(stderr, "%20.20s = 0x%02x\n", igsRegName(buf, reg),
-		    VgaFetch (&igsvga->card, reg));
-    }
-#endif
-    return TRUE;
-}
-
-Bool
-igsDPMS (ScreenPtr pScreen, int mode)
-{
-    KdScreenPriv(pScreen);
-    IgsCardInfo	*igsc = pScreenPriv->card->driver;
-    IgsVga	*igsvga = &igsc->igsvga;
-    
-    switch (mode) {
-    case KD_DPMS_NORMAL:
-	igsSetSync (igsc, 0, 0);
-	igsSetBlank (igsvga, FALSE);
-	break;
-    case KD_DPMS_STANDBY:
-	igsSetBlank (igsvga, TRUE);
-	igsSetSync (igsc, 1, 0);
-	break;
-    case KD_DPMS_SUSPEND:
-	igsSetBlank (igsvga, TRUE);
-	igsSetSync (igsc, 0, 1);
-	break;
-    case KD_DPMS_POWERDOWN:
-	igsSetBlank (igsvga, TRUE);
-	igsSetSync (igsc, 1, 1);
-	break;
-    }
-    return TRUE;
-}
-
-void
-igsDisable (ScreenPtr pScreen)
-{
-}
-
-void
-igsRestore (KdCardInfo *card)
-{
-    IgsCardInfo	*igsc = card->driver;
-    IgsVga	*igsvga = &igsc->igsvga;
-    
-    igsReset (igsvga);
-}
-    
-void
-igsScreenFini (KdScreenInfo *screen)
-{
-    IgsScreenInfo   *igss = (IgsScreenInfo *) screen->driver;
-
-#if BITMAP_BIT_ORDER == MSBFirst
-    if (igss->cursor_base)
-	KdUnmapDevice ((void *) igss->cursor_base, 1024);
-#endif
-    xfree (igss);
-    screen->driver = 0;
-}
-    
-void
-igsCardFini (KdCardInfo *card)
-{
-    IgsCardInfo	*igsc = card->driver;
-
-    if (igsc->copData)
-	KdUnmapDevice ((void *) igsc->copData, IGS_COP_DATA_LEN);
-    if (igsc->cop)
-	KdUnmapDevice ((void *) igsc->cop, sizeof (Cop5xxx));
-    if (igsc->vga)
-	KdUnmapDevice ((void *) igsc->vga, 64 * 1024);
-    if (igsc->frameBuffer)
-	KdUnmapDevice (igsc->frameBuffer, IGS_MEM);
-    xfree (igsc);
-    card->driver = 0;
-}
-
-KdCardFuncs	igsFuncs = {
-    igsCardInit,	    /* cardinit */
-    igsScreenInit,	    /* scrinit */
-    igsInitScreen,
-    igsPreserve,	    /* preserve */
-    igsEnable,		    /* enable */
-    igsDPMS,		    /* dpms */
-    igsDisable,		    /* disable */
-    igsRestore,		    /* restore */
-    igsScreenFini,	    /* scrfini */
-    igsCardFini,	    /* cardfini */
-    
-    igsCursorInit,    	    /* initCursor */
-    igsCursorEnable,	    /* enableCursor */
-    igsCursorDisable,	    /* disableCursor */
-    igsCursorFini,    	    /* finiCursor */
-    0,			    /* recolorCursor */
-    
-    igsDrawInit,    	    /* initAccel */
-    igsDrawEnable,    	    /* enableAccel */
-    igsDrawSync,	    /* drawSync */
-    igsDrawDisable,    	    /* disableAccel */
-    igsDrawFini,    	    /* finiAccel */
-    
-    igsGetColors,    	    /* getColors */
-    igsPutColors, 	    /* putColors */
-};
diff --git a/hw/kdrive/igs/igs.h b/hw/kdrive/igs/igs.h
deleted file mode 100644
index 9f0336b..0000000
--- a/hw/kdrive/igs/igs.h
+++ /dev/null
@@ -1,327 +0,0 @@
-/*
- * Copyright © 1999 SuSE, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of SuSE not be used in advertising or
- * publicity pertaining to distribution of the software without specific,
- * written prior permission.  SuSE makes no representations about the
- * suitability of this software for any purpose.  It is provided "as is"
- * without express or implied warranty.
- *
- * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
- * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
- * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
- * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * Author:  Keith Packard, SuSE, Inc.
- */
-
-#ifndef _IGS_H_
-#define _IGS_H_
-
-#include "kdrive.h"
-#include "igsreg.h"
-
-extern KdCardFuncs  igsFuncs;
-
-/*
- * FB		0x00000000
- * VGA		0x00800000
- * Blt window	0x008a0000
- * Coprocessor	0x008bf000
- */
-
-#if BITMAP_BIT_ORDER == MSBFirst
-#define IGS_FB		    0x00400000
-#else
-#define IGS_FB		    0x00000000
-#endif
-#define IGS_VGA		    0x00800000
-#define IGS_COP_DATA	    0x008a0000
-#define IGS_COP_DATA_LEN    0x00010000
-#define IGS_COP_OFFSET	    0x008bf000
-/* give audio 1/2 meg at end */
-#if 1
-#define IGS_MEM		    ((4096-512)*1024)
-#else
-#define IGS_MEM		    ((4096)*1024)
-#endif
-
-#define IGS_CLOCK_REF	24576	/* KHz */
-
-#define IGS_SCALE(p)	((p) ? (2 * (p)) : 1)
-
-#define IGS_CLOCK(m,n,p)	((IGS_CLOCK_REF * ((m) + 1)) / (((n) + 1) * IGS_SCALE(p)))
-
-#define IGS_MAX_CLOCK	260000
-
-#define IGS_MIN_VCO	115000
-
-typedef volatile CARD8	VOL8;
-typedef volatile CARD16	VOL16;
-typedef volatile CARD32	VOL32;
-
-typedef struct _Cop5xxx {
-    VOL8	pad000[0x10];		    /* 0x000 */
-    
-    VOL32	control;		    /* 0x010 */
-#define IGS_CONTROL_HBLTW_RDYZ	    0x0100
-#define IGS_CONTROL_MALLWBEPTZ	    0x0200
-#define IGS_CONTROL_CMDFF	    0x0400
-#define IGS_CONTROL_SOP		    0x0800
-#define IGS_CONTROL_OPS		    0x1000
-#define IGS_CONTROL_TER		    0x2000
-#define IGS_CONTROL_HBACKZ	    0x4000
-#define IGS_CONTROL_BUSY	    0x8000
-    
-    VOL8	pad014[0x04];		    /* 0x014 */
-    
-    VOL32	src1_stride;		    /* 0x018 */
-    
-    VOL32	format;			    /* 0x01c */
-
-#define IGS_FORMAT_8BPP	    0
-#define IGS_FORMAT_16BPP    1
-#define IGS_FORMAT_24BPP    2
-#define IGS_FORMAT_32BPP    3
-
-    VOL32	bres_error;		    /* 0x020 */
-    VOL32	bres_k1;		    /* 0x024 */
-    VOL32	bres_k2;		    /* 0x028 */
-    VOL8	pad02c[0x1c];		    /* 0x02c */
-    
-    VOL32	mix;			    /* 0x048 */
-#define IGS_MIX_FG	0x00ff
-#define IGS_MIX_BG	0xff00
-#define IGS_MAKE_MIX(fg,bg)	((fg) | ((bg) << 8))
-
-#define IGS_MIX_ZERO		    0x0
-#define IGS_MIX_SRC_AND_DST	    0x1
-#define IGS_MIX_SRC_AND_NOT_DST	    0x2
-#define IGS_MIX_SRC		    0x3
-#define IGS_MIX_NOT_SRC_AND_DST	    0x4
-#define IGS_MIX_DST		    0x5
-#define IGS_MIX_SRC_XOR_DST	    0x6
-#define IGS_MIX_SRC_OR_DST	    0x7
-#define IGS_MIX_NOT_SRC_AND_NOT_DST 0x8
-#define IGS_MIX_SRC_XOR_NOT_DST	    0x9
-#define IGS_MIX_NOT_DST		    0xa
-#define IGS_MIX_SRC_OR_NOT_DST	    0xb
-#define IGS_MIX_NOT_SRC		    0xc
-#define IGS_MIX_NOT_SRC_OR_DST	    0xd
-#define IGS_MIX_NOT_SRC_OR_NOT_DST  0xe
-#define IGS_MIX_ONE		    0xf
-    
-    VOL32	colorComp;		    /* 0x04c */
-    VOL32	planemask;		    /* 0x050 */
-    
-    VOL8	pad054[0x4];		    /* 0x054 */
-    
-    VOL32	fg;			    /* 0x058 */
-    VOL32	bg;			    /* 0x05c */
-    VOL32	dim;			    /* 0x060 */
-#define IGS_MAKE_DIM(w,h)   ((w) | ((h) << 16))
-    VOL8	pad5[0x0c];		    /* 0x064 */
-    
-    VOL32	src1_base_address;	    /* 0x070 */
-    VOL8	pad074[0x04];		    /* 0x074 */
-    
-    VOL32	rotate;			    /* 0x078 */
-#define IGS_MAKE_ROTATE(x,y)	((x) | ((y) << 16))
-    VOL32	operation;		    /* 0x07c */
-
-/* OCT[2:0] */
-#define IGS_DRAW_X_MAJOR	0x00000000
-#define IGS_DRAW_Y_MAJOR	0x00000001
-#define IGS_DRAW_T_B		0x00000000
-#define IGS_DRAW_B_T		0x00000002
-#define IGS_DRAW_L_R		0x00000000
-#define IGS_DRAW_R_L		0x00000004
-    
-/* Draw_Mode[1:0] */
-#define IGS_DRAW_ALL		0x00000000
-#define IGS_DRAW_NOT_FIRST	0x00000010
-#define IGS_DRAW_NOT_LAST	0x00000020
-#define IGS_DRAW_NOT_FIRST_LAST	0x00000030
-
-/* TRPS[1:0] */
-#define IGS_TRANS_SRC1		0x00000000
-#define IGS_TRANS_SRC2		0x00000100
-#define IGS_TRANS_DST		0x00000200
-/* TRPS2 Transparent Invert */
-#define IGS_TRANS_INVERT	0x00000400
-/* TRPS3, Transparent Enable */
-#define IGS_TRANS_ENABLE	0x00000800
-
-/* PPS[3:0], Pattern Pixel Select */
-#define IGS_PIXEL_TEXT_OPAQUE	0x00001000
-#define IGS_PIXEL_STIP_OPAQUE	0x00002000
-#define IGS_PIXEL_LINE_OPAQUE	0x00003000
-#define IGS_PIXEL_TEXT_TRANS	0x00005000
-#define IGS_PIXEL_STIP_TRANS	0x00006000
-#define IGS_PIXEL_LINE_TRANS	0x00007000
-#define IGS_PIXEL_FG		0x00008000
-#define IGS_PIXEL_TILE		0x00009000
-#define IGS_PIXEL_TILE_OPAQUE	0x0000d000
-    
-/* HostBltEnable[1:0] */
-#define IGS_HBLT_DISABLE	0x00000000
-#define IGS_HBLT_READ		0x00010000
-#define IGS_HBLT_WRITE_1	0x00020000
-#define IGS_HBLT_WRITE_2	0x00030000
-
-/* Src2MapSelect[2:0], Src2 map select mode */
-#define IGS_SRC2_NORMAL		0x00000000
-#define IGS_SRC2_MONO_OPAQUE	0x00100000
-#define IGS_SRC2_FG		0x00200000
-#define IGS_SRC2_MONO_TRANS	0x00500000
-
-/* StepFunction[3:0], Step function select */
-#define IGS_STEP_DRAW_AND_STEP	0x04000000
-#define IGS_STEP_LINE_DRAW	0x05000000
-#define IGS_STEP_PXBLT		0x08000000
-#define IGS_STEP_INVERT_PXBLT	0x09000000
-#define IGS_STEP_TERNARY_PXBLT	0x0b000000
-
-/* FGS */
-#define IGS_FGS_FG		0x00000000
-#define IGS_FGS_SRC		0x20000000
-    
-/* BGS */
-#define IGS_BGS_BG		0x00000000
-#define IGS_BGS_SRC		0x80000000
-    VOL8	pad080[0x90];		    /* 0x080 */
-    
-    VOL32	debug_control;		    /* 0x110 */
-    VOL8	pad114[0x04];		    /* 0x114 */
-    
-    VOL32	src2_stride;		    /* 0x118 */
-    VOL8	pad11c[0x14];		    /* 0x11c */
-    
-    VOL32	extension;		    /* 0x130 */
-
-#define IGS_BURST_ENABLE    0x01
-#define IGS_STYLE_LINE	    0x02
-#define IGS_ADDITIONAL_WAIT 0x04
-#define	IGS_BLOCK_COP_REG   0x08
-#define IGS_TURBO_MONO	    0x10
-#define IGS_SELECT_SAMPLE   0x40
-#define IGS_MDSBL_RD_B_WR   0x80
-#define IGS_WRMRSTZ	    0x100
-#define IGS_TEST_MTST	    0x200
-
-    VOL32	style_line;		    /* 0x134 */
-#define IGS_MAKE_STILE_LINE(roll_over,inc,pattern,accumulator) \
-    ((roll_over) | \
-     ((style_line_inc) << 8) | \
-     ((style_line_patern) << 16) | \
-     ((style_line_accumullator) << 24))
-    VOL32	style_line_pattern_index;   /* 0x138 */
-
-    VOL32	mono_burst_total;	    /* 0x13c */
-    VOL8	pad140[0x10];		    /* 0x140 */
-    
-    VOL32	pat_x_rotate;		    /* 0x150 */
-    VOL8	pad154[0x1c];		    /* 0x154 */
-
-    VOL32	src1_start;		    /* 0x170 */
-    VOL32	src2_start;		    /* 0x174 */
-    VOL32	dst_start;		    /* 0x178 */
-    VOL8	pad17c[0x9c];		    /* 0x17c */
-    
-    VOL32	dst_stride;		    /* 0x218 */
-} Cop5xxx;
-
-typedef struct _igsCardInfo {
-    Cop5xxx	*cop;
-    VOL8	*vga;
-    VOL32	*copData;
-    CARD8	*frameBuffer;
-    IgsVga	igsvga;
-} IgsCardInfo;
-    
-#define getIgsCardInfo(kd)  ((IgsCardInfo *) ((kd)->card->driver))
-#define igsCardInfo(kd)	    IgsCardInfo	*igsc = getIgsCardInfo(kd)
-
-typedef struct _igsCursor {
-    int		width, height;
-    int		xhot, yhot;
-    Bool	has_cursor;
-    CursorPtr	pCursor;
-    Pixel	source, mask;
-} IgsCursor;
-
-#define IGS_CURSOR_WIDTH	64
-#define IGS_CURSOR_HEIGHT	64
-
-typedef struct _igsPattern {
-    INT32	xrot, yrot;
-    CARD32	serial_number;
-    CARD8	*base;
-    CARD32	offset;
-} IgsPattern;
-
-#define IGS_NUM_PATTERN		8
-#define IGS_PATTERN_WIDTH	8
-#define IGS_PATTERN_HEIGHT	8
-
-typedef struct _igsPatternCache {
-    CARD8	*base;
-    CARD32	offset;
-    IgsPattern	pattern[IGS_NUM_PATTERN];
-    int		next;
-} IgsPatternCache;
-
-typedef struct _igsScreenInfo {
-    CARD8	    *cursor_base;
-    CARD32	    cursor_offset;
-    IgsCursor	    cursor;
-    IgsPatternCache tile;
-    IgsPatternCache stipple;
-} IgsScreenInfo;
-
-#define IgsTileSize(bpp)	(IGS_PATTERN_WIDTH*(bpp)/8*IGS_PATTERN_HEIGHT)
-#define IgsStippleSize(bpp)	(IGS_PATTERN_WIDTH/8*IGS_PATTERN_HEIGHT)
-
-#define getIgsScreenInfo(kd) ((IgsScreenInfo *) ((kd)->screen->driver))
-#define igsScreenInfo(kd)    IgsScreenInfo *igss = getIgsScreenInfo(kd)
-
-Bool
-igsDrawInit (ScreenPtr pScreen);
-
-void
-igsDrawEnable (ScreenPtr pScreen);
-
-void
-igsDrawDisable (ScreenPtr pScreen);
-
-void
-igsDrawSync (ScreenPtr pScreen);
-
-void
-igsDrawFini (ScreenPtr pScreen);
-
-void
-igsGetColors (ScreenPtr pScreen, int fb, int ndef, xColorItem *pdefs);
-
-void
-igsPutColors (ScreenPtr pScreen, int fb, int ndef, xColorItem *pdefs);
-
-Bool
-igsCursorInit (ScreenPtr pScreen);
-
-void
-igsCursorEnable (ScreenPtr pScreen);
-
-void
-igsCursorDisable (ScreenPtr pScreen);
-
-void
-igsCursorFini (ScreenPtr pScreen);
-
-#endif /* _IGS_H_ */
diff --git a/hw/kdrive/igs/igscmap.c b/hw/kdrive/igs/igscmap.c
deleted file mode 100644
index dff028e..0000000
--- a/hw/kdrive/igs/igscmap.c
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright © 2000 Keith Packard
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Keith Packard not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  Keith Packard makes no
- * representations about the suitability of this software for any purpose.  It
- * is provided "as is" without express or implied warranty.
- *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <kdrive-config.h>
-#endif
-#include "igs.h"
-
-#define IGS_DAC_SHIFT	8
-void
-igsGetColors (ScreenPtr pScreen, int fb, int ndef, xColorItem *pdefs)
-{
-    KdScreenPriv(pScreen);
-    igsCardInfo(pScreenPriv);
-    IgsVga   *igsvga = &igsc->igsvga;
-
-    while (ndef--)
-    {
-	igsSetImm (igsvga, igs_dac_read_index, pdefs->pixel);
-	pdefs->red = igsGetImm (igsvga, igs_dac_data) << IGS_DAC_SHIFT;
-	pdefs->green = igsGetImm (igsvga, igs_dac_data) << IGS_DAC_SHIFT;
-	pdefs->blue = igsGetImm (igsvga, igs_dac_data) << IGS_DAC_SHIFT;
-	pdefs++;
-    }
-}
-
-void
-igsPutColors (ScreenPtr pScreen, int fb, int ndef, xColorItem *pdefs)
-{
-    KdScreenPriv(pScreen);
-    igsCardInfo(pScreenPriv);
-    IgsVga   *igsvga = &igsc->igsvga;
-
-    while (ndef--)
-    {
-	igsSetImm (igsvga, igs_dac_write_index, pdefs->pixel);
-	igsSetImm (igsvga, igs_dac_data, pdefs->red >> IGS_DAC_SHIFT);
-	igsSetImm (igsvga, igs_dac_data, pdefs->green >> IGS_DAC_SHIFT);
-	igsSetImm (igsvga, igs_dac_data, pdefs->blue >> IGS_DAC_SHIFT);
-	pdefs++;
-    }
-}
-
diff --git a/hw/kdrive/igs/igscurs.c b/hw/kdrive/igs/igscurs.c
deleted file mode 100644
index b8bd509..0000000
--- a/hw/kdrive/igs/igscurs.c
+++ /dev/null
@@ -1,345 +0,0 @@
-/*
- * Copyright © 2000 Keith Packard
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Keith Packard not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  Keith Packard makes no
- * representations about the suitability of this software for any purpose.  It
- * is provided "as is" without express or implied warranty.
- *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <kdrive-config.h>
-#endif
-#include "igs.h"
-#include "cursorstr.h"
-
-#define SetupCursor(s)	    KdScreenPriv(s); \
-			    igsCardInfo(pScreenPriv); \
-			    igsScreenInfo(pScreenPriv); \
-			    IgsCursor *pCurPriv = &igss->cursor; \
-			    IgsVga    *igsvga = &igsc->igsvga
-
-static void
-_igsMoveCursor (ScreenPtr pScreen, int x, int y)
-{
-    SetupCursor(pScreen);
-    CARD8   xoff, yoff;
-
-    x -= pCurPriv->xhot;
-    xoff = 0;
-    if (x < 0)
-    {
-	xoff = -x;
-	x = 0;
-    }
-    y -= pCurPriv->yhot;
-    yoff = 0;
-    if (y < 0)
-    {
-	yoff = -y;
-	y = 0;
-    }
-
-    igsSet (igsvga, igs_sprite_x, x);
-    igsSet (igsvga, igs_sprite_preset_x, xoff);
-    igsSet (igsvga, igs_sprite_y, y);
-    igsSet (igsvga, igs_sprite_preset_y, yoff);
-}
-
-static void
-igsMoveCursor (ScreenPtr pScreen, int x, int y)
-{
-    SetupCursor (pScreen);
-    
-    if (!pCurPriv->has_cursor)
-	return;
-    
-    if (!pScreenPriv->enabled)
-	return;
-    
-    _igsMoveCursor (pScreen, x, y);
-    VgaFlush (&igsvga->card);
-}
-
-
-static void
-igsSetCursorColors (ScreenPtr pScreen)
-{
-    SetupCursor (pScreen);
-    CursorPtr	pCursor = pCurPriv->pCursor;
-    
-    igsSetImm (igsvga, igs_cursor_write_index, 0);
-    igsSetImm (igsvga, igs_cursor_data, pCursor->backRed >> 8);
-    igsSetImm (igsvga, igs_cursor_data, pCursor->backGreen >> 8);
-    igsSetImm (igsvga, igs_cursor_data, pCursor->backBlue >> 8);
-    igsSetImm (igsvga, igs_cursor_write_index, 1);
-    igsSetImm (igsvga, igs_cursor_data, pCursor->foreRed >> 8);
-    igsSetImm (igsvga, igs_cursor_data, pCursor->foreGreen >> 8);
-    igsSetImm (igsvga, igs_cursor_data, pCursor->foreBlue >> 8);
-}
-    
-#if BITMAP_BIT_ORDER == MSBFirst
-#define IgsAdjustCursor(v) { \
-    v = ((v & 0x55555555) << 1) | ((v >> 1) & 0x55555555); \
-    v = ((v & 0x33333333) << 2) | ((v >> 2) & 0x33333333); \
-    v = ((v & 0x0f0f0f0f) << 4) | ((v >> 4) & 0x0f0f0f0f); \
-    v = ((v & 0x00ff00ff) << 8) | ((v >> 8) & 0x00ff00ff); \
-    v = ((v & 0x0000ffff) <<16) | ((v >>16) & 0x0000ffff); \
-}
-#else
-#define IgsAdjustCursor(v)
-#endif
-
-#define ExplodeBits2(v)	    (((v) & 1) | (((v) & 2) << 1))
-#define ExplodeBits4(v)     ((ExplodeBits2((v) >> 2) << 4) | \
-			     (ExplodeBits2((v) & 0x3)))
-#define ExplodeBits8(v)	    ((ExplodeBits4((v) >> 4) << 8) | \
-			     (ExplodeBits4((v) & 0xf)))
-#define ExplodeBits16(v)    ((ExplodeBits8((v) >> 8) << 16) | \
-			     (ExplodeBits8((v) & 0xff)))
-static void
-igsLoadCursor (ScreenPtr pScreen, int x, int y)
-{
-    SetupCursor(pScreen);
-    CursorPtr	    pCursor = pCurPriv->pCursor;
-    CursorBitsPtr   bits = pCursor->bits;
-    int	w, h;
-    CARD32	    *ram, *msk, *mskLine, *src, *srcLine;
-    int		    i, j;
-    int		    cursor_address;
-    int		    lwsrc;
-    unsigned char   ramdac_control_;
-    CARD32	    offset;
-    CARD32	    b0, b1;
-
-    pCurPriv->pCursor = pCursor;
-    pCurPriv->xhot = pCursor->bits->xhot;
-    pCurPriv->yhot = pCursor->bits->yhot;
-    
-    /*
-     * Stick new image into cursor memory
-     */
-    ram = (CARD32 *) igss->cursor_base;
-    mskLine = (CARD32 *) bits->mask;
-    srcLine = (CARD32 *) bits->source;
-
-    h = bits->height;
-    if (h > IGS_CURSOR_HEIGHT)
-	h = IGS_CURSOR_HEIGHT;
-
-    lwsrc = BitmapBytePad(bits->width) / 4;        /* words per line */
-
-    for (i = 0; i < IGS_CURSOR_HEIGHT; i++) {
-	msk = mskLine;
-	src = srcLine;
-	mskLine += lwsrc;
-	srcLine += lwsrc;
-	for (j = 0; j < IGS_CURSOR_WIDTH / 32; j++) {
-
-	    CARD32  m, s;
-
-	    if (i < h && j < lwsrc) 
-	    {
-		m = *msk++;
-		s = *src++;
-		IgsAdjustCursor(m);
-		IgsAdjustCursor(s);
-	    }
-	    else
-	    {
-		m = 0;
-		s = 0;
-	    }
-	    s &= m;
-	    m = ~m;
-	    b0 = ExplodeBits16(s&0xffff) | (ExplodeBits16(m&0xffff)<<1);
-	    b1 = ExplodeBits16(s>>16) | (ExplodeBits16(m>>16)<<1);
-	    *ram++ = b0;
-	    *ram++ = b1;
-	}
-    }
-    
-    /* Set new color */
-    igsSetCursorColors (pScreen);
-     
-    /* Set address for cursor bits */
-    offset = igss->cursor_offset;
-    offset >>= 10;
-    igsSet (igsvga, igs_sprite_addr, offset);
-    
-    /* Assume TV interpolation off */
-    igsSet (igsvga, igs_hcshf, 3);
-    /* Enable the cursor */
-    igsSet (igsvga, igs_sprite_visible, 1);
-    igsSet (igsvga, igs_sprite_64x64, 1);
-    /* Move to new position */
-    _igsMoveCursor (pScreen, x, y);
-
-    VgaFlush (&igsvga->card);
-}
-
-static void
-igsUnloadCursor (ScreenPtr pScreen)
-{
-    SetupCursor (pScreen);
-    
-    /* Disable cursor */
-    igsSet (igsvga, igs_sprite_visible, 0);
-    VgaFlush (&igsvga->card);
-}
-
-static Bool
-igsRealizeCursor (ScreenPtr pScreen, CursorPtr pCursor)
-{
-    SetupCursor(pScreen);
-
-    if (!pScreenPriv->enabled)
-	return TRUE;
-    
-    /* miRecolorCursor does this */
-    if (pCurPriv->pCursor == pCursor)
-    {
-	if (pCursor)
-	{
-	    int	    x, y;
-	    
-	    miPointerPosition (&x, &y);
-	    igsLoadCursor (pScreen, x, y);
-	}
-    }
-    return TRUE;
-}
-
-static Bool
-igsUnrealizeCursor (ScreenPtr pScreen, CursorPtr pCursor)
-{
-    return TRUE;
-}
-
-static void
-igsSetCursor (ScreenPtr pScreen, CursorPtr pCursor, int x, int y)
-{
-    SetupCursor(pScreen);
-
-    pCurPriv->pCursor = pCursor;
-    
-    if (!pScreenPriv->enabled)
-	return;
-    
-    if (pCursor)
-	igsLoadCursor (pScreen, x, y);
-    else
-	igsUnloadCursor (pScreen);
-}
-
-miPointerSpriteFuncRec igsPointerSpriteFuncs = {
-    igsRealizeCursor,
-    igsUnrealizeCursor,
-    igsSetCursor,
-    igsMoveCursor,
-};
-
-static void
-igsQueryBestSize (int class, 
-		 unsigned short *pwidth, unsigned short *pheight, 
-		 ScreenPtr pScreen)
-{
-    SetupCursor (pScreen);
-
-    switch (class)
-    {
-    case CursorShape:
-	if (*pwidth > pCurPriv->width)
-	    *pwidth = pCurPriv->width;
-	if (*pheight > pCurPriv->height)
-	    *pheight = pCurPriv->height;
-	if (*pwidth > pScreen->width)
-	    *pwidth = pScreen->width;
-	if (*pheight > pScreen->height)
-	    *pheight = pScreen->height;
-	break;
-    default:
-	fbQueryBestSize (class, pwidth, pheight, pScreen);
-	break;
-    }
-}
-
-Bool
-igsCursorInit (ScreenPtr pScreen)
-{
-    SetupCursor (pScreen);
-
-    if (!igss->cursor_base)
-    {
-	pCurPriv->has_cursor = FALSE;
-	return FALSE;
-    }
-    
-    pCurPriv->width = IGS_CURSOR_WIDTH;
-    pCurPriv->height= IGS_CURSOR_HEIGHT;
-    pScreen->QueryBestSize = igsQueryBestSize;
-    miPointerInitialize (pScreen,
-			 &igsPointerSpriteFuncs,
-			 &kdPointerScreenFuncs,
-			 FALSE);
-    pCurPriv->has_cursor = TRUE;
-    pCurPriv->pCursor = NULL;
-    return TRUE;
-}
-
-void
-igsCursorEnable (ScreenPtr pScreen)
-{
-    SetupCursor (pScreen);
-
-    if (pCurPriv->has_cursor)
-    {
-	if (pCurPriv->pCursor)
-	{
-	    int	    x, y;
-	    
-	    miPointerPosition (&x, &y);
-	    igsLoadCursor (pScreen, x, y);
-	}
-	else
-	    igsUnloadCursor (pScreen);
-    }
-}
-
-void
-igsCursorDisable (ScreenPtr pScreen)
-{
-    SetupCursor (pScreen);
-
-    if (!pScreenPriv->enabled)
-	return;
-    
-    if (pCurPriv->has_cursor)
-    {
-	if (pCurPriv->pCursor)
-	{
-	    igsUnloadCursor (pScreen);
-	}
-    }
-}
-
-void
-igsCursorFini (ScreenPtr pScreen)
-{
-    SetupCursor (pScreen);
-
-    pCurPriv->pCursor = NULL;
-}
diff --git a/hw/kdrive/igs/igsdraw.c b/hw/kdrive/igs/igsdraw.c
deleted file mode 100644
index 677436b..0000000
--- a/hw/kdrive/igs/igsdraw.c
+++ /dev/null
@@ -1,1463 +0,0 @@
-/*
- * Copyright © 2000 Keith Packard
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Keith Packard not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  Keith Packard makes no
- * representations about the suitability of this software for any purpose.  It
- * is provided "as is" without express or implied warranty.
- *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <kdrive-config.h>
-#endif
-#include "igs.h"
-#include "igsdraw.h"
-
-#include	"Xmd.h"
-#include	"gcstruct.h"
-#include	"scrnintstr.h"
-#include	"pixmapstr.h"
-#include	"regionstr.h"
-#include	"mistruct.h"
-#include	"fontstruct.h"
-#include	"dixfontstr.h"
-#include	"fb.h"
-#include	"migc.h"
-#include	"miline.h"
-
-CARD8 igsPatRop[16] = {
-    /* GXclear      */      0x00,         /* 0 */
-    /* GXand        */      0xa0,         /* src AND dst */
-    /* GXandReverse */      0x50,         /* src AND NOT dst */
-    /* GXcopy       */      0xf0,         /* src */
-    /* GXandInverted*/      0x0a,         /* NOT src AND dst */
-    /* GXnoop       */      0xaa,         /* dst */
-    /* GXxor        */      0x5a,         /* src XOR dst */
-    /* GXor         */      0xfa,         /* src OR dst */
-    /* GXnor        */      0x05,         /* NOT src AND NOT dst */
-    /* GXequiv      */      0xa5,         /* NOT src XOR dst */
-    /* GXinvert     */      0x55,         /* NOT dst */
-    /* GXorReverse  */      0xf5,         /* src OR NOT dst */
-    /* GXcopyInverted*/     0x0f,         /* NOT src */
-    /* GXorInverted */      0xaf,         /* NOT src OR dst */
-    /* GXnand       */      0x5f,         /* NOT src OR NOT dst */
-    /* GXset        */      0xff,         /* 1 */
-};
-
-/*
- * Handle pixel transfers
- */
-
-#define BURST
-#ifdef BURST
-#define PixTransDeclare	VOL32	*pix_trans_base = igsc->copData,\
-				*pix_trans = pix_trans_base
-#define PixTransStart(n)	if (pix_trans + (n) > pix_trans_base + 16384) pix_trans = pix_trans_base
-#define PixTransStore(t)	*pix_trans++ = (t)
-#else
-#define PixTransDeclare	VOL32	*pix_trans = igsc->copData
-#define PixTransStart(n)	
-#define PixTransStore(t)	*pix_trans = (t)
-#endif
-
-static IgsPattern *
-igsSetPattern (ScreenPtr    pScreen,
-	       PixmapPtr    pPixmap,
-	       CARD8	    fillStyle,
-	       INT32	    xrot,
-	       INT32	    yrot)
-{
-    KdScreenPriv(pScreen);
-    igsCardInfo(pScreenPriv);
-    igsScreenInfo(pScreenPriv);
-    int		i;
-    IgsPatternCache *c;
-    IgsPattern	*p;
-
-    if (fillStyle == FillTiled)
-	c = &igss->tile;
-    else
-	c = &igss->stipple;
-    for (i = 0; i < IGS_NUM_PATTERN; i++)
-    {
-	p = &c->pattern[i];
-	if (p->serial_number == pPixmap->drawable.serialNumber &&
-	    p->xrot == xrot &&
-	    p->yrot == yrot)
-	{
-	    return p;
-	}
-    }
-    p = &c->pattern[c->next];
-    if (++c->next == IGS_NUM_PATTERN)
-	c->next = 0;
-    p->serial_number = pPixmap->drawable.serialNumber;
-    p->xrot = xrot;
-    p->yrot = yrot;
-
-    if (fillStyle != FillTiled)
-    {
-	FbStip	    *pix;
-	FbStride    pixStride;
-	int	    pixBpp;
-	int	    pixXoff, pixYoff;
-	CARD8	    tmp[8];
-	CARD32	    *pat;
-	int	    stipX, stipY;
-	int	    y;
-	FbStip	    bits;
-
-	fbGetStipDrawable (&pPixmap->drawable, pix, pixStride, pixBpp, pixXoff, pixYoff);
-	
-	modulus (-yrot - pixYoff, pPixmap->drawable.height, stipY);
-	modulus (-xrot - pixXoff, FB_UNIT, stipX);
-
-	pat = (CARD32 *) p->base;
-
-	for (y = 0; y < 8; y++)
-	{
-	    bits = pix[stipY * pixStride];
-	    FbRotLeft (bits, stipX);
-	    tmp[y] = (CARD8) bits;
-	    stipY++;
-	    if (stipY == pPixmap->drawable.height)
-		stipY = 0;
-	}
-	for (i = 0; i < 2; i++)
-	{
-	    bits = (tmp[i*4+0] | 
-		      (tmp[i*4+1] << 8) | 
-		      (tmp[i*4+2] << 16) |
-		      (tmp[i*4+3] << 24));
-	    IgsAdjustBits32 (bits);
-	    *pat++ = bits;
-	}
-    }
-    else
-    {
-	FbBits	    *pix;
-	FbStride    pixStride;
-	int	    pixBpp;
-	FbBits	    *pat;
-	FbStride    patStride;
-	int	    patBpp;
-	int	    patXoff, patYoff;
-	
-	fbGetDrawable (&pPixmap->drawable, pix, pixStride, pixBpp, patXoff, patYoff);
-
-	pat = (FbBits *) p->base;
-	patBpp = pixBpp;
-	patStride = (patBpp * IGS_PATTERN_WIDTH) / (8 * sizeof (FbBits));
-
-	fbTile (pat, patStride, 0,
-		patBpp * IGS_PATTERN_WIDTH, IGS_PATTERN_HEIGHT,
-
-		pix, pixStride, 
-		pPixmap->drawable.width * pixBpp,
-		pPixmap->drawable.height,
-		GXcopy, FB_ALLONES, pixBpp,
-		(xrot - patXoff) * pixBpp, yrot - patYoff);
-    }
-    return p;
-}
-
-void
-igsFillBoxSolid (DrawablePtr pDrawable, int nBox, BoxPtr pBox, 
-		 unsigned long pixel, int alu, unsigned long planemask)
-{
-    SetupIgs(pDrawable->pScreen);
-    CARD32	cmd;
-
-    _igsSetSolidRect(cop,alu,planemask,pixel,cmd);
-    while (nBox--) 
-    {
-	_igsRect(cop,pBox->x1,pBox->y1,pBox->x2-pBox->x1,pBox->y2-pBox->y1,cmd);
-	pBox++;
-    }
-    KdMarkSync (pDrawable->pScreen);
-}
-
-void
-igsFillBoxTiled (DrawablePtr pDrawable, int nBox, BoxPtr pBox,
-		 PixmapPtr pPixmap, int xrot, int yrot, int alu)
-{
-    SetupIgs(pDrawable->pScreen);
-    CARD32      cmd;
-    IgsPattern	*p = igsSetPattern (pDrawable->pScreen,
-				    pPixmap,
-				    FillTiled,
-				    xrot, yrot);
-    
-    _igsSetTiledRect(cop,alu,planemask,p->offset,cmd);
-    while (nBox--) 
-    {
-	_igsPatRect(cop,pBox->x1,pBox->y1,pBox->x2-pBox->x1,pBox->y2-pBox->y1,cmd);
-	pBox++;
-    }
-    KdMarkSync (pDrawable->pScreen);
-}
-
-void
-igsFillBoxStippled (DrawablePtr pDrawable, GCPtr pGC,
-		    int nBox, BoxPtr pBox)
-{
-    SetupIgs(pDrawable->pScreen);
-    CARD32      cmd;
-    int		xrot = pGC->patOrg.x + pDrawable->x;
-    int		yrot = pGC->patOrg.y + pDrawable->y;
-    IgsPattern	*p = igsSetPattern (pDrawable->pScreen,
-				    pGC->stipple,
-				    pGC->fillStyle,
-				    xrot, yrot);
-    if (pGC->fillStyle == FillStippled)
-    {
-	_igsSetStippledRect (cop,pGC->alu,planemask,pGC->fgPixel,p->offset,cmd);
-    }
-    else
-    {
-	_igsSetOpaqueStippledRect (cop,pGC->alu,planemask,
-				   pGC->fgPixel,pGC->bgPixel,p->offset,cmd);
-    }
-    while (nBox--) 
-    {
-	_igsPatRect(cop,pBox->x1,pBox->y1,pBox->x2-pBox->x1,pBox->y2-pBox->y1,cmd);
-	pBox++;
-    }
-    KdMarkSync (pDrawable->pScreen);
-}
-
-
-void
-igsStipple (ScreenPtr	pScreen,
-	    CARD32	cmd,
-	    FbStip	*psrcBase,
-	    FbStride	widthSrc,
-	    int		srcx,
-	    int		srcy,
-	    int		dstx,
-	    int		dsty,
-	    int		width,
-	    int		height)
-{
-    SetupIgs(pScreen);
-    FbStip	*psrcLine, *psrc;
-    FbStride	widthRest;
-    FbStip	bits, tmp, lastTmp;
-    int		leftShift, rightShift;
-    int		nl, nlMiddle;
-    int		r;
-    PixTransDeclare;
-    
-    /* Compute blt address and parameters */
-    psrc = psrcBase + srcy * widthSrc + (srcx >> 5);
-    nlMiddle = (width + 31) >> 5;
-    leftShift = srcx & 0x1f;
-    rightShift = 32 - leftShift;
-    widthRest = widthSrc - nlMiddle;
-    
-    _igsPlaneBlt(cop,dstx,dsty,width,height,cmd);
-    
-    if (leftShift == 0)
-    {
-	while (height--)
-	{
-	    nl = nlMiddle;
-	    PixTransStart(nl);
-	    while (nl--)
-	    {
-		tmp = *psrc++;
-		IgsAdjustBits32 (tmp);
-		PixTransStore (tmp);
-	    }
-	    psrc += widthRest;
-	}
-    }
-    else
-    {
-	widthRest--;
-	while (height--)
-	{
-	    bits = *psrc++;
-	    nl = nlMiddle;
-	    PixTransStart(nl);
-	    while (nl--)
-	    {
-		tmp = FbStipLeft(bits, leftShift);
-		bits = *psrc++;
-		tmp |= FbStipRight(bits, rightShift);
-		IgsAdjustBits32(tmp);
-		PixTransStore (tmp);
-	    }
-	    psrc += widthRest;
-	}
-    }
-}
-	    
-void
-igsCopyNtoN (DrawablePtr	pSrcDrawable,
-	    DrawablePtr	pDstDrawable,
-	    GCPtr	pGC,
-	    BoxPtr	pbox,
-	    int		nbox,
-	    int		dx,
-	    int		dy,
-	    Bool	reverse,
-	    Bool	upsidedown,
-	    Pixel	bitplane,
-	    void	*closure)
-{
-    SetupIgs(pDstDrawable->pScreen);
-    int	    srcX, srcY, dstX, dstY;
-    int	    w, h;
-    CARD32  flags;
-    CARD32  cmd;
-    CARD8   alu;
-    
-    if (pGC)
-    {
-	alu = pGC->alu;
-	if (sourceInvarient (pGC->alu))
-	{
-	    igsFillBoxSolid (pDstDrawable, nbox, pbox, 0, pGC->alu, pGC->planemask);
-	    return;
-	}
-    }
-    else
-	alu = GXcopy;
-    
-    _igsSetBlt(cop,alu,pGC->planemask,reverse,upsidedown,cmd);
-    while (nbox--)
-    {
-	w = pbox->x2 - pbox->x1;
-	h = pbox->y2 - pbox->y1;
-	if (reverse)
-	    dstX = pbox->x2 - 1;
-	else
-	    dstX = pbox->x1;
-	srcX = dstX + dx;
-	
-	if (upsidedown)
-	    dstY = pbox->y2 - 1;
-	else
-	    dstY = pbox->y1;
-	
-	srcY = dstY + dy;
-	
-	_igsBlt (cop, srcX, srcY, dstX, dstY, w, h, cmd);
-	pbox++;
-    }
-    KdMarkSync (pDstDrawable->pScreen);
-}
-
-RegionPtr
-igsCopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, GCPtr pGC,
-	   int srcx, int srcy, int width, int height, int dstx, int dsty)
-{
-    KdScreenPriv(pDstDrawable->pScreen);
-    FbBits	    depthMask;
-    
-    depthMask = FbFullMask (pDstDrawable->depth);
-    if ((pGC->planemask & depthMask) == depthMask &&
-	pSrcDrawable->type == DRAWABLE_WINDOW &&
-	pDstDrawable->type == DRAWABLE_WINDOW)
-    {
-	return fbDoCopy (pSrcDrawable, pDstDrawable, pGC, 
-			 srcx, srcy, width, height, 
-			 dstx, dsty, igsCopyNtoN, 0, 0);
-    }
-    return KdCheckCopyArea (pSrcDrawable, pDstDrawable, pGC, 
-		       srcx, srcy, width, height, dstx, dsty);
-}
-
-typedef struct _igs1toNargs {
-    unsigned long	copyPlaneFG, copyPlaneBG;
-    Bool		opaque;
-} igs1toNargs;
-
-void
-igsCopy1toN (DrawablePtr    pSrcDrawable,
-	     DrawablePtr    pDstDrawable,
-	     GCPtr	    pGC,
-	     BoxPtr	    pbox,
-	     int	    nbox,
-	     int	    dx,
-	     int	    dy,
-	     Bool	    reverse,
-	     Bool	    upsidedown,
-	     Pixel	    bitplane,
-	     void	    *closure)
-{
-    SetupIgs(pDstDrawable->pScreen);
-    
-    igs1toNargs		*args = closure;
-    int			dstx, dsty;
-    FbStip		*psrcBase;
-    FbStride		widthSrc;
-    int			srcBpp;
-    int			srcXoff, srcYoff;
-    CARD32		cmd;
-
-    if (args->opaque && sourceInvarient (pGC->alu))
-    {
-	igsFillBoxSolid (pDstDrawable, nbox, pbox,
-			 pGC->bgPixel, pGC->alu, pGC->planemask);
-	return;
-    }
-    
-    fbGetStipDrawable (pSrcDrawable, psrcBase, widthSrc, srcBpp, srcXoff, srcYoff);
-    
-    if (args->opaque)
-    {
-	_igsSetOpaquePlaneBlt (cop, pGC->alu, pGC->planemask, args->copyPlaneFG,
-			       args->copyPlaneBG, cmd);
-    }
-    else
-    {
-	_igsSetTransparentPlaneBlt (cop, pGC->alu, pGC->planemask,
-				    args->copyPlaneFG, cmd);
-    }
-    
-    while (nbox--)
-    {
-	dstx = pbox->x1;
-	dsty = pbox->y1;
-	
-	igsStipple (pDstDrawable->pScreen, cmd,
-		    psrcBase, widthSrc, 
-		    dstx + dx - srcXoff, dsty + dy - srcYoff,
-		    dstx, dsty, 
-		    pbox->x2 - dstx, pbox->y2 - dsty);
-	pbox++;
-    }
-    KdMarkSync (pDstDrawable->pScreen);
-}
-
-RegionPtr
-igsCopyPlane (DrawablePtr   pSrcDrawable,
-	      DrawablePtr   pDstDrawable,
-	      GCPtr	    pGC,
-	      int	    srcx,
-	      int	    srcy,
-	      int	    width,
-	      int	    height, 
-	      int	    dstx,
-	      int	    dsty,
-	      unsigned long bitPlane)
-{
-    RegionPtr	    ret;
-    igs1toNargs	    args;
-    FbBits	    depthMask;
-
-    depthMask = FbFullMask (pDstDrawable->depth);
-    if ((pGC->planemask & depthMask) == depthMask &&
-	pDstDrawable->type == DRAWABLE_WINDOW &&
-	pSrcDrawable->depth == 1)
-    {
-	args.copyPlaneFG = pGC->fgPixel;
-	args.copyPlaneBG = pGC->bgPixel;
-	args.opaque = TRUE;
-	return fbDoCopy (pSrcDrawable, pDstDrawable, pGC, 
-			 srcx, srcy, width, height, 
-			 dstx, dsty, igsCopy1toN, bitPlane, &args);
-    }
-    return KdCheckCopyPlane(pSrcDrawable, pDstDrawable, pGC, 
-			    srcx, srcy, width, height, 
-			    dstx, dsty, bitPlane);
-}
-
-#if 0
-/* would you believe this is slower than fb? */
-void
-igsPushPixels (GCPtr	    pGC,
-	       PixmapPtr    pBitmap,
-	       DrawablePtr  pDrawable,
-	       int	    w,
-	       int	    h,
-	       int	    x,
-	       int	    y)
-{
-    igs1toNargs		args;
-    FbBits	    depthMask;
-
-    depthMask = FbFullMask (pDstDrawable->depth);
-    if ((pGC->planemask & depthMask) == depthMask &&
-	pDrawable->type == DRAWABLE_WINDOW && 
-	pGC->fillStyle == FillSolid)
-    {
-	args.opaque = FALSE;
-	args.copyPlaneFG = pGC->fgPixel;
-	(void) fbDoCopy ((DrawablePtr) pBitmap, pDrawable, pGC,
-			  0, 0, w, h, x, y, igsCopy1toN, 1, &args);
-    }
-    else
-    {
-	KdCheckPushPixels (pGC, pBitmap, pDrawable, w, h, x, y);
-    }
-}
-#else
-#define igsPushPixels KdCheckPushPixels
-#endif
-
-BOOL
-igsFillOk (GCPtr pGC)
-{
-    FbBits  depthMask;
-
-    depthMask = FbFullMask(pGC->depth);
-    if ((pGC->planemask & depthMask) != depthMask)
-	return FALSE;
-    switch (pGC->fillStyle) {
-    case FillSolid:
-	return TRUE;
-    case FillTiled:
-	return (igsPatternDimOk (pGC->tile.pixmap->drawable.width) &&
-		igsPatternDimOk (pGC->tile.pixmap->drawable.height));
-    case FillStippled:
-    case FillOpaqueStippled:
-	return (igsPatternDimOk (pGC->stipple->drawable.width) &&
-		igsPatternDimOk (pGC->stipple->drawable.height));
-    }
-    return FALSE;
-}
-
-void
-igsFillSpans (DrawablePtr pDrawable, GCPtr pGC, int n, 
-	     DDXPointPtr ppt, int *pwidth, int fSorted)
-{
-    SetupIgs(pDrawable->pScreen);
-    DDXPointPtr	    pptFree;
-    FbGCPrivPtr	    fbPriv = fbGetGCPrivate(pGC);
-    int		    *pwidthFree;/* copies of the pointers to free */
-    CARD32	    cmd;
-    int		    nTmp;
-    INT16	    x, y;
-    int		    width;
-    IgsPattern	    *p;
-    
-    if (!igsFillOk (pGC))
-    {
-	KdCheckFillSpans (pDrawable, pGC, n, ppt, pwidth, fSorted);
-	return;
-    }
-    nTmp = n * miFindMaxBand(fbGetCompositeClip(pGC));
-    pwidthFree = (int *)xalloc(nTmp * sizeof(int));
-    pptFree = (DDXPointRec *)xalloc(nTmp * sizeof(DDXPointRec));
-    if(!pptFree || !pwidthFree)
-    {
-	if (pptFree) xfree(pptFree);
-	if (pwidthFree) xfree(pwidthFree);
-	return;
-    }
-    n = miClipSpans(fbGetCompositeClip(pGC),
-		     ppt, pwidth, n,
-		     pptFree, pwidthFree, fSorted);
-    pwidth = pwidthFree;
-    ppt = pptFree;
-    switch (pGC->fillStyle) {
-    case FillSolid:
-	_igsSetSolidRect(cop,pGC->alu,pGC->planemask,pGC->fgPixel,cmd);
-	break;
-    case FillTiled:
-	p = igsSetPattern (pDrawable->pScreen,
-			   pGC->tile.pixmap,
-			   FillTiled,
-			   pGC->patOrg.x + pDrawable->x,
-			   pGC->patOrg.y + pDrawable->y);
-	_igsSetTiledRect (cop,pGC->alu,pGC->planemask,p->offset,cmd);
-	break;
-    default:
-	p = igsSetPattern (pDrawable->pScreen,
-			   pGC->stipple,
-			   pGC->fillStyle,
-			   pGC->patOrg.x + pDrawable->x,
-			   pGC->patOrg.y + pDrawable->y);
-	if (pGC->fillStyle == FillStippled)
-	{
-	    _igsSetStippledRect (cop,pGC->alu,pGC->planemask,
-				 pGC->fgPixel,p->offset,cmd);
-	}
-	else
-	{
-	    _igsSetOpaqueStippledRect (cop,pGC->alu,pGC->planemask,
-				       pGC->fgPixel,pGC->bgPixel,p->offset,cmd);
-	}
-	break;
-    }
-    while (n--)
-    {
-	x = ppt->x;
-	y = ppt->y;
-	ppt++;
-	width = *pwidth++;
-	if (width)
-	{
-	    _igsPatRect(cop,x,y,width,1,cmd);
-	}
-    }
-    xfree(pptFree);
-    xfree(pwidthFree);
-    KdMarkSync (pDrawable->pScreen);
-}
-
-#define NUM_STACK_RECTS	1024
-
-void
-igsPolyFillRect (DrawablePtr pDrawable, GCPtr pGC, 
-		int nrectFill, xRectangle *prectInit)
-{
-    SetupIgs(pDrawable->pScreen);
-    xRectangle	    *prect;
-    RegionPtr	    prgnClip;
-    register BoxPtr pbox;
-    register BoxPtr pboxClipped;
-    BoxPtr	    pboxClippedBase;
-    BoxPtr	    pextent;
-    BoxRec	    stackRects[NUM_STACK_RECTS];
-    FbGCPrivPtr	    fbPriv = fbGetGCPrivate (pGC);
-    int		    numRects;
-    int		    n;
-    int		    xorg, yorg;
-    int		    x, y;
-    
-    if (!igsFillOk (pGC))
-    {
-	KdCheckPolyFillRect (pDrawable, pGC, nrectFill, prectInit);
-	return;
-    }
-    prgnClip = fbGetCompositeClip (pGC);
-    xorg = pDrawable->x;
-    yorg = pDrawable->y;
-    
-    if (xorg || yorg)
-    {
-	prect = prectInit;
-	n = nrectFill;
-	while(n--)
-	{
-	    prect->x += xorg;
-	    prect->y += yorg;
-	    prect++;
-	}
-    }
-    
-    prect = prectInit;
-
-    numRects = REGION_NUM_RECTS(prgnClip) * nrectFill;
-    if (numRects > NUM_STACK_RECTS)
-    {
-	pboxClippedBase = (BoxPtr)xalloc(numRects * sizeof(BoxRec));
-	if (!pboxClippedBase)
-	    return;
-    }
-    else
-	pboxClippedBase = stackRects;
-
-    pboxClipped = pboxClippedBase;
-	
-    if (REGION_NUM_RECTS(prgnClip) == 1)
-    {
-	int x1, y1, x2, y2, bx2, by2;
-
-	pextent = REGION_RECTS(prgnClip);
-	x1 = pextent->x1;
-	y1 = pextent->y1;
-	x2 = pextent->x2;
-	y2 = pextent->y2;
-    	while (nrectFill--)
-    	{
-	    if ((pboxClipped->x1 = prect->x) < x1)
-		pboxClipped->x1 = x1;
-    
-	    if ((pboxClipped->y1 = prect->y) < y1)
-		pboxClipped->y1 = y1;
-    
-	    bx2 = (int) prect->x + (int) prect->width;
-	    if (bx2 > x2)
-		bx2 = x2;
-	    pboxClipped->x2 = bx2;
-    
-	    by2 = (int) prect->y + (int) prect->height;
-	    if (by2 > y2)
-		by2 = y2;
-	    pboxClipped->y2 = by2;
-
-	    prect++;
-	    if ((pboxClipped->x1 < pboxClipped->x2) &&
-		(pboxClipped->y1 < pboxClipped->y2))
-	    {
-		pboxClipped++;
-	    }
-    	}
-    }
-    else
-    {
-	int x1, y1, x2, y2, bx2, by2;
-
-	pextent = REGION_EXTENTS(pGC->pScreen, prgnClip);
-	x1 = pextent->x1;
-	y1 = pextent->y1;
-	x2 = pextent->x2;
-	y2 = pextent->y2;
-    	while (nrectFill--)
-    	{
-	    BoxRec box;
-    
-	    if ((box.x1 = prect->x) < x1)
-		box.x1 = x1;
-    
-	    if ((box.y1 = prect->y) < y1)
-		box.y1 = y1;
-    
-	    bx2 = (int) prect->x + (int) prect->width;
-	    if (bx2 > x2)
-		bx2 = x2;
-	    box.x2 = bx2;
-    
-	    by2 = (int) prect->y + (int) prect->height;
-	    if (by2 > y2)
-		by2 = y2;
-	    box.y2 = by2;
-    
-	    prect++;
-    
-	    if ((box.x1 >= box.x2) || (box.y1 >= box.y2))
-	    	continue;
-    
-	    n = REGION_NUM_RECTS (prgnClip);
-	    pbox = REGION_RECTS(prgnClip);
-    
-	    /* clip the rectangle to each box in the clip region
-	       this is logically equivalent to calling Intersect()
-	    */
-	    while(n--)
-	    {
-		pboxClipped->x1 = max(box.x1, pbox->x1);
-		pboxClipped->y1 = max(box.y1, pbox->y1);
-		pboxClipped->x2 = min(box.x2, pbox->x2);
-		pboxClipped->y2 = min(box.y2, pbox->y2);
-		pbox++;
-
-		/* see if clipping left anything */
-		if(pboxClipped->x1 < pboxClipped->x2 && 
-		   pboxClipped->y1 < pboxClipped->y2)
-		{
-		    pboxClipped++;
-		}
-	    }
-    	}
-    }
-    if (pboxClipped != pboxClippedBase)
-    {
-	switch (pGC->fillStyle) {
-	case FillSolid:
-	    igsFillBoxSolid(pDrawable,
-			   pboxClipped-pboxClippedBase, pboxClippedBase,
-			   pGC->fgPixel, pGC->alu, pGC->planemask);
-	    break;
-	case FillTiled:
-	    igsFillBoxTiled(pDrawable,
-			    pboxClipped-pboxClippedBase, pboxClippedBase,
-			    pGC->tile.pixmap,
-			    pGC->patOrg.x + pDrawable->x,
-			    pGC->patOrg.y + pDrawable->y,
-			    pGC->alu);
-	    break;
-	case FillStippled:
-	case FillOpaqueStippled:
-	    igsFillBoxStippled (pDrawable, pGC,
-				pboxClipped-pboxClippedBase, pboxClippedBase);
-	    break;
-	}
-    }
-    if (pboxClippedBase != stackRects)
-    	xfree(pboxClippedBase);
-}
-
-int
-igsTextInRegion (GCPtr		pGC,
-		 int		x,
-		 int		y,
-		 unsigned int	nglyph,
-		 CharInfoPtr	*ppci)
-{
-    int		    w;
-    FontPtr	    pfont = pGC->font;
-    BoxRec	    bbox;
-    
-    if (FONTCONSTMETRICS(pfont))
-	w = FONTMAXBOUNDS(pfont,characterWidth) * nglyph;
-    else
-    {
-	w = 0;
-	while (nglyph--)
-	    w += (*ppci++)->metrics.characterWidth;
-    }
-    if (w < 0)
-    {
-	bbox.x1 = x + w;
-	bbox.x2 = x;
-    }
-    else
-    {
-	bbox.x1 = x;
-	bbox.x2 = x + w;
-    }
-    w = FONTMINBOUNDS(pfont,leftSideBearing);
-    if (w < 0)
-	bbox.x1 += w;
-    w = FONTMAXBOUNDS(pfont, rightSideBearing) - FONTMINBOUNDS(pfont, characterWidth);
-    if (w > 0)
-	bbox.x2 += w;
-    bbox.y1 = y - FONTMAXBOUNDS(pfont,ascent);
-    bbox.y2 = y + FONTMAXBOUNDS(pfont,descent);
-    
-    return RECT_IN_REGION(pGC->pScreen, fbGetCompositeClip(pGC), &bbox);
-}
-		 
-void
-igsGlyphBltClipped (DrawablePtr	    pDrawable,
-		    GCPtr	    pGC,
-		    int		    x,
-		    int		    y,
-		    unsigned int    nglyph,
-		    CharInfoPtr	    *ppciInit,
-		    Bool	    image)
-{
-    SetupIgs(pDrawable->pScreen);
-    CARD32	    cmd;
-    int		    h;
-    int		    w;
-    int		    xBack, yBack;
-    int		    hBack, wBack;
-    int		    lw;
-    FontPtr	    pfont = pGC->font;
-    CharInfoPtr	    pci;
-    unsigned long   *bits;
-    BoxPtr	    extents;
-    BoxRec	    bbox;
-    CARD32	    b;
-    CharInfoPtr	    *ppci;
-    FbGCPrivPtr	    fbPriv = fbGetGCPrivate(pGC);
-    RegionPtr	    pClip = fbGetCompositeClip(pGC);
-    BoxPtr	    pBox;
-    int		    nbox;
-    int		    x1, y1, x2, y2;
-    unsigned char   alu;
-    Bool	    set;
-    PixTransDeclare;
-
-    if (image)
-    {
-	xBack = x;
-	yBack = y - FONTASCENT(pGC->font);
-	wBack = 0;
-	hBack = FONTASCENT(pGC->font) + FONTDESCENT(pGC->font);
-	if (hBack)
-	{
-	    h = nglyph;
-	    ppci = ppciInit;
-	    while (h--)
-		wBack += (*ppci++)->metrics.characterWidth;
-	}
-	if (wBack < 0)
-	{
-	    xBack = xBack + wBack;
-	    wBack = -wBack;
-	}
-	if (hBack < 0)
-	{
-	    yBack = yBack + hBack;
-	    hBack = -hBack;
-	}
-	alu = GXcopy;
-	if (wBack)
-	{
-	    _igsSetSolidRect (cop, GXcopy, pGC->planemask, pGC->bgPixel, cmd);
-	    for (nbox = REGION_NUM_RECTS (pClip),
-		 pBox = REGION_RECTS (pClip);
-		 nbox--;
-		 pBox++)
-	    {
-		x1 = xBack;
-		x2 = xBack + wBack;
-		y1 = yBack;
-		y2 = yBack + hBack;
-		if (x1 < pBox->x1) x1 = pBox->x1;
-		if (x2 > pBox->x2) x2 = pBox->x2;
-		if (y1 < pBox->y1) y1 = pBox->y1;
-		if (y2 > pBox->y2) y2 = pBox->y2;
-		if (x1 < x2 && y1 < y2)
-		{
-		    _igsRect (cop, x1, y1, x2 - x1, y2 - y1, cmd);
-		}
-	    }
-	    KdMarkSync (pDrawable->pScreen);
-	}
-    }
-    else
-    {
-	wBack = 0;
-	alu = pGC->alu;
-    }
-    
-    ppci = ppciInit;
-    set = FALSE;
-    while (nglyph--)
-    {
-	pci = *ppci++;
-	h = pci->metrics.ascent + pci->metrics.descent;
-	w = pci->metrics.rightSideBearing - pci->metrics.leftSideBearing;
-	x1 = x + pci->metrics.leftSideBearing;
-	y1 = y - pci->metrics.ascent;
-	bbox.x1 = x1;
-	bbox.y1 = y1;
-	bbox.x2 = x1 + w;
-	bbox.y2 = y1 + h;
-	switch (RECT_IN_REGION(pGC->pScreen, pClip, &bbox))
-	{
-	case rgnIN:
-	    lw = h * ((w + 31) >> 5);
-	    if (lw)
-	    {
-		if (!set)
-		{
-		    _igsSetTransparentPlaneBlt (cop, alu, pGC->planemask, pGC->fgPixel, cmd);
-		    set = TRUE;
-		}
-		_igsPlaneBlt(cop,
-			     x + pci->metrics.leftSideBearing,
-			     y - pci->metrics.ascent,
-			     w, h, cmd);
-		bits = (unsigned long *) pci->bits;
-		PixTransStart (lw);
-		while (lw--) 
-		{
-		    b = *bits++;
-		    IgsAdjustBits32 (b);
-		    PixTransStore(b);
-		}
-		KdMarkSync (pDrawable->pScreen);
-	    }
-	    break;
-	case rgnPART:
-	    set = FALSE;
-	    KdCheckSync (pDrawable->pScreen);
-	    fbPutXYImage (pDrawable,
-			  pClip,
-			  fbPriv->fg,
-			  fbPriv->bg,
-			  fbPriv->pm,
-			  alu,
-			  FALSE,
-			  x1, y1,
-			  w, h,
-			  (FbStip *) pci->bits,
-			  (w + 31) >> 5,
-			  0);
-	    break;
-	case rgnOUT:
-	    break;
-	}
-	x += pci->metrics.characterWidth;
-    }
-}
-		       
-void
-igsGlyphBlt (DrawablePtr    pDrawable, 
-	     GCPtr	    pGC, 
-	     int	    x,
-	     int	    y, 
-	     unsigned int   nglyph,
-	     CharInfoPtr    *ppciInit,
-	     Bool	    image)
-{
-    SetupIgs(pDrawable->pScreen);
-    CARD32	    cmd;
-    int		    h;
-    int		    w;
-    int		    xBack, yBack;
-    int		    hBack, wBack;
-    int		    lw;
-    FontPtr	    pfont = pGC->font;
-    CharInfoPtr	    pci;
-    unsigned long   *bits;
-    BoxPtr	    extents;
-    BoxRec	    bbox;
-    CARD32	    b;
-    CharInfoPtr	    *ppci;
-    unsigned char   alu;
-    PixTransDeclare;
-
-    /*
-     * Paint background for image text
-     */
-    if (image)
-    {
-	xBack = x;
-	yBack = y - FONTASCENT(pGC->font);
-	wBack = 0;
-	hBack = FONTASCENT(pGC->font) + FONTDESCENT(pGC->font);
-	if (hBack)
-	{
-	    h = nglyph;
-	    ppci = ppciInit;
-	    while (h--)
-		wBack += (*ppci++)->metrics.characterWidth;
-	}
-	if (wBack < 0)
-	{
-	    xBack = xBack + wBack;
-	    wBack = -wBack;
-	}
-	if (hBack < 0)
-	{
-	    yBack = yBack + hBack;
-	    hBack = -hBack;
-	}
-	alu = GXcopy;
-	if (wBack)
-	{
-	    _igsSetSolidRect (cop, GXcopy, pGC->planemask, pGC->bgPixel, cmd);
-	    _igsRect (cop, xBack, yBack, wBack, hBack, cmd);
-	}
-    }
-    else
-    {
-	wBack = 0;
-	alu = pGC->alu;
-    }
-    
-    _igsSetTransparentPlaneBlt (cop, alu, pGC->planemask, pGC->fgPixel, cmd);
-    ppci = ppciInit;
-    while (nglyph--)
-    {
-	pci = *ppci++;
-	h = pci->metrics.ascent + pci->metrics.descent;
-	w = pci->metrics.rightSideBearing - pci->metrics.leftSideBearing;
-	lw = h * ((w + 31) >> 5);
-	if (lw)
-	{
-	    _igsPlaneBlt(cop,
-			 x + pci->metrics.leftSideBearing,
-			 y - pci->metrics.ascent,
-			 w, h, cmd);
-	    bits = (unsigned long *) pci->bits;
-	    PixTransStart(lw);
-	    while (lw--) 
-	    {
-		b = *bits++;
-		IgsAdjustBits32 (b);
-		PixTransStore(b);
-	    }
-	}
-	x += pci->metrics.characterWidth;
-    }
-    KdMarkSync (pDrawable->pScreen);
-}
-
-void
-igsTEGlyphBlt (DrawablePtr  pDrawable,
-	       GCPtr	    pGC,
-	       int	    xInit,
-	       int	    yInit,
-	       unsigned int nglyph,
-	       CharInfoPtr  *ppci,
-	       Bool	    image)
-{
-    SetupIgs(pDrawable->pScreen);
-    CARD32	    cmd;
-    int		    x, y;
-    int		    h, lw, lwTmp;
-    int		    w;
-    FontPtr	    pfont = pGC->font;
-    unsigned long   *char1, *char2, *char3, *char4;
-    int		    widthGlyphs, widthGlyph;
-    BoxRec	    bbox;
-    CARD32	    tmp;
-    PixTransDeclare;
-
-    widthGlyph = FONTMAXBOUNDS(pfont,characterWidth);
-    if (!widthGlyph)
-	return;
-    
-    h = FONTASCENT(pfont) + FONTDESCENT(pfont);
-    if (!h)
-	return;
-    
-    x = xInit + FONTMAXBOUNDS(pfont,leftSideBearing);
-    y = yInit - FONTASCENT(pfont);
-    
-    if (image)
-    {
-	_igsSetOpaquePlaneBlt (cop, GXcopy, pGC->planemask, pGC->fgPixel, pGC->bgPixel, cmd);
-    }
-    else
-    {
-	_igsSetTransparentPlaneBlt (cop, pGC->alu, pGC->planemask, pGC->fgPixel, cmd);
-    }
-
-#if BITMAP_BIT_ORDER == LSBFirst
-#define SHIFT	<<
-#else
-#define SHIFT	>>
-#endif
-    
-#define LoopIt(count, w, loadup, fetch) \
-    while (nglyph >= count) \
-    { \
-	nglyph -= count; \
-	_igsPlaneBlt (cop, x, y, w, h, cmd); \
-	x += w; \
-	loadup \
-	lwTmp = h; \
-	PixTransStart(h); \
-	while (lwTmp--) { \
-	    tmp = fetch; \
-	    IgsAdjustBits32(tmp); \
-	    PixTransStore(tmp); \
-	} \
-    }
-
-    if (widthGlyph <= 8)
-    {
-	widthGlyphs = widthGlyph << 2;
-	LoopIt(4, widthGlyphs,
-	       char1 = (unsigned long *) (*ppci++)->bits;
-	       char2 = (unsigned long *) (*ppci++)->bits;
-	       char3 = (unsigned long *) (*ppci++)->bits;
-	       char4 = (unsigned long *) (*ppci++)->bits;,
-	       (*char1++ | ((*char2++ | ((*char3++ | (*char4++
-						      SHIFT widthGlyph))
-					 SHIFT widthGlyph))
-			    SHIFT widthGlyph)))
-    }
-    else if (widthGlyph <= 10)
-    {
-	widthGlyphs = (widthGlyph << 1) + widthGlyph;
-	LoopIt(3, widthGlyphs,
-	       char1 = (unsigned long *) (*ppci++)->bits;
-	       char2 = (unsigned long *) (*ppci++)->bits;
-	       char3 = (unsigned long *) (*ppci++)->bits;,
-	       (*char1++ | ((*char2++ | (*char3++ SHIFT widthGlyph)) SHIFT widthGlyph)))
-    }
-    else if (widthGlyph <= 16)
-    {
-	widthGlyphs = widthGlyph << 1;
-	LoopIt(2, widthGlyphs,
-	       char1 = (unsigned long *) (*ppci++)->bits;
-	       char2 = (unsigned long *) (*ppci++)->bits;,
-	       (*char1++ | (*char2++ SHIFT widthGlyph)))
-    }
-    lw = h * ((widthGlyph + 31) >> 5);
-    while (nglyph--) 
-    {
-	_igsPlaneBlt (cop, x, y, widthGlyph, h, cmd);
-	x += widthGlyph;
-	char1 = (unsigned long *) (*ppci++)->bits;
-	lwTmp = lw;
-	PixTransStart(lw);
-	while (lwTmp--)
-	{
-	    tmp = *char1++;
-	    IgsAdjustBits32(tmp);
-	    PixTransStore(tmp);
-	}
-    }
-    KdMarkSync (pDrawable->pScreen);
-}
-
-/*
- * Blt glyphs using image transfer window
- */
-
-void
-igsPolyGlyphBlt (DrawablePtr	pDrawable, 
-		 GCPtr		pGC, 
-		 int		x,
-		 int		y, 
-		 unsigned int	nglyph,
-		 CharInfoPtr	*ppci, 
-		 pointer	pglyphBase)
-{
-    if (pGC->fillStyle != FillSolid ||
-	fbGetGCPrivate(pGC)->pm != FB_ALLONES)
-    {
-	KdCheckPolyGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
-	return;
-    }
-    x += pDrawable->x;
-    y += pDrawable->y;
-
-    switch (igsTextInRegion (pGC, x, y, nglyph, ppci)) {
-    case rgnIN:
-	if (TERMINALFONT(pGC->font))
-	    igsTEGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, FALSE);
-	else
-	    igsGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, FALSE);
-	break;
-    case rgnPART:
-	igsGlyphBltClipped (pDrawable, pGC, x, y, nglyph, ppci, FALSE);
-	break;
-    case rgnOUT:
-	break;
-    }
-}
-
-void
-igsImageGlyphBlt (DrawablePtr pDrawable, 
-		GCPtr pGC, 
-		int x, int y, 
-		unsigned int nglyph, 
-		CharInfoPtr *ppci, 
-		pointer pglyphBase)
-{
-    if (fbGetGCPrivate(pGC)->pm != FB_ALLONES)
-    {
-	KdCheckImageGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
-	return;
-    }
-    x += pDrawable->x;
-    y += pDrawable->y;
-
-    switch (igsTextInRegion (pGC, x, y, nglyph, ppci)) {
-    case rgnIN:
-	if (TERMINALFONT(pGC->font))
-	    igsTEGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, TRUE);
-	else
-	    igsGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, TRUE);
-	break;
-    case rgnPART:
-	igsGlyphBltClipped (pDrawable, pGC, x, y, nglyph, ppci, TRUE);
-	break;
-    case rgnOUT:
-	break;
-    }
-}
-
-static void
-igsInvalidatePattern (IgsPatternCache	*c,
-		      PixmapPtr		pPixmap)
-{
-    int i;
-
-    if (c->base)
-    {
-	for (i = 0; i < IGS_NUM_PATTERN; i++)
-	{
-	    if (c->pattern[i].serial_number == pPixmap->drawable.serialNumber)
-		c->pattern[i].serial_number = ~0;
-	}
-    }    
-}
-
-static void
-igsInitPattern (IgsPatternCache *c, int bsize, int psize)
-{
-    int	    i;
-    int	    boffset;
-    int	    poffset;
-
-    for (i = 0; i < IGS_NUM_PATTERN; i++)
-    {
-	boffset = i * bsize;
-	poffset = i * psize;
-	c->pattern[i].xrot = -1;
-	c->pattern[i].yrot = -1;
-	c->pattern[i].serial_number = ~0;
-	c->pattern[i].offset = c->offset + poffset;
-	c->pattern[i].base = c->base + boffset;
-    }
-    c->next = 0;
-}
-	
-static const GCOps	igsOps = {
-    igsFillSpans,
-    KdCheckSetSpans,
-    KdCheckPutImage,
-    igsCopyArea,
-    igsCopyPlane,
-    KdCheckPolyPoint,
-    KdCheckPolylines,
-    KdCheckPolySegment,
-    miPolyRectangle,
-    KdCheckPolyArc,
-    miFillPolygon,
-    igsPolyFillRect,
-    KdCheckPolyFillArc,
-    miPolyText8,
-    miPolyText16,
-    miImageText8,
-    miImageText16,
-    igsImageGlyphBlt,
-    igsPolyGlyphBlt,
-    igsPushPixels,
-};
-
-void
-igsValidateGC (GCPtr pGC, Mask changes, DrawablePtr pDrawable)
-{
-    FbGCPrivPtr fbPriv = fbGetGCPrivate(pGC);
-    
-    fbValidateGC (pGC, changes, pDrawable);
-    
-    if (pDrawable->type == DRAWABLE_WINDOW)
-	pGC->ops = (GCOps *) &igsOps;
-    else
-	pGC->ops = (GCOps *) &fbGCOps;
-}
-
-GCFuncs	igsGCFuncs = {
-    igsValidateGC,
-    miChangeGC,
-    miCopyGC,
-    miDestroyGC,
-    miChangeClip,
-    miDestroyClip,
-    miCopyClip
-};
-
-int
-igsCreateGC (GCPtr pGC)
-{
-    if (!fbCreateGC (pGC))
-	return FALSE;
-
-    if (pGC->depth != 1)
-	pGC->funcs = &igsGCFuncs;
-    
-    return TRUE;
-}
-
-void
-igsCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
-{
-    ScreenPtr	pScreen = pWin->drawable.pScreen;
-    KdScreenPriv(pScreen);
-    RegionRec	rgnDst;
-    int		dx, dy;
-    WindowPtr	pwinRoot;
-
-    pwinRoot = WindowTable[pWin->drawable.pScreen->myNum];
-
-    dx = ptOldOrg.x - pWin->drawable.x;
-    dy = ptOldOrg.y - pWin->drawable.y;
-    REGION_TRANSLATE(pWin->drawable.pScreen, prgnSrc, -dx, -dy);
-
-    REGION_INIT (pWin->drawable.pScreen, &rgnDst, NullBox, 0);
-    
-    REGION_INTERSECT(pWin->drawable.pScreen, &rgnDst, &pWin->borderClip, prgnSrc);
-
-    fbCopyRegion ((DrawablePtr)pwinRoot, (DrawablePtr)pwinRoot,
-		  0,
-		  &rgnDst, dx, dy, igsCopyNtoN, 0, 0);
-    
-    REGION_UNINIT(pWin->drawable.pScreen, &rgnDst);
-}
-
-
-Bool
-igsDrawInit (ScreenPtr pScreen)
-{
-    KdScreenPriv(pScreen);
-    igsCardInfo(pScreenPriv);
-    igsScreenInfo(pScreenPriv);
-    int i;
-    int pattern_size;
-    int boffset, poffset;
-    
-    KdScreenInitAsync (pScreen);
-    
-    /*
-     * Replace various fb screen functions
-     */
-    pScreen->CreateGC = igsCreateGC;
-    pScreen->CopyWindow = igsCopyWindow;
-
-    /*
-     * Initialize patterns
-     */
-    if (igss->tile.base)
-    {
-	pattern_size = IgsTileSize(pScreenPriv->screen->fb[0].bitsPerPixel);
-	igsInitPattern (&igss->tile,
-			pattern_size,
-			pattern_size * 8 / pScreenPriv->screen->fb[0].bitsPerPixel);
-	pattern_size = IgsStippleSize(pScreenPriv->screen->fb[0].bitsPerPixel);
-	igsInitPattern (&igss->stipple,
-			pattern_size,
-			pattern_size * 8 / pScreenPriv->screen->fb[0].bitsPerPixel);
-    }
-    return TRUE;
-}
-
-void
-igsDrawEnable (ScreenPtr pScreen)
-{
-    SetupIgs(pScreen);
-    CARD32  cmd;
-    CARD32  base;
-    CARD16  stride;
-    CARD32  format;
-    
-    stride = pScreenPriv->screen->fb[0].pixelStride;
-    _igsWaitIdleEmpty(cop);
-    _igsReset(cop);
-    switch (pScreenPriv->screen->fb[0].bitsPerPixel) {
-    case 8:
-	format = IGS_FORMAT_8BPP;
-	break;
-    case 16:
-	format = IGS_FORMAT_16BPP;
-	break;
-    case 24:
-	format = IGS_FORMAT_24BPP;
-	break;
-    case 32:
-	format = IGS_FORMAT_32BPP;
-	break;
-    }
-    cop->format = format;
-    cop->dst_stride = stride - 1;
-    cop->src1_stride = stride - 1;
-    cop->src2_stride = stride - 1;
-    cop->src1_start = 0;
-    cop->src2_start = 0;
-    cop->extension |= IGS_BLOCK_COP_REG | IGS_BURST_ENABLE;
-    
-    _igsSetSolidRect(cop, GXcopy, ~0, pScreen->blackPixel, cmd);
-    _igsRect (cop, 0, 0, 
-	      pScreenPriv->screen->width, pScreenPriv->screen->height,
-	      cmd);
-    _igsWaitIdleEmpty (cop);
-}
-
-void
-igsDrawDisable (ScreenPtr pScreen)
-{
-}
-
-void
-igsDrawFini (ScreenPtr pScreen)
-{
-}
-
-void
-igsDrawSync (ScreenPtr pScreen)
-{
-    SetupIgs(pScreen);
-
-    _igsWaitIdleEmpty(cop);
-}
diff --git a/hw/kdrive/igs/igsdraw.h b/hw/kdrive/igs/igsdraw.h
deleted file mode 100644
index ab80f9a..0000000
--- a/hw/kdrive/igs/igsdraw.h
+++ /dev/null
@@ -1,258 +0,0 @@
-/*
- * Copyright © 2000 Keith Packard
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Keith Packard not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  Keith Packard makes no
- * representations about the suitability of this software for any purpose.  It
- * is provided "as is" without express or implied warranty.
- *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifndef _IGSDRAW_H_
-#define _IGSDRAW_H_
-
-extern CARD8	igsPatRop[];
-
-#define SetupIgs(s) KdScreenPriv(s); \
-		    igsCardInfo(pScreenPriv); \
-		    Cop5xxx *cop = igsc->cop; \
-		    int	    cop_stride = pScreenPriv->screen->fb[0].pixelStride
-
-#define _igsWaitLoop(cop,mask,value) { \
-    int __loop = 1000000; \
-    while (((cop)->control & (mask)) != (value)) { \
-	if (--__loop <= 0) { \
-	    FatalError("Warning: igsWaitLoop 0x%x 0x%x failed\n", mask, value); \
-	} \
-    } \
-}
-
-#define _igsWaitDone(cop)   _igsWaitLoop(cop, \
-					 (IGS_CONTROL_BUSY| \
-					  IGS_CONTROL_MALLWBEPTZ), \
-					 0)
-
-#if 1
-#define _igsWaitFull(cop)   _igsWaitLoop(cop, \
-					 IGS_CONTROL_CMDFF, \
-					 0)
-#else
-#define _igsWaitFull(cop)   _igsWaitDone(cop)
-#endif
-
-#define _igsWaitIdleEmpty(cop)	_igsWaitDone(cop)
-#define _igsWaitHostBltAck(cop)	_igsWaitLoop(cop, \
-					     (IGS_CONTROL_HBACKZ| \
-					      IGS_CONTROL_CMDFF), \
-					     0)
-					      
-#define _igsReset(cop)		((cop)->control = 0)
-
-#define IgsInvertBits32(v) { \
-    v = ((v & 0x55555555) << 1) | ((v >> 1) & 0x55555555); \
-    v = ((v & 0x33333333) << 2) | ((v >> 2) & 0x33333333); \
-    v = ((v & 0x0f0f0f0f) << 4) | ((v >> 4) & 0x0f0f0f0f); \
-}
-
-#define IgsInvertBits16(v) { \
-    v = ((v & 0x5555) << 1) | ((v >> 1) & 0x5555); \
-    v = ((v & 0x3333) << 2) | ((v >> 2) & 0x3333); \
-    v = ((v & 0x0f0f) << 4) | ((v >> 4) & 0x0f0f); \
-}
-
-#define IgsInvertBits8(v) { \
-    v = ((v & 0x55) << 1) | ((v >> 1) & 0x55); \
-    v = ((v & 0x33) << 2) | ((v >> 2) & 0x33); \
-    v = ((v & 0x0f) << 4) | ((v >> 4) & 0x0f); \
-}
-
-#define IgsByteSwap32(x)    	((x) = (((x) >> 24) | \
-					(((x) >> 8) & 0xff00) | \
-					(((x) << 8) & 0xff0000) | \
-					((x) << 24)))
-
-#define IgsByteSwap16(x)    	((x) = ((x) << 8) | ((x) >> 8))
-
-#define igsPatternDimOk(d)  ((d) <= IGS_PATTERN_WIDTH && (((d) & ((d) - 1)) == 0))
-
-#if BITMAP_BIT_ORDER == LSBFirst
-#define IgsAdjustBits32(b)	IgsInvertBits32(b)
-#define IgsAdjustBits16(x)	IgsInvertBits16(x)
-#else
-#define IgsAdjustBits32(x)	IgsByteSwap32(x)
-#define IgsAdjustBits16(x)	IgsByteSwap16(x)
-#endif
-
-#define _igsSetSolidRect(cop,alu,pm,pix,cmd) {\
-    _igsWaitFull(cop); \
-    (cop)->mix = IGS_MAKE_MIX(alu,alu); \
-    (cop)->fg = (pix); \
-    (cmd) = (IGS_DRAW_T_B | \
-	     IGS_DRAW_L_R | \
-	     IGS_DRAW_ALL | \
-	     IGS_PIXEL_FG | \
-	     IGS_HBLT_DISABLE | \
-	     IGS_SRC2_NORMAL | \
-	     IGS_STEP_PXBLT | \
-	     IGS_FGS_FG | \
-	     IGS_BGS_BG); \
-}
-
-#define _igsSetTiledRect(cop,alu,pm,base,cmd) {\
-    _igsWaitFull(cop); \
-    (cop)->mix = IGS_MAKE_MIX(alu,alu); \
-    (cop)->src1_stride = IGS_PATTERN_WIDTH - 1; \
-    (cop)->src1_start = (base); \
-    (cmd) = (IGS_DRAW_T_B | \
-	     IGS_DRAW_L_R | \
-	     IGS_DRAW_ALL | \
-	     IGS_PIXEL_TILE | \
-	     IGS_HBLT_DISABLE | \
-	     IGS_SRC2_NORMAL | \
-	     IGS_STEP_PXBLT | \
-	     IGS_FGS_SRC | \
-	     IGS_BGS_BG); \
-}
-
-#define _igsSetStippledRect(cop,alu,pm,pix,base,cmd) {\
-    _igsWaitFull(cop); \
-    (cop)->mix = IGS_MAKE_MIX(alu,alu); \
-    (cop)->src1_start = (base); \
-    (cop)->fg = (pix); \
-    (cmd) = (IGS_DRAW_T_B | \
-	     IGS_DRAW_L_R | \
-	     IGS_DRAW_ALL | \
-	     IGS_PIXEL_STIP_TRANS | \
-	     IGS_HBLT_DISABLE | \
-	     IGS_SRC2_NORMAL | \
-	     IGS_STEP_PXBLT | \
-	     IGS_FGS_FG | \
-	     IGS_BGS_BG); \
-}
-
-#define _igsSetOpaqueStippledRect(cop,alu,pm,_fg,_bg,base,cmd) {\
-    _igsWaitFull(cop); \
-    (cop)->mix = IGS_MAKE_MIX(alu,alu); \
-    (cop)->src1_start = (base); \
-    (cop)->fg = (_fg); \
-    (cop)->bg = (_bg); \
-    (cmd) = (IGS_DRAW_T_B | \
-	     IGS_DRAW_L_R | \
-	     IGS_DRAW_ALL | \
-	     IGS_PIXEL_STIP_OPAQUE | \
-	     IGS_HBLT_DISABLE | \
-	     IGS_SRC2_NORMAL | \
-	     IGS_STEP_PXBLT | \
-	     IGS_FGS_FG | \
-	     IGS_BGS_BG); \
-}
-
-#define _igsRect(cop,x,y,w,h,cmd) { \
-    _igsWaitFull(cop); \
-    (cop)->dst_start = (x) + (y) * (cop_stride); \
-    (cop)->dim = IGS_MAKE_DIM(w-1,h-1); \
-    (cop)->operation = (cmd); \
-}
-
-#define _igsPatRect(cop,x,y,w,h,cmd) { \
-    _igsWaitFull(cop); \
-    (cop)->dst_start = (x) + (y) * (cop_stride); \
-    (cop)->rotate = IGS_MAKE_ROTATE(x&7,y&7); \
-    (cop)->dim = IGS_MAKE_DIM(w-1,h-1); \
-    (cop)->operation = (cmd); \
-}
-
-#define _igsSetBlt(cop,alu,pm,backwards,upsidedown,cmd) { \
-    _igsWaitFull(cop); \
-    (cop)->mix = IGS_MAKE_MIX(alu,alu); \
-    (cop)->src1_stride = cop_stride - 1; \
-    (cmd) = (IGS_DRAW_ALL | \
-	     IGS_PIXEL_FG | \
-	     IGS_HBLT_DISABLE | \
-	     IGS_SRC2_NORMAL | \
-	     IGS_STEP_PXBLT | \
-	     IGS_FGS_SRC | \
-	     IGS_BGS_BG); \
-    if (backwards) (cmd) |= IGS_DRAW_R_L; \
-    if (upsidedown) (cmd) |= IGS_DRAW_B_T; \
-}
-
-#if 0
-#define _igsPreparePlaneBlt(cop) { \
-    _igsReset(cop); \
-    (cop)->dst_stride = cop_stride - 1; \
-    (cop)->src1_stride = cop_stride - 1; \
-    (cop)->src2_stride = cop_stride - 1; \
-    (cop)->format = IGS_FORMAT_16BPP;  \
-    (cop)->src1_start = 0; \
-    (cop)->src2_start = 0; \
-}
-#else
-#define _igsPreparePlaneBlt(cop)
-#endif
-    
-#define _igsSetTransparentPlaneBlt(cop,alu,pm,fg_pix,cmd) { \
-    _igsWaitIdleEmpty(cop); \
-    _igsPreparePlaneBlt(cop); \
-    (cop)->mix = IGS_MAKE_MIX(igsPatRop[alu],igsPatRop[alu]); \
-    (cop)->fg = (fg_pix); \
-    (cmd) = (IGS_DRAW_T_B | \
-	     IGS_DRAW_L_R | \
-	     IGS_DRAW_ALL | \
-	     IGS_PIXEL_FG | \
-	     IGS_HBLT_WRITE_2 | \
-	     IGS_SRC2_MONO_TRANS | \
-	     IGS_STEP_TERNARY_PXBLT | \
-	     IGS_FGS_FG | \
-	     IGS_BGS_BG); \
-}
-
-#define _igsSetOpaquePlaneBlt(cop,alu,pm,fg_pix,bg_pix,cmd) { \
-    _igsWaitIdleEmpty(cop); \
-    _igsPreparePlaneBlt(cop); \
-    (cop)->mix = IGS_MAKE_MIX(igsPatRop[alu],igsPatRop[alu]); \
-    (cop)->fg = (fg_pix); \
-    (cop)->bg = (bg_pix); \
-    (cmd) = (IGS_DRAW_T_B | \
-	     IGS_DRAW_L_R | \
-	     IGS_DRAW_ALL | \
-	     IGS_PIXEL_FG | \
-	     IGS_HBLT_WRITE_2 | \
-	     IGS_SRC2_MONO_OPAQUE | \
-	     IGS_STEP_TERNARY_PXBLT | \
-	     IGS_FGS_FG | \
-	     IGS_BGS_BG); \
-}
-
-#define _igsPlaneBlt(cop,x,y,w,h,cmd) { \
-/*    _igsWaitFull(cop); */ \
-    (cop)->dst_start = (x) + (y) * (cop_stride); \
-    (cop)->dim = IGS_MAKE_DIM((w)-1,(h)-1); \
-    (cop)->operation = (cmd); \
-/*    _igsWaitHostBltAck(cop); */ \
-}
-    
-#define _igsBlt(cop,sx,sy,dx,dy,w,h,cmd) { \
-    _igsWaitFull(cop); \
-    (cop)->dst_start = (dx) + (dy) * cop_stride; \
-    (cop)->src1_start = (sx) + (sy) * cop_stride; \
-    (cop)->src1_stride = cop_stride - 1; \
-    (cop)->dim = IGS_MAKE_DIM(w-1,h-1); \
-    (cop)->operation = (cmd); \
-}
-
-#define sourceInvarient(alu)	(((alu) & 3) == (((alu) >> 2) & 3))
-
-#endif
diff --git a/hw/kdrive/igs/igsreg.c b/hw/kdrive/igs/igsreg.c
deleted file mode 100644
index 6d6f28b..0000000
--- a/hw/kdrive/igs/igsreg.c
+++ /dev/null
@@ -1,969 +0,0 @@
-/*
- * Copyright © 2000 Keith Packard
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Keith Packard not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  Keith Packard makes no
- * representations about the suitability of this software for any purpose.  It
- * is provided "as is" without express or implied warranty.
- *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <kdrive-config.h>
-#endif
-#include "igsreg.h"
-#include <stdio.h>
-
-#define CR00 IGS_CR+0x00
-#define CR01 IGS_CR+0x01
-#define CR02 IGS_CR+0x02
-#define CR03 IGS_CR+0x03
-#define CR04 IGS_CR+0x04
-#define CR05 IGS_CR+0x05
-#define CR06 IGS_CR+0x06
-#define CR07 IGS_CR+0x07
-#define CR08 IGS_CR+0x08
-#define CR09 IGS_CR+0x09
-#define CR0A IGS_CR+0x0A
-#define CR0B IGS_CR+0x0B
-#define CR0C IGS_CR+0x0C
-#define CR0D IGS_CR+0x0D
-#define CR0E IGS_CR+0x0E
-#define CR0F IGS_CR+0x0F
-#define CR10 IGS_CR+0x10
-#define CR11 IGS_CR+0x11
-#define CR12 IGS_CR+0x12
-#define CR13 IGS_CR+0x13
-#define CR14 IGS_CR+0x14
-#define CR15 IGS_CR+0x15
-#define CR16 IGS_CR+0x16
-#define CR17 IGS_CR+0x17
-#define CR18 IGS_CR+0x18
-#define CR19 IGS_CR+0x19
-#define CR1A IGS_CR+0x1A
-#define CR1B IGS_CR+0x1B
-#define CR1C IGS_CR+0x1C
-#define CR1D IGS_CR+0x1D
-#define CR1E IGS_CR+0x1E
-#define CR1F IGS_CR+0x1F
-#define CR20 IGS_CR+0x20
-#define CR21 IGS_CR+0x21
-#define CR22 IGS_CR+0x22
-#define CR23 IGS_CR+0x23
-#define CR24 IGS_CR+0x24
-#define CR25 IGS_CR+0x25
-#define CR26 IGS_CR+0x26
-#define CR27 IGS_CR+0x27
-#define CR28 IGS_CR+0x28
-#define CR29 IGS_CR+0x29
-#define CR2A IGS_CR+0x2A
-#define CR2B IGS_CR+0x2B
-#define CR2C IGS_CR+0x2C
-#define CR2D IGS_CR+0x2D
-#define CR2E IGS_CR+0x2E
-#define CR2F IGS_CR+0x2F
-#define CR30 IGS_CR+0x30
-#define CR31 IGS_CR+0x31
-#define CR32 IGS_CR+0x32
-#define CR33 IGS_CR+0x33
-#define CR34 IGS_CR+0x34
-#define CR35 IGS_CR+0x35
-#define CR36 IGS_CR+0x36
-#define CR37 IGS_CR+0x37
-#define CR38 IGS_CR+0x38
-#define CR39 IGS_CR+0x39
-#define CR3A IGS_CR+0x3A
-#define CR3B IGS_CR+0x3B
-#define CR3C IGS_CR+0x3C
-#define CR3D IGS_CR+0x3D
-#define CR3E IGS_CR+0x3E
-#define CR3F IGS_CR+0x3F
-#define CR40 IGS_CR+0x40
-#define CR41 IGS_CR+0x41
-#define CR42 IGS_CR+0x42
-#define CR43 IGS_CR+0x43
-#define CR44 IGS_CR+0x44
-#define CR45 IGS_CR+0x45
-#define CR46 IGS_CR+0x46
-#define CR47 IGS_CR+0x47
-#define CR48 IGS_CR+0x48
-
-#define CR_FIRST    CR00
-#define CR_LAST	    CR48
-
-#define SR00 IGS_SR+0x00
-#define SR01 IGS_SR+0x01
-#define SR02 IGS_SR+0x02
-#define SR03 IGS_SR+0x03
-#define SR04 IGS_SR+0x04
-
-#define SR_FIRST    SR00
-#define SR_LAST	    SR04
-
-#define AR00 IGS_AR+0x00
-#define AR01 IGS_AR+0x01
-#define AR02 IGS_AR+0x02
-#define AR03 IGS_AR+0x03
-#define AR04 IGS_AR+0x04
-#define AR05 IGS_AR+0x05
-#define AR06 IGS_AR+0x06
-#define AR07 IGS_AR+0x07
-#define AR08 IGS_AR+0x08
-#define AR09 IGS_AR+0x09
-#define AR0A IGS_AR+0x0A
-#define AR0B IGS_AR+0x0B
-#define AR0C IGS_AR+0x0C
-#define AR0D IGS_AR+0x0D
-#define AR0E IGS_AR+0x0E
-#define AR0F IGS_AR+0x0F
-#define AR10 IGS_AR+0x10
-#define AR11 IGS_AR+0x11
-#define AR12 IGS_AR+0x12
-#define AR13 IGS_AR+0x13
-#define AR14 IGS_AR+0x14
-
-#define AR_FIRST    AR00
-#define AR_LAST	    AR14
-
-#define GR00 IGS_GR+0x00
-#define GR01 IGS_GR+0x01
-#define GR02 IGS_GR+0x02
-#define GR03 IGS_GR+0x03
-#define GR04 IGS_GR+0x04
-#define GR05 IGS_GR+0x05
-#define GR06 IGS_GR+0x06
-#define GR07 IGS_GR+0x07
-#define GR08 IGS_GR+0x08
-#define GR09 IGS_GR+0x09
-#define GR0A IGS_GR+0x0A
-#define GR0B IGS_GR+0x0B
-#define GR0C IGS_GR+0x0C
-#define GR0D IGS_GR+0x0D
-#define GR0E IGS_GR+0x0E
-#define GR0F IGS_GR+0x0F
-#define GR10 IGS_GR+0x10
-#define GR11 IGS_GR+0x11
-#define GR12 IGS_GR+0x12
-#define GR13 IGS_GR+0x13
-#define GR14 IGS_GR+0x14
-#define GR15 IGS_GR+0x15
-#define GR16 IGS_GR+0x16
-#define GR17 IGS_GR+0x17
-#define GR18 IGS_GR+0x18
-#define GR19 IGS_GR+0x19
-#define GR1A IGS_GR+0x1A
-#define GR1B IGS_GR+0x1B
-#define GR1C IGS_GR+0x1C
-#define GR1D IGS_GR+0x1D
-#define GR1E IGS_GR+0x1E
-#define GR1F IGS_GR+0x1F
-#define GR20 IGS_GR+0x20
-#define GR21 IGS_GR+0x21
-#define GR22 IGS_GR+0x22
-#define GR23 IGS_GR+0x23
-#define GR24 IGS_GR+0x24
-#define GR25 IGS_GR+0x25
-#define GR26 IGS_GR+0x26
-#define GR27 IGS_GR+0x27
-#define GR28 IGS_GR+0x28
-#define GR29 IGS_GR+0x29
-#define GR2A IGS_GR+0x2A
-#define GR2B IGS_GR+0x2B
-#define GR2C IGS_GR+0x2C
-#define GR2D IGS_GR+0x2D
-#define GR2E IGS_GR+0x2E
-#define GR2F IGS_GR+0x2F
-#define GR30 IGS_GR+0x30
-#define GR31 IGS_GR+0x31
-#define GR32 IGS_GR+0x32
-#define GR33 IGS_GR+0x33
-#define GR34 IGS_GR+0x34
-#define GR35 IGS_GR+0x35
-#define GR36 IGS_GR+0x36
-#define GR37 IGS_GR+0x37
-#define GR38 IGS_GR+0x38
-#define GR39 IGS_GR+0x39
-#define GR3A IGS_GR+0x3A
-#define GR3B IGS_GR+0x3B
-#define GR3C IGS_GR+0x3C
-#define GR3D IGS_GR+0x3D
-#define GR3E IGS_GR+0x3E
-#define GR3F IGS_GR+0x3F
-#define GR40 IGS_GR+0x40
-#define GR41 IGS_GR+0x41
-#define GR42 IGS_GR+0x42
-#define GR43 IGS_GR+0x43
-#define GR44 IGS_GR+0x44
-#define GR45 IGS_GR+0x45
-#define GR46 IGS_GR+0x46
-#define GR47 IGS_GR+0x47
-#define GR48 IGS_GR+0x48
-#define GR49 IGS_GR+0x49
-#define GR4A IGS_GR+0x4A
-#define GR4B IGS_GR+0x4B
-#define GR4C IGS_GR+0x4C
-#define GR4D IGS_GR+0x4D
-#define GR4E IGS_GR+0x4E
-#define GR4F IGS_GR+0x4F
-#define GR50 IGS_GR+0x50
-#define GR51 IGS_GR+0x51
-#define GR52 IGS_GR+0x52
-#define GR53 IGS_GR+0x53
-#define GR54 IGS_GR+0x54
-#define GR55 IGS_GR+0x55
-#define GR56 IGS_GR+0x56
-#define GR57 IGS_GR+0x57
-#define GR58 IGS_GR+0x58
-#define GR59 IGS_GR+0x59
-#define GR5A IGS_GR+0x5A
-#define GR5B IGS_GR+0x5B
-#define GR5C IGS_GR+0x5C
-#define GR5D IGS_GR+0x5D
-#define GR5E IGS_GR+0x5E
-#define GR5F IGS_GR+0x5F
-#define GR60 IGS_GR+0x60
-#define GR61 IGS_GR+0x61
-#define GR62 IGS_GR+0x62
-#define GR63 IGS_GR+0x63
-#define GR64 IGS_GR+0x64
-#define GR65 IGS_GR+0x65
-#define GR66 IGS_GR+0x66
-#define GR67 IGS_GR+0x67
-#define GR68 IGS_GR+0x68
-#define GR69 IGS_GR+0x69
-#define GR6A IGS_GR+0x6A
-#define GR6B IGS_GR+0x6B
-#define GR6C IGS_GR+0x6C
-#define GR6D IGS_GR+0x6D
-#define GR6E IGS_GR+0x6E
-#define GR6F IGS_GR+0x6F
-#define GR70 IGS_GR+0x70
-#define GR71 IGS_GR+0x71
-#define GR72 IGS_GR+0x72
-#define GR73 IGS_GR+0x73
-#define GR74 IGS_GR+0x74
-#define GR75 IGS_GR+0x75
-#define GR76 IGS_GR+0x76
-#define GR77 IGS_GR+0x77
-#define GR78 IGS_GR+0x78
-#define GR79 IGS_GR+0x79
-#define GR7A IGS_GR+0x7A
-#define GR7B IGS_GR+0x7B
-#define GR7C IGS_GR+0x7C
-#define GR7D IGS_GR+0x7D
-#define GR7E IGS_GR+0x7E
-#define GR7F IGS_GR+0x7F
-#define GR80 IGS_GR+0x80
-#define GR81 IGS_GR+0x81
-#define GR82 IGS_GR+0x82
-#define GR83 IGS_GR+0x83
-#define GR84 IGS_GR+0x84
-#define GR85 IGS_GR+0x85
-#define GR86 IGS_GR+0x86
-#define GR87 IGS_GR+0x87
-#define GR88 IGS_GR+0x88
-#define GR89 IGS_GR+0x89
-#define GR8A IGS_GR+0x8A
-#define GR8B IGS_GR+0x8B
-#define GR8C IGS_GR+0x8C
-#define GR8D IGS_GR+0x8D
-#define GR8E IGS_GR+0x8E
-#define GR8F IGS_GR+0x8F
-#define GR90 IGS_GR+0x90
-#define GR91 IGS_GR+0x91
-#define GR92 IGS_GR+0x92
-#define GR93 IGS_GR+0x93
-#define GR94 IGS_GR+0x94
-#define GR95 IGS_GR+0x95
-#define GR96 IGS_GR+0x96
-#define GR97 IGS_GR+0x97
-#define GR98 IGS_GR+0x98
-#define GR99 IGS_GR+0x99
-#define GR9A IGS_GR+0x9A
-#define GR9B IGS_GR+0x9B
-#define GR9C IGS_GR+0x9C
-#define GR9D IGS_GR+0x9D
-#define GR9E IGS_GR+0x9E
-#define GR9F IGS_GR+0x9F
-#define GRA0 IGS_GR+0xA0
-#define GRA1 IGS_GR+0xA1
-#define GRA2 IGS_GR+0xA2
-#define GRA3 IGS_GR+0xA3
-#define GRA4 IGS_GR+0xA4
-#define GRA5 IGS_GR+0xA5
-#define GRA6 IGS_GR+0xA6
-#define GRA7 IGS_GR+0xA7
-#define GRA8 IGS_GR+0xA8
-#define GRA9 IGS_GR+0xA9
-#define GRAA IGS_GR+0xAA
-#define GRAB IGS_GR+0xAB
-#define GRAC IGS_GR+0xAC
-#define GRAD IGS_GR+0xAD
-#define GRAE IGS_GR+0xAE
-#define GRAF IGS_GR+0xAF
-#define GRB0 IGS_GR+0xB0
-#define GRB1 IGS_GR+0xB1
-#define GRB2 IGS_GR+0xB2
-#define GRB3 IGS_GR+0xB3
-#define GRB4 IGS_GR+0xB4
-#define GRB5 IGS_GR+0xB5
-#define GRB6 IGS_GR+0xB6
-#define GRB7 IGS_GR+0xB7
-#define GRB8 IGS_GR+0xB8
-#define GRB9 IGS_GR+0xB9
-#define GRBA IGS_GR+0xBA
-#define GRBB IGS_GR+0xBB
-#define GRBC IGS_GR+0xBC
-#define GRBD IGS_GR+0xBD
-#define GRBE IGS_GR+0xBE
-#define GRBF IGS_GR+0xBF
-
-#define GR_FIRST    GR00
-#define GR_LAST	    GRBF
-
-#define GREX3C	IGS_GREX+(0x3c-IGS_GREXBASE)
-
-VgaReg igs_h_total[] = {
-    CR00,   0, 8,
-    VGA_REG_END
-};
-
-VgaReg igs_h_de_end[] = {
-    CR01,   0, 8,
-    VGA_REG_END
-};
-
-VgaReg igs_h_bstart[] = {
-    CR02,   0, 8,
-    VGA_REG_END
-};
-
-VgaReg igs_h_bend[] = {
-    CR03,   0, 5,
-    CR05,   7, 1,
-    VGA_REG_END
-};
-
-VgaReg igs_de_skew[] = {
-    CR03,   5, 2,
-    VGA_REG_END
-};
-
-VgaReg igs_ena_vr_access[] = {
-    CR03,   7, 1,
-    VGA_REG_END
-};
-
-VgaReg igs_h_rstart[] = {
-    CR04,   0, 8,
-    VGA_REG_END
-};
-
-VgaReg igs_h_rend[] = {
-    CR05,   0, 5,
-    VGA_REG_END
-};
-
-VgaReg igs_h_rdelay[] = {
-    CR05,   5, 2,
-    VGA_REG_END
-};
-
-VgaReg igs_v_total[] = {
-    CR06,   0, 8,
-    CR07,   0, 1,
-    CR07,   5, 1,
-    GR11,   0, 1,
-    VGA_REG_END
-};
-
-VgaReg igs_v_rstart[] = {
-    CR10,   0, 8,
-    CR07,   2, 1,
-    CR07,   7, 1,
-    GR11,   2, 1,
-    VGA_REG_END
-};
-
-VgaReg igs_v_rend[] = {
-    CR11,   0, 4,
-    VGA_REG_END
-};
-
-VgaReg igs_clear_v_int[] = {
-    CR11,   4, 1,
-    VGA_REG_END
-};
-
-VgaReg igs_disable_v_int[] = {
-    CR11,   5, 1,
-    VGA_REG_END
-};
-
-VgaReg igs_bandwidth[] = {
-    CR11,   6, 1,
-    VGA_REG_END
-};
-
-VgaReg igs_crt_protect[] = {
-    CR11,   7, 1,
-    VGA_REG_END
-};
-
-VgaReg igs_v_de_end[] = {
-    CR12,   0, 8,
-    CR07,   1, 1,
-    CR07,   6, 1,
-    GR11,   1, 1,
-    VGA_REG_END
-};
-
-VgaReg igs_offset[] = {
-    CR13,   0, 8,
-    GR15,   4, 2,
-    VGA_REG_END
-};
-
-VgaReg igs_v_bstart[] = {
-    CR15,   0, 8,
-    CR07,   3, 1,
-    CR09,   5, 1,
-    GR11,   3, 1,
-    VGA_REG_END
-};
-
-VgaReg igs_v_bend[] = {
-    CR16,   0, 7,
-    VGA_REG_END
-};
-
-VgaReg igs_linecomp[] = {
-    CR18,   0, 8,
-    CR07,   4, 1,
-    CR09,   6, 1,
-    GR11,   4, 1,
-    VGA_REG_END
-};
-
-VgaReg igs_ivideo[] = {
-    GR11,   5, 1,
-    VGA_REG_END
-};
-
-VgaReg igs_num_fetch[] = {
-    GR14,   0, 8,
-    GR15,   0, 2,
-    VGA_REG_END
-};
-
-VgaReg igs_wcrt0[] = {
-    CR1F, 0, 1,
-    VGA_REG_END
-};
-
-VgaReg igs_wcrt1[] = {
-    CR1F, 1, 1,
-    VGA_REG_END
-};
-
-VgaReg igs_rcrts1[] = {
-    CR1F, 4, 1,
-    VGA_REG_END
-};
-
-VgaReg igs_selwk[] = {
-    CR1F, 6, 1,
-    VGA_REG_END
-};
-
-VgaReg igs_dot_clock_8[] = {
-    SR01, 0, 1,
-    VGA_REG_END
-};
-
-VgaReg igs_screen_off[] = {
-    SR01, 5, 1,
-    VGA_REG_END
-};
-
-VgaReg igs_enable_write_plane[] = {
-    SR02, 0, 4,
-    VGA_REG_END
-};
-
-VgaReg igs_mexhsyn[] = {
-    GR16,   0, 2,
-    VGA_REG_END
-};
-
-VgaReg igs_mexvsyn[] = {
-    GR16,   2, 2,
-    VGA_REG_END
-};
-
-VgaReg igs_pci_burst_write[] = {
-    GR30,   5, 1,
-    VGA_REG_END
-};
-
-VgaReg igs_pci_burst_read[] = {
-    GR30,   7, 1,
-    VGA_REG_END
-};
-
-VgaReg	igs_iow_retry[] = {
-    GREX3C, 0, 1,
-    VGA_REG_END
-};
-
-VgaReg  igs_mw_retry[] = {
-    GREX3C, 1, 1,
-    VGA_REG_END
-};
-
-VgaReg  igs_mr_retry[] = {
-    GREX3C, 2, 1,
-    VGA_REG_END
-};
-
-
-
-VgaReg	igs_biga22en[] = {
-    GR3D,   4, 1,
-    VGA_REG_END
-};
-
-VgaReg	igs_biga24en[] = {
-    GR3D,   5, 1,
-    VGA_REG_END
-};
-
-VgaReg	igs_biga22force[] = {
-    GR3D,   6, 1,
-    VGA_REG_END
-};
-
-VgaReg	igs_bigswap[] = {
-    GR3F,   0, 6,
-    VGA_REG_END
-};
-
-/* #define IGS_BIGSWAP_8	0x3f */
-/* #define IGS_BIGSWAP_16	0x2a */
-/* #define IGS_BIGSWAP_32	0x00 */
-
-VgaReg  igs_sprite_x[] = {
-    GR50,   0, 8,
-    GR51,   0, 3,
-    VGA_REG_END
-};
-
-VgaReg  igs_sprite_preset_x[] = {
-    GR52,   0, 6,
-    VGA_REG_END
-};
-
-VgaReg  igs_sprite_y[] = {
-    GR53,   0, 8,
-    GR54,   0, 3,
-    VGA_REG_END
-};
-
-VgaReg  igs_sprite_preset_y[] = {
-    GR55,   0, 6,
-    VGA_REG_END
-};
-
-VgaReg	igs_sprite_visible[] = {
-    GR56,   0, 1,
-    VGA_REG_END
-};
-
-VgaReg  igs_sprite_64x64[] = {
-    GR56,   1, 1,
-    VGA_REG_END
-};
-
-VgaReg  igs_mgrext[] = {
-    GR57,   0, 1,
-    VGA_REG_END
-};
-
-VgaReg  igs_hcshf[] = {
-    GR57,   4, 2,
-    VGA_REG_END
-};
-
-VgaReg	igs_mbpfix[] = {
-    GR57,   6, 2,
-    VGA_REG_END
-};
-
-VgaReg igs_overscan_red[] = {
-    GR58, 0, 8,
-    VGA_REG_END
-};
-
-VgaReg igs_overscan_green[] = {
-    GR59, 0, 8,
-    VGA_REG_END
-};
-
-VgaReg igs_overscan_blue[] = {
-    GR5A, 0, 8,
-    VGA_REG_END
-};
-
-VgaReg igs_memgopg[] = {
-    GR73,   2, 1,
-    VGA_REG_END
-};
-
-VgaReg igs_memr2wpg[] = {
-    GR73,   1, 1,
-    VGA_REG_END
-};
-
-VgaReg igs_crtff16[] = {
-    GR73,   3, 1,
-    VGA_REG_END
-};
-
-VgaReg igs_fifomust[] = {
-    GR74,   0, 5,
-    VGA_REG_END
-};
-
-VgaReg igs_fifogen[] = {
-    GR75,   0, 5,
-    VGA_REG_END
-};
-
-VgaReg igs_mode_sel[] = {
-    GR77,   0, 4,
-    VGA_REG_END
-};
-
-/* #define IGS_MODE_TEXT	0 */
-/* #define IGS_MODE_8	1 */
-/* #define IGS_MODE_565	2 */
-/* #define IGS_MODE_5551	6 */
-/* #define IGS_MODE_8888	3 */
-/* #define IGS_MODE_888	4 */
-/* #define IGS_MODE_332	9 */
-/* #define IGS_MODE_4444	10 */
-
-VgaReg  igs_sprite_addr[] = {
-    GR7E,   0, 8,
-    GR7F,   0, 4,
-    VGA_REG_END
-};
-
-VgaReg  igs_fastmpie[] = {
-    GR9E,   0, 1,
-    VGA_REG_END
-};
-
-VgaReg  igs_vclk_m[] = {
-    GRB0,   0, 8,
-    GRBA,   0, 3,
-    VGA_REG_END
-};
-
-VgaReg  igs_vclk_n[] = {
-    GRB1,   0, 5,
-    GRBA,   3, 3,
-    VGA_REG_END
-};
-
-VgaReg  igs_vfsel[] = {
-    GRB1,   5, 1,
-    VGA_REG_END
-};
-
-VgaReg  igs_vclk_p[] = {
-    GRB1,   6, 2,
-    GRBA,   6, 1,
-    VGA_REG_END
-};
-
-VgaReg  igs_frqlat[] = {
-    GRB9, 7, 1,
-    VGA_REG_END
-};
-
-
-VgaReg igs_dac_mask[] = {
-    IGS_DAC + 0,	0, 8,
-    VGA_REG_END
-};
-
-VgaReg igs_dac_read_index[] = {
-    IGS_DAC + 1, 0, 8,
-    VGA_REG_END
-};
-
-VgaReg igs_dac_write_index[] = {
-    IGS_DAC + 2, 0, 8,
-    VGA_REG_END
-};
-
-VgaReg igs_dac_data[] = {
-    IGS_DAC + 3, 0, 8,
-    VGA_REG_END
-};
-
-VgaReg	igs_rampwdn[] = {
-    IGS_DACEX + 0,   0, 1,
-    VGA_REG_END
-};
-
-VgaReg	igs_dac6_8[] = {
-    IGS_DACEX + 0,   1, 1,
-    VGA_REG_END
-};
-
-VgaReg  igs_ramdacbypass[] = {
-    IGS_DACEX + 0,   4, 1,
-    VGA_REG_END
-};
-
-VgaReg	igs_dacpwdn[] = {
-    IGS_DACEX + 0,   6, 1,
-    VGA_REG_END
-};
-
-VgaReg	igs_cursor_read_index[] = {
-    IGS_DACEX + 1, 0, 8,
-    VGA_REG_END
-};
-
-VgaReg igs_cursor_write_index[] = {
-    IGS_DACEX + 2, 0, 8,
-    VGA_REG_END
-};
-
-VgaReg igs_cursor_data[] = {
-    IGS_DACEX + 3, 0, 8,
-    VGA_REG_END
-};
-
-VGA8
-_igsInb (VgaCard *card, VGA16 port)
-{
-    VGAVOL8 *reg;
-    
-    if (card->closure)
-	return VgaReadMemb ((VGA32) card->closure + port);
-    else
-	return VgaInb (port);
-}
-
-void
-_igsOutb (VgaCard *card, VGA8 value, VGA16 port)
-{
-    if (card->closure)
-	VgaWriteMemb (value, (VGA32) card->closure + port);
-    else
-	VgaOutb (value, port);
-}
-
-void
-_igsRegMap (VgaCard *card, VGA16 reg, VgaMap *map, VGABOOL write)
-{
-    if (reg < IGS_SR + IGS_NSR)
-    {
-	map->access = VgaAccessIndIo;
-	map->port = 0x3c4;
-	map->addr = 0;
-	map->value = 1;
-	map->index = reg - IGS_SR;
-    }
-    else if (reg < IGS_GR + IGS_NGR)
-    {
-	map->access = VgaAccessIndIo;
-	map->port = 0x3ce;
-	map->addr = 0;
-	map->value = 1;
-	map->index = reg - IGS_GR;
-    }
-    else if (reg < IGS_GREX + IGS_NGREX)
-    {
-	VGA8	gr33;
-
-	map->access = VgaAccessDone;
-	_igsOutb (card, 0x33, 0x3ce);
-	gr33 = _igsInb (card, 0x3cf);
-	_igsOutb (card, gr33 | 0x40, 0x3cf);
-	_igsOutb (card, IGS_GREXBASE + reg - IGS_GREX, 0x3ce);
-	if (write)
-	    _igsOutb (card, map->value, 0x3cf);
-	else
-	    map->value = _igsInb (card, 0x3cf);
-	_igsOutb (card, 0x33, 0x3ce);
-	_igsOutb (card, gr33, 0x3cf);
-	return;
-    }
-    else if (reg < IGS_AR + IGS_NAR)
-    {
-	reg -= IGS_AR;
-	map->access = VgaAccessDone;
-	/* reset AFF to index */
-	(void) _igsInb (card, 0x3da);
-	if (reg >= 16)
-	    reg |= 0x20;
-	_igsOutb (card, reg, 0x3c0);
-	if (write)
-	    _igsOutb (card, map->value, 0x3c0);
-	else
-	    map->value = _igsInb (card, 0x3c1);
-	if (!(reg & 0x20))
-	{
-	    /* enable video display again */
-	    (void) _igsInb (card, 0x3da);
-	    _igsOutb (card, 0x20, 0x3c0);
-	}
-	return;
-    }
-    else if (reg < IGS_CR + IGS_NCR)
-    {
-	map->access = VgaAccessIndIo;
-	map->port = 0x3d4;
-	map->addr = 0;
-	map->value = 1;
-	map->index = reg - IGS_CR;
-    }
-    else if (reg < IGS_DAC + IGS_NDAC)
-    {
-	map->access = VgaAccessIo;
-	map->port = 0x3c6 + reg - IGS_DAC;
-    }
-    else if (reg < IGS_DACEX + IGS_NDACEX)
-    {
-	VGA8	gr56;
-	reg = 0x3c6 + reg - IGS_DACEX;
-	map->access = VgaAccessDone;
-	_igsOutb (card, 0x56, 0x3ce);
-	gr56 = _igsInb (card, 0x3cf);
-	_igsOutb (card, gr56 | 4, 0x3cf);
-	if (write)
-	    _igsOutb (card, map->value, reg);
-	else
-	    map->value = _igsInb (card, reg);
-	_igsOutb (card, gr56, 0x3cf);
-	return;
-    }
-    else switch (reg) {
-    case IGS_MISC_OUT:
-	map->access = VgaAccessIo;
-	if (write)
-	    map->port = 0x3c2;
-	else
-	    map->port = 0x3cc;
-	break;
-    case IGS_INPUT_STATUS_1:
-	map->access = VgaAccessIo;
-	map->port = 0x3da;
-	break;
-    }
-    if (card->closure)
-    {
-	map->port = map->port + (VGA32) card->closure;
-	if (map->access == VgaAccessIo)
-	    map->access = VgaAccessMem;
-	if (map->access == VgaAccessIndIo)
-	    map->access = VgaAccessIndMem;
-    }
-}
-
-VgaSave	    igsSaves[] = {
-    CR00, CR18,
-    SR01, SR02,
-    GR11, GRBA,
-    IGS_MISC_OUT, IGS_MISC_OUT,
-    VGA_SAVE_END
-};
-
-void
-igsRegInit (IgsVga *igsvga, VGAVOL8 *mmio)
-{
-    igsvga->card.map = _igsRegMap;
-    igsvga->card.closure = (void *) mmio;
-    igsvga->card.max = IGS_NREG;
-    igsvga->card.values = igsvga->values;
-    igsvga->card.saves = igsSaves;
-}
-
-void
-igsSave (IgsVga *igsvga)
-{
-    igsSetImm (igsvga, igs_wcrt0, 1);
-    igsSetImm (igsvga, igs_wcrt1, 1);
-    igsSetImm (igsvga, igs_rcrts1, 1);
-    igsSetImm (igsvga, igs_selwk, 1);
-    VgaPreserve (&igsvga->card);
-}
-
-void
-igsReset (IgsVga *igsvga)
-{
-    VgaRestore (&igsvga->card);
-    igsSetImm (igsvga, igs_frqlat, 0);
-    igsSetImm (igsvga, igs_frqlat, 1);
-    igsSetImm (igsvga, igs_frqlat, 0);    
-    VgaFinish (&igsvga->card);
-}
-
-char *
-igsRegName(char *buf, VGA16 reg)
-{
-    if (reg < IGS_SR + IGS_NSR)
-    {
-	sprintf (buf, "  SR%02X", reg - IGS_SR);
-    }
-    else if (reg < IGS_GR + IGS_NGR)
-    {
-	sprintf (buf, "  GR%02X", reg - IGS_GR);
-    }
-    else if (reg < IGS_GREX + IGS_NGREX)
-    {
-	sprintf (buf, " GRX%02X", reg - IGS_GREX + IGS_GREXBASE);
-    }
-    else if (reg < IGS_AR + IGS_NAR)
-    {
-	sprintf (buf, "  AR%02X", reg - IGS_AR);
-    }
-    else if (reg < IGS_CR + IGS_NCR)
-    {
-	sprintf (buf, "  CR%02X", reg - IGS_CR);
-    }
-    else if (reg < IGS_DAC + IGS_NDAC)
-    {
-	sprintf (buf, " DAC%02X", reg - IGS_DAC);
-    }
-    else if (reg < IGS_DACEX + IGS_NDACEX)
-    {
-	sprintf (buf, "DACX%02X", reg - IGS_DACEX);
-    }
-    else switch (reg) {
-    case IGS_MISC_OUT:
-	sprintf (buf, "MISC_O");
-	break;
-    case IGS_INPUT_STATUS_1:
-	sprintf (buf, "IN_S_1");
-	break;
-    }
-    return buf;
-}
diff --git a/hw/kdrive/igs/igsreg.h b/hw/kdrive/igs/igsreg.h
deleted file mode 100644
index 2230ff0..0000000
--- a/hw/kdrive/igs/igsreg.h
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * Copyright © 2000 Keith Packard
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Keith Packard not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  Keith Packard makes no
- * representations about the suitability of this software for any purpose.  It
- * is provided "as is" without express or implied warranty.
- *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifndef _IGSREG_H_
-#define _IGSREG_H_
-
-#include "vga.h"
-
-#define IGS_SR	    0
-#define IGS_NSR	    5
-#define IGS_GR	    (IGS_SR+IGS_NSR)
-#define IGS_NGR	    0xC0
-#define IGS_GREX    (IGS_GR+IGS_NGR)
-#define IGS_GREXBASE	0x3c
-#define IGS_NGREX   1
-#define IGS_AR	    (IGS_GREX+IGS_NGREX)
-#define IGS_NAR	    0x15
-#define IGS_CR	    (IGS_AR+IGS_NAR)
-#define IGS_NCR	    0x48
-#define IGS_DAC	    (IGS_CR+IGS_NCR)
-#define IGS_NDAC    4
-#define IGS_DACEX   (IGS_DAC+IGS_NDAC)
-#define IGS_NDACEX  4
-#define IGS_MISC_OUT	    (IGS_DACEX + IGS_NDACEX)
-#define IGS_INPUT_STATUS_1  (IGS_MISC_OUT+1)
-#define IGS_NREG	    (IGS_INPUT_STATUS_1+1)
-
-extern VgaReg igs_h_total[];
-extern VgaReg igs_h_de_end[];
-extern VgaReg igs_h_bstart[];
-extern VgaReg igs_h_bend[];
-extern VgaReg igs_de_skew[];
-extern VgaReg igs_ena_vr_access[];
-extern VgaReg igs_h_rstart[];
-extern VgaReg igs_h_rend[];
-extern VgaReg igs_h_rdelay[];
-extern VgaReg igs_v_total[];
-extern VgaReg igs_v_rstart[];
-extern VgaReg igs_v_rend[];
-extern VgaReg igs_clear_v_int[];
-extern VgaReg igs_disable_v_int[];
-extern VgaReg igs_bandwidth[];
-extern VgaReg igs_crt_protect[];
-extern VgaReg igs_v_de_end[];
-extern VgaReg igs_offset[];
-extern VgaReg igs_v_bstart[];
-extern VgaReg igs_v_bend[];
-extern VgaReg igs_linecomp[];
-extern VgaReg igs_ivideo[];
-extern VgaReg igs_num_fetch[];
-extern VgaReg igs_wcrt0[];
-extern VgaReg igs_wcrt1[];
-extern VgaReg igs_rcrts1[];
-extern VgaReg igs_selwk[];
-extern VgaReg igs_dot_clock_8[];
-extern VgaReg igs_screen_off[];
-extern VgaReg igs_enable_write_plane[];
-extern VgaReg igs_mexhsyn[];
-extern VgaReg igs_mexvsyn[];
-extern VgaReg igs_pci_burst_write[];
-extern VgaReg igs_pci_burst_read[];
-extern VgaReg	igs_iow_retry[];
-extern VgaReg  igs_mw_retry[];
-extern VgaReg  igs_mr_retry[];
-extern VgaReg	igs_biga22en[];
-extern VgaReg	igs_biga24en[];
-extern VgaReg	igs_biga22force[];
-extern VgaReg	igs_bigswap[];
-#define IGS_BIGSWAP_8	0x3f
-#define IGS_BIGSWAP_16	0x2a
-#define IGS_BIGSWAP_32	0x00
-extern VgaReg  igs_sprite_x[];
-extern VgaReg  igs_sprite_preset_x[];
-extern VgaReg  igs_sprite_y[];
-extern VgaReg  igs_sprite_preset_y[];
-extern VgaReg	igs_sprite_visible[];
-extern VgaReg  igs_sprite_64x64[];
-extern VgaReg  igs_mgrext[];
-extern VgaReg  igs_hcshf[];
-extern VgaReg	igs_mbpfix[];
-extern VgaReg igs_overscan_red[];
-extern VgaReg igs_overscan_green[];
-extern VgaReg igs_overscan_blue[];
-extern VgaReg igs_memgopg[];
-extern VgaReg igs_memr2wpg[];
-extern VgaReg igs_crtff16[];
-extern VgaReg igs_fifomust[];
-extern VgaReg igs_fifogen[];
-extern VgaReg igs_mode_sel[];
-#define IGS_MODE_TEXT	0
-#define IGS_MODE_8	1
-#define IGS_MODE_565	2
-#define IGS_MODE_5551	6
-#define IGS_MODE_8888	3
-#define IGS_MODE_888	4
-#define IGS_MODE_332	9
-#define IGS_MODE_4444	10
-extern VgaReg  igs_sprite_addr[];
-extern VgaReg  igs_fastmpie[];
-extern VgaReg  igs_vclk_m[];
-extern VgaReg  igs_vclk_n[];
-extern VgaReg  igs_vfsel[];
-extern VgaReg  igs_vclk_p[];
-extern VgaReg  igs_frqlat[];
-extern VgaReg igs_dac_mask[];
-extern VgaReg igs_dac_read_index[];
-extern VgaReg igs_dac_write_index[];
-extern VgaReg igs_dac_data[];
-extern VgaReg	igs_rampwdn[];
-extern VgaReg	igs_dac6_8[];
-extern VgaReg  igs_ramdacbypass[];
-extern VgaReg	igs_dacpwdn[];
-extern VgaReg	igs_cursor_read_index[];
-extern VgaReg igs_cursor_write_index[];
-extern VgaReg igs_cursor_data[];
-
-#define igsGet(sv,r)	    VgaGet(&(sv)->card, (r))
-#define igsGetImm(sv,r)	    VgaGetImm(&(sv)->card, (r))
-#define igsSet(sv,r,v)	    VgaSet(&(sv)->card, (r), (v))
-#define igsSetImm(sv,r,v)    VgaSetImm(&(sv)->card, (r), (v))
-
-typedef struct _igsVga {
-    VgaCard	card;
-    VgaValue	values[IGS_NREG];
-} IgsVga;
-
-void
-igsRegInit (IgsVga *igsvga, VGAVOL8 *mmio);
-
-void
-igsSave (IgsVga *igsvga);
-
-void
-igsReset (IgsVga *igsvga);
-
-#endif /* _IGSREG_H_ */
diff --git a/hw/kdrive/igs/igsstub.c b/hw/kdrive/igs/igsstub.c
deleted file mode 100644
index 1c58827..0000000
--- a/hw/kdrive/igs/igsstub.c
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright © 2000 Keith Packard
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Keith Packard not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  Keith Packard makes no
- * representations about the suitability of this software for any purpose.  It
- * is provided "as is" without express or implied warranty.
- *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <kdrive-config.h>
-#endif
-#include "igs.h"
-
-void
-InitCard (char *name)
-{
-    KdCardAttr	attr;
-    CARD32	count;
-
-    count = 0;
-#ifdef EMBED
-    attr.address[0] = 0x10000000;  /* Adomo Wing video base address  */
-    attr.io = 0;
-    attr.naddr = 1;
-#else
-    while (LinuxFindPci (0x10ea, 0x5000, count, &attr))
-#endif
-    {
-	KdCardInfoAdd (&igsFuncs, &attr, 0);
-	count++;
-    }
-}
-
-void
-InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv)
-{
-    KdInitOutput (pScreenInfo, argc, argv);
-}
-
-void
-InitInput (int argc, char **argv)
-{
-    KdOsAddInputDrivers ();
-    KdInitInput ();
-}
-
-void
-ddxUseMsg (void)
-{
-    KdUseMsg ();
-}
-
-int
-ddxProcessArgument (int argc, char **argv, int i)
-{
-    return KdProcessArgument (argc, argv, i);
-}
diff --git a/hw/kdrive/ipaq/ipaq.c b/hw/kdrive/ipaq/ipaq.c
deleted file mode 100644
index 057b799..0000000
--- a/hw/kdrive/ipaq/ipaq.c
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright © 1999 Keith Packard
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Keith Packard not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  Keith Packard makes no
- * representations about the suitability of this software for any purpose.  It
- * is provided "as is" without express or implied warranty.
- *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- *
- * Adapted from ts300.c by Alan Hourihane <alanh at fairlite.demon.co.uk>
- * For the Compaq IPAQ handheld, with the HP VGA Out Card (F1252A).
- */
-
-#ifdef HAVE_CONFIG_H
-#include <kdrive-config.h>
-#endif
-#include "pcmcia.h"
-
-extern KdCardFuncs  pcmciaFuncs;
-
-void
-InitCard (char *name)
-{
-    KdCardAttr attr;
-    if (name && !strcmp(name, "pcmcia"))
-    	KdCardInfoAdd (&pcmciaFuncs, &attr, 0);
-    else
-    	KdCardInfoAdd (&fbdevFuncs, &attr, 0);
-}
-
-void
-InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv)
-{
-    KdInitOutput (pScreenInfo, argc, argv);
-}
-
-void
-InitInput (int argc, char **argv)
-{
-    KdInitInput (&LinuxMouseFuncs, &LinuxKeyboardFuncs);
-#ifdef TOUCHSCREEN
-    KdAddMouseDriver (&TsFuncs);
-#endif
-}
-
-extern pcmciaDisplayModeRec pcmciaDefaultModes[];
-
-void
-ddxUseMsg (void)
-{
-    KdUseMsg();
-}
-
-int
-ddxProcessArgument (int argc, char **argv, int i)
-{
-    return KdProcessArgument (argc, argv, i);
-}
diff --git a/hw/kdrive/itsy/itsy.c b/hw/kdrive/itsy/itsy.c
deleted file mode 100644
index 47cc050..0000000
--- a/hw/kdrive/itsy/itsy.c
+++ /dev/null
@@ -1,325 +0,0 @@
-/*
- * Copyright © 1999 Keith Packard
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Keith Packard not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  Keith Packard makes no
- * representations about the suitability of this software for any purpose.  It
- * is provided "as is" without express or implied warranty.
- *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <kdrive-config.h>
-#endif
-#include "itsy.h"
-
-/* struct with LCD characteristics defined in fb_brutus.h  */
-static struct FbLcdParamsStruct fbLcdParams; 
-static int fb_d;
-static int fbn;
-Bool
-itsyCardInit (KdCardInfo *card)
-{
-    int	    k;
-    char    *fb;
-    char    *pixels;
-
-    if ((fb_d = open("/dev/fbclone", O_RDWR)) < 0) {
-	perror("Error opening /dev/fb\n");
-	return FALSE;
-    }
-    if ((k=ioctl(fb_d, FB_LCD_PARAMS, &fbLcdParams)) != 0) {
-	perror("Error with /dev/fb ioctl FB_LCD_PARAMS call");
-	return FALSE;
-    }
-
-    fb = (char *) mmap ((caddr_t) NULL, fbLcdParams.frameBufferSize,
-			PROT_READ|PROT_WRITE, MAP_FILE|MAP_SHARED, fb_d, 0);
-
-    fprintf (stderr, "fb mapped at 0x%x\n", fb);
-    if (fb == (char *)-1) {
-	perror("ERROR: mmap framebuffer fails!");
-	return FALSE;
-    }
-    
-    card->driver = fb;
-    
-    return TRUE;
-}
-
-Bool
-itsyScreenInit (KdScreenInfo *screen)
-{
-    CARD8   *fb = screen->card->driver;
-
-    screen->width = fbLcdParams.screenSizeH;
-    screen->height = fbLcdParams.screenSizeV;
-    screen->depth = fbLcdParams.bitsPerPixel;
-    screen->bitsPerPixel = fbLcdParams.bitsPerPixel;
-    screen->byteStride = fbLcdParams.frameBufferSizeH;
-    screen->pixelStride = (fbLcdParams.frameBufferSizeH * 8 / 
-			   fbLcdParams.bitsPerPixel);
-    fprintf (stderr, "width %d height %d depth %d pstride %d bstride %d\n",
-	     screen->width, screen->height, screen->depth, 
-	     screen->pixelStride, screen->byteStride);
-    screen->dumb = FALSE;
-    screen->softCursor = TRUE;
-    screen->blueMask = 0;
-    screen->greenMask = 0;
-    screen->redMask = 0;
-    screen->visuals = 1 << StaticGray;
-    screen->rate = 72;
-    screen->frameBuffer = (CARD8 *) (fb + 
-				     fbLcdParams.pixelDataOffset +
-				     (fbLcdParams.reserveTopRows * 
-				      screen->byteStride));
-    fprintf (stderr, "Frame buffer 0x%x\n", screen->frameBuffer);
-    return TRUE;
-}
-
-static unsigned short itsyIntensity[16] = {
-    0xffff,
-    0xffff,
-    0xedb6,
-    0xdb6d,
-    0xc924,
-    0xb6db,
-    0xa492,
-    0x9249,
-    0x8000,
-    0x6db6,
-    0x5b6d,
-    0x4924,
-    0x36db,
-    0x2492,
-    0x1249,
-    0x0000,
-};
-
-Bool
-itsyCreateColormap (ColormapPtr pmap)
-{
-    int	    i;
-
-    for (i = 0; i < 16; i++)
-    {
-	pmap->red[i].co.local.red = itsyIntensity[i];
-	pmap->red[i].co.local.green = itsyIntensity[i];
-	pmap->red[i].co.local.blue = itsyIntensity[i];
-    }
-    return TRUE;
-}
-
-Bool
-itsyInitScreen (ScreenPtr pScreen)
-{
-    pScreen->CreateColormap = itsyCreateColormap;
-    return TRUE;
-}
-
-void
-itsyPreserve (KdCardInfo *card)
-{
-}
-
-void
-itsyEnable (ScreenPtr pScreen)
-{
-    KdScreenPriv(pScreen);
-
-    fprintf (stderr, "Enabling LCD display\n");
-    /* display it on the LCD */
-    ioctl(fb_d, FB_LCD_SHOW, 0);
-}
-
-Bool
-itsyDPMS (ScreenPtr pScreen, int mode)
-{
-    if (mode)
-	ioctl (fb_d, FB_LCD_OFF, 0);
-    else
-	ioctl (fb_d, FB_LCD_ON, 0);
-    return TRUE;
-}
-
-void
-itsyDisable (ScreenPtr pScreen)
-{
-/*    ioctl (fb_d, FB_LCD_SWITCH, 0); */
-/*    fprintf (stderr, "Disabling LCD display\n");*/
-}
-
-void
-itsyRestore (KdCardInfo *card)
-{
-}
-
-void
-itsyScreenFini (KdScreenInfo *screen)
-{
-}
-
-void
-itsyCardFini (KdCardInfo *card)
-{
-    int	k;
-    
-    fprintf (stderr, "Unmapping driver at 0x%x\n", card->driver);
-    munmap (card->driver, fbLcdParams.frameBufferSize);
-    fprintf (stderr, "Releasing fbn %d\n", fbn);
-    /* release it */
-    if (ioctl(fb_d, FB_LCD_FREE, fbn) != 0) {
-	printf("FB_LCD_FREE of %d fails!\n", fbn);
-    }
-    close (fb_d);
-    fprintf (stderr, "itsyFini done\n");
-}
-
-KdCardFuncs	itsyFuncs = {
-    itsyCardInit,	    /* cardinit */
-    itsyScreenInit,	    /* scrinit */
-    itsyInitScreen,	    /* initScreen */
-    itsyPreserve,	    /* preserve */
-    itsyEnable,		    /* enable */
-    itsyDPMS,		    /* dpms */
-    itsyDisable,	    /* disable */
-    itsyRestore,	    /* restore */
-    itsyScreenFini,	    /* scrfini */
-    itsyCardFini,	    /* cardfini */
-    
-    0,			    /* initCursor */
-    0,			    /* enableCursor */
-    0,			    /* disableCursor */
-    0,			    /* finiCursor */
-    0,			    /* recolorCursor */
-    
-    0,			    /* initAccel */
-    0,			    /* enableAccel */
-    0,			    /* disableAccel */
-    0,			    /* finiAccel */
-    
-    0,			    /* getColors */
-    0,			    /* putColors */
-};
-
-void
-InitCard (void)
-{
-    KdCardAttr	attr;
-    
-    KdCardInfoAdd (&itsyFuncs, &attr, 0);
-}
-
-void
-InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv)
-{
-    KdInitOutput (pScreenInfo, argc, argv);
-}
-
-void
-InitInput (int argc, char **argv)
-{
-    KdInitInput (&itsyTsMouseFuncs, &itsyKeyboardFuncs);
-}
-
-int	itsySessionFd = -1;
-
-int
-ItsyOsInit (void)
-{
-    pid_t		sid;
-    int			i;
-    itsy_session_info	info;
-
-    if (itsySessionFd < 0)
-    {
-	itsySessionFd = open ("/dev/session", 0);
-	ErrorF("itsySessionFD %d\n", itsySessionFd);
-    }
-    
-    (void) setsid ();
-    sid = getsid (0);
-    ErrorF ("Session ID %d PID %d\n", sid, getpid ());
-    info.sid = sid;
-    strcpy (info.name, "X");
-    if (itsySessionFd >= 0)
-    {
-	i = ioctl (itsySessionFd, SESSION_SET_INFO, &info);
-	if (i < 0)
-	    perror ("SESSION_SET_INFO");
-    }
-    return 1;
-}
-
-void
-ItsyOsEnable (void)
-{
-    itsy_session_request    req;
-    int			    i;
-    
-#define MANAGER_SID_TO_FOREGROUND	2
-    
-    req.operation = MANAGER_SID_TO_FOREGROUND;
-    req.data = 0;
-    if (itsySessionFd >= 0)
-    {
-	i = ioctl (itsySessionFd, SESSION_MANAGER_REQUEST, &req);
-	if (i < 0)
-	    perror ("SESSION_MANAGER_REQUEST");
-    }
-}
-
-Bool
-ItsyOsSpecialKey (KeySym sym)
-{
-    return FALSE;
-}
-
-void
-ItsyOsDisable (void)
-{
-}
-
-void
-ItsyOsFini (void)
-{
-}
-
-KdOsFuncs   ItsyOsFuncs = {
-    ItsyOsInit,
-    ItsyOsEnable,
-    ItsyOsSpecialKey,
-    ItsyOsDisable,
-    ItsyOsFini,
-    0
-};
-    
-void
-OsVendorInit (void)
-{
-    KdOsInit (&ItsyOsFuncs);
-}
-
-void
-ddxUseMsg (void)
-{
-    KdUseMsg();
-}
-
-int
-ddxProcessArgument (int argc, char **argv, int i)
-{
-    return KdProcessArgument (argc, argv, i);
-}
diff --git a/hw/kdrive/itsy/itsy.h b/hw/kdrive/itsy/itsy.h
deleted file mode 100644
index fc8fb8f..0000000
--- a/hw/kdrive/itsy/itsy.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright © 1999 Keith Packard
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Keith Packard not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  Keith Packard makes no
- * representations about the suitability of this software for any purpose.  It
- * is provided "as is" without express or implied warranty.
- *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include "kdrive.h"
-#include <stdio.h>
-#include <sys/ioctl.h>
-#include <linux/itsy_fb.h>
-#include <linux/itsy_ts.h>
-#include <linux/itsy_buttons.h>
-#include <linux/itsy_session.h>
-#include <unistd.h>
-#include <sys/mman.h>
-
-#define FB_HEIGHT 200
-#define FB_WIDTH  320
-#define FB_DEPTH  4
-#define FB_PALETTE_SIZE 16
-
-extern KdMouseFuncs itsyTsMouseFuncs;
-extern KdKeyboardFuncs itsyKeyboardFuncs;
diff --git a/hw/kdrive/itsy/kbd.c b/hw/kdrive/itsy/kbd.c
deleted file mode 100644
index 83ed49e..0000000
--- a/hw/kdrive/itsy/kbd.c
+++ /dev/null
@@ -1,251 +0,0 @@
-/*
- * Copyright © 1999 Keith Packard
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Keith Packard not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  Keith Packard makes no
- * representations about the suitability of this software for any purpose.  It
- * is provided "as is" without express or implied warranty.
- *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <kdrive-config.h>
-#endif
-#include "itsy.h"
-#include <X11/keysym.h>
-#include <linux/itsy_buttons.h>
-
-#define ITSY_WIDTH  2
-
-KeySym ItsyKeymap[] = {
-/*      1     8 */	 XK_Escape, NoSymbol,
-/*      2     9 */	 XK_1,	XK_exclam,
-/*      3    10 */	 XK_2,	XK_at,
-/*      4    11 */	 XK_3,	XK_numbersign,
-/*      5    12 */	 XK_4,	XK_dollar,
-/*      6    13 */	 XK_5,	XK_percent,
-/*      7    14 */	 XK_6,	XK_asciicircum,
-/*      8    15 */	 XK_7,	XK_ampersand,
-/*      9    16 */	 XK_8,	XK_asterisk,
-/*     10    17 */	 XK_9,	XK_parenleft,
-/*     11    18 */	 XK_0,	XK_parenright,
-/*     12    19 */	 XK_minus,	XK_underscore,
-/*     13    20 */	 XK_equal,	XK_plus,
-/*     14    21 */	 XK_BackSpace,	NoSymbol,
-/*     15    22 */	 XK_Tab,	NoSymbol,
-/*     16    23 */	 XK_Q,	NoSymbol,
-/*     17    24 */	 XK_W,	NoSymbol,
-/*     18    25 */	 XK_E,	NoSymbol,
-/*     19    26 */	 XK_R,	NoSymbol,
-/*     20    27 */	 XK_T,	NoSymbol,
-/*     21    28 */	 XK_Y,	NoSymbol,
-/*     22    29 */	 XK_U,	NoSymbol,
-/*     23    30 */	 XK_I,	NoSymbol,
-/*     24    31 */	 XK_O,	NoSymbol,
-/*     25    32 */	 XK_P,	NoSymbol,
-/*     26    33 */	 XK_bracketleft,	XK_braceleft,
-/*     27    34 */	 XK_bracketright,	XK_braceright,
-/*     28    35 */	 XK_Return,	NoSymbol,
-/*     29    36 */	 XK_Control_L,	NoSymbol,
-/*     30    37 */	 XK_A,	NoSymbol,
-/*     31    38 */	 XK_S,	NoSymbol,
-/*     32    39 */	 XK_D,	NoSymbol,
-/*     33    40 */	 XK_F,	NoSymbol,
-/*     34    41 */	 XK_G,	NoSymbol,
-/*     35    42 */	 XK_H,	NoSymbol,
-/*     36    43 */	 XK_J,	NoSymbol,
-/*     37    44 */	 XK_K,	NoSymbol,
-/*     38    45 */	 XK_L,	NoSymbol,
-/*     39    46 */	 XK_semicolon,	XK_colon,
-/*     40    47 */	 XK_apostrophe,	XK_quotedbl,
-/*     41    48 */	 XK_grave,	XK_asciitilde,
-/*     42    49 */	 XK_Shift_L,	NoSymbol,
-/*     43    50 */	 XK_backslash,	XK_bar,
-/*     44    51 */	 XK_Z,	NoSymbol,
-/*     45    52 */	 XK_X,	NoSymbol,
-/*     46    53 */	 XK_C,	NoSymbol,
-/*     47    54 */	 XK_V,	NoSymbol,
-/*     48    55 */	 XK_B,	NoSymbol,
-/*     49    56 */	 XK_N,	NoSymbol,
-/*     50    57 */	 XK_M,	NoSymbol,
-/*     51    58 */	 XK_comma,	XK_less,
-/*     52    59 */	 XK_period,	XK_greater,
-/*     53    60 */	 XK_slash,	XK_question,
-/*     54    61 */	 XK_Shift_R,	NoSymbol,
-/*     55    62 */	 XK_KP_Multiply,	NoSymbol,
-/*     56    63 */	 XK_Alt_L,	XK_Meta_L,
-/*     57    64 */	 XK_space,	NoSymbol,
-/*     58    65 */	 XK_Caps_Lock,	NoSymbol,
-/*     59    66 */	 XK_F1,	NoSymbol,
-/*     60    67 */	 XK_F2,	NoSymbol,
-/*     61    68 */	 XK_F3,	NoSymbol,
-/*     62    69 */	 XK_F4,	NoSymbol,
-/*     63    70 */	 XK_F5,	NoSymbol,
-/*     64    71 */	 XK_F6,	NoSymbol,
-/*     65    72 */	 XK_F7,	NoSymbol,
-/*     66    73 */	 XK_F8,	NoSymbol,
-/*     67    74 */	 XK_F9,	NoSymbol,
-/*     68    75 */	 XK_F10,	NoSymbol,
-/*     69    76 */	 XK_Break,	XK_Pause,
-/*     70    77 */	 XK_Scroll_Lock,	NoSymbol,
-/*     71    78 */	 XK_KP_Home,	XK_KP_7,
-/*     72    79 */	 XK_KP_Up,	XK_KP_8,
-/*     73    80 */	 XK_KP_Page_Up,	XK_KP_9,
-/*     74    81 */	 XK_KP_Subtract,	NoSymbol,
-/*     75    82 */	 XK_KP_Left,	XK_KP_4,
-/*     76    83 */	 XK_KP_5,	NoSymbol,
-/*     77    84 */	 XK_KP_Right,	XK_KP_6,
-/*     78    85 */	 XK_KP_Add,	NoSymbol,
-/*     79    86 */	 XK_KP_End,	XK_KP_1,
-/*     80    87 */	 XK_KP_Down,	XK_KP_2,
-/*     81    88 */	 XK_KP_Page_Down,	XK_KP_3,
-/*     82    89 */	 XK_KP_Insert,	XK_KP_0,
-/*     83    90 */	 XK_KP_Delete,	XK_KP_Decimal,
-/*     84    91 */     NoSymbol,	NoSymbol,
-/*     85    92 */     NoSymbol,	NoSymbol,
-/*     86    93 */     NoSymbol,	NoSymbol,
-/*     87    94 */	 XK_F11,	NoSymbol,
-/*     88    95 */	 XK_F12,	NoSymbol,
-    
-/* These are remapped from the extended set (using ExtendMap) */
-    
-/*     89    96 */	 XK_Control_R,	NoSymbol,
-/*     90    97 */	 XK_KP_Enter,	NoSymbol,
-/*     91    98 */	 XK_KP_Divide,	NoSymbol,
-/*     92    99 */	 XK_Sys_Req,	XK_Print,
-/*     93   100 */	 XK_Alt_R,	XK_Meta_R,
-/*     94   101 */	 XK_Num_Lock,	NoSymbol,
-/*     95   102 */	 XK_Home,	NoSymbol,
-/*     96   103 */	 XK_Up,		NoSymbol,
-/*     97   104 */	 XK_Page_Up,	NoSymbol,
-/*     98   105 */	 XK_Left,	NoSymbol,
-/*     99   106 */	 XK_Right,	NoSymbol,
-/*    100   107 */	 XK_End,	NoSymbol,
-/*    101   108 */	 XK_Down,	NoSymbol,
-/*    102   109 */	 XK_Page_Down,	NoSymbol,
-/*    103   110 */	 XK_Insert,	NoSymbol,
-/*    104   111 */	 XK_Delete,	NoSymbol,
-/*    105   112 */	 XK_Super_L,	NoSymbol,
-/*    106   113 */	 XK_Super_R,	NoSymbol,
-/*    107   114 */	 XK_Menu,	NoSymbol,
-
-/* Itsy hardware buttons */
-#define ITSY_BUTTON_FIRST   108
-#define ITSY_BUTTON_LAST    116
-    
-/*    108   115 */	 XK_Next,	NoSymbol,   /* right button on side */
-/*    109   116 */	 XK_Prior,	NoSymbol,   /* left button on side */
-/*    110   117 */	 XK_Up,		NoSymbol,   /* joypad */
-/*    111   118 */	 XK_Down,	NoSymbol,
-/*    112   119 */	 XK_Left,	NoSymbol,
-/*    113   120 */	 XK_Right,	NoSymbol,
-/*    114   121 */	 NoSymbol,	NoSymbol,   /* left near speaker */
-/*    115   122 */	 NoSymbol,	NoSymbol,   /* right near speaker */
-/*    116   123 */	 NoSymbol,	NoSymbol,   /* tiny button */
-};
-
-static unsigned long	itsyButtonState;
-
-void
-ItsyKeyboardLoad (void)
-{
-    KeySym  *k;
-
-}
-
-static Status
-ItsyKeyboardInit (KdKeyboardInfo *ki)
-{
-    if (!ki)
-        return BadImplementation;
-
-    ki->driverPrivate = open ("/dev/buttons", 0);
-
-    itsyButtonState = 0;
-    ki->keySyms.minKeyCode = 1;
-    ki->keySyms.maxKeyCode = (sizeof (ItsyKeymap) / sizeof (ItsyKeymap[0])) / ITSY_WIDTH;
-    ki->minScanCode = ki->keySyms.minKeyCode;
-    ki->maxScanCode = ki->keySyms.maxKeyCode;
-    ki->keySyms.mapWidth = ITSY_WIDTH;
-
-    if (ki->keySyms.map)
-        xfree(ki->keySyms.map);
-    ki->keySyms.map = xalloc(sizeof(ItsyKeymap));
-    if (!ki->keySyms.map)
-        return BadAlloc;
-    memcpy (kdKeymap, ItsyKeymap, sizeof (ItsyKeymap));
-
-    return Success;
-}
-
-static void
-ItsyKeyboardDisable (KdKeybdInfo *ki)
-{
-    if (fd >= 0)
-	close ((int)ki->driverPrivate);
-}
-
-static void
-ItsyKeyboardFini (KdKeybdInfo *ki)
-{
-    return;
-}
-
-void
-ItsyKeyboardRead (int fd)
-{
-    itsy_buttons_event	event;
-    int			b;
-    unsigned long	bit;
-    unsigned long	change;
-    unsigned long	buttons;
-
-    if (read (fd, &event, sizeof (event)) == sizeof (event))
-    {
-	buttons = event.state;
-	change = buttons ^ itsyButtonState;
-	if (!change)
-	    return;
-	for (b = ITSY_BUTTON_FIRST; b <= ITSY_BUTTON_LAST; b++)
-	{
-	    bit = (1 << (b - ITSY_BUTTON_FIRST));
-	    if (change & bit)
-		KdEnqueueKeyboardEvent (b, (buttons & bit) == 0);
-	}
-	itsyButtonState = buttons;
-    }
-}
-
-void
-ItsyKeyboardLeds (int leds)
-{
-}
-
-void
-ItsyKeyboardBell (int volume, int frequency, int duration)
-{
-}
-
-KdKeyboardFuncs	itsyKeyboardFuncs = {
-    "itsy",
-    ItsyKeyboardInit,
-    ItsyKeyboardEnable,
-    ItsyKeyboardRead,
-    ItsyKeyboardLeds,
-    ItsyKeyboardBell,
-    ItsyKeyboardDisable
-    ItsyKeyboardFini,
-    NULL,
-};
diff --git a/hw/kdrive/itsy/ts.c b/hw/kdrive/itsy/ts.c
deleted file mode 100644
index 34ff6a8..0000000
--- a/hw/kdrive/itsy/ts.c
+++ /dev/null
@@ -1,210 +0,0 @@
-/*
- * Copyright © 1999 Keith Packard
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Keith Packard not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  Keith Packard makes no
- * representations about the suitability of this software for any purpose.  It
- * is provided "as is" without express or implied warranty.
- *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <kdrive-config.h>
-#endif
-#define NEED_EVENTS
-#include "itsy.h"
-#include <X11/Xproto.h>
-#include "inputstr.h"
-#include "Xpoll.h"
-
-int
-itsyTsReadBytes (int fd, char *buf, int len, int min)
-{
-    int		    n, tot;
-    fd_set	    set;
-    struct timeval  tv;
-
-    tot = 0;
-    while (len)
-    {
-	n = read (fd, buf, len);
-	if (n > 0)
-	{
-	    tot += n;
-	    buf += n;
-	    len -= n;
-	}
-	if (tot % min == 0)
-	    break;
-	FD_ZERO (&set);
-	FD_SET (fd, &set);
-	tv.tv_sec = 0;
-	tv.tv_usec = 100 * 1000;
-	n = select (fd + 1, &set, 0, 0, &tv);
-	if (n <= 0)
-	    break;
-    }
-    return tot;
-}
-
-void
-itsyTsRead (KdPointerInfo *pi, int tsPort)
-{
-    ts_event	    event;
-    long	    buf[3];
-    int		    n;
-    long	    pressure;
-    long	    x, y;
-    unsigned long   flags;
-    unsigned long   buttons;
-
-    n = itsyTsReadBytes (tsPort, (char *) &event, 
-			 sizeof (event), sizeof (event));
-    if (n == sizeof (event))
-    {
-	if (event.pressure)
-	{
-	    flags = KD_BUTTON_1;
-	    x = event.point.x;
-	    y = event.point.y;
-	}
-	else
-	{
-	    flags = KD_MOUSE_DELTA;
-	    x = 0;
-	    y = 0;
-	}
-	KdEnqueuePointerEvent (pi, flags, x, y, 0);
-    }
-}
-
-#if 0
-#define ITSY_DEBUG_LOW	1
-
-//
-// Touch screen parameters are stored
-// in the flash. This code is taken from 'wm1'.
-//
-void itsySetTouchCalibration (int mou_filedsc, 
-			      int xs, int xt, int ys, int yt, int xys)
-{
-  int k, ibuf[10];
-
-  ibuf[0] = xs;
-  ibuf[1] = xt;
-  ibuf[2] = ys;
-  ibuf[3] = yt;
-  ibuf[4] = xys;
-  if ((k=ioctl(mou_filedsc, TS_SET_CALM, ibuf)) != 0) {
-    fprintf(stderr, "ERROR: ioctl TS_SET_CALM returns %d\n", k);
-  }
-}
-
-
-int itsyReadFlashBlock(int location, signed char *data, int dbytes) 
-{
-  int offset, bytes;
-  int flashfd;
-
-  flashfd = open("/dev/flash1", O_RDONLY);
-  if (flashfd < 0) return(0);
-
-  offset = lseek(flashfd, location, SEEK_SET);
-  if (offset != location) {
-    close(flashfd);
-    return(0);
-  }
-
-  bytes = read(flashfd, data, dbytes);
-  if (bytes != dbytes) {
-    close(flashfd);
-    return(0);
-  }
-
-  close(flashfd);
-  return(1);
-}
-
-/**********************************************************************/
-#define RAMSIZE (0x400000)
-#define MONITOR_BLOCKSIZE (32)
-/**********************************************************************/
-
-/* code for storing calibration into flash */
-
-#define CALIBRATE_BLOCKSIZE (32)
-#define CALIBRATE_OFFSET (RAMSIZE-MONITOR_BLOCKSIZE-CALIBRATE_BLOCKSIZE)
-#define CALIBRATE_MAGIC_NUM (0x0babedee)
-
-
-static int check_if_calibrated_and_set(int mou_filedsc) 
-{
-  signed char cal_data[CALIBRATE_BLOCKSIZE];
-  int *iptr;
-
-  if (itsyReadFlashBlock(CALIBRATE_OFFSET,
-			 cal_data, CALIBRATE_BLOCKSIZE) == 0) {
-    if ( ITSY_DEBUG_LOW ) {
-      fprintf(stderr,"unable to read calibration data for touch screen\n");
-    }
-    return(0);
-  }
-
-  iptr = (int *) cal_data;
-  if (iptr[0] == CALIBRATE_MAGIC_NUM) {
-    if ( ITSY_DEBUG_LOW ) {
-      fprintf(stderr,"Calibrating touch screen using %d, %d, %d, %d, %d\n",
-	      iptr[1], iptr[2], iptr[3], iptr[4], iptr[5]);
-    }
-    itsySetTouchCalibration(mou_filedsc, iptr[1], iptr[2], iptr[3], iptr[4], iptr[5]);
-    return(1);
-  }
-  else {
-    if ( ITSY_DEBUG_LOW ) {
-      fprintf(stderr,"Couldn't calibrate screen\n");
-    }
-    return(0);
-  }
-}
-#endif
-
-int
-itsyTsInit (void)
-{
-    int	tsPort;
-
-    tsPort = open ("/dev/ts", 0);
-    fprintf (stderr, "tsPort %d\n", tsPort);
-#if 0
-    if (tsPort >= 0)
-	check_if_calibrated_and_set (tsPort);
-#endif
-    return tsPort;
-}
-
-void
-itsyTsFini (int tsPort)
-{
-    if (tsPort >= 0)
-	close (tsPort);
-}
-
-KdPointerDriver itsyTsMouseDriver = {
-    "itsyts",
-    itsyTsInit,
-    itsyTsRead,
-    itsyTsFini
-};
-
diff --git a/hw/kdrive/mach64/Makefile.am b/hw/kdrive/mach64/Makefile.am
deleted file mode 100644
index 6ca376a..0000000
--- a/hw/kdrive/mach64/Makefile.am
+++ /dev/null
@@ -1,43 +0,0 @@
-INCLUDES = 					\
-        @KDRIVE_INCS@				\
-	-I$(top_srcdir)/hw/kdrive/vesa		\
-	@KDRIVE_CFLAGS@
-
-bin_PROGRAMS = Xmach64
-
-if TSLIB
-TSLIB_FLAG = -lts
-endif
-
-
-noinst_LIBRARIES = libmach64.a
-
-libmach64_a_SOURCES = 	\
-	mach64.c	\
-	mach64draw.c	\
-	mach64video.c	\
-	mach64.h	\
-	mach64draw.h
-
-Xmach64_SOURCES = \
-	mach64stub.c
-
-MACH64_LIBS =						\
-	libmach64.a 					\
-	$(top_builddir)/hw/kdrive/vesa/libvesa.a        
-
-
-if GLX
-Xmach64_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
-endif
-
-Xmach64_LDADD = 					\
-	$(MACH64_LIBS)					\
-	@KDRIVE_LIBS@
-
-Xmach64_DEPENDENCIES =	\
-	libmach64.a 					\
-	@KDRIVE_LOCAL_LIBS@
-
-relink:
-	rm -f $(bin_PROGRAMS) && make $(bin_PROGRAMS)
diff --git a/hw/kdrive/mach64/mach64.c b/hw/kdrive/mach64/mach64.c
deleted file mode 100644
index 3c513ba..0000000
--- a/hw/kdrive/mach64/mach64.c
+++ /dev/null
@@ -1,433 +0,0 @@
-/*
- * Copyright © 2001 Keith Packard
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Keith Packard not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  Keith Packard makes no
- * representations about the suitability of this software for any purpose.  It
- * is provided "as is" without express or implied warranty.
- *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <kdrive-config.h>
-#endif
-#include "mach64.h"
-#include "kaa.h"
-
-static Bool
-mach64CardInit (KdCardInfo *card)
-{
-    Mach64CardInfo	*mach64c;
-
-    mach64c = (Mach64CardInfo *) xalloc (sizeof (Mach64CardInfo));
-    if (!mach64c)
-	return FALSE;
-    
-    (void) mach64MapReg (card, mach64c);
-    mach64c->lcdEnabled = FALSE;
-    
-    if (!vesaInitialize (card, &mach64c->vesa))
-    {
-	xfree (mach64c);
-	return FALSE;
-    }
-
-    card->driver = mach64c;
-    
-    return TRUE;
-}
-
-static Bool
-mach64ScreenInit (KdScreenInfo *screen)
-{
-    Mach64CardInfo	*mach64c = screen->card->driver;
-    Mach64ScreenInfo	*mach64s;
-
-    mach64s = (Mach64ScreenInfo *) xalloc (sizeof (Mach64ScreenInfo));
-    if (!mach64s)
-	return FALSE;
-    memset (mach64s, '\0', sizeof (Mach64ScreenInfo));
-    if (!vesaScreenInitialize (screen, &mach64s->vesa))
-    {
-	xfree (mach64s);
-	return FALSE;
-    }
-    if (!mach64c->reg)
-	screen->dumb = TRUE;
-    if (mach64s->vesa.mapping != VESA_LINEAR)
-	screen->dumb = TRUE;
-    switch (screen->fb[0].depth) {
-    case 8:
-	mach64s->colorKey = 0xff;
-	break;
-    case 15:
-    case 16:
-	mach64s->colorKey = 0x001e;
-	break;
-    case 24:
-	mach64s->colorKey = 0x0000fe;
-	break;
-    default:
-	mach64s->colorKey = 1;
-	break;
-    }
-    screen->driver = mach64s;
-    return TRUE;
-}
-
-static Bool
-mach64InitScreen (ScreenPtr pScreen)
-{
-#ifdef XV
-    mach64InitVideo(pScreen);
-#endif
-    return vesaInitScreen (pScreen);
-}
-
-#ifdef RANDR
-static Bool
-mach64RandRSetConfig (ScreenPtr		pScreen,
-		      Rotation		rotation,
-		      int		rate,
-		      RRScreenSizePtr	pSize)
-{
-   kaaWaitSync (pScreen);
-
-    if (!vesaRandRSetConfig (pScreen, rotation, rate, pSize))
-	return FALSE;
-    
-    return TRUE;
-}
-
-static void
-mach64RandRInit (ScreenPtr pScreen)
-{
-    rrScrPriv(pScreen);
-
-    pScrPriv->rrSetConfig = mach64RandRSetConfig;
-}
-#endif
-
-static Bool
-mach64FinishInitScreen (ScreenPtr pScreen)
-{
-    Bool    ret;
-    ret = vesaFinishInitScreen (pScreen);
-#ifdef RANDR
-    mach64RandRInit (pScreen);
-#endif
-    return ret;
-}
-
-static Bool
-mach64CreateResources (ScreenPtr pScreen)
-{
-    return vesaCreateResources (pScreen);
-}
-
-CARD32
-mach64ReadLCD (Reg *reg, int id)
-{
-    CARD32  LCD_INDEX;
-
-    LCD_INDEX = reg->LCD_INDEX & ~(0x3f);
-    reg->LCD_INDEX = (LCD_INDEX | id);
-    return reg->LCD_DATA;
-}
-
-void
-mach64WriteLCD (Reg *reg, int id, CARD32 data)
-{
-    CARD32  LCD_INDEX;
-
-    LCD_INDEX = reg->LCD_INDEX & ~(0x3f);
-    reg->LCD_INDEX = (LCD_INDEX | id);
-    reg->LCD_DATA = data;
-}
-
-void
-mach64Preserve (KdCardInfo *card)
-{
-    Mach64CardInfo	*mach64c = card->driver;
-    Reg			*reg = mach64c->reg;
-
-    vesaPreserve(card);
-    if (reg)
-    {
-	mach64c->save.LCD_GEN_CTRL = mach64ReadLCD (reg, 1);
-    }
-}
-
-Bool
-mach64MapReg (KdCardInfo *card, Mach64CardInfo *mach64c)
-{
-    mach64c->reg_base = (CARD8 *) KdMapDevice (MACH64_REG_BASE(card),
-					       MACH64_REG_SIZE(card));
-    
-    if (!mach64c->reg_base)
-    {
-	mach64c->reg = 0;
-	mach64c->media_reg = 0;
-	return FALSE;
-    }
-    
-    KdSetMappedMode (MACH64_REG_BASE(card),
-		     MACH64_REG_SIZE(card),
-		     KD_MAPPED_MODE_REGISTERS);
-    mach64c->reg = (Reg *) (mach64c->reg_base + MACH64_REG_OFF(card));
-    mach64c->media_reg = (MediaReg *) (mach64c->reg_base + MACH64_MEDIA_REG_OFF(card));
-    return TRUE;
-}
-
-void
-mach64UnmapReg (KdCardInfo *card, Mach64CardInfo *mach64c)
-{
-    if (mach64c->reg_base)
-    {
-	KdResetMappedMode (MACH64_REG_BASE(card),
-			   MACH64_REG_SIZE(card),
-			   KD_MAPPED_MODE_REGISTERS);
-	KdUnmapDevice ((void *) mach64c->reg_base, MACH64_REG_SIZE(card));
-	mach64c->reg_base = 0;
-	mach64c->reg = 0;
-	mach64c->media_reg = 0;
-    }
-}
-
-void
-mach64SetMMIO (KdCardInfo *card, Mach64CardInfo *mach64c)
-{
-    if (!mach64c->reg_base)
-	mach64MapReg (card, mach64c);
-    if (mach64c->reg)
-    {
-	if (mach64c->reg->GUI_STAT == 0xffffffff)
-	    FatalError ("Mach64 REG not visible\n");
-    }
-}
-
-void
-mach64ResetMMIO (KdCardInfo *card, Mach64CardInfo *mach64c)
-{
-    mach64UnmapReg (card, mach64c);
-}
-
-Bool
-mach64Enable (ScreenPtr pScreen)
-{
-    KdScreenPriv(pScreen);
-    Mach64CardInfo	*mach64c = pScreenPriv->card->driver;
-
-    if (!vesaEnable (pScreen))
-	return FALSE;
-    
-    mach64SetMMIO (pScreenPriv->card, mach64c);
-    mach64DPMS (pScreen, KD_DPMS_NORMAL);
-#ifdef XV
-    KdXVEnable (pScreen);
-#endif
-    return TRUE;
-}
-
-void
-mach64Disable (ScreenPtr pScreen)
-{
-    KdScreenPriv(pScreen);
-    Mach64CardInfo	*mach64c = pScreenPriv->card->driver;
-
-#ifdef XV
-    KdXVDisable (pScreen);
-#endif
-    mach64ResetMMIO (pScreenPriv->card, mach64c);
-    vesaDisable (pScreen);
-}
-
-const CARD8	mach64DPMSModes[4] = {
-    0x80,	    /* KD_DPMS_NORMAL */
-    0x8c,	    /* KD_DPMS_STANDBY */
-    0x8c,	    /* KD_DPMS_STANDBY */
-    0x8c,	    /* KD_DPMS_STANDBY */
-/*    0xb0,	       KD_DPMS_SUSPEND */
-/*    0xbc,	       KD_DPMS_POWERDOWN */
-};
-
-#define PWR_MGT_ON		    (1 << 0)
-#define PWR_MGT_MODE		    (3 << 1)
-#define  PWR_MGT_MODE_PIN	    (0 << 1)
-#define  PWR_MGT_MODE_REG	    (1 << 1)
-#define  PWR_MGT_MODE_TIMER	    (2 << 1)
-#define  PWR_MGR_MODE_PCI	    (3 << 1)
-#define AUTO_PWRUP_EN		    (1 << 3)
-#define ACTIVITY_PIN_ON		    (1 << 4)
-#define STANDBY_POL		    (1 << 5)
-#define SUSPEND_POL		    (1 << 6)
-#define SELF_REFRESH		    (1 << 7)
-#define ACTIVITY_PIN_EN		    (1 << 8)
-#define KEYBD_SNOOP		    (1 << 9)
-#define DONT_USE_F32KHZ		    (1 << 10)
-#define TRISTATE_MEM_EN		    (1 << 11)
-#define LCDENG_TEST_MODE	    (0xf << 12)
-#define STANDBY_COUNT		    (0xf << 16)
-#define SUSPEND_COUNT		    (0xf << 20)
-#define BIASON			    (1 << 24)
-#define BLON			    (1 << 25)
-#define DIGON			    (1 << 26)
-#define PM_D3_RST_ENB		    (1 << 27)
-#define STANDBY_NOW		    (1 << 28)
-#define SUSPEND_NOW		    (1 << 29)
-#define PWR_MGT_STATUS		    (3 << 30)
-#define  PWR_MGT_STATUS_ON	    (0 << 30)
-#define  PWR_MGT_STATUS_STANDBY	    (1 << 30)
-#define  PWR_MGT_STATUS_SUSPEND	    (2 << 30)
-#define  PWR_MGT_STATUS_TRANSITION  (3 << 30)
-
-Bool
-mach64DPMS (ScreenPtr pScreen, int mode)
-{
-    KdScreenPriv(pScreen);
-    Mach64CardInfo	*mach64c = pScreenPriv->card->driver;
-    int			hsync_off = 0, vsync_off = 0, blank = 0;
-    CARD32		CRTC_GEN_CNTL;
-    CARD32		LCD_GEN_CTRL;
-    Reg			*reg = mach64c->reg;
-
-    if (!reg)
-	return FALSE;
-    
-    CRTC_GEN_CNTL = reg->CRTC_GEN_CNTL;
-    LCD_GEN_CTRL = mach64ReadLCD (reg, 1);
-
-    switch (mode) {
-    case KD_DPMS_NORMAL:
-	hsync_off = 0;
-	vsync_off = 0;
-	blank = 0;
-	break;
-    case KD_DPMS_STANDBY:
-	hsync_off = 1;
-	vsync_off = 0;
-	blank = 1;
-	break;
-    case KD_DPMS_SUSPEND:
-	hsync_off = 0;
-	vsync_off = 1;
-	blank = 1;
-	break;
-    case KD_DPMS_POWERDOWN:
-	hsync_off = 1;
-	vsync_off = 1;
-	blank = 1;
-    }
-    
-    if (hsync_off)
-	CRTC_GEN_CNTL |= (1 << 2);
-    else
-	CRTC_GEN_CNTL &= ~(1 << 2);
-    if (vsync_off)
-	CRTC_GEN_CNTL |= (1 << 3);
-    else
-	CRTC_GEN_CNTL &= ~(1 << 3);
-    if (blank)
-    {
-	mach64c->lcdEnabled = (LCD_GEN_CTRL & (1 << 1)) != 0;
-	LCD_GEN_CTRL &= ~(1 << 1);
-	CRTC_GEN_CNTL |= (1 << 6);
-	
-    }
-    else
-    {
-	if (!(LCD_GEN_CTRL & 3) || mach64c->lcdEnabled)
-	    LCD_GEN_CTRL |= (1 << 1);
-	CRTC_GEN_CNTL &= ~(1 << 6);
-    }
-    
-    kaaWaitSync (pScreen);
-
-    mach64WriteLCD (reg, 1, LCD_GEN_CTRL);
-    
-    reg->CRTC_GEN_CNTL = CRTC_GEN_CNTL;
-    return TRUE;
-}
-
-static void
-mach64Restore (KdCardInfo *card)
-{
-    Mach64CardInfo	*mach64c = card->driver;
-    Reg			*reg = mach64c->reg;
-
-    if (reg)
-    {
-	mach64WriteLCD (reg, 1, mach64c->save.LCD_GEN_CTRL);
-    }
-    mach64ResetMMIO (card, mach64c);
-    vesaRestore (card);
-}
-
-static void
-mach64ScreenFini (KdScreenInfo *screen)
-{
-    Mach64ScreenInfo	*mach64s = (Mach64ScreenInfo *) screen->driver;
-#ifdef XV
-    mach64FiniVideo(screen->pScreen);
-#endif
-    vesaScreenFini (screen);
-    xfree (mach64s);
-    screen->driver = 0;
-}
-
-static void
-mach64CardFini (KdCardInfo *card)
-{
-    Mach64CardInfo	*mach64c = card->driver;
-
-    mach64UnmapReg (card, mach64c);
-    vesaCardFini (card);
-    xfree (mach64c);
-}
-
-#define mach64CursorInit 0       /* initCursor */
-#define mach64CursorEnable 0    /* enableCursor */
-#define mach64CursorDisable 0   /* disableCursor */
-#define mach64CursorFini 0       /* finiCursor */
-#define mach64RecolorCursor 0   /* recolorCursor */
-
-KdCardFuncs	mach64Funcs = {
-    mach64CardInit,	    /* cardinit */
-    mach64ScreenInit,	    /* scrinit */
-    mach64InitScreen,	    /* initScreen */
-    mach64FinishInitScreen, /* finishInitScreen */
-    mach64CreateResources,  /* createRes */
-    mach64Preserve,	    /* preserve */
-    mach64Enable,	    /* enable */
-    mach64DPMS,		    /* dpms */
-    mach64Disable,	    /* disable */
-    mach64Restore,	    /* restore */
-    mach64ScreenFini,	    /* scrfini */
-    mach64CardFini,	    /* cardfini */
-    
-    mach64CursorInit,	    /* initCursor */
-    mach64CursorEnable,	    /* enableCursor */
-    mach64CursorDisable,    /* disableCursor */
-    mach64CursorFini,	    /* finiCursor */
-    mach64RecolorCursor,    /* recolorCursor */
-    
-    mach64DrawInit,	    /* initAccel */
-    mach64DrawEnable,	    /* enableAccel */
-    mach64DrawDisable,	    /* disableAccel */
-    mach64DrawFini,	    /* finiAccel */
-    
-    vesaGetColors,    	    /* getColors */
-    vesaPutColors,	    /* putColors */
-};
diff --git a/hw/kdrive/mach64/mach64.h b/hw/kdrive/mach64/mach64.h
deleted file mode 100644
index fbb10b2..0000000
--- a/hw/kdrive/mach64/mach64.h
+++ /dev/null
@@ -1,653 +0,0 @@
-/*
- * Copyright © 2001 Keith Packard
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Keith Packard not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  Keith Packard makes no
- * representations about the suitability of this software for any purpose.  It
- * is provided "as is" without express or implied warranty.
- *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifndef _MACH64_H_
-#define _MACH64_H_
-#include <vesa.h>
-#include "kxv.h"
-
-/*
- * offset from ioport beginning 
- */
-
-#define MACH64_REG_BASE(c)	    ((c)->attr.address[1])
-#define MACH64_REG_SIZE(c)	    (4096)
-
-#define MACH64_REG_OFF(c)	    (1024)
-#define MACH64_MEDIA_REG_OFF(c)	    (0)
-
-typedef volatile CARD8	VOL8;
-typedef volatile CARD16	VOL16;
-typedef volatile CARD32	VOL32;
-
-typedef struct _Reg {
-    VOL32	CRTC_H_TOTAL_DISP;	    /* 0x00 */
-    VOL32	CRTC_H_SYNC_STRT_WID;	    /* 0x01 */
-    VOL32	CRTC_V_TOTAL_DISP;	    /* 0x02 */
-    VOL32	CRTC_V_SYNC_STRT_WID;	    /* 0x03 */
-    VOL32	CRTC_VLINE_CRNT_VLINE;	    /* 0x04 */
-    VOL32	CRTC_OFF_PITCH;		    /* 0x05 */
-    VOL32	CRTC_INT_CNTL;		    /* 0x06 */
-    VOL32	CRTC_GEN_CNTL;		    /* 0x07 */
-    VOL32	DSP_CONFIG;		    /* 0x08 */
-    VOL32	DSP_ON_OFF;		    /* 0x09 */
-    VOL32	TIMER_CONFIG;		    /* 0x0a */
-    VOL32	MEM_BUF_CNTL;		    /* 0x0b */
-    VOL32	unused0;		    /* 0x0c */
-    VOL32	MEM_ADDR_CONFIG;	    /* 0x0d */
-    VOL32	CRT_TRAP;		    /* 0x0e */
-    VOL32	I2C_CNTL_0;		    /* 0x0f */
-    VOL32	OVR_CLR;		    /* 0x10 */
-    VOL32	OVR_WID_LEFT_RIGHT;	    /* 0x11 */
-    VOL32	OVR_WID_TOP_BOTTOM;	    /* 0x12 */
-    VOL32	VGA_DSP_CONFIG;		    /* 0x13 */
-    VOL32	VGA_DSP_ON_OFF;		    /* 0x14 */
-    VOL32	DSP2_CONFIG;		    /* 0x15 */
-    VOL32	DSP2_ON_OFF;		    /* 0x16 */
-    VOL32	CRTC2_OFF_PITCH;	    /* 0x17 */
-    VOL32	CUR_CLR0;		    /* 0x18 */
-    VOL32	CUR_CLR1;		    /* 0x19 */
-    VOL32	CUR_OFFSET;		    /* 0x1a */
-    VOL32	CUR_HORZ_VERT_POSN;	    /* 0x1b */
-    VOL32	CUR_HORZ_VERT_OFF;	    /* 0x1c */
-    VOL32	TV_OUT_INDEX;		    /* 0x1d */
-    VOL32	GP_IO;			    /* 0x1e */
-    VOL32	HW_DEBUG;		    /* 0x1f */
-    VOL32	SCRATCH_REG0;		    /* 0x20 */
-    VOL32	SCRATCH_REG1;
-    VOL32	SCRATCH_REG2;
-    VOL32	SCRATCH_REG3;
-    VOL32	CLOCK_CNTL;
-    VOL32	CONFIG_STAT1;
-    VOL32	CONFIG_STAT2;
-    VOL32	TV_OUT_DATA;
-    VOL32	BUS_CNTL;		    /* 0x28 */
-    VOL32	LCD_INDEX;		    /* 0x29 */
-    VOL32	LCD_DATA;		    /* 0x2a */
-    VOL32	EXT_MEM_CNTL;
-    VOL32	MEM_CNTL;
-    VOL32	MEM_VGA_WP_SEL;
-    VOL32	MEM_VGA_RP_SEL;
-    VOL32	I2C_CNTL_1;
-    VOL32	DAC_REGS;		    /* 0x30 */
-    VOL32	DAC_CNTL;		    /* 0x31 */
-    VOL32	unused_32;
-    VOL32	unused_33;
-    VOL32	GEN_TEST_CNTL;		    /* 0x34 */
-    VOL32	CUSTOM_MACRO_CNTL;
-    VOL32	unused36;
-    VOL32	CONFIG_CNTL;
-    VOL32	CONFIG_CHIP_ID;
-    VOL32	CONFIG_STAT0;
-    VOL32	CRC_SIG;
-    VOL32	unused_3b;
-    VOL32	unused_3c;
-    VOL32	unused_3d;
-    VOL32	unused_3e;
-    VOL32	unused_3f;
-    VOL32	DST_OFF_PITCH;		    /* 0x40 */
-    VOL32	DST_X;
-    VOL32	DST_Y;
-    VOL32	DST_Y_X;
-    VOL32	DST_WIDTH;
-    VOL32	DST_HEIGHT;
-    VOL32	DST_HEIGHT_WIDTH;
-    VOL32	DST_X_WIDTH;
-    VOL32	DST_BRES_LNTH;
-    VOL32	DST_BRES_ERR;
-    VOL32	DST_BRES_INC;
-    VOL32	DST_BRES_DEC;
-    VOL32	DST_CNTL;
-    VOL32	DST_Y_X_ALIAS;
-    VOL32	TRAIL_BRES_ERR;
-    VOL32	TRAIL_BRES_INC;
-    VOL32	TRAIL_BRES_DEC;
-    VOL32	LEAD_BRES_LNTH;
-    VOL32	Z_OFF_PITCH;
-    VOL32	Z_CNTL;
-    VOL32	ALPHA_TST_CNTL;
-    VOL32	unused55;
-    VOL32	SECONDARY_STW_EXP;
-    VOL32	SECONDARY_S_X_INC;
-    VOL32	SECONDARY_S_Y_INC;
-    VOL32	SECONDARY_S_START;
-    VOL32	SECONDARY_W_X_INC;
-    VOL32	SECONDARY_W_Y_INC;
-    VOL32	SECONDARY_W_START;
-    VOL32	SECONDARY_T_X_INC;
-    VOL32	SECONDARY_T_Y_INC;
-    VOL32	SECONDARY_T_START;
-    VOL32	SRC_OFF_PITCH;
-    VOL32	SRC_X;
-    VOL32	SRC_Y;
-    VOL32	SRC_Y_X;
-    VOL32	SRC_WIDTH1;
-    VOL32	SRC_HEIGHT1;
-    VOL32	SRC_HEIGHT1_WIDTH1;
-    VOL32	SRC_X_START;
-    VOL32	SRC_Y_START;
-    VOL32	SRC_Y_X_START;
-    VOL32	SRC_WIDTH2;
-    VOL32	SRC_HEIGHT2;
-    VOL32	SRC_HEIGHT2_WIDTH2;
-    VOL32	SRC_CNTL;
-    VOL32	unused6e;
-    VOL32	unused6f;
-    union {
-	struct {
-    VOL32	SCALE_OFF;		/* 0x70 */
-    VOL32	unused71;
-    VOL32	unused72;
-    VOL32	unused73;
-    VOL32	unused74;
-    VOL32	unused75;
-    VOL32	unused76;
-    VOL32	SCALE_WIDTH;
-    VOL32	SCALE_HEIGHT;
-    VOL32	unused79;
-    VOL32	unused7a;
-    VOL32	SCALE_PITCH;
-    VOL32	SCALE_X_INC;
-    VOL32	SCALE_Y_INC;
-    VOL32	SCALE_VACC;
-    VOL32	SCALE_3D_CNTL;		/* 0x7f */
-	} scaler;
-	struct {
-    VOL32	TEX_0_OFF;		/* 0x70 */
-    VOL32	TEX_1_OFF;
-    VOL32	TEX_2_OFF;
-    VOL32	TEX_3_OFF;
-    VOL32	TEX_4_OFF;
-    VOL32	TEX_5_OFF;
-    VOL32	TEX_6_OFF;
-    VOL32	TEX_7_OFF;
-    VOL32	TEX_8_OFF;
-    VOL32	TEX_9_OFF;
-    VOL32	TEX_10_OFF;
-    VOL32	S_Y_INC;
-    VOL32	RED_X_INC;
-    VOL32	GREEN_X_INC;		/* 0x7d */
-    VOL32	unused7e;
-    VOL32	unused7f;
-	} texture;
-    } u;
-    VOL32	HOST_DATA[16];		/* 0x80 */
-    VOL32	HOST_CNTL;		/* 0x90 */
-    VOL32	BM_HOSTDATA;		/* 0x91 */
-    VOL32	BM_ADDR;		/* 0x92 */
-    VOL32	BM_GUI_TABLE_CMD;	/* 0x93 */
-    VOL32	unused94;		/* 0x94 */
-    VOL32	unused95;		/* 0x95 */
-    VOL32	unused96;		/* 0x96 */
-    VOL32	FOG_TABLE_INDEX;	/* 0x97 */
-    VOL32	FOG_TABLE_DATA[8];	/* 0x98 */
-    VOL32	PAT_REG0;		/* 0xa0 */
-    VOL32	PAT_REG1;
-    VOL32	PAT_CNTL;
-    VOL32	unused_0a3;
-    VOL32	unused_0a4;
-    VOL32	unused_0a5;
-    VOL32	unused_0a6;
-    VOL32	unused_0a7;
-    VOL32	SC_LEFT;
-    VOL32	SC_RIGHT;
-    VOL32	SC_LEFT_RIGHT;
-    VOL32	SC_TOP;
-    VOL32	SC_BOTTOM;
-    VOL32	SC_TOP_BOTTOM;
-    VOL32	USR1_DST_OFF_PITCH;
-    VOL32	USR2_DST_OFF_PITCH;
-    VOL32	DP_BKGD_CLR;		/* 0xb0 */
-    VOL32	DP_FRGD_CLR;
-    VOL32	DP_WRITE_MSK;
-    VOL32	unused_0b3;
-    VOL32	DP_PIX_WIDTH;
-    VOL32	DP_MIX;
-    VOL32	DP_SRC;
-    VOL32	DP_FRGD_CLR_MIX;
-    VOL32	DP_FRGD_BKGD_CLR;
-    VOL32	unused_0b9;
-    VOL32	DST_X_Y;
-    VOL32	DST_WIDTH_HEIGHT;
-    VOL32	USR_DST_PITCH;
-    VOL32	unused_0bd;
-    VOL32	DP_SET_GUI_ENGINE2;
-    VOL32	DP_SET_GUI_ENGINE;
-    VOL32	CLR_CMP_CLR;		/* 0xc0 */
-    VOL32	CLR_CMP_MSK;
-    VOL32	CLR_CMP_CNTL;
-    VOL32	unused_0c3;
-    VOL32	FIFO_STAT;
-    VOL32	unused_0c5;
-    VOL32	unused_0c6;
-    VOL32	unused_0c7;
-    VOL32	unused_0c8;
-    VOL32	unused_0c9;
-    VOL32	unused_0ca;
-    VOL32	unused_0cb;
-    VOL32	GUI_TRAJ_CNTL;
-    VOL32	unused_0cd;
-    VOL32	GUI_STAT;
-    VOL32	unused_0cf;
-    VOL32	TEX_PALETTE_INDEX;
-    VOL32	STW_EXP;
-    VOL32	LOG_MAX_INC;
-    VOL32	S_X_INC;
-    VOL32	S_Y_INC_2_SCALE_PITCH;
-    VOL32	S_START;
-    VOL32	W_X_INC;
-    VOL32	W_Y_INC;
-    VOL32	W_START;
-    VOL32	T_X_INC;
-    VOL32	T_Y_INC_SECONDARY_SCALE_PITCH;
-    VOL32	T_START;
-    VOL32	TEX_SIZE_PITCH;
-    VOL32	TEX_CNTL;
-    VOL32	SECONDARY_TEX_OFFSET_SECONDARY_SCALE_OFF;
-    VOL32	TEX_PALETTE;
-    VOL32	SCALE_PITCH_BOTH;	/* 0xe0 */
-    VOL32	SECONDARY_SCALE_OFF_ACC;
-    VOL32	SCALE_OFF_ACC;
-    VOL32	SCALE_DST_Y_X;
-    VOL32	unused_0e4;
-    VOL32	unused_0e5;
-    VOL32	COMPOSITE_SHADOW_ID;
-    VOL32	SECONDARY_SCALE_X_INC_SPECULAR_RED_X_INC;
-    VOL32	SPECULAR_RED_Y_INC;
-    VOL32	SPECULAR_RED_START_SECONDARY_SCALE_HACC;;
-    VOL32	SPECULAR_GREEN_X_INC;
-    VOL32	SPECULAR_GREEN_Y_INC;
-    VOL32	SPECULAR_GREEN_START;
-    VOL32	SPECULAR_BLUE_X_INC;
-    VOL32	SPECULAR_BLUE_Y_INC;
-    VOL32	SPECULAR_BLUE_START;
-    VOL32	RED_X_INC_SCALE_X_INC;
-    VOL32	RED_Y_INC;
-    VOL32	RED_START_SCALE_HACC;
-    VOL32	GREEN_X_INC_SCALE_Y_INC;
-    VOL32	GREEN_Y_INC_SECONDARY_SCALE_Y_INC;
-    VOL32	GREEN_START_SECONDARY_SCALE_VACC;
-    VOL32	BLUE_X_INC;
-    VOL32	BLUE_Y_INC;
-    VOL32	BLUE_START;
-    VOL32	Z_X_INC;
-    VOL32	Z_Y_INC;
-    VOL32	Z_START;
-    VOL32	ALPHA_X_INC;
-    VOL32	FOG_X_INC;
-    VOL32	ALPHA_Y_INC;
-    VOL32	FOG_Y_INC;
-    VOL32	ALPHA_START;
-    VOL32	FOG_START;
-    VOL32	unused_0ff;
-} Reg;					/* 0x100 */
-
-#define DST_X_DIR		(1 << 0)
-#define DST_Y_DIR		(1 << 1)
-#define DST_Y_MAJOR		(1 << 2)
-#define DST_X_TILE		(1 << 3)
-#define DST_Y_TILE		(1 << 4)
-#define DST_LAST_PEL		(1 << 5)
-#define DST_POLYGON_EN		(1 << 6)
-#define DST_24_ROT_EN		(1 << 7)
-#define DST_24_ROT(n)		((n) << 8)
-#define DST_BRES_ZERO		(1 << 11)
-#define DST_POLYGON_RTEDGE_DIS	(1 << 12)
-#define TRAIL_X_DIR		(1 << 13)
-#define TRAP_FILL_DIR		(1 << 14)
-#define TRAIL_BRES_SIGN		(1 << 15)
-#define SRC_PATT_EN		(1 << 16)
-#define SRC_PATT_ROT_EN		(1 << 17)
-#define SRC_LINEAR_EN		(1 << 18)
-#define SRC_BYTE_ALIGN		(1 << 19)
-#define SRC_LINE_X_DIR		(1 << 20)
-#define SRC_8x8x8_BRUSH		(1 << 21)
-#define FAST_FILL_EN		(1 << 22)
-#define SRC_TRACK_DST		(1 << 23)
-#define PAT_MONO_EN		(1 << 24)
-#define PAT_CLR_4x2_EN		(1 << 25)
-#define PAT_CLR_8x1_EN		(1 << 26)
-#define HOST_BYTE_ALIGN		(1 << 28)
-#define HOST_BIG_ENDIAN_EN	(1 << 29)
-
-/* BUS_CNTL bits */
-#define BUS_DBL_RESYNC		(1 << 0)
-#define BUS_MSTR_RESET		(1 << 1)
-#define BUS_FLUSH_BUF		(1 << 2)
-#define BUS_STOP_REQ_DIS	(1 << 3)
-#define BUS_APER_REG_DIS	(1 << 4)
-#define BUS_EXTRA_PIPE_DIS	(1 << 5)
-#define BUS_MASTER_DIS		(1 << 6)
-#define ROM_WRT_EN		(1 << 7)
-#define CHIP_HIDDEN_REV		(3 << 8)
-#define BUS_PCI_READ_RETRY_EN	(1 << 13)
-#define BUS_PCI_WRT_RETRY_EN	(1 << 15)
-#define BUS_RETRY_WS		(0xf << 16)
-#define BUS_MSTR_RD_MULT	(1 << 20)
-#define BUS_MSTR_RD_LINE	(1 << 21)
-#define BUS_SUSPEND		(1 << 22)
-#define LAT16X			(1 << 23)
-#define BUS_RD_DISCARD_EN	(1 << 24)
-#define BUS_RD_ABORT_EN		(1 << 25)
-#define BUS_MSTR_WS		(1 << 26)
-#define BUS_EXT_REG_EN		(1 << 27)
-#define BUS_MSTR_DISCONNECT_EN	(1 << 28)
-#define BUS_WRT_BURST		(1 << 29)
-#define BUS_READ_BURST		(1 << 30)
-#define BUS_RDY_READ_DLY	(1 << 31)
-
-#define SCALE_PIX_EXPAND    (1 << 0)
-#define SCALE_Y2R_TEMP	    (1 << 1)
-#define SCALE_HORZ_MODE	    (1 << 2)
-#define SCALE_VERT_MODE	    (1 << 3)
-#define SCALE_SIGNED_UV	    (1 << 4)
-#define SCALE_GAMMA_SEL	    (3 << 5)
-#define SCALE_GAMMA_BRIGHT  (0 << 5)
-#define SCALE_GAMMA_22	    (1 << 5)
-#define SCALE_GAMMA_18	    (2 << 5)
-#define SCALE_GAMMA_14	    (3 << 5)
-#define SCALE_DISP_SEL	    (1 << 7)
-#define SCALE_BANDWIDTH	    (1 << 26)
-#define SCALE_DIS_LIMIT	    (1 << 27)
-#define SCALE_CLK_FORCE_ON  (1 << 29)
-#define SCALE_OVERLAY_EN    (1 << 30)
-#define SCALE_EN	    (1 << 31)
-
-#define VIDEO_IN_VYUY422    (0xb)
-#define VIDEO_IN_YVYU422    (0xc)
-#define SCALER_IN_15bpp	    (0x3 << 16)
-#define SCALER_IN_16bpp	    (0x4 << 16)
-#define SCALER_IN_32bpp	    (0x6 << 16)
-#define SCALER_IN_YUV_9	    (0x9 << 16)
-#define SCALER_IN_YUV_12    (0xa << 16)
-#define SCALER_IN_VYUY422   (0xb << 16)
-#define SCALER_IN_YVYU422   (0xc << 16)
-
-#define CAP_INPUT_MODE	    (1 << 0)
-#define CAP_BUF_MODE	    (1 << 2)
-#define CAP_START_BUF	    (1 << 3)
-#define CAP_BUF_TYPE_FIELD  (0 << 4)
-#define CAP_BUF_TYPE_ALTERNATING  (1 << 4)
-#define CAP_BUF_TYPE_FRAME  (2 << 4)
-
-#define OVL_BUF_MODE	    (1 << 28)
-#define OVL_BUF_NEXT	    (1 << 29)
-
-#define CAP_TRIGGER	    (3 << 0)
-#define OVL_CUR_BUF	    (1 << 5)
-#define OVL_BUF_STATUS	    (1 << 6)
-#define CAP_BUF_STATUS	    (1 << 7)
-#define CAPTURE_EN	    (1 << 31)
-
-typedef struct _MediaReg {
-    VOL32	OVERLAY_Y_X_START;	/* 0x100 */
-    VOL32	OVERLAY_Y_X_END;
-    VOL32	OVERLAY_VIDEO_KEY_CLR;
-    VOL32	OVERLAY_VIDEO_KEY_MSK;
-    VOL32	OVERLAY_GRAPHICS_KEY_CLR;
-    VOL32	OVERLAY_GRAPHICS_KEY_MSK;
-    VOL32	OVERLAY_KEY_CNTL;
-    VOL32	unused_107;
-    VOL32	OVERLAY_SCALE_INC;
-    VOL32	OVERLAY_SCALE_CNTL;
-    VOL32	SCALER_HEIGHT_WIDTH;
-    VOL32	SCALER_TEST;
-    VOL32	unused_10c;
-    VOL32	SCALER_BUF0_OFFSET;
-    VOL32	SCALER_BUF1_OFFSET;
-    VOL32	SCALER_BUF_PITCH;
-    VOL32	CAPTURE_START_END;	/* 0x110 */
-    VOL32	CAPTURE_X_WIDTH;
-    VOL32	VIDEO_FORMAT;
-    VOL32	VBI_START_END;
-    VOL32	CAPTURE_CONFIG;
-    VOL32	TRIG_CNTL;
-    VOL32	OVERLAY_EXCLUSIVE_HORZ;
-    VOL32	OVERLAY_EXCLUSIVE_VERT;
-    VOL32	VBI_WIDTH;
-    VOL32	CAPTURE_DEBUG;
-    VOL32	VIDEO_SYNC_TEST;
-    VOL32	unused_11b;
-    VOL32	SNAPSHOT_VH_COUNTS;
-    VOL32	SNAPSHOT_F_COUNT;
-    VOL32	N_VIF_COUNT;
-    VOL32	SNAPSHOT_VIF_COUNT;
-    VOL32	CAPTURE_BUF0_OFFSET;	/* 0x120 */
-    VOL32	CAPTURE_BUF1_OFFSET;
-    VOL32	ONESHOT_BUF_OFFSET;
-    VOL32	unused_123;
-    VOL32	unused_124;
-    VOL32	unused_125;
-    VOL32	unused_126;
-    VOL32	unused_127;
-    VOL32	unused_128;
-    VOL32	unused_129;
-    VOL32	unused_12a;
-    VOL32	unused_12b;
-    VOL32	SNAPSHOT2_VH_COUNTS;
-    VOL32	SNAPSHOT2_F_COUNT;
-    VOL32	N_VIF2_COUNT;
-    VOL32	SNAPSHOT2_VIF_COUNT;
-    VOL32	MPP_CONFIG;		/* 0x130 */
-    VOL32	MPP_STROBE_SEQ;
-    VOL32	MPP_ADDR;
-    VOL32	MPP_DATA;
-    VOL32	unused_134;
-    VOL32	unused_135;
-    VOL32	unused_136;
-    VOL32	unused_137;
-    VOL32	unused_138;
-    VOL32	unused_139;
-    VOL32	unused_13a;
-    VOL32	unused_13b;
-    VOL32	unused_13c;
-    VOL32	unused_13d;
-    VOL32	unused_13e;
-    VOL32	unused_13f;
-    VOL32	TVO_CNTL;		/* 0x140 */
-    VOL32	unused_141[15];
-    VOL32	unused_150;		/* 0x150 */
-    VOL32	CRT_HORZ_VERT_LOAD;	/* 0x151 */
-    VOL32	AGP_BASE;		/* 0x152 */
-    VOL32	AGP_CNTL;		/* 0x153 */
-    VOL32	SCALER_COLOUR_CNTL;	/* 0x154 */
-    VOL32	SCALER_H_COEFF0;	/* 0x155 */
-    VOL32	SCALER_H_COEFF1;	/* 0x156 */
-    VOL32	SCALER_H_COEFF2;	/* 0x157 */
-    VOL32	SCALER_H_COEFF3;	/* 0x158 */
-    VOL32	SCALER_H_COEFF4;	/* 0x159 */
-    VOL32	unused_15a;
-    VOL32	unused_15b;
-    VOL32	GUI_CMDFIFO_DEBUG;
-    VOL32	GUI_CMDFIFO_DATA;
-    VOL32	GUI_CNTL;
-    VOL32	unused_15f;
-    VOL32	BM_FRAME_BUF_OFFSET;	/* 0x160 */
-    VOL32	BM_SYSTEM_MEM_ADDR;
-    VOL32	BM_COMMAND;
-    VOL32	BM_STATUS;
-    VOL32	unused_164[10];
-    VOL32	BM_GUI_TABLE;
-    VOL32	BM_SYSTEM_TABLE;
-    VOL32	unused_170[5];		/* 0x170 */
-    VOL32	SCALER_BUF0_OFFSET_U;
-    VOL32	SCALER_BUF0_OFFSET_V;
-    VOL32	SCALER_BUF1_OFFSET_U;
-    VOL32	SCALER_BUF1_OFFSET_V;
-    VOL32	unused_179[7];
-    VOL32	unused_180[16];		/* 0x180 */
-    VOL32	setup_engine[0x40];	/* 0x190 */
-    VOL32	dvd_subpicture[0x30];	/* 0x1d0 */
-} MediaReg;
-
-#define MACH64_XY(x,y)	    (((x) & 0x7fff) | (((y) & 0x7fff) << 16))
-#define MACH64_YX(x,y)	    (((y) & 0x7fff) | (((x) & 0x7fff) << 16))
-
-typedef struct _mach64Save {
-    CARD32	LCD_GEN_CTRL;
-} Mach64Save;
-
-typedef struct _mach64CardInfo {
-    VesaCardPrivRec	vesa;
-    CARD8		*reg_base;
-    Reg			*reg;
-    MediaReg		*media_reg;
-    Mach64Save		save;
-    Bool		lcdEnabled;
-} Mach64CardInfo;
-    
-#define getMach64CardInfo(kd)	((Mach64CardInfo *) ((kd)->card->driver))
-#define mach64CardInfo(kd)	Mach64CardInfo	*mach64c = getMach64CardInfo(kd)
-
-typedef struct _mach64Cursor {
-    int		width, height;
-    int		xhot, yhot;
-    Bool	has_cursor;
-    CursorPtr	pCursor;
-    Pixel	source, mask;
-} Mach64Cursor;
-
-#define MACH64_CURSOR_WIDTH	64
-#define MACH64_CURSOR_HEIGHT	64
-
-/*
- * Xv information, optional
- */
-typedef struct _mach64PortPriv {
-    CARD32      YBuf0Offset;
-
-    CARD32      YBuf1Offset;
-
-    CARD8	currentBuf;
-
-    int		brightness;
-    int		saturation;
-
-    RegionRec   clip;
-    CARD32      colorKey;
-
-    Bool	videoOn;
-    Time        offTime;
-    Time        freeTime;
-    CARD32	size;
-    CARD32	offset;
-    KdOffscreenArea *off_screen;
-} Mach64PortPrivRec, *Mach64PortPrivPtr;
-
-Bool mach64InitVideo(ScreenPtr pScreen);
-void mach64FiniVideo(ScreenPtr pScreen);
-
-/*
- * These values are per-format, which is essentially per-depth/per-bpp.
- * Because bpp is fixed for the screen by depth, they're computed
- * per-screen per-depth.
- */
-
-typedef struct _mach64ScreenInfo {
-    VesaScreenPrivRec		vesa;
-    Mach64Cursor		cursor;
-    CARD32			colorKey;
-    KdVideoAdaptorPtr		pAdaptor;
-    KaaScreenInfoRec		kaa;
-} Mach64ScreenInfo;
-
-#define getMach64ScreenInfo(kd) ((Mach64ScreenInfo *) ((kd)->screen->driver))
-#define mach64ScreenInfo(kd)    Mach64ScreenInfo *mach64s = getMach64ScreenInfo(kd)
-
-CARD32
-mach64ReadLCD (Reg *reg, int id);
-
-void
-mach64WriteLCD (Reg *reg, int id, CARD32 data);
-    
-void
-mach64Preserve (KdCardInfo *card);
-
-Bool
-mach64MapReg (KdCardInfo *card, Mach64CardInfo *mach64c);
-
-void
-mach64UnmapReg (KdCardInfo *card, Mach64CardInfo *mach64c);
-
-void
-mach64SetMMIO (KdCardInfo *card, Mach64CardInfo *mach64c);
-
-void
-mach64ResetMMIO (KdCardInfo *card, Mach64CardInfo *mach64c);
-
-Bool
-mach64Enable (ScreenPtr pScreen);
-
-void
-mach64Disable (ScreenPtr pScreen);
-
-Bool
-mach64DPMS (ScreenPtr pScreen, int mode);
-
-void
-mach64WaitAvail(Reg *reg, int n);
-
-void
-mach64WaitIdle (Reg *reg);
-    
-Bool
-mach64DrawSetup (ScreenPtr pScreen);
-
-Bool
-mach64DrawInit (ScreenPtr pScreen);
-
-void
-mach64DrawReinit (ScreenPtr pScreen);
-
-void
-mach64DrawEnable (ScreenPtr pScreen);
-
-void
-mach64DrawDisable (ScreenPtr pScreen);
-
-void
-mach64DrawFini (ScreenPtr pScreen);
-
-CARD8
-mach64ReadIndex (Mach64CardInfo *mach64c, CARD16 port, CARD8 index);
-
-void
-mach64WriteIndex (Mach64CardInfo *mach64c, CARD16 port, CARD8 index, CARD8 value);
-
-Bool
-mach64CursorInit (ScreenPtr pScreen);
-
-void
-mach64CursorEnable (ScreenPtr pScreen);
-
-void
-mach64CursorDisable (ScreenPtr pScreen);
-
-void
-mach64CursorFini (ScreenPtr pScreen);
-
-void
-mach64RecolorCursor (ScreenPtr pScreen, int ndef, xColorItem *pdef);
-
-extern KdCardFuncs  mach64Funcs;
-
-#endif /* _MACH64_H_ */
diff --git a/hw/kdrive/mach64/mach64curs.c b/hw/kdrive/mach64/mach64curs.c
deleted file mode 100644
index 4a59381..0000000
--- a/hw/kdrive/mach64/mach64curs.c
+++ /dev/null
@@ -1,389 +0,0 @@
-/*
- * Copyright © 1999 Keith Packard
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Keith Packard not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  Keith Packard makes no
- * representations about the suitability of this software for any purpose.  It
- * is provided "as is" without express or implied warranty.
- *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <kdrive-config.h>
-#endif
-#include "trident.h"
-#include "cursorstr.h"
-
-#define SetupCursor(s)	    KdScreenPriv(s); \
-			    tridentCardInfo(pScreenPriv); \
-			    tridentScreenInfo(pScreenPriv); \
-			    TridentCursor *pCurPriv = &tridents->cursor
-
-static void
-_tridentMoveCursor (ScreenPtr pScreen, int x, int y)
-{
-    SetupCursor(pScreen);
-    CARD8   xlow, xhigh, ylow, yhigh;
-    CARD8   xoff, yoff;
-
-    x -= pCurPriv->xhot;
-    xoff = 0;
-    if (x < 0)
-    {
-	xoff = -x;
-	x = 0;
-    }
-    y -= pCurPriv->yhot;
-    yoff = 0;
-    if (y < 0)
-    {
-	yoff = -y;
-	y = 0;
-    }
-    xlow = (CARD8) x;
-    xhigh = (CARD8) (x >> 8);
-    ylow = (CARD8) y;
-    yhigh = (CARD8) (y >> 8);
-    
-    
-    /* This is the recommended order to move the cursor */
-    
-    tridentWriteIndex (tridentc, 0x3d4, 0x41, xhigh);
-    tridentWriteIndex (tridentc, 0x3d4, 0x40, xlow);
-    tridentWriteIndex (tridentc, 0x3d4, 0x42, ylow);
-    tridentWriteIndex (tridentc, 0x3d4, 0x46, xoff);
-    tridentWriteIndex (tridentc, 0x3d4, 0x47, yoff);
-    tridentWriteIndex (tridentc, 0x3d4, 0x43, yhigh);
-}
-
-static void
-tridentMoveCursor (ScreenPtr pScreen, int x, int y)
-{
-    SetupCursor (pScreen);
-    
-    if (!pCurPriv->has_cursor)
-	return;
-    
-    if (!pScreenPriv->enabled)
-	return;
-    
-    _tridentMoveCursor (pScreen, x, y);
-}
-
-static void
-tridentAllocCursorColors (ScreenPtr pScreen)
-{
-    SetupCursor (pScreen);
-    CursorPtr	    pCursor = pCurPriv->pCursor;
-    
-    KdAllocateCursorPixels (pScreen, 0, pCursor, 
-			    &pCurPriv->source, &pCurPriv->mask);
-    switch (pScreenPriv->screen->fb[0].bitsPerPixel) {
-    case 4:
-	pCurPriv->source |= pCurPriv->source << 4;
-	pCurPriv->mask |= pCurPriv->mask << 4;
-    case 8:
-	pCurPriv->source |= pCurPriv->source << 8;
-	pCurPriv->mask |= pCurPriv->mask << 8;
-    case 16:
-	pCurPriv->source |= pCurPriv->source << 16;
-	pCurPriv->mask |= pCurPriv->mask << 16;
-    }
-}
-
-static void
-tridentSetCursorColors (ScreenPtr pScreen)
-{
-    SetupCursor (pScreen);
-    CursorPtr	pCursor = pCurPriv->pCursor;
-    CARD32	fg, bg;
-    
-    fg = pCurPriv->source;
-    bg = pCurPriv->mask;
-    tridentWriteIndex (tridentc, 0x3d4, 0x48, fg);
-    tridentWriteIndex (tridentc, 0x3d4, 0x49, fg >> 8);
-    tridentWriteIndex (tridentc, 0x3d4, 0x4a, fg >> 16);
-    
-    tridentWriteIndex (tridentc, 0x3d4, 0x4c, bg);
-    tridentWriteIndex (tridentc, 0x3d4, 0x4d, bg >> 8);
-    tridentWriteIndex (tridentc, 0x3d4, 0x4e, bg >> 16);
-}
-    
-void
-tridentRecolorCursor (ScreenPtr pScreen, int ndef, xColorItem *pdef)
-{
-    SetupCursor (pScreen);
-    CursorPtr	    pCursor = pCurPriv->pCursor;
-    xColorItem	    sourceColor, maskColor;
-
-    if (!pCurPriv->has_cursor || !pCursor)
-	return;
-    
-    if (!pScreenPriv->enabled)
-	return;
-    
-    if (pdef)
-    {
-	while (ndef)
-	{
-	    if (pdef->pixel == pCurPriv->source || 
-		pdef->pixel == pCurPriv->mask)
-		break;
-	    ndef--;
-	}
-	if (!ndef)
-	    return;
-    }
-    tridentAllocCursorColors (pScreen);
-    tridentSetCursorColors (pScreen);
-}
-    
-#define InvertBits32(v) { \
-    v = ((v & 0x55555555) << 1) | ((v >> 1) & 0x55555555); \
-    v = ((v & 0x33333333) << 2) | ((v >> 2) & 0x33333333); \
-    v = ((v & 0x0f0f0f0f) << 4) | ((v >> 4) & 0x0f0f0f0f); \
-}
-
-static void
-tridentLoadCursor (ScreenPtr pScreen, int x, int y)
-{
-    SetupCursor(pScreen);
-    CursorPtr	    pCursor = pCurPriv->pCursor;
-    CursorBitsPtr   bits = pCursor->bits;
-    int	w, h;
-    CARD32	    *ram, *msk, *mskLine, *src, *srcLine;
-    int		    i, j;
-    int		    cursor_address;
-    int		    lwsrc;
-    unsigned char   ramdac_control_;
-    CARD32	    offset;
-
-    /*
-     * Allocate new colors
-     */
-    tridentAllocCursorColors (pScreen);
-    
-    pCurPriv->pCursor = pCursor;
-    pCurPriv->xhot = pCursor->bits->xhot;
-    pCurPriv->yhot = pCursor->bits->yhot;
-    
-    /*
-     * Stick new image into cursor memory
-     */
-    ram = (CARD32 *) tridents->cursor_base;
-    mskLine = (CARD32 *) bits->mask;
-    srcLine = (CARD32 *) bits->source;
-
-    h = bits->height;
-    if (h > TRIDENT_CURSOR_HEIGHT)
-	h = TRIDENT_CURSOR_HEIGHT;
-
-    lwsrc = BitmapBytePad(bits->width) / 4;        /* words per line */
-
-    for (i = 0; i < TRIDENT_CURSOR_HEIGHT; i++) {
-	msk = mskLine;
-	src = srcLine;
-	mskLine += lwsrc;
-	srcLine += lwsrc;
-	for (j = 0; j < TRIDENT_CURSOR_WIDTH / 32; j++) {
-
-	    CARD32  m, s;
-
-#if 1
-	    if (i < h && j < lwsrc) 
-	    {
-		m = *msk++;
-		s = *src++;
-		InvertBits32(m);
-		InvertBits32(s);
-	    }
-	    else
-	    {
-		m = 0;
-		s = 0;
-	    }
-#endif
-	    *ram++ = m;
-	    *ram++ = s;
-	}
-    }
-    
-    /* Set address for cursor bits */
-    offset = tridents->cursor_base - (CARD8 *) tridents->screen;
-    offset >>= 10;
-    tridentWriteIndex (tridentc, 0x3d4, 0x44, (CARD8) (offset & 0xff));
-    tridentWriteIndex (tridentc, 0x3d4, 0x45, (CARD8) (offset >> 8));
-    
-    /* Set new color */
-    tridentSetCursorColors (pScreen);
-     
-    /* Enable the cursor */
-    tridentWriteIndex (tridentc, 0x3d4, 0x50, 0xc1);
-    
-    /* Move to new position */
-    tridentMoveCursor (pScreen, x, y);
-}
-
-static void
-tridentUnloadCursor (ScreenPtr pScreen)
-{
-    SetupCursor (pScreen);
-    
-    /* Disable cursor */
-    tridentWriteIndex (tridentc, 0x3d4, 0x50, 0);
-}
-
-static Bool
-tridentRealizeCursor (ScreenPtr pScreen, CursorPtr pCursor)
-{
-    SetupCursor(pScreen);
-
-    if (!pScreenPriv->enabled)
-	return TRUE;
-    
-    /* miRecolorCursor does this */
-    if (pCurPriv->pCursor == pCursor)
-    {
-	if (pCursor)
-	{
-	    int	    x, y;
-	    
-	    miPointerPosition (&x, &y);
-	    tridentLoadCursor (pScreen, x, y);
-	}
-    }
-    return TRUE;
-}
-
-static Bool
-tridentUnrealizeCursor (ScreenPtr pScreen, CursorPtr pCursor)
-{
-    return TRUE;
-}
-
-static void
-tridentSetCursor (ScreenPtr pScreen, CursorPtr pCursor, int x, int y)
-{
-    SetupCursor(pScreen);
-
-    pCurPriv->pCursor = pCursor;
-    
-    if (!pScreenPriv->enabled)
-	return;
-    
-    if (pCursor)
-	tridentLoadCursor (pScreen, x, y);
-    else
-	tridentUnloadCursor (pScreen);
-}
-
-miPointerSpriteFuncRec tridentPointerSpriteFuncs = {
-    tridentRealizeCursor,
-    tridentUnrealizeCursor,
-    tridentSetCursor,
-    tridentMoveCursor,
-};
-
-static void
-tridentQueryBestSize (int class, 
-		 unsigned short *pwidth, unsigned short *pheight, 
-		 ScreenPtr pScreen)
-{
-    SetupCursor (pScreen);
-
-    switch (class)
-    {
-    case CursorShape:
-	if (*pwidth > pCurPriv->width)
-	    *pwidth = pCurPriv->width;
-	if (*pheight > pCurPriv->height)
-	    *pheight = pCurPriv->height;
-	if (*pwidth > pScreen->width)
-	    *pwidth = pScreen->width;
-	if (*pheight > pScreen->height)
-	    *pheight = pScreen->height;
-	break;
-    default:
-	fbQueryBestSize (class, pwidth, pheight, pScreen);
-	break;
-    }
-}
-
-Bool
-tridentCursorInit (ScreenPtr pScreen)
-{
-    SetupCursor (pScreen);
-
-    if (!tridents->cursor_base)
-    {
-	pCurPriv->has_cursor = FALSE;
-	return FALSE;
-    }
-    
-    pCurPriv->width = TRIDENT_CURSOR_WIDTH;
-    pCurPriv->height= TRIDENT_CURSOR_HEIGHT;
-    pScreen->QueryBestSize = tridentQueryBestSize;
-    miPointerInitialize (pScreen,
-			 &tridentPointerSpriteFuncs,
-			 &kdPointerScreenFuncs,
-			 FALSE);
-    pCurPriv->has_cursor = TRUE;
-    pCurPriv->pCursor = NULL;
-    return TRUE;
-}
-
-void
-tridentCursorEnable (ScreenPtr pScreen)
-{
-    SetupCursor (pScreen);
-
-    if (pCurPriv->has_cursor)
-    {
-	if (pCurPriv->pCursor)
-	{
-	    int	    x, y;
-	    
-	    miPointerPosition (&x, &y);
-	    tridentLoadCursor (pScreen, x, y);
-	}
-	else
-	    tridentUnloadCursor (pScreen);
-    }
-}
-
-void
-tridentCursorDisable (ScreenPtr pScreen)
-{
-    SetupCursor (pScreen);
-
-    if (!pScreenPriv->enabled)
-	return;
-    
-    if (pCurPriv->has_cursor)
-    {
-	if (pCurPriv->pCursor)
-	{
-	    tridentUnloadCursor (pScreen);
-	}
-    }
-}
-
-void
-tridentCursorFini (ScreenPtr pScreen)
-{
-    SetupCursor (pScreen);
-
-    pCurPriv->pCursor = NULL;
-}
diff --git a/hw/kdrive/mach64/mach64draw.c b/hw/kdrive/mach64/mach64draw.c
deleted file mode 100644
index 15d4d41..0000000
--- a/hw/kdrive/mach64/mach64draw.c
+++ /dev/null
@@ -1,590 +0,0 @@
-/*
- * Copyright © 1999 Keith Packard
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Keith Packard not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  Keith Packard makes no
- * representations about the suitability of this software for any purpose.  It
- * is provided "as is" without express or implied warranty.
- *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <kdrive-config.h>
-#endif
-#include "mach64.h"
-#include "mach64draw.h"
-
-#include	<X11/Xmd.h>
-#include	"gcstruct.h"
-#include	"scrnintstr.h"
-#include	"pixmapstr.h"
-#include	"regionstr.h"
-#include	"mistruct.h"
-#include	"dixfontstr.h"
-#include	"fb.h"
-#include	"migc.h"
-#include	"miline.h"
-#include	"picturestr.h"
-#include	"kaa.h"
-
-CARD8 mach64Rop[16] = {
-    /* GXclear      */      0x01,         /* 0 */
-    /* GXand        */      0x0c,         /* src AND dst */
-    /* GXandReverse */      0x0d,         /* src AND NOT dst */
-    /* GXcopy       */      0x07,         /* src */
-    /* GXandInverted*/      0x0e,         /* NOT src AND dst */
-    /* GXnoop       */      0x03,         /* dst */
-    /* GXxor        */      0x05,         /* src XOR dst */
-    /* GXor         */      0x0b,         /* src OR dst */
-    /* GXnor        */      0x0f,         /* NOT src AND NOT dst */
-    /* GXequiv      */      0x06,         /* NOT src XOR dst */
-    /* GXinvert     */      0x00,         /* NOT dst */
-    /* GXorReverse  */      0x0a,         /* src OR NOT dst */
-    /* GXcopyInverted*/     0x04,         /* NOT src */
-    /* GXorInverted */      0x09,         /* NOT src OR dst */
-    /* GXnand       */      0x08,         /* NOT src OR NOT dst */
-    /* GXset        */      0x02,         /* 1 */
-};
-
-#define MACH64_DRAW_COMBO_SOLID	0x1
-#define MACH64_DRAW_COMBO_COPY	0x8
-
-#define SYNC_ALWAYS 0
-static Reg	*reg;
-static CARD32	avail;
-static CARD32	triple;
-
-#define IDX(reg,n)  (&(reg)->n - &(reg)->CRTC_H_TOTAL_DISP)
-
-void
-mach64WaitAvail(Reg *reg, int n)
-{
-    if (avail < n)
-    {
-	while ((avail = ((reg->GUI_STAT) >> 16) & 0x3ff) < n)
-	    ;
-    }
-    avail -= n;
-}
-
-void
-mach64WaitIdle (Reg *reg)
-{
-    while (reg->GUI_STAT & 1)
-	;
-}
-
-#define PIX_FORMAT_MONO	0
-#define PIX_FORMAT_PSEUDO_8	2
-#define PIX_FORMAT_TRUE_1555	3
-#define PIX_FORMAT_TRUE_565	4
-#define PIX_FORMAT_TRUE_8888    6
-#define PIX_FORMAT_TRUE_332	7
-#define PIX_FORMAT_GRAY_8	8
-#define PIX_FORMAT_YUV_422	0xb
-#define PIX_FORMAT_YUV_444	0xe
-#define PIX_FORMAT_TRUE_4444	0xf
-
-typedef struct _mach64AccelReg {
-    int		depth;
-    int		bitsPerPixel;
-    CARD32	DP_PIX_WIDTH;
-    CARD32	DP_SET_GUI_ENGINE;    
-} Mach64AccelReg;
-
-static const Mach64AccelReg	mach64AccelReg[] = {
-    { 1, 1,
-	/* DP_PIX_WIDTH */
-	((PIX_FORMAT_MONO << 0) |	/* DP_DST_PIX_WIDTH */
-	 (PIX_FORMAT_MONO << 4) |	/* COMPOSITE_PIX_WIDTH */
-	 (PIX_FORMAT_MONO << 8) |	/* DP_SRC_PIX_WIDTH */
-	 (0 << 13) |			/* DP_HOST_TRIPLE_EN */
-	 (0 << 14) |			/* DP_PALETTE_TYPE */
-	 (PIX_FORMAT_MONO << 16) |	/* DP_HOST_PIX_WIDTH */
-	 (0 << 20) |			/* DP_C14_RGB_INDEX */
-	 (0 << 24) |			/* DP_BYTE_PIX_ORDER */
-	 (0 << 25) |			/* DP_CONVERSION_TEMP */
-	 (0 << 26) |			/* DP_C14_RGB_LOW_NIBBLE */
-	 (0 << 27) |			/* DP_C14_RGB_HIGH_NIBBLE */
-	 (PIX_FORMAT_MONO << 28) |	/* DP_SCALE_PIX_WIDTH */
-	 0),
-	/* DP_SET_GUI_ENGINE */
-	((PIX_FORMAT_MONO << 3) |
-	 (1 << 6) |		/* SET_DP_SRC_PIX_WIDTH */
-	 (6 << 7) |		/* SET_DST_OFFSET */
-	 (0 << 10) |		/* SET_DST_PITCH */
-	 (0 << 14) |		/* SET_DST_PITCH_BY_2 */
-	 (0 << 15) |		/* SET_SRC_OFFPITCH_COPY */
-	 (0 << 16) |		/* SET_SRC_HGTWID1_2 */
-	 (0 << 20) |		/* SET_DRAWING_COMBO */
-	 (1 << 24) |		/* SET_BUS_MASTER_OP */
-	 (0 << 26) |		/* SET_BUS_MASTER_EN */
-	 (0 << 27) |		/* SET_BUS_MASTER_SYNC */
-	 (0 << 28) |		/* DP_HOST_TRIPLE_EN */
-	 (0 << 29) |		/* FAST_FILL_EN */
-	 (0 << 30) |		/* BLOCK_WRITE_EN */
-	 0)
-    },
-    { 8, 8,
-	/* DP_PIX_WIDTH */
-	((PIX_FORMAT_PSEUDO_8 << 0) |	/* DP_DST_PIX_WIDTH */
-	 (PIX_FORMAT_PSEUDO_8 << 4) |	/* COMPOSITE_PIX_WIDTH */
-	 (PIX_FORMAT_PSEUDO_8 << 8) |	/* DP_SRC_PIX_WIDTH */
-	 (0 << 13) |			/* DP_HOST_TRIPLE_EN */
-	 (0 << 14) |			/* DP_PALETTE_TYPE */
-	 (PIX_FORMAT_PSEUDO_8 << 16) |	/* DP_HOST_PIX_WIDTH */
-	 (0 << 20) |			/* DP_C14_RGB_INDEX */
-	 (0 << 24) |			/* DP_BYTE_PIX_ORDER */
-	 (0 << 25) |			/* DP_CONVERSION_TEMP */
-	 (0 << 26) |			/* DP_C14_RGB_LOW_NIBBLE */
-	 (0 << 27) |			/* DP_C14_RGB_HIGH_NIBBLE */
-	 (PIX_FORMAT_PSEUDO_8 << 28) |	/* DP_SCALE_PIX_WIDTH */
-	 0),
-	/* DP_SET_GUI_ENGINE */
-	((PIX_FORMAT_PSEUDO_8 << 3) |
-	 (1 << 6) |		/* SET_DP_SRC_PIX_WIDTH */
-	 (6 << 7) |		/* SET_DST_OFFSET */
-	 (0 << 10) |		/* SET_DST_PITCH */
-	 (0 << 14) |		/* SET_DST_PITCH_BY_2 */
-	 (0 << 15) |		/* SET_SRC_OFFPITCH_COPY */
-	 (0 << 16) |		/* SET_SRC_HGTWID1_2 */
-	 (0 << 20) |		/* SET_DRAWING_COMBO */
-	 (1 << 24) |		/* SET_BUS_MASTER_OP */
-	 (0 << 26) |		/* SET_BUS_MASTER_EN */
-	 (0 << 27) |		/* SET_BUS_MASTER_SYNC */
-	 (0 << 28) |		/* DP_HOST_TRIPLE_EN */
-	 (0 << 29) |		/* FAST_FILL_EN */
-	 (0 << 30) |		/* BLOCK_WRITE_EN */
-	 0)
-    },
-    { 15, 16,
-	/* DP_PIX_WIDTH */
-	((PIX_FORMAT_TRUE_1555 << 0) |	/* DP_DST_PIX_WIDTH */
-	 (PIX_FORMAT_TRUE_1555 << 4) |	/* COMPOSITE_PIX_WIDTH */
-	 (PIX_FORMAT_TRUE_1555 << 8) |	/* DP_SRC_PIX_WIDTH */
-	 (0 << 13) |			/* DP_HOST_TRIPLE_EN */
-	 (0 << 14) |			/* DP_PALETTE_TYPE */
-	 (PIX_FORMAT_TRUE_1555 << 16) |	/* DP_HOST_PIX_WIDTH */
-	 (0 << 20) |			/* DP_C14_RGB_INDEX */
-	 (0 << 24) |			/* DP_BYTE_PIX_ORDER */
-	 (0 << 25) |			/* DP_CONVERSION_TEMP */
-	 (0 << 26) |			/* DP_C14_RGB_LOW_NIBBLE */
-	 (0 << 27) |			/* DP_C14_RGB_HIGH_NIBBLE */
-	 (PIX_FORMAT_TRUE_1555 << 28) |	/* DP_SCALE_PIX_WIDTH */
-	 0),
-	/* DP_SET_GUI_ENGINE */
-	((PIX_FORMAT_TRUE_1555 << 3) |
-	 (1 << 6) |		/* SET_DP_SRC_PIX_WIDTH */
-	 (6 << 7) |		/* SET_DST_OFFSET */
-	 (0 << 10) |		/* SET_DST_PITCH */
-	 (0 << 14) |		/* SET_DST_PITCH_BY_2 */
-	 (0 << 15) |		/* SET_SRC_OFFPITCH_COPY */
-	 (0 << 16) |		/* SET_SRC_HGTWID1_2 */
-	 (0 << 20) |		/* SET_DRAWING_COMBO */
-	 (1 << 24) |		/* SET_BUS_MASTER_OP */
-	 (0 << 26) |		/* SET_BUS_MASTER_EN */
-	 (0 << 27) |		/* SET_BUS_MASTER_SYNC */
-	 (0 << 28) |		/* DP_HOST_TRIPLE_EN */
-	 (0 << 29) |		/* FAST_FILL_EN */
-	 (0 << 30) |		/* BLOCK_WRITE_EN */
-	 0)
-    },
-    { 16, 16,
-	/* DP_PIX_WIDTH */
-	((PIX_FORMAT_TRUE_565 << 0) |	/* DP_DST_PIX_WIDTH */
-	 (PIX_FORMAT_TRUE_565 << 4) |	/* COMPOSITE_PIX_WIDTH */
-	 (PIX_FORMAT_TRUE_565 << 8) |	/* DP_SRC_PIX_WIDTH */
-	 (0 << 13) |			/* DP_HOST_TRIPLE_EN */
-	 (0 << 14) |			/* DP_PALETTE_TYPE */
-	 (PIX_FORMAT_TRUE_565 << 16) |	/* DP_HOST_PIX_WIDTH */
-	 (0 << 20) |			/* DP_C14_RGB_INDEX */
-	 (0 << 24) |			/* DP_BYTE_PIX_ORDER */
-	 (0 << 25) |			/* DP_CONVERSION_TEMP */
-	 (0 << 26) |			/* DP_C14_RGB_LOW_NIBBLE */
-	 (0 << 27) |			/* DP_C14_RGB_HIGH_NIBBLE */
-	 (PIX_FORMAT_TRUE_565 << 28) |	/* DP_SCALE_PIX_WIDTH */
-	 0),
-	/* DP_SET_GUI_ENGINE */
-	((PIX_FORMAT_TRUE_565 << 3) |
-	 (1 << 6) |		/* SET_DP_SRC_PIX_WIDTH */
-	 (6 << 7) |		/* SET_DST_OFFSET */
-	 (0 << 10) |		/* SET_DST_PITCH */
-	 (0 << 14) |		/* SET_DST_PITCH_BY_2 */
-	 (0 << 15) |		/* SET_SRC_OFFPITCH_COPY */
-	 (0 << 16) |		/* SET_SRC_HGTWID1_2 */
-	 (0 << 20) |		/* SET_DRAWING_COMBO */
-	 (1 << 24) |		/* SET_BUS_MASTER_OP */
-	 (0 << 26) |		/* SET_BUS_MASTER_EN */
-	 (0 << 27) |		/* SET_BUS_MASTER_SYNC */
-	 (0 << 28) |		/* DP_HOST_TRIPLE_EN */
-	 (0 << 29) |		/* FAST_FILL_EN */
-	 (0 << 30) |		/* BLOCK_WRITE_EN */
-	 0)
-    },
-    { 24, 24,
-	/* DP_PIX_WIDTH */
-	((PIX_FORMAT_PSEUDO_8 << 0) |    /* DP_DST_PIX_WIDTH */
-	 (PIX_FORMAT_PSEUDO_8 << 4) |    /* COMPOSITE_PIX_WIDTH */
-	 (PIX_FORMAT_PSEUDO_8 << 8) |    /* DP_SRC_PIX_WIDTH */
-	 (0 << 13) |			    /* DP_HOST_TRIPLE_EN */
-	 (0 << 14) |			    /* DP_PALETTE_TYPE */
-	 (PIX_FORMAT_PSEUDO_8 << 16) |   /* DP_HOST_PIX_WIDTH */
-	 (0 << 20) |			    /* DP_C14_RGB_INDEX */
-	 (0 << 24) |			    /* DP_BYTE_PIX_ORDER */
-	 (0 << 25) |			    /* DP_CONVERSION_TEMP */
-	 (0 << 26) |			    /* DP_C14_RGB_LOW_NIBBLE */
-	 (0 << 27) |			    /* DP_C14_RGB_HIGH_NIBBLE */
-	 (PIX_FORMAT_PSEUDO_8 << 28) |  /* DP_SCALE_PIX_WIDTH */
-	 0),
-	/* DP_SET_GUI_ENGINE */
-	((PIX_FORMAT_PSEUDO_8 << 3) |
-	 (1 << 6) |		/* SET_DP_SRC_PIX_WIDTH */
-	 (6 << 7) |		/* SET_DST_OFFSET */
-	 (0 << 10) |		/* SET_DST_PITCH */
-	 (0 << 14) |		/* SET_DST_PITCH_BY_2 */
-	 (0 << 15) |		/* SET_SRC_OFFPITCH_COPY */
-	 (0 << 16) |		/* SET_SRC_HGTWID1_2 */
-	 (0 << 20) |		/* SET_DRAWING_COMBO */
-	 (1 << 24) |		/* SET_BUS_MASTER_OP */
-	 (0 << 26) |		/* SET_BUS_MASTER_EN */
-	 (0 << 27) |		/* SET_BUS_MASTER_SYNC */
-	 (0 << 28) |		/* DP_HOST_TRIPLE_EN */
-	 (0 << 29) |		/* FAST_FILL_EN */
-	 (0 << 30) |		/* BLOCK_WRITE_EN */
-	 0)
-    },
-    { 24, 32,
-	/* DP_PIX_WIDTH */
-	((PIX_FORMAT_TRUE_8888 << 0) |   /* DP_DST_PIX_WIDTH */
-	 (PIX_FORMAT_TRUE_8888 << 4) |   /* COMPOSITE_PIX_WIDTH */
-	 (PIX_FORMAT_TRUE_8888 << 8) |   /* DP_SRC_PIX_WIDTH */
-	 (0 << 13) |			    /* DP_HOST_TRIPLE_EN */
-	 (0 << 14) |			    /* DP_PALETTE_TYPE */
-	 (PIX_FORMAT_TRUE_8888 << 16) |  /* DP_HOST_PIX_WIDTH */
-	 (0 << 20) |			    /* DP_C14_RGB_INDEX */
-	 (0 << 24) |			    /* DP_BYTE_PIX_ORDER */
-	 (0 << 25) |			    /* DP_CONVERSION_TEMP */
-	 (0 << 26) |			    /* DP_C14_RGB_LOW_NIBBLE */
-	 (0 << 27) |			    /* DP_C14_RGB_HIGH_NIBBLE */
-	 (PIX_FORMAT_TRUE_8888 << 28) |  /* DP_SCALE_PIX_WIDTH */
-	 0),
-	/* DP_SET_GUI_ENGINE */
-	((PIX_FORMAT_TRUE_8888 << 3) |
-	 (1 << 6) |		/* SET_DP_SRC_PIX_WIDTH */
-	 (6 << 7) |		/* SET_DST_OFFSET */
-	 (0 << 10) |		/* SET_DST_PITCH */
-	 (0 << 14) |		/* SET_DST_PITCH_BY_2 */
-	 (0 << 15) |		/* SET_SRC_OFFPITCH_COPY */
-	 (0 << 16) |		/* SET_SRC_HGTWID1_2 */
-	 (0 << 20) |		/* SET_DRAWING_COMBO */
-	 (1 << 24) |		/* SET_BUS_MASTER_OP */
-	 (0 << 26) |		/* SET_BUS_MASTER_EN */
-	 (0 << 27) |		/* SET_BUS_MASTER_SYNC */
-	 (0 << 28) |		/* DP_HOST_TRIPLE_EN */
-	 (0 << 29) |		/* FAST_FILL_EN */
-	 (0 << 30) |		/* BLOCK_WRITE_EN */
-	 0)
-    },
-    { 32, 32,
-	/* DP_PIX_WIDTH */
-	((PIX_FORMAT_TRUE_8888 << 0) |   /* DP_DST_PIX_WIDTH */
-	 (PIX_FORMAT_TRUE_8888 << 4) |   /* COMPOSITE_PIX_WIDTH */
-	 (PIX_FORMAT_TRUE_8888 << 8) |   /* DP_SRC_PIX_WIDTH */
-	 (0 << 13) |			    /* DP_HOST_TRIPLE_EN */
-	 (0 << 14) |			    /* DP_PALETTE_TYPE */
-	 (PIX_FORMAT_TRUE_8888 << 16) |  /* DP_HOST_PIX_WIDTH */
-	 (0 << 20) |			    /* DP_C14_RGB_INDEX */
-	 (0 << 24) |			    /* DP_BYTE_PIX_ORDER */
-	 (0 << 25) |			    /* DP_CONVERSION_TEMP */
-	 (0 << 26) |			    /* DP_C14_RGB_LOW_NIBBLE */
-	 (0 << 27) |			    /* DP_C14_RGB_HIGH_NIBBLE */
-	 (PIX_FORMAT_TRUE_8888 << 28) |  /* DP_SCALE_PIX_WIDTH */
-	 0),
-	/* DP_SET_GUI_ENGINE */
-	((PIX_FORMAT_TRUE_8888 << 3) |
-	 (1 << 6) |		/* SET_DP_SRC_PIX_WIDTH */
-	 (6 << 7) |		/* SET_DST_OFFSET */
-	 (0 << 10) |		/* SET_DST_PITCH */
-	 (0 << 14) |		/* SET_DST_PITCH_BY_2 */
-	 (0 << 15) |		/* SET_SRC_OFFPITCH_COPY */
-	 (0 << 16) |		/* SET_SRC_HGTWID1_2 */
-	 (0 << 20) |		/* SET_DRAWING_COMBO */
-	 (1 << 24) |		/* SET_BUS_MASTER_OP */
-	 (0 << 26) |		/* SET_BUS_MASTER_EN */
-	 (0 << 27) |		/* SET_BUS_MASTER_SYNC */
-	 (0 << 28) |		/* DP_HOST_TRIPLE_EN */
-	 (0 << 29) |		/* FAST_FILL_EN */
-	 (0 << 30) |		/* BLOCK_WRITE_EN */
-	 0)
-    }
-};
-
-#define NACCELREG (sizeof mach64AccelReg / sizeof mach64AccelReg[0])
-
-static void
-mach64WaitMarker (ScreenPtr pScreen, int marker)
-{
-    KdScreenPriv(pScreen);
-    mach64CardInfo(pScreenPriv);
-    reg = mach64c->reg;
-    
-    mach64WaitIdle (reg);
-}
-
-static Bool
-mach64Setup (PixmapPtr pDst, PixmapPtr pSrc, CARD32 combo, int wait)
-{
-    ScreenPtr pScreen = pDst->drawable.pScreen;
-    KdScreenPriv(pScreen);
-    mach64CardInfo(pScreenPriv);
-    CARD32  DST_PITCH;
-    CARD32  DST_OFFSET;
-    CARD32  SRC_PITCH;
-    CARD32  SRC_OFFSET;
-    CARD32  DP_PIX_WIDTH;
-    CARD32  DP_SET_GUI_ENGINE;
-    int	    i;
-
-    for (i = 0; i < NACCELREG; i++)
-	if (mach64AccelReg[i].depth == pDst->drawable.depth &&
-	    mach64AccelReg[i].bitsPerPixel == pDst->drawable.bitsPerPixel)
-	    break;
-    if (i == NACCELREG)
-	return FALSE;
-    DP_PIX_WIDTH = mach64AccelReg[i].DP_PIX_WIDTH;
-    DP_SET_GUI_ENGINE = mach64AccelReg[i].DP_SET_GUI_ENGINE;
-
-    reg = mach64c->reg;
-    if (!reg)
-	return FALSE;
-    
-    triple = (pDst->drawable.bitsPerPixel == 24);
-    
-    if (triple)
-    {
-	/* bytes / 8 = bytes >> 3 */
-	DST_PITCH = pDst->devKind >> 3;
-    }
-    else
-    {
-	/* pixels / 8 = ((bytes * 8) / bpp) / 8 = bytes / bpp */
-	DST_PITCH = pDst->devKind / pDst->drawable.bitsPerPixel;
-    }
-    
-    /* bytes / 8 */
-    DST_OFFSET = ((CARD8 *) pDst->devPrivate.ptr - pScreenPriv->screen->memory_base) >> 3;
-    
-    mach64WaitAvail(reg, wait + (pSrc ? 5 : 4));
-    reg->DP_SET_GUI_ENGINE = DP_SET_GUI_ENGINE | (combo << 20);
-    reg->DP_PIX_WIDTH = DP_PIX_WIDTH;
-    reg->DST_OFF_PITCH = ((DST_OFFSET << 0) |	/* USR1_DST_OFFSET */
-			  (DST_PITCH << 22) |	/* USR1_DST_PITCH */
-			  0);
-    if (pSrc)
-    {
-	if (triple)
-	{
-	    SRC_PITCH = pSrc->devKind >> 3;
-	}
-        else
-	{
-	    /* pixels / 8 = ((bytes * 8) / bpp) / 8 = bytes / bpp */
-	    SRC_PITCH = pSrc->devKind / pSrc->drawable.bitsPerPixel;
-	}
-	/* bytes / 8 */
-	SRC_OFFSET = ((CARD8 *) pSrc->devPrivate.ptr - pScreenPriv->screen->memory_base) >> 3;
-	
-	reg->SRC_OFF_PITCH = ((SRC_OFFSET << 0) |
-			      (SRC_PITCH << 22) |
-			      0);
-    }
-    return TRUE;
-}
-
-static Bool
-mach64PrepareSolid (PixmapPtr   pPixmap,
-		    int		alu,
-		    Pixel	pm,
-		    Pixel	fg)
-{
-    if (!mach64Setup (pPixmap, 0, 1, 3))
-	return FALSE;
-    reg->DP_MIX = (mach64Rop[alu] << 16) | 0;
-    reg->DP_WRITE_MSK = pm;
-    reg->DP_FRGD_CLR = fg;
-    return TRUE;
-}
-
-static void
-mach64Solid (int x1, int y1, int x2, int y2)
-{
-    if (triple)
-    {
-	CARD32	traj;
-
-	x1 *= 3;
-	x2 *= 3;
-
-	traj = (DST_X_DIR | 
-		DST_Y_DIR |
-		DST_24_ROT_EN | 
-		DST_24_ROT((x1 / 4) % 6));
-	mach64WaitAvail (reg, 1);
-	reg->GUI_TRAJ_CNTL = traj;
-    }
-    mach64WaitAvail(reg,2);
-    reg->DST_X_Y = MACH64_XY(x1,y1);
-    reg->DST_WIDTH_HEIGHT = MACH64_XY(x2-x1,y2-y1);
-}
-
-static void
-mach64DoneSolid (void)
-{
-#if SYNC_ALWAYS
-    mach64WaitIdle (reg);
-#endif
-}
-
-static int copyDx;
-static int copyDy;
-static CARD32	copyCombo;
-
-static Bool
-mach64PrepareCopy (PixmapPtr	pSrcPixmap,
-		   PixmapPtr	pDstPixmap,
-		   int		dx,
-		   int		dy,
-		   int		alu,
-		   Pixel	pm)
-{
-    copyCombo = 8 | 2 | 1;
-    copyDx = dx;
-    copyDy = dy;
-    
-    /*
-     * Avoid going backwards when copying pixmaps to the screen.
-     * This should reduce tearing somewhat
-     */
-    if (pSrcPixmap == pDstPixmap)
-    {
-        if (dx <= 0)
-	    copyCombo &= ~1;
-	if (dy <= 0)
-	    copyCombo &= ~2;
-    }
-
-    if (!mach64Setup (pDstPixmap, pSrcPixmap, copyCombo, 2))
-	return FALSE;
-    
-    reg->DP_MIX = (mach64Rop[alu] << 16) | 0;
-    reg->DP_WRITE_MSK = pm;
-    return TRUE;
-}
-
-static void
-mach64Copy (int srcX,
-	    int srcY,
-	    int dstX,
-	    int dstY,
-	    int w,
-	    int h)
-{
-    if (triple)
-    {
-	CARD32	traj;
-
-	srcX *= 3;
-	dstX *= 3;
-	w *= 3;
-
-	traj = DST_24_ROT_EN | DST_24_ROT((dstX / 4) % 6);
-	
-	if (copyCombo & 1)
-	    traj |= 1;
-	if (copyCombo & 2)
-	    traj |= 2;
-	
-	mach64WaitAvail (reg, 1);
-	reg->GUI_TRAJ_CNTL = traj;
-    }
-    if ((copyCombo & 1) == 0)
-    {
-	srcX += w - 1;
-	dstX += w - 1;
-    }
-    if ((copyCombo & 2) == 0)
-    {
-	srcY += h - 1;
-	dstY += h - 1;
-    }
-    mach64WaitAvail (reg, 4);
-    reg->SRC_Y_X = MACH64_YX(srcX, srcY);
-    reg->SRC_WIDTH1 = w;
-    reg->DST_Y_X = MACH64_YX(dstX, dstY);
-    reg->DST_HEIGHT_WIDTH = MACH64_YX(w,h);
-}
-
-static void
-mach64DoneCopy (void)
-{
-#if SYNC_ALWAYS
-    mach64WaitIdle (reg);
-#endif
-}
-
-
-Bool
-mach64DrawInit (ScreenPtr pScreen)
-{
-    KdScreenPriv(pScreen);
-    mach64ScreenInfo(pScreenPriv);
-
-    memset(&mach64s->kaa, 0, sizeof(KaaScreenInfoRec));
-    mach64s->kaa.waitMarker	= mach64WaitMarker;
-    mach64s->kaa.PrepareSolid	= mach64PrepareSolid;
-    mach64s->kaa.Solid		= mach64Solid;
-    mach64s->kaa.DoneSolid	= mach64DoneSolid;
-    mach64s->kaa.PrepareCopy	= mach64PrepareCopy;
-    mach64s->kaa.Copy		= mach64Copy;
-    mach64s->kaa.DoneCopy	= mach64DoneCopy;
-    mach64s->kaa.offsetAlign	= 64;
-    mach64s->kaa.pitchAlign	= 64;
-    mach64s->kaa.flags		= KAA_OFFSCREEN_PIXMAPS;
-
-    if (pScreenPriv->screen->fb[0].depth == 4)
-	return FALSE;
-    
-    if (!kaaDrawInit (pScreen, &mach64s->kaa))
-	return FALSE;
-
-    return TRUE;
-}
-
-void
-mach64DrawEnable (ScreenPtr pScreen)
-{
-    kaaMarkSync (pScreen);
-}
-
-void
-mach64DrawDisable (ScreenPtr pScreen)
-{
-}
-
-void
-mach64DrawFini (ScreenPtr pScreen)
-{
-    kaaDrawFini (pScreen);
-}
diff --git a/hw/kdrive/mach64/mach64draw.h b/hw/kdrive/mach64/mach64draw.h
deleted file mode 100644
index bac11c2..0000000
--- a/hw/kdrive/mach64/mach64draw.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright © 1999 Keith Packard
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Keith Packard not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  Keith Packard makes no
- * representations about the suitability of this software for any purpose.  It
- * is provided "as is" without express or implied warranty.
- *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifndef _TRIDENTDRAW_H_
-#define _TRIDENTDRAW_H_
-
-#define SetupTrident(s) KdScreenPriv(s); \
-		    tridentCardInfo(pScreenPriv); \
-		    Cop	    *cop = tridentc->cop
-
-#define TridentAlpha	(COP_MULTI_ALPHA|COP_ALPHA_WRITE_ENABLE)
-
-#define _tridentInit(cop,tridentc) { \
-    if ((cop)->status == 0xffffffff) tridentSetMMIO(tridentc); \
-    (cop)->multi = (tridentc)->cop_depth; \
-    (cop)->multi = (tridentc)->cop_stride; \
-    (cop)->multi = TridentAlpha; \
-} \
-
-#define _tridentSetSolidRect(cop,pix,alu,cmd) {\
-    cop->multi = COP_MULTI_PATTERN; \
-    cop->multi = COP_MULTI_ROP | tridentRop[alu]; \
-    cop->fg = (pix); \
-    cmd = COP_OP_BLT | COP_SCL_OPAQUE | COP_OP_ROP | COP_OP_FG; \
-}
-
-#define _tridentRect(cop,x1,y1,x2,y2,cmd) { \
-    (cop)->dst_start_xy = TRI_XY (x1,y1); \
-    (cop)->dst_end_xy = TRI_XY(x2,y2); \
-    _tridentWaitDone(cop); \
-    (cop)->command = (cmd); \
-}
-
-#define COP_STATUS_BUSY	(COP_STATUS_BE_BUSY | \
-			 COP_STATUS_DPE_BUSY | \
-			 COP_STATUS_MI_BUSY)
-
-#define _tridentWaitDone(cop)   { \
-    int __q__ = 500000; \
-    while (__q__-- && (cop)->status & COP_STATUS_BUSY) \
-	; \
-    if (!__q__) \
-	(cop)->status = 0;  \
-}
-
-#define _tridentWaitIdleEmpty(cop)	_tridentWaitDone(cop)
-
-#define sourceInvarient(alu)	(((alu) & 3) == (((alu) >> 2) & 3))
-
-#endif
diff --git a/hw/kdrive/mach64/mach64stub.c b/hw/kdrive/mach64/mach64stub.c
deleted file mode 100644
index 5895a3c..0000000
--- a/hw/kdrive/mach64/mach64stub.c
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright 1999 SuSE, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of SuSE not be used in advertising or
- * publicity pertaining to distribution of the software without specific,
- * written prior permission.  SuSE makes no representations about the
- * suitability of this software for any purpose.  It is provided "as is"
- * without express or implied warranty.
- *
- * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
- * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
- * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
- * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * Author:  Keith Packard, SuSE, Inc.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <kdrive-config.h>
-#endif
-#include "mach64.h"
-#include <klinux.h>
-
-void
-InitCard (char *name)
-{
-    KdCardAttr	attr;
-
-    if (LinuxFindPci (0x1002, 0x4750, 0, &attr))
-	KdCardInfoAdd (&mach64Funcs, &attr, 0);
-    else if (LinuxFindPci (0x1002, 0x4c42, 0, &attr))
-	KdCardInfoAdd (&mach64Funcs, &attr, 0);
-    else if (LinuxFindPci (0x1002, 0x4c46, 0, &attr))
-	KdCardInfoAdd (&mach64Funcs, &attr, 0);
-    else if (LinuxFindPci (0x1002, 0x4c49, 0, &attr))
-	KdCardInfoAdd (&mach64Funcs, &attr, 0);
-    else if (LinuxFindPci (0x1002, 0x4c4d, 0, &attr))
-	KdCardInfoAdd (&mach64Funcs, &attr, 0);
-}
-
-void
-InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv)
-{
-    KdInitOutput (pScreenInfo, argc, argv);
-}
-
-void
-InitInput (int argc, char **argv)
-{
-    KdOsAddInputDrivers ();
-    KdInitInput ();
-}
-
-void
-ddxUseMsg (void)
-{
-    KdUseMsg();
-    vesaUseMsg();
-}
-
-int
-ddxProcessArgument (int argc, char **argv, int i)
-{
-    int	ret;
-    
-    if (!(ret = vesaProcessArgument (argc, argv, i)))
-	ret = KdProcessArgument(argc, argv, i);
-    return ret;
-}
diff --git a/hw/kdrive/mach64/mach64video.c b/hw/kdrive/mach64/mach64video.c
deleted file mode 100644
index 38fcef7..0000000
--- a/hw/kdrive/mach64/mach64video.c
+++ /dev/null
@@ -1,994 +0,0 @@
-/*
- * Copyright © 2001 Keith Packard
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Keith Packard not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  Keith Packard makes no
- * representations about the suitability of this software for any purpose.  It
- * is provided "as is" without express or implied warranty.
- *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-#ifdef HAVE_CONFIG_H
-#include <kdrive-config.h>
-#endif
-#include "mach64.h"
-
-#include <X11/extensions/Xv.h>
-#include "fourcc.h"
-
-#define MAKE_ATOM(a) MakeAtom(a, sizeof(a) - 1, TRUE)
-
-static Atom xvBrightness, xvSaturation, xvColorKey;
-
-#define IMAGE_MAX_WIDTH		720
-#define IMAGE_MAX_HEIGHT	576
-
-static void
-mach64StopVideo(KdScreenInfo *screen, pointer data, Bool exit)
-{
-    ScreenPtr		pScreen = screen->pScreen;
-    KdScreenPriv(pScreen);
-    KdCardInfo		*card = pScreenPriv->card;
-    Mach64ScreenInfo	*mach64s = (Mach64ScreenInfo *) screen->driver;
-    Mach64CardInfo	*mach64c = (Mach64CardInfo *) card->driver;
-    Mach64PortPrivPtr	pPortPriv = mach64s->pAdaptor->pPortPrivates[0].ptr;
-    Reg			*reg = mach64c->reg;
-    MediaReg		*media = mach64c->media_reg;
-
-    REGION_EMPTY(screen->pScreen, &pPortPriv->clip);   
-
-    if (!media)
-	return;
-
-    if(pPortPriv->videoOn)
-    {
-	mach64WaitIdle (reg);
-	/* wait for buffer to be displayed */
-	while (((media->TRIG_CNTL >> 5) & 1) != pPortPriv->currentBuf)
-	    ;
-	/* wait for buffer to be finished */
-	while (((media->TRIG_CNTL >> 6) & 1) != 0)
-	    ;
-	mach64WaitAvail (reg, 1);
-	media->OVERLAY_SCALE_CNTL = 0;
-	pPortPriv->videoOn = FALSE;
-	mach64WaitIdle (reg);
-    }
-    if (pPortPriv->off_screen)
-    {
-	KdOffscreenFree (pScreen, pPortPriv->off_screen);
-	pPortPriv->off_screen = 0;
-    }
-}
-
-static int
-mach64SetPortAttribute(KdScreenInfo *screen,
-		       Atom	    attribute,
-		       int	    value,
-		       pointer	    data)
-{
-    Mach64ScreenInfo	*mach64s = (Mach64ScreenInfo *) screen->driver;
-    Mach64PortPrivPtr	pPortPriv = mach64s->pAdaptor->pPortPrivates[0].ptr;
-
-    if(attribute == xvBrightness) 
-    {
-	if(value < -1000)
-	    value = -1000;
-	if (value > 1000)
-	    value = 1000;
-	pPortPriv->brightness = value;
-    }
-    else if(attribute == xvSaturation) 
-    {
-	if (value < -1000)
-	    value = -1000;
-	if (value > 1000)
-	    value = 1000;
-	pPortPriv->saturation = value;
-    }
-    else if(attribute == xvColorKey) 
-    {
-	if (pPortPriv->colorKey != value)
-	{
-	    pPortPriv->colorKey = value;
-	    REGION_EMPTY(screen->pScreen, &pPortPriv->clip);   
-	}
-    }
-    else 
-	return BadMatch;
-
-    return Success;
-}
-
-static int
-mach64GetPortAttribute(KdScreenInfo *screen, 
-		       Atom	    attribute,
-		       int	    *value,
-		       pointer	    data)
-{
-    Mach64PortPrivPtr pPortPriv = (Mach64PortPrivPtr)data;
-
-    if(attribute == xvBrightness) 
-	*value = pPortPriv->brightness;
-    else if(attribute == xvSaturation)
-	*value = pPortPriv->saturation;
-    else if(attribute == xvColorKey)
-	*value = pPortPriv->colorKey;
-    else
-	return BadMatch;
-
-    return Success;
-}
-
-static void
-mach64QueryBestSize(KdScreenInfo    *screen,
-		    Bool	    motion,
-		    short	    vid_w,
-		    short	    vid_h,
-		    short	    drw_w,
-		    short	    drw_h, 
-		    unsigned int    *p_w,
-		    unsigned int    *p_h,
-		    pointer	    data)
-{
-    *p_w = drw_w;
-    *p_h = drw_h; 
-}
-
-
-static void
-mach64CopyPackedData(KdScreenInfo   *screen, 
-		     unsigned char  *buf,
-		     int	    randr,
-		     int	    srcPitch,
-		     int	    dstPitch,
-		     int	    srcW,
-		     int	    srcH,
-		     int	    top,
-		     int	    left,
-		     int	    h,
-		     int	    w)
-{
-    Mach64ScreenInfo	*mach64s = (Mach64ScreenInfo *) screen->driver;
-    Mach64PortPrivPtr	pPortPriv = mach64s->pAdaptor->pPortPrivates[0].ptr;
-    CARD8		*src = buf, *dst;
-    int			srcDown = srcPitch, srcRight = 2, srcNext;
-    int			p;
-
-    switch (randr & RR_Rotate_All) {
-    case RR_Rotate_0:
-	src = buf;
-	srcDown = srcPitch;
-	srcRight = 2;
-	break;
-    case RR_Rotate_90:
-	src = buf + (srcH - 1) * 2;
-	srcDown = -2;
-	srcRight = srcPitch;
-	break;
-    case RR_Rotate_180:
-	src = buf + srcPitch * (srcH - 1) + (srcW - 1) * 2;
-	srcDown = -srcPitch;
-	srcRight = -2;
-	break;
-    case RR_Rotate_270:
-	src = buf + srcPitch * (srcW - 1);
-	srcDown = 2;
-	srcRight = -srcPitch;
-	break;
-    }
-
-    src = src + top*srcDown + left*srcRight;
-
-    if (pPortPriv->currentBuf == 0)
-	dst = (CARD8 *) mach64s->vesa.fb + pPortPriv->YBuf0Offset;
-    else
-	dst = (CARD8 *) mach64s->vesa.fb + pPortPriv->YBuf1Offset;
-
-    w >>= 1;
-    srcRight >>= 1;
-    srcNext = srcRight >> 1;
-    while(h--) 
-    {
-	CARD16	*s = (CARD16 *) src;
-	CARD32	*d = (CARD32 *) dst;
-	p = w;
-	while (p--)
-	{
-	    *d++ = s[0] | (s[srcNext] << 16);
-	    s += srcRight;
-	}
-	src += srcPitch;
-	dst += dstPitch;
-    }
-}
-
-static void
-mach64CopyPlanarData(KdScreenInfo   *screen, 
-		     unsigned char  *buf,
-		     int	    randr,
-		     int	    srcPitch,
-		     int	    srcPitch2,
-		     int	    dstPitch,  /* of chroma */
-		     int	    srcW,
-		     int	    srcH,
-		     int	    height,
-		     int	    top,
-		     int	    left,
-		     int	    h,
-		     int	    w,
-		     int	    id)
-{
-    Mach64ScreenInfo	*mach64s = (Mach64ScreenInfo *) screen->driver;
-    Mach64PortPrivPtr	pPortPriv = mach64s->pAdaptor->pPortPrivates[0].ptr;
-    int			i, j;
-    CARD8		*src1, *src2, *src3, *dst1;
-    int			srcDown = srcPitch, srcDown2 = srcPitch2;
-    int			srcRight = 2, srcRight2 = 1, srcNext = 1;
-
-    /* compute source data pointers */
-    src1 = buf;
-    src2 = src1 + height * srcPitch;
-    src3 = src2 + (height >> 1) * srcPitch2;
-    switch (randr & RR_Rotate_All) {
-    case RR_Rotate_0:
-	srcDown = srcPitch;
-	srcDown2 = srcPitch2;
-	srcRight = 2;
-	srcRight2 = 1;
-	srcNext = 1;
-	break;
-    case RR_Rotate_90:
-	src1 = src1 + srcH - 1;
-	src2 = src2 + (srcH >> 1) - 1;
-	src3 = src3 + (srcH >> 1) - 1;
-	srcDown = -1;
-	srcDown2 = -1;
-	srcRight = srcPitch * 2;
-	srcRight2 = srcPitch2;
-	srcNext = srcPitch;
-	break;
-    case RR_Rotate_180:
-	src1 = src1 + srcPitch * (srcH - 1) + (srcW - 1);
-	src2 = src2 + srcPitch2 * ((srcH >> 1) - 1) + ((srcW >> 1) - 1);
-	src3 = src3 + srcPitch2 * ((srcH >> 1) - 1) + ((srcW >> 1) - 1);
-	srcDown = -srcPitch;
-	srcDown2 = -srcPitch2;
-	srcRight = -2;
-	srcRight2 = -1;
-	srcNext = -1;
-	break;
-    case RR_Rotate_270:
-	src1 = src1 + srcPitch * (srcW - 1);
-	src2 = src2 + srcPitch2 * ((srcW >> 1) - 1);
-	src3 = src3 + srcPitch2 * ((srcW >> 1) - 1);
-	srcDown = 1;
-	srcDown2 = 1;
-	srcRight = -srcPitch * 2;
-	srcRight2 = -srcPitch2;
-	srcNext = -srcPitch;
-	break;
-    }
-    
-    /* adjust for origin */
-    src1 += top * srcDown + left * srcNext;
-    src2 += (top >> 1) * srcDown2 + (left >> 1) * srcRight2;
-    src3 += (top >> 1) * srcDown2 + (left >> 1) * srcRight2;
-    
-    if (id == FOURCC_I420)
-    {
-	CARD8	*srct = src2;
-	src2 = src3;
-	src3 = srct;
-    }
-    
-    if (pPortPriv->currentBuf == 0)
-	dst1 = (CARD8 *) mach64s->vesa.fb + pPortPriv->YBuf0Offset;
-    else
-	dst1 = (CARD8 *) mach64s->vesa.fb + pPortPriv->YBuf1Offset;
-
-    w >>= 1;
-    for (j = 0; j < h; j++) 
-    {
-	CARD32	*dst = (CARD32 *) dst1;
-	CARD8	*s1l = src1;
-	CARD8	*s1r = src1 + srcNext;
-	CARD8	*s2 = src2;
-	CARD8	*s3 = src3;
-
-	for (i = 0; i < w; i++)
-	{
-	    *dst++ = *s1l | (*s1r << 16) | (*s3 << 8) | (*s2 << 24);
-	    s1l += srcRight;
-	    s1r += srcRight;
-	    s2 += srcRight2;
-	    s3 += srcRight2;
-	}
-	src1 += srcDown;
-	dst1 += dstPitch;
-	if (j & 1)
-	{
-	    src2 += srcDown2;
-	    src3 += srcDown2;
-	}
-    }
-}
-
-
-/* Mach64ClipVideo -  
-
-   Takes the dst box in standard X BoxRec form (top and left
-   edges inclusive, bottom and right exclusive).  The new dst
-   box is returned.  The source boundaries are given (x1, y1 
-   inclusive, x2, y2 exclusive) and returned are the new source 
-   boundaries in 16.16 fixed point. 
-*/
-
-static void
-Mach64ClipVideo(BoxPtr dst, 
-		INT32 *x1, 
-		INT32 *x2, 
-		INT32 *y1, 
-		INT32 *y2,
-		BoxPtr extents,            /* extents of the clip region */
-		INT32 width, 
-		INT32 height)
-{
-    INT32 vscale, hscale, delta;
-    int diff;
-
-    hscale = ((*x2 - *x1) << 16) / (dst->x2 - dst->x1);
-    vscale = ((*y2 - *y1) << 16) / (dst->y2 - dst->y1);
-
-    *x1 <<= 16; *x2 <<= 16;
-    *y1 <<= 16; *y2 <<= 16;
-
-    diff = extents->x1 - dst->x1;
-    if(diff > 0) {
-	dst->x1 = extents->x1;
-	*x1 += diff * hscale;     
-    }
-    diff = dst->x2 - extents->x2;
-    if(diff > 0) {
-	dst->x2 = extents->x2;
-	*x2 -= diff * hscale;     
-    }
-    diff = extents->y1 - dst->y1;
-    if(diff > 0) {
-	dst->y1 = extents->y1;
-	*y1 += diff * vscale;     
-    }
-    diff = dst->y2 - extents->y2;
-    if(diff > 0) {
-	dst->y2 = extents->y2;
-	*y2 -= diff * vscale;     
-    }
-
-    if(*x1 < 0) {
-	diff =  (- *x1 + hscale - 1)/ hscale;
-	dst->x1 += diff;
-	*x1 += diff * hscale;
-    }
-    delta = *x2 - (width << 16);
-    if(delta > 0) {
-	diff = (delta + hscale - 1)/ hscale;
-	dst->x2 -= diff;
-	*x2 -= diff * hscale;
-    }
-    if(*y1 < 0) {
-	diff =  (- *y1 + vscale - 1)/ vscale;
-	dst->y1 += diff;
-	*y1 += diff * vscale;
-    }
-    delta = *y2 - (height << 16);
-    if(delta > 0) {
-	diff = (delta + vscale - 1)/ vscale;
-	dst->y2 -= diff;
-	*y2 -= diff * vscale;
-    }
-} 
-
-static void
-mach64DisplayVideo(KdScreenInfo *screen,
-		   int		id,
-		   int		dstPitch,  /* of chroma for 4:2:0 */
-		   int		x1,
-		   int		y1,
-		   int		x2,
-		   int		y2,
-		   int		dst_x1,
-		   int		dst_y1,
-		   int		dst_x2,
-		   int		dst_y2,
-		   short	src_w,
-		   short	src_h,
-		   short	drw_w, 
-		   short	drw_h)
-{
-    ScreenPtr		pScreen = screen->pScreen;
-    KdScreenPriv(pScreen);
-    KdCardInfo		*card = pScreenPriv->card;
-    Mach64ScreenInfo	*mach64s = (Mach64ScreenInfo *) screen->driver;
-    Mach64CardInfo	*mach64c = (Mach64CardInfo *) card->driver;
-    Mach64PortPrivPtr	pPortPriv = mach64s->pAdaptor->pPortPrivates[0].ptr;
-    Reg			*reg = mach64c->reg;
-    MediaReg		*media = mach64c->media_reg;
-    int			HORZ_INC, VERT_INC;
-    CARD32		SCALER_IN;
-    int			bright;
-    int			sat;
-
-    if (id == FOURCC_UYVY)
-	SCALER_IN = SCALER_IN_YVYU422;
-    else
-	SCALER_IN = SCALER_IN_VYUY422;
-
-    mach64WaitAvail (reg, 4);
-    
-    media->VIDEO_FORMAT = SCALER_IN | VIDEO_IN_VYUY422;
-
-    /* color key */
-    media->OVERLAY_GRAPHICS_KEY_MSK = (1 << screen->fb[0].depth) - 1;
-    media->OVERLAY_GRAPHICS_KEY_CLR = pPortPriv->colorKey;
-    /* set key control to obey only graphics color key */
-    media->OVERLAY_KEY_CNTL = 0x50;
-    
-    mach64WaitAvail (reg, 9);
-    media->CAPTURE_DEBUG = 0;
-    /* no exclusive video region */
-    media->OVERLAY_EXCLUSIVE_HORZ = 0;
-    media->OVERLAY_EXCLUSIVE_VERT = 0;
-    /* scaling coefficients */
-    media->SCALER_H_COEFF0 = 0x00002000;
-    media->SCALER_H_COEFF1 = 0x0D06200D;
-    media->SCALER_H_COEFF2 = 0x0D0A1C0D;
-    media->SCALER_H_COEFF3 = 0x0C0E1A0C;
-    media->SCALER_H_COEFF4 = 0x0C14140C;
-    media->SCALER_TEST = 0;
-
-    mach64WaitAvail (reg, 2);
-    media->OVERLAY_SCALE_CNTL = (SCALE_PIX_EXPAND |
-				 SCALE_GAMMA_BRIGHT |
-				 SCALE_BANDWIDTH |
-				 SCALE_OVERLAY_EN |
-				 SCALE_EN);
-
-    bright = (pPortPriv->brightness * 64 / 1000);
-    if (bright < -0x40)
-	bright = -0x40;
-    if (bright > 0x3f)
-	bright = 0x3f;
-    bright = bright & 0x7f;
-    sat = ((pPortPriv->saturation * 31 + 31000) / 2000);
-    if (sat > 0x1f)
-	sat = 0x1f;
-    if (sat < 0)
-	sat = 0;
-    
-    media->SCALER_COLOUR_CNTL = ((bright << 0) |	/* BRIGHTNESS */
-				 (sat << 8) |	/* SATURATION_U */
-				 (sat << 16) |	/* SATURATION_V */
-				 (0 << 21) |	/* SCALER_VERT_ADJ_UV */
-				 (0 << 28));	/* SCALER_HORZ_ADJ_UV */
-
-    VERT_INC = (src_h << 12) / drw_h;
-    HORZ_INC = (src_w << 12) / drw_w;
-
-    mach64WaitAvail (reg, 13);
-
-    /* lock registers to prevent non-atomic update */
-    media->OVERLAY_Y_X_START = 0x80000000 | MACH64_YX (dst_x1, dst_y1);
-    /* ending screen coordinate */
-    media->OVERLAY_Y_X_END = 0x80000000 | MACH64_YX (dst_x2, dst_y2);
-    
-    media->OVERLAY_SCALE_INC = MACH64_YX(HORZ_INC, VERT_INC);
-
-    media->SCALER_BUF0_OFFSET = pPortPriv->YBuf0Offset;
-    media->SCALER_BUF1_OFFSET = pPortPriv->YBuf1Offset;
-    
-    media->SCALER_BUF0_OFFSET_U = pPortPriv->YBuf0Offset;
-    media->SCALER_BUF1_OFFSET_U = pPortPriv->YBuf1Offset;
-    
-    media->SCALER_BUF0_OFFSET_V = pPortPriv->YBuf0Offset;
-    media->SCALER_BUF1_OFFSET_V = pPortPriv->YBuf1Offset;
-    
-    media->SCALER_BUF_PITCH = dstPitch >> 1;
-    media->SCALER_HEIGHT_WIDTH = MACH64_YX(src_w - (x1 >> 16), src_h - (y1 >> 16));
-
-    media->CAPTURE_CONFIG = pPortPriv->currentBuf << 28;
-
-    /* set XY location and unlock */
-    media->OVERLAY_Y_X_START = MACH64_YX (dst_x1, dst_y1);
-}
-
-static void
-mach64VideoSave (ScreenPtr pScreen, KdOffscreenArea *area)
-{
-    KdScreenPriv(pScreen);
-    KdScreenInfo	*screen = pScreenPriv->screen;
-    Mach64ScreenInfo	*mach64s = (Mach64ScreenInfo *) screen->driver;
-    Mach64PortPrivPtr	pPortPriv = mach64s->pAdaptor->pPortPrivates[0].ptr;
-
-    if (pPortPriv->off_screen == area)
-	pPortPriv->off_screen = 0;
-}
-
-static int
-mach64PutImage(KdScreenInfo	    *screen, 
-	       DrawablePtr	    pDraw,
-	       short		    src_x,
-	       short		    src_y,
-	       short		    drw_x,
-	       short		    drw_y,
-	       short		    src_w,
-	       short		    src_h,
-	       short		    drw_w,
-	       short		    drw_h,
-	       int		     id,
-	       unsigned char	    *buf,
-	       short		    width,
-	       short		    height,
-	       Bool		    sync,
-	       RegionPtr	    clipBoxes,
-	       pointer		    data)
-{
-    KdCardInfo		*card = screen->card;
-    Mach64ScreenInfo	*mach64s = (Mach64ScreenInfo *) screen->driver;
-    Mach64CardInfo	*mach64c = (Mach64CardInfo *) card->driver;
-    Mach64PortPrivPtr	pPortPriv = (Mach64PortPrivPtr)data;
-    MediaReg		*media = mach64c->media_reg;
-    INT32		x1, x2, y1, y2;
-    int			randr = mach64s->vesa.randr;
-    int			srcPitch, srcPitch2, dstPitch;
-    int			top, left, npixels, nlines, size;
-    BoxRec		dstBox;
-    int			dst_width = width, dst_height = height;
-    int			rot_x1, rot_y1, rot_x2, rot_y2;
-    int			dst_x1, dst_y1, dst_x2, dst_y2;
-    int			rot_src_w, rot_src_h, rot_drw_w, rot_drw_h;
-
-    /* Clip */
-    x1 = src_x;
-    x2 = src_x + src_w;
-    y1 = src_y;
-    y2 = src_y + src_h;
-
-    dstBox.x1 = drw_x;
-    dstBox.x2 = drw_x + drw_w;
-    dstBox.y1 = drw_y;
-    dstBox.y2 = drw_y + drw_h;
-
-    Mach64ClipVideo(&dstBox, &x1, &x2, &y1, &y2, 
-		  REGION_EXTENTS(pScreen, clipBoxes), width, height);
-
-    if((x1 >= x2) || (y1 >= y2))
-	return Success;
-
-    if (!media)
-	return BadAlloc;
-
-    if (randr & (RR_Rotate_0|RR_Rotate_180))
-    {
-	dst_width = width;
-	dst_height = height;
-	rot_src_w = src_w;
-	rot_src_h = src_h;
-	rot_drw_w = drw_w;
-	rot_drw_h = drw_h;
-    }
-    else
-    {
-	dst_width = height;
-	dst_height = width;
-	rot_src_w = src_h;
-	rot_src_h = src_w;
-	rot_drw_w = drw_h;
-	rot_drw_h = drw_w;
-    }
-	
-    switch (randr & RR_Rotate_All) {
-    case RR_Rotate_0:
-    default:
-	dst_x1 = dstBox.x1;
-	dst_y1 = dstBox.y1;
-	dst_x2 = dstBox.x2;
-	dst_y2 = dstBox.y2;
-	rot_x1 = x1;
-	rot_y1 = y1;
-	rot_x2 = x2;
-	rot_y2 = y2;
-	break;
-    case RR_Rotate_90:
-	dst_x1 = dstBox.y1;
-	dst_y1 = screen->height - dstBox.x2;
-	dst_x2 = dstBox.y2;
-	dst_y2 = screen->height - dstBox.x1;
-	
-	rot_x1 = y1;
-	rot_y1 = (src_w << 16) - x2;
-	rot_x2 = y2;
-	rot_y2 = (src_w << 16) - x1;
-	break;
-    case RR_Rotate_180:
-	dst_x1 = screen->width - dstBox.x2;
-	dst_y1 = screen->height - dstBox.y2;
-	dst_x2 = screen->width - dstBox.x1;
-	dst_y2 = screen->height - dstBox.y1;
-	rot_x1 = (src_w << 16) - x2;
-	rot_y1 = (src_h << 16) - y2;
-	rot_x2 = (src_w << 16) - x1;
-	rot_y2 = (src_h << 16) - y1;
-	break;
-    case RR_Rotate_270:
-	dst_x1 = screen->width - dstBox.y2;
-	dst_y1 = dstBox.x1;
-	dst_x2 = screen->width - dstBox.y1;
-	dst_y2 = dstBox.x2;
-	rot_x1 = (src_h << 16) - y2;
-	rot_y1 = x1;
-	rot_x2 = (src_h << 16) - y1;
-	rot_y2 = x2;
-	break;
-    }
-
-    switch(id) {
-    case FOURCC_YV12:
-    case FOURCC_I420:
-	dstPitch = ((dst_width << 1) + 15) & ~15;
-	srcPitch = (width + 3) & ~3;
-	srcPitch2 = ((width >> 1) + 3) & ~3;
-	size =  dstPitch * (int) dst_height;
-	break;
-    case FOURCC_UYVY:
-    case FOURCC_YUY2:
-    default:
-	dstPitch = ((dst_width << 1) + 15) & ~15;
-	srcPitch = (width << 1);
-	srcPitch2 = 0;
-	size = dstPitch * (int) dst_height;
-	break;
-    }  
-
-    if (pPortPriv->off_screen && size != pPortPriv->size)
-    {
-	KdOffscreenFree (screen->pScreen, pPortPriv->off_screen);
-	pPortPriv->off_screen = 0;
-    }
-
-    if (!pPortPriv->off_screen)
-    {
-	pPortPriv->off_screen = KdOffscreenAlloc (screen->pScreen, size * 2, 64,
-						  TRUE, mach64VideoSave,
-						  pPortPriv);
-	if (!pPortPriv->off_screen)
-	    return BadAlloc;
-    }
-    
-    pPortPriv->offset = pPortPriv->off_screen->offset;
-    pPortPriv->size = size;
-    /* fixup pointers */
-    
-    pPortPriv->YBuf0Offset = pPortPriv->offset;
-    pPortPriv->YBuf1Offset = pPortPriv->offset + size;
-
-#if 0
-    mach64WaitIdle (reg);
-
-    if (pPortPriv->videoOn)
-    {
-	/* wait for buffer to be displayed */
-	while (((media->TRIG_CNTL >> 5) & 1) != pPortPriv->currentBuf)
-	    ;
-    }
-#endif
-    /*
-     * Use the other buffer
-     */
-    pPortPriv->currentBuf = 1 - pPortPriv->currentBuf;
-    
-    /* copy data */
-    top = rot_y1 >> 16;
-    left = (rot_x1 >> 16) & ~1;
-    npixels = ((((rot_x2 + 0xffff) >> 16) + 1) & ~1) - left;
-
-    switch(id) {
-    case FOURCC_YV12:
-    case FOURCC_I420:
-	top &= ~1;
-	nlines = ((((rot_y2 + 0xffff) >> 16) + 1) & ~1) - top;
-	mach64CopyPlanarData(screen, buf, randr,
-			     srcPitch, srcPitch2, dstPitch,  
-			     rot_src_w, rot_src_h, height,
-			     top, left, nlines, npixels, id);
-	break;
-    case FOURCC_UYVY:
-    case FOURCC_YUY2:
-    default:
-	nlines = ((rot_y2 + 0xffff) >> 16) - top;
-	mach64CopyPackedData(screen, buf, randr,
-			     srcPitch, dstPitch,
-			     rot_src_w, rot_src_h,
-			     top, left, nlines, 
-			     npixels);
-	break;
-    }
-
-    mach64DisplayVideo(screen, id, dstPitch, 
-		       rot_x1, rot_y1, rot_x2, rot_y2, 
-		       dst_x1, dst_y1,
-		       dst_x2, dst_y2,
-		       rot_src_w, rot_src_h, rot_drw_w, rot_drw_h);
-
-    /* update cliplist */
-    if (!REGION_EQUAL (screen->pScreen, &pPortPriv->clip, clipBoxes))
-    {
-	REGION_COPY (screen->pScreen, &pPortPriv->clip, clipBoxes);
-	KXVPaintRegion (pDraw, &pPortPriv->clip, pPortPriv->colorKey);
-    }
-
-    pPortPriv->videoOn = TRUE;
-
-    return Success;
-}
-
-static int
-mach64QueryImageAttributes(KdScreenInfo	    *screen, 
-			   int		    id,
-			   unsigned short   *w,
-			   unsigned short   *h,  
-			   int		    *pitches,
-			   int		    *offsets)
-{
-    int size, tmp;
-
-    if(*w > IMAGE_MAX_WIDTH) 
-	*w = IMAGE_MAX_WIDTH;
-    if(*h > IMAGE_MAX_HEIGHT) 
-	*h = IMAGE_MAX_HEIGHT;
-
-    *w = (*w + 1) & ~1;
-    if(offsets) offsets[0] = 0;
-
-    switch(id) {
-    case FOURCC_YV12:
-    case FOURCC_I420:
-	*h = (*h + 1) & ~1;
-	size = (*w + 3) & ~3;
-	if(pitches) 
-	    pitches[0] = size;
-	size *= *h;
-	if(offsets) 
-	    offsets[1] = size;
-	tmp = ((*w >> 1) + 3) & ~3;
-	if(pitches) 
-	    pitches[1] = pitches[2] = tmp;
-	tmp *= (*h >> 1);
-	size += tmp;
-	if(offsets) 
-	    offsets[2] = size;
-	size += tmp;
-	break;
-    case FOURCC_UYVY:
-    case FOURCC_YUY2:
-    default:
-	size = *w << 1;
-	if(pitches) 
-	    pitches[0] = size;
-	size *= *h;
-	break;
-    }
-
-    return size;
-}
-
-
-/* client libraries expect an encoding */
-static KdVideoEncodingRec DummyEncoding[1] =
-{
- {
-   0,
-   "XV_IMAGE",
-   IMAGE_MAX_WIDTH, IMAGE_MAX_HEIGHT,
-   {1, 1}
- }
-};
-
-#define NUM_FORMATS 3
-
-static KdVideoFormatRec Formats[NUM_FORMATS] = 
-{
-  {15, TrueColor}, {16, TrueColor}, {24, TrueColor}
-};
-
-#define NUM_ATTRIBUTES 3
-
-static KdAttributeRec Attributes[NUM_ATTRIBUTES] =
-{
-   {XvSettable | XvGettable, 0, ~0, "XV_COLORKEY"},
-   {XvSettable | XvGettable, -1000, 1000, "XV_BRIGHTNESS"},
-   {XvSettable | XvGettable, -1000, 1000, "XV_SATURATION"}
-};
-
-#define NUM_IMAGES 4
-
-static KdImageRec Im